13#include <fairlogger/Logger.h>
29 mDecodeinputs = ctx.
options().
get<
bool>(
"ctpinputs-decoding");
31 mNTFToIntegrate = ctx.
options().
get<
int>(
"ntf-to-average");
32 mVerbose = ctx.
options().
get<
bool>(
"use-verbose-mode");
33 int maxerrors = ctx.
options().
get<
int>(
"print-errors-num");
38 std::string lumiinp1 = ctx.
options().
get<std::string>(
"lumi-inp1");
39 std::string lumiinp2 = ctx.
options().
get<std::string>(
"lumi-inp2");
42 mOutputLumiInfo.
inp1 = inp1;
43 mOutputLumiInfo.
inp2 = inp2;
44 mMaxInputSize = ctx.
options().
get<
int>(
"max-input-size");
45 mMaxInputSizeFatal = ctx.
options().
get<
bool>(
"max-input-size-fatal");
46 LOG(info) <<
"CTP reco init done. Inputs decoding here:" << mDecodeinputs <<
" DoLumi:" << mDoLumi <<
" DoDigits:" << mDoDigits <<
" NTF:" << mNTFToIntegrate <<
" Lumi inputs:" << lumiinp1 <<
":" << inp1 <<
" " << lumiinp2 <<
":" << inp2 <<
" Max errors:" << maxerrors <<
" Max input size:" << mMaxInputSize <<
" MaxInputSizeFatal:" << mMaxInputSizeFatal;
52 std::sort(TFOrbits.begin(), TFOrbits.end());
53 size_t l = TFOrbits.size();
60 std::cout <<
"Missing orbits:";
61 for (
int i = 1;
i < l;
i++) {
62 if ((TFOrbits[
i] - o0) > 0x20) {
64 std::cout <<
" " << o0 <<
"-" << TFOrbits[
i];
66 nmiss += (TFOrbits[
i] - o0) / 0x20;
71 std::cout << std::endl;
72 std::cout <<
"Number of missing TF:" << nmiss << std::endl;
73 std::cout <<
"# of IR errors:" << mDecoder.
getErrorIR() <<
" TCR errors:" << mDecoder.
getErrorTCR() << std::endl;
78 mOutputDigits.clear();
79 std::map<o2::InteractionRecord, CTPDigit>
digits;
84 auto& inputs = ctx.
inputs();
85 auto dummyOutput = [&ctx,
this]() {
86 if (this->mDoDigits) {
96 static size_t contDeadBeef = 0;
99 const auto dh = o2::framework::DataRefUtils::getHeader<o2::header::DataHeader*>(
ref);
101 if (payloadSize == 0) {
103 if (++contDeadBeef <= maxWarn) {
104 LOGP(alarm,
"Found input [{}/{}/{:#x}] TF#{} 1st_orbit:{} Payload {} : assuming no payload for all links in this TF{}",
105 dh->dataOrigin.str, dh->dataDescription.str, dh->subSpecification, dh->tfCounter, dh->firstTForbit, payloadSize,
106 contDeadBeef == maxWarn ? fmt::format(
". {} such inputs in row received, stopping reporting", contDeadBeef) :
"");
115 std::vector<LumiInfo> lumiPointsHBF1;
118 if (mMaxInputSize > 0) {
119 size_t payloadSize = 0;
121 const auto dh = o2::framework::DataRefUtils::getHeader<o2::header::DataHeader*>(
ref);
124 if (payloadSize > (
size_t)mMaxInputSize) {
125 if (mMaxInputSizeFatal) {
127 LOG(error) <<
"Input data size bigger than threshold: " << mMaxInputSize <<
" < " << payloadSize <<
" decoding TF and exiting.";
130 LOG(error) <<
"Input data size:" << payloadSize <<
" sending dummy output";
140 ret = mDecoder.
decodeRaw(inputs,
filter, mOutputDigits, lumiPointsHBF1);
147 LOG(info) <<
"[CTPRawToDigitConverter - run] Writing " << mOutputDigits.size() <<
" digits. IR rejected:" << mDecoder.
getIRRejected() <<
" TCR rejected:" << mDecoder.
getTCRRejected();
151 uint32_t tfCountsT = 0;
152 uint32_t tfCountsV = 0;
153 for (
auto const& lp : lumiPointsHBF1) {
154 tfCountsT += lp.counts;
155 tfCountsV += lp.countsFV0;
159 mHistoryT.push_back(tfCountsT);
160 mCountsT += tfCountsT;
161 if (mHistoryT.size() <= mNTFToIntegrate) {
162 mNHBIntegratedT += lumiPointsHBF1.size();
164 mCountsT -= mHistoryT.front();
165 mHistoryT.pop_front();
168 mHistoryV.push_back(tfCountsV);
169 mCountsV += tfCountsV;
170 if (mHistoryV.size() <= mNTFToIntegrate) {
171 mNHBIntegratedV += lumiPointsHBF1.size();
173 mCountsV -= mHistoryV.front();
174 mHistoryV.pop_front();
177 if (mNHBIntegratedT || mNHBIntegratedV) {
178 mOutputLumiInfo.
orbit = lumiPointsHBF1[0].orbit;
180 mOutputLumiInfo.
counts = mCountsT;
187 LOGP(info,
"Orbit {}: {}/{} counts inp1/inp2 in {}/{} HBFs -> lumi_inp1 = {:.3e}+-{:.3e} lumi_inp2 = {:.3e}+-{:.3e}", mOutputLumiInfo.
orbit, mCountsT, mCountsV, mNHBIntegratedT, mNHBIntegratedV, mOutputLumiInfo.
getLumi(), mOutputLumiInfo.
getLumiError(), mOutputLumiInfo.
getLumiFV0(), mOutputLumiInfo.
getLumiFV0Error());
195 throw std::runtime_error(
"all outputs were disabled");
197 std::vector<o2::framework::InputSpec> inputs;
200 inputs.emplace_back(
"stdDist",
"FLP",
"DISTSUBTIMEFRAME", 0, o2::framework::Lifetime::Timeframe);
203 std::vector<o2::framework::OutputSpec> outputs;
204 inputs.emplace_back(
"ctpconfig",
"CTP",
"CTPCONFIG", 0, o2::framework::Lifetime::Condition,
o2::framework::ccdbParamSpec(
"CTP/Config/Config", 1));
205 inputs.emplace_back(
"trigoffset",
"CTP",
"Trig_Offset", 0, o2::framework::Lifetime::Condition,
o2::framework::ccdbParamSpec(
"CTP/Config/TriggerOffsets"));
207 outputs.emplace_back(
"CTP",
"DIGITS", 0, o2::framework::Lifetime::Timeframe);
210 outputs.emplace_back(
"CTP",
"LUMI", 0, o2::framework::Lifetime::Timeframe);
225 {
"ctpinputs-decoding",
o2::framework::VariantType::Bool,
false, {
"Inputs alignment: true - raw decoder - has to be compatible with CTF decoder: allowed options: 10,01,00"}}}};
232 LOG(info) <<
"updateing TroggerOffsetsParam: inputs L0_L1:" << trigOffsParam.
L0_L1 <<
" classes L0_L1:" << trigOffsParam.
L0_L1_classes;
234 if (ctpcfg !=
nullptr) {
static const VerbosityConfig & Instance()
uint32_t getTCRRejected() const
std::vector< uint32_t > & getTFOrbits()
void setCTPConfig(CTPConfiguration cfg)
int setLumiInp(int lumiinp, std::string inp)
void setDoDigits(bool digi)
int decodeRaw(o2::framework::InputRecord &inputs, std::vector< o2::framework::InputSpec > &filter, o2::pmr::vector< CTPDigit > &digits, std::vector< LumiInfo > &lumiPointsHBF1)
CTPConfiguration & getCTPConfig()
void setDecodeInps(bool decodeinps)
void setDoLumi(bool lumi)
int decodeRawFatal(o2::framework::InputRecord &inputs, std::vector< o2::framework::InputSpec > &filter)
uint32_t getIRRejected() const
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void updateTimeDependentParams(framework::ProcessingContext &pc)
void init(framework::InitContext &ctx) final
Initializing the RawDecoderSpec.
void run(framework::ProcessingContext &ctx) final
Run conversion of raw data to cells.
T get(const char *key) const
void snapshot(const Output &spec, T const &object)
ConfigParamRegistry const & options()
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
o2::framework::DataProcessorSpec getRawDecoderSpec(bool askSTFDist, bool digits, bool lumi)
Creating DataProcessorSpec for the CTP.
Lifetime
Possible Lifetime of objects being exchanged by the DPL.
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
std::vector< ConfigParamSpec > Options
float getLumiFV0Error() const
float getLumiError() const
static o2::header::DataHeader::PayloadSizeType getPayloadSize(const DataRef &ref)
bool globalRunNumberChanged
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Digit > digits