CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/DQM/HcalMonitorTasks/interface/HcalRawDataMonitor.h

Go to the documentation of this file.
00001 #ifndef DQM_HCALMONITORTASKS_HCALRAWDATAMONITOR_H
00002 #define DQM_HCALMONITORTASKS_HCALRAWDATAMONITOR_H
00003 
00004 #define  NUMDCCS      32
00005 #define  NUMSPIGS     15
00006 #define  HTRCHANMAX   24
00007 //Dimensions of 'LED' plots, grouping bits by hardware space
00008 //  NUMBER_HDWARE = 1 + ((NUMBER +1)*(NUM_HRDWARE_PIECES))
00009 #define  TWO___FED   (1+((2+1)*NUMDCCS)   )
00010 #define  THREE_FED   (1+((3+1)*NUMDCCS)   )
00011 #define  TWO__SPGT   (1+((2+1)*NUMSPIGS)  )
00012 #define  THREE_SPG   (1+((3+1)*NUMSPIGS)  ) 
00013 #define  TWO_CHANN   (1+((2+1)*HTRCHANMAX))
00014 
00015 #define ETABINS   85
00016 #define PHIBINS   72
00017 #define DEPTHBINS  4
00018 
00019 #include "DQM/HcalMonitorTasks/interface/HcalBaseDQMonitor.h"
00020 #include "EventFilter/HcalRawToDigi/interface/HcalUnpacker.h"
00021 #include "EventFilter/HcalRawToDigi/interface/HcalHTRData.h"
00022 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
00023 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
00024 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
00025 #include "DataFormats/FEDRawData/interface/FEDTrailer.h"
00026 #include <math.h>
00027 
00034 class HcalRawDataMonitor: public HcalBaseDQMonitor {
00035  public:
00036   HcalRawDataMonitor(const edm::ParameterSet& ps);
00037   //Constructor with no arguments
00038   HcalRawDataMonitor(){};
00039   ~HcalRawDataMonitor();
00040  protected:
00041   void analyze(const edm::Event& e, const edm::EventSetup& c);
00042   void beginRun(const edm::Run& run, const edm::EventSetup& c);
00043   void beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg,
00044                             const edm::EventSetup& c) ;
00045   // End LumiBlock 
00046   // Dump the backstage arrays into MEs, for normalization by the Client
00047   void endLuminosityBlock(const edm::LuminosityBlock& lumiSeg,
00048                           const edm::EventSetup& c);
00049   // Within Analyze(), processEvent
00050   void processEvent(const FEDRawDataCollection& rawraw, 
00051                     const HcalUnpackerReport& report);
00052   // Within processEvent, unpack(fed)
00053   void unpack(const FEDRawData& raw);
00054   void endJob(void);
00055   void endRun(const edm::Run& run, const edm::EventSetup& c);
00056   void setup(void);
00057   void reset(void);
00058 
00059   edm::InputTag FEDRawDataCollection_;
00060   edm::InputTag digiLabel_;
00061   const HcalElectronicsMap*    readoutMap_;
00062   //Electronics map -> geographic channel map
00063   inline int hashup(uint32_t d=0, uint32_t s=0, uint32_t c=1) {
00064     return (int) ( (d*NUMSPIGS*HTRCHANMAX)+(s*HTRCHANMAX)+(c)); }
00065   void stashHDI(int thehash, HcalDetId thehcaldetid);
00066   //Protect against indexing past array.
00067   inline HcalDetId HashToHDI(int thehash) {
00068     return ( ( (thehash<0) || (thehash>(NUMDCCS*NUMSPIGS*HTRCHANMAX)) )
00069              ?(HcalDetId::Undefined)
00070              :(hashedHcalDetId_[thehash]));
00071   };
00072   uint64_t uniqcounter[ETABINS][PHIBINS][DEPTHBINS]; // HFd1,2 at 'depths' 3,4 to avoid collision with HE
00073   uint64_t problemcount[ETABINS][PHIBINS][DEPTHBINS]; // HFd1,2 at 'depths' 3,4 to avoid collision with HE
00074   bool     problemfound[ETABINS][PHIBINS][DEPTHBINS]; // HFd1,2 at 'depths' 3,4 to avoid collision with HE
00075   void mapDCCproblem  (int dcc);                          // Set problemfound[][][] = true for the hardware's ieta/iphi/depth's
00076   void mapHTRproblem  (int dcc, int spigot);              // Set problemfound[][][] = true for the hardware's ieta/iphi/depth's
00077   void mapChannproblem(int dcc, int spigot, int htrchan); // Set problemfound[][][] = true for the hardware's ieta/iphi/depth 
00078   void whosebad(int subdet);        //Increment the NumBad counter for this LS, for this Hcal subdet
00079 
00080  private:
00081   MonitorElement* meCh_DataIntegrityFED00_;   //DataIntegrity for channels in FED 00
00082   MonitorElement* meCh_DataIntegrityFED01_;   //DataIntegrity for channels in FED 01
00083   MonitorElement* meCh_DataIntegrityFED02_;   //DataIntegrity for channels in FED 02
00084   MonitorElement* meCh_DataIntegrityFED03_;   //DataIntegrity for channels in FED 03
00085   MonitorElement* meCh_DataIntegrityFED04_;   //DataIntegrity for channels in FED 04
00086   MonitorElement* meCh_DataIntegrityFED05_;   //DataIntegrity for channels in FED 05
00087   MonitorElement* meCh_DataIntegrityFED06_;   //DataIntegrity for channels in FED 06
00088   MonitorElement* meCh_DataIntegrityFED07_;   //DataIntegrity for channels in FED 07
00089   MonitorElement* meCh_DataIntegrityFED08_;   //DataIntegrity for channels in FED 08
00090   MonitorElement* meCh_DataIntegrityFED09_;   //DataIntegrity for channels in FED 09
00091   MonitorElement* meCh_DataIntegrityFED10_;   //DataIntegrity for channels in FED 10
00092   MonitorElement* meCh_DataIntegrityFED11_;   //DataIntegrity for channels in FED 11
00093   MonitorElement* meCh_DataIntegrityFED12_;   //DataIntegrity for channels in FED 12
00094   MonitorElement* meCh_DataIntegrityFED13_;   //DataIntegrity for channels in FED 13
00095   MonitorElement* meCh_DataIntegrityFED14_;   //DataIntegrity for channels in FED 14
00096   MonitorElement* meCh_DataIntegrityFED15_;   //DataIntegrity for channels in FED 15
00097   MonitorElement* meCh_DataIntegrityFED16_;   //DataIntegrity for channels in FED 16
00098   MonitorElement* meCh_DataIntegrityFED17_;   //DataIntegrity for channels in FED 17
00099   MonitorElement* meCh_DataIntegrityFED18_;   //DataIntegrity for channels in FED 18
00100   MonitorElement* meCh_DataIntegrityFED19_;   //DataIntegrity for channels in FED 19
00101   MonitorElement* meCh_DataIntegrityFED20_;   //DataIntegrity for channels in FED 20
00102   MonitorElement* meCh_DataIntegrityFED21_;   //DataIntegrity for channels in FED 21
00103   MonitorElement* meCh_DataIntegrityFED22_;   //DataIntegrity for channels in FED 22
00104   MonitorElement* meCh_DataIntegrityFED23_;   //DataIntegrity for channels in FED 23
00105   MonitorElement* meCh_DataIntegrityFED24_;   //DataIntegrity for channels in FED 24
00106   MonitorElement* meCh_DataIntegrityFED25_;   //DataIntegrity for channels in FED 25
00107   MonitorElement* meCh_DataIntegrityFED26_;   //DataIntegrity for channels in FED 26
00108   MonitorElement* meCh_DataIntegrityFED27_;   //DataIntegrity for channels in FED 27
00109   MonitorElement* meCh_DataIntegrityFED28_;   //DataIntegrity for channels in FED 28
00110   MonitorElement* meCh_DataIntegrityFED29_;   //DataIntegrity for channels in FED 29
00111   MonitorElement* meCh_DataIntegrityFED30_;   //DataIntegrity for channels in FED 30
00112   MonitorElement* meCh_DataIntegrityFED31_;   //DataIntegrity for channels in FED 31
00113   // handy array of pointers to pointers...
00114   MonitorElement* meChann_DataIntegrityCheck_[NUMDCCS];
00115 
00116   uint64_t UScount[NUMDCCS][NUMSPIGS];
00117   float HalfHTRDataCorruptionIndicators_  [THREE_FED][THREE_SPG];  
00118   float LRBDataCorruptionIndicators_      [THREE_FED][THREE_SPG];  
00119   float ChannSumm_DataIntegrityCheck_     [TWO___FED][TWO__SPGT];
00120   float Chann_DataIntegrityCheck_[NUMDCCS][TWO_CHANN][TWO__SPGT];
00121   float DataFlowInd_                      [TWO___FED][THREE_SPG];
00122 
00123   MonitorElement* meHalfHTRDataCorruptionIndicators_;
00124   MonitorElement* meLRBDataCorruptionIndicators_;
00125   MonitorElement* meChannSumm_DataIntegrityCheck_;
00126   MonitorElement* meDataFlowInd_;
00127 
00128   //Histogram labelling functions
00129   void label_ySpigots(MonitorElement* me_ptr,int ybins);
00130   void label_xFEDs   (MonitorElement* me_ptr,int xbins);
00131   void label_xChanns (MonitorElement* me_ptr,int xbins);
00132 
00133   HcalDetId hashedHcalDetId_[NUMDCCS * NUMSPIGS * HTRCHANMAX];
00134 
00135   // Transfer internal problem counts to ME's, & reset internal counters.
00136   void UpdateMEs (void );
00137 
00138   //Member variables for reference values to be used in consistency checks.
00139   std::map<int, short> CDFversionNumber_list;
00140   std::map<int, short>::iterator CDFvers_it;
00141   std::map<int, short> CDFReservedBits_list;
00142   std::map<int, short>::iterator CDFReservedBits_it;
00143   std::map<int, short> DCCEvtFormat_list;
00144   std::map<int, short>::iterator DCCEvtFormat_it;
00145 
00146   // The following MEs map specific conditons from the EventFragment headers as specified in
00147   //   http://cmsdoc.cern.ch/cms/HCAL/document/CountingHouse/DCC/DCC_1Jul06.pdf
00148   MonitorElement* meCDFErrorFound_;       //Summary histo of Common Data Format violations by FED ID
00149   MonitorElement* meDCCEventFormatError_; //Summary histo of DCC Event Format violations by FED ID 
00150 
00151   //Check that evt numbers are synchronized across all half-HTRs and their DCC
00152   MonitorElement* meBCN_;            // Bunch count number distributions
00153   MonitorElement* medccBCN_;         // Bunch count number distributions
00154   MonitorElement* meBCNCheck_;       // HTR BCN compared to DCC BCN
00155   MonitorElement* meBCNSynch_;       // htr-htr disagreement location
00156 
00157   MonitorElement* meEvtNCheck_;      // HTR Evt # compared to DCC Evt #
00158   MonitorElement* meEvtNumberSynch_; // htr-htr disagreement location
00159 
00160   MonitorElement* meOrNCheck_;       // htr OrN compared to dcc OrN
00161   MonitorElement* meOrNSynch_;       // htr-htr disagreement location
00162   MonitorElement* meBCNwhenOrNDiff_; // BCN distribution (subset)
00163 
00164   MonitorElement* mefedEntries_;
00165   MonitorElement* meFEDRawDataSizes_;
00166   MonitorElement* meEvFragSize_;
00167   MonitorElement* meEvFragSize2_;
00168   MonitorElement* meDCCVersion_;
00169 
00170   void labelHTRBits(MonitorElement* mePlot,unsigned int axisType);
00171   MonitorElement* HTR_StatusWd_HBHE;
00172   MonitorElement* HTR_StatusWd_HF;
00173   MonitorElement* HTR_StatusWd_HO;
00174   MonitorElement* meStatusWdCrate_;  //HTR status bits by crate
00175   MonitorElement* meInvHTRData_;
00176   MonitorElement* meFibBCN_;
00177 
00178   // The following MEs map specific conditons from the HTR/DCC headers as specified in
00179   //   http://cmsdoc.cern.ch/cms/HCAL/document/CountingHouse/HTR/design/Rev4MainFPGA.pdf
00180   MonitorElement* meCrate0HTRStatus_ ;   //Map of HTR status bits into Crate 0
00181   MonitorElement* meCrate1HTRStatus_ ;   //Map of HTR status bits into Crate 1
00182   MonitorElement* meCrate2HTRStatus_ ;   //Map of HTR status bits into Crate 2
00183   MonitorElement* meCrate3HTRStatus_ ;   //Map of HTR status bits into Crate 3
00184   MonitorElement* meCrate4HTRStatus_ ;   //Map of HTR status bits into Crate 4
00185   MonitorElement* meCrate5HTRStatus_ ;   //Map of HTR status bits into Crate 5
00186   MonitorElement* meCrate6HTRStatus_ ;   //Map of HTR status bits into Crate 6
00187   MonitorElement* meCrate7HTRStatus_ ;   //Map of HTR status bits into Crate 7
00188   MonitorElement* meCrate9HTRStatus_ ;   //Map of HTR status bits into Crate 9
00189   MonitorElement* meCrate10HTRStatus_;   //Map of HTR status bits into Crate 10
00190   MonitorElement* meCrate11HTRStatus_;   //Map of HTR status bits into Crate 11
00191   MonitorElement* meCrate12HTRStatus_;   //Map of HTR status bits into Crate 12
00192   MonitorElement* meCrate13HTRStatus_;   //Map of HTR status bits into Crate 13
00193   MonitorElement* meCrate14HTRStatus_;   //Map of HTR status bits into Crate 14
00194   MonitorElement* meCrate15HTRStatus_;   //Map of HTR status bits into Crate 15
00195   MonitorElement* meCrate17HTRStatus_;   //Map of HTR status bits into Crate 17
00196 
00197   MonitorElement* meUSFractSpigs_;
00198   MonitorElement* meHTRFWVersion_;
00199   MonitorElement* meFib1OrbMsgBCN_;  //BCN of Fiber 1 Orb Msg
00200   MonitorElement* meFib2OrbMsgBCN_;  //BCN of Fiber 2 Orb Msg
00201   MonitorElement* meFib3OrbMsgBCN_;  //BCN of Fiber 3 Orb Msg
00202   MonitorElement* meFib4OrbMsgBCN_;  //BCN of Fiber 4 Orb Msg
00203   MonitorElement* meFib5OrbMsgBCN_;  //BCN of Fiber 5 Orb Msg
00204   MonitorElement* meFib6OrbMsgBCN_;  //BCN of Fiber 6 Orb Msg
00205   MonitorElement* meFib7OrbMsgBCN_;  //BCN of Fiber 7 Orb Msg
00206   MonitorElement* meFib8OrbMsgBCN_;  //BCN of Fiber 8 Orb Msg
00207 
00208   int NumBadHB, NumBadHE, NumBadHO, NumBadHF, NumBadHFLUMI, NumBadHO0, NumBadHO12;
00209 
00210   void HTRPrint(const HcalHTRData& htr,int prtlvl);
00211 
00212   bool excludeHORing2_;
00213 };
00214 
00215 #endif