Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions PWGJE/TableProducer/emcalCorrectionTask.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "EMCALBase/ClusterFactory.h"
#include "EMCALBase/Geometry.h"
#include "EMCALBase/NonlinearityHandler.h"
#include "EMCALCalib/GainCalibrationFactors.h"
#include "EMCALCalibration/EMCALTempCalibExtractor.h"
#include "EMCALReconstruction/Clusterizer.h"
#include "Framework/ASoA.h"
Expand Down Expand Up @@ -118,6 +119,7 @@
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
Configurable<bool> useTempCalibMean{"useTempCalibMean", false, "Switch to turn on Temperature mean calculation instead of median."};
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."};
Configurable<bool> applyGainCalibShift{"applyGainCalibShift", false, "Apply shift for cell gain calibration to use values before cell format change (Sept. 2023)"};

// Require EMCAL cells (CALO type 1)
Filter emccellfilter = aod::calo::caloType == selectedCellType;
Expand Down Expand Up @@ -151,6 +153,9 @@
std::unique_ptr<o2::emcal::EMCALTempCalibExtractor> mTempCalibExtractor;
bool mIsTempCalibInitialized = false;

// Gain calibration
std::array<float, 17664> mArrGainCalibDiff;

std::vector<std::pair<int, int>> mExtraTimeShiftRunRanges;

// Current run number
Expand Down Expand Up @@ -184,6 +189,11 @@
mTempCalibExtractor = std::make_unique<o2::emcal::EMCALTempCalibExtractor>();
}

// gain calibration shift initialization
if (applyGainCalibShift) {
initializeGainCalibShift();
}

