Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:12:27

0001 // -*-c++-*-
0002 //
0003 // Client class for HLT Scalers module.
0004 //
0005 
0006 // Revision 1.13  2010/03/17 20:56:18  wittich
0007 // Check for good updates based on mergeCount values
0008 // add code for rates normalized per FU
0009 //
0010 // Revision 1.12  2010/03/16 22:19:19  wittich
0011 // updates for per-LS normalization for variable
0012 // number of FU's sending information back to the clients.
0013 //
0014 // Revision 1.11  2010/02/15 17:10:45  wittich
0015 // Allow for longer length runs (2400 ls)
0016 // this is only in the client
0017 //
0018 // Revision 1.10  2010/02/11 23:55:18  wittich
0019 // - adapt to shorter Lumi Section length
0020 // - fix bug in how history of counts was filled
0021 //
0022 // Revision 1.9  2010/02/11 00:11:09  wmtan
0023 // Adapt to moved framework header
0024 //
0025 // Revision 1.8  2010/02/02 11:44:20  wittich
0026 // more diagnostics for online scalers
0027 //
0028 // Revision 1.7  2009/12/15 20:41:16  wittich
0029 // better hlt scalers client
0030 //
0031 // Revision 1.6  2009/11/22 14:17:46  puigh
0032 // fix compilation warning
0033 //
0034 // Revision 1.5  2009/11/22 13:32:38  puigh
0035 // clean beginJob
0036 //
0037 
0038 #ifndef HLTSCALERSCLIENT_H
0039 #define HLTSCALERSCLIENT_H
0040 #include <deque>
0041 #include <fstream>
0042 #include <utility>
0043 #include <vector>
0044 
0045 #include "FWCore/Framework/interface/EDAnalyzer.h"
0046 #include "FWCore/Framework/interface/Frameworkfwd.h"
0047 
0048 #include "DQMServices/Core/interface/DQMStore.h"
0049 
0050 #include "FWCore/Utilities/interface/InputTag.h"
0051 //#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
0052 
0053 #define MAX_PATHS 200
0054 #define MAX_LUMI_SEG_HLT 2400
0055 
0056 class HLTScalersClient : public edm::EDAnalyzer {
0057 private:
0058   std::ofstream textfile_;
0059 
0060 public:
0061   typedef dqm::legacy::MonitorElement MonitorElement;
0062   typedef dqm::legacy::DQMStore DQMStore;
0063   //   typedef std::pair<int,double> CountLS_t;
0064   //   //typedef std::deque<CountLS_t> CountLSFifo_t;
0065   //   typedef std::map<int,double> CountLSFifo_t;
0066 
0067   // helper data structures - slightly modified stl objects
0068   class CountLS_t : public std::pair<int, double> {
0069   public:
0070     CountLS_t(int ls, double cnt) : std::pair<int, double>(ls, cnt){};
0071     bool operator==(int ls) const { return ls == this->first; }
0072     bool operator<(CountLS_t &rhs) { return this->first < rhs.first; };
0073   };
0074 
0075   class CountLSFifo_t : public std::deque<CountLS_t> {
0076   private:
0077     unsigned int targetSize_;
0078     bool accumulate_;
0079 
0080   public:
0081     // default constructor
0082     CountLSFifo_t(unsigned int sz = 3) : std::deque<CountLS_t>(), targetSize_(sz) {}
0083     unsigned int targetSize() const { return targetSize_; };
0084     double getCount(int ls) {
0085       CountLSFifo_t::iterator p = std::find(this->begin(), this->end(), ls);
0086       if (p != end())
0087         return p->second;
0088       else
0089         return -1;
0090     }
0091 
0092     void update(const CountLS_t &T) {
0093       // do we already have data for this LS?
0094       CountLSFifo_t::iterator p = std::find(this->begin(), this->end(), T.first);
0095       if (p != this->end()) {  // we already have data for this LS
0096         p->second = T.second;
0097       } else {  // new data
0098         this->push_back(T);
0099       }
0100       trim_();
0101     }
0102 
0103   private:
0104     void trim_() {
0105       if (this->size() > targetSize_) {
0106         std::sort(begin(), end());
0107         while (size() > targetSize_) {
0108           pop_front();
0109         }
0110       }
0111     }
0112   };
0113 
0114 public:
0115   /// Constructors
0116   HLTScalersClient(const edm::ParameterSet &ps);
0117 
0118   /// Destructor
0119   ~HLTScalersClient() override {
0120     if (debug_) {
0121       textfile_.close();
0122     }
0123   };
0124 
0125   /// BeginJob
0126   void beginJob(void) override;
0127 
0128   /// BeginRun
0129   void beginRun(const edm::Run &run, const edm::EventSetup &c) override;
0130 
0131   /// EndRun
0132   void endRun(const edm::Run &run, const edm::EventSetup &c) override;
0133 
0134   /// End LumiBlock
0135   /// DQM Client Diagnostic should be performed here
0136   void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override;
0137 
0138   // unused
0139   void analyze(const edm::Event &e, const edm::EventSetup &c) override;
0140 
0141 private:
0142   DQMStore *dbe_;
0143 
0144   int nev_;    // Number of events processed
0145   int nLumi_;  // number of lumi blocks
0146   int currentRun_;
0147 
0148   MonitorElement *currentRate_;
0149   int currentLumiBlockNumber_;
0150   std::vector<MonitorElement *> rateHistories_;
0151   std::vector<MonitorElement *> countHistories_;
0152 
0153   std::vector<MonitorElement *> hltCurrentRate_;
0154   MonitorElement *hltRate_;   // global rate - any accept
0155   MonitorElement *hltCount_;  // globalCounts
0156   //  MonitorElement *hltCountN_; // globalCounts normalized
0157   MonitorElement *updates_;
0158   MonitorElement *mergeCount_;
0159 
0160   // Normalized
0161   MonitorElement *hltNormRate_;  // global rate - any accept
0162   MonitorElement *currentNormRate_;
0163   std::vector<MonitorElement *> rateNormHistories_;
0164   std::vector<MonitorElement *> hltCurrentNormRate_;
0165 
0166   bool first_, missingPathNames_;
0167   std::string folderName_;
0168   unsigned int kRateIntegWindow_;
0169   std::string processName_;
0170   // HLTConfigProvider hltConfig_;
0171   std::deque<int> ignores_;
0172   std::pair<double, double> getSlope_(const CountLSFifo_t &points);
0173 
0174 private:
0175   bool debug_;
0176   int maxFU_;
0177   std::vector<CountLSFifo_t> recentPathCountsPerLS_;
0178   CountLSFifo_t recentOverallCountsPerLS_;
0179 
0180   std::vector<CountLSFifo_t> recentNormedPathCountsPerLS_;
0181   CountLSFifo_t recentNormedOverallCountsPerLS_;
0182 };
0183 
0184 #endif  // HLTSCALERSCLIENT_H