Skip to content

Commit d0c2c24

Browse files
committed
fix: suppressing excesive output from raw decoder
1 parent 5b5f1d9 commit d0c2c24

File tree

6 files changed

+76
-37
lines changed

6 files changed

+76
-37
lines changed

DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class CTPConfiguration
160160
const std::vector<CTPClass>& getCTPClasses() const { return mCTPClasses; } // Read-only interface
161161
uint64_t getInputMask(const std::string& name) const;
162162
int getInputIndex(const std::string& name) const;
163-
std::string getClassNameFromIndex(int index) { return mCTPClasses[index].name; };
163+
std::string getClassNameFromIndex(int index) ;
164164
std::string getClassNameFromHWIndex(int index);
165165
const CTPClass* getCTPClassFromHWIndex(const int index) const;
166166
bool isMaskInInputs(const uint64_t& mask) const;

DataFormats/Detectors/CTP/src/Configuration.cxx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,15 @@ int CTPConfiguration::getInputIndex(const std::string& name) const
780780
LOG(info) << "input:" << name << " index:" << index;
781781
return index;
782782
}
783+
std::string CTPConfiguration::getClassNameFromIndex(int index)
784+
{
785+
if(index < mCTPClasses.size()) {
786+
return mCTPClasses[index].name;
787+
} else {
788+
std::string name = "Cls"+std::to_string(index);
789+
return name;
790+
}
791+
};
783792
std::string CTPConfiguration::getClassNameFromHWIndex(int index)
784793
{
785794
for (auto& cls : mCTPClasses) {

Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ class RawDataDecoder
6060
std::array<uint64_t, o2::ctp::CTP_NCLASSES> getClassErrorsB() { return mClassErrorsB; }
6161
std::array<uint64_t, o2::ctp::CTP_NCLASSES> getClassCountersA() { return mClassCountersA; }
6262
std::array<uint64_t, o2::ctp::CTP_NCLASSES> getClassCountersB() { return mClassCountersB; }
63-
int getLostDueToShift() { return mLostDueToShift; }
63+
int getLostDueToShiftCls() { return mLostDueToShiftCC; }
64+
int getLostDueToShiftInp() { return mLostDueToShiftInps; }
6465

6566
private:
6667
static constexpr uint32_t TF_TRIGGERTYPE_MASK = 0x800;
@@ -80,8 +81,8 @@ class RawDataDecoder
8081
gbtword80_t mTVXMask = 0x4; // TVX is 3rd input
8182
gbtword80_t mVBAMask = 0x20; // VBA is 6 th input
8283
bool mVerbose = false;
83-
uint32_t mIRRejected = 0;
84-
uint32_t mTCRRejected = 0;
84+
int mIRRejected = 0;
85+
int mTCRRejected = 0;
8586
bool mPadding = true;
8687
uint32_t mTFOrbit = 0;
8788
std::vector<uint32_t> mTFOrbits;
@@ -94,7 +95,8 @@ class RawDataDecoder
9495
std::array<uint64_t, o2::ctp::CTP_NCLASSES> mClassErrorsB{}; // from inputs
9596
std::array<uint64_t, o2::ctp::CTP_NCLASSES> mClassCountersA{};
9697
std::array<uint64_t, o2::ctp::CTP_NCLASSES> mClassCountersB{}; // from inputs
97-
int mLostDueToShift = 0;
98+
int mLostDueToShiftCC = 0;
99+
int mLostDueToShiftInps = 0;
98100
CTPConfiguration mCTPConfig;
99101
};
100102
} // namespace ctp

