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