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_(
80 convertToRegex(ps.getParameter<
std::vector<
std::
string>>(
"moduleLabelPatternsToMatch"))),
81 moduleLabelPatternsToSkip_(
82 convertToRegex(ps.getParameter<
std::vector<
std::
string>>(
"moduleLabelPatternsToSkip"))),
83 filterTagsEvent_(pn_ !=
"*"),
84 filterTagsStream_(pn_ !=
"*"),
85 collectionTagsEvent_(pn_ !=
"*"),
86 collectionTagsStream_(pn_ !=
"*"),
98 edm::LogError(
"TriggerSummaryProducerAOD") <<
"HLT Error: TriggerNamesService not available!";
107 LogDebug(
"TriggerSummaryProducerAOD") <<
"Using process name: '" <<
pn_ <<
"'";
112 produces<trigger::TriggerEvent>();
114 auto const* pProcessName = &
pn_;
119 if (iBranch.processName() == *pProcessName || *pProcessName ==
"*") {
120 auto const&
label = iBranch.moduleLabel();
124 for (
auto& reject : moduleLabelPatternsToSkip) {
125 if (std::regex_match(
label, reject)) {
196 const char token(
':');
201 if (
i1 == string::npos) {
205 instance = label.substr(
i1 + 1);
208 if (
i2 == string::npos) {
211 process = instance.substr(
i2 + 1);
220 desc.
add<
bool>(
"throw",
false)->setComment(
"Throw exception or LogError");
223 "Process name to use when getting data. The value of '@' is used to denote the current process name.");
224 desc.
add<std::vector<std::string>>(
"moduleLabelPatternsToMatch", std::vector<std::string>(1,
"hlt*"))
225 ->
setComment(
"glob patterns for module labels to get data.");
226 desc.
add<std::vector<std::string>>(
"moduleLabelPatternsToSkip", std::vector<std::string>())
227 ->
setComment(
"module labels for data products which should not be gotten.");
228 descriptions.
add(
"triggerSummaryProducerAOD", desc);
235 using namespace reco;
240 std::vector<edm::Handle<trigger::TriggerFilterObjectWithRefs>> fobs;
243 const unsigned int nfob(fobs.size());
244 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of filter objects found: " << nfob;
246 string tagLabel, tagInstance, tagProcess;
258 for (
unsigned int ifob = 0; ifob != nfob; ++ifob) {
260 const vector<string>& collectionTags_(fobs[ifob]->getCollectionTagsAsStrings());
261 const unsigned int ncol(collectionTags_.size());
266 const string&
instance(fobs[ifob].provenance()->productInstanceName());
269 for (
unsigned int icol = 0; icol != ncol; ++icol) {
271 tokenizeTag(collectionTags_[icol], tagLabel, tagInstance, tagProcess);
278 LogError(
"TriggerSummaryProducerAOD")
279 <<
"Mismatch in number of filter tags: " <<
filterTagsEvent_.size() <<
"!=" << nf;
290 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of unique collections requested " << nc;
293 for (InputTagSet::const_iterator ci = cb; ci != ce; ++ci) {
294 LogTrace(
"TriggerSummaryProducerAOD") <<
distance(cb, ci) <<
" " << ci->encode();
297 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of unique filters requested " << nf;
300 for (InputTagSet::const_iterator fi =
fb; fi != fe; ++fi) {
321 fillTriggerObjectCollections<IsolatedPixelTrackCandidateCollection>(
iEvent,
339 const unsigned int nk(
tags_.size());
340 LogDebug(
"TriggerSummaryProducerAOD") <<
"Number of collections found: " << nk;
341 const unsigned int no(
toc_.size());
342 LogDebug(
"TriggerSummaryProducerAOD") <<
"Number of physics objects found: " << no;
350 product->addObjects(
toc_);
353 for (
unsigned int ifob = 0; ifob != nfob; ++ifob) {
356 const string&
instance(fobs[ifob].provenance()->productInstanceName());
382 product->addFilter(filterTag,
ids_,
keys_);
387 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of physics objects packed: " << ref->
sizeObjects();
388 LogTrace(
"TriggerSummaryProducerAOD") <<
"Number of filter objects packed: " << ref->
sizeFilters();
391 template <
typename C>
400 using namespace reco;
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>
446 object.hfEtSum(L1HFRings::kRing1PosEta),
447 object.hfEtSum(L1HFRings::kRing1NegEta),
448 object.hfEtSum(L1HFRings::kRing2PosEta),
449 object.hfEtSum(L1HFRings::kRing2NegEta)));
451 object.hfBitCount(L1HFRings::kRing1PosEta),
452 object.hfBitCount(L1HFRings::kRing1NegEta),
453 object.hfBitCount(L1HFRings::kRing2PosEta),
454 object.hfBitCount(L1HFRings::kRing2NegEta)));
464 if (
object.
type() == L1EtMissParticle::kMET) {
466 }
else if (
object.
type() == L1EtMissParticle::kMHT) {
476 using namespace reco;
488 using namespace reco;
500 using namespace reco;
511 template <
typename C>
522 using namespace reco;
526 if (ids.size() != refs.size()) {
527 LogError(
"TriggerSummaryProducerAOD") <<
"Vector length is different: " << ids.size() <<
" " << refs.size();
530 const unsigned int n(
min(ids.size(), refs.size()));
531 for (
unsigned int i = 0;
i !=
n; ++
i) {
534 std::ostringstream ost;
535 ost <<
"Iinvalid pid: " << pid <<
" FilterTag / Key: " << tag.
encode() <<
" / " <<
i <<
"of" << n
536 <<
" CollectionTag / Key: " 537 <<
" <Unrecoverable>" 538 <<
" / " << refs[
i].key() <<
" CollectionType: " <<
typeid(
C).
name();
542 LogError(
"TriggerSummaryProducerAOD") << ost.str();
548 std::ostringstream ost;
549 ost <<
"Uunknown pid: " << pid <<
" FilterTag / Key: " << tag.
encode() <<
" / " <<
i <<
"of" << n
551 <<
" CollectionType: " <<
typeid(
C).
name();
555 LogError(
"TriggerSummaryProducerAOD") << ost.str();
564 template <
typename C>
566 keys_.push_back(offset + ref.
key());
578 keys_.push_back(offset + 2 * ref.
key() + 1);
580 keys_.push_back(offset + 2 * ref.
key() + 0);
593 keys_.push_back(offset + 2 * ref.
key() + 1);
595 keys_.push_back(offset + 2 * ref.
key() + 0);
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);
627 keys_.push_back(offset + 4 * ref.
key() + 1);
629 keys_.push_back(offset + 4 * ref.
key() + 2);
631 keys_.push_back(offset + 4 * ref.
key() + 3);
633 keys_.push_back(offset + 4 * ref.
key() + 0);
646 keys_.push_back(offset + 4 * ref.
key() + 1);
648 keys_.push_back(offset + 4 * ref.
key() + 2);
650 keys_.push_back(offset + 4 * ref.
key() + 3);
652 keys_.push_back(offset + 4 * ref.
key() + 0);
671 LogVerbatim(
"TriggerSummaryProducerAOD") <<
"TriggerSummaryProducerAOD::globalEndJob - accumulated tags:" << endl;
679 const unsigned int nc(collectionTags.size());
680 const unsigned int nf(filterTags.size());
681 LogVerbatim(
"TriggerSummaryProducerAOD") <<
" Overall number of Collections/Filters: " << 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;
~TriggerSummaryProducerAOD() override
void produce(edm::Event &, const edm::EventSetup &) override
void setComment(std::string const &value)
moduleLabelPatternsToSkip
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_
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_
bool throw_
throw on error
void fillHandles(edm::Event const &event, std::vector< edm::Handle< T >> &handles) const
void fillFilterObjectMembers(const edm::Event &, const edm::InputTag &tag, const trigger::Vids &, const std::vector< edm::Ref< C >> &)
std::map< edm::ProductID, unsigned int > offset_
global map for indices into toc_: offset per input L3 collection
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
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::set< edm::InputTag, OrderInputTag > InputTagSet
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
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_
moduleLabelPatternsToMatch
edm::GetterOfProducts< l1t::EGammaBxCollection > getL1TEGammaParticleCollection_