CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTMuonValidator.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HLTMuonValidator
4 // Class: HLTMuonValidator
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 
24 
25 
28 
29 
30 #include "TFile.h"
31 #include "TDirectory.h"
32 #include "TPRegexp.h"
33 #include "boost/tuple/tuple.hpp"
34 
35 
36 
39 
40 
41 
42 class HLTMuonValidator : public edm::EDAnalyzer {
43 
44 public:
45 
46  explicit HLTMuonValidator(const edm::ParameterSet&);
47 
48 private:
49 
50  // Analyzer Methods
51  virtual void beginJob() override;
52  virtual void beginRun(const edm::Run &, const edm::EventSetup &) override;
53  virtual void analyze(const edm::Event &, const edm::EventSetup &) override;
54  virtual void endRun(const edm::Run &, const edm::EventSetup &) override;
55  virtual void endJob() override;
56 
57  // Extra Methods
58  std::vector<std::string> moduleLabels(std::string);
59  std::vector<std::string> stepLabels(const std::vector<std::string>&);
60 
61  // Input from Configuration File
64  std::vector<std::string> hltPathsToCheck_;
65 
66  // Member Variables
67  std::vector<HLTMuonPlotter> analyzers_;
69  boost::tuple<
73 
74  // Access to the DQM
75  DQMStore * dbe_;
76 
77 };
78 
79 
80 
83 
84 using namespace std;
85 using namespace edm;
86 using namespace reco;
87 using namespace trigger;
88 
89 typedef vector<string> vstring;
90 
91 
92 
95 
97  pset_(pset),
98  hltProcessName_(pset.getParameter<string>("hltProcessName")),
99  hltPathsToCheck_(pset.getParameter<vstring>("hltPathsToCheck"))
100 {
101 
103 
104 }
105 
106 
107 
108 vector<string>
110 
111  vector<string> modules = hltConfig_.moduleLabels(path);
112  vector<string>::iterator iter = modules.begin();
113 
114  while (iter != modules.end())
115  if (iter->find("Filtered") == string::npos)
116  iter = modules.erase(iter);
117  else
118  ++iter;
119 
120  return modules;
121 
122 }
123 
124 vector<string>
125 HLTMuonValidator::stepLabels(const vector<string>& modules) {
126  vector<string> steps(1, "All");
127  for (size_t i = 0; i < modules.size(); i++) {
128  if (modules[i].find("IsoFiltered") != string::npos) {
129  if (modules[i].find("L3") != string::npos)
130  steps.push_back("L3Iso");
131  else
132  steps.push_back("L2Iso");
133  }
134  else if (modules[i].find("L3") != string::npos)
135  steps.push_back("L3");
136  else if (modules[i].find("L2") != string::npos)
137  steps.push_back("L2");
138  else if (modules[i].find("L1") != string::npos)
139  steps.push_back("L1");
140  else
141  return vector<string>();
142  }
143  if (steps.size() < 2 || steps[1] != "L1")
144  return vector<string>();
145  return steps;
146 
147 }
148 
149 
150 void
152  const edm::EventSetup & iSetup)
153 {
154  // Initialize hltConfig
155  bool changedConfig;
156  if (!hltConfig_.init(iRun, iSetup, hltProcessName_, changedConfig)) {
157  LogError("HLTMuonVal") << "Initialization of HLTConfigProvider failed!!";
158  return;
159  }
160 
161  // Get the set of trigger paths we want to make plots for
162  set<string> hltPaths;
163  for (size_t i = 0; i < hltPathsToCheck_.size(); i++) {
164  TPRegexp pattern(hltPathsToCheck_[i]);
165  for (size_t j = 0; j < hltConfig_.triggerNames().size(); j++)
166  if (TString(hltConfig_.triggerNames()[j]).Contains(pattern))
167  hltPaths.insert(hltConfig_.triggerNames()[j]);
168  }
169 
170  // Initialize the analyzers
171  analyzers_.clear();
172  set<string>::iterator iPath;
173  for (iPath = hltPaths.begin(); iPath != hltPaths.end(); iPath++) {
174 
175  string path = * iPath;
176  string shortpath = path;
177  if (path.rfind("_v") < path.length())
178  shortpath = path.substr(0, path.rfind("_v"));
179 
180  vector<string> labels = moduleLabels(path);
181  vector<string> steps = stepLabels(labels);
182 
183  if (labels.size() > 0 && steps.size() > 0) {
184  HLTMuonPlotter analyzer(pset_, shortpath, labels, steps, myTokens_);
185  analyzers_.push_back(analyzer);
186  }
187  }
188 
189  // Call the beginRun (which books all the histograms)
190  vector<HLTMuonPlotter>::iterator iter;
191  for (iter = analyzers_.begin(); iter != analyzers_.end(); ++iter) {
192  iter->beginRun(iRun, iSetup);
193  }
194 
195 }
196 
197 void
199  const EventSetup& iSetup)
200 {
201 
202  vector<HLTMuonPlotter>::iterator iter;
203  for (iter = analyzers_.begin(); iter != analyzers_.end(); ++iter) {
204  iter->analyze(iEvent, iSetup);
205  }
206 
207 }
208 
209 
210 
211 void
213 {
214 }
215 
216 
217 
218 void
220  const edm::EventSetup& iSetup)
221 {
222 
223  // vector<HLTMuonPlotter>::iterator iter;
224  // for (iter = analyzers_.begin(); iter != analyzers_.end(); ++iter) {
225  // iter->endRun(iRun, iSetup);
226  // }
227 
228 }
229 
230 
231 
232 void
234 {
235 }
236 
237 
238 
239 //define this as a plug-in
int i
Definition: DBlmapReader.cc:9
vector< string > vstring
Definition: ExoticaDQM.cc:75
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< std::string > stepLabels(const std::vector< std::string > &)
const std::vector< std::string > & triggerNames() const
names of trigger paths
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::vector< HLTMuonPlotter > analyzers_
edm::ParameterSet pset_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
boost::tuple< edm::EDGetTokenT< trigger::TriggerEventWithRefs >, edm::EDGetTokenT< reco::GenParticleCollection >, edm::EDGetTokenT< reco::MuonCollection > > myTokens_
static boost::tuple< edm::EDGetTokenT< trigger::TriggerEventWithRefs >, edm::EDGetTokenT< reco::GenParticleCollection >, edm::EDGetTokenT< reco::MuonCollection > > getTokens(const edm::ParameterSet &, edm::ConsumesCollector &&)
int iEvent
Definition: GenABIO.cc:243
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
int j
Definition: DBlmapReader.cc:9
std::vector< std::string > moduleLabels(std::string)
virtual void beginJob()
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
virtual void endRun(const edm::Run &, const edm::EventSetup &) override
HLTConfigProvider hltConfig_
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
std::string hltProcessName_
virtual void endJob() override
HLTMuonValidator(const edm::ParameterSet &)
std::vector< std::string > hltPathsToCheck_
Definition: Run.h:41