@@ -226,8 +226,8 @@ void Digitizer<DetID>::fillOutputContainer(uint32_t frameLast, int layer)
226226 auto & preDig = iter->second ; // preDigit
227227 if (preDig.charge >= mParams .getChargeThreshold ()) {
228228 int digID = mDigits ->size ();
229- mDigits ->emplace_back (chip.getChipIndex (), preDig.row , preDig.col , preDig.charge );
230- LOG (debug) << " Adding digit ID: " << digID << " with chipID: " << chip.getChipIndex () << " , row: " << preDig.row << " , col: " << preDig.col << " , charge: " << preDig.charge ;
229+ mDigits ->emplace_back (chip.getChipIndex (), preDig.row , preDig.col , preDig.charge , preDig. toa );
230+ LOG (debug) << " Adding digit ID: " << digID << " with chipID: " << chip.getChipIndex () << " , row: " << preDig.row << " , col: " << preDig.col << " , charge: " << preDig.charge << " , ToA: " << preDig. toa ;
231231 mMCLabels ->addElement (digID, preDig.labelRef .label );
232232 auto & nextRef = preDig.labelRef ; // extra contributors are in extra array
233233 while (nextRef.next >= 0 ) {
@@ -297,6 +297,9 @@ void Digitizer<DetID>::processHit(const o2::trkft3::Hit& hit, uint32_t& maxFr, i
297297 float tTot = mParams .getSignalShape ().getMaxDuration ();
298298 // frame of the hit signal start wrt event ROFrame
299299 int roFrameRel = int (timeInROF * mParams .getROFrameLengthInv (rofLayer));
300+ // Time of Arrival w.r.t. the start of the ROF where the signal starts (= w.r.t. roFrameAbs)
301+ float toaInROF = timeInROF - roFrameRel * mParams .getROFrameLength (rofLayer);
302+
300303 // frame of the hit signal end wrt event ROFrame: in the triggered mode we read just 1 frame
301304 uint32_t roFrameRelMax = (timeInROF + tTot) * mParams .getROFrameLengthInv (rofLayer);
302305 int nFrames = roFrameRelMax + 1 - roFrameRel;
@@ -493,24 +496,25 @@ void Digitizer<DetID>::processHit(const o2::trkft3::Hit& hit, uint32_t& maxFr, i
493496 if (mDeadChanMap && mDeadChanMap ->isNoisy (chipID, rowIS, colIS)) {
494497 continue ;
495498 }
496- registerDigits (chip, roFrameAbs, timeInROF , nFrames, rowIS, colIS, nEle, lbl, rofLayer);
499+ registerDigits (chip, roFrameAbs, toaInROF , nFrames, rowIS, colIS, nEle, lbl, rofLayer);
497500 }
498501 }
499502}
500503
501504// ________________________________________________________________________________
502505template <int DetID>
503- void Digitizer<DetID>::registerDigits(o2::trkft3::ChipDigitsContainer& chip, uint32_t roFrame, float tInROF , int nROF,
506+ void Digitizer<DetID>::registerDigits(o2::trkft3::ChipDigitsContainer& chip, uint32_t roFrame, float toaInROF , int nROF,
504507 uint16_t row, uint16_t col, int nEle, o2::MCCompLabel& lbl, int layer)
505508{
506509 // Register digits for given pixel, accounting for the possible signal contribution to
507- // multiple ROFrame. The signal starts at time tInROF wrt the start of provided roFrame
510+ // multiple ROFrame. The signal starts at time toaInROF wrt the start of provided roFrame
508511 // In every ROFrame we check the collected signal during strobe
509512 LOG (debug) << " Registering digits for chip " << chip.getChipIndex () << " at ROFrame " << roFrame
510- << " row " << row << " col " << col << " nEle " << nEle << " label " << lbl;
511- float tStrobe = mParams .getStrobeDelay (layer) - tInROF ; // strobe start wrt signal start
512- for (int i = 0 ; i < nROF; i++) { // loop on all the ROFs occupied by the same signal to calculate the charge accumulated in that ROF
513+ << " row " << row << " col " << col << " nEle " << nEle << " label " << lbl << " layer " << layer << " toa " << toaInROF ;
514+ float tStrobe = mParams .getStrobeDelay (layer) - toaInROF ; // strobe start wrt signal start
515+ for (int i = 0 ; i < nROF; i++) { // loop on all the ROFs occupied by the same signal to calculate the charge accumulated in that ROF
513516 uint32_t roFr = roFrame + i;
517+ float toaROF = toaInROF - i * mParams .getROFrameLength (layer); // ToA w.r.t. start of ROF
514518 int nEleROF = mParams .getSignalShape ().getCollectedCharge (nEle, tStrobe, tStrobe + mParams .getStrobeLength (layer));
515519 tStrobe += mParams .getROFrameLength (layer); // for the next ROF
516520
@@ -525,14 +529,15 @@ void Digitizer<DetID>::registerDigits(o2::trkft3::ChipDigitsContainer& chip, uin
525529 mEventROFrameMin = roFr;
526530 }
527531 auto key = chip.getOrderingKey (roFr, row, col);
528- o2::itsmft ::PreDigit* pd = chip.findDigit (key);
532+ o2::trkft3 ::PreDigit* pd = chip.findDigit (key);
529533 if (!pd) {
530- chip.addDigit (key, roFr, row, col, nEleROF, lbl);
534+ chip.addDigit (key, roFr, row, col, nEleROF, lbl, toaROF );
531535 LOG (debug) << " Added digit with key: " << key << " ROF: " << roFr << " row: " << row << " col: " << col << " charge: " << nEleROF;
532536 } else { // there is already a digit at this slot, account as PreDigitExtra contribution
533537 LOG (debug) << " Added to pre-digit with key: " << key << " ROF: " << roFr << " row: " << row << " col: " << col << " charge: " << nEleROF;
534538 pd->charge += nEleROF;
535- if (pd->labelRef .label == lbl) { // don't store the same label twice
539+ pd->toa = std::min (pd->toa , toaROF); // / in case of two hits on the same digit in the same ROF, get the first ToA
540+ if (pd->labelRef .label == lbl) { // don't store the same label twice
536541 continue ;
537542 }
538543 ExtraDig* extra = getExtraDigBuffer (roFr);
0 commit comments