Skip to content

Commit 093db2b

Browse files
mfasDasawenzel
authored andcommitted
[EMCAL-518] Handling of TOF in time sampling
- Add templates for different TOF to the EMCAL surface - Limit accepted TOF to the EMCAL readout window - Resolution 1 ns for 1.5 mus (1500 templates per phase) - Do not do SDigitization when sampling for different Time-of-flight, as delays in the same tower can be sufficiently different
1 parent b1f612c commit 093db2b

4 files changed

Lines changed: 51 additions & 15 deletions

File tree

Detectors/EMCAL/simulation/include/EMCALSimulation/Digitizer.h

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,28 @@ class Digitizer : public TObject
9494
const std::vector<o2::emcal::TriggerRecord>& getTriggerRecords() const { return mDigits.getTriggerRecords(); }
9595
const o2::dataformats::MCTruthContainer<o2::emcal::MCLabel>& getMCLabels() const { return mDigits.getMCLabels(); }
9696

97+
static constexpr int getTOFSamplingBins() { return EMC_TOF_BINS; }
98+
9799
private:
98-
static constexpr int EMC_PHASES = 4; ///< Number of phases
99-
short mEventTimeOffset = 0; ///< event time difference from trigger time (in number of bins)
100-
short mPhase = 0; ///< event phase
101-
UInt_t mROFrameMin = 0; ///< lowest RO frame of current digits
102-
UInt_t mROFrameMax = 0; ///< highest RO frame of current digits
103-
bool mSmearEnergy = true; ///< do time and energy smearing
104-
bool mSimulateTimeResponse = true; ///< simulate time response
105-
const SimParam* mSimParam = nullptr; ///< SimParam object
100+
using TimeSampleContainer = std::array<double, constants::EMCAL_MAXTIMEBINS>;
101+
static constexpr int EMC_PHASES = 4; ///< Number of phases
102+
static constexpr int EMC_TOF_BINS = 1500; ///< Number of bins in TOF sampling of the time response
103+
static constexpr double EMC_TOF_MIN = 0; ///< Min TOF
104+
static constexpr double EMC_TOF_MAX = 1500.; ///< Max TOF
105+
static constexpr double EMC_TOF_BINWITH = (EMC_TOF_MAX - EMC_TOF_MIN) / EMC_TOF_BINS; ///< Number time samples simulated
106+
short mEventTimeOffset = 0; ///< event time difference from trigger time (in number of bins)
107+
short mPhase = 0; ///< event phase
108+
UInt_t mROFrameMin = 0; ///< lowest RO frame of current digits
109+
UInt_t mROFrameMax = 0; ///< highest RO frame of current digits
110+
bool mSmearEnergy = true; ///< do time and energy smearing
111+
bool mSimulateTimeResponse = true; ///< simulate time response
112+
const SimParam* mSimParam = nullptr; ///< SimParam object
106113

107114
std::vector<Digit> mTempDigitVector; ///< temporary digit storage
108115
o2::emcal::DigitsWriteoutBuffer mDigits; ///< used to sort digits and labels by tower
109116

110117
TRandom3* mRandomGenerator = nullptr; ///< random number generator
111-
std::array<std::array<double, constants::EMCAL_MAXTIMEBINS>, EMC_PHASES>
118+
std::array<std::array<TimeSampleContainer, EMC_TOF_BINS>, EMC_PHASES>
112119
mAmplitudeInTimeBins; ///< template of the sampled time response function: amplitude of signal for each time bin (per phase)
113120

114121
std::unique_ptr<o2::utils::TreeStreamRedirector> mDebugStream = nullptr;

