File indexing completed on 2024-04-06 12:09:55
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include <memory>
0014 #include <iostream>
0015
0016
0017 #include "DQMOffline/Trigger/interface/HLTMuonMatchAndPlotContainer.h"
0018
0019 #include "DQMServices/Core/interface/DQMStore.h"
0020
0021 #include "FWCore/Framework/interface/Frameworkfwd.h"
0022 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0023 #include "FWCore/Framework/interface/ConsumesCollector.h"
0024 #include "FWCore/Framework/interface/MakerMacros.h"
0025 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0026 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0027
0028 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
0029 #include "FWCore/ServiceRegistry/interface/Service.h"
0030
0031 #include "TFile.h"
0032 #include "TDirectory.h"
0033 #include "TPRegexp.h"
0034
0035
0036
0037
0038 class HLTMuonOfflineAnalyzer : public DQMEDAnalyzer {
0039 public:
0040 explicit HLTMuonOfflineAnalyzer(const edm::ParameterSet &);
0041
0042 private:
0043
0044 void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override;
0045 void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
0046 void analyze(const edm::Event &, const edm::EventSetup &) override;
0047
0048
0049 std::vector<std::string> moduleLabels(const std::string &);
0050
0051
0052 edm::ParameterSet pset_;
0053 std::string hltProcessName_;
0054 std::vector<std::string> hltPathsToCheck_;
0055
0056
0057 HLTMuonMatchAndPlotContainer plotterContainer_;
0058 HLTConfigProvider hltConfig_;
0059 };
0060
0061
0062
0063
0064 using namespace std;
0065 using namespace edm;
0066 using namespace reco;
0067 using namespace trigger;
0068
0069 using vstring = vector<string>;
0070
0071
0072
0073
0074 HLTMuonOfflineAnalyzer::HLTMuonOfflineAnalyzer(const ParameterSet &pset)
0075 : pset_(pset),
0076 hltProcessName_(pset.getParameter<string>("hltProcessName")),
0077 hltPathsToCheck_(pset.getParameter<vstring>("hltPathsToCheck")),
0078 plotterContainer_(consumesCollector(), pset) {}
0079
0080 vector<string> HLTMuonOfflineAnalyzer::moduleLabels(const string &path) {
0081 vector<string> modules = hltConfig_.moduleLabels(path);
0082 auto iter = modules.begin();
0083 while (iter != modules.end()) {
0084 if ((iter->find("Filtered") == string::npos) && (iter->find("hltL1s") == string::npos)) {
0085 iter = modules.erase(iter);
0086 } else if (iter->find("L1Filtered0") != string::npos) {
0087 iter = modules.erase(iter);
0088 } else if (iter->find("TracksFiltered") != string::npos)
0089 iter = modules.erase(iter);
0090 else
0091 ++iter;
0092 }
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102 return modules;
0103 }
0104
0105 void HLTMuonOfflineAnalyzer::dqmBeginRun(const edm::Run &iRun, const edm::EventSetup &iSetup) {
0106
0107 bool changedConfig;
0108 if (!hltConfig_.init(iRun, iSetup, hltProcessName_, changedConfig)) {
0109 LogError("HLTMuonVal") << "Initialization of HLTConfigProvider failed!!";
0110 return;
0111 }
0112
0113
0114 set<string> hltPaths;
0115 for (auto const &i : hltPathsToCheck_) {
0116 for (auto const &j : hltConfig_.triggerNames()) {
0117 if (j.find(i) != std::string::npos) {
0118 hltPaths.insert(j);
0119 }
0120 }
0121 }
0122
0123
0124 set<string>::iterator iPath;
0125 vector<string>::const_iterator ilabel;
0126 for (iPath = hltPaths.begin(); iPath != hltPaths.end(); iPath++) {
0127 const string &path = *iPath;
0128 vector<string> labels = moduleLabels(path);
0129 bool isLastLabel = false;
0130 for (ilabel = labels.begin(); ilabel != labels.end(); ilabel++) {
0131 if (*ilabel == labels.back())
0132 isLastLabel = true;
0133 plotterContainer_.addPlotter(pset_, path, *ilabel, isLastLabel);
0134 }
0135 }
0136 }
0137
0138 void HLTMuonOfflineAnalyzer::bookHistograms(DQMStore::IBooker &iBooker,
0139 edm::Run const &iRun,
0140 edm::EventSetup const &iSetup) {
0141 plotterContainer_.beginRun(iBooker, iRun, iSetup);
0142 }
0143
0144 void HLTMuonOfflineAnalyzer::analyze(const Event &iEvent, const EventSetup &iSetup) {
0145 plotterContainer_.analyze(iEvent, iSetup);
0146 }
0147
0148
0149 DEFINE_FWK_MODULE(HLTMuonOfflineAnalyzer);