Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-05 00:07:57

0001 /** \class HLTJetTimingFilter
0002  *
0003  *  \brief  This makes selections on the timing and associated ecal cells 
0004  *          produced by HLTJetTimingProducer
0005  *  \author Matthew Citron
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   // Input collections
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   // Thresholds for selection
0038   const unsigned int minJets_;
0039   const double jetTimeThresh_;
0040   const double jetEcalEtForTimingThresh_;
0041   const unsigned int jetCellsForTimingThresh_;
0042   const double minPt_;
0043 };
0044 
0045 template <typename T>
0046 HLTJetTimingFilter<T>::HLTJetTimingFilter(const edm::ParameterSet& iConfig)
0047     : HLTFilter(iConfig),
0048       jetInput_{iConfig.getParameter<edm::InputTag>("jets")},
0049       jetInputToken_{consumes<std::vector<T>>(jetInput_)},
0050       jetTimesInputToken_{consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("jetTimes"))},
0051       jetCellsForTimingInputToken_{
0052           consumes<edm::ValueMap<unsigned int>>(iConfig.getParameter<edm::InputTag>("jetCellsForTiming"))},
0053       jetEcalEtForTimingInputToken_{
0054           consumes<edm::ValueMap<float>>(iConfig.getParameter<edm::InputTag>("jetEcalEtForTiming"))},
0055       minJets_{iConfig.getParameter<unsigned int>("minJets")},
0056       jetTimeThresh_{iConfig.getParameter<double>("jetTimeThresh")},
0057       jetEcalEtForTimingThresh_{iConfig.getParameter<double>("jetEcalEtForTimingThresh")},
0058       jetCellsForTimingThresh_{iConfig.getParameter<unsigned int>("jetCellsForTimingThresh")},
0059       minPt_{iConfig.getParameter<double>("minJetPt")} {}
0060 
0061 template <typename T>
0062 bool HLTJetTimingFilter<T>::hltFilter(edm::Event& iEvent,
0063                                       const edm::EventSetup& iSetup,
0064                                       trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0065   if (saveTags())
0066     filterproduct.addCollectionTag(jetInput_);
0067 
0068   auto const jets = iEvent.getHandle(jetInputToken_);
0069   auto const& jetTimes = iEvent.get(jetTimesInputToken_);
0070   auto const& jetCellsForTiming = iEvent.get(jetCellsForTimingInputToken_);
0071   auto const& jetEcalEtForTiming = iEvent.get(jetEcalEtForTimingInputToken_);
0072 
0073   uint njets = 0;
0074   for (auto iterJet = jets->begin(); iterJet != jets->end(); ++iterJet) {
0075     edm::Ref<std::vector<T>> const caloJetRef(jets, std::distance(jets->begin(), iterJet));
0076     if (iterJet->pt() > minPt_ and jetTimes[caloJetRef] > jetTimeThresh_ and
0077         jetEcalEtForTiming[caloJetRef] > jetEcalEtForTimingThresh_ and
0078         jetCellsForTiming[caloJetRef] > jetCellsForTimingThresh_) {
0079       // add caloJetRef to the event
0080       filterproduct.addObject(trigger::TriggerJet, caloJetRef);
0081       ++njets;
0082     }
0083   }
0084 
0085   return njets >= minJets_;
0086 }
0087 
0088 template <typename T>
0089 void HLTJetTimingFilter<T>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0090   edm::ParameterSetDescription desc;
0091   makeHLTFilterDescription(desc);
0092   desc.add<edm::InputTag>("jets", edm::InputTag("hltDisplacedHLTCaloJetCollectionProducerMidPt"));
0093   desc.add<edm::InputTag>("jetTimes", edm::InputTag("hltDisplacedHLTCaloJetCollectionProducerMidPtTiming"));
0094   desc.add<edm::InputTag>("jetCellsForTiming",
0095                           edm::InputTag("hltDisplacedHLTCaloJetCollectionProducerMidPtTiming", "jetCellsForTiming"));
0096   desc.add<edm::InputTag>("jetEcalEtForTiming",
0097                           edm::InputTag("hltDisplacedHLTCaloJetCollectionProducerMidPtTiming", "jetEcalEtForTiming"));
0098   desc.add<unsigned int>("minJets", 1);
0099   desc.add<double>("jetTimeThresh", 1.);
0100   desc.add<unsigned int>("jetCellsForTimingThresh", 5);
0101   desc.add<double>("jetEcalEtForTimingThresh", 10.);
0102   desc.add<double>("minJetPt", 40.);
0103   descriptions.add(defaultModuleLabel<HLTJetTimingFilter<T>>(), desc);
0104 }
0105 
0106 #endif  // HLTrigger_JetMET_plugins_HLTJetTimingFilter_h