diff --git a/Modules/EMCAL/include/EMCAL/BCTask.h b/Modules/EMCAL/include/EMCAL/BCTask.h index 9e3abae56b..41729b6fa7 100644 --- a/Modules/EMCAL/include/EMCAL/BCTask.h +++ b/Modules/EMCAL/include/EMCAL/BCTask.h @@ -25,6 +25,11 @@ class TH1F; +namespace o2::ctp +{ +class CTPConfiguration; +} + using namespace o2::quality_control::core; namespace o2::quality_control_modules::emcal @@ -61,12 +66,12 @@ class BCTask final : public TaskInterface void endOfCycle() override; void endOfActivity(const Activity& activity) override; void reset() override; + void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) override; protected: /// \brief Load trigger configuration for current run and timestamp - /// \param timestamp Timestamp from ProcessingContext - /// \return True if classes were successfully loaded, false otherwise - bool loadTriggerClasses(uint64_t timestamp); + /// \param ctpconfig CTP configuration + void loadTriggerClasses(const o2::ctp::CTPConfiguration* ctpconfig); /// \brief Check if the class masks are initialized /// \return True if the class masks are initialized, false otherwise diff --git a/Modules/EMCAL/src/BCTask.cxx b/Modules/EMCAL/src/BCTask.cxx index 40f46971f3..1dd1c9ffa9 100644 --- a/Modules/EMCAL/src/BCTask.cxx +++ b/Modules/EMCAL/src/BCTask.cxx @@ -75,13 +75,7 @@ void BCTask::startOfCycle() void BCTask::monitorData(o2::framework::ProcessingContext& ctx) { - bool hasCTPConfig = true; - if (!hasClassMasksLoaded()) { - if (!loadTriggerClasses(ctx.services().get().creation)) { - ILOG(Error, Support) << "No trigger classes loaded, processing CTP digits not possible" << ENDM; - hasCTPConfig = false; - } - } + auto ctpconfig = ctx.inputs().get("ctp-config"); auto emctriggers = ctx.inputs().get>("emcal-triggers"); for (const auto& emctrg : emctriggers) { if (emctrg.getTriggerBits() & o2::trigger::PhT) { @@ -89,7 +83,7 @@ void BCTask::monitorData(o2::framework::ProcessingContext& ctx) } } - if (hasCTPConfig) { + if (hasClassMasksLoaded()) { auto ctpdigits = ctx.inputs().get>("ctp-digits"); for (const auto& ctpdigit : ctpdigits) { auto bc = ctpdigit.intRecord.bc; @@ -128,6 +122,17 @@ void BCTask::endOfActivity(const Activity& /*activity*/) ILOG(Debug, Devel) << "endOfActivity" << ENDM; } +void BCTask::finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) +{ + if (matcher == o2::framework::ConcreteDataMatcher("CTP", "CONFIG", 0)) { + auto triggerconfig = reinterpret_cast(obj); + if (triggerconfig) { + ILOG(Info, Support) << "Loading EMCAL trigger classes for new trigger configuration: " << ENDM; + loadTriggerClasses(triggerconfig); + } + } +} + void BCTask::reset() { // clean all the monitor objects here @@ -221,7 +226,7 @@ BCTask::BeamPresenceMode_t BCTask::getBeamPresenceMode(const std::string_view be return BeamPresenceMode_t::ANY; } -bool BCTask::loadTriggerClasses(uint64_t timestamp) +void BCTask::loadTriggerClasses(const o2::ctp::CTPConfiguration* ctpconfig) { auto tokenize = [](const std::string_view trgclass, char delimiter) -> std::vector { std::vector tokens; @@ -234,45 +239,35 @@ bool BCTask::loadTriggerClasses(uint64_t timestamp) return tokens; }; mAllEMCALClasses.clear(); - std::map metadata; - metadata["runNumber"] = std::to_string(mCurrentRun); - // temproary fix to make the task not crashing if the trigger configuration for the given run is not found (O2-4122) - o2::ccdb::BasicCCDBManager::instance().setFatalWhenNull(false); - auto ctpconfig = this->retrieveConditionAny("CTP/Config/Config", metadata, timestamp); - if (ctpconfig) { - for (auto& cls : ctpconfig->getCTPClasses()) { - auto trgclsname = boost::algorithm::to_upper_copy(cls.name); - auto tokens = tokenize(trgclsname, '-'); - auto triggercluster = tokens[3]; - if (triggercluster.find("EMC") == std::string::npos) { - // Not an EMCAL trigger class + + for (auto& cls : ctpconfig->getCTPClasses()) { + auto trgclsname = boost::algorithm::to_upper_copy(cls.name); + auto tokens = tokenize(trgclsname, '-'); + auto triggercluster = tokens[3]; + if (triggercluster.find("EMC") == std::string::npos) { + // Not an EMCAL trigger class + continue; + } + if (mBeamMode != BeamPresenceMode_t::ANY) { + if (tokens[1] != getBeamPresenceModeToken(mBeamMode)) { + // beam mode not matching continue; } - if (mBeamMode != BeamPresenceMode_t::ANY) { - if (tokens[1] != getBeamPresenceModeToken(mBeamMode)) { - // beam mode not matching - continue; - } - } - ILOG(Info, Support) << "EMCAL trigger cluster: Found trigger class: " << trgclsname << ENDM; - mAllEMCALClasses.insert(cls.classMask); - if (tokens[0] == mTriggerAliases.find("MB")->second) { - mTriggerClassIndices[EMCMinBias] = cls.classMask; - ILOG(Info, Support) << "Trigger class index EMC min bias: " << mTriggerClassIndices[EMCMinBias] << " (Class name: " << cls.name << ")" << ENDM; - } - if (tokens[0] == mTriggerAliases.find("0EMC")->second) { - mTriggerClassIndices[EMCL0] = cls.classMask; - ILOG(Info, Support) << "Trigger class index EMC L0: " << mTriggerClassIndices[EMCL0] << " (Class name: " << cls.name << ")" << ENDM; - } - if (tokens[0] == mTriggerAliases.find("0DMC")->second) { - mTriggerClassIndices[DMCL0] = cls.classMask; - ILOG(Info, Support) << "Trigger class index DMC L0: " << mTriggerClassIndices[DMCL0] << " (Class name: " << cls.name << ")" << ENDM; - } } - return true; - } else { - ILOG(Error, Support) << "Failed loading CTP configuration for run " << mCurrentRun << ", timestamp " << timestamp << ENDM; - return false; + ILOG(Info, Support) << "EMCAL trigger cluster: Found trigger class: " << trgclsname << ENDM; + mAllEMCALClasses.insert(cls.classMask); + if (tokens[0] == mTriggerAliases.find("MB")->second) { + mTriggerClassIndices[EMCMinBias] = cls.classMask; + ILOG(Info, Support) << "Trigger class index EMC min bias: " << mTriggerClassIndices[EMCMinBias] << " (Class name: " << cls.name << ")" << ENDM; + } + if (tokens[0] == mTriggerAliases.find("0EMC")->second) { + mTriggerClassIndices[EMCL0] = cls.classMask; + ILOG(Info, Support) << "Trigger class index EMC L0: " << mTriggerClassIndices[EMCL0] << " (Class name: " << cls.name << ")" << ENDM; + } + if (tokens[0] == mTriggerAliases.find("0DMC")->second) { + mTriggerClassIndices[DMCL0] = cls.classMask; + ILOG(Info, Support) << "Trigger class index DMC L0: " << mTriggerClassIndices[DMCL0] << " (Class name: " << cls.name << ")" << ENDM; + } } }