Skip to content

Commit ff3f5b3

Browse files
authored
TOF digitizer: Ability to process events happening before timeframe start (#13572)
Relates to https://its.cern.ch/jira/browse/O2-5395 This commit makes sure that TOF digitization treats correctly events happening before timeframe start: - cut away hits from events much before first readout frame - allow to pickup hits from events happening just before the first readout frame (due to time of flight) some slight code reorganization: - introduce a getReadoutWindow function for reuse - introduce a constant for maximal time of flight of hits
1 parent 015c38a commit ff3f5b3

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

Detectors/TOF/base/include/TOFBase/WindowFiller.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ class WindowFiller
104104

105105
protected:
106106
// info TOF timewindow
107-
uint64_t mReadoutWindowCurrent = 0;
108-
InteractionRecord mFirstIR{0, 0}; // reference IR (1st IR of the timeframe)
107+
uint64_t mReadoutWindowCurrent = 0; // keeps track of current readout window
108+
InteractionRecord mFirstIR{0, 0}; // reference IR (1st IR of the timeframe)
109109
InteractionTimeRecord mEventTime;
110110

111111
bool mContinuous = true;

Detectors/TOF/simulation/include/TOFSimulation/Digitizer.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ class Digitizer : public WindowFiller
8383
void setEffBoundary2(float val) { mEffBoundary2 = val; }
8484
void setEffBoundary3(float val) { mEffBoundary3 = val; }
8585

86+
// determines the readout window id, given a time in nanoseconds (relative
87+
// to orbit-reset)
88+
uint64_t getReadoutWindow(double timeNS) const
89+
{
90+
// event time shifted by 2 BC as safe margin before to change current readout window to account for decalibration
91+
return uint64_t((timeNS - Geo::BC_TIME * (Geo::OVERLAP_IN_BC + 2)) * Geo::READOUTWINDOW_INV);
92+
}
93+
8694
private:
8795
// parameters
8896
Int_t mMode;

Detectors/TOF/simulation/include/TOFSimulation/TOFSimParams.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ struct TOFSimParams : public o2::conf::ConfigurableParamHelper<TOFSimParams> {
3333
float eff_boundary2 = 0.833; // efficiency in the pad border
3434
float eff_boundary3 = 0.1; // efficiency in mBound3
3535

36+
float max_hit_time = 1000.; // time cutoff for hits (time of flight); default 1us
37+
3638
O2ParamDef(TOFSimParams, "TOFSimParams");
3739
};
3840

Detectors/TOF/simulation/src/Digitizer.cxx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ void Digitizer::init()
6969
{
7070

7171
// set first readout window in MC production getting
72+
// orbitFirstSampled corresponds to the start of the concrete timeframe (it is set in O2DPG productions)
7273
mReadoutWindowCurrent = uint64_t(o2::raw::HBFUtils::Instance().orbitFirstSampled) * Geo::NWINDOW_IN_ORBIT;
7374

7475
// method to initialize the parameters neede to digitize and the array of strip objects containing
@@ -91,12 +92,21 @@ void Digitizer::init()
9192

9293
int Digitizer::process(const std::vector<HitType>* hits, std::vector<Digit>* digits)
9394
{
95+
const double max_hit_time = TOFSimParams::Instance().max_hit_time;
96+
9497
// hits array of TOF hits for a given simulated event
9598
// digits passed from external to be filled, in continuous readout mode we will push it on mDigitsPerTimeFrame vector of vectors of digits
9699

97100
// printf("process event time = %f with %ld hits\n",mEventTime.getTimeNS(),hits->size());
98101

99-
uint64_t readoutwindow = uint64_t((mEventTime.getTimeNS() - Geo::BC_TIME * (Geo::OVERLAP_IN_BC + 2)) * Geo::READOUTWINDOW_INV); // event time shifted by 2 BC as safe margin before to change current readout window to account for decalibration
102+
uint64_t readoutwindow = getReadoutWindow(mEventTime.getTimeNS());
103+
104+
// determines the maximal readout window difference to a preceding RO which can still affect the current readout window
105+
int max_readout_diff = int(max_hit_time * Geo::READOUTWINDOW_INV) + 1;
106+
// early return based on events happening earlier than MAX_READOUT_DIFF away from current RO frame
107+
if (readoutwindow < mReadoutWindowCurrent && mReadoutWindowCurrent - readoutwindow > max_readout_diff) {
108+
return 0;
109+
}
100110

101111
if (mContinuous && readoutwindow > mReadoutWindowCurrent) { // if we are moving in future readout windows flush previous ones (only for continuous readout mode)
102112
digits->clear();
@@ -110,9 +120,18 @@ int Digitizer::process(const std::vector<HitType>* hits, std::vector<Digit>* dig
110120
for (auto& hit : *hits) {
111121
// TODO: put readout window counting/selection
112122
// neglect very slow particles (low energy neutrons)
113-
if (hit.GetTime() > 1000) { // 1 mus
123+
if (hit.GetTime() > max_hit_time) { // 1 mus
124+
continue;
125+
}
126+
127+
// discard hits arriving before the minimum readout window
128+
auto hit_ro_window = getReadoutWindow(double(hit.GetTime()) + mEventTime.getTimeNS() /*+ Geo::LATENCYWINDOW*/);
129+
130+
// discard hits arriving too early
131+
if (hit_ro_window < mReadoutWindowCurrent) {
114132
continue;
115133
}
134+
116135
processHit(hit, mEventTime.getTimeOffsetWrtBC() + Geo::LATENCYWINDOW);
117136
} // end loop over hits
118137

0 commit comments

Comments
 (0)