CMS 3D CMS Logo

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 public: // interface
16 
18 
19 #ifndef __GCCXML__
22 #endif
23 
25  std::string versionStr = parameters.getParameter<std::string>("version");
26  if (versionStr != "FIRSTDATA") {
27  std::cout << "The version " << versionStr << " is deprecated. Setting to FIRSTDATA" << std::endl;
28  }
29 
30  if (versionStr == "FIRSTDATA") {
32  parameters.getParameter<double>("D0"),
33  parameters.getParameter<double>("ED0"),
34  parameters.getParameter<double>("SD0"),
35  parameters.getParameter<double>("RelIso"));
36  if (parameters.exists("cutsToIgnore"))
37  setIgnoredCuts(parameters.getParameter<std::vector<std::string> >("cutsToIgnore"));
38  } else {
39  throw cms::Exception("InvalidInput") << "Expect version to be one of SUMMER08, FIRSTDATA," << std::endl;
40  }
41 
43  }
44 
46  Version_t version, double d0 = 0.2, double ed0 = 999.0, double sd0 = 999.0, double reliso = 0.1) {
47  initialize(version, d0, ed0, sd0, reliso);
48  }
49 
50  void initialize(Version_t version, double d0, double ed0, double sd0, double reliso) {
51  version_ = version;
52 
53  push_back("D0", d0);
54  push_back("ED0", ed0);
55  push_back("SD0", sd0);
56  push_back("RelIso", reliso);
57 
58  // all on by default
59  set("D0");
60  set("ED0");
61  set("SD0");
62  set("RelIso");
63 
64  indexD0_ = index_type(&bits_, "D0");
65  indexED0_ = index_type(&bits_, "ED0");
66  indexSD0_ = index_type(&bits_, "SD0");
67  indexRelIso_ = index_type(&bits_, "RelIso");
68  }
69 
70  // Allow for multiple definitions of the cuts.
72  if (version_ == FIRSTDATA)
73  return firstDataCuts(electron, ret);
74  else {
75  return false;
76  }
77  }
78 
80 
81  // cuts based on craft 08 analysis.
83  ret.set(false);
84  double corr_d0 = electron.dB();
85  double corr_ed0 = electron.edB();
86  double corr_sd0 = (corr_ed0 > 0.000000001) ? corr_d0 / corr_ed0 : 999.0;
87 
88  double hcalIso = electron.dr03HcalTowerSumEt();
89  double ecalIso = electron.dr03EcalRecHitSumEt();
90  double trkIso = electron.dr03TkSumPt();
91  double et = electron.et();
92 
93  double relIso = (ecalIso + hcalIso + trkIso) / et;
94 
95  if (fabs(corr_d0) < cut(indexD0_, double()) || ignoreCut(indexD0_))
97  if (fabs(corr_ed0) < cut(indexED0_, double()) || ignoreCut(indexED0_))
99  if (fabs(corr_sd0) < cut(indexSD0_, double()) || ignoreCut(indexSD0_))
101  if (relIso < cut(indexRelIso_, double()) || ignoreCut(indexRelIso_))
103 
104  setIgnored(ret);
105  return (bool)ret;
106  }
107 
108 private: // member variables
110 
115 };
116 
117 #endif
bool ignoreCut(std::string const &s) const
ignore the cut at index "s"
Definition: Selector.h:127
bool operator()(const pat::Electron &electron, pat::strbitset &ret) override
This provides the interface for base classes to select objects.
ret
prodAgent to be discontinued
bool firstDataCuts(const pat::Electron &electron, pat::strbitset &ret)
pat::strbitset::index_type index_type
Definition: Selector.h:25
void setIgnored(pat::strbitset &ret)
set ignored bits
Definition: Selector.h:181
pat::strbitset retInternal_
internal ret if users don&#39;t care about return bits
Definition: Selector.h:242
pat::strbitset bits_
the bitset indexed by strings
Definition: Selector.h:241
void passCut(pat::strbitset &ret, std::string const &s)
Passing cuts.
Definition: Selector.h:142
void initialize(Version_t version, double d0, double ed0, double sd0, double reliso)
virtual void push_back(std::string const &s)
This is the registration of an individual cut string.
Definition: Selector.h:42
Functor that operates on <T>
Definition: Selector.h:22
static constexpr float d0
ElectronVPlusJetsIDSelectionFunctor(edm::ParameterSet const &parameters, edm::ConsumesCollector &iC)
pat::strbitset getBitTemplate() const
Get an empty bitset with the proper names.
Definition: Selector.h:168
int cut(index_type const &i, int val) const
Access the int cut values at index "s".
Definition: Selector.h:158
Analysis-level electron class.
Definition: Electron.h:51
ElectronVPlusJetsIDSelectionFunctor(edm::ParameterSet const &parameters)
ElectronVPlusJetsIDSelectionFunctor(Version_t version, double d0=0.2, double ed0=999.0, double sd0=999.0, double reliso=0.1)
void setIgnoredCuts(std::vector< std::string > const &bitsToIgnore)
set the bits to ignore from a vector
Definition: Selector.h:131