|
35 | 35 | #include "EMCALBase/ClusterFactory.h" |
36 | 36 | #include "EMCALBase/Geometry.h" |
37 | 37 | #include "EMCALBase/NonlinearityHandler.h" |
| 38 | +#include "EMCALCalib/GainCalibrationFactors.h" |
38 | 39 | #include "EMCALCalibration/EMCALTempCalibExtractor.h" |
39 | 40 | #include "EMCALReconstruction/Clusterizer.h" |
40 | 41 | #include "Framework/ASoA.h" |
@@ -118,6 +119,7 @@ struct EmcalCorrectionTask { |
118 | 119 | Configurable<std::string> 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 |
119 | 120 | Configurable<bool> useTempCalibMean{"useTempCalibMean", false, "Switch to turn on Temperature mean calculation instead of median."}; |
120 | 121 | Configurable<float> 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."}; |
| 122 | + Configurable<bool> applyGainCalibShift{"applyGainCalibShift", false, "Apply shift for cell gain calibration to use values before cell format change (Sept. 2023)"}; |
121 | 123 |
|
122 | 124 | // Require EMCAL cells (CALO type 1) |
123 | 125 | Filter emccellfilter = aod::calo::caloType == selectedCellType; |
@@ -151,6 +153,9 @@ struct EmcalCorrectionTask { |
151 | 153 | std::unique_ptr<o2::emcal::EMCALTempCalibExtractor> mTempCalibExtractor; |
152 | 154 | bool mIsTempCalibInitialized = false; |
153 | 155 |
|
| 156 | + // Gain calibration |
| 157 | + std::array<float, 17664> mArrGainCalibDiff; |
| 158 | + |
154 | 159 | std::vector<std::pair<int, int>> mExtraTimeShiftRunRanges; |
155 | 160 |
|
156 | 161 | // Current run number |
@@ -184,6 +189,11 @@ struct EmcalCorrectionTask { |
184 | 189 | mTempCalibExtractor = std::make_unique<o2::emcal::EMCALTempCalibExtractor>(); |
185 | 190 | } |
186 | 191 |
|
| 192 | + // gain calibration shift initialization |
| 193 | + if (applyGainCalibShift) { |
| 194 | + initializeGainCalibShift(); |
| 195 | + } |
| 196 | + |
187 | 197 | // read all the cluster definitions specified in the options |
188 | 198 | if (clusterDefinitions->length()) { |
189 | 199 | std::stringstream parser(clusterDefinitions.value); |
@@ -361,6 +371,9 @@ struct EmcalCorrectionTask { |
361 | 371 | if (applyCellAbsScale) { |
362 | 372 | amplitude *= getAbsCellScale(cell.cellNumber()); |
363 | 373 | } |
| 374 | + if (applyGainCalibShift) { |
| 375 | + amplitude *= mArrGainCalibDiff[cell.cellNumber()]; |
| 376 | + } |
364 | 377 | if (applyTempCalib) { |
365 | 378 | amplitude *= mTempCalibExtractor->getGainCalibFactor(static_cast<uint16_t>(cell.cellNumber())); |
366 | 379 | } |
@@ -611,6 +624,9 @@ struct EmcalCorrectionTask { |
611 | 624 | if (static_cast<bool>(hasShaperCorrection) && emcal::intToChannelType(cell.cellType()) == emcal::ChannelType_t::LOW_GAIN) { // Apply shaper correction to LG cells |
612 | 625 | amplitude = o2::emcal::NonlinearityHandler::evaluateShaperCorrectionCellEnergy(amplitude); |
613 | 626 | } |
| 627 | + if (applyGainCalibShift) { |
| 628 | + amplitude *= mArrGainCalibDiff[cell.cellNumber()]; |
| 629 | + } |
614 | 630 | if (applyTempCalib) { |
615 | 631 | amplitude *= mTempCalibExtractor->getGainCalibFactor(static_cast<uint16_t>(cell.cellNumber())); |
616 | 632 | } |
@@ -1013,6 +1029,18 @@ struct EmcalCorrectionTask { |
1013 | 1029 | } |
1014 | 1030 | return timeshift + timesmear; |
1015 | 1031 | }; |
| 1032 | + |
| 1033 | + void initializeGainCalibShift() |
| 1034 | + { |
| 1035 | + auto& ccdbMgr = o2::ccdb::BasicCCDBManager::instance(); |
| 1036 | + uint64_t tsOld = 1634853602000; // timestamp corresponding to LHC22o old gain calib object |
| 1037 | + o2::emcal::GainCalibrationFactors* paramsOld = ccdbMgr.getForTimeStamp<o2::emcal::GainCalibrationFactors>("EMC/Calib/GainCalibFactors", tsOld); |
| 1038 | + uint64_t tsNew = 1734853602000; // timestamp corresponding to new gain calib object (new cell compression) |
| 1039 | + o2::emcal::GainCalibrationFactors* paramsNew = ccdbMgr.getForTimeStamp<o2::emcal::GainCalibrationFactors>("EMC/Calib/GainCalibFactors", tsNew); |
| 1040 | + for (uint16_t i = 0; i < mArrGainCalibDiff.size(); ++i) { |
| 1041 | + mArrGainCalibDiff[i] = paramsOld->getGainCalibFactors(i) == 0 ? 1. : paramsNew->getGainCalibFactors(i) / paramsOld->getGainCalibFactors(i); |
| 1042 | + } |
| 1043 | + } |
1016 | 1044 | }; |
1017 | 1045 |
|
1018 | 1046 | WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) |
|
0 commit comments