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();
206 const char token(
':');
211 if (
i1 == string::npos) {
218 if (
i2 == string::npos) {
230 desc.add<
bool>(
"throw",
false)->setComment(
"Throw exception or LogError");
233 "Process name to use when getting data. The value of '@' is used to denote the current process name.");
234 desc.add<std::vector<std::string>>(
"moduleLabelPatternsToMatch", std::vector<std::string>(1,
"hlt*"))
235 ->setComment(
"glob patterns for module labels to get data.");
236 desc.add<std::vector<std::string>>(
"moduleLabelPatternsToSkip", std::vector<std::string>())
237 ->setComment(
"module labels for data products which should not be gotten.");
238 descriptions.
add(
"triggerSummaryProducerAOD",
desc);
245 using namespace reco;
250 std::vector<edm::Handle<trigger::TriggerFilterObjectWithRefs>> fobs;
253 const unsigned int nfob(fobs.size());
254 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of filter objects found: " << nfob;
256 string tagLabel, tagInstance, tagProcess;
263 std::vector<bool> maskFilters;
264 maskFilters.resize(nfob);
269 for (
unsigned int ifob = 0; ifob != nfob; ++ifob) {
270 maskFilters[ifob] =
false;
271 const vector<string>& collectionTags_(fobs[ifob]->getCollectionTagsAsStrings());
272 const unsigned int ncol(collectionTags_.size());
275 maskFilters[ifob] =
true;
280 for (
unsigned int icol = 0; icol != ncol; ++icol) {
282 tokenizeTag(collectionTags_[icol], tagLabel, tagInstance, tagProcess);
283 collectionTagsEvent.insert(
InputTag(tagLabel, tagInstance,
pn_));
288 if (filterTagsEvent.size() != nf) {
289 LogError(
"TriggerSummaryProducerAOD")
290 <<
"Mismatch in number of filter tags: " << filterTagsEvent.size() <<
"!=" << nf;
300 const unsigned int nc(collectionTagsEvent.size());
301 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of unique collections requested " << nc;
302 const InputTagSet::const_iterator cb(collectionTagsEvent.begin());
303 const InputTagSet::const_iterator ce(collectionTagsEvent.end());
304 for (InputTagSet::const_iterator ci = cb; ci != ce; ++ci) {
305 LogTrace(
"TriggerSummaryProducerAOD") <<
distance(cb, ci) <<
" " << ci->encode();
307 const unsigned int nf(filterTagsEvent.size());
308 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of unique filters requested " << nf;
309 const InputTagSet::const_iterator fb(filterTagsEvent.begin());
310 const InputTagSet::const_iterator fe(filterTagsEvent.end());
311 for (InputTagSet::const_iterator fi = fb; fi != fe; ++fi) {
312 LogTrace(
"TriggerSummaryProducerAOD") <<
distance(fb, fi) <<
" " << fi->encode();
323 std::vector<std::string>
tags;
325 std::map<edm::ProductID, unsigned int>
offset;
327 fillTriggerObjectCollections<RecoEcalCandidateCollection>(
329 fillTriggerObjectCollections<ElectronCollection>(
331 fillTriggerObjectCollections<RecoChargedCandidateCollection>(
333 fillTriggerObjectCollections<CaloJetCollection>(
335 fillTriggerObjectCollections<CompositeCandidateCollection>(
338 fillTriggerObjectCollections<CaloMETCollection>(
340 fillTriggerObjectCollections<IsolatedPixelTrackCandidateCollection>(
343 fillTriggerObjectCollections<L1EmParticleCollection>(
345 fillTriggerObjectCollections<L1MuonParticleCollection>(
347 fillTriggerObjectCollections<L1JetParticleCollection>(
349 fillTriggerObjectCollections<L1EtMissParticleCollection>(
351 fillTriggerObjectCollections<L1HFRingsCollection>(
353 fillTriggerObjectCollections<MuonBxCollection>(
355 fillTriggerObjectCollections<MuonShowerBxCollection>(
357 fillTriggerObjectCollections<EGammaBxCollection>(
359 fillTriggerObjectCollections<JetBxCollection>(
361 fillTriggerObjectCollections<TauBxCollection>(
363 fillTriggerObjectCollections<EtSumBxCollection>(
366 fillTriggerObjectCollections<l1t::TrackerMuonCollection>(
368 fillTriggerObjectCollections<l1t::TkElectronCollection>(
370 fillTriggerObjectCollections<l1t::TkEmCollection>(
372 fillTriggerObjectCollections<l1t::PFJetCollection>(
374 fillTriggerObjectCollections<l1t::PFTauCollection>(
376 fillTriggerObjectCollections<l1t::HPSPFTauCollection>(
378 fillTriggerObjectCollections<l1t::PFTrackCollection>(
381 fillTriggerObjectCollections<reco::PFJetCollection>(
383 fillTriggerObjectCollections<reco::PFTauCollection>(
385 fillTriggerObjectCollections<reco::PFMETCollection>(
388 const unsigned int nk(
tags.size());
389 LogDebug(
"TriggerSummaryProducerAOD") <<
"Number of collections found: " << nk;
390 const unsigned int no(toc.size());
391 LogDebug(
"TriggerSummaryProducerAOD") <<
"Number of physics objects found: " << no;
398 product->addCollections(
tags,
keys);
399 product->addObjects(toc);
403 for (
unsigned int ifob = 0; ifob != nfob; ++ifob) {
404 if (maskFilters[ifob]) {
413 iEvent, filterTag, fobs[ifob]->electronIds(), fobs[ifob]->electronRefs(),
offset,
keys, ids);
417 iEvent, filterTag, fobs[ifob]->compositeIds(), fobs[ifob]->compositeRefs(),
offset,
keys, ids);
419 iEvent, filterTag, fobs[ifob]->basemetIds(), fobs[ifob]->basemetRefs(),
offset,
keys, ids);
421 iEvent, filterTag, fobs[ifob]->calometIds(), fobs[ifob]->calometRefs(),
offset,
keys, ids);
423 iEvent, filterTag, fobs[ifob]->pixtrackIds(), fobs[ifob]->pixtrackRefs(),
offset,
keys, ids);
428 iEvent, filterTag, fobs[ifob]->l1etmissIds(), fobs[ifob]->l1etmissRefs(),
offset,
keys, ids);
430 iEvent, filterTag, fobs[ifob]->l1hfringsIds(), fobs[ifob]->l1hfringsRefs(),
offset,
keys, ids);
432 iEvent, filterTag, fobs[ifob]->l1tmuonIds(), fobs[ifob]->l1tmuonRefs(),
offset,
keys, ids);
434 iEvent, filterTag, fobs[ifob]->l1tmuonShowerIds(), fobs[ifob]->l1tmuonShowerRefs(),
offset,
keys, ids);
436 iEvent, filterTag, fobs[ifob]->l1tegammaIds(), fobs[ifob]->l1tegammaRefs(),
offset,
keys, ids);
440 iEvent, filterTag, fobs[ifob]->l1tetsumIds(), fobs[ifob]->l1tetsumRefs(),
offset,
keys, ids);
443 iEvent, filterTag, fobs[ifob]->l1ttkmuonIds(), fobs[ifob]->l1ttkmuonRefs(),
offset,
keys, ids);
445 iEvent, filterTag, fobs[ifob]->l1ttkeleIds(), fobs[ifob]->l1ttkeleRefs(),
offset,
keys, ids);
447 iEvent, filterTag, fobs[ifob]->l1ttkemIds(), fobs[ifob]->l1ttkemRefs(),
offset,
keys, ids);
449 iEvent, filterTag, fobs[ifob]->l1tpfjetIds(), fobs[ifob]->l1tpfjetRefs(),
offset,
keys, ids);
451 iEvent, filterTag, fobs[ifob]->l1tpftauIds(), fobs[ifob]->l1tpftauRefs(),
offset,
keys, ids);
453 iEvent, filterTag, fobs[ifob]->l1thpspftauIds(), fobs[ifob]->l1thpspftauRefs(),
offset,
keys, ids);
455 iEvent, filterTag, fobs[ifob]->l1tpftrackIds(), fobs[ifob]->l1tpftrackRefs(),
offset,
keys, ids);
460 product->addFilter(filterTag, ids,
keys);
465 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of physics objects packed: " << ref->
sizeObjects();
466 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of filter objects packed: " << ref->
sizeFilters();
469 template <
typename C>
472 std::vector<std::string>&
tags,
483 using namespace reco;
492 for (
unsigned int ic = 0; ic != nc; ++ic) {
499 if (collectionTagsEvent.find(collectionTag) != collectionTagsEvent.end()) {
502 LogError(
"TriggerSummaryProducerAOD") <<
"Duplicate pid: " << pid;
506 for (
unsigned int i = 0;
i !=
n; ++
i) {
509 tags.push_back(collectionTag.encode());
510 keys.push_back(toc.size());
516 template <
typename T>
519 toc.emplace_back(
object);
530 object.hfEtSum(L1HFRings::kRing1PosEta),
531 object.hfEtSum(L1HFRings::kRing1NegEta),
532 object.hfEtSum(L1HFRings::kRing2PosEta),
533 object.hfEtSum(L1HFRings::kRing2NegEta));
535 object.hfBitCount(L1HFRings::kRing1PosEta),
536 object.hfBitCount(L1HFRings::kRing1NegEta),
537 object.hfBitCount(L1HFRings::kRing2PosEta),
538 object.hfBitCount(L1HFRings::kRing2NegEta));
548 toc.emplace_back(
object);
549 if (
object.
type() == L1EtMissParticle::kMET) {
550 toc.emplace_back(
TriggerL1ETT,
object.etTotal(), 0.0, 0.0, 0.0);
551 }
else if (
object.
type() == L1EtMissParticle::kMHT) {
552 toc.emplace_back(
TriggerL1HTT,
object.etTotal(), 0.0, 0.0, 0.0);
554 toc.emplace_back(0,
object.etTotal(), 0.0, 0.0, 0.0);
562 using namespace reco;
565 toc.emplace_back(
object);
567 toc.emplace_back(
TriggerMETSig,
object.mEtSig(), 0.0, 0.0, 0.0);
568 toc.emplace_back(
TriggerELongit,
object.e_longitudinal(), 0.0, 0.0, 0.0);
575 using namespace reco;
578 toc.emplace_back(
object);
580 toc.emplace_back(
TriggerMETSig,
object.mEtSig(), 0.0, 0.0, 0.0);
581 toc.emplace_back(
TriggerELongit,
object.e_longitudinal(), 0.0, 0.0, 0.0);
588 using namespace reco;
591 toc.emplace_back(
object);
593 toc.emplace_back(
TriggerMHTSig,
object.mEtSig(), 0.0, 0.0, 0.0);
594 toc.emplace_back(
TriggerHLongit,
object.e_longitudinal(), 0.0, 0.0, 0.0);
599 template <
typename C>
613 using namespace reco;
617 if (ids.size() != refs.size()) {
618 LogError(
"TriggerSummaryProducerAOD") <<
"Vector length is different: " << ids.size() <<
" " << refs.size();
621 const unsigned int n(
min(ids.size(), refs.size()));
622 for (
unsigned int i = 0;
i !=
n; ++
i) {
625 std::ostringstream ost;
626 ost <<
"Iinvalid pid: " << pid <<
" FilterTag / Key: " <<
tag.encode() <<
" / " <<
i <<
"of" <<
n 627 <<
" CollectionTag / Key: " 628 <<
" <Unrecoverable>" 629 <<
" / " << refs[
i].key() <<
" CollectionType: " <<
typeid(
C).
name();
633 LogError(
"TriggerSummaryProducerAOD") << ost.str();
636 auto itOffset =
offset.find(pid);
637 if (itOffset ==
offset.end()) {
638 const auto& prov =
iEvent.getStableProvenance(pid);
639 const string&
label(prov.moduleLabel());
640 const string&
instance(prov.productInstanceName());
641 const string&
process(prov.processName());
642 std::ostringstream ost;
643 ost <<
"Uunknown pid: " << pid <<
" FilterTag / Key: " <<
tag.encode() <<
" / " <<
i <<
"of" <<
n 645 <<
" CollectionType: " <<
typeid(
C).
name();
649 LogError(
"TriggerSummaryProducerAOD") << ost.str();
659 template <
typename C>
771 LogVerbatim(
"TriggerSummaryProducerAOD") <<
"TriggerSummaryProducerAOD::globalEndJob - accumulated tags:" << endl;
780 const unsigned int nf(filterTags.size());
781 LogVerbatim(
"TriggerSummaryProducerAOD") <<
" Overall number of Collections/Filters: " << nc <<
"/" << nf << endl;
783 LogVerbatim(
"TriggerSummaryProducerAOD") <<
" The collections: " << nc << endl;
786 for (InputTagSet::const_iterator ci = cb; ci != ce; ++ci) {
787 LogVerbatim(
"TriggerSummaryProducerAOD") <<
" " <<
distance(cb, ci) <<
" " << ci->encode() << endl;
790 LogVerbatim(
"TriggerSummaryProducerAOD") <<
" The filters:" << nf << endl;
791 const InputTagSet::const_iterator fb(filterTags.begin());
792 const InputTagSet::const_iterator fe(filterTags.end());
793 for (InputTagSet::const_iterator fi = fb; fi != fe; ++fi) {
794 LogVerbatim(
"TriggerSummaryProducerAOD") <<
" " <<
distance(fb, fi) <<
" " << fi->encode() << endl;
797 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.
moduleLabelPatternsToSkip
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_
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
void fillHandles(edm::Event const &event, std::vector< edm::Handle< T >> &handles) const
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_
moduleLabelPatternsToMatch
edm::GetterOfProducts< l1t::PFJetCollection > getL1TPFJetCollection_
edm::GetterOfProducts< l1t::EtSumBxCollection > getL1TEtSumParticleCollection_
edm::GetterOfProducts< l1extra::L1EmParticleCollection > getL1EmParticleCollection_
edm::GetterOfProducts< l1t::EGammaBxCollection > getL1TEGammaParticleCollection_