CMS 3D CMS Logo

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 
12  type_(convertFromStr(typeStr)){}
13 
14  static EnergyType convertFromStr(const std::string& typeStr){
15  if(typeStr=="EcalTrk") return EnergyType::EcalTrk;
16  else if(typeStr=="Ecal") return EnergyType::Ecal;
17  else if(typeStr=="SuperCluster") return EnergyType::SuperCluster;
18  else if(typeStr=="SuperClusterRaw") return EnergyType::SuperClusterRaw;
19  else {
20  throw cms::Exception("ConfigError") <<" type \""<<typeStr<<"\" not recognised, must be of type EcalTrk,Ecal,SuperCluster,SuperClusterRaw";
21  }
22  }
23 
24  float operator()(const reco::GsfElectron& ele)const{
25  switch(type_){
26  case EnergyType::EcalTrk: return ele.energy();
27  case EnergyType::Ecal: return ele.ecalEnergy();
28  case EnergyType::SuperCluster: return ele.superCluster()->energy();
29  case EnergyType::SuperClusterRaw: return ele.superCluster()->rawEnergy();
30  }
31  return 0.;
32  }
33 
34 private:
36 
37 };
38 
39 #endif
static EnergyType convertFromStr(const std::string &typeStr)
float operator()(const reco::GsfElectron &ele) const
double energy() const final
energy
float ecalEnergy() const
Definition: GsfElectron.h:859
EleEnergyRetriever(const std::string &typeStr)
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:185