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 
43 
44 public:
45 
46  explicit HLTMuonValidator(const edm::ParameterSet&);
47 
48 private:
49 
50  // Analyzer Methods
51  virtual void beginJob();
52  virtual void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override;
53  virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
54  virtual void analyze(const edm::Event &, const edm::EventSetup &) override;
55  virtual void endRun(const edm::Run &, const edm::EventSetup &) override;
56  virtual void endJob();
57 
58  // Extra Methods
59  std::vector<std::string> moduleLabels(std::string);
60  std::vector<std::string> stepLabels(const std::vector<std::string>&);
61 
62  // Input from Configuration File
65  std::vector<std::string> hltPathsToCheck_;
66 
67  // Member Variables
68  std::vector<HLTMuonPlotter> analyzers_;
70  boost::tuple<
74 
75 };
76 
77 
78 
81 
82 using namespace std;
83 using namespace edm;
84 using namespace reco;
85 using namespace trigger;
86 
87 typedef vector<string> vstring;
88 
89 
90 
93 
95  pset_(pset),
96  hltProcessName_(pset.getParameter<string>("hltProcessName")),
97  hltPathsToCheck_(pset.getParameter<vstring>("hltPathsToCheck"))
98 {
99 
101 
102 }
103 
104 
105 
106 vector<string>
108 
109  vector<string> modules = hltConfig_.moduleLabels(path);
110  vector<string>::iterator iter = modules.begin();
111 
112  while (iter != modules.end())
113  if (iter->find("Filtered") == string::npos)
114  iter = modules.erase(iter);
115  else
116  ++iter;
117 
118  return modules;
119 
120 }
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("L3TkIso");
131  else
132  steps.push_back("L2Iso");
133  }
134  else if ((modules[i].find("pfecalIsoRhoFiltered") != string::npos)) {
135  if (modules[i].find("L3") != string::npos)
136  steps.push_back("L3EcalIso");
137  else if (modules[i].find("TkFiltered") != string::npos)
138  steps.push_back("TkEcalIso");
139  }
140  else if ((modules[i].find("pfhcalIsoRhoFiltered") != string::npos)) {
141  if (modules[i].find("L3") != string::npos)
142  steps.push_back("L3HcalIso");
143  else if (modules[i].find("TkFiltered") != string::npos)
144  steps.push_back("TkHcalIso");
145  }
146  else if (modules[i].find("TkFiltered") != string::npos){
147  steps.push_back("TkL2");
148  steps.push_back("Tk");
149  }
150  else if (modules[i].find("L3") != string::npos)
151  steps.push_back("L3");
152  else if (modules[i].find("L2") != string::npos)
153  steps.push_back("L2");
154  else if (modules[i].find("L1") != string::npos)
155  steps.push_back("L1");
156  else
157  return vector<string>();
158  }
159 
160  if (steps.size() < 2 || ((steps[1] != "L1")&&(steps[1] != "Tk")))
161  return vector<string>();
162  return steps;
163 
164 }
165 
166 
167 
168 void
170  const edm::EventSetup & iSetup)
171 {
172  // Initialize hltConfig
173  bool changedConfig;
174  if (!hltConfig_.init(iRun, iSetup, hltProcessName_, changedConfig)) {
175  LogError("HLTMuonVal") << "Initialization of HLTConfigProvider failed!!";
176  return;
177  }
178 
179  // Get the set of trigger paths we want to make plots for
180  set<string> hltPaths;
181  for (size_t i = 0; i < hltPathsToCheck_.size(); i++) {
182  TPRegexp pattern(hltPathsToCheck_[i]);
183  for (size_t j = 0; j < hltConfig_.triggerNames().size(); j++)
184  if (TString(hltConfig_.triggerNames()[j]).Contains(pattern))
185  hltPaths.insert(hltConfig_.triggerNames()[j]);
186  }
187 
188  // Initialize the analyzers
189  analyzers_.clear();
190  set<string>::iterator iPath;
191  for (iPath = hltPaths.begin(); iPath != hltPaths.end(); iPath++) {
192 
193  string path = * iPath;
194  string shortpath = path;
195  if (path.rfind("_v") < path.length())
196  shortpath = path.substr(0, path.rfind("_v"));
197 
198  vector<string> labels = moduleLabels(path);
199  vector<string> steps = stepLabels(labels);
200 
201  if (labels.size() > 0 && steps.size() > 0) {
202  HLTMuonPlotter analyzer(pset_, shortpath, labels, steps, myTokens_);
203  analyzers_.push_back(analyzer);
204  }
205  }
206 
207 }
208 
209 
210 
212  edm::Run const & iRun,
213  edm::EventSetup const & iSetup)
214 {
215 
216  // Call the beginRun (which books all the histograms)
217  vector<HLTMuonPlotter>::iterator iter;
218  for (iter = analyzers_.begin(); iter != analyzers_.end(); ++iter) {
219  iter->beginRun(iBooker, iRun, iSetup);
220  }
221 
222 }
223 
224 
225 
226 void
228  const EventSetup& iSetup)
229 {
230 
231  vector<HLTMuonPlotter>::iterator iter;
232  for (iter = analyzers_.begin(); iter != analyzers_.end(); ++iter) {
233  iter->analyze(iEvent, iSetup);
234  }
235 
236 }
237 
238 
239 
240 void
242 {
243 
244 }
245 
246 
247 
248 void
250  const edm::EventSetup& iSetup)
251 {
252 
253  // vector<HLTMuonPlotter>::iterator iter;
254  // for (iter = analyzers_.begin(); iter != analyzers_.end(); ++iter) {
255  // iter->endRun(iRun, iSetup);
256  // }
257 
258 }
259 
260 
261 
262 void
264 {
265 
266 }
267 
268 
269 
270 //define this as a plug-in
int i
Definition: DBlmapReader.cc:9
vector< string > vstring
Definition: ExoticaDQM.cc:86
#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
std::vector< HLTMuonPlotter > analyzers_
list pattern
Definition: chain.py:104
edm::ParameterSet pset_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::vector< std::string > hltPathsToCheck_
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:230
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
tuple path
else: Piece not in the list, fine.
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
int j
Definition: DBlmapReader.cc:9
virtual void endJob()
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_
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
std::string hltProcessName_
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
virtual void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
HLTMuonValidator(const edm::ParameterSet &)
Definition: Run.h:41