test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
62 //
63 // member functions
64 //
65 void
68  desc.add<std::string>("processName","HLT");
69  desc.add<std::string>("triggerName","@");
70  desc.add<edm::InputTag>("triggerResults",edm::InputTag("TriggerResults","","HLT"));
71  desc.add<edm::InputTag>("triggerEventWithRefs",edm::InputTag("hltTriggerSummaryRAW","","HLT"));
72  descriptions.add("hltEventAnalyzerRAW", desc);
73 }
74 
75 void
76 HLTEventAnalyzerRAW::endRun(edm::Run const & iRun, edm::EventSetup const& iSetup) {}
77 
78 void
80 {
81  using namespace std;
82  using namespace edm;
83 
84  bool changed(true);
85  if (hltConfig_.init(iRun,iSetup,processName_,changed)) {
86  if (changed) {
87  // check if trigger name in (new) config
88  if (triggerName_!="@") { // "@" means: analyze all triggers in config
89  const unsigned int n(hltConfig_.size());
90  const unsigned int triggerIndex(hltConfig_.triggerIndex(triggerName_));
91  if (triggerIndex>=n) {
92  LogVerbatim("HLTEventAnalyzerRAW") << "HLTEventAnalyzerRAW::analyze:"
93  << " TriggerName " << triggerName_
94  << " not available in (new) config!" << endl;
95  LogVerbatim("HLTEventAnalyzerRAW") << "Available TriggerNames are: " << endl;
96  hltConfig_.dump("Triggers");
97  }
98  }
99  }
100  } else {
101  LogVerbatim("HLTEventAnalyzerRAW") << "HLTEventAnalyzerRAW::analyze:"
102  << " config extraction failure with process name "
103  << processName_ << endl;
104  }
105 
106 }
107 
108 // ------------ method called to produce the data ------------
109 void
111 {
112  using namespace std;
113  using namespace edm;
114 
115  LogVerbatim("HLTEventAnalyzerRAW") << endl;
116 
117  // get event products
120  LogVerbatim("HLTEventAnalyzerRAW") << "HLTEventAnalyzerRAW::analyze: Error in getting TriggerResults product from Event!" << endl;
121  return;
122  }
125  LogVerbatim("HLTEventAnalyzerRAW") << "HLTEventAnalyzerRAW::analyze: Error in getting TriggerEventWithRefs product from Event!" << endl;
126  return;
127  }
128  // sanity check
130 
131  // analyze this event for the triggers requested
132  if (triggerName_=="@") {
133  const unsigned int n(hltConfig_.size());
134  for (unsigned int i=0; i!=n; ++i) {
135  analyzeTrigger(iEvent,iSetup,hltConfig_.triggerName(i));
136  }
137  } else {
138  analyzeTrigger(iEvent,iSetup,triggerName_);
139  }
140 
141  return;
142 
143 }
144 
145 void HLTEventAnalyzerRAW::analyzeTrigger(const edm::Event& iEvent, const edm::EventSetup& iSetup, const std::string& triggerName) {
146 
147  using namespace std;
148  using namespace edm;
149  using namespace reco;
150  using namespace trigger;
151 
152  LogVerbatim("HLTEventAnalyzerRAW") << endl;
153 
154  const unsigned int n(hltConfig_.size());
155  const unsigned int triggerIndex(hltConfig_.triggerIndex(triggerName));
156  assert(triggerIndex==iEvent.triggerNames(*triggerResultsHandle_).triggerIndex(triggerName));
157 
158  // abort on invalid trigger name
159  if (triggerIndex>=n) {
160  LogVerbatim("HLTEventAnalyzerRAW") << "HLTEventAnalyzerRAW::analyzeTrigger: path "
161  << triggerName << " - not found!" << endl;
162  return;
163  }
164 
165  LogVerbatim("HLTEventAnalyzerRAW") << "HLTEventAnalyzerRAW::analyzeTrigger: path "
166  << triggerName << " [" << triggerIndex << "]" << endl;
167  // modules on this trigger path
168  const unsigned int m(hltConfig_.size(triggerIndex));
169  const vector<string>& moduleLabels(hltConfig_.moduleLabels(triggerIndex));
170 
171  // Results from TriggerResults product
172  LogVerbatim("HLTEventAnalyzerRAW") << " Trigger path status:"
173  << " WasRun=" << triggerResultsHandle_->wasrun(triggerIndex)
174  << " Accept=" << triggerResultsHandle_->accept(triggerIndex)
175  << " Error =" << triggerResultsHandle_->error(triggerIndex)
176  << endl;
177  const unsigned int moduleIndex(triggerResultsHandle_->index(triggerIndex));
178  LogVerbatim("HLTEventAnalyzerRAW") << " Last active module - label/type: "
179  << moduleLabels[moduleIndex] << "/" << hltConfig_.moduleType(moduleLabels[moduleIndex])
180  << " [" << moduleIndex << " out of 0-" << (m-1) << " on this path]"
181  << endl;
182  assert (moduleIndex<m);
183 
184  // Results from TriggerEventWithRefs product
185  photonIds_.clear();
186  photonRefs_.clear();
187  electronIds_.clear();
188  electronRefs_.clear();
189  muonIds_.clear();
190  muonRefs_.clear();
191  jetIds_.clear();
192  jetRefs_.clear();
193  compositeIds_.clear();
194  compositeRefs_.clear();
195  basemetIds_.clear();
196  basemetRefs_.clear();
197  calometIds_.clear();
198  calometRefs_.clear();
199  pixtrackIds_.clear();
200  pixtrackRefs_.clear();
201  l1emIds_.clear();
202  l1emRefs_.clear();
203  l1muonIds_.clear();
204  l1muonRefs_.clear();
205  l1jetIds_.clear();
206  l1jetRefs_.clear();
207  l1etmissIds_.clear();
208  l1etmissRefs_.clear();
209  l1hfringsIds_.clear();
210  l1hfringsRefs_.clear();
211  pfjetIds_.clear();
212  pfjetRefs_.clear();
213  pftauIds_.clear();
214  pftauRefs_.clear();
215  pfmetIds_.clear();
216  pfmetRefs_.clear();
217 
218  // Attention: must look only for modules actually run in this path
219  // for this event!
220  for (unsigned int j=0; j<=moduleIndex; ++j) {
221  const string& moduleLabel(moduleLabels[j]);
222  const string moduleType(hltConfig_.moduleType(moduleLabel));
223  // check whether the module is packed up in TriggerEventWithRef product
224  const unsigned int filterIndex(triggerEventWithRefsHandle_->filterIndex(InputTag(moduleLabel,"",processName_)));
225  if (filterIndex<triggerEventWithRefsHandle_->size()) {
226  LogVerbatim("HLTEventAnalyzerRAW") << " Filter in slot " << j << " - label/type " << moduleLabel << "/" << moduleType << endl;
227  LogVerbatim("HLTEventAnalyzerRAW") << " Filter packed up at: " << filterIndex << endl;
228  LogVerbatim("HLTEventAnalyzerRAW") << " Accepted objects:" << endl;
229 
230  triggerEventWithRefsHandle_->getObjects(filterIndex,photonIds_,photonRefs_);
231  const unsigned int nPhotons(photonIds_.size());
232  if (nPhotons>0) {
233  LogVerbatim("HLTEventAnalyzerRAW") << " Photons: " << nPhotons << " - the objects: # id pt" << endl;
234  for (unsigned int i=0; i!=nPhotons; ++i) {
235  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << photonIds_[i]
236  << " " << photonRefs_[i]->pt()
237  << endl;
238  }
239  }
240 
241  triggerEventWithRefsHandle_->getObjects(filterIndex,electronIds_,electronRefs_);
242  const unsigned int nElectrons(electronIds_.size());
243  if (nElectrons>0) {
244  LogVerbatim("HLTEventAnalyzerRAW") << " Electrons: " << nElectrons << " - the objects: # id pt" << endl;
245  for (unsigned int i=0; i!=nElectrons; ++i) {
246  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << electronIds_[i]
247  << " " << electronRefs_[i]->pt()
248  << endl;
249  }
250  }
251 
252  triggerEventWithRefsHandle_->getObjects(filterIndex,muonIds_,muonRefs_);
253  const unsigned int nMuons(muonIds_.size());
254  if (nMuons>0) {
255  LogVerbatim("HLTEventAnalyzerRAW") << " Muons: " << nMuons << " - the objects: # id pt" << endl;
256  for (unsigned int i=0; i!=nMuons; ++i) {
257  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << muonIds_[i]
258  << " " << muonRefs_[i]->pt()
259  << endl;
260  }
261  }
262 
263  triggerEventWithRefsHandle_->getObjects(filterIndex,jetIds_,jetRefs_);
264  const unsigned int nJets(jetIds_.size());
265  if (nJets>0) {
266  LogVerbatim("HLTEventAnalyzerRAW") << " Jets: " << nJets << " - the objects: # id pt" << endl;
267  for (unsigned int i=0; i!=nJets; ++i) {
268  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << jetIds_[i]
269  << " " << jetRefs_[i]->pt()
270  << endl;
271  }
272  }
273 
275  const unsigned int nComposites(compositeIds_.size());
276  if (nComposites>0) {
277  LogVerbatim("HLTEventAnalyzerRAW") << " Composites: " << nComposites << " - the objects: # id pt" << endl;
278  for (unsigned int i=0; i!=nComposites; ++i) {
279  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << compositeIds_[i]
280  << " " << compositeRefs_[i]->pt()
281  << endl;
282  }
283  }
284 
285  triggerEventWithRefsHandle_->getObjects(filterIndex,basemetIds_,basemetRefs_);
286  const unsigned int nBaseMETs(basemetIds_.size());
287  if (nBaseMETs>0) {
288  LogVerbatim("HLTEventAnalyzerRAW") << " BaseMETs: " << nBaseMETs << " - the objects: # id pt" << endl;
289  for (unsigned int i=0; i!=nBaseMETs; ++i) {
290  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << basemetIds_[i]
291  << " " << basemetRefs_[i]->pt()
292  << endl;
293  }
294  }
295 
296  triggerEventWithRefsHandle_->getObjects(filterIndex,calometIds_,calometRefs_);
297  const unsigned int nCaloMETs(calometIds_.size());
298  if (nCaloMETs>0) {
299  LogVerbatim("HLTEventAnalyzerRAW") << " CaloMETs: " << nCaloMETs << " - the objects: # id pt" << endl;
300  for (unsigned int i=0; i!=nCaloMETs; ++i) {
301  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << calometIds_[i]
302  << " " << calometRefs_[i]->pt()
303  << endl;
304  }
305  }
306 
307  triggerEventWithRefsHandle_->getObjects(filterIndex,pixtrackIds_,pixtrackRefs_);
308  const unsigned int nPixTracks(pixtrackIds_.size());
309  if (nPixTracks>0) {
310  LogVerbatim("HLTEventAnalyzerRAW") << " PixTracks: " << nPixTracks << " - the objects: # id pt" << endl;
311  for (unsigned int i=0; i!=nPixTracks; ++i) {
312  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << pixtrackIds_[i]
313  << " " << pixtrackRefs_[i]->pt()
314  << endl;
315  }
316  }
317 
318  triggerEventWithRefsHandle_->getObjects(filterIndex,l1emIds_,l1emRefs_);
319  const unsigned int nL1EM(l1emIds_.size());
320  if (nL1EM>0) {
321  LogVerbatim("HLTEventAnalyzerRAW") << " L1EM: " << nL1EM << " - the objects: # id pt" << endl;
322  for (unsigned int i=0; i!=nL1EM; ++i) {
323  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << l1emIds_[i]
324  << " " << l1emRefs_[i]->pt()
325  << endl;
326  }
327  }
328 
329  triggerEventWithRefsHandle_->getObjects(filterIndex,l1muonIds_,l1muonRefs_);
330  const unsigned int nL1Muon(l1muonIds_.size());
331  if (nL1Muon>0) {
332  LogVerbatim("HLTEventAnalyzerRAW") << " L1Muon: " << nL1Muon << " - the objects: # id pt" << endl;
333  for (unsigned int i=0; i!=nL1Muon; ++i) {
334  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << l1muonIds_[i]
335  << " " << l1muonRefs_[i]->pt()
336  << endl;
337  }
338  }
339 
340  triggerEventWithRefsHandle_->getObjects(filterIndex,l1jetIds_,l1jetRefs_);
341  const unsigned int nL1Jet(l1jetIds_.size());
342  if (nL1Jet>0) {
343  LogVerbatim("HLTEventAnalyzerRAW") << " L1Jet: " << nL1Jet << " - the objects: # id pt" << endl;
344  for (unsigned int i=0; i!=nL1Jet; ++i) {
345  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << l1jetIds_[i]
346  << " " << l1jetRefs_[i]->pt()
347  << endl;
348  }
349  }
350 
351  triggerEventWithRefsHandle_->getObjects(filterIndex,l1etmissIds_,l1etmissRefs_);
352  const unsigned int nL1EtMiss(l1etmissIds_.size());
353  if (nL1EtMiss>0) {
354  LogVerbatim("HLTEventAnalyzerRAW") << " L1EtMiss: " << nL1EtMiss << " - the objects: # id pt" << endl;
355  for (unsigned int i=0; i!=nL1EtMiss; ++i) {
356  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << l1etmissIds_[i]
357  << " " << l1etmissRefs_[i]->pt()
358  << endl;
359  }
360  }
361 
363  const unsigned int nL1HfRings(l1hfringsIds_.size());
364  if (nL1HfRings>0) {
365  LogVerbatim("HLTEventAnalyzerRAW") << " L1HfRings: " << nL1HfRings << " - the objects: # id 4 4" << endl;
366  for (unsigned int i=0; i!=nL1HfRings; ++i) {
367  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << l1hfringsIds_[i]
372  << " " << l1hfringsRefs_[i]->hfBitCount(l1extra::L1HFRings::kRing1PosEta)
373  << " " << l1hfringsRefs_[i]->hfBitCount(l1extra::L1HFRings::kRing1NegEta)
374  << " " << l1hfringsRefs_[i]->hfBitCount(l1extra::L1HFRings::kRing2PosEta)
375  << " " << l1hfringsRefs_[i]->hfBitCount(l1extra::L1HFRings::kRing2NegEta)
376  << endl;
377  }
378  }
379 
380  triggerEventWithRefsHandle_->getObjects(filterIndex,pfjetIds_,pfjetRefs_);
381  const unsigned int nPFJets(pfjetIds_.size());
382  if (nPFJets>0) {
383  LogVerbatim("HLTEventAnalyzerRAW") << " PFJets: " << nPFJets << " - the objects: # id pt" << endl;
384  for (unsigned int i=0; i!=nPFJets; ++i) {
385  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << pfjetIds_[i]
386  << " " << pfjetRefs_[i]->pt()
387  << endl;
388  }
389  }
390 
391  triggerEventWithRefsHandle_->getObjects(filterIndex,pftauIds_,pftauRefs_);
392  const unsigned int nPFTaus(pftauIds_.size());
393  if (nPFTaus>0) {
394  LogVerbatim("HLTEventAnalyzerRAW") << " PFTaus: " << nPFTaus << " - the objects: # id pt" << endl;
395  for (unsigned int i=0; i!=nPFTaus; ++i) {
396  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << pftauIds_[i]
397  << " " << pftauRefs_[i]->pt()
398  << endl;
399  }
400  }
401 
402  triggerEventWithRefsHandle_->getObjects(filterIndex,pfmetIds_,pfmetRefs_);
403  const unsigned int nPfMETs(pfmetIds_.size());
404  if (nPfMETs>0) {
405  LogVerbatim("HLTEventAnalyzerRAW") << " PfMETs: " << nPfMETs << " - the objects: # id pt" << endl;
406  for (unsigned int i=0; i!=nPfMETs; ++i) {
407  LogVerbatim("HLTEventAnalyzerRAW") << " " << i << " " << pfmetIds_[i]
408  << " " << pfmetRefs_[i]->pt()
409  << endl;
410  }
411  }
412 
413  }
414  }
415 
416  return;
417 }
unsigned int size() const
number of trigger paths in trigger table
void dump(const std::string &what) const
Dumping config info to cout.
int i
Definition: DBlmapReader.cc:9
trigger::Vids compositeIds_
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:215
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:462
trigger::VRl1muon l1muonRefs_
trigger::Vids electronIds_
const edm::InputTag triggerEventWithRefsTag_
assert(m_qm.get())
trigger::VRl1em l1emRefs_
trigger::VRpftau pftauRefs_
virtual void endRun(edm::Run const &, edm::EventSetup const &) override
HLTEventAnalyzerRAW(const edm::ParameterSet &)
const edm::InputTag triggerResultsTag_
std::string encode() const
Definition: InputTag.cc:164
trigger::VRpfjet pfjetRefs_
trigger::Vids photonIds_
payload extracted from TriggerEventWithRefs
trigger::VRl1jet l1jetRefs_
triggerResultsToken_(consumes< edm::TriggerResults >(edm::InputTag("TriggerResults")))
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
virtual 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)
HLTConfigProvider hltConfig_
trigger::VRpfmet pfmetRefs_
int j
Definition: DBlmapReader.cc:9
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:75
trigger::VRelectron electronRefs_
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_
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)
const std::string triggerName_
trigger::VRmuon muonRefs_
trigger::VRpixtrack pixtrackRefs_
trigger::VRbasemet basemetRefs_
tuple size
Write out results.
Definition: Run.h:43