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  // Attention: must look only for modules actually run in this path for this event!
252  for (unsigned int j = 0; j <= moduleIndex; ++j) {
253  const std::string& moduleLabel(moduleLabels[j]);
254  const std::string moduleType(hltConfig_.moduleType(moduleLabel));
255  // check whether the module is packed up in TriggerEventWithRefs product
256  const unsigned int filterIndex(
258  if (filterIndex < triggerEventWithRefsHandle_->size()) {
259  LOG(logMsgType_) << " Filter in slot " << j << " - label/type " << moduleLabel << "/" << moduleType;
260  LOG(logMsgType_) << " Filter packed up at: " << filterIndex;
261  LOG(logMsgType_) << " Accepted objects:";
262 
263  // Photons
265  showObjects(photonIds_, photonRefs_, "Photons");
266 
267  // Electrons
269  showObjects(electronIds_, electronRefs_, "Electrons");
270 
271  // Muons
273  showObjects(muonIds_, muonRefs_, "Muons");
274 
275  // Jets
277  showObjects(jetIds_, jetRefs_, "Jets");
278 
279  // Composites
281  showObjects(compositeIds_, compositeRefs_, "Composites");
282 
283  // BaseMETs
285  showObjects(basemetIds_, basemetRefs_, "BaseMETs");
286 
287  // CaloMETs
289  showObjects(calometIds_, calometRefs_, "CaloMETs");
290 
291  // PixTracks
293  showObjects(pixtrackIds_, pixtrackRefs_, "PixTracks");
294 
295  // L1EMs
297  showObjects(l1emIds_, l1emRefs_, "L1EMs");
298 
299  // L1Muons
301  showObjects(l1muonIds_, l1muonRefs_, "L1Muons");
302 
303  // L1Jets
305  showObjects(l1jetIds_, l1jetRefs_, "L1Jets");
306 
307  // L1EtMiss
309  showObjects(l1etmissIds_, l1etmissRefs_, "L1EtMiss");
310 
311  // L1HFRings
314 
315  // L1TMuons
317  showObjects(l1tmuonIds_, l1tmuonRefs_, "L1TMuons");
318 
319  // L1TMuonShowers
322 
323  // L1TEGammas
325  showObjects(l1tegammaIds_, l1tegammaRefs_, "L1TEGammas");
326 
327  // L1TJets
329  showObjects(l1tjetIds_, l1tjetRefs_, "L1TJets");
330 
331  // L1TTaus
333  showObjects(l1ttauIds_, l1ttauRefs_, "L1TTaus");
334 
335  // L1TEtSums
337  showObjects(l1tetsumIds_, l1tetsumRefs_, "L1TEtSum");
338 
340 
341  // L1TTkMuons
343  showObjects(l1ttkmuIds_, l1ttkmuRefs_, "L1TTkMuons");
344 
345  // L1TTkElectrons
347  showObjects(l1ttkeleIds_, l1ttkeleRefs_, "L1TTkElectrons");
348 
349  // L1TTkEMs
351  showObjects(l1ttkemIds_, l1ttkemRefs_, "L1TTkEMs");
352 
353  // L1TPFJets
355  showObjects(l1tpfjetIds_, l1tpfjetRefs_, "L1TPFJets");
356 
357  // L1TPFTaus
359  showObjects(l1tpftauIds_, l1tpftauRefs_, "L1TPFTaus");
360 
361  // L1THPSPFTaus
363  showObjects(l1thpspftauIds_, l1thpspftauRefs_, "L1THPSPFTaus");
364 
365  // L1TPFTracks
367  showObjects(l1tpftrackIds_, l1tpftrackRefs_, "L1TPFTracks");
368 
369  // PFJets
371  showObjects(pfjetIds_, pfjetRefs_, "PFJets");
372 
373  // PFTaus
375  showObjects(pftauIds_, pftauRefs_, "PFTaus");
376 
377  // PFMETs
379  showObjects(pfmetIds_, pfmetRefs_, "PFMETs");
380  }
381  }
382 
383  return;
384 }
385 
386 template <>
388  log << "hfEtSum(ring1PosEta)=" << ref->hfEtSum(l1extra::L1HFRings::kRing1PosEta)
389  << " hfEtSum(ring1NegEta)=" << ref->hfEtSum(l1extra::L1HFRings::kRing1NegEta)
390  << " hfEtSum(ring2PosEta)=" << ref->hfEtSum(l1extra::L1HFRings::kRing2PosEta)
391  << " hfEtSum(ring2NegEta)=" << ref->hfEtSum(l1extra::L1HFRings::kRing2NegEta)
392  << " hfBitCount(ring1PosEta)=" << ref->hfBitCount(l1extra::L1HFRings::kRing1PosEta)
393  << " hfBitCount(ring1NegEta)=" << ref->hfBitCount(l1extra::L1HFRings::kRing1NegEta)
394  << " hfBitCount(ring2PosEta)=" << ref->hfBitCount(l1extra::L1HFRings::kRing2PosEta)
395  << " hfBitCount(ring2NegEta)=" << ref->hfBitCount(l1extra::L1HFRings::kRing2NegEta);
396 }
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_
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
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_