CMS 3D CMS Logo

PFJetIDSelectionFunctor.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_SelectorUtils_interface_PFJetIDSelectionFunctor_h
2 #define PhysicsTools_SelectorUtils_interface_PFJetIDSelectionFunctor_h
3 
15 #ifndef __GCCXML__
17 #endif
20 
22 
23 #include <TMath.h>
24 class PFJetIDSelectionFunctor : public Selector<pat::Jet> {
25 
26  public: // interface
27 
30 
32 
33 #ifndef __GCCXML__
36  {}
37 #endif
38 
40  {
41  std::string versionStr = params.getParameter<std::string>("version");
42  std::string qualityStr = params.getParameter<std::string>("quality");
43 
44  if ( versionStr == "FIRSTDATA" )
46  else if( versionStr == "RUNIISTARTUP")
48  // WINTER16 implements most recent (as of Feb 2017) JetID criteria
49  // See: https://twiki.cern.ch/twiki/bin/view/CMS/JetID13TeVRun2016
50  else if( versionStr == "WINTER16")
51  version_ = WINTER16;
52  else if( versionStr == "WINTER17")
53  version_ = WINTER17;
54  else version_ = WINTER17;//set WINTER17 as default
55 
56 
57  if ( qualityStr == "LOOSE") quality_ = LOOSE;
58  else if ( qualityStr == "TIGHT") quality_ = TIGHT;
59  else if ( qualityStr == "TIGHTLEPVETO") quality_ = TIGHTLEPVETO;
60  else quality_ = TIGHT;
61 
62  push_back("CHF" );
63  push_back("NHF" );
64  if( version_ != WINTER17 || quality_ != TIGHT ) push_back("CEF" );
65  push_back("NEF" );
66  push_back("NCH" );
67  push_back("nConstituents");
68  if(version_ == RUNIISTARTUP ){
69  push_back("NEF_FW");
70  push_back("nNeutrals_FW");
71  }
72  if(version_ == WINTER16 ){
73  push_back("NHF_EC");
74  push_back("NEF_EC");
75  push_back("nNeutrals_EC");
76  push_back("NEF_FW");
77  push_back("nNeutrals_FW");
78  }
79  if(version_ == WINTER17 ){
80  push_back("NEF_EC_L");
81  push_back("NEF_EC_U");
82  push_back("nNeutrals_EC");
83  push_back("NEF_FW");
84  push_back("NHF_FW");
85  push_back("nNeutrals_FW");
86  if (quality_ == TIGHTLEPVETO) push_back("MUF");;
87  }
88 
89 
90  if(version_ == WINTER17 && quality_ == LOOSE ){
91  edm::LogWarning("BadJetIDVersion") << "Winter17 JetID version does not support the LOOSE operating point -- defaulting to TIGHT";
92  quality_ = TIGHT;
93  }
94 
96  edm::LogWarning("BadJetIDVersion") << "JetID version does not support the TIGHTLEPVETO operating point -- defaulting to TIGHT";
97  quality_ = TIGHT;
98  }
99 
100 
101  // Set some default cuts for LOOSE, TIGHT
102  if ( quality_ == LOOSE ) {
103  set("CHF", 0.0);
104  set("NHF", 0.99);
105  set("CEF", 0.99);
106  set("NEF", 0.99);
107  set("NCH", 0);
108  set("nConstituents", 1);
109  if(version_ == RUNIISTARTUP){
110  set("NEF_FW",0.90);
111  set("nNeutrals_FW",10);
112  }
113  if(version_ == WINTER16){
114  set("NHF_EC",0.98);
115  set("NEF_EC",0.01);
116  set("nNeutrals_EC",2);
117  set("NEF_FW",0.90);
118  set("nNeutrals_FW",10);
119  }
120 
121 
122  } else if ( quality_ == TIGHT ) {
123  set("CHF", 0.0);
124  set("NHF", 0.9);
125  if(version_ != WINTER17 ) set("CEF", 0.99);
126  set("NEF", 0.9);
127  set("NCH", 0);
128  set("nConstituents", 1);
129  if(version_ == RUNIISTARTUP){
130  set("NEF_FW",0.90);
131  set("nNeutrals_FW",10);
132  }
133  if(version_ == WINTER16){
134  set("NHF_EC",0.98);
135  set("NEF_EC",0.01);
136  set("nNeutrals_EC",2);
137  set("NEF_FW",0.90);
138  set("nNeutrals_FW",10);
139  }
140  if(version_ == WINTER17){
141  set("NEF_EC_L",0.02);
142  set("NEF_EC_U",0.99);
143  set("nNeutrals_EC",2);
144  set("NHF_FW",0.02);
145  set("NEF_FW",0.90);
146  set("nNeutrals_FW",10);
147  }
148 
149  }else if ( quality_ == TIGHTLEPVETO ) {
150  set("CHF", 0.0);
151  set("NHF", 0.9);
152  set("CEF", 0.8);
153  set("NEF", 0.9);
154  set("NCH", 0);
155  set("nConstituents", 1);
156  if(version_ == WINTER17){
157  set("NEF_EC_L",0.02);
158  set("NEF_EC_U",0.99);
159  set("nNeutrals_EC",2);
160  set("NHF_FW",0.02);
161  set("NEF_FW",0.90);
162  set("nNeutrals_FW",10);
163  set("MUF", 0.8);
164  }
165 
166  }
167 
168 
169  // Now check the configuration to see if the user changed anything
170  if ( params.exists("CHF") ) set("CHF", params.getParameter<double>("CHF") );
171  if ( params.exists("NHF") ) set("NHF", params.getParameter<double>("NHF") );
172  if(version_ != WINTER17 || quality_ != TIGHT ) {if ( params.exists("CEF") ) set("CEF", params.getParameter<double>("CEF") );}
173  if ( params.exists("NEF") ) set("NEF", params.getParameter<double>("NEF") );
174  if ( params.exists("NCH") ) set("NCH", params.getParameter<int> ("NCH") );
175  if ( params.exists("nConstituents") ) set("nConstituents", params.getParameter<int> ("nConstituents") );
176  if(version_ == RUNIISTARTUP){
177  if ( params.exists("NEF_FW") ) set("NEF_FW", params.getParameter<double> ("NEF_FW") );
178  if ( params.exists("nNeutrals_FW") ) set("nNeutrals_FW", params.getParameter<int> ("nNeutrals_FW") );
179  }
180  if(version_ == WINTER16){
181  if ( params.exists("NHF_EC") ) set("NHF_EC", params.getParameter<int> ("NHF_EC") );
182  if ( params.exists("NEF_EC") ) set("NEF_EC", params.getParameter<int> ("NEF_EC") );
183  if ( params.exists("nNeutrals_EC") ) set("nNeutrals_EC", params.getParameter<int> ("nNeutrals_EC") );
184  if ( params.exists("NEF_FW") ) set("NEF_FW", params.getParameter<double> ("NEF_FW") );
185  if ( params.exists("nNeutrals_FW") ) set("nNeutrals_FW", params.getParameter<int> ("nNeutrals_FW") );
186  }
187  if(version_ == WINTER17){
188  if ( params.exists("NEF_EC_L") ) set("NEF_EC_L", params.getParameter<int> ("NEF_EC_L") );
189  if ( params.exists("NEF_EC_U") ) set("NEF_EC_U", params.getParameter<int> ("NEF_EC_U") );
190  if ( params.exists("nNeutrals_EC") ) set("nNeutrals_EC", params.getParameter<int> ("nNeutrals_EC") );
191  if ( params.exists("NHF_FW") ) set("NHF_FW", params.getParameter<double> ("NHF_FW") );
192  if ( params.exists("NEF_FW") ) set("NEF_FW", params.getParameter<double> ("NEF_FW") );
193  if ( params.exists("nNeutrals_FW") ) set("nNeutrals_FW", params.getParameter<int> ("nNeutrals_FW") );
194  if ( quality_ == TIGHTLEPVETO ) {if ( params.exists("MUF") ) set("MUF", params.getParameter<int> ("MUF") );}
195  }
196 
197 
198  if ( params.exists("cutsToIgnore") )
199  setIgnoredCuts( params.getParameter<std::vector<std::string> >("cutsToIgnore") );
200 
201 
202  indexNConstituents_ = index_type (&bits_, "nConstituents");
203  indexNEF_ = index_type (&bits_, "NEF");
204  indexNHF_ = index_type (&bits_, "NHF");
205  if(version_ != WINTER17 || quality_ != TIGHT ) indexCEF_ = index_type (&bits_, "CEF");
206 
207  indexCHF_ = index_type (&bits_, "CHF");
208  indexNCH_ = index_type (&bits_, "NCH");
209  if(version_ == RUNIISTARTUP){
210  indexNEF_FW_ = index_type (&bits_, "NEF_FW");
211  indexNNeutrals_FW_ = index_type (&bits_, "nNeutrals_FW");
212  }
213  if(version_ == WINTER16){
214  indexNHF_EC_ = index_type (&bits_, "NHF_EC");
215  indexNEF_EC_ = index_type (&bits_, "NEF_EC");
216  indexNNeutrals_EC_ = index_type (&bits_, "nNeutrals_EC");
217  indexNEF_FW_ = index_type (&bits_, "NEF_FW");
218  indexNNeutrals_FW_ = index_type (&bits_, "nNeutrals_FW");
219  }
220  if(version_ == WINTER17){
221  indexNEF_EC_L_ = index_type (&bits_, "NEF_EC_L");
222  indexNEF_EC_U_ = index_type (&bits_, "NEF_EC_U");
223  indexNNeutrals_EC_ = index_type (&bits_, "nNeutrals_EC");
224  indexNHF_FW_ = index_type (&bits_, "NHF_FW");
225  indexNEF_FW_ = index_type (&bits_, "NEF_FW");
226  indexNNeutrals_FW_ = index_type (&bits_, "nNeutrals_FW");
227  if ( quality_ == TIGHTLEPVETO ) {indexMUF_ = index_type (&bits_, "MUF");}
228 
229 
230  }
231 
232 
233 
235 
236  }
237 
238 
240  Quality_t quality ) :
241  version_(version), quality_(quality)
242  {
243 
244  push_back("CHF" );
245  push_back("NHF" );
246  if(version_ != WINTER17 || quality_ != TIGHT ) push_back("CEF" );
247  push_back("NEF" );
248  push_back("NCH" );
249  push_back("nConstituents");
250  if(version_ == RUNIISTARTUP){
251  push_back("NEF_FW");
252  push_back("nNeutrals_FW");
253  }
254  if(version_ == WINTER16){
255  push_back("NHF_EC");
256  push_back("NEF_EC");
257  push_back("nNeutrals_EC");
258  push_back("NEF_FW");
259  push_back("nNeutrals_FW");
260  }
261  if(version_ == WINTER17){
262  push_back("NEF_EC_L");
263  push_back("NEF_EC_U");
264  push_back("nNeutrals_EC");
265  push_back("NHF_FW");
266  push_back("NEF_FW");
267  push_back("nNeutrals_FW");
268  if ( quality_ == TIGHTLEPVETO ) { push_back("MUF");}
269  }
270 
271 
272  if(version_ == WINTER17 && quality_ == LOOSE ){
273  edm::LogWarning("BadJetIDVersion") << "Winter17 JetID version does not support the LOOSE operating point -- defaulting to TIGHT";
274  quality_ = TIGHT;
275  }
276  if(version_ != WINTER17 && quality_ == TIGHTLEPVETO){
277  edm::LogWarning("BadJetIDVersion") << "JetID version does not support the TIGHTLEPVETO operating point -- defaulting to TIGHT";
278  quality_ = TIGHT;
279  }
280  // Set some default cuts for LOOSE, TIGHT
281  if ( quality_ == LOOSE ) {
282  set("CHF", 0.0);
283  set("NHF", 0.99);
284  set("CEF", 0.99);
285  set("NEF", 0.99);
286  set("NCH", 0);
287  set("nConstituents", 1);
288  if(version_ == RUNIISTARTUP){
289  set("NEF_FW",0.90);
290  set("nNeutrals_FW",10);
291  }
292  if(version_ == WINTER16){
293  set("NHF_EC",0.98);
294  set("NEF_EC",0.01);
295  set("nNeutrals_EC",2);
296  set("NEF_FW",0.90);
297  set("nNeutrals_FW",10);
298  }
299 
300 
301 
302 
303 
304  } else if ( quality_ == TIGHT ) {
305  set("CHF", 0.0);
306  set("NHF", 0.9);
307  if(version_ != WINTER17) set("CEF", 0.99);
308  set("NEF", 0.9);
309  set("NCH", 0);
310  set("nConstituents", 1);
311  if(version_ == RUNIISTARTUP){
312  set("NEF_FW",0.90);
313  set("nNeutrals_FW",10);
314  }
315  if(version_ == WINTER16){
316  set("NHF_EC",0.98);
317  set("NEF_EC",0.01);
318  set("nNeutrals_EC",2);
319  set("NEF_FW",0.90);
320  set("nNeutrals_FW",10);
321  }
322  if(version_ == WINTER17){
323  set("NEF_EC_L",0.02);
324  set("NEF_EC_U",0.99);
325  set("nNeutrals_EC",2);
326  set("NHF_FW",0.02);
327  set("NEF_FW",0.90);
328  set("nNeutrals_FW",10);
329  }
330 
331  } else if ( quality_ == TIGHTLEPVETO ) {
332  set("CHF", 0.0);
333  set("NHF", 0.9);
334  set("CEF", 0.8);
335  set("NEF", 0.9);
336  set("NCH", 0);
337  set("nConstituents", 1);
338  if(version_ == WINTER17){
339  set("NEF_EC_L",0.02);
340  set("NEF_EC_U",0.99);
341  set("nNeutrals_EC",2);
342  set("NHF_FW",0.02);
343  set("NEF_FW",0.90);
344  set("nNeutrals_FW",10);
345  set("MUF", 0.8);
346  }
347 
348  }
349 
350 
351 
352 
353  indexNConstituents_ = index_type (&bits_, "nConstituents");
354  indexNEF_ = index_type (&bits_, "NEF");
355  indexNHF_ = index_type (&bits_, "NHF");
356  if(version_ != WINTER17 || quality_ != TIGHT ) indexCEF_ = index_type (&bits_, "CEF");
357  indexCHF_ = index_type (&bits_, "CHF");
358  indexNCH_ = index_type (&bits_, "NCH");
359  if(version_ == RUNIISTARTUP){
360  indexNEF_FW_ = index_type (&bits_, "NEF_FW");
361  indexNNeutrals_FW_ = index_type (&bits_, "nNeutrals_FW");
362  }
363  if(version_ == WINTER16){
364  indexNHF_EC_ = index_type (&bits_, "NHF_EC");
365  indexNEF_EC_ = index_type (&bits_, "NEF_EC");
366  indexNNeutrals_EC_ = index_type (&bits_, "nNeutrals_EC");
367  indexNEF_FW_ = index_type (&bits_, "NEF_FW");
368  indexNNeutrals_FW_ = index_type (&bits_, "nNeutrals_FW");
369  }
370  if(version_ == WINTER17){
371 
372  indexNEF_EC_L_ = index_type (&bits_, "NEF_EC_L");
373  indexNEF_EC_U_ = index_type (&bits_, "NEF_EC_U");
374  indexNNeutrals_EC_ = index_type (&bits_, "nNeutrals_EC");
375  indexNHF_FW_ = index_type (&bits_, "NHF_FW");
376  indexNEF_FW_ = index_type (&bits_, "NEF_FW");
377  indexNNeutrals_FW_ = index_type (&bits_, "nNeutrals_FW");
378  if ( quality_ == TIGHTLEPVETO ) { indexMUF_ = index_type (&bits_, "MUF"); }
379  }
380 
381 
383  }
384 
385 
386  //
387  // Accessor from PAT jets
388  //
389  bool operator()( const pat::Jet & jet, pat::strbitset & ret ) override
390  {
392  if ( jet.currentJECLevel() == "Uncorrected" || !jet.jecSetsAvailable() )
393  return firstDataCuts( jet, ret, version_);
394  else
395  return firstDataCuts( jet.correctedJet("Uncorrected"), ret, version_ );
396  }
397  else {
398  return false;
399  }
400  }
402 
403  //
404  // Accessor from *CORRECTED* 4-vector, EMF, and Jet ID.
405  // This can be used with reco quantities.
406  //
407  bool operator()( const reco::PFJet & jet, pat::strbitset & ret )
408  {
409  if ( version_ == FIRSTDATA || version_ == RUNIISTARTUP || version_ == WINTER16 || version_ == WINTER17 ){ return firstDataCuts( jet, ret, version_);
410  }
411  else {
412  return false;
413  }
414  }
415 
416  bool operator()( const reco::PFJet & jet )
417  {
418  retInternal_.set(false);
419  operator()(jet, retInternal_);
421  return (bool)retInternal_;
422  }
423 
424  //
425  // cuts based on craft 08 analysis.
426  //
427  bool firstDataCuts( reco::Jet const & jet,
429  {
430  ret.set(false);
431 
432  // cache some variables
433  double chf = 0.0;
434  double nhf = 0.0;
435  double cef = 0.0;
436  double nef = 0.0;
437  double muf = 0.0;
438  int nch = 0;
439  int nconstituents = 0;
440  int nneutrals = 0;
441 
442  // Have to do this because pat::Jet inherits from reco::Jet but not reco::PFJet
443  reco::PFJet const * pfJet = dynamic_cast<reco::PFJet const *>(&jet);
444  pat::Jet const * patJet = dynamic_cast<pat::Jet const *>(&jet);
445  reco::BasicJet const * basicJet = dynamic_cast<reco::BasicJet const *>(&jet);
446 
447  if ( patJet != nullptr ) {
448  if ( patJet->isPFJet() ) {
449  chf = patJet->chargedHadronEnergyFraction();
450  nhf = patJet->neutralHadronEnergyFraction();
451  cef = patJet->chargedEmEnergyFraction();
452  nef = patJet->neutralEmEnergyFraction();
453  nch = patJet->chargedMultiplicity();
454  nconstituents = patJet->numberOfDaughters();
455  nneutrals = patJet->neutralMultiplicity();
456  }
457  // Handle the special case where this is a composed jet for
458  // subjet analyses
459  else if ( patJet->isBasicJet() ) {
460  double e_chf = 0.0;
461  double e_nhf = 0.0;
462  double e_cef = 0.0;
463  double e_nef = 0.0;
464  nch = 0;
465  nconstituents = 0;
466  nneutrals = 0;
467 
468  for ( reco::Jet::const_iterator ibegin = patJet->begin(),
469  iend = patJet->end(), isub = ibegin;
470  isub != iend; ++isub ) {
471  reco::PFJet const * pfsub = dynamic_cast<reco::PFJet const *>( &*isub );
472  pat::Jet const * patsub = dynamic_cast<pat::Jet const *>( &*isub );
473  if ( patsub ) {
474  e_chf += patsub->chargedHadronEnergy();
475  e_nhf += patsub->neutralHadronEnergy();
476  e_cef += patsub->chargedEmEnergy();
477  e_nef += patsub->neutralEmEnergy();
478  nch += patsub->chargedMultiplicity();
479  nconstituents += patsub->numberOfDaughters();
480  nneutrals += patsub->neutralMultiplicity();
481  } else if ( pfsub ) {
482  e_chf += pfsub->chargedHadronEnergy();
483  e_nhf += pfsub->neutralHadronEnergy();
484  e_cef += pfsub->chargedEmEnergy();
485  e_nef += pfsub->neutralEmEnergy();
486  nch += pfsub->chargedMultiplicity();
487  nconstituents += pfsub->numberOfDaughters();
488  nneutrals += pfsub->neutralMultiplicity();
489  } else assert(0);
490  }
491  double e = patJet->energy();
492  if ( e > 0.000001 ) {
493  chf = e_chf / e;
494  nhf = e_nhf / e;
495  cef = e_cef / e;
496  nef = e_nef / e;
497  } else {
498  chf = nhf = cef = nef = 0.0;
499  }
500  }
501  } // end if pat jet
502  else if ( pfJet != nullptr ) {
503  // CV: need to compute energy fractions in a way that works for corrected as well as for uncorrected PFJets
504  double jetEnergyUncorrected =
505  pfJet->chargedHadronEnergy()
506  + pfJet->neutralHadronEnergy()
507  + pfJet->photonEnergy()
508  + pfJet->electronEnergy()
509  + pfJet->muonEnergy()
510  + pfJet->HFEMEnergy();
511  if ( jetEnergyUncorrected > 0. ) {
512  chf = pfJet->chargedHadronEnergy() / jetEnergyUncorrected;
513  nhf = pfJet->neutralHadronEnergy() / jetEnergyUncorrected;
514  cef = pfJet->chargedEmEnergy() / jetEnergyUncorrected;
515  nef = pfJet->neutralEmEnergy() / jetEnergyUncorrected;
516  muf = pfJet->muonEnergy() / jetEnergyUncorrected;
517  }
518  nch = pfJet->chargedMultiplicity();
519  nconstituents = pfJet->numberOfDaughters();
520  nneutrals = pfJet->neutralMultiplicity();
521  } // end if PF jet
522  // Handle the special case where this is a composed jet for
523  // subjet analyses
524  else if ( basicJet != nullptr ) {
525  double e_chf = 0.0;
526  double e_nhf = 0.0;
527  double e_cef = 0.0;
528  double e_nef = 0.0;
529  nch = 0;
530  nconstituents = 0;
531  for ( reco::Jet::const_iterator ibegin = basicJet->begin(),
532  iend = patJet->end(), isub = ibegin;
533  isub != iend; ++isub ) {
534  reco::PFJet const * pfsub = dynamic_cast<reco::PFJet const *>( &*isub );
535  e_chf += pfsub->chargedHadronEnergy();
536  e_nhf += pfsub->neutralHadronEnergy();
537  e_cef += pfsub->chargedEmEnergy();
538  e_nef += pfsub->neutralEmEnergy();
539  nch += pfsub->chargedMultiplicity();
540  nconstituents += pfsub->numberOfDaughters();
541  nneutrals += pfsub->neutralMultiplicity();
542  }
543  double e = basicJet->energy();
544  if ( e > 0.000001 ) {
545  chf = e_chf / e;
546  nhf = e_nhf / e;
547  cef = e_cef / e;
548  nef = e_nef / e;
549  }
550  } // end if basic jet
551 
552 
553 
554  // Cuts for |eta| < 2.4 for FIRSTDATA, RUNIISTARTUP, WINTER16 and WINTER17
555  if(version_ != WINTER17 || quality_ != TIGHT ) {if ( ignoreCut(indexCEF_) || ( cef < cut(indexCEF_, double()) || std::abs(jet.eta()) > 2.4 ) ) passCut( ret, indexCEF_);}
556 
557  if ( ignoreCut(indexCHF_) || ( chf > cut(indexCHF_, double()) || std::abs(jet.eta()) > 2.4 ) ) passCut( ret, indexCHF_);
558  if ( ignoreCut(indexNCH_) || ( nch > cut(indexNCH_, int()) || std::abs(jet.eta()) > 2.4 ) ) passCut( ret, indexNCH_);
559 
560  if(version_ == FIRSTDATA){// Cuts for all eta for FIRSTDATA
561  if ( ignoreCut(indexNConstituents_) || ( nconstituents > cut(indexNConstituents_, int()) ) ) passCut( ret, indexNConstituents_);
562  if ( ignoreCut(indexNEF_) || ( nef < cut(indexNEF_, double()) ) ) passCut( ret, indexNEF_);
563  if ( ignoreCut(indexNHF_) || ( nhf < cut(indexNHF_, double()) ) ) passCut( ret, indexNHF_);
564  }else if(version_ == RUNIISTARTUP){
565  // Cuts for |eta| <= 3.0 for RUNIISTARTUP scenario
566  if ( ignoreCut(indexNConstituents_) || ( nconstituents > cut(indexNConstituents_, int()) || std::abs(jet.eta()) > 3.0 ) ) passCut( ret, indexNConstituents_);
567  if ( ignoreCut(indexNEF_) || ( nef < cut(indexNEF_, double()) || std::abs(jet.eta()) > 3.0 ) ) passCut( ret, indexNEF_);
568  if ( ignoreCut(indexNHF_) || ( nhf < cut(indexNHF_, double()) || std::abs(jet.eta()) > 3.0 ) ) passCut( ret, indexNHF_);
569  // Cuts for |eta| > 3.0 for RUNIISTARTUP scenario
570  if ( ignoreCut(indexNEF_FW_) || ( nef < cut(indexNEF_FW_, double()) || std::abs(jet.eta()) <= 3.0 ) ) passCut( ret, indexNEF_FW_);
571  if ( ignoreCut(indexNNeutrals_FW_) || ( nneutrals > cut(indexNNeutrals_FW_, int()) || std::abs(jet.eta()) <= 3.0 ) ) passCut( ret, indexNNeutrals_FW_);
572  }
573  else if(version_ == WINTER16){
574  // Cuts for |eta| <= 2.7 for WINTER16 scenario
575  if ( ignoreCut(indexNConstituents_) || ( nconstituents > cut(indexNConstituents_, int()) || std::abs(jet.eta()) > 2.7 ) ) passCut( ret, indexNConstituents_);
576  if ( ignoreCut(indexNEF_) || ( nef < cut(indexNEF_, double()) || std::abs(jet.eta()) > 2.7 ) ) passCut( ret, indexNEF_);
577  if ( ignoreCut(indexNHF_) || ( nhf < cut(indexNHF_, double()) || std::abs(jet.eta()) > 2.7 ) ) passCut( ret, indexNHF_);
578 
579  // Cuts for 2.7 < |eta| <= 3.0 for WINTER16 scenario
580  if ( ignoreCut(indexNHF_EC_) || ( nhf < cut(indexNHF_EC_, double()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0) ) passCut( ret, indexNHF_EC_);
581  if ( ignoreCut(indexNEF_EC_) || ( nef > cut(indexNEF_EC_, double()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0) ) passCut( ret, indexNEF_EC_);
582  if ( ignoreCut(indexNNeutrals_EC_) || ( nneutrals > cut(indexNNeutrals_EC_, int()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0) ) passCut( ret, indexNNeutrals_EC_);
583 
584  // Cuts for |eta| > 3.0 for WINTER16 scenario
585  if ( ignoreCut(indexNEF_FW_) || ( nef < cut(indexNEF_FW_, double()) || std::abs(jet.eta()) <= 3.0 ) ) passCut( ret, indexNEF_FW_);
586  if ( ignoreCut(indexNNeutrals_FW_) || ( nneutrals > cut(indexNNeutrals_FW_, int()) || std::abs(jet.eta()) <= 3.0 ) ) passCut( ret, indexNNeutrals_FW_);
587  }
588  else if(version_ == WINTER17){
589  // Cuts for |eta| <= 2.7 for WINTER17 scenario
590  if ( ignoreCut(indexNConstituents_) || ( nconstituents > cut(indexNConstituents_, int()) || std::abs(jet.eta()) > 2.7 ) ) passCut( ret, indexNConstituents_);
591  if ( ignoreCut(indexNEF_) || ( nef < cut(indexNEF_, double()) || std::abs(jet.eta()) > 2.7 ) ) passCut( ret, indexNEF_);
592  if ( ignoreCut(indexNHF_) || ( nhf < cut(indexNHF_, double()) || std::abs(jet.eta()) > 2.7 ) ) passCut( ret, indexNHF_);
593  if ( quality_ == TIGHTLEPVETO ) {if ( ignoreCut(indexMUF_) || ( muf < cut(indexMUF_, double()) || std::abs(jet.eta()) > 2.7 ) ) passCut( ret, indexMUF_);}
594 
595  // Cuts for 2.7 < |eta| <= 3.0 for WINTER17 scenario
596 
597  if ( ignoreCut(indexNEF_EC_L_) || ( nef > cut(indexNEF_EC_L_, double()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0) ) passCut( ret, indexNEF_EC_L_);
598  if ( ignoreCut(indexNEF_EC_U_) || ( nef < cut(indexNEF_EC_U_, double()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0) ) passCut( ret, indexNEF_EC_U_);
599  if ( ignoreCut(indexNNeutrals_EC_) || ( nneutrals > cut(indexNNeutrals_EC_, int()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0) ) passCut( ret, indexNNeutrals_EC_);
600 
601  // Cuts for |eta| > 3.0 for WINTER17 scenario
602  if ( ignoreCut(indexNHF_FW_) || ( nhf > cut(indexNHF_FW_, double()) || std::abs(jet.eta()) <= 3.0 ) ) passCut( ret, indexNHF_FW_);
603  if ( ignoreCut(indexNEF_FW_) || ( nef < cut(indexNEF_FW_, double()) || std::abs(jet.eta()) <= 3.0 ) ) passCut( ret, indexNEF_FW_);
604  if ( ignoreCut(indexNNeutrals_FW_) || ( nneutrals > cut(indexNNeutrals_FW_, int()) || std::abs(jet.eta()) <= 3.0 ) ) passCut( ret, indexNNeutrals_FW_);
605 
606  }
607 
608 
609  //std::cout << "<PFJetIDSelectionFunctor::firstDataCuts>:" << std::endl;
610  //std::cout << " jet: Pt = " << jet.pt() << ", eta = " << jet.eta() << ", phi = " << jet.phi() << std::endl;
611  //ret.print(std::cout);
612 
613  setIgnored( ret );
614  return (bool)ret;
615  }
616 
617  private: // member variables
618 
621 
629 
633 
639 
640 
641 };
642 
643 #endif
T getParameter(std::string const &) const
float photonEnergy() const
photonEnergy
Definition: PFJet.h:106
float neutralHadronEnergyFraction() const
neutralHadronEnergyFraction (relative to uncorrected jet energy)
Definition: Jet.h:374
double eta() const final
momentum pseudorapidity
bool jecSetsAvailable() const
Definition: Jet.h:131
float muonEnergy() const
muonEnergy
Definition: PFJet.h:114
float chargedHadronEnergy() const
chargedHadronEnergy
Definition: Jet.h:649
float chargedEmEnergy() const
chargedEmEnergy
Definition: PFJet.h:142
float neutralEmEnergy() const
neutralEmEnergy
Definition: Jet.h:670
float chargedHadronEnergyFraction() const
chargedHadronEnergyFraction (relative to uncorrected jet energy)
Definition: Jet.h:372
PFJetIDSelectionFunctor(edm::ParameterSet const &params, edm::ConsumesCollector &iC)
Base class for all types of Jets.
Definition: Jet.h:20
float neutralHadronEnergy() const
neutralHadronEnergy
Definition: Jet.h:656
float chargedEmEnergyFraction() const
chargedEmEnergyFraction (relative to uncorrected jet energy)
Definition: Jet.h:376
bool exists(std::string const &parameterName) const
checks if a parameter exists
pat::strbitset::index_type index_type
Definition: Selector.h:29
void setIgnored(pat::strbitset &ret)
set ignored bits
Definition: Selector.h:224
int neutralMultiplicity() const
neutralMultiplicity
Definition: Jet.h:422
pat::strbitset retInternal_
internal ret if users don&#39;t care about return bits
Definition: Selector.h:287
Jets made from CaloTowers.
Definition: BasicJet.h:20
int chargedMultiplicity() const
chargedMultiplicity
Definition: PFJet.h:155
Jets made from PFObjects.
Definition: PFJet.h:21
PFJetIDSelectionFunctor(Version_t version, Quality_t quality)
float neutralEmEnergy() const
neutralEmEnergy
Definition: PFJet.h:150
bool operator()(const reco::PFJet &jet, pat::strbitset &ret)
float chargedEmEnergy() const
chargedEmEnergy
Definition: Jet.h:663
float electronEnergy() const
electronEnergy
Definition: PFJet.h:110
size_t numberOfDaughters() const override
number of daughters
PFJetIDSelectionFunctor(edm::ParameterSet const &params)
pat::strbitset bits_
the bitset indexed by strings
Definition: Selector.h:286
void passCut(pat::strbitset &ret, std::string const &s)
Passing cuts.
Definition: Selector.h:176
float HFEMEnergy() const
HFEMEnergy.
Definition: PFJet.h:122
bool ignoreCut(std::string const &s) const
ignore the cut at index "s"
Definition: Selector.h:159
const_iterator end() const
last daughter const_iterator
Definition: Candidate.h:146
double energy() const final
energy
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual void push_back(std::string const &s)
This is the registration of an individual cut string.
Definition: Selector.h:46
bool operator()(const reco::PFJet &jet)
Functor that operates on <T>
Definition: Selector.h:24
PF Jet selector for pat::Jets.
bool isPFJet() const
check to see if the jet is a reco::PFJet
Definition: Jet.h:255
int neutralMultiplicity() const
neutralMultiplicity
Definition: PFJet.h:157
bool operator()(const pat::Jet &jet, pat::strbitset &ret) override
strbitset & set(bool val=true)
set method of all bits
Definition: strbitset.h:144
std::string currentJECLevel() const
return the name of the current step of jet energy corrections
Definition: Jet.h:141
Analysis-level calorimeter jet class.
Definition: Jet.h:80
size_t numberOfDaughters() const override
pat::strbitset getBitTemplate() const
Get an empty bitset with the proper names.
Definition: Selector.h:212
bool isBasicJet() const
check to see if the jet is no more than a reco::BasicJet
Definition: Jet.h:257
const_iterator begin() const
first daughter const_iterator
Definition: Candidate.h:144
float neutralHadronEnergy() const
neutralHadronEnergy
Definition: PFJet.h:102
void setIgnoredCuts(std::vector< std::string > const &bitsToIgnore)
set the bits to ignore from a vector
Definition: Selector.h:167
float neutralEmEnergyFraction() const
neutralEmEnergyFraction (relative to uncorrected jet energy)
Definition: Jet.h:378
Jet correctedJet(const std::string &level, const std::string &flavor="none", const std::string &set="") const
int chargedMultiplicity() const
chargedMultiplicity
Definition: Jet.h:684
bool firstDataCuts(reco::Jet const &jet, pat::strbitset &ret, Version_t version_)
float chargedHadronEnergy() const
chargedHadronEnergy
Definition: PFJet.h:98
int cut(index_type const &i, int val) const
Access the int cut values at index "s".
Definition: Selector.h:194