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_;
114 auto productMatch = [pProcessName,&moduleLabelPatternsToSkip,&moduleLabelPatternsToMatch](
edm::BranchDescription const& iBranch) ->
bool {
115 if(iBranch.processName() == *pProcessName || *pProcessName ==
"*") {
116 auto const&
label = iBranch.moduleLabel();
117 for(
auto&
match: moduleLabelPatternsToMatch) {
120 for(
auto& reject: moduleLabelPatternsToSkip) {
121 if(std::regex_match(
label,reject)) {
193 const char token(
':');
198 if (i1==string::npos) {
202 instance=label.substr(i1+1);
205 if (i2==string::npos) {
208 process=instance.substr(i2+1);
217 desc.
add<
std::string>(
"processName",
"@")->setComment(
"Process name to use when getting data. The value of '@' is used to denote the current process name.");
218 desc.
add<std::vector<std::string>>(
"moduleLabelPatternsToMatch",std::vector<std::string>(1,
"hlt*"))->
setComment(
"glob patterns for module labels to get data.");
219 desc.
add<std::vector<std::string>>(
"moduleLabelPatternsToSkip",std::vector<std::string>())->
setComment(
"module labels for data products which should not be gotten.");
220 descriptions.
add(
"triggerSummaryProducerAOD", desc);
229 using namespace reco;
234 std::vector<edm::Handle<trigger::TriggerFilterObjectWithRefs> > fobs;
237 const unsigned int nfob(fobs.size());
238 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of filter objects found: " << nfob;
240 string tagLabel,tagInstance,tagProcess;
252 for (
unsigned int ifob=0; ifob!=nfob; ++ifob) {
254 const vector<string>& collectionTags_(fobs[ifob]->getCollectionTagsAsStrings());
255 const unsigned int ncol(collectionTags_.size());
259 const string&
label (fobs[ifob].provenance()->moduleLabel());
260 const string&
instance (fobs[ifob].provenance()->productInstanceName());
263 for (
unsigned int icol=0; icol!=
ncol; ++icol) {
265 tokenizeTag(collectionTags_[icol],tagLabel,tagInstance,tagProcess);
272 LogError(
"TriggerSummaryProducerAOD")
273 <<
"Mismatch in number of filter tags: " 286 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of unique collections requested " << nc;
289 for ( InputTagSet::const_iterator ci=cb; ci!=ce; ++ci) {
290 LogTrace(
"TriggerSummaryProducerAOD") <<
distance(cb,ci) <<
" " << ci->encode();
293 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of unique filters requested " << nf;
296 for ( InputTagSet::const_iterator fi=
fb; fi!=fe; ++fi) {
335 const unsigned int nk(
tags_.size());
336 LogDebug(
"TriggerSummaryProducerAOD") <<
"Number of collections found: " << nk;
337 const unsigned int no(
toc_.size());
338 LogDebug(
"TriggerSummaryProducerAOD") <<
"Number of physics objects found: " << no;
346 product->addObjects(
toc_);
349 for (
unsigned int ifob=0; ifob!=nfob; ++ifob) {
351 const string&
label (fobs[ifob].provenance()->moduleLabel());
352 const string&
instance (fobs[ifob].provenance()->productInstanceName());
378 product->addFilter(filterTag,
ids_,
keys_);
383 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of physics objects packed: " << ref->
sizeObjects();
384 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of filter objects packed: " << ref->
sizeFilters();
388 template <
typename C>
397 using namespace reco;
402 vector<Handle<C> > collections;
404 const unsigned int nc(collections.size());
406 for (
unsigned int ic=0; ic!=nc; ++ic) {
407 const Provenance& provenance(*(collections[ic].provenance()));
414 const ProductID pid(collections[ic].provenance()->productID());
416 LogError(
"TriggerSummaryProducerAOD") <<
"Duplicate pid!";
419 const unsigned int n(collections[ic]->
size());
420 for (
unsigned int i=0;
i!=
n; ++
i) {
423 tags_.push_back(collectionTag.encode());
430 template <
typename T>
445 object.hfEtSum(L1HFRings::kRing1PosEta),
446 object.hfEtSum(L1HFRings::kRing1NegEta),
447 object.hfEtSum(L1HFRings::kRing2PosEta),
448 object.hfEtSum(L1HFRings::kRing2NegEta) ) );
450 object.hfBitCount(L1HFRings::kRing1PosEta),
451 object.hfBitCount(L1HFRings::kRing1NegEta),
452 object.hfBitCount(L1HFRings::kRing2PosEta),
453 object.hfBitCount(L1HFRings::kRing2NegEta) ) );
464 if (
object.
type()==L1EtMissParticle::kMET) {
466 }
else if (
object.
type()==L1EtMissParticle::kMHT) {
477 using namespace reco;
490 using namespace reco;
503 using namespace reco;
514 template <
typename C>
523 using namespace reco;
527 if (ids.size()!=refs.size()) {
528 LogError(
"TriggerSummaryProducerAOD") <<
"Vector length is different: " 529 << ids.size() <<
" " << refs.size();
532 const unsigned int n(
min(ids.size(),refs.size()));
533 for (
unsigned int i=0;
i!=
n; ++
i) {
536 LogError(
"TriggerSummaryProducerAOD")
537 <<
"Iinvalid pid: " << pid
538 <<
" FilterTag / Key: " << tag.
encode()
539 <<
" / " <<
i <<
"of" << n
540 <<
" CollectionTag / Key: " 541 <<
" <Unrecoverable>" 542 <<
" / " << refs[
i].key()
543 <<
" CollectionType: " <<
typeid(
C).
name();
548 LogError(
"TriggerSummaryProducerAOD")
549 <<
"Uunknown pid: " << pid
550 <<
" FilterTag / Key: " << tag.
encode()
551 <<
" / " <<
i <<
"of" << n
552 <<
" CollectionTag / Key: " 554 <<
" / " << refs[
i].key()
555 <<
" CollectionType: " <<
typeid(
C).
name();
564 template <
typename C>
578 keys_.push_back(offset+2*ref.
key()+1);
580 keys_.push_back(offset+2*ref.
key()+0);
592 keys_.push_back(offset+2*ref.
key()+1);
594 keys_.push_back(offset+2*ref.
key()+0);
606 keys_.push_back(offset+4*ref.
key()+1);
608 keys_.push_back(offset+4*ref.
key()+2);
610 keys_.push_back(offset+4*ref.
key()+3);
612 keys_.push_back(offset+4*ref.
key()+0);
624 keys_.push_back(offset+4*ref.
key()+1);
626 keys_.push_back(offset+4*ref.
key()+2);
628 keys_.push_back(offset+4*ref.
key()+3);
630 keys_.push_back(offset+4*ref.
key()+0);
642 keys_.push_back(offset+4*ref.
key()+1);
644 keys_.push_back(offset+4*ref.
key()+2);
646 keys_.push_back(offset+4*ref.
key()+3);
648 keys_.push_back(offset+4*ref.
key()+0);
668 LogVerbatim(
"TriggerSummaryProducerAOD") <<
"TriggerSummaryProducerAOD::globalEndJob - accumulated tags:" << endl;
676 const unsigned int nc(collectionTags.size());
677 const unsigned int nf(filterTags.size());
678 LogVerbatim(
"TriggerSummaryProducerAOD") <<
" Overall number of Collections/Filters: " 679 << nc <<
"/" << nf << endl;
681 LogVerbatim(
"TriggerSummaryProducerAOD") <<
" The collections: " << nc << endl;
682 const InputTagSet::const_iterator cb(collectionTags.begin());
683 const InputTagSet::const_iterator ce(collectionTags.end());
684 for ( InputTagSet::const_iterator ci=cb; ci!=ce; ++ci) {
685 LogVerbatim(
"TriggerSummaryProducerAOD") <<
" " <<
distance(cb,ci) <<
" " << ci->encode() << endl;
688 LogVerbatim(
"TriggerSummaryProducerAOD") <<
" The filters:" << nf << endl;
689 const InputTagSet::const_iterator
fb(filterTags.begin());
690 const InputTagSet::const_iterator fe(filterTags.end());
691 for ( InputTagSet::const_iterator fi=
fb; fi!=fe; ++fi) {
695 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_
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::size_type sizeFilters() const
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.
std::vector< std::string > tags_
std::string const & processName() const
edm::GetterOfProducts< reco::PFJetCollection > getPFJetCollection_
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_
trigger::size_type sizeObjects() const
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
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_
edm::GetterOfProducts< l1extra::L1EmParticleCollection > getL1EmParticleCollection_
edm::GetterOfProducts< l1t::EGammaBxCollection > getL1TEGammaParticleCollection_