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