diff --git a/PWGJE/TableProducer/CMakeLists.txt b/PWGJE/TableProducer/CMakeLists.txt index 5413eef70db..31e50dab3cf 100644 --- a/PWGJE/TableProducer/CMakeLists.txt +++ b/PWGJE/TableProducer/CMakeLists.txt @@ -93,7 +93,7 @@ endif() o2physics_add_dpl_workflow(emcal-correction-task SOURCES emcalCorrectionTask.cxx - PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase O2::EMCALBase O2::EMCALReconstruction + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase O2::EMCALBase O2::EMCALReconstruction O2::EMCALCalibration COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(emcal-matchedtracks-writer diff --git a/PWGJE/TableProducer/emcalCorrectionTask.cxx b/PWGJE/TableProducer/emcalCorrectionTask.cxx index 8b114289992..73da05e5d52 100644 --- a/PWGJE/TableProducer/emcalCorrectionTask.cxx +++ b/PWGJE/TableProducer/emcalCorrectionTask.cxx @@ -35,6 +35,7 @@ #include "EMCALBase/ClusterFactory.h" #include "EMCALBase/Geometry.h" #include "EMCALBase/NonlinearityHandler.h" +#include "EMCALCalibration/EMCALTempCalibExtractor.h" #include "EMCALReconstruction/Clusterizer.h" #include "Framework/ASoA.h" #include "Framework/AnalysisDataModel.h" @@ -113,6 +114,9 @@ struct EmcalCorrectionTask { Configurable 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."}; Configurable fillQA{"fillQA", false, "Switch to turn on QA histograms."}; Configurable 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."}; + Configurable applyTempCalib{"applyTempCalib", false, "Switch to turn on Temperature calibration."}; + Configurable 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 + Configurable useTempCalibMean{"useTempCalibMean", false, "Switch to turn on Temperature mean calculation instead of median."}; // Require EMCAL cells (CALO type 1) Filter emccellfilter = aod::calo::caloType == selectedCellType; @@ -142,6 +146,10 @@ struct EmcalCorrectionTask { // EMCal geometry o2::emcal::Geometry* geometry; + // EMCal cell temperature calibrator + std::unique_ptr mTempCalibExtractor; + bool mIsTempCalibInitialized = false; + std::vector> mExtraTimeShiftRunRanges; // Current run number @@ -171,6 +179,10 @@ struct EmcalCorrectionTask { geometry->SetMisalMatrixFromCcdb(); } + if (applyTempCalib) { + mTempCalibExtractor = std::make_unique(); + } + // read all the cluster definitions specified in the options if (clusterDefinitions->length()) { std::stringstream parser(clusterDefinitions.value); @@ -316,6 +328,11 @@ struct EmcalCorrectionTask { // get run number runNumber = bc.runNumber(); + if (applyTempCalib && !mIsTempCalibInitialized) { // needs to be called once + mTempCalibExtractor->InitializeFromCCDB(pathTempCalibCCDB, static_cast(runNumber)); + mIsTempCalibInitialized = true; + } + // Convert aod::Calo to o2::emcal::Cell which can be used with the clusterizer. // In particular, we need to filter only EMCAL cells. @@ -343,6 +360,9 @@ struct EmcalCorrectionTask { if (applyCellAbsScale) { amplitude *= getAbsCellScale(cell.cellNumber()); } + if (applyTempCalib) { + amplitude *= mTempCalibExtractor->getGainCalibFactor(static_cast(cell.cellNumber())); + } cellsBC.emplace_back(cell.cellNumber(), amplitude, cell.time() + getCellTimeShift(cell.cellNumber(), amplitude, o2::emcal::intToChannelType(cell.cellType()), runNumber), @@ -565,6 +585,11 @@ struct EmcalCorrectionTask { // get run number runNumber = bc.runNumber(); + if (applyTempCalib && !mIsTempCalibInitialized) { // needs to be called once + mTempCalibExtractor->InitializeFromCCDB(pathTempCalibCCDB, static_cast(runNumber)); + mIsTempCalibInitialized = true; + } + auto collisionsInBC = collisions.sliceBy(collisionsPerBC, bc.globalIndex()); auto cellsInBC = cells.sliceBy(cellsPerFoundBC, bc.globalIndex()); @@ -578,9 +603,16 @@ struct EmcalCorrectionTask { std::vector cellsBC; std::vector cellIndicesBC; for (const auto& cell : cellsInBC) { + auto amplitude = cell.amplitude(); + if (static_cast(hasShaperCorrection) && emcal::intToChannelType(cell.cellType()) == emcal::ChannelType_t::LOW_GAIN) { // Apply shaper correction to LG cells + amplitude = o2::emcal::NonlinearityHandler::evaluateShaperCorrectionCellEnergy(amplitude); + } + if (applyTempCalib) { + amplitude *= mTempCalibExtractor->getGainCalibFactor(static_cast(cell.cellNumber())); + } cellsBC.emplace_back(cell.cellNumber(), - cell.amplitude(), - cell.time() + getCellTimeShift(cell.cellNumber(), cell.amplitude(), o2::emcal::intToChannelType(cell.cellType()), runNumber), + amplitude, + cell.time() + getCellTimeShift(cell.cellNumber(), amplitude, o2::emcal::intToChannelType(cell.cellType()), runNumber), o2::emcal::intToChannelType(cell.cellType())); cellIndicesBC.emplace_back(cell.globalIndex()); }