CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
EpCombinationTool Class Reference

#include <EpCombinationTool.h>

Public Member Functions

void combine (SimpleElectron &mySimpleElectron)
 
 EpCombinationTool ()
 
bool init (const std::string &regressionFile, const std::string &bdtName="")
 
 ~EpCombinationTool ()
 

Private Attributes

GBRForestm_forest
 

Detailed Description

Definition at line 10 of file EpCombinationTool.h.

Constructor & Destructor Documentation

EpCombinationTool::EpCombinationTool ( )

Definition at line 13 of file EpCombinationTool.cc.

13  :
14  m_forest(NULL)
15 /*****************************************************************/
16 {
17 }
#define NULL
Definition: scimark2.h:8
EpCombinationTool::~EpCombinationTool ( )

Definition at line 22 of file EpCombinationTool.cc.

References m_forest.

24 {
25  if(m_forest) delete m_forest;
26 }

Member Function Documentation

void EpCombinationTool::combine ( SimpleElectron mySimpleElectron)

Definition at line 54 of file EpCombinationTool.cc.

References gather_cfg::cout, relval_parameters_module::energy, energyError(), SimpleElectron::getElClass(), SimpleElectron::getNewEnergy(), SimpleElectron::getNewEnergyError(), GBRForest::GetResponse(), SimpleElectron::getTrackerMomentum(), SimpleElectron::getTrackerMomentumError(), SimpleElectron::isEB(), SimpleElectron::isEcalDriven(), SimpleElectron::isTrackerDriven(), m_forest, SimpleElectron::setCombinedMomentum(), SimpleElectron::setCombinedMomentumError(), mathSSE::sqrt(), and histoStyle::weight.

56 {
57  if(!m_forest)
58  {
59  cout<<"ERROR: The combination tool is not initialized\n";
60  return;
61  }
62 
63  float energy = mySimpleElectron.getNewEnergy();
64  float energyError = mySimpleElectron.getNewEnergyError();
65  float momentum = mySimpleElectron.getTrackerMomentum();
66  float momentumError = mySimpleElectron.getTrackerMomentumError();
67  int electronClass = mySimpleElectron.getElClass();
68  bool isEcalDriven = mySimpleElectron.isEcalDriven();
69  bool isTrackerDriven = mySimpleElectron.isTrackerDriven();
70  bool isEB = mySimpleElectron.isEB();
71 
72  // compute relative errors and ratio of errors
73  float energyRelError = energyError / energy;
74  float momentumRelError = momentumError / momentum;
75  float errorRatio = energyRelError / momentumRelError;
76 
77  // calculate E/p and corresponding error
78  float eOverP = energy / momentum;
79  float eOverPerror = sqrt(
80  (energyError/momentum)*(energyError/momentum) +
81  (energy*momentumError/momentum/momentum)*
82  (energy*momentumError/momentum/momentum));
83 
84  // fill input variables
85  float* regressionInputs = new float[11];
86  regressionInputs[0] = energy;
87  regressionInputs[1] = energyRelError;
88  regressionInputs[2] = momentum;
89  regressionInputs[3] = momentumRelError;
90  regressionInputs[4] = errorRatio;
91  regressionInputs[5] = eOverP;
92  regressionInputs[6] = eOverPerror;
93  regressionInputs[7] = static_cast<float>(isEcalDriven);
94  regressionInputs[8] = static_cast<float>(isTrackerDriven);
95  regressionInputs[9] = static_cast<float>(electronClass);
96  regressionInputs[10] = static_cast<float>(isEB);
97 
98  // retrieve combination weight
99  float weight = 0.;
100  if(eOverP>0.025
101  &&fabs(momentum-energy)<15.*sqrt(momentumError*momentumError + energyError*energyError)
102  ) // protection against crazy track measurement
103  {
104  weight = m_forest->GetResponse(regressionInputs);
105  if(weight>1.) weight = 1.;
106  else if(weight<0.) weight = 0.;
107  }
108 
109  float combinedMomentum = weight*momentum + (1.-weight)*energy;
110  float combinedMomentumError = sqrt(weight*weight*momentumError*momentumError + (1.-weight)*(1.-weight)*energyError*energyError);
111 
112  // FIXME : pure tracker electrons have track momentum error of 999.
113  // If the combination try to combine such electrons then the original combined momentum is kept
114  if(momentumError!=999. || weight==0.)
115  {
116  mySimpleElectron.setCombinedMomentum(combinedMomentum);
117  mySimpleElectron.setCombinedMomentumError(combinedMomentumError);
118  }
119 
120  delete[] regressionInputs;
121 }
double GetResponse(const float *vector) const
Definition: GBRForest.h:59
void setCombinedMomentum(double combinedMomentum)
bool isTrackerDriven()
double getTrackerMomentum()
double getNewEnergyError()
double getTrackerMomentumError()
T sqrt(T t)
Definition: SSEVec.h:48
double getNewEnergy()
tuple cout
Definition: gather_cfg.py:121
int weight
Definition: histoStyle.py:50
void setCombinedMomentumError(double combinedMomentumError)
float energyError(float E, float *par)
bool EpCombinationTool::init ( const std::string &  regressionFile,
const std::string &  bdtName = "" 
)

Definition at line 30 of file EpCombinationTool.cc.

References gather_cfg::cout, and m_forest.

32 {
33  TFile* regressionFile = TFile::Open(regressionFileName.c_str());
34  if(!regressionFile)
35  {
36  cout<<"ERROR: Cannot open regression file "<<regressionFileName<<"\n";
37  return false;
38  }
39  m_forest = (GBRForest*) regressionFile->Get(bdtName.c_str());
40  //regressionFile->GetObject(bdtName.c_str(), m_forest);
41  if(!m_forest)
42  {
43  cout<<"ERROR: Cannot find forest "<<bdtName<<" in "<<regressionFileName<<"\n";
44  regressionFile->Close();
45  return false;
46  }
47  regressionFile->Close();
48  return true;
49 }
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

GBRForest* EpCombinationTool::m_forest
private

Definition at line 25 of file EpCombinationTool.h.

Referenced by combine(), init(), and ~EpCombinationTool().