13#include <fairlogger/Logger.h>
29 mCheckConsistency = ctx.
options().
get<
bool>(
"check-consistency");
31 mDecodeinputs = ctx.
options().
get<
bool>(
"ctpinputs-decoding");
33 mNTFToIntegrate = ctx.
options().
get<
int>(
"ntf-to-average");
34 mVerbose = ctx.
options().
get<
bool>(
"use-verbose-mode");
35 int maxerrors = ctx.
options().
get<
int>(
"print-errors-num");
40 std::string lumiinp1 = ctx.
options().
get<std::string>(
"lumi-inp1");
41 std::string lumiinp2 = ctx.
options().
get<std::string>(
"lumi-inp2");
44 mOutputLumiInfo.
inp1 = inp1;
45 mOutputLumiInfo.
inp2 = inp2;
46 mMaxInputSize = ctx.
options().
get<
int>(
"max-input-size");
47 mMaxInputSizeFatal = ctx.
options().
get<
bool>(
"max-input-size-fatal");
48 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 <<
" CheckConsistency:" << mCheckConsistency;
54 std::sort(TFOrbits.begin(), TFOrbits.end());
55 size_t l = TFOrbits.size();
62 std::cout <<
"Missing orbits:";
63 for (
int i = 1;
i < l;
i++) {
64 if ((TFOrbits[
i] - o0) > 0x20) {
66 std::cout <<
" " << o0 <<
"-" << TFOrbits[
i];
68 nmiss += (TFOrbits[
i] - o0) / 0x20;
73 std::cout << std::endl;
74 LOG(info) <<
"Number of non continous TF:" << nmiss << std::endl;
75 LOG(info) <<
"Lost in shiftInputs:" << mLostDueToShiftInps;
76 LOG(info) <<
"Lost in addDigit Inputs:" << mIRRejected <<
" Classes:" << mTCRRejected;
77 if (mErrorIR || mErrorTCR) {
78 LOG(error) <<
"# of IR errors:" << mErrorIR <<
" TCR errors:" << mErrorTCR << std::endl;
80 if (mCheckConsistency) {
83 for (
int i = 0;
i < o2::ctp::CTP_NCLASSES;
i++) {
86 LOG(error) <<
" Class without inputs:";
88 LOG(important) <<
"CLASS:" <<
name <<
":" <<
i <<
" Cls=>Inp:" << mClsA[
i] <<
" Inp=>Cls:" << mClsB[
i] <<
" ErrorsCls=>Inps:" << mClsEA[
i] <<
" MissingInps=>Cls:" << mClsEB[
i];
95 mOutputDigits.clear();
96 std::map<o2::InteractionRecord, CTPDigit>
digits;
101 auto& inputs = ctx.
inputs();
102 auto dummyOutput = [&ctx,
this]() {
103 if (this->mDoDigits) {
113 static size_t contDeadBeef = 0;
116 const auto dh = o2::framework::DataRefUtils::getHeader<o2::header::DataHeader*>(
ref);
118 if (payloadSize == 0) {
120 if (++contDeadBeef <= maxWarn) {
121 LOGP(alarm,
"Found input [{}/{}/{:#x}] TF#{} 1st_orbit:{} Payload {} : assuming no payload for all links in this TF{}",
122 dh->dataOrigin.str, dh->dataDescription.str, dh->subSpecification, dh->tfCounter, dh->firstTForbit, payloadSize,
123 contDeadBeef == maxWarn ? fmt::format(
". {} such inputs in row received, stopping reporting", contDeadBeef) :
"");
132 std::vector<LumiInfo> lumiPointsHBF1;
135 if (mMaxInputSize > 0) {
136 size_t payloadSize = 0;
138 const auto dh = o2::framework::DataRefUtils::getHeader<o2::header::DataHeader*>(
ref);
141 if (payloadSize > (
size_t)mMaxInputSize) {
142 if (mMaxInputSizeFatal) {
144 LOG(error) <<
"Input data size bigger than threshold: " << mMaxInputSize <<
" < " << payloadSize <<
" decoding TF and exiting.";
147 LOG(error) <<
"Input data size:" << payloadSize <<
" sending dummy output";
157 ret = mDecoder.
decodeRaw(inputs,
filter, mOutputDigits, lumiPointsHBF1);
164 LOG(info) <<
"[CTPRawToDigitConverter - run] Writing " << mOutputDigits.size() <<
" digits. IR rejected:" << mDecoder.
getIRRejected() <<
" TCR rejected:" << mDecoder.
getTCRRejected();
175 for (
int i = 0;
i < o2::ctp::CTP_NCLASSES;
i++) {
176 mClsEA[
i] += clsEA[
i];
177 mClsEB[
i] += clsEB[
i];
178 mClsA[
i] += cntCA[
i];
179 mClsB[
i] += cntCB[
i];
183 uint32_t tfCountsT = 0;
184 uint32_t tfCountsV = 0;
185 for (
auto const& lp : lumiPointsHBF1) {
186 tfCountsT += lp.counts;
187 tfCountsV += lp.countsFV0;
191 mHistoryT.push_back(tfCountsT);
192 mCountsT += tfCountsT;
193 if (mHistoryT.size() <= mNTFToIntegrate) {
194 mNHBIntegratedT += lumiPointsHBF1.size();
196 mCountsT -= mHistoryT.front();
197 mHistoryT.pop_front();
200 mHistoryV.push_back(tfCountsV);
201 mCountsV += tfCountsV;
202 if (mHistoryV.size() <= mNTFToIntegrate) {
203 mNHBIntegratedV += lumiPointsHBF1.size();
205 mCountsV -= mHistoryV.front();
206 mHistoryV.pop_front();
209 if (mNHBIntegratedT || mNHBIntegratedV) {
210 mOutputLumiInfo.
orbit = lumiPointsHBF1[0].orbit;
212 mOutputLumiInfo.
counts = mCountsT;
219 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());
227 throw std::runtime_error(
"all outputs were disabled");
229 std::vector<o2::framework::InputSpec> inputs;
232 inputs.emplace_back(
"stdDist",
"FLP",
"DISTSUBTIMEFRAME", 0, o2::framework::Lifetime::Timeframe);
235 std::vector<o2::framework::OutputSpec> outputs;
236 inputs.emplace_back(
"ctpconfig",
"CTP",
"CTPCONFIG", 0, o2::framework::Lifetime::Condition,
o2::framework::ccdbParamSpec(
"CTP/Config/Config", 1));
237 inputs.emplace_back(
"trigoffset",
"CTP",
"Trig_Offset", 0, o2::framework::Lifetime::Condition,
o2::framework::ccdbParamSpec(
"CTP/Config/TriggerOffsets"));
239 outputs.emplace_back(
"CTP",
"DIGITS", 0, o2::framework::Lifetime::Timeframe);
242 outputs.emplace_back(
"CTP",
"LUMI", 0, o2::framework::Lifetime::Timeframe);
258 {
"ctpinputs-decoding",
o2::framework::VariantType::Bool,
false, {
"Inputs alignment: true - raw decoder - has to be compatible with CTF decoder: allowed options: 10,01,00"}}}};
265 LOG(info) <<
"updateing TroggerOffsetsParam: inputs L0_L1:" << trigOffsParam.
L0_L1 <<
" classes L0_L1:" << trigOffsParam.
L0_L1_classes;
267 if (ctpcfg !=
nullptr) {
static const VerbosityConfig & Instance()
std::string getClassNameFromIndex(int index)
std::array< uint64_t, o2::ctp::CTP_NCLASSES > getClassCountersA()
uint32_t getTCRRejected() const
std::array< uint64_t, o2::ctp::CTP_NCLASSES > getClassErrorsA()
std::array< uint64_t, o2::ctp::CTP_NCLASSES > getClassCountersB()
std::vector< uint32_t > & getTFOrbits()
void setCTPConfig(CTPConfiguration cfg)
int getLostDueToShiftInp()
int setLumiInp(int lumiinp, std::string inp)
int getLostDueToShiftCls()
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)
std::array< uint64_t, o2::ctp::CTP_NCLASSES > getClassErrorsB()
CTPConfiguration & getCTPConfig()
void setCheckConsistency(bool check)
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.
GLuint const GLchar * name
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