![]() |
![]() |
00001 #include "EgammaAnalysis/ElectronTools/interface/ElectronEPcombinator.h" 00002 #include <iostream> 00003 00004 //Accessor to the combination results 00005 void ElectronEPcombinator::combine(SimpleElectron & electron) 00006 { 00007 electron_ = electron; 00008 computeEPcombination(); 00009 electron.setCombinedMomentum(combinedMomentum_); 00010 electron.setCombinedMomentumError(combinedMomentumError_); 00011 } 00012 00013 //Core code to compute the EP combination 00014 void ElectronEPcombinator::computeEPcombination() 00015 { 00016 if ( mode_==1 ) 00017 { 00018 scEnergy_ = electron_.getNewEnergy(); 00019 scEnergyError_ = electron_.getNewEnergyError(); 00020 } 00021 if ( mode_==2 ) 00022 { 00023 scEnergy_ = electron_.getRegEnergy(); 00024 scEnergyError_ = electron_.getRegEnergyError(); 00025 } 00026 trackerMomentum_ = electron_.getTrackerMomentum(); 00027 trackerMomentumError_ = electron_.getTrackerMomentumError(); 00028 elClass_ = electron_.getElClass(); 00029 00030 combinedMomentum_ = scEnergy_; // initial 00031 combinedMomentumError_ = 999.; 00032 00033 // first check for large errors 00034 00035 if ( trackerMomentumError_/trackerMomentum_ > 0.5 00036 && scEnergyError_/scEnergy_ <= 0.5 ) 00037 { 00038 combinedMomentum_ = scEnergy_; 00039 combinedMomentumError_ = scEnergyError_; 00040 } 00041 else if ( trackerMomentumError_/trackerMomentum_ <= 0.5 00042 && scEnergyError_/scEnergy_ > 0.5 ) 00043 { 00044 combinedMomentum_ = trackerMomentum_; 00045 combinedMomentumError_ = trackerMomentumError_; 00046 } 00047 else if ( trackerMomentumError_/trackerMomentum_ > 0.5 00048 && scEnergyError_/scEnergy_ > 0.5 ) 00049 { 00050 if ( trackerMomentumError_/trackerMomentum_ < scEnergyError_/scEnergy_ ) 00051 { 00052 combinedMomentum_ = trackerMomentum_; 00053 combinedMomentumError_ = trackerMomentumError_; 00054 } 00055 else 00056 { 00057 combinedMomentum_ = scEnergy_; 00058 combinedMomentumError_ = scEnergyError_; 00059 } 00060 } 00061 00062 // then apply the combination algorithm 00063 else 00064 { 00065 // calculate E/p and corresponding error 00066 float eOverP = scEnergy_ / trackerMomentum_; 00067 float errorEOverP = sqrt( 00068 (scEnergyError_/trackerMomentum_)*(scEnergyError_/trackerMomentum_) + 00069 (scEnergy_*trackerMomentumError_/trackerMomentum_/trackerMomentum_) * 00070 (scEnergy_*trackerMomentumError_/trackerMomentum_/trackerMomentum_) ); 00071 00072 bool eleIsNotInCombination = false; 00073 if ( ( eOverP > 1 + 2.5*errorEOverP ) 00074 || ( eOverP < 1 - 2.5*errorEOverP ) 00075 || ( eOverP < 0.8 ) || ( eOverP > 1.3 ) ) 00076 { 00077 eleIsNotInCombination = true; 00078 } 00079 00080 if ( eleIsNotInCombination ) 00081 { 00082 if ( eOverP > 1 ) 00083 { 00084 combinedMomentum_ = scEnergy_; 00085 combinedMomentumError_ = scEnergyError_; 00086 } 00087 else 00088 { 00089 if ( elClass_ == 0 ) // == reco::GsfElectron::GOLDEN) 00090 { 00091 combinedMomentum_ = scEnergy_; 00092 combinedMomentumError_ = scEnergyError_; 00093 } 00094 if ( elClass_ == 1 ) //reco::GsfElectron::BIGBREM) 00095 { 00096 if ( scEnergy_ < 36 ) 00097 { 00098 combinedMomentum_ = trackerMomentum_; 00099 combinedMomentumError_ = trackerMomentumError_; 00100 } else 00101 { 00102 combinedMomentum_ = scEnergy_; 00103 combinedMomentumError_ = scEnergyError_; 00104 } 00105 } 00106 if ( elClass_ == 2 ) // == reco::GsfElectron::BADTRACK) 00107 { 00108 combinedMomentum_ = scEnergy_; 00109 combinedMomentumError_ = scEnergyError_; 00110 } 00111 if ( elClass_ == 3 ) //reco::GsfElectron::SHOWERING) 00112 { 00113 if ( scEnergy_ < 30 ) 00114 { 00115 combinedMomentum_ = trackerMomentum_; 00116 combinedMomentumError_ = trackerMomentumError_; 00117 } else 00118 { 00119 combinedMomentum_ = scEnergy_; 00120 combinedMomentumError_ = scEnergyError_; 00121 } 00122 } 00123 if ( elClass_ == 4 ) //reco::GsfElectron::GAP) 00124 { 00125 if ( scEnergy_ < 60 ) 00126 { 00127 combinedMomentum_ = trackerMomentum_; 00128 combinedMomentumError_ = trackerMomentumError_; 00129 } else 00130 { 00131 combinedMomentum_ = scEnergy_; 00132 combinedMomentumError_ = scEnergyError_; 00133 } 00134 } 00135 } 00136 } else 00137 { 00138 // combination 00139 combinedMomentum_ = (scEnergy_/scEnergyError_/scEnergyError_ 00140 + trackerMomentum_/trackerMomentumError_/trackerMomentumError_) / 00141 (1/scEnergyError_/scEnergyError_ + 1/trackerMomentumError_/trackerMomentumError_); 00142 float combinedMomentum_Variance = 1 / (1/scEnergyError_/scEnergyError_ + 1/trackerMomentumError_/trackerMomentumError_); 00143 combinedMomentumError_ = sqrt(combinedMomentum_Variance); 00144 } 00145 } 00146 }