From 5432aab002bac38931eec05978cbaade8367a82d Mon Sep 17 00:00:00 2001 From: Sean Murray Date: Thu, 9 Mar 2023 12:54:39 +0100 Subject: [PATCH] TRD fix ccdb object time requesting [O2-3592] --- Modules/TRD/TRDQC.json | 11 ++--- Modules/TRD/include/TRD/DigitsTask.h | 6 +-- Modules/TRD/include/TRD/PulseHeight.h | 4 +- Modules/TRD/include/TRD/PulseHeightCheck.h | 1 - .../TRD/include/TRD/PulseHeightTrackMatch.h | 6 --- Modules/TRD/include/TRD/TrackletsCheck.h | 2 - Modules/TRD/include/TRD/TrackletsTask.h | 6 +-- Modules/TRD/src/DigitsTask.cxx | 48 ++++++++++--------- Modules/TRD/src/PulseHeight.cxx | 28 +++++------ Modules/TRD/src/PulseHeightCheck.cxx | 9 ---- Modules/TRD/src/PulseHeightTrackMatch.cxx | 11 ----- Modules/TRD/src/TrackletsCheck.cxx | 17 +------ Modules/TRD/src/TrackletsTask.cxx | 48 +++++++++---------- 13 files changed, 68 insertions(+), 129 deletions(-) diff --git a/Modules/TRD/TRDQC.json b/Modules/TRD/TRDQC.json index 927cebca82..1e55c5927d 100644 --- a/Modules/TRD/TRDQC.json +++ b/Modules/TRD/TRDQC.json @@ -59,12 +59,9 @@ "maxNumberCycles": "-1", "dataSource": { "type": "direct", - "query": "digits:TRD/DIGITS;tracklets:TRD/TRACKLETS;triggers:TRD/TRKTRGRD" + "query": "digits:TRD/DIGITS;tracklets:TRD/TRACKLETS;triggers:TRD/TRKTRGRD;clnoisemap:TRD/NOISEMCM/0?lifetime=condition&ccdb-path=TRD/Calib/NoiseMapMCM;clchamberstatus:TRD/CHAMBERSTATUS/0?lifetime=condition&ccdb-path=TRD/Calib/ChamberStatus" }, - "taskParameters": { - "peakregionstart": "7.0", - "peakregionend": "20.0", - "pulseheightpeaklower": "1.0", + "taskParameters": { "peakregionstart": "7.0", "peakregionend": "20.0", "pulseheightpeaklower": "1.0", "pulseheightpeakupper": "5.0" }, "location": "remote", @@ -80,7 +77,7 @@ "dataSource_comment": "no comment", "dataSource": { "type": "direct", - "query": "digits:TRD/DIGITS;tracklets:TRD/TRACKLETS;triggers:TRD/TRKTRGRD" + "query": "digits:TRD/DIGITS;tracklets:TRD/TRACKLETS;triggers:TRD/TRKTRGRD;clnoisemap:TRD/NOISEMCM/0?lifetime=condition&ccdb-path=TRD/Calib/NoiseMapMCM;clchamberstatus:TRD/CHAMBERSTATUS/0?lifetime=condition&ccdb-path=TRD/Calib/ChamberStatus" }, "taskParameters": { "peakregionstart": "7.0", @@ -100,7 +97,7 @@ "maxNumberCycles": "-1", "dataSource": { "type": "direct", - "query": "digits:TRD/DIGITS;tracklets:TRD/TRACKLETS;triggers:TRD/TRKTRGRD;rawstats:TRD/RAWSTATS" + "query": "digits:TRD/DIGITS;tracklets:TRD/TRACKLETS;triggers:TRD/TRKTRGRD;clnoisemap:TRD/NOISEMCM/0?lifetime=condition&ccdb-path=TRD/Calib/NoiseMapMCM;clchamberstatus:TRD/CHAMBERSTATUS/0?lifetime=condition&ccdb-path=TRD/Calib/ChamberStatus" }, "taskParameters": { "peakregionstart": "7.0", diff --git a/Modules/TRD/include/TRD/DigitsTask.h b/Modules/TRD/include/TRD/DigitsTask.h index cec6434de7..3916e9d1b8 100644 --- a/Modules/TRD/include/TRD/DigitsTask.h +++ b/Modules/TRD/include/TRD/DigitsTask.h @@ -56,7 +56,6 @@ class DigitsTask final : public TaskInterface void buildHistograms(); void drawLinesMCM(TH2F* histo); void drawTrdLayersGrid(TH2F* hist); - void retrieveCCDBSettings(); void drawLinesOnPulseHeight(TH1F* h); void fillLinesOnHistsPerLayer(int iLayer); void drawHashOnLayers(int layer, int hcid, int col, int rowstart, int rowend); @@ -69,7 +68,6 @@ class DigitsTask final : public TaskInterface unsigned int mPulseHeightThreshold; std::pair mDriftRegion; std::pair mPulseHeightPeakRegion; - long int mTimestamp; std::shared_ptr mDigitsPerEvent; std::shared_ptr mEventswDigitsPerTimeFrame; @@ -112,8 +110,8 @@ class DigitsTask final : public TaskInterface // std::array, 540> mPulseHeightPerChamber_1D; // ph2DSM; std::vector mLayers; // information pulled from ccdb - o2::trd::NoiseStatusMCM* mNoiseMap = nullptr; - o2::trd::HalfChamberStatusQC* mChamberStatus = nullptr; + const o2::trd::NoiseStatusMCM* mNoiseMap = nullptr; + const o2::trd::HalfChamberStatusQC* mChamberStatus = nullptr; std::string mChambersToIgnore; std::bitset mChambersToIgnoreBP; }; diff --git a/Modules/TRD/include/TRD/PulseHeight.h b/Modules/TRD/include/TRD/PulseHeight.h index 1b0ee693ae..f909c159f7 100644 --- a/Modules/TRD/include/TRD/PulseHeight.h +++ b/Modules/TRD/include/TRD/PulseHeight.h @@ -52,10 +52,8 @@ class PulseHeight final : public TaskInterface void endOfActivity(Activity& activity) override; void reset() override; void buildHistograms(); - void retrieveCCDBSettings(); private: - long int mTimestamp; std::shared_ptr mPulseHeight = nullptr; std::shared_ptr mPulseHeightScaled = nullptr; std::shared_ptr mTotalPulseHeight2D = nullptr; @@ -70,7 +68,7 @@ class PulseHeight final : public TaskInterface std::shared_ptr mPulseHeightDuration; std::shared_ptr mPulseHeightDuration1; std::shared_ptr mPulseHeightDurationDiff; - o2::trd::NoiseStatusMCM* mNoiseMap = nullptr; + const o2::trd::NoiseStatusMCM* mNoiseMap = nullptr; std::shared_ptr mPulseHeightpro = nullptr; std::shared_ptr mPulseHeightperchamber = nullptr; }; diff --git a/Modules/TRD/include/TRD/PulseHeightCheck.h b/Modules/TRD/include/TRD/PulseHeightCheck.h index 680ce74247..c1e7ca7f8d 100644 --- a/Modules/TRD/include/TRD/PulseHeightCheck.h +++ b/Modules/TRD/include/TRD/PulseHeightCheck.h @@ -39,7 +39,6 @@ class PulseHeightCheck : public o2::quality_control::checker::CheckInterface void beautify(std::shared_ptr mo, Quality checkResult = Quality::Null) override; std::string getAcceptedType() override; void buildChamberIgnoreBP(); - long int mTimeStamp; std::pair mDriftRegion; std::pair mPulseHeightPeakRegion; unsigned int mPulseHeightMinSum; diff --git a/Modules/TRD/include/TRD/PulseHeightTrackMatch.h b/Modules/TRD/include/TRD/PulseHeightTrackMatch.h index cf08c4d375..57b084be84 100644 --- a/Modules/TRD/include/TRD/PulseHeightTrackMatch.h +++ b/Modules/TRD/include/TRD/PulseHeightTrackMatch.h @@ -71,7 +71,6 @@ class PulseHeightTrackMatch final : public TaskInterface unsigned int mPulseHeightThreshold; std::pair mDriftRegion; std::pair mPulseHeightPeakRegion; - long int mTimestamp; std::shared_ptr mParsingTimePerTF; std::shared_ptr mDigitsPerEvent; std::shared_ptr mTrackletsPerEvent; @@ -83,11 +82,6 @@ class PulseHeightTrackMatch final : public TaskInterface std::shared_ptr mPulseHeightperchamber = nullptr; std::vector mLayers; - // information pulled from ccdb - o2::trd::NoiseStatusMCM* mNoiseMap = nullptr; - o2::trd::HalfChamberStatusQC* mChamberStatus = nullptr; - std::string mChambersToIgnore; - std::bitset mChambersToIgnoreBP; }; } // namespace o2::quality_control_modules::trd diff --git a/Modules/TRD/include/TRD/TrackletsCheck.h b/Modules/TRD/include/TRD/TrackletsCheck.h index 7f572d77a0..732491e15f 100644 --- a/Modules/TRD/include/TRD/TrackletsCheck.h +++ b/Modules/TRD/include/TRD/TrackletsCheck.h @@ -40,10 +40,8 @@ class TrackletsCheck : public o2::quality_control::checker::CheckInterface void beautify(std::shared_ptr mo, Quality checkResult = Quality::Null) override; std::string getAcceptedType() override; - void retrieveCCDBSettings(); private: - long int mTimestamp; float mIntegralThreshold; float mRatioThreshold; float mZeroBinRatioThreshold; diff --git a/Modules/TRD/include/TRD/TrackletsTask.h b/Modules/TRD/include/TRD/TrackletsTask.h index 519aa075b1..bb24585a5e 100644 --- a/Modules/TRD/include/TRD/TrackletsTask.h +++ b/Modules/TRD/include/TRD/TrackletsTask.h @@ -50,7 +50,6 @@ class TrackletsTask final : public TaskInterface void endOfActivity(Activity& activity) override; void reset() override; void buildHistograms(); - void retrieveCCDBSettings(); void drawLinesMCM(TH2F* histo); void drawTrdLayersGrid(TH2F* hist); void buildTrackletLayers(); @@ -58,7 +57,6 @@ class TrackletsTask final : public TaskInterface void drawHashOnLayers(int layer, int hcid, int rowstart, int rowend); private: - long int mTimestamp; std::array moHCMCM; std::array mTrackletQ0perSector; std::array mTrackletQ1perSector; @@ -86,8 +84,8 @@ class TrackletsTask final : public TaskInterface int mMarkerStyle; // data to pull from CCDB - o2::trd::NoiseStatusMCM* mNoiseMap = nullptr; - o2::trd::HalfChamberStatusQC* mChamberStatus = nullptr; + const o2::trd::NoiseStatusMCM* mNoiseMap = nullptr; + const o2::trd::HalfChamberStatusQC* mChamberStatus = nullptr; }; } // namespace o2::quality_control_modules::trd diff --git a/Modules/TRD/src/DigitsTask.cxx b/Modules/TRD/src/DigitsTask.cxx index fa95fab560..0d042c20ae 100644 --- a/Modules/TRD/src/DigitsTask.cxx +++ b/Modules/TRD/src/DigitsTask.cxx @@ -25,31 +25,11 @@ #include "CCDB/BasicCCDBManager.h" namespace o2::quality_control_modules::trd { + DigitsTask::~DigitsTask() { } -void DigitsTask::retrieveCCDBSettings() -{ - if (auto param = mCustomParameters.find("ccdbtimestamp"); param != mCustomParameters.end()) { - mTimestamp = std::stol(mCustomParameters["ccdbtimestamp"]); - ILOG(Debug, Support) << "configure() : using ccdbtimestamp = " << mTimestamp << ENDM; - } else { - mTimestamp = o2::ccdb::getCurrentTimestamp(); - ILOG(Debug, Support) << "configure() : using default timestam of now = " << mTimestamp << ENDM; - } - auto& mgr = o2::ccdb::BasicCCDBManager::instance(); - mgr.setTimestamp(mTimestamp); - mNoiseMap = mgr.get("/TRD/Calib/NoiseMapMCM"); - if (mNoiseMap == nullptr) { - ILOG(Info, Support) << "mNoiseMap is null, no noisy mcm reduction" << ENDM; - } - mChamberStatus = mgr.get("/TRD/Calib/HalfChamberStatusQC"); - if (mChamberStatus == nullptr) { - ILOG(Info, Support) << "mChamberStatus is null, no chamber status to display" << ENDM; - } -} - void DigitsTask::buildChamberIgnoreBP() { mChambersToIgnoreBP.reset(); @@ -465,13 +445,13 @@ void DigitsTask::initialize(o2::framework::InitContext& /*ctx*/) } buildChamberIgnoreBP(); - retrieveCCDBSettings(); buildHistograms(); } -void DigitsTask::startOfActivity(Activity& /*activity*/) +void DigitsTask::startOfActivity(Activity& activity) { ILOG(Debug, Devel) << "startOfActivity" << ENDM; + // mTimeStamp = activity.mValidity.; } // set stats/stacs void DigitsTask::startOfCycle() @@ -510,6 +490,28 @@ bool DigitsTask::isChamberToBeIgnored(unsigned int sm, unsigned int stack, unsig void DigitsTask::monitorData(o2::framework::ProcessingContext& ctx) { + //get ccdb objects if not already retrieved: + if (mNoiseMap == nullptr) { + ILOG(Info, Support) << "Getting noisemap from ccdb" << ENDM; + auto mNoiseMapPtr = ctx.inputs().get("clnoisemap"); + mNoiseMap = mNoiseMapPtr.get(); + if (mNoiseMap == nullptr) { + ILOG(Error, Support) << "NoiseMap never loaded, leaving monitor" << ENDM; + return; + } + ILOG(Info, Support) << "NoiseMap loaded" << ENDM; + } + if (mChamberStatus == nullptr) { + ILOG(Info, Support) << "Getting chamber status from ccdb" << ENDM; + auto mChamberStatusPtr = ctx.inputs().get("clchamberstatus"); + mChamberStatus = mChamberStatusPtr.get(); + if (mChamberStatus == nullptr) { + ILOG(Error, Support) << "Chamber Status never loaded, leaving monitor" << ENDM; + return; + } + ILOG(Info, Support) << "Chamber Status loaded" << ENDM; + } + for (auto&& input : ctx.inputs()) { if (input.header != nullptr && input.payload != nullptr) { diff --git a/Modules/TRD/src/PulseHeight.cxx b/Modules/TRD/src/PulseHeight.cxx index 3e4e78bb94..76fa603432 100644 --- a/Modules/TRD/src/PulseHeight.cxx +++ b/Modules/TRD/src/PulseHeight.cxx @@ -41,22 +41,6 @@ PulseHeight::~PulseHeight() { } -void PulseHeight::retrieveCCDBSettings() -{ - if (auto param = mCustomParameters.find("ccdbtimestamp"); param != mCustomParameters.end()) { - mTimestamp = std::stol(mCustomParameters["ccdbtimestamp"]); - ILOG(Debug, Support) << "configure() : using ccdbtimestamp = " << mTimestamp << ENDM; - } else { - mTimestamp = o2::ccdb::getCurrentTimestamp(); - ILOG(Debug, Support) << "configure() : using default timestam of now = " << mTimestamp << ENDM; - } - auto& mgr = o2::ccdb::BasicCCDBManager::instance(); - mgr.setTimestamp(mTimestamp); - mNoiseMap = mgr.get("/TRD/Calib/NoiseMapMCM"); - if (mNoiseMap == nullptr) { - ILOG(Info, Support) << "mNoiseMap is null, no noisy mcm reduction" << ENDM; - } -} void PulseHeight::buildHistograms() { @@ -142,7 +126,6 @@ void PulseHeight::initialize(o2::framework::InitContext& /*ctx*/) ILOG(Debug, Support) << "configure() : using default pulseheightupper = " << mPulseHeightPeakRegion.second << ENDM; } buildHistograms(); - retrieveCCDBSettings(); } void PulseHeight::startOfActivity(Activity& activity) @@ -181,6 +164,17 @@ bool pulseheightdigitindexcompare(unsigned int A, unsigned int B, const std::vec void PulseHeight::monitorData(o2::framework::ProcessingContext& ctx) { + //get ccdb objects if not already retrieved: + if (mNoiseMap == nullptr) { + ILOG(Info, Support) << "Getting noisemap from ccdb" << ENDM; + auto mNoiseMapPtr = ctx.inputs().get("clnoisemap"); + mNoiseMap = mNoiseMapPtr.get(); + if (mNoiseMap == nullptr) { + ILOG(Error, Support) << "NoiseMap never loaded, leaving monitor" << ENDM; + return; + } + ILOG(Info, Support) << "NoiseMap loaded" << ENDM; + } auto digits = ctx.inputs().get>("digits"); auto tracklets = ctx.inputs().get>("tracklets"); auto triggerrecords = ctx.inputs().get>("triggers"); diff --git a/Modules/TRD/src/PulseHeightCheck.cxx b/Modules/TRD/src/PulseHeightCheck.cxx index 48b40a5067..3f4e1746a8 100644 --- a/Modules/TRD/src/PulseHeightCheck.cxx +++ b/Modules/TRD/src/PulseHeightCheck.cxx @@ -38,15 +38,6 @@ namespace o2::quality_control_modules::trd void PulseHeightCheck::configure() { - if (auto param = mCustomParameters.find("ccdbtimestamp"); param != mCustomParameters.end()) { - mTimeStamp = std::stol(mCustomParameters["ccdbtimestamp"]); - ILOG(Debug, Support) << "configure() : using ccdbtimestamp = " << mTimeStamp << ENDM; - } else { - mTimeStamp = o2::ccdb::getCurrentTimestamp(); - ILOG(Debug, Support) << "configure() : using default timestam of now = " << mTimeStamp << ENDM; - } - auto& mgr = o2::ccdb::BasicCCDBManager::instance(); - mgr.setTimestamp(mTimeStamp); ILOG(Debug, Devel) << "initialize PulseHeight" << ENDM; // QcInfoLogger is used. FairMQ logs will go to there as well. if (auto param = mCustomParameters.find("driftregionstart"); param != mCustomParameters.end()) { mDriftRegion.first = stof(param->second); diff --git a/Modules/TRD/src/PulseHeightTrackMatch.cxx b/Modules/TRD/src/PulseHeightTrackMatch.cxx index eb9bdae382..452047a003 100644 --- a/Modules/TRD/src/PulseHeightTrackMatch.cxx +++ b/Modules/TRD/src/PulseHeightTrackMatch.cxx @@ -46,17 +46,6 @@ PulseHeightTrackMatch::~PulseHeightTrackMatch() { } -void PulseHeightTrackMatch::retrieveCCDBSettings() -{ - if (auto param = mCustomParameters.find("ccdbtimestamp"); param != mCustomParameters.end()) { - mTimestamp = std::stol(mCustomParameters["ccdbtimestamp"]); - ILOG(Debug, Support) << "configure() : using ccdbtimestamp = " << mTimestamp << ENDM; - } else { - mTimestamp = o2::ccdb::getCurrentTimestamp(); - ILOG(Debug, Support) << "configure() : using default timestam of now = " << mTimestamp << ENDM; - } -} - void PulseHeightTrackMatch::buildHistograms() { mParsingTimePerTF.reset(new TH1F("parsingtimeperTF", "Time for processing each TF", 100000, 0, 100000)); diff --git a/Modules/TRD/src/TrackletsCheck.cxx b/Modules/TRD/src/TrackletsCheck.cxx index fc52ce1695..513a5f1d58 100644 --- a/Modules/TRD/src/TrackletsCheck.cxx +++ b/Modules/TRD/src/TrackletsCheck.cxx @@ -32,17 +32,8 @@ using namespace o2::quality_control; namespace o2::quality_control_modules::trd { -void TrackletsCheck::retrieveCCDBSettings() +void TrackletsCheck::configure() { - if (auto param = mCustomParameters.find("ccdbtimestamp"); param != mCustomParameters.end()) { - mTimestamp = std::stol(mCustomParameters["ccdbtimestamp"]); - ILOG(Debug, Support) << "configure() : using ccdbtimestamp = " << mTimestamp << ENDM; - } else { - mTimestamp = o2::ccdb::getCurrentTimestamp(); - ILOG(Debug, Support) << "configure() : using default timestam of now = " << mTimestamp << ENDM; - } - auto& mgr = o2::ccdb::BasicCCDBManager::instance(); - mgr.setTimestamp(mTimestamp); if (auto param = mCustomParameters.find("integralthreshold"); param != mCustomParameters.end()) { mIntegralThreshold = std::stol(mCustomParameters["integralthreshold"]); ILOG(Debug, Support) << "configure() : using integral threshold = " << mIntegralThreshold << ENDM; @@ -66,12 +57,6 @@ void TrackletsCheck::retrieveCCDBSettings() } } -void TrackletsCheck::configure() -{ - //get ccdb values - //fill mask spectra - retrieveCCDBSettings(); -} Quality TrackletsCheck::check(std::map>* moMap) { diff --git a/Modules/TRD/src/TrackletsTask.cxx b/Modules/TRD/src/TrackletsTask.cxx index d4a5446224..692695a7a0 100644 --- a/Modules/TRD/src/TrackletsTask.cxx +++ b/Modules/TRD/src/TrackletsTask.cxx @@ -100,30 +100,6 @@ void TrackletsTask::drawTrdLayersGrid(TH2F* hist) } } -void TrackletsTask::retrieveCCDBSettings() -{ - if (auto param = mCustomParameters.find("ccdbtimestamp"); param != mCustomParameters.end()) { - mTimestamp = std::stol(mCustomParameters["ccdbtimestamp"]); - ILOG(Debug, Support) << "configure() : using ccdbtimestamp = " << mTimestamp << ENDM; - } else { - mTimestamp = o2::ccdb::getCurrentTimestamp(); - ILOG(Debug, Support) << "configure() : using default timestam of now = " << mTimestamp << ENDM; - } - auto& mgr = o2::ccdb::BasicCCDBManager::instance(); - mgr.setTimestamp(mTimestamp); - mNoiseMap = mgr.get("/TRD/Calib/NoiseMapMCM"); - if (mNoiseMap == nullptr) { - ILOG(Info, Support) << "mNoiseMap is null, no noisy mcm reduction" << ENDM; - } - mChamberStatus = mgr.get("/TRD/Calib/HalfChamberStatusQC"); - if (mChamberStatus == nullptr) { - ILOG(Info, Support) << "mChamberStatus is null, no chamber status to display" << ENDM; - } - // j else{ - // drawHashedOnHistsPerLayer(); - // } -} - void TrackletsTask::buildHistograms() { for (Int_t sm = 0; sm < o2::trd::constants::NSECTOR; ++sm) { @@ -312,7 +288,6 @@ void TrackletsTask::initialize(o2::framework::InitContext& /*ctx*/) ILOG(Debug, Support) << "configure() : using default markersize = " << mMarkerSize << ENDM; } - retrieveCCDBSettings(); buildHistograms(); } @@ -331,13 +306,34 @@ void TrackletsTask::startOfCycle() void TrackletsTask::monitorData(o2::framework::ProcessingContext& ctx) { + //get ccdb objects if not already retrieved: + if (mNoiseMap == nullptr) { + ILOG(Info, Support) << "Getting noisemap from ccdb" << ENDM; + auto mNoiseMapPtr = ctx.inputs().get("clnoisemap"); + mNoiseMap = mNoiseMapPtr.get(); + ILOG(Info, Support) << "NoiseMap loaded" << ENDM; + if (mNoiseMap == nullptr) { + ILOG(Error, Support) << "NoiseMap never loaded, leaving monitor" << ENDM; + return; + } + } + if (mChamberStatus == nullptr) { + ILOG(Info, Support) << "Getting chamber status from ccdb" << ENDM; + auto mChamberStatusPtr = ctx.inputs().get("clchamberstatus"); + mChamberStatus = mChamberStatusPtr.get(); + if (mChamberStatus == nullptr) { + ILOG(Error, Support) << "Chamber Status never loaded, leaving monitor" << ENDM; + return; + } + ILOG(Info, Support) << "Chamber Status loaded" << ENDM; + } + for (auto&& input : ctx.inputs()) { if (input.header != nullptr && input.payload != nullptr) { auto digits = ctx.inputs().get>("digits"); auto tracklets = ctx.inputs().get>("tracklets"); auto triggerrecords = ctx.inputs().get>("triggers"); - // std::cout << "Tracklets per time frame: " << tracklets.size(); mTrackletsPerTimeFrame->Fill(tracklets.size()); mTrackletsPerTimeFrameCycled->Fill(tracklets.size()); mTriggersPerTimeFrame->Fill(triggerrecords.size());