Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-24 09:52:56

0001 /**\class JetHTJetPlusHOFilter JetHTJetPlusHOFilter.cc Test/BarrelJetFilter/src/BarrelJetFilter.cc
0002 
0003 Skimming of JetHT data set for the study of HO absolute weight calculation
0004 * 
0005 * Skimming Efficiency : ~ 5 %
0006 
0007  Description: [one line class summary]
0008 
0009  Implementation:
0010      [Notes on implementation]
0011 
0012 */
0013 //
0014 // Original Author: Gobinda Majumder & Suman Chatterjee
0015 //         Created:  Fri Dec 16 14:52:17 IST 2011
0016 // $Id$
0017 //
0018 //
0019 
0020 // system include files
0021 #include <memory>
0022 
0023 // user include files
0024 #include "FWCore/Framework/interface/Frameworkfwd.h"
0025 #include "FWCore/Framework/interface/stream/EDFilter.h"
0026 
0027 #include "FWCore/Framework/interface/Event.h"
0028 #include "FWCore/Framework/interface/MakerMacros.h"
0029 
0030 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0031 
0032 #include "DataFormats/JetReco/interface/PFJet.h"
0033 #include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
0034 #include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h"
0035 #include "DataFormats/Math/interface/deltaR.h"
0036 
0037 using namespace std;
0038 using namespace edm;
0039 using namespace reco;
0040 
0041 class JetHTJetPlusHOFilter : public edm::stream::EDFilter<> {
0042 public:
0043   explicit JetHTJetPlusHOFilter(const edm::ParameterSet&);
0044   ~JetHTJetPlusHOFilter() override;
0045 
0046   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0047 
0048 private:
0049   bool filter(edm::Event&, const edm::EventSetup&) override;
0050 
0051   // ----------member data ---------------------------
0052   int Nevt;
0053   int Njetp;
0054   int Npass;
0055   double jtptthr;
0056   double jtetath;
0057   double hothres;
0058   bool isOthHistFill;
0059 
0060   edm::EDGetTokenT<reco::PFJetCollection> tok_PFJets_;
0061   edm::EDGetTokenT<reco::PFClusterCollection> tok_hoht_;
0062 };
0063 
0064 //
0065 // constants, enums and typedefs
0066 //
0067 
0068 //
0069 // static data member definitions
0070 //
0071 
0072 //
0073 // constructors and destructor
0074 //
0075 JetHTJetPlusHOFilter::JetHTJetPlusHOFilter(const edm::ParameterSet& iConfig) {
0076   tok_PFJets_ = consumes<reco::PFJetCollection>(iConfig.getParameter<edm::InputTag>("PFJets"));
0077   tok_hoht_ = consumes<reco::PFClusterCollection>(iConfig.getParameter<edm::InputTag>("particleFlowClusterHO"));
0078 
0079   //now do what ever initialization is needed
0080   jtptthr = iConfig.getUntrackedParameter<double>("Ptcut", 200.0);
0081   jtetath = iConfig.getUntrackedParameter<double>("Etacut", 1.5);
0082   hothres = iConfig.getUntrackedParameter<double>("HOcut", 8.0);
0083 
0084   Nevt = 0;
0085   Njetp = 0;
0086   Npass = 0;
0087 }
0088 
0089 JetHTJetPlusHOFilter::~JetHTJetPlusHOFilter() {
0090   // do anything here that needs to be done at desctruction time
0091   // (e.g. close files, deallocate resources etc.)
0092 }
0093 
0094 //
0095 
0096 // ------------ method called on each new Event  ------------
0097 bool JetHTJetPlusHOFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0098   using namespace std;
0099   using namespace edm;
0100   using namespace reco;
0101   Nevt++;
0102 
0103   edm::Handle<reco::PFJetCollection> PFJets;
0104   iEvent.getByToken(tok_PFJets_, PFJets);
0105   bool passed = false;
0106   vector<pair<double, double> > jetdirection;
0107   vector<double> jetspt;
0108   if (PFJets.isValid()) {
0109     for (unsigned jet = 0; jet < PFJets->size(); jet++) {
0110       if (((*PFJets)[jet].pt() < jtptthr) || (abs((*PFJets)[jet].eta()) > jtetath))
0111         continue;
0112 
0113       std::pair<double, double> etaphi((*PFJets)[jet].eta(), (*PFJets)[jet].phi());
0114       jetdirection.push_back(etaphi);
0115       jetspt.push_back((*PFJets)[jet].pt());
0116       passed = true;
0117     }
0118   }
0119 
0120   if (!passed)
0121     return false;
0122   Njetp++;
0123   bool isJetDir = false;
0124 
0125   edm::Handle<PFClusterCollection> hoht;
0126   iEvent.getByToken(tok_hoht_, hoht);
0127   if (hoht.isValid()) {
0128     if (!(*hoht).empty()) {
0129       for (PFClusterCollection::const_iterator ij = (*hoht).begin(); ij != (*hoht).end(); ij++) {
0130         double hoenr = (*ij).energy();
0131         if (hoenr < hothres)
0132           continue;
0133 
0134         const math::XYZPoint& cluster_pos = ij->position();
0135 
0136         double hoeta = cluster_pos.eta();
0137         double hophi = cluster_pos.phi();
0138 
0139         for (unsigned ijet = 0; ijet < jetdirection.size(); ijet++) {
0140           double delta = deltaR2(jetdirection[ijet].first, jetdirection[ijet].second, hoeta, hophi);
0141           if (delta < 0.5) {
0142             isJetDir = true;
0143             break;
0144           }
0145         }
0146       }
0147     }
0148   }
0149 
0150   if (isJetDir) {
0151     Npass++;
0152   }
0153 
0154   return isJetDir;
0155 }
0156 
0157 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
0158 void JetHTJetPlusHOFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0159   //The following says we do not know what parameters are allowed so do no validation
0160   // Please change this to state exactly what you do use, even if it is no parameters
0161   edm::ParameterSetDescription desc;
0162   desc.setUnknown();
0163   descriptions.addDefault(desc);
0164 }
0165 
0166 //define this as a plug-in
0167 DEFINE_FWK_MODULE(JetHTJetPlusHOFilter);
0168 
0169 /*
0170 End of JetHTJetPlusHOFilter with event 20 Jetpassed 9 passed 1
0171 */