55 #include "boost/algorithm/string.hpp"
58 std::vector<std::regex> convertToRegex(std::vector<std::string>
const& iPatterns) {
59 std::vector<std::regex>
result;
61 for(
auto const&
pattern: iPatterns) {
63 boost::replace_all(regexPattern,
"*",
".*");
64 boost::replace_all(regexPattern,
"?",
".");
66 result.emplace_back(regexPattern);
76 pn_(ps.getParameter<std::
string>(
"processName")),
77 moduleLabelPatternsToMatch_(convertToRegex(ps.getParameter<std::vector<std::
string>>(
"moduleLabelPatternsToMatch"))),
78 moduleLabelPatternsToSkip_(convertToRegex(ps.getParameter<std::vector<std::
string>>(
"moduleLabelPatternsToSkip"))),
79 filterTagsEvent_(pn_!=
"*"),
80 filterTagsStream_(pn_!=
"*"),
81 collectionTagsEvent_(pn_!=
"*"),
82 collectionTagsStream_(pn_!=
"*"),
95 edm::LogError(
"TriggerSummaryProducerAOD") <<
"HLT Error: TriggerNamesService not available!";
104 LogDebug(
"TriggerSummaryProducerAOD") <<
"Using process name: '" <<
pn_ <<
"'";
109 produces<trigger::TriggerEvent>();
111 auto const* pProcessName = &
pn_;
115 if(iBranch.processName() == *pProcessName || *pProcessName ==
"*") {
116 auto const&
label = iBranch.moduleLabel();
120 for(
auto& reject: moduleLabelPatternsToSkip) {
121 if(std::regex_match(
label,reject)) {
195 const char token(
':');
200 if (i1==string::npos) {
204 instance=label.substr(i1+1);
207 if (i2==string::npos) {
210 process=instance.substr(i2+1);
219 desc.
add<
std::string>(
"processName",
"@")->setComment(
"Process name to use when getting data. The value of '@' is used to denote the current process name.");
220 desc.
add<std::vector<std::string>>(
"moduleLabelPatternsToMatch",std::vector<std::string>(1,
"hlt*"))->
setComment(
"glob patterns for module labels to get data.");
221 desc.
add<std::vector<std::string>>(
"moduleLabelPatternsToSkip",std::vector<std::string>())->
setComment(
"module labels for data products which should not be gotten.");
222 descriptions.
add(
"triggerSummaryProducerAOD", desc);
231 using namespace reco;
232 using namespace l1extra;
233 using namespace trigger;
236 std::vector<edm::Handle<trigger::TriggerFilterObjectWithRefs> > fobs;
239 const unsigned int nfob(fobs.size());
240 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of filter objects found: " << nfob;
242 string tagLabel,tagInstance,tagProcess;
254 for (
unsigned int ifob=0; ifob!=nfob; ++ifob) {
256 const vector<string>& collectionTags_(fobs[ifob]->getCollectionTagsAsStrings());
257 const unsigned int ncol(collectionTags_.size());
261 const string&
label (fobs[ifob].provenance()->moduleLabel());
262 const string&
instance (fobs[ifob].provenance()->productInstanceName());
265 for (
unsigned int icol=0; icol!=ncol; ++icol) {
267 tokenizeTag(collectionTags_[icol],tagLabel,tagInstance,tagProcess);
274 LogError(
"TriggerSummaryProducerAOD")
275 <<
"Mismatch in number of filter tags: "
288 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of unique collections requested " << nc;
291 for ( InputTagSet::const_iterator ci=cb; ci!=ce; ++ci) {
292 LogTrace(
"TriggerSummaryProducerAOD") <<
distance(cb,ci) <<
" " << ci->encode();
295 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of unique filters requested " << nf;
298 for ( InputTagSet::const_iterator fi=
fb; fi!=fe; ++fi) {
337 const unsigned int nk(
tags_.size());
338 LogDebug(
"TriggerSummaryProducerAOD") <<
"Number of collections found: " << nk;
339 const unsigned int no(
toc_.size());
340 LogDebug(
"TriggerSummaryProducerAOD") <<
"Number of physics objects found: " << no;
348 product->addObjects(
toc_);
351 for (
unsigned int ifob=0; ifob!=nfob; ++ifob) {
353 const string&
label (fobs[ifob].provenance()->moduleLabel());
354 const string&
instance (fobs[ifob].provenance()->productInstanceName());
380 product->addFilter(filterTag,
ids_,
keys_);
385 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of physics objects packed: " << ref->sizeObjects();
386 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of filter objects packed: " << ref->sizeFilters();
390 template <
typename C>
399 using namespace reco;
400 using namespace l1extra;
401 using namespace trigger;
404 vector<Handle<C> > collections;
406 const unsigned int nc(collections.size());
408 for (
unsigned int ic=0; ic!=nc; ++ic) {
409 const Provenance& provenance(*(collections[ic].provenance()));
413 const InputTag collectionTag(label,instance,process);
416 const ProductID pid(collections[ic].provenance()->productID());
418 LogError(
"TriggerSummaryProducerAOD") <<
"Duplicate pid!";
421 const unsigned int n(collections[ic]->
size());
422 for (
unsigned int i=0;
i!=
n; ++
i) {
425 tags_.push_back(collectionTag.encode());
432 template <
typename T>
435 using namespace trigger;
443 using namespace l1extra;
444 using namespace trigger;
447 object.hfEtSum(L1HFRings::kRing1PosEta),
448 object.hfEtSum(L1HFRings::kRing1NegEta),
449 object.hfEtSum(L1HFRings::kRing2PosEta),
450 object.hfEtSum(L1HFRings::kRing2NegEta) ) );
452 object.hfBitCount(L1HFRings::kRing1PosEta),
453 object.hfBitCount(L1HFRings::kRing1NegEta),
454 object.hfBitCount(L1HFRings::kRing2PosEta),
455 object.hfBitCount(L1HFRings::kRing2NegEta) ) );
462 using namespace l1extra;
463 using namespace trigger;
466 if (
object.
type()==L1EtMissParticle::kMET) {
468 }
else if (
object.
type()==L1EtMissParticle::kMHT) {
479 using namespace reco;
480 using namespace trigger;
492 using namespace reco;
493 using namespace trigger;
505 using namespace reco;
506 using namespace trigger;
516 template <
typename C>
525 using namespace reco;
526 using namespace l1extra;
527 using namespace trigger;
529 if (ids.size()!=refs.size()) {
530 LogError(
"TriggerSummaryProducerAOD") <<
"Vector length is different: "
531 << ids.size() <<
" " << refs.size();
534 const unsigned int n(
min(ids.size(),refs.size()));
535 for (
unsigned int i=0;
i!=
n; ++
i) {
538 LogError(
"TriggerSummaryProducerAOD")
539 <<
"Iinvalid pid: " << pid
540 <<
" FilterTag / Key: " << tag.
encode()
541 <<
" / " <<
i <<
"of" << n
542 <<
" CollectionTag / Key: "
543 <<
" <Unrecoverable>"
544 <<
" / " << refs[
i].key()
545 <<
" CollectionType: " <<
typeid(
C).
name();
550 LogError(
"TriggerSummaryProducerAOD")
551 <<
"Uunknown pid: " << pid
552 <<
" FilterTag / Key: " << tag.
encode()
553 <<
" / " <<
i <<
"of" << n
554 <<
" CollectionTag / Key: "
555 <<
InputTag(label,instance,process).encode()
556 <<
" / " << refs[
i].key()
557 <<
" CollectionType: " <<
typeid(
C).
name();
566 template <
typename C>
577 using namespace trigger;
580 keys_.push_back(offset+2*ref.
key()+1);
582 keys_.push_back(offset+2*ref.
key()+0);
591 using namespace trigger;
594 keys_.push_back(offset+2*ref.
key()+1);
596 keys_.push_back(offset+2*ref.
key()+0);
605 using namespace trigger;
608 keys_.push_back(offset+4*ref.
key()+1);
610 keys_.push_back(offset+4*ref.
key()+2);
612 keys_.push_back(offset+4*ref.
key()+3);
614 keys_.push_back(offset+4*ref.
key()+0);
623 using namespace trigger;
626 keys_.push_back(offset+4*ref.
key()+1);
628 keys_.push_back(offset+4*ref.
key()+2);
630 keys_.push_back(offset+4*ref.
key()+3);
632 keys_.push_back(offset+4*ref.
key()+0);
641 using namespace trigger;
644 keys_.push_back(offset+4*ref.
key()+1);
646 keys_.push_back(offset+4*ref.
key()+2);
648 keys_.push_back(offset+4*ref.
key()+3);
650 keys_.push_back(offset+4*ref.
key()+0);
667 using namespace trigger;
670 LogVerbatim(
"TriggerSummaryProducerAOD") <<
"TriggerSummaryProducerAOD::globalEndJob - accumulated tags:" << endl;
678 const unsigned int nc(collectionTags.size());
679 const unsigned int nf(filterTags.size());
680 LogVerbatim(
"TriggerSummaryProducerAOD") <<
" Overall number of Collections/Filters: "
681 << nc <<
"/" << nf << endl;
683 LogVerbatim(
"TriggerSummaryProducerAOD") <<
" The collections: " << nc << endl;
684 const InputTagSet::const_iterator cb(collectionTags.begin());
685 const InputTagSet::const_iterator ce(collectionTags.end());
686 for ( InputTagSet::const_iterator ci=cb; ci!=ce; ++ci) {
687 LogVerbatim(
"TriggerSummaryProducerAOD") <<
" " <<
distance(cb,ci) <<
" " << ci->encode() << endl;
690 LogVerbatim(
"TriggerSummaryProducerAOD") <<
" The filters:" << nf << endl;
691 const InputTagSet::const_iterator
fb(filterTags.begin());
692 const InputTagSet::const_iterator fe(filterTags.end());
693 for ( InputTagSet::const_iterator fi=
fb; fi!=fe; ++fi) {
697 LogVerbatim(
"TriggerSummaryProducerAOD") <<
"TriggerSummaryProducerAOD::endJob." << endl;
virtual void produce(edm::Event &, const edm::EventSetup &) override
void callWhenNewProductsRegistered(std::function< void(BranchDescription const &)> const &func)
void setComment(std::string const &value)
edm::GetterOfProducts< l1t::TauBxCollection > getL1TTauParticleCollection_
std::vector< std::regex > moduleLabelPatternsToSkip_
edm::GetterOfProducts< l1extra::L1JetParticleCollection > getL1JetParticleCollection_
edm::GetterOfProducts< reco::IsolatedPixelTrackCandidateCollection > getIsolatedPixelTrackCandidateCollection_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::GetterOfProducts< reco::RecoEcalCandidateCollection > getRecoEcalCandidateCollection_
std::string const & getProcessName() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::GetterOfProducts< l1extra::L1MuonParticleCollection > getL1MuonParticleCollection_
The single EDProduct to be saved for each event (AOD case)
trigger::TriggerObjectCollection toc_
trigger object collection
edm::GetterOfProducts< reco::PFTauCollection > getPFTauCollection_
~TriggerSummaryProducerAOD()
static PFTauRenderPlugin instance
std::vector< bool > maskFilters_
packing decision
edm::GetterOfProducts< reco::METCollection > getMETCollection_
edm::GetterOfProducts< l1t::JetBxCollection > getL1TJetParticleCollection_
std::set< edm::InputTag, OrderInputTag > InputTagSet
edm::GetterOfProducts< reco::CaloJetCollection > getCaloJetCollection_
void fillFilterObjectMember(const int &, const int &, const edm::Ref< C > &)
edm::GetterOfProducts< l1extra::L1EtMissParticleCollection > getL1EtMissParticleCollection_
key_type key() const
Accessor for product key.
tuple moduleLabelPatternsToMatch
std::vector< std::string > tags_
std::string const & processName() const
edm::GetterOfProducts< reco::PFJetCollection > getPFJetCollection_
Single trigger physics object (e.g., an isolated muon)
edm::GetterOfProducts< reco::RecoChargedCandidateCollection > getRecoChargedCandidateCollection_
InputTagSet collectionTagsStream_
edm::GetterOfProducts< l1extra::L1HFRingsCollection > getL1HFRingsCollection_
void fillTriggerObject(const T &)
std::vector< std::regex > moduleLabelPatternsToMatch_
module labels which should be avoided
std::map< edm::ProductID, unsigned int > offset_
global map for indices into toc_: offset per input L3 collection
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void fillFilterObjectMembers(const edm::Event &, const edm::InputTag &tag, const trigger::Vids &, const std::vector< edm::Ref< C > > &)
edm::GetterOfProducts< l1t::MuonBxCollection > getL1TMuonParticleCollection_
InputTagSet filterTagsStream_
virtual void endStream() override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::string const & moduleLabel() const
edm::GetterOfProducts< reco::CaloMETCollection > getCaloMETCollection_
edm::GetterOfProducts< reco::ElectronCollection > getElectronCollection_
InputTagSet collectionTagsEvent_
list of L3 collection tags
tuple moduleLabelPatternsToSkip
void fillHandles(edm::Event const &event, std::vector< edm::Handle< T > > &handles) const
edm::GetterOfProducts< reco::CompositeCandidateCollection > getCompositeCandidateCollection_
edm::GetterOfProducts< trigger::TriggerFilterObjectWithRefs > getTriggerFilterObjectWithRefs_
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_
void fillTriggerObjectCollections(const edm::Event &, edm::GetterOfProducts< C > &)
InputTagSet filterTagsEvent_
list of L3 filter tags
TriggerSummaryProducerAOD(const edm::ParameterSet &, const GlobalInputTags *)
static void globalEndJob(const GlobalInputTags *)
std::string const & productInstanceName() const
Provenance getProvenance(BranchID const &theID) const
edm::GetterOfProducts< l1t::EtSumBxCollection > getL1TEtSumParticleCollection_
tuple size
Write out results.
edm::GetterOfProducts< l1extra::L1EmParticleCollection > getL1EmParticleCollection_
edm::GetterOfProducts< l1t::EGammaBxCollection > getL1TEGammaParticleCollection_