CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EleEnergyRetriever.h
Go to the documentation of this file.
1 #ifndef RecoEgamma_EgammaTools_EleEnergyRetriever_h
2 #define RecoEgamma_EgammaTools_EleEnergyRetriever_h
3 
6 
8 public:
10 
11  EleEnergyRetriever(const std::string& typeStr) : type_(convertFromStr(typeStr)) {}
12 
13  static EnergyType convertFromStr(const std::string& typeStr) {
14  if (typeStr == "EcalTrk")
15  return EnergyType::EcalTrk;
16  else if (typeStr == "Ecal")
17  return EnergyType::Ecal;
18  else if (typeStr == "SuperCluster")
20  else if (typeStr == "SuperClusterRaw")
22  else {
23  throw cms::Exception("ConfigError")
24  << " type \"" << typeStr << "\" not recognised, must be of type EcalTrk,Ecal,SuperCluster,SuperClusterRaw";
25  }
26  }
27 
28  float operator()(const reco::GsfElectron& ele) const {
29  switch (type_) {
31  return ele.energy();
32  case EnergyType::Ecal:
33  return ele.ecalEnergy();
35  return ele.superCluster()->energy();
37  return ele.superCluster()->rawEnergy();
38  }
39  return 0.;
40  }
41 
42 private:
44 };
45 
46 #endif
static EnergyType convertFromStr(const std::string &typeStr)
float operator()(const reco::GsfElectron &ele) const
float ecalEnergy() const
Definition: GsfElectron.h:896
EleEnergyRetriever(const std::string &typeStr)
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:155
double energy() const final
energy