Skip to content

Commit 6247e47

Browse files
jokonigjokonig
andauthored
[PWGJE,EMCAL-568] Add option to use energy calibration done with old … (AliceO2Group#11935)
Co-authored-by: jokonig <[email protected]>
1 parent 743d318 commit 6247e47

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"
@@ -119,6 +120,7 @@ struct EmcalCorrectionTask {
119120
Configurable<bool> useTempCalibMean{"useTempCalibMean", false, "Switch to turn on Temperature mean calculation instead of median."};
120121
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."};
121122
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)"};
122124

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

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

157162
// Current run number
@@ -185,6 +190,11 @@ struct EmcalCorrectionTask {
185190
mTempCalibExtractor = std::make_unique<o2::emcal::EMCALTempCalibExtractor>();
186191
}
187192

193+
// gain calibration shift initialization
194+
if (applyGainCalibShift) {
195+
initializeGainCalibShift();
196+
}
197+
188198
// read all the cluster definitions specified in the options
189199
if (clusterDefinitions->length()) {
190200
std::stringstream parser(clusterDefinitions.value);
@@ -363,6 +373,9 @@ struct EmcalCorrectionTask {
363373
if (applyCellAbsScale) {
364374
amplitude *= getAbsCellScale(cell.cellNumber());
365375
}
376+
if (applyGainCalibShift) {
377+
amplitude *= mArrGainCalibDiff[cell.cellNumber()];
378+
}
366379
if (applyTempCalib) {
367380
float tempCalibFactor = mTempCalibExtractor->getGainCalibFactor(static_cast<uint16_t>(cell.cellNumber()));
368381
amplitude *= tempCalibFactor;
@@ -618,6 +631,9 @@ struct EmcalCorrectionTask {
618631
if (static_cast<bool>(hasShaperCorrection) && emcal::intToChannelType(cell.cellType()) == emcal::ChannelType_t::LOW_GAIN) { // Apply shaper correction to LG cells
619632
amplitude = o2::emcal::NonlinearityHandler::evaluateShaperCorrectionCellEnergy(amplitude);
620633
}
634+
if (applyGainCalibShift) {
635+
amplitude *= mArrGainCalibDiff[cell.cellNumber()];
636+
}
621637
if (applyTempCalib) {
622638
float tempCalibFactor = mTempCalibExtractor->getGainCalibFactor(static_cast<uint16_t>(cell.cellNumber()));
623639
amplitude *= tempCalibFactor;
@@ -1022,6 +1038,18 @@ struct EmcalCorrectionTask {
10221038
}
10231039
return timeshift + timesmear;
10241040
};
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+
}
10251053
};
10261054

10271055
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)

0 commit comments

Comments
 (0)