CMS 3D CMS Logo

HLTEventAnalyzerRAW.cc
Go to the documentation of this file.
1 
15 
16 // need access to class objects being referenced to get their content!
33 
34 #include <cassert>
35 
36 //
37 // constructors and destructor
38 //
40  processName_(ps.getParameter<std::string>("processName")),
41  triggerName_(ps.getParameter<std::string>("triggerName")),
42  triggerResultsTag_(ps.getParameter<edm::InputTag>("triggerResults")),
43  triggerResultsToken_(consumes<edm::TriggerResults>(triggerResultsTag_)),
44  triggerEventWithRefsTag_(ps.getParameter<edm::InputTag>("triggerEventWithRefs")),
45  triggerEventWithRefsToken_(consumes<trigger::TriggerEventWithRefs>(triggerEventWithRefsTag_))
46 {
47  using namespace std;
48  using namespace edm;
49 
50  LogVerbatim("HLTEventAnalyzerRAW") << "HLTEventAnalyzerRAW configuration: " << endl
51  << " ProcessName = " << processName_ << endl
52  << " TriggerName = " << triggerName_ << endl
53  << " TriggerResultsTag = " << triggerResultsTag_.encode() << endl
54  << " TriggerEventWithRefsTag = " << triggerEventWithRefsTag_.encode() << endl;
55 
56 }
57 
59 
60 //
61 // member functions
62 //
63 void
66  desc.add<std::string>("processName","HLT");
67  desc.add<std::string>("triggerName","@");
68  desc.add<edm::InputTag>("triggerResults",edm::InputTag("TriggerResults","","HLT"));
69  desc.add<edm::InputTag>("triggerEventWithRefs",edm::InputTag("hltTriggerSummaryRAW","","HLT"));
70  descriptions.add("hltEventAnalyzerRAW", desc);
71 }
72 
73 void
74 HLTEventAnalyzerRAW::endRun(edm::Run const & iRun, edm::EventSetup const& iSetup) {}
75 
76 void
78 {
79  using namespace std;
80  using namespace edm;
81 
82  bool changed(true);
83  if (hltConfig_.init(iRun,iSetup,processName_,changed)) {
84  if (changed) {
85  // check if trigger name in (new) config
86  if (triggerName_!="@") { // "@" means: analyze all triggers in config
87  const unsigned int n(hltConfig_.size());
88  const unsigned int triggerIndex(hltConfig_.triggerIndex(triggerName_));
89  if (triggerIndex>=n) {
90  LogVerbatim("HLTEventAnalyzerRAW") << "HLTEventAnalyzerRAW::analyze:"
91  << " TriggerName " << triggerName_
92  << " not available in (new) config!" << endl;
93  LogVerbatim("HLTEventAnalyzerRAW") << "Available TriggerNames are: " << endl;
94  hltConfig_.dump("Triggers");
95  }
96  }
97  }
98  } else {
99  LogVerbatim("HLTEventAnalyzerRAW") << "HLTEventAnalyzerRAW::analyze:"
100  << " config extraction failure with process name "
101  << processName_ << endl;
102  }
103 
104 }
105 
106 // ------------ method called to produce the data ------------
107 void
109 {
110  using namespace std;
111  using namespace edm;
112 
113  LogVerbatim("HLTEventAnalyzerRAW") << endl;
114 
115  // get event products
118  LogVerbatim("HLTEventAnalyzerRAW") << "HLTEventAnalyzerRAW::analyze: Error in getting TriggerResults product from Event!" << endl;
119  return;
120  }
123  LogVerbatim("HLTEventAnalyzerRAW") << "HLTEventAnalyzerRAW::analyze: Error in getting TriggerEventWithRefs product from Event!" << endl;
124  return;
125  }
126  // sanity check
128 
129  // analyze this event for the triggers requested
130  if (triggerName_=="@") {
131  const unsigned int n(hltConfig_.size());
132  for (unsigned int i=0; i!=n; ++i) {
133  analyzeTrigger(iEvent,iSetup,hltConfig_.triggerName(i));
134  }
135  } else {
136  analyzeTrigger(iEvent,iSetup,triggerName_);
137  }
138 
139  return;
140 
141 }
142 
143 void HLTEventAnalyzerRAW::analyzeTrigger(const edm::Event& iEvent, const edm::EventSetup& iSetup, const std::string& triggerName) {
144 
145  using namespace std;
146  using namespace edm;
147  using namespace reco;
148  using namespace trigger;
149 
150  LogVerbatim("HLTEventAnalyzerRAW") << endl;
151 
152  const unsigned int n(hltConfig_.size());
153  const unsigned int triggerIndex(hltConfig_.triggerIndex(triggerName));
154  assert(triggerIndex==iEvent.triggerNames(*triggerResultsHandle_).triggerIndex(triggerName));
155 
156  // abort on invalid trigger name
157  if (triggerIndex>=n) {
158  LogVerbatim("HLTEventAnalyzerRAW") << "HLTEventAnalyzerRAW::analyzeTrigger: path "
159  << triggerName << " - not found!" << endl;
160  return;
161  }
162 
163  LogVerbatim("HLTEventAnalyzerRAW") << "HLTEventAnalyzerRAW::analyzeTrigger: path "
164  << triggerName << " [" << triggerIndex << "]" << endl;
165  // modules on this trigger path
166  const unsigned int m(hltConfig_.size(triggerIndex));
167  const vector<string>& moduleLabels(hltConfig_.moduleLabels(triggerIndex));
168 
169  // Results from TriggerResults product
170  LogVerbatim("HLTEventAnalyzerRAW") << " Trigger path status:"
171  << " WasRun=" << triggerResultsHandle_->wasrun(triggerIndex)
172  << " Accept=" << triggerResultsHandle_->accept(triggerIndex)
173  << " Error =" << triggerResultsHandle_->error(triggerIndex)
174  << endl;
175  const unsigned int moduleIndex(triggerResultsHandle_->index(triggerIndex));
176  LogVerbatim("HLTEventAnalyzerRAW") << " Last active module - label/type: "
177  << moduleLabels[moduleIndex] << "/" << hltConfig_.moduleType(moduleLabels[moduleIndex])
178  << " [" << moduleIndex << " out of 0-" << (m-1) << " on this path]"
179  << endl;
180  assert (moduleIndex<m);
181 
182  // Results from TriggerEventWithRefs product
183  photonIds_.clear();
184  photonRefs_.clear();
185  electronIds_.clear();
186  electronRefs_.clear();
187  muonIds_.clear();
188  muonRefs_.clear();
189  jetIds_.clear();
190  jetRefs_.clear();
191  compositeIds_.clear();
192  compositeRefs_.clear();
193  basemetIds_.clear();
194  basemetRefs_.clear();
195  calometIds_.clear();
196  calometRefs_.clear();
197  pixtrackIds_.clear();
198  pixtrackRefs_.clear();
199  l1emIds_.clear();
200  l1emRefs_.clear();
201  l1muonIds_.clear();
202  l1muonRefs_.clear();
203  l1jetIds_.clear();
204  l1jetRefs_.clear();
205  l1etmissIds_.clear();
206  l1etmissRefs_.clear();
207  l1hfringsIds_.clear();
208  l1hfringsRefs_.clear();
209  pfjetIds_.clear();
210  pfjetRefs_.clear();
211  pftauIds_.clear();
212  pftauRefs_.clear();
213  pfmetIds_.clear();
214  pfmetRefs_.clear();
215 
216  // Attention: must look only for modules actually run in this path
217  // for this event!
218  for (unsigned int j=0; j<=moduleIndex; ++j) {
219  const string& moduleLabel(moduleLabels[j]);
220  const string moduleType(hltConfig_.moduleType(moduleLabel));
221  // check whether the module is packed up in TriggerEventWithRef product
222  const unsigned int filterIndex(triggerEventWithRefsHandle_->filterIndex(InputTag(moduleLabel,"",processName_)));
223  if (filterIndex<triggerEventWithRefsHandle_->size()) {
224  LogVerbatim("HLTEventAnalyzerRAW") << " Filter in slot " << j << " - label/type " << moduleLabel << "/" << moduleType << endl;
225  LogVerbatim("HLTEventAnalyzerRAW") << " Filter packed up at: " << filterIndex << endl;
226  LogVerbatim("HLTEventAnalyzerRAW") << " Accepted objects:" << endl;
227 
229  const unsigned int nPhotons(photonIds_.size());
230  if (nPhotons>0) {
231  LogVerbatim("HLTEventAnalyzerRAW") << " Photons: " << nPhotons << " - the objects: # id pt" << endl;
232  for (unsigned int i=0; i!=nPhotons; ++i) {
233  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << photonIds_[i]
234  << " " << photonRefs_[i]->pt()
235  << endl;
236  }
237  }
238 
240  const unsigned int nElectrons(electronIds_.size());
241  if (nElectrons>0) {
242  LogVerbatim("HLTEventAnalyzerRAW") << " Electrons: " << nElectrons << " - the objects: # id pt" << endl;
243  for (unsigned int i=0; i!=nElectrons; ++i) {
244  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << electronIds_[i]
245  << " " << electronRefs_[i]->pt()
246  << endl;
247  }
248  }
249 
251  const unsigned int nMuons(muonIds_.size());
252  if (nMuons>0) {
253  LogVerbatim("HLTEventAnalyzerRAW") << " Muons: " << nMuons << " - the objects: # id pt" << endl;
254  for (unsigned int i=0; i!=nMuons; ++i) {
255  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << muonIds_[i]
256  << " " << muonRefs_[i]->pt()
257  << endl;
258  }
259  }
260 
262  const unsigned int nJets(jetIds_.size());
263  if (nJets>0) {
264  LogVerbatim("HLTEventAnalyzerRAW") << " Jets: " << nJets << " - the objects: # id pt" << endl;
265  for (unsigned int i=0; i!=nJets; ++i) {
266  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << jetIds_[i]
267  << " " << jetRefs_[i]->pt()
268  << endl;
269  }
270  }
271 
273  const unsigned int nComposites(compositeIds_.size());
274  if (nComposites>0) {
275  LogVerbatim("HLTEventAnalyzerRAW") << " Composites: " << nComposites << " - the objects: # id pt" << endl;
276  for (unsigned int i=0; i!=nComposites; ++i) {
277  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << compositeIds_[i]
278  << " " << compositeRefs_[i]->pt()
279  << endl;
280  }
281  }
282 
284  const unsigned int nBaseMETs(basemetIds_.size());
285  if (nBaseMETs>0) {
286  LogVerbatim("HLTEventAnalyzerRAW") << " BaseMETs: " << nBaseMETs << " - the objects: # id pt" << endl;
287  for (unsigned int i=0; i!=nBaseMETs; ++i) {
288  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << basemetIds_[i]
289  << " " << basemetRefs_[i]->pt()
290  << endl;
291  }
292  }
293 
295  const unsigned int nCaloMETs(calometIds_.size());
296  if (nCaloMETs>0) {
297  LogVerbatim("HLTEventAnalyzerRAW") << " CaloMETs: " << nCaloMETs << " - the objects: # id pt" << endl;
298  for (unsigned int i=0; i!=nCaloMETs; ++i) {
299  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << calometIds_[i]
300  << " " << calometRefs_[i]->pt()
301  << endl;
302  }
303  }
304 
306  const unsigned int nPixTracks(pixtrackIds_.size());
307  if (nPixTracks>0) {
308  LogVerbatim("HLTEventAnalyzerRAW") << " PixTracks: " << nPixTracks << " - the objects: # id pt" << endl;
309  for (unsigned int i=0; i!=nPixTracks; ++i) {
310  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << pixtrackIds_[i]
311  << " " << pixtrackRefs_[i]->pt()
312  << endl;
313  }
314  }
315 
317  const unsigned int nL1EM(l1emIds_.size());
318  if (nL1EM>0) {
319  LogVerbatim("HLTEventAnalyzerRAW") << " L1EM: " << nL1EM << " - the objects: # id pt" << endl;
320  for (unsigned int i=0; i!=nL1EM; ++i) {
321  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << l1emIds_[i]
322  << " " << l1emRefs_[i]->pt()
323  << endl;
324  }
325  }
326 
328  const unsigned int nL1Muon(l1muonIds_.size());
329  if (nL1Muon>0) {
330  LogVerbatim("HLTEventAnalyzerRAW") << " L1Muon: " << nL1Muon << " - the objects: # id pt" << endl;
331  for (unsigned int i=0; i!=nL1Muon; ++i) {
332  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << l1muonIds_[i]
333  << " " << l1muonRefs_[i]->pt()
334  << endl;
335  }
336  }
337 
339  const unsigned int nL1Jet(l1jetIds_.size());
340  if (nL1Jet>0) {
341  LogVerbatim("HLTEventAnalyzerRAW") << " L1Jet: " << nL1Jet << " - the objects: # id pt" << endl;
342  for (unsigned int i=0; i!=nL1Jet; ++i) {
343  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << l1jetIds_[i]
344  << " " << l1jetRefs_[i]->pt()
345  << endl;
346  }
347  }
348 
350  const unsigned int nL1EtMiss(l1etmissIds_.size());
351  if (nL1EtMiss>0) {
352  LogVerbatim("HLTEventAnalyzerRAW") << " L1EtMiss: " << nL1EtMiss << " - the objects: # id pt" << endl;
353  for (unsigned int i=0; i!=nL1EtMiss; ++i) {
354  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << l1etmissIds_[i]
355  << " " << l1etmissRefs_[i]->pt()
356  << endl;
357  }
358  }
359 
361  const unsigned int nL1HfRings(l1hfringsIds_.size());
362  if (nL1HfRings>0) {
363  LogVerbatim("HLTEventAnalyzerRAW") << " L1HfRings: " << nL1HfRings << " - the objects: # id 4 4" << endl;
364  for (unsigned int i=0; i!=nL1HfRings; ++i) {
365  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << l1hfringsIds_[i]
370  << " " << l1hfringsRefs_[i]->hfBitCount(l1extra::L1HFRings::kRing1PosEta)
371  << " " << l1hfringsRefs_[i]->hfBitCount(l1extra::L1HFRings::kRing1NegEta)
372  << " " << l1hfringsRefs_[i]->hfBitCount(l1extra::L1HFRings::kRing2PosEta)
373  << " " << l1hfringsRefs_[i]->hfBitCount(l1extra::L1HFRings::kRing2NegEta)
374  << endl;
375  }
376  }
377 
379  const unsigned int nPFJets(pfjetIds_.size());
380  if (nPFJets>0) {
381  LogVerbatim("HLTEventAnalyzerRAW") << " PFJets: " << nPFJets << " - the objects: # id pt" << endl;
382  for (unsigned int i=0; i!=nPFJets; ++i) {
383  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << pfjetIds_[i]
384  << " " << pfjetRefs_[i]->pt()
385  << endl;
386  }
387  }
388 
390  const unsigned int nPFTaus(pftauIds_.size());
391  if (nPFTaus>0) {
392  LogVerbatim("HLTEventAnalyzerRAW") << " PFTaus: " << nPFTaus << " - the objects: # id pt" << endl;
393  for (unsigned int i=0; i!=nPFTaus; ++i) {
394  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << pftauIds_[i]
395  << " " << pftauRefs_[i]->pt()
396  << endl;
397  }
398  }
399 
401  const unsigned int nPfMETs(pfmetIds_.size());
402  if (nPfMETs>0) {
403  LogVerbatim("HLTEventAnalyzerRAW") << " PfMETs: " << nPfMETs << " - the objects: # id pt" << endl;
404  for (unsigned int i=0; i!=nPfMETs; ++i) {
405  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << pfmetIds_[i]
406  << " " << pfmetRefs_[i]->pt()
407  << endl;
408  }
409  }
410 
411  }
412  }
413 
414  return;
415 }
unsigned int size() const
number of trigger paths in trigger table
size
Write out results.
void dump(const std::string &what) const
Dumping config info to cout.
bool wasrun() const
Was at least one path run?
trigger::Vids compositeIds_
const std::string moduleType(const std::string &module) const
C++ class name of module.
trigger::Vids l1etmissIds_
edm::Handle< edm::TriggerResults > triggerResultsHandle_
additional class data memebers
const std::string & triggerName(unsigned int triggerIndex) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
trigger::VRl1muon l1muonRefs_
trigger::Vids electronIds_
const edm::InputTag triggerEventWithRefsTag_
bool accept() const
Has at least one path accepted the event?
trigger::VRl1em l1emRefs_
trigger::VRpftau pftauRefs_
void endRun(edm::Run const &, edm::EventSetup const &) override
HLTEventAnalyzerRAW(const edm::ParameterSet &)
const edm::InputTag triggerResultsTag_
std::string encode() const
Definition: InputTag.cc:166
trigger::VRpfjet pfjetRefs_
trigger::Vids photonIds_
payload extracted from TriggerEventWithRefs
trigger::VRl1jet l1jetRefs_
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
void beginRun(edm::Run const &, edm::EventSetup const &) override
trigger::VRcomposite compositeRefs_
const std::string processName_
module config parameters
int iEvent
Definition: GenABIO.cc:230
const edm::EDGetTokenT< trigger::TriggerEventWithRefs > triggerEventWithRefsToken_
trigger::VRphoton photonRefs_
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:32
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
unsigned int size() const
Get number of paths stored.
HLTConfigProvider hltConfig_
unsigned int index(const unsigned int i) const
Get index (slot position) of module giving the decision of the ith path.
trigger::VRpfmet pfmetRefs_
bool error() const
Has any path encountered an error (exception)
~HLTEventAnalyzerRAW() override
void analyze(const edm::Event &, const edm::EventSetup &) override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:74
trigger::VRelectron electronRefs_
size_type filterIndex(const edm::InputTag &filterTag) const
index from tag
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
const edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
trigger::Vids pixtrackIds_
trigger::Vids l1hfringsIds_
trigger::VRl1etmiss l1etmissRefs_
void getObjects(size_type filter, Vids &ids, VRphoton &photons) const
extract Ref<C>s for a specific filter and of specific physics type
edm::Handle< trigger::TriggerEventWithRefs > triggerEventWithRefsHandle_
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
void add(std::string const &label, ParameterSetDescription const &psetDescription)
trigger::VRl1hfrings l1hfringsRefs_
trigger::VRcalomet calometRefs_
virtual void analyzeTrigger(const edm::Event &, const edm::EventSetup &, const std::string &triggerName)
fixed size matrix
HLT enums.
const std::string triggerName_
trigger::VRmuon muonRefs_
trigger::VRpixtrack pixtrackRefs_
trigger::VRbasemet basemetRefs_
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:272
Definition: Run.h:43