66 #include "boost/algorithm/string.hpp" 69 std::vector<std::regex> convertToRegex(std::vector<std::string>
const& iPatterns) {
70 std::vector<std::regex>
result;
72 for (
auto const&
pattern : iPatterns) {
74 boost::replace_all(regexPattern,
"*",
".*");
75 boost::replace_all(regexPattern,
"?",
".");
77 result.emplace_back(regexPattern);
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"))) {
98 edm::LogError(
"TriggerSummaryProducerAOD") <<
"HLT Error: TriggerNamesService not available!";
102 LogDebug(
"TriggerSummaryProducerAOD") <<
"Using process name: '" <<
pn_ <<
"'";
104 produces<trigger::TriggerEvent>();
106 auto const* pProcessName = &
pn_;
111 if (iBranch.processName() == *pProcessName || *pProcessName ==
"*") {
112 auto const&
label = iBranch.moduleLabel();
209 const char token(
':');
214 if (
i1 == string::npos) {
221 if (
i2 == string::npos) {
233 desc.add<
bool>(
"throw",
false)->setComment(
"Throw exception or LogError");
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);
248 using namespace reco;
253 std::vector<edm::Handle<trigger::TriggerFilterObjectWithRefs>> fobs;
256 const unsigned int nfob(fobs.size());
257 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of filter objects found: " << nfob;
259 string tagLabel, tagInstance, tagProcess;
266 std::vector<bool> maskFilters;
267 maskFilters.resize(nfob);
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());
278 maskFilters[ifob] =
true;
283 for (
unsigned int icol = 0; icol != ncol; ++icol) {
285 tokenizeTag(collectionTags_[icol], tagLabel, tagInstance, tagProcess);
286 collectionTagsEvent.insert(
InputTag(tagLabel, tagInstance,
pn_));
291 if (filterTagsEvent.size() != nf) {
292 LogError(
"TriggerSummaryProducerAOD")
293 <<
"Mismatch in number of filter tags: " << filterTagsEvent.size() <<
"!=" << nf;
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();
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();
324 std::vector<std::string>
tags;
326 std::map<edm::ProductID, unsigned int>
offset;
328 fillTriggerObjectCollections<RecoEcalCandidateCollection>(
330 fillTriggerObjectCollections<ElectronCollection>(
332 fillTriggerObjectCollections<RecoChargedCandidateCollection>(
334 fillTriggerObjectCollections<CaloJetCollection>(
336 fillTriggerObjectCollections<CompositeCandidateCollection>(
339 fillTriggerObjectCollections<CaloMETCollection>(
341 fillTriggerObjectCollections<IsolatedPixelTrackCandidateCollection>(
344 fillTriggerObjectCollections<L1EmParticleCollection>(
346 fillTriggerObjectCollections<L1MuonParticleCollection>(
348 fillTriggerObjectCollections<L1JetParticleCollection>(
350 fillTriggerObjectCollections<L1EtMissParticleCollection>(
352 fillTriggerObjectCollections<L1HFRingsCollection>(
354 fillTriggerObjectCollections<MuonBxCollection>(
356 fillTriggerObjectCollections<MuonShowerBxCollection>(
358 fillTriggerObjectCollections<EGammaBxCollection>(
360 fillTriggerObjectCollections<JetBxCollection>(
362 fillTriggerObjectCollections<TauBxCollection>(
364 fillTriggerObjectCollections<EtSumBxCollection>(
367 fillTriggerObjectCollections<l1t::TrackerMuonCollection>(
369 fillTriggerObjectCollections<l1t::TkElectronCollection>(
371 fillTriggerObjectCollections<l1t::TkEmCollection>(
373 fillTriggerObjectCollections<l1t::PFJetCollection>(
375 fillTriggerObjectCollections<l1t::PFTauCollection>(
377 fillTriggerObjectCollections<l1t::HPSPFTauCollection>(
379 fillTriggerObjectCollections<l1t::PFTrackCollection>(
382 fillTriggerObjectCollections<reco::PFJetCollection>(
384 fillTriggerObjectCollections<reco::PFTauCollection>(
386 fillTriggerObjectCollections<reco::PFMETCollection>(
389 fillTriggerObjectCollections<l1t::P2GTCandidateCollection>(
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;
401 product->addCollections(
tags,
keys);
402 product->addObjects(toc);
406 for (
unsigned int ifob = 0; ifob != nfob; ++ifob) {
407 if (maskFilters[ifob]) {
416 iEvent, filterTag, fobs[ifob]->electronIds(), fobs[ifob]->electronRefs(),
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);
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);
443 iEvent, filterTag, fobs[ifob]->l1tetsumIds(), fobs[ifob]->l1tetsumRefs(),
offset,
keys, ids);
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);
464 iEvent, filterTag, fobs[ifob]->l1tp2gtcandIds(), fobs[ifob]->l1tp2gtcandRefs(),
offset,
keys, ids);
465 product->addFilter(filterTag, ids,
keys);
470 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of physics objects packed: " << ref->
sizeObjects();
471 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of filter objects packed: " << ref->
sizeFilters();
474 template <
typename C>
477 std::vector<std::string>&
tags,
488 using namespace reco;
497 for (
unsigned int ic = 0; ic != nc; ++ic) {
504 if (collectionTagsEvent.find(collectionTag) != collectionTagsEvent.end()) {
507 LogError(
"TriggerSummaryProducerAOD") <<
"Duplicate pid: " << pid;
511 for (
unsigned int i = 0;
i !=
n; ++
i) {
514 tags.push_back(collectionTag.encode());
515 keys.push_back(toc.size());
521 template <
typename T>
524 toc.emplace_back(
object);
535 object.hfEtSum(L1HFRings::kRing1PosEta),
536 object.hfEtSum(L1HFRings::kRing1NegEta),
537 object.hfEtSum(L1HFRings::kRing2PosEta),
538 object.hfEtSum(L1HFRings::kRing2NegEta));
540 object.hfBitCount(L1HFRings::kRing1PosEta),
541 object.hfBitCount(L1HFRings::kRing1NegEta),
542 object.hfBitCount(L1HFRings::kRing2PosEta),
543 object.hfBitCount(L1HFRings::kRing2NegEta));
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);
559 toc.emplace_back(0,
object.etTotal(), 0.0, 0.0, 0.0);
567 using namespace reco;
570 toc.emplace_back(
object);
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);
580 using namespace reco;
583 toc.emplace_back(
object);
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);
593 using namespace reco;
596 toc.emplace_back(
object);
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);
604 template <
typename C>
618 using namespace reco;
622 if (ids.size() != refs.size()) {
623 LogError(
"TriggerSummaryProducerAOD") <<
"Vector length is different: " << ids.size() <<
" " << refs.size();
626 const unsigned int n(
min(ids.size(), refs.size()));
627 for (
unsigned int i = 0;
i !=
n; ++
i) {
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();
638 LogError(
"TriggerSummaryProducerAOD") << ost.str();
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 650 <<
" CollectionType: " <<
typeid(
C).
name();
654 LogError(
"TriggerSummaryProducerAOD") << ost.str();
664 template <
typename C>
776 LogVerbatim(
"TriggerSummaryProducerAOD") <<
"TriggerSummaryProducerAOD::globalEndJob - accumulated tags:" << endl;
785 const unsigned int nf(filterTags.size());
786 LogVerbatim(
"TriggerSummaryProducerAOD") <<
" Overall number of Collections/Filters: " << nc <<
"/" << nf << endl;
788 LogVerbatim(
"TriggerSummaryProducerAOD") <<
" The collections: " << nc << endl;
791 for (InputTagSet::const_iterator ci = cb; ci != ce; ++ci) {
792 LogVerbatim(
"TriggerSummaryProducerAOD") <<
" " <<
distance(cb, ci) <<
" " << ci->encode() << endl;
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;
802 LogVerbatim(
"TriggerSummaryProducerAOD") <<
"TriggerSummaryProducerAOD::endJob." << endl;
~TriggerSummaryProducerAOD() override
Log< level::Info, true > LogVerbatim
void callWhenNewProductsRegistered(std::function< void(BranchDescription const &)> const &func)
edm::GetterOfProducts< l1t::TauBxCollection > getL1TTauParticleCollection_
std::vector< std::regex > moduleLabelPatternsToSkip_
edm::GetterOfProducts< l1extra::L1JetParticleCollection > getL1JetParticleCollection_
edm::GetterOfProducts< reco::IsolatedPixelTrackCandidateCollection > getIsolatedPixelTrackCandidateCollection_
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
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_
edm::GetterOfProducts< l1extra::L1EtMissParticleCollection > getL1EtMissParticleCollection_
Log< level::Error, false > LogError
std::string const & getProcessName() const
key_type key() const
Accessor for product key.
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
void fillFilterObjectMember(trigger::Keys &keys, trigger::Vids &ids, const int &, const int &, const edm::Ref< C > &) const
std::set< edm::InputTag, OrderInputTag > InputTagSet
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 &)
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
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)
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_
std::map< edm::ProductID, unsigned int > ProductIDtoIndex
edm::GetterOfProducts< reco::CompositeCandidateCollection > getCompositeCandidateCollection_
edm::GetterOfProducts< trigger::TriggerFilterObjectWithRefs > getTriggerFilterObjectWithRefs_
trigger object collection
std::string pn_
process name
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
edm::GetterOfProducts< reco::PFMETCollection > getPFMETCollection_
edm::GetterOfProducts< l1t::PFJetCollection > getL1TPFJetCollection_
moduleLabelPatternsToMatch
edm::GetterOfProducts< l1t::P2GTCandidateCollection > getL1TP2GTCandCollection_
edm::GetterOfProducts< l1t::EtSumBxCollection > getL1TEtSumParticleCollection_
moduleLabelPatternsToSkip
edm::GetterOfProducts< l1extra::L1EmParticleCollection > getL1EmParticleCollection_
edm::GetterOfProducts< l1t::EGammaBxCollection > getL1TEGammaParticleCollection_