Skip to content

Commit 5861449

Browse files
authored
[PWGJE] [PWGJE]Add cell time smearing in MC (#8697)
1 parent 7ef5f9c commit 5861449

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

PWGJE/TableProducer/emcalCorrectionTask.cxx

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <string>
2323
#include <tuple>
2424
#include <vector>
25+
#include <random>
2526

2627
#include "CCDB/BasicCCDBManager.h"
2728
#include "Framework/runDataProcessing.h"
@@ -90,7 +91,7 @@ struct EmcalCorrectionTask {
9091
Configurable<float> exoticCellInCrossMinAmplitude{"exoticCellInCrossMinAmplitude", 0.1, "Minimum energy of cells in cross, if lower not considered in cross"};
9192
Configurable<bool> useWeightExotic{"useWeightExotic", false, "States if weights should be used for exotic cell cut"};
9293
Configurable<bool> isMC{"isMC", false, "States if run over MC"};
93-
Configurable<int> applyCellTimeShift{"applyCellTimeShift", 0, "apply shift to the cell time for data and MC; For data: 0 = off; non-zero = log function extracted from data - For MC: 0 = off; 1 = const shift; 2 = eta-dependent shift"};
94+
Configurable<bool> applyCellTimeCorrection{"applyCellTimeCorrection", true, "apply a correction to the cell time for data and MC: Shift both average cell times to 0 and smear MC time distribution to fit data better"};
9495

9596
// Require EMCAL cells (CALO type 1)
9697
Filter emccellfilter = aod::calo::caloType == selectedCellType;
@@ -112,6 +113,11 @@ struct EmcalCorrectionTask {
112113
// QA
113114
o2::framework::HistogramRegistry mHistManager{"EMCALCorrectionTaskQAHistograms"};
114115

116+
// Random number generator to draw cell time smearing for MC
117+
std::random_device rd{};
118+
std::mt19937_64 rdgen{rd()};
119+
std::normal_distribution<> normalgaus{0, 1}; // mean = 0, stddev = 1 (apply amplitude of smearing after drawing random for performance reasons)
120+
115121
// EMCal geometry
116122
o2::emcal::Geometry* geometry;
117123

@@ -189,8 +195,9 @@ struct EmcalCorrectionTask {
189195
mHistManager.add("hCellE", "hCellE", o2HistType::kTH1F, {energyAxis});
190196
mHistManager.add("hCellTowerID", "hCellTowerID", o2HistType::kTH1D, {{20000, 0, 20000}});
191197
mHistManager.add("hCellEtaPhi", "hCellEtaPhi", o2HistType::kTH2F, {etaAxis, phiAxis});
198+
mHistManager.add("hCellTimeEnergy", "hCellTime", o2HistType::kTH2F, {{300, -30, 30}, {200, 0., 20.}});
192199
// NOTE: Reversed column and row because it's more natural for presentation.
193-
mHistManager.add("hCellRowCol", "hCellRowCol;Column;Row", o2HistType::kTH2D, {{97, 0, 97}, {600, 0, 600}});
200+
mHistManager.add("hCellRowCol", "hCellRowCol;Column;Row", o2HistType::kTH2D, {{96, -0.5, 95.5}, {208, -0.5, 207.5}});
194201
mHistManager.add("hClusterE", "hClusterE", o2HistType::kTH1F, {energyAxis});
195202
mHistManager.add("hClusterNLM", "hClusterNLM", o2HistType::kTH1F, {nlmAxis});
196203
mHistManager.add("hClusterEtaPhi", "hClusterEtaPhi", o2HistType::kTH2F, {etaAxis, phiAxis});
@@ -770,6 +777,7 @@ struct EmcalCorrectionTask {
770777
// For convenience, use the clusterizer stored geometry to get the eta-phi
771778
for (auto& cell : cellsBC) {
772779
mHistManager.fill(HIST("hCellE"), cell.getEnergy());
780+
mHistManager.fill(HIST("hCellTimeEnergy"), cell.getTimeStamp(), cell.getEnergy());
773781
mHistManager.fill(HIST("hCellTowerID"), cell.getTower());
774782
auto res = mClusterizers.at(0)->getGeometry()->EtaPhiFromIndex(cell.getTower());
775783
mHistManager.fill(HIST("hCellEtaPhi"), std::get<0>(res), TVector2::Phi_0_2pi(std::get<1>(res)));
@@ -801,33 +809,29 @@ struct EmcalCorrectionTask {
801809
// In data this is done to correct for the time walk effect
802810
float getCellTimeShift(const int16_t cellID, const float cellEnergy)
803811
{
812+
if (!applyCellTimeCorrection) {
813+
return 0.f;
814+
}
815+
float timeshift = 0.f;
816+
float timesmear = 0.f;
804817
if (isMC) {
805-
if (applyCellTimeShift == 1) { // constant shift
806-
LOG(debug) << "shift the cell time by 15ns";
807-
return -15.f; // roughly calculated by assuming particles travel with v=c (photons) and EMCal is 4.4m away from vertex
808-
} else if (applyCellTimeShift == 2) { // eta dependent shift ( as larger eta values are further away from collision point)
809-
// Use distance between vertex and EMCal (at eta = 0) and distance on EMCal surface (cell size times column) to calculate distance to cell
810-
// 0.2 is cell size in m (0.06) divided by the speed of light in m/ns (0.3)
811-
// 47.5 is the "middle" of the EMCal (2*48 cells in one column)
812-
float timeCol = 0.2f * (geometry->GlobalCol(cellID) - 47.5f); // calculate time to get to specific column
813-
float time = -sqrt(215.f + timeCol * timeCol); // 215 is 14.67ns^2 (time it takes to get the cell at eta = 0)
814-
LOG(debug) << "shift the cell time by " << time << " applyCellTimeShift " << applyCellTimeShift;
815-
return time;
816-
} else {
817-
return 0.f;
818-
}
819-
} else { // data
820-
if (applyCellTimeShift != 0) {
821-
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
822-
return 0.f;
823-
else if (cellEnergy < 4.) // Low energy regime
824-
return (0.57284 + 0.82194 * TMath::Log(1.30651 * cellEnergy)); // Parameters extracted from LHC22o (pp), but also usable for other periods
825-
else // High energy regime
826-
return (-0.05858 + 1.50593 * TMath::Log(0.97591 * cellEnergy)); // Parameters extracted from LHC22o (pp), but also usable for other periods
827-
} else { // Dont apply cell time shift if applyCellTimeShift == 0
828-
return 0.f;
829-
}
818+
// Shift the time to 0, as the TOF was simulated -> eta dependent shift (as larger eta values are further away from collision point)
819+
// Use distance between vertex and EMCal (at eta = 0) and distance on EMCal surface (cell size times column) to calculate distance to cell
820+
// 0.2 is cell size in m (0.06) divided by the speed of light in m/ns (0.3) - 47.5 is the "middle" of the EMCal (2*48 cells in one column)
821+
float timeCol = 0.2f * (geometry->GlobalCol(cellID) - 47.5f); // calculate time to get to specific column
822+
timeshift = -sqrt(215.f + timeCol * timeCol); // 215 is 14.67ns^2 (time it takes to get the cell at eta = 0)
823+
// Also smear the time to account for the broader time resolution in data than in MC
824+
timesmear = normalgaus(rdgen) * (1.6 + 9.5 * TMath::Exp(-3. * cellEnergy)); // Parameters extracted from LHC22o (pp), but also usable for other periods
825+
} else { // data
826+
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
827+
timeshift = 0.;
828+
else if (cellEnergy < 4.) // Low energy regime
829+
timeshift = 0.57284 + 0.82194 * TMath::Log(1.30651 * cellEnergy); // Parameters extracted from LHC22o (pp), but also usable for other periods
830+
else // High energy regime
831+
timeshift = -0.05858 + 1.50593 * TMath::Log(0.97591 * cellEnergy); // Parameters extracted from LHC22o (pp), but also usable for other periods
830832
}
833+
LOG(debug) << "Shift the cell time by " << timeshift << " + " << timesmear << " ns";
834+
return timeshift + timesmear;
831835
}
832836
};
833837

0 commit comments

Comments
 (0)