Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class CTPConfiguration
const std::vector<CTPClass>& getCTPClasses() const { return mCTPClasses; } // Read-only interface
uint64_t getInputMask(const std::string& name) const;
int getInputIndex(const std::string& name) const;
std::string getClassNameFromIndex(int index) { return mCTPClasses[index].name; };
std::string getClassNameFromIndex(int index);
std::string getClassNameFromHWIndex(int index);
const CTPClass* getCTPClassFromHWIndex(const int index) const;
bool isMaskInInputs(const uint64_t& mask) const;
Expand Down
12 changes: 11 additions & 1 deletion DataFormats/Detectors/CTP/src/Configuration.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,15 @@ int CTPConfiguration::getInputIndex(const std::string& name) const
LOG(info) << "input:" << name << " index:" << index;
return index;
}
std::string CTPConfiguration::getClassNameFromIndex(int index)
{
if (index < (int)mCTPClasses.size()) {
return mCTPClasses[index].name;
} else {
std::string name = "Cls" + std::to_string(index);
return name;
}
};
std::string CTPConfiguration::getClassNameFromHWIndex(int index)
{
for (auto& cls : mCTPClasses) {
Expand Down Expand Up @@ -924,8 +933,9 @@ uint64_t CTPConfiguration::getTriggerClassMaskWInputsNoTrgDets() const
exclude += cls.name.find("EMC") != std::string::npos;
exclude += cls.name.find("TRD") != std::string::npos;
exclude += cls.name.find("HMP") != std::string::npos;
if (!exclude)
if (!exclude) {
clsmask |= cls.classMask;
}
}
return clsmask;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class RawDataDecoder
std::array<uint64_t, o2::ctp::CTP_NCLASSES> getClassErrorsB() { return mClassErrorsB; }
std::array<uint64_t, o2::ctp::CTP_NCLASSES> getClassCountersA() { return mClassCountersA; }
std::array<uint64_t, o2::ctp::CTP_NCLASSES> getClassCountersB() { return mClassCountersB; }
int getLostDueToShift() { return mLostDueToShift; }
int getLostDueToShiftCls() { return mLostDueToShiftCC; }
int getLostDueToShiftInp() { return mLostDueToShiftInps; }

private:
static constexpr uint32_t TF_TRIGGERTYPE_MASK = 0x800;
Expand All @@ -80,8 +81,8 @@ class RawDataDecoder
gbtword80_t mTVXMask = 0x4; // TVX is 3rd input
gbtword80_t mVBAMask = 0x20; // VBA is 6 th input
bool mVerbose = false;
uint32_t mIRRejected = 0;
uint32_t mTCRRejected = 0;
int mIRRejected = 0;
int mTCRRejected = 0;
bool mPadding = true;
uint32_t mTFOrbit = 0;
std::vector<uint32_t> mTFOrbits;
Expand All @@ -94,7 +95,8 @@ class RawDataDecoder
std::array<uint64_t, o2::ctp::CTP_NCLASSES> mClassErrorsB{}; // from inputs
std::array<uint64_t, o2::ctp::CTP_NCLASSES> mClassCountersA{};
std::array<uint64_t, o2::ctp::CTP_NCLASSES> mClassCountersB{}; // from inputs
int mLostDueToShift = 0;
int mLostDueToShiftCC = 0;
int mLostDueToShiftInps = 0;
CTPConfiguration mCTPConfig;
};
} // namespace ctp
Expand Down
32 changes: 16 additions & 16 deletions Detectors/CTP/reconstruction/src/RawDataDecoder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,12 @@ int RawDataDecoder::decodeRaw(o2::framework::InputRecord& inputs, std::vector<o2
uint64_t trgclassmask = 0xffffffffffffffff;
uint64_t trgclassmaskNOTRGDet = 0xffffffffffffffff;
if (mCTPConfig.getRunNumber() != 0) {
trgclassmask = mCTPConfig.getTriggerClassMaskWInputs();
trgclassmask = mCTPConfig.getTriggerClassMaskWInputs(); // classes triggered by internal ctp generators not here
trgclassmaskNOTRGDet = mCTPConfig.getTriggerClassMaskWInputsNoTrgDets();
// mCTPConfig.printStream(std::cout);
}
// std::cout << "trgclassmask:" << std::hex << trgclassmask << std::dec << std::endl;
ret = shiftInputs(digitsMap, digits, mTFOrbit);
mLostDueToShiftInps += shiftInputs(digitsMap, digits, mTFOrbit);
if (mCheckConsistency) {
ret = checkReadoutConsistentncy(digits, trgclassmask, trgclassmaskNOTRGDet);
}
Expand Down Expand Up @@ -524,7 +524,9 @@ int RawDataDecoder::shiftNew(const o2::InteractionRecord& irin, uint32_t TFOrbit
digmap[ir] = digit;
}
} else {
LOG(info) << "LOST:" << irin << " shift:" << shift;
// LOG(info) << "LOST:" << irin << " shift:" << shift;
return 1;
;
}
return 0;
}
Expand All @@ -533,6 +535,7 @@ int RawDataDecoder::shiftNew(const o2::InteractionRecord& irin, uint32_t TFOrbit
int RawDataDecoder::shiftInputs(std::map<o2::InteractionRecord, CTPDigit>& digitsMap, o2::pmr::vector<CTPDigit>& digits, uint32_t TFOrbit, uint64_t trgclassmask)
{
// int nClasswoInp = 0; // counting classes without input which should never happen
int lost = 0;
std::map<o2::InteractionRecord, CTPDigit> digitsMapShifted;
auto L0shift = o2::ctp::TriggerOffsetsParam::Instance().LM_L0;
auto L1shift = L0shift + o2::ctp::TriggerOffsetsParam::Instance().L0_L1;
Expand All @@ -551,38 +554,38 @@ int RawDataDecoder::shiftInputs(std::map<o2::InteractionRecord, CTPDigit>& digit
if (lut == 0 || lut == 1) { // no inps or LM
digitsMapShifted[dig.first] = dig.second;
} else if (lut == 2) { // L0
shiftNew(dig.first, TFOrbit, inpmask, L0shift, 0, digitsMapShifted);
lost += shiftNew(dig.first, TFOrbit, inpmask, L0shift, 0, digitsMapShifted);
if (dig.second.CTPClassMask.count()) {
// LOG(error) << "Adding class mask without input ?";
// This is not needed as it can happen; Full checj done below - see next LOG(error)
CTPDigit digi = {dig.first, 0, dig.second.CTPClassMask};
digitsMapShifted[dig.first] = digi;
}
} else if (lut == 4) { // L1
shiftNew(dig.first, TFOrbit, inpmask, L1shift, 1, digitsMapShifted);
lost += shiftNew(dig.first, TFOrbit, inpmask, L1shift, 1, digitsMapShifted);
if (dig.second.CTPClassMask.count()) {
CTPDigit digi = {dig.first, 0, dig.second.CTPClassMask};
digitsMapShifted[dig.first] = digi;
}
} else if (lut == 6) { // L0 and L1
shiftNew(dig.first, TFOrbit, inpmask, L0shift, 0, digitsMapShifted);
shiftNew(dig.first, TFOrbit, inpmask, L1shift, 1, digitsMapShifted);
lost += shiftNew(dig.first, TFOrbit, inpmask, L0shift, 0, digitsMapShifted);
lost += shiftNew(dig.first, TFOrbit, inpmask, L1shift, 1, digitsMapShifted);
if (dig.second.CTPClassMask.count()) {
CTPDigit digi = {dig.first, 0, dig.second.CTPClassMask};
digitsMapShifted[dig.first] = digi;
}
} else if (lut == 3) { // LM and L0
shiftNew(dig.first, TFOrbit, inpmask, L0shift, 0, digitsMapShifted);
lost += shiftNew(dig.first, TFOrbit, inpmask, L0shift, 0, digitsMapShifted);
CTPDigit digi = {dig.first, inpmask & (~L0MASKInputs), dig.second.CTPClassMask};
// if LM level do not need to add class as LM is not shifted;
digitsMapShifted[dig.first] = digi;
} else if (lut == 5) { // LM and L1
shiftNew(dig.first, TFOrbit, inpmask, L1shift, 1, digitsMapShifted);
lost += shiftNew(dig.first, TFOrbit, inpmask, L1shift, 1, digitsMapShifted);
CTPDigit digi = {dig.first, inpmask & (~L1MASKInputs), dig.second.CTPClassMask};
digitsMapShifted[dig.first] = digi;
} else if (lut == 7) { // LM and L0 and L1
shiftNew(dig.first, TFOrbit, inpmask, L0shift, 0, digitsMapShifted);
shiftNew(dig.first, TFOrbit, inpmask, L1shift, 1, digitsMapShifted);
lost += shiftNew(dig.first, TFOrbit, inpmask, L0shift, 0, digitsMapShifted);
lost += shiftNew(dig.first, TFOrbit, inpmask, L1shift, 1, digitsMapShifted);
CTPDigit digi = {dig.first, inpmaskLM, dig.second.CTPClassMask};
digitsMapShifted[dig.first] = digi;
} else {
Expand All @@ -592,7 +595,7 @@ int RawDataDecoder::shiftInputs(std::map<o2::InteractionRecord, CTPDigit>& digit
for (auto const& dig : digitsMapShifted) {
digits.push_back(dig.second);
}
return 0;
return lost;
}
//
int RawDataDecoder::checkReadoutConsistentncy(o2::pmr::vector<CTPDigit>& digits, uint64_t trgclassmask, uint64_t trgclassmaskNoTrgDet)
Expand Down Expand Up @@ -654,16 +657,13 @@ int RawDataDecoder::checkReadoutConsistentncy(o2::pmr::vector<CTPDigit>& digits,
mClassErrorsB[cls.getIndex()]++;
ret = 256;
} else {
mLostDueToShift++;
mLostDueToShiftCC++;
}
}
}
}
}
}
if (mLostDueToShift) {
LOG(debug) << "LOST classes because of shift:" << mLostDueToShift;
}
return ret;
}
//
Expand Down
11 changes: 11 additions & 0 deletions Detectors/CTP/workflow/include/CTPWorkflow/RawDecoderSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ class RawDecoderSpec : public framework::Task
std::deque<size_t> mHistoryT;
std::deque<size_t> mHistoryV;
RawDataDecoder mDecoder;
// Errors
int mLostDueToShiftInps = 0;
int mErrorIR = 0;
int mErrorTCR = 0;
int mIRRejected = 0;
int mTCRRejected = 0;
std::array<uint64_t, o2::ctp::CTP_NCLASSES> mClsEA{};
std::array<uint64_t, o2::ctp::CTP_NCLASSES> mClsEB{}; // from inputs
std::array<uint64_t, o2::ctp::CTP_NCLASSES> mClsA{};
std::array<uint64_t, o2::ctp::CTP_NCLASSES> mClsB{}; // from inputs
bool mCheckConsistency = false;
};

