Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:08:49

0001 #include "FWCore/Utilities/interface/Exception.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 
0004 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0005 #include "DataFormats/DetId/interface/DetId.h"
0006 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0007 
0008 #include "EventFilter/SiStripRawToDigi/interface/PipeAddrToTimeLookupTable.h"
0009 
0010 #include "DQM/SiStripMonitorHardware/interface/HistogramBase.hh"
0011 #include "DQM/SiStripMonitorHardware/interface/FEDErrors.hh"
0012 #include "DQM/SiStripCommon/interface/TkHistoMap.h"
0013 
0014 FEDErrors::FEDErrors() {
0015   //initialiseLumiBlock();
0016   initialiseEvent();
0017 }
0018 
0019 FEDErrors::~FEDErrors() {}
0020 
0021 void FEDErrors::initialiseLumiBlock() {}
0022 
0023 void FEDErrors::initialiseEvent() {
0024   fedID_ = 0;
0025   failUnpackerFEDCheck_ = false;
0026 
0027   connected_.clear();
0028   detid_.clear();
0029   nChInModule_.clear();
0030 
0031   subDetId_.clear();
0032 
0033   lFedCounter_.nFEDErrors = 0;
0034   lFedCounter_.nDAQProblems = 0;
0035   lFedCounter_.nFEDsWithFEProblems = 0;
0036   lFedCounter_.nCorruptBuffers = 0;
0037   lFedCounter_.nBadChannels = 0;
0038   lFedCounter_.nBadActiveChannels = 0;
0039   lFedCounter_.nFEDsWithFEOverflows = 0;
0040   lFedCounter_.nFEDsWithFEBadMajorityAddresses = 0;
0041   lFedCounter_.nFEDsWithMissingFEs = 0;
0042   lFedCounter_.nTotalBadChannels = 0;
0043   lFedCounter_.nTotalBadActiveChannels = 0;
0044 
0045   lChCounter_.nNotConnected = 0;
0046   lChCounter_.nUnlocked = 0;
0047   lChCounter_.nOutOfSync = 0;
0048   lChCounter_.nAPVStatusBit = 0;
0049   lChCounter_.nAPVError = 0;
0050   lChCounter_.nAPVAddressError = 0;
0051 
0052   feCounter_.nFEOverflows = 0;
0053   feCounter_.nFEBadMajorityAddresses = 0;
0054   feCounter_.nFEMissing = 0;
0055 
0056   fedErrors_.HasCabledChannels = false;
0057   fedErrors_.DataPresent = false;
0058   fedErrors_.DataMissing = false;
0059   fedErrors_.InvalidBuffers = false;
0060   fedErrors_.BadFEDCRCs = false;
0061   fedErrors_.BadDAQCRCs = false;
0062   fedErrors_.BadIDs = false;
0063   fedErrors_.BadDAQPacket = false;
0064   fedErrors_.CorruptBuffer = false;
0065   fedErrors_.FEsOverflow = false;
0066   fedErrors_.FEsMissing = false;
0067   fedErrors_.FEsBadMajorityAddress = false;
0068   fedErrors_.BadChannelStatusBit = false;
0069   fedErrors_.BadActiveChannelStatusBit = false;
0070 
0071   feErrors_.clear();
0072 
0073   chErrorsDetailed_.clear();
0074 
0075   apvErrors_.clear();
0076 
0077   chErrors_.clear();
0078 
0079   eventProp_.deltaBX = 0;
0080 }
0081 
0082 void FEDErrors::initialiseFED(const unsigned int aFedID,
0083                               const SiStripFedCabling* aCabling,
0084                               const TrackerTopology* tTopo,
0085                               const bool initVars) {
0086   fedID_ = aFedID;
0087   failUnpackerFEDCheck_ = false;
0088 
0089   //initialise first.  if no channel connected in one FE, subdetid =
0090   //0.  in the loop on channels, if at least one channel is connected
0091   //and has a valid ID, the subdet value will be changed to the right
0092   //one.
0093   if (initVars) {
0094     subDetId_.resize(sistrip::FEUNITS_PER_FED, 0);
0095 
0096     connected_.resize(sistrip::FEDCH_PER_FED, false);
0097     detid_.resize(sistrip::FEDCH_PER_FED, 0);
0098     nChInModule_.resize(sistrip::FEDCH_PER_FED, 0);
0099 
0100     for (unsigned int iCh = 0; iCh < sistrip::FEDCH_PER_FED; iCh++) {
0101       const FedChannelConnection& lConnection = aCabling->fedConnection(fedID_, iCh);
0102       connected_[iCh] = lConnection.isConnected();
0103       detid_[iCh] = lConnection.detId();
0104       nChInModule_[iCh] = lConnection.nApvPairs();
0105 
0106       unsigned short lFeNumber = static_cast<unsigned int>(iCh / sistrip::FEDCH_PER_FEUNIT);
0107       unsigned int lDetid = detid_[iCh];
0108 
0109       if (lDetid && lDetid != sistrip::invalid32_ && connected_[iCh]) {
0110         unsigned int lSubid = 6;
0111         // 3=TIB, 4=TID, 5=TOB, 6=TEC (TECB here)
0112         switch (DetId(lDetid).subdetId()) {
0113           case 3:
0114             lSubid = 2;  //TIB
0115             break;
0116 
0117           case 4: {
0118             if (tTopo->tidSide(lDetid) == 2)
0119               lSubid = 4;  //TIDF
0120             else
0121               lSubid = 3;  //TIDB
0122             break;
0123           }
0124 
0125           case 5:
0126             lSubid = 5;  //TOB
0127             break;
0128 
0129           case 6: {
0130             if (tTopo->tecSide(lDetid) == 2)
0131               lSubid = 1;  //TECF
0132             else
0133               lSubid = 0;  //TECB
0134             break;
0135           }
0136 
0137           default:
0138             lSubid = 6;
0139             break;
0140         }
0141         subDetId_[lFeNumber] = lSubid;
0142         //if (iCh%12==0) std::cout << fedID_ << " " << lFeNumber << " " << subDetId_[lFeNumber] << std::endl;
0143       }
0144     }
0145 
0146     feCounter_.nFEOverflows = 0;
0147     feCounter_.nFEBadMajorityAddresses = 0;
0148     feCounter_.nFEMissing = 0;
0149 
0150     fedErrors_.HasCabledChannels = false;
0151     fedErrors_.DataPresent = false;
0152     fedErrors_.DataMissing = false;
0153     fedErrors_.InvalidBuffers = false;
0154     fedErrors_.BadFEDCRCs = false;
0155     fedErrors_.BadDAQCRCs = false;
0156     fedErrors_.BadIDs = false;
0157     fedErrors_.BadDAQPacket = false;
0158     fedErrors_.CorruptBuffer = false;
0159     fedErrors_.FEsOverflow = false;
0160     fedErrors_.FEsMissing = false;
0161     fedErrors_.FEsBadMajorityAddress = false;
0162     fedErrors_.BadChannelStatusBit = false;
0163     fedErrors_.BadActiveChannelStatusBit = false;
0164 
0165     feErrors_.clear();
0166 
0167     chErrorsDetailed_.clear();
0168 
0169     apvErrors_.clear();
0170 
0171     chErrors_.clear();
0172   }
0173 }
0174 
0175 bool FEDErrors::checkDataPresent(const FEDRawData& aFedData) {
0176   if (!aFedData.size() || !aFedData.data()) {
0177     for (unsigned int iCh = 0; iCh < sistrip::FEDCH_PER_FED; iCh++) {
0178       if (connected_[iCh]) {
0179         fedErrors_.HasCabledChannels = true;
0180         fedErrors_.DataMissing = true;
0181         return false;
0182       }
0183     }
0184     fedErrors_.DataMissing = true;
0185     fedErrors_.HasCabledChannels = false;
0186     return false;
0187   } else {
0188     fedErrors_.DataPresent = true;
0189     for (unsigned int iCh = 0; iCh < sistrip::FEDCH_PER_FED; iCh++) {
0190       if (connected_[iCh]) {
0191         fedErrors_.HasCabledChannels = true;
0192         break;
0193       }
0194     }
0195     return true;
0196   }
0197 }
0198 
0199 bool FEDErrors::failUnpackerFEDCheck() { return failUnpackerFEDCheck_; }
0200 
0201 bool FEDErrors::fillFatalFEDErrors(const FEDRawData& aFedData, const unsigned int aPrintDebug) {
0202   const auto st_buffer = sistrip::preconstructCheckFEDBufferBase(aFedData);
0203   if (sistrip::FEDBufferStatusCode::SUCCESS != st_buffer) {
0204     fedErrors_.InvalidBuffers = true;
0205     failUnpackerFEDCheck_ = true;
0206     //don't check anything else if the buffer is invalid
0207     return false;
0208   }
0209   const sistrip::FEDBufferBase buffer{aFedData};
0210 
0211   //CRC checks
0212   //if CRC fails then don't continue as if the buffer has been corrupted in DAQ then anything else could be invalid
0213   if (!buffer.checkNoSlinkCRCError()) {
0214     fedErrors_.BadFEDCRCs = true;
0215     return false;
0216   } else if (!buffer.checkCRC()) {
0217     failUnpackerFEDCheck_ = true;
0218     fedErrors_.BadDAQCRCs = true;
0219     return false;
0220   }
0221   //next check that it is a SiStrip buffer
0222   //if not then stop checks
0223   if (!buffer.checkSourceIDs() || !buffer.checkNoUnexpectedSourceID()) {
0224     fedErrors_.BadIDs = true;
0225     return false;
0226   }
0227   //if so then do DAQ header/trailer checks
0228   //if these fail then buffer may be incomplete and checking contents doesn't make sense
0229   else if (!buffer.doDAQHeaderAndTrailerChecks()) {
0230     failUnpackerFEDCheck_ = true;
0231     fedErrors_.BadDAQPacket = true;
0232     return false;
0233   }
0234 
0235   //now do checks on header
0236   //check that tracker special header is consistent
0237   if (!(buffer.checkBufferFormat() && buffer.checkHeaderType() && buffer.checkReadoutMode())) {
0238     failUnpackerFEDCheck_ = true;
0239     fedErrors_.InvalidBuffers = true;
0240     //do not return false if debug printout of the buffer done below...
0241     if (!printDebug() || aPrintDebug < 3)
0242       return false;
0243   }
0244 
0245   //FE unit overflows
0246   if (!buffer.checkNoFEOverflows()) {
0247     failUnpackerFEDCheck_ = true;
0248     fedErrors_.FEsOverflow = true;
0249     //do not return false if debug printout of the buffer done below...
0250     if (!printDebug() || aPrintDebug < 3)
0251       return false;
0252   }
0253 
0254   return true;
0255 }
0256 
0257 bool FEDErrors::fillCorruptBuffer(const sistrip::FEDBuffer& aBuffer) {
0258   //corrupt buffer checks
0259   if (!(aBuffer.checkChannelLengthsMatchBufferLength() && aBuffer.checkChannelPacketCodes() &&
0260         aBuffer.checkFEUnitLengths())) {
0261     fedErrors_.CorruptBuffer = true;
0262 
0263     return false;
0264   }
0265 
0266   return true;
0267 }
0268 
0269 float FEDErrors::fillNonFatalFEDErrors(const sistrip::FEDBuffer* aBuffer, const SiStripFedCabling* aCabling) {
0270   unsigned int lBadChans = 0;
0271   unsigned int lTotChans = 0;
0272   for (unsigned int iCh = 0; iCh < sistrip::FEDCH_PER_FED; iCh++) {  //loop on channels
0273     bool lIsConnected = false;
0274     if (aCabling) {
0275       const FedChannelConnection& lConnection = aCabling->fedConnection(fedID_, iCh);
0276       lIsConnected = lConnection.isConnected();
0277     } else
0278       lIsConnected = connected_[iCh];
0279 
0280     if (!lIsConnected)
0281       continue;
0282     lTotChans++;
0283     if (!aBuffer->channelGood(iCh, true))
0284       lBadChans++;
0285   }
0286 
0287   return static_cast<float>(lBadChans * 1.0 / lTotChans);
0288 }
0289 
0290 bool FEDErrors::fillFEDErrors(const FEDRawData& aFedData,
0291                               bool& aFullDebug,
0292                               const unsigned int aPrintDebug,
0293                               unsigned int& aCounterMonitoring,
0294                               unsigned int& aCounterUnpacker,
0295                               const bool aDoMeds,
0296                               MonitorElement* aMedianHist0,
0297                               MonitorElement* aMedianHist1,
0298                               const bool aDoFEMaj,
0299                               std::vector<std::vector<std::pair<unsigned int, unsigned int> > >& aFeMajFrac) {
0300   //try to construct the basic buffer object (do not check payload)
0301   //if this fails then count it as an invalid buffer and stop checks since we can't understand things like buffer ordering
0302 
0303   if (!fillFatalFEDErrors(aFedData, aPrintDebug))
0304     return false;
0305 
0306   //need to construct full object to go any further
0307   const auto st_buffer = sistrip::preconstructCheckFEDBuffer(aFedData, true);
0308   if (sistrip::FEDBufferStatusCode::SUCCESS != st_buffer) {
0309     throw cms::Exception("FEDBuffer") << st_buffer << " (check debug output for more details)";
0310   }
0311   sistrip::FEDBuffer buffer{aFedData, true};
0312   buffer.findChannels();  // no need to check the status, also bad buffers are allowed
0313 
0314   //fill remaining unpackerFEDcheck
0315   if (!buffer.checkChannelLengths())
0316     failUnpackerFEDCheck_ = true;
0317 
0318   //payload checks, only if none of the above error occured
0319   if (!this->anyFEDErrors()) {
0320     bool lCorruptCheck = fillCorruptBuffer(buffer);
0321     if (aPrintDebug > 1 && !lCorruptCheck) {
0322       edm::LogWarning("SiStripMonitorHardware")
0323           << "CorruptBuffer check failed for FED " << fedID_ << std::endl
0324           << " -- buffer->checkChannelLengthsMatchBufferLength() = " << buffer.checkChannelLengthsMatchBufferLength()
0325           << std::endl
0326           << " -- buffer->checkChannelPacketCodes() = " << buffer.checkChannelPacketCodes() << std::endl
0327           << " -- buffer->checkFEUnitLengths() = " << buffer.checkFEUnitLengths() << std::endl;
0328     }
0329 
0330     //corruptBuffer concerns the payload: header info should still be reliable...
0331     //so analyze FE and channels to fill histograms.
0332 
0333     //fe check...
0334     fillFEErrors(buffer, aDoFEMaj, aFeMajFrac);
0335 
0336     //channel checks
0337     fillChannelErrors(
0338         buffer, aFullDebug, aPrintDebug, aCounterMonitoring, aCounterUnpacker, aDoMeds, aMedianHist0, aMedianHist1);
0339   }
0340 
0341   if (printDebug() && aPrintDebug > 2) {
0342     const sistrip::FEDBufferBase& debugBuffer = buffer;
0343 
0344     std::vector<FEDErrors::APVLevelErrors>& lChVec = getAPVLevelErrors();
0345     std::ostringstream debugStream;
0346     if (!lChVec.empty()) {
0347       std::sort(lChVec.begin(), lChVec.end());
0348       debugStream << "[FEDErrors] Cabled channels which had errors: ";
0349 
0350       for (unsigned int iBadCh(0); iBadCh < lChVec.size(); iBadCh++) {
0351         print(lChVec[iBadCh], debugStream);
0352       }
0353       debugStream << std::endl;
0354       debugStream << "[FEDErrors] Active (have been locked in at least one event) cabled channels which had errors: ";
0355       for (unsigned int iBadCh(0); iBadCh < lChVec.size(); iBadCh++) {
0356         if ((lChVec[iBadCh]).IsActive)
0357           print(lChVec[iBadCh], debugStream);
0358       }
0359     }
0360     debugStream << debugBuffer << std::endl;
0361     debugBuffer.dump(debugStream);
0362     debugStream << std::endl;
0363     edm::LogInfo("SiStripMonitorHardware") << "[FEDErrors] Errors found in FED " << fedID_;
0364     edm::LogVerbatim("SiStripMonitorHardware") << debugStream.str();
0365   }
0366 
0367   return !(anyFEDErrors());
0368 }
0369 
0370 bool FEDErrors::fillFEErrors(const sistrip::FEDBuffer& aBuffer,
0371                              const bool aDoFEMaj,
0372                              std::vector<std::vector<std::pair<unsigned int, unsigned int> > >& aFeMajFrac) {
0373   bool foundOverflow = false;
0374   bool foundBadMajority = false;
0375   bool foundMissing = false;
0376   for (unsigned int iFE = 0; iFE < sistrip::FEUNITS_PER_FED; iFE++) {
0377     FEDErrors::FELevelErrors lFeErr;
0378     lFeErr.FeID = iFE;
0379     lFeErr.SubDetID = subDetId_[iFE];
0380     lFeErr.Overflow = false;
0381     lFeErr.Missing = false;
0382     lFeErr.BadMajorityAddress = false;
0383     lFeErr.TimeDifference = 0;
0384     lFeErr.Apve = 0;
0385     lFeErr.FeMaj = 0;
0386     //check for cabled channels
0387     bool hasCabledChannels = false;
0388     for (unsigned int feUnitCh = 0; feUnitCh < sistrip::FEDCH_PER_FEUNIT; feUnitCh++) {
0389       if (connected_[iFE * sistrip::FEDCH_PER_FEUNIT + feUnitCh]) {
0390         hasCabledChannels = true;
0391         break;
0392       }
0393     }
0394 
0395     if (!hasCabledChannels)
0396       continue;
0397 
0398     if (aBuffer.feOverflow(iFE)) {
0399       lFeErr.Overflow = true;
0400       foundOverflow = true;
0401       addBadFE(lFeErr);
0402       //if FE overflowed then address isn't valid
0403       continue;
0404     }
0405     if (!aBuffer.feEnabled(iFE))
0406       continue;
0407 
0408     //check for missing data
0409     if (!aBuffer.fePresent(iFE)) {
0410       //if (hasCabledChannels) {
0411       lFeErr.Missing = true;
0412       foundMissing = true;
0413       addBadFE(lFeErr);
0414       //}
0415       continue;
0416     }
0417     //two independent checks for the majority address of a FE:
0418     //first is done inside the FED,
0419     //second is comparing explicitely the FE majAddress with the APVe address.
0420     //!aBuffer.checkFEUnitAPVAddresses(): for all FE's....
0421     //want to do it only for this FE... do it directly with the time difference.
0422     if (aBuffer.majorityAddressErrorForFEUnit(iFE)) {
0423       lFeErr.BadMajorityAddress = true;
0424       foundBadMajority = true;
0425       //no continue to fill the timeDifference.
0426     }
0427 
0428     //need fullDebugHeader to fill histo with time difference between APVe and FEmajAddress
0429     const sistrip::FEDFEHeader* header = aBuffer.feHeader();
0430     const sistrip::FEDFullDebugHeader* debugHeader = dynamic_cast<const sistrip::FEDFullDebugHeader*>(header);
0431     // if (debugHeader) {
0432     //   unsigned int apveTime = static_cast<unsigned int>(sistrip::FEDAddressConversion::timeLocation(aBuffer.apveAddress()));
0433     //   unsigned int feTime = static_cast<unsigned int>(sistrip::FEDAddressConversion::timeLocation(debugHeader->feUnitMajorityAddress(iFE)));
0434     //   if ((apveTime == 200 && aBuffer.apveAddress()) || feTime == 200) {
0435     //  std::cout << "FED " << fedID_ << ", iFE = " << iFE << std::endl
0436     //      << " -- aBuffer.apveAddress() = " << static_cast<unsigned int>(aBuffer.apveAddress())
0437     // //       << ", debugHeader = " << debugHeader
0438     // //       << ", header->feGood(iFE) = " << aBuffer.feGood(iFE)
0439     //          << ", debugHeader->feUnitMajorityAddress(iFE) " << static_cast<unsigned int>(debugHeader->feUnitMajorityAddress(iFE))
0440     //          << std::endl
0441     //          << " -- timeLoc(feUnitMajAddr) = "
0442     //          << static_cast<unsigned int>(sistrip::FEDAddressConversion::timeLocation(debugHeader->feUnitMajorityAddress(iFE)))
0443     //          << ", timeLoc(apveAddr) = "
0444     //          << static_cast<unsigned int>(sistrip::FEDAddressConversion::timeLocation(aBuffer.apveAddress()))
0445     // //       << ", aBuffer.checkFEUnitAPVAddresses() = "
0446     // //       << aBuffer.checkFEUnitAPVAddresses()
0447     //          << std::endl;
0448     //  std::cout << "My checks = "
0449     //      << ", feOverflows = " << lFeErr.Overflow << " " << foundOverflow
0450     //      << ", feMissing = " << lFeErr.Missing << " " << foundMissing
0451     //      << ", feBadMajAddr = " << lFeErr.BadMajorityAddress  << " " << foundBadMajority
0452     //      << std::endl;
0453 
0454     //  std::cout << "TimeDiff = " << feTime-apveTime << std::endl;
0455 
0456     //  //   std::cout << "aBuffer.checkFEUnitAPVAddresses() = " << aBuffer.checkFEUnitAPVAddresses() << std::endl;
0457     //   }
0458     // }
0459 
0460     lFeErr.Apve = aBuffer.apveAddress();
0461 
0462     if (debugHeader) {
0463       lFeErr.FeMaj = debugHeader->feUnitMajorityAddress(iFE);
0464 
0465       if (aDoFEMaj) {
0466         if (lFeErr.SubDetID == 2 || lFeErr.SubDetID == 3 || lFeErr.SubDetID == 4)
0467           aFeMajFrac[0].push_back(std::pair<unsigned int, unsigned int>(fedID_, lFeErr.FeMaj));
0468         else if (lFeErr.SubDetID == 5)
0469           aFeMajFrac[1].push_back(std::pair<unsigned int, unsigned int>(fedID_, lFeErr.FeMaj));
0470         else if (lFeErr.SubDetID == 0)
0471           aFeMajFrac[2].push_back(std::pair<unsigned int, unsigned int>(fedID_, lFeErr.FeMaj));
0472         else if (lFeErr.SubDetID == 1)
0473           aFeMajFrac[3].push_back(std::pair<unsigned int, unsigned int>(fedID_, lFeErr.FeMaj));
0474       }
0475 
0476       if (aBuffer.apveAddress()) {
0477         lFeErr.TimeDifference =  //0;
0478             static_cast<unsigned int>(
0479                 sistrip::FEDAddressConversion::timeLocation(debugHeader->feUnitMajorityAddress(iFE))) -
0480             static_cast<unsigned int>(sistrip::FEDAddressConversion::timeLocation(aBuffer.apveAddress()));
0481         //aBuffer.apveAddress(), debugHeader->feUnitMajorityAddress(iFE)
0482         //FEDAddressConversion::timeLocation(const uint8_t aPipelineAddress)
0483       }
0484     }
0485 
0486     if (foundBadMajority || lFeErr.TimeDifference != 0) {
0487       addBadFE(lFeErr);
0488 
0489       //      LogDebug("SiStripMonitorHardware") << " -- Problem found with FE maj address :" << std::endl
0490       //                     << " --- FED = " << fedID_
0491       //                     << ", iFE = " << iFE << std::endl
0492       //                     << " --- aBuffer.apveAddress() = " << static_cast<unsigned int>(aBuffer.apveAddress())
0493       //                     << std::endl
0494       //                     << " --- debugHeader->feUnitMajorityAddress(iFE) " << static_cast<unsigned int>(debugHeader->feUnitMajorityAddress(iFE))<< std::endl
0495       //                     << " --- timeLoc(feUnitMajAddr) = "
0496       //                     << static_cast<unsigned int>(sistrip::FEDAddressConversion::timeLocation(debugHeader->feUnitMajorityAddress(iFE)))<< std::endl
0497       //                     << " --- timeLoc(apveAddr) = "
0498       //                     << static_cast<unsigned int>(sistrip::FEDAddressConversion::timeLocation(aBuffer.apveAddress())) << std::endl
0499       //                     << " --- aBuffer.checkFEUnitAPVAddresses() = "
0500       //                     << aBuffer.checkFEUnitAPVAddresses()
0501       //                     << std::endl;
0502     }
0503   }
0504 
0505   return !(foundOverflow || foundMissing || foundBadMajority);
0506 }
0507 
0508 bool FEDErrors::fillChannelErrors(const sistrip::FEDBuffer& aBuffer,
0509                                   bool& aFullDebug,
0510                                   const unsigned int aPrintDebug,
0511                                   unsigned int& aCounterMonitoring,
0512                                   unsigned int& aCounterUnpacker,
0513                                   const bool aDoMeds,
0514                                   MonitorElement* aMedianHist0,
0515                                   MonitorElement* aMedianHist1) {
0516   bool foundError = false;
0517 
0518   const sistrip::FEDFEHeader* header = aBuffer.feHeader();
0519   const sistrip::FEDFullDebugHeader* debugHeader = dynamic_cast<const sistrip::FEDFullDebugHeader*>(header);
0520 
0521   aFullDebug = debugHeader;
0522 
0523   bool lMedValid = aBuffer.readoutMode() == sistrip::READOUT_MODE_ZERO_SUPPRESSED;
0524 
0525   //this method is not called if there was anyFEDerrors(),
0526   //so only corruptBuffer+FE check are useful.
0527   bool lPassedMonitoringFEDcheck = !fedErrors_.CorruptBuffer;
0528 
0529   for (unsigned int iCh = 0; iCh < sistrip::FEDCH_PER_FED; iCh++) {  //loop on channels
0530 
0531     bool lFailUnpackerChannelCheck = (!aBuffer.channelGood(iCh, true) && connected_[iCh]) || failUnpackerFEDCheck_;
0532     bool lFailMonitoringChannelCheck = !lPassedMonitoringFEDcheck && connected_[iCh];
0533 
0534     FEDErrors::ChannelLevelErrors lChErr;
0535     lChErr.ChannelID = iCh;
0536     lChErr.Connected = connected_[iCh];
0537     lChErr.IsActive = false;
0538     lChErr.Unlocked = false;
0539     lChErr.OutOfSync = false;
0540 
0541     if (!connected_[iCh]) {
0542       //to fill histo with unconnected channels
0543       addBadChannel(lChErr);
0544       foundError = true;
0545     } else {  //if channel connected
0546       if (!aBuffer.feGood(static_cast<unsigned int>(iCh / sistrip::FEDCH_PER_FEUNIT))) {
0547         lFailMonitoringChannelCheck = true;
0548         foundError = true;
0549       } else {  //if FE good
0550 
0551         bool apvBad[2] = {false, false};
0552         sistrip::FEDChannelStatus lStatus = sistrip::CHANNEL_STATUS_NO_PROBLEMS;
0553         //CHANNEL_STATUS_NO_PROBLEMS
0554         //CHANNEL_STATUS_LOCKED
0555         //CHANNEL_STATUS_IN_SYNC
0556         //CHANNEL_STATUS_APV1_ADDRESS_GOOD
0557         //CHANNEL_STATUS_APV1_NO_ERROR_BIT
0558         //CHANNEL_STATUS_APV0_ADDRESS_GOOD
0559         //CHANNEL_STATUS_APV0_NO_ERROR_BIT
0560 
0561         if (debugHeader) {
0562           lStatus = debugHeader->getChannelStatus(iCh);
0563           apvBad[0] = !(lStatus & sistrip::CHANNEL_STATUS_LOCKED) || !(lStatus & sistrip::CHANNEL_STATUS_IN_SYNC) ||
0564                       !(lStatus & sistrip::CHANNEL_STATUS_APV0_ADDRESS_GOOD) ||
0565                       !(lStatus & sistrip::CHANNEL_STATUS_APV0_NO_ERROR_BIT);
0566           apvBad[1] = !(lStatus & sistrip::CHANNEL_STATUS_LOCKED) || !(lStatus & sistrip::CHANNEL_STATUS_IN_SYNC) ||
0567                       !(lStatus & sistrip::CHANNEL_STATUS_APV1_ADDRESS_GOOD) ||
0568                       !(lStatus & sistrip::CHANNEL_STATUS_APV1_NO_ERROR_BIT);
0569           //if (!debugHeader->unlocked(iCh)) {
0570           if (lStatus & sistrip::CHANNEL_STATUS_LOCKED) {
0571             lChErr.IsActive = true;
0572             if (lStatus == sistrip::CHANNEL_STATUS_NO_PROBLEMS)
0573               continue;
0574             //if (debugHeader->outOfSyncFromBit(iCh)) {
0575             if (!(lStatus & sistrip::CHANNEL_STATUS_IN_SYNC)) {
0576               lChErr.OutOfSync = true;
0577             }
0578           } else {
0579             lChErr.Unlocked = true;
0580           }
0581         } else {
0582           //if (header->checkChannelStatusBits(iCh)) activeChannel = true;
0583           apvBad[0] = !header->checkStatusBits(iCh, 0);
0584           apvBad[1] = !header->checkStatusBits(iCh, 1);
0585           if (!apvBad[0] && !apvBad[1]) {
0586             lChErr.IsActive = true;
0587             continue;
0588           }
0589         }
0590 
0591         if (lChErr.Unlocked || lChErr.OutOfSync)
0592           addBadChannel(lChErr);
0593 
0594         //std::ostringstream lMode;
0595         //lMode << aBuffer.readoutMode();
0596 
0597         bool lFirst = true;
0598 
0599         for (unsigned int iAPV = 0; iAPV < 2; iAPV++) {  //loop on APVs
0600 
0601           FEDErrors::APVLevelErrors lAPVErr;
0602           lAPVErr.APVID = 2 * iCh + iAPV;
0603           lAPVErr.ChannelID = iCh;
0604           lAPVErr.Connected = connected_[iCh];
0605           lAPVErr.IsActive = lChErr.IsActive;
0606           lAPVErr.APVStatusBit = false;
0607           lAPVErr.APVError = false;
0608           lAPVErr.APVAddressError = false;
0609 
0610           //if (!header->checkStatusBits(iCh,iAPV)){
0611           if (apvBad[iAPV]) {
0612             lFailMonitoringChannelCheck = true;
0613             lAPVErr.APVStatusBit = true;
0614             foundError = true;
0615           }
0616 
0617           if (debugHeader && !lChErr.Unlocked && !lChErr.OutOfSync) {
0618             //if (debugHeader->apvErrorFromBit(iCh,iAPV)) {
0619             if ((iAPV == 0 && !(lStatus & sistrip::CHANNEL_STATUS_APV0_NO_ERROR_BIT)) ||
0620                 (iAPV == 1 && !(lStatus & sistrip::CHANNEL_STATUS_APV1_NO_ERROR_BIT))) {
0621               lAPVErr.APVError = true;
0622             }
0623             //if (debugHeader->apvAddressErrorFromBit(iCh,iAPV)) {
0624             if ((iAPV == 0 && !(lStatus & sistrip::CHANNEL_STATUS_APV0_ADDRESS_GOOD)) ||
0625                 (iAPV == 1 && !(lStatus & sistrip::CHANNEL_STATUS_APV1_ADDRESS_GOOD))) {
0626               lAPVErr.APVAddressError = true;
0627             }
0628           }
0629 
0630           if (lAPVErr.APVStatusBit || lAPVErr.APVError || lAPVErr.APVAddressError)
0631             addBadAPV(lAPVErr, lFirst);
0632         }  //loop on APVs
0633 
0634       }  //if FE good
0635     }    //if connected
0636 
0637     if (lFailUnpackerChannelCheck != lFailMonitoringChannelCheck && connected_[iCh]) {
0638       if (aPrintDebug > 1) {
0639         std::ostringstream debugStream;
0640         debugStream << "[FEDErrors] ------ WARNING: FED " << fedID_ << ", channel " << iCh
0641                     << ", isConnected = " << connected_[iCh] << std::endl
0642                     << "[FEDErrors] --------- Monitoring Channel check ";
0643         if (lFailMonitoringChannelCheck)
0644           debugStream << "failed." << std::endl;
0645         else
0646           debugStream << "passed." << std::endl;
0647         debugStream << "[FEDErrors] --------- Unpacker Channel check ";
0648         if (lFailUnpackerChannelCheck)
0649           debugStream << "failed." << std::endl;
0650         else
0651           debugStream << "passed." << std::endl;
0652         debugStream << "[FEDErrors] --------- fegood = "
0653                     << aBuffer.feGood(static_cast<unsigned int>(iCh / sistrip::FEDCH_PER_FEUNIT)) << std::endl
0654                     << "[FEDErrors] --------- unpacker FED check = " << failUnpackerFEDCheck_ << std::endl;
0655         edm::LogError("SiStripMonitorHardware") << debugStream.str();
0656       }
0657 
0658       if (lFailMonitoringChannelCheck)
0659         aCounterMonitoring++;
0660       if (lFailUnpackerChannelCheck)
0661         aCounterUnpacker++;
0662     }
0663 
0664     if (lMedValid && !foundError && lPassedMonitoringFEDcheck && aDoMeds) {
0665       //get CM values
0666       const sistrip::FEDChannel& lChannel = aBuffer.channel(iCh);
0667 
0668       HistogramBase::fillHistogram(aMedianHist0, lChannel.cmMedian(0));
0669       HistogramBase::fillHistogram(aMedianHist1, lChannel.cmMedian(1));
0670     }
0671 
0672   }  //loop on channels
0673 
0674   return !foundError;
0675 }
0676 
0677 void FEDErrors::fillBadChannelList(const bool doTkHistoMap,
0678                                    TkHistoMap* aTkMapPointer,
0679                                    MonitorElement* aFedIdVsApvId,
0680                                    unsigned int& aNBadChannels,
0681                                    unsigned int& aNBadActiveChannels,
0682                                    unsigned int& aNBadChannels_perFEDID,
0683                                    std::vector<unsigned int>& nTotal,
0684                                    std::vector<unsigned int>& nErrors) {
0685   uint32_t lPrevId = 0;
0686   uint16_t nBad = 0;
0687   uint16_t lPrevTot = 0;
0688   bool hasBeenProcessed = false;
0689   bool lFailFED = failMonitoringFEDCheck();
0690 
0691   for (unsigned int iCh = 0; iCh < sistrip::FEDCH_PER_FED; iCh++) {  //loop on channels
0692 
0693     if (!connected_[iCh])
0694       continue;
0695     if (!detid_[iCh] || detid_[iCh] == sistrip::invalid32_)
0696       continue;
0697 
0698     if (lPrevId == 0) {
0699       lPrevId = detid_[iCh];
0700       lPrevTot = nChInModule_[iCh];
0701     }
0702 
0703     unsigned int feNumber = static_cast<unsigned int>(iCh / sistrip::FEDCH_PER_FEUNIT);
0704 
0705     bool isBadFE = false;
0706     bool isMissingFE = false;
0707     //feErrors vector of FE 0 - 7, each FE has channels 0 -11, 12 .. - ,... - 96
0708     for (unsigned int badfe(0); badfe < feErrors_.size(); badfe++) {
0709       if ((feErrors_[badfe]).FeID == feNumber) {
0710         isBadFE = true;
0711         if ((feErrors_[badfe]).Missing)
0712           isMissingFE = true;
0713         break;
0714       }
0715     }
0716 
0717     bool isBadChan = false;
0718     bool isActiveChan = false;
0719     //FED errors, apv
0720     //for (unsigned int badCh(0); badCh<chErrors_.size(); badCh++) {
0721     //if (chErrors_[badCh].first == iCh) {
0722     //if (chErrors_[badCh].second) isActiveChan = true;
0723     //isBadChan = true;
0724     //break;
0725     //}
0726     //}
0727 
0728     //apvErrors_
0729     bool isBadApv1 = false;
0730     bool isBadApv2 = false;
0731     for (unsigned int badApv(0); badApv < apvErrors_.size(); badApv++) {
0732       if ((apvErrors_[badApv]).ChannelID == iCh) {
0733         isBadChan = true;
0734         if (apvErrors_[badApv].IsActive)
0735           isActiveChan = true;
0736       }
0737       if (apvErrors_[badApv].APVID == 2 * iCh)
0738         isBadApv1 = true;
0739       if (apvErrors_[badApv].APVID == 2 * iCh + 1) {
0740         isBadApv2 = true;
0741         break;
0742       }
0743     }
0744 
0745     if (detid_[iCh] == lPrevId) {
0746       if (hasBeenProcessed)
0747         hasBeenProcessed = false;
0748     }
0749     //fill vector for previous detid
0750     if (detid_[iCh] != lPrevId) {
0751       processDet(lPrevId, lPrevTot, doTkHistoMap, nBad, aTkMapPointer);
0752       lPrevId = detid_[iCh];
0753       lPrevTot = nChInModule_[iCh];
0754       hasBeenProcessed = true;
0755     }
0756 
0757     bool lHasErr = lFailFED || isBadFE || isBadChan;
0758     incrementLumiErrors(lHasErr, subDetId_[feNumber], nTotal, nErrors);
0759 
0760     if (lHasErr) {
0761       nBad++;
0762       aNBadChannels++;
0763       aNBadChannels_perFEDID = aNBadChannels_perFEDID + 1;
0764       //define as active channel if channel locked AND not from an unlocked FE.
0765       if ((isBadChan && isActiveChan) || lFailFED || (isBadFE && !isMissingFE))
0766         aNBadActiveChannels++;
0767       if (isBadApv1 || lFailFED || isBadFE)
0768         HistogramBase::fillHistogram(aFedIdVsApvId, 2 * iCh, fedID_);
0769       if (isBadApv2 || lFailFED || isBadFE)
0770         HistogramBase::fillHistogram(aFedIdVsApvId, 2 * iCh + 1, fedID_);
0771     }
0772 
0773   }  //loop on channels
0774 
0775   if (!hasBeenProcessed) {
0776     processDet(lPrevId, lPrevTot, doTkHistoMap, nBad, aTkMapPointer);
0777   }
0778 }
0779 
0780 void FEDErrors::fillEventProperties(long long dbx) { eventProp_.deltaBX = dbx; }
0781 
0782 void FEDErrors::incrementLumiErrors(const bool hasError,
0783                                     const unsigned int aSubDet,
0784                                     std::vector<unsigned int>& nTotal,
0785                                     std::vector<unsigned int>& nErrors) {
0786   if (nTotal.empty())
0787     return;
0788   if (aSubDet >= nTotal.size()) {
0789     edm::LogError("SiStripMonitorHardware") << " -- FED " << fedID_ << ", invalid subdetid : " << aSubDet
0790                                             << ", size of lumiErr : " << nTotal.size() << std::endl;
0791   } else {
0792     if (hasError)
0793       nErrors[aSubDet]++;
0794     nTotal[aSubDet]++;
0795   }
0796 }
0797 
0798 void FEDErrors::processDet(const uint32_t aPrevId,
0799                            const uint16_t aPrevTot,
0800                            const bool doTkHistoMap,
0801                            uint16_t& nBad,
0802                            TkHistoMap* aTkMapPointer) {
0803   if (aPrevTot < nBad) {
0804     edm::LogError("SiStripMonitorHardware") << " -- Number of bad channels in det " << aPrevId << " = " << nBad
0805                                             << ", total number of pairs for this det = " << aPrevTot << std::endl;
0806   }
0807 
0808   //tkHistoMap takes a uint & as argument
0809   uint32_t lDetid = aPrevId;
0810   if (aPrevTot != 0 && doTkHistoMap && aTkMapPointer)
0811     HistogramBase::fillTkHistoMap(aTkMapPointer, lDetid, static_cast<float>(nBad) / aPrevTot);
0812 
0813   nBad = 0;
0814 }
0815 
0816 const bool FEDErrors::failMonitoringFEDCheck() { return (anyFEDErrors() || fedErrors_.CorruptBuffer); }
0817 
0818 const bool FEDErrors::anyDAQProblems() {
0819   return (fedErrors_.DataMissing || fedErrors_.InvalidBuffers || fedErrors_.BadFEDCRCs || fedErrors_.BadDAQCRCs ||
0820           fedErrors_.BadIDs || fedErrors_.BadDAQPacket);
0821 }
0822 
0823 const bool FEDErrors::anyFEDErrors() {
0824   return (fedErrors_.InvalidBuffers || fedErrors_.BadFEDCRCs || fedErrors_.BadDAQCRCs || fedErrors_.BadIDs ||
0825           fedErrors_.BadDAQPacket || fedErrors_.FEsOverflow);
0826 }
0827 
0828 const bool FEDErrors::anyFEProblems() {
0829   return (fedErrors_.FEsOverflow || fedErrors_.FEsMissing || fedErrors_.FEsBadMajorityAddress);
0830 }
0831 
0832 const bool FEDErrors::printDebug() {
0833   return (anyFEDErrors() || anyFEProblems() || fedErrors_.CorruptBuffer || fedErrors_.BadChannelStatusBit);
0834 }
0835 
0836 const unsigned int FEDErrors::fedID() { return fedID_; }
0837 
0838 FEDErrors::FEDCounters& FEDErrors::getFEDErrorsCounters() { return lFedCounter_; }
0839 
0840 FEDErrors::ChannelCounters& FEDErrors::getChannelErrorsCounters() { return lChCounter_; }
0841 
0842 FEDErrors::FECounters& FEDErrors::getFEErrorsCounters() { return feCounter_; }
0843 
0844 FEDErrors::FEDLevelErrors& FEDErrors::getFEDLevelErrors() { return fedErrors_; }
0845 
0846 FEDErrors::EventProperties& FEDErrors::getEventProperties() { return eventProp_; }
0847 
0848 std::vector<FEDErrors::FELevelErrors>& FEDErrors::getFELevelErrors() { return feErrors_; }
0849 
0850 std::vector<FEDErrors::ChannelLevelErrors>& FEDErrors::getChannelLevelErrors() { return chErrorsDetailed_; }
0851 
0852 std::vector<FEDErrors::APVLevelErrors>& FEDErrors::getAPVLevelErrors() { return apvErrors_; }
0853 
0854 std::vector<std::pair<unsigned int, bool> >& FEDErrors::getBadChannels() { return chErrors_; }
0855 
0856 void FEDErrors::addBadFE(const FEDErrors::FELevelErrors& aFE) {
0857   if (aFE.Overflow) {
0858     fedErrors_.FEsOverflow = true;
0859     (feCounter_.nFEOverflows)++;
0860   } else if (aFE.Missing) {
0861     fedErrors_.FEsMissing = true;
0862     (feCounter_.nFEMissing)++;
0863     feErrors_.push_back(aFE);
0864   } else if (aFE.BadMajorityAddress) {
0865     fedErrors_.FEsBadMajorityAddress = true;
0866     (feCounter_.nFEBadMajorityAddresses)++;
0867     feErrors_.push_back(aFE);
0868   } else if (aFE.TimeDifference != 0) {
0869     feErrors_.push_back(aFE);
0870   }
0871 }
0872 
0873 void FEDErrors::addBadChannel(const FEDErrors::ChannelLevelErrors& aChannel) {
0874   if (aChannel.Connected)
0875     chErrorsDetailed_.push_back(aChannel);
0876   incrementChannelCounters(aChannel);
0877 }
0878 
0879 void FEDErrors::addBadAPV(const FEDErrors::APVLevelErrors& aAPV, bool& aFirst) {
0880   apvErrors_.push_back(aAPV);
0881   incrementAPVCounters(aAPV);
0882   if (aAPV.APVStatusBit && aFirst) {
0883     fedErrors_.BadChannelStatusBit = true;
0884     lFedCounter_.nBadChannels++;
0885     chErrors_.push_back(std::pair<unsigned int, bool>(aAPV.ChannelID, aAPV.IsActive));
0886     if (aAPV.IsActive) {
0887       //print(aAPV);
0888       fedErrors_.BadActiveChannelStatusBit = true;
0889       lFedCounter_.nBadActiveChannels++;
0890       //std::cout << "------ nBadActiveChannels = " << FEDErrors::getFEDErrorsCounters().nBadActiveChannels << std::endl;
0891     }
0892     aFirst = false;
0893   }
0894 }
0895 
0896 void FEDErrors::incrementFEDCounters() {
0897   if (fedErrors_.InvalidBuffers || fedErrors_.BadFEDCRCs || fedErrors_.BadDAQCRCs || fedErrors_.BadIDs ||
0898       fedErrors_.BadDAQPacket) {
0899     lFedCounter_.nDAQProblems++;
0900     lFedCounter_.nFEDErrors++;
0901   }
0902 
0903   //FElevel errors
0904   if (fedErrors_.FEsOverflow) {
0905     lFedCounter_.nFEDsWithFEOverflows++;
0906   } else if (fedErrors_.FEsMissing) {
0907     lFedCounter_.nFEDsWithMissingFEs++;
0908   } else if (fedErrors_.FEsBadMajorityAddress) {
0909     lFedCounter_.nFEDsWithFEBadMajorityAddresses++;
0910   }
0911 
0912   if (fedErrors_.FEsOverflow || fedErrors_.FEsBadMajorityAddress || fedErrors_.FEsMissing) {
0913     lFedCounter_.nFEDsWithFEProblems++;
0914     lFedCounter_.nFEDErrors++;
0915   } else if (fedErrors_.CorruptBuffer) {
0916     lFedCounter_.nCorruptBuffers++;
0917     lFedCounter_.nFEDErrors++;
0918   }
0919 }
0920 
0921 void FEDErrors::incrementChannelCounters(const FEDErrors::ChannelLevelErrors& aChannel) {
0922   if (aChannel.Unlocked && aChannel.Connected)
0923     lChCounter_.nUnlocked++;
0924   if (aChannel.OutOfSync && aChannel.Connected)
0925     lChCounter_.nOutOfSync++;
0926   if (!aChannel.Connected)
0927     lChCounter_.nNotConnected++;
0928 }
0929 
0930 void FEDErrors::incrementAPVCounters(const FEDErrors::APVLevelErrors& aAPV) {
0931   if (aAPV.Connected && aAPV.IsActive) {
0932     if (aAPV.APVStatusBit)
0933       lChCounter_.nAPVStatusBit++;
0934     if (aAPV.APVAddressError)
0935       lChCounter_.nAPVAddressError++;
0936     if (aAPV.APVError)
0937       lChCounter_.nAPVError++;
0938   }
0939 }
0940 
0941 bool FEDErrors::ChannelLevelErrors::operator<(const FEDErrors::ChannelLevelErrors& aErr) const {
0942   if (this->ChannelID < aErr.ChannelID)
0943     return true;
0944   return false;
0945 }
0946 
0947 bool FEDErrors::APVLevelErrors::operator<(const FEDErrors::APVLevelErrors& aErr) const {
0948   if (this->ChannelID < aErr.ChannelID)
0949     return true;
0950   return false;
0951 }
0952 
0953 void FEDErrors::print(const FEDErrors::FEDCounters& aFEDCounter, std::ostream& aOs) {
0954   aOs << std::endl;
0955   aOs << "[FEDErrors]============================================" << std::endl
0956       << "[FEDErrors]==== Printing FEDCounters information : ====" << std::endl
0957       << "[FEDErrors]============================================" << std::endl
0958       << "[FEDErrors]======== nFEDErrors = " << aFEDCounter.nFEDErrors << std::endl
0959       << "[FEDErrors]======== nDAQProblems = " << aFEDCounter.nDAQProblems << std::endl
0960       << "[FEDErrors]======== nFEDsWithFEProblems = " << aFEDCounter.nFEDsWithFEProblems << std::endl
0961       << "[FEDErrors]======== nCorruptBuffers = " << aFEDCounter.nCorruptBuffers << std::endl
0962       << "[FEDErrors]======== nBadChannels = " << aFEDCounter.nBadChannels << std::endl
0963       << "[FEDErrors]======== nBadActiveChannels = " << aFEDCounter.nBadActiveChannels << std::endl
0964       << "[FEDErrors]======== nFEDsWithFEOverflows = " << aFEDCounter.nFEDsWithFEOverflows << std::endl
0965       << "[FEDErrors]======== nFEDsWithFEBadMajorityAddresses = " << aFEDCounter.nFEDsWithFEBadMajorityAddresses
0966       << std::endl
0967       << "[FEDErrors]======== nFEDsWithMissingFEs = " << aFEDCounter.nFEDsWithMissingFEs << std::endl
0968       << "[FEDErrors]======== nTotalBadChannels = " << aFEDCounter.nTotalBadChannels << std::endl
0969       << "[FEDErrors]======== nTotalBadActiveChannels = " << aFEDCounter.nTotalBadActiveChannels << std::endl
0970       << "[FEDErrors]============================================" << std::endl;
0971 }
0972 
0973 void FEDErrors::print(const FEDErrors::FECounters& aFECounter, std::ostream& aOs) {
0974   aOs << std::endl;
0975   aOs << "[FEDErrors]============================================" << std::endl
0976       << "[FEDErrors]==== Printing FECounters information :  ====" << std::endl
0977       << "[FEDErrors]============================================" << std::endl
0978       << "[FEDErrors]======== nFEOverflows = " << aFECounter.nFEOverflows << std::endl
0979       << "[FEDErrors]======== nFEBadMajorityAddresses = " << aFECounter.nFEBadMajorityAddresses << std::endl
0980       << "[FEDErrors]======== nFEMissing = " << aFECounter.nFEMissing << std::endl
0981       << "[FEDErrors]============================================" << std::endl;
0982 }
0983 
0984 void FEDErrors::print(const FEDErrors::FEDLevelErrors& aFEDErr, std::ostream& aOs) {
0985   aOs << std::endl;
0986   aOs << "[FEDErrors]============================================" << std::endl
0987       << "[FEDErrors]==== Printing FED errors information :  ====" << std::endl
0988       << "[FEDErrors]============================================" << std::endl
0989       << "[FEDErrors]======== HasCabledChannels = " << aFEDErr.HasCabledChannels << std::endl
0990       << "[FEDErrors]======== DataPresent = " << aFEDErr.DataPresent << std::endl
0991       << "[FEDErrors]======== DataMissing = " << aFEDErr.DataMissing << std::endl
0992       << "[FEDErrors]======== InvalidBuffers = " << aFEDErr.InvalidBuffers << std::endl
0993       << "[FEDErrors]======== BadFEDCRCs = " << aFEDErr.BadFEDCRCs << std::endl
0994       << "[FEDErrors]======== BadDAQCRCs = " << aFEDErr.BadDAQCRCs << std::endl
0995       << "[FEDErrors]======== BadIDs = " << aFEDErr.BadIDs << std::endl
0996       << "[FEDErrors]======== BadDAQPacket = " << aFEDErr.BadDAQPacket << std::endl
0997       << "[FEDErrors]======== CorruptBuffer = " << aFEDErr.CorruptBuffer << std::endl
0998       << "[FEDErrors]======== FEOverflows = " << aFEDErr.FEsOverflow << std::endl
0999       << "[FEDErrors]======== FEMissing = " << aFEDErr.FEsMissing << std::endl
1000       << "[FEDErrors]======== BadMajorityAddresses = " << aFEDErr.FEsBadMajorityAddress << std::endl
1001       << "[FEDErrors]============================================" << std::endl;
1002 }
1003 
1004 void FEDErrors::print(const FEDErrors::FELevelErrors& aErr, std::ostream& aOs) {
1005   aOs << std::endl;
1006   aOs << "[FEDErrors]============================================" << std::endl
1007       << "[FEDErrors]==== Printing FE errors information :   ====" << std::endl
1008       << "[FEDErrors]============================================" << std::endl
1009       << "[FEDErrors]======== FE #" << aErr.FeID << std::endl
1010       << "[FEDErrors]======== subdet " << aErr.SubDetID << std::endl
1011       << "[FEDErrors]======== FEOverflow = " << aErr.Overflow << std::endl
1012       << "[FEDErrors]======== FEMissing = " << aErr.Missing << std::endl
1013       << "[FEDErrors]======== BadMajorityAddresses = " << aErr.BadMajorityAddress << std::endl
1014       << "[FEDErrors]======== TimeDifference = " << aErr.TimeDifference << std::endl
1015       << "[FEDErrors]============================================" << std::endl;
1016 }
1017 
1018 void FEDErrors::print(const FEDErrors::ChannelLevelErrors& aErr, std::ostream& aOs) {
1019   aOs << std::endl;
1020   aOs << "[FEDErrors]=================================================" << std::endl
1021       << "[FEDErrors]==== Printing channel errors information :   ====" << std::endl
1022       << "[FEDErrors]=================================================" << std::endl
1023       << "[FEDErrors]============ Channel #" << aErr.ChannelID << std::endl
1024       << "[FEDErrors]============ connected  = " << aErr.Connected << std::endl
1025       << "[FEDErrors]============ isActive  = " << aErr.IsActive << std::endl
1026       << "[FEDErrors]============ Unlocked = " << aErr.Unlocked << std::endl
1027       << "[FEDErrors]============ OutOfSync = " << aErr.OutOfSync << std::endl
1028       << "[FEDErrors]=================================================" << std::endl;
1029 }
1030 
1031 void FEDErrors::print(const FEDErrors::APVLevelErrors& aErr, std::ostream& aOs) {
1032   aOs << std::endl;
1033   aOs << "[FEDErrors]=================================================" << std::endl
1034       << "[FEDErrors]==== Printing APV errors information :       ====" << std::endl
1035       << "[FEDErrors]=================================================" << std::endl
1036       << "[FEDErrors]============ APV #" << aErr.APVID << std::endl
1037       << "[FEDErrors]============ Channel #" << aErr.ChannelID << std::endl
1038       << "[FEDErrors]============ connected  = " << aErr.Connected << std::endl
1039       << "[FEDErrors]============ isActive  = " << aErr.IsActive << std::endl
1040       << "[FEDErrors]============ APVStatusBit = " << aErr.APVStatusBit << std::endl
1041       << "[FEDErrors]============ APVError = " << aErr.APVError << std::endl
1042       << "[FEDErrors]============ APVAddressError = " << aErr.APVAddressError << std::endl
1043       << "[FEDErrors]=================================================" << std::endl;
1044 }