From 90669289cf5b0c27e4a57e8996823acf526aeefd Mon Sep 17 00:00:00 2001 From: Roman Lietava Date: Fri, 2 May 2025 14:50:00 +0200 Subject: [PATCH 1/8] dev: checkConsistency and ctp.cfg --- .../include/DataFormatsCTP/Configuration.h | 12 ++++ .../Detectors/CTP/src/Configuration.cxx | 49 ++++++++++++++++ .../CTPReconstruction/RawDataDecoder.h | 7 ++- .../CTP/reconstruction/src/RawDataDecoder.cxx | 57 +++++-------------- Detectors/CTP/workflow/src/RawDecoderSpec.cxx | 4 +- Detectors/CTP/workflowScalers/CMakeLists.txt | 3 +- .../include/CTPWorkflowScalers/RunManager.h | 2 + .../CTPWorkflowScalers/ctpCCDBManager.h | 4 +- .../CTP/workflowScalers/src/RunManager.cxx | 5 +- .../workflowScalers/src/ctpCCDBManager.cxx | 28 +++++++++ 10 files changed, 122 insertions(+), 49 deletions(-) diff --git a/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h index 4ff0256f33827..54fef59f591b7 100644 --- a/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h +++ b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h @@ -173,6 +173,7 @@ class CTPConfiguration uint64_t getDecrtiptorInputsMask(const std::string& name) const; std::map> getDet2InputMap(); uint64_t getTriggerClassMask() const; + uint64_t getTriggerClassMaskOnlywInputs() const; std::vector getTriggerClassList() const; uint32_t getRunNumber() { return mRunNumber; }; std::vector getDetectorList() const; @@ -203,6 +204,17 @@ class CTPConfiguration std::ostream& operator<<(std::ostream& in, const CTPConfiguration& conf); +struct CtpCfg +{ + CtpCfg() = default; + std::string filename = "/home/alice/trigger/DBCTP/ctp.cfg"; + CtpCfg readAndSave(); + uint32_t TFOrbits = 0; + int ccdb = -1; // -1 means def constructor was called + uint32_t orbitShift = 0; + uint32_t irInputs_1_24 = 0; + uint32_t irInputs_25_48 = 0; +}; } // namespace ctp } // namespace o2 #endif //_CTP_CONFIGURATION_H_ diff --git a/DataFormats/Detectors/CTP/src/Configuration.cxx b/DataFormats/Detectors/CTP/src/Configuration.cxx index 03f9b38db0e9f..975f96bf0a06f 100644 --- a/DataFormats/Detectors/CTP/src/Configuration.cxx +++ b/DataFormats/Detectors/CTP/src/Configuration.cxx @@ -905,6 +905,17 @@ uint64_t CTPConfiguration::getTriggerClassMask() const } return clsmask; } +uint64_t CTPConfiguration::getTriggerClassMaskOnlywInputs() const +{ + uint64_t clsmask = 0; + for (auto const& cls : mCTPClasses) { + if( cls.name.find("TRUE") != std::string::npos) { // ignoring internal ctp generators + continue; + } + clsmask |= cls.classMask; + } + return clsmask; +} // Hardware positions of classes std::vector CTPConfiguration::getTriggerClassList() const { @@ -1153,6 +1164,44 @@ int CTPInputsConfiguration::getInputIndexFromName(std::string& name) return 0xff; } +CtpCfg CtpCfg::readAndSave() +{ + std::ifstream ctpcfg(filename); + if (ctpcfg.is_open()) { + std::string line; + while (std::getline(ctpcfg, line)) { + o2::utils::Str::trim(line); + if (line.size() == 0) { + continue; + } + if (line[0] == '#') { + continue; + } + std::vector tokens = o2::utils::Str::tokenize(line, ' '); + size_t ntokens = tokens.size(); + if(ntokens < 2) { + LOG(warn) << "Not enough tokens"; + return *this; + } + if(tokens[0].find("TForbits") != std::string::npos) { + TFOrbits = std::atol(tokens[1].c_str()); + } else if(tokens[0].find("ccdb") != std::string::npos) { + ccdb = std::atoi(tokens[1].c_str()); + } else if(tokens[0].find("orbitshift") != std::string::npos) { + orbitShift = std::atol(tokens[1].c_str()); + } else if(tokens[0].find("ir_inputs") != std::string::npos){ + irInputs_1_24 = std::stoul(tokens[1].c_str(), nullptr, 16); + irInputs_25_48 = std::stoul(tokens[2].c_str(), nullptr, 16); + } else { + LOG(warn) << " Token not found:" << tokens[0]; + } + } + } else { + LOG(warn) << "Can not open file:" << filename; + } + return *this; +} + std::ostream& o2::ctp::operator<<(std::ostream& in, const o2::ctp::CTPConfiguration& conf) { conf.printStream(in); diff --git a/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h b/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h index 7579e9dc1d6f5..a3c3ac5a42e80 100644 --- a/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h +++ b/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h @@ -56,7 +56,8 @@ class RawDataDecoder static int shiftNew(const o2::InteractionRecord& irin, uint32_t TFOrbit, std::bitset<48>& inpmask, int64_t shift, int level, std::map& digmap); static int shiftInputs(std::map& digitsMap, o2::pmr::vector& digits, uint32_t TFOrbit, uint64_t trgclassmask = 0xffffffffffffffff); int checkReadoutConsistentncy(o2::pmr::vector& digits, uint64_t trgclassmask = 0xffffffffffffffff); - + std::map getClassErrors() {return mClassErrors; } + std::map getInpError() { return mInpErrors; } private: static constexpr uint32_t TF_TRIGGERTYPE_MASK = 0x800; static constexpr uint32_t HB_TRIGGERTYPE_MASK = 0x2; @@ -83,8 +84,10 @@ class RawDataDecoder // error verbosness int mErrorIR = 0; int mErrorTCR = 0; - int mErrorMax = 3; + int mErrorMax = 5; bool mStickyError = false; + std::map mClassErrors; + std::map mInpErrors; CTPConfiguration mCTPConfig; }; } // namespace ctp diff --git a/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx b/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx index fa7fd673c7e85..9ce773fe9a1ff 100644 --- a/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx +++ b/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx @@ -295,7 +295,7 @@ int RawDataDecoder::decodeRaw(o2::framework::InputRecord& inputs, std::vector& digitsMap, o2::pmr::vector& digits, uint32_t TFOrbit, uint64_t trgclassmask) { // int nClasswoInp = 0; // counting classes without input which should never happen - int nLM = 0; - int nL0 = 0; - int nL1 = 0; - int nTwI = 0; - int nTwoI = 0; - int nTwoIlost = 0; std::map digitsMapShifted; auto L0shift = o2::ctp::TriggerOffsetsParam::Instance().LM_L0; auto L1shift = L0shift + o2::ctp::TriggerOffsetsParam::Instance().L0_L1; @@ -593,60 +587,35 @@ int RawDataDecoder::shiftInputs(std::map& digit } } for (auto const& dig : digitsMapShifted) { - auto d = dig.second; - if ((d.CTPInputMask & LMMASKInputs).count()) { - nLM++; - } - if ((d.CTPInputMask & L0MASKInputs).count()) { - nL0++; - } - if ((d.CTPInputMask & L1MASKInputs).count()) { - nL1++; - } - if ((d.CTPClassMask).to_ulong() & trgclassmask) { - if (d.CTPInputMask.count()) { - nTwI++; - } else { - if (d.intRecord.bc == (o2::constants::lhc::LHCMaxBunches - L1shift)) { // input can be lost because latency class-l1input = 1 - nTwoIlost++; - } else { - // LOG(error) << d.intRecord << " " << d.CTPClassMask << " " << d.CTPInputMask; - // std::cout << "ERROR:" << std::hex << d.CTPClassMask << " " << d.CTPInputMask << std::dec << std::endl; - nTwoI++; - } - } - } 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 ret; + return 0; } // int RawDataDecoder::checkReadoutConsistentncy(o2::pmr::vector& digits, uint64_t trgclassmask) { int ret = 0; int lost = 0; + static int nerror = 0; for (auto const& digit : digits) { // if class mask => inps for (int i = 0; i < digit.CTPClassMask.size(); i++) { if (digit.CTPClassMask[i] & trgclassmask) { const CTPClass* cls = mCTPConfig.getCTPClassFromHWIndex(i); if (cls == nullptr) { - LOG(error) << "Class mask index not found in CTP config:" << i; + if(nerror < mErrorMax) + LOG(error) << "Class mask index not found in CTP config:" << i; ret = 128; continue; } 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; + if(nerror < mErrorMax) + LOG(error) << "CTP class:" << cls->name << " inpmask:" << clsinpmask << " not compatible with inputs mask:" << diginpmask; + auto result = mClassErrors.insert({cls->getIndex(),1}); + if(!result.second) + mClassErrors[cls->getIndex()]++; ret = 128; } } @@ -662,7 +631,11 @@ int RawDataDecoder::checkReadoutConsistentncy(o2::pmr::vector& digits, 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; + if(nerror < mErrorMax) + LOG(error) << "CTP class:" << cls.name << " inpmask:" << clsinpmask << " cls mask:" << cls.classMask << " not found in digit:" << digit; + auto result = mInpErrors.insert({diginpmask,1}); + if(!result.second) + mInpErrors[diginpmask]++; ret = 256; } else { lost++; diff --git a/Detectors/CTP/workflow/src/RawDecoderSpec.cxx b/Detectors/CTP/workflow/src/RawDecoderSpec.cxx index 753f88114a14b..448598d44cfd6 100644 --- a/Detectors/CTP/workflow/src/RawDecoderSpec.cxx +++ b/Detectors/CTP/workflow/src/RawDecoderSpec.cxx @@ -69,8 +69,8 @@ void RawDecoderSpec::endOfStream(framework::EndOfStreamContext& ec) o0 = TFOrbits[i]; } std::cout << std::endl; - std::cout << "Number of missing TF:" << nmiss << std::endl; - std::cout << "# of IR errors:" << mDecoder.getErrorIR() << " TCR errors:" << mDecoder.getErrorTCR() << std::endl; + LOG(info) << "Number of missing TF:" << nmiss << std::endl; + LOG(info) << "# of IR errors:" << mDecoder.getErrorIR() << " TCR errors:" << mDecoder.getErrorTCR() << std::endl; } void RawDecoderSpec::run(framework::ProcessingContext& ctx) { diff --git a/Detectors/CTP/workflowScalers/CMakeLists.txt b/Detectors/CTP/workflowScalers/CMakeLists.txt index a31774ac66d69..666c76a9ad397 100644 --- a/Detectors/CTP/workflowScalers/CMakeLists.txt +++ b/Detectors/CTP/workflowScalers/CMakeLists.txt @@ -13,7 +13,8 @@ o2_add_library(CTPWorkflowScalers SOURCES src/RunManager.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DataFormatsCTP - AliceO2::BookkeepingApi) + AliceO2::BookkeepingApi + AliceO2::InfoLogger) o2_target_root_dictionary(CTPWorkflowScalers HEADERS include/CTPWorkflowScalers/ctpCCDBManager.h) o2_add_executable( diff --git a/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/RunManager.h b/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/RunManager.h index 72fb9c2056367..d988c09ef9639 100644 --- a/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/RunManager.h +++ b/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/RunManager.h @@ -18,6 +18,7 @@ #include "DataFormatsCTP/Configuration.h" #include "BookkeepingApi/BkpClientFactory.h" #include "BookkeepingApi/BkpClient.h" +#include using namespace o2::bkp::api; namespace o2 @@ -72,6 +73,7 @@ class CTPRunManager : public ctpCCDBManager int mEOX = 0; // redundancy check int mNew = 1; // 1 - no CCDB: used for QC int mQCWritePeriod = 3; // Time in 10secs between two writes to QCCD + AliceO2::InfoLogger::InfoLogger mInfoLogger; ClassDefNV(CTPRunManager, 7); }; } // namespace ctp diff --git a/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/ctpCCDBManager.h b/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/ctpCCDBManager.h index c968a83183624..402c09cf8b73a 100644 --- a/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/ctpCCDBManager.h +++ b/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/ctpCCDBManager.h @@ -29,6 +29,7 @@ class ctpCCDBManager int saveRunConfigToCCDB(CTPConfiguration* cfg, long timeStart); int saveSoxOrbit(uint32_t runNumber, uint32_t soxOrbit, long timeStart); int saveOrbitReset(long timeStamp); + int saveCtpCfg(uint32_t runNumber, long timeStamp); static CTPConfiguration getConfigFromCCDB(long timestamp, std::string run, bool& ok); static CTPConfiguration getConfigFromCCDB(long timestamp, std::string run); CTPRunScalers getScalersFromCCDB(long timestamp, std::string, bool& ok); @@ -46,7 +47,8 @@ class ctpCCDBManager const std::string mQCDBPathCTPScalers = "qc/CTP/Scalers"; const std::string mCCDBPathSoxOrbit = "CTP/Calib/FirstRunOrbit"; const std::string mCCDBPathOrbitReset = "CTP/Calib/OrbitReset"; - ClassDefNV(ctpCCDBManager, 1); + const std::string mCCDBPathCtpCfg = "CTP/Config/CtpCfg"; + ClassDefNV(ctpCCDBManager, 2); }; } // namespace ctp } // namespace o2 diff --git a/Detectors/CTP/workflowScalers/src/RunManager.cxx b/Detectors/CTP/workflowScalers/src/RunManager.cxx index 5d0b906e28088..254d9706259f4 100644 --- a/Detectors/CTP/workflowScalers/src/RunManager.cxx +++ b/Detectors/CTP/workflowScalers/src/RunManager.cxx @@ -122,7 +122,7 @@ int CTPRunManager::loadRun(const std::string& cfg) // mRunsLoaded[runnumber] = activerun; saveRunConfigToCCDB(&activerun->cfg, timeStamp); - + saveCtpCfg(runnumber, timeStamp); return 0; } int CTPRunManager::setRunConfigBK(uint32_t runNumber, const std::string& cfg) @@ -221,6 +221,9 @@ int CTPRunManager::addScalers(uint32_t irun, std::time_t time, bool start) int CTPRunManager::processMessage(std::string& topic, const std::string& message) { LOG(info) << "Processing message with topic:" << topic; + std::string ahoj = "ahoj kniznica"; + mInfoLogger.logInfo(ahoj); + LOG(important) << " ahoj important"; std::string firstcounters; if (topic.find("clear") != std::string::npos) { mRunsLoaded.clear(); diff --git a/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx b/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx index cbe8fe5dd675f..18f85abf30b2a 100644 --- a/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx +++ b/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx @@ -167,6 +167,34 @@ int ctpCCDBManager::saveOrbitReset(long timeStamp) } return 0; } +int ctpCCDBManager::saveCtpCfg(uint32_t runNumber, long timeStart) +{ + if (mCCDBHost == "none") { + LOG(info) << "CtpCfg not written to CCDB none"; + return 0; + } + CtpCfg ctpcfg; + ctpcfg.readAndSave(); + using namespace std::chrono_literals; + std::chrono::seconds days3 = 259200s; + std::chrono::seconds min10 = 600s; + long time3days = std::chrono::duration_cast(days3).count(); + long time10min = std::chrono::duration_cast(min10).count(); + long tmin = timeStart - time10min; + long tmax = timeStart + time3days; + o2::ccdb::CcdbApi api; + map metadata; // can be empty + metadata["runNumber"] = std::to_string(runNumber); + api.init(mCCDBHost.c_str()); // or http://localhost:8080 for a local installation + // store abitrary user object in strongly typed manner + int ret = 0; //api.storeAsTFileAny(&vect, mCCDBPathCtpCfg, metadata, tmin, tmax); + if (ret == 0) { + LOG(info) << "CtpCfg saved in ccdb:" << mCCDBHost << " tmin:" << tmin << " tmax:" << tmax; + } else { + LOG(error) << "CtpCfg Problem writing to database ret:" << ret; + } + return 0; +} CTPConfiguration ctpCCDBManager::getConfigFromCCDB(long timestamp, std::string run, bool& ok) { auto& mgr = o2::ccdb::BasicCCDBManager::instance(); From 77c3b989cd711d97e811840f4d6301f65dcf8138 Mon Sep 17 00:00:00 2001 From: Roman Lietava Date: Sat, 3 May 2025 11:38:30 +0200 Subject: [PATCH 2/8] dev: consistency checker --- .../include/DataFormatsCTP/Configuration.h | 3 +- .../Detectors/CTP/src/Configuration.cxx | 15 +++++++++- .../CTPReconstruction/RawDataDecoder.h | 16 ++++++---- .../CTP/reconstruction/src/RawDataDecoder.cxx | 30 +++++++++---------- Detectors/CTP/workflow/src/RawDecoderSpec.cxx | 9 ++++++ Detectors/CTP/workflowScalers/CMakeLists.txt | 3 +- .../include/CTPWorkflowScalers/RunManager.h | 2 -- .../CTP/workflowScalers/src/RunManager.cxx | 3 -- 8 files changed, 51 insertions(+), 30 deletions(-) diff --git a/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h index 54fef59f591b7..2cdab2f4e0596 100644 --- a/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h +++ b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h @@ -173,7 +173,8 @@ class CTPConfiguration uint64_t getDecrtiptorInputsMask(const std::string& name) const; std::map> getDet2InputMap(); uint64_t getTriggerClassMask() const; - uint64_t getTriggerClassMaskOnlywInputs() const; + uint64_t getTriggerClassMaskWInputs() const; + uint64_t getTriggerClassMaskWInputsNoTrgDets() const; std::vector getTriggerClassList() const; uint32_t getRunNumber() { return mRunNumber; }; std::vector getDetectorList() const; diff --git a/DataFormats/Detectors/CTP/src/Configuration.cxx b/DataFormats/Detectors/CTP/src/Configuration.cxx index 975f96bf0a06f..a7f8f3c0fef24 100644 --- a/DataFormats/Detectors/CTP/src/Configuration.cxx +++ b/DataFormats/Detectors/CTP/src/Configuration.cxx @@ -905,7 +905,7 @@ uint64_t CTPConfiguration::getTriggerClassMask() const } return clsmask; } -uint64_t CTPConfiguration::getTriggerClassMaskOnlywInputs() const +uint64_t CTPConfiguration::getTriggerClassMaskWInputs() const { uint64_t clsmask = 0; for (auto const& cls : mCTPClasses) { @@ -916,6 +916,19 @@ uint64_t CTPConfiguration::getTriggerClassMaskOnlywInputs() const } return clsmask; } +uint64_t CTPConfiguration::getTriggerClassMaskWInputsNoTrgDets() const +{ + uint64_t clsmask = 0; + for (auto const& cls : mCTPClasses) { + bool exclude = cls.name.find("TRUE") != std::string::npos; // ignoring internal ctp generators + 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) + clsmask |= cls.classMask; + } + return clsmask; +} // Hardware positions of classes std::vector CTPConfiguration::getTriggerClassList() const { diff --git a/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h b/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h index a3c3ac5a42e80..ebe2384aa1082 100644 --- a/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h +++ b/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h @@ -55,9 +55,12 @@ 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& digmap); static int shiftInputs(std::map& digitsMap, o2::pmr::vector& digits, uint32_t TFOrbit, uint64_t trgclassmask = 0xffffffffffffffff); - int checkReadoutConsistentncy(o2::pmr::vector& digits, uint64_t trgclassmask = 0xffffffffffffffff); - std::map getClassErrors() {return mClassErrors; } - std::map getInpError() { return mInpErrors; } + int checkReadoutConsistentncy(o2::pmr::vector& digits, uint64_t trgclassmask = 0xffffffffffffffff, uint64_t trigclassmaskNoTrgDets = 0xffffffffffffffff); + std::array getClassErrorsA() {return mClassErrorsA; } + std::array getClassErrorsB() { return mClassErrorsB; } + std::array getClassCountersA() {return mClassCountersA; } + std::array getClassCountersB() { return mClassCountersB; } + int getLostDueToShift() { return mLostDueToShift; } private: static constexpr uint32_t TF_TRIGGERTYPE_MASK = 0x800; static constexpr uint32_t HB_TRIGGERTYPE_MASK = 0x2; @@ -86,8 +89,11 @@ class RawDataDecoder int mErrorTCR = 0; int mErrorMax = 5; bool mStickyError = false; - std::map mClassErrors; - std::map mInpErrors; + std::array mClassErrorsA; + std::array mClassErrorsB; // from inputs + std::array mClassCountersA; + std::array mClassCountersB; // from inputs + int mLostDueToShift = 0; CTPConfiguration mCTPConfig; }; } // namespace ctp diff --git a/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx b/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx index 9ce773fe9a1ff..cc15afec5225d 100644 --- a/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx +++ b/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx @@ -294,13 +294,15 @@ int RawDataDecoder::decodeRaw(o2::framework::InputRecord& inputs, std::vector& digit return 0; } // -int RawDataDecoder::checkReadoutConsistentncy(o2::pmr::vector& digits, uint64_t trgclassmask) +int RawDataDecoder::checkReadoutConsistentncy(o2::pmr::vector& digits, uint64_t trgclassmask, uint64_t trgclassmaskNoTrgDet) { int ret = 0; - int lost = 0; static int nerror = 0; for (auto const& digit : digits) { // if class mask => inps @@ -608,21 +609,20 @@ int RawDataDecoder::checkReadoutConsistentncy(o2::pmr::vector& digits, ret = 128; continue; } + mClassCountersA[i]++; uint64_t clsinpmask = cls->descriptor->getInputsMask(); uint64_t diginpmask = digit.CTPInputMask.to_ullong(); if (!((clsinpmask & diginpmask) == clsinpmask)) { if(nerror < mErrorMax) LOG(error) << "CTP class:" << cls->name << " inpmask:" << clsinpmask << " not compatible with inputs mask:" << diginpmask; - auto result = mClassErrors.insert({cls->getIndex(),1}); - if(!result.second) - mClassErrors[cls->getIndex()]++; + mClassErrorsA[i]++; ret = 128; } } } // if inps => class mask for (auto const& cls : mCTPConfig.getCTPClasses()) { - uint64_t clsinpmask = cls.descriptor->getInputsMask(); + uint64_t clsinpmask = cls.descriptor->getInputsMask(); // class definition uint64_t diginpmask = digit.CTPInputMask.to_ullong(); uint64_t digclsmask = digit.CTPClassMask.to_ullong(); if ((clsinpmask & diginpmask) == clsinpmask) { @@ -631,21 +631,19 @@ int RawDataDecoder::checkReadoutConsistentncy(o2::pmr::vector& digits, 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) { - if(nerror < mErrorMax) + if((nerror < mErrorMax) && (cls.classMask & ~trgclassmaskNoTrgDet)) LOG(error) << "CTP class:" << cls.name << " inpmask:" << clsinpmask << " cls mask:" << cls.classMask << " not found in digit:" << digit; - auto result = mInpErrors.insert({diginpmask,1}); - if(!result.second) - mInpErrors[diginpmask]++; + mClassErrorsB[cls.getIndex()]++; ret = 256; } else { - lost++; + mLostDueToShift++; } } } } } - if (lost) { - LOG(info) << "LOST classes because of shift:" << lost; + if (mLostDueToShift) { + LOG(debug) << "LOST classes because of shift:" << mLostDueToShift; } return ret; } diff --git a/Detectors/CTP/workflow/src/RawDecoderSpec.cxx b/Detectors/CTP/workflow/src/RawDecoderSpec.cxx index 448598d44cfd6..4c08d8192f23d 100644 --- a/Detectors/CTP/workflow/src/RawDecoderSpec.cxx +++ b/Detectors/CTP/workflow/src/RawDecoderSpec.cxx @@ -71,6 +71,15 @@ void RawDecoderSpec::endOfStream(framework::EndOfStreamContext& ec) std::cout << std::endl; LOG(info) << "Number of missing TF:" << nmiss << std::endl; LOG(info) << "# of IR errors:" << mDecoder.getErrorIR() << " TCR errors:" << mDecoder.getErrorTCR() << std::endl; + std::array clsA = mDecoder.getClassCountersA(); + std::array clsB = mDecoder.getClassCountersB(); + std::array clsEA = mDecoder.getClassErrorsA(); + std::array 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; + LOG(important) << "CLASS:" << i << " A:" << clsA[i] << " B:" << clsB[i] << " EA:" << clsEA[i] << " EB:" << clsEB[i]; + } } void RawDecoderSpec::run(framework::ProcessingContext& ctx) { diff --git a/Detectors/CTP/workflowScalers/CMakeLists.txt b/Detectors/CTP/workflowScalers/CMakeLists.txt index 666c76a9ad397..a31774ac66d69 100644 --- a/Detectors/CTP/workflowScalers/CMakeLists.txt +++ b/Detectors/CTP/workflowScalers/CMakeLists.txt @@ -13,8 +13,7 @@ o2_add_library(CTPWorkflowScalers SOURCES src/RunManager.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DataFormatsCTP - AliceO2::BookkeepingApi - AliceO2::InfoLogger) + AliceO2::BookkeepingApi) o2_target_root_dictionary(CTPWorkflowScalers HEADERS include/CTPWorkflowScalers/ctpCCDBManager.h) o2_add_executable( diff --git a/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/RunManager.h b/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/RunManager.h index d988c09ef9639..72fb9c2056367 100644 --- a/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/RunManager.h +++ b/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/RunManager.h @@ -18,7 +18,6 @@ #include "DataFormatsCTP/Configuration.h" #include "BookkeepingApi/BkpClientFactory.h" #include "BookkeepingApi/BkpClient.h" -#include using namespace o2::bkp::api; namespace o2 @@ -73,7 +72,6 @@ class CTPRunManager : public ctpCCDBManager int mEOX = 0; // redundancy check int mNew = 1; // 1 - no CCDB: used for QC int mQCWritePeriod = 3; // Time in 10secs between two writes to QCCD - AliceO2::InfoLogger::InfoLogger mInfoLogger; ClassDefNV(CTPRunManager, 7); }; } // namespace ctp diff --git a/Detectors/CTP/workflowScalers/src/RunManager.cxx b/Detectors/CTP/workflowScalers/src/RunManager.cxx index 254d9706259f4..77010d64aec0d 100644 --- a/Detectors/CTP/workflowScalers/src/RunManager.cxx +++ b/Detectors/CTP/workflowScalers/src/RunManager.cxx @@ -221,9 +221,6 @@ int CTPRunManager::addScalers(uint32_t irun, std::time_t time, bool start) int CTPRunManager::processMessage(std::string& topic, const std::string& message) { LOG(info) << "Processing message with topic:" << topic; - std::string ahoj = "ahoj kniznica"; - mInfoLogger.logInfo(ahoj); - LOG(important) << " ahoj important"; std::string firstcounters; if (topic.find("clear") != std::string::npos) { mRunsLoaded.clear(); From 2b16b658c589daf6d13e7086e8839e9940f1c9f2 Mon Sep 17 00:00:00 2001 From: lietava Date: Mon, 5 May 2025 11:30:04 +0200 Subject: [PATCH 3/8] dev:ctpcfg to CCDB --- .../include/DataFormatsCTP/Configuration.h | 5 +- .../Detectors/CTP/src/Configuration.cxx | 4 +- .../Detectors/CTP/src/DataFormatsCTPLinkDef.h | 2 + .../CTPReconstruction/RawDataDecoder.h | 8 +-- .../CTP/reconstruction/src/RawDataDecoder.cxx | 52 +++++++++++++------ Detectors/CTP/workflow/src/RawDecoderSpec.cxx | 8 ++- .../include/CTPWorkflowScalers/RunManager.h | 2 +- .../CTPWorkflowScalers/ctpCCDBManager.h | 3 ++ .../CTP/workflowScalers/src/RunManager.cxx | 6 ++- .../CTP/workflowScalers/src/ctp-proxy.cxx | 7 ++- .../workflowScalers/src/ctpCCDBManager.cxx | 4 +- 11 files changed, 67 insertions(+), 34 deletions(-) diff --git a/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h index 2cdab2f4e0596..24e8701069a96 100644 --- a/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h +++ b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h @@ -208,13 +208,14 @@ std::ostream& operator<<(std::ostream& in, const CTPConfiguration& conf); struct CtpCfg { CtpCfg() = default; - std::string filename = "/home/alice/trigger/DBCTP/ctp.cfg"; - CtpCfg readAndSave(); + std::string filename = "ctp.cfg"; + CtpCfg readAndSave(std::string& path); uint32_t TFOrbits = 0; int ccdb = -1; // -1 means def constructor was called uint32_t orbitShift = 0; uint32_t irInputs_1_24 = 0; uint32_t irInputs_25_48 = 0; + ClassDefNV(CtpCfg, 1) }; } // namespace ctp } // namespace o2 diff --git a/DataFormats/Detectors/CTP/src/Configuration.cxx b/DataFormats/Detectors/CTP/src/Configuration.cxx index a7f8f3c0fef24..944b25ab24e34 100644 --- a/DataFormats/Detectors/CTP/src/Configuration.cxx +++ b/DataFormats/Detectors/CTP/src/Configuration.cxx @@ -1177,9 +1177,9 @@ int CTPInputsConfiguration::getInputIndexFromName(std::string& name) return 0xff; } -CtpCfg CtpCfg::readAndSave() +CtpCfg CtpCfg::readAndSave(std::string& path) { - std::ifstream ctpcfg(filename); + std::ifstream ctpcfg(path+filename); if (ctpcfg.is_open()) { std::string line; while (std::getline(ctpcfg, line)) { diff --git a/DataFormats/Detectors/CTP/src/DataFormatsCTPLinkDef.h b/DataFormats/Detectors/CTP/src/DataFormatsCTPLinkDef.h index da21f779723f8..14bff1ba1950b 100644 --- a/DataFormats/Detectors/CTP/src/DataFormatsCTPLinkDef.h +++ b/DataFormats/Detectors/CTP/src/DataFormatsCTPLinkDef.h @@ -55,4 +55,6 @@ #pragma link C++ class o2::ctp::TriggerOffsetsParam + ; #pragma link C++ class o2::conf::ConfigurableParamHelper < o2::ctp::TriggerOffsetsParam> + ; +#pragma link C++ class o2::ctp::CtpCfg +; + #endif diff --git a/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h b/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h index ebe2384aa1082..230e0caf8a7ae 100644 --- a/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h +++ b/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h @@ -89,10 +89,10 @@ class RawDataDecoder int mErrorTCR = 0; int mErrorMax = 5; bool mStickyError = false; - std::array mClassErrorsA; - std::array mClassErrorsB; // from inputs - std::array mClassCountersA; - std::array mClassCountersB; // from inputs + std::array mClassErrorsA{}; + std::array mClassErrorsB{}; // from inputs + std::array mClassCountersA{}; + std::array mClassCountersB{}; // from inputs int mLostDueToShift = 0; CTPConfiguration mCTPConfig; }; diff --git a/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx b/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx index cc15afec5225d..1ab626a3d09ab 100644 --- a/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx +++ b/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx @@ -298,10 +298,12 @@ int RawDataDecoder::decodeRaw(o2::framework::InputRecord& inputs, std::vector& digit // int RawDataDecoder::checkReadoutConsistentncy(o2::pmr::vector& digits, uint64_t trgclassmask, uint64_t trgclassmaskNoTrgDet) { + LOG(debug) << "Checking readout"; int ret = 0; static int nerror = 0; for (auto const& digit : digits) { // if class mask => inps for (int i = 0; i < digit.CTPClassMask.size(); i++) { - if (digit.CTPClassMask[i] & trgclassmask) { + bool trgcls = trgclassmask & (1ull << i); + if (digit.CTPClassMask[i] & trgcls) { const CTPClass* cls = mCTPConfig.getCTPClassFromHWIndex(i); if (cls == nullptr) { - if(nerror < mErrorMax) + if(nerror < mErrorMax) { LOG(error) << "Class mask index not found in CTP config:" << i; + nerror++; + } ret = 128; continue; } mClassCountersA[i]++; + if( cls->descriptor == nullptr) + continue; uint64_t clsinpmask = cls->descriptor->getInputsMask(); uint64_t diginpmask = digit.CTPInputMask.to_ullong(); if (!((clsinpmask & diginpmask) == clsinpmask)) { - if(nerror < mErrorMax) - LOG(error) << "CTP class:" << cls->name << " inpmask:" << clsinpmask << " not compatible with inputs mask:" << diginpmask; + if(nerror < mErrorMax) { + LOG(error) << "Cls=>Inps: CTP class:" << cls->name << " inpmask:" << clsinpmask << " not compatible with inputs mask:" << diginpmask; + nerror++; + } mClassErrorsA[i]++; ret = 128; } @@ -622,21 +632,29 @@ int RawDataDecoder::checkReadoutConsistentncy(o2::pmr::vector& digits, } // if inps => class mask for (auto const& cls : mCTPConfig.getCTPClasses()) { + //cls.printStream(std::cout); + if(cls.descriptor == nullptr) + continue; uint64_t clsinpmask = cls.descriptor->getInputsMask(); // class definition 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) { - if((nerror < mErrorMax) && (cls.classMask & ~trgclassmaskNoTrgDet)) - LOG(error) << "CTP class:" << cls.name << " inpmask:" << clsinpmask << " cls mask:" << cls.classMask << " not found in digit:" << digit; - mClassErrorsB[cls.getIndex()]++; - ret = 256; - } else { - mLostDueToShift++; + if(cls.classMask & trgclassmask) { + mClassCountersB[cls.getIndex()]++; + 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) { + if((nerror < mErrorMax) && (cls.classMask & ~trgclassmaskNoTrgDet)){ + LOG(info) << "Inp=>Cls: CTP class:" << cls.name << " inpmask:" << clsinpmask << " cls mask:" << cls.classMask << " not found in digit:" << digit; + nerror++; + } + mClassErrorsB[cls.getIndex()]++; + ret = 256; + } else { + mLostDueToShift++; + } } } } diff --git a/Detectors/CTP/workflow/src/RawDecoderSpec.cxx b/Detectors/CTP/workflow/src/RawDecoderSpec.cxx index 4c08d8192f23d..6b5d99ee5d78f 100644 --- a/Detectors/CTP/workflow/src/RawDecoderSpec.cxx +++ b/Detectors/CTP/workflow/src/RawDecoderSpec.cxx @@ -69,8 +69,10 @@ 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; - LOG(info) << "# of IR errors:" << mDecoder.getErrorIR() << " TCR errors:" << mDecoder.getErrorTCR() << std::endl; + if(mDecoder.getErrorIR() || mDecoder.getErrorTCR()) + LOG(error) << "# of IR errors:" << mDecoder.getErrorIR() << " TCR errors:" << mDecoder.getErrorTCR() << std::endl; std::array clsA = mDecoder.getClassCountersA(); std::array clsB = mDecoder.getClassCountersB(); std::array clsEA = mDecoder.getClassErrorsA(); @@ -78,7 +80,9 @@ void RawDecoderSpec::endOfStream(framework::EndOfStreamContext& ec) for(int i = 0; i < o2::ctp::CTP_NCLASSES; i ++){ bool print = clsA[i] > 0 || clsB[i] > 0 || clsEA[i] > 0 || clsEB[i] > 0; - LOG(important) << "CLASS:" << i << " A:" << clsA[i] << " B:" << clsB[i] << " EA:" << clsEA[i] << " EB:" << clsEB[i]; + if(clsEA[i]) + LOG(error) << " Class without inputs:"; + 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) diff --git a/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/RunManager.h b/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/RunManager.h index 72fb9c2056367..6d2172e3da165 100644 --- a/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/RunManager.h +++ b/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/RunManager.h @@ -72,7 +72,7 @@ class CTPRunManager : public ctpCCDBManager int mEOX = 0; // redundancy check int mNew = 1; // 1 - no CCDB: used for QC int mQCWritePeriod = 3; // Time in 10secs between two writes to QCCD - ClassDefNV(CTPRunManager, 7); + ClassDefNV(CTPRunManager, 8); }; } // namespace ctp } // namespace o2 diff --git a/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/ctpCCDBManager.h b/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/ctpCCDBManager.h index 402c09cf8b73a..4237ad4501fcc 100644 --- a/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/ctpCCDBManager.h +++ b/Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/ctpCCDBManager.h @@ -35,6 +35,7 @@ class ctpCCDBManager CTPRunScalers getScalersFromCCDB(long timestamp, std::string, bool& ok); static void setCCDBHost(std::string host) { mCCDBHost = host; }; static void setQCDBHost(std::string host) { mQCDBHost = host; }; + void setCtpCfgDir(std::string& ctpcfgdir) { mCtpCfgDir = ctpcfgdir; }; protected: /// Database constants @@ -48,6 +49,8 @@ class ctpCCDBManager const std::string mCCDBPathSoxOrbit = "CTP/Calib/FirstRunOrbit"; const std::string mCCDBPathOrbitReset = "CTP/Calib/OrbitReset"; const std::string mCCDBPathCtpCfg = "CTP/Config/CtpCfg"; + std::string mCtpCfgDir; + ClassDefNV(ctpCCDBManager, 2); }; } // namespace ctp diff --git a/Detectors/CTP/workflowScalers/src/RunManager.cxx b/Detectors/CTP/workflowScalers/src/RunManager.cxx index 77010d64aec0d..5b111b65202fa 100644 --- a/Detectors/CTP/workflowScalers/src/RunManager.cxx +++ b/Detectors/CTP/workflowScalers/src/RunManager.cxx @@ -87,6 +87,7 @@ void CTPRunManager::init() LOG(info) << "QCDB writing every:" << mQCWritePeriod << " 10 secs"; LOG(info) << "CCDB host:" << mCCDBHost; LOG(info) << "CTP vNew cfg:" << mNew; + LOG(info) << "ctp.cfg dir:" << mCtpCfgDir; LOG(info) << "CTPRunManager initialised."; } int CTPRunManager::loadRun(const std::string& cfg) @@ -106,7 +107,7 @@ int CTPRunManager::loadRun(const std::string& cfg) timeStamp = (tt * 1000.); LOG(info) << "Timestamp file:" << timeStamp; cfgmod = cfg.substr(pos, cfg.size()); - LOG(info) << "ctpcfg: using ctp time"; + LOG(info) << "ctpconfig: using ctp time"; } } CTPActiveRun* activerun = new CTPActiveRun; @@ -122,7 +123,8 @@ int CTPRunManager::loadRun(const std::string& cfg) // mRunsLoaded[runnumber] = activerun; saveRunConfigToCCDB(&activerun->cfg, timeStamp); - saveCtpCfg(runnumber, timeStamp); + if(mCtpCfgDir != "none") + saveCtpCfg(runnumber, timeStamp); return 0; } int CTPRunManager::setRunConfigBK(uint32_t runNumber, const std::string& cfg) diff --git a/Detectors/CTP/workflowScalers/src/ctp-proxy.cxx b/Detectors/CTP/workflowScalers/src/ctp-proxy.cxx index b2896215d1c6a..f8f8ad3c95fbb 100644 --- a/Detectors/CTP/workflowScalers/src/ctp-proxy.cxx +++ b/Detectors/CTP/workflowScalers/src/ctp-proxy.cxx @@ -46,13 +46,14 @@ #include "BookkeepingApi/BkpClient.h" using namespace o2::framework; using DetID = o2::detectors::DetID; -InjectorFunction dcs2dpl(std::string& ccdbhost, std::string& bkhost, std::string& qchost, int qcwriteperiod) +InjectorFunction dcs2dpl(std::string& ccdbhost, std::string& bkhost, std::string& qchost, int qcwriteperiod, std::string& ctpcfgdir) { auto runMgr = std::make_shared(); runMgr->setCCDBHost(ccdbhost); runMgr->setBKHost(bkhost); runMgr->setQCDBHost(qchost); runMgr->setQCWritePeriod(qcwriteperiod); + runMgr->setCtpCfgDir(ctpcfgdir); runMgr->init(); // runMgr->setClient(client); return [runMgr](TimingInfo&, ServiceRegistryRef const& services, fair::mq::Parts& parts, ChannelRetriever channelRetriever, size_t newTimesliceId, bool& stop) -> bool { @@ -78,6 +79,7 @@ void customize(std::vector& workflowOptions) workflowOptions.push_back(ConfigParamSpec{"ccdb-host", VariantType::String, "http://o2-ccdb.internal:8080", {"ccdb host"}}); workflowOptions.push_back(ConfigParamSpec{"bk-host", VariantType::String, "none", {"bk host"}}); workflowOptions.push_back(ConfigParamSpec{"qc-host", VariantType::String, "none", {"qc host"}}); + workflowOptions.push_back(ConfigParamSpec{"ctpcfg-dir", VariantType::String, "none", {"ctp.cfg file directory"}}); workflowOptions.push_back(ConfigParamSpec{"qc-writeperiod", VariantType::Int, 30, {"Period of writing to QCDB in units of 10secs, default = 30 (5 mins)"}}); } @@ -104,6 +106,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& config) std::string bkhost = config.options().get("bk-host"); std::string qchost = config.options().get("qc-host"); int qcwriteperiod = config.options().get("qc-writeperiod"); + std::string ctpcfgdir = config.options().get("ctpcfg-dir"); if (chan.empty()) { throw std::runtime_error("input channel is not provided"); } @@ -118,7 +121,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& config) std::move(ctpCountersOutputs), // this is just default, can be overriden by --ctp-config-proxy '--channel-config..' chan.c_str(), - dcs2dpl(ccdbhost, bkhost, qchost, qcwriteperiod)); + dcs2dpl(ccdbhost, bkhost, qchost, qcwriteperiod, ctpcfgdir)); ctpProxy.labels.emplace_back(DataProcessorLabel{"input-proxy"}); LOG(info) << "===> Proxy done"; WorkflowSpec workflow; diff --git a/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx b/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx index 18f85abf30b2a..7a1007019fff3 100644 --- a/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx +++ b/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx @@ -174,7 +174,7 @@ int ctpCCDBManager::saveCtpCfg(uint32_t runNumber, long timeStart) return 0; } CtpCfg ctpcfg; - ctpcfg.readAndSave(); + ctpcfg.readAndSave(mCtpCfgDir); using namespace std::chrono_literals; std::chrono::seconds days3 = 259200s; std::chrono::seconds min10 = 600s; @@ -187,7 +187,7 @@ int ctpCCDBManager::saveCtpCfg(uint32_t runNumber, long timeStart) metadata["runNumber"] = std::to_string(runNumber); api.init(mCCDBHost.c_str()); // or http://localhost:8080 for a local installation // store abitrary user object in strongly typed manner - int ret = 0; //api.storeAsTFileAny(&vect, mCCDBPathCtpCfg, metadata, tmin, tmax); + int ret = api.storeAsTFileAny(&ctpcfg, mCCDBPathCtpCfg, metadata, tmin, tmax); if (ret == 0) { LOG(info) << "CtpCfg saved in ccdb:" << mCCDBHost << " tmin:" << tmin << " tmax:" << tmax; } else { From 555994ac8b22c7d36598f8f361897cb5c5690523 Mon Sep 17 00:00:00 2001 From: Roman Lietava Date: Mon, 5 May 2025 11:58:46 +0200 Subject: [PATCH 4/8] clang --- .../include/DataFormatsCTP/Configuration.h | 5 ++-- .../Detectors/CTP/src/Configuration.cxx | 22 ++++++++--------- .../Detectors/CTP/src/DataFormatsCTPLinkDef.h | 2 +- .../CTPReconstruction/RawDataDecoder.h | 17 ++++++------- .../CTP/reconstruction/src/RawDataDecoder.cxx | 24 +++++++++---------- Detectors/CTP/workflow/src/RawDecoderSpec.cxx | 8 +++---- .../CTP/workflowScalers/src/RunManager.cxx | 2 +- .../workflowScalers/src/ctpCCDBManager.cxx | 2 +- 8 files changed, 41 insertions(+), 41 deletions(-) diff --git a/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h index 24e8701069a96..f8d9b7c4dfb23 100644 --- a/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h +++ b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h @@ -205,13 +205,12 @@ class CTPConfiguration std::ostream& operator<<(std::ostream& in, const CTPConfiguration& conf); -struct CtpCfg -{ +struct CtpCfg { CtpCfg() = default; std::string filename = "ctp.cfg"; CtpCfg readAndSave(std::string& path); uint32_t TFOrbits = 0; - int ccdb = -1; // -1 means def constructor was called + int ccdb = -1; // -1 means def constructor was called uint32_t orbitShift = 0; uint32_t irInputs_1_24 = 0; uint32_t irInputs_25_48 = 0; diff --git a/DataFormats/Detectors/CTP/src/Configuration.cxx b/DataFormats/Detectors/CTP/src/Configuration.cxx index 944b25ab24e34..3d07a5c84fb62 100644 --- a/DataFormats/Detectors/CTP/src/Configuration.cxx +++ b/DataFormats/Detectors/CTP/src/Configuration.cxx @@ -909,7 +909,7 @@ uint64_t CTPConfiguration::getTriggerClassMaskWInputs() const { uint64_t clsmask = 0; for (auto const& cls : mCTPClasses) { - if( cls.name.find("TRUE") != std::string::npos) { // ignoring internal ctp generators + if (cls.name.find("TRUE") != std::string::npos) { // ignoring internal ctp generators continue; } clsmask |= cls.classMask; @@ -921,10 +921,10 @@ uint64_t CTPConfiguration::getTriggerClassMaskWInputsNoTrgDets() const uint64_t clsmask = 0; for (auto const& cls : mCTPClasses) { bool exclude = cls.name.find("TRUE") != std::string::npos; // ignoring internal ctp generators - 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) + 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) clsmask |= cls.classMask; } return clsmask; @@ -1179,7 +1179,7 @@ int CTPInputsConfiguration::getInputIndexFromName(std::string& name) CtpCfg CtpCfg::readAndSave(std::string& path) { - std::ifstream ctpcfg(path+filename); + std::ifstream ctpcfg(path + filename); if (ctpcfg.is_open()) { std::string line; while (std::getline(ctpcfg, line)) { @@ -1192,17 +1192,17 @@ CtpCfg CtpCfg::readAndSave(std::string& path) } std::vector tokens = o2::utils::Str::tokenize(line, ' '); size_t ntokens = tokens.size(); - if(ntokens < 2) { + if (ntokens < 2) { LOG(warn) << "Not enough tokens"; return *this; } - if(tokens[0].find("TForbits") != std::string::npos) { + if (tokens[0].find("TForbits") != std::string::npos) { TFOrbits = std::atol(tokens[1].c_str()); - } else if(tokens[0].find("ccdb") != std::string::npos) { + } else if (tokens[0].find("ccdb") != std::string::npos) { ccdb = std::atoi(tokens[1].c_str()); - } else if(tokens[0].find("orbitshift") != std::string::npos) { + } else if (tokens[0].find("orbitshift") != std::string::npos) { orbitShift = std::atol(tokens[1].c_str()); - } else if(tokens[0].find("ir_inputs") != std::string::npos){ + } else if (tokens[0].find("ir_inputs") != std::string::npos) { irInputs_1_24 = std::stoul(tokens[1].c_str(), nullptr, 16); irInputs_25_48 = std::stoul(tokens[2].c_str(), nullptr, 16); } else { diff --git a/DataFormats/Detectors/CTP/src/DataFormatsCTPLinkDef.h b/DataFormats/Detectors/CTP/src/DataFormatsCTPLinkDef.h index 14bff1ba1950b..ac2a83d31edda 100644 --- a/DataFormats/Detectors/CTP/src/DataFormatsCTPLinkDef.h +++ b/DataFormats/Detectors/CTP/src/DataFormatsCTPLinkDef.h @@ -55,6 +55,6 @@ #pragma link C++ class o2::ctp::TriggerOffsetsParam + ; #pragma link C++ class o2::conf::ConfigurableParamHelper < o2::ctp::TriggerOffsetsParam> + ; -#pragma link C++ class o2::ctp::CtpCfg +; +#pragma link C++ class o2::ctp::CtpCfg + ; #endif diff --git a/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h b/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h index 230e0caf8a7ae..8ebc7e0304561 100644 --- a/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h +++ b/Detectors/CTP/reconstruction/include/CTPReconstruction/RawDataDecoder.h @@ -56,11 +56,12 @@ class RawDataDecoder static int shiftNew(const o2::InteractionRecord& irin, uint32_t TFOrbit, std::bitset<48>& inpmask, int64_t shift, int level, std::map& digmap); static int shiftInputs(std::map& digitsMap, o2::pmr::vector& digits, uint32_t TFOrbit, uint64_t trgclassmask = 0xffffffffffffffff); int checkReadoutConsistentncy(o2::pmr::vector& digits, uint64_t trgclassmask = 0xffffffffffffffff, uint64_t trigclassmaskNoTrgDets = 0xffffffffffffffff); - std::array getClassErrorsA() {return mClassErrorsA; } - std::array getClassErrorsB() { return mClassErrorsB; } - std::array getClassCountersA() {return mClassCountersA; } - std::array getClassCountersB() { return mClassCountersB; } + std::array getClassErrorsA() { return mClassErrorsA; } + std::array getClassErrorsB() { return mClassErrorsB; } + std::array getClassCountersA() { return mClassCountersA; } + std::array getClassCountersB() { return mClassCountersB; } int getLostDueToShift() { return mLostDueToShift; } + private: static constexpr uint32_t TF_TRIGGERTYPE_MASK = 0x800; static constexpr uint32_t HB_TRIGGERTYPE_MASK = 0x2; @@ -89,10 +90,10 @@ class RawDataDecoder int mErrorTCR = 0; int mErrorMax = 5; bool mStickyError = false; - std::array mClassErrorsA{}; - std::array mClassErrorsB{}; // from inputs - std::array mClassCountersA{}; - std::array mClassCountersB{}; // from inputs + std::array mClassErrorsA{}; + std::array mClassErrorsB{}; // from inputs + std::array mClassCountersA{}; + std::array mClassCountersB{}; // from inputs int mLostDueToShift = 0; CTPConfiguration mCTPConfig; }; diff --git a/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx b/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx index 1ab626a3d09ab..797dd0e300519 100644 --- a/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx +++ b/Detectors/CTP/reconstruction/src/RawDataDecoder.cxx @@ -298,12 +298,12 @@ int RawDataDecoder::decodeRaw(o2::framework::InputRecord& inputs, std::vector& digits, if (digit.CTPClassMask[i] & trgcls) { const CTPClass* cls = mCTPConfig.getCTPClassFromHWIndex(i); if (cls == nullptr) { - if(nerror < mErrorMax) { + if (nerror < mErrorMax) { LOG(error) << "Class mask index not found in CTP config:" << i; nerror++; } @@ -616,12 +616,12 @@ int RawDataDecoder::checkReadoutConsistentncy(o2::pmr::vector& digits, continue; } mClassCountersA[i]++; - if( cls->descriptor == nullptr) + if (cls->descriptor == nullptr) continue; uint64_t clsinpmask = cls->descriptor->getInputsMask(); uint64_t diginpmask = digit.CTPInputMask.to_ullong(); if (!((clsinpmask & diginpmask) == clsinpmask)) { - if(nerror < mErrorMax) { + if (nerror < mErrorMax) { LOG(error) << "Cls=>Inps: CTP class:" << cls->name << " inpmask:" << clsinpmask << " not compatible with inputs mask:" << diginpmask; nerror++; } @@ -632,21 +632,21 @@ int RawDataDecoder::checkReadoutConsistentncy(o2::pmr::vector& digits, } // if inps => class mask for (auto const& cls : mCTPConfig.getCTPClasses()) { - //cls.printStream(std::cout); - if(cls.descriptor == nullptr) + // cls.printStream(std::cout); + if (cls.descriptor == nullptr) continue; - uint64_t clsinpmask = cls.descriptor->getInputsMask(); // class definition + uint64_t clsinpmask = cls.descriptor->getInputsMask(); // class definition uint64_t diginpmask = digit.CTPInputMask.to_ullong(); uint64_t digclsmask = digit.CTPClassMask.to_ullong(); if ((clsinpmask & diginpmask) == clsinpmask) { - if(cls.classMask & trgclassmask) { + if (cls.classMask & trgclassmask) { mClassCountersB[cls.getIndex()]++; 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) { - if((nerror < mErrorMax) && (cls.classMask & ~trgclassmaskNoTrgDet)){ + if ((nerror < mErrorMax) && (cls.classMask & ~trgclassmaskNoTrgDet)) { LOG(info) << "Inp=>Cls: CTP class:" << cls.name << " inpmask:" << clsinpmask << " cls mask:" << cls.classMask << " not found in digit:" << digit; nerror++; } diff --git a/Detectors/CTP/workflow/src/RawDecoderSpec.cxx b/Detectors/CTP/workflow/src/RawDecoderSpec.cxx index 6b5d99ee5d78f..3f7c729b351a3 100644 --- a/Detectors/CTP/workflow/src/RawDecoderSpec.cxx +++ b/Detectors/CTP/workflow/src/RawDecoderSpec.cxx @@ -71,19 +71,19 @@ void RawDecoderSpec::endOfStream(framework::EndOfStreamContext& ec) 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()) + if (mDecoder.getErrorIR() || mDecoder.getErrorTCR()) LOG(error) << "# of IR errors:" << mDecoder.getErrorIR() << " TCR errors:" << mDecoder.getErrorTCR() << std::endl; std::array clsA = mDecoder.getClassCountersA(); std::array clsB = mDecoder.getClassCountersB(); std::array clsEA = mDecoder.getClassErrorsA(); std::array clsEB = mDecoder.getClassErrorsB(); - for(int i = 0; i < o2::ctp::CTP_NCLASSES; i ++){ + 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]) + if (clsEA[i]) LOG(error) << " Class without inputs:"; 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) { diff --git a/Detectors/CTP/workflowScalers/src/RunManager.cxx b/Detectors/CTP/workflowScalers/src/RunManager.cxx index 5b111b65202fa..f87a086bdae54 100644 --- a/Detectors/CTP/workflowScalers/src/RunManager.cxx +++ b/Detectors/CTP/workflowScalers/src/RunManager.cxx @@ -123,7 +123,7 @@ int CTPRunManager::loadRun(const std::string& cfg) // mRunsLoaded[runnumber] = activerun; saveRunConfigToCCDB(&activerun->cfg, timeStamp); - if(mCtpCfgDir != "none") + if (mCtpCfgDir != "none") saveCtpCfg(runnumber, timeStamp); return 0; } diff --git a/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx b/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx index 7a1007019fff3..512c665389151 100644 --- a/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx +++ b/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx @@ -185,7 +185,7 @@ int ctpCCDBManager::saveCtpCfg(uint32_t runNumber, long timeStart) o2::ccdb::CcdbApi api; map metadata; // can be empty metadata["runNumber"] = std::to_string(runNumber); - api.init(mCCDBHost.c_str()); // or http://localhost:8080 for a local installation + api.init(mCCDBHost.c_str()); // or http://localhost:8080 for a local installation // store abitrary user object in strongly typed manner int ret = api.storeAsTFileAny(&ctpcfg, mCCDBPathCtpCfg, metadata, tmin, tmax); if (ret == 0) { From 9b468a9fc6aec2f92359a7d8f341a152e5769c63 Mon Sep 17 00:00:00 2001 From: Roman Lietava Date: Wed, 7 May 2025 18:37:54 +0200 Subject: [PATCH 5/8] dev:ctpcfg --- .../include/DataFormatsCTP/Configuration.h | 2 +- .../Detectors/CTP/src/Configuration.cxx | 12 ++++-- .../CTP/workflowScalers/src/RunManager.cxx | 6 ++- .../workflowScalers/src/ctpCCDBManager.cxx | 43 ++++++++++--------- 4 files changed, 37 insertions(+), 26 deletions(-) diff --git a/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h index f8d9b7c4dfb23..4bd170f61bfda 100644 --- a/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h +++ b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h @@ -208,7 +208,7 @@ std::ostream& operator<<(std::ostream& in, const CTPConfiguration& conf); struct CtpCfg { CtpCfg() = default; std::string filename = "ctp.cfg"; - CtpCfg readAndSave(std::string& path); + CtpCfg readAndSave(std::string& path, int& ret); uint32_t TFOrbits = 0; int ccdb = -1; // -1 means def constructor was called uint32_t orbitShift = 0; diff --git a/DataFormats/Detectors/CTP/src/Configuration.cxx b/DataFormats/Detectors/CTP/src/Configuration.cxx index 3d07a5c84fb62..966f281853765 100644 --- a/DataFormats/Detectors/CTP/src/Configuration.cxx +++ b/DataFormats/Detectors/CTP/src/Configuration.cxx @@ -1177,9 +1177,11 @@ int CTPInputsConfiguration::getInputIndexFromName(std::string& name) return 0xff; } -CtpCfg CtpCfg::readAndSave(std::string& path) +CtpCfg CtpCfg::readAndSave(std::string& path, int& ret) { - std::ifstream ctpcfg(path + filename); + ret = 0; + std::string file = path + filename; + std::ifstream ctpcfg(file); if (ctpcfg.is_open()) { std::string line; while (std::getline(ctpcfg, line)) { @@ -1194,7 +1196,7 @@ CtpCfg CtpCfg::readAndSave(std::string& path) size_t ntokens = tokens.size(); if (ntokens < 2) { LOG(warn) << "Not enough tokens"; - return *this; + continue; } if (tokens[0].find("TForbits") != std::string::npos) { TFOrbits = std::atol(tokens[1].c_str()); @@ -1209,8 +1211,10 @@ CtpCfg CtpCfg::readAndSave(std::string& path) LOG(warn) << " Token not found:" << tokens[0]; } } + LOG(warn) << "Open file success:" << file; } else { - LOG(warn) << "Can not open file:" << filename; + LOG(warn) << "Can not open file:" << file; + ret = 1; } return *this; } diff --git a/Detectors/CTP/workflowScalers/src/RunManager.cxx b/Detectors/CTP/workflowScalers/src/RunManager.cxx index f87a086bdae54..f39dbf110d5c5 100644 --- a/Detectors/CTP/workflowScalers/src/RunManager.cxx +++ b/Detectors/CTP/workflowScalers/src/RunManager.cxx @@ -123,8 +123,9 @@ int CTPRunManager::loadRun(const std::string& cfg) // mRunsLoaded[runnumber] = activerun; saveRunConfigToCCDB(&activerun->cfg, timeStamp); - if (mCtpCfgDir != "none") + if (mCtpCfgDir != "none") { saveCtpCfg(runnumber, timeStamp); + } return 0; } int CTPRunManager::setRunConfigBK(uint32_t runNumber, const std::string& cfg) @@ -274,6 +275,9 @@ int CTPRunManager::processMessage(std::string& topic, const std::string& message } return ret; } + if(topic.find("rocnts") != std::string::npos) { + return 0; + } static int nerror = 0; if (topic.find("sox") != std::string::npos) { // get config diff --git a/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx b/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx index 512c665389151..9a878bd6eb35d 100644 --- a/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx +++ b/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx @@ -174,26 +174,29 @@ int ctpCCDBManager::saveCtpCfg(uint32_t runNumber, long timeStart) return 0; } CtpCfg ctpcfg; - ctpcfg.readAndSave(mCtpCfgDir); - using namespace std::chrono_literals; - std::chrono::seconds days3 = 259200s; - std::chrono::seconds min10 = 600s; - long time3days = std::chrono::duration_cast(days3).count(); - long time10min = std::chrono::duration_cast(min10).count(); - long tmin = timeStart - time10min; - long tmax = timeStart + time3days; - o2::ccdb::CcdbApi api; - map metadata; // can be empty - metadata["runNumber"] = std::to_string(runNumber); - api.init(mCCDBHost.c_str()); // or http://localhost:8080 for a local installation - // store abitrary user object in strongly typed manner - int ret = api.storeAsTFileAny(&ctpcfg, mCCDBPathCtpCfg, metadata, tmin, tmax); - if (ret == 0) { - LOG(info) << "CtpCfg saved in ccdb:" << mCCDBHost << " tmin:" << tmin << " tmax:" << tmax; - } else { - LOG(error) << "CtpCfg Problem writing to database ret:" << ret; - } - return 0; + int ret; + ctpcfg.readAndSave(mCtpCfgDir, ret); + if(ret == 0) { + using namespace std::chrono_literals; + std::chrono::seconds days3 = 259200s; + std::chrono::seconds min10 = 600s; + long time3days = std::chrono::duration_cast(days3).count(); + long time10min = std::chrono::duration_cast(min10).count(); + long tmin = timeStart - time10min; + long tmax = timeStart + time3days; + o2::ccdb::CcdbApi api; + map metadata; // can be empty + metadata["runNumber"] = std::to_string(runNumber); + api.init(mCCDBHost.c_str()); // or http://localhost:8080 for a local installation + // store abitrary user object in strongly typed manner + ret = api.storeAsTFileAny(&ctpcfg, mCCDBPathCtpCfg, metadata, tmin, tmax); + if (ret == 0) { + LOG(info) << "CtpCfg saved in ccdb:" << mCCDBHost << " tmin:" << tmin << " tmax:" << tmax; + } else { + LOG(error) << "CtpCfg Problem writing to database ret:" << ret; + } + } + return ret; } CTPConfiguration ctpCCDBManager::getConfigFromCCDB(long timestamp, std::string run, bool& ok) { From 23d61a7a813b6a80934932236aff7319e404dd37 Mon Sep 17 00:00:00 2001 From: Roman Lietava Date: Wed, 7 May 2025 18:38:54 +0200 Subject: [PATCH 6/8] clang --- Detectors/CTP/workflowScalers/src/RunManager.cxx | 2 +- Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Detectors/CTP/workflowScalers/src/RunManager.cxx b/Detectors/CTP/workflowScalers/src/RunManager.cxx index f39dbf110d5c5..054505aea7ba6 100644 --- a/Detectors/CTP/workflowScalers/src/RunManager.cxx +++ b/Detectors/CTP/workflowScalers/src/RunManager.cxx @@ -275,7 +275,7 @@ int CTPRunManager::processMessage(std::string& topic, const std::string& message } return ret; } - if(topic.find("rocnts") != std::string::npos) { + if (topic.find("rocnts") != std::string::npos) { return 0; } static int nerror = 0; diff --git a/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx b/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx index 9a878bd6eb35d..9df7a21e7a181 100644 --- a/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx +++ b/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx @@ -176,7 +176,7 @@ int ctpCCDBManager::saveCtpCfg(uint32_t runNumber, long timeStart) CtpCfg ctpcfg; int ret; ctpcfg.readAndSave(mCtpCfgDir, ret); - if(ret == 0) { + if (ret == 0) { using namespace std::chrono_literals; std::chrono::seconds days3 = 259200s; std::chrono::seconds min10 = 600s; @@ -195,7 +195,7 @@ int ctpCCDBManager::saveCtpCfg(uint32_t runNumber, long timeStart) } else { LOG(error) << "CtpCfg Problem writing to database ret:" << ret; } - } + } return ret; } CTPConfiguration ctpCCDBManager::getConfigFromCCDB(long timestamp, std::string run, bool& ok) From 12919ca57e84846d63dcd4db5dfe564bbd499b58 Mon Sep 17 00:00:00 2001 From: Roman Lietava Date: Thu, 8 May 2025 13:14:57 +0200 Subject: [PATCH 7/8] fix --- .../Detectors/CTP/include/DataFormatsCTP/Configuration.h | 2 +- DataFormats/Detectors/CTP/src/Configuration.cxx | 7 +++---- Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h index 4bd170f61bfda..fdd73986f1eaf 100644 --- a/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h +++ b/DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h @@ -208,7 +208,7 @@ std::ostream& operator<<(std::ostream& in, const CTPConfiguration& conf); struct CtpCfg { CtpCfg() = default; std::string filename = "ctp.cfg"; - CtpCfg readAndSave(std::string& path, int& ret); + int readAndSave(std::string& path); uint32_t TFOrbits = 0; int ccdb = -1; // -1 means def constructor was called uint32_t orbitShift = 0; diff --git a/DataFormats/Detectors/CTP/src/Configuration.cxx b/DataFormats/Detectors/CTP/src/Configuration.cxx index 966f281853765..5c4a339569b27 100644 --- a/DataFormats/Detectors/CTP/src/Configuration.cxx +++ b/DataFormats/Detectors/CTP/src/Configuration.cxx @@ -1177,9 +1177,8 @@ int CTPInputsConfiguration::getInputIndexFromName(std::string& name) return 0xff; } -CtpCfg CtpCfg::readAndSave(std::string& path, int& ret) +int CtpCfg::readAndSave(std::string& path) { - ret = 0; std::string file = path + filename; std::ifstream ctpcfg(file); if (ctpcfg.is_open()) { @@ -1214,9 +1213,9 @@ CtpCfg CtpCfg::readAndSave(std::string& path, int& ret) LOG(warn) << "Open file success:" << file; } else { LOG(warn) << "Can not open file:" << file; - ret = 1; + return 1; } - return *this; + return 0; } std::ostream& o2::ctp::operator<<(std::ostream& in, const o2::ctp::CTPConfiguration& conf) diff --git a/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx b/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx index 9df7a21e7a181..58850d88eb2c6 100644 --- a/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx +++ b/Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx @@ -174,8 +174,7 @@ int ctpCCDBManager::saveCtpCfg(uint32_t runNumber, long timeStart) return 0; } CtpCfg ctpcfg; - int ret; - ctpcfg.readAndSave(mCtpCfgDir, ret); + int ret = ctpcfg.readAndSave(mCtpCfgDir); if (ret == 0) { using namespace std::chrono_literals; std::chrono::seconds days3 = 259200s; From 772980cbf7e1eef578c7b2df4999cd800fa20b8b Mon Sep 17 00:00:00 2001 From: Roman Lietava Date: Thu, 8 May 2025 13:48:13 +0200 Subject: [PATCH 8/8] fix --- DataFormats/Detectors/CTP/src/Configuration.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DataFormats/Detectors/CTP/src/Configuration.cxx b/DataFormats/Detectors/CTP/src/Configuration.cxx index 5c4a339569b27..38a49132db3d1 100644 --- a/DataFormats/Detectors/CTP/src/Configuration.cxx +++ b/DataFormats/Detectors/CTP/src/Configuration.cxx @@ -1204,8 +1204,8 @@ int CtpCfg::readAndSave(std::string& path) } else if (tokens[0].find("orbitshift") != std::string::npos) { orbitShift = std::atol(tokens[1].c_str()); } else if (tokens[0].find("ir_inputs") != std::string::npos) { - irInputs_1_24 = std::stoul(tokens[1].c_str(), nullptr, 16); - irInputs_25_48 = std::stoul(tokens[2].c_str(), nullptr, 16); + irInputs_1_24 = std::stoul(tokens[2].c_str(), nullptr, 16); + irInputs_25_48 = std::stoul(tokens[1].c_str(), nullptr, 16); } else { LOG(warn) << " Token not found:" << tokens[0]; }