CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ElectronVPlusJetsIDSelectionFunctor.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_PatUtils_interface_ElectronVPlusJetsIDSelectionFunctor_h
2 #define PhysicsTools_PatUtils_interface_ElectronVPlusJetsIDSelectionFunctor_h
3 
4 #ifndef __GCCXML__
6 #endif
9 
12 
13 class ElectronVPlusJetsIDSelectionFunctor : public Selector<pat::Electron> {
14 
15  public: // interface
16 
18 
20 
21 #ifndef __GCCXML__
24  {}
25 #endif
26 
28 
29  std::string versionStr = parameters.getParameter<std::string>("version");
30  if ( versionStr != "FIRSTDATA") {
31  std::cout << "The version " << versionStr << " is deprecated. Setting to FIRSTDATA" << std::endl;
32  }
33 
34  if (versionStr == "FIRSTDATA") {
36  parameters.getParameter<double>("D0"),
37  parameters.getParameter<double>("ED0"),
38  parameters.getParameter<double>("SD0"),
39  parameters.getParameter<double>("RelIso") );
40  if ( parameters.exists("cutsToIgnore") )
41  setIgnoredCuts( parameters.getParameter<std::vector<std::string> >("cutsToIgnore") );
42  } else {
43  throw cms::Exception("InvalidInput") << "Expect version to be one of SUMMER08, FIRSTDATA," << std::endl;
44  }
45 
47 
48  }
49 
50 
52  double d0 = 0.2,
53  double ed0 = 999.0,
54  double sd0 = 999.0,
55  double reliso = 0.1) {
56  initialize( version, d0, ed0, sd0, reliso );
57  }
58 
59 
61  double d0,
62  double ed0,
63  double sd0,
64  double reliso)
65  {
66  version_ = version;
67 
68  push_back("D0", d0);
69  push_back("ED0", ed0);
70  push_back("SD0", sd0);
71  push_back("RelIso", reliso);
72 
73  // all on by default
74  set("D0");
75  set("ED0");
76  set("SD0");
77  set("RelIso");
78 
79 
80  indexD0_ = index_type(&bits_, "D0" );
81  indexED0_ = index_type(&bits_, "ED0" );
82  indexSD0_ = index_type(&bits_, "SD0" );
83  indexRelIso_ = index_type(&bits_, "RelIso" );
84 
85  }
86 
87  // Allow for multiple definitions of the cuts.
89  {
90  if ( version_ == FIRSTDATA ) return firstDataCuts( electron, ret );
91  else {
92  return false;
93  }
94  }
95 
97 
98  // cuts based on craft 08 analysis.
100  {
101 
102  ret.set(false);
103  double corr_d0 = electron.dB();
104  double corr_ed0 = electron.edB();
105  double corr_sd0 = ( corr_ed0 > 0.000000001 ) ? corr_d0 / corr_ed0 : 999.0;
106 
107  double hcalIso = electron.dr03HcalTowerSumEt();
108  double ecalIso = electron.dr03EcalRecHitSumEt();
109  double trkIso = electron.dr03TkSumPt();
110  double et = electron.et() ;
111 
112  double relIso = (ecalIso + hcalIso + trkIso) / et;
113 
114  if ( fabs(corr_d0) < cut(indexD0_, double()) || ignoreCut(indexD0_) ) passCut(ret, indexD0_ );
115  if ( fabs(corr_ed0)< cut(indexED0_, double()) || ignoreCut(indexED0_) ) passCut(ret, indexED0_ );
116  if ( fabs(corr_sd0)< cut(indexSD0_, double()) || ignoreCut(indexSD0_) ) passCut(ret, indexSD0_ );
117  if ( relIso < cut(indexRelIso_, double()) || ignoreCut(indexRelIso_) ) passCut(ret, indexRelIso_ );
118 
119  setIgnored(ret);
120  return (bool)ret;
121  }
122 
123 
124  private: // member variables
125 
127 
132 
133 };
134 
135 #endif
T getParameter(std::string const &) const
void set(std::string const &s, bool val=true)
Set a given selection cut, on or off.
Definition: Selector.h:105
dictionary parameters
Definition: Parameters.py:2
virtual double et() const
transverse energy
bool firstDataCuts(const pat::Electron &electron, pat::strbitset &ret)
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
pat::strbitset retInternal_
internal ret if users don&#39;t care about return bits
Definition: Selector.h:287
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
void initialize(Version_t version, double d0, double ed0, double sd0, double reliso)
bool ignoreCut(std::string const &s) const
ignore the cut at index &quot;s&quot;
Definition: Selector.h:159
float dr03TkSumPt() const
Definition: GsfElectron.h:491
virtual void push_back(std::string const &s)
This is the registration of an individual cut string.
Definition: Selector.h:46
Functor that operates on &lt;T&gt;
Definition: Selector.h:24
ElectronVPlusJetsIDSelectionFunctor(edm::ParameterSet const &parameters, edm::ConsumesCollector &iC)
strbitset & set(bool val=true)
set method of all bits
Definition: strbitset.h:144
Analysis-level electron class.
Definition: Electron.h:52
float dr03EcalRecHitSumEt() const
Definition: GsfElectron.h:492
pat::strbitset getBitTemplate() const
Get an empty bitset with the proper names.
Definition: Selector.h:212
ElectronVPlusJetsIDSelectionFunctor(edm::ParameterSet const &parameters)
double dB(IPTYPE type) const
Impact parameter wrt primary vertex or beamspot.
ElectronVPlusJetsIDSelectionFunctor(Version_t version, double d0=0.2, double ed0=999.0, double sd0=999.0, double reliso=0.1)
float dr03HcalTowerSumEt() const
Definition: GsfElectron.h:495
tuple cout
Definition: gather_cfg.py:121
void setIgnoredCuts(std::vector< std::string > const &bitsToIgnore)
set the bits to ignore from a vector
Definition: Selector.h:167
bool operator()(const pat::Electron &electron, pat::strbitset &ret)
This provides the interface for base classes to select objects.
double edB(IPTYPE type) const
Uncertainty on the corresponding impact parameter.
int cut(index_type const &i, int val) const
Access the int cut values at index &quot;s&quot;.
Definition: Selector.h:194