From 95aa1888479d7a9d88824648a557d705f59ca6d2 Mon Sep 17 00:00:00 2001 From: wiechula Date: Thu, 19 Dec 2024 16:03:50 +0100 Subject: [PATCH] Add treatment of clustom dE/dx file and disabling dE/dx input --- Detectors/TPC/workflow/src/CalibdEdxSpec.cxx | 36 ++++++++++++++++--- .../TPC/workflow/src/CalibratordEdxSpec.cxx | 34 +++++++++++++++--- 2 files changed, 61 insertions(+), 9 deletions(-) diff --git a/Detectors/TPC/workflow/src/CalibdEdxSpec.cxx b/Detectors/TPC/workflow/src/CalibdEdxSpec.cxx index a32a4a1bb3089..97b69156a2a6d 100644 --- a/Detectors/TPC/workflow/src/CalibdEdxSpec.cxx +++ b/Detectors/TPC/workflow/src/CalibdEdxSpec.cxx @@ -18,17 +18,18 @@ // o2 includes #include "CCDB/CcdbApi.h" #include "CCDB/CcdbObjectInfo.h" -#include "CommonUtils/NameConf.h" +// #include "CommonUtils/NameConf.h" #include "DataFormatsTPC/TrackTPC.h" -#include "DataFormatsParameters/GRPObject.h" +// #include "DataFormatsParameters/GRPObject.h" #include "DetectorsCalibration/Utils.h" #include "Framework/Task.h" #include "Framework/DataProcessorSpec.h" #include "Framework/ConfigParamRegistry.h" #include "Framework/CCDBParamSpec.h" +#include "GPUO2InterfaceConfigurableParam.h" #include "TPCCalibration/CalibdEdx.h" #include "TPCWorkflow/ProcessingHelpers.h" -#include "TPCBase/CDBInterface.h" +#include "TPCBase/CDBTypes.h" #include "TPCBase/Utils.h" #include "DetectorsBase/GRPGeomHelper.h" @@ -68,6 +69,29 @@ class CalibdEdxDevice : public Task mCalib->set2DFitThreshold(minEntries2D); mCalib->setElectronCut(fitThreshold, fitPasses, fitThresholdLowFactor); mCalib->setMaterialType(mMatType); + + mCustomdEdxFileName = o2::gpu::GPUConfigurableParamGPUSettingsO2::Instance().dEdxCorrFile; + mDisableTimeGain = o2::gpu::GPUConfigurableParamGPUSettingsO2::Instance().dEdxDisableResidualGain; + + if (mDisableTimeGain) { + LOGP(info, "TimeGain correction was disabled via GPU_global.dEdxDisableResidualGain=1"); + } + + if (!mDisableTimeGain && !mCustomdEdxFileName.empty()) { + std::unique_ptr fdEdxCustom(TFile::Open(mCustomdEdxFileName.data())); + if (!fdEdxCustom || !fdEdxCustom->IsOpen() || fdEdxCustom->IsZombie()) { + LOGP(error, "Could not open custom TimeGain file {}", mCustomdEdxFileName); + } else { + const auto timeGain = fdEdxCustom->Get("CalibdEdxCorrection"); + if (!timeGain) { + LOGP(error, "Could not load 'CalibdEdxCorrection' from file {}", mCustomdEdxFileName); + } else { + const auto meanParamTot = timeGain->getMeanParams(ChargeType::Tot); + LOGP(info, "Loaded custom TimeGain from file {} with {} dimensions and mean qTot Params {}", mCustomdEdxFileName, timeGain->getDims(), utils::elementsToString(meanParamTot)); + mCalib->setCalibrationInput(*timeGain); + } + } + } } void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final @@ -75,7 +99,7 @@ class CalibdEdxDevice : public Task if (o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj)) { return; } - if (matcher == ConcreteDataMatcher("TPC", "TIMEGAIN", 0)) { + if ((mDisableTimeGain == 0) && mCustomdEdxFileName.empty() && (matcher == ConcreteDataMatcher("TPC", "TIMEGAIN", 0))) { mCalib->setCalibrationInput(*(o2::tpc::CalibdEdxCorrection*)obj); const auto meanParamTot = mCalib->getCalibrationInput().getMeanParams(ChargeType::Tot); LOGP(info, "Updating TimeGain with {} dimensions and mean qTot Params {}", mCalib->getCalibrationInput().getDims(), utils::elementsToString(meanParamTot)); @@ -143,7 +167,9 @@ class CalibdEdxDevice : public Task uint64_t mRunNumber{0}; ///< processed run number uint64_t mTimeStampStart{0}; ///< time stamp for first TF for CCDB output std::unique_ptr mCalib; - bool mMakeGaussianFits{true}; ///< make gaussian fits or take the mean + bool mMakeGaussianFits{true}; ///< make gaussian fits or take the mean + bool mDisableTimeGain{false}; ///< if time gain is disabled via GPU_global.dEdxDisableResidualGain=1 + std::string mCustomdEdxFileName{}; ///< name of the custom dE/dx file configured via GPU_global.dEdxCorrFile }; DataProcessorSpec getCalibdEdxSpec(const o2::base::Propagator::MatCorrType matType) diff --git a/Detectors/TPC/workflow/src/CalibratordEdxSpec.cxx b/Detectors/TPC/workflow/src/CalibratordEdxSpec.cxx index 6e477084d992c..ce45356aa28c8 100644 --- a/Detectors/TPC/workflow/src/CalibratordEdxSpec.cxx +++ b/Detectors/TPC/workflow/src/CalibratordEdxSpec.cxx @@ -21,18 +21,19 @@ // o2 includes #include "CCDB/CcdbApi.h" #include "CCDB/CcdbObjectInfo.h" -#include "CommonUtils/NameConf.h" +// #include "CommonUtils/NameConf.h" #include "DataFormatsTPC/TrackTPC.h" -#include "DataFormatsParameters/GRPObject.h" +// #include "DataFormatsParameters/GRPObject.h" #include "DetectorsCalibration/Utils.h" #include "Framework/Task.h" #include "Framework/DataProcessorSpec.h" #include "Framework/ConfigParamRegistry.h" #include "Framework/CCDBParamSpec.h" +#include "GPUO2InterfaceConfigurableParam.h" #include "TPCCalibration/CalibratordEdx.h" #include "TPCWorkflow/ProcessingHelpers.h" #include "DetectorsBase/GRPGeomHelper.h" -#include "TPCBase/CDBInterface.h" +#include "TPCBase/CDBTypes.h" #include "TPCBase/Utils.h" using namespace o2::framework; @@ -85,6 +86,29 @@ class CalibratordEdxDevice : public Task mCalibrator->setTrackDebug(trackDebug); mCalibrator->setMakeGaussianFits(makeGaussianFits); + mCustomdEdxFileName = o2::gpu::GPUConfigurableParamGPUSettingsO2::Instance().dEdxCorrFile; + mDisableTimeGain = o2::gpu::GPUConfigurableParamGPUSettingsO2::Instance().dEdxDisableResidualGain; + + if (mDisableTimeGain) { + LOGP(info, "TimeGain correction was disabled via GPU_global.dEdxDisableResidualGain=1"); + } + + if (!mDisableTimeGain && !mCustomdEdxFileName.empty()) { + std::unique_ptr fdEdxCustom(TFile::Open(mCustomdEdxFileName.data())); + if (!fdEdxCustom || !fdEdxCustom->IsOpen() || fdEdxCustom->IsZombie()) { + LOGP(error, "Could not open custom TimeGain file {}", mCustomdEdxFileName); + } else { + const auto timeGain = fdEdxCustom->Get("CalibdEdxCorrection"); + if (!timeGain) { + LOGP(error, "Could not load 'CalibdEdxCorrection' from file {}", mCustomdEdxFileName); + } else { + mTimeGain = *timeGain; + const auto meanParamTot = mTimeGain.getMeanParams(ChargeType::Tot); + LOGP(info, "Loaded custom TimeGain from file {} with {} dimensions and mean qTot Params {}", mCustomdEdxFileName, mTimeGain.getDims(), utils::elementsToString(meanParamTot)); + } + } + } + if (dumpData) { const auto dumpDataName = ic.options().get("file-dump-name"); mCalibrator->enableDebugOutput(dumpDataName); @@ -96,7 +120,7 @@ class CalibratordEdxDevice : public Task if (o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj)) { return; } - if (matcher == ConcreteDataMatcher("TPC", "TIMEGAIN", 0)) { + if ((mDisableTimeGain == 0) && mCustomdEdxFileName.empty() && (matcher == ConcreteDataMatcher("TPC", "TIMEGAIN", 0))) { mTimeGain = *(o2::tpc::CalibdEdxCorrection*)obj; const auto meanParamTot = mTimeGain.getMeanParams(ChargeType::Tot); LOGP(info, "Updating TimeGain with {} dimensions and mean qTot Params {}", mTimeGain.getDims(), utils::elementsToString(meanParamTot)); @@ -181,6 +205,8 @@ class CalibratordEdxDevice : public Task uint32_t mRunNumber{0}; ///< processed run number long mCalibIntervalExtensionMS{0}; ///< Extension of the calibration interval end in ms o2::tpc::CalibdEdxCorrection mTimeGain{}; ///< currently valid TimeGain + bool mDisableTimeGain{false}; ///< if time gain is disabled via GPU_global.dEdxDisableResidualGain=1 + std::string mCustomdEdxFileName{}; ///< name of the custom dE/dx file configured via GPU_global.dEdxCorrFile }; DataProcessorSpec getCalibratordEdxSpec(const o2::base::Propagator::MatCorrType matType)