Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:09:28

0001 /*
0002  * =====================================================================================
0003  *
0004  *       Filename:  EventProcessor.h
0005  *
0006  *    Description:  Object which processes Event and provides Hits to
0007  *    HitHandler object.
0008  *
0009  *        Version:  1.0
0010  *        Created:  10/03/2008 10:26:04 AM
0011  *       Revision:  none
0012  *       Compiler:  gcc
0013  *
0014  *         Author:  Valdas Rapsevicius, valdas.rapsevicius@cern.ch
0015  *        Company:  CERN, CH
0016  *
0017  * =====================================================================================
0018  */
0019 
0020 #ifndef CSCDQM_EventProcessor_H
0021 #define CSCDQM_EventProcessor_H
0022 
0023 #include <set>
0024 #include <string>
0025 #include <cmath>
0026 
0027 #include <TString.h>
0028 
0029 #ifdef DQMGLOBAL
0030 
0031 #include "FWCore/Framework/interface/ConsumesCollector.h"
0032 #include "FWCore/Framework/interface/Event.h"
0033 #include "FWCore/Utilities/interface/InputTag.h"
0034 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0035 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0036 #include "EventFilter/CSCRawToDigi/interface/CSCDCCEventData.h"
0037 
0038 #endif
0039 
0040 #include "CSCDQM_Logger.h"
0041 #include "CSCDQM_Summary.h"
0042 #include "CSCDQM_StripClusterFinder.h"
0043 #include "CSCDQM_Configuration.h"
0044 #include "CSCDQM_Configuration.h"
0045 
0046 #include "EventFilter/CSCRawToDigi/interface/CSCDCCExaminer.h"
0047 #include "EventFilter/CSCRawToDigi/interface/CSCDDUEventData.h"
0048 #include "EventFilter/CSCRawToDigi/interface/CSCCFEBTimeSlice.h"
0049 #include "EventFilter/CSCRawToDigi/interface/CSCCFEBData.h"
0050 
0051 #include "DataFormats/CSCDigi/interface/CSCDCCFormatStatusDigi.h"
0052 #include "DataFormats/CSCDigi/interface/CSCDCCFormatStatusDigiCollection.h"
0053 
0054 namespace cscdqm {
0055 
0056   /**
0057    * Structure of standby flags
0058    */
0059   struct HWStandbyType {
0060     // if standby flag should be considered at all?
0061     // at the start it will be false, thus good for last value ;)
0062     bool process;
0063 
0064     // ME+
0065     bool MeP;
0066 
0067     // ME-
0068     bool MeM;
0069 
0070     HWStandbyType() { process = MeP = MeM = false; }
0071 
0072     void applyMeP(bool ready) { MeP = MeP || !ready; }
0073 
0074     void applyMeM(bool ready) { MeM = MeM || !ready; }
0075 
0076     bool fullStandby() const { return (MeM && MeP); }
0077 
0078     bool operator==(const HWStandbyType& t) const { return (t.MeP == MeP && t.MeM == MeM && t.process == process); }
0079 
0080     bool operator!=(const HWStandbyType& t) const { return !(*this == t); }
0081 
0082     const HWStandbyType& operator=(const HWStandbyType& t) {
0083       MeP = t.MeP;
0084       MeM = t.MeM;
0085       process = t.process;
0086       return *this;
0087     }
0088   };
0089 
0090   typedef std::map<CSCIdType, ExaminerStatusType> CSCExaminerMapType;
0091   typedef std::vector<DDUIdType> DDUExaminerVectorType;
0092   // typedef std::map<int, long> CSCExaminerMapType;
0093   // typedef std::vector<int>    DDUExaminerVectorType;
0094 
0095   /**
0096    * @class EventProcessor
0097    * @brief Object used to process Events and compute statistics
0098    */
0099   class EventProcessor {
0100     // ===================================================================================================
0101     // General stuff
0102     // ===================================================================================================
0103 
0104   public:
0105     EventProcessor(Configuration* const p_config);
0106 
0107 #ifdef DQMGLOBAL
0108 
0109     EventProcessor(Configuration* const p_config, const edm::InputTag& itag, edm::ConsumesCollector& coco);
0110 
0111 #endif
0112 
0113     /**
0114        * @brief  Destructor
0115        */
0116     ~EventProcessor() {}
0117 
0118     void init();
0119 
0120     void updateFractionHistos();
0121     void updateEfficiencyHistos();
0122     void standbyEfficiencyHistos(HWStandbyType& standby);
0123     void writeShifterHistograms();
0124 
0125     unsigned int maskHWElements(std::vector<std::string>& tokens);
0126 
0127   private:
0128     bool processExaminer(const CSCDCCExaminer& binChecker);
0129     bool processExaminer(const CSCDCCExaminer& binChecker, const CSCDCCFormatStatusDigi& digi);
0130     void processDDU(const CSCDDUEventData& data, const CSCDCCExaminer& binChecker);
0131     void processCSC(const CSCEventData& data, const int dduID, const CSCDCCExaminer& binChecker);
0132 
0133     void calcEMUFractionHisto(const HistoId& result, const HistoId& set, const HistoId& subset);
0134 
0135     const bool getEMUHisto(const HistoId& histo, MonitorObject*& me);
0136     const bool getFEDHisto(const HistoId& histo, const HwId& fedID, MonitorObject*& me);
0137     const bool getDDUHisto(const HistoId& histo, const HwId& dduID, MonitorObject*& me);
0138     const bool getCSCHisto(const HistoId& histo, const HwId& crateID, const HwId& dmbSlot, MonitorObject*& me);
0139     const bool getCSCHisto(
0140         const HistoId& histo, const HwId& crateID, const HwId& dmbSlot, const HwId& adId, MonitorObject*& me);
0141     const bool getParHisto(const HistoId& histo, MonitorObject*& me);
0142     void preProcessEvent();
0143 
0144     const bool getCSCFromMap(const unsigned int& crateId,
0145                              const unsigned int& dmbId,
0146                              unsigned int& cscType,
0147                              unsigned int& cscPosition) const;
0148     void setEmuEventDisplayBit(MonitorObject*& mo, const unsigned int x, const unsigned int y, const unsigned int bit);
0149     void resetEmuEventDisplays();
0150 
0151     /** Pointer to Global Configuration */
0152     Configuration* config;
0153 
0154     /** Detector efficiency manipulation object */
0155     Summary summary;
0156 
0157     std::map<uint32_t, uint32_t> L1ANumbers;
0158     std::map<uint32_t, bool> fNotFirstEvent;
0159     uint32_t L1ANumber;
0160     uint32_t BXN;
0161     uint32_t cntDMBs;   /// Total Number of DMBs per event from DDU Header DAV
0162     uint32_t cntCFEBs;  /// Total Number of CFEBs per event from DMB DAV
0163     uint32_t cntALCTs;  /// Total Number of ALCTs per event from DMB DAV
0164     uint32_t cntTMBs;   /// Total Number of TMBs per event from DMB DAV
0165 
0166     uint16_t theFormatVersion;  /// Data Format version (2005, 2013)
0167 
0168     // bool fFirstEvent;
0169     bool fCloseL1As;  // Close L1A bit from DDU Trailer
0170     bool EmuEventDisplayWasReset;
0171 
0172     // token for input
0173     edm::EDGetTokenT<FEDRawDataCollection> frdtoken;
0174 
0175     // ===================================================================================================
0176     // Local ONLY stuff
0177     // ===================================================================================================
0178 
0179 #ifdef DQMLOCAL
0180 
0181   public:
0182     void processEvent(const char* data, const int32_t dataSize, const uint32_t errorStat, const int32_t nodeNumber);
0183 
0184 #endif
0185 
0186     // ===================================================================================================
0187     // Global ONLY stuff
0188     // ===================================================================================================
0189 
0190 #ifdef DQMGLOBAL
0191 
0192   private:
0193     bool bCSCEventCounted;
0194 
0195   public:
0196     void processEvent(const edm::Event& e, const edm::InputTag& inputTag);
0197 
0198 #endif
0199   };
0200 
0201 }  // namespace cscdqm
0202 
0203 #endif