diff --git a/CCDB/include/CCDB/CcdbObjectInfo.h b/CCDB/include/CCDB/CcdbObjectInfo.h index fc9776b5c8f40..11d1058f709e4 100644 --- a/CCDB/include/CCDB/CcdbObjectInfo.h +++ b/CCDB/include/CCDB/CcdbObjectInfo.h @@ -24,6 +24,15 @@ namespace o2::ccdb class CcdbObjectInfo { public: + // time intervals in milliseconds + static constexpr long SECOND = 1000; + static constexpr long MINUTE = 60 * SECOND; + static constexpr long HOUR = 60 * MINUTE; + static constexpr long DAY = 24 * HOUR; + static constexpr long MONTH = 30 * DAY; + static constexpr long YEAR = 364 * DAY; + static constexpr long INFINITE_TIMESTAMP = 9999999999999; + CcdbObjectInfo() = default; CcdbObjectInfo(std::string path, std::string objType, std::string flName, std::map metadata, diff --git a/Detectors/Base/README.md b/Detectors/Base/README.md index b5b6db3a265fa..723d28d57088d 100644 --- a/Detectors/Base/README.md +++ b/Detectors/Base/README.md @@ -25,21 +25,24 @@ and the method `GRPGeomRequest::instance()->checkUpdates(pc)` is called in the b ```cpp class MyTask { public: - MyTask(std::shared_ptr req, ...) - { - GRPGeomRequest::instance()->setRequest(req); + MyTask(std::shared_ptr req, ...) : mCCDBReq(req) { + } + void init(o2::framework::InitContext& ic) { + GRPGeomHelper::instance()->setRequest(req); ... } void finaliseCCDB(ConcreteDataMatcher& matcher, void* obj) { - GRPGeomRequest::instance()->finaliseCCDB(matcher, obj); + GRPGeomHelper::instance()->finaliseCCDB(matcher, obj); ... } void run(ProcessingContext& pc) { - GRPGeomRequest::instance()->checkUpdates(pc); + GRPGeomHelper::instance()->checkUpdates(pc); ... } + protected: + std::shared_ptr mCCDBReq; }; ``` diff --git a/Detectors/Base/include/DetectorsBase/GRPGeomHelper.h b/Detectors/Base/include/DetectorsBase/GRPGeomHelper.h index 3e7f04fd79211..43e8699eaa2bf 100644 --- a/Detectors/Base/include/DetectorsBase/GRPGeomHelper.h +++ b/Detectors/Base/include/DetectorsBase/GRPGeomHelper.h @@ -17,6 +17,7 @@ #define ALICEO2_GRPGEOM_HELPER #include +#include #include "DetectorsCommonDataFormats/DetID.h" namespace o2::framework @@ -60,18 +61,23 @@ class MatLayerCylSet; I.e the task should look like: class MyTask { public: - MyTask(std::shared_ptr req, ...) { - GRPGeomRequest::instance()->setRequest(req); + MyTask(std::shared_ptr req, ...) : mCCDBReq(req) { + ... + } + void init(o2::framework::InitContext& ic) { + GRPGeomHelper::instance()->setRequest(mCCDBReq); ... } void finaliseCCDB(ConcreteDataMatcher& matcher, void* obj) { - GRPGeomRequest::instance()->finaliseCCDB(matcher, obj); + GRPGeomHelper::instance()->finaliseCCDB(matcher, obj); ... } void run(ProcessingContext& pc) { - GRPGeomRequest::instance()->checkUpdates(pc); + GRPGeomHelper::instance()->checkUpdates(pc); ... } + protected: + std::shared_ptr mCCDBReq; } */ @@ -117,6 +123,8 @@ class GRPGeomHelper auto getGRPMagField() const { return mGRPMagField; } auto getOrbitResetTimeMS() const { return mOrbitResetTimeMS; } + static int getNHBFPerTF(); + private: GRPGeomHelper() = default; diff --git a/Detectors/Base/src/GRPGeomHelper.cxx b/Detectors/Base/src/GRPGeomHelper.cxx index 22db23d34316d..3eff4192d96ae 100644 --- a/Detectors/Base/src/GRPGeomHelper.cxx +++ b/Detectors/Base/src/GRPGeomHelper.cxx @@ -176,3 +176,8 @@ void GRPGeomHelper::checkUpdates(ProcessingContext& pc) const } } } + +int GRPGeomHelper::getNHBFPerTF() +{ + return instance().mGRPECS ? instance().mGRPECS->getNHBFPerTF() : 128; +} diff --git a/Detectors/CPV/calib/CPVCalibWorkflow/src/CPVBadMapCalibDevice.cxx b/Detectors/CPV/calib/CPVCalibWorkflow/src/CPVBadMapCalibDevice.cxx index b35c97819035c..42d0629b7313b 100644 --- a/Detectors/CPV/calib/CPVCalibWorkflow/src/CPVBadMapCalibDevice.cxx +++ b/Detectors/CPV/calib/CPVCalibWorkflow/src/CPVBadMapCalibDevice.cxx @@ -163,7 +163,7 @@ void CPVBadMapCalibDevice::sendOutput(DataAllocator& output) // TODO: should be changed to time of the run time_t now = time(nullptr); info.setStartValidityTimestamp(now); - info.setEndValidityTimestamp(99999999999999); + info.setEndValidityTimestamp(o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); std::map md; info.setMetaData(md); diff --git a/Detectors/CPV/calib/CPVCalibWorkflow/src/CPVGainCalibDevice.cxx b/Detectors/CPV/calib/CPVCalibWorkflow/src/CPVGainCalibDevice.cxx index 6044ba1322e5c..c3d0a6dd05a33 100644 --- a/Detectors/CPV/calib/CPVCalibWorkflow/src/CPVGainCalibDevice.cxx +++ b/Detectors/CPV/calib/CPVCalibWorkflow/src/CPVGainCalibDevice.cxx @@ -113,7 +113,7 @@ void CPVGainCalibDevice::sendOutput(DataAllocator& output) // TODO: should be changed to time of the run time_t now = time(nullptr); info.setStartValidityTimestamp(now); - info.setEndValidityTimestamp(99999999999999); + info.setEndValidityTimestamp(o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); std::map md; info.setMetaData(md); diff --git a/Detectors/CPV/calib/CPVCalibWorkflow/src/CPVPedestalCalibDevice.cxx b/Detectors/CPV/calib/CPVCalibWorkflow/src/CPVPedestalCalibDevice.cxx index 30faed25b36b0..699c8715bb46c 100644 --- a/Detectors/CPV/calib/CPVCalibWorkflow/src/CPVPedestalCalibDevice.cxx +++ b/Detectors/CPV/calib/CPVCalibWorkflow/src/CPVPedestalCalibDevice.cxx @@ -106,7 +106,7 @@ void CPVPedestalCalibDevice::sendOutput(DataAllocator& output) const auto now = std::chrono::system_clock::now(); long timeStart = std::chrono::duration_cast(now.time_since_epoch()).count(); info.setStartValidityTimestamp(timeStart); - info.setEndValidityTimestamp(99999999999999); + info.setEndValidityTimestamp(o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); std::map md; info.setMetaData(md); diff --git a/Detectors/CPV/calib/include/CPVCalibration/NoiseCalibrator.h b/Detectors/CPV/calib/include/CPVCalibration/NoiseCalibrator.h index 6e86ede603c8a..447fd09c33fec 100644 --- a/Detectors/CPV/calib/include/CPVCalibration/NoiseCalibrator.h +++ b/Detectors/CPV/calib/include/CPVCalibration/NoiseCalibrator.h @@ -62,7 +62,7 @@ class NoiseCalibrator final : public o2::calibration::TimeSlotCalibration> mPedEfficiencies = nullptr; diff --git a/Detectors/CPV/calib/include/CPVCalibration/PedestalCalibrator.h b/Detectors/CPV/calib/include/CPVCalibration/PedestalCalibrator.h index 6a10189eb5bf3..dc5445068df8a 100644 --- a/Detectors/CPV/calib/include/CPVCalibration/PedestalCalibrator.h +++ b/Detectors/CPV/calib/include/CPVCalibration/PedestalCalibrator.h @@ -94,7 +94,7 @@ class PedestalCalibrator final : public o2::calibration::TimeSlotCalibration req) : mCCDBRequest(req) {} + //_________________________________________________________________ void init(o2::framework::InitContext& ic) final { - uint64_t slotL = ic.options().get("tf-per-slot"); - uint64_t delay = ic.options().get("max-delay"); - uint64_t updateInterval = ic.options().get("updateInterval"); + o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest); + auto slotL = ic.options().get("tf-per-slot"); + auto delay = ic.options().get("max-delay"); + auto updateInterval = ic.options().get("updateInterval"); bool updateAtTheEndOfRunOnly = ic.options().get("updateAtTheEndOfRunOnly"); mCalibrator = std::make_unique(); mCalibrator->setSlotLength(slotL); @@ -50,9 +54,16 @@ class CPVNoiseCalibratorSpec : public o2::framework::Task LOG(info) << "updateInterval = " << updateInterval; LOG(info) << "updateAtTheEndOfRunOnly = " << updateAtTheEndOfRunOnly; } + + void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final + { + o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj); + } + //_________________________________________________________________ void run(o2::framework::ProcessingContext& pc) final { + o2::base::GRPGeomHelper::instance().checkUpdates(pc); o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mCalibrator->getCurrentTFInfo()); TFType tfcounter = mCalibrator->getCurrentTFInfo().startTime; auto&& digits = pc.inputs().get>("digits"); @@ -107,6 +118,7 @@ class CPVNoiseCalibratorSpec : public o2::framework::Task //_________________________________________________________________ private: std::unique_ptr mCalibrator; + std::shared_ptr mCCDBRequest; void sendOutput(DataAllocator& output) { @@ -145,7 +157,13 @@ DataProcessorSpec getCPVNoiseCalibratorSpec() inputs.emplace_back("pedeffs", "CPV", "CPV_PedEffs", 0, Lifetime::Condition, ccdbParamSpec("CPV/PedestalRun/ChannelEfficiencies")); inputs.emplace_back("deadchs", "CPV", "CPV_DeadChnls", 0, Lifetime::Condition, ccdbParamSpec("CPV/PedestalRun/DeadChannels")); inputs.emplace_back("highpeds", "CPV", "CPV_HighThrs", 0, Lifetime::Condition, ccdbParamSpec("CPV/PedestalRun/HighPedChannels")); - + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputs); std::vector outputs; // Length of data description ("CPV_Pedestals") must be < 16 characters. outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "CPV_BadMap"}, Lifetime::Sporadic); @@ -155,12 +173,12 @@ DataProcessorSpec getCPVNoiseCalibratorSpec() "cpv-noise-calibration", inputs, outputs, - AlgorithmSpec{adaptFromTask()}, + AlgorithmSpec{adaptFromTask(ccdbRequest)}, Options{ - {"tf-per-slot", VariantType::UInt64, (uint64_t)std::numeric_limits::max(), {"number of TFs per calibration time slot"}}, - {"max-delay", VariantType::UInt64, uint64_t(1000), {"number of slots in past to consider"}}, + {"tf-per-slot", VariantType::UInt32, o2::calibration::INFINITE_TF, {"number of TFs per calibration time slot, if 0: finalize once statistics is reached"}}, + {"max-delay", VariantType::UInt32, 1000u, {"number of slots in past to consider"}}, {"updateAtTheEndOfRunOnly", VariantType::Bool, false, {"finalize the slots and prepare the CCDB entries only at the end of the run."}}, - {"updateInterval", VariantType::UInt64, (uint64_t)10, {"try to finalize the slot (and produce calibration) when the updateInterval has passed.\n To be used together with tf-per-slot = std::numeric_limits::max()"}}}}; + {"updateInterval", VariantType::UInt32, 10u, {"try to finalize the slot (and produce calibration) when the updateInterval has passed.\n To be used together with tf-per-slot = 0"}}}}; } } // namespace framework } // namespace o2 diff --git a/Detectors/CPV/calib/testWorkflow/PedestalCalibratorSpec.h b/Detectors/CPV/calib/testWorkflow/PedestalCalibratorSpec.h index 2c3a7627f1ace..771dd8588e5f7 100644 --- a/Detectors/CPV/calib/testWorkflow/PedestalCalibratorSpec.h +++ b/Detectors/CPV/calib/testWorkflow/PedestalCalibratorSpec.h @@ -19,6 +19,7 @@ #include "CPVCalibration/PedestalCalibrator.h" #include "DataFormatsCPV/Digit.h" #include "DataFormatsCPV/TriggerRecord.h" +#include "DetectorsBase/GRPGeomHelper.h" using namespace o2::framework; @@ -29,9 +30,11 @@ namespace calibration class CPVPedestalCalibratorSpec : public o2::framework::Task { public: + CPVPedestalCalibratorSpec(std::shared_ptr req) : mCCDBRequest(req) {} //_________________________________________________________________ void init(o2::framework::InitContext& ic) final { + o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest); uint64_t slotL = ic.options().get("tf-per-slot"); uint64_t delay = ic.options().get("max-delay"); uint64_t updateInterval = ic.options().get("updateInterval"); @@ -49,9 +52,17 @@ class CPVPedestalCalibratorSpec : public o2::framework::Task LOG(info) << "updateInterval = " << updateInterval; LOG(info) << "updateAtTheEndOfRunOnly = " << updateAtTheEndOfRunOnly; } + + //_________________________________________________________________ + void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final + { + o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj); + } + //_________________________________________________________________ void run(o2::framework::ProcessingContext& pc) final { + o2::base::GRPGeomHelper::instance().checkUpdates(pc); o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mCalibrator->getCurrentTFInfo()); TFType tfcounter = mCalibrator->getCurrentTFInfo().startTime; auto&& digits = pc.inputs().get>("digits"); @@ -82,6 +93,7 @@ class CPVPedestalCalibratorSpec : public o2::framework::Task private: std::unique_ptr mCalibrator; + std::shared_ptr mCCDBRequest; void sendOutput(DataAllocator& output) { @@ -136,6 +148,7 @@ class CPVPedestalCalibratorSpec : public o2::framework::Task } }; // class CPVPedestalCalibratorSpec } // namespace calibration + namespace framework { DataProcessorSpec getCPVPedestalCalibratorSpec() @@ -154,19 +167,25 @@ DataProcessorSpec getCPVPedestalCalibratorSpec() outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "CPV_DeadChnls"}, Lifetime::Sporadic); outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "CPV_HighThrs"}, Lifetime::Sporadic); outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "CPV_HighThrs"}, Lifetime::Sporadic); - + std::vector inputs{{"digits", "CPV", "DIGITS"}, + {"trigrecs", "CPV", "DIGITTRIGREC"}}; + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputs); return DataProcessorSpec{ "cpv-pedestal-calibration", - Inputs{ - {"digits", "CPV", "DIGITS"}, - {"trigrecs", "CPV", "DIGITTRIGREC"}}, + inputs, outputs, - AlgorithmSpec{adaptFromTask()}, + AlgorithmSpec{adaptFromTask(ccdbRequest)}, Options{ - {"tf-per-slot", VariantType::UInt64, (uint64_t)std::numeric_limits::max(), {"number of TFs per calibration time slot"}}, - {"max-delay", VariantType::UInt64, uint64_t(1000), {"number of slots in past to consider"}}, + {"tf-per-slot", VariantType::UInt32, o2::calibration::INFINITE_TF, {"number of TFs per calibration time slot, if 0: finalize once statistics is reached"}}, + {"max-delay", VariantType::UInt32, 1000u, {"number of slots in past to consider"}}, {"updateAtTheEndOfRunOnly", VariantType::Bool, false, {"finalize the slots and prepare the CCDB entries only at the end of the run."}}, - {"updateInterval", VariantType::UInt64, (uint64_t)10, {"try to finalize the slot (and produce calibration) when the updateInterval has passed.\n To be used together with tf-per-slot = std::numeric_limits::max()"}}}}; + {"updateInterval", VariantType::UInt32, 10u, {"try to finalize the slot (and produce calibration) when the updateInterval has passed.\n To be used together with tf-per-slot = 0"}}}}; } } // namespace framework } // namespace o2 diff --git a/Detectors/Calibration/README.md b/Detectors/Calibration/README.md index f39fc3f879628..9e74903cbf4ca 100644 --- a/Detectors/Calibration/README.md +++ b/Detectors/Calibration/README.md @@ -9,15 +9,17 @@ The calibration flow of O2 foresees that every calibration device (expected to a ## TimeSlotCalibration Each calibration device (to be run in a workflow) has to derive from `o2::calibration::TimeSlotCalibration`, which is a templated class that takes as types the Input type (i.e. the object to be processed, coming from the upstream device) and the Container type (i.e. the object that will contain the calibration data per TimeSlot). Each calibration device has to be configured with the following parameters: -```cpp -tf-per-slot : default length of a TiemSlot in TFs (will be widened in case of too little statistics). If this is set to `std::numeric_limits::max()`, then there will be - only 1 slot at a time, valid till infinity. -updateInterval : to be used together with `tf-per-slot = std::numeric_limits::max()`: it allows to try to finalize the slot (and produce calibration) when the `updateInterval` - has passed. Note that this is an approximation (as explained in the code) due to the fact that TFs will come asynchronously (not ordered in time). -max-delay : maximum arrival delay of a TF with respect to the most recent one processed; units in number of TimeSlots; if beyond this, the TF will be considered too old, and discarded. - If `tf-per-slot == std::numeric_limits::max()`, or `updateAtTheEndOfRunOnly == true`, its value is irrelevant. -updateAtTheEndOfRunOnly : to tell the TimeCalibration to finalize the slots and prepare the CCDB entries only at the end of the run. -``` +`tf-per-slot` : default length of a TiemSlot in TFs (will be widened in case of too little statistics). If this is set to `o2::calibration::INFINITE_TF`, then there will be only 1 slot at a time, valid till infinity. Value 0 is reserved for a special mode: a single slot w/o explicit boundaries is +filled until the requested statistics is reached. Once `hasEnoughData` return true, the slot will be closed with really seen min/max TFs and new one will be created with lower boundary equal the end of the previous slot. +The slot duration can be also set via methods `setSlotLengthInSeconds(int s)` or `setSlotLengthInOrbits(int n)`, which will be internally converted (and rounded) to the number of TFs at the 1st TF processing (when the NHBF per orbit will be available from the GRPECS). + +`updateInterval` : to be used together with `tf-per-slot = o2::calibration::INFINITE_TF`: it allows to try to finalize the slot (and produce calibration) when the `updateInterval` has passed. Note that this is an approximation (as explained in the code) due to the fact that TFs will come asynchronously (not ordered in time). + +`max-delay` : maximum arrival delay of a TF with respect to the most recent one processed; units in number of TimeSlots; if beyond this, the TF will be considered too old, and discarded. +If `tf-per-slot == o2::calibration::INFINITE_TF`, or `updateAtTheEndOfRunOnly == true`, its value is irrelevant. + +`updateAtTheEndOfRunOnly` : to tell the TimeCalibration to finalize the slots and prepare the CCDB entries only at the end of the run. + Example for the options above: `tf-per-slot = 20` `max-delay = 3` @@ -31,7 +33,7 @@ Each calibration device has to implement the following methods: `void finalizeSlot(o2::calibration::TimeSlot& slot)` : method to process the calibration data accumulated in each TimeSlot; -`o2::calibration::TimeSlot& slot emplaceNewSlot(bool front, uint64_t tstart, uint64_t tend` : method to creata a new TimeSlot; this is specific to the calibration procedure as it instantiates the detector-calibration-specific object. +`o2::calibration::TimeSlot& slot emplaceNewSlot(bool front, TFType tstart, TFType tend)` : method to creata a new TimeSlot; this is specific to the calibration procedure as it instantiates the detector-calibration-specific object. See e.g. LHCClockCalibrator.h/cxx in AliceO2/Detectors/TOF/calibration/include/TOFCalibration/LHCClockCalibrator.h and AliceO2/Detectors/TOF/calibration/srcLHCClockCalibrator.cxx @@ -51,6 +53,8 @@ If provided, this latter method will be used. See e.g. LHCClockCalibrator.h/cxx in AliceO2/Detectors/TOF/calibration/include/TOFCalibration/LHCClockCalibrator.h and AliceO2/Detectors/TOF/calibration/srcLHCClockCalibrator.cxx +The Slot provides a generic methods to access its boundaries: `getTFStart()` and `getTFEnd()` in terms of TF counter (as assigned by the DataDistribution) and `getStartTimeMS()`, `getEndTimeMS()` for the absolute time stamp in milleseconds. + ## detector-specific-calibrator-workflow Each calibration will need to be implemented in the form of a workflow, whose options should include those for the calibration device itself (`tf-per-slot` and `max-delay`, see above). @@ -68,6 +72,8 @@ output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, "TOF_LHCph output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "TOF_LHCphase", i}, w); // root-serialized ``` +Note that in order to access the absolute time of the slot boundaries, one should subscribe to CTP orbit reset time object (at least) via GRPGeomHelper class. + See e.g. AliceO2/Detectors/TOF/calibration/testWorkflow/LHCClockCalibratorSpec.h, AliceO2/Detectors/TOF/calibration/testWorkflow/lhc-clockphase-workflow.cxx ## ccdb-populator-workflow diff --git a/Detectors/Calibration/include/DetectorsCalibration/MeanVertexCalibrator.h b/Detectors/Calibration/include/DetectorsCalibration/MeanVertexCalibrator.h index a5ccceb9ebbb1..9c628f1bab58a 100644 --- a/Detectors/Calibration/include/DetectorsCalibration/MeanVertexCalibrator.h +++ b/Detectors/Calibration/include/DetectorsCalibration/MeanVertexCalibrator.h @@ -30,7 +30,6 @@ class MeanVertexCalibrator final : public o2::calibration::TimeSlotCalibration; using MVObject = o2::dataformats::MeanVertexObject; using MVObjectVector = std::vector; @@ -86,9 +85,9 @@ class MeanVertexCalibrator final : public o2::calibration::TimeSlotCalibration mTmpMVobjDq; // This is the deque of MeanVertex objecs that will be used for the // simple moving average MVObject mSMAMVobj; // object containing the Simple Moving Average to be put to CCDB - std::deque mTmpMVobjDqTimeStart; // This is the deque of MeanVertex objecs that will be used for the + std::deque mTmpMVobjDqTimeStart; // This is the deque of MeanVertex objecs that will be used for the // simple moving average, start time of used TFs - std::deque> mTmpMVobjDqTime; // This is the deque for the start and end time of the + std::deque> mTmpMVobjDqTime; // This is the deque for the start and end time of the // slots used for the SMA std::deque mTmpMVdataDq; // This is the vector of Mean Vertex data to be used for the simple // moving average diff --git a/Detectors/Calibration/include/DetectorsCalibration/MeanVertexParams.h b/Detectors/Calibration/include/DetectorsCalibration/MeanVertexParams.h index 5de4f74de317e..b7ee88aee5378 100644 --- a/Detectors/Calibration/include/DetectorsCalibration/MeanVertexParams.h +++ b/Detectors/Calibration/include/DetectorsCalibration/MeanVertexParams.h @@ -34,8 +34,8 @@ struct MeanVertexParams : public o2::conf::ConfigurableParamHelper, TPCVDTglContainer> { - using TFType = uint64_t; using Slot = o2::calibration::TimeSlot; public: TPCVDriftTglCalibration() = default; - TPCVDriftTglCalibration(int ntgl, float tglMax, int ndtgl, float dtglMax, size_t slotL, size_t minEnt) : mNBinsTgl(ntgl), mMaxTgl(tglMax), mNBinsDTgl(ndtgl), mMaxDTgl(dtglMax), mMineEntriesPerSlot(minEnt) + TPCVDriftTglCalibration(int ntgl, float tglMax, int ndtgl, float dtglMax, uint32_t slotL, size_t minEnt) : mNBinsTgl(ntgl), mMaxTgl(tglMax), mNBinsDTgl(ndtgl), mMaxDTgl(dtglMax), mMineEntriesPerSlot(minEnt) { setSlotLength(slotL); - setMaxSlotsDelay(slotL); + setMaxSlotsDelay(10); } ~TPCVDriftTglCalibration() final = default; diff --git a/Detectors/Calibration/include/DetectorsCalibration/TimeSlot.h b/Detectors/Calibration/include/DetectorsCalibration/TimeSlot.h index fbc2fa44847e1..e514ccac8d37f 100644 --- a/Detectors/Calibration/include/DetectorsCalibration/TimeSlot.h +++ b/Detectors/Calibration/include/DetectorsCalibration/TimeSlot.h @@ -16,6 +16,8 @@ #include #include "Framework/Logger.h" #include "CommonDataFormat/TFIDInfo.h" +#include "CommonConstants/LHCConstants.h" +#include "DetectorsBase/GRPGeomHelper.h" /// @brief Wrapper for the container of calibration data for single time slot @@ -24,7 +26,8 @@ namespace o2 namespace calibration { -using TFType = uint64_t; +using TFType = uint32_t; +inline constexpr TFType INFINITE_TF = std::numeric_limits::max(); template class TimeSlot @@ -47,12 +50,18 @@ class TimeSlot TFType getTFStart() const { return mTFStart; } TFType getTFEnd() const { return mTFEnd; } + + long getStartTimeMS() const { return o2::base::GRPGeomHelper::instance().getOrbitResetTimeMS() + (mRunStartOrbit + long(o2::base::GRPGeomHelper::getNHBFPerTF()) * mTFStart) * o2::constants::lhc::LHCOrbitMUS / 1000; } + long getEndTimeMS() const { return o2::base::GRPGeomHelper::instance().getOrbitResetTimeMS() + (mRunStartOrbit + long(o2::base::GRPGeomHelper::getNHBFPerTF()) * (mTFEnd + 1)) * o2::constants::lhc::LHCOrbitMUS / 1000; } + const Container* getContainer() const { return mContainer.get(); } Container* getContainer() { return mContainer.get(); } void setContainer(std::unique_ptr ptr) { mContainer = std::move(ptr); } void setTFStart(TFType v) { mTFStart = v; } void setTFEnd(TFType v) { mTFEnd = v; } + void setRunStartOrbit(long t) { mRunStartOrbit = t; } + auto getRunStartOrbit() const { return mRunStartOrbit; } // compare the TF with this slot boundaties int relateToTF(TFType tf) { return tf < mTFStart ? -1 : (tf > mTFEnd ? 1 : 0); } @@ -74,6 +83,7 @@ class TimeSlot TFType mTFStart = 0; TFType mTFEnd = 0; size_t mEntries = 0; + long mRunStartOrbit = 0; std::unique_ptr mContainer; // user object to accumulate the calibration data for this slot ClassDefNV(TimeSlot, 1); diff --git a/Detectors/Calibration/include/DetectorsCalibration/TimeSlotCalibration.h b/Detectors/Calibration/include/DetectorsCalibration/TimeSlotCalibration.h index 4e00f38f33b6d..ee9eb77c8aa67 100644 --- a/Detectors/Calibration/include/DetectorsCalibration/TimeSlotCalibration.h +++ b/Detectors/Calibration/include/DetectorsCalibration/TimeSlotCalibration.h @@ -16,6 +16,7 @@ #include "DetectorsCalibration/TimeSlot.h" #include "DetectorsBase/TFIDInfoHelper.h" +#include "DetectorsBase/GRPGeomHelper.h" #include "CommonDataFormat/TFIDInfo.h" #include #include @@ -34,26 +35,62 @@ namespace calibration template class TimeSlotCalibration { + public: using Slot = TimeSlot; + using TFType = o2::calibration::TFType; + + static constexpr TFType INFINITE_TF = o2::calibration::INFINITE_TF; - public: TimeSlotCalibration() = default; virtual ~TimeSlotCalibration() = default; - uint64_t getMaxSlotsDelay() const { return mMaxSlotsDelay; } - void setMaxSlotsDelay(uint64_t v) { mMaxSlotsDelay = v; } - - uint64_t getSlotLength() const { return mSlotLength; } - void setSlotLength(uint64_t v) { mSlotLength = v < 1 ? 1 : v; } + TFType getMaxSlotsDelay() const { return mMaxSlotsDelay; } + void setMaxSlotsDelay(TFType v) { mMaxSlotsDelay = v; } + + TFType getSlotLength() const { return mSlotLength; } + void setSlotLength(TFType v) + { + if (v == 0) { + setFinalizeWhenReady(); + } else { + mSlotLength = v; + } + } - uint64_t getCheckIntervalInfiniteSlot() const { return mCheckIntervalInfiniteSlot; } - void setCheckIntervalInfiniteSlot(uint64_t v) { mCheckIntervalInfiniteSlot = v; } + TFType getCheckIntervalInfiniteSlot() const { return mCheckIntervalInfiniteSlot; } + void setCheckIntervalInfiniteSlot(TFType v) { mCheckIntervalInfiniteSlot = v; } - uint64_t getCheckDeltaIntervalInfiniteSlot() const { return mCheckDeltaIntervalInfiniteSlot; } - void setCheckDeltaIntervalInfiniteSlot(uint64_t v) { mCheckDeltaIntervalInfiniteSlot = v < 1 ? mCheckIntervalInfiniteSlot : v; } // if the delta is 0, we ignore it + TFType getCheckDeltaIntervalInfiniteSlot() const { return mCheckDeltaIntervalInfiniteSlot; } + void setCheckDeltaIntervalInfiniteSlot(TFType v) { mCheckDeltaIntervalInfiniteSlot = v < 1 ? mCheckIntervalInfiniteSlot : v; } // if the delta is 0, we ignore it TFType getFirstTF() const { return mFirstTF; } void setFirstTF(TFType v) { mFirstTF = v; } + void setSlotLengthInSeconds(int s) { mSlotLengthInSeconds = s > 0 ? s : 1; } + void setSlotLengthInOrbits(int n) { mSlotLengthInOrbits = n > 0 ? n : 1; } + void checkSlotLength() + { + if (mSlotLengthInSeconds > 0) { + TFType ntf = mSlotLengthInSeconds / (long(o2::base::GRPGeomHelper::getNHBFPerTF()) * o2::constants::lhc::LHCOrbitMUS / 1000000); + LOGP(info, "Redefining slot duration from {} s. to {} TFs", mSlotLengthInSeconds, ntf); + setSlotLength(ntf); + mSlotLengthInSeconds = 0; + } else if (mSlotLengthInOrbits > 0) { + TFType ntf = mSlotLengthInOrbits / o2::base::GRPGeomHelper::getNHBFPerTF(); + if (ntf < 1) { + ntf = 1; + } + LOGP(info, "Redefining slot duration from {} orbits to {} TFs", mSlotLengthInOrbits, ntf); + setSlotLength(ntf); + mSlotLengthInOrbits = 0; + } + } + + void setFinalizeWhenReady() + { + mFinalizeWhenReady = true; + setSlotLength(INFINITE_TF); + } + void setUpdateAtTheEndOfRunOnly() { mUpdateAtTheEndOfRunOnly = kTRUE; } int getNSlots() const { return mSlots.size(); } @@ -115,30 +152,31 @@ class TimeSlotCalibration protected: auto& getSlots() { return mSlots; } - + int getRunStartOrbit() const { return mCurrentTFInfo.firstTForbit - o2::base::GRPGeomHelper::getNHBFPerTF() * mCurrentTFInfo.tfCounter; } TFType tf2SlotMin(TFType tf) const; std::deque mSlots; o2::dataformats::TFIDInfo mCurrentTFInfo{}; - + int mSlotLengthInSeconds = -1; // optionally provided slot length in seconds + int mSlotLengthInOrbits = -1; // optionally provided slot length in orbits TFType mLastClosedTF = 0; TFType mFirstTF = 0; - TFType mMaxSeenTF = 0; // largest TF processed - uint64_t mSlotLength = 1; - uint64_t mMaxSlotsDelay = 3; - bool mUpdateAtTheEndOfRunOnly = false; - uint64_t mCheckIntervalInfiniteSlot = 1; // will be used if the TF length is INFINITE_TF_int64 to decide + TFType mMaxSeenTF = 0; // largest TF processed + TFType mSlotLength = 1; // slot length in TFs + TFType mMaxSlotsDelay = 3; // difference between the current TF slot ID and the oldest slot to account for the TF + TFType mCheckIntervalInfiniteSlot = 1; // will be used if the TF length is INFINITE_TF_int64 to decide // when to check if to call the finalize; otherwise it is called // at every new TF; note that this is an approximation, // since TFs come in async order TFType mLastCheckedTFInfiniteSlot = 0; // will be used if the TF length is INFINITE_TF_int64 to book-keep // the last TF at which we tried to calibrate - uint64_t mCheckDeltaIntervalInfiniteSlot = 1; // will be used if the TF length is INFINITE_TF_int64 when + TFType mCheckDeltaIntervalInfiniteSlot = 1; // will be used if the TF length is INFINITE_TF_int64 when // the check on the statistics returned false, to determine // after how many TF to check again. bool mWasCheckedInfiniteSlot = false; // flag to know whether the statistics of the infinite slot was already checked - + bool mUpdateAtTheEndOfRunOnly = false; + bool mFinalizeWhenReady = false; // if true: single bin is filled until ready, then closed and new one is added ClassDef(TimeSlotCalibration, 1); }; @@ -149,14 +187,14 @@ bool TimeSlotCalibration::process(const DATA& data) { // process current TF - TFType tf = mCurrentTFInfo.startTime; - - int maxDelay = mMaxSlotsDelay * mSlotLength; + TFType tf = mCurrentTFInfo.tfCounter; + uint64_t maxDelay64 = uint64_t(mSlotLength) * mMaxSlotsDelay; + TFType maxDelay = maxDelay64 > o2::calibration::INFINITE_TF ? o2::calibration::INFINITE_TF : TFType(maxDelay64); if (!mUpdateAtTheEndOfRunOnly) { // if you update at the end of run only, then you accept everything - if (tf < mLastClosedTF || (!mSlots.empty() && getLastSlot().getTFStart() > tf + maxDelay)) { // ignore TF; note that if you have only 1 timeslot - // which is INFINITE_TF wide, then maxDelay - // does not matter: you won't accept TFs from the past, - // so the first condition will be used + if (tf < mLastClosedTF || (!mSlots.empty() && getLastSlot().getTFStart() > tf + maxDelay64)) { // ignore TF; note that if you have only 1 timeslot + // which is INFINITE_TF wide, then maxDelay + // does not matter: you won't accept TFs from the past, + // so the first condition will be used LOG(info) << "Ignoring TF " << tf << ", mLastClosedTF = " << mLastClosedTF; return false; } @@ -185,14 +223,15 @@ bool TimeSlotCalibration::process(const gsl::span { // process current TF - TFType tf = mCurrentTFInfo.startTime; - - int maxDelay = mMaxSlotsDelay * mSlotLength; - if (!mUpdateAtTheEndOfRunOnly) { // if you update at the end of run only, then you accept everything - if (tf < mLastClosedTF || (!mSlots.empty() && getLastSlot().getTFStart() > tf + maxDelay)) { // ignore TF; note that if you have only 1 timeslot - // which is INFINITE_TF wide, then maxDelay - // does not matter: you won't accept TFs from the past, - // so the first condition will be used + TFType tf = mCurrentTFInfo.tfCounter; + uint64_t maxDelay64 = uint64_t(mSlotLength) * mMaxSlotsDelay; + TFType maxDelay = maxDelay64 > o2::calibration::INFINITE_TF ? o2::calibration::INFINITE_TF : TFType(maxDelay64); + + if (!mUpdateAtTheEndOfRunOnly) { // if you update at the end of run only, then you accept everything + if (tf < mLastClosedTF || (!mSlots.empty() && getLastSlot().getTFStart() > tf + maxDelay64)) { // ignore TF; note that if you have only 1 timeslot + // which is INFINITE_TF wide, then maxDelay + // does not matter: you won't accept TFs from the past, + // so the first condition will be used LOG(info) << "Ignoring TF " << tf << ", mLastClosedTF = " << mLastClosedTF; return false; } @@ -222,15 +261,9 @@ void TimeSlotCalibration::checkSlotsToFinalize(TFType tf, int { // Check which slots can be finalized, provided the newly arrived TF is tf - constexpr uint64_t INFINITE_TF = 0xffffffffffffffff; - constexpr int64_t INFINITE_TF_int64 = std::numeric_limits::max() - 1; // this is used to define the end - // of the slot in case it is "std::numeric_limits::max()" - // long (so we need to subtract 1) - - // if we have one slot only which is INFINITE_TF_int64 long, and we are not at the end of run (tf != INFINITE_TF), - // we need to check if we got enough statistics, and if so, redefine the slot - if (mSlots.size() == 1 && mSlots[0].getTFEnd() == INFINITE_TF_int64) { - uint64_t checkInterval = mCheckIntervalInfiniteSlot + mLastCheckedTFInfiniteSlot; + // if slot finalization is asked as soon as the slot is ready, we need to check if we got enough statistics, and if so, redefine the slot + if (mSlots.size() == 1 && mFinalizeWhenReady) { + TFType checkInterval = mCheckIntervalInfiniteSlot + mLastCheckedTFInfiniteSlot; if (mWasCheckedInfiniteSlot) { checkInterval = mCheckDeltaIntervalInfiniteSlot + mLastCheckedTFInfiniteSlot; } @@ -240,7 +273,7 @@ void TimeSlotCalibration::checkSlotsToFinalize(TFType tf, int LOG(info) << "End of run reached, trying to calibrate what we have, if we have enough statistics"; } else { LOG(info) << "Calibrating as soon as we have enough statistics:"; - LOG(info) << "Update interval passed (" << checkInterval << "), checking slot for " << mSlots[0].getTFStart() << " <= TF <= " << mSlots[0].getTFEnd(); + LOG(info) << "Update interval passed (" << checkInterval << "), checking slot for " << mSlots[0].getTFStart() << " <= TF <= " << INFINITE_TF; } mLastCheckedTFInfiniteSlot = tf; if (hasEnoughData(mSlots[0])) { @@ -249,12 +282,13 @@ void TimeSlotCalibration::checkSlotsToFinalize(TFType tf, int mSlots[0].setTFEnd(mMaxSeenTF); LOG(info) << "Finalizing slot for " << mSlots[0].getTFStart() << " <= TF <= " << mSlots[0].getTFEnd(); finalizeSlot(mSlots[0]); // will be removed after finalization - mLastClosedTF = mSlots[0].getTFEnd() + 1; // will not accept any TF below this + mLastClosedTF = mSlots[0].getTFEnd() < INFINITE_TF ? (mSlots[0].getTFEnd() + 1) : mSlots[0].getTFEnd() < INFINITE_TF; // will not accept any TF below this mSlots.erase(mSlots.begin()); // creating a new slot if we are not at the end of run if (tf != INFINITE_TF) { - LOG(info) << "Creating new slot for " << mLastClosedTF << " <= TF <= " << INFINITE_TF_int64; - emplaceNewSlot(true, mLastClosedTF, INFINITE_TF_int64); + LOG(info) << "Creating new slot for " << mLastClosedTF << " <= TF <= " << INFINITE_TF; + auto& sl = emplaceNewSlot(true, mLastClosedTF, INFINITE_TF); + sl.setRunStartOrbit(getRunStartOrbit()); } } else { LOG(info) << "Not enough data to calibrate"; @@ -266,8 +300,9 @@ void TimeSlotCalibration::checkSlotsToFinalize(TFType tf, int } else { // check if some slots are done for (auto slot = mSlots.begin(); slot != mSlots.end();) { - //if (maxDelay == 0 || (slot->getTFEnd() + maxDelay) < tf) { - if ((slot->getTFEnd() + maxDelay) < tf) { + uint64_t lim64 = uint64_t(maxDelay) + slot->getTFEnd(); + TFType tfLim = lim64 < INFINITE_TF ? TFType(lim64) : INFINITE_TF; + if (tfLim < tf) { if (hasEnoughData(*slot)) { LOG(debug) << "Finalizing slot for " << slot->getTFStart() << " <= TF <= " << slot->getTFEnd(); finalizeSlot(*slot); // will be removed after finalization @@ -311,12 +346,13 @@ inline TFType TimeSlotCalibration::tf2SlotMin(TFType tf) const // returns the min TF of the slot to which "tf" belongs if (tf < mFirstTF) { - throw std::runtime_error("invalide TF"); + throw std::runtime_error("invalid TF"); } if (mUpdateAtTheEndOfRunOnly) { return mFirstTF; } - return TFType((tf - mFirstTF) / mSlotLength) * mSlotLength + mFirstTF; + uint64_t tft = int64_t(((tf - mFirstTF) / mSlotLength) * mSlotLength) + mFirstTF; + return tft < o2::calibration::INFINITE_TF ? TFType(tft) : INFINITE_TF; } //_________________________________________________ @@ -325,12 +361,13 @@ TimeSlot& TimeSlotCalibration::getSlotForTF(TFType { LOG(debug) << "Getting slot for TF " << tf; - + checkSlotLength(); if (mUpdateAtTheEndOfRunOnly) { if (!mSlots.empty() && mSlots.back().getTFEnd() < tf) { mSlots.back().setTFEnd(tf); } else if (mSlots.empty()) { - emplaceNewSlot(true, mFirstTF, tf); + auto& sl = emplaceNewSlot(true, mFirstTF, tf); + sl.setRunStartOrbit(getRunStartOrbit()); } return mSlots.back(); } @@ -339,8 +376,11 @@ TimeSlot& TimeSlotCalibration::getSlotForTF(TFType auto tfmn = tf2SlotMin(mSlots.front().getTFStart() - 1); // min TF of the slot corresponding to a TF smaller than the first seen auto tftgt = tf2SlotMin(tf); // min TF of the slot to which the TF "tf" would belong while (tfmn >= tftgt) { - LOG(info) << "Adding new slot for " << tfmn << " <= TF <= " << tfmn + mSlotLength - 1; - emplaceNewSlot(true, tfmn, tfmn + mSlotLength - 1); + uint64_t tft = uint64_t(tfmn) + mSlotLength - 1; + TFType tfmx = tft < o2::calibration::INFINITE_TF ? TFType(tft) : o2::calibration::INFINITE_TF; + LOG(info) << "Adding new slot for " << tfmn << " <= TF <= " << tfmx; + auto& sl = emplaceNewSlot(true, tfmn, tfmx); + sl.setRunStartOrbit(getRunStartOrbit()); if (!tfmn) { break; } @@ -357,24 +397,17 @@ TimeSlot& TimeSlotCalibration::getSlotForTF(TFType // need to add in the end auto tfmn = mSlots.empty() ? tf2SlotMin(tf) : tf2SlotMin(mSlots.back().getTFEnd() + 1); do { - LOG(info) << "Adding new slot for " << tfmn << " <= TF <= " << tfmn + mSlotLength - 1; - emplaceNewSlot(false, tfmn, tfmn + mSlotLength - 1); + uint64_t tft = uint64_t(tfmn) + mSlotLength - 1; + TFType tfmx = tft < o2::calibration::INFINITE_TF ? TFType(tft) : o2::calibration::INFINITE_TF; + LOG(info) << "Adding new slot for " << tfmn << " <= TF <= " << tfmx; + auto& sl = emplaceNewSlot(false, tfmn, tfmx); + sl.setRunStartOrbit(getRunStartOrbit()); tfmn = tf2SlotMin(mSlots.back().getTFEnd() + 1); } while (tf > mSlots.back().getTFEnd()); return mSlots.back(); } -/* -//_________________________________________________ -template -void TimeSlotCalibration::setCurrentTFInfo(uint32_t firstOrbit, uint32_t tfCounter, uint32_t runNumber, uint64_t creation) -{ - mTFfirstOrbit = firstOrbit; - mTFcounter = tfCounter; - mTFrunNumber = runNumber; - mTFcreationTime = creation; -} -*/ + //_________________________________________________ template void TimeSlotCalibration::print() const diff --git a/Detectors/Calibration/include/DetectorsCalibration/Utils.h b/Detectors/Calibration/include/DetectorsCalibration/Utils.h index 4a55274a3b357..d1f8967328c0e 100644 --- a/Detectors/Calibration/include/DetectorsCalibration/Utils.h +++ b/Detectors/Calibration/include/DetectorsCalibration/Utils.h @@ -34,7 +34,6 @@ namespace calibration struct Utils { static constexpr o2::header::DataOrigin gDataOriginCDBPayload{"CLP"}; // generic DataOrigin for calibrations payload static constexpr o2::header::DataOrigin gDataOriginCDBWrapper{"CLW"}; // generic DataOrigin for calibrations wrapper - static constexpr long INFINITE_TIME = 99999999999999; template static void prepareCCDBobjectInfo(T& obj, o2::ccdb::CcdbObjectInfo& info, const std::string& path, const std::map& md, long start, long end = -1); diff --git a/Detectors/Calibration/src/MeanVertexCalibrator.cxx b/Detectors/Calibration/src/MeanVertexCalibrator.cxx index a18f2c6269e0a..217492f886ab6 100644 --- a/Detectors/Calibration/src/MeanVertexCalibrator.cxx +++ b/Detectors/Calibration/src/MeanVertexCalibrator.cxx @@ -41,7 +41,7 @@ void MeanVertexCalibrator::finalizeSlot(Slot& slot) o2::calibration::MeanVertexData* c = slot.getContainer(); LOG(info) << "Finalize slot " << slot.getTFStart() << " <= TF <= " << slot.getTFEnd() << " with " << c->getEntries() << " entries"; - mTmpMVobjDqTime.emplace_back(slot.getTFStart(), slot.getTFEnd()); + mTmpMVobjDqTime.emplace_back(slot.getStartTimeMS(), slot.getEndTimeMS()); if (mUseFit) { MeanVertexObject mvo; @@ -135,18 +135,15 @@ void MeanVertexCalibrator::finalizeSlot(Slot& slot) mSMAMVobj.setSigmaZ(fitValues[2]); } - // TODO: the timestamp is now given with the TF index, but it will have - // to become an absolute time. This is true both for the lhc phase object itself - // and the CCDB entry if (mTmpMVobjDqTime.size() > mSMAslots) { mTmpMVobjDqTime.pop_front(); } - TFType startValidity = (mTmpMVobjDqTime.front().getMin() + mTmpMVobjDqTime.back().getMax()) / 2; // will be rounded to uint64_t + long startValidity = (mTmpMVobjDqTime.front().getMin() + mTmpMVobjDqTime.back().getMax()) / 2; LOG(info) << "start validity = " << startValidity; std::map md; auto clName = o2::utils::MemFileHelper::getClassName(mSMAMVobj); auto flName = o2::ccdb::CcdbApi::generateFileName(clName); - mInfoVector.emplace_back("GLO/Calib/MeanVertex", clName, flName, md, startValidity, 99999999999999); + mInfoVector.emplace_back("GLO/Calib/MeanVertex", clName, flName, md, startValidity - 10 * o2::ccdb::CcdbObjectInfo::SECOND, startValidity + o2::ccdb::CcdbObjectInfo::MONTH); mMeanVertexVector.emplace_back(mSMAMVobj); slot.print(); diff --git a/Detectors/Calibration/src/TPCVDriftTglCalibration.cxx b/Detectors/Calibration/src/TPCVDriftTglCalibration.cxx index d835e35236469..3b320f26421f3 100644 --- a/Detectors/Calibration/src/TPCVDriftTglCalibration.cxx +++ b/Detectors/Calibration/src/TPCVDriftTglCalibration.cxx @@ -79,10 +79,10 @@ void TPCVDriftTglCalibration::finalizeSlot(Slot& slot) auto clName = o2::utils::MemFileHelper::getClassName(mVDPerSlot.back()); auto flName = o2::ccdb::CcdbApi::generateFileName(clName); std::map md; - mCCDBInfoPerSlot.emplace_back("TPC/Calib/VDriftTgl", clName, flName, md, slot.getTFStart(), 99999999999999); - LOG(info) << "Finalize slot " << slot.getTFStart() << " <= TF <= " << slot.getTFEnd() << " with " << cont->entries << " entries :" - << " dTgl vs Tgl_ITS offset:" << offs << "+-" << offsErr << " Slope: " << slope << "+-" << slopErr - << " -> VD corr factor = " << corrFact << "+-" << corrFactErr; + mCCDBInfoPerSlot.emplace_back("TPC/Calib/VDriftTgl", clName, flName, md, + slot.getStartTimeMS() - 10 * o2::ccdb::CcdbObjectInfo::SECOND, slot.getEndTimeMS() + o2::ccdb::CcdbObjectInfo::MONTH); + LOGP(info, "Finalize slot {}({})<=TF<={}({}) with {} entries | dTgl vs Tgl_ITS offset: {}+-{} Slope: {}+-{} -> VD corr factor = {}+-{}", slot.getTFStart(), slot.getStartTimeMS(), + slot.getTFEnd(), slot.getEndTimeMS(), cont->entries, offs, offsErr, slope, slopErr, corrFact, corrFactErr); } //_____________________________________________ diff --git a/Detectors/Calibration/workflow/src/MeanVertexCalibratorSpec.cxx b/Detectors/Calibration/workflow/src/MeanVertexCalibratorSpec.cxx index 9ae3d72f1a513..babaf89a2169b 100644 --- a/Detectors/Calibration/workflow/src/MeanVertexCalibratorSpec.cxx +++ b/Detectors/Calibration/workflow/src/MeanVertexCalibratorSpec.cxx @@ -39,8 +39,8 @@ void MeanVertexCalibDevice::init(InitContext& ic) float rangeZ = params->rangeZ; int nSlots4SMA = params->nSlots4SMA; bool useFit = params->useFit; - int slotL = params->tfPerSlot; - int delay = params->maxTFdelay; + auto slotL = params->tfPerSlot; + auto delay = params->maxTFdelay; mCalibrator = std::make_unique(minEnt, useFit, nbX, rangeX, nbY, rangeY, nbZ, rangeZ, nSlots4SMA); mCalibrator->setSlotLength(slotL); mCalibrator->setMaxSlotsDelay(delay); @@ -65,8 +65,7 @@ void MeanVertexCalibDevice::endOfStream(o2::framework::EndOfStreamContext& ec) { LOG(info) << "Finalizing calibration"; - constexpr uint64_t INFINITE_TF = 0xffffffffffffffff; - mCalibrator->checkSlotsToFinalize(INFINITE_TF); + mCalibrator->checkSlotsToFinalize(o2::calibration::INFINITE_TF); sendOutput(ec.outputs()); } diff --git a/Detectors/Calibration/workflow/src/TPCVDriftTglCalibSpec.cxx b/Detectors/Calibration/workflow/src/TPCVDriftTglCalibSpec.cxx index f474b085f667c..66da6e9c3e108 100644 --- a/Detectors/Calibration/workflow/src/TPCVDriftTglCalibSpec.cxx +++ b/Detectors/Calibration/workflow/src/TPCVDriftTglCalibSpec.cxx @@ -49,8 +49,7 @@ class TPCVDriftTglCalibSpec : public Task void endOfStream(EndOfStreamContext& ec) final { LOG(info) << "Finalizing calibration"; - constexpr uint64_t INFINITE_TF = 0xffffffffffffffff; - mCalibrator->checkSlotsToFinalize(INFINITE_TF); + mCalibrator->checkSlotsToFinalize(o2::calibration::INFINITE_TF); sendOutput(ec.outputs()); } diff --git a/Detectors/EMCAL/calib/include/EMCALCalib/EMCDCSProcessor.h b/Detectors/EMCAL/calib/include/EMCALCalib/EMCDCSProcessor.h index 5657b05ea71fa..c8c96a133d518 100644 --- a/Detectors/EMCAL/calib/include/EMCALCalib/EMCDCSProcessor.h +++ b/Detectors/EMCAL/calib/include/EMCALCalib/EMCDCSProcessor.h @@ -125,7 +125,7 @@ void EMCDCSProcessor::prepareCCDBobjectInfo(const T& obj, CcdbObjectInfo& info, info.setObjectType(clName); info.setFileName(flName); info.setStartValidityTimestamp(tf); - info.setEndValidityTimestamp(99999999999999); + info.setEndValidityTimestamp(o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); info.setMetaData(md); } diff --git a/Detectors/EMCAL/calibration/include/EMCALCalibration/EMCALChannelCalibrator.h b/Detectors/EMCAL/calibration/include/EMCALCalibration/EMCALChannelCalibrator.h index eb76897093a99..cdbe179a1eac3 100644 --- a/Detectors/EMCAL/calibration/include/EMCALCalibration/EMCALChannelCalibrator.h +++ b/Detectors/EMCAL/calibration/include/EMCALCalibration/EMCALChannelCalibrator.h @@ -52,7 +52,7 @@ namespace emcal template class EMCALChannelCalibrator : public o2::calibration::TimeSlotCalibration { - using TFType = uint64_t; + using TFType = o2::calibration::TFType; using Slot = o2::calibration::TimeSlot; using Cell = o2::emcal::Cell; using CcdbObjectInfo = o2::ccdb::CcdbObjectInfo; @@ -133,7 +133,7 @@ void EMCALChannelCalibrator::finalizeSlot( // for the CCDB entry auto clName = o2::utils::MemFileHelper::getClassName(bcm); auto flName = o2::ccdb::CcdbApi::generateFileName(clName); - mInfoVector.emplace_back(CalibDB::getCDBPathBadChannelMap(), clName, flName, md, slot.getTFStart(), 99999999999999); + mInfoVector.emplace_back(CalibDB::getCDBPathBadChannelMap(), clName, flName, md, slot.getStartTimeMS(), o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); mCalibObjectVector.push_back(bcm); } else if constexpr (std::is_same::value) { auto tcd = mCalibrator->calibrateTime(c->getHisto()); @@ -143,18 +143,18 @@ void EMCALChannelCalibrator::finalizeSlot( auto flName = o2::ccdb::CcdbApi::generateFileName(clName); //prepareCCDBobjectInfo - mInfoVector.emplace_back(CalibDB::getCDBPathTimeCalibrationParams(), clName, flName, md, slot.getTFStart(), 99999999999999); + mInfoVector.emplace_back(CalibDB::getCDBPathTimeCalibrationParams(), clName, flName, md, slot.getStartTimeMS(), o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); mCalibObjectVector.push_back(tcd); if (namePathStoreLocal.find(".root") != std::string::npos) { TFile fLocalStorage(namePathStoreLocal.c_str(), "update"); fLocalStorage.cd(); TH1F* histTCparams = (TH1F*)tcd.getHistogramRepresentation(false); - std::string nameTCHist = "TCParams_" + std::to_string(slot.getTFStart()); + std::string nameTCHist = "TCParams_" + std::to_string(slot.getStartTimeMS()); histTCparams->Write(nameTCHist.c_str(), TObject::kOverwrite); TH2F hCalibHist = o2::utils::TH2FFromBoost(c->getHisto()); - std::string nameTCInputHist = "TimeVsCellID_" + std::to_string(slot.getTFStart()); + std::string nameTCInputHist = "TimeVsCellID_" + std::to_string(slot.getStartTimeMS()); hCalibHist.Write(nameTCInputHist.c_str(), TObject::kOverwrite); fLocalStorage.Close(); } diff --git a/Detectors/EMCAL/calibration/testWorkflow/EMCALChannelCalibratorSpec.h b/Detectors/EMCAL/calibration/testWorkflow/EMCALChannelCalibratorSpec.h index eaf8f99550107..a58ad82ea9521 100644 --- a/Detectors/EMCAL/calibration/testWorkflow/EMCALChannelCalibratorSpec.h +++ b/Detectors/EMCAL/calibration/testWorkflow/EMCALChannelCalibratorSpec.h @@ -30,6 +30,7 @@ #include "CCDB/CcdbApi.h" #include "CCDB/CcdbObjectInfo.h" #include "CommonUtils/NameConf.h" +#include "DetectorsBase/GRPGeomHelper.h" using namespace o2::framework; @@ -45,10 +46,11 @@ class EMCALChannelCalibDevice : public o2::framework::Task //using LHCphase = o2::dataformats::CalibLHCphaseEMCAL; public: - EMCALChannelCalibDevice() = default; + EMCALChannelCalibDevice(std::shared_ptr req) : mCCDBRequest(req) {} + void init(o2::framework::InitContext& ic) final { - + o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest); int isTest = ic.options().get("do-EMCAL-channel-calib-in-test-mode"); std::string calibType = ic.options().get("calibType"); std::string localStorePath = ic.options().get("localFilePath"); @@ -77,8 +79,15 @@ class EMCALChannelCalibDevice : public o2::framework::Task } } + //_________________________________________________________________ + void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final + { + o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj); + } + void run(o2::framework::ProcessingContext& pc) final { + o2::base::GRPGeomHelper::instance().checkUpdates(pc); o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mTimeCalibrator->getCurrentTFInfo()); auto tfcounter = o2::header::get(pc.inputs().get(getCellBinding()).header)->startTime; @@ -112,12 +121,11 @@ class EMCALChannelCalibDevice : public o2::framework::Task void endOfStream(o2::framework::EndOfStreamContext& ec) final { - constexpr uint64_t INFINITE_TF = 0xffffffffffffffff; if (isBadChannelCalib) { - mBadChannelCalibrator->checkSlotsToFinalize(INFINITE_TF); + mBadChannelCalibrator->checkSlotsToFinalize(o2::calibration::INFINITE_TF); sendOutput(ec.outputs()); } else { - mTimeCalibrator->checkSlotsToFinalize(INFINITE_TF); + mTimeCalibrator->checkSlotsToFinalize(o2::calibration::INFINITE_TF); sendOutput(ec.outputs()); } } @@ -129,6 +137,7 @@ class EMCALChannelCalibDevice : public o2::framework::Task std::unique_ptr> mBadChannelCalibrator; std::unique_ptr> mTimeCalibrator; std::shared_ptr mCalibExtractor; + std::shared_ptr mCCDBRequest; bool isBadChannelCalib = true; //________________________________________________________________ @@ -198,11 +207,18 @@ DataProcessorSpec getEMCALChannelCalibDeviceSpec(std::string calibType = "badcel std::vector inputs; inputs.emplace_back(device::getCellBinding(), o2::header::gDataOriginEMC, "CELLS", 0, o2::framework::Lifetime::Timeframe); inputs.emplace_back(device::getCellTriggerRecordBinding(), o2::header::gDataOriginEMC, "CELLSTRGR", 0, o2::framework::Lifetime::Timeframe); + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputs); return DataProcessorSpec{ "calib-emcalchannel-calibration", inputs, outputs, - AlgorithmSpec{adaptFromTask()}, + AlgorithmSpec{adaptFromTask(ccdbRequest)}, Options{ {"do-EMCAL-channel-calib-in-test-mode", VariantType::Bool, false, {"to run in test mode for simplification"}}, {"ccdb-path", VariantType::String, o2::base::NameConf::getCCDBServer(), {"Path to CCDB"}}, diff --git a/Detectors/FIT/FT0/calibration/include/FT0Calibration/FT0CalibCollector.h b/Detectors/FIT/FT0/calibration/include/FT0Calibration/FT0CalibCollector.h index 7249356cf89a9..94f9adb79ef2c 100644 --- a/Detectors/FIT/FT0/calibration/include/FT0Calibration/FT0CalibCollector.h +++ b/Detectors/FIT/FT0/calibration/include/FT0Calibration/FT0CalibCollector.h @@ -62,7 +62,7 @@ class FT0CalibInfoSlot class FT0CalibCollector final : public o2::calibration::TimeSlotCalibration { - using TFType = uint64_t; + using TFType = o2::calibration::TFType; using Slot = o2::calibration::TimeSlot; static constexpr int NCHANNELS = o2::ft0::Geometry::Nchannels; diff --git a/Detectors/FIT/FT0/calibration/include/FT0Calibration/LHCClockCalibrator.h b/Detectors/FIT/FT0/calibration/include/FT0Calibration/LHCClockCalibrator.h index 714065052565a..eece53669b341 100644 --- a/Detectors/FIT/FT0/calibration/include/FT0Calibration/LHCClockCalibrator.h +++ b/Detectors/FIT/FT0/calibration/include/FT0Calibration/LHCClockCalibrator.h @@ -54,7 +54,7 @@ struct LHCClockDataHisto { class LHCClockCalibrator { - using TFType = uint64_t; + using TFType = o2::calibration::TFType; using Slot = o2::calibration::TimeSlot; using LHCphase = o2::ft0::LHCphaseCalibrationObject; using CcdbObjectInfo = o2::ccdb::CcdbObjectInfo; diff --git a/Detectors/FIT/FT0/calibration/testWorkflow/FT0CalibSlewingCollectorSpec.h b/Detectors/FIT/FT0/calibration/testWorkflow/FT0CalibSlewingCollectorSpec.h index 35359fb297095..0985f82c9d09c 100644 --- a/Detectors/FIT/FT0/calibration/testWorkflow/FT0CalibSlewingCollectorSpec.h +++ b/Detectors/FIT/FT0/calibration/testWorkflow/FT0CalibSlewingCollectorSpec.h @@ -24,6 +24,7 @@ #include "Framework/ControlService.h" #include "Framework/WorkflowSpec.h" #include "FairLogger.h" +#include "DetectorsBase/GRPGeomHelper.h" using namespace o2::framework; @@ -36,27 +37,35 @@ class FT0CalibCollectorDevice : public o2::framework::Task { public: + FT0CalibCollectorDevice(std::shared_ptr req) : mCCDBRequest(req) {} void init(o2::framework::InitContext& ic) final { + o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest); bool isTFsendingPolicy = ic.options().get("tf-sending-policy"); int maxEnt = ic.options().get("max-number-hits-to-fill-tree"); - int slotL = ic.options().get("tf-per-slot"); + auto slotL = ic.options().get("tf-per-slot"); bool absMaxEnt = ic.options().get("is-max-number-hits-to-fill-tree-absolute"); mCollector = std::make_unique(isTFsendingPolicy, maxEnt); + mCollector->setSlotLength(slotL); + } + + void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final + { + o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj); } void run(o2::framework::ProcessingContext& pc) final { - auto data = pc.inputs().get>("input"); + o2::base::GRPGeomHelper::instance().checkUpdates(pc); o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mCollector->getCurrentTFInfo()); + auto data = pc.inputs().get>("input"); mCollector->process(data); sendOutput(pc.outputs()); } void endOfStream(o2::framework::EndOfStreamContext& ec) final { - constexpr uint64_t INFINITE_TF = 0xffffffffffffffff; - mCollector->checkSlotsToFinalize(INFINITE_TF); + mCollector->checkSlotsToFinalize(o2::calibration::INFINITE_TF); // we force finalizing slot zero (unless everything was already finalized), no matter how many entries we had if (mCollector->getNSlots() != 0) { mCollector->finalizeSlot(mCollector->getSlot(0)); @@ -66,6 +75,7 @@ class FT0CalibCollectorDevice : public o2::framework::Task private: std::unique_ptr mCollector; + std::shared_ptr mCCDBRequest; int mMaxNumOfHits = 0; //________________________________________________________________ @@ -101,17 +111,23 @@ DataProcessorSpec getFT0CalibCollectorDeviceSpec() std::vector inputs; inputs.emplace_back("input", "FT0", "CALIB_INFO"); - + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputs); return DataProcessorSpec{ "calib-ft0calib-collector", inputs, outputs, - AlgorithmSpec{adaptFromTask()}, + AlgorithmSpec{adaptFromTask(ccdbRequest)}, Options{ {"max-number-hits-to-fill-tree", VariantType::Int, 1000, {"maximum number of entries in one channel to trigger teh filling of the tree"}}, {"is-max-number-hits-to-fill-tree-absolute", VariantType::Bool, false, {"to decide if we want to multiply the max-number-hits-to-fill-tree by the number of channels (when set to true), or not (when set to false) for fast checks"}}, {"tf-sending-policy", VariantType::Bool, false, {"if we are sending output at every TF; otherwise, we use the max-number-hits-to-fill-tree"}}, - {"tf-per-slot", o2::framework::VariantType::Int, 200000, {"TF per slot "}}}}; + {"tf-per-slot", o2::framework::VariantType::UInt32, 200000u, {"TF per slot "}}}}; } } // namespace framework diff --git a/Detectors/FIT/FT0/calibration/testWorkflow/FT0ChannelTimeCalibrationSpec.h b/Detectors/FIT/FT0/calibration/testWorkflow/FT0ChannelTimeCalibrationSpec.h index 7738b2a9c1980..fbca6164d4836 100644 --- a/Detectors/FIT/FT0/calibration/testWorkflow/FT0ChannelTimeCalibrationSpec.h +++ b/Detectors/FIT/FT0/calibration/testWorkflow/FT0ChannelTimeCalibrationSpec.h @@ -33,15 +33,21 @@ o2::framework::DataProcessorSpec getFT0ChannelTimeCalibrationSpec() std::vector inputs; inputs.emplace_back(DEFAULT_INPUT_LABEL, "FT0", "CALIB_INFO"); - + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputs); return o2::framework::DataProcessorSpec{ "calib-ft0-channel-time", inputs, outputs, - o2::framework::AlgorithmSpec{o2::framework::adaptFromTask(DEFAULT_INPUT_LABEL)}, + o2::framework::AlgorithmSpec{o2::framework::adaptFromTask(DEFAULT_INPUT_LABEL, ccdbRequest)}, o2::framework::Options{ - {"tf-per-slot", o2::framework::VariantType::Int, 56000, {""}}, - {"max-delay", o2::framework::VariantType::Int, 3, {""}}}}; + {"tf-per-slot", o2::framework::VariantType::UInt32, 56000u, {""}}, + {"max-delay", o2::framework::VariantType::UInt32, 3u, {""}}}}; } } // namespace o2::ft0 diff --git a/Detectors/FIT/FT0/calibration/testWorkflow/GlobalOffsetsCalibrationSpec.h b/Detectors/FIT/FT0/calibration/testWorkflow/GlobalOffsetsCalibrationSpec.h index 528c32e0b6f95..f02781eeba586 100644 --- a/Detectors/FIT/FT0/calibration/testWorkflow/GlobalOffsetsCalibrationSpec.h +++ b/Detectors/FIT/FT0/calibration/testWorkflow/GlobalOffsetsCalibrationSpec.h @@ -32,18 +32,24 @@ o2::framework::DataProcessorSpec getGlobalOffsetsCalibrationSpec() std::vector inputs; inputs.emplace_back(DEFAULT_INPUT_LABEL, "FT0", "CALIB_INFO"); - + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputs); std::vector outputs; outputs.emplace_back(o2::framework::ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "FIT_CALIB"}, o2::framework::Lifetime::Sporadic); outputs.emplace_back(o2::framework::ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "FIT_CALIB"}, o2::framework::Lifetime::Sporadic); return o2::framework::DataProcessorSpec{ "ft0-global-offsets", - inputs, //o2::framework::Inputs{{"input", "FT0", "CALIBDATA"}}, + inputs, // o2::framework::Inputs{{"input", "FT0", "CALIBDATA"}}, outputs, - o2::framework::AlgorithmSpec{o2::framework::adaptFromTask(DEFAULT_INPUT_LABEL)}, + o2::framework::AlgorithmSpec{o2::framework::adaptFromTask(DEFAULT_INPUT_LABEL, ccdbRequest)}, Options{ - {"tf-per-slot", VariantType::Int, 55000, {"number of TFs per calibration time slot"}}, - {"max-delay", VariantType::Int, 3, {"number of slots in past to consider"}}, + {"tf-per-slot", VariantType::UInt32, 55000u, {"number of TFs per calibration time slot"}}, + {"max-delay", VariantType::UInt32, 3u, {"number of slots in past to consider"}}, {"min-entries", VariantType::Int, 500, {"minimum number of entries to fit single time slot"}}}}; } diff --git a/Detectors/FIT/FT0/calibration/testWorkflow/LHCClockCalibratorSpec.h b/Detectors/FIT/FT0/calibration/testWorkflow/LHCClockCalibratorSpec.h index d814cd407c748..b680ece7169a4 100644 --- a/Detectors/FIT/FT0/calibration/testWorkflow/LHCClockCalibratorSpec.h +++ b/Detectors/FIT/FT0/calibration/testWorkflow/LHCClockCalibratorSpec.h @@ -32,18 +32,24 @@ o2::framework::DataProcessorSpec getLHCClockCalibDeviceSpec() std::vector inputs; inputs.emplace_back(DEFAULT_INPUT_LABEL, "FT0", "CALIB_INFO"); - + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputs); std::vector outputs; outputs.emplace_back(o2::framework::ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "FIT_CALIB"}, o2::framework::Lifetime::Sporadic); outputs.emplace_back(o2::framework::ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "FIT_CALIB"}, o2::framework::Lifetime::Sporadic); return o2::framework::DataProcessorSpec{ "ft0-lhcphase-calibration", - inputs, //o2::framework::Inputs{{"input", "FT0", "CALIBDATA"}}, + inputs, // o2::framework::Inputs{{"input", "FT0", "CALIBDATA"}}, outputs, - o2::framework::AlgorithmSpec{o2::framework::adaptFromTask(DEFAULT_INPUT_LABEL)}, + o2::framework::AlgorithmSpec{o2::framework::adaptFromTask(DEFAULT_INPUT_LABEL, ccdbRequest)}, Options{ - {"tf-per-slot", VariantType::Int, 26000, {"number of TFs per calibration time slot"}}, - {"max-delay", VariantType::Int, 3, {"number of slots in past to consider"}}, + {"tf-per-slot", VariantType::UInt32, 26000u, {"number of TFs per calibration time slot"}}, + {"max-delay", VariantType::UInt32, 3u, {"number of slots in past to consider"}}, {"min-entries", VariantType::Int, 500, {"minimum number of entries to fit single time slot"}}}}; } diff --git a/Detectors/FIT/FV0/calibration/include/FV0Calibration/FV0CalibCollector.h b/Detectors/FIT/FV0/calibration/include/FV0Calibration/FV0CalibCollector.h index 5cf612e43a086..f19ce17916331 100644 --- a/Detectors/FIT/FV0/calibration/include/FV0Calibration/FV0CalibCollector.h +++ b/Detectors/FIT/FV0/calibration/include/FV0Calibration/FV0CalibCollector.h @@ -60,7 +60,7 @@ class FV0CalibInfoSlot class FV0CalibCollector final : public o2::calibration::TimeSlotCalibration { - using TFType = uint64_t; + using TFType = o2::calibration::TFType; using Slot = o2::calibration::TimeSlot; static constexpr int NCHANNELS = Constants::nFv0Channels; diff --git a/Detectors/FIT/FV0/calibration/workflow/FV0ChannelTimeCalibrationSpec.h b/Detectors/FIT/FV0/calibration/workflow/FV0ChannelTimeCalibrationSpec.h index ffdffe13a6942..602fca1537bd8 100644 --- a/Detectors/FIT/FV0/calibration/workflow/FV0ChannelTimeCalibrationSpec.h +++ b/Detectors/FIT/FV0/calibration/workflow/FV0ChannelTimeCalibrationSpec.h @@ -34,16 +34,22 @@ o2::framework::DataProcessorSpec getFV0ChannelTimeCalibrationSpec() std::vector inputs; inputs.emplace_back(DEFAULT_INPUT_LABEL, "FV0", "CALIB_INFO"); - + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputs); return o2::framework::DataProcessorSpec{ "calib-fv0-channel-time", inputs, outputs, - o2::framework::AlgorithmSpec{o2::framework::adaptFromTask(DEFAULT_INPUT_LABEL)}, + o2::framework::AlgorithmSpec{o2::framework::adaptFromTask(DEFAULT_INPUT_LABEL, ccdbRequest)}, o2::framework::Options{ - {"tf-per-slot", o2::framework::VariantType::Int, 5, {""}}, - {"max-delay", o2::framework::VariantType::Int, 3, {""}}, - {"updateInterval", o2::framework::VariantType::Int64, 10ll, {""}}}}; + {"tf-per-slot", o2::framework::VariantType::UInt32, 5u, {""}}, + {"max-delay", o2::framework::VariantType::UInt32, 3u, {""}}, + {"updateInterval", o2::framework::VariantType::UInt32, 10u, {""}}}}; } } // namespace o2::fv0 diff --git a/Detectors/FIT/common/calibration/include/FITCalibration/FITCalibrationDevice.h b/Detectors/FIT/common/calibration/include/FITCalibration/FITCalibrationDevice.h index 9b331abafba9b..5b20394c4ee92 100644 --- a/Detectors/FIT/common/calibration/include/FITCalibration/FITCalibrationDevice.h +++ b/Detectors/FIT/common/calibration/include/FITCalibration/FITCalibrationDevice.h @@ -22,6 +22,7 @@ #include #include #include +#include "DetectorsBase/GRPGeomHelper.h" namespace o2::fit { @@ -40,14 +41,19 @@ class FITCalibrationDevice : public o2::framework::Task using CalibratorType = FITCalibrator; public: - explicit FITCalibrationDevice(std::string inputDataLabel = DEFAULT_INPUT_DATA_LABEL) - : mInputDataLabel(std::move(inputDataLabel)) {} + explicit FITCalibrationDevice(std::string inputDataLabel = DEFAULT_INPUT_DATA_LABEL, std::shared_ptr req = {}) + : mInputDataLabel(std::move(inputDataLabel)), mCCDBRequest(req) {} void init(o2::framework::InitContext& context) final; void run(o2::framework::ProcessingContext& context) final; void endOfStream(o2::framework::EndOfStreamContext& context) final; + void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final + { + o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj); + } + private: void _sendOutputs(o2::framework::DataAllocator& outputs); void _sendCalibrationObjectIfSlotFinalized(o2::framework::DataAllocator& outputs); @@ -55,13 +61,15 @@ class FITCalibrationDevice : public o2::framework::Task private: const std::string mInputDataLabel; std::unique_ptr mCalibrator; + std::shared_ptr mCCDBRequest; }; FIT_CALIBRATION_DEVICE_TEMPLATES void FIT_CALIBRATION_DEVICE_TYPE::init(o2::framework::InitContext& context) { - int slotL = context.options().get("tf-per-slot"); - int delay = context.options().get("max-delay"); + o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest); + auto slotL = context.options().get("tf-per-slot"); + auto delay = context.options().get("max-delay"); mCalibrator = std::make_unique(); @@ -74,6 +82,7 @@ void FIT_CALIBRATION_DEVICE_TYPE::init(o2::framework::InitContext& context) FIT_CALIBRATION_DEVICE_TEMPLATES void FIT_CALIBRATION_DEVICE_TYPE::run(o2::framework::ProcessingContext& context) { + o2::base::GRPGeomHelper::instance().checkUpdates(context); auto data = context.inputs().get>(mInputDataLabel); o2::base::TFIDInfoHelper::fillTFIDInfo(context, mCalibrator->getCurrentTFInfo()); mCalibrator->process(data); @@ -86,8 +95,7 @@ void FIT_CALIBRATION_DEVICE_TYPE::endOfStream(o2::framework::EndOfStreamContext& { //nope, we have to check if we can finalize slot anyway - scenario with one batch - static constexpr uint64_t INFINITE_TF = 0xffffffffffffffff; - mCalibrator->checkSlotsToFinalize(INFINITE_TF); + mCalibrator->checkSlotsToFinalize(o2::calibration::INFINITE_TF); _sendCalibrationObjectIfSlotFinalized(context.outputs()); } diff --git a/Detectors/FIT/common/calibration/include/FITCalibration/FITCalibrator.h b/Detectors/FIT/common/calibration/include/FITCalibration/FITCalibrator.h index e8d768ae15ef5..858f997c56ccb 100644 --- a/Detectors/FIT/common/calibration/include/FITCalibration/FITCalibrator.h +++ b/Detectors/FIT/common/calibration/include/FITCalibration/FITCalibrator.h @@ -38,7 +38,7 @@ class FITCalibrator final : public o2::calibration::TimeSlotCalibration; public: @@ -90,7 +90,7 @@ void FIT_CALIBRATOR_TYPE::finalizeSlot(Slot& slot) starting = container->getFirstCreation(); } uint64_t stopping = starting + (slot.getTFEnd() - slot.getTFStart()) * TFlength; - LOG(info) << "!!!! TFstart " << slot.getTFStart() << " TFend " << slot.getTFEnd() << "starting = " << starting << " - stopping = " << stopping; + LOGP(info, "!!!! {}({})<=TF<={}({}), starting: {} stopping {}", slot.getTFStart(), slot.getStartTimeMS(), slot.getTFEnd(), slot.getEndTimeMS(), starting, stopping); auto calibrationObject = FITCalibrationObjectProducer::generateCalibrationObject(*container); auto preparedCalibObjects = FITCalibrationApi::prepareCalibrationObjectToSend(calibrationObject, starting, stopping); diff --git a/Detectors/GRP/calibration/src/GRPDCSDPsProcessor.cxx b/Detectors/GRP/calibration/src/GRPDCSDPsProcessor.cxx index fe4908d68091a..d24b87cec3852 100644 --- a/Detectors/GRP/calibration/src/GRPDCSDPsProcessor.cxx +++ b/Detectors/GRP/calibration/src/GRPDCSDPsProcessor.cxx @@ -402,7 +402,7 @@ void GRPDCSDPsProcessor::updateMagFieldCCDB() } std::map md; md["responsible"] = "Chiara Zampolli"; - o2::calibration::Utils::prepareCCDBobjectInfo(mMagField, mccdbMagFieldInfo, "GLO/Config/GRPMagField", md, mStartValidity, o2::calibration::Utils::INFINITE_TIME); + o2::calibration::Utils::prepareCCDBobjectInfo(mMagField, mccdbMagFieldInfo, "GLO/Config/GRPMagField", md, mStartValidity, o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); return; } diff --git a/Detectors/GRP/macros/makeGRPCCDBEntryForDCS.C b/Detectors/GRP/macros/makeGRPCCDBEntryForDCS.C index ecd6f192a3495..581ffb1429826 100644 --- a/Detectors/GRP/macros/makeGRPCCDBEntryForDCS.C +++ b/Detectors/GRP/macros/makeGRPCCDBEntryForDCS.C @@ -72,7 +72,7 @@ int makeGRPCCDBEntryForDCS(const std::string url = "http://localhost:8080") api.init(url); // or http://localhost:8080 for a local installation std::map md; long ts = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); - api.storeAsTFileAny(&dpid2DataDesc, "GRP/Config/DCSDPconfig", md, ts, 99999999999999); + api.storeAsTFileAny(&dpid2DataDesc, "GRP/Config/DCSDPconfig", md, ts, o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); return 0; } diff --git a/Detectors/GRP/workflows/src/GRPLHCIFfileSpec.cxx b/Detectors/GRP/workflows/src/GRPLHCIFfileSpec.cxx index e13452f990f41..f8542a3f959b5 100644 --- a/Detectors/GRP/workflows/src/GRPLHCIFfileSpec.cxx +++ b/Detectors/GRP/workflows/src/GRPLHCIFfileSpec.cxx @@ -25,7 +25,6 @@ #include using namespace o2::framework; -using TFType = uint64_t; using HighResClock = std::chrono::high_resolution_clock; using Duration = std::chrono::duration>; using GRPLHCIFData = o2::parameters::GRPLHCIFData; @@ -211,7 +210,7 @@ void GRPLHCIFfileProcessor::sendOutput(DataAllocator& output, long start, const auto flName = o2::ccdb::CcdbApi::generateFileName(clName); std::map md; md.emplace("created_by", "dpl"); - o2::ccdb::CcdbObjectInfo info("GLO/Config/GRPLHCIFData", clName, flName, md, start, o2::calibration::Utils::INFINITE_TIME); + o2::ccdb::CcdbObjectInfo info("GLO/Config/GRPLHCIFData", clName, flName, md, start, o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); auto image = o2::ccdb::CcdbApi::createObjectImage(&lhcifdata, &info); LOG(info) << "Sending object " << info.getPath() << "/" << info.getFileName() << " of size " << image->size() << " bytes, valid for " << info.getStartValidityTimestamp() << " : " << info.getEndValidityTimestamp(); diff --git a/Detectors/GlobalTrackingWorkflow/tpcinterpolationworkflow/include/TPCInterpolationWorkflow/TPCResidualAggregatorSpec.h b/Detectors/GlobalTrackingWorkflow/tpcinterpolationworkflow/include/TPCInterpolationWorkflow/TPCResidualAggregatorSpec.h index d4dabd003281f..c2d1a8f57b3cf 100644 --- a/Detectors/GlobalTrackingWorkflow/tpcinterpolationworkflow/include/TPCInterpolationWorkflow/TPCResidualAggregatorSpec.h +++ b/Detectors/GlobalTrackingWorkflow/tpcinterpolationworkflow/include/TPCInterpolationWorkflow/TPCResidualAggregatorSpec.h @@ -24,6 +24,7 @@ #include "Framework/ConfigParamRegistry.h" #include "Framework/ControlService.h" #include "Framework/WorkflowSpec.h" +#include "DetectorsBase/GRPGeomHelper.h" using namespace o2::framework; @@ -35,15 +36,18 @@ namespace calibration class ResidualAggregatorDevice : public o2::framework::Task { public: + ResidualAggregatorDevice(std::shared_ptr req) : mCCDBRequest(req) {} + void init(o2::framework::InitContext& ic) final { + o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest); int minEnt = ic.options().get("min-entries"); - long slotLength = ic.options().get("tf-per-slot"); - if (slotLength == -1) { - slotLength = std::numeric_limits::max(); + auto slotLength = ic.options().get("tf-per-slot"); + if (slotLength == 0) { + slotLength = o2::calibration::INFINITE_TF; } - int updateInterval = ic.options().get("updateInterval"); - int delay = ic.options().get("max-delay"); + auto updateInterval = ic.options().get("updateInterval"); + auto delay = ic.options().get("max-delay"); mAggregator = std::make_unique(minEnt); // TODO mAggregator should get an option to set the binning externally (expose TrackResiduals::setBinning methods to user? as command line option?) mAggregator->setSlotLength(slotLength); @@ -51,8 +55,14 @@ class ResidualAggregatorDevice : public o2::framework::Task mAggregator->setCheckIntervalInfiniteSlot(updateInterval); } + void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final + { + o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj); + } + void run(o2::framework::ProcessingContext& pc) final { + o2::base::GRPGeomHelper::instance().checkUpdates(pc); auto data = pc.inputs().get>("input"); o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mAggregator->getCurrentTFInfo()); LOG(debug) << "Processing TF " << mAggregator->getCurrentTFInfo().tfCounter << " with " << data.size() << " unbinned residuals"; @@ -62,13 +72,13 @@ class ResidualAggregatorDevice : public o2::framework::Task void endOfStream(o2::framework::EndOfStreamContext& ec) final { LOG(info) << "Finalizing calibration for end of stream"; - constexpr uint64_t INFINITE_TF = 0xffffffffffffffff; - mAggregator->checkSlotsToFinalize(INFINITE_TF); + mAggregator->checkSlotsToFinalize(o2::calibration::INFINITE_TF); mAggregator.reset(); // must invoke destructor manually here, otherwise we get a segfault } private: std::unique_ptr mAggregator; + std::shared_ptr mCCDBRequest; }; } // namespace calibration @@ -78,15 +88,23 @@ namespace framework DataProcessorSpec getTPCResidualAggregatorSpec() { + std::vector inputs{{"input", "GLO", "UNBINNEDRES"}}; + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputs); return DataProcessorSpec{ "residual-aggregator", - Inputs{{"input", "GLO", "UNBINNEDRES"}}, + inputs, Outputs{}, - AlgorithmSpec{adaptFromTask()}, + AlgorithmSpec{adaptFromTask(ccdbRequest)}, Options{ - {"tf-per-slot", VariantType::Int, 6'000, {"number of TFs per calibration time slot (put -1 for infinite slot length)"}}, - {"updateInterval", VariantType::Int, 6'000, {"update interval in number of TFs in case slot length is infinite"}}, - {"max-delay", VariantType::Int, 10, {"number of slots in past to consider"}}, + {"tf-per-slot", VariantType::UInt32, 6'000u, {"number of TFs per calibration time slot (put 0 for infinite slot length)"}}, + {"updateInterval", VariantType::UInt32, 6'000u, {"update interval in number of TFs in case slot length is infinite"}}, + {"max-delay", VariantType::UInt32, 10u, {"number of slots in past to consider"}}, {"min-entries", VariantType::Int, 0, {"minimum number of entries on average per voxel"}}}}; } diff --git a/Detectors/ITSMFT/ITS/calibration/include/ITSCalibration/NoiseCalibratorSpec.h b/Detectors/ITSMFT/ITS/calibration/include/ITSCalibration/NoiseCalibratorSpec.h index 3361130404209..0d3d0765f6273 100644 --- a/Detectors/ITSMFT/ITS/calibration/include/ITSCalibration/NoiseCalibratorSpec.h +++ b/Detectors/ITSMFT/ITS/calibration/include/ITSCalibration/NoiseCalibratorSpec.h @@ -18,6 +18,7 @@ #include #include "Framework/DataProcessorSpec.h" #include "Framework/Task.h" +#include "DetectorsBase/GRPGeomHelper.h" //#define TIME_SLOT_CALIBRATION #ifdef TIME_SLOT_CALIBRATION @@ -39,7 +40,7 @@ namespace its class NoiseCalibratorSpec : public Task { public: - NoiseCalibratorSpec(bool useClusters = false) : mUseClusters(useClusters) + NoiseCalibratorSpec(bool useClusters = false, std::shared_ptr req = {}) : mUseClusters(useClusters), mCCDBRequest(req) { mTimer.Stop(); } @@ -54,6 +55,7 @@ class NoiseCalibratorSpec : public Task void sendOutput(DataAllocator& output); void updateTimeDependentParams(ProcessingContext& pc); std::unique_ptr mCalibrator = nullptr; + std::shared_ptr mCCDBRequest; size_t mDataSizeStat = 0; size_t mNClustersProc = 0; int mValidityDays = 3; diff --git a/Detectors/ITSMFT/ITS/calibration/src/NoiseCalibratorSpec.cxx b/Detectors/ITSMFT/ITS/calibration/src/NoiseCalibratorSpec.cxx index 76a1bf337fa2d..4d1acb42497b0 100644 --- a/Detectors/ITSMFT/ITS/calibration/src/NoiseCalibratorSpec.cxx +++ b/Detectors/ITSMFT/ITS/calibration/src/NoiseCalibratorSpec.cxx @@ -37,6 +37,7 @@ namespace its void NoiseCalibratorSpec::init(InitContext& ic) { + o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest); auto onepix = ic.options().get("1pix-only"); LOG(info) << "Fast 1=pixel calibration: " << onepix; auto probT = ic.options().get("prob-threshold"); @@ -124,6 +125,7 @@ void NoiseCalibratorSpec::endOfStream(o2::framework::EndOfStreamContext& ec) ///_______________________________________ void NoiseCalibratorSpec::updateTimeDependentParams(ProcessingContext& pc) { + o2::base::GRPGeomHelper::instance().checkUpdates(pc); if (mUseClusters) { pc.inputs().get("cldict"); // just to trigger the finaliseCCDB } @@ -132,6 +134,7 @@ void NoiseCalibratorSpec::updateTimeDependentParams(ProcessingContext& pc) ///_______________________________________ void NoiseCalibratorSpec::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj) { + o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj); if (matcher == ConcreteDataMatcher("ITS", "CLUSDICT", 0)) { LOG(info) << "cluster dictionary updated"; mCalibrator->setClusterDictionary((const o2::itsmft::TopologyDictionary*)obj); @@ -150,7 +153,13 @@ DataProcessorSpec getNoiseCalibratorSpec(bool useClusters) inputs.emplace_back("digits", "ITS", "DIGITS", 0, Lifetime::Timeframe); inputs.emplace_back("ROframes", "ITS", "DIGITSROF", 0, Lifetime::Timeframe); } - + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputs); std::vector outputs; outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "ITS_NOISE"}, Lifetime::Sporadic); outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "ITS_NOISE"}, Lifetime::Sporadic); @@ -159,7 +168,7 @@ DataProcessorSpec getNoiseCalibratorSpec(bool useClusters) "its-noise-calibrator", inputs, outputs, - AlgorithmSpec{adaptFromTask(useClusters)}, + AlgorithmSpec{adaptFromTask(useClusters, ccdbRequest)}, Options{ {"1pix-only", VariantType::Bool, false, {"Fast 1-pixel calibration only (cluster input only)"}}, {"prob-threshold", VariantType::Float, 3.e-6f, {"Probability threshold for noisy pixels"}}, diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h index 484715d87e53c..07aafb301d434 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseCalibratorSpec.h @@ -20,6 +20,7 @@ #include "Framework/Task.h" #include "MFTCalibration/NoiseCalibrator.h" +#include "DetectorsBase/GRPGeomHelper.h" using CALIBRATOR = o2::mft::NoiseCalibrator; //#include "MFTCalibration/NoiseSlotCalibrator.h" //For TimeSlot calibration @@ -38,7 +39,7 @@ namespace mft class NoiseCalibratorSpec : public Task { public: - NoiseCalibratorSpec(bool digits = false); + NoiseCalibratorSpec(bool digits = false, std::shared_ptr req = {}); ~NoiseCalibratorSpec() override = default; void init(InitContext& ic) final; @@ -54,6 +55,7 @@ class NoiseCalibratorSpec : public Task void setOutputDcs(const o2::itsmft::NoiseMap& payload); o2::itsmft::NoiseMap mNoiseMap{936}; std::unique_ptr mCalibrator = nullptr; + std::shared_ptr mCCDBRequest; std::string mPath; std::string mMeta; diff --git a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h index 619513984cbee..c985f156b87b1 100644 --- a/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h +++ b/Detectors/ITSMFT/MFT/calibration/include/MFTCalibration/NoiseSlotCalibrator.h @@ -45,7 +45,7 @@ class NoiseSlotCalibrator : public o2::calibration::TimeSlotCalibration::max); + setSlotLength(INFINITE_TF); } ~NoiseSlotCalibrator() final = default; diff --git a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx index ce263f676fdef..31e9ffd695f04 100644 --- a/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx +++ b/Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx @@ -35,13 +35,14 @@ namespace o2 namespace mft { -NoiseCalibratorSpec::NoiseCalibratorSpec(bool useDigits) - : mDigits(useDigits) +NoiseCalibratorSpec::NoiseCalibratorSpec(bool useDigits, std::shared_ptr req) + : mDigits(useDigits), mCCDBRequest(req) { } void NoiseCalibratorSpec::init(InitContext& ic) { + o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest); auto probT = ic.options().get("prob-threshold"); LOG(info) << "Setting the probability threshold to " << probT; @@ -302,6 +303,7 @@ void NoiseCalibratorSpec::endOfStream(o2::framework::EndOfStreamContext& ec) ///_______________________________________ void NoiseCalibratorSpec::updateTimeDependentParams(ProcessingContext& pc) { + o2::base::GRPGeomHelper::instance().checkUpdates(pc); if (!mDigits) { pc.inputs().get("cldict"); // just to trigger the finaliseCCDB } @@ -310,6 +312,7 @@ void NoiseCalibratorSpec::updateTimeDependentParams(ProcessingContext& pc) ///_______________________________________ void NoiseCalibratorSpec::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj) { + o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj); if (matcher == ConcreteDataMatcher("MFT", "CLUSDICT", 0)) { LOG(info) << "cluster dictionary updated"; mCalibrator->setClusterDictionary((const o2::itsmft::TopologyDictionary*)obj); @@ -329,7 +332,13 @@ DataProcessorSpec getNoiseCalibratorSpec(bool useDigits) inputs.emplace_back("ROframes", detOrig, "CLUSTERSROF", 0, Lifetime::Timeframe); inputs.emplace_back("cldict", "ITS", "CLUSDICT", 0, Lifetime::Condition, ccdbParamSpec("MFT/Calib/ClusterDictionary")); } - + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputs); using clbUtils = o2::calibration::Utils; std::vector outputs; outputs.emplace_back(ConcreteDataTypeMatcher{clbUtils::gDataOriginCDBPayload, "MFT_NoiseMap"}, Lifetime::Sporadic); @@ -339,7 +348,7 @@ DataProcessorSpec getNoiseCalibratorSpec(bool useDigits) "mft-noise-calibrator", inputs, outputs, - AlgorithmSpec{adaptFromTask(useDigits)}, + AlgorithmSpec{adaptFromTask(useDigits, ccdbRequest)}, Options{ {"prob-threshold", VariantType::Float, 1.e-6f, {"Probability threshold for noisy pixels"}}, {"tstart", VariantType::Int64, -1ll, {"Start of validity timestamp"}}, diff --git a/Detectors/ITSMFT/MFT/condition/include/MFTCondition/MFTDCSProcessor.h b/Detectors/ITSMFT/MFT/condition/include/MFTCondition/MFTDCSProcessor.h index 6541165574016..323086c5afe9b 100644 --- a/Detectors/ITSMFT/MFT/condition/include/MFTCondition/MFTDCSProcessor.h +++ b/Detectors/ITSMFT/MFT/condition/include/MFTCondition/MFTDCSProcessor.h @@ -122,7 +122,7 @@ void MFTDCSProcessor::prepareCCDBobjectInfo(T& obj, CcdbObjectInfo& info, const info.setObjectType(clName); info.setFileName(flName); info.setStartValidityTimestamp(tf); - info.setEndValidityTimestamp(99999999999999); + info.setEndValidityTimestamp(o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); info.setMetaData(md); } diff --git a/Detectors/ITSMFT/MFT/condition/testWorkflow/MFTDCSConfigProcessorSpec.h b/Detectors/ITSMFT/MFT/condition/testWorkflow/MFTDCSConfigProcessorSpec.h index a837103cd8c59..aef6c32bbc309 100644 --- a/Detectors/ITSMFT/MFT/condition/testWorkflow/MFTDCSConfigProcessorSpec.h +++ b/Detectors/ITSMFT/MFT/condition/testWorkflow/MFTDCSConfigProcessorSpec.h @@ -74,8 +74,6 @@ class MFTDCSConfigProcessor : public o2::framework::Task auto tf = std::chrono::duration_cast(HighResClock::now().time_since_epoch()).count(); - constexpr uint64_t INFINITE_TF = 0xffffffffffffffff; - using clbUtils = o2::calibration::Utils; const auto& payload = mReader.getConfigInfo(); @@ -86,7 +84,7 @@ class MFTDCSConfigProcessor : public o2::framework::Task std::map md; md.emplace("created by", "dpl"); - o2::ccdb::CcdbObjectInfo info("MFT/Config/Params", clName, flName, md, tf, INFINITE_TF); + o2::ccdb::CcdbObjectInfo info("MFT/Config/Params", clName, flName, md, tf, o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); auto image = o2::ccdb::CcdbApi::createObjectImage(&payload, &info); diff --git a/Detectors/MUON/Common/src/dcs-ccdb.cxx b/Detectors/MUON/Common/src/dcs-ccdb.cxx index b5026a522692b..c8e61ce75f28d 100644 --- a/Detectors/MUON/Common/src/dcs-ccdb.cxx +++ b/Detectors/MUON/Common/src/dcs-ccdb.cxx @@ -120,10 +120,7 @@ void makeCCDBEntryForDCS(const std::string ccdbUrl, uint64_t timestamp) << o2::muon::subsysname() << " data points to " << CcdbDpConfName() << "\n"; - uint64_t endOfValidity = 99999999999999; - - api.storeAsTFileAny(&dpid2DataDesc, CcdbDpConfName(), md, timestamp, - endOfValidity); + api.storeAsTFileAny(&dpid2DataDesc, CcdbDpConfName(), md, timestamp, o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); } bool match(const std::vector& queries, const char* pattern) diff --git a/Detectors/MUON/Common/src/dcs-processor-workflow.cxx b/Detectors/MUON/Common/src/dcs-processor-workflow.cxx index f3f821c1b8782..c8a2dc34a281a 100644 --- a/Detectors/MUON/Common/src/dcs-processor-workflow.cxx +++ b/Detectors/MUON/Common/src/dcs-processor-workflow.cxx @@ -65,7 +65,7 @@ o2::ccdb::CcdbObjectInfo createDefaultInfo(const char* path) info.setObjectType(clName); info.setFileName(flName); info.setStartValidityTimestamp(0); - info.setEndValidityTimestamp(99999999999999); + info.setEndValidityTimestamp(o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); std::map md; info.setMetaData(md); return info; diff --git a/Detectors/MUON/MCH/Calibration/include/MCHCalibration/BadChannelCalibrator.h b/Detectors/MUON/MCH/Calibration/include/MCHCalibration/BadChannelCalibrator.h index c09db6979200b..3516fd4ec2043 100644 --- a/Detectors/MUON/MCH/Calibration/include/MCHCalibration/BadChannelCalibrator.h +++ b/Detectors/MUON/MCH/Calibration/include/MCHCalibration/BadChannelCalibrator.h @@ -27,20 +27,20 @@ namespace o2::mch::calibration { -/** +/** * @class BadChannelCalibrator * @brief Compute bad channel map from pedestal data * - * Calibrator that checks the computed mean and RMS of the MCH pedestals + * Calibrator that checks the computed mean and RMS of the MCH pedestals * and compares the values with (configurable) thresholds. - * The channels whose values exceed one of the thresholds are + * The channels whose values exceed one of the thresholds are * considered bad/noisy and they are stored into a * "bad channels" list that is sent to the CDDB populator(s). */ class BadChannelCalibrator final : public o2::calibration::TimeSlotCalibration { - using TFType = uint64_t; + using TFType = o2::calibration::TFType; using Slot = o2::calibration::TimeSlot; using BadChannelsVector = std::vector; using PedestalsVector = std::vector; @@ -51,7 +51,7 @@ class BadChannelCalibrator final : public o2::calibration::TimeSlotCalibration("logging-interval") * 1000; mCalibrator = std::make_unique(); - mCalibrator->setSlotLength(std::numeric_limits::max()); + mCalibrator->setSlotLength(o2::calibration::INFINITE_TF); mCalibrator->setUpdateAtTheEndOfRunOnly(); mTimeStamp = std::numeric_limits::max(); } +//_________________________________________________________________ +void BadChannelCalibrationDevice::finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) +{ + o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj); +} + void BadChannelCalibrationDevice::logStats(size_t dataSize) { static auto loggerStart = std::chrono::high_resolution_clock::now(); @@ -64,6 +71,7 @@ void BadChannelCalibrationDevice::logStats(size_t dataSize) void BadChannelCalibrationDevice::run(o2::framework::ProcessingContext& pc) { + o2::base::GRPGeomHelper::instance().checkUpdates(pc); o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mCalibrator->getCurrentTFInfo()); mTimeStamp = std::min(mTimeStamp, mCalibrator->getCurrentTFInfo().creation); auto data = pc.inputs().get>("digits"); @@ -84,7 +92,7 @@ ccdb::CcdbObjectInfo createCcdbInfo(const T& object, uint64_t timeStamp, std::st auto flName = o2::ccdb::CcdbApi::generateFileName(clName); std::map md; md["upload-reason"] = reason; - return o2::ccdb::CcdbObjectInfo("MCH/BadChannelCalib", clName, flName, md, timeStamp, 99999999999999); + return o2::ccdb::CcdbObjectInfo("MCH/BadChannelCalib", clName, flName, md, timeStamp, o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); } void BadChannelCalibrationDevice::endOfStream(o2::framework::EndOfStreamContext& ec) @@ -139,8 +147,7 @@ void BadChannelCalibrationDevice::sendOutput(o2::framework::DataAllocator& outpu auto reason_with_entries = fmt::format("{} ; nentries = {}", reason, nentries); LOGP(info, "sendOutput: {}", reason_with_entries); - constexpr uint64_t INFINITE_TF = 0xffffffffffffffff; - mCalibrator->checkSlotsToFinalize(INFINITE_TF); + mCalibrator->checkSlotsToFinalize(o2::calibration::INFINITE_TF); // send regular bad channel object to subspec 0. This regular object // is meant for O2 consumption (in reconstruction and/or simulation) diff --git a/Detectors/MUON/MCH/Calibration/src/BadChannelCalibrationDevice.h b/Detectors/MUON/MCH/Calibration/src/BadChannelCalibrationDevice.h index 667f825607a74..edbb43472d328 100644 --- a/Detectors/MUON/MCH/Calibration/src/BadChannelCalibrationDevice.h +++ b/Detectors/MUON/MCH/Calibration/src/BadChannelCalibrationDevice.h @@ -16,6 +16,7 @@ #include "Framework/Task.h" #include #include +#include "DetectorsBase/GRPGeomHelper.h" namespace o2::framework { @@ -36,7 +37,7 @@ namespace o2::mch::calibration class BadChannelCalibrationDevice : public o2::framework::Task { public: - explicit BadChannelCalibrationDevice() = default; + explicit BadChannelCalibrationDevice(std::shared_ptr req) : mCCDBRequest(req) {} void init(o2::framework::InitContext& ic) final; @@ -46,11 +47,14 @@ class BadChannelCalibrationDevice : public o2::framework::Task void endOfStream(o2::framework::EndOfStreamContext& ec) final; + void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final; + private: void sendOutput(o2::framework::DataAllocator& output, std::string_view reason); private: std::unique_ptr mCalibrator; + std::shared_ptr mCCDBRequest; uint64_t mTimeStamp; int mLoggingInterval = {0}; /// time interval between statistics logging messages diff --git a/Detectors/MUON/MCH/Calibration/src/badchannel-calib-workflow.cxx b/Detectors/MUON/MCH/Calibration/src/badchannel-calib-workflow.cxx index 401aad70b66db..aa6251c1389cd 100644 --- a/Detectors/MUON/MCH/Calibration/src/badchannel-calib-workflow.cxx +++ b/Detectors/MUON/MCH/Calibration/src/badchannel-calib-workflow.cxx @@ -45,12 +45,19 @@ DataProcessorSpec getBadChannelCalibratorSpec(const char* specName, const std::s outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "MCH_BADCHAN"}, Lifetime::Sporadic); outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "MCH_BADCHAN"}, Lifetime::Sporadic); outputs.emplace_back(OutputSpec{"MCH", "PEDESTALS", 0, Lifetime::Sporadic}); - + std::vector inputs = o2::framework::select(fmt::format("digits:MCH/{}", inputSpec.data()).c_str()); + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputs); return DataProcessorSpec{ specName, - o2::framework::select(fmt::format("digits:MCH/{}", inputSpec.data()).c_str()), + inputs, outputs, - AlgorithmSpec{adaptFromTask()}, + AlgorithmSpec{adaptFromTask(ccdbRequest)}, Options{ {"logging-interval", VariantType::Int, 0, {"time interval in seconds between logging messages (set to zero to disable)"}}, }}; diff --git a/Detectors/MUON/MID/Calibration/include/MIDCalibration/ChannelCalibrator.h b/Detectors/MUON/MID/Calibration/include/MIDCalibration/ChannelCalibrator.h index a53a15d83f019..1b68412828662 100644 --- a/Detectors/MUON/MID/Calibration/include/MIDCalibration/ChannelCalibrator.h +++ b/Detectors/MUON/MID/Calibration/include/MIDCalibration/ChannelCalibrator.h @@ -57,7 +57,7 @@ class NoiseData class ChannelCalibrator final : public o2::calibration::TimeSlotCalibration { - using TFType = uint64_t; + using TFType = o2::calibration::TFType; using Slot = o2::calibration::TimeSlot; public: @@ -110,4 +110,4 @@ class ChannelCalibrator final : public o2::calibration::TimeSlotCalibration req) : mCCDBRequest(req) { mCalibrator.setReferenceMasks(makeDefaultMasksFromCrateConfig(feeIdConfig, crateMasks)); } void init(of::InitContext& ic) { + o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest); mThreshold = ic.options().get("mid-mask-threshold"); - int slotL = ic.options().get("tf-per-slot"); - int delay = ic.options().get("max-delay"); + auto slotL = ic.options().get("tf-per-slot"); + auto delay = ic.options().get("max-delay"); mCalibrator.setSlotLength(slotL); mCalibrator.setMaxSlotsDelay(delay); mCalibrator.setUpdateAtTheEndOfRunOnly(); } + //_________________________________________________________________ + void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) + { + o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj); + } + void run(of::ProcessingContext& pc) { + o2::base::GRPGeomHelper::instance().checkUpdates(pc); auto noiseRof = pc.inputs().get>("mid_noise_rof"); unsigned long nEvents = noiseRof.size(); if (nEvents == 0) { @@ -87,13 +96,13 @@ class ChannelCalibratorDeviceDPL void endOfStream(of::EndOfStreamContext& ec) { - constexpr uint64_t INFINITE_TF = 0xffffffffffffffff; - mCalibrator.checkSlotsToFinalize(INFINITE_TF); + mCalibrator.checkSlotsToFinalize(ChannelCalibrator::INFINITE_TF); sendOutput(ec.outputs()); } private: ChannelCalibrator mCalibrator{}; ///< Calibrator + std::shared_ptr mCCDBRequest; std::vector mRefMasks{}; ///< Reference masks double mThreshold{0.9}; ///< Occupancy threshold for producing a mask @@ -114,7 +123,7 @@ class ChannelCalibratorDeviceDPL { o2::ccdb::CcdbObjectInfo info; std::map md; - o2::calibration::Utils::prepareCCDBobjectInfo(payload, info, path, md, mCalibrator.getTFEnd(), o2::calibration::Utils::INFINITE_TIME); + o2::calibration::Utils::prepareCCDBobjectInfo(payload, info, path, md, mCalibrator.getTFEnd(), o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); 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(); @@ -132,7 +141,13 @@ of::DataProcessorSpec getChannelCalibratorSpec(const FEEIdConfig& feeIdConfig, c inputSpecs.emplace_back("mid_noise_rof", header::gDataOriginMID, "NOISEROF"); inputSpecs.emplace_back("mid_dead", header::gDataOriginMID, "DEAD"); inputSpecs.emplace_back("mid_dead_rof", header::gDataOriginMID, "DEADROF"); - + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputSpecs); std::vector outputSpecs; outputSpecs.emplace_back(o2::calibration::Utils::gDataOriginCDBPayload, "MID_BAD_CHANNELS", 0, of::Lifetime::Sporadic); outputSpecs.emplace_back(o2::calibration::Utils::gDataOriginCDBWrapper, "MID_BAD_CHANNELS", 0, of::Lifetime::Sporadic); @@ -143,11 +158,11 @@ of::DataProcessorSpec getChannelCalibratorSpec(const FEEIdConfig& feeIdConfig, c "MIDChannelCalibrator", {inputSpecs}, {outputSpecs}, - of::AlgorithmSpec{of::adaptFromTask(feeIdConfig, crateMasks)}, + of::AlgorithmSpec{of::adaptFromTask(feeIdConfig, crateMasks, ccdbRequest)}, of::Options{ {"mid-mask-threshold", of::VariantType::Double, 0.9, {"Tolerated occupancy before producing a map"}}, - {"tf-per-slot", of::VariantType::Int64, INFINITE_TF, {"number of TFs per calibration time slot"}}, - {"max-delay", of::VariantType::Int64, 0ll, {"number of slots in past to consider"}}}}; + {"tf-per-slot", of::VariantType::UInt32, INFINITE_TF, {"number of TFs per calibration time slot"}}, + {"max-delay", of::VariantType::UInt32, 0u, {"number of slots in past to consider"}}}}; } } // namespace mid } // namespace o2 diff --git a/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSEnergyCalibDevice.h b/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSEnergyCalibDevice.h index 57a109fc89700..dca1800be0a69 100644 --- a/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSEnergyCalibDevice.h +++ b/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSEnergyCalibDevice.h @@ -24,6 +24,7 @@ #include "DataFormatsPHOS/BadChannelsMap.h" #include "DataFormatsPHOS/CalibParams.h" #include "PHOSCalibWorkflow/PHOSEnergyCalibrator.h" +#include "DetectorsBase/GRPGeomHelper.h" #include "TFile.h" #include "TTree.h" @@ -37,7 +38,7 @@ namespace phos class PHOSEnergyCalibDevice : public o2::framework::Task { public: - explicit PHOSEnergyCalibDevice(bool useCCDB) : mUseCCDB(useCCDB) {} + explicit PHOSEnergyCalibDevice(bool useCCDB, std::shared_ptr req) : mUseCCDB(useCCDB), mCCDBRequest(req) {} void init(o2::framework::InitContext& ic) final; @@ -47,6 +48,11 @@ class PHOSEnergyCalibDevice : public o2::framework::Task void stop() final; + void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final + { + o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj); + } + protected: void postHistosCCDB(o2::framework::EndOfStreamContext& ec); void fillOutputTree(); @@ -75,6 +81,7 @@ class PHOSEnergyCalibDevice : public o2::framework::Task std::unique_ptr mFileOut; /// File to store output calib digits std::unique_ptr mTreeOut; /// Tree to store output calib digits std::unique_ptr mFileMetaData; + std::shared_ptr mCCDBRequest; }; o2::framework::DataProcessorSpec getPHOSEnergyCalibDeviceSpec(bool useCCDB); diff --git a/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSEnergyCalibrator.h b/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSEnergyCalibrator.h index e2deec6f5944e..ae59a2e88e78c 100644 --- a/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSEnergyCalibrator.h +++ b/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSEnergyCalibrator.h @@ -119,7 +119,7 @@ class PHOSEnergyCalibrator final : public o2::calibration::TimeSlotCalibration& clusters, const gsl::span& cluelements, const gsl::span& cluTR, std::vector& outputDigits); void endOfStream(); diff --git a/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSRunbyrunCalibDevice.h b/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSRunbyrunCalibDevice.h index 6bbb69221c725..72b43c239986b 100644 --- a/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSRunbyrunCalibDevice.h +++ b/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSRunbyrunCalibDevice.h @@ -21,6 +21,7 @@ #include "DataFormatsPHOS/Cluster.h" #include "DataFormatsPHOS/BadChannelsMap.h" #include "PHOSCalibWorkflow/PHOSRunbyrunCalibrator.h" +#include "DetectorsBase/GRPGeomHelper.h" using namespace o2::framework; @@ -32,7 +33,7 @@ namespace phos class PHOSRunbyrunCalibDevice { public: - PHOSRunbyrunCalibDevice() = default; + PHOSRunbyrunCalibDevice(std::shared_ptr req) : mCCDBRequest(req) {} void init(o2::framework::InitContext& ic); @@ -40,6 +41,11 @@ class PHOSRunbyrunCalibDevice void endOfStream(o2::framework::EndOfStreamContext& ec); + void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) + { + o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj); + } + protected: bool checkFitResult(); @@ -48,6 +54,7 @@ class PHOSRunbyrunCalibDevice long mRunStartTime = 0; /// start time of the run (sec) std::array mRunByRun; /// Final calibration object std::unique_ptr mCalibrator; /// Agregator of calibration TimeFrameSlots + std::shared_ptr mCCDBRequest; }; o2::framework::DataProcessorSpec getPHOSRunbyrunCalibDeviceSpec(bool useCCDB); diff --git a/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSRunbyrunCalibrator.h b/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSRunbyrunCalibrator.h index c89c38e017dc6..ee4ad9cf58f19 100644 --- a/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSRunbyrunCalibrator.h +++ b/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSRunbyrunCalibrator.h @@ -80,8 +80,8 @@ class PHOSRunbyrunCalibrator final : public o2::calibration::TimeSlotCalibration bool hasEnoughData(const Slot& slot) const final; void initOutput() final; void finalizeSlot(Slot& slot) final; - Slot& emplaceNewSlot(bool front, uint64_t tstart, uint64_t tend) final; - bool process(uint64_t tf, const gsl::span& clu, const gsl::span& trs); + Slot& emplaceNewSlot(bool front, TFType tstart, TFType tend) final; + bool process(TFType tf, const gsl::span& clu, const gsl::span& trs); std::array getCalibration() { return mRunByRun; } void endOfStream(); diff --git a/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSTurnonCalibDevice.h b/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSTurnonCalibDevice.h index c57cd22d76301..0401f3132f4d0 100644 --- a/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSTurnonCalibDevice.h +++ b/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSTurnonCalibDevice.h @@ -22,6 +22,7 @@ #include "DataFormatsPHOS/Cluster.h" #include "DataFormatsPHOS/TriggerMap.h" #include "PHOSCalibWorkflow/PHOSTurnonCalibrator.h" +#include "DetectorsBase/GRPGeomHelper.h" using namespace o2::framework; @@ -33,7 +34,7 @@ namespace phos class PHOSTurnonCalibDevice : public o2::framework::Task { public: - explicit PHOSTurnonCalibDevice(bool useCCDB) : mUseCCDB(useCCDB) {} + explicit PHOSTurnonCalibDevice(bool useCCDB, std::shared_ptr req) : mUseCCDB(useCCDB), mCCDBRequest(req) {} void init(o2::framework::InitContext& ic) final; @@ -41,6 +42,11 @@ class PHOSTurnonCalibDevice : public o2::framework::Task void endOfStream(o2::framework::EndOfStreamContext& ec) final; + void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final + { + o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj); + } + protected: bool checkFitResult() { return true; } // TODO!! implement true check @@ -49,6 +55,7 @@ class PHOSTurnonCalibDevice : public o2::framework::Task long mRunStartTime = 0; /// start time of the run (sec) std::unique_ptr mTriggerMap; /// Final calibration object std::unique_ptr mCalibrator; /// Agregator of calibration TimeFrameSlots + std::shared_ptr mCCDBRequest; }; o2::framework::DataProcessorSpec getPHOSTurnonCalibDeviceSpec(bool useCCDB); diff --git a/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSTurnonCalibrator.h b/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSTurnonCalibrator.h index bf7934a40fcff..27a74db9b9641 100644 --- a/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSTurnonCalibrator.h +++ b/Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSTurnonCalibrator.h @@ -78,7 +78,7 @@ class PHOSTurnonCalibrator final : public o2::calibration::TimeSlotCalibration& cells, const gsl::span& trs, const gsl::span& clusters, const gsl::span& cluTR); diff --git a/Detectors/PHOS/calib/src/PHOSEnergyCalibDevice.cxx b/Detectors/PHOS/calib/src/PHOSEnergyCalibDevice.cxx index ec83ab3a427c0..134932182c0c5 100644 --- a/Detectors/PHOS/calib/src/PHOSEnergyCalibDevice.cxx +++ b/Detectors/PHOS/calib/src/PHOSEnergyCalibDevice.cxx @@ -30,7 +30,7 @@ using namespace o2::phos; void PHOSEnergyCalibDevice::init(o2::framework::InitContext& ic) { - + o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest); mOutputDir = ic.options().get("output-dir"); mOutputDir = o2::utils::Str::rectifyDirectory(mOutputDir); mMetaFileDir = ic.options().get("meta-output-dir"); @@ -72,6 +72,7 @@ void PHOSEnergyCalibDevice::init(o2::framework::InitContext& ic) void PHOSEnergyCalibDevice::run(o2::framework::ProcessingContext& pc) { + o2::base::GRPGeomHelper::instance().checkUpdates(pc); // Do not use ccdb if already created if (!mHasCalib) { // Default map and calibration was not set, use CCDB @@ -116,8 +117,7 @@ void PHOSEnergyCalibDevice::run(o2::framework::ProcessingContext& pc) void PHOSEnergyCalibDevice::endOfStream(o2::framework::EndOfStreamContext& ec) { - constexpr uint64_t INFINITE_TF = 0xffffffffffffffff; - mCalibrator->checkSlotsToFinalize(INFINITE_TF); + mCalibrator->checkSlotsToFinalize(o2::calibration::INFINITE_TF); mCalibrator->endOfStream(); if (mPostHistos) { postHistosCCDB(ec); @@ -198,7 +198,7 @@ void PHOSEnergyCalibDevice::postHistosCCDB(o2::framework::EndOfStreamContext& ec // prepare all info to be sent to CCDB auto flName = o2::ccdb::CcdbApi::generateFileName("TimeEnHistos"); std::map md; - o2::ccdb::CcdbObjectInfo info("PHS/Calib/TimeEnHistos", "TimeEnHistos", flName, md, mRunStartTime, 99999999999999); + o2::ccdb::CcdbObjectInfo info("PHS/Calib/TimeEnHistos", "TimeEnHistos", flName, md, mRunStartTime, o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); info.setMetaData(md); auto image = o2::ccdb::CcdbApi::createObjectImage(mCalibrator->getCollectedHistos(), &info); @@ -222,6 +222,13 @@ o2::framework::DataProcessorSpec o2::phos::getPHOSEnergyCalibDeviceSpec(bool use inputs.emplace_back("bdmap", o2::header::gDataOriginPHS, "PHS_BM", 0, o2::framework::Lifetime::Condition, o2::framework::ccdbParamSpec("PHS/Calib/BadMap")); inputs.emplace_back("clb", o2::header::gDataOriginPHS, "PHS_Calibr", 0, o2::framework::Lifetime::Condition, o2::framework::ccdbParamSpec("PHS/Calib/CalibParams")); } + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputs); using clbUtils = o2::calibration::Utils; std::vector outputs; outputs.emplace_back(ConcreteDataTypeMatcher{clbUtils::gDataOriginCDBPayload, "PHOS_TEHistos"}, o2::framework::Lifetime::Sporadic); @@ -230,7 +237,7 @@ o2::framework::DataProcessorSpec o2::phos::getPHOSEnergyCalibDeviceSpec(bool use return o2::framework::DataProcessorSpec{"PHOSEnergyCalibDevice", inputs, outputs, - o2::framework::adaptFromTask(useCCDB), + o2::framework::adaptFromTask(useCCDB, ccdbRequest), o2::framework::Options{ {"ptminmgg", o2::framework::VariantType::Float, 1.5f, {"minimal pt to fill mgg calib histos"}}, {"eminhgtime", o2::framework::VariantType::Float, 1.5f, {"minimal E (GeV) to fill HG time calib histos"}}, diff --git a/Detectors/PHOS/calib/src/PHOSEnergyCalibrator.cxx b/Detectors/PHOS/calib/src/PHOSEnergyCalibrator.cxx index 36dc77de46cfc..faf9adddf9f20 100644 --- a/Detectors/PHOS/calib/src/PHOSEnergyCalibrator.cxx +++ b/Detectors/PHOS/calib/src/PHOSEnergyCalibrator.cxx @@ -201,7 +201,7 @@ void PHOSEnergyCalibrator::finalizeSlot(Slot& slot) mHistos->merge(c->getCollectedHistos()); } -Slot& PHOSEnergyCalibrator::emplaceNewSlot(bool front, uint64_t tstart, uint64_t tend) +Slot& PHOSEnergyCalibrator::emplaceNewSlot(bool front, TFType tstart, TFType tend) { auto& cont = getSlots(); auto& slot = front ? cont.emplace_front(tstart, tend) : cont.emplace_back(tstart, tend); diff --git a/Detectors/PHOS/calib/src/PHOSRunbyrunCalibDevice.cxx b/Detectors/PHOS/calib/src/PHOSRunbyrunCalibDevice.cxx index 91e9106aab914..1bda107bdbb12 100644 --- a/Detectors/PHOS/calib/src/PHOSRunbyrunCalibDevice.cxx +++ b/Detectors/PHOS/calib/src/PHOSRunbyrunCalibDevice.cxx @@ -22,6 +22,7 @@ using namespace o2::phos; void PHOSRunbyrunCalibDevice::init(o2::framework::InitContext& ic) { + o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest); // int slotL = ic.options().get("tf-per-slot"); // int delay = ic.options().get("max-delay"); mCalibrator.reset(new PHOSRunbyrunCalibrator()); @@ -32,11 +33,12 @@ void PHOSRunbyrunCalibDevice::init(o2::framework::InitContext& ic) } void PHOSRunbyrunCalibDevice::run(o2::framework::ProcessingContext& pc) { + o2::base::GRPGeomHelper::instance().checkUpdates(pc); if (mRunStartTime == 0) { const auto ref = pc.inputs().getFirstValid(true); mRunStartTime = DataRefUtils::getHeader(ref)->creation; // approximate time in ms } - auto tfcounter = o2::header::get(pc.inputs().get("clusters").header)->startTime; // is this the timestamp of the current TF? + auto tfcounter = o2::header::get(pc.inputs().get("clusters").header)->tfCounter; auto clusters = pc.inputs().get>("clusters"); auto cluTR = pc.inputs().get>("cluTR"); LOG(info) << "Processing TF with " << clusters.size() << " clusters and " << cluTR.size() << " TriggerRecords"; @@ -45,8 +47,7 @@ void PHOSRunbyrunCalibDevice::run(o2::framework::ProcessingContext& pc) void PHOSRunbyrunCalibDevice::endOfStream(o2::framework::EndOfStreamContext& ec) { - constexpr uint64_t INFINITE_TF = 0xffffffffffffffff; - mCalibrator->checkSlotsToFinalize(INFINITE_TF); + mCalibrator->checkSlotsToFinalize(o2::calibration::INFINITE_TF); mCalibrator->endOfStream(); mRunByRun = mCalibrator->getCalibration(); if (checkFitResult()) { @@ -54,7 +55,7 @@ void PHOSRunbyrunCalibDevice::endOfStream(o2::framework::EndOfStreamContext& ec) // prepare all info to be sent to CCDB auto flName = o2::ccdb::CcdbApi::generateFileName("Runbyrun"); std::map md; - o2::ccdb::CcdbObjectInfo info("PHS/Calib/Runbyrun", "Runbyrun", flName, md, mRunStartTime, INFINITE_TF); + o2::ccdb::CcdbObjectInfo info("PHS/Calib/Runbyrun", "Runbyrun", flName, md, mRunStartTime, o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); info.setMetaData(md); auto image = o2::ccdb::CcdbApi::createObjectImage(&mRunByRun, &info); @@ -100,11 +101,17 @@ o2::framework::DataProcessorSpec o2::phos::getPHOSRunbyrunCalibDeviceSpec(bool u std::vector inputs; inputs.emplace_back("clusters", "PHS", "CLUSTERS"); inputs.emplace_back("cluTR", "PHS", "CLUSTERTRIGREC"); - + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputs); return DataProcessorSpec{ "calib-phos-runbyrun", inputs, outputs, - AlgorithmSpec{adaptFromTask()}, + AlgorithmSpec{adaptFromTask(ccdbRequest)}, Options{}}; } diff --git a/Detectors/PHOS/calib/src/PHOSRunbyrunCalibrator.cxx b/Detectors/PHOS/calib/src/PHOSRunbyrunCalibrator.cxx index 99770db2afae1..f596b40b52c34 100644 --- a/Detectors/PHOS/calib/src/PHOSRunbyrunCalibrator.cxx +++ b/Detectors/PHOS/calib/src/PHOSRunbyrunCalibrator.cxx @@ -190,7 +190,7 @@ void PHOSRunbyrunCalibrator::finalizeSlot(Slot& slot) c->clear(); } -Slot& PHOSRunbyrunCalibrator::emplaceNewSlot(bool front, uint64_t tstart, uint64_t tend) +Slot& PHOSRunbyrunCalibrator::emplaceNewSlot(bool front, TFType tstart, TFType tend) { auto& cont = getSlots(); @@ -199,7 +199,7 @@ Slot& PHOSRunbyrunCalibrator::emplaceNewSlot(bool front, uint64_t tstart, uint64 return slot; } -bool PHOSRunbyrunCalibrator::process(uint64_t tf, const gsl::span& clu, const gsl::span& tr) +bool PHOSRunbyrunCalibrator::process(TFType tf, const gsl::span& clu, const gsl::span& tr) { // if (!mUpdateAtTheEndOfRunOnly) { // int maxDelay = mMaxSlotsDelay * mSlotLength; diff --git a/Detectors/PHOS/calib/src/PHOSTurnonCalibDevice.cxx b/Detectors/PHOS/calib/src/PHOSTurnonCalibDevice.cxx index d9cdae7b42124..8c6bd21ea8ca0 100644 --- a/Detectors/PHOS/calib/src/PHOSTurnonCalibDevice.cxx +++ b/Detectors/PHOS/calib/src/PHOSTurnonCalibDevice.cxx @@ -28,6 +28,7 @@ using namespace o2::phos; void PHOSTurnonCalibDevice::init(o2::framework::InitContext& ic) { + o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest); // int slotL = ic.options().get("tf-per-slot"); // int delay = ic.options().get("max-delay"); mCalibrator.reset(new PHOSTurnonCalibrator()); @@ -38,6 +39,7 @@ void PHOSTurnonCalibDevice::init(o2::framework::InitContext& ic) } void PHOSTurnonCalibDevice::run(o2::framework::ProcessingContext& pc) { + o2::base::GRPGeomHelper::instance().checkUpdates(pc); auto tfcounter = o2::header::get(pc.inputs().get("clusters").header)->startTime; // is this the timestamp of the current TF? auto cells = pc.inputs().get>("cells"); auto cellTR = pc.inputs().get>("cellTriggerRecords"); @@ -51,15 +53,14 @@ void PHOSTurnonCalibDevice::run(o2::framework::ProcessingContext& pc) void PHOSTurnonCalibDevice::endOfStream(o2::framework::EndOfStreamContext& ec) { - constexpr uint64_t INFINITE_TF = 0xffffffffffffffff; - mCalibrator->checkSlotsToFinalize(INFINITE_TF); + mCalibrator->checkSlotsToFinalize(o2::calibration::INFINITE_TF); mCalibrator->endOfStream(); mTriggerMap.reset(new TriggerMap(mCalibrator->getCalibration())); if (checkFitResult()) { // Calculate and send final object to CCDB auto flName = o2::ccdb::CcdbApi::generateFileName("TriggerMap"); std::map md; - o2::ccdb::CcdbObjectInfo info("PHS/Calib/TriggerMap", "TriggerMap", flName, md, mRunStartTime, 99999999999999); + o2::ccdb::CcdbObjectInfo info("PHS/Calib/TriggerMap", "TriggerMap", flName, md, mRunStartTime, o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); info.setMetaData(md); auto image = o2::ccdb::CcdbApi::createObjectImage(mTriggerMap.get(), &info); @@ -87,7 +88,13 @@ o2::framework::DataProcessorSpec o2::phos::getPHOSTurnonCalibDeviceSpec(bool use inputs.emplace_back("cellTriggerRecords", o2::header::gDataOriginPHS, "CELLTRIGREC", 0, o2::framework::Lifetime::Timeframe); inputs.emplace_back("clusters", o2::header::gDataOriginPHS, "CLUSTERS", 0, o2::framework::Lifetime::Timeframe); inputs.emplace_back("clusterTriggerRecords", o2::header::gDataOriginPHS, "CLUSTERTRIGREC", 0, o2::framework::Lifetime::Timeframe); - + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputs); using clbUtils = o2::calibration::Utils; std::vector outputs; outputs.emplace_back( @@ -100,6 +107,6 @@ o2::framework::DataProcessorSpec o2::phos::getPHOSTurnonCalibDeviceSpec(bool use return o2::framework::DataProcessorSpec{"PHOSTurnonCalibDevice", inputs, outputs, - o2::framework::adaptFromTask(useCCDB), + o2::framework::adaptFromTask(useCCDB, ccdbRequest), o2::framework::Options{}}; } diff --git a/Detectors/PHOS/calib/src/PHOSTurnonCalibrator.cxx b/Detectors/PHOS/calib/src/PHOSTurnonCalibrator.cxx index 00fb384e66e82..dac748611652e 100644 --- a/Detectors/PHOS/calib/src/PHOSTurnonCalibrator.cxx +++ b/Detectors/PHOS/calib/src/PHOSTurnonCalibrator.cxx @@ -143,7 +143,7 @@ void PHOSTurnonCalibrator::finalizeSlot(Slot& slot) } c->clear(); } -PHOSTurnonCalibrator::Slot& PHOSTurnonCalibrator::emplaceNewSlot(bool front, uint64_t tstart, uint64_t tend) +PHOSTurnonCalibrator::Slot& PHOSTurnonCalibrator::emplaceNewSlot(bool front, TFType tstart, TFType tend) { auto& cont = getSlots(); diff --git a/Detectors/TOF/calibration/include/TOFCalibration/LHCClockCalibrator.h b/Detectors/TOF/calibration/include/TOFCalibration/LHCClockCalibrator.h index e0dda6a4adfc3..0ee10d67f6e1a 100644 --- a/Detectors/TOF/calibration/include/TOFCalibration/LHCClockCalibrator.h +++ b/Detectors/TOF/calibration/include/TOFCalibration/LHCClockCalibrator.h @@ -56,7 +56,7 @@ struct LHCClockDataHisto { class LHCClockCalibrator final : public o2::calibration::TimeSlotCalibration { - using TFType = uint64_t; + using TFType = o2::calibration::TFType; using Slot = o2::calibration::TimeSlot; using CalibTOFapi = o2::tof::CalibTOFapi; using LHCphase = o2::dataformats::CalibLHCphaseTOF; diff --git a/Detectors/TOF/calibration/include/TOFCalibration/TOFCalibCollector.h b/Detectors/TOF/calibration/include/TOFCalibration/TOFCalibCollector.h index 230e17d771192..99846863c1cc5 100644 --- a/Detectors/TOF/calibration/include/TOFCalibration/TOFCalibCollector.h +++ b/Detectors/TOF/calibration/include/TOFCalibration/TOFCalibCollector.h @@ -64,7 +64,7 @@ class TOFCalibInfoSlot class TOFCalibCollector final : public o2::calibration::TimeSlotCalibration { - using TFType = uint64_t; + using TFType = o2::calibration::TFType; using Slot = o2::calibration::TimeSlot; public: diff --git a/Detectors/TOF/calibration/include/TOFCalibration/TOFChannelCalibrator.h b/Detectors/TOF/calibration/include/TOFCalibration/TOFChannelCalibrator.h index cdd86b4d2fa4c..7642be3ca21fb 100644 --- a/Detectors/TOF/calibration/include/TOFCalibration/TOFChannelCalibrator.h +++ b/Detectors/TOF/calibration/include/TOFCalibration/TOFChannelCalibrator.h @@ -139,7 +139,7 @@ class TOFChannelData template class TOFChannelCalibrator final : public o2::calibration::TimeSlotCalibration { - using TFType = uint64_t; + using TFType = o2::calibration::TFType; using Slot = o2::calibration::TimeSlot; using CalibTOFapi = o2::tof::CalibTOFapi; using TimeSlewing = o2::dataformats::CalibTimeSlewingParamTOF; diff --git a/Detectors/TOF/calibration/include/TOFCalibration/TOFDiagnosticCalibrator.h b/Detectors/TOF/calibration/include/TOFCalibration/TOFDiagnosticCalibrator.h index b81fd67a8c972..ee222fb1ef378 100644 --- a/Detectors/TOF/calibration/include/TOFCalibration/TOFDiagnosticCalibrator.h +++ b/Detectors/TOF/calibration/include/TOFCalibration/TOFDiagnosticCalibrator.h @@ -24,7 +24,7 @@ namespace tof class TOFDiagnosticCalibrator final : public o2::calibration::TimeSlotCalibration { - using TFType = uint64_t; + using TFType = o2::calibration::TFType; using Slot = o2::calibration::TimeSlot; using CcdbObjectInfo = o2::ccdb::CcdbObjectInfo; using CcdbObjectInfoVector = std::vector; diff --git a/Detectors/TOF/calibration/src/LHCClockCalibrator.cxx b/Detectors/TOF/calibration/src/LHCClockCalibrator.cxx index 5ec181f5bed1d..c1cc634ff7166 100644 --- a/Detectors/TOF/calibration/src/LHCClockCalibrator.cxx +++ b/Detectors/TOF/calibration/src/LHCClockCalibrator.cxx @@ -84,8 +84,6 @@ void LHCClockCalibrator::initOutput() //_____________________________________________ void LHCClockCalibrator::finalizeSlot(Slot& slot) { - static const double TFlength = 1E-3 * o2::raw::HBFUtils::Instance().getNOrbitsPerTF() * o2::constants::lhc::LHCOrbitMUS; // in ms - // Extract results for the single slot o2::tof::LHCClockDataHisto* c = slot.getContainer(); LOG(info) << "Finalize slot " << slot.getTFStart() << " <= TF <= " << slot.getTFEnd() << " with " @@ -108,9 +106,9 @@ void LHCClockCalibrator::finalizeSlot(Slot& slot) auto clName = o2::utils::MemFileHelper::getClassName(l); auto flName = o2::ccdb::CcdbApi::generateFileName(clName); - uint64_t starting = slot.getTFStart() * TFlength - 10000; // start 10 seconds before - uint64_t stopping = slot.getTFEnd() * TFlength + 10000; // stop 10 seconds after - LOG(info) << "starting = " << starting * 1E-3 << " - stopping = " << stopping * 1E-3 << " -> phase = " << fitValues[1] << " ps"; + auto starting = slot.getStartTimeMS() - 10000; // start 10 seconds before + auto stopping = slot.getEndTimeMS() + 10000; // stop 10 seconds after + LOG(info) << "starting = " << starting << " - stopping = " << stopping << " -> phase = " << fitValues[1] << " ps"; mInfoVector.emplace_back("TOF/Calib/LHCphase", clName, flName, md, starting, stopping); mLHCphaseVector.emplace_back(l); diff --git a/Detectors/TOF/calibration/src/TOFChannelCalibrator.cxx b/Detectors/TOF/calibration/src/TOFChannelCalibrator.cxx index cae52a482ffbf..cac1d45844b70 100644 --- a/Detectors/TOF/calibration/src/TOFChannelCalibrator.cxx +++ b/Detectors/TOF/calibration/src/TOFChannelCalibrator.cxx @@ -609,7 +609,7 @@ void TOFChannelCalibrator::finalizeSlotWithCosmics(Slot& slot) auto clName = o2::utils::MemFileHelper::getClassName(ts); auto flName = o2::ccdb::CcdbApi::generateFileName(clName); - mInfoVector.emplace_back("TOF/Calib/ChannelCalib", clName, flName, md, slot.getTFStart(), 99999999999999); + mInfoVector.emplace_back("TOF/Calib/ChannelCalib", clName, flName, md, slot.getTFStart(), o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); mTimeSlewingVector.emplace_back(ts); #ifdef DEBUGGING @@ -727,7 +727,7 @@ void TOFChannelCalibrator::finalizeSlotWithTracks(Slot& slot) } // end loop over sectors auto clName = o2::utils::MemFileHelper::getClassName(ts); auto flName = o2::ccdb::CcdbApi::generateFileName(clName); - mInfoVector.emplace_back("TOF/Calib/ChannelCalib", clName, flName, md, slot.getTFStart(), 99999999999999); + mInfoVector.emplace_back("TOF/Calib/ChannelCalib", clName, flName, md, slot.getTFStart(), o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); mTimeSlewingVector.emplace_back(ts); #ifdef DEBUGGING diff --git a/Detectors/TOF/calibration/src/TOFDCSProcessor.cxx b/Detectors/TOF/calibration/src/TOFDCSProcessor.cxx index e9e1fd5a91026..732b7e8ea7ad3 100644 --- a/Detectors/TOF/calibration/src/TOFDCSProcessor.cxx +++ b/Detectors/TOF/calibration/src/TOFDCSProcessor.cxx @@ -410,7 +410,7 @@ void TOFDCSProcessor::updateFEACCCDB() } std::map md; md["responsible"] = "Chiara Zampolli"; - o2::calibration::Utils::prepareCCDBobjectInfo(mFeac, mccdbLVInfo, "TOF/Calib/LVStatus", md, mStartValidity, o2::calibration::Utils::INFINITE_TIME); + o2::calibration::Utils::prepareCCDBobjectInfo(mFeac, mccdbLVInfo, "TOF/Calib/LVStatus", md, mStartValidity, o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); return; } @@ -426,7 +426,7 @@ void TOFDCSProcessor::updateHVCCDB() } std::map md; md["responsible"] = "Chiara Zampolli"; - o2::calibration::Utils::prepareCCDBobjectInfo(mHV, mccdbHVInfo, "TOF/Calib/HVStatus", md, mStartValidity, o2::calibration::Utils::INFINITE_TIME); + o2::calibration::Utils::prepareCCDBobjectInfo(mHV, mccdbHVInfo, "TOF/Calib/HVStatus", md, mStartValidity, o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); return; } diff --git a/Detectors/TOF/calibration/testWorkflow/DataGeneratorSpec.h b/Detectors/TOF/calibration/testWorkflow/DataGeneratorSpec.h index c2744b0d5b038..95eb5f65d9ede 100644 --- a/Detectors/TOF/calibration/testWorkflow/DataGeneratorSpec.h +++ b/Detectors/TOF/calibration/testWorkflow/DataGeneratorSpec.h @@ -42,7 +42,7 @@ class TFDispatcher : public o2::framework::Task void init(o2::framework::InitContext& ic) final { mMaxTF = ic.options().get("max-timeframes"); - mMinSize = ic.options().get("min-number-of-info"); + mMinSize = ic.options().get("min-number-of-info"); } void run(o2::framework::ProcessingContext& pc) final @@ -221,7 +221,7 @@ DataProcessorSpec getTFDispatcherSpec(int slot, int ngen, int nlanes, int latenc Outputs{{{"output"}, "TOF", "DATASIZE"}}, AlgorithmSpec{adaptFromTask(slot, ngen, nlanes, latency)}, Options{{"max-timeframes", VariantType::Int64, 99999999999ll, {"max TimeFrames to generate"}}, - {"min-number-of-info", VariantType::Int64, 99999999999ll, {"min number of Info (CalibTOFInfo, or Diagnostic) to generate"}}}}; + {"min-number-of-info", VariantType::Int, 9999, {"min number of Info (CalibTOFInfo, or Diagnostic) to generate"}}}}; } DataProcessorSpec getTFProcessorCalibInfoTOFSpec(int latency, int latencyRMS) diff --git a/Detectors/TOF/calibration/testWorkflow/LHCClockCalibratorSpec.h b/Detectors/TOF/calibration/testWorkflow/LHCClockCalibratorSpec.h index aa9920eb57a65..fa4be3e81e11e 100644 --- a/Detectors/TOF/calibration/testWorkflow/LHCClockCalibratorSpec.h +++ b/Detectors/TOF/calibration/testWorkflow/LHCClockCalibratorSpec.h @@ -26,6 +26,7 @@ #include "CCDB/CcdbApi.h" #include "CCDB/CcdbObjectInfo.h" #include "DetectorsRaw/HBFUtils.h" +#include "DetectorsBase/GRPGeomHelper.h" using namespace o2::framework; @@ -40,12 +41,15 @@ class LHCClockCalibDevice : public o2::framework::Task using LHCphase = o2::dataformats::CalibLHCphaseTOF; public: + LHCClockCalibDevice(std::shared_ptr req) : mCCDBRequest(req) {} + void init(o2::framework::InitContext& ic) final { + o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest); int minEnt = std::max(300, ic.options().get("min-entries")); int nb = std::max(500, ic.options().get("nbins")); - int slotL = ic.options().get("tf-per-slot"); - int delay = ic.options().get("max-delay"); + auto slotL = ic.options().get("tf-per-slot"); + auto delay = ic.options().get("max-delay"); mCalibrator = std::make_unique(minEnt, nb); mCalibrator->setSlotLength(slotL); mCalibrator->setMaxSlotsDelay(delay); @@ -71,6 +75,7 @@ class LHCClockCalibDevice : public o2::framework::Task void run(o2::framework::ProcessingContext& pc) final { + o2::base::GRPGeomHelper::instance().checkUpdates(pc); auto data = pc.inputs().get>("input"); o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mCalibrator->getCurrentTFInfo()); @@ -90,11 +95,15 @@ class LHCClockCalibDevice : public o2::framework::Task LOG(info) << "Created " << infoVec.size() << " objects for TF " << mCalibrator->getCurrentTFInfo().tfCounter; } + void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final + { + o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj); + } + void endOfStream(o2::framework::EndOfStreamContext& ec) final { LOG(info) << "Finalizing calibration"; - constexpr uint64_t INFINITE_TF = 0xffffffffffffffff; - mCalibrator->checkSlotsToFinalize(INFINITE_TF); + mCalibrator->checkSlotsToFinalize(o2::calibration::INFINITE_TF); sendOutput(ec.outputs()); } @@ -103,6 +112,7 @@ class LHCClockCalibDevice : public o2::framework::Task LHCphase mPhase; TimeSlewing mTimeSlewing; std::unique_ptr mCalibrator; + std::shared_ptr mCCDBRequest; //________________________________________________________________ void sendOutput(DataAllocator& output) @@ -137,18 +147,25 @@ DataProcessorSpec getLHCClockCalibDeviceSpec() { using device = o2::calibration::LHCClockCalibDevice; using clbUtils = o2::calibration::Utils; - + std::vector inputs{{"input", "TOF", "CALIBDATA"}}; + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputs); std::vector outputs; outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "TOF_LHCphase"}, Lifetime::Sporadic); outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "TOF_LHCphase"}, Lifetime::Sporadic); return DataProcessorSpec{ "calib-lhcclock-calibration", - Inputs{{"input", "TOF", "CALIBDATA"}}, + inputs, outputs, - AlgorithmSpec{adaptFromTask()}, + AlgorithmSpec{adaptFromTask(ccdbRequest)}, Options{ - {"tf-per-slot", VariantType::Int, 5, {"number of TFs per calibration time slot"}}, - {"max-delay", VariantType::Int, 3, {"number of slots in past to consider"}}, + {"tf-per-slot", VariantType::UInt32, 5u, {"number of TFs per calibration time slot"}}, + {"max-delay", VariantType::UInt32, 3u, {"number of slots in past to consider"}}, {"min-entries", VariantType::Int, 500, {"minimum number of entries to fit single time slot"}}, {"nbins", VariantType::Int, 1000, {"number of bins for "}}}}; } diff --git a/Detectors/TOF/calibration/testWorkflow/README.md b/Detectors/TOF/calibration/testWorkflow/README.md index 379fa9621400c..cab0daac60f12 100644 --- a/Detectors/TOF/calibration/testWorkflow/README.md +++ b/Detectors/TOF/calibration/testWorkflow/README.md @@ -55,7 +55,7 @@ o2-calibration-ccdb-populator-workflow --ccdb-path localhost:8080 ## TOF channel calibration: -To obtain the TOF channel offsets (at end of processing). Input from simulation, but is should work if attached to reco+calib flow +To obtain the TOF channel offsets (at end of processing). Input from simulation, but it should work if attached to reco+calib flow * simulating reading from ccdb, and using it, with "-b", in "test" mode --> to use this, we need an appropriate CCDB object in the CCDB @@ -109,6 +109,9 @@ o2-calibration-data-generator-workflow --lanes 8 --max-timeframes 5000 --gen-nor o2-calibration-data-generator-workflow --lanes 8 --max-timeframes 5000 --gen-norm 3 --gen-slot 2 ``` +Note that the `o2-calibration-data-generator-workflow` parses the string passed via `--configKeyValues` option and the DataHeaders to generate can be steered using HBFUtils class, +e.g. the "run start" time as HBFUtils.startTime (if 0, `now()` will be used), starting orbit via HBFUtils.orbitFirstSampled etc. + * To run the calibration with cosmics: ```shell diff --git a/Detectors/TOF/calibration/testWorkflow/TOFCalibCollectorSpec.h b/Detectors/TOF/calibration/testWorkflow/TOFCalibCollectorSpec.h index 96611c05cd06b..b7979f32e706d 100644 --- a/Detectors/TOF/calibration/testWorkflow/TOFCalibCollectorSpec.h +++ b/Detectors/TOF/calibration/testWorkflow/TOFCalibCollectorSpec.h @@ -22,6 +22,7 @@ #include "Framework/ConfigParamRegistry.h" #include "Framework/ControlService.h" #include "Framework/WorkflowSpec.h" +#include "DetectorsBase/GRPGeomHelper.h" #include @@ -36,24 +37,33 @@ class TOFCalibCollectorDevice : public o2::framework::Task { public: + TOFCalibCollectorDevice(std::shared_ptr req) : mCCDBRequest(req) {} + void init(o2::framework::InitContext& ic) final { - + o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest); bool isTFsendingPolicy = ic.options().get("tf-sending-policy"); int maxEnt = ic.options().get("max-number-hits-to-fill-tree"); bool isTest = ic.options().get("running-in-test-mode"); bool absMaxEnt = ic.options().get("is-max-number-hits-to-fill-tree-absolute"); - int updateInterval = ic.options().get("update-interval"); + auto updateInterval = ic.options().get("update-interval"); mCollector = std::make_unique(isTFsendingPolicy, maxEnt); mCollector->setIsTest(isTest); mCollector->setIsMaxNumberOfHitsAbsolute(absMaxEnt); - mCollector->setSlotLength(std::numeric_limits::max()); + mCollector->setFinalizeWhenReady(); // finalize slot once stat is ok and create next one mCollector->setCheckIntervalInfiniteSlot(updateInterval); mCollector->setMaxSlotsDelay(0); } + //_________________________________________________________________ + void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final + { + o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj); + } + void run(o2::framework::ProcessingContext& pc) final { + o2::base::GRPGeomHelper::instance().checkUpdates(pc); auto data = pc.inputs().get>("input"); o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mCollector->getCurrentTFInfo()); LOG(info) << "Processing TF " << mCollector->getCurrentTFInfo().tfCounter << " with " << data.size() << " tracks"; @@ -63,8 +73,7 @@ class TOFCalibCollectorDevice : public o2::framework::Task void endOfStream(o2::framework::EndOfStreamContext& ec) final { - constexpr uint64_t INFINITE_TF = 0xffffffffffffffff; - mCollector->checkSlotsToFinalize(INFINITE_TF); + mCollector->checkSlotsToFinalize(o2::calibration::INFINITE_TF); // we force finalizing slot zero (unless everything was already finalized), no matter how many entries we had if (mCollector->getNSlots() != 0) { mCollector->finalizeSlot(mCollector->getSlot(0)); @@ -74,6 +83,7 @@ class TOFCalibCollectorDevice : public o2::framework::Task private: std::unique_ptr mCollector; + std::shared_ptr mCCDBRequest; int mMaxNumOfHits = 0; //________________________________________________________________ @@ -109,18 +119,24 @@ DataProcessorSpec getTOFCalibCollectorDeviceSpec() std::vector inputs; inputs.emplace_back("input", "TOF", "CALIBDATA"); - + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputs); return DataProcessorSpec{ "calib-tofcalib-collector", inputs, outputs, - AlgorithmSpec{adaptFromTask()}, + AlgorithmSpec{adaptFromTask(ccdbRequest)}, Options{ {"max-number-hits-to-fill-tree", VariantType::Int, 500, {"maximum number of entries in one channel to trigger teh filling of the tree"}}, {"is-max-number-hits-to-fill-tree-absolute", VariantType::Bool, false, {"to decide if we want to multiply the max-number-hits-to-fill-tree by the number of channels (when set to true), or not (when set to false) for fast checks"}}, {"tf-sending-policy", VariantType::Bool, false, {"if we are sending output at every TF; otherwise, we use the max-number-hits-to-fill-tree"}}, {"running-in-test-mode", VariantType::Bool, false, {"to run in test mode for simplification"}}, - {"update-interval", VariantType::Int64, 10ll, {"number of TF after which to try to finalize calibration"}}}}; + {"update-interval", VariantType::UInt32, 10u, {"number of TF after which to try to finalize calibration"}}}}; } } // namespace framework diff --git a/Detectors/TOF/calibration/testWorkflow/TOFChannelCalibratorSpec.h b/Detectors/TOF/calibration/testWorkflow/TOFChannelCalibratorSpec.h index 1a47c7ec512d1..139fb4467528a 100644 --- a/Detectors/TOF/calibration/testWorkflow/TOFChannelCalibratorSpec.h +++ b/Detectors/TOF/calibration/testWorkflow/TOFChannelCalibratorSpec.h @@ -29,6 +29,7 @@ #include "CCDB/CcdbObjectInfo.h" #include #include "TFile.h" +#include "DetectorsBase/GRPGeomHelper.h" using namespace o2::framework; @@ -45,19 +46,19 @@ class TOFChannelCalibDevice : public o2::framework::Task using LHCphase = o2::dataformats::CalibLHCphaseTOF; public: - explicit TOFChannelCalibDevice(bool useCCDB, bool attachChannelOffsetToLHCphase, bool isCosmics, bool perstrip = false, bool safe = false) : mUseCCDB(useCCDB), mAttachToLHCphase(attachChannelOffsetToLHCphase), mCosmics(isCosmics), mDoPerStrip(perstrip), mSafeMode(safe) {} + explicit TOFChannelCalibDevice(std::shared_ptr req, bool useCCDB, bool attachChannelOffsetToLHCphase, bool isCosmics, bool perstrip = false, bool safe = false) : mCCDBRequest(req), mUseCCDB(useCCDB), mAttachToLHCphase(attachChannelOffsetToLHCphase), mCosmics(isCosmics), mDoPerStrip(perstrip), mSafeMode(safe) {} void init(o2::framework::InitContext& ic) final { - + o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest); int minEnt = ic.options().get("min-entries"); //std::max(50, ic.options().get("min-entries")); int nb = std::max(500, ic.options().get("nbins")); float range = ic.options().get("range"); int isTest = ic.options().get("do-TOF-channel-calib-in-test-mode"); bool updateAtEORonly = ic.options().get("update-at-end-of-run-only"); - int64_t slotL = ic.options().get("tf-per-slot"); - int64_t delay = ic.options().get("max-delay"); - int updateInterval = ic.options().get("update-interval"); - int deltaUpdateInterval = ic.options().get("delta-update-interval"); + auto slotL = ic.options().get("tf-per-slot"); + auto delay = ic.options().get("max-delay"); + auto updateInterval = ic.options().get("update-interval"); + auto deltaUpdateInterval = ic.options().get("delta-update-interval"); mCalibrator = std::make_unique>(minEnt, nb, range); mCalibrator->doPerStrip(mDoPerStrip); @@ -100,9 +101,15 @@ class TOFChannelCalibDevice : public o2::framework::Task } } - void run(o2::framework::ProcessingContext& pc) final + //_________________________________________________________________ + void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final { + o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj); + } + void run(o2::framework::ProcessingContext& pc) final + { + o2::base::GRPGeomHelper::instance().checkUpdates(pc); long startTimeLHCphase; long startTimeChCalib; o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mCalibrator->getCurrentTFInfo()); @@ -179,13 +186,13 @@ class TOFChannelCalibDevice : public o2::framework::Task void endOfStream(o2::framework::EndOfStreamContext& ec) final { - constexpr uint64_t INFINITE_TF = 0xffffffffffffffff; - mCalibrator->checkSlotsToFinalize(INFINITE_TF); + mCalibrator->checkSlotsToFinalize(o2::calibration::INFINITE_TF); sendOutput(ec.outputs()); } private: std::unique_ptr> mCalibrator; + std::shared_ptr mCCDBRequest; o2::tof::CalibTOFapi* mcalibTOFapi = nullptr; LHCphase mPhase; TimeSlewing mTimeSlewing; @@ -228,7 +235,6 @@ namespace framework template DataProcessorSpec getTOFChannelCalibDeviceSpec(bool useCCDB, bool attachChannelOffsetToLHCphase = false, bool isCosmics = false, bool perstrip = false, bool safe = false) { - constexpr int64_t INFINITE_TF_int64 = std::numeric_limits::max(); using device = o2::calibration::TOFChannelCalibDevice; using clbUtils = o2::calibration::Utils; @@ -242,7 +248,13 @@ DataProcessorSpec getTOFChannelCalibDeviceSpec(bool useCCDB, bool attachChannelO } else { inputs.emplace_back("input", "TOF", "INFOCALCLUS"); } - + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputs); if (useCCDB) { inputs.emplace_back("tofccdbLHCphase", o2::header::gDataOriginTOF, "LHCphase"); inputs.emplace_back("tofccdbChannelCalib", o2::header::gDataOriginTOF, "ChannelCalib"); @@ -254,7 +266,7 @@ DataProcessorSpec getTOFChannelCalibDeviceSpec(bool useCCDB, bool attachChannelO "calib-tofchannel-calibration", inputs, outputs, - AlgorithmSpec{adaptFromTask(useCCDB, attachChannelOffsetToLHCphase, isCosmics, perstrip, safe)}, + AlgorithmSpec{adaptFromTask(ccdbRequest, useCCDB, attachChannelOffsetToLHCphase, isCosmics, perstrip, safe)}, Options{ {"min-entries", VariantType::Int, 500, {"minimum number of entries to fit channel histos"}}, {"nbins", VariantType::Int, 1000, {"number of bins for t-texp"}}, @@ -262,10 +274,10 @@ DataProcessorSpec getTOFChannelCalibDeviceSpec(bool useCCDB, bool attachChannelO {"do-TOF-channel-calib-in-test-mode", VariantType::Bool, false, {"to run in test mode for simplification"}}, {"ccdb-path", VariantType::String, o2::base::NameConf::getCCDBServer(), {"Path to CCDB"}}, {"update-at-end-of-run-only", VariantType::Bool, false, {"to update the CCDB only at the end of the run; has priority over calibrating in time slots"}}, - {"tf-per-slot", VariantType::Int64, INFINITE_TF_int64, {"number of TFs per calibration time slot"}}, - {"max-delay", VariantType::Int64, 0ll, {"number of slots in past to consider"}}, - {"update-interval", VariantType::Int64, 10ll, {"number of TF after which to try to finalize calibration"}}, - {"delta-update-interval", VariantType::Int64, 10ll, {"number of TF after which to try to finalize calibration, if previous attempt failed"}}}}; + {"tf-per-slot", VariantType::UInt32, 0u, {"number of TFs per calibration time slot, if 0: close once statistics reached"}}, + {"max-delay", VariantType::UInt32, 0u, {"number of slots in past to consider"}}, + {"update-interval", VariantType::UInt32, 10u, {"number of TF after which to try to finalize calibration"}}, + {"delta-update-interval", VariantType::UInt32, 10u, {"number of TF after which to try to finalize calibration, if previous attempt failed"}}}}; } } // namespace framework diff --git a/Detectors/TOF/calibration/testWorkflow/TOFDCSConfigProcessorSpec.h b/Detectors/TOF/calibration/testWorkflow/TOFDCSConfigProcessorSpec.h index 7109758746e3e..460b23f74dc56 100644 --- a/Detectors/TOF/calibration/testWorkflow/TOFDCSConfigProcessorSpec.h +++ b/Detectors/TOF/calibration/testWorkflow/TOFDCSConfigProcessorSpec.h @@ -74,15 +74,13 @@ class TOFDCSConfigProcessor : public o2::framework::Task { // sending output to CCDB - constexpr uint64_t INFINITE_TF = 0xffffffffffffffff; - using clbUtils = o2::calibration::Utils; const auto& payload = mTOFFEElightReader.getTOFFEElightInfo(); auto clName = o2::utils::MemFileHelper::getClassName(payload); auto flName = o2::ccdb::CcdbApi::generateFileName(clName); std::map md; md.emplace("created_by", "dpl"); - o2::ccdb::CcdbObjectInfo info("TOF/Calib/FEELIGHT", clName, flName, md, tf, INFINITE_TF); + o2::ccdb::CcdbObjectInfo info("TOF/Calib/FEELIGHT", clName, flName, md, tf, o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); 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(); diff --git a/Detectors/TOF/calibration/testWorkflow/TOFDiagnosticCalibratorSpec.h b/Detectors/TOF/calibration/testWorkflow/TOFDiagnosticCalibratorSpec.h index edd4dfdfbab19..64a6184be9a37 100644 --- a/Detectors/TOF/calibration/testWorkflow/TOFDiagnosticCalibratorSpec.h +++ b/Detectors/TOF/calibration/testWorkflow/TOFDiagnosticCalibratorSpec.h @@ -25,6 +25,7 @@ #include "CCDB/CcdbApi.h" #include "CCDB/CcdbObjectInfo.h" #include "DetectorsRaw/HBFUtils.h" +#include "DetectorsBase/GRPGeomHelper.h" using namespace o2::framework; @@ -36,19 +37,26 @@ namespace calibration class TOFDiagnosticCalibDevice : public o2::framework::Task { public: - TOFDiagnosticCalibDevice(int runnumber = -1) : mRunNumber(runnumber) {} + TOFDiagnosticCalibDevice(std::shared_ptr req, int runnumber = -1) : mCCDBRequest(req), mRunNumber(runnumber) {} void init(o2::framework::InitContext& ic) final { - int slotL = ic.options().get("tf-per-slot"); - int delay = ic.options().get("max-delay"); + o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest); + auto slotL = ic.options().get("tf-per-slot"); + auto delay = ic.options().get("max-delay"); mCalibrator = std::make_unique(); mCalibrator->setSlotLength(slotL); mCalibrator->setMaxSlotsDelay(delay); mCalibrator->setRunNumber(mRunNumber); } + void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final + { + o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj); + } + void run(o2::framework::ProcessingContext& pc) final { + o2::base::GRPGeomHelper::instance().checkUpdates(pc); o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mCalibrator->getCurrentTFInfo()); auto const data = pc.inputs().get("input"); LOG(info) << "Processing TF " << mCalibrator->getCurrentTFInfo().tfCounter; @@ -59,13 +67,13 @@ class TOFDiagnosticCalibDevice : public o2::framework::Task void endOfStream(o2::framework::EndOfStreamContext& ec) final { LOG(info) << "Finalizing calibration"; - constexpr uint64_t INFINITE_TF = 0xffffffffffffffff; - mCalibrator->checkSlotsToFinalize(INFINITE_TF); + mCalibrator->checkSlotsToFinalize(o2::calibration::INFINITE_TF); sendOutput(ec.outputs()); } private: std::unique_ptr mCalibrator; + std::shared_ptr mCCDBRequest; int mRunNumber = -1; //________________________________________________________________ @@ -104,14 +112,23 @@ DataProcessorSpec getTOFDiagnosticCalibDeviceSpec(int runnumber) std::vector outputs; outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "TOF_Diagnostic"}, Lifetime::Sporadic); outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "TOF_Diagnostic"}, Lifetime::Sporadic); + std::vector inputs{{"input", "TOF", "DIAFREQ"}}; + + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputs); return DataProcessorSpec{ "tof-diagnostic-calibration", - Inputs{{"input", "TOF", "DIAFREQ"}}, + inputs, outputs, - AlgorithmSpec{adaptFromTask(runnumber)}, + AlgorithmSpec{adaptFromTask(ccdbRequest, runnumber)}, Options{ - {"tf-per-slot", VariantType::Int, 5, {"number of TFs per calibration time slot"}}, - {"max-delay", VariantType::Int, 3, {"number of slots in past to consider"}}}}; + {"tf-per-slot", VariantType::UInt32, 5u, {"number of TFs per calibration time slot"}}, + {"max-delay", VariantType::UInt32, 3u, {"number of slots in past to consider"}}}}; } } // namespace framework diff --git a/Detectors/TOF/calibration/testWorkflow/data-generator-diagnostic-workflow.cxx b/Detectors/TOF/calibration/testWorkflow/data-generator-diagnostic-workflow.cxx index b4fd0c6f0bfb3..3d4018bbafa26 100644 --- a/Detectors/TOF/calibration/testWorkflow/data-generator-diagnostic-workflow.cxx +++ b/Detectors/TOF/calibration/testWorkflow/data-generator-diagnostic-workflow.cxx @@ -10,10 +10,30 @@ // or submit itself to any jurisdiction. #include "Framework/DataProcessorSpec.h" +#include "Framework/CallbacksPolicy.h" #include "DataGeneratorSpec.h" using namespace o2::framework; +void customize(std::vector& policies) +{ + policies.push_back(o2::framework::CallbacksPolicy{ + [](o2::framework::DeviceSpec const& spec, o2::framework::ConfigContext const& context) -> bool { + return spec.name == "calib-tf-dispatcher"; // apply policy only to the upstream device + }, + [](o2::framework::CallbackService& service, o2::framework::InitContext& context) { + const auto& hbfu = o2::raw::HBFUtils::Instance(); + long startTime = hbfu.startTime > 0 ? hbfu.startTime : std::chrono::time_point_cast(std::chrono::system_clock::now()).time_since_epoch().count(); + service.set(o2::framework::CallbackService::Id::NewTimeslice, + [startTime](o2::header::DataHeader& dh, o2::framework::DataProcessingHeader& dph) { + const auto& hbfu = o2::raw::HBFUtils::Instance(); + dh.firstTForbit = hbfu.getFirstIRofTF({0, hbfu.orbitFirstSampled}).orbit + int64_t(hbfu.nHBFPerTF) * dh.tfCounter; + dh.runNumber = hbfu.runNumber; + dph.creation = startTime + (dh.firstTForbit - hbfu.orbitFirst) * o2::constants::lhc::LHCOrbitMUS * 1.e-3; + }); + }}); +} + // we need to add workflow options before including Framework/runDataProcessing void customize(std::vector& workflowOptions) { @@ -24,6 +44,7 @@ void customize(std::vector& workflowOptions) workflowOptions.push_back(ConfigParamSpec{"pressure", o2::framework::VariantType::Float, 1.f, {"generation / processing rate factor"}}); workflowOptions.push_back(ConfigParamSpec{"mean-latency", o2::framework::VariantType::Int, 1000, {"mean latency of the processor in microseconds"}}); workflowOptions.push_back(ConfigParamSpec{"latency-spread", o2::framework::VariantType::Int, 100, {"latency gaussian RMS of the processor in microseconds"}}); + workflowOptions.push_back(ConfigParamSpec{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings ..."}}); } // ------------------------------------------------------------------ @@ -33,6 +54,7 @@ void customize(std::vector& workflowOptions) WorkflowSpec defineDataProcessing(ConfigContext const& configcontext) { WorkflowSpec specs; + o2::conf::ConfigurableParam::updateFromString(configcontext.options().get("configKeyValues")); auto nlanes = std::max(1, configcontext.options().get("lanes")); auto ngen = std::max(1, configcontext.options().get("gen-norm")); auto slot = std::max(0, configcontext.options().get("gen-slot")); diff --git a/Detectors/TOF/calibration/testWorkflow/data-generator-workflow.cxx b/Detectors/TOF/calibration/testWorkflow/data-generator-workflow.cxx index f8fa38432cbd7..1b5283423c964 100644 --- a/Detectors/TOF/calibration/testWorkflow/data-generator-workflow.cxx +++ b/Detectors/TOF/calibration/testWorkflow/data-generator-workflow.cxx @@ -10,10 +10,30 @@ // or submit itself to any jurisdiction. #include "Framework/DataProcessorSpec.h" +#include "Framework/CallbacksPolicy.h" #include "DataGeneratorSpec.h" using namespace o2::framework; +void customize(std::vector& policies) +{ + policies.push_back(o2::framework::CallbacksPolicy{ + [](o2::framework::DeviceSpec const& spec, o2::framework::ConfigContext const& context) -> bool { + return spec.name == "calib-tf-dispatcher"; // apply policy only to the upstream device + }, + [](o2::framework::CallbackService& service, o2::framework::InitContext& context) { + const auto& hbfu = o2::raw::HBFUtils::Instance(); + long startTime = hbfu.startTime > 0 ? hbfu.startTime : std::chrono::time_point_cast(std::chrono::system_clock::now()).time_since_epoch().count(); + service.set(o2::framework::CallbackService::Id::NewTimeslice, + [startTime](o2::header::DataHeader& dh, o2::framework::DataProcessingHeader& dph) { + const auto& hbfu = o2::raw::HBFUtils::Instance(); + dh.firstTForbit = hbfu.getFirstIRofTF({0, hbfu.orbitFirstSampled}).orbit + int64_t(hbfu.nHBFPerTF) * dh.tfCounter; + dh.runNumber = hbfu.runNumber; + dph.creation = startTime + (dh.firstTForbit - hbfu.orbitFirst) * o2::constants::lhc::LHCOrbitMUS * 1.e-3; + }); + }}); +} + // we need to add workflow options before including Framework/runDataProcessing void customize(std::vector& workflowOptions) { @@ -24,6 +44,7 @@ void customize(std::vector& workflowOptions) workflowOptions.push_back(ConfigParamSpec{"pressure", o2::framework::VariantType::Float, 1.f, {"generation / processing rate factor"}}); workflowOptions.push_back(ConfigParamSpec{"mean-latency", o2::framework::VariantType::Int, 1000, {"mean latency of the processor in microseconds"}}); workflowOptions.push_back(ConfigParamSpec{"latency-spread", o2::framework::VariantType::Int, 100, {"latency gaussian RMS of the processor in microseconds"}}); + workflowOptions.push_back(ConfigParamSpec{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings ..."}}); } // ------------------------------------------------------------------ @@ -33,6 +54,7 @@ void customize(std::vector& workflowOptions) WorkflowSpec defineDataProcessing(ConfigContext const& configcontext) { WorkflowSpec specs; + o2::conf::ConfigurableParam::updateFromString(configcontext.options().get("configKeyValues")); auto nlanes = std::max(1, configcontext.options().get("lanes")); auto ngen = std::max(1, configcontext.options().get("gen-norm")); auto slot = std::max(0, configcontext.options().get("gen-slot")); diff --git a/Detectors/TPC/base/include/TPCBase/CDBInterface.h b/Detectors/TPC/base/include/TPCBase/CDBInterface.h index c2adf246c50f9..51b889a64f724 100644 --- a/Detectors/TPC/base/include/TPCBase/CDBInterface.h +++ b/Detectors/TPC/base/include/TPCBase/CDBInterface.h @@ -369,11 +369,11 @@ class CDBStorage storeObject(obj, type, mMetaData, start, end); } - void uploadNoiseAndPedestal(std::string_view fileName, long first = -1, long last = 99999999999999); - void uploadGainMap(std::string_view fileName, bool isFull = true, long first = -1, long last = 99999999999999); - void uploadPulserOrCEData(CDBType type, std::string_view fileName, long first = -1, long last = 99999999999999); - void uploadFEEConfigPad(std::string_view fileName, long first = -1, long last = 99999999999999); - void uploadTimeGain(std::string_view fileName, long first = -1, long last = 99999999999999); + void uploadNoiseAndPedestal(std::string_view fileName, long first = -1, long last = o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); + void uploadGainMap(std::string_view fileName, bool isFull = true, long first = -1, long last = o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); + void uploadPulserOrCEData(CDBType type, std::string_view fileName, long first = -1, long last = o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); + void uploadFEEConfigPad(std::string_view fileName, long first = -1, long last = o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); + void uploadTimeGain(std::string_view fileName, long first = -1, long last = o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); private: bool checkMetaData(MetaData_t metaData) const; diff --git a/Detectors/TPC/calibration/SpacePoints/include/SpacePoints/ResidualAggregator.h b/Detectors/TPC/calibration/SpacePoints/include/SpacePoints/ResidualAggregator.h index 404f75bdc4fad..1ac3008ea4b18 100644 --- a/Detectors/TPC/calibration/SpacePoints/include/SpacePoints/ResidualAggregator.h +++ b/Detectors/TPC/calibration/SpacePoints/include/SpacePoints/ResidualAggregator.h @@ -78,7 +78,7 @@ class ResidualAggregator final : public o2::calibration::TimeSlotCalibrationfileOut.reset(); } -Slot& ResidualAggregator::emplaceNewSlot(bool front, uint64_t tStart, uint64_t tEnd) +Slot& ResidualAggregator::emplaceNewSlot(bool front, TFType tStart, TFType tEnd) { auto& cont = getSlots(); auto& slot = front ? cont.emplace_front(tStart, tEnd) : cont.emplace_back(tStart, tEnd); diff --git a/Detectors/TPC/calibration/include/TPCCalibration/LaserTracksCalibrator.h b/Detectors/TPC/calibration/include/TPCCalibration/LaserTracksCalibrator.h index 8ada7e0027bb9..9db1a4a78e3fd 100644 --- a/Detectors/TPC/calibration/include/TPCCalibration/LaserTracksCalibrator.h +++ b/Detectors/TPC/calibration/include/TPCCalibration/LaserTracksCalibrator.h @@ -26,7 +26,7 @@ namespace o2::tpc class LaserTracksCalibrator : public o2::calibration::TimeSlotCalibration { - using TFType = uint64_t; + using TFType = o2::calibration::TFType; using Slot = o2::calibration::TimeSlot; public: diff --git a/Detectors/TPC/workflow/include/TPCWorkflow/CalibLaserTracksSpec.h b/Detectors/TPC/workflow/include/TPCWorkflow/CalibLaserTracksSpec.h index 71a33c7d5e1f2..a0d326fb3f3c4 100644 --- a/Detectors/TPC/workflow/include/TPCWorkflow/CalibLaserTracksSpec.h +++ b/Detectors/TPC/workflow/include/TPCWorkflow/CalibLaserTracksSpec.h @@ -109,7 +109,7 @@ class CalibLaserTracksDevice : public o2::framework::Task const auto now = std::chrono::system_clock::now(); const long timeStart = std::chrono::duration_cast(now.time_since_epoch()).count(); //const auto timeStart = ltrCalib.firstTime; //TODO: use once it is a correct time not TFid - const long timeEnd = 99999999999999; + const long timeEnd = o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP; w.setPath("TPC/Calib/LaserTracks"); w.setStartValidityTimestamp(timeStart); diff --git a/Detectors/TPC/workflow/include/TPCWorkflow/CalibratorPadGainTracksSpec.h b/Detectors/TPC/workflow/include/TPCWorkflow/CalibratorPadGainTracksSpec.h index 5f44671a536b6..6a96e083bddba 100644 --- a/Detectors/TPC/workflow/include/TPCWorkflow/CalibratorPadGainTracksSpec.h +++ b/Detectors/TPC/workflow/include/TPCWorkflow/CalibratorPadGainTracksSpec.h @@ -26,6 +26,7 @@ #include "Framework/ConfigParamRegistry.h" #include "TPCBase/CDBInterface.h" #include "TPCWorkflow/ProcessingHelpers.h" +#include "DetectorsBase/GRPGeomHelper.h" using namespace o2::framework; @@ -35,10 +36,12 @@ namespace o2::tpc class CalibratorPadGainTracksDevice : public Task { public: + CalibratorPadGainTracksDevice(std::shared_ptr req) : mCCDBRequest(req) {} void init(framework::InitContext& ic) final { - const int slotLength = ic.options().get("tf-per-slot"); - const int maxDelay = ic.options().get("max-delay"); + o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest); + const auto slotLength = ic.options().get("tf-per-slot"); + const auto maxDelay = ic.options().get("max-delay"); const int minEntries = ic.options().get("min-entries"); const bool debug = ic.options().get("file-dump"); const auto lowTrunc = ic.options().get("lowTrunc"); @@ -56,8 +59,14 @@ class CalibratorPadGainTracksDevice : public Task mWriteToDB = mDBapi.isHostReachable() ? true : false; } + void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final + { + o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj); + } + void run(ProcessingContext& pc) final { + o2::base::GRPGeomHelper::instance().checkUpdates(pc); const auto histomaps = pc.inputs().get("gainhistos"); o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mCalibrator->getCurrentTFInfo()); mCalibrator->process(*histomaps.get()); @@ -73,8 +82,7 @@ class CalibratorPadGainTracksDevice : public Task void endOfStream(EndOfStreamContext& eos) final { LOGP(info, "Finalizing calibration"); - constexpr calibration::TFType INFINITE_TF = 0xffffffffffffffff; - mCalibrator->checkSlotsToFinalize(INFINITE_TF); + mCalibrator->checkSlotsToFinalize(o2::calibration::INFINITE_TF); sendOutput(eos.outputs()); } @@ -98,6 +106,7 @@ class CalibratorPadGainTracksDevice : public Task } std::unique_ptr mCalibrator; ///< calibrator object for creating the pad-by-pad gain map + std::shared_ptr mCCDBRequest; bool mWriteToDB{}; ///< flag if writing to CCDB will be done o2::ccdb::CcdbApi mDBapi; ///< API for storing the gain map in the CCDB std::map mMetadata; ///< meta data of the stored object in CCDB @@ -108,17 +117,23 @@ class CalibratorPadGainTracksDevice : public Task o2::framework::DataProcessorSpec getTPCCalibPadGainTracksSpec() { std::vector outputs; + std::vector inputs{{"gainhistos", "TPC", "TRACKGAINHISTOS"}}; + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputs); return DataProcessorSpec{ "tpc-calibrator-gainmap-tracks", - Inputs{ - InputSpec{"gainhistos", "TPC", "TRACKGAINHISTOS"}, - }, + inputs, outputs, - adaptFromTask(), + adaptFromTask(ccdbRequest), Options{ {"ccdb-uri", VariantType::String, o2::base::NameConf::getCCDBServer(), {"URI for the CCDB access."}}, - {"tf-per-slot", VariantType::Int, 100, {"number of TFs per calibration time slot"}}, - {"max-delay", VariantType::Int, 3, {"number of slots in past to consider"}}, + {"tf-per-slot", VariantType::UInt32, 100u, {"number of TFs per calibration time slot"}}, + {"max-delay", VariantType::UInt32, 3u, {"number of slots in past to consider"}}, {"min-entries", VariantType::Int, 50, {"minimum entries per pad-by-pad histogram which are required"}}, {"lowTrunc", VariantType::Float, 0.05f, {"lower truncation range for calculating the rel gain"}}, {"upTrunc", VariantType::Float, 0.6f, {"upper truncation range for calculating the rel gain"}}, diff --git a/Detectors/TPC/workflow/include/TPCWorkflow/LaserTracksCalibratorSpec.h b/Detectors/TPC/workflow/include/TPCWorkflow/LaserTracksCalibratorSpec.h index 56c428c08dd34..ed61d5e63b8e8 100644 --- a/Detectors/TPC/workflow/include/TPCWorkflow/LaserTracksCalibratorSpec.h +++ b/Detectors/TPC/workflow/include/TPCWorkflow/LaserTracksCalibratorSpec.h @@ -24,6 +24,7 @@ #include "Framework/WorkflowSpec.h" #include "CCDB/CcdbApi.h" #include "CCDB/CcdbObjectInfo.h" +#include "DetectorsBase/GRPGeomHelper.h" using namespace o2::framework; @@ -33,11 +34,13 @@ namespace o2::tpc class LaserTracksCalibratorDevice : public o2::framework::Task { public: + LaserTracksCalibratorDevice(std::shared_ptr req) : mCCDBRequest(req) {} void init(o2::framework::InitContext& ic) final { + o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest); const int minTFs = ic.options().get("min-tfs"); - const int slotL = ic.options().get("tf-per-slot"); - const int delay = ic.options().get("max-delay"); + const auto slotL = ic.options().get("tf-per-slot"); + const auto delay = ic.options().get("max-delay"); const bool debug = ic.options().get("write-debug"); mCalibrator = std::make_unique(minTFs); @@ -48,8 +51,8 @@ class LaserTracksCalibratorDevice : public o2::framework::Task void run(o2::framework::ProcessingContext& pc) final { + o2::base::GRPGeomHelper::instance().checkUpdates(pc); const auto dph = o2::header::get(pc.inputs().get("laserTracks").header); - o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mCalibrator->getCurrentTFInfo()); auto data = pc.inputs().get>("laserTracks"); LOGP(info, "Processing TF {} and {} tracks", mCalibrator->getCurrentTFInfo().tfCounter, data.size()); @@ -61,23 +64,28 @@ class LaserTracksCalibratorDevice : public o2::framework::Task } } + void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final + { + o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj); + } + void endOfStream(o2::framework::EndOfStreamContext& ec) final { LOGP(info, "LaserTracksCalibratorDevice::endOfStream: Finalizing calibration"); - constexpr uint64_t INFINITE_TF = 0xffffffffffffffff; - mCalibrator->checkSlotsToFinalize(INFINITE_TF); + mCalibrator->checkSlotsToFinalize(o2::calibration::INFINITE_TF); sendOutput(ec.outputs()); } private: std::unique_ptr mCalibrator; + std::shared_ptr mCCDBRequest; //________________________________________________________________ void sendOutput(DataAllocator& output) { using clbUtils = o2::calibration::Utils; const auto& calibrations = mCalibrator->getCalibPerSlot(); - const long timeEnd = 99999999999999; + const long timeEnd = o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP; for (uint32_t iCalib = 0; iCalib < calibrations.size(); ++iCalib) { const auto& object = calibrations[iCalib]; o2::ccdb::CcdbObjectInfo w; @@ -104,14 +112,22 @@ DataProcessorSpec getLaserTracksCalibrator() std::vector outputs; outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "TPC_CalibLtr"}, Lifetime::Sporadic); outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "TPC_CalibLtr"}, Lifetime::Sporadic); + std::vector inputs{{"laserTracks", "TPC", "LASERTRACKS"}}; + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputs); return DataProcessorSpec{ "tpc-laser-tracks-calibrator", - Inputs{{"laserTracks", "TPC", "LASERTRACKS"}}, + inputs, outputs, - AlgorithmSpec{adaptFromTask()}, + AlgorithmSpec{adaptFromTask(ccdbRequest)}, Options{ - {"tf-per-slot", VariantType::Int, 5000, {"number of TFs per calibration time slot"}}, - {"max-delay", VariantType::Int, 3, {"number of slots in past to consider"}}, + {"tf-per-slot", VariantType::UInt32, 5000u, {"number of TFs per calibration time slot"}}, + {"max-delay", VariantType::UInt32, 3u, {"number of slots in past to consider"}}, {"min-tfs", VariantType::Int, 100, {"minimum number of TFs with enough laser tracks to finalize a slot"}}, {"write-debug", VariantType::Bool, false, {"write a debug output tree."}}, }}; diff --git a/Detectors/TPC/workflow/include/TPCWorkflow/TPCFactorizeIDCSpec.h b/Detectors/TPC/workflow/include/TPCWorkflow/TPCFactorizeIDCSpec.h index fffc010018be7..b46b21f9ac5a2 100644 --- a/Detectors/TPC/workflow/include/TPCWorkflow/TPCFactorizeIDCSpec.h +++ b/Detectors/TPC/workflow/include/TPCWorkflow/TPCFactorizeIDCSpec.h @@ -108,9 +108,9 @@ class TPCFactorizeIDCSpec : public o2::framework::Task if (mWriteToDB && mUpdateGroupingPar) { // validity for grouping parameters is from first TF to some really large TF (until it is updated) TODO do somewhere else?! if constexpr (std::is_same_v) { - mDBapi.storeAsTFileAny(&mIDCStruct.mIDCs.getIDCGroupHelperSector().getGroupingParameter(), "TPC/Calib/IDC/GROUPINGPAR", mMetadata, mTimeStampFirst, 99999999999999); + mDBapi.storeAsTFileAny(&mIDCStruct.mIDCs.getIDCGroupHelperSector().getGroupingParameter(), "TPC/Calib/IDC/GROUPINGPAR", mMetadata, mTimeStampFirst, o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); } else { - mDBapi.storeAsTFileAny(&mIDCFactorization.getGroupingParameter(), "TPC/Calib/IDC/GROUPINGPAR", mMetadata, mTimeStampFirst, 99999999999999); + mDBapi.storeAsTFileAny(&mIDCFactorization.getGroupingParameter(), "TPC/Calib/IDC/GROUPINGPAR", mMetadata, mTimeStampFirst, o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); } mUpdateGroupingPar = false; // write grouping parameters only once } @@ -232,7 +232,7 @@ class TPCFactorizeIDCSpec : public o2::framework::Task if (mWriteToDB) { const auto timeStampStart = mTimeStampFirst; - const auto timeStampEnd = 99999999999999; + const auto timeStampEnd = o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP; LOGP(info, "Writing IDCs to CCDB"); mDBapi.storeAsTFileAny(&mIDCFactorization.getIDCZero(), "TPC/Calib/IDC/IDC0", mMetadata, timeStampStart, timeStampEnd); diff --git a/Detectors/TPC/workflow/src/CalDetMergerPublisherSpec.cxx b/Detectors/TPC/workflow/src/CalDetMergerPublisherSpec.cxx index 70ed5cd7f3325..7a25afe351836 100644 --- a/Detectors/TPC/workflow/src/CalDetMergerPublisherSpec.cxx +++ b/Detectors/TPC/workflow/src/CalDetMergerPublisherSpec.cxx @@ -166,7 +166,7 @@ class CalDetMergerPublisherSpec : public o2::framework::Task // perhaps should be changed to time of the run const auto now = std::chrono::system_clock::now(); const long timeStart = std::chrono::duration_cast(now.time_since_epoch()).count(); - const long timeEnd = 99999999999999; + const long timeEnd = o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP; std::map md; diff --git a/Detectors/TPC/workflow/src/CalibdEdxSpec.cxx b/Detectors/TPC/workflow/src/CalibdEdxSpec.cxx index 592e27853f702..06d1c5beb0326 100644 --- a/Detectors/TPC/workflow/src/CalibdEdxSpec.cxx +++ b/Detectors/TPC/workflow/src/CalibdEdxSpec.cxx @@ -103,7 +103,7 @@ class CalibdEdxDevice : public Task const auto now = std::chrono::system_clock::now(); const long timeStart = std::chrono::duration_cast(now.time_since_epoch()).count(); - const long timeEnd = 99999999999999; + const long timeEnd = o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP; info.setPath("TPC/Calib/dEdx"); info.setStartValidityTimestamp(timeStart); diff --git a/Detectors/TPC/workflow/src/CalibratordEdxSpec.cxx b/Detectors/TPC/workflow/src/CalibratordEdxSpec.cxx index 4a8db88a05647..92c349665e1c5 100644 --- a/Detectors/TPC/workflow/src/CalibratordEdxSpec.cxx +++ b/Detectors/TPC/workflow/src/CalibratordEdxSpec.cxx @@ -30,6 +30,7 @@ #include "Framework/ConfigParamRegistry.h" #include "TPCCalibration/CalibratordEdx.h" #include "TPCWorkflow/ProcessingHelpers.h" +#include "DetectorsBase/GRPGeomHelper.h" using namespace o2::framework; @@ -39,10 +40,12 @@ namespace o2::tpc class CalibratordEdxDevice : public Task { public: + CalibratordEdxDevice(std::shared_ptr req) : mCCDBRequest(req) {} void init(framework::InitContext& ic) final { - const auto slotLength = ic.options().get("tf-per-slot"); - const auto maxDelay = ic.options().get("max-delay"); + o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest); + const auto slotLength = ic.options().get("tf-per-slot"); + const auto maxDelay = ic.options().get("max-delay"); const auto minEntries = ic.options().get("min-entries"); const auto minEntriesSector = ic.options().get("min-entries-sector"); @@ -83,9 +86,14 @@ class CalibratordEdxDevice : public Task mCalibrator->enableDebugOutput("calibratordEdx.root"); } } + void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final + { + o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj); + } void run(ProcessingContext& pc) final { + o2::base::GRPGeomHelper::instance().checkUpdates(pc); const auto tracks = pc.inputs().get>("tracks"); o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mCalibrator->getCurrentTFInfo()); LOGP(info, "Processing TF {} with {} tracks", mCalibrator->getCurrentTFInfo().tfCounter, tracks.size()); @@ -100,8 +108,7 @@ class CalibratordEdxDevice : public Task void endOfStream(EndOfStreamContext& eos) final { LOGP(info, "Finalizing calibration"); - static constexpr calibration::TFType INFINITE_TF = 0xffffffffffffffff; - mCalibrator->checkSlotsToFinalize(INFINITE_TF); + mCalibrator->checkSlotsToFinalize(o2::calibration::INFINITE_TF); sendOutput(eos.outputs()); if (mCalibrator->hasDebugOutput()) { @@ -114,7 +121,7 @@ class CalibratordEdxDevice : public Task { const auto& calibrations = mCalibrator->getCalibs(); auto& intervals = mCalibrator->getTFinterval(); - const long timeEnd = o2::calibration::Utils::INFINITE_TIME; + const long timeEnd = o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP; for (unsigned int i = 0; i < calibrations.size(); i++) { const auto& object = calibrations[i]; @@ -139,6 +146,7 @@ class CalibratordEdxDevice : public Task } std::unique_ptr mCalibrator; + std::shared_ptr mCCDBRequest; uint64_t mRunNumber{0}; ///< processed run number }; @@ -147,17 +155,22 @@ DataProcessorSpec getCalibratordEdxSpec() std::vector outputs; outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "TPC_CalibdEdx"}, Lifetime::Sporadic); outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "TPC_CalibdEdx"}, Lifetime::Sporadic); - + std::vector inputs{{"tracks", "TPC", "MIPS"}}; + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputs); return DataProcessorSpec{ "tpc-calibrator-dEdx", - Inputs{ - InputSpec{"tracks", "TPC", "MIPS"}, - }, + inputs, outputs, - adaptFromTask(), + adaptFromTask(ccdbRequest), Options{ - {"tf-per-slot", VariantType::Int, 6000, {"number of TFs per calibration time slot"}}, - {"max-delay", VariantType::Int, 10, {"number of slots in past to consider"}}, + {"tf-per-slot", VariantType::UInt32, 6000u, {"number of TFs per calibration time slot"}}, + {"max-delay", VariantType::UInt32, 10u, {"number of slots in past to consider"}}, {"min-entries", VariantType::Int, 10000, {"minimum entries per stack to fit a single time slot"}}, {"min-entries-sector", VariantType::Int, 1000, {"min entries per GEM stack to enable sector by sector correction. Below this value we only perform one fit per ROC type (IROC, OROC1, ...; no side nor sector information)."}}, diff --git a/Detectors/TRD/calibration/include/TRDCalibration/CalibratorVdExB.h b/Detectors/TRD/calibration/include/TRDCalibration/CalibratorVdExB.h index 8e01fa6bb5d7c..66cc75276ab4c 100644 --- a/Detectors/TRD/calibration/include/TRDCalibration/CalibratorVdExB.h +++ b/Detectors/TRD/calibration/include/TRDCalibration/CalibratorVdExB.h @@ -58,7 +58,7 @@ class CalibratorVdExB final : public o2::calibration::TimeSlotCalibrationgetNEntries() >= mMinEntries; } void initOutput() final; void finalizeSlot(Slot& slot) final; - Slot& emplaceNewSlot(bool front, uint64_t tStart, uint64_t tEnd) final; + Slot& emplaceNewSlot(bool front, TFType tStart, TFType tEnd) final; void initProcessing(); diff --git a/Detectors/TRD/calibration/src/CalibratorVdExB.cxx b/Detectors/TRD/calibration/src/CalibratorVdExB.cxx index 68b469125132e..643bcd0acae20 100644 --- a/Detectors/TRD/calibration/src/CalibratorVdExB.cxx +++ b/Detectors/TRD/calibration/src/CalibratorVdExB.cxx @@ -171,7 +171,7 @@ void CalibratorVdExB::finalizeSlot(Slot& slot) ccdb.storeAsTFileAny(&calObject, "TRD/Calib/CalVdriftExB", metadata, timeStamp, timeStampEnd); } -Slot& CalibratorVdExB::emplaceNewSlot(bool front, uint64_t tStart, uint64_t tEnd) +Slot& CalibratorVdExB::emplaceNewSlot(bool front, TFType tStart, TFType tEnd) { auto& container = getSlots(); auto& slot = front ? container.emplace_front(tStart, tEnd) : container.emplace_back(tStart, tEnd); diff --git a/Detectors/TRD/calibration/src/DCSProcessor.cxx b/Detectors/TRD/calibration/src/DCSProcessor.cxx index dc2125c79ccf8..578c80dfed72f 100644 --- a/Detectors/TRD/calibration/src/DCSProcessor.cxx +++ b/Detectors/TRD/calibration/src/DCSProcessor.cxx @@ -243,7 +243,7 @@ void DCSProcessor::updateDPsCCDB() } std::map md; md["responsible"] = "Ole Schmidt"; - o2::calibration::Utils::prepareCCDBobjectInfo(mTRDDCS, mCcdbDPsInfo, "TRD/Calib/DCSDPs", md, mStartValidity, o2::calibration::Utils::INFINITE_TIME); + o2::calibration::Utils::prepareCCDBobjectInfo(mTRDDCS, mCcdbDPsInfo, "TRD/Calib/DCSDPs", md, mStartValidity, o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP); return; } diff --git a/Detectors/TRD/workflow/include/TRDWorkflow/VdAndExBCalibSpec.h b/Detectors/TRD/workflow/include/TRDWorkflow/VdAndExBCalibSpec.h index 578363b7eb5d1..6b39297b04469 100644 --- a/Detectors/TRD/workflow/include/TRDWorkflow/VdAndExBCalibSpec.h +++ b/Detectors/TRD/workflow/include/TRDWorkflow/VdAndExBCalibSpec.h @@ -26,6 +26,7 @@ #include "Framework/WorkflowSpec.h" #include "CCDB/CcdbApi.h" #include "CCDB/CcdbObjectInfo.h" +#include "DetectorsBase/GRPGeomHelper.h" using namespace o2::framework; @@ -37,18 +38,26 @@ namespace calibration class VdAndExBCalibDevice : public o2::framework::Task { public: + VdAndExBCalibDevice(std::shared_ptr req) : mCCDBRequest(req) {} void init(o2::framework::InitContext& ic) final { + o2::base::GRPGeomHelper::instance().setRequest(mCCDBRequest); int minEnt = ic.options().get("min-entries"); - int slotL = ic.options().get("tf-per-slot"); - int delay = ic.options().get("max-delay"); + auto slotL = ic.options().get("tf-per-slot"); + auto delay = ic.options().get("max-delay"); mCalibrator = std::make_unique(minEnt); mCalibrator->setSlotLength(slotL); mCalibrator->setMaxSlotsDelay(delay); } + void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final + { + o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj); + } + void run(o2::framework::ProcessingContext& pc) final { + o2::base::GRPGeomHelper::instance().checkUpdates(pc); auto data = pc.inputs().get("input"); o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mCalibrator->getCurrentTFInfo()); LOG(info) << "Processing TF " << mCalibrator->getCurrentTFInfo().tfCounter << " with " << data.getNEntries() << " AngularResidHistos entries"; @@ -59,14 +68,13 @@ class VdAndExBCalibDevice : public o2::framework::Task void endOfStream(o2::framework::EndOfStreamContext& ec) final { LOG(info) << "Finalizing calibration"; - constexpr uint64_t INFINITE_TF = 0xffffffffffffffff; - mCalibrator->checkSlotsToFinalize(INFINITE_TF); + mCalibrator->checkSlotsToFinalize(o2::calibration::INFINITE_TF); sendOutput(ec.outputs()); } private: std::unique_ptr mCalibrator; - + std::shared_ptr mCCDBRequest; //________________________________________________________________ void sendOutput(DataAllocator& output) { @@ -89,14 +97,22 @@ DataProcessorSpec getTRDVdAndExBCalibSpec() std::vector outputs; //outputs.emplace_back(ConcreteDataTypeMatcher{clbUtils::gDataOriginCLB, clbUtils::gDataDescriptionCLBPayload}); //outputs.emplace_back(ConcreteDataTypeMatcher{clbUtils::gDataOriginCLB, clbUtils::gDataDescriptionCLBInfo}); + std::vector inputs{{"input", "TRD", "ANGRESHISTS"}}; + auto ccdbRequest = std::make_shared(true, // orbitResetTime + true, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry + inputs); return DataProcessorSpec{ "calib-vdexb-calibration", - Inputs{{"input", "TRD", "ANGRESHISTS"}}, + inputs, outputs, - AlgorithmSpec{adaptFromTask()}, + AlgorithmSpec{adaptFromTask(ccdbRequest)}, Options{ - {"tf-per-slot", VariantType::Int, 5, {"number of TFs per calibration time slot"}}, - {"max-delay", VariantType::Int, 90'000, {"number of slots in past to consider"}}, // 15 minutes delay, 10ms TF + {"tf-per-slot", VariantType::UInt32, 5u, {"number of TFs per calibration time slot"}}, + {"max-delay", VariantType::UInt32, 90'000u, {"number of slots in past to consider"}}, // 15 minutes delay, 10ms TF {"min-entries", VariantType::Int, 500, {"minimum number of entries to fit single time slot"}}}}; } diff --git a/macro/UploadDummyAlignment.C b/macro/UploadDummyAlignment.C index a84285b17efe5..b1b2dd6940857 100644 --- a/macro/UploadDummyAlignment.C +++ b/macro/UploadDummyAlignment.C @@ -12,7 +12,7 @@ using DetID = o2::detectors::DetID; // upload dummy alignment objects to CCDB -void UploadDummyAlignment(const std::string& ccdbHost = "http://ccdb-test.cern.ch:8080", long tmin = 1, long tmax = 99999999999999, DetID::mask_t msk = DetID::FullMask) +void UploadDummyAlignment(const std::string& ccdbHost = "http://ccdb-test.cern.ch:8080", long tmin = 1, long tmax = o2::ccdb::CcdbObjectInfo::INFINITE_TIMESTAMP, DetID::mask_t msk = DetID::FullMask) { DetID::mask_t dets = msk & DetID::FullMask & (~DetID::getMask(DetID::CTP)); LOG(info) << "Mask = " << dets;