CMS 3D CMS Logo

HLTEventAnalyzerRAW.cc
Go to the documentation of this file.
1 
14 
15 // need access to class objects being referenced to get their content!
25 
26 #include "DataFormats/L1Trigger/interface/L1HFRings.h" // deprecate
31 
38 
48 
49 #include <cassert>
50 
51 //
52 // constructor
53 //
55  : processName_(ps.getParameter<std::string>("processName")),
56  triggerName_(ps.getParameter<std::string>("triggerName")),
57  triggerResultsTag_(ps.getParameter<edm::InputTag>("triggerResults")),
58  triggerResultsToken_(consumes<edm::TriggerResults>(triggerResultsTag_)),
59  triggerEventWithRefsTag_(ps.getParameter<edm::InputTag>("triggerEventWithRefs")),
60  triggerEventWithRefsToken_(consumes<trigger::TriggerEventWithRefs>(triggerEventWithRefsTag_)),
61  verbose_(ps.getParameter<bool>("verbose")),
62  permissive_(ps.getParameter<bool>("permissive")) {
63  LOG(logMsgType_) << logMsgType_ << " configuration:\n"
64  << " ProcessName = " << processName_ << "\n"
65  << " TriggerName = " << triggerName_ << "\n"
66  << " TriggerResultsTag = " << triggerResultsTag_.encode() << "\n"
67  << " TriggerEventWithRefsTag = " << triggerEventWithRefsTag_.encode();
68 }
69 
70 //
71 // member functions
72 //
75  desc.add<std::string>("processName", "HLT");
76  desc.add<std::string>("triggerName", "@")
77  ->setComment("name of trigger Path to consider (use \"@\" to consider all Paths)");
78  desc.add<edm::InputTag>("triggerResults", edm::InputTag("TriggerResults", "", "HLT"));
79  desc.add<edm::InputTag>("triggerEventWithRefs", edm::InputTag("hltTriggerSummaryRAW", "", "HLT"));
80  desc.add<bool>("verbose", false)->setComment("enable verbose mode");
81  desc.add<bool>("permissive", false)
82  ->setComment("if true, exceptions due to Refs pointing to unavailable collections are bypassed");
83  descriptions.add("hltEventAnalyzerRAW", desc);
84 }
85 
86 void HLTEventAnalyzerRAW::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
87  bool changed(true);
88  if (hltConfig_.init(iRun, iSetup, processName_, changed)) {
89  if (changed) {
90  // check if trigger name in (new) config
91  if (triggerName_ != "@") { // "@" means: analyze all triggers in config
92  const unsigned int n(hltConfig_.size());
93  const unsigned int triggerIndex(hltConfig_.triggerIndex(triggerName_));
94  if (triggerIndex >= n) {
95  LOG(logMsgType_) << logMsgType_ << "::beginRun: TriggerName " << triggerName_
96  << " not available in (new) config!";
97  LOG(logMsgType_) << "Available TriggerNames are: ";
98  hltConfig_.dump("Triggers");
99  }
100  }
101  // in verbose mode, print process info to stdout
102  if (verbose_) {
103  hltConfig_.dump("ProcessName");
104  hltConfig_.dump("GlobalTag");
105  hltConfig_.dump("TableName");
106  hltConfig_.dump("Streams");
107  hltConfig_.dump("Datasets");
108  hltConfig_.dump("PrescaleTable");
109  hltConfig_.dump("ProcessPSet");
110  }
111  }
112  } else {
113  LOG(logMsgType_) << logMsgType_ << "::beginRun: config extraction failure with process name " << processName_;
114  }
115 }
116 
118  // get event products
120  if (not triggerResultsHandle_.isValid()) {
121  LOG(logMsgType_) << logMsgType_ << "::analyze: Error in getting TriggerResults product from Event!";
122  return;
123  }
126  LOG(logMsgType_) << logMsgType_ << "::analyze: Error in getting TriggerEventWithRefs product from Event!";
127  return;
128  }
129 
130  // sanity check
132 
133  // analyze this event for the triggers requested
134  if (triggerName_ == "@") {
135  const unsigned int n(hltConfig_.size());
136  for (unsigned int i = 0; i != n; ++i) {
138  }
139  } else {
141  }
142 
143  return;
144 }
145 
147  const edm::EventSetup& iSetup,
148  const std::string& triggerName) {
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  LOG(logMsgType_) << logMsgType_ << "::analyzeTrigger: path " << triggerName << " - not found!";
156  return;
157  }
158 
159  LOG(logMsgType_) << logMsgType_ << "::analyzeTrigger: path " << triggerName << " [" << triggerIndex << "]";
160 
161  // results from TriggerResults product
162  LOG(logMsgType_) << " Trigger path status:"
163  << " WasRun=" << triggerResultsHandle_->wasrun(triggerIndex)
164  << " Accept=" << triggerResultsHandle_->accept(triggerIndex)
165  << " Error=" << triggerResultsHandle_->error(triggerIndex);
166 
167  // modules on this trigger path
168  const unsigned int m(hltConfig_.size(triggerIndex));
169  const std::vector<std::string>& moduleLabels(hltConfig_.moduleLabels(triggerIndex));
170  assert(m == moduleLabels.size());
171 
172  // skip empty Path
173  if (m == 0) {
174  LOG(logMsgType_) << logMsgType_ << "::analyzeTrigger: path " << triggerName << " [" << triggerIndex
175  << "] is empty!";
176  return;
177  }
178 
179  // index of last module executed in this Path
180  const unsigned int moduleIndex(triggerResultsHandle_->index(triggerIndex));
181  assert(moduleIndex < m);
182 
183  LOG(logMsgType_) << " Last active module - label/type: " << moduleLabels[moduleIndex] << "/"
184  << hltConfig_.moduleType(moduleLabels[moduleIndex]) << " [" << moduleIndex << " out of 0-" << (m - 1)
185  << " on this path]";
186 
187  // results from TriggerEventWithRefs product
188  photonIds_.clear();
189  photonRefs_.clear();
190  electronIds_.clear();
191  electronRefs_.clear();
192  muonIds_.clear();
193  muonRefs_.clear();
194  jetIds_.clear();
195  jetRefs_.clear();
196  compositeIds_.clear();
197  compositeRefs_.clear();
198  basemetIds_.clear();
199  basemetRefs_.clear();
200  calometIds_.clear();
201  calometRefs_.clear();
202  pixtrackIds_.clear();
203  pixtrackRefs_.clear();
204 
205  l1emIds_.clear();
206  l1emRefs_.clear();
207  l1muonIds_.clear();
208  l1muonRefs_.clear();
209  l1jetIds_.clear();
210  l1jetRefs_.clear();
211  l1etmissIds_.clear();
212  l1etmissRefs_.clear();
213  l1hfringsIds_.clear();
214  l1hfringsRefs_.clear();
215 
216  l1tmuonIds_.clear();
217  l1tmuonRefs_.clear();
218  l1tmuonShowerIds_.clear();
219  l1tmuonShowerRefs_.clear();
220  l1tegammaIds_.clear();
221  l1tegammaRefs_.clear();
222  l1tjetIds_.clear();
223  l1tjetRefs_.clear();
224  l1ttauIds_.clear();
225  l1ttauRefs_.clear();
226  l1tetsumIds_.clear();
227  l1tetsumRefs_.clear();
228 
229  l1ttkmuIds_.clear();
230  l1ttkmuRefs_.clear();
231  l1ttkeleIds_.clear();
232  l1ttkeleRefs_.clear();
233  l1ttkemIds_.clear();
234  l1ttkemRefs_.clear();
235  l1tpfjetIds_.clear();
236  l1tpfjetRefs_.clear();
237  l1tpftauIds_.clear();
238  l1tpftauRefs_.clear();
239  l1thpspftauIds_.clear();
240  l1thpspftauRefs_.clear();
241  l1tpftrackIds_.clear();
242  l1tpftrackRefs_.clear();
243 
244  pfjetIds_.clear();
245  pfjetRefs_.clear();
246  pftauIds_.clear();
247  pftauRefs_.clear();
248  pfmetIds_.clear();
249  pfmetRefs_.clear();
250 
251  l1tp2gtcandIds_.clear();
252  l1tp2gtcandRefs_.clear();
253 
254  // Attention: must look only for modules actually run in this path for this event!
255  for (unsigned int j = 0; j <= moduleIndex; ++j) {
256  const std::string& moduleLabel(moduleLabels[j]);
257  const std::string moduleType(hltConfig_.moduleType(moduleLabel));
258  // check whether the module is packed up in TriggerEventWithRefs product
259  const unsigned int filterIndex(
261  if (filterIndex < triggerEventWithRefsHandle_->size()) {
262  LOG(logMsgType_) << " Filter in slot " << j << " - label/type " << moduleLabel << "/" << moduleType;
263  LOG(logMsgType_) << " Filter packed up at: " << filterIndex;
264  LOG(logMsgType_) << " Accepted objects:";
265 
266  // Photons
268  showObjects(photonIds_, photonRefs_, "Photons");
269 
270  // Electrons
272  showObjects(electronIds_, electronRefs_, "Electrons");
273 
274  // Muons
276  showObjects(muonIds_, muonRefs_, "Muons");
277 
278  // Jets
280  showObjects(jetIds_, jetRefs_, "Jets");
281 
282  // Composites
284  showObjects(compositeIds_, compositeRefs_, "Composites");
285 
286  // BaseMETs
288  showObjects(basemetIds_, basemetRefs_, "BaseMETs");
289 
290  // CaloMETs
292  showObjects(calometIds_, calometRefs_, "CaloMETs");
293 
294  // PixTracks
296  showObjects(pixtrackIds_, pixtrackRefs_, "PixTracks");
297 
298  // L1EMs
300  showObjects(l1emIds_, l1emRefs_, "L1EMs");
301 
302  // L1Muons
304  showObjects(l1muonIds_, l1muonRefs_, "L1Muons");
305 
306  // L1Jets
308  showObjects(l1jetIds_, l1jetRefs_, "L1Jets");
309 
310  // L1EtMiss
312  showObjects(l1etmissIds_, l1etmissRefs_, "L1EtMiss");
313 
314  // L1HFRings
317 
318  // L1TMuons
320  showObjects(l1tmuonIds_, l1tmuonRefs_, "L1TMuons");
321 
322  // L1TMuonShowers
325 
326  // L1TEGammas
328  showObjects(l1tegammaIds_, l1tegammaRefs_, "L1TEGammas");
329 
330  // L1TJets
332  showObjects(l1tjetIds_, l1tjetRefs_, "L1TJets");
333 
334  // L1TTaus
336  showObjects(l1ttauIds_, l1ttauRefs_, "L1TTaus");
337 
338  // L1TEtSums
340  showObjects(l1tetsumIds_, l1tetsumRefs_, "L1TEtSum");
341 
343 
344  // L1TTkMuons
346  showObjects(l1ttkmuIds_, l1ttkmuRefs_, "L1TTkMuons");
347 
348  // L1TTkElectrons
350  showObjects(l1ttkeleIds_, l1ttkeleRefs_, "L1TTkElectrons");
351 
352  // L1TTkEMs
354  showObjects(l1ttkemIds_, l1ttkemRefs_, "L1TTkEMs");
355 
356  // L1TPFJets
358  showObjects(l1tpfjetIds_, l1tpfjetRefs_, "L1TPFJets");
359 
360  // L1TPFTaus
362  showObjects(l1tpftauIds_, l1tpftauRefs_, "L1TPFTaus");
363 
364  // L1THPSPFTaus
366  showObjects(l1thpspftauIds_, l1thpspftauRefs_, "L1THPSPFTaus");
367 
368  // L1TPFTracks
370  showObjects(l1tpftrackIds_, l1tpftrackRefs_, "L1TPFTracks");
371 
372  // PFJets
374  showObjects(pfjetIds_, pfjetRefs_, "PFJets");
375 
376  // PFTaus
378  showObjects(pftauIds_, pftauRefs_, "PFTaus");
379 
380  // PFMETs
382  showObjects(pfmetIds_, pfmetRefs_, "PFMETs");
383 
384  // L1TP2GTCandidates
386  showObjects(l1tp2gtcandIds_, l1tp2gtcandRefs_, "L1TP2GTCandidates");
387  }
388  }
389 
390  return;
391 }
392 
393 template <>
395  log << "hfEtSum(ring1PosEta)=" << ref->hfEtSum(l1extra::L1HFRings::kRing1PosEta)
396  << " hfEtSum(ring1NegEta)=" << ref->hfEtSum(l1extra::L1HFRings::kRing1NegEta)
397  << " hfEtSum(ring2PosEta)=" << ref->hfEtSum(l1extra::L1HFRings::kRing2PosEta)
398  << " hfEtSum(ring2NegEta)=" << ref->hfEtSum(l1extra::L1HFRings::kRing2NegEta)
399  << " hfBitCount(ring1PosEta)=" << ref->hfBitCount(l1extra::L1HFRings::kRing1PosEta)
400  << " hfBitCount(ring1NegEta)=" << ref->hfBitCount(l1extra::L1HFRings::kRing1NegEta)
401  << " hfBitCount(ring2PosEta)=" << ref->hfBitCount(l1extra::L1HFRings::kRing2PosEta)
402  << " hfBitCount(ring2NegEta)=" << ref->hfBitCount(l1extra::L1HFRings::kRing2NegEta);
403 }
size
Write out results.
unsigned int index(const unsigned int i) const
Get index (slot position) of module giving the decision of the ith path.
bool accept() const
Has at least one path accepted the event?
const std::string & triggerName(unsigned int triggerIndex) const
trigger::VRl1ttkele l1ttkeleRefs_
trigger::Vids l1tmuonShowerIds_
trigger::Vids compositeIds_
trigger::Vids l1thpspftauIds_
trigger::Vids l1etmissIds_
bool error() const
Has any path encountered an error (exception)
edm::Handle< edm::TriggerResults > triggerResultsHandle_
trigger::Vids l1tp2gtcandIds_
bool const verbose_
additional class data members
std::string encode() const
Definition: InputTag.cc:159
trigger::VRl1muon l1muonRefs_
trigger::VRl1tmuonShower l1tmuonShowerRefs_
trigger::VRl1ttau l1ttauRefs_
trigger::Vids electronIds_
const edm::InputTag triggerEventWithRefsTag_
void showObject(LOG &log, TREF const &ref) const
trigger::VRl1em l1emRefs_
const std::string moduleType(const std::string &module) const
C++ class name of module.
trigger::VRpftau pftauRefs_
void showObjects(TVID const &vids, TVREF const &vrefs, std::string const &name) const
trigger::VRl1tpftrack l1tpftrackRefs_
trigger::VRl1tjet l1tjetRefs_
assert(be >=bs)
HLTEventAnalyzerRAW(const edm::ParameterSet &)
const edm::InputTag triggerResultsTag_
trigger::VRpfjet pfjetRefs_
bool wasrun() const
Was at least one path run?
trigger::Vids photonIds_
payload extracted from TriggerEventWithRefs
trigger::VRl1jet l1jetRefs_
void beginRun(edm::Run const &, edm::EventSetup const &) override
trigger::VRl1tp2gtcand l1tp2gtcandRefs_
unsigned int size() const
Get number of paths stored.
trigger::VRcomposite compositeRefs_
const std::string processName_
module config parameters
int iEvent
Definition: GenABIO.cc:224
void dump(const std::string &what) const
Dumping config info to cout.
const edm::EDGetTokenT< trigger::TriggerEventWithRefs > triggerEventWithRefsToken_
trigger::VRphoton photonRefs_
unsigned int size() const
number of trigger paths in trigger table
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
size_type filterIndex(const edm::InputTag &filterTag) const
index from tag
HLTConfigProvider hltConfig_
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
trigger::VRpfmet pfmetRefs_
void analyze(const edm::Event &, const edm::EventSetup &) override
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
trigger::VRelectron electronRefs_
trigger::VRl1tegamma l1tegammaRefs_
trigger::VRl1tpftau l1tpftauRefs_
const edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
trigger::Vids pixtrackIds_
trigger::Vids l1hfringsIds_
trigger::VRl1etmiss l1etmissRefs_
trigger::VRl1tpfjet l1tpfjetRefs_
trigger::VRl1thpspftau l1thpspftauRefs_
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::Vids l1tpftrackIds_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
trigger::VRl1hfrings l1hfringsRefs_
edm::LogVerbatim LOG
bool isValid() const
Definition: HandleBase.h:70
trigger::VRcalomet calometRefs_
virtual void analyzeTrigger(const edm::Event &, const edm::EventSetup &, const std::string &triggerName)
HLT enums.
trigger::VRl1ttkmuon l1ttkmuRefs_
const std::string triggerName_
trigger::VRmuon muonRefs_
trigger::VRl1tmuon l1tmuonRefs_
trigger::VRpixtrack pixtrackRefs_
trigger::VRbasemet basemetRefs_
trigger::VRl1ttkem l1ttkemRefs_
Definition: Run.h:45
trigger::VRl1tetsum l1tetsumRefs_
trigger::Vids l1ttkmuIds_
Phase 2.
void getObjects(size_type filter, Vids &ids, VRphoton &photons) const
extract Ref<C>s for a specific filter and of specific physics type
static constexpr const char * logMsgType_