CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HLTMuonOfflineAnalyzer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HLTMuonOfflineAnalyzer
4 // Class: HLTMuonOfflineAnalyzer
5 //
6 
7 //
8 // Jason Slaunwhite and Jeff Klukas
9 //
10 //
11 
12 // system include files
13 #include <memory>
14 #include <iostream>
15 
16 // user include files
18 
20 
27 
30 
31 #include "TFile.h"
32 #include "TDirectory.h"
33 #include "TPRegexp.h"
34 
37 
38 class HLTMuonOfflineAnalyzer : public DQMEDAnalyzer {
39 public:
40  explicit HLTMuonOfflineAnalyzer(const edm::ParameterSet &);
41 
42 private:
43  // Analyzer Methods
44  void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override;
45  void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
46  void analyze(const edm::Event &, const edm::EventSetup &) override;
47 
48  // Extra Methods
49  std::vector<std::string> moduleLabels(const std::string &);
50 
51  // Input from Configuration File
54  std::vector<std::string> hltPathsToCheck_;
55 
56  // Member Variables
59 };
60 
63 
64 using namespace std;
65 using namespace edm;
66 using namespace reco;
67 using namespace trigger;
68 
69 using vstring = vector<string>;
70 
73 
75  : pset_(pset),
76  hltProcessName_(pset.getParameter<string>("hltProcessName")),
77  hltPathsToCheck_(pset.getParameter<vstring>("hltPathsToCheck")),
78  plotterContainer_(consumesCollector(), pset) {}
79 
80 vector<string> HLTMuonOfflineAnalyzer::moduleLabels(const string &path) {
81  vector<string> modules = hltConfig_.moduleLabels(path);
82  auto iter = modules.begin();
83  while (iter != modules.end()) {
84  if ((iter->find("Filtered") == string::npos) && (iter->find("hltL1s") == string::npos)) {
85  iter = modules.erase(iter);
86  } else if (iter->find("L1Filtered0") != string::npos)
87  iter = modules.erase(iter);
88  else
89  ++iter;
90  }
91  // iter = modules.begin();
92  // while (iter != modules.end()){
93  // if ((iter->find("Filtered0") == string::npos)){
94  // std::cout<< *iter << std::endl;
95  // iter = modules.erase(iter);
96  // }
97  // else ++iter;
98  // }
99 
100  return modules;
101 }
102 
104  // Initialize hltConfig
105  bool changedConfig;
106  if (!hltConfig_.init(iRun, iSetup, hltProcessName_, changedConfig)) {
107  LogError("HLTMuonVal") << "Initialization of HLTConfigProvider failed!!";
108  return;
109  }
110 
111  // Get the set of trigger paths we want to make plots for
112  set<string> hltPaths;
113  for (auto const &i : hltPathsToCheck_) {
114  for (auto const &j : hltConfig_.triggerNames()) {
115  if (j.find(i) != std::string::npos) {
116  hltPaths.insert(j);
117  }
118  }
119  }
120 
121  // Initialize the plotters
122  set<string>::iterator iPath;
123  vector<string>::const_iterator ilabel;
124  for (iPath = hltPaths.begin(); iPath != hltPaths.end(); iPath++) {
125  string path = *iPath;
126  vector<string> labels = moduleLabels(path);
127  bool isLastLabel = false;
128  for (ilabel = labels.begin(); ilabel != labels.end(); ilabel++) {
129  if (*ilabel == labels.back())
130  isLastLabel = true;
131  plotterContainer_.addPlotter(pset_, path, *ilabel, isLastLabel);
132  }
133  }
134 }
135 
137  edm::Run const &iRun,
138  edm::EventSetup const &iSetup) {
139  plotterContainer_.beginRun(iBooker, iRun, iSetup);
140 }
141 
143  plotterContainer_.analyze(iEvent, iSetup);
144 }
145 
146 //define this as a plug-in
HLTMuonMatchAndPlotContainer plotterContainer_
vector< string > vstring
Definition: ExoticaDQM.cc:8
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const std::vector< std::string > & triggerNames() const
names of trigger paths
Log< level::Error, false > LogError
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:224
void analyze(const edm::Event &, const edm::EventSetup &)
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
void analyze(const edm::Event &, const edm::EventSetup &) override
HLTMuonOfflineAnalyzer(const edm::ParameterSet &)
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
void beginRun(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
std::vector< std::string > moduleLabels(const std::string &)
Container Class Definition (this is what is used by the DQM module) ///////.
void addPlotter(const edm::ParameterSet &, std::string, std::string, bool)
Add a HLTMuonMatchAndPlot for a given path.
Definition: Run.h:45
std::vector< std::string > hltPathsToCheck_