@@ -123,14 +123,13 @@ int Digitizer::processHit(const Hit& hit, int detID, int eventTime)
123123 auto charge = resp.etocharge (hit.GetEnergyLoss ());
124124
125125 // convert float ns time to BC counts
126- auto time = int (eventTime/ 25 .) & int (hit.GetTime () / 25 .);
126+ auto time = int (eventTime / 25 .) & int (hit.GetTime () / 25 .);
127127 // FIXME: need to put the orbit and the bc into a TimeFrame information and not here
128128 // Digit::Time time;
129129 // time.sampaTime = hit.GetTime();
130130 // time.bunchCrossing = bc;
131131 // time.orbit = orbit;
132132
133-
134133 // transformation from global to local
135134 auto transformation = o2::mch::geo::transformationFromTGeoManager (*gGeoManager );
136135 auto t = transformation (detID);
@@ -184,7 +183,7 @@ int Digitizer::processHit(const Hit& hit, int detID, int eventTime)
184183
185184 // / FIXME: which time definition is used when calling this function?
186185 digits.emplace_back (detID, padid, signal, time);
187- // Digit::Time dtime;
186+ // Digit::Time dtime;
188187 // dtime.sampaTime = static_cast<uint16_t>(time) & 0x3FF;
189188 ++ndigits;
190189 }
@@ -206,7 +205,7 @@ void Digitizer::generateNoiseDigits()
206205 for (int i = 0 ; i < nNoisyPads; i++) {
207206 int padid = gRandom ->Integer (nNoisyPads + 1 );
208207 // FIXME: can we use eventTime as the digit time?
209- time = int (time/ 25 .);// not clear if ok
208+ time = int (time / 25 .); // not clear if ok
210209 // time.sampa = 0; //not clear what to do...
211210 // time.bunchCrossing = bc;
212211 // time.orbit = orbit;
@@ -223,12 +222,12 @@ void Digitizer::generateNoiseDigits()
223222// ______________________________________________________________________
224223void Digitizer::mergeDigits (std::vector<Digit>& rofdigits, std::vector<o2::MCCompLabel>& rofLabels, std::vector<int >& indexhelper)
225224{
226- std::vector<int > indices (rofdigits.size ());// TODO problematic. since mDigits.reserve in mergeDi
227- std::iota (begin (indices), end (indices), 0 );// problem with iota if vector longer than number of non-trivial entries
225+ std::vector<int > indices (rofdigits.size ()); // TODO problematic. since mDigits.reserve in mergeDi
226+ std::iota (begin (indices), end (indices), 0 ); // problem with iota if vector longer than number of non-trivial entries
228227 // labels go WRONG!
229228 std::sort (indices.begin (), indices.end (), [&rofdigits, this ](int a, int b) {
230229 return (getGlobalDigit (rofdigits[a].getDetID (), rofdigits[a].getPadID ()) < getGlobalDigit (rofdigits[b].getDetID (), rofdigits[b].getPadID ()));
231- });// this is ok!
230+ }); // this is ok!
232231
233232 auto sortedDigits = [rofdigits, &indices](int i) {
234233 return rofdigits[indices[i]];
@@ -245,13 +244,13 @@ void Digitizer::mergeDigits(std::vector<Digit>& rofdigits, std::vector<o2::MCCom
245244 rofdigits.reserve (sizedigits);
246245 rofLabels.clear ();
247246 rofLabels.reserve (sizelabels);
248-
247+
249248 int count = mDigits .size ();
250249
251250 int i = 0 ;
252251 while (i < indices.size ()) {
253252 int j = i + 1 ;
254- while (j < indices.size () && (getGlobalDigit (sortedDigits (i).getDetID (), sortedDigits (i).getPadID ())) == (getGlobalDigit (sortedDigits (j).getDetID (), sortedDigits (j).getPadID ())) && (std::fabs (sortedDigits (i).getTime () - sortedDigits (j).getTime ()) < mDeltat )) {// important that time is unambiguous within one processing, i.e. that simulation only does one TF and that it passes a new processing
253+ while (j < indices.size () && (getGlobalDigit (sortedDigits (i).getDetID (), sortedDigits (i).getPadID ())) == (getGlobalDigit (sortedDigits (j).getDetID (), sortedDigits (j).getPadID ())) && (std::fabs (sortedDigits (i).getTime () - sortedDigits (j).getTime ()) < mDeltat )) { // important that time is unambiguous within one processing, i.e. that simulation only does one TF and that it passes a new processing
255254 j++;
256255 }
257256 uint32_t adc{0 };
@@ -261,12 +260,12 @@ void Digitizer::mergeDigits(std::vector<Digit>& rofdigits, std::vector<o2::MCCom
261260 for (int k = i; k < j; k++) {
262261 adc += sortedDigits (k).getADC ();
263262 if (k == i) {
264- rofLabels.emplace_back (sortedLabels (k).getTrackID (), sortedLabels (k).getEventID (), sortedLabels (k).getSourceID (), false );
265- indexhelper.emplace_back (count);
263+ rofLabels.emplace_back (sortedLabels (k).getTrackID (), sortedLabels (k).getEventID (), sortedLabels (k).getSourceID (), false );
264+ indexhelper.emplace_back (count);
266265 } else {
267266 if ((sortedLabels (k).getTrackID () != sortedLabels (k - 1 ).getTrackID ()) || (sortedLabels (k).getSourceID () != sortedLabels (k - 1 ).getSourceID ())) {
268267 rofLabels.emplace_back (sortedLabels (k).getTrackID (), sortedLabels (k).getEventID (), sortedLabels (k).getSourceID (), false );
269- indexhelper.emplace_back (count);
268+ indexhelper.emplace_back (count);
270269 }
271270 }
272271 }
@@ -289,36 +288,34 @@ void Digitizer::mergeDigits(std::vector<Digit>& digits, o2::dataformats::MCTruth
289288 // and not touch mDigits
290289 // always only doing the index from the start to the end of the ROF
291290 // mDigits only for one Rof used
292- std::vector<Digit> rofDigits;// use accumDIgits for mDigits and pass digits
291+ std::vector<Digit> rofDigits; // use accumDIgits for mDigits and pass digits
293292 std::vector<o2::MCCompLabel> rofLabels;
294293 std::vector<int > indexhelper;
295- for (int rofindex = 0 ; rofindex < rofs.size (); ++rofindex)
296- {
297- for (int index = rofs[rofindex].getFirstIdx (); index < (rofs[rofindex].getLastIdx ()+1 ); ++index) {
298- auto digit = digits.at (index);
299- rofDigits.emplace_back (digit.getDetID (), digit.getPadID (), digit.getADC (), digit.getTime ());
300- }
301- for (int index = rofs[rofindex].getFirstIdx (); index < (rofs[rofindex].getLastIdx ()+1 ); ++index) {
302- // at this stage label schould still have 1-to-1 corresponds in term of number to number of digits
303- auto label = mcContainer.getElement (index);
304- rofLabels.emplace_back (label.getTrackID (), label.getEventID (), label.getSourceID (), label.isFake ());
305- }
306- // mergeDigits does simply merging within 1 ROF
307- mergeDigits (rofDigits, rofLabels, indexhelper);
308- rofs[rofindex].setDataRef (mDigits .size (), rofDigits.size ());
309-
310- mDigits .insert (std::end (mDigits ), std::begin (rofDigits), std::end (rofDigits));
311- mTrackLabels .insert (std::end (mTrackLabels ), std::begin (rofLabels), std::end (rofLabels));
312- rofDigits.clear ();
313- rofLabels.clear ();
294+ for (int rofindex = 0 ; rofindex < rofs.size (); ++rofindex) {
295+ for (int index = rofs[rofindex].getFirstIdx (); index < (rofs[rofindex].getLastIdx () + 1 ); ++index) {
296+ auto digit = digits.at (index);
297+ rofDigits.emplace_back (digit.getDetID (), digit.getPadID (), digit.getADC (), digit.getTime ());
314298 }
315-
316- for (int labelindex=0 ; labelindex < mTrackLabels .size (); ++labelindex)
317- {
318- auto digitindex = indexhelper.at (labelindex);
319- MCCompLabel label (mTrackLabels [labelindex].getTrackID (), mTrackLabels [labelindex].getEventID (), mTrackLabels [labelindex].getSourceID (), mTrackLabels [labelindex].isFake ());
320- mMCTruthOutputContainer .addElement (digitindex, label);
299+ for (int index = rofs[rofindex].getFirstIdx (); index < (rofs[rofindex].getLastIdx () + 1 ); ++index) {
300+ // at this stage label schould still have 1-to-1 corresponds in term of number to number of digits
301+ auto label = mcContainer.getElement (index);
302+ rofLabels.emplace_back (label.getTrackID (), label.getEventID (), label.getSourceID (), label.isFake ());
321303 }
304+ // mergeDigits does simply merging within 1 ROF
305+ mergeDigits (rofDigits, rofLabels, indexhelper);
306+ rofs[rofindex].setDataRef (mDigits .size (), rofDigits.size ());
307+
308+ mDigits .insert (std::end (mDigits ), std::begin (rofDigits), std::end (rofDigits));
309+ mTrackLabels .insert (std::end (mTrackLabels ), std::begin (rofLabels), std::end (rofLabels));
310+ rofDigits.clear ();
311+ rofLabels.clear ();
312+ }
313+
314+ for (int labelindex = 0 ; labelindex < mTrackLabels .size (); ++labelindex) {
315+ auto digitindex = indexhelper.at (labelindex);
316+ MCCompLabel label (mTrackLabels [labelindex].getTrackID (), mTrackLabels [labelindex].getEventID (), mTrackLabels [labelindex].getSourceID (), mTrackLabels [labelindex].isFake ());
317+ mMCTruthOutputContainer .addElement (digitindex, label);
318+ }
322319 fillOutputContainer (digits);
323320
324321 provideMC (mcContainer);
@@ -330,7 +327,7 @@ void Digitizer::fillOutputContainer(std::vector<Digit>& digits)
330327 if (mDigits .empty ()) {
331328 return ;
332329 }
333-
330+
334331 digits.clear ();
335332 digits.reserve (mDigits .size ());
336333
0 commit comments