1616#include " ITSMFTSimulation/Digitizer.h"
1717#include " MathUtils/Cartesian.h"
1818#include " SimulationDataFormat/MCTruthContainer.h"
19+ #include " DetectorsRaw/HBFUtils.h"
1920
2021#include < TRandom.h>
2122#include < climits>
@@ -44,6 +45,7 @@ void Digitizer::init()
4445 mParams .setAlpSimResponse (mAlpSimResp .get ());
4546 }
4647 mParams .print ();
48+ mIRFirstSampledTF = o2::raw::HBFUtils::Instance ().getFirstSampledTFIR ();
4749}
4850
4951// _______________________________________________________________________
@@ -92,7 +94,7 @@ void Digitizer::setEventTime(const o2::InteractionTimeRecord& irt)
9294 // RO frame corresponding to provided time
9395 mCollisionTimeWrtROF = mEventTime .timeInBCNS ; // in triggered mode the ROF starts at BC (is there a delay?)
9496 if (mParams .isContinuous ()) {
95- auto nbc = mEventTime .toLong ( );
97+ auto nbc = mEventTime .differenceInBC ( mIRFirstSampledTF );
9698 if (mCollisionTimeWrtROF < 0 && nbc > 0 ) {
9799 nbc--;
98100 }
@@ -114,7 +116,7 @@ void Digitizer::setEventTime(const o2::InteractionTimeRecord& irt)
114116}
115117
116118// _______________________________________________________________________
117- void Digitizer::fillOutputContainer (UInt_t frameLast)
119+ void Digitizer::fillOutputContainer (uint32_t frameLast)
118120{
119121 // fill output with digits from min.cached up to requested frame, generating the noise beforehand
120122 if (frameLast > mROFrameMax ) {
@@ -164,7 +166,7 @@ void Digitizer::fillOutputContainer(UInt_t frameLast)
164166 // finalize ROF record
165167 rcROF.setNEntries (mDigits ->size () - rcROF.getFirstEntry ()); // number of digits
166168 if (isContinuous ()) {
167- rcROF.getBCData ().setFromLong (mROFrameMin * mParams .getROFrameLengthInBC ());
169+ rcROF.getBCData ().setFromLong (mIRFirstSampledTF . toLong () + mROFrameMin * mParams .getROFrameLengthInBC ());
168170 } else {
169171 rcROF.getBCData () = mEventTime ; // RSTODO do we need to add trigger delay?
170172 }
@@ -179,7 +181,7 @@ void Digitizer::fillOutputContainer(UInt_t frameLast)
179181}
180182
181183// _______________________________________________________________________
182- void Digitizer::processHit (const o2::itsmft::Hit& hit, UInt_t & maxFr, int evID, int srcID)
184+ void Digitizer::processHit (const o2::itsmft::Hit& hit, uint32_t & maxFr, int evID, int srcID)
183185{
184186 // convert single hit to digits
185187 float timeInROF = hit.GetTime () * sec2ns;
@@ -203,9 +205,9 @@ void Digitizer::processHit(const o2::itsmft::Hit& hit, UInt_t& maxFr, int evID,
203205 // frame of the hit signal start wrt event ROFrame
204206 int roFrameRel = int (timeInROF * mParams .getROFrameLengthInv ());
205207 // frame of the hit signal end wrt event ROFrame: in the triggered mode we read just 1 frame
206- UInt_t roFrameRelMax = mParams .isContinuous () ? (timeInROF + tTot) * mParams .getROFrameLengthInv () : roFrameRel;
208+ uint32_t roFrameRelMax = mParams .isContinuous () ? (timeInROF + tTot) * mParams .getROFrameLengthInv () : roFrameRel;
207209 int nFrames = roFrameRelMax + 1 - roFrameRel;
208- UInt_t roFrameMax = mNewROFrame + roFrameRelMax;
210+ uint32_t roFrameMax = mNewROFrame + roFrameRelMax;
209211 if (roFrameMax > maxFr) {
210212 maxFr = roFrameMax; // if signal extends beyond current maxFrame, increase the latter
211213 }
@@ -325,7 +327,7 @@ void Digitizer::processHit(const o2::itsmft::Hit& hit, UInt_t& maxFr, int evID,
325327 auto & chip = mChips [hit.GetDetectorID ()];
326328 auto roFrameAbs = mNewROFrame + roFrameRel;
327329 for (int irow = rowSpan; irow--;) {
328- UShort_t rowIS = irow + rowS;
330+ uint16_t rowIS = irow + rowS;
329331 for (int icol = colSpan; icol--;) {
330332 float nEleResp = respMatrix[irow][icol];
331333 if (!nEleResp) {
@@ -336,24 +338,24 @@ void Digitizer::processHit(const o2::itsmft::Hit& hit, UInt_t& maxFr, int evID,
336338 if (nEle < mParams .getMinChargeToAccount ()) {
337339 continue ;
338340 }
339- UShort_t colIS = icol + colS;
341+ uint16_t colIS = icol + colS;
340342 //
341343 registerDigits (chip, roFrameAbs, timeInROF, nFrames, rowIS, colIS, nEle, lbl);
342344 }
343345 }
344346}
345347
346348// ________________________________________________________________________________
347- void Digitizer::registerDigits (ChipDigitsContainer& chip, UInt_t roFrame, float tInROF, int nROF,
348- UShort_t row, UShort_t col, int nEle, o2::MCCompLabel& lbl)
349+ void Digitizer::registerDigits (ChipDigitsContainer& chip, uint32_t roFrame, float tInROF, int nROF,
350+ uint16_t row, uint16_t col, int nEle, o2::MCCompLabel& lbl)
349351{
350352 // Register digits for given pixel, accounting for the possible signal contribution to
351353 // multiple ROFrame. The signal starts at time tInROF wrt the start of provided roFrame
352354 // In every ROFrame we check the collected signal during strobe
353355
354356 float tStrobe = mParams .getStrobeDelay () - tInROF; // strobe start wrt signal start
355357 for (int i = 0 ; i < nROF; i++) {
356- UInt_t roFr = roFrame + i;
358+ uint32_t roFr = roFrame + i;
357359 int nEleROF = mParams .getSignalShape ().getCollectedCharge (nEle, tStrobe, tStrobe + mParams .getStrobeLength ());
358360 tStrobe += mParams .getROFrameLength (); // for the next ROF
359361
0 commit comments