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 // $Id: HLTMuonOfflineAnalyzer.cc,v 1.3 2011/04/01 20:39:01 klukas Exp $
10 //
11 //
12 
13 // system include files
14 #include <memory>
15 #include <iostream>
16 
17 // user include files
19 
21 
24 // #include "FWCore/Framework/interface/Event.h"
25 // #include "FWCore/Framework/interface/Run.h"
26 // #include "FWCore/Framework/interface/EventSetup.h"
30 
31 
34 
35 
36 #include "TFile.h"
37 #include "TDirectory.h"
38 #include "TPRegexp.h"
39 
40 
43 
44 
45 
47 
48 public:
49 
51 
52 private:
53 
54  // Analyzer Methods
55  virtual void beginJob();
56  virtual void beginRun(const edm::Run &, const edm::EventSetup &);
57  virtual void analyze(const edm::Event &, const edm::EventSetup &);
58  virtual void endRun(const edm::Run &, const edm::EventSetup &);
59  virtual void endJob();
60 
61  // Extra Methods
62  std::vector<std::string> moduleLabels(std::string);
63 
64  // Input from Configuration File
68  std::vector<std::string> hltPathsToCheck_;
69 
70  // Member Variables
71  std::vector<HLTMuonMatchAndPlot> analyzers_;
73 
74  // Access to the DQM
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  destination_(pset.getUntrackedParameter<string>("destination")),
100  hltPathsToCheck_(pset.getParameter<vstring>("hltPathsToCheck"))
101 {
102  // Prepare the DQMStore object.
104  dbe_->setVerbose(0);
106 }
107 
108 
109 
110 vector<string>
112 
113  vector<string> modules = hltConfig_.moduleLabels(path);
114  vector<string>::iterator iter = modules.begin();
115 
116  while (iter != modules.end())
117  if (iter->find("Filtered") == string::npos)
118  iter = modules.erase(iter);
119  else
120  ++iter;
121 
122  return modules;
123 
124 }
125 
126 
127 
128 void
130  const edm::EventSetup & iSetup) {
131 
132  // Initialize hltConfig
133  bool changedConfig;
134  if (!hltConfig_.init(iRun, iSetup, hltProcessName_, changedConfig)) {
135  LogError("HLTMuonVal") << "Initialization of HLTConfigProvider failed!!";
136  return;
137  }
138 
139  // Get the set of trigger paths we want to make plots for
140  set<string> hltPaths;
141  for (size_t i = 0; i < hltPathsToCheck_.size(); i++) {
142  TPRegexp pattern(hltPathsToCheck_[i]);
143  for (size_t j = 0; j < hltConfig_.triggerNames().size(); j++)
144  if (TString(hltConfig_.triggerNames()[j]).Contains(pattern))
145  hltPaths.insert(hltConfig_.triggerNames()[j]);
146  }
147 
148  // Initialize the analyzers
149  analyzers_.clear();
150  set<string>::iterator iPath;
151  for (iPath = hltPaths.begin(); iPath != hltPaths.end(); iPath++) {
152  string path = * iPath;
153  vector<string> labels = moduleLabels(path);
154  if (labels.size() > 0) {
155  HLTMuonMatchAndPlot analyzer(pset_, path, moduleLabels(path));
156  analyzers_.push_back(analyzer);
157  }
158  }
159 
160  // Call the beginRun (which books all the histograms)
161  vector<HLTMuonMatchAndPlot>::iterator iter;
162  for (iter = analyzers_.begin(); iter != analyzers_.end(); ++iter) {
163  iter->beginRun(iRun, iSetup);
164  }
165 
166 }
167 
168 void
170  const EventSetup& iSetup)
171 {
172 
173  vector<HLTMuonMatchAndPlot>::iterator iter;
174  for (iter = analyzers_.begin(); iter != analyzers_.end(); ++iter) {
175  iter->analyze(iEvent, iSetup);
176  }
177 
178 }
179 
180 
181 
182 void
184 {
185 }
186 
187 
188 
189 void
191  const edm::EventSetup& iSetup)
192 {
193 
194  // vector<HLTMuonMatchAndPlot>::iterator iter;
195  // for (iter = analyzers_.begin(); iter != analyzers_.end(); ++iter) {
196  // iter->endRun(iRun, iSetup);
197  // }
198 
199 }
200 
201 
202 
203 void
205 {
206 }
207 
208 
209 
210 //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 > moduleLabels(std::string)
const std::vector< std::string > & triggerNames() const
names of trigger paths
int iEvent
Definition: GenABIO.cc:243
virtual void analyze(const edm::Event &, const edm::EventSetup &)
int j
Definition: DBlmapReader.cc:9
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
void setVerbose(unsigned level)
Definition: DQMStore.cc:398
std::vector< HLTMuonMatchAndPlot > analyzers_
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
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 endRun(const edm::Run &, const edm::EventSetup &)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
Definition: Run.h:36
std::vector< std::string > hltPathsToCheck_