Skip to content

Commit

Permalink
[EMCAL-1037] Use DPL CCDB fetcher and finalizeCCDD for loading of the…
Browse files Browse the repository at this point in the history
… CTP configuration (#2044)
  • Loading branch information
mfasDa committed Nov 23, 2023
1 parent 889e24a commit d294eab
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 48 deletions.
11 changes: 8 additions & 3 deletions Modules/EMCAL/include/EMCAL/BCTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@

class TH1F;

namespace o2::ctp
{
class CTPConfiguration;
}

using namespace o2::quality_control::core;

namespace o2::quality_control_modules::emcal
Expand Down Expand Up @@ -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
Expand Down
85 changes: 40 additions & 45 deletions Modules/EMCAL/src/BCTask.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,15 @@ void BCTask::startOfCycle()

void BCTask::monitorData(o2::framework::ProcessingContext& ctx)
{
bool hasCTPConfig = true;
if (!hasClassMasksLoaded()) {
if (!loadTriggerClasses(ctx.services().get<o2::framework::TimingInfo>().creation)) {
ILOG(Error, Support) << "No trigger classes loaded, processing CTP digits not possible" << ENDM;
hasCTPConfig = false;
}
}
auto ctpconfig = ctx.inputs().get<o2::ctp::CTPConfiguration*>("ctp-config");

This comment has been minimized.

Copy link
@chiarazampolli

chiarazampolli Nov 30, 2023

Contributor

Hello @mfasDa ,

dev/master of O2/O2DPG/QC are broken with this change (FYI: @wiechula , @noferini ), giving:

[762471:qc-task-EMC-BCs]: [17:06:36][ERROR] Exception caught: InputRecord::get: no input with binding ctp-config found. Available inputs: timer-cycle, emcal-triggers, ctp-digits

Probably it is something missing in the json like:

ctp-config:CTP/CONFIG/0?lifetime=condition&ccdb-path=CTP/Config/Config

to be added to:
https://github.com/AliceO2Group/O2DPG/blob/db4983326f8185dcb7c90731c71e84d6d819aaca/DATA/production/qc-async/emc_PbPb.json#L90
and:
https://github.com/AliceO2Group/O2DPG/blob/db4983326f8185dcb7c90731c71e84d6d819aaca/DATA/production/qc-async/emc.json#L76

(I don't see the bc task in MC - https://github.com/AliceO2Group/O2DPG/blob/master/MC/config/QC/json/emc-cell-task.json)

How did you test it?

Thanks,

Chiara

This comment has been minimized.

Copy link
@mfasDa

mfasDa Nov 30, 2023

Author Collaborator

Hi @chiarazampolli,

the input spec ctp-config is defined in the config file, which is in O2DPG. The corresponding commit I can only make once the new tag is deployed - which is now the case. A corresponding PR in O2DPG will be opened later.

Cheers

Markus

auto emctriggers = ctx.inputs().get<gsl::span<o2::emcal::TriggerRecord>>("emcal-triggers");
for (const auto& emctrg : emctriggers) {
if (emctrg.getTriggerBits() & o2::trigger::PhT) {
mBCReadout->Fill(emctrg.getBCData().bc);
}
}

if (hasCTPConfig) {
if (hasClassMasksLoaded()) {
auto ctpdigits = ctx.inputs().get<gsl::span<o2::ctp::CTPDigit>>("ctp-digits");
for (const auto& ctpdigit : ctpdigits) {
auto bc = ctpdigit.intRecord.bc;
Expand Down Expand Up @@ -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<const o2::ctp::CTPConfiguration*>(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
Expand Down Expand Up @@ -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::string> {
std::vector<std::string> tokens;
Expand All @@ -234,45 +239,35 @@ bool BCTask::loadTriggerClasses(uint64_t timestamp)
return tokens;
};
mAllEMCALClasses.clear();
std::map<std::string, std::string> 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<o2::ctp::CTPConfiguration>("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;
}
}
}

Expand Down

0 comments on commit d294eab

Please sign in to comment.