Detectors/CTP/reconstruction/src/RawDataDecoder.cxx

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,12 @@ int RawDataDecoder::decodeRaw(o2::framework::InputRecord& inputs, std::vector<o2
296296
uint64_t trgclassmask = 0xffffffffffffffff;
297297
uint64_t trgclassmaskNOTRGDet = 0xffffffffffffffff;
298298
if (mCTPConfig.getRunNumber() != 0) {
299-
trgclassmask = mCTPConfig.getTriggerClassMaskWInputs();
299+
trgclassmask = mCTPConfig.getTriggerClassMaskWInputs(); // classes triggered by internal ctp generators not here
300300
trgclassmaskNOTRGDet = mCTPConfig.getTriggerClassMaskWInputsNoTrgDets();
301301
// mCTPConfig.printStream(std::cout);
302302
}
303303
// std::cout << "trgclassmask:" << std::hex << trgclassmask << std::dec << std::endl;
304-
ret = shiftInputs(digitsMap, digits, mTFOrbit);
304+
mLostDueToShiftInps += shiftInputs(digitsMap, digits, mTFOrbit);
305305
if (mCheckConsistency) {
306306
ret = checkReadoutConsistentncy(digits, trgclassmask, trgclassmaskNOTRGDet);
307307
}
@@ -524,7 +524,8 @@ int RawDataDecoder::shiftNew(const o2::InteractionRecord& irin, uint32_t TFOrbit
524524
digmap[ir] = digit;
525525
}
526526
} else {
527-
LOG(info) << "LOST:" << irin << " shift:" << shift;
527+
//LOG(info) << "LOST:" << irin << " shift:" << shift;
528+
return 1;;
528529
}
529530
return 0;
530531
}
@@ -533,6 +534,7 @@ int RawDataDecoder::shiftNew(const o2::InteractionRecord& irin, uint32_t TFOrbit
533534
int RawDataDecoder::shiftInputs(std::map<o2::InteractionRecord, CTPDigit>& digitsMap, o2::pmr::vector<CTPDigit>& digits, uint32_t TFOrbit, uint64_t trgclassmask)
534535
{
535536
// int nClasswoInp = 0; // counting classes without input which should never happen
537+
int lost = 0;
536538
std::map<o2::InteractionRecord, CTPDigit> digitsMapShifted;
537539
auto L0shift = o2::ctp::TriggerOffsetsParam::Instance().LM_L0;
538540
auto L1shift = L0shift + o2::ctp::TriggerOffsetsParam::Instance().L0_L1;
@@ -551,38 +553,38 @@ int RawDataDecoder::shiftInputs(std::map<o2::InteractionRecord, CTPDigit>& digit
551553
if (lut == 0 || lut == 1) { // no inps or LM
552554
digitsMapShifted[dig.first] = dig.second;
553555
} else if (lut == 2) { // L0
554-
shiftNew(dig.first, TFOrbit, inpmask, L0shift, 0, digitsMapShifted);
556+
lost += shiftNew(dig.first, TFOrbit, inpmask, L0shift, 0, digitsMapShifted);
555557
if (dig.second.CTPClassMask.count()) {
556558
// LOG(error) << "Adding class mask without input ?";
557559
// This is not needed as it can happen; Full checj done below - see next LOG(error)
558560
CTPDigit digi = {dig.first, 0, dig.second.CTPClassMask};
559561
digitsMapShifted[dig.first] = digi;
560562
}
561563
} else if (lut == 4) { // L1
562-
shiftNew(dig.first, TFOrbit, inpmask, L1shift, 1, digitsMapShifted);
564+
lost += shiftNew(dig.first, TFOrbit, inpmask, L1shift, 1, digitsMapShifted);
563565
if (dig.second.CTPClassMask.count()) {
564566
CTPDigit digi = {dig.first, 0, dig.second.CTPClassMask};
565567
digitsMapShifted[dig.first] = digi;
566568
}
567569
} else if (lut == 6) { // L0 and L1
568-
shiftNew(dig.first, TFOrbit, inpmask, L0shift, 0, digitsMapShifted);
569-
shiftNew(dig.first, TFOrbit, inpmask, L1shift, 1, digitsMapShifted);
570+
lost += shiftNew(dig.first, TFOrbit, inpmask, L0shift, 0, digitsMapShifted);
571+
lost += shiftNew(dig.first, TFOrbit, inpmask, L1shift, 1, digitsMapShifted);
570572
if (dig.second.CTPClassMask.count()) {
571573
CTPDigit digi = {dig.first, 0, dig.second.CTPClassMask};
572574
digitsMapShifted[dig.first] = digi;
573575
}
574576
} else if (lut == 3) { // LM and L0
575-
shiftNew(dig.first, TFOrbit, inpmask, L0shift, 0, digitsMapShifted);
577+
lost += shiftNew(dig.first, TFOrbit, inpmask, L0shift, 0, digitsMapShifted);
576578
CTPDigit digi = {dig.first, inpmask & (~L0MASKInputs), dig.second.CTPClassMask};
577579
// if LM level do not need to add class as LM is not shifted;
578580
digitsMapShifted[dig.first] = digi;
579581
} else if (lut == 5) { // LM and L1
580-
shiftNew(dig.first, TFOrbit, inpmask, L1shift, 1, digitsMapShifted);
582+
lost += shiftNew(dig.first, TFOrbit, inpmask, L1shift, 1, digitsMapShifted);
581583
CTPDigit digi = {dig.first, inpmask & (~L1MASKInputs), dig.second.CTPClassMask};
582584
digitsMapShifted[dig.first] = digi;
583585
} else if (lut == 7) { // LM and L0 and L1
584-
shiftNew(dig.first, TFOrbit, inpmask, L0shift, 0, digitsMapShifted);
585-
shiftNew(dig.first, TFOrbit, inpmask, L1shift, 1, digitsMapShifted);
586+
lost += shiftNew(dig.first, TFOrbit, inpmask, L0shift, 0, digitsMapShifted);
587+
lost += shiftNew(dig.first, TFOrbit, inpmask, L1shift, 1, digitsMapShifted);
586588
CTPDigit digi = {dig.first, inpmaskLM, dig.second.CTPClassMask};
587589
digitsMapShifted[dig.first] = digi;
588590
} else {
@@ -592,7 +594,7 @@ int RawDataDecoder::shiftInputs(std::map<o2::InteractionRecord, CTPDigit>& digit
592594
for (auto const& dig : digitsMapShifted) {
593595
digits.push_back(dig.second);
594596
}
595-
return 0;
597+
return lost;
596598
}
597599
//
598600
int RawDataDecoder::checkReadoutConsistentncy(o2::pmr::vector<CTPDigit>& digits, uint64_t trgclassmask, uint64_t trgclassmaskNoTrgDet)
@@ -654,16 +656,13 @@ int RawDataDecoder::checkReadoutConsistentncy(o2::pmr::vector<CTPDigit>& digits,
654656
mClassErrorsB[cls.getIndex()]++;
655657
ret = 256;
656658
} else {
657-
mLostDueToShift++;
659+
mLostDueToShiftCC++;
658660
}
659661
}
660662
}
661663
}
662664
}
663665
}
664-
if (mLostDueToShift) {
665-
LOG(debug) << "LOST classes because of shift:" << mLostDueToShift;
666-
}
667666
return ret;
668667
}
669668
//

