Skip to content

Commit ad63c32

Browse files
authored
Ctpdev: readout consistency (#13989)
* fix: adding return in orbit reset code * dev: adding consistency check classes vs inputs to readout * clang
1 parent 769e674 commit ad63c32

File tree

5 files changed

+74
-10
lines changed

5 files changed

+74
-10
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ class CTPConfiguration
162162
int getInputIndex(const std::string& name) const;
163163
std::string getClassNameFromIndex(int index) { return mCTPClasses[index].name; };
164164
std::string getClassNameFromHWIndex(int index);
165+
const CTPClass* getCTPClassFromHWIndex(const int index) const;
165166
bool isMaskInInputs(const uint64_t& mask) const;
166167
bool isBCMaskInConfig(const std::string maskname) const;
167168
const BCMask* isBCMaskInConfigP(const std::string bcmask) const;

DataFormats/Detectors/CTP/src/Configuration.cxx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,17 @@ std::string CTPConfiguration::getClassNameFromHWIndex(int index)
790790
std::string ret = "not found";
791791
return ret;
792792
}
793+
const CTPClass* CTPConfiguration::getCTPClassFromHWIndex(int index) const
794+
{
795+
const CTPClass* clsfound = nullptr;
796+
for (auto const& cls : mCTPClasses) {
797+
if (index == cls.getIndex()) {
798+
clsfound = &cls;
799+
break;
800+
}
801+
}
802+
return clsfound;
803+
}
793804
bool CTPConfiguration::isMaskInInputs(const uint64_t& mask) const
794805
{
795806
for (auto const& inp : mInputs) {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class RawDataDecoder
4545
void setMAXErrors(int m) { mErrorMax = m; }
4646
int setLumiInp(int lumiinp, std::string inp);
4747
void setCTPConfig(CTPConfiguration cfg) { mCTPConfig = std::move(cfg); };
48+
void setCheckConsistency(bool check) { mCheckConsistency = check; }
4849
uint32_t getIRRejected() const { return mIRRejected; }
4950
uint32_t getTCRRejected() const { return mTCRRejected; }
5051
std::vector<uint32_t>& getTFOrbits() { return mTFOrbits; }
@@ -54,12 +55,14 @@ class RawDataDecoder
5455
int init();
5556
static int shiftNew(const o2::InteractionRecord& irin, uint32_t TFOrbit, std::bitset<48>& inpmask, int64_t shift, int level, std::map<o2::InteractionRecord, CTPDigit>& digmap);
5657
static int shiftInputs(std::map<o2::InteractionRecord, CTPDigit>& digitsMap, o2::pmr::vector<CTPDigit>& digits, uint32_t TFOrbit, uint64_t trgclassmask = 0xffffffffffffffff);
58+
int checkReadoutConsistentncy(o2::pmr::vector<CTPDigit>& digits, uint64_t trgclassmask = 0xffffffffffffffff);
5759

5860
private:
5961
static constexpr uint32_t TF_TRIGGERTYPE_MASK = 0x800;
6062
static constexpr uint32_t HB_TRIGGERTYPE_MASK = 0x2;
6163
// true: full inps decoding includine latency shifts here; false: latency shifts in CTF decoder
6264
bool mDecodeInps = false;
65+
bool mCheckConsistency = false;
6366
// for digits
6467
bool mDoDigits = true;
6568
std::vector<CTPDigit> mOutputDigits;

Detectors/CTP/reconstruction/src/RawDataDecoder.cxx

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ int RawDataDecoder::addCTPDigit(uint32_t linkCRU, uint32_t orbit, gbtword80_t& d
7979
if (mErrorIR < mErrorMax) {
8080
LOG(error) << "Two CTP IRs with the same timestamp:" << ir.bc << " " << ir.orbit << " pld:" << pld << " dig:" << digits[ir];
8181
}
82-
ret = 2;
82+
ret = 4;
8383
mErrorIR++;
8484
mStickyError = true;
8585
}
8686
} else {
8787
LOG(error) << "Two digits with the same timestamp:" << ir.bc << " " << ir.orbit;
88-
ret = 2;
88+
ret = 8;
8989
}
9090
} else if (linkCRU == o2::ctp::GBTLinkIDClassRec) {
9191
int32_t BCShiftCorrection = -o2::ctp::TriggerOffsetsParam::Instance().customOffset[o2::detectors::DetID::CTP];
@@ -113,11 +113,11 @@ int RawDataDecoder::addCTPDigit(uint32_t linkCRU, uint32_t orbit, gbtword80_t& d
113113
mStickyError = true;
114114
}
115115
mErrorTCR++;
116-
ret = 3;
116+
ret = 16;
117117
}
118118
} else {
119119
LOG(error) << "Two digits with the same timestamp:" << ir.bc << " " << ir.orbit;
120-
ret = 3;
120+
ret = 32;
121121
}
122122
} else {
123123
LOG(error) << "Unxpected CTP CRU link:" << linkCRU;
@@ -298,7 +298,10 @@ int RawDataDecoder::decodeRaw(o2::framework::InputRecord& inputs, std::vector<o2
298298
trgclassmask = mCTPConfig.getTriggerClassMask();
299299
}
300300
// std::cout << "trgclassmask:" << std::hex << trgclassmask << std::dec << std::endl;
301-
shiftInputs(digitsMap, digits, mTFOrbit, trgclassmask);
301+
ret = shiftInputs(digitsMap, digits, mTFOrbit, trgclassmask);
302+
if (mCheckConsistency) {
303+
ret = checkReadoutConsistentncy(digits, trgclassmask);
304+
}
302305
}
303306
if (mDoDigits && !mDecodeInps) {
304307
for (auto const& dig : digitsMap) {
@@ -615,13 +618,58 @@ int RawDataDecoder::shiftInputs(std::map<o2::InteractionRecord, CTPDigit>& digit
615618
}
616619
digits.push_back(dig.second);
617620
}
621+
int ret = 0;
618622
if (nTwoI) { // Trigger class wo Input
619623
LOG(error) << "LM:" << nLM << " L0:" << nL0 << " L1:" << nL1 << " TwI:" << nTwI << " Trigger classes wo input:" << nTwoI;
624+
ret = 64;
620625
}
621626
if (nTwoIlost) {
622627
LOG(warn) << " Trigger classes wo input from diff latency 1:" << nTwoIlost;
623628
}
624-
return 0;
629+
return ret;
630+
}
631+
//
632+
int RawDataDecoder::checkReadoutConsistentncy(o2::pmr::vector<CTPDigit>& digits, uint64_t trgclassmask)
633+
{
634+
int ret = 0;
635+
int lost = 0;
636+
for (auto const& digit : digits) {
637+
// if class mask => inps
638+
for (int i = 0; i < digit.CTPClassMask.size(); i++) {
639+
if (digit.CTPClassMask[i]) {
640+
const CTPClass* cls = mCTPConfig.getCTPClassFromHWIndex(i);
641+
uint64_t clsinpmask = cls->descriptor->getInputsMask();
642+
uint64_t diginpmask = digit.CTPInputMask.to_ullong();
643+
if (!((clsinpmask & diginpmask) == clsinpmask)) {
644+
LOG(error) << "CTP class:" << cls->name << " inpmask:" << clsinpmask << " not compatible with inputs mask:" << diginpmask;
645+
ret = 128;
646+
}
647+
}
648+
}
649+
// if inps => class mask
650+
for (auto const& cls : mCTPConfig.getCTPClasses()) {
651+
uint64_t clsinpmask = cls.descriptor->getInputsMask();
652+
uint64_t diginpmask = digit.CTPInputMask.to_ullong();
653+
uint64_t digclsmask = digit.CTPClassMask.to_ullong();
654+
if ((clsinpmask & diginpmask) == clsinpmask) {
655+
if ((cls.classMask & digclsmask) == 0) {
656+
int32_t BCShiftCorrection = -o2::ctp::TriggerOffsetsParam::Instance().customOffset[o2::detectors::DetID::CTP];
657+
int32_t offset = BCShiftCorrection + o2::ctp::TriggerOffsetsParam::Instance().LM_L0 + o2::ctp::TriggerOffsetsParam::Instance().L0_L1_classes - 1;
658+
offset = o2::constants::lhc::LHCMaxBunches - offset;
659+
if (digit.intRecord.bc < offset) {
660+
LOG(error) << "CTP class:" << cls.name << " inpmask:" << clsinpmask << " cls mask:" << cls.classMask << " not found in digit:" << digit;
661+
ret = 256;
662+
} else {
663+
lost++;
664+
}
665+
}
666+
}
667+
}
668+
}
669+
if (lost) {
670+
LOG(info) << "LOST classes because of shift:" << lost;
671+
}
672+
return ret;
625673
}
626674
//
627675
int RawDataDecoder::setLumiInp(int lumiinp, std::string inp)

Detectors/CTP/workflowScalers/src/ctp-ccdb-orbit.cxx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ int main(int argc, char** argv)
7676
std::cerr << e.what() << ", application will now exit" << std::endl;
7777
exit(2);
7878
}
79+
int ret = 0;
7980
std::string action = vm["action"].as<std::string>();
8081
std::vector<int64_t> vect;
8182
std::string ccdbPath;
@@ -120,10 +121,10 @@ int main(int argc, char** argv)
120121
int64_t runnum = vm["run-number"].as<int64_t>();
121122
metadata["runNumber"] = std::to_string(runnum);
122123
std::cout << "Storing:" << ccdbPath << " " << metadata["runNumber"] << " tmin:" << tmin << " tmax:" << tmax << " ts:" << tt << std::endl;
123-
api.storeAsTFileAny(&(vect), ccdbPath, metadata, tmin, tmax);
124+
ret = api.storeAsTFileAny(&(vect), ccdbPath, metadata, tmin, tmax);
124125
} else {
125126
std::cout << "Storing:" << ccdbPath << " tmin:" << tmin << " tmax:" << tmax << " ts:" << tt << std::endl;
126-
api.storeAsTFileAny(&(vect), ccdbPath, metadata, tmin, tmax);
127+
ret = api.storeAsTFileAny(&(vect), ccdbPath, metadata, tmin, tmax);
127128
}
128129
}
129130
//
@@ -132,7 +133,7 @@ int main(int argc, char** argv)
132133
TFile* f = TFile::Open(file.c_str(), "RECREATE");
133134
if (f == nullptr) {
134135
std::cout << "Error: File" << file << " could not be open for writing !!!" << std::endl;
135-
return 1;
136+
ret++;
136137
} else {
137138
std::cout << "File" << file << " being writen." << std::endl;
138139
f->WriteObject(&vect, "ccdb_object");
@@ -141,5 +142,5 @@ int main(int argc, char** argv)
141142
} else {
142143
std::cout << "No file created" << std::endl;
143144
}
144-
return 0;
145+
return ret;
145146
}

0 commit comments

Comments
 (0)