Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:43:31

0001 // -*- C++ -*-
0002 //
0003 // Package:    DQM/SiStripMonitorHardware
0004 // Class:      FEDErrors
0005 //
0006 /**\class FEDErrors DQM/SiStripMonitorHardware/interface/FEDErrors.hh
0007 
0008  Description: class summarising FED errors
0009 */
0010 //
0011 // Original Author:  Nicholas Cripps in plugin file
0012 //         Created:  2008/09/16
0013 // Modified by    :  Anne-Marie Magnan, code copied from plugin to this class
0014 //
0015 
0016 #ifndef DQM_SiStripMonitorHardware_FEDErrors_HH
0017 #define DQM_SiStripMonitorHardware_FEDErrors_HH
0018 
0019 #include <sstream>
0020 #include <iostream>
0021 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0022 
0023 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
0024 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0025 
0026 #include "DQMServices/Core/interface/DQMStore.h"
0027 
0028 #include "CondFormats/SiStripObjects/interface/SiStripFedCabling.h"
0029 
0030 #include "EventFilter/SiStripRawToDigi/interface/SiStripFEDBuffer.h"
0031 
0032 class TkHistoMap;
0033 class TrackerTopology;
0034 
0035 class FEDErrors {
0036 public:
0037   typedef dqm::legacy::MonitorElement MonitorElement;
0038   typedef dqm::legacy::DQMStore DQMStore;
0039 
0040   struct FEDCounters {
0041     unsigned int nFEDErrors;
0042     unsigned int nDAQProblems;
0043     unsigned int nFEDsWithFEProblems;
0044     unsigned int nCorruptBuffers;
0045     unsigned int nBadChannels;
0046     unsigned int nBadActiveChannels;
0047     unsigned int nFEDsWithFEOverflows;
0048     unsigned int nFEDsWithFEBadMajorityAddresses;
0049     unsigned int nFEDsWithMissingFEs;
0050     unsigned int nTotalBadChannels;
0051     unsigned int nTotalBadActiveChannels;
0052   };
0053 
0054   struct ChannelCounters {
0055     unsigned int nNotConnected;
0056     unsigned int nUnlocked;
0057     unsigned int nOutOfSync;
0058     unsigned int nAPVStatusBit;
0059     unsigned int nAPVError;
0060     unsigned int nAPVAddressError;
0061   };
0062 
0063   struct FECounters {
0064     unsigned int nFEOverflows;
0065     unsigned int nFEBadMajorityAddresses;
0066     unsigned int nFEMissing;
0067   };
0068 
0069   struct FEDLevelErrors {
0070     bool HasCabledChannels;
0071     bool DataPresent;
0072     bool DataMissing;
0073     bool InvalidBuffers;
0074     bool BadFEDCRCs;
0075     bool BadDAQCRCs;
0076     bool BadIDs;
0077     bool BadDAQPacket;
0078     bool CorruptBuffer;
0079     bool FEsOverflow;
0080     bool FEsMissing;
0081     bool FEsBadMajorityAddress;
0082     bool BadChannelStatusBit;
0083     bool BadActiveChannelStatusBit;
0084   };
0085 
0086   struct FELevelErrors {
0087     unsigned short FeID;
0088     unsigned short SubDetID;
0089     bool Overflow;
0090     bool Missing;
0091     bool BadMajorityAddress;
0092     int TimeDifference;
0093     unsigned int Apve;
0094     unsigned int FeMaj;
0095   };
0096 
0097   struct ChannelLevelErrors {
0098     unsigned int ChannelID;
0099     bool Connected;
0100     bool IsActive;
0101     bool Unlocked;
0102     bool OutOfSync;
0103     bool operator<(const ChannelLevelErrors& aErr) const;
0104   };
0105 
0106   struct APVLevelErrors {
0107     unsigned int APVID;
0108     unsigned int ChannelID;
0109     bool Connected;
0110     bool IsActive;
0111     bool APVStatusBit;
0112     bool APVError;
0113     bool APVAddressError;
0114 
0115     bool operator<(const APVLevelErrors& aErr) const;
0116   };
0117 
0118   struct EventProperties {
0119     long long deltaBX;
0120   };
0121 
0122   FEDErrors();
0123 
0124   ~FEDErrors();
0125 
0126   void initialiseLumiBlock();
0127 
0128   void initialiseEvent();
0129 
0130   void initialiseFED(const unsigned int aFedID,
0131                      const SiStripFedCabling* aCabling,
0132                      const TrackerTopology* tTopo,
0133                      bool initVars = true);
0134 
0135   //return false if no data, with or without cabled channels.
0136   bool checkDataPresent(const FEDRawData& aFedData);
0137 
0138   //perform a sanity check with unpacking code check
0139   bool failUnpackerFEDCheck();
0140 
0141   //return true if there were no errors at the level they are analysing
0142   //ie analyze FED returns true if there were no FED level errors which prevent the whole FED being unpacked
0143   bool fillFatalFEDErrors(const FEDRawData& aFedData, const unsigned int aPrintDebug);
0144 
0145   //expensive check: fatal but kept separate
0146   bool fillCorruptBuffer(const sistrip::FEDBuffer& aBuffer);
0147 
0148   //FE/Channel check: rate of channels with error (only considering connected channels)
0149   float fillNonFatalFEDErrors(const sistrip::FEDBuffer* aBuffer, const SiStripFedCabling* aCabling = nullptr);
0150 
0151   //fill errors: define the order of importance.
0152   bool fillFEDErrors(const FEDRawData& aFedData,
0153                      bool& aFullDebug,
0154                      const unsigned int aPrintDebug,
0155                      unsigned int& aCounterMonitoring,
0156                      unsigned int& aCounterUnpacker,
0157                      const bool aDoMeds,
0158                      MonitorElement* aMedianHist0,
0159                      MonitorElement* aMedianHist1,
0160                      const bool aDoFEMaj,
0161                      std::vector<std::vector<std::pair<unsigned int, unsigned int> > >& aFeMajFrac);
0162 
0163   bool fillFEErrors(const sistrip::FEDBuffer& aBuffer,
0164                     const bool aDoFEMaj,
0165                     std::vector<std::vector<std::pair<unsigned int, unsigned int> > >& aFeMajFrac);
0166 
0167   bool fillChannelErrors(const sistrip::FEDBuffer& aBuffer,
0168                          bool& aFullDebug,
0169                          const unsigned int aPrintDebug,
0170                          unsigned int& aCounterMonitoring,
0171                          unsigned int& aCounterUnpacker,
0172                          const bool aDoMeds,
0173                          MonitorElement* aMedianHist0,
0174                          MonitorElement* aMedianHist1);
0175 
0176   //1--Add all channels of a FED if anyFEDErrors or corruptBuffer
0177   //2--if aFillAll = true, add all channels anyway with 0 if no errors, so TkHistoMap is filled for all valid channels ...
0178   void fillBadChannelList(const bool doTkHistoMap,
0179                           TkHistoMap* aTkMapPointer,
0180                           MonitorElement* aFedIdVsApvId,
0181                           unsigned int& aNBadChannels,
0182                           unsigned int& aNBadActiveChannels,
0183                           unsigned int& aNBadChannels_perFEDID,
0184                           std::vector<unsigned int>& nTotal,
0185                           std::vector<unsigned int>& nErrors);
0186 
0187   void fillEventProperties(long long dbx);
0188 
0189   //bool foundFEDErrors();
0190 
0191   const bool failMonitoringFEDCheck();
0192 
0193   const bool anyDAQProblems();
0194 
0195   const bool anyFEDErrors();
0196 
0197   const bool anyFEProblems();
0198 
0199   const bool printDebug();
0200 
0201   const unsigned int fedID();
0202 
0203   FEDCounters& getFEDErrorsCounters();
0204 
0205   ChannelCounters& getChannelErrorsCounters();
0206 
0207   FECounters& getFEErrorsCounters();
0208 
0209   FEDLevelErrors& getFEDLevelErrors();
0210 
0211   EventProperties& getEventProperties();
0212 
0213   std::vector<FELevelErrors>& getFELevelErrors();
0214 
0215   std::vector<ChannelLevelErrors>& getChannelLevelErrors();
0216 
0217   std::vector<APVLevelErrors>& getAPVLevelErrors();
0218 
0219   std::vector<std::pair<unsigned int, bool> >& getBadChannels();
0220 
0221   void addBadFE(const FELevelErrors& aFE);
0222 
0223   void addBadChannel(const ChannelLevelErrors& aChannel);
0224 
0225   void addBadAPV(const APVLevelErrors& aAPV, bool& aFirst);
0226 
0227   void incrementFEDCounters();
0228 
0229   void incrementChannelCounters(const FEDErrors::ChannelLevelErrors& aChannel);
0230 
0231   void incrementAPVCounters(const FEDErrors::APVLevelErrors& aAPV);
0232 
0233   void print(const FEDCounters& aFEDCounter, std::ostream& aOs = std::cout);
0234   void print(const FECounters& aFECounter, std::ostream& aOs = std::cout);
0235   void print(const FEDLevelErrors& aFEDErr, std::ostream& aOs = std::cout);
0236   void print(const FELevelErrors& aFEErr, std::ostream& aOs = std::cout);
0237   void print(const ChannelLevelErrors& aErr, std::ostream& aOs = std::cout);
0238   void print(const APVLevelErrors& aErr, std::ostream& aOs = std::cout);
0239 
0240 protected:
0241 private:
0242   void incrementLumiErrors(const bool hasError,
0243                            const unsigned int aSubDet,
0244                            std::vector<unsigned int>& nTotal,
0245                            std::vector<unsigned int>& nErrors);
0246 
0247   void processDet(const uint32_t aPrevId,
0248                   const uint16_t aPrevTot,
0249                   const bool doTkHistoMap,
0250                   uint16_t& nBad,
0251                   TkHistoMap* aTkMapPointer);
0252 
0253   unsigned int fedID_;
0254 
0255   std::vector<bool> connected_;
0256   std::vector<unsigned int> detid_;
0257   std::vector<unsigned short> nChInModule_;
0258 
0259   std::vector<unsigned short> subDetId_;
0260 
0261   FECounters feCounter_;
0262   FEDLevelErrors fedErrors_;
0263   ChannelCounters lChCounter_;
0264   FEDCounters lFedCounter_;
0265 
0266   std::vector<FELevelErrors> feErrors_;
0267   std::vector<ChannelLevelErrors> chErrorsDetailed_;
0268   std::vector<APVLevelErrors> apvErrors_;
0269   std::vector<std::pair<unsigned int, bool> > chErrors_;
0270 
0271   bool failUnpackerFEDCheck_;
0272 
0273   EventProperties eventProp_;
0274 
0275 };  //class
0276 
0277 #endif  //DQM_SiStripMonitorHardware_FEDErrors_HH