@@ -93,7 +93,7 @@ class CMVToVectorDevice : public o2::framework::Task
9393 // open files if necessary
9494 if ((mWriteDebug || mWriteDebugOnError ) && !mDebugStream ) {
9595 const auto debugFileName = fmt::format (fmt::runtime (mDebugStreamFileName ), fmt::arg (" run" , runNumber));
96- LOGP (info, " creating debug stream {}" , debugFileName);
96+ LOGP (info, " Creating debug stream {}" , debugFileName);
9797 mDebugStream = std::make_unique<o2::utils::TreeStreamRedirector>(debugFileName.data (), " recreate" );
9898 }
9999
@@ -103,7 +103,7 @@ class CMVToVectorDevice : public o2::framework::Task
103103 rawType = " cmv.raw" ;
104104 }
105105 const auto rawFileName = fmt::format (fmt::runtime (mRawOutputFileName ), fmt::arg (" run" , runNumber), fmt::arg (" raw_type" , rawType));
106- LOGP (info, " creating raw debug file {}" , rawFileName);
106+ LOGP (info, " Creating raw debug file {}" , rawFileName);
107107 mRawOutputFile .open (rawFileName, std::ios::binary);
108108 }
109109
@@ -118,6 +118,7 @@ class CMVToVectorDevice : public o2::framework::Task
118118 tfCounter = dh->tfCounter ;
119119 const auto subSpecification = dh->subSpecification ;
120120 auto payloadSize = DataRefUtils::getPayloadSize (ref);
121+ // LOGP(info, "Processing TF {}, subSpecification {}, payloadSize {}", tfCounter, subSpecification, payloadSize);
121122
122123 // ---| data loop |---
123124 const gsl::span<const char > raw = pc.inputs ().get <gsl::span<char >>(ref);
@@ -150,10 +151,14 @@ class CMVToVectorDevice : public o2::framework::Task
150151 const uint32_t cruID = rdh_utils::getCRU (feeId);
151152 const auto detField = RDHUtils::getDetectorField (*rdhPtr);
152153
154+ // LOGP(info, "Detected CMV packet: CRU {}, link {}, feeId {}", cruID, link, feeId);
155+
153156 if ((detField != (decltype (detField))RawDataType::CMV) || (link != rdh_utils::CMVLinkID)) {
157+ // LOGP(debug, "Skipping packet: detField {}, (expected RawDataType {}), link {}, (expected CMVLinkID {})", detField, (decltype(detField))RawDataType::CMV, link, rdh_utils::CMVLinkID);
154158 continue ;
155159 }
156- LOGP (debug, " CMV Processing firstTForbit {:9}, tfCounter {:5}, run {:6}, feeId {:6} ({:3}/-/{:2})" , dh->firstTForbit , dh->tfCounter , dh->runNumber , feeId, cruID, link);
160+
161+ LOGP (debug, " Processing firstTForbit {:9}, tfCounter {:5}, run {:6}, feeId {:6}, cruID {:3}, link {:2}" , dh->firstTForbit , dh->tfCounter , dh->runNumber , feeId, cruID, link);
157162
158163 if (std::find (mCRUs .begin (), mCRUs .end (), cruID) == mCRUs .end ()) {
159164 LOGP (error, " CMV CRU {:3} not configured in CRUs, skipping" , cruID);
@@ -163,7 +168,10 @@ class CMVToVectorDevice : public o2::framework::Task
163168 auto & cmvVec = mCMVvectors [cruID];
164169 auto & infoVec = mCMVInfos [cruID];
165170
166- assert (size == sizeof (cmv::Container));
171+ if (size != sizeof (cmv::Container)) {
172+ LOGP (error, " CMV packet size mismatch: got {} bytes, expected {} bytes (sizeof cmv::Container). Skipping package." , size, sizeof (cmv::Container));
173+ return ;
174+ }
167175 auto data = it.data ();
168176 auto & cmvs = *((cmv::Container*)(data));
169177 const uint32_t orbit = cmvs.header .heartbeatOrbit ;
@@ -174,6 +182,7 @@ class CMVToVectorDevice : public o2::framework::Task
174182 cmvVec.reserve (cmvVec.size () + cmv::NTimeBins);
175183 for (uint32_t tb = 0 ; tb < cmv::NTimeBins; ++tb) {
176184 cmvVec.push_back (cmvs.getCMVFloat (tb));
185+ // LOGP(info, "Appended CMV {} for timebin {}, CRU {}, orbit {}, bc {}", cmvs.getCMVFloat(tb), tb, cruID, orbit, bc);
177186 }
178187 }
179188 } catch (const std::exception& e) {
@@ -263,23 +272,21 @@ class CMVToVectorDevice : public o2::framework::Task
263272 bool matches (uint32_t orbit, int16_t bc) const { return ((heartbeatOrbit == orbit) && (heartbeatBC == bc)); }
264273 };
265274
266- int mRawDataType {0 }; // /< type of raw data to dump in case of errors
267- bool mWriteDebug {false }; // /< write a debug output
268- bool mWriteDebugOnError {false }; // /< write a debug output in case of errors
269- bool mWriteRawDataOnError {false }; // /< write raw data in case of errors
270- std::vector<uint32_t > mCRUs ; // /< CRUs expected for this device
271- std::unordered_map<uint32_t , std::vector<float >> mCMVvectors ; // /< decoded CMVs per cru over all CMV packets in the TF
272- std::unordered_map<uint32_t , std::vector<CMVInfo>> mCMVInfos ; // /< CMV packet information within the TF
273- std::string mDebugStreamFileName ; // /< name of the debug stream output file
274- std::unique_ptr<o2::utils::TreeStreamRedirector> mDebugStream ; // /< debug output streamer
275- std::ofstream mRawOutputFile ; // /< raw output file
276- std::string mRawOutputFileName ; // /< name of the raw output file
275+ int mRawDataType {0 }; // /< type of raw data to dump in case of errors
276+ bool mWriteDebug {false }; // /< write a debug output
277+ bool mWriteDebugOnError {false }; // /< write a debug output in case of errors
278+ bool mWriteRawDataOnError {false }; // /< write raw data in case of errors
279+ std::vector<uint32_t > mCRUs ; // /< CRUs expected for this device
280+ std::unordered_map<uint32_t , std::vector<float >> mCMVvectors ; // /< decoded CMVs per cru over all CMV packets in the TF
281+ std::unordered_map<uint32_t , std::vector<CMVInfo>> mCMVInfos ; // /< CMV packet information within the TF
282+ std::string mDebugStreamFileName ; // /< name of the debug stream output file
283+ std::unique_ptr<o2::utils::TreeStreamRedirector> mDebugStream ; // /< debug output streamer
284+ std::ofstream mRawOutputFile ; // /< raw output file
285+ std::string mRawOutputFileName ; // /< name of the raw output file
277286
278287 // ____________________________________________________________________________
279288 bool snapshotCMVs (DataAllocator& output, uint32_t tfCounter)
280289 {
281- LOGP (debug, " snapshotCMVs" );
282-
283290 bool hasErrors = false ;
284291
285292 // send data per CRU with its own orbit/BC vector
@@ -288,11 +295,11 @@ class CMVToVectorDevice : public o2::framework::Task
288295 const auto & infVec = mCMVInfos [cru];
289296
290297 if (infVec.size () != 4 ) {
291- LOGP (warning, " CMV CRU {:3}: expected 4 packets per TF, got {}" , cru, infVec.size ());
298+ LOGP (warning, " CRU {:3}: expected 4 packets per TF, got {}" , cru, infVec.size ());
292299 hasErrors = true ;
293300 }
294301 if (cmvVec.size () != cmv::NTimeBins * infVec.size ()) {
295- LOGP (warning, " CMV CRU {:3}: vector size {} does not match expected {}" , cru, cmvVec.size (), cmv::NTimeBins * infVec.size ());
302+ LOGP (warning, " CRU {:3}: vector size {} does not match expected {}" , cru, cmvVec.size (), cmv::NTimeBins * infVec.size ());
296303 hasErrors = true ;
297304 }
298305
@@ -336,17 +343,16 @@ class CMVToVectorDevice : public o2::framework::Task
336343 if (mCMVInfos .find (cru) == mCMVInfos .end ()) {
337344 continue ;
338345 }
339-
346+
340347 auto & infos = mCMVInfos [cru];
341348 auto & cmvVec = mCMVvectors [cru];
342-
349+
343350 stream << " cru=" << cru
344351 << " tfCounter=" << tfCounter
345352 << " nCMVs=" << cmvVec.size ()
346353 << " cmvs=" << cmvVec
347354 << " \n " ;
348355 }
349-
350356 }
351357
352358 void writeRawData (InputRecord& inputs)
0 commit comments