CMS 3D CMS Logo

TriggerSummaryProducerAOD.cc
Go to the documentation of this file.
1 
10 #include <ostream>
11 #include <algorithm>
12 #include <memory>
13 #include <typeinfo>
14 
17 
24 
37 
43 
50 
59 
62 
65 
66 #include "boost/algorithm/string.hpp"
67 
68 namespace {
69  std::vector<std::regex> convertToRegex(std::vector<std::string> const& iPatterns) {
70  std::vector<std::regex> result;
71 
72  for (auto const& pattern : iPatterns) {
73  auto regexPattern = pattern;
74  boost::replace_all(regexPattern, "*", ".*");
75  boost::replace_all(regexPattern, "?", ".");
76 
77  result.emplace_back(regexPattern);
78  }
79  return result;
80  }
81 } // namespace
82 
83 //
84 // constructors and destructor
85 //
87  : throw_(ps.getParameter<bool>("throw")),
88  pn_(ps.getParameter<std::string>("processName")),
89  moduleLabelPatternsToMatch_(
90  convertToRegex(ps.getParameter<std::vector<std::string>>("moduleLabelPatternsToMatch"))),
91  moduleLabelPatternsToSkip_(
92  convertToRegex(ps.getParameter<std::vector<std::string>>("moduleLabelPatternsToSkip"))) {
93  if (pn_ == "@") {
95  if (tns.isAvailable()) {
96  pn_ = tns->getProcessName();
97  } else {
98  edm::LogError("TriggerSummaryProducerAOD") << "HLT Error: TriggerNamesService not available!";
99  pn_ = "*";
100  }
101  }
102  LogDebug("TriggerSummaryProducerAOD") << "Using process name: '" << pn_ << "'";
103 
104  produces<trigger::TriggerEvent>();
105 
106  auto const* pProcessName = &pn_;
109  auto productMatch = [pProcessName, &moduleLabelPatternsToSkip, &moduleLabelPatternsToMatch](
110  edm::BranchDescription const& iBranch) -> bool {
111  if (iBranch.processName() == *pProcessName || *pProcessName == "*") {
112  auto const& label = iBranch.moduleLabel();
113  for (auto& match : moduleLabelPatternsToMatch) {
114  if (std::regex_match(label, match)) {
115  //make sure this is not in the reject list
116  for (auto& reject : moduleLabelPatternsToSkip) {
117  if (std::regex_match(label, reject)) {
118  return false;
119  }
120  }
121  return true;
122  }
123  }
124  }
125  return false;
126  };
127 
149 
157 
161 
163 
171  getMETCollection_(bd);
196  });
197 }
198 
200 
201 //
202 // member functions
203 //
204 
205 namespace {
206  inline void tokenizeTag(const std::string& tag, std::string& label, std::string& instance, std::string& process) {
207  using std::string;
208 
209  const char token(':');
210  const string empty;
211 
212  label = tag;
213  const string::size_type i1(label.find(token));
214  if (i1 == string::npos) {
215  instance = empty;
216  process = empty;
217  } else {
218  instance = label.substr(i1 + 1);
219  label.resize(i1);
220  const string::size_type i2(instance.find(token));
221  if (i2 == string::npos) {
222  process = empty;
223  } else {
224  process = instance.substr(i2 + 1);
225  instance.resize(i2);
226  }
227  }
228  }
229 } // namespace
230 
233  desc.add<bool>("throw", false)->setComment("Throw exception or LogError");
234  desc.add<std::string>("processName", "@")
235  ->setComment(
236  "Process name to use when getting data. The value of '@' is used to denote the current process name.");
237  desc.add<std::vector<std::string>>("moduleLabelPatternsToMatch", std::vector<std::string>(1, "hlt*"))
238  ->setComment("glob patterns for module labels to get data.");
239  desc.add<std::vector<std::string>>("moduleLabelPatternsToSkip", std::vector<std::string>())
240  ->setComment("module labels for data products which should not be gotten.");
241  descriptions.add("triggerSummaryProducerAOD", desc);
242 }
243 
244 // ------------ method called to produce the data ------------
246  using namespace std;
247  using namespace edm;
248  using namespace reco;
249  using namespace l1extra;
250  using namespace trigger;
251  using namespace l1t;
252 
253  std::vector<edm::Handle<trigger::TriggerFilterObjectWithRefs>> fobs;
255 
256  const unsigned int nfob(fobs.size());
257  LogTrace("TriggerSummaryProducerAOD") << "Number of filter objects found: " << nfob;
258 
259  string tagLabel, tagInstance, tagProcess;
260 
266  std::vector<bool> maskFilters;
267  maskFilters.resize(nfob);
268  InputTagSet filterTagsEvent(pn_ == "*");
269  InputTagSet collectionTagsEvent(pn_ == "*");
270 
271  unsigned int nf(0);
272  for (unsigned int ifob = 0; ifob != nfob; ++ifob) {
273  maskFilters[ifob] = false;
274  const vector<string>& collectionTags_(fobs[ifob]->getCollectionTagsAsStrings());
275  const unsigned int ncol(collectionTags_.size());
276  if (ncol > 0) {
277  nf++;
278  maskFilters[ifob] = true;
279  const string& label(fobs[ifob].provenance()->moduleLabel());
280  const string& instance(fobs[ifob].provenance()->productInstanceName());
281  const string& process(fobs[ifob].provenance()->processName());
282  filterTagsEvent.insert(InputTag(label, instance, process));
283  for (unsigned int icol = 0; icol != ncol; ++icol) {
284  // overwrite process name (usually not set)
285  tokenizeTag(collectionTags_[icol], tagLabel, tagInstance, tagProcess);
286  collectionTagsEvent.insert(InputTag(tagLabel, tagInstance, pn_));
287  }
288  }
289  }
291  if (filterTagsEvent.size() != nf) {
292  LogError("TriggerSummaryProducerAOD")
293  << "Mismatch in number of filter tags: " << filterTagsEvent.size() << "!=" << nf;
294  }
295 
297  collectionTagsGlobal_.insert(collectionTagsEvent.begin(), collectionTagsEvent.end());
298  filterTagsGlobal_.insert(filterTagsEvent.begin(), filterTagsEvent.end());
299 
301  if (isDebugEnabled()) {
303  LogTrace("TriggerSummaryProducerAOD") << "Number of unique collections requested " << collectionTagsEvent.size();
304  const InputTagSet::const_iterator cb(collectionTagsEvent.begin());
305  const InputTagSet::const_iterator ce(collectionTagsEvent.end());
306  for (InputTagSet::const_iterator ci = cb; ci != ce; ++ci) {
307  LogTrace("TriggerSummaryProducerAOD") << distance(cb, ci) << " " << ci->encode();
308  }
309  LogTrace("TriggerSummaryProducerAOD") << "Number of unique filters requested " << filterTagsEvent.size();
310  const InputTagSet::const_iterator fb(filterTagsEvent.begin());
311  const InputTagSet::const_iterator fe(filterTagsEvent.end());
312  for (InputTagSet::const_iterator fi = fb; fi != fe; ++fi) {
313  LogTrace("TriggerSummaryProducerAOD") << distance(fb, fi) << " " << fi->encode();
314  }
315  }
316 
323  //toc_.clear();
324  std::vector<std::string> tags;
326  std::map<edm::ProductID, unsigned int> offset;
327 
328  fillTriggerObjectCollections<RecoEcalCandidateCollection>(
329  toc, offset, tags, keys, iEvent, getRecoEcalCandidateCollection_, collectionTagsEvent);
330  fillTriggerObjectCollections<ElectronCollection>(
331  toc, offset, tags, keys, iEvent, getElectronCollection_, collectionTagsEvent);
332  fillTriggerObjectCollections<RecoChargedCandidateCollection>(
333  toc, offset, tags, keys, iEvent, getRecoChargedCandidateCollection_, collectionTagsEvent);
334  fillTriggerObjectCollections<CaloJetCollection>(
335  toc, offset, tags, keys, iEvent, getCaloJetCollection_, collectionTagsEvent);
336  fillTriggerObjectCollections<CompositeCandidateCollection>(
337  toc, offset, tags, keys, iEvent, getCompositeCandidateCollection_, collectionTagsEvent);
338  fillTriggerObjectCollections<METCollection>(toc, offset, tags, keys, iEvent, getMETCollection_, collectionTagsEvent);
339  fillTriggerObjectCollections<CaloMETCollection>(
340  toc, offset, tags, keys, iEvent, getCaloMETCollection_, collectionTagsEvent);
341  fillTriggerObjectCollections<IsolatedPixelTrackCandidateCollection>(
342  toc, offset, tags, keys, iEvent, getIsolatedPixelTrackCandidateCollection_, collectionTagsEvent);
344  fillTriggerObjectCollections<L1EmParticleCollection>(
345  toc, offset, tags, keys, iEvent, getL1EmParticleCollection_, collectionTagsEvent);
346  fillTriggerObjectCollections<L1MuonParticleCollection>(
347  toc, offset, tags, keys, iEvent, getL1MuonParticleCollection_, collectionTagsEvent);
348  fillTriggerObjectCollections<L1JetParticleCollection>(
349  toc, offset, tags, keys, iEvent, getL1JetParticleCollection_, collectionTagsEvent);
350  fillTriggerObjectCollections<L1EtMissParticleCollection>(
351  toc, offset, tags, keys, iEvent, getL1EtMissParticleCollection_, collectionTagsEvent);
352  fillTriggerObjectCollections<L1HFRingsCollection>(
353  toc, offset, tags, keys, iEvent, getL1HFRingsCollection_, collectionTagsEvent);
354  fillTriggerObjectCollections<MuonBxCollection>(
355  toc, offset, tags, keys, iEvent, getL1TMuonParticleCollection_, collectionTagsEvent);
356  fillTriggerObjectCollections<MuonShowerBxCollection>(
357  toc, offset, tags, keys, iEvent, getL1TMuonShowerParticleCollection_, collectionTagsEvent);
358  fillTriggerObjectCollections<EGammaBxCollection>(
359  toc, offset, tags, keys, iEvent, getL1TEGammaParticleCollection_, collectionTagsEvent);
360  fillTriggerObjectCollections<JetBxCollection>(
361  toc, offset, tags, keys, iEvent, getL1TJetParticleCollection_, collectionTagsEvent);
362  fillTriggerObjectCollections<TauBxCollection>(
363  toc, offset, tags, keys, iEvent, getL1TTauParticleCollection_, collectionTagsEvent);
364  fillTriggerObjectCollections<EtSumBxCollection>(
365  toc, offset, tags, keys, iEvent, getL1TEtSumParticleCollection_, collectionTagsEvent);
367  fillTriggerObjectCollections<l1t::TrackerMuonCollection>(
368  toc, offset, tags, keys, iEvent, getL1TTkMuonCollection_, collectionTagsEvent);
369  fillTriggerObjectCollections<l1t::TkElectronCollection>(
370  toc, offset, tags, keys, iEvent, getL1TTkElectronCollection_, collectionTagsEvent);
371  fillTriggerObjectCollections<l1t::TkEmCollection>(
372  toc, offset, tags, keys, iEvent, getL1TTkEmCollection_, collectionTagsEvent);
373  fillTriggerObjectCollections<l1t::PFJetCollection>(
374  toc, offset, tags, keys, iEvent, getL1TPFJetCollection_, collectionTagsEvent);
375  fillTriggerObjectCollections<l1t::PFTauCollection>(
376  toc, offset, tags, keys, iEvent, getL1TPFTauCollection_, collectionTagsEvent);
377  fillTriggerObjectCollections<l1t::HPSPFTauCollection>(
378  toc, offset, tags, keys, iEvent, getL1THPSPFTauCollection_, collectionTagsEvent);
379  fillTriggerObjectCollections<l1t::PFTrackCollection>(
380  toc, offset, tags, keys, iEvent, getL1TPFTrackCollection_, collectionTagsEvent);
382  fillTriggerObjectCollections<reco::PFJetCollection>(
383  toc, offset, tags, keys, iEvent, getPFJetCollection_, collectionTagsEvent);
384  fillTriggerObjectCollections<reco::PFTauCollection>(
385  toc, offset, tags, keys, iEvent, getPFTauCollection_, collectionTagsEvent);
386  fillTriggerObjectCollections<reco::PFMETCollection>(
387  toc, offset, tags, keys, iEvent, getPFMETCollection_, collectionTagsEvent);
389  fillTriggerObjectCollections<l1t::P2GTCandidateCollection>(
390  toc, offset, tags, keys, iEvent, getL1TP2GTCandCollection_, collectionTagsEvent);
391  const unsigned int nk(tags.size());
392  LogDebug("TriggerSummaryProducerAOD") << "Number of collections found: " << nk;
393  const unsigned int no(toc.size());
394  LogDebug("TriggerSummaryProducerAOD") << "Number of physics objects found: " << no;
395 
398  unique_ptr<TriggerEvent> product(new TriggerEvent(pn_, nk, no, nf));
399 
401  product->addCollections(tags, keys);
402  product->addObjects(toc);
403 
405  trigger::Vids ids;
406  for (unsigned int ifob = 0; ifob != nfob; ++ifob) {
407  if (maskFilters[ifob]) {
408  const string& label(fobs[ifob].provenance()->moduleLabel());
409  const string& instance(fobs[ifob].provenance()->productInstanceName());
410  const string& process(fobs[ifob].provenance()->processName());
411  const edm::InputTag filterTag(label, instance, process);
412  ids.clear();
413  keys.clear();
414  fillFilterObjectMembers(iEvent, filterTag, fobs[ifob]->photonIds(), fobs[ifob]->photonRefs(), offset, keys, ids);
416  iEvent, filterTag, fobs[ifob]->electronIds(), fobs[ifob]->electronRefs(), offset, keys, ids);
417  fillFilterObjectMembers(iEvent, filterTag, fobs[ifob]->muonIds(), fobs[ifob]->muonRefs(), offset, keys, ids);
418  fillFilterObjectMembers(iEvent, filterTag, fobs[ifob]->jetIds(), fobs[ifob]->jetRefs(), offset, keys, ids);
420  iEvent, filterTag, fobs[ifob]->compositeIds(), fobs[ifob]->compositeRefs(), offset, keys, ids);
422  iEvent, filterTag, fobs[ifob]->basemetIds(), fobs[ifob]->basemetRefs(), offset, keys, ids);
424  iEvent, filterTag, fobs[ifob]->calometIds(), fobs[ifob]->calometRefs(), offset, keys, ids);
426  iEvent, filterTag, fobs[ifob]->pixtrackIds(), fobs[ifob]->pixtrackRefs(), offset, keys, ids);
427  fillFilterObjectMembers(iEvent, filterTag, fobs[ifob]->l1emIds(), fobs[ifob]->l1emRefs(), offset, keys, ids);
428  fillFilterObjectMembers(iEvent, filterTag, fobs[ifob]->l1muonIds(), fobs[ifob]->l1muonRefs(), offset, keys, ids);
429  fillFilterObjectMembers(iEvent, filterTag, fobs[ifob]->l1jetIds(), fobs[ifob]->l1jetRefs(), offset, keys, ids);
431  iEvent, filterTag, fobs[ifob]->l1etmissIds(), fobs[ifob]->l1etmissRefs(), offset, keys, ids);
433  iEvent, filterTag, fobs[ifob]->l1hfringsIds(), fobs[ifob]->l1hfringsRefs(), offset, keys, ids);
435  iEvent, filterTag, fobs[ifob]->l1tmuonIds(), fobs[ifob]->l1tmuonRefs(), offset, keys, ids);
437  iEvent, filterTag, fobs[ifob]->l1tmuonShowerIds(), fobs[ifob]->l1tmuonShowerRefs(), offset, keys, ids);
439  iEvent, filterTag, fobs[ifob]->l1tegammaIds(), fobs[ifob]->l1tegammaRefs(), offset, keys, ids);
440  fillFilterObjectMembers(iEvent, filterTag, fobs[ifob]->l1tjetIds(), fobs[ifob]->l1tjetRefs(), offset, keys, ids);
441  fillFilterObjectMembers(iEvent, filterTag, fobs[ifob]->l1ttauIds(), fobs[ifob]->l1ttauRefs(), offset, keys, ids);
443  iEvent, filterTag, fobs[ifob]->l1tetsumIds(), fobs[ifob]->l1tetsumRefs(), offset, keys, ids);
444 
446  iEvent, filterTag, fobs[ifob]->l1ttkmuonIds(), fobs[ifob]->l1ttkmuonRefs(), offset, keys, ids);
448  iEvent, filterTag, fobs[ifob]->l1ttkeleIds(), fobs[ifob]->l1ttkeleRefs(), offset, keys, ids);
450  iEvent, filterTag, fobs[ifob]->l1ttkemIds(), fobs[ifob]->l1ttkemRefs(), offset, keys, ids);
452  iEvent, filterTag, fobs[ifob]->l1tpfjetIds(), fobs[ifob]->l1tpfjetRefs(), offset, keys, ids);
454  iEvent, filterTag, fobs[ifob]->l1tpftauIds(), fobs[ifob]->l1tpftauRefs(), offset, keys, ids);
456  iEvent, filterTag, fobs[ifob]->l1thpspftauIds(), fobs[ifob]->l1thpspftauRefs(), offset, keys, ids);
458  iEvent, filterTag, fobs[ifob]->l1tpftrackIds(), fobs[ifob]->l1tpftrackRefs(), offset, keys, ids);
459 
460  fillFilterObjectMembers(iEvent, filterTag, fobs[ifob]->pfjetIds(), fobs[ifob]->pfjetRefs(), offset, keys, ids);
461  fillFilterObjectMembers(iEvent, filterTag, fobs[ifob]->pftauIds(), fobs[ifob]->pftauRefs(), offset, keys, ids);
462  fillFilterObjectMembers(iEvent, filterTag, fobs[ifob]->pfmetIds(), fobs[ifob]->pfmetRefs(), offset, keys, ids);
464  iEvent, filterTag, fobs[ifob]->l1tp2gtcandIds(), fobs[ifob]->l1tp2gtcandRefs(), offset, keys, ids);
465  product->addFilter(filterTag, ids, keys);
466  }
467  }
468 
469  OrphanHandle<TriggerEvent> ref = iEvent.put(std::move(product));
470  LogTrace("TriggerSummaryProducerAOD") << "Number of physics objects packed: " << ref->sizeObjects();
471  LogTrace("TriggerSummaryProducerAOD") << "Number of filter objects packed: " << ref->sizeFilters();
472 }
473 
474 template <typename C>
477  std::vector<std::string>& tags,
479  const edm::Event& iEvent,
480  const edm::GetterOfProducts<C>& getter,
481  const InputTagSet& collectionTagsEvent) const {
485 
486  using namespace std;
487  using namespace edm;
488  using namespace reco;
489  using namespace l1extra;
490  using namespace trigger;
491  using namespace l1t;
492 
493  vector<Handle<C>> collections;
494  getter.fillHandles(iEvent, collections);
495  const unsigned int nc(collections.size());
496 
497  for (unsigned int ic = 0; ic != nc; ++ic) {
498  const Provenance& provenance(*(collections[ic].provenance()));
499  const string& label(provenance.moduleLabel());
500  const string& instance(provenance.productInstanceName());
501  const string& process(provenance.processName());
502  const InputTag collectionTag(label, instance, process);
503 
504  if (collectionTagsEvent.find(collectionTag) != collectionTagsEvent.end()) {
505  const ProductID pid(collections[ic].provenance()->productID());
506  if (offset.find(pid) != offset.end()) {
507  LogError("TriggerSummaryProducerAOD") << "Duplicate pid: " << pid;
508  }
509  offset[pid] = toc.size();
510  const unsigned int n(collections[ic]->size());
511  for (unsigned int i = 0; i != n; ++i) {
512  fillTriggerObject(toc, (*collections[ic])[i]);
513  }
514  tags.push_back(collectionTag.encode());
515  keys.push_back(toc.size());
516  }
517 
518  }
519 }
520 
521 template <typename T>
523  using namespace trigger;
524  toc.emplace_back(object);
525 
526  return;
527 }
528 
530  const l1extra::L1HFRings& object) const {
531  using namespace l1extra;
532  using namespace trigger;
533 
534  toc.emplace_back(TriggerL1HfRingEtSums,
535  object.hfEtSum(L1HFRings::kRing1PosEta),
536  object.hfEtSum(L1HFRings::kRing1NegEta),
537  object.hfEtSum(L1HFRings::kRing2PosEta),
538  object.hfEtSum(L1HFRings::kRing2NegEta));
539  toc.emplace_back(TriggerL1HfBitCounts,
540  object.hfBitCount(L1HFRings::kRing1PosEta),
541  object.hfBitCount(L1HFRings::kRing1NegEta),
542  object.hfBitCount(L1HFRings::kRing2PosEta),
543  object.hfBitCount(L1HFRings::kRing2NegEta));
544 
545  return;
546 }
547 
549  const l1extra::L1EtMissParticle& object) const {
550  using namespace l1extra;
551  using namespace trigger;
552 
553  toc.emplace_back(object);
554  if (object.type() == L1EtMissParticle::kMET) {
555  toc.emplace_back(TriggerL1ETT, object.etTotal(), 0.0, 0.0, 0.0);
556  } else if (object.type() == L1EtMissParticle::kMHT) {
557  toc.emplace_back(TriggerL1HTT, object.etTotal(), 0.0, 0.0, 0.0);
558  } else {
559  toc.emplace_back(0, object.etTotal(), 0.0, 0.0, 0.0);
560  }
561 
562  return;
563 }
564 
566  const reco::PFMET& object) const {
567  using namespace reco;
568  using namespace trigger;
569 
570  toc.emplace_back(object);
571  toc.emplace_back(TriggerTET, object.sumEt(), 0.0, 0.0, 0.0);
572  toc.emplace_back(TriggerMETSig, object.mEtSig(), 0.0, 0.0, 0.0);
573  toc.emplace_back(TriggerELongit, object.e_longitudinal(), 0.0, 0.0, 0.0);
574 
575  return;
576 }
577 
579  const reco::CaloMET& object) const {
580  using namespace reco;
581  using namespace trigger;
582 
583  toc.emplace_back(object);
584  toc.emplace_back(TriggerTET, object.sumEt(), 0.0, 0.0, 0.0);
585  toc.emplace_back(TriggerMETSig, object.mEtSig(), 0.0, 0.0, 0.0);
586  toc.emplace_back(TriggerELongit, object.e_longitudinal(), 0.0, 0.0, 0.0);
587 
588  return;
589 }
590 
592  const reco::MET& object) const {
593  using namespace reco;
594  using namespace trigger;
595 
596  toc.emplace_back(object);
597  toc.emplace_back(TriggerTHT, object.sumEt(), 0.0, 0.0, 0.0);
598  toc.emplace_back(TriggerMHTSig, object.mEtSig(), 0.0, 0.0, 0.0);
599  toc.emplace_back(TriggerHLongit, object.e_longitudinal(), 0.0, 0.0, 0.0);
600 
601  return;
602 }
603 
604 template <typename C>
606  const edm::InputTag& tag,
607  const trigger::Vids& ids,
608  const std::vector<edm::Ref<C>>& refs,
609  const ProductIDtoIndex& offset,
611  trigger::Vids& oIDs) const {
615 
616  using namespace std;
617  using namespace edm;
618  using namespace reco;
619  using namespace l1extra;
620  using namespace trigger;
621 
622  if (ids.size() != refs.size()) {
623  LogError("TriggerSummaryProducerAOD") << "Vector length is different: " << ids.size() << " " << refs.size();
624  }
625 
626  const unsigned int n(min(ids.size(), refs.size()));
627  for (unsigned int i = 0; i != n; ++i) {
628  const ProductID pid(refs[i].id());
629  if (!(pid.isValid())) {
630  std::ostringstream ost;
631  ost << "Iinvalid pid: " << pid << " FilterTag / Key: " << tag.encode() << " / " << i << "of" << n
632  << " CollectionTag / Key: "
633  << " <Unrecoverable>"
634  << " / " << refs[i].key() << " CollectionType: " << typeid(C).name();
635  if (throw_) {
636  throw cms::Exception("TriggerSummaryProducerAOD") << ost.str();
637  } else {
638  LogError("TriggerSummaryProducerAOD") << ost.str();
639  }
640  } else {
641  auto itOffset = offset.find(pid);
642  if (itOffset == offset.end()) {
643  const auto& prov = iEvent.getStableProvenance(pid);
644  const string& label(prov.moduleLabel());
645  const string& instance(prov.productInstanceName());
646  const string& process(prov.processName());
647  std::ostringstream ost;
648  ost << "Uunknown pid: " << pid << " FilterTag / Key: " << tag.encode() << " / " << i << "of" << n
649  << " CollectionTag / Key: " << InputTag(label, instance, process).encode() << " / " << refs[i].key()
650  << " CollectionType: " << typeid(C).name();
651  if (throw_) {
652  throw cms::Exception("TriggerSummaryProducerAOD") << ost.str();
653  } else {
654  LogError("TriggerSummaryProducerAOD") << ost.str();
655  }
656  } else {
657  fillFilterObjectMember(keys, oIDs, itOffset->second, ids[i], refs[i]);
658  }
659  }
660  }
661  return;
662 }
663 
664 template <typename C>
666  trigger::Keys& keys, trigger::Vids& ids, const int& offset, const int& id, const edm::Ref<C>& ref) const {
667  keys.push_back(offset + ref.key());
668  ids.push_back(id);
669 
670  return;
671 }
672 
674  trigger::Vids& ids,
675  const int& offset,
676  const int& id,
677  const edm::Ref<l1extra::L1HFRingsCollection>& ref) const {
678  using namespace trigger;
679 
680  if (id == TriggerL1HfBitCounts) {
681  keys.push_back(offset + 2 * ref.key() + 1);
682  } else { // if (ids[i]==TriggerL1HfRingEtSums) {
683  keys.push_back(offset + 2 * ref.key() + 0);
684  }
685  ids.push_back(id);
686 
687  return;
688 }
689 
691  trigger::Vids& ids,
692  const int& offset,
693  const int& id,
695  using namespace trigger;
696 
697  if ((id == TriggerL1ETT) || (id == TriggerL1HTT)) {
698  keys.push_back(offset + 2 * ref.key() + 1);
699  } else {
700  keys.push_back(offset + 2 * ref.key() + 0);
701  }
702  ids.push_back(id);
703 
704  return;
705 }
706 
708  trigger::Vids& ids,
709  const int& offset,
710  const int& id,
711  const edm::Ref<reco::PFMETCollection>& ref) const {
712  using namespace trigger;
713 
714  if ((id == TriggerTHT) || (id == TriggerTET)) {
715  keys.push_back(offset + 4 * ref.key() + 1);
716  } else if ((id == TriggerMETSig) || (id == TriggerMHTSig)) {
717  keys.push_back(offset + 4 * ref.key() + 2);
718  } else if ((id == TriggerELongit) || (id == TriggerHLongit)) {
719  keys.push_back(offset + 4 * ref.key() + 3);
720  } else {
721  keys.push_back(offset + 4 * ref.key() + 0);
722  }
723  ids.push_back(id);
724 
725  return;
726 }
727 
729  trigger::Vids& ids,
730  const int& offset,
731  const int& id,
732  const edm::Ref<reco::CaloMETCollection>& ref) const {
733  using namespace trigger;
734 
735  if ((id == TriggerTHT) || (id == TriggerTET)) {
736  keys.push_back(offset + 4 * ref.key() + 1);
737  } else if ((id == TriggerMETSig) || (id == TriggerMHTSig)) {
738  keys.push_back(offset + 4 * ref.key() + 2);
739  } else if ((id == TriggerELongit) || (id == TriggerHLongit)) {
740  keys.push_back(offset + 4 * ref.key() + 3);
741  } else {
742  keys.push_back(offset + 4 * ref.key() + 0);
743  }
744  ids.push_back(id);
745 
746  return;
747 }
748 
750  trigger::Vids& ids,
751  const int& offset,
752  const int& id,
753  const edm::Ref<reco::METCollection>& ref) const {
754  using namespace trigger;
755 
756  if ((id == TriggerTHT) || (id == TriggerTET)) {
757  keys.push_back(offset + 4 * ref.key() + 1);
758  } else if ((id == TriggerMETSig) || (id == TriggerMHTSig)) {
759  keys.push_back(offset + 4 * ref.key() + 2);
760  } else if ((id == TriggerELongit) || (id == TriggerHLongit)) {
761  keys.push_back(offset + 4 * ref.key() + 3);
762  } else {
763  keys.push_back(offset + 4 * ref.key() + 0);
764  }
765  ids.push_back(id);
766 
767  return;
768 }
769 
771  using namespace std;
772  using namespace edm;
773  using namespace trigger;
774 
775  LogVerbatim("TriggerSummaryProducerAOD") << endl;
776  LogVerbatim("TriggerSummaryProducerAOD") << "TriggerSummaryProducerAOD::globalEndJob - accumulated tags:" << endl;
777 
778  InputTagSet filterTags(false);
780 
781  filterTags.insert(filterTagsGlobal_.begin(), filterTagsGlobal_.end());
783 
784  const unsigned int nc(collectionTags.size());
785  const unsigned int nf(filterTags.size());
786  LogVerbatim("TriggerSummaryProducerAOD") << " Overall number of Collections/Filters: " << nc << "/" << nf << endl;
787 
788  LogVerbatim("TriggerSummaryProducerAOD") << " The collections: " << nc << endl;
789  const InputTagSet::const_iterator cb(collectionTags.begin());
790  const InputTagSet::const_iterator ce(collectionTags.end());
791  for (InputTagSet::const_iterator ci = cb; ci != ce; ++ci) {
792  LogVerbatim("TriggerSummaryProducerAOD") << " " << distance(cb, ci) << " " << ci->encode() << endl;
793  }
794 
795  LogVerbatim("TriggerSummaryProducerAOD") << " The filters:" << nf << endl;
796  const InputTagSet::const_iterator fb(filterTags.begin());
797  const InputTagSet::const_iterator fe(filterTags.end());
798  for (InputTagSet::const_iterator fi = fb; fi != fe; ++fi) {
799  LogVerbatim("TriggerSummaryProducerAOD") << " " << distance(fb, fi) << " " << fi->encode() << endl;
800  }
801 
802  LogVerbatim("TriggerSummaryProducerAOD") << "TriggerSummaryProducerAOD::endJob." << endl;
803  LogVerbatim("TriggerSummaryProducerAOD") << endl;
804 
805  return;
806 }
size
Write out results.
~TriggerSummaryProducerAOD() override
Log< level::Info, true > LogVerbatim
void callWhenNewProductsRegistered(std::function< void(BranchDescription const &)> const &func)
Definition: ProducerBase.h:87
bool isDebugEnabled()
edm::GetterOfProducts< l1t::TauBxCollection > getL1TTauParticleCollection_
std::vector< std::regex > moduleLabelPatternsToSkip_
edm::GetterOfProducts< l1extra::L1JetParticleCollection > getL1JetParticleCollection_
edm::GetterOfProducts< reco::IsolatedPixelTrackCandidateCollection > getIsolatedPixelTrackCandidateCollection_
bool isValid() const
Definition: ProductID.h:32
edm::GetterOfProducts< reco::RecoEcalCandidateCollection > getRecoEcalCandidateCollection_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::GetterOfProducts< l1t::PFTrackCollection > getL1TPFTrackCollection_
edm::GetterOfProducts< l1extra::L1MuonParticleCollection > getL1MuonParticleCollection_
edm::GetterOfProducts< reco::PFTauCollection > getPFTauCollection_
static PFTauRenderPlugin instance
edm::GetterOfProducts< reco::METCollection > getMETCollection_
edm::GetterOfProducts< l1t::JetBxCollection > getL1TJetParticleCollection_
edm::GetterOfProducts< l1t::TkElectronCollection > getL1TTkElectronCollection_
trigger::size_type sizeFilters() const
Definition: TriggerEvent.h:147
tbb::concurrent_unordered_set< edm::InputTag, InputTagHash > filterTagsGlobal_
list of L3 filter tags
tbb::concurrent_unordered_set< edm::InputTag, InputTagHash > collectionTagsGlobal_
list of L3 collection tags
edm::GetterOfProducts< reco::CaloJetCollection > getCaloJetCollection_
delete x;
Definition: CaloConfig.h:22
edm::GetterOfProducts< l1extra::L1EtMissParticleCollection > getL1EtMissParticleCollection_
Log< level::Error, false > LogError
std::string const & getProcessName() const
uint16_t size_type
key_type key() const
Accessor for product key.
Definition: Ref.h:250
#define LogTrace(id)
void fillTriggerObject(trigger::TriggerObjectCollection &, const T &) const
edm::GetterOfProducts< reco::PFJetCollection > getPFJetCollection_
const bool throw_
throw on error
void fillTriggerObjectCollections(trigger::TriggerObjectCollection &, ProductIDtoIndex &, std::vector< std::string > &, trigger::Keys &, const edm::Event &, const edm::GetterOfProducts< C > &, const InputTagSet &) const
char const * label
void fillFilterObjectMember(trigger::Keys &keys, trigger::Vids &ids, const int &, const int &, const edm::Ref< C > &) const
std::set< edm::InputTag, OrderInputTag > InputTagSet
int iEvent
Definition: GenABIO.cc:224
edm::GetterOfProducts< l1t::TkEmCollection > getL1TTkEmCollection_
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
edm::GetterOfProducts< reco::RecoChargedCandidateCollection > getRecoChargedCandidateCollection_
TriggerSummaryProducerAOD(const edm::ParameterSet &)
Definition: MET.h:41
edm::GetterOfProducts< l1extra::L1HFRingsCollection > getL1HFRingsCollection_
void fillFilterObjectMembers(const edm::Event &, const edm::InputTag &tag, const trigger::Vids &, const std::vector< edm::Ref< C >> &, const ProductIDtoIndex &, trigger::Keys &keys, trigger::Vids &oIds) const
std::vector< std::regex > moduleLabelPatternsToMatch_
module labels which should be avoided
edm::GetterOfProducts< l1t::PFTauCollection > getL1TPFTauCollection_
trigger::size_type sizeObjects() const
Definition: TriggerEvent.h:146
edm::GetterOfProducts< l1t::MuonBxCollection > getL1TMuonParticleCollection_
edm::GetterOfProducts< l1t::TrackerMuonCollection > getL1TTkMuonCollection_
edm::GetterOfProducts< l1t::HPSPFTauCollection > getL1THPSPFTauCollection_
void fillHandles(ProductContainer const &productContainer, std::vector< edm::Handle< T >> &handles) const
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:75
std::vector< size_type > Keys
edm::GetterOfProducts< l1t::MuonShowerBxCollection > getL1TMuonShowerParticleCollection_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::GetterOfProducts< reco::CaloMETCollection > getCaloMETCollection_
edm::GetterOfProducts< reco::ElectronCollection > getElectronCollection_
fixed size matrix
HLT enums.
std::map< edm::ProductID, unsigned int > ProductIDtoIndex
edm::GetterOfProducts< reco::CompositeCandidateCollection > getCompositeCandidateCollection_
edm::GetterOfProducts< trigger::TriggerFilterObjectWithRefs > getTriggerFilterObjectWithRefs_
trigger object collection
bool isAvailable() const
Definition: Service.h:40
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
edm::GetterOfProducts< reco::PFMETCollection > getPFMETCollection_
edm::GetterOfProducts< l1t::PFJetCollection > getL1TPFJetCollection_
edm::GetterOfProducts< l1t::P2GTCandidateCollection > getL1TP2GTCandCollection_
long double T
edm::GetterOfProducts< l1t::EtSumBxCollection > getL1TEtSumParticleCollection_
std::vector< int > Vids
edm::GetterOfProducts< l1extra::L1EmParticleCollection > getL1EmParticleCollection_
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)
edm::GetterOfProducts< l1t::EGammaBxCollection > getL1TEGammaParticleCollection_