// read all the cluster definitions specified in the options
if (clusterDefinitions->length()) {
std::stringstream parser(clusterDefinitions.value);
Expand Down Expand Up @@ -228,11 +238,11 @@

// Define the cell energy binning
std::vector<double> cellEnergyBins;
for (int i = 0; i < 51; i++)

Check failure on line 241 in PWGJE/TableProducer/emcalCorrectionTask.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
cellEnergyBins.emplace_back(0.1 * (i - 0) + 0.0); // from 0 to 5 GeV/c, every 0.1 GeV
for (int i = 51; i < 76; i++)

Check failure on line 243 in PWGJE/TableProducer/emcalCorrectionTask.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
cellEnergyBins.emplace_back(0.2 * (i - 51) + 5.2); // from 5.2 to 10.0 GeV, every 0.2 GeV
for (int i = 76; i < 166; i++)

Check failure on line 245 in PWGJE/TableProducer/emcalCorrectionTask.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
cellEnergyBins.emplace_back(1. * (i - 76) + 11.); // from 11.0 to 100. GeV, every 1 GeV

// Setup QA hists.
Expand Down Expand Up @@ -361,6 +371,9 @@
if (applyCellAbsScale) {
amplitude *= getAbsCellScale(cell.cellNumber());
}
if (applyGainCalibShift) {
amplitude *= mArrGainCalibDiff[cell.cellNumber()];
}
if (applyTempCalib) {
amplitude *= mTempCalibExtractor->getGainCalibFactor(static_cast<uint16_t>(cell.cellNumber()));
}
Expand Down Expand Up @@ -611,6 +624,9 @@
if (static_cast<bool>(hasShaperCorrection) && emcal::intToChannelType(cell.cellType()) == emcal::ChannelType_t::LOW_GAIN) { // Apply shaper correction to LG cells
amplitude = o2::emcal::NonlinearityHandler::evaluateShaperCorrectionCellEnergy(amplitude);
}
if (applyGainCalibShift) {
amplitude *= mArrGainCalibDiff[cell.cellNumber()];
}
if (applyTempCalib) {
amplitude *= mTempCalibExtractor->getGainCalibFactor(static_cast<uint16_t>(cell.cellNumber()));
}
Expand Down Expand Up @@ -711,7 +727,7 @@
void fillClusterTable(Collision const& col, math_utils::Point3D<float> const& vertexPos, size_t iClusterizer, const gsl::span<int64_t> cellIndicesBC, const std::tuple<std::vector<std::vector<int>>, std::vector<std::vector<int>>>* indexMapPair = nullptr, const std::vector<int64_t>* trackGlobalIndex = nullptr)
{
// average number of cells per cluster, only used the reseve a reasonable amount for the clustercells table
const size_t NAvgNcells = 3;

Check failure on line 730 in PWGJE/TableProducer/emcalCorrectionTask.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[name/function-variable]

Use lowerCamelCase for names of functions and variables.
// we found a collision, put the clusters into the none ambiguous table
clusters.reserve(mAnalysisClusters.size());
if (!mClusterLabels.empty()) {
Expand Down Expand Up @@ -888,7 +904,7 @@
}
// Tracks that do not point to the EMCal/DCal/PHOS get default values of -999
// This way we can cut out tracks that do not point to the EMCal+DCal
if (track.trackEtaEmcal() < -900 || track.trackPhiEmcal() < -900) {

Check failure on line 907 in PWGJE/TableProducer/emcalCorrectionTask.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
continue;
}
if (trackMinPt > 0 && track.pt() < trackMinPt) {
Expand Down Expand Up @@ -954,7 +970,7 @@
return cellAbsScaleFactors.value[mClusterizers.at(0)->getGeometry()->GetSMType(iSM)];

// Apply cell scale based on columns to accoutn for material of TRD structures
} else if (applyCellAbsScale == 2) {

Check failure on line 973 in PWGJE/TableProducer/emcalCorrectionTask.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
auto res = mClusterizers.at(0)->getGeometry()->GlobalRowColFromIndex(cellID);
return cellAbsScaleFactors.value[std::get<1>(res)];
} else {
Expand All @@ -980,7 +996,7 @@
timeshift = -std::sqrt(215.f + timeCol * timeCol); // 215 is 14.67ns^2 (time it takes to get the cell at eta = 0)

// Also smear the time to account for the broader time resolution in data than in MC
if (cellEnergy < 0.3) // Cells with tless than 300 MeV cannot be the leading cell in the cluster, so their time does not require precise calibration

Check failure on line 999 in PWGJE/TableProducer/emcalCorrectionTask.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
timesmear = 0.; // They will therefore not be smeared and only get their shift
else if (cellType == emcal::ChannelType_t::HIGH_GAIN) // High gain cells -> Low energies
timesmear = normalgaus(rdgen) * (1.6 + 9.5 * std::exp(-3. * cellEnergy)); // Parameters extracted from LHC24f3b & LHC22o (pp), but also usable for other periods
Expand All @@ -988,15 +1004,15 @@
timesmear = normalgaus(rdgen) * (5.0); // Parameters extracted from LHC24g4 & LHC24aj (pp), but also usable for other periods

} else { // ---> Data
if (cellEnergy < 0.3) { // Cells with tless than 300 MeV cannot be the leading cell in the cluster, so their time does not require precise calibration

Check failure on line 1007 in PWGJE/TableProducer/emcalCorrectionTask.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
timeshift = 0.; // In data they will not be shifted (they are close to 0 anyways)
} else if (cellType == emcal::ChannelType_t::HIGH_GAIN) { // High gain cells -> Low energies
if (cellEnergy < 4.) // Low energy regime

Check failure on line 1010 in PWGJE/TableProducer/emcalCorrectionTask.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
timeshift = 0.8 * std::log(2.7 * cellEnergy); // Parameters extracted from LHC22o (pp), but also usable for other periods
else // Medium energy regime
timeshift = 1.5 * std::log(0.9 * cellEnergy); // Parameters extracted from LHC22o (pp), but also usable for other periods
} else if (cellType == emcal::ChannelType_t::LOW_GAIN) { // Low gain cells -> High energies
if (cellEnergy < 30.) // High energy regime

Check failure on line 1015 in PWGJE/TableProducer/emcalCorrectionTask.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
timeshift = 1.9 * std::log(0.09 * cellEnergy); // Parameters extracted from LHC24aj (pp), but also usable for other periods
else // Very high energy regime
timeshift = 1.9; // Parameters extracted from LHC24aj (pp), but also usable for other periods
Expand All @@ -1013,6 +1029,18 @@
}
return timeshift + timesmear;
};

void initializeGainCalibShift()
{
auto& ccdbMgr = o2::ccdb::BasicCCDBManager::instance();
uint64_t tsOld = 1634853602000; // timestamp corresponding to LHC22o old gain calib object
o2::emcal::GainCalibrationFactors* paramsOld = ccdbMgr.getForTimeStamp<o2::emcal::GainCalibrationFactors>("EMC/Calib/GainCalibFactors", tsOld);
uint64_t tsNew = 1734853602000; // timestamp corresponding to new gain calib object (new cell compression)
o2::emcal::GainCalibrationFactors* paramsNew = ccdbMgr.getForTimeStamp<o2::emcal::GainCalibrationFactors>("EMC/Calib/GainCalibFactors", tsNew);
for (uint16_t i = 0; i < mArrGainCalibDiff.size(); ++i) {
mArrGainCalibDiff[i] = paramsOld->getGainCalibFactors(i) == 0 ? 1. : paramsNew->getGainCalibFactors(i) / paramsOld->getGainCalibFactors(i);
}
}
};

WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
Expand Down
Loading