@@ -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