CMS 3D CMS Logo

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  void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override;
52  void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
53  void analyze(const edm::Event &, const edm::EventSetup &) override;
54  void endRun(const edm::Run &, const edm::EventSetup &) override;
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  boost::tuple<
72 
73 };
74 
75 
76 
79 
80 using namespace std;
81 using namespace edm;
82 using namespace reco;
83 using namespace trigger;
84 
85 typedef vector<string> vstring;
86 
87 
88 
91 
93  pset_(pset),
94  hltProcessName_(pset.getParameter<string>("hltProcessName")),
95  hltPathsToCheck_(pset.getParameter<vstring>("hltPathsToCheck"))
96 {
97 
98  myTokens_ = HLTMuonPlotter::getTokens(pset_, consumesCollector());
99 
100 }
101 
102 
103 
104 vector<string>
106 
107  vector<string> modules = hltConfig_.moduleLabels(path);
108  vector<string>::iterator iter = modules.begin();
109 
110  while (iter != modules.end())
111  if (iter->find("Filtered") == string::npos)
112  iter = modules.erase(iter);
113  else
114  ++iter;
115 
116  return modules;
117 
118 }
119 
120 
121 
122 vector<string>
123 HLTMuonValidator::stepLabels(const vector<string>& modules) {
124  vector<string> steps(1, "All");
125  for (size_t i = 0; i < modules.size(); i++) {
126  if ((modules[i].find("IsoFiltered") != string::npos)){
127  if (modules[i].find("L3") != string::npos)
128  steps.push_back("L3TkIso");
129  else
130  steps.push_back("L2Iso");
131  }
132  else if ((modules[i].find("pfecalIsoRhoFiltered") != string::npos)) {
133  if (modules[i].find("L3") != string::npos)
134  steps.push_back("L3EcalIso");
135  else if (modules[i].find("TkFiltered") != string::npos)
136  steps.push_back("TkEcalIso");
137  }
138  else if ((modules[i].find("pfhcalIsoRhoFiltered") != string::npos)) {
139  if (modules[i].find("L3") != string::npos)
140  steps.push_back("L3HcalIso");
141  else if (modules[i].find("TkFiltered") != string::npos)
142  steps.push_back("TkHcalIso");
143  }
144  else if (modules[i].find("TkFiltered") != string::npos){
145  steps.push_back("Tk");
146  }
147  else if (modules[i].find("L3") != string::npos)
148  steps.push_back("L3");
149  else if (modules[i].find("L2") != string::npos)
150  steps.push_back("L2");
151  else if (modules[i].find("L1") != string::npos)
152  steps.push_back("L1");
153  else
154  return vector<string>();
155  }
156 
157  if (steps.size() < 2 || ((steps[1] != "L1")&&(steps[1] != "Tk")))
158  return vector<string>();
159  return steps;
160 
161 }
162 
163 
164 
165 void
167  const edm::EventSetup & iSetup)
168 {
169  // Initialize hltConfig
170  bool changedConfig;
171  if (!hltConfig_.init(iRun, iSetup, hltProcessName_, changedConfig)) {
172  LogError("HLTMuonVal") << "Initialization of HLTConfigProvider failed!!";
173  return;
174  }
175 
176  // Get the set of trigger paths we want to make plots for
177  set<string> hltPaths;
178  for (size_t i = 0; i < hltPathsToCheck_.size(); i++) {
179  TPRegexp pattern(hltPathsToCheck_[i]);
180  for (size_t j = 0; j < hltConfig_.triggerNames().size(); j++)
181  if (TString(hltConfig_.triggerNames()[j]).Contains(pattern))
182  hltPaths.insert(hltConfig_.triggerNames()[j]);
183  }
184 
185  // Initialize the analyzers
186  analyzers_.clear();
187  set<string>::iterator iPath;
188  for (iPath = hltPaths.begin(); iPath != hltPaths.end(); iPath++) {
189 
190  string path = * iPath;
191  string shortpath = path;
192  if (path.rfind("_v") < path.length())
193  shortpath = path.substr(0, path.rfind("_v"));
194 
195  vector<string> labels = moduleLabels(path);
196  vector<string> steps = stepLabels(labels);
197 
198  if (!labels.empty() && !steps.empty()) {
199  HLTMuonPlotter analyzer(pset_, shortpath, labels, steps, myTokens_);
200  analyzers_.push_back(analyzer);
201  }
202  }
203 
204 }
205 
206 
207 
209  edm::Run const & iRun,
210  edm::EventSetup const & iSetup)
211 {
212 
213  // Call the beginRun (which books all the histograms)
214  vector<HLTMuonPlotter>::iterator iter;
215  for (iter = analyzers_.begin(); iter != analyzers_.end(); ++iter) {
216  iter->beginRun(iBooker, iRun, iSetup);
217  }
218 
219 }
220 
221 
222 
223 void
225  const EventSetup& iSetup)
226 {
227 
228  vector<HLTMuonPlotter>::iterator iter;
229  for (iter = analyzers_.begin(); iter != analyzers_.end(); ++iter) {
230  iter->analyze(iEvent, iSetup);
231  }
232 
233 }
234 
235 
236 
237 
238 void
240  const edm::EventSetup& iSetup)
241 {
242 
243  // vector<HLTMuonPlotter>::iterator iter;
244  // for (iter = analyzers_.begin(); iter != analyzers_.end(); ++iter) {
245  // iter->endRun(iRun, iSetup);
246  // }
247 
248 }
249 
250 
251 
252 
253 
254 //define this as a plug-in
vector< string > vstring
Definition: ExoticaDQM.cc:8
#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_
edm::ParameterSet pset_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
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
void analyze(const edm::Event &, const edm::EventSetup &) override
std::vector< std::string > moduleLabels(std::string)
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
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_
fixed size matrix
HLT enums.
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
vector< string > vstring
HLTMuonValidator(const edm::ParameterSet &)
Definition: Run.h:44