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 // $Id: HLTMuonValidator.cc,v 1.31 2013/04/19 23:22:27 wmtan Exp $
10 //
11 //
12 
13 // system include files
14 #include <memory>
15 #include <iostream>
16 
17 // user include files
19 
25 
26 
29 
30 
31 #include "TFile.h"
32 #include "TDirectory.h"
33 #include "TPRegexp.h"
34 
35 
38 
39 
40 
41 class HLTMuonValidator : public edm::EDAnalyzer {
42 
43 public:
44 
45  explicit HLTMuonValidator(const edm::ParameterSet&);
46 
47 private:
48 
49  // Analyzer Methods
50  virtual void beginJob();
51  virtual void beginRun(const edm::Run &, const edm::EventSetup &);
52  virtual void analyze(const edm::Event &, const edm::EventSetup &);
53  virtual void endRun(const edm::Run &, const edm::EventSetup &);
54  virtual void endJob();
55 
56  // Extra Methods
57  std::vector<std::string> moduleLabels(std::string);
58  std::vector<std::string> stepLabels(const std::vector<std::string>&);
59 
60  // Input from Configuration File
63  std::vector<std::string> hltPathsToCheck_;
64 
65  // Member Variables
66  std::vector<HLTMuonPlotter> analyzers_;
68 
69  // Access to the DQM
70  DQMStore * dbe_;
71 
72 };
73 
74 
75 
78 
79 using namespace std;
80 using namespace edm;
81 using namespace reco;
82 using namespace trigger;
83 
84 typedef vector<string> vstring;
85 
86 
87 
90 
92  pset_(pset),
93  hltProcessName_(pset.getParameter<string>("hltProcessName")),
94  hltPathsToCheck_(pset.getParameter<vstring>("hltPathsToCheck"))
95 {
96 }
97 
98 
99 
100 vector<string>
102 
103  vector<string> modules = hltConfig_.moduleLabels(path);
104  vector<string>::iterator iter = modules.begin();
105 
106  while (iter != modules.end())
107  if (iter->find("Filtered") == string::npos)
108  iter = modules.erase(iter);
109  else
110  ++iter;
111 
112  return modules;
113 
114 }
115 
116 vector<string>
117 HLTMuonValidator::stepLabels(const vector<string>& modules) {
118  vector<string> steps(1, "All");
119  for (size_t i = 0; i < modules.size(); i++) {
120  if (modules[i].find("IsoFiltered") != string::npos) {
121  if (modules[i].find("L3") != string::npos)
122  steps.push_back("L3Iso");
123  else
124  steps.push_back("L2Iso");
125  }
126  else if (modules[i].find("L3") != string::npos)
127  steps.push_back("L3");
128  else if (modules[i].find("L2") != string::npos)
129  steps.push_back("L2");
130  else if (modules[i].find("L1") != string::npos)
131  steps.push_back("L1");
132  else
133  return vector<string>();
134  }
135  if (steps.size() < 2 || steps[1] != "L1")
136  return vector<string>();
137  return steps;
138 
139 }
140 
141 
142 void
144  const edm::EventSetup & iSetup) {
145 
146  // Initialize hltConfig
147  bool changedConfig;
148  if (!hltConfig_.init(iRun, iSetup, hltProcessName_, changedConfig)) {
149  LogError("HLTMuonVal") << "Initialization of HLTConfigProvider failed!!";
150  return;
151  }
152 
153  // Get the set of trigger paths we want to make plots for
154  set<string> hltPaths;
155  for (size_t i = 0; i < hltPathsToCheck_.size(); i++) {
156  TPRegexp pattern(hltPathsToCheck_[i]);
157  for (size_t j = 0; j < hltConfig_.triggerNames().size(); j++)
158  if (TString(hltConfig_.triggerNames()[j]).Contains(pattern))
159  hltPaths.insert(hltConfig_.triggerNames()[j]);
160  }
161 
162  // Initialize the analyzers
163  analyzers_.clear();
164  set<string>::iterator iPath;
165  for (iPath = hltPaths.begin(); iPath != hltPaths.end(); iPath++) {
166 
167  string path = * iPath;
168  string shortpath = path;
169  if (path.rfind("_v") < path.length())
170  shortpath = path.substr(0, path.rfind("_v"));
171 
172  vector<string> labels = moduleLabels(path);
173  vector<string> steps = stepLabels(labels);
174 
175  if (labels.size() > 0 && steps.size() > 0) {
176  HLTMuonPlotter analyzer(pset_, shortpath, labels, steps);
177  analyzers_.push_back(analyzer);
178  }
179  }
180 
181  // Call the beginRun (which books all the histograms)
182  vector<HLTMuonPlotter>::iterator iter;
183  for (iter = analyzers_.begin(); iter != analyzers_.end(); ++iter) {
184  iter->beginRun(iRun, iSetup);
185  }
186 
187 }
188 
189 void
191  const EventSetup& iSetup)
192 {
193 
194  vector<HLTMuonPlotter>::iterator iter;
195  for (iter = analyzers_.begin(); iter != analyzers_.end(); ++iter) {
196  iter->analyze(iEvent, iSetup);
197  }
198 
199 }
200 
201 
202 
203 void
205 {
206 }
207 
208 
209 
210 void
212  const edm::EventSetup& iSetup)
213 {
214 
215  // vector<HLTMuonPlotter>::iterator iter;
216  // for (iter = analyzers_.begin(); iter != analyzers_.end(); ++iter) {
217  // iter->endRun(iRun, iSetup);
218  // }
219 
220 }
221 
222 
223 
224 void
226 {
227 }
228 
229 
230 
231 //define this as a plug-in
virtual void endRun(const edm::Run &, const edm::EventSetup &)
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
int iEvent
Definition: GenABIO.cc:243
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
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_
HLTMuonValidator(const edm::ParameterSet &)
std::vector< std::string > hltPathsToCheck_
Definition: Run.h:36