@@ -125,48 +125,56 @@ void ClustererDPL<N>::run(ProcessingContext& pc)
125125 size_t nROFs = clusROFVec.size ();
126126 const int nROFsPerOrbit = o2::constants::lhc::LHCMaxBunches / par.getROFLengthInBC (iLayer);
127127 const int nROFsTF = nROFsPerOrbit * o2::base::GRPGeomHelper::getNHBFPerTF ();
128- if (nROFsTF != clusROFVec.size ()) {
129- // it can happen that in the digitization rofs without contributing hits are skipped
130- // however downstream consumers of the clusters cannot know apriori the time structure
131- // the cluster rofs do not account for the bias so it will start always at BC=0
132- // if we receive more cluster rofs then there supposed to be, do not throw away this data
133- // the clusterer should be blind to this!
134- const size_t nROFsLayer = std::max ((size_t )nROFsTF, clusROFVec.size ());
135- std::vector<o2::itsmft::ROFRecord> expClusRofVec (nROFsLayer);
136- for (int iROF{0 }; iROF < nROFsLayer; ++iROF) {
137- auto & rof = expClusRofVec[iROF];
138- int orb = iROF * par.getROFLengthInBC (iLayer) / o2::constants::lhc::LHCMaxBunches + firstTForbit;
139- int bc = iROF * par.getROFLengthInBC (iLayer) % o2::constants::lhc::LHCMaxBunches;
140- o2::InteractionRecord ir (bc, orb);
141- rof.setBCData (ir);
142- rof.setROFrame (iROF);
143- rof.setNEntries (0 );
144- rof.setFirstEntry (-1 );
128+ // It can happen that in the digitization rofs without contributing hits are skipped or there are stray ROFs
129+ // We will preserve the clusters as they are but the stray ROFs will be removed (leaving their clusters unaddressed).
130+ std::vector<o2::itsmft::ROFRecord> expClusRofVec (nROFsTF);
131+ for (int iROF{0 }; iROF < nROFsTF; ++iROF) {
132+ auto & rof = expClusRofVec[iROF];
133+ int orb = iROF * par.getROFLengthInBC (iLayer) / o2::constants::lhc::LHCMaxBunches + firstTForbit;
134+ int bc = iROF * par.getROFLengthInBC (iLayer) % o2::constants::lhc::LHCMaxBunches;
135+ o2::InteractionRecord ir (bc, orb);
136+ rof.setBCData (ir);
137+ rof.setROFrame (iROF);
138+ rof.setNEntries (0 );
139+ rof.setFirstEntry (-1 );
140+ }
141+ uint32_t prevEntry{0 };
142+ for (const auto & rof : clusROFVec) {
143+ const auto & ir = rof.getBCData ();
144+ if (ir < firstIR) {
145+ LOGP (warn, " Discard ROF {} preceding TF 1st orbit {}, layer:{}" , ir.asString (), firstTForbit, iLayer);
146+ continue ;
147+ }
148+ const auto irToFirst = ir - firstIR;
149+ const long irROF = irToFirst.toLong () / par.getROFLengthInBC (iLayer);
150+ if (irROF >= nROFsTF) {
151+ LOGP (warn, " Discard ROF {} exceding TF orbit range, layer:{}" , ir.asString (), iLayer);
152+ continue ;
145153 }
146- uint32_t prevEntry{0 };
147- for (const auto & rof : clusROFVec) {
148- const auto & ir = rof.getBCData ();
149- const auto irToFirst = ir - firstIR;
150- const int irROF = irToFirst.toLong () / par.getROFLengthInBC (iLayer);
151- auto & expROF = expClusRofVec[irROF];
154+ auto & expROF = expClusRofVec[irROF];
155+ if (expROF.getNEntries () == 0 ) {
152156 expROF.setFirstEntry (rof.getFirstEntry ());
153157 expROF.setNEntries (rof.getNEntries ());
154- if (expROF.getBCData () != rof.getBCData ()) {
155- LOGP (fatal, " detected mismatch between expected ROF:{} and received ROF:{}" , expROF.asString (), rof.asString ());
158+ } else {
159+ if (expROF.getNEntries () < rof.getNEntries ()) {
160+ LOGP (warn, " Repeating ROF {} with {} clusters, prefer to already processed instance with {} clusters" , rof.asString (), rof.getNEntries (), expROF.getNEntries ());
161+ expROF.setFirstEntry (rof.getFirstEntry ());
162+ expROF.setNEntries (rof.getNEntries ());
163+ } else {
164+ LOGP (warn, " Repeating ROF {} with {} clusters, discard preferring already processed instance with {} clusters" , rof.asString (), rof.getNEntries (), expROF.getNEntries ());
156165 }
157166 }
158- int prevFirst{0 };
159- for (auto & rof : expClusRofVec) {
160- if (rof.getFirstEntry () < 0 ) {
161- rof.setFirstEntry (prevFirst);
162- }
163- prevFirst = rof.getFirstEntry ();
167+ }
168+ int prevFirst{0 };
169+ for (auto & rof : expClusRofVec) {
170+ if (rof.getFirstEntry () < 0 ) {
171+ rof.setFirstEntry (prevFirst);
164172 }
165- nROFs = expClusRofVec.size ();
166- pc.outputs ().snapshot (Output{Origin, " CLUSTERSROF" , iLayer}, expClusRofVec);
167- } else {
168- pc.outputs ().snapshot (Output{Origin, " CLUSTERSROF" , iLayer}, clusROFVec);
173+ prevFirst = rof.getFirstEntry ();
169174 }
175+ nROFs = expClusRofVec.size ();
176+ pc.outputs ().snapshot (Output{Origin, " CLUSTERSROF" , iLayer}, expClusRofVec);
177+
170178 pc.outputs ().snapshot (Output{Origin, " COMPCLUSTERS" , iLayer}, clusCompVec);
171179 pc.outputs ().snapshot (Output{Origin, " PATTERNS" , iLayer}, clusPattVec);
172180
0 commit comments