Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /** \class HLT2jetGapFilter
0002  *
0003  *  \author Monica Vazquez Acosta (CERN)
0004  *
0005  */
0006 
0007 #include "HLTrigger/JetMET/interface/HLT2jetGapFilter.h"
0008 
0009 #include "DataFormats/Common/interface/Handle.h"
0010 
0011 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0012 
0013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0014 
0015 #include "FWCore/Framework/interface/ESHandle.h"
0016 #include "FWCore/Framework/interface/EventSetup.h"
0017 
0018 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0019 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0020 #include "FWCore/Utilities/interface/InputTag.h"
0021 
0022 //
0023 // constructors and destructor
0024 //
0025 HLT2jetGapFilter::HLT2jetGapFilter(const edm::ParameterSet& iConfig) : HLTFilter(iConfig) {
0026   inputTag_ = iConfig.getParameter<edm::InputTag>("inputTag");
0027   minEt_ = iConfig.getParameter<double>("minEt");
0028   minEta_ = iConfig.getParameter<double>("minEta");
0029 
0030   m_theCaloJetToken = consumes<reco::CaloJetCollection>(inputTag_);
0031 }
0032 
0033 HLT2jetGapFilter::~HLT2jetGapFilter() = default;
0034 
0035 void HLT2jetGapFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0036   edm::ParameterSetDescription desc;
0037   makeHLTFilterDescription(desc);
0038   desc.add<edm::InputTag>("inputTag", edm::InputTag("iterativeCone5CaloJets"));
0039   desc.add<double>("minEt", 90.0);
0040   desc.add<double>("minEta", 1.9);
0041   descriptions.add("hlt2jetGapFilter", desc);
0042 }
0043 
0044 // ------------ method called to produce the data  ------------
0045 bool HLT2jetGapFilter::hltFilter(edm::Event& iEvent,
0046                                  const edm::EventSetup& iSetup,
0047                                  trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0048   using namespace trigger;
0049 
0050   // The filter object
0051   if (saveTags())
0052     filterproduct.addCollectionTag(inputTag_);
0053 
0054   edm::Handle<reco::CaloJetCollection> recocalojets;
0055   iEvent.getByToken(m_theCaloJetToken, recocalojets);
0056 
0057   // look at all candidates,  check cuts and add to filter object
0058   int n(0);
0059 
0060   if (recocalojets->size() > 1) {
0061     // events with two or more jets
0062 
0063     double etjet1 = 0.;
0064     double etjet2 = 0.;
0065     double etajet1 = 0.;
0066     double etajet2 = 0.;
0067     int countjets = 0;
0068 
0069     for (auto recocalojet = recocalojets->begin(); recocalojet <= (recocalojets->begin() + 1); recocalojet++) {
0070       if (countjets == 0) {
0071         etjet1 = recocalojet->et();
0072         etajet1 = recocalojet->eta();
0073       }
0074       if (countjets == 1) {
0075         etjet2 = recocalojet->et();
0076         etajet2 = recocalojet->eta();
0077       }
0078       countjets++;
0079     }
0080 
0081     if (etjet1 > minEt_ && etjet2 > minEt_ && (etajet1 * etajet2) < 0 && std::abs(etajet1) > minEta_ &&
0082         std::abs(etajet2) > minEta_) {
0083       for (auto recocalojet = recocalojets->begin(); recocalojet <= (recocalojets->begin() + 1); recocalojet++) {
0084         reco::CaloJetRef ref(reco::CaloJetRef(recocalojets, distance(recocalojets->begin(), recocalojet)));
0085         filterproduct.addObject(TriggerJet, ref);
0086         n++;
0087       }
0088     }
0089 
0090   }  // events with two or more jets
0091 
0092   // filter decision
0093   bool accept(n >= 2);
0094 
0095   return accept;
0096 }