File indexing completed on 2021-02-14 13:12:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
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
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
0064
0065
0066
0067
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
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
0094 CountLSFifo_t::iterator p = std::find(this->begin(), this->end(), T.first);
0095 if (p != this->end()) {
0096 p->second = T.second;
0097 } else {
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
0116 HLTScalersClient(const edm::ParameterSet &ps);
0117
0118
0119 ~HLTScalersClient() override {
0120 if (debug_) {
0121 textfile_.close();
0122 }
0123 };
0124
0125
0126 void beginJob(void) override;
0127
0128
0129 void beginRun(const edm::Run &run, const edm::EventSetup &c) override;
0130
0131
0132 void endRun(const edm::Run &run, const edm::EventSetup &c) override;
0133
0134
0135
0136 void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override;
0137
0138
0139 void analyze(const edm::Event &e, const edm::EventSetup &c) override;
0140
0141 private:
0142 DQMStore *dbe_;
0143
0144 int nev_;
0145 int nLumi_;
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_;
0155 MonitorElement *hltCount_;
0156
0157 MonitorElement *updates_;
0158 MonitorElement *mergeCount_;
0159
0160
0161 MonitorElement *hltNormRate_;
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
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