File indexing completed on 2024-04-06 12:18:31
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef HLTrigger_JetMET_plugins_HLTJetTimingFilter_h
0009 #define HLTrigger_JetMET_plugins_HLTJetTimingFilter_h
0010
0011 #include <memory>
0012
0013 #include "FWCore/Framework/interface/Frameworkfwd.h"
0014 #include "FWCore/Framework/interface/Event.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0016 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0017 #include "HLTrigger/HLTcore/interface/HLTFilter.h"
0018 #include "HLTrigger/HLTcore/interface/defaultModuleLabel.h"
0019
0020 template <typename T>
0021 class HLTJetTimingFilter : public HLTFilter {
0022 public:
0023 explicit HLTJetTimingFilter(const edm::ParameterSet& iConfig);
0024 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0025 bool hltFilter(edm::Event&,
0026 const edm::EventSetup&,
0027 trigger::TriggerFilterObjectWithRefs& filterproduct) const override;
0028
0029 private:
0030
0031 const edm::InputTag jetInput_;
0032 const edm::EDGetTokenT<std::vector<T>> jetInputToken_;
0033 const edm::EDGetTokenT<edm::ValueMap<float>> jetTimesInputToken_;
0034 const edm::EDGetTokenT<edm::ValueMap<unsigned int>> jetCellsForTimingInputToken_;
0035 const edm::EDGetTokenT<edm::ValueMap<float>> jetEcalEtForTimingInputToken_;
0036
0037
0038 const unsigned int minJets_;
0039 const double jetTimeThresh_;
0040 const double jetMaxTimeThresh_;
0041 const double jetEcalEtForTimingThresh_;
0042 const unsigned int jetCellsForTimingThresh_;
0043 const double minPt_;
0044 };
0045
0046 template <typename T>
0047 HLTJetTimingFilter<T>::HLTJetTimingFilter(const edm::ParameterSet& iConfig)
0048 : HLTFilter(iConfig),
0049 jetInput_{iConfig.getParameter<edm::InputTag>("jets")},
0050 jetInputToken_{consumes<std::vector<T>>(jetInput_)},
0051 jetTimesInputToken_{consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("jetTimes"))},
0052 jetCellsForTimingInputToken_{
0053 consumes<edm::ValueMap<unsigned int>>(iConfig.getParameter<edm::InputTag>("jetCellsForTiming"))},
0054 jetEcalEtForTimingInputToken_{
0055 consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("jetEcalEtForTiming"))},
0056 minJets_{iConfig.getParameter<unsigned int>("minJets")},
0057 jetTimeThresh_{iConfig.getParameter<double>("jetTimeThresh")},
0058 jetMaxTimeThresh_{iConfig.getParameter<double>("jetMaxTimeThresh")},
0059 jetEcalEtForTimingThresh_{iConfig.getParameter<double>("jetEcalEtForTimingThresh")},
0060 jetCellsForTimingThresh_{iConfig.getParameter<unsigned int>("jetCellsForTimingThresh")},
0061 minPt_{iConfig.getParameter<double>("minJetPt")} {}
0062
0063 template <typename T>
0064 bool HLTJetTimingFilter<T>::hltFilter(edm::Event& iEvent,
0065 const edm::EventSetup& iSetup,
0066 trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0067 if (saveTags())
0068 filterproduct.addCollectionTag(jetInput_);
0069
0070 auto const jets = iEvent.getHandle(jetInputToken_);
0071 auto const& jetTimes = iEvent.get(jetTimesInputToken_);
0072 auto const& jetCellsForTiming = iEvent.get(jetCellsForTimingInputToken_);
0073 auto const& jetEcalEtForTiming = iEvent.get(jetEcalEtForTimingInputToken_);
0074
0075 uint njets = 0;
0076 for (auto iterJet = jets->begin(); iterJet != jets->end(); ++iterJet) {
0077 edm::Ref<std::vector<T>> const caloJetRef(jets, std::distance(jets->begin(), iterJet));
0078 if (iterJet->pt() > minPt_ and jetTimes[caloJetRef] > jetTimeThresh_ and
0079 jetTimes[caloJetRef] < jetMaxTimeThresh_ and jetEcalEtForTiming[caloJetRef] > jetEcalEtForTimingThresh_ and
0080 jetCellsForTiming[caloJetRef] > jetCellsForTimingThresh_) {
0081
0082 filterproduct.addObject(trigger::TriggerJet, caloJetRef);
0083 ++njets;
0084 }
0085 }
0086
0087 return njets >= minJets_;
0088 }
0089
0090 template <typename T>
0091 void HLTJetTimingFilter<T>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0092 edm::ParameterSetDescription desc;
0093 makeHLTFilterDescription(desc);
0094 desc.add<edm::InputTag>("jets", edm::InputTag("hltDisplacedHLTCaloJetCollectionProducerMidPt"));
0095 desc.add<edm::InputTag>("jetTimes", edm::InputTag("hltDisplacedHLTCaloJetCollectionProducerMidPtTiming"));
0096 desc.add<edm::InputTag>("jetCellsForTiming",
0097 edm::InputTag("hltDisplacedHLTCaloJetCollectionProducerMidPtTiming", "jetCellsForTiming"));
0098 desc.add<edm::InputTag>("jetEcalEtForTiming",
0099 edm::InputTag("hltDisplacedHLTCaloJetCollectionProducerMidPtTiming", "jetEcalEtForTiming"));
0100 desc.add<unsigned int>("minJets", 1);
0101 desc.add<double>("jetTimeThresh", 1.);
0102 desc.add<double>("jetMaxTimeThresh", 999999);
0103 desc.add<unsigned int>("jetCellsForTimingThresh", 5);
0104 desc.add<double>("jetEcalEtForTimingThresh", 10.);
0105 desc.add<double>("minJetPt", 40.);
0106 descriptions.add(defaultModuleLabel<HLTJetTimingFilter<T>>(), desc);
0107 }
0108
0109 #endif