diff --git a/Detectors/TRD/calibration/include/TRDCalibration/DCSProcessor.h b/Detectors/TRD/calibration/include/TRDCalibration/DCSProcessor.h index 7ff85499835f4..27cba85a89941 100644 --- a/Detectors/TRD/calibration/include/TRDCalibration/DCSProcessor.h +++ b/Detectors/TRD/calibration/include/TRDCalibration/DCSProcessor.h @@ -63,14 +63,11 @@ class DCSProcessor bool updateVoltagesDPsCCDB(); bool updateCurrentsDPsCCDB(); bool updateEnvDPsCCDB(); - bool updateRunDPsCCDB(); - // LB: new DPs for Fed bool updateFedChamberStatusDPsCCDB(); bool updateFedCFGtagDPsCCDB(); // signal that the CCDB object for the voltages should be updated due to change exceeding threshold bool shouldUpdateVoltages() const { return mShouldUpdateVoltages; } - bool shouldUpdateRun() const { return mShouldUpdateRun; } // LB: Only update ChamberStatus/CFGtag if both conditions are met (complete DPs and new run) bool shouldUpdateFedChamberStatus() const { return mFedChamberStatusCompleteDPs && mFirstRunEntryForFedChamberStatusUpdate; } bool shouldUpdateFedCFGtag() const { return mFedCFGtagCompleteDPs && mFirstRunEntryForFedCFGtagUpdate; } @@ -91,14 +88,13 @@ class DCSProcessor CcdbObjectInfo& getccdbVoltagesDPsInfo() { return mCcdbVoltagesDPsInfo; } CcdbObjectInfo& getccdbCurrentsDPsInfo() { return mCcdbCurrentsDPsInfo; } CcdbObjectInfo& getccdbEnvDPsInfo() { return mCcdbEnvDPsInfo; } - CcdbObjectInfo& getccdbRunDPsInfo() { return mCcdbRunDPsInfo; } CcdbObjectInfo& getccdbFedChamberStatusDPsInfo() { return mCcdbFedChamberStatusDPsInfo; } CcdbObjectInfo& getccdbFedCFGtagDPsInfo() { return mCcdbFedCFGtagDPsInfo; } + const std::unordered_map& getTRDGasDPsInfo() const { return mTRDDCSGas; } const std::unordered_map& getTRDVoltagesDPsInfo() const { return mTRDDCSVoltages; } const std::unordered_map& getTRDCurrentsDPsInfo() const { return mTRDDCSCurrents; } const std::unordered_map& getTRDEnvDPsInfo() const { return mTRDDCSEnv; } - const std::unordered_map& getTRDRunDPsInfo() const { return mTRDDCSRun; } const std::array& getTRDFedChamberStatusDPsInfo() const { return mTRDDCSFedChamberStatus; } const std::array& getTRDFedCFGtagDPsInfo() const { return mTRDDCSFedCFGtag; } @@ -115,7 +111,6 @@ class DCSProcessor void clearCurrentsDPsInfo(); void clearEnvDPsInfo(); void clearRunDPsInfo(); - // LB: new DPs for Fed void clearFedChamberStatusDPsInfo(); void clearFedCFGtagDPsInfo(); @@ -128,8 +123,6 @@ class DCSProcessor std::unordered_map mTRDDCSCurrents; ///< anode and drift currents std::unordered_map mTRDDCSVoltages; ///< anode and drift voltages std::unordered_map mTRDDCSEnv; ///< environment parameters (temperatures, pressures, humidity) - std::unordered_map mTRDDCSRun; ///< run number (run type ignored) - // LB: new DPs for Fed std::array mTRDDCSFedChamberStatus; ///< fed chamber status std::array mTRDDCSFedCFGtag; ///< fed config tag @@ -140,8 +133,6 @@ class DCSProcessor CcdbObjectInfo mCcdbVoltagesDPsInfo; CcdbObjectInfo mCcdbCurrentsDPsInfo; CcdbObjectInfo mCcdbEnvDPsInfo; - CcdbObjectInfo mCcdbRunDPsInfo; - // LB: new DPs for Fed CcdbObjectInfo mCcdbFedChamberStatusDPsInfo; CcdbObjectInfo mCcdbFedCFGtagDPsInfo; @@ -149,9 +140,6 @@ class DCSProcessor TFType mVoltagesStartTS; ///< the time stamp of the first TF which was processesd for the current voltages CCDB object TFType mCurrentsStartTS; ///< the time stamp of the first TF which was processesd for the current voltages CCDB object TFType mEnvStartTS; - TFType mRunStartTS; - TFType mRunEndTS; - // LB: new DPs for Fed TFType mFedChamberStatusStartTS; TFType mFedCFGtagStartTS; TFType mCurrentTS{0}; ///< the time stamp of the TF currently being processed @@ -159,13 +147,10 @@ class DCSProcessor bool mVoltagesStartTSSet{false}; bool mCurrentsStartTSSet{false}; bool mEnvStartTSSet{false}; - bool mRunStartTSSet{false}; - // LB: new DPs for Fed bool mFedChamberStatusStartTSSet{false}; bool mFedCFGtagStartTSSet{false}; std::bitset mVoltageSet{}; bool mShouldUpdateVoltages{false}; - bool mShouldUpdateRun{false}; // LB: FedChamberStatus and FedCFGtag logic bool mFedChamberStatusCompleteDPs{false}; bool mFedCFGtagCompleteDPs{false}; @@ -174,8 +159,6 @@ class DCSProcessor int mCurrentRunNumber{-1}; int mFedChamberStatusAlarmCounter{0}; int mFedCFGtagAlarmCounter{0}; - // LB: for testing runNo object, turned off for now - // int mFinishedRunNumber; // settings int mVerbosity{0}; diff --git a/Detectors/TRD/calibration/src/DCSProcessor.cxx b/Detectors/TRD/calibration/src/DCSProcessor.cxx index ec86cbbd5df4d..165bbbd6a6148 100644 --- a/Detectors/TRD/calibration/src/DCSProcessor.cxx +++ b/Detectors/TRD/calibration/src/DCSProcessor.cxx @@ -197,46 +197,38 @@ int DCSProcessor::processDP(const DPCOM& dpcom) } if (type == DPVAL_INT) { - if (std::strstr(dpid.get_alias(), "trd_fed_runNo") != nullptr) { // DP is trd_fed_runNo - if (!mRunStartTSSet) { - mRunStartTS = mCurrentTS; - mRunStartTSSet = true; - } - - auto& runNumber = mTRDDCSRun[dpid]; - // LB: Check if new value is a valid run number (0 = cleared variable) + // check if DP is run number, only used for Chamber Status/CFGtag metadata + if (std::strstr(dpid.get_alias(), "trd_fed_runNo") != nullptr) { // DP is trd_fed_runNo + // LB: Check if new value is a valid run number (0 = cleared variable, -1 = start variable) if (o2::dcs::getValue(dpcom) > 0) { // If value has changed from previous one, new run has begun and update if (o2::dcs::getValue(dpcom) != mCurrentRunNumber) { LOG(info) << "New run number " << o2::dcs::getValue(dpcom) << " differs from the old one " << mCurrentRunNumber; - mShouldUpdateRun = true; // LB: two different flags as they reset separately, after upload of CCDB, for each object mFirstRunEntryForFedChamberStatusUpdate = true; mFirstRunEntryForFedCFGtagUpdate = true; // LB: reset alarm counters mFedChamberStatusAlarmCounter = 0; mFedCFGtagAlarmCounter = 0; - mRunEndTS = mCurrentTS; } // LB: Save current run number mCurrentRunNumber = o2::dcs::getValue(dpcom); - // Save to mTRDDCSRun - runNumber = mCurrentRunNumber; } if (mVerbosity > 2) { LOG(info) << "Current Run Number: " << mCurrentRunNumber; } - } else if (std::strstr(dpid.get_alias(), "trd_chamberStatus") != nullptr) { // DP is trd_chamberStatus + // check if DP is Chamber Status + } else if (std::strstr(dpid.get_alias(), "trd_chamberStatus") != nullptr) { if (!mFedChamberStatusStartTSSet) { mFedChamberStatusStartTS = mCurrentTS; mFedChamberStatusStartTSSet = true; } - // LB: for ChamberStatus, grab the chamber number from alias + // LB: grab the chamber number from alias int chamberId = getChamberIdFromAlias(dpid.get_alias()); auto& dpInfoFedChamberStatus = mTRDDCSFedChamberStatus[chamberId]; if (etime != mLastDPTimeStamps[dpid]) { @@ -261,7 +253,9 @@ int DCSProcessor::processDP(const DPCOM& dpcom) } if (type == DPVAL_STRING) { - if (std::strstr(dpid.get_alias(), "trd_CFGtag") != nullptr) { // DP is trd_CFGtag + + // check if DP is chamber configuration tag + if (std::strstr(dpid.get_alias(), "trd_CFGtag") != nullptr) { if (!mFedCFGtagStartTSSet) { mFedCFGtagStartTS = mCurrentTS; mFedCFGtagStartTSSet = true; @@ -476,38 +470,6 @@ bool DCSProcessor::updateEnvDPsCCDB() return retVal; } -bool DCSProcessor::updateRunDPsCCDB() -{ - // here we create the object containing the run data points to then be sent to CCDB - LOG(info) << "Preparing CCDB object for TRD run DPs"; - - bool retVal = false; // set to 'true' in case at least one DP for run has been processed - - for (const auto& it : mPids) { - const auto& type = it.first.get_type(); - if (type == o2::dcs::DPVAL_INT) { - if (std::strstr(it.first.get_alias(), "trd_fed_run") != nullptr) { - if (it.second == true) { // we processed the DP at least 1x - retVal = true; - } - if (mVerbosity > 0) { - LOG(info) << "PID = " << it.first.get_alias() << ". Value = " << mTRDDCSRun[it.first]; - } - } - } - } - std::map md; - md["responsible"] = "Leonardo Barreto"; - // Redundancy for testing, this object is updated after run ended, so need to write old run number, not current - // md["runNumber"] = std::to_string(mFinishedRunNumber); - o2::calibration::Utils::prepareCCDBobjectInfo(mTRDDCSRun, mCcdbRunDPsInfo, "TRD/Calib/DCSDPsRun", md, mRunStartTS, mRunEndTS); - - // LB: Deactivated upload of Run DPs to CCDB even if processed - // To turn it back on just comment the next line - retVal = false; - return retVal; -} - bool DCSProcessor::updateFedChamberStatusDPsCCDB() { // here we create the object containing the fedChamberStatus data points to then be sent to CCDB @@ -533,9 +495,9 @@ bool DCSProcessor::updateFedChamberStatusDPsCCDB() std::map md; md["responsible"] = "Leonardo Barreto"; md["runNumber"] = std::to_string(mCurrentRunNumber); - // LB: set start timestamp 30 seconds before DPs are received + // LB: set start timestamp 30000 miliseconds before DPs are received o2::calibration::Utils::prepareCCDBobjectInfo(mTRDDCSFedChamberStatus, mCcdbFedChamberStatusDPsInfo, - "TRD/Calib/DCSDPsFedChamberStatus", md, mFedChamberStatusStartTS - 30, + "TRD/Calib/DCSDPsFedChamberStatus", md, mFedChamberStatusStartTS - 30000, mFedChamberStatusStartTS + 3 * o2::ccdb::CcdbObjectInfo::DAY); return retVal; @@ -566,9 +528,9 @@ bool DCSProcessor::updateFedCFGtagDPsCCDB() std::map md; md["responsible"] = "Leonardo Barreto"; md["runNumber"] = std::to_string(mCurrentRunNumber); - // LB: set start timestamp 30 seconds before DPs are received + // LB: set start timestamp 30000 seconds before DPs are received o2::calibration::Utils::prepareCCDBobjectInfo(mTRDDCSFedCFGtag, mCcdbFedCFGtagDPsInfo, - "TRD/Calib/DCSDPsFedCFGtag", md, mFedCFGtagStartTS - 30, + "TRD/Calib/DCSDPsFedCFGtag", md, mFedCFGtagStartTS - 30000, mFedCFGtagStartTS + 3 * o2::ccdb::CcdbObjectInfo::DAY); return retVal; @@ -637,22 +599,6 @@ void DCSProcessor::clearEnvDPsInfo() } } -void DCSProcessor::clearRunDPsInfo() -{ - mTRDDCSRun.clear(); - mRunStartTSSet = false; - mShouldUpdateRun = false; - // reset the 'processed' flags for the run DPs - for (auto& it : mPids) { - const auto& type = it.first.get_type(); - if (type == o2::dcs::DPVAL_INT) { - if (std::strstr(it.first.get_alias(), "trd_fed_run") != nullptr) { - it.second = false; - } - } - } -} - void DCSProcessor::clearFedChamberStatusDPsInfo() { // mTRDDCSFedChamberStatus should not be cleared after upload giving alarm/warn logic diff --git a/Detectors/TRD/calibration/workflow/TRDDCSDataProcessorSpec.h b/Detectors/TRD/calibration/workflow/TRDDCSDataProcessorSpec.h index 8cff9a19a685e..b601448c286fd 100644 --- a/Detectors/TRD/calibration/workflow/TRDDCSDataProcessorSpec.h +++ b/Detectors/TRD/calibration/workflow/TRDDCSDataProcessorSpec.h @@ -150,12 +150,14 @@ class TRDDCSDataProcessor : public o2::framework::Task LOG(info) << "Invalid voltage variation trigger of DPs to update Anode/DriftUMon to " << utrigger << ", using default value of 1 V"; } + mUploadAtEoS = ic.options().get("enable-uploadAtEoS"); + LOG(info) << "Setting upload of CCDB objects at end of stream to " << mUploadAtEoS; + mProcessor->init(vect); mTimerGas = std::chrono::high_resolution_clock::now(); mTimerVoltages = mTimerGas; mTimerCurrents = mTimerGas; mTimerEnv = mTimerGas; - // LB: new DPs for Fed mTimerFedChamberStatus = mTimerGas; mTimerFedCFGtag = mTimerGas; @@ -201,7 +203,6 @@ class TRDDCSDataProcessor : public o2::framework::Task mTimerEnv = timeNow; } - // LB: processing logic for FedChamberStatus and FedCFGtag if (mProcessor->shouldUpdateFedChamberStatus()) { sendDPsoutputFedChamberStatus(pc.outputs()); } @@ -210,10 +211,8 @@ class TRDDCSDataProcessor : public o2::framework::Task sendDPsoutputFedCFGtag(pc.outputs()); } - if (mProcessor->shouldUpdateRun()) { - sendDPsoutputRun(pc.outputs()); - } sw.Stop(); + if (mReportTiming) { LOGP(info, "Timing CPU:{:.3e} Real:{:.3e} at slice {}", sw.CpuTime(), sw.RealTime(), pc.services().get().timeslice); } @@ -221,24 +220,26 @@ class TRDDCSDataProcessor : public o2::framework::Task void endOfStream(o2::framework::EndOfStreamContext& ec) final { - sendDPsoutputGas(ec.outputs()); - sendDPsoutputVoltages(ec.outputs()); - sendDPsoutputCurrents(ec.outputs()); - sendDPsoutputEnv(ec.outputs()); - sendDPsoutputRun(ec.outputs()); - // LB: new DPs for Fed - sendDPsoutputFedChamberStatus(ec.outputs()); - sendDPsoutputFedCFGtag(ec.outputs()); + // LB: no objects should be uploaded at end of stream, unless stated otherwise + if (mUploadAtEoS) { + LOG(info) << "End of stream upload of CCDB objects"; + sendDPsoutputGas(ec.outputs()); + sendDPsoutputVoltages(ec.outputs()); + sendDPsoutputCurrents(ec.outputs()); + sendDPsoutputEnv(ec.outputs()); + } else { + LOG(info) << "No CCDB object upload done at the end of stream"; + } } private: + bool mUploadAtEoS = false; bool mReportTiming = false; std::unique_ptr mProcessor; std::chrono::high_resolution_clock::time_point mTimerGas; std::chrono::high_resolution_clock::time_point mTimerVoltages; std::chrono::high_resolution_clock::time_point mTimerCurrents; std::chrono::high_resolution_clock::time_point mTimerEnv; - // LB: new DPs for Fed std::chrono::high_resolution_clock::time_point mTimerFedChamberStatus; std::chrono::high_resolution_clock::time_point mTimerFedCFGtag; @@ -247,7 +248,6 @@ class TRDDCSDataProcessor : public o2::framework::Task int64_t mCurrentsDPsUpdateInterval; int64_t mMinUpdateIntervalU; int64_t mEnvDPsUpdateInterval; - // LB: new DPs for Fed int64_t mFedChamberStatusDPsUpdateInterval; int64_t mFedCFGtagDPsUpdateInterval; @@ -325,27 +325,6 @@ class TRDDCSDataProcessor : public o2::framework::Task } } - //________________________________________________________________ - void sendDPsoutputRun(DataAllocator& output) - { - // extract CCDB infos and calibration object for DPs - if (mProcessor->updateRunDPsCCDB()) { - const auto& payload = mProcessor->getTRDRunDPsInfo(); - auto& info = mProcessor->getccdbRunDPsInfo(); - auto image = o2::ccdb::CcdbApi::createObjectImage(&payload, &info); - LOG(info) << "Sending object " << info.getPath() << "/" << info.getFileName() << " of size " << image->size() - << " bytes, valid for " << info.getStartValidityTimestamp() << " : " << info.getEndValidityTimestamp(); - output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, "TRD_DCSRunDPs", 0}, *image.get()); - output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "TRD_DCSRunDPs", 0}, info); - mProcessor->clearRunDPsInfo(); - } else { - auto& info = mProcessor->getccdbRunDPsInfo(); - // LOG(info) << "Not sending object " << info.getPath() << "/" << info.getFileName() << " since no DPs were processed for it"; - LOG(info) << "Not sending object " << info.getPath() << "/" << info.getFileName() << " as upload of Run DPs was deactivated"; - } - } - - // LB: new DP for FedChamberStatus //________________________________________________________________ void sendDPsoutputFedChamberStatus(DataAllocator& output) { @@ -365,7 +344,6 @@ class TRDDCSDataProcessor : public o2::framework::Task } } - // LB: new DP for FedCFGtag //________________________________________________________________ void sendDPsoutputFedCFGtag(DataAllocator& output) { @@ -395,18 +373,14 @@ DataProcessorSpec getTRDDCSDataProcessorSpec() { std::vector outputs; - outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "TRD_DCSGasDPs"}, Lifetime::Sporadic); outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "TRD_DCSGasDPs"}, Lifetime::Sporadic); outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "TRD_DCSUDPs"}, Lifetime::Sporadic); outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "TRD_DCSUDPs"}, Lifetime::Sporadic); outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "TRD_DCSIDPs"}, Lifetime::Sporadic); outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "TRD_DCSIDPs"}, Lifetime::Sporadic); - outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "TRD_DCSRunDPs"}, Lifetime::Sporadic); - outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "TRD_DCSRunDPs"}, Lifetime::Sporadic); outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "TRD_DCSEnvDPs"}, Lifetime::Sporadic); outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "TRD_DCSEnvDPs"}, Lifetime::Sporadic); - // LB: new DPs for Fed // Must use reduced names due to initializer string cannot exceed descriptor size in Data Format outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "TRD_ChamberStat"}, Lifetime::Sporadic); outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "TRD_ChamberStat"}, Lifetime::Sporadic); @@ -429,7 +403,8 @@ DataProcessorSpec getTRDDCSDataProcessorSpec() {"DPs-voltage-variation-trigger", VariantType::Int64, 1ll, {"Voltage variation trigger for upload of CCDB object"}}, {"DPs-update-interval-gas", VariantType::Int64, 900ll, {"Interval (in s) after which to update the DPs CCDB entry for gas parameters"}}, {"DPs-max-counter-alarm-fed", VariantType::Int, 1, {"Maximum number of alarms after FedChamberStatus and FedCFGtag changes, following changes are logged as warnings"}}, - {"DPs-min-counter-update-fed", VariantType::Int, 522, {"Minimum number of DPs to update FedChamberStatus and FedCFGtag objects"}}}}; + {"DPs-min-counter-update-fed", VariantType::Int, 522, {"Minimum number of DPs to update FedChamberStatus and FedCFGtag objects"}}, + {"enable-uploadAtEoS", VariantType::Bool, false, {"Upload CCDB objects at end of stream"}}}}; } } // namespace framework