|
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" |
@@ -119,6 +120,7 @@ struct EmcalCorrectionTask { |
119 | 120 | Configurable<bool> useTempCalibMean{"useTempCalibMean", false, "Switch to turn on Temperature mean calculation instead of median."}; |
120 | 121 | Configurable<float> mcCellEnergyShift{"mcCellEnergyShift", 1., "Relative shift of the MC cell energy. 1.1 for 10% shift to higher mass, etc. Only applied to MC."}; |
121 | 122 | 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."}; |
| 123 | + Configurable<bool> applyGainCalibShift{"applyGainCalibShift", false, "Apply shift for cell gain calibration to use values before cell format change (Sept. 2023)"}; |
122 | 124 |
|
123 | 125 | // Require EMCAL cells (CALO type 1) |
124 | 126 | Filter emccellfilter = aod::calo::caloType == selectedCellType; |
@@ -152,6 +154,9 @@ struct EmcalCorrectionTask { |
152 | 154 | std::unique_ptr<o2::emcal::EMCALTempCalibExtractor> mTempCalibExtractor; |
153 | 155 | bool mIsTempCalibInitialized = false; |
154 | 156 |
|
| 157 | + // Gain calibration |
| 158 | + std::array<float, 17664> mArrGainCalibDiff; |
| 159 | + |
155 | 160 | std::vector<std::pair<int, int>> mExtraTimeShiftRunRanges; |
156 | 161 |
|
157 | 162 | // Current run number |
@@ -185,6 +190,11 @@ struct EmcalCorrectionTask { |
185 | 190 | mTempCalibExtractor = std::make_unique<o2::emcal::EMCALTempCalibExtractor>(); |
186 | 191 | } |
187 | 192 |
|
| 193 | + // gain calibration shift initialization |
| 194 | + if (applyGainCalibShift) { |
| 195 | + initializeGainCalibShift(); |
| 196 | + } |
| 197 | + |
188 | 198 | // read all the cluster definitions specified in the options |
189 | 199 | if (clusterDefinitions->length()) { |
190 | 200 | std::stringstream parser(clusterDefinitions.value); |
@@ -363,6 +373,9 @@ struct EmcalCorrectionTask { |
363 | 373 | if (applyCellAbsScale) { |
364 | 374 | amplitude *= getAbsCellScale(cell.cellNumber()); |
365 | 375 | } |
| 376 | + if (applyGainCalibShift) { |
| 377 | + amplitude *= mArrGainCalibDiff[cell.cellNumber()]; |
| 378 | + } |
366 | 379 | if (applyTempCalib) { |
367 | 380 | float tempCalibFactor = mTempCalibExtractor->getGainCalibFactor(static_cast<uint16_t>(cell.cellNumber())); |
368 | 381 | amplitude *= tempCalibFactor; |
@@ -618,6 +631,9 @@ struct EmcalCorrectionTask { |
618 | 631 | if (static_cast<bool>(hasShaperCorrection) && emcal::intToChannelType(cell.cellType()) == emcal::ChannelType_t::LOW_GAIN) { // Apply shaper correction to LG cells |
619 | 632 | amplitude = o2::emcal::NonlinearityHandler::evaluateShaperCorrectionCellEnergy(amplitude); |
620 | 633 | } |
| 634 | + if (applyGainCalibShift) { |
| 635 | + amplitude *= mArrGainCalibDiff[cell.cellNumber()]; |
| 636 | + } |
621 | 637 | if (applyTempCalib) { |
622 | 638 | float tempCalibFactor = mTempCalibExtractor->getGainCalibFactor(static_cast<uint16_t>(cell.cellNumber())); |
623 | 639 | amplitude *= tempCalibFactor; |
@@ -1022,6 +1038,18 @@ struct EmcalCorrectionTask { |
1022 | 1038 | } |
1023 | 1039 | return timeshift + timesmear; |
1024 | 1040 | }; |
| 1041 | + |
| 1042 | + void initializeGainCalibShift() |
| 1043 | + { |
| 1044 | + auto& ccdbMgr = o2::ccdb::BasicCCDBManager::instance(); |
| 1045 | + uint64_t tsOld = 1634853602000; // timestamp corresponding to LHC22o old gain calib object |
| 1046 | + o2::emcal::GainCalibrationFactors* paramsOld = ccdbMgr.getForTimeStamp<o2::emcal::GainCalibrationFactors>("EMC/Calib/GainCalibFactors", tsOld); |
| 1047 | + uint64_t tsNew = 1734853602000; // timestamp corresponding to new gain calib object (new cell compression) |
| 1048 | + o2::emcal::GainCalibrationFactors* paramsNew = ccdbMgr.getForTimeStamp<o2::emcal::GainCalibrationFactors>("EMC/Calib/GainCalibFactors", tsNew); |
| 1049 | + for (uint16_t i = 0; i < mArrGainCalibDiff.size(); ++i) { |
| 1050 | + mArrGainCalibDiff[i] = paramsOld->getGainCalibFactors(i) == 0 ? 1. : paramsNew->getGainCalibFactors(i) / paramsOld->getGainCalibFactors(i); |
| 1051 | + } |
| 1052 | + } |
1025 | 1053 | }; |
1026 | 1054 |
|
1027 | 1055 | WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) |
|
0 commit comments