Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /** \class HLTDiJetEtaTopologyFilter
0002  *
0003  *
0004  *  \author Tomasz Fruboes
0005  *     based on HLTDiJetAveFilter
0006  */
0007 
0008 #include "HLTrigger/JetMET/interface/HLTDiJetEtaTopologyFilter.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 HLTDiJetEtaTopologyFilter<T>::HLTDiJetEtaTopologyFilter(const edm::ParameterSet& iConfig)
0030     : HLTFilter(iConfig),
0031       inputJetTag_(iConfig.template getParameter<edm::InputTag>("inputJetTag")),
0032       m_theJetToken(consumes<std::vector<T>>(inputJetTag_)),
0033       minPtAve_(iConfig.template getParameter<double>("minPtAve")),
0034       atLeastOneJetAbovePT_(iConfig.template getParameter<double>("atLeastOneJetAbovePT")),
0035       minPtTag_(iConfig.template getParameter<double>("minPtTag")),
0036       minPtProbe_(iConfig.template getParameter<double>("minPtProbe")),
0037       minDphi_(iConfig.template getParameter<double>("minDphi")),
0038       tagEtaMin_(iConfig.template getParameter<double>("minTagEta")),
0039       tagEtaMax_(iConfig.template getParameter<double>("maxTagEta")),
0040       probeEtaMin_(iConfig.template getParameter<double>("minProbeEta")),
0041       probeEtaMax_(iConfig.template getParameter<double>("maxProbeEta")),
0042       applyAbsToTag_(iConfig.template getParameter<bool>("applyAbsToTag")),
0043       applyAbsToProbe_(iConfig.template getParameter<bool>("applyAbsToProbe")),
0044       oppositeEta_(iConfig.template getParameter<bool>("oppositeEta")),
0045 
0046       triggerType_(iConfig.template getParameter<int>("triggerType")) {
0047   LogDebug("") << "HLTDiJetEtaTopologyFilter: Input/minDphi/triggerType : " << inputJetTag_.encode()
0048                << " "
0049                //<< minPtJet3_ << " "
0050                << minDphi_ << " " << triggerType_;
0051 }
0052 
0053 template <typename T>
0054 HLTDiJetEtaTopologyFilter<T>::~HLTDiJetEtaTopologyFilter() = default;
0055 
0056 template <typename T>
0057 void HLTDiJetEtaTopologyFilter<T>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0058   edm::ParameterSetDescription desc;
0059   makeHLTFilterDescription(desc);
0060   desc.add<edm::InputTag>("inputJetTag", edm::InputTag("hltIterativeCone5CaloJets"));
0061   desc.add<double>("minPtAve", 0.0);
0062   desc.add<double>("atLeastOneJetAbovePT", 0.0)->setComment("At least one jet with pt above threshold");
0063   desc.add<double>("minPtTag", 50.0)->setComment("pt requirement on tag jet");
0064   desc.add<double>("minPtProbe", 50.0)->setComment("pt requirement on probe jet");
0065   //desc.add<double>("minPtJet3",99999.0);
0066   desc.add<double>("minDphi", -1.0);
0067   desc.add<double>("minTagEta", -1.);
0068   desc.add<double>("maxTagEta", 1.4);
0069   desc.add<double>("minProbeEta", 2.7);
0070   desc.add<double>("maxProbeEta", 5.5);
0071   desc.add<bool>("applyAbsToTag", false), desc.add<bool>("applyAbsToProbe", false),
0072       desc.add<bool>("oppositeEta", false), desc.add<int>("triggerType", trigger::TriggerJet);
0073   descriptions.add(defaultModuleLabel<HLTDiJetEtaTopologyFilter<T>>(), desc);
0074 }
0075 
0076 // ------------ method called to produce the data  ------------
0077 template <typename T>
0078 bool HLTDiJetEtaTopologyFilter<T>::hltFilter(edm::Event& iEvent,
0079                                              const edm::EventSetup& iSetup,
0080                                              trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0081   using namespace std;
0082   using namespace edm;
0083   using namespace reco;
0084   using namespace trigger;
0085 
0086   typedef vector<T> TCollection;
0087   typedef Ref<TCollection> TRef;
0088 
0089   // The filter object
0090   if (saveTags())
0091     filterproduct.addCollectionTag(inputJetTag_);
0092 
0093   // get hold of collection of objects
0094   Handle<TCollection> objects;
0095   iEvent.getByToken(m_theJetToken, objects);
0096 
0097   int n(0);
0098 
0099   if (objects->size() > 1) {  // events with two or more jets
0100     typename TCollection::const_iterator iProbe(objects->begin());
0101     typename TCollection::const_iterator iEnd(objects->end());
0102     for (; iProbe != iEnd; ++iProbe) {
0103       if (iProbe->pt() < minPtProbe_)
0104         continue;
0105 
0106       // for easier trigger efficiency evaluation save all probe/tag
0107       // objects passing the minPT/eta criteria (outer loop)
0108       float eta = iProbe->eta();
0109       float etaForProbeTest = eta;
0110       float etaForTagTest = eta;
0111       //applyAbsToTag_ (iConfig.template getParameter<bool> ("applyAbsToTag")),
0112       //applyAbsToProbe_ (iConfig.template getParameter<bool> ("applyAbsToProbe")),
0113       if (applyAbsToProbe_) {
0114         etaForProbeTest = abs(etaForProbeTest);
0115       }
0116       if (applyAbsToTag_) {
0117         etaForTagTest = abs(etaForTagTest);
0118       }
0119 
0120       bool isGood = false;  // probe or tag
0121       bool isProbe = false;
0122       if (etaForProbeTest > probeEtaMin_ && etaForProbeTest < probeEtaMax_) {
0123         isGood = true;
0124         isProbe = true;
0125       }
0126       if (etaForTagTest > tagEtaMin_ && etaForTagTest < tagEtaMax_) {
0127         isGood = true;
0128       }
0129       if (isGood) {
0130         filterproduct.addObject(triggerType_, TRef(objects, distance(objects->begin(), iProbe)));
0131       }
0132 
0133       if (!isProbe)
0134         continue;
0135 
0136       typename TCollection::const_iterator iTag(objects->begin());
0137       for (; iTag != iEnd; ++iTag) {
0138         if (iTag == iProbe)
0139           continue;
0140         if (iTag->pt() < minPtTag_)
0141           continue;
0142         if (std::max(iTag->pt(), iProbe->pt()) < atLeastOneJetAbovePT_)
0143           continue;
0144 
0145         float eta2 = iTag->eta();
0146         if (applyAbsToTag_) {
0147           eta2 = abs(eta2);
0148         }
0149 
0150         if (eta2 < tagEtaMin_ || eta2 > tagEtaMax_)
0151           continue;
0152         double dphi = std::abs(deltaPhi(iProbe->phi(), iTag->phi()));
0153         if (dphi < minDphi_) {
0154           continue;
0155         }
0156         if (oppositeEta_ && etaForProbeTest * eta2 > 0) {
0157           continue;
0158         }
0159 
0160         double ptAve = (iProbe->pt() + iTag->pt()) / 2;
0161         if (ptAve < minPtAve_) {
0162           continue;
0163         }
0164         ++n;
0165       }
0166     }
0167   }  // events with two or more jets
0168   // filter decision
0169   bool accept(n >= 1);
0170   return accept;
0171 }