Detectors/EMCAL/simulation/src/Digitizer.cxx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,12 @@ void Digitizer::init()
6464
// parameter 1: Handling phase + delay
6565
// phase: 25 ns * phase index (-4)
6666
// delay: Average signal delay
67-
RawResponse.SetParameter(1, 0.25 * phase + mSimParam->getSignalDelay() / constants::EMCAL_TIMESAMPLE);
68-
for (int sample = 0; sample < constants::EMCAL_MAXTIMEBINS; sample++) {
69-
mAmplitudeInTimeBins[phase][sample] = RawResponse.Eval(sample);
67+
for (int itofbin = 0; itofbin < EMC_TOF_BINS; itofbin++) {
68+
double tofbincenter = itofbin * EMC_TOF_BINWITH + 0.5 * EMC_TOF_BINWITH;
69+
RawResponse.SetParameter(1, 0.25 * phase + (tofbincenter + mSimParam->getSignalDelay()) / constants::EMCAL_TIMESAMPLE);
70+
for (int sample = 0; sample < constants::EMCAL_MAXTIMEBINS; sample++) {
71+
mAmplitudeInTimeBins[phase][itofbin][sample] = RawResponse.Eval(sample);
72+
}
7073
}
7174
}
7275
} else {
@@ -158,15 +161,29 @@ void Digitizer::sampleSDigit(const Digit& sDigit)
158161

159162
Double_t energies[15];
160163
if (mSimulateTimeResponse) {
161-
for (int sample = 0; sample < mAmplitudeInTimeBins[mPhase].size(); sample++) {
164+
if (sDigit.getTimeStamp() + mSimParam->getSignalDelay() + mPhase * 25 > EMC_TOF_MAX) {
165+
// Digit time larger than sampling window, will not be sampled
166+
// For time response simulation take also signal delay and phase into account
167+
return;
168+
}
169+
int tofbin = static_cast<int>(sDigit.getTimeStamp() / EMC_TOF_BINWITH);
170+
if (tofbin >= EMC_TOF_BINS) {
171+
tofbin = EMC_TOF_BINS - 1;
172+
}
173+
for (int sample = 0; sample < mAmplitudeInTimeBins[mPhase][tofbin].size(); sample++) {
162174

163-
double val = energy * (mAmplitudeInTimeBins[mPhase][sample]);
175+
double val = energy * (mAmplitudeInTimeBins[mPhase][tofbin][sample]);
164176
energies[sample] = val;
165177
double digitTime = mEventTimeOffset * constants::EMCAL_TIMESAMPLE;
166178
Digit digit(tower, val, digitTime);
167179
mTempDigitVector.push_back(digit);
168180
}
169181
} else {
182+
if (sDigit.getTimeStamp() > EMC_TOF_MAX) {
183+
// Digit time larger than sampling window, will not be sampled
184+
// In non-sampled mode only apply the max. time window
185+
return;
186+
}
170187
Digit digit(tower, energy, smearTime(sDigit.getTimeStamp(), energy));
171188
mTempDigitVector.push_back(digit);
172189
}

Detectors/EMCAL/workflow/include/EMCALWorkflow/EMCALDigitizerSpec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class DigitizerSpec final : public o2::base::BaseDPLDigitizer, public o2::framew
7070
private:
7171
Bool_t mFinished = false; ///< Flag for digitization finished
7272
bool mIsConfigured = false; ///< Initialization status of the digitizer
73+
bool mRunSDitizer = false; ///< Run SDigitization
7374
Digitizer mDigitizer; ///< Digitizer object
7475
o2::emcal::SDigitizer mSumDigitizer; ///< Summed digitizer
7576
std::shared_ptr<CalibLoader> mCalibHandler; ///< Handler of calibration objects

Detectors/EMCAL/workflow/src/EMCALDigitizerSpec.cxx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,18 @@ void DigitizerSpec::run(framework::ProcessingContext& ctx)
119119

120120
LOG(info) << "For collision " << collID << " eventID " << part.entryID << " found " << mHits.size() << " hits ";
121121

122-
std::vector<o2::emcal::LabeledDigit> summedDigits = mSumDigitizer.process(mHits);
122+
std::vector<o2::emcal::LabeledDigit> summedDigits;
123+
if (mRunSDitizer) {
124+
summedDigits = mSumDigitizer.process(mHits);
125+
} else {
126+
for (auto& hit : mHits) {
127+
o2::emcal::MCLabel digitlabel(hit.GetTrackID(), part.entryID, part.sourceID, false, 1.);
128+
if (hit.GetEnergyLoss() < __DBL_EPSILON__) {
129+
digitlabel.setAmplitudeFraction(0);
130+
}
131+
summedDigits.emplace_back(hit.GetDetectorID(), hit.GetEnergyLoss(), hit.GetTime(), digitlabel);
132+
}
133+
}
123134

124135
// call actual digitization procedure
125136
mDigitizer.process(summedDigits);

0 commit comments

Comments
 (0)