diff --git a/Detectors/TPC/calibration/include/TPCCalibration/CalibdEdx.h b/Detectors/TPC/calibration/include/TPCCalibration/CalibdEdx.h index b07d00c132175..a025e6ba76cfc 100644 --- a/Detectors/TPC/calibration/include/TPCCalibration/CalibdEdx.h +++ b/Detectors/TPC/calibration/include/TPCCalibration/CalibdEdx.h @@ -120,6 +120,9 @@ class CalibdEdx const CalibdEdxCorrection& getCalib() const { return mCalib; } + /// calibration used during reconstruction + void setCalibrationInput(const CalibdEdxCorrection& calib) { mCalibIn = calib; } + /// Return the number of hist entries of the gem stack with less statistics int minStackEntries() const; @@ -152,8 +155,9 @@ class CalibdEdx float mFitLowCutFactor = 1.5; ///< dEdx cut multiplier for the lower dE/dx range int mFitPasses = 3; ///< number of fit passes used to remove electron tracks - Hist mHist; ///< dEdx multidimensional histogram - CalibdEdxCorrection mCalib{}; ///< Calibration output + Hist mHist; ///< dEdx multidimensional histogram + CalibdEdxCorrection mCalib{}; ///< Calibration output + CalibdEdxCorrection mCalibIn{}; ///< Calibration output o2::base::Propagator::MatCorrType mMatType{}; ///< material type for track propagation diff --git a/Detectors/TPC/calibration/src/CalibdEdx.cxx b/Detectors/TPC/calibration/src/CalibdEdx.cxx index 6d6aa980b9680..00ddadccae5f2 100644 --- a/Detectors/TPC/calibration/src/CalibdEdx.cxx +++ b/Detectors/TPC/calibration/src/CalibdEdx.cxx @@ -96,13 +96,21 @@ void CalibdEdx::fill(const TrackTPC& track) } } const float snp = cpTrack.getSnp(); - const float scaledTgl = scaleTgl(std::abs(cpTrack.getTgl()), roc); + const float tgl = cpTrack.getTgl(); + const float scaledTgl = scaleTgl(std::abs(tgl), roc); if (track.hasCSideClusters()) { sector += SECTORSPERSIDE; } - mHist(dEdxMax[roc] * dEdxScale, scaledTgl, snp, sector, roc, ChargeType::Max); - mHist(dEdxTot[roc] * dEdxScale, scaledTgl, snp, sector, roc, ChargeType::Tot); + // undo previously done corrections, to allow for residual corrections + // output will still be the full correction + float corrMax = mCalibIn.getCorrection(StackID{static_cast(sector), roc}, ChargeType::Max, tgl, snp); + float corrTot = mCalibIn.getCorrection(StackID{static_cast(sector), roc}, ChargeType::Tot, tgl, snp); + corrMax = (corrMax > 0.1f) ? 1.f / corrMax : 1.f; + corrTot = (corrTot > 0.1f) ? 1.f / corrTot : 1.f; + + mHist(dEdxMax[roc] * dEdxScale * corrMax, scaledTgl, snp, sector, roc, ChargeType::Max); + mHist(dEdxTot[roc] * dEdxScale * corrTot, scaledTgl, snp, sector, roc, ChargeType::Tot); } } diff --git a/Detectors/TPC/workflow/src/CalibdEdxSpec.cxx b/Detectors/TPC/workflow/src/CalibdEdxSpec.cxx index 2447b1f3969f2..263210c874ca3 100644 --- a/Detectors/TPC/workflow/src/CalibdEdxSpec.cxx +++ b/Detectors/TPC/workflow/src/CalibdEdxSpec.cxx @@ -25,6 +25,7 @@ #include "Framework/Task.h" #include "Framework/DataProcessorSpec.h" #include "Framework/ConfigParamRegistry.h" +#include "Framework/CCDBParamSpec.h" #include "TPCCalibration/CalibdEdx.h" #include "TPCWorkflow/ProcessingHelpers.h" #include "TPCBase/CDBInterface.h" @@ -69,12 +70,18 @@ class CalibdEdxDevice : public Task void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final { - o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj); + if (o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj)) { + return; + } + if (matcher == ConcreteDataMatcher("TPC", "TIMEGAIN", 0)) { + mCalib->setCalibrationInput(*(o2::tpc::CalibdEdxCorrection*)obj); + } } void run(ProcessingContext& pc) final { o2::base::GRPGeomHelper::instance().checkUpdates(pc); + checkUpdates(pc); const auto tfcounter = o2::header::get(pc.inputs().get("tracks").header)->startTime; const auto tracks = pc.inputs().get>("tracks"); @@ -115,6 +122,15 @@ class CalibdEdxDevice : public Task output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "TPC_CalibdEdx", 0}, info); } + void checkUpdates(ProcessingContext& pc) const + { + if (pc.inputs().isValid("tpctimegain")) { + pc.inputs().get("tpctimegain"); + } else { + return; + } + } + std::shared_ptr mCCDBRequest; const o2::base::Propagator::MatCorrType mMatType{}; int mDumpToFile{}; @@ -130,6 +146,8 @@ DataProcessorSpec getCalibdEdxSpec(const o2::base::Propagator::MatCorrType matTy 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", Lifetime::Sporadic}}; + inputs.emplace_back("tpctimegain", "TPC", "TIMEGAIN", 0, Lifetime::Condition, ccdbParamSpec(o2::tpc::CDBTypeMap.at(o2::tpc::CDBType::CalTimeGain), {}, 1)); // time-dependent + auto ccdbRequest = std::make_shared(true, // orbitResetTime false, // GRPECS=true false, // GRPLHCIF diff --git a/Detectors/TPC/workflow/src/CalibratordEdxSpec.cxx b/Detectors/TPC/workflow/src/CalibratordEdxSpec.cxx index 08b93b0b915c7..5420b2929e0e3 100644 --- a/Detectors/TPC/workflow/src/CalibratordEdxSpec.cxx +++ b/Detectors/TPC/workflow/src/CalibratordEdxSpec.cxx @@ -28,6 +28,7 @@ #include "Framework/Task.h" #include "Framework/DataProcessorSpec.h" #include "Framework/ConfigParamRegistry.h" +#include "Framework/CCDBParamSpec.h" #include "TPCCalibration/CalibratordEdx.h" #include "TPCWorkflow/ProcessingHelpers.h" #include "DetectorsBase/GRPGeomHelper.h" @@ -81,14 +82,21 @@ class CalibratordEdxDevice : public Task void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final { - o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj); + if (o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj)) { + return; + } + if (matcher == ConcreteDataMatcher("TPC", "TIMEGAIN", 0)) { + auto& slotTF = mCalibrator->getSlotForTF(mCalibrator->getCurrentTFInfo().tfCounter); + slotTF.getContainer()->setCalibrationInput(*(o2::tpc::CalibdEdxCorrection*)obj); + } } void run(ProcessingContext& pc) final { + o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mCalibrator->getCurrentTFInfo()); o2::base::GRPGeomHelper::instance().checkUpdates(pc); + checkUpdates(pc); const auto tracks = pc.inputs().get>("tracks"); - o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mCalibrator->getCurrentTFInfo()); LOGP(detail, "Processing TF {} with {} tracks", mCalibrator->getCurrentTFInfo().tfCounter, tracks.size()); mRunNumber = mCalibrator->getCurrentTFInfo().runNumber; mCalibrator->process(tracks); @@ -127,6 +135,15 @@ class CalibratordEdxDevice : public Task mCalibrator->initOutput(); // empty the outputs after they are send } + void checkUpdates(ProcessingContext& pc) const + { + if (pc.inputs().isValid("tpctimegain")) { + pc.inputs().get("tpctimegain"); + } else { + return; + } + } + std::unique_ptr mCalibrator; const o2::base::Propagator::MatCorrType mMatType{}; std::shared_ptr mCCDBRequest; @@ -140,6 +157,8 @@ DataProcessorSpec getCalibratordEdxSpec(const o2::base::Propagator::MatCorrType 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", Lifetime::Sporadic}}; + inputs.emplace_back("tpctimegain", "TPC", "TIMEGAIN", 0, Lifetime::Condition, ccdbParamSpec(o2::tpc::CDBTypeMap.at(o2::tpc::CDBType::CalTimeGain), {}, 1)); // time-dependent + auto ccdbRequest = std::make_shared(true, // orbitResetTime true, // GRPECS=true false, // GRPLHCIF