File indexing completed on 2024-09-07 04:36:37
0001 #ifndef HLTcore_TriggerSummaryProducerAOD_h
0002 #define HLTcore_TriggerSummaryProducerAOD_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include "FWCore/Framework/interface/Event.h"
0015 #include "FWCore/Framework/interface/global/EDProducer.h"
0016 #include "FWCore/Framework/interface/GetterOfProducts.h"
0017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0018 #include "FWCore/Utilities/interface/InputTag.h"
0019 #include "DataFormats/Common/interface/Ref.h"
0020 #include "DataFormats/Provenance/interface/ProductID.h"
0021
0022 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
0023 #include "DataFormats/HLTReco/interface/TriggerObject.h"
0024 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0025
0026 #include "DataFormats/L1Trigger/interface/L1HFRingsFwd.h"
0027 #include "DataFormats/L1Trigger/interface/L1EtMissParticleFwd.h"
0028 #include "DataFormats/METReco/interface/METFwd.h"
0029 #include "DataFormats/METReco/interface/CaloMETFwd.h"
0030 #include "DataFormats/METReco/interface/PFMETFwd.h"
0031
0032 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateFwd.h"
0033 #include "DataFormats/EgammaCandidates/interface/ElectronFwd.h"
0034 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
0035 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
0036 #include "DataFormats/Candidate/interface/CompositeCandidateFwd.h"
0037 #include "DataFormats/METReco/interface/METCollection.h"
0038 #include "DataFormats/METReco/interface/CaloMETCollection.h"
0039 #include "DataFormats/METReco/interface/PFMETCollection.h"
0040 #include "DataFormats/HcalIsolatedTrack/interface/IsolatedPixelTrackCandidateFwd.h"
0041 #include "DataFormats/L1Trigger/interface/L1EmParticleFwd.h"
0042 #include "DataFormats/L1Trigger/interface/L1MuonParticleFwd.h"
0043 #include "DataFormats/L1Trigger/interface/L1JetParticleFwd.h"
0044 #include "DataFormats/L1Trigger/interface/L1EtMissParticleFwd.h"
0045 #include "DataFormats/L1Trigger/interface/L1HFRingsFwd.h"
0046 #include "DataFormats/L1Trigger/interface/P2GTCandidate.h"
0047 #include "DataFormats/JetReco/interface/PFJetCollection.h"
0048 #include "DataFormats/TauReco/interface/PFTauFwd.h"
0049
0050 #include "DataFormats/L1TMuonPhase2/interface/TrackerMuon.h"
0051 #include "DataFormats/L1TCorrelator/interface/TkElectron.h"
0052 #include "DataFormats/L1TCorrelator/interface/TkEm.h"
0053 #include "DataFormats/L1TParticleFlow/interface/PFJet.h"
0054 #include "DataFormats/L1TParticleFlow/interface/PFTau.h"
0055 #include "DataFormats/L1TParticleFlow/interface/HPSPFTau.h"
0056 #include "DataFormats/L1TParticleFlow/interface/HPSPFTauFwd.h"
0057 #include "DataFormats/L1TParticleFlow/interface/PFTrack.h"
0058
0059 #include <map>
0060 #include <set>
0061 #include <string>
0062 #include <vector>
0063
0064 #include <functional>
0065 #include "oneapi/tbb/concurrent_unordered_set.h"
0066 #include <regex>
0067
0068 namespace edm {
0069 class EventSetup;
0070 }
0071
0072 namespace edm {
0073 class ConfigurationDescriptions;
0074 }
0075
0076
0077
0078
0079
0080
0081 struct InputTagHash {
0082 std::size_t operator()(const edm::InputTag& inputTag) const {
0083 std::hash<std::string> Hash;
0084
0085 return Hash(inputTag.label()) ^ Hash(inputTag.instance()) ^ Hash(inputTag.process());
0086 }
0087 };
0088 class TriggerSummaryProducerAOD : public edm::global::EDProducer<> {
0089 public:
0090 explicit TriggerSummaryProducerAOD(const edm::ParameterSet&);
0091 ~TriggerSummaryProducerAOD() override;
0092 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0093 void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0094 void endJob() override;
0095
0096 private:
0097
0098 struct OrderInputTag {
0099 bool ignoreProcess_;
0100 OrderInputTag(bool ignoreProcess) : ignoreProcess_(ignoreProcess) {}
0101 inline bool operator()(const edm::InputTag& l, const edm::InputTag& r) const {
0102 int c = l.label().compare(r.label());
0103 if (0 == c) {
0104 if (ignoreProcess_) {
0105 return l.instance() < r.instance();
0106 }
0107 c = l.instance().compare(r.instance());
0108 if (0 == c) {
0109 return l.process() < r.process();
0110 }
0111 }
0112 return c < 0;
0113 };
0114 };
0115
0116 using ProductIDtoIndex = std::map<edm::ProductID, unsigned int>;
0117 using InputTagSet = std::set<edm::InputTag, OrderInputTag>;
0118 template <typename C>
0119 void fillTriggerObjectCollections(trigger::TriggerObjectCollection&,
0120 ProductIDtoIndex&,
0121 std::vector<std::string>&,
0122 trigger::Keys&,
0123 const edm::Event&,
0124 const edm::GetterOfProducts<C>&,
0125 const InputTagSet&) const;
0126
0127 template <typename T>
0128 void fillTriggerObject(trigger::TriggerObjectCollection&, const T&) const;
0129 void fillTriggerObject(trigger::TriggerObjectCollection&, const l1extra::L1HFRings&) const;
0130 void fillTriggerObject(trigger::TriggerObjectCollection&, const l1extra::L1EtMissParticle&) const;
0131 void fillTriggerObject(trigger::TriggerObjectCollection&, const reco::PFMET&) const;
0132 void fillTriggerObject(trigger::TriggerObjectCollection&, const reco::CaloMET&) const;
0133 void fillTriggerObject(trigger::TriggerObjectCollection&, const reco::MET&) const;
0134
0135 template <typename C>
0136 void fillFilterObjectMembers(const edm::Event&,
0137 const edm::InputTag& tag,
0138 const trigger::Vids&,
0139 const std::vector<edm::Ref<C>>&,
0140 const ProductIDtoIndex&,
0141 trigger::Keys& keys,
0142 trigger::Vids& oIds) const;
0143
0144 template <typename C>
0145 void fillFilterObjectMember(trigger::Keys& keys, trigger::Vids& ids, const int&, const int&, const edm::Ref<C>&) const;
0146 void fillFilterObjectMember(trigger::Keys& keys,
0147 trigger::Vids& ids,
0148 const int&,
0149 const int&,
0150 const edm::Ref<l1extra::L1HFRingsCollection>&) const;
0151 void fillFilterObjectMember(trigger::Keys& keys,
0152 trigger::Vids& ids,
0153 const int&,
0154 const int&,
0155 const edm::Ref<l1extra::L1EtMissParticleCollection>&) const;
0156 void fillFilterObjectMember(
0157 trigger::Keys& keys, trigger::Vids& ids, const int&, const int&, const edm::Ref<reco::PFMETCollection>&) const;
0158 void fillFilterObjectMember(
0159 trigger::Keys& keys, trigger::Vids& ids, const int&, const int&, const edm::Ref<reco::CaloMETCollection>&) const;
0160 void fillFilterObjectMember(
0161 trigger::Keys& keys, trigger::Vids& ids, const int&, const int&, const edm::Ref<reco::METCollection>&) const;
0162
0163
0164 const bool throw_;
0165
0166 std::string pn_;
0167
0168 std::vector<std::regex> moduleLabelPatternsToMatch_;
0169 std::vector<std::regex> moduleLabelPatternsToSkip_;
0170
0171
0172 mutable tbb::concurrent_unordered_set<edm::InputTag, InputTagHash> filterTagsGlobal_;
0173
0174
0175 mutable tbb::concurrent_unordered_set<edm::InputTag, InputTagHash> collectionTagsGlobal_;
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191 edm::GetterOfProducts<trigger::TriggerFilterObjectWithRefs> getTriggerFilterObjectWithRefs_;
0192 edm::GetterOfProducts<reco::RecoEcalCandidateCollection> getRecoEcalCandidateCollection_;
0193 edm::GetterOfProducts<reco::ElectronCollection> getElectronCollection_;
0194 edm::GetterOfProducts<reco::RecoChargedCandidateCollection> getRecoChargedCandidateCollection_;
0195 edm::GetterOfProducts<reco::CaloJetCollection> getCaloJetCollection_;
0196 edm::GetterOfProducts<reco::CompositeCandidateCollection> getCompositeCandidateCollection_;
0197 edm::GetterOfProducts<reco::METCollection> getMETCollection_;
0198 edm::GetterOfProducts<reco::CaloMETCollection> getCaloMETCollection_;
0199 edm::GetterOfProducts<reco::PFMETCollection> getPFMETCollection_;
0200 edm::GetterOfProducts<reco::IsolatedPixelTrackCandidateCollection> getIsolatedPixelTrackCandidateCollection_;
0201 edm::GetterOfProducts<l1extra::L1EmParticleCollection> getL1EmParticleCollection_;
0202 edm::GetterOfProducts<l1extra::L1MuonParticleCollection> getL1MuonParticleCollection_;
0203 edm::GetterOfProducts<l1extra::L1JetParticleCollection> getL1JetParticleCollection_;
0204 edm::GetterOfProducts<l1extra::L1EtMissParticleCollection> getL1EtMissParticleCollection_;
0205 edm::GetterOfProducts<l1extra::L1HFRingsCollection> getL1HFRingsCollection_;
0206 edm::GetterOfProducts<reco::PFJetCollection> getPFJetCollection_;
0207 edm::GetterOfProducts<reco::PFTauCollection> getPFTauCollection_;
0208 edm::GetterOfProducts<l1t::MuonBxCollection> getL1TMuonParticleCollection_;
0209 edm::GetterOfProducts<l1t::MuonShowerBxCollection> getL1TMuonShowerParticleCollection_;
0210 edm::GetterOfProducts<l1t::EGammaBxCollection> getL1TEGammaParticleCollection_;
0211 edm::GetterOfProducts<l1t::JetBxCollection> getL1TJetParticleCollection_;
0212 edm::GetterOfProducts<l1t::TauBxCollection> getL1TTauParticleCollection_;
0213 edm::GetterOfProducts<l1t::EtSumBxCollection> getL1TEtSumParticleCollection_;
0214 edm::GetterOfProducts<l1t::TrackerMuonCollection> getL1TTkMuonCollection_;
0215 edm::GetterOfProducts<l1t::TkElectronCollection> getL1TTkElectronCollection_;
0216 edm::GetterOfProducts<l1t::TkEmCollection> getL1TTkEmCollection_;
0217 edm::GetterOfProducts<l1t::PFJetCollection> getL1TPFJetCollection_;
0218 edm::GetterOfProducts<l1t::PFTauCollection> getL1TPFTauCollection_;
0219 edm::GetterOfProducts<l1t::HPSPFTauCollection> getL1THPSPFTauCollection_;
0220 edm::GetterOfProducts<l1t::PFTrackCollection> getL1TPFTrackCollection_;
0221 edm::GetterOfProducts<l1t::P2GTCandidateCollection> getL1TP2GTCandCollection_;
0222 };
0223 #endif