File indexing completed on 2023-03-17 10:57:28
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/one/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
0057 : public edm::one::EDAnalyzer<edm::one::SharedResources, edm::one::WatchRuns, edm::one::WatchLuminosityBlocks> {
0058 private:
0059 std::ofstream textfile_;
0060
0061 public:
0062 typedef dqm::legacy::MonitorElement MonitorElement;
0063 typedef dqm::legacy::DQMStore DQMStore;
0064
0065
0066
0067
0068
0069 class CountLS_t : public std::pair<int, double> {
0070 public:
0071 CountLS_t(int ls, double cnt) : std::pair<int, double>(ls, cnt){};
0072 bool operator==(int ls) const { return ls == this->first; }
0073 bool operator<(CountLS_t &rhs) { return this->first < rhs.first; };
0074 };
0075
0076 class CountLSFifo_t : public std::deque<CountLS_t> {
0077 private:
0078 unsigned int targetSize_;
0079 bool accumulate_;
0080
0081 public:
0082
0083 CountLSFifo_t(unsigned int sz = 3) : std::deque<CountLS_t>(), targetSize_(sz) {}
0084 unsigned int targetSize() const { return targetSize_; };
0085 double getCount(int ls) {
0086 CountLSFifo_t::iterator p = std::find(this->begin(), this->end(), ls);
0087 if (p != end())
0088 return p->second;
0089 else
0090 return -1;
0091 }
0092
0093 void update(const CountLS_t &T) {
0094
0095 CountLSFifo_t::iterator p = std::find(this->begin(), this->end(), T.first);
0096 if (p != this->end()) {
0097 p->second = T.second;
0098 } else {
0099 this->push_back(T);
0100 }
0101 trim_();
0102 }
0103
0104 private:
0105 void trim_() {
0106 if (this->size() > targetSize_) {
0107 std::sort(begin(), end());
0108 while (size() > targetSize_) {
0109 pop_front();
0110 }
0111 }
0112 }
0113 };
0114
0115 public:
0116
0117 HLTScalersClient(const edm::ParameterSet &ps);
0118
0119
0120 ~HLTScalersClient() override {
0121 if (debug_) {
0122 textfile_.close();
0123 }
0124 };
0125
0126
0127 void beginJob(void) override;
0128
0129
0130 void beginRun(const edm::Run &run, const edm::EventSetup &c) override;
0131
0132
0133 void endRun(const edm::Run &run, const edm::EventSetup &c) override;
0134
0135
0136
0137 void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override {}
0138 void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override;
0139
0140
0141 void analyze(const edm::Event &e, const edm::EventSetup &c) override;
0142
0143 private:
0144 DQMStore *dbe_;
0145
0146 int nev_;
0147 int nLumi_;
0148 int currentRun_;
0149
0150 MonitorElement *currentRate_;
0151 int currentLumiBlockNumber_;
0152 std::vector<MonitorElement *> rateHistories_;
0153 std::vector<MonitorElement *> countHistories_;
0154
0155 std::vector<MonitorElement *> hltCurrentRate_;
0156 MonitorElement *hltRate_;
0157 MonitorElement *hltCount_;
0158
0159 MonitorElement *updates_;
0160 MonitorElement *mergeCount_;
0161
0162
0163 MonitorElement *hltNormRate_;
0164 MonitorElement *currentNormRate_;
0165 std::vector<MonitorElement *> rateNormHistories_;
0166 std::vector<MonitorElement *> hltCurrentNormRate_;
0167
0168 bool first_, missingPathNames_;
0169 std::string folderName_;
0170 unsigned int kRateIntegWindow_;
0171 std::string processName_;
0172
0173 std::deque<int> ignores_;
0174 std::pair<double, double> getSlope_(const CountLSFifo_t &points);
0175
0176 private:
0177 bool debug_;
0178 int maxFU_;
0179 std::vector<CountLSFifo_t> recentPathCountsPerLS_;
0180 CountLSFifo_t recentOverallCountsPerLS_;
0181
0182 std::vector<CountLSFifo_t> recentNormedPathCountsPerLS_;
0183 CountLSFifo_t recentNormedOverallCountsPerLS_;
0184 };
0185
0186 #endif