/// \brief Creating DataProcessorSpec for the CTP
Expand Down
50 changes: 34 additions & 16 deletions Detectors/CTP/workflow/src/RawDecoderSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ using namespace o2::ctp::reco_workflow;

void RawDecoderSpec::init(framework::InitContext& ctx)
{
mCheckConsistency = ctx.options().get<bool>("check-consistency");
mDecoder.setCheckConsistency(mCheckConsistency);
mDecodeinputs = ctx.options().get<bool>("ctpinputs-decoding");
mDecoder.setDecodeInps(mDecodeinputs);
mNTFToIntegrate = ctx.options().get<int>("ntf-to-average");
Expand All @@ -43,7 +45,7 @@ void RawDecoderSpec::init(framework::InitContext& ctx)
mOutputLumiInfo.inp2 = inp2;
mMaxInputSize = ctx.options().get<int>("max-input-size");
mMaxInputSizeFatal = ctx.options().get<bool>("max-input-size-fatal");
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;
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;
// mOutputLumiInfo.printInputs();
}
void RawDecoderSpec::endOfStream(framework::EndOfStreamContext& ec)
Expand All @@ -69,22 +71,22 @@ void RawDecoderSpec::endOfStream(framework::EndOfStreamContext& ec)
o0 = TFOrbits[i];
}
std::cout << std::endl;
LOG(info) << " Lost due to the shift:" << mDecoder.getLostDueToShift();
LOG(info) << "Number of missing TF:" << nmiss << std::endl;
if (mDecoder.getErrorIR() || mDecoder.getErrorTCR()) {
LOG(error) << "# of IR errors:" << mDecoder.getErrorIR() << " TCR errors:" << mDecoder.getErrorTCR() << std::endl;
LOG(info) << "Number of non continous TF:" << nmiss << std::endl;
LOG(info) << "Lost in shiftInputs:" << mLostDueToShiftInps;
LOG(info) << "Lost in addDigit Inputs:" << mIRRejected << " Classes:" << mTCRRejected;
if (mErrorIR || mErrorTCR) {
LOG(error) << "# of IR errors:" << mErrorIR << " TCR errors:" << mErrorTCR << std::endl;
}
std::array<uint64_t, o2::ctp::CTP_NCLASSES> clsA = mDecoder.getClassCountersA();
std::array<uint64_t, o2::ctp::CTP_NCLASSES> clsB = mDecoder.getClassCountersB();
std::array<uint64_t, o2::ctp::CTP_NCLASSES> clsEA = mDecoder.getClassErrorsA();
std::array<uint64_t, o2::ctp::CTP_NCLASSES> clsEB = mDecoder.getClassErrorsB();

for (int i = 0; i < o2::ctp::CTP_NCLASSES; i++) {
bool print = clsA[i] > 0 || clsB[i] > 0 || clsEA[i] > 0 || clsEB[i] > 0;
if (clsEA[i]) {
LOG(error) << " Class without inputs:";
if (mCheckConsistency) {
LOG(info) << "Lost due to the shift Consistency Checker:" << mDecoder.getLostDueToShiftCls();
auto ctpcfg = mDecoder.getCTPConfig();
for (int i = 0; i < o2::ctp::CTP_NCLASSES; i++) {
std::string name = ctpcfg.getClassNameFromIndex(i);
if (mClsEA[i]) {
LOG(error) << " Class without inputs:";
}
LOG(important) << "CLASS:" << name << ":" << i << " Cls=>Inp:" << mClsA[i] << " Inp=>Cls:" << mClsB[i] << " ErrorsCls=>Inps:" << mClsEA[i] << " MissingInps=>Cls:" << mClsEB[i];
}
LOG(important) << "CLASS:" << i << " Cls=>Inp:" << clsA[i] << " Inp=>Cls:" << clsB[i] << " ErrorsCls=>Inps:" << clsEA[i] << " MissingInps=>Cls:" << clsEB[i];
}
}
void RawDecoderSpec::run(framework::ProcessingContext& ctx)
Expand Down Expand Up @@ -161,6 +163,21 @@ void RawDecoderSpec::run(framework::ProcessingContext& ctx)
if (mDoDigits) {
LOG(info) << "[CTPRawToDigitConverter - run] Writing " << mOutputDigits.size() << " digits. IR rejected:" << mDecoder.getIRRejected() << " TCR rejected:" << mDecoder.getTCRRejected();
ctx.outputs().snapshot(o2::framework::Output{"CTP", "DIGITS", 0}, mOutputDigits);
mLostDueToShiftInps += mDecoder.getLostDueToShiftInp();
mErrorIR += mDecoder.getErrorIR();
mErrorTCR += mDecoder.getErrorTCR();
mIRRejected += mDecoder.getIRRejected();
mTCRRejected += mDecoder.getTCRRejected();
auto clsEA = mDecoder.getClassErrorsA();
auto clsEB = mDecoder.getClassErrorsB();
auto cntCA = mDecoder.getClassCountersA();
auto cntCB = mDecoder.getClassCountersB();
for (int i = 0; i < o2::ctp::CTP_NCLASSES; i++) {
mClsEA[i] += clsEA[i];
mClsEB[i] += clsEB[i];
mClsA[i] += cntCA[i];
mClsB[i] += cntCB[i];
}
}
if (mDoLumi) {
uint32_t tfCountsT = 0;
Expand Down Expand Up @@ -236,7 +253,8 @@ o2::framework::DataProcessorSpec o2::ctp::reco_workflow::getRawDecoderSpec(bool
{"lumi-inp2", o2::framework::VariantType::String, "VBA", {"The second input used for online lumi. Name in capital."}},
{"use-verbose-mode", o2::framework::VariantType::Bool, false, {"Verbose logging"}},
{"max-input-size", o2::framework::VariantType::Int, 0, {"Do not process input if bigger than max size, 0 - do not check"}},
{"max-input-size-fatal", o2::framework::VariantType::Bool, false, {"If true issue fatal error otherwise error on;y"}},
{"max-input-size-fatal", o2::framework::VariantType::Bool, false, {"If true issue fatal error otherwise error only"}},
{"check-consistency", o2::framework::VariantType::Bool, false, {"If true checks digits consistency using ctp config"}},
{"ctpinputs-decoding", o2::framework::VariantType::Bool, false, {"Inputs alignment: true - raw decoder - has to be compatible with CTF decoder: allowed options: 10,01,00"}}}};
}
void RawDecoderSpec::updateTimeDependentParams(framework::ProcessingContext& pc)
Expand Down