Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:07:07

0001 #ifndef DTDataIntegrityTask_H
0002 #define DTDataIntegrityTask_H
0003 
0004 /** \class DTDataIntegrityTask
0005  *
0006  * Class for DT Data Integrity
0007  * at Online DQM (Single Thread)
0008  * expected to monitor uROS
0009  * Class with MEs vs Time/LS
0010  *
0011  * \author Javier Fernandez (Uni. Oviedo) 
0012  *
0013  */
0014 
0015 #include "FWCore/Framework/interface/Frameworkfwd.h"
0016 #include "FWCore/Framework/interface/Event.h"
0017 #include "FWCore/Framework/interface/LuminosityBlock.h"
0018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0019 #include "FWCore/Utilities/interface/EDGetToken.h"
0020 
0021 #include "DQMServices/Core/interface/DQMStore.h"
0022 #include "DQMServices/Core/interface/DQMOneEDAnalyzer.h"
0023 
0024 #include "DataFormats/DTDigi/interface/DTuROSControlData.h"
0025 
0026 #include <fstream>
0027 #include <map>
0028 #include <string>
0029 #include <vector>
0030 #include <list>
0031 
0032 namespace dtdi {
0033   struct LumiCache {
0034     int nEventsLS = 0;
0035   };
0036 }  // namespace dtdi
0037 
0038 class DTuROSROSData;
0039 class DTuROSFEDData;
0040 class DTTimeEvolutionHisto;
0041 
0042 class DTDataIntegrityTask : public DQMOneEDAnalyzer<edm::LuminosityBlockCache<dtdi::LumiCache>> {
0043 public:
0044   DTDataIntegrityTask(const edm::ParameterSet& ps);
0045 
0046   ~DTDataIntegrityTask() override;
0047 
0048   void TimeHistos(DQMStore::IBooker&, std::string histoType);
0049 
0050   void processuROS(DTuROSROSData& data, int fed, int uRos);
0051   void processFED(DTuROSFEDData& data, int fed);
0052 
0053   std::shared_ptr<dtdi::LumiCache> globalBeginLuminosityBlock(const edm::LuminosityBlock& ls,
0054                                                               const edm::EventSetup& es) const override;
0055   void globalEndLuminosityBlock(const edm::LuminosityBlock& ls, const edm::EventSetup& es) override;
0056 
0057   void analyze(const edm::Event& e, const edm::EventSetup& c) override;
0058 
0059 protected:
0060   void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
0061 
0062 private:
0063   void bookHistos(DQMStore::IBooker&, const int fedMin, const int fedMax);
0064   void bookHistos(DQMStore::IBooker&, std::string folder, const int fed);
0065   void bookHistosuROS(DQMStore::IBooker&, const int fed, const int uRos);
0066   void bookHistosROS(DQMStore::IBooker&, const int wheel, const int ros);
0067 
0068   std::string topFolder(bool isFEDIntegrity) const;
0069 
0070   //conversions
0071   int theDDU(int crate, int slot, int link, bool tenDDU);
0072   int theROS(int slot, int link);
0073 
0074   //If you want info VS time histos
0075   bool doTimeHisto;
0076 
0077   int nevents;
0078 
0079   // Monitor Elements
0080   MonitorElement* nEventMonitor;
0081   // <histoType, <index , histo> >
0082   std::map<std::string, std::map<int, MonitorElement*>> fedHistos;
0083   // <histoType, histo> >
0084   std::map<std::string, std::map<int, MonitorElement*>> summaryHistos;
0085   // <key , histo> >
0086   std::map<unsigned int, MonitorElement*> urosHistos;
0087 
0088   //enum histoTypes for reduced map of MEs urosHistos
0089   // key = stringEnum*1000 + (fed-minFED)#*100 + (uROS-minuROS)#
0090   enum histoTypes { uROSEventLength = 0, uROSError = 1, TDCError = 4, TTSValues = 7 };
0091 
0092   // standard ME for monitoring of FED integrity
0093   MonitorElement* hFEDEntry;
0094   MonitorElement* hFEDFatal;
0095 
0096   //time histos for FEDs/uROS
0097   std::map<std::string, std::map<int, DTTimeEvolutionHisto*>> fedTimeHistos;
0098   // <key, histo> >
0099   std::map<unsigned int, DTTimeEvolutionHisto*> urosTimeHistos;
0100   //key =  (fed-minFED)#*100 + (uROS-minuROS)#
0101 
0102 #ifdef EDM_ML_DEBUG
0103   int neventsFED;
0104   int neventsuROS;
0105 #endif
0106 
0107   const int FEDIDmin;
0108   const int FEDIDmax;
0109 
0110   int errorX[6][12][5] = {{{0}}};  //5th is notOK flag and 6th is TDC Fatal; Second index is ROS. Last index is wheel
0111   int nLinksForFatal;  //Minumum number of Links/wheel with notOKFlag or TDC fatal errors to consider a FEDfatal event
0112 
0113   // Number of uROS per FED
0114   const int NuROS = 12;
0115 
0116   // flag to toggle the creation of only the summaries (for HLT running)
0117   int mode;
0118   std::string fedIntegrityFolder;
0119 
0120   // The label to retrieve the digis
0121   edm::EDGetTokenT<DTuROSFEDDataCollection> fedToken;
0122 };
0123 
0124 #endif