Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:20:32

0001 /** \class HLTJetEtaTopologyFilter
0002  *
0003  *
0004  *  \author Tomasz Fruboes
0005  *     based on HLTDiJetAveFilter
0006  */
0007 
0008 #include "HLTrigger/JetMET/interface/HLTJetEtaTopologyFilter.h"
0009 
0010 #include "DataFormats/Common/interface/Ref.h"
0011 #include "DataFormats/Common/interface/Handle.h"
0012 #include "DataFormats/Math/interface/deltaPhi.h"
0013 
0014 #include "FWCore/Framework/interface/ESHandle.h"
0015 #include "FWCore/Framework/interface/EventSetup.h"
0016 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0017 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0018 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0020 #include "FWCore/Utilities/interface/InputTag.h"
0021 #include "HLTrigger/HLTcore/interface/defaultModuleLabel.h"
0022 
0023 #include <typeinfo>
0024 
0025 //
0026 // constructors and destructor
0027 //
0028 template <typename T>
0029 HLTJetEtaTopologyFilter<T>::HLTJetEtaTopologyFilter(const edm::ParameterSet& iConfig)
0030     : HLTFilter(iConfig),
0031       inputJetTag_(iConfig.template getParameter<edm::InputTag>("inputJetTag")),
0032       m_theJetToken(consumes<std::vector<T>>(inputJetTag_)),
0033       minPtJet_(iConfig.template getParameter<double>("minPtJet")),
0034       //minPtJet3_   (iConfig.template getParameter<double> ("minPtJet3")),
0035       jetEtaMin_(iConfig.template getParameter<double>("minJetEta")),
0036       jetEtaMax_(iConfig.template getParameter<double>("maxJetEta")),
0037       applyAbsToJet_(iConfig.template getParameter<bool>("applyAbsToJet")),
0038 
0039       triggerType_(iConfig.template getParameter<int>("triggerType")) {
0040   LogDebug("") << "HLTJetEtaTopologyFilter: Input/minDphi/triggerType : " << inputJetTag_.encode() << " "
0041                << triggerType_;
0042 }
0043 
0044 template <typename T>
0045 HLTJetEtaTopologyFilter<T>::~HLTJetEtaTopologyFilter() = default;
0046 
0047 template <typename T>
0048 void HLTJetEtaTopologyFilter<T>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0049   edm::ParameterSetDescription desc;
0050   makeHLTFilterDescription(desc);
0051   desc.add<edm::InputTag>("inputJetTag", edm::InputTag("hltIterativeCone5CaloJets"));
0052   desc.add<double>("minPtJet", 50.0);
0053   //desc.add<double>("minPtJet3",99999.0);
0054   desc.add<double>("minJetEta", -1.);
0055   desc.add<double>("maxJetEta", 1.4);
0056   desc.add<bool>("applyAbsToJet", false), desc.add<int>("triggerType", trigger::TriggerJet);
0057   descriptions.add(defaultModuleLabel<HLTJetEtaTopologyFilter<T>>(), desc);
0058 }
0059 
0060 // ------------ method called to produce the data  ------------
0061 template <typename T>
0062 bool HLTJetEtaTopologyFilter<T>::hltFilter(edm::Event& iEvent,
0063                                            const edm::EventSetup& iSetup,
0064                                            trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0065   using namespace std;
0066   using namespace edm;
0067   using namespace reco;
0068   using namespace trigger;
0069 
0070   typedef vector<T> TCollection;
0071   typedef Ref<TCollection> TRef;
0072 
0073   // The filter object
0074   if (saveTags())
0075     filterproduct.addCollectionTag(inputJetTag_);
0076 
0077   // get hold of collection of objects
0078   Handle<TCollection> objects;
0079   iEvent.getByToken(m_theJetToken, objects);
0080 
0081   int n(0);
0082 
0083   if (!objects->empty()) {  // events with two or more jets
0084     typename TCollection::const_iterator iEnd(objects->end());
0085     typename TCollection::const_iterator iJet(objects->begin());
0086     for (; iJet != iEnd; ++iJet) {
0087       if (iJet->pt() < minPtJet_)
0088         continue;
0089       float eta = iJet->eta();
0090       if (applyAbsToJet_) {
0091         eta = abs(eta);
0092       }
0093 
0094       if (eta < jetEtaMin_ || eta > jetEtaMax_)
0095         continue;
0096       filterproduct.addObject(triggerType_, TRef(objects, distance(objects->begin(), iJet)));
0097 
0098       ++n;
0099     }
0100   }  // events with one or more jets
0101   bool accept(n >= 1);
0102   return accept;
0103 }