Skip to content

Commit 8280dc9

Browse files
sawenzelalcaliva
authored andcommitted
TPC digi: Cut digits arriving before timeframe/readout start
Relates to https://its.cern.ch/jira/browse/O2-5395 and should allow to treat correctly events coming before the timeframe start to reduce the startup effect in MC. (cherry picked from commit 81baf91)
1 parent 1f9e13d commit 8280dc9

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Detectors/TPC/simulation/include/TPCSimulation/SAMPAProcessing.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@ inline float SAMPAProcessing::getZfromTimeBin(float timeBin, Side s) const
258258

259259
inline TimeBin SAMPAProcessing::getTimeBinFromTime(float time) const
260260
{
261+
if (time < 0.f) {
262+
// protection and convention for negative times (otherwise overflow)
263+
return 0;
264+
}
261265
return static_cast<TimeBin>(time / mEleParam->ZbinWidth);
262266
}
263267

Detectors/TPC/simulation/src/Digitizer.cxx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ void Digitizer::process(const std::vector<o2::tpc::HitGroup>& hits,
111111
}
112112
const float absoluteTime = eleTime + mTDriftOffset + (mEventTime - mOutputDigitTimeOffset); /// in us
113113

114+
/// the absolute time needs to be within the readout limits
115+
/// (otherwise negative times would all be accumulated in the 0-th timebin further below)
116+
if (!(absoluteTime >= 0 /* && absoluteTime <= timeframelength */)) {
117+
continue;
118+
}
119+
114120
/// Attachment
115121
if (electronTransport.isElectronAttachment(driftTime)) {
116122
continue;
@@ -217,9 +223,14 @@ void Digitizer::setUseSCDistortions(std::string_view finp)
217223

218224
void Digitizer::setStartTime(double time)
219225
{
226+
// this is setting the first timebin index for the digit container
227+
// note that negative times w.r.t start of timeframe/data-taking == mOutputDigitTimeOffset
228+
// will yield the 0-th bin (due to casting logic in sampaProcessing)
220229
SAMPAProcessing& sampaProcessing = SAMPAProcessing::instance();
221230
sampaProcessing.updateParameters(mVDrift);
222-
mDigitContainer.setStartTime(sampaProcessing.getTimeBinFromTime(time - mOutputDigitTimeOffset));
231+
const auto timediff = time - mOutputDigitTimeOffset;
232+
const auto starttimebin = sampaProcessing.getTimeBinFromTime(timediff);
233+
mDigitContainer.setStartTime(starttimebin);
223234
}
224235

225236
void Digitizer::setLumiScaleFactor()

0 commit comments

Comments
 (0)