From e9c1164394fb73ba625adc5d927e6edc5d623f09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thiago=20Badar=C3=B3?= Date: Fri, 8 Apr 2022 00:02:56 +0200 Subject: [PATCH] TPC: validity timestamp for time slot residual gain calibration Also, better default values for fit selection --- .../include/TPCWorkflow/ProcessingHelpers.h | 7 ++++ Detectors/TPC/workflow/src/CalibdEdxSpec.cxx | 37 +++++++++++++------ .../TPC/workflow/src/CalibratordEdxSpec.cxx | 21 +++++------ .../TPC/workflow/src/ProcessingHelpers.cxx | 15 ++++++++ 4 files changed, 57 insertions(+), 23 deletions(-) diff --git a/Detectors/TPC/workflow/include/TPCWorkflow/ProcessingHelpers.h b/Detectors/TPC/workflow/include/TPCWorkflow/ProcessingHelpers.h index 32af19458bd4c..626150c9fc326 100644 --- a/Detectors/TPC/workflow/include/TPCWorkflow/ProcessingHelpers.h +++ b/Detectors/TPC/workflow/include/TPCWorkflow/ProcessingHelpers.h @@ -35,5 +35,12 @@ uint64_t getTimeStamp(o2::framework::ProcessingContext& pc); /// Note that the input spec has to be defined as: inputSpecs.emplace_back("orbitreset", "CTP", "ORBITRESET", 0, Lifetime::Condition, ccdbParamSpec("CTP/Calib/OrbitReset")); Long64_t getOrbitReset(o2::framework::ProcessingContext& pc); +/// \return returns time stamp in time frame units of time +uint64_t getAbsoluteTF(o2::framework::ProcessingContext& pc); + +/// \return returns time stamp in miliseconds-precission +/// \param timeFrame time stamp in time frame units of time, same as returned by \ref getAbsoluteTF +uint64_t toTimeStamp(uint64_t timeFrame); + } // namespace processing_helpers } // namespace o2::tpc diff --git a/Detectors/TPC/workflow/src/CalibdEdxSpec.cxx b/Detectors/TPC/workflow/src/CalibdEdxSpec.cxx index 592e27853f702..65e424f4344ec 100644 --- a/Detectors/TPC/workflow/src/CalibdEdxSpec.cxx +++ b/Detectors/TPC/workflow/src/CalibdEdxSpec.cxx @@ -28,6 +28,9 @@ #include "TPCCalibration/CalibdEdx.h" #include "TPCWorkflow/ProcessingHelpers.h" +#include +#include + using namespace o2::framework; namespace o2::tpc @@ -73,10 +76,11 @@ class CalibdEdxDevice : public Task void run(ProcessingContext& pc) final { - const auto tfcounter = o2::header::get(pc.inputs().get("tracks").header)->startTime; + const auto tfcounter = processing_helpers::getAbsoluteTF(pc); const auto tracks = pc.inputs().get>("tracks"); - LOGP(info, "Processing TF {} with {} tracks", tfcounter, tracks.size()); + registerTF(tfcounter); + LOGP(info, "Processing TF {} with {} tracks", processing_helpers::getCurrentTF(pc), tracks.size()); mRunNumber = processing_helpers::getRunNumber(pc); mCalib->fill(tracks); } @@ -101,13 +105,9 @@ class CalibdEdxDevice : public Task o2::ccdb::CcdbObjectInfo info; - const auto now = std::chrono::system_clock::now(); - const long timeStart = std::chrono::duration_cast(now.time_since_epoch()).count(); - const long timeEnd = 99999999999999; - - info.setPath("TPC/Calib/dEdx"); - info.setStartValidityTimestamp(timeStart); - info.setEndValidityTimestamp(timeEnd); + info.setPath("TPC/Calib/TimeGain"); + info.setStartValidityTimestamp(processing_helpers::toTimeStamp(mTFinterval.first)); + info.setEndValidityTimestamp(processing_helpers::toTimeStamp(mTFinterval.second + 1)); auto md = info.getMetaData(); md["runNumber"] = std::to_string(mRunNumber); @@ -120,9 +120,22 @@ class CalibdEdxDevice : public Task output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "TPC_CalibdEdx", 0}, info); } + void registerTF(uint64_t tf) + { + if (mTFinterval.first == 0) { + mTFinterval.first = tf; + mTFinterval.second = tf; + } else if (tf > mTFinterval.second) { + mTFinterval.second = tf; + } else if (tf < mTFinterval.first) { + mTFinterval.first = tf; + } + } + bool mDumpToFile{}; uint64_t mRunNumber{0}; ///< processed run number std::unique_ptr mCalib; + std::pair mTFinterval{0, 0}; }; DataProcessorSpec getCalibdEdxSpec() @@ -139,9 +152,9 @@ DataProcessorSpec getCalibdEdxSpec() outputs, adaptFromTask(), Options{ - {"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)."}}, - {"min-entries-1d", VariantType::Int, 10000, {"minimum entries per stack to fit 1D correction"}}, - {"min-entries-2d", VariantType::Int, 50000, {"minimum entries per stack to fit 2D correction"}}, + {"min-entries-sector", VariantType::Int, 3000, {"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)."}}, + {"min-entries-1d", VariantType::Int, 200, {"minimum entries per stack to fit 1D correction"}}, + {"min-entries-2d", VariantType::Int, 10000, {"minimum entries per stack to fit 2D correction"}}, {"fit-passes", VariantType::Int, 3, {"number of fit iterations"}}, {"fit-threshold", VariantType::Float, 0.2f, {"dEdx width around the MIP peak used in the fit"}}, diff --git a/Detectors/TPC/workflow/src/CalibratordEdxSpec.cxx b/Detectors/TPC/workflow/src/CalibratordEdxSpec.cxx index fc612769225a1..4d06267190c20 100644 --- a/Detectors/TPC/workflow/src/CalibratordEdxSpec.cxx +++ b/Detectors/TPC/workflow/src/CalibratordEdxSpec.cxx @@ -86,16 +86,16 @@ class CalibratordEdxDevice : public Task void run(ProcessingContext& pc) final { - const auto tfcounter = o2::header::get(pc.inputs().get("tracks").header)->startTime; + const auto tfcounter = processing_helpers::getAbsoluteTF(pc); const auto tracks = pc.inputs().get>("tracks"); - LOGP(info, "Processing TF {} with {} tracks", tfcounter, tracks.size()); + LOGP(info, "Processing TF {} with {} tracks", processing_helpers::getCurrentTF(pc), tracks.size()); mRunNumber = processing_helpers::getRunNumber(pc); mCalibrator->process(tfcounter, tracks); sendOutput(pc.outputs()); const auto& infoVec = mCalibrator->getTFinterval(); - LOGP(info, "Created {} objects for TF {}", infoVec.size(), tfcounter); + LOGP(info, "Created {} objects for TF {}", infoVec.size(), processing_helpers::getCurrentTF(pc)); } void endOfStream(EndOfStreamContext& eos) final @@ -114,7 +114,7 @@ class CalibratordEdxDevice : public Task void sendOutput(DataAllocator& output) { const auto& calibrations = mCalibrator->getCalibs(); - auto& intervals = mCalibrator->getTFinterval(); + auto& tfIntervals = mCalibrator->getTFinterval(); const long timeEnd = o2::calibration::Utils::INFINITE_TIME; for (unsigned int i = 0; i < calibrations.size(); i++) { @@ -122,10 +122,9 @@ class CalibratordEdxDevice : public Task o2::ccdb::CcdbObjectInfo info; auto image = o2::ccdb::CcdbApi::createObjectImage(&object, &info); - info.setPath("TPC/Calib/dEdx"); - // FIXME: use time frame timestamp - info.setStartValidityTimestamp(intervals[i].first); - info.setEndValidityTimestamp(timeEnd); + info.setPath("TPC/Calib/TimeGain"); + info.setStartValidityTimestamp(processing_helpers::toTimeStamp(tfIntervals[i].first)); + info.setEndValidityTimestamp(processing_helpers::toTimeStamp(tfIntervals[i].second + 1)); auto md = info.getMetaData(); md["runNumber"] = std::to_string(mRunNumber); @@ -161,9 +160,9 @@ DataProcessorSpec getCalibratordEdxSpec() {"max-delay", VariantType::Int, 10, {"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)."}}, - {"min-entries-1d", VariantType::Int, 10000, {"minimum entries per stack to fit 1D correction"}}, - {"min-entries-2d", VariantType::Int, 50000, {"minimum entries per stack to fit 2D correction"}}, + {"min-entries-sector", VariantType::Int, 3000, {"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)."}}, + {"min-entries-1d", VariantType::Int, 200, {"minimum entries per stack to fit 1D correction"}}, + {"min-entries-2d", VariantType::Int, 10000, {"minimum entries per stack to fit 2D correction"}}, {"fit-passes", VariantType::Int, 3, {"number of fit iterations"}}, {"fit-threshold", VariantType::Float, 0.2f, {"dEdx width around the MIP peak used in the fit"}}, diff --git a/Detectors/TPC/workflow/src/ProcessingHelpers.cxx b/Detectors/TPC/workflow/src/ProcessingHelpers.cxx index 1d6a70742bd2e..196771476e151 100644 --- a/Detectors/TPC/workflow/src/ProcessingHelpers.cxx +++ b/Detectors/TPC/workflow/src/ProcessingHelpers.cxx @@ -9,6 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +#include #include #include @@ -20,6 +21,7 @@ #include "Framework/InputRecord.h" #include "Framework/ServiceRegistry.h" #include "CommonConstants/LHCConstants.h" +#include "DetectorsRaw/HBFUtils.h" #include "TPCWorkflow/ProcessingHelpers.h" @@ -76,3 +78,16 @@ Long64_t processing_helpers::getOrbitReset(o2::framework::ProcessingContext& pc) const auto orbitReset = tv->front(); return orbitReset; } + +uint64_t processing_helpers::getAbsoluteTF(o2::framework::ProcessingContext& pc) +{ + static const double TFlength = 1e-3 * o2::raw::HBFUtils::Instance().getNOrbitsPerTF() * o2::constants::lhc::LHCOrbitMUS; // in ms + const double creation = static_cast(processing_helpers::getCreationTime(pc)); + return static_cast(creation / TFlength); +} + +uint64_t processing_helpers::toTimeStamp(uint64_t timeFrame) +{ + static const double TFlength = 1e-3 * o2::raw::HBFUtils::Instance().getNOrbitsPerTF() * o2::constants::lhc::LHCOrbitMUS; // in ms + return static_cast(static_cast(timeFrame) * TFlength); +}