Skip to content

Commit 3939a4f

Browse files
jokonigjokonig
andauthored
[PWGJE,EMCAL-567] Add temperature calib. to EMC corr. task (#11916)
Co-authored-by: jokonig <jokonig@cern.ch>
1 parent d9239c0 commit 3939a4f

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

PWGJE/TableProducer/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ endif()
9393

9494
o2physics_add_dpl_workflow(emcal-correction-task
9595
SOURCES emcalCorrectionTask.cxx
96-
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase O2::EMCALBase O2::EMCALReconstruction
96+
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase O2::EMCALBase O2::EMCALReconstruction O2::EMCALCalibration
9797
COMPONENT_NAME Analysis)
9898

9999
o2physics_add_dpl_workflow(emcal-matchedtracks-writer

PWGJE/TableProducer/emcalCorrectionTask.cxx

Lines changed: 34 additions & 2 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 "EMCALCalibration/EMCALTempCalibExtractor.h"
3839
#include "EMCALReconstruction/Clusterizer.h"
3940
#include "Framework/ASoA.h"
4041
#include "Framework/AnalysisDataModel.h"
@@ -113,6 +114,9 @@ struct EmcalCorrectionTask {
113114
Configurable<float> trackMinPt{"trackMinPt", 0.3, "Minimum pT for tracks to perform track matching, to reduce computing time. Tracks below a certain pT will be loopers anyway."};
114115
Configurable<bool> fillQA{"fillQA", false, "Switch to turn on QA histograms."};
115116
Configurable<bool> useCCDBAlignment{"useCCDBAlignment", false, "EXPERTS ONLY! Switch to use the alignment object stored in CCDB instead of using the default alignment from the global geometry object."};
117+
Configurable<bool> applyTempCalib{"applyTempCalib", false, "Switch to turn on Temperature calibration."};
118+
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+
Configurable<bool> useTempCalibMean{"useTempCalibMean", false, "Switch to turn on Temperature mean calculation instead of median."};
116120

117121
// Require EMCAL cells (CALO type 1)
118122
Filter emccellfilter = aod::calo::caloType == selectedCellType;
@@ -142,6 +146,10 @@ struct EmcalCorrectionTask {
142146
// EMCal geometry
143147
o2::emcal::Geometry* geometry;
144148

149+
// EMCal cell temperature calibrator
150+
std::unique_ptr<o2::emcal::EMCALTempCalibExtractor> mTempCalibExtractor;
151+
bool mIsTempCalibInitialized = false;
152+
145153
std::vector<std::pair<int, int>> mExtraTimeShiftRunRanges;
146154

147155
// Current run number
@@ -171,6 +179,10 @@ struct EmcalCorrectionTask {
171179
geometry->SetMisalMatrixFromCcdb();
172180
}
173181

182+
if (applyTempCalib) {
183+
mTempCalibExtractor = std::make_unique<o2::emcal::EMCALTempCalibExtractor>();
184+
}
185+
174186
// read all the cluster definitions specified in the options
175187
if (clusterDefinitions->length()) {
176188
std::stringstream parser(clusterDefinitions.value);
@@ -316,6 +328,11 @@ struct EmcalCorrectionTask {
316328
// get run number
317329
runNumber = bc.runNumber();
318330

331+
if (applyTempCalib && !mIsTempCalibInitialized) { // needs to be called once
332+
mTempCalibExtractor->InitializeFromCCDB(pathTempCalibCCDB, static_cast<uint64_t>(runNumber));
333+
mIsTempCalibInitialized = true;
334+
}
335+
319336
// Convert aod::Calo to o2::emcal::Cell which can be used with the clusterizer.
320337
// In particular, we need to filter only EMCAL cells.
321338

@@ -343,6 +360,9 @@ struct EmcalCorrectionTask {
343360
if (applyCellAbsScale) {
344361
amplitude *= getAbsCellScale(cell.cellNumber());
345362
}
363+
if (applyTempCalib) {
364+
amplitude *= mTempCalibExtractor->getGainCalibFactor(static_cast<uint16_t>(cell.cellNumber()));
365+
}
346366
cellsBC.emplace_back(cell.cellNumber(),
347367
amplitude,
348368
cell.time() + getCellTimeShift(cell.cellNumber(), amplitude, o2::emcal::intToChannelType(cell.cellType()), runNumber),
@@ -565,6 +585,11 @@ struct EmcalCorrectionTask {
565585
// get run number
566586
runNumber = bc.runNumber();
567587

588+
if (applyTempCalib && !mIsTempCalibInitialized) { // needs to be called once
589+
mTempCalibExtractor->InitializeFromCCDB(pathTempCalibCCDB, static_cast<uint64_t>(runNumber));
590+
mIsTempCalibInitialized = true;
591+
}
592+
568593
auto collisionsInBC = collisions.sliceBy(collisionsPerBC, bc.globalIndex());
569594
auto cellsInBC = cells.sliceBy(cellsPerFoundBC, bc.globalIndex());
570595

@@ -578,9 +603,16 @@ struct EmcalCorrectionTask {
578603
std::vector<o2::emcal::Cell> cellsBC;
579604
std::vector<int64_t> cellIndicesBC;
580605
for (const auto& cell : cellsInBC) {
606+
auto amplitude = cell.amplitude();
607+
if (static_cast<bool>(hasShaperCorrection) && emcal::intToChannelType(cell.cellType()) == emcal::ChannelType_t::LOW_GAIN) { // Apply shaper correction to LG cells
608+
amplitude = o2::emcal::NonlinearityHandler::evaluateShaperCorrectionCellEnergy(amplitude);
609+
}
610+
if (applyTempCalib) {
611+
amplitude *= mTempCalibExtractor->getGainCalibFactor(static_cast<uint16_t>(cell.cellNumber()));
612+
}
581613
cellsBC.emplace_back(cell.cellNumber(),
582-
cell.amplitude(),
583-
cell.time() + getCellTimeShift(cell.cellNumber(), cell.amplitude(), o2::emcal::intToChannelType(cell.cellType()), runNumber),
614+
amplitude,
615+
cell.time() + getCellTimeShift(cell.cellNumber(), amplitude, o2::emcal::intToChannelType(cell.cellType()), runNumber),
584616
o2::emcal::intToChannelType(cell.cellType()));
585617
cellIndicesBC.emplace_back(cell.globalIndex());
586618
}

0 commit comments

Comments
 (0)