Skip to content

Commit 1a49ff8

Browse files
noferinishahor02
authored andcommitted
fix for float truncation affecting timing in large timeframe numbers
1 parent fd22b1c commit 1a49ff8

2 files changed

Lines changed: 11 additions & 18 deletions

File tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ class Geo
6262

6363
static constexpr Int_t RAW_PAGE_MAX_SIZE = 8192;
6464

65-
static constexpr Float_t BC_TIME = o2::constants::lhc::LHCBunchSpacingNS; // bunch crossing in ns
66-
static constexpr Float_t BC_TIME_INV = 1. / BC_TIME; // inv bunch crossing in ns
67-
static constexpr Float_t BC_TIME_INPS = BC_TIME * 1000; // bunch crossing in ps
68-
static constexpr Float_t BC_TIME_INPS_INV = 1. / BC_TIME_INPS; // inv bunch crossing in ps
65+
static constexpr Double_t BC_TIME = o2::constants::lhc::LHCBunchSpacingNS; // bunch crossing in ns
66+
static constexpr Double_t BC_TIME_INV = 1. / BC_TIME; // inv bunch crossing in ns
67+
static constexpr Double_t BC_TIME_INPS = BC_TIME * 1000; // bunch crossing in ps
68+
static constexpr Double_t BC_TIME_INPS_INV = 1. / BC_TIME_INPS; // inv bunch crossing in ps
6969
static constexpr int BC_IN_ORBIT = o2::constants::lhc::LHCMaxBunches; // N. bunch crossing in 1 orbit
7070

7171
static constexpr Int_t NPADX = 48;

Detectors/TOF/simulation/src/Digitizer.cxx

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -271,16 +271,19 @@ void Digitizer::addDigit(Int_t channel, UInt_t istrip, Double_t time, Float_t x,
271271
// Decalibrate
272272
time -= mCalibApi->getTimeDecalibration(channel, tot); //TODO: to be checked that "-" is correct, and we did not need "+" instead :-)
273273

274+
// let's move from time to bc, tdc
275+
274276
Int_t nbc = Int_t(time * Geo::BC_TIME_INPS_INV); // time elapsed in number of bunch crossing
275277
//Digit newdigit(time, channel, (time - Geo::BC_TIME_INPS * nbc) * Geo::NTDCBIN_PER_PS, tot * Geo::NTOTBIN_PER_NS, nbc);
276278

277279
int tdc = int((time - Geo::BC_TIME_INPS * nbc) * Geo::NTDCBIN_PER_PS);
278280

279281
// additional check to avoid very rare truncation
280-
if (tdc < 0) {
282+
while (tdc < 0) {
281283
nbc--;
282284
tdc += 1024;
283-
} else if (tdc >= 1024) {
285+
}
286+
while (tdc >= 1024) {
284287
nbc++;
285288
tdc -= 1024;
286289
}
@@ -353,12 +356,7 @@ void Digitizer::addDigit(Int_t channel, UInt_t istrip, Double_t time, Float_t x,
353356
mcTruthContainer = mMCTruthContainerNext[isnext - 1];
354357
}
355358

356-
int eventcounter = mReadoutWindowCurrent + isnext;
357-
int hittimeTDC = (nbc - eventcounter * Geo::BC_IN_WINDOW) * 1024 + tdc; // time in TDC bin within the TOF WINDOW
358-
if (hittimeTDC < 0)
359-
LOG(ERROR) << "1) Negative hit " << hittimeTDC << ", something went wrong in filling readout window: isnext=" << isnext << ", isIfOverlap=" << isIfOverlap;
360-
else
361-
fillDigitsInStrip(strips, mcTruthContainer, channel, tdc, tot, nbc, istrip, trackID, mEventID, mSrcID);
359+
fillDigitsInStrip(strips, mcTruthContainer, channel, tdc, tot, nbc, istrip, trackID, mEventID, mSrcID);
362360

363361
if (isIfOverlap > -1 && isIfOverlap < MAXWINDOWS) { // fill also a second readout window because of the overlap
364362
if (!isIfOverlap) {
@@ -369,12 +367,7 @@ void Digitizer::addDigit(Int_t channel, UInt_t istrip, Double_t time, Float_t x,
369367
mcTruthContainer = mMCTruthContainerNext[isIfOverlap - 1];
370368
}
371369

372-
int eventcounter = mReadoutWindowCurrent + isIfOverlap;
373-
int hittimeTDC = (nbc - eventcounter * Geo::BC_IN_WINDOW) * 1024 + tdc; // time in TDC bin within the TOF WINDOW
374-
if (hittimeTDC < 0)
375-
LOG(ERROR) << "2) Negative hit " << hittimeTDC << ", something went wrong in filling readout window: isnext=" << isnext << ", isIfOverlap=" << isIfOverlap;
376-
else
377-
fillDigitsInStrip(strips, mcTruthContainer, channel, tdc, tot, nbc, istrip, trackID, mEventID, mSrcID);
370+
fillDigitsInStrip(strips, mcTruthContainer, channel, tdc, tot, nbc, istrip, trackID, mEventID, mSrcID);
378371
}
379372
}
380373
//______________________________________________________________________

0 commit comments

Comments
 (0)