Skip to content

Commit 2f5ee39

Browse files
author
jokonig
committed
[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
1 parent c8f0999 commit 2f5ee39

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

PWGJE/TableProducer/emcalCorrectionTask.cxx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "EMCALBase/ClusterFactory.h"
3636
#include "EMCALBase/Geometry.h"
3737
#include "EMCALBase/NonlinearityHandler.h"
38+
#include "EMCALCalib/GainCalibrationFactors.h"
3839
#include "EMCALCalibration/EMCALTempCalibExtractor.h"
3940
#include "EMCALReconstruction/Clusterizer.h"
4041
#include "Framework/ASoA.h"
@@ -118,6 +119,7 @@ struct EmcalCorrectionTask {
118119
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
119120
Configurable<bool> useTempCalibMean{"useTempCalibMean", false, "Switch to turn on Temperature mean calculation instead of median."};
120121
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)"};
121123

122124
// Require EMCAL cells (CALO type 1)
123125
Filter emccellfilter = aod::calo::caloType == selectedCellType;
@@ -151,6 +153,9 @@ struct EmcalCorrectionTask {
151153
std::unique_ptr<o2::emcal::EMCALTempCalibExtractor> mTempCalibExtractor;
152154
bool mIsTempCalibInitialized = false;
153155

156+
// Gain calibration
157+
std::array<float, 17664> mArrGainCalibDiff;
158+
154159
std::vector<std::pair<int, int>> mExtraTimeShiftRunRanges;
155160

156161
// Current run number
@@ -184,6 +189,11 @@ struct EmcalCorrectionTask {
184189
mTempCalibExtractor = std::make_unique<o2::emcal::EMCALTempCalibExtractor>();
185190
}
186191

192+
// gain calibration shift initialization
193+
if (applyGainCalibShift) {
194+
initializeGainCalibShift();
195+
}
196+
187197
// read all the cluster definitions specified in the options
188198
if (clusterDefinitions->length()) {
189199
std::stringstream parser(clusterDefinitions.value);
@@ -361,6 +371,9 @@ struct EmcalCorrectionTask {
361371
if (applyCellAbsScale) {
362372
amplitude *= getAbsCellScale(cell.cellNumber());
363373
}
374+
if (applyGainCalibShift) {
375+
amplitude *= mArrGainCalibDiff[cell.cellNumber()];
376+
}
364377
if (applyTempCalib) {
365378
amplitude *= mTempCalibExtractor->getGainCalibFactor(static_cast<uint16_t>(cell.cellNumber()));
366379
}
@@ -611,6 +624,9 @@ struct EmcalCorrectionTask {
611624
if (static_cast<bool>(hasShaperCorrection) && emcal::intToChannelType(cell.cellType()) == emcal::ChannelType_t::LOW_GAIN) { // Apply shaper correction to LG cells
612625
amplitude = o2::emcal::NonlinearityHandler::evaluateShaperCorrectionCellEnergy(amplitude);
613626
}
627+
if (applyGainCalibShift) {
628+
amplitude *= mArrGainCalibDiff[cell.cellNumber()];
629+
}
614630
if (applyTempCalib) {
615631
amplitude *= mTempCalibExtractor->getGainCalibFactor(static_cast<uint16_t>(cell.cellNumber()));
616632
}
@@ -1013,6 +1029,18 @@ struct EmcalCorrectionTask {
10131029
}
10141030
return timeshift + timesmear;
10151031
};
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+
}
10161044
};
10171045

10181046
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)

0 commit comments

Comments
 (0)