From 2f5ee3928808da069970cb21e1ddc9a83edcb72f Mon Sep 17 00:00:00 2001 From: jokonig Date: Sun, 6 Jul 2025 21:39:50 +0200 Subject: [PATCH] [PWGJE,EMCAL-568] Add option to use energy calibration done with old cell format - The Pi0 was observed to be wider when using 2024 data. This might be introduced with the energy calibration usign the new cell format - In this PR, an option to correct the cell energy by dividing with the new and multiplying with the old gain calib is introduced - Option is off by default --- PWGJE/TableProducer/emcalCorrectionTask.cxx | 28 +++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/PWGJE/TableProducer/emcalCorrectionTask.cxx b/PWGJE/TableProducer/emcalCorrectionTask.cxx index c46d5e1ebcd..3b358acda1a 100644 --- a/PWGJE/TableProducer/emcalCorrectionTask.cxx +++ b/PWGJE/TableProducer/emcalCorrectionTask.cxx @@ -35,6 +35,7 @@ #include "EMCALBase/ClusterFactory.h" #include "EMCALBase/Geometry.h" #include "EMCALBase/NonlinearityHandler.h" +#include "EMCALCalib/GainCalibrationFactors.h" #include "EMCALCalibration/EMCALTempCalibExtractor.h" #include "EMCALReconstruction/Clusterizer.h" #include "Framework/ASoA.h" @@ -118,6 +119,7 @@ struct EmcalCorrectionTask { Configurable pathTempCalibCCDB{"pathTempCalibCCDB", "Users/j/jokonig/EMCalTempCalibParams", "Path in the ccdb where slope and intercept for each cell are stored"}; // change to official path as soon as it is available Configurable useTempCalibMean{"useTempCalibMean", false, "Switch to turn on Temperature mean calculation instead of median."}; Configurable mcCellEnergyResolutionBroadening{"mcCellEnergyResolutionBroadening", 0., "Relative widening of the MC cell energy resolution. 0 for no widening, 0.1 for 10% widening, etc. Only applied to MC."}; + Configurable applyGainCalibShift{"applyGainCalibShift", false, "Apply shift for cell gain calibration to use values before cell format change (Sept. 2023)"}; // Require EMCAL cells (CALO type 1) Filter emccellfilter = aod::calo::caloType == selectedCellType; @@ -151,6 +153,9 @@ struct EmcalCorrectionTask { std::unique_ptr mTempCalibExtractor; bool mIsTempCalibInitialized = false; + // Gain calibration + std::array mArrGainCalibDiff; + std::vector> mExtraTimeShiftRunRanges; // Current run number @@ -184,6 +189,11 @@ struct EmcalCorrectionTask { mTempCalibExtractor = std::make_unique(); } + // gain calibration shift initialization + if (applyGainCalibShift) { + initializeGainCalibShift(); + } + // read all the cluster definitions specified in the options if (clusterDefinitions->length()) { std::stringstream parser(clusterDefinitions.value); @@ -361,6 +371,9 @@ struct EmcalCorrectionTask { if (applyCellAbsScale) { amplitude *= getAbsCellScale(cell.cellNumber()); } + if (applyGainCalibShift) { + amplitude *= mArrGainCalibDiff[cell.cellNumber()]; + } if (applyTempCalib) { amplitude *= mTempCalibExtractor->getGainCalibFactor(static_cast(cell.cellNumber())); } @@ -611,6 +624,9 @@ struct EmcalCorrectionTask { if (static_cast(hasShaperCorrection) && emcal::intToChannelType(cell.cellType()) == emcal::ChannelType_t::LOW_GAIN) { // Apply shaper correction to LG cells amplitude = o2::emcal::NonlinearityHandler::evaluateShaperCorrectionCellEnergy(amplitude); } + if (applyGainCalibShift) { + amplitude *= mArrGainCalibDiff[cell.cellNumber()]; + } if (applyTempCalib) { amplitude *= mTempCalibExtractor->getGainCalibFactor(static_cast(cell.cellNumber())); } @@ -1013,6 +1029,18 @@ struct EmcalCorrectionTask { } return timeshift + timesmear; }; + + void initializeGainCalibShift() + { + auto& ccdbMgr = o2::ccdb::BasicCCDBManager::instance(); + uint64_t tsOld = 1634853602000; // timestamp corresponding to LHC22o old gain calib object + o2::emcal::GainCalibrationFactors* paramsOld = ccdbMgr.getForTimeStamp("EMC/Calib/GainCalibFactors", tsOld); + uint64_t tsNew = 1734853602000; // timestamp corresponding to new gain calib object (new cell compression) + o2::emcal::GainCalibrationFactors* paramsNew = ccdbMgr.getForTimeStamp("EMC/Calib/GainCalibFactors", tsNew); + for (uint16_t i = 0; i < mArrGainCalibDiff.size(); ++i) { + mArrGainCalibDiff[i] = paramsOld->getGainCalibFactors(i) == 0 ? 1. : paramsNew->getGainCalibFactors(i) / paramsOld->getGainCalibFactors(i); + } + } }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)