CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
23 // #include "FWCore/Framework/interface/Event.h"
24 // #include "FWCore/Framework/interface/Run.h"
25 // #include "FWCore/Framework/interface/EventSetup.h"
29 
30 
33 
34 
35 #include "TFile.h"
36 #include "TDirectory.h"
37 #include "TPRegexp.h"
38 
39 
42 
43 
44 
46 
47 public:
48 
50 
51 private:
52 
53  // Analyzer Methods
54  virtual void beginJob() override;
55  virtual void beginRun(const edm::Run &, const edm::EventSetup &) override;
56  virtual void analyze(const edm::Event &, const edm::EventSetup &) override;
57  virtual void endRun(const edm::Run &, const edm::EventSetup &) override;
58  virtual void endJob() override;
59 
60  // Extra Methods
61  std::vector<std::string> moduleLabels(std::string);
62 
63  // Input from Configuration File
67  std::vector<std::string> hltPathsToCheck_;
68 
69  // Member Variables
70  std::vector<HLTMuonMatchAndPlot> analyzers_;
72 
73  // Access to the DQM
75 
76 };
77 
78 
79 
82 
83 using namespace std;
84 using namespace edm;
85 using namespace reco;
86 using namespace trigger;
87 
88 typedef vector<string> vstring;
89 
90 
91 
94 
96  pset_(pset),
97  hltProcessName_(pset.getParameter<string>("hltProcessName")),
98  destination_(pset.getUntrackedParameter<string>("destination")),
99  hltPathsToCheck_(pset.getParameter<vstring>("hltPathsToCheck"))
100 {
101  // Prepare the DQMStore object.
103  dbe_->setVerbose(0);
105 }
106 
107 
108 
109 vector<string>
111 
112  vector<string> modules = hltConfig_.moduleLabels(path);
113  vector<string>::iterator iter = modules.begin();
114 
115  while (iter != modules.end())
116  if (iter->find("Filtered") == string::npos)
117  iter = modules.erase(iter);
118  else
119  ++iter;
120 
121  return modules;
122 
123 }
124 
125 
126 
127 void
129  const edm::EventSetup & iSetup) {
130 
131  // Initialize hltConfig
132  bool changedConfig;
133  if (!hltConfig_.init(iRun, iSetup, hltProcessName_, changedConfig)) {
134  LogError("HLTMuonVal") << "Initialization of HLTConfigProvider failed!!";
135  return;
136  }
137 
138  // Get the set of trigger paths we want to make plots for
139  set<string> hltPaths;
140  for (size_t i = 0; i < hltPathsToCheck_.size(); i++) {
141  TPRegexp pattern(hltPathsToCheck_[i]);
142  for (size_t j = 0; j < hltConfig_.triggerNames().size(); j++)
143  if (TString(hltConfig_.triggerNames()[j]).Contains(pattern))
144  hltPaths.insert(hltConfig_.triggerNames()[j]);
145  }
146 
147  // Initialize the analyzers
148  analyzers_.clear();
149  set<string>::iterator iPath;
150  for (iPath = hltPaths.begin(); iPath != hltPaths.end(); iPath++) {
151  string path = * iPath;
152  vector<string> labels = moduleLabels(path);
153  if (labels.size() > 0) {
154  HLTMuonMatchAndPlot analyzer(pset_, path, moduleLabels(path));
155  analyzers_.push_back(analyzer);
156  }
157  }
158 
159  // Call the beginRun (which books all the histograms)
160  vector<HLTMuonMatchAndPlot>::iterator iter;
161  for (iter = analyzers_.begin(); iter != analyzers_.end(); ++iter) {
162  iter->beginRun(iRun, iSetup);
163  }
164 
165 }
166 
167 void
169  const EventSetup& iSetup)
170 {
171 
172  vector<HLTMuonMatchAndPlot>::iterator iter;
173  for (iter = analyzers_.begin(); iter != analyzers_.end(); ++iter) {
174  iter->analyze(iEvent, iSetup);
175  }
176 
177 }
178 
179 
180 
181 void
183 {
184 }
185 
186 
187 
188 void
190  const edm::EventSetup& iSetup)
191 {
192 
193  // vector<HLTMuonMatchAndPlot>::iterator iter;
194  // for (iter = analyzers_.begin(); iter != analyzers_.end(); ++iter) {
195  // iter->endRun(iRun, iSetup);
196  // }
197 
198 }
199 
200 
201 
202 void
204 {
205 }
206 
207 
208 
209 //define this as a plug-in
int i
Definition: DBlmapReader.cc:9
vector< string > vstring
Definition: ExoticaDQM.cc:75
virtual void endRun(const edm::Run &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< std::string > moduleLabels(std::string)
const std::vector< std::string > & triggerNames() const
names of trigger paths
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
virtual void beginJob() override
int iEvent
Definition: GenABIO.cc:243
int j
Definition: DBlmapReader.cc:9
void setVerbose(unsigned level)
Definition: DQMStore.cc:548
std::vector< HLTMuonMatchAndPlot > analyzers_
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
virtual 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
virtual void endJob() override
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
Definition: Run.h:41
std::vector< std::string > hltPathsToCheck_