Detectors/CTP/workflow/include/CTPWorkflow/RawDecoderSpec.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,17 @@ class RawDecoderSpec : public framework::Task
7474
std::deque<size_t> mHistoryT;
7575
std::deque<size_t> mHistoryV;
7676
RawDataDecoder mDecoder;
77+
// Errors
78+
int mLostDueToShiftInps = 0;
79+
int mErrorIR = 0;
80+
int mErrorTCR = 0;
81+
int mIRRejected = 0;
82+
int mTCRRejected = 0;
83+
std::array<uint64_t, o2::ctp::CTP_NCLASSES> mClsEA{};
84+
std::array<uint64_t, o2::ctp::CTP_NCLASSES> mClsEB{}; // from inputs
85+
std::array<uint64_t, o2::ctp::CTP_NCLASSES> mClsA{};
86+
std::array<uint64_t, o2::ctp::CTP_NCLASSES> mClsB{}; // from inputs
87+
bool mCheckConsistency = false;
7788
};
7889

7990
/// \brief Creating DataProcessorSpec for the CTP

Detectors/CTP/workflow/src/RawDecoderSpec.cxx

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ using namespace o2::ctp::reco_workflow;
2626

2727
void RawDecoderSpec::init(framework::InitContext& ctx)
2828
{
29+
mCheckConsistency = ctx.options().get<bool>("check-consistency");
30+
mDecoder.setCheckConsistency(mCheckConsistency);
2931
mDecodeinputs = ctx.options().get<bool>("ctpinputs-decoding");
3032
mDecoder.setDecodeInps(mDecodeinputs);
3133
mNTFToIntegrate = ctx.options().get<int>("ntf-to-average");
@@ -43,7 +45,7 @@ void RawDecoderSpec::init(framework::InitContext& ctx)
4345
mOutputLumiInfo.inp2 = inp2;
4446
mMaxInputSize = ctx.options().get<int>("max-input-size");
4547
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;
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;
4749
// mOutputLumiInfo.printInputs();
4850
}
4951
void RawDecoderSpec::endOfStream(framework::EndOfStreamContext& ec)
@@ -69,22 +71,22 @@ void RawDecoderSpec::endOfStream(framework::EndOfStreamContext& ec)
6971
o0 = TFOrbits[i];
7072
}
7173
std::cout << std::endl;
72-
LOG(info) << " Lost due to the shift:" << mDecoder.getLostDueToShift();
73-
LOG(info) << "Number of missing TF:" << nmiss << std::endl;
74-
if (mDecoder.getErrorIR() || mDecoder.getErrorTCR()) {
75-
LOG(error) << "# of IR errors:" << mDecoder.getErrorIR() << " TCR errors:" << mDecoder.getErrorTCR() << 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;
7679
}
77-
std::array<uint64_t, o2::ctp::CTP_NCLASSES> clsA = mDecoder.getClassCountersA();
78-
std::array<uint64_t, o2::ctp::CTP_NCLASSES> clsB = mDecoder.getClassCountersB();
79-
std::array<uint64_t, o2::ctp::CTP_NCLASSES> clsEA = mDecoder.getClassErrorsA();
80-
std::array<uint64_t, o2::ctp::CTP_NCLASSES> clsEB = mDecoder.getClassErrorsB();
81-
82-
for (int i = 0; i < o2::ctp::CTP_NCLASSES; i++) {
83-
bool print = clsA[i] > 0 || clsB[i] > 0 || clsEA[i] > 0 || clsEB[i] > 0;
84-
if (clsEA[i]) {
85-
LOG(error) << " Class without inputs:";
80+
if(mCheckConsistency) {
81+
LOG(info) << "Lost due to the shift Consistency Checker:" << mDecoder.getLostDueToShiftCls();
82+
auto ctpcfg = mDecoder.getCTPConfig();
83+
for (int i = 0; i < o2::ctp::CTP_NCLASSES; i++) {
84+
std::string name = ctpcfg.getClassNameFromIndex(i);
85+
if (mClsEA[i]) {
86+
LOG(error) << " Class without inputs:";
87+
}
88+
LOG(important) << "CLASS:"<< name << ":" << i << " Cls=>Inp:" << mClsA[i] << " Inp=>Cls:" << mClsB[i] << " ErrorsCls=>Inps:" << mClsEA[i] << " MissingInps=>Cls:" << mClsEB[i];
8689
}
87-
LOG(important) << "CLASS:" << i << " Cls=>Inp:" << clsA[i] << " Inp=>Cls:" << clsB[i] << " ErrorsCls=>Inps:" << clsEA[i] << " MissingInps=>Cls:" << clsEB[i];
8890
}
8991
}
9092
void RawDecoderSpec::run(framework::ProcessingContext& ctx)
@@ -161,6 +163,21 @@ void RawDecoderSpec::run(framework::ProcessingContext& ctx)
161163
if (mDoDigits) {
162164
LOG(info) << "[CTPRawToDigitConverter - run] Writing " << mOutputDigits.size() << " digits. IR rejected:" << mDecoder.getIRRejected() << " TCR rejected:" << mDecoder.getTCRRejected();
163165
ctx.outputs().snapshot(o2::framework::Output{"CTP", "DIGITS", 0}, mOutputDigits);
166+
mLostDueToShiftInps += mDecoder.getLostDueToShiftInp();
167+
mErrorIR += mDecoder.getErrorIR();
168+
mErrorTCR += mDecoder.getErrorTCR();
169+
mIRRejected += mDecoder.getIRRejected();
170+
mTCRRejected += mDecoder.getTCRRejected();
171+
auto clsEA = mDecoder.getClassErrorsA();
172+
auto clsEB = mDecoder.getClassErrorsB();
173+
auto cntCA = mDecoder.getClassCountersA();
174+
auto cntCB = mDecoder.getClassCountersB();
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];
180+
}
164181
}
165182
if (mDoLumi) {
166183
uint32_t tfCountsT = 0;
@@ -236,7 +253,8 @@ o2::framework::DataProcessorSpec o2::ctp::reco_workflow::getRawDecoderSpec(bool
236253
{"lumi-inp2", o2::framework::VariantType::String, "VBA", {"The second input used for online lumi. Name in capital."}},
237254
{"use-verbose-mode", o2::framework::VariantType::Bool, false, {"Verbose logging"}},
238255
{"max-input-size", o2::framework::VariantType::Int, 0, {"Do not process input if bigger than max size, 0 - do not check"}},
239-
{"max-input-size-fatal", o2::framework::VariantType::Bool, false, {"If true issue fatal error otherwise error on;y"}},
256+
{"max-input-size-fatal", o2::framework::VariantType::Bool, false, {"If true issue fatal error otherwise error only"}},
257+
{"check-consistency", o2::framework::VariantType::Bool, false, {"If true checks digits consistency using ctp config"}},
240258
{"ctpinputs-decoding", o2::framework::VariantType::Bool, false, {"Inputs alignment: true - raw decoder - has to be compatible with CTF decoder: allowed options: 10,01,00"}}}};
241259
}
242260
void RawDecoderSpec::updateTimeDependentParams(framework::ProcessingContext& pc)

0 commit comments

Comments
 (0)