Skip to content

Commit

Permalink
Merge pull request #1097 in B2/basf2 from bugfix/BII-9410-a-bug-corre…
Browse files Browse the repository at this point in the history
…ction-of-svd-unpacker-packer-for-pcie40-readout_release-06-01 to release/06-01

* commit 'be5ee09357901a32a7e8017239015cc6899bd772':
  Change the location of the seenHeadersAndTrailers initialization in event()
  A bug in the header and trailer checks was fixed
  • Loading branch information
GiacomoXT committed Jun 18, 2022
2 parents b8ae780 + be5ee09 commit 938b323
Showing 1 changed file with 26 additions and 27 deletions.
53 changes: 26 additions & 27 deletions svd/modules/svdUnpacker/src/SVDUnpackerModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,17 @@ void SVDUnpackerModule::event()
short strip, sample[6];
vector<uint32_t> crc16vec;

//reset value for headers and trailers check
seenHeadersAndTrailers = 0;

for (; data32_it != &data32tab[buf][nWords[buf]]; data32_it++) {
m_data32 = *data32_it; //put current 32-bit frame to union

if (m_data32 == 0xffaa0000) { // first part of FTB header
crc16vec.clear(); // clear the input container for crc16 calculation
crc16vec.push_back(m_data32);

seenHeadersAndTrailers++; // we found FTB header
seenHeadersAndTrailers |= 0x1; // we found FTB header

data32_it++; // go to 2nd part of FTB header
crc16vec.push_back(*data32_it);
Expand Down Expand Up @@ -290,7 +293,7 @@ void SVDUnpackerModule::event()

if (m_MainHeader.check == 6) { // FADC header

seenHeadersAndTrailers += 2; //we found FADC Header
seenHeadersAndTrailers |= 0x2; //we found FADC Header

fadc = m_MainHeader.FADCnum;
trgType = m_MainHeader.trgType;
Expand Down Expand Up @@ -437,7 +440,7 @@ void SVDUnpackerModule::event()

if (m_FADCTrailer.check == 14) { // FADC trailer

seenHeadersAndTrailers += 4; // we found FAD trailer
seenHeadersAndTrailers |= 0x4; // we found FADC trailer

//additional check if we have a faulty/fake FADC that is not in the map
if (APVmap->find(fadc) == APVmap->end()) badMapping = true;
Expand Down Expand Up @@ -503,7 +506,7 @@ void SVDUnpackerModule::event()

if (m_FTBTrailer.controlWord == 0xff55) {// FTB trailer

seenHeadersAndTrailers += 8; // we found FTB trailer
seenHeadersAndTrailers |= 0x8; // we found FTB trailer

//check CRC16
crc16vec.pop_back();
Expand All @@ -527,32 +530,28 @@ void SVDUnpackerModule::event()

} // end loop over 32-bit frames in each buffer

} // end iteration on 4(COPPER)/48(PCIe40) data buffers

//Let's check if all the headers and trailers were in place in the last frame
if (seenHeadersAndTrailers != 0xf) {
if (!(seenHeadersAndTrailers & 1)) {B2ERROR("Missing FTB Header is detected. SVD data might be corrupted!" << LogVar("Event number", eventNo) << LogVar("FADC", fadc)); missedHeader = true;}
if (!(seenHeadersAndTrailers & 2)) {B2ERROR("Missing FADC Header is detected -> related FADC number couldn't be retreived. SVD data might be corrupted! " << LogVar("Event number", eventNo) << LogVar("previous FADC", fadc)); missedHeader = true;}
if (!(seenHeadersAndTrailers & 4)) {B2ERROR("Missing FADC Trailer is detected. SVD data might be corrupted!" << LogVar("Event number", eventNo) << LogVar("FADC", fadc)); missedTrailer = true;}
if (!(seenHeadersAndTrailers & 8)) {B2ERROR("Missing FTB Trailer is detected. SVD data might be corrupted!" << LogVar("Event number", eventNo) << LogVar("FADC", fadc)); missedTrailer = true;}
}

//reset value for headers and trailers check
seenHeadersAndTrailers = 0;
//Let's check if all the headers and trailers were in place in the last frame
if (seenHeadersAndTrailers != 0xf) {
if (!(seenHeadersAndTrailers & 1)) {B2ERROR("Missing FTB Header is detected. SVD data might be corrupted!" << LogVar("Event number", eventNo) << LogVar("FADC", fadc)); missedHeader = true;}
if (!(seenHeadersAndTrailers & 2)) {B2ERROR("Missing FADC Header is detected -> related FADC number couldn't be retreived. SVD data might be corrupted! " << LogVar("Event number", eventNo) << LogVar("previous FADC", fadc)); missedHeader = true;}
if (!(seenHeadersAndTrailers & 4)) {B2ERROR("Missing FADC Trailer is detected. SVD data might be corrupted!" << LogVar("Event number", eventNo) << LogVar("FADC", fadc)); missedTrailer = true;}
if (!(seenHeadersAndTrailers & 8)) {B2ERROR("Missing FTB Trailer is detected. SVD data might be corrupted!" << LogVar("Event number", eventNo) << LogVar("FADC", fadc)); missedTrailer = true;}
}

for (auto p : vDiagnostic_ptr) {
// adding remaining info to Diagnostic object
p->setFTBFlags(ftbFlags);
p->setApvErrorOR(apvErrorsOR);
p->setAPVMatch(nAPVmatch);
p->setBadMapping(badMapping);
p->setBadTrailer(badTrailer);
p->setMissedHeader(missedHeader);
p->setMissedTrailer(missedTrailer);
for (auto p : vDiagnostic_ptr) {
// adding remaining info to Diagnostic object
p->setFTBFlags(ftbFlags);
p->setApvErrorOR(apvErrorsOR);
p->setAPVMatch(nAPVmatch);
p->setBadMapping(badMapping);
p->setBadTrailer(badTrailer);
p->setMissedHeader(missedHeader);
p->setMissedTrailer(missedTrailer);
}

}
vDiagnostic_ptr.clear();

vDiagnostic_ptr.clear();
} // end iteration on 4(COPPER)/48(PCIe40) data buffers

} // end event loop

Expand Down

0 comments on commit 938b323

Please sign in to comment.