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 @@ -162,6 +162,7 @@ class CTPConfiguration
int getInputIndex(const std::string& name) const;
std::string getClassNameFromIndex(int index) { return mCTPClasses[index].name; };
std::string getClassNameFromHWIndex(int index);
const CTPClass* getCTPClassFromHWIndex(const int index) const;
bool isMaskInInputs(const uint64_t& mask) const;
bool isBCMaskInConfig(const std::string maskname) const;
const BCMask* isBCMaskInConfigP(const std::string bcmask) const;
Expand Down
11 changes: 11 additions & 0 deletions DataFormats/Detectors/CTP/src/Configuration.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,17 @@ std::string CTPConfiguration::getClassNameFromHWIndex(int index)
std::string ret = "not found";
return ret;
}
const CTPClass* CTPConfiguration::getCTPClassFromHWIndex(int index) const
{
const CTPClass* clsfound = nullptr;
for (auto const& cls : mCTPClasses) {
if (index == cls.getIndex()) {
clsfound = &cls;
break;
}
}
return clsfound;
}
bool CTPConfiguration::isMaskInInputs(const uint64_t& mask) const
{
for (auto const& inp : mInputs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class RawDataDecoder
void setMAXErrors(int m) { mErrorMax = m; }
int setLumiInp(int lumiinp, std::string inp);
void setCTPConfig(CTPConfiguration cfg) { mCTPConfig = std::move(cfg); };
void setCheckConsistency(bool check) { mCheckConsistency = check; }
uint32_t getIRRejected() const { return mIRRejected; }
uint32_t getTCRRejected() const { return mTCRRejected; }
std::vector<uint32_t>& getTFOrbits() { return mTFOrbits; }
Expand All @@ -54,12 +55,14 @@ class RawDataDecoder
int init();
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);
static int shiftInputs(std::map<o2::InteractionRecord, CTPDigit>& digitsMap, o2::pmr::vector<CTPDigit>& digits, uint32_t TFOrbit, uint64_t trgclassmask = 0xffffffffffffffff);
int checkReadoutConsistentncy(o2::pmr::vector<CTPDigit>& digits, uint64_t trgclassmask = 0xffffffffffffffff);

private:
static constexpr uint32_t TF_TRIGGERTYPE_MASK = 0x800;
static constexpr uint32_t HB_TRIGGERTYPE_MASK = 0x2;
// true: full inps decoding includine latency shifts here; false: latency shifts in CTF decoder
bool mDecodeInps = false;
bool mCheckConsistency = false;
// for digits
bool mDoDigits = true;
std::vector<CTPDigit> mOutputDigits;
Expand Down
60 changes: 54 additions & 6 deletions Detectors/CTP/reconstruction/src/RawDataDecoder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ int RawDataDecoder::addCTPDigit(uint32_t linkCRU, uint32_t orbit, gbtword80_t& d
if (mErrorIR < mErrorMax) {
LOG(error) << "Two CTP IRs with the same timestamp:" << ir.bc << " " << ir.orbit << " pld:" << pld << " dig:" << digits[ir];
}
ret = 2;
ret = 4;
mErrorIR++;
mStickyError = true;
}
} else {
LOG(error) << "Two digits with the same timestamp:" << ir.bc << " " << ir.orbit;
ret = 2;
ret = 8;
}
} else if (linkCRU == o2::ctp::GBTLinkIDClassRec) {
int32_t BCShiftCorrection = -o2::ctp::TriggerOffsetsParam::Instance().customOffset[o2::detectors::DetID::CTP];
Expand Down Expand Up @@ -113,11 +113,11 @@ int RawDataDecoder::addCTPDigit(uint32_t linkCRU, uint32_t orbit, gbtword80_t& d
mStickyError = true;
}
mErrorTCR++;
ret = 3;
ret = 16;
}
} else {
LOG(error) << "Two digits with the same timestamp:" << ir.bc << " " << ir.orbit;
ret = 3;
ret = 32;
}
} else {
LOG(error) << "Unxpected CTP CRU link:" << linkCRU;
Expand Down Expand Up @@ -298,7 +298,10 @@ int RawDataDecoder::decodeRaw(o2::framework::InputRecord& inputs, std::vector<o2
trgclassmask = mCTPConfig.getTriggerClassMask();
}
// std::cout << "trgclassmask:" << std::hex << trgclassmask << std::dec << std::endl;
shiftInputs(digitsMap, digits, mTFOrbit, trgclassmask);
ret = shiftInputs(digitsMap, digits, mTFOrbit, trgclassmask);
if (mCheckConsistency) {
ret = checkReadoutConsistentncy(digits, trgclassmask);
}
}
if (mDoDigits && !mDecodeInps) {
for (auto const& dig : digitsMap) {
Expand Down Expand Up @@ -615,13 +618,58 @@ int RawDataDecoder::shiftInputs(std::map<o2::InteractionRecord, CTPDigit>& digit
}
digits.push_back(dig.second);
}
int ret = 0;
if (nTwoI) { // Trigger class wo Input
LOG(error) << "LM:" << nLM << " L0:" << nL0 << " L1:" << nL1 << " TwI:" << nTwI << " Trigger classes wo input:" << nTwoI;
ret = 64;
}
if (nTwoIlost) {
LOG(warn) << " Trigger classes wo input from diff latency 1:" << nTwoIlost;
}
return 0;
return ret;
}
//
int RawDataDecoder::checkReadoutConsistentncy(o2::pmr::vector<CTPDigit>& digits, uint64_t trgclassmask)
{
int ret = 0;
int lost = 0;
for (auto const& digit : digits) {
// if class mask => inps
for (int i = 0; i < digit.CTPClassMask.size(); i++) {
if (digit.CTPClassMask[i]) {
const CTPClass* cls = mCTPConfig.getCTPClassFromHWIndex(i);
uint64_t clsinpmask = cls->descriptor->getInputsMask();
uint64_t diginpmask = digit.CTPInputMask.to_ullong();
if (!((clsinpmask & diginpmask) == clsinpmask)) {
LOG(error) << "CTP class:" << cls->name << " inpmask:" << clsinpmask << " not compatible with inputs mask:" << diginpmask;
ret = 128;
}
}
}
// if inps => class mask
for (auto const& cls : mCTPConfig.getCTPClasses()) {
uint64_t clsinpmask = cls.descriptor->getInputsMask();
uint64_t diginpmask = digit.CTPInputMask.to_ullong();
uint64_t digclsmask = digit.CTPClassMask.to_ullong();
if ((clsinpmask & diginpmask) == clsinpmask) {
if ((cls.classMask & digclsmask) == 0) {
int32_t BCShiftCorrection = -o2::ctp::TriggerOffsetsParam::Instance().customOffset[o2::detectors::DetID::CTP];
int32_t offset = BCShiftCorrection + o2::ctp::TriggerOffsetsParam::Instance().LM_L0 + o2::ctp::TriggerOffsetsParam::Instance().L0_L1_classes - 1;
offset = o2::constants::lhc::LHCMaxBunches - offset;
if (digit.intRecord.bc < offset) {
LOG(error) << "CTP class:" << cls.name << " inpmask:" << clsinpmask << " cls mask:" << cls.classMask << " not found in digit:" << digit;
ret = 256;
} else {
lost++;
}
}
}
}
}
if (lost) {
LOG(info) << "LOST classes because of shift:" << lost;
}
return ret;
}
//
int RawDataDecoder::setLumiInp(int lumiinp, std::string inp)
Expand Down
9 changes: 5 additions & 4 deletions Detectors/CTP/workflowScalers/src/ctp-ccdb-orbit.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ int main(int argc, char** argv)
std::cerr << e.what() << ", application will now exit" << std::endl;
exit(2);
}
int ret = 0;
std::string action = vm["action"].as<std::string>();
std::vector<int64_t> vect;
std::string ccdbPath;
Expand Down Expand Up @@ -120,10 +121,10 @@ int main(int argc, char** argv)
int64_t runnum = vm["run-number"].as<int64_t>();
metadata["runNumber"] = std::to_string(runnum);
std::cout << "Storing:" << ccdbPath << " " << metadata["runNumber"] << " tmin:" << tmin << " tmax:" << tmax << " ts:" << tt << std::endl;
api.storeAsTFileAny(&(vect), ccdbPath, metadata, tmin, tmax);
ret = api.storeAsTFileAny(&(vect), ccdbPath, metadata, tmin, tmax);
} else {
std::cout << "Storing:" << ccdbPath << " tmin:" << tmin << " tmax:" << tmax << " ts:" << tt << std::endl;
api.storeAsTFileAny(&(vect), ccdbPath, metadata, tmin, tmax);
ret = api.storeAsTFileAny(&(vect), ccdbPath, metadata, tmin, tmax);
}
}
//
Expand All @@ -132,7 +133,7 @@ int main(int argc, char** argv)
TFile* f = TFile::Open(file.c_str(), "RECREATE");
if (f == nullptr) {
std::cout << "Error: File" << file << " could not be open for writing !!!" << std::endl;
return 1;
ret++;
} else {
std::cout << "File" << file << " being writen." << std::endl;
f->WriteObject(&vect, "ccdb_object");
Expand All @@ -141,5 +142,5 @@ int main(int argc, char** argv)
} else {
std::cout << "No file created" << std::endl;
}
return 0;
return ret;
}