1 |
// -*- C++ -*-
|
2 |
//
|
3 |
// Package: TriggerEventAnalyzer
|
4 |
// Class: TriggerEventAnalyzer
|
5 |
//
|
6 |
/**\class TriggerEventAnalyzer TriggerEventAnalyzer.cc SusyAnalysis/TriggerEventAnalyzer/src/TriggerEventAnalyzer.cc
|
7 |
|
8 |
Description: [one line class summary]
|
9 |
|
10 |
Implementation:
|
11 |
[Notes on implementation]
|
12 |
*/
|
13 |
//
|
14 |
// Original Author: Yutaro Iiyama,512 1-005,+41227670489,
|
15 |
// Created: Sat Jun 16 12:57:28 CEST 2012
|
16 |
// $Id$
|
17 |
//
|
18 |
//
|
19 |
|
20 |
|
21 |
// system include files
|
22 |
#include <memory>
|
23 |
|
24 |
// user include files
|
25 |
#include "FWCore/Framework/interface/Frameworkfwd.h"
|
26 |
#include "FWCore/Framework/interface/EDAnalyzer.h"
|
27 |
|
28 |
#include "FWCore/Framework/interface/Event.h"
|
29 |
#include "FWCore/Framework/interface/MakerMacros.h"
|
30 |
|
31 |
#include "FWCore/ParameterSet/interface/ParameterSet.h"
|
32 |
|
33 |
#include "FWCore/Utilities/interface/InputTag.h"
|
34 |
|
35 |
#include "DataFormats/Common/interface/Handle.h"
|
36 |
#include "DataFormats/HLTReco/interface/TriggerEvent.h"
|
37 |
#include "DataFormats/Common/interface/TriggerResults.h"
|
38 |
#include "FWCore/Common/interface/TriggerNames.h"
|
39 |
//
|
40 |
// class declaration
|
41 |
//
|
42 |
|
43 |
class TriggerEventAnalyzer : public edm::EDAnalyzer {
|
44 |
public:
|
45 |
explicit TriggerEventAnalyzer(const edm::ParameterSet&);
|
46 |
~TriggerEventAnalyzer();
|
47 |
|
48 |
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
|
49 |
|
50 |
|
51 |
private:
|
52 |
virtual void beginJob() ;
|
53 |
virtual void analyze(const edm::Event&, const edm::EventSetup&);
|
54 |
virtual void endJob() ;
|
55 |
|
56 |
virtual void beginRun(edm::Run const&, edm::EventSetup const&);
|
57 |
virtual void endRun(edm::Run const&, edm::EventSetup const&);
|
58 |
virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
|
59 |
virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
|
60 |
|
61 |
// ----------member data ---------------------------
|
62 |
|
63 |
std::vector<std::string> pathNames_;
|
64 |
std::vector<int> accept_;
|
65 |
int iDisplay_;
|
66 |
int maxDisplay_;
|
67 |
};
|
68 |
|
69 |
//
|
70 |
// constants, enums and typedefs
|
71 |
//
|
72 |
|
73 |
//
|
74 |
// static data member definitions
|
75 |
//
|
76 |
|
77 |
//
|
78 |
// constructors and destructor
|
79 |
//
|
80 |
TriggerEventAnalyzer::TriggerEventAnalyzer(const edm::ParameterSet& iConfig) :
|
81 |
pathNames_(iConfig.getParameter<std::vector<std::string> >("pathNames")),
|
82 |
accept_(iConfig.getParameter<std::vector<int> >("accept")),
|
83 |
iDisplay_(0),
|
84 |
maxDisplay_(iConfig.getUntrackedParameter<int>("maxDisplay", 1))
|
85 |
{
|
86 |
//now do what ever initialization is needed
|
87 |
|
88 |
}
|
89 |
|
90 |
|
91 |
TriggerEventAnalyzer::~TriggerEventAnalyzer()
|
92 |
{
|
93 |
|
94 |
// do anything here that needs to be done at desctruction time
|
95 |
// (e.g. close files, deallocate resources etc.)
|
96 |
|
97 |
}
|
98 |
|
99 |
|
100 |
//
|
101 |
// member functions
|
102 |
//
|
103 |
|
104 |
// ------------ method called for each event ------------
|
105 |
void
|
106 |
TriggerEventAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
|
107 |
{
|
108 |
using namespace edm;
|
109 |
using namespace std;
|
110 |
|
111 |
if(iDisplay_ == maxDisplay_) return;
|
112 |
|
113 |
Handle<trigger::TriggerEvent> teHndl;
|
114 |
if(!iEvent.getByLabel("hltTriggerSummaryAOD", teHndl)) return;
|
115 |
|
116 |
Handle<TriggerResults> trHndl;
|
117 |
if(!iEvent.getByLabel(InputTag("TriggerResults", "", "HLT"), trHndl)) return;
|
118 |
|
119 |
vector<bool> passed(pathNames_.size());
|
120 |
for(unsigned iP(0); iP < passed.size(); iP++)
|
121 |
passed[iP] = !bool(accept_.at(iP));
|
122 |
|
123 |
edm::TriggerNames const& triggerNames(iEvent.triggerNames(*trHndl));
|
124 |
|
125 |
for(unsigned iP(0); iP < pathNames_.size(); iP++){
|
126 |
for(unsigned iT(0); iT < triggerNames.size(); iT++){
|
127 |
if(triggerNames.triggerName(iT).find(pathNames_[iP]) != string::npos)
|
128 |
passed[iP] = (trHndl->accept(iT) ^ passed[iP]);
|
129 |
}
|
130 |
}
|
131 |
|
132 |
bool process(true);
|
133 |
for(unsigned iP(0); iP < passed.size(); iP++) process &= passed[iP];
|
134 |
|
135 |
if(!process) return;
|
136 |
|
137 |
iDisplay_ += 1;
|
138 |
|
139 |
cout << "TriggerEvent" << endl;
|
140 |
|
141 |
cout << "COLLECTIONTAGS:" << endl;
|
142 |
vector<string> const& tags(teHndl->collectionTags());
|
143 |
for(unsigned iT = 0; iT < tags.size(); iT++)
|
144 |
cout << " " << iT << ". " << tags[iT] << endl;
|
145 |
|
146 |
cout << endl << "FILTERS: " << endl;
|
147 |
unsigned nF(teHndl->sizeFilters());
|
148 |
for(unsigned iF = 0; iF < nF; iF++){
|
149 |
cout << " " << iF << ". " << teHndl->filterTag(iF) << ": ";
|
150 |
trigger::Vids const& vids(teHndl->filterIds(iF));
|
151 |
trigger::Keys const& keys(teHndl->filterKeys(iF));
|
152 |
for(unsigned iI = 0; iI < vids.size(); iI++){
|
153 |
cout << keys.at(iI) << "(" << vids.at(iI) << ") ";
|
154 |
}
|
155 |
cout << endl;
|
156 |
}
|
157 |
}
|
158 |
|
159 |
|
160 |
// ------------ method called once each job just before starting event loop ------------
|
161 |
void
|
162 |
TriggerEventAnalyzer::beginJob()
|
163 |
{
|
164 |
}
|
165 |
|
166 |
// ------------ method called once each job just after ending the event loop ------------
|
167 |
void
|
168 |
TriggerEventAnalyzer::endJob()
|
169 |
{
|
170 |
}
|
171 |
|
172 |
// ------------ method called when starting to processes a run ------------
|
173 |
void
|
174 |
TriggerEventAnalyzer::beginRun(edm::Run const&, edm::EventSetup const&)
|
175 |
{
|
176 |
}
|
177 |
|
178 |
// ------------ method called when ending the processing of a run ------------
|
179 |
void
|
180 |
TriggerEventAnalyzer::endRun(edm::Run const&, edm::EventSetup const&)
|
181 |
{
|
182 |
}
|
183 |
|
184 |
// ------------ method called when starting to processes a luminosity block ------------
|
185 |
void
|
186 |
TriggerEventAnalyzer::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
|
187 |
{
|
188 |
}
|
189 |
|
190 |
// ------------ method called when ending the processing of a luminosity block ------------
|
191 |
void
|
192 |
TriggerEventAnalyzer::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
|
193 |
{
|
194 |
}
|
195 |
|
196 |
// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
|
197 |
void
|
198 |
TriggerEventAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
|
199 |
//The following says we do not know what parameters are allowed so do no validation
|
200 |
// Please change this to state exactly what you do use, even if it is no parameters
|
201 |
edm::ParameterSetDescription desc;
|
202 |
desc.setUnknown();
|
203 |
descriptions.addDefault(desc);
|
204 |
}
|
205 |
|
206 |
//define this as a plug-in
|
207 |
DEFINE_FWK_MODULE(TriggerEventAnalyzer);
|