@@ -500,7 +500,9 @@ bool CruRawReader::processHalfCRU(int iteration)
500500 mEventRecords .incLinkWords (halfChamberId, mCurrentHalfCRULinkLengths [currentlinkindex]);
501501 uint32_t currentlinksize32 = mCurrentHalfCRULinkLengths [currentlinkindex] * 8 ; // x8 to go from 256 bits to 32 bit;
502502 uint32_t endOfCurrentLink = mHBFoffset32 + currentlinksize32;
503-
503+ if (mOptions [TRDVerboseBit] && currentlinksize32 > 0 ) {
504+ LOGP (info, " Reading {} (link ID {}, HCID {}) with {} 32-bit words" , HelperMethods::getSectorStackLayerSide (halfChamberId), linkIdxGlobal, halfChamberId, currentlinksize32);
505+ }
504506 linksizeAccum32 += currentlinksize32;
505507 if (currentlinksize32 == 0 ) {
506508 mEventRecords .incLinkNoData (halfChamberId);
@@ -521,8 +523,13 @@ bool CruRawReader::processHalfCRU(int iteration)
521523 LOGF (info, " Tracklet parser starting at offset %u and processing up to %u words" , mHBFoffset32 , currentlinksize32);
522524 }
523525 int trackletWordsRejected = 0 ;
524- int trackletWordsRead = parseTrackletLinkData (currentlinksize32, halfChamberId, trackletWordsRejected);
526+ int trackletWordsReadOK = 0 ;
527+ int numberOfTrackletsFound = 0 ; // count the number of found tracklets for this link
528+ int trackletWordsRead = parseTrackletLinkData (currentlinksize32, halfChamberId, trackletWordsRejected, trackletWordsReadOK, numberOfTrackletsFound);
525529 std::chrono::duration<float , std::micro> trackletparsingtime = std::chrono::high_resolution_clock::now () - trackletparsingstart;
530+ if (mOptions [TRDVerboseBit]) {
531+ LOGP (info, " Could read {} 32-bit words w/o errors, found {} tracklets, rejected {} 32-bit words for {}. Parsing OK? {}" , trackletWordsReadOK, numberOfTrackletsFound, trackletWordsRejected, HelperMethods::getSectorStackLayerSide (halfChamberId), (trackletWordsRead != -1 && trackletWordsRejected == 0 ));
532+ }
526533 if (trackletWordsRead == -1 ) {
527534 // something went wrong bailout of here.
528535 mHBFoffset32 = hbfOffsetTmp + linksizeAccum32;
@@ -544,7 +551,7 @@ bool CruRawReader::processHalfCRU(int iteration)
544551 }
545552 mEventRecords .getCurrentEventRecord ().incTrackletTime (trackletparsingtime.count ());
546553 if (mOptions [TRDVerboseBit]) {
547- LOGF (info , " Read %i tracklet words and rejected %i words" , trackletWordsRead, trackletWordsRejected);
554+ LOGF (debug , " Read %i tracklet words and rejected %i words" , trackletWordsRead, trackletWordsRejected);
548555 }
549556 mTrackletWordsRejected += trackletWordsRejected;
550557 mTrackletWordsRead += trackletWordsRead;
@@ -836,10 +843,9 @@ int CruRawReader::parseDigitLinkData(int maxWords32, int hcid, int& wordsRejecte
836843}
837844
838845// Returns number of words read (>=0) or error state (<0)
839- int CruRawReader::parseTrackletLinkData (int linkSize32, int & hcid, int & wordsRejected)
846+ int CruRawReader::parseTrackletLinkData (int linkSize32, int & hcid, int & wordsRejected, int & wordsReadOK, int & trackletsFound )
840847{
841848 int wordsRead = 0 ; // count the number of words which were parsed (both successful and not successful)
842- int numberOfTrackletsFound = 0 ; // count the number of found tracklets for this link
843849 int state = StateTrackletHCHeader; // we expect to always see a TrackletHCHeader at the beginning of the link
844850 // tracklet data for one link is expected to arrive ordered
845851 // first MCM in row=0, column=0, then row=0, column=1, ... row=1, column=0, ...
@@ -865,6 +871,7 @@ int CruRawReader::parseTrackletLinkData(int linkSize32, int& hcid, int& wordsRej
865871 // either the TrackletHCHeader is corrupt or we have only digits on this link
866872 return 0 ;
867873 }
874+ ++wordsReadOK;
868875 state = StateTrackletMCMHeader; // we do expect tracklets following
869876 } else {
870877 // we always expect a TrackletHCHeader as first word for a link (default)
@@ -876,12 +883,14 @@ int CruRawReader::parseTrackletLinkData(int linkSize32, int& hcid, int& wordsRej
876883 ++wordsRejected;
877884 continue ;
878885 }
886+ ++wordsReadOK;
879887 state = StateTrackletMCMHeader; // we might have tracklets following or tracklet end markers
880888 }
881889 } // StateTrackletHCHeader
882890
883891 else if (state == StateTrackletMCMHeader) {
884892 if (currWord == TRACKLETENDMARKER) {
893+ ++wordsReadOK;
885894 state = StateSecondEndmarker; // we expect a second tracklet end marker to follow
886895 } else {
887896 mcmHeader.word = currWord;
@@ -912,6 +921,7 @@ int CruRawReader::parseTrackletLinkData(int linkSize32, int& hcid, int& wordsRej
912921 previousColumn = mcmHeader.col ;
913922 previousRow = mcmHeader.padrow ;
914923 }
924+ ++wordsReadOK;
915925 state = StateTrackletMCMData; // tracklet words must be following, unless the HC header format indicates sending of empty MCM headers
916926 }
917927 ++wordsRead;
@@ -935,20 +945,23 @@ int CruRawReader::parseTrackletLinkData(int linkSize32, int& hcid, int& wordsRej
935945 break ;
936946 }
937947 if ((currWord & 0x1 ) == 0x1 ) {
938- // the reserved bit of the trackler MCM data is set
948+ // the reserved bit of the tracklet MCM data is set, we don't create a tracklet from this word
939949 incrementErrors (TrackletMCMDataFailure, hcid, fmt::format (" Invalid word {:#010x} for the expected TrackletMCMData" , currWord));
940950 ++wordsRejected;
951+ ++wordsRead;
952+ continue ;
941953 }
942954 TrackletMCMData mcmData;
943955 mcmData.word = currWord;
944956 mEventRecords .getCurrentEventRecord ().addTracklet (assembleTracklet64 (hcHeader.format , mcmHeader, mcmData, iCpu, hcid));
945- ++numberOfTrackletsFound ;
957+ ++trackletsFound ;
946958 ++mTrackletsFound ;
947959 addedTracklet = true ;
948960 ++wordsRead;
961+ ++wordsReadOK;
949962 if (wordsRead == linkSize32) {
950963 incrementErrors (TrackletNoTrackletEndMarker, hcid, fmt::format (" After reading the word {:#010x} we are at the end of the link data" , currWord));
951- return wordsRead ;
964+ return - 1 ;
952965 }
953966 currWord = mHBFPayload [mHBFoffset32 + wordsRead];
954967 }
@@ -978,9 +991,10 @@ int CruRawReader::parseTrackletLinkData(int linkSize32, int& hcid, int& wordsRej
978991 else if (state == StateSecondEndmarker) {
979992 ++wordsRead;
980993 if (currWord != TRACKLETENDMARKER) {
981- incrementErrors (TrackletNoSecondEndMarker, hcid, fmt::format (" Expected second tracklet end marker, but found {:#010x} instead " , currWord));
994+ incrementErrors (TrackletNoSecondEndMarker, hcid, fmt::format (" Invalid word {:#010x} for the expected second end marker " , currWord));
982995 return -1 ;
983996 }
997+ ++wordsReadOK;
984998 state = StateFinished;
985999 } // StateSecondEndmarker
9861000
@@ -1001,7 +1015,7 @@ int CruRawReader::parseTrackletLinkData(int linkSize32, int& hcid, int& wordsRej
10011015
10021016 } // end of state machine
10031017
1004- if (mTrackletHCHeaderState == 1 && numberOfTrackletsFound == 0 ) {
1018+ if (mTrackletHCHeaderState == 1 && trackletsFound == 0 ) {
10051019 if (mMaxErrsPrinted > 0 ) {
10061020 LOG (error) << " We found a TrackletHCHeader in mode 1, but did not add any tracklets" ;
10071021 checkNoErr ();
0 commit comments