2828#include < cassert>
2929#include < iomanip>
3030#include < string>
31+ #include < numeric>
3132
3233using namespace o2 ::framework;
3334using namespace o2 ::header;
@@ -123,6 +124,7 @@ DataProcessorSpec getClusterDecoderRawSpec(bool sendMC, int fanNumber)
123124 // only for single 8kb pages. So we have to add the raw pages individually and create
124125 // MC label containers for the corresponding clusters.
125126 size_t mcinPos = 0 ;
127+ size_t totalNumberOfClusters = 0 ;
126128 for (size_t page = 0 ; page < nPages; page++) {
127129 inputList.emplace_back (reinterpret_cast <const ClusterHardwareContainer*>(ref.payload + page * 8192 ), 1 );
128130 const ClusterHardwareContainer& container = *(inputList.back ().first );
@@ -131,15 +133,24 @@ DataProcessorSpec getClusterDecoderRawSpec(bool sendMC, int fanNumber)
131133 << " CRU " << std::setw (3 ) << container.CRU << " " //
132134 << std::setw (3 ) << container.numberOfClusters << " cluster(s)" ; //
133135 }
136+ totalNumberOfClusters += container.numberOfClusters ;
134137 if (mcin) {
135- for (size_t mccopyPos = 0 ; mccopyPos < container.numberOfClusters ; mccopyPos++, mcinPos++) {
138+ for (size_t mccopyPos = 0 ;
139+ mccopyPos < container.numberOfClusters && mcinPos < mcin->getIndexedSize ();
140+ mccopyPos++, mcinPos++) {
136141 for (auto const & label : mcin->getLabels (mcinPos)) {
137142 mcinCopies[page].addElement (mccopyPos, label);
138143 }
139144 }
140145 }
141146 }
142- assert (!mcin || mcinPos == mcin->getIndexedSize ());
147+ // FIXME: introduce error handling policy: throw, ignore, warn
148+ // assert(!mcin || mcinPos == mcin->getIndexedSize());
149+ if (mcin && mcinPos != totalNumberOfClusters) {
150+ LOG (ERROR) << " inconsistent number of MC label objects processed"
151+ << " , expecting MC label objects for " << totalNumberOfClusters << " cluster(s)"
152+ << " , got " << mcin->getIndexedSize ();
153+ }
143154 // output of the decoder is sorted in (sector,globalPadRow) coordinates, individual
144155 // containers are created for clusters and MC labels per (sector,globalPadRow) address
145156 std::vector<ClusterNativeContainer> cont;
@@ -160,7 +171,7 @@ DataProcessorSpec getClusterDecoderRawSpec(bool sendMC, int fanNumber)
160171 auto * target = pc.outputs ().newChunk (OutputRef{ " clusterout" , fanSpec, std::move (rawHeaderStack) }, totalSize).data ;
161172
162173 for (const auto & coll : cont) {
163- if (verbosity > 0 ) {
174+ if (verbosity > 1 ) {
164175 LOG (INFO) << " decoder " << std::setw (2 ) << sectorHeader->sector //
165176 << " : decoded " << std::setw (4 ) << coll.clusters .size () << " clusters on sector " //
166177 << std::setw (2 ) << (int )coll.sector << " [" << (int )coll.globalPadRow << " ]" ; //
@@ -173,7 +184,9 @@ DataProcessorSpec getClusterDecoderRawSpec(bool sendMC, int fanNumber)
173184 }
174185 if (sendMC) {
175186 if (verbosity > 0 ) {
176- LOG (INFO) << " sending " << mcoutList.size () << " MC label containers" << std::endl;
187+ LOG (INFO) << " sending " << mcoutList.size () << " MC label container(s) with in total "
188+ << std::accumulate (mcoutList.begin (), mcoutList.end (), size_t (0 ), [](size_t l, auto const & r) { return l + r.getIndexedSize (); })
189+ << " label object(s)" << std::endl;
177190 }
178191 // serialize the complete list of MC label containers
179192 pc.outputs ().snapshot (OutputRef{ " mclblout" , fanSpec, std::move (mcHeaderStack) }, mcoutList);
0 commit comments