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