CMS 3D CMS Logo

JetHTJetPlusHOFilter.cc
Go to the documentation of this file.
1 
13 //
14 // Original Author: Gobinda Majumder & Suman Chatterjee
15 // Created: Fri Dec 16 14:52:17 IST 2011
16 // $Id$
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
30 
32 
37 
38 using namespace std;
39 using namespace edm;
40 using namespace reco;
41 
42 
43 
45  public:
46  explicit JetHTJetPlusHOFilter(const edm::ParameterSet&);
47  ~JetHTJetPlusHOFilter() override;
48 
49  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
50 
51  private:
52  bool filter(edm::Event&, const edm::EventSetup&) override;
53 
54  // ----------member data ---------------------------
55  int Nevt;
56  int Njetp;
57  int Npass;
58  double jtptthr;
59  double jtetath;
60  double hothres;
62 
65 
66 };
67 
68 //
69 // constants, enums and typedefs
70 //
71 
72 //
73 // static data member definitions
74 //
75 
76 //
77 // constructors and destructor
78 //
80 
81  tok_PFJets_ = consumes<reco::PFJetCollection>( iConfig.getParameter<edm::InputTag>("PFJets"));
82  tok_hoht_ = consumes<reco::PFClusterCollection>( iConfig.getParameter<edm::InputTag>("particleFlowClusterHO"));
83 
84 
85  //now do what ever initialization is needed
86  jtptthr = iConfig.getUntrackedParameter<double>("Ptcut", 200.0);
87  jtetath = iConfig.getUntrackedParameter<double>("Etacut",1.5);
88  hothres = iConfig.getUntrackedParameter<double>("HOcut", 8.0);
89 
90  Nevt = 0;
91  Njetp=0;
92  Npass=0;
93 
94 
95 }
96 
97 
99 {
100 
101  // do anything here that needs to be done at desctruction time
102  // (e.g. close files, deallocate resources etc.)
103 
104 }
105 
106 
107 //
108 
109 // ------------ method called on each new Event ------------
110 bool
112 {
113  using namespace std;
114  using namespace edm;
115  using namespace reco;
116  Nevt++;
117 
119  iEvent.getByToken(tok_PFJets_,PFJets);
120  bool passed=false;
121  vector <pair<double, double> > jetdirection;
122  vector<double> jetspt;
123  if (PFJets.isValid()) {
124  for (unsigned jet = 0; jet<PFJets->size(); jet++) {
125  if(((*PFJets)[jet].pt()<jtptthr)||(abs((*PFJets)[jet].eta())>jtetath)) continue;
126 
127  std::pair<double, double> etaphi((*PFJets)[jet].eta(),(*PFJets)[jet].phi());
128  jetdirection.push_back(etaphi);
129  jetspt.push_back((*PFJets)[jet].pt());
130  passed = true;
131  }
132  }
133 
134  if (!passed) return false;
135  Njetp++;
136  bool isJetDir=false;
137 
139  iEvent.getByToken(tok_hoht_,hoht);
140  if (hoht.isValid()) {
141  if (!(*hoht).empty()) {
142  for (PFClusterCollection::const_iterator ij=(*hoht).begin(); ij!=(*hoht).end(); ij++){
143  double hoenr = (*ij).energy();
144  if (hoenr <hothres) continue;
145 
146  const math::XYZPoint& cluster_pos = ij->position();
147 
148  double hoeta = cluster_pos.eta() ;
149  double hophi = cluster_pos.phi() ;
150 
151  for (unsigned ijet = 0; ijet< jetdirection.size(); ijet++) {
152  double delta = deltaR2(jetdirection[ijet].first, jetdirection[ijet].second, hoeta, hophi);
153  if (delta <0.5) {
154  isJetDir=true; break;
155  }
156  }
157  }
158  }
159  }
160 
161  if (isJetDir) {Npass++;}
162 
163  return isJetDir;
164 
165 }
166 
167 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
168 void
170  //The following says we do not know what parameters are allowed so do no validation
171  // Please change this to state exactly what you do use, even if it is no parameters
173  desc.setUnknown();
174  descriptions.addDefault(desc);
175 }
176 
177 //define this as a plug-in
179 
180 /*
181 End of JetHTJetPlusHOFilter with event 20 Jetpassed 9 passed 1
182 */
edm::EDGetTokenT< reco::PFClusterCollection > tok_hoht_
dbl * delta
Definition: mlp_gen.cc:36
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
U second(std::pair< T, U > const &p)
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void addDefault(ParameterSetDescription const &psetDescription)
JetHTJetPlusHOFilter(const edm::ParameterSet &)
bool filter(edm::Event &, const edm::EventSetup &) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::pair< T, T > etaphi(T x, T y, T z)
Definition: FastMath.h:128
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isValid() const
Definition: HandleBase.h:74
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
fixed size matrix
HLT enums.
edm::EDGetTokenT< reco::PFJetCollection > tok_PFJets_