56 #include "boost/algorithm/string.hpp" 59 std::vector<std::regex> convertToRegex(std::vector<std::string>
const& iPatterns) {
60 std::vector<std::regex>
result;
62 for(
auto const&
pattern: iPatterns) {
64 boost::replace_all(regexPattern,
"*",
".*");
65 boost::replace_all(regexPattern,
"?",
".");
67 result.emplace_back(regexPattern);
77 throw_(ps.getParameter<
bool>(
"throw")),
78 pn_(ps.getParameter<
std::
string>(
"processName")),
79 moduleLabelPatternsToMatch_(convertToRegex(ps.getParameter<
std::vector<
std::
string>>(
"moduleLabelPatternsToMatch"))),
80 moduleLabelPatternsToSkip_(convertToRegex(ps.getParameter<
std::vector<
std::
string>>(
"moduleLabelPatternsToSkip"))),
81 filterTagsEvent_(pn_!=
"*"),
82 filterTagsStream_(pn_!=
"*"),
83 collectionTagsEvent_(pn_!=
"*"),
84 collectionTagsStream_(pn_!=
"*"),
97 edm::LogError(
"TriggerSummaryProducerAOD") <<
"HLT Error: TriggerNamesService not available!";
106 LogDebug(
"TriggerSummaryProducerAOD") <<
"Using process name: '" <<
pn_ <<
"'";
111 produces<trigger::TriggerEvent>();
113 auto const* pProcessName = &
pn_;
116 auto productMatch = [pProcessName,&moduleLabelPatternsToSkip,&moduleLabelPatternsToMatch](
edm::BranchDescription const& iBranch) ->
bool {
117 if(iBranch.processName() == *pProcessName || *pProcessName ==
"*") {
118 auto const&
label = iBranch.moduleLabel();
119 for(
auto&
match: moduleLabelPatternsToMatch) {
122 for(
auto& reject: moduleLabelPatternsToSkip) {
123 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<
bool>(
"throw",
false)->setComment(
"Throw exception or LogError");
220 desc.
add<
std::string>(
"processName",
"@")->setComment(
"Process name to use when getting data. The value of '@' is used to denote the current process name.");
221 desc.
add<std::vector<std::string>>(
"moduleLabelPatternsToMatch",std::vector<std::string>(1,
"hlt*"))->
setComment(
"glob patterns for module labels to get data.");
222 desc.
add<std::vector<std::string>>(
"moduleLabelPatternsToSkip",std::vector<std::string>())->
setComment(
"module labels for data products which should not be gotten.");
223 descriptions.
add(
"triggerSummaryProducerAOD", desc);
232 using namespace reco;
237 std::vector<edm::Handle<trigger::TriggerFilterObjectWithRefs> > fobs;
240 const unsigned int nfob(fobs.size());
241 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of filter objects found: " << nfob;
243 string tagLabel,tagInstance,tagProcess;
255 for (
unsigned int ifob=0; ifob!=nfob; ++ifob) {
257 const vector<string>& collectionTags_(fobs[ifob]->getCollectionTagsAsStrings());
258 const unsigned int ncol(collectionTags_.size());
262 const string&
label (fobs[ifob].provenance()->moduleLabel());
263 const string&
instance (fobs[ifob].provenance()->productInstanceName());
266 for (
unsigned int icol=0; icol!=
ncol; ++icol) {
268 tokenizeTag(collectionTags_[icol],tagLabel,tagInstance,tagProcess);
275 LogError(
"TriggerSummaryProducerAOD")
276 <<
"Mismatch in number of filter tags: " 289 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of unique collections requested " << nc;
292 for ( InputTagSet::const_iterator ci=cb; ci!=ce; ++ci) {
293 LogTrace(
"TriggerSummaryProducerAOD") <<
distance(cb,ci) <<
" " << ci->encode();
296 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of unique filters requested " << nf;
299 for ( InputTagSet::const_iterator fi=
fb; fi!=fe; ++fi) {
338 const unsigned int nk(
tags_.size());
339 LogDebug(
"TriggerSummaryProducerAOD") <<
"Number of collections found: " << nk;
340 const unsigned int no(
toc_.size());
341 LogDebug(
"TriggerSummaryProducerAOD") <<
"Number of physics objects found: " << no;
349 product->addObjects(
toc_);
352 for (
unsigned int ifob=0; ifob!=nfob; ++ifob) {
354 const string&
label (fobs[ifob].provenance()->moduleLabel());
355 const string&
instance (fobs[ifob].provenance()->productInstanceName());
381 product->addFilter(filterTag,
ids_,
keys_);
386 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of physics objects packed: " << ref->
sizeObjects();
387 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of filter objects packed: " << ref->
sizeFilters();
391 template <
typename C>
400 using namespace reco;
405 vector<Handle<C> > collections;
407 const unsigned int nc(collections.size());
409 for (
unsigned int ic=0; ic!=nc; ++ic) {
410 const Provenance& provenance(*(collections[ic].provenance()));
417 const ProductID pid(collections[ic].provenance()->productID());
419 LogError(
"TriggerSummaryProducerAOD") <<
"Duplicate pid: " <<
pid;
422 const unsigned int n(collections[ic]->
size());
423 for (
unsigned int i=0;
i!=
n; ++
i) {
426 tags_.push_back(collectionTag.encode());
433 template <
typename T>
448 object.hfEtSum(L1HFRings::kRing1PosEta),
449 object.hfEtSum(L1HFRings::kRing1NegEta),
450 object.hfEtSum(L1HFRings::kRing2PosEta),
451 object.hfEtSum(L1HFRings::kRing2NegEta) ) );
453 object.hfBitCount(L1HFRings::kRing1PosEta),
454 object.hfBitCount(L1HFRings::kRing1NegEta),
455 object.hfBitCount(L1HFRings::kRing2PosEta),
456 object.hfBitCount(L1HFRings::kRing2NegEta) ) );
467 if (
object.
type()==L1EtMissParticle::kMET) {
469 }
else if (
object.
type()==L1EtMissParticle::kMHT) {
480 using namespace reco;
493 using namespace reco;
506 using namespace reco;
517 template <
typename C>
526 using namespace reco;
530 if (ids.size()!=refs.size()) {
531 LogError(
"TriggerSummaryProducerAOD") <<
"Vector length is different: " 532 << ids.size() <<
" " << refs.size();
535 const unsigned int n(
min(ids.size(),refs.size()));
536 for (
unsigned int i=0;
i!=
n; ++
i) {
539 std::ostringstream ost;
541 <<
"Iinvalid pid: " << pid
542 <<
" FilterTag / Key: " << tag.
encode()
543 <<
" / " <<
i <<
"of" << n
544 <<
" CollectionTag / Key: " 545 <<
" <Unrecoverable>" 546 <<
" / " << refs[
i].key()
547 <<
" CollectionType: " <<
typeid(
C).
name();
551 LogError(
"TriggerSummaryProducerAOD") << ost.str();
557 std::ostringstream ost;
559 <<
"Uunknown pid: " << pid
560 <<
" FilterTag / Key: " << tag.
encode()
561 <<
" / " <<
i <<
"of" << n
562 <<
" CollectionTag / Key: " 564 <<
" / " << refs[
i].key()
565 <<
" CollectionType: " <<
typeid(
C).
name();
569 LogError(
"TriggerSummaryProducerAOD") << ost.str();
579 template <
typename C>
593 keys_.push_back(offset+2*ref.
key()+1);
595 keys_.push_back(offset+2*ref.
key()+0);
607 keys_.push_back(offset+2*ref.
key()+1);
609 keys_.push_back(offset+2*ref.
key()+0);
621 keys_.push_back(offset+4*ref.
key()+1);
623 keys_.push_back(offset+4*ref.
key()+2);
625 keys_.push_back(offset+4*ref.
key()+3);
627 keys_.push_back(offset+4*ref.
key()+0);
639 keys_.push_back(offset+4*ref.
key()+1);
641 keys_.push_back(offset+4*ref.
key()+2);
643 keys_.push_back(offset+4*ref.
key()+3);
645 keys_.push_back(offset+4*ref.
key()+0);
657 keys_.push_back(offset+4*ref.
key()+1);
659 keys_.push_back(offset+4*ref.
key()+2);
661 keys_.push_back(offset+4*ref.
key()+3);
663 keys_.push_back(offset+4*ref.
key()+0);
683 LogVerbatim(
"TriggerSummaryProducerAOD") <<
"TriggerSummaryProducerAOD::globalEndJob - accumulated tags:" << endl;
691 const unsigned int nc(collectionTags.size());
692 const unsigned int nf(filterTags.size());
693 LogVerbatim(
"TriggerSummaryProducerAOD") <<
" Overall number of Collections/Filters: " 694 << nc <<
"/" << nf << endl;
696 LogVerbatim(
"TriggerSummaryProducerAOD") <<
" The collections: " << nc << endl;
697 const InputTagSet::const_iterator cb(collectionTags.begin());
698 const InputTagSet::const_iterator ce(collectionTags.end());
699 for ( InputTagSet::const_iterator ci=cb; ci!=ce; ++ci) {
700 LogVerbatim(
"TriggerSummaryProducerAOD") <<
" " <<
distance(cb,ci) <<
" " << ci->encode() << endl;
703 LogVerbatim(
"TriggerSummaryProducerAOD") <<
" The filters:" << nf << endl;
704 const InputTagSet::const_iterator
fb(filterTags.begin());
705 const InputTagSet::const_iterator fe(filterTags.end());
706 for ( InputTagSet::const_iterator fi=
fb; fi!=fe; ++fi) {
710 LogVerbatim(
"TriggerSummaryProducerAOD") <<
"TriggerSummaryProducerAOD::endJob." << endl;
~TriggerSummaryProducerAOD() override
void produce(edm::Event &, const edm::EventSetup &) override
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_
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
bool throw_
throw on error
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
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_