00001 #include <TFile.h>
00002 #include "EgammaAnalysis/ElectronTools/interface/EGammaMvaEleEstimator.h"
00003 #include <cmath>
00004 #include <vector>
00005 using namespace std;
00006
00007 #ifndef STANDALONE
00008 #include "DataFormats/TrackReco/interface/Track.h"
00009 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
00010 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00011 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00012 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00013 #include "DataFormats/MuonReco/interface/Muon.h"
00014 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
00015 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
00016 #include "DataFormats/Common/interface/RefToPtr.h"
00017 #include "DataFormats/VertexReco/interface/Vertex.h"
00018 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"
00019 #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
00020 #include "TrackingTools/IPTools/interface/IPTools.h"
00021 #include "EgammaAnalysis/ElectronTools/interface/ElectronEffectiveArea.h"
00022 #include "DataFormats/Common/interface/RefToPtr.h"
00023 using namespace reco;
00024 #endif
00025
00026
00027 EGammaMvaEleEstimator::EGammaMvaEleEstimator() :
00028 fMethodname("BDTG method"),
00029 fisInitialized(kFALSE),
00030 fMVAType(kTrig),
00031 fUseBinnedVersion(kTRUE),
00032 fNMVABins(0)
00033 {
00034
00035 }
00036
00037
00038 EGammaMvaEleEstimator::~EGammaMvaEleEstimator()
00039 {
00040 for (unsigned int i=0;i<fTMVAReader.size(); ++i) {
00041 if (fTMVAReader[i]) delete fTMVAReader[i];
00042 }
00043 }
00044
00045
00046 void EGammaMvaEleEstimator::initialize( std::string methodName,
00047 std::string weightsfile,
00048 EGammaMvaEleEstimator::MVAType type)
00049 {
00050
00051 std::vector<std::string> tempWeightFileVector;
00052 tempWeightFileVector.push_back(weightsfile);
00053 initialize(methodName,type,kFALSE,tempWeightFileVector);
00054 }
00055
00056
00057
00058 void EGammaMvaEleEstimator::initialize( std::string methodName,
00059 EGammaMvaEleEstimator::MVAType type,
00060 Bool_t useBinnedVersion,
00061 std::vector<std::string> weightsfiles
00062 ) {
00063
00064
00065 for (unsigned int i=0;i<fTMVAReader.size(); ++i) {
00066 if (fTMVAReader[i]) delete fTMVAReader[i];
00067 }
00068 fTMVAReader.clear();
00069
00070
00071 fisInitialized = kTRUE;
00072 fMVAType = type;
00073 fMethodname = methodName;
00074 fUseBinnedVersion = useBinnedVersion;
00075
00076
00077 UInt_t ExpectedNBins = 0;
00078 if (!fUseBinnedVersion) {
00079 ExpectedNBins = 1;
00080 } else if (type == kTrig) {
00081 ExpectedNBins = 6;
00082 }else if (type == kTrigNoIP) {
00083 ExpectedNBins = 6;
00084 } else if (type == kNonTrig) {
00085 ExpectedNBins = 6;
00086 } else if (type == kIsoRings) {
00087 ExpectedNBins = 4;
00088 } else if (type == kTrigIDIsoCombined) {
00089 ExpectedNBins = 6;
00090 } else if (type == kTrigIDIsoCombinedPUCorrected) {
00091 ExpectedNBins = 6;
00092 }
00093
00094 fNMVABins = ExpectedNBins;
00095
00096
00097 if (fNMVABins != weightsfiles.size() ) {
00098 std::cout << "Error: Expected Number of bins = " << fNMVABins << " does not equal to weightsfiles.size() = "
00099 << weightsfiles.size() << std::endl;
00100
00101 #ifndef STANDALONE
00102 assert(fNMVABins == weightsfiles.size());
00103 #endif
00104 }
00105
00106
00107 for (unsigned int i=0;i<fNMVABins; ++i) {
00108
00109 TMVA::Reader *tmpTMVAReader = new TMVA::Reader( "!Color:!Silent:Error" );
00110 tmpTMVAReader->SetVerbose(kTRUE);
00111
00112 if (type == kTrig) {
00113
00114 tmpTMVAReader->AddVariable("fbrem", &fMVAVar_fbrem);
00115 tmpTMVAReader->AddVariable("kfchi2", &fMVAVar_kfchi2);
00116 tmpTMVAReader->AddVariable("kfhits", &fMVAVar_kfhits);
00117 tmpTMVAReader->AddVariable("gsfchi2", &fMVAVar_gsfchi2);
00118
00119
00120 tmpTMVAReader->AddVariable("deta", &fMVAVar_deta);
00121 tmpTMVAReader->AddVariable("dphi", &fMVAVar_dphi);
00122 tmpTMVAReader->AddVariable("detacalo", &fMVAVar_detacalo);
00123
00124
00125 tmpTMVAReader->AddVariable("see", &fMVAVar_see);
00126 tmpTMVAReader->AddVariable("spp", &fMVAVar_spp);
00127 tmpTMVAReader->AddVariable("etawidth", &fMVAVar_etawidth);
00128 tmpTMVAReader->AddVariable("phiwidth", &fMVAVar_phiwidth);
00129 tmpTMVAReader->AddVariable("e1x5e5x5", &fMVAVar_OneMinusE1x5E5x5);
00130 tmpTMVAReader->AddVariable("R9", &fMVAVar_R9);
00131
00132
00133 tmpTMVAReader->AddVariable("HoE", &fMVAVar_HoE);
00134 tmpTMVAReader->AddVariable("EoP", &fMVAVar_EoP);
00135 tmpTMVAReader->AddVariable("IoEmIoP", &fMVAVar_IoEmIoP);
00136 tmpTMVAReader->AddVariable("eleEoPout", &fMVAVar_eleEoPout);
00137 if(i == 2 || i == 5)
00138 tmpTMVAReader->AddVariable("PreShowerOverRaw",&fMVAVar_PreShowerOverRaw);
00139
00140 if(!fUseBinnedVersion)
00141 tmpTMVAReader->AddVariable("PreShowerOverRaw",&fMVAVar_PreShowerOverRaw);
00142
00143
00144 tmpTMVAReader->AddVariable("d0", &fMVAVar_d0);
00145 tmpTMVAReader->AddVariable("ip3d", &fMVAVar_ip3d);
00146
00147 tmpTMVAReader->AddSpectator("eta", &fMVAVar_eta);
00148 tmpTMVAReader->AddSpectator("pt", &fMVAVar_pt);
00149 }
00150
00151 if (type == kTrigNoIP) {
00152
00153
00154
00155 tmpTMVAReader->AddVariable("fbrem", &fMVAVar_fbrem);
00156 tmpTMVAReader->AddVariable("kfchi2", &fMVAVar_kfchi2);
00157 tmpTMVAReader->AddVariable("kfhits", &fMVAVar_kfhits);
00158 tmpTMVAReader->AddVariable("gsfchi2", &fMVAVar_gsfchi2);
00159
00160
00161 tmpTMVAReader->AddVariable("deta", &fMVAVar_deta);
00162 tmpTMVAReader->AddVariable("dphi", &fMVAVar_dphi);
00163 tmpTMVAReader->AddVariable("detacalo", &fMVAVar_detacalo);
00164
00165
00166 tmpTMVAReader->AddVariable("see", &fMVAVar_see);
00167 tmpTMVAReader->AddVariable("spp", &fMVAVar_spp);
00168 tmpTMVAReader->AddVariable("etawidth", &fMVAVar_etawidth);
00169 tmpTMVAReader->AddVariable("phiwidth", &fMVAVar_phiwidth);
00170 tmpTMVAReader->AddVariable("e1x5e5x5", &fMVAVar_OneMinusE1x5E5x5);
00171 tmpTMVAReader->AddVariable("R9", &fMVAVar_R9);
00172
00173
00174 tmpTMVAReader->AddVariable("HoE", &fMVAVar_HoE);
00175 tmpTMVAReader->AddVariable("EoP", &fMVAVar_EoP);
00176 tmpTMVAReader->AddVariable("IoEmIoP", &fMVAVar_IoEmIoP);
00177 tmpTMVAReader->AddVariable("eleEoPout", &fMVAVar_eleEoPout);
00178 tmpTMVAReader->AddVariable("rho", &fMVAVar_rho);
00179
00180 if(i == 2 || i == 5)
00181 tmpTMVAReader->AddVariable("PreShowerOverRaw",&fMVAVar_PreShowerOverRaw);
00182
00183 if(!fUseBinnedVersion)
00184 tmpTMVAReader->AddVariable("PreShowerOverRaw",&fMVAVar_PreShowerOverRaw);
00185
00186 tmpTMVAReader->AddSpectator("eta", &fMVAVar_eta);
00187 tmpTMVAReader->AddSpectator("pt", &fMVAVar_pt);
00188
00189 }
00190
00191 if (type == kNonTrig) {
00192
00193
00194 tmpTMVAReader->AddVariable("fbrem", &fMVAVar_fbrem);
00195 tmpTMVAReader->AddVariable("kfchi2", &fMVAVar_kfchi2);
00196 tmpTMVAReader->AddVariable("kfhits", &fMVAVar_kfhits);
00197 tmpTMVAReader->AddVariable("gsfchi2", &fMVAVar_gsfchi2);
00198
00199
00200 tmpTMVAReader->AddVariable("deta", &fMVAVar_deta);
00201 tmpTMVAReader->AddVariable("dphi", &fMVAVar_dphi);
00202 tmpTMVAReader->AddVariable("detacalo", &fMVAVar_detacalo);
00203
00204
00205 tmpTMVAReader->AddVariable("see", &fMVAVar_see);
00206 tmpTMVAReader->AddVariable("spp", &fMVAVar_spp);
00207 tmpTMVAReader->AddVariable("etawidth", &fMVAVar_etawidth);
00208 tmpTMVAReader->AddVariable("phiwidth", &fMVAVar_phiwidth);
00209 tmpTMVAReader->AddVariable("e1x5e5x5", &fMVAVar_OneMinusE1x5E5x5);
00210 tmpTMVAReader->AddVariable("R9", &fMVAVar_R9);
00211
00212
00213 tmpTMVAReader->AddVariable("HoE", &fMVAVar_HoE);
00214 tmpTMVAReader->AddVariable("EoP", &fMVAVar_EoP);
00215 tmpTMVAReader->AddVariable("IoEmIoP", &fMVAVar_IoEmIoP);
00216 tmpTMVAReader->AddVariable("eleEoPout", &fMVAVar_eleEoPout);
00217 if(i == 2 || i == 5)
00218 tmpTMVAReader->AddVariable("PreShowerOverRaw",&fMVAVar_PreShowerOverRaw);
00219
00220 if(!fUseBinnedVersion)
00221 tmpTMVAReader->AddVariable("PreShowerOverRaw",&fMVAVar_PreShowerOverRaw);
00222
00223 tmpTMVAReader->AddSpectator("eta", &fMVAVar_eta);
00224 tmpTMVAReader->AddSpectator("pt", &fMVAVar_pt);
00225
00226 }
00227
00228 if (type == kIsoRings) {
00229 tmpTMVAReader->AddVariable( "ChargedIso_DR0p0To0p1", &fMVAVar_ChargedIso_DR0p0To0p1 );
00230 tmpTMVAReader->AddVariable( "ChargedIso_DR0p1To0p2", &fMVAVar_ChargedIso_DR0p1To0p2 );
00231 tmpTMVAReader->AddVariable( "ChargedIso_DR0p2To0p3", &fMVAVar_ChargedIso_DR0p2To0p3 );
00232 tmpTMVAReader->AddVariable( "ChargedIso_DR0p3To0p4", &fMVAVar_ChargedIso_DR0p3To0p4 );
00233 tmpTMVAReader->AddVariable( "ChargedIso_DR0p4To0p5", &fMVAVar_ChargedIso_DR0p4To0p5 );
00234 tmpTMVAReader->AddVariable( "GammaIso_DR0p0To0p1", &fMVAVar_GammaIso_DR0p0To0p1 );
00235 tmpTMVAReader->AddVariable( "GammaIso_DR0p1To0p2", &fMVAVar_GammaIso_DR0p1To0p2 );
00236 tmpTMVAReader->AddVariable( "GammaIso_DR0p2To0p3", &fMVAVar_GammaIso_DR0p2To0p3 );
00237 tmpTMVAReader->AddVariable( "GammaIso_DR0p3To0p4", &fMVAVar_GammaIso_DR0p3To0p4 );
00238 tmpTMVAReader->AddVariable( "GammaIso_DR0p4To0p5", &fMVAVar_GammaIso_DR0p4To0p5 );
00239 tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p0To0p1", &fMVAVar_NeutralHadronIso_DR0p0To0p1 );
00240 tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p1To0p2", &fMVAVar_NeutralHadronIso_DR0p1To0p2 );
00241 tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p2To0p3", &fMVAVar_NeutralHadronIso_DR0p2To0p3 );
00242 tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p3To0p4", &fMVAVar_NeutralHadronIso_DR0p3To0p4 );
00243 tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p4To0p5", &fMVAVar_NeutralHadronIso_DR0p4To0p5 );
00244 tmpTMVAReader->AddSpectator("eta", &fMVAVar_eta);
00245 tmpTMVAReader->AddSpectator("pt", &fMVAVar_pt);
00246 }
00247
00248
00249 if (type == kTrigIDIsoCombinedPUCorrected) {
00250
00251
00252 tmpTMVAReader->AddVariable("fbrem", &fMVAVar_fbrem);
00253 tmpTMVAReader->AddVariable("kfchi2", &fMVAVar_kfchi2);
00254 tmpTMVAReader->AddVariable("kflayers", &fMVAVar_kfhits);
00255 tmpTMVAReader->AddVariable("gsfchi2", &fMVAVar_gsfchi2);
00256
00257
00258 tmpTMVAReader->AddVariable("deta", &fMVAVar_deta);
00259 tmpTMVAReader->AddVariable("dphi", &fMVAVar_dphi);
00260 tmpTMVAReader->AddVariable("detacalo", &fMVAVar_detacalo);
00261
00262
00263 tmpTMVAReader->AddVariable("see", &fMVAVar_see);
00264 tmpTMVAReader->AddVariable("spp", &fMVAVar_spp);
00265 tmpTMVAReader->AddVariable("etawidth", &fMVAVar_etawidth);
00266 tmpTMVAReader->AddVariable("phiwidth", &fMVAVar_phiwidth);
00267 tmpTMVAReader->AddVariable("OneMinusSeedE1x5OverE5x5", &fMVAVar_OneMinusE1x5E5x5);
00268 tmpTMVAReader->AddVariable("R9", &fMVAVar_R9);
00269
00270
00271 tmpTMVAReader->AddVariable("HoE", &fMVAVar_HoE);
00272 tmpTMVAReader->AddVariable("EoP", &fMVAVar_EoP);
00273 tmpTMVAReader->AddVariable("IoEmIoP", &fMVAVar_IoEmIoP);
00274 tmpTMVAReader->AddVariable("EEleoPout", &fMVAVar_eleEoPout);
00275 if(i == 2 || i == 5) {
00276 tmpTMVAReader->AddVariable("PreShowerOverRaw",&fMVAVar_PreShowerOverRaw);
00277 }
00278 if(!fUseBinnedVersion) {
00279 tmpTMVAReader->AddVariable("PreShowerOverRaw",&fMVAVar_PreShowerOverRaw);
00280 }
00281
00282
00283 tmpTMVAReader->AddVariable("d0", &fMVAVar_d0);
00284 tmpTMVAReader->AddVariable("ip3d", &fMVAVar_ip3d);
00285
00286
00287 tmpTMVAReader->AddVariable( "ChargedIso_DR0p0To0p1", &fMVAVar_ChargedIso_DR0p0To0p1 );
00288 tmpTMVAReader->AddVariable( "ChargedIso_DR0p1To0p2", &fMVAVar_ChargedIso_DR0p1To0p2 );
00289 tmpTMVAReader->AddVariable( "ChargedIso_DR0p2To0p3", &fMVAVar_ChargedIso_DR0p2To0p3 );
00290 tmpTMVAReader->AddVariable( "ChargedIso_DR0p3To0p4", &fMVAVar_ChargedIso_DR0p3To0p4 );
00291 tmpTMVAReader->AddVariable( "ChargedIso_DR0p4To0p5", &fMVAVar_ChargedIso_DR0p4To0p5 );
00292 tmpTMVAReader->AddVariable( "GammaIso_DR0p0To0p1", &fMVAVar_GammaIso_DR0p0To0p1 );
00293 tmpTMVAReader->AddVariable( "GammaIso_DR0p1To0p2", &fMVAVar_GammaIso_DR0p1To0p2 );
00294 tmpTMVAReader->AddVariable( "GammaIso_DR0p2To0p3", &fMVAVar_GammaIso_DR0p2To0p3 );
00295 tmpTMVAReader->AddVariable( "GammaIso_DR0p3To0p4", &fMVAVar_GammaIso_DR0p3To0p4 );
00296 tmpTMVAReader->AddVariable( "GammaIso_DR0p4To0p5", &fMVAVar_GammaIso_DR0p4To0p5 );
00297 tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p0To0p1", &fMVAVar_NeutralHadronIso_DR0p0To0p1 );
00298 tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p1To0p2", &fMVAVar_NeutralHadronIso_DR0p1To0p2 );
00299 tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p2To0p3", &fMVAVar_NeutralHadronIso_DR0p2To0p3 );
00300 tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p3To0p4", &fMVAVar_NeutralHadronIso_DR0p3To0p4 );
00301 tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p4To0p5", &fMVAVar_NeutralHadronIso_DR0p4To0p5 );
00302
00303
00304 tmpTMVAReader->AddSpectator("eta", &fMVAVar_eta);
00305 tmpTMVAReader->AddSpectator("pt", &fMVAVar_pt);
00306
00307 }
00308
00309 if (type == kTrigIDIsoCombined) {
00310
00311
00312 tmpTMVAReader->AddVariable("fbrem", &fMVAVar_fbrem);
00313 tmpTMVAReader->AddVariable("kfchi2", &fMVAVar_kfchi2);
00314 tmpTMVAReader->AddVariable("kflayers", &fMVAVar_kfhits);
00315 tmpTMVAReader->AddVariable("gsfchi2", &fMVAVar_gsfchi2);
00316
00317
00318 tmpTMVAReader->AddVariable("deta", &fMVAVar_deta);
00319 tmpTMVAReader->AddVariable("dphi", &fMVAVar_dphi);
00320 tmpTMVAReader->AddVariable("detacalo", &fMVAVar_detacalo);
00321
00322
00323 tmpTMVAReader->AddVariable("see", &fMVAVar_see);
00324 tmpTMVAReader->AddVariable("spp", &fMVAVar_spp);
00325 tmpTMVAReader->AddVariable("etawidth", &fMVAVar_etawidth);
00326 tmpTMVAReader->AddVariable("phiwidth", &fMVAVar_phiwidth);
00327 tmpTMVAReader->AddVariable("OneMinusSeedE1x5OverE5x5", &fMVAVar_OneMinusE1x5E5x5);
00328 tmpTMVAReader->AddVariable("R9", &fMVAVar_R9);
00329
00330
00331 tmpTMVAReader->AddVariable("HoE", &fMVAVar_HoE);
00332 tmpTMVAReader->AddVariable("EoP", &fMVAVar_EoP);
00333 tmpTMVAReader->AddVariable("IoEmIoP", &fMVAVar_IoEmIoP);
00334 tmpTMVAReader->AddVariable("EEleoPout", &fMVAVar_eleEoPout);
00335 if(i == 2 || i == 5) {
00336 tmpTMVAReader->AddVariable("PreShowerOverRaw",&fMVAVar_PreShowerOverRaw);
00337 }
00338 if(!fUseBinnedVersion) {
00339 tmpTMVAReader->AddVariable("PreShowerOverRaw",&fMVAVar_PreShowerOverRaw);
00340 }
00341
00342
00343 tmpTMVAReader->AddVariable("d0", &fMVAVar_d0);
00344 tmpTMVAReader->AddVariable("ip3d", &fMVAVar_ip3d);
00345
00346
00347 tmpTMVAReader->AddVariable( "ChargedIso_DR0p0To0p1", &fMVAVar_ChargedIso_DR0p0To0p1 );
00348 tmpTMVAReader->AddVariable( "ChargedIso_DR0p1To0p2", &fMVAVar_ChargedIso_DR0p1To0p2 );
00349 tmpTMVAReader->AddVariable( "ChargedIso_DR0p2To0p3", &fMVAVar_ChargedIso_DR0p2To0p3 );
00350 tmpTMVAReader->AddVariable( "ChargedIso_DR0p3To0p4", &fMVAVar_ChargedIso_DR0p3To0p4 );
00351 tmpTMVAReader->AddVariable( "ChargedIso_DR0p4To0p5", &fMVAVar_ChargedIso_DR0p4To0p5 );
00352 tmpTMVAReader->AddVariable( "GammaIso_DR0p0To0p1", &fMVAVar_GammaIso_DR0p0To0p1 );
00353 tmpTMVAReader->AddVariable( "GammaIso_DR0p1To0p2", &fMVAVar_GammaIso_DR0p1To0p2 );
00354 tmpTMVAReader->AddVariable( "GammaIso_DR0p2To0p3", &fMVAVar_GammaIso_DR0p2To0p3 );
00355 tmpTMVAReader->AddVariable( "GammaIso_DR0p3To0p4", &fMVAVar_GammaIso_DR0p3To0p4 );
00356 tmpTMVAReader->AddVariable( "GammaIso_DR0p4To0p5", &fMVAVar_GammaIso_DR0p4To0p5 );
00357 tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p0To0p1", &fMVAVar_NeutralHadronIso_DR0p0To0p1 );
00358 tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p1To0p2", &fMVAVar_NeutralHadronIso_DR0p1To0p2 );
00359 tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p2To0p3", &fMVAVar_NeutralHadronIso_DR0p2To0p3 );
00360 tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p3To0p4", &fMVAVar_NeutralHadronIso_DR0p3To0p4 );
00361 tmpTMVAReader->AddVariable( "NeutralHadronIso_DR0p4To0p5", &fMVAVar_NeutralHadronIso_DR0p4To0p5 );
00362 tmpTMVAReader->AddVariable( "rho", &fMVAVar_rho );
00363
00364
00365 tmpTMVAReader->AddSpectator("eta", &fMVAVar_eta);
00366 tmpTMVAReader->AddSpectator("pt", &fMVAVar_pt);
00367
00368 }
00369
00370
00371
00372 tmpTMVAReader->BookMVA(fMethodname , weightsfiles[i]);
00373 std::cout << "MVABin " << i << " : MethodName = " << fMethodname
00374 << " , type == " << type << " , "
00375 << "Load weights file : " << weightsfiles[i]
00376 << std::endl;
00377 fTMVAReader.push_back(tmpTMVAReader);
00378 }
00379 std::cout << "Electron ID MVA Completed\n";
00380
00381 }
00382
00383
00384
00385 UInt_t EGammaMvaEleEstimator::GetMVABin( double eta, double pt) const {
00386
00387
00388 unsigned int bin = 0;
00389
00390 if (fMVAType == EGammaMvaEleEstimator::kIsoRings) {
00391 if (pt < 10 && fabs(eta) < 1.479) bin = 0;
00392 if (pt < 10 && fabs(eta) >= 1.479) bin = 1;
00393 if (pt >= 10 && fabs(eta) < 1.479) bin = 2;
00394 if (pt >= 10 && fabs(eta) >= 1.479) bin = 3;
00395 }
00396
00397 if (fMVAType == EGammaMvaEleEstimator::kNonTrig ) {
00398 bin = 0;
00399 if (pt < 10 && fabs(eta) < 0.8) bin = 0;
00400 if (pt < 10 && fabs(eta) >= 0.8 && fabs(eta) < 1.479 ) bin = 1;
00401 if (pt < 10 && fabs(eta) >= 1.479) bin = 2;
00402 if (pt >= 10 && fabs(eta) < 0.8) bin = 3;
00403 if (pt >= 10 && fabs(eta) >= 0.8 && fabs(eta) < 1.479 ) bin = 4;
00404 if (pt >= 10 && fabs(eta) >= 1.479) bin = 5;
00405 }
00406
00407
00408 if (fMVAType == EGammaMvaEleEstimator::kTrig ||
00409 fMVAType == EGammaMvaEleEstimator::kTrigIDIsoCombined ||
00410 fMVAType == EGammaMvaEleEstimator::kTrigIDIsoCombinedPUCorrected ||
00411 fMVAType == EGammaMvaEleEstimator::kTrigNoIP
00412 ) {
00413 bin = 0;
00414 if (pt < 20 && fabs(eta) < 0.8) bin = 0;
00415 if (pt < 20 && fabs(eta) >= 0.8 && fabs(eta) < 1.479 ) bin = 1;
00416 if (pt < 20 && fabs(eta) >= 1.479) bin = 2;
00417 if (pt >= 20 && fabs(eta) < 0.8) bin = 3;
00418 if (pt >= 20 && fabs(eta) >= 0.8 && fabs(eta) < 1.479 ) bin = 4;
00419 if (pt >= 20 && fabs(eta) >= 1.479) bin = 5;
00420 }
00421
00422
00423
00424 return bin;
00425 }
00426
00427
00428
00429
00430 Double_t EGammaMvaEleEstimator::mvaValue(Double_t fbrem,
00431 Double_t kfchi2,
00432 Int_t kfhits,
00433 Double_t gsfchi2,
00434 Double_t deta,
00435 Double_t dphi,
00436 Double_t detacalo,
00437
00438 Double_t see,
00439 Double_t spp,
00440 Double_t etawidth,
00441 Double_t phiwidth,
00442 Double_t OneMinusE1x5E5x5,
00443 Double_t R9,
00444
00445 Double_t HoE,
00446 Double_t EoP,
00447 Double_t IoEmIoP,
00448 Double_t eleEoPout,
00449 Double_t PreShowerOverRaw,
00450
00451 Double_t d0,
00452 Double_t ip3d,
00453 Double_t eta,
00454 Double_t pt,
00455 Bool_t printDebug) {
00456
00457 if (!fisInitialized) {
00458 std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
00459 return -9999;
00460 }
00461
00462 if (fMVAType != EGammaMvaEleEstimator::kTrig) {
00463 std::cout << "Error: This method should be called for kTrig MVA only" << endl;
00464 return -9999;
00465 }
00466
00467 fMVAVar_fbrem = fbrem;
00468 fMVAVar_kfchi2 = kfchi2;
00469 fMVAVar_kfhits = float(kfhits);
00470 fMVAVar_gsfchi2 = gsfchi2;
00471
00472 fMVAVar_deta = deta;
00473 fMVAVar_dphi = dphi;
00474 fMVAVar_detacalo = detacalo;
00475
00476
00477 fMVAVar_see = see;
00478 fMVAVar_spp = spp;
00479 fMVAVar_etawidth = etawidth;
00480 fMVAVar_phiwidth = phiwidth;
00481 fMVAVar_OneMinusE1x5E5x5 = OneMinusE1x5E5x5;
00482 fMVAVar_R9 = R9;
00483
00484
00485 fMVAVar_HoE = HoE;
00486 fMVAVar_EoP = EoP;
00487 fMVAVar_IoEmIoP = IoEmIoP;
00488 fMVAVar_eleEoPout = eleEoPout;
00489 fMVAVar_PreShowerOverRaw= PreShowerOverRaw;
00490
00491 fMVAVar_d0 = d0;
00492 fMVAVar_ip3d = ip3d;
00493 fMVAVar_eta = eta;
00494 fMVAVar_pt = pt;
00495
00496
00497 bindVariables();
00498 Double_t mva = -9999;
00499 if (fUseBinnedVersion) {
00500 mva = fTMVAReader[GetMVABin(fMVAVar_eta,fMVAVar_pt)]->EvaluateMVA(fMethodname);
00501 } else {
00502 mva = fTMVAReader[0]->EvaluateMVA(fMethodname);
00503 }
00504
00505 if(printDebug) {
00506 cout << " *** Inside the class fMethodname " << fMethodname << endl;
00507 cout << " fbrem " << fMVAVar_fbrem
00508 << " kfchi2 " << fMVAVar_kfchi2
00509 << " mykfhits " << fMVAVar_kfhits
00510 << " gsfchi2 " << fMVAVar_gsfchi2
00511 << " deta " << fMVAVar_deta
00512 << " dphi " << fMVAVar_dphi
00513 << " detacalo " << fMVAVar_detacalo
00514 << " see " << fMVAVar_see
00515 << " spp " << fMVAVar_spp
00516 << " etawidth " << fMVAVar_etawidth
00517 << " phiwidth " << fMVAVar_phiwidth
00518 << " OneMinusE1x5E5x5 " << fMVAVar_OneMinusE1x5E5x5
00519 << " R9 " << fMVAVar_R9
00520 << " HoE " << fMVAVar_HoE
00521 << " EoP " << fMVAVar_EoP
00522 << " IoEmIoP " << fMVAVar_IoEmIoP
00523 << " eleEoPout " << fMVAVar_eleEoPout
00524 << " PreShowerOverRaw " << fMVAVar_PreShowerOverRaw
00525 << " d0 " << fMVAVar_d0
00526 << " ip3d " << fMVAVar_ip3d
00527 << " eta " << fMVAVar_eta
00528 << " pt " << fMVAVar_pt << endl;
00529 cout << " ### MVA " << mva << endl;
00530 }
00531
00532
00533 return mva;
00534 }
00535
00536
00537
00538 Double_t EGammaMvaEleEstimator::mvaValue(Double_t fbrem,
00539 Double_t kfchi2,
00540 Int_t kfhits,
00541 Double_t gsfchi2,
00542 Double_t deta,
00543 Double_t dphi,
00544 Double_t detacalo,
00545 Double_t see,
00546 Double_t spp,
00547 Double_t etawidth,
00548 Double_t phiwidth,
00549 Double_t e1x5e5x5,
00550 Double_t R9,
00551 Double_t HoE,
00552 Double_t EoP,
00553 Double_t IoEmIoP,
00554 Double_t eleEoPout,
00555 Double_t rho,
00556 Double_t PreShowerOverRaw,
00557 Double_t eta,
00558 Double_t pt,
00559 Bool_t printDebug) {
00560
00561 if (!fisInitialized) {
00562 std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
00563 return -9999;
00564 }
00565
00566 if (fMVAType != EGammaMvaEleEstimator::kTrigNoIP) {
00567 std::cout << "Error: This method should be called for kTrigNoIP MVA only" << endl;
00568 return -9999;
00569 }
00570
00571 fMVAVar_fbrem = fbrem;
00572 fMVAVar_kfchi2 = kfchi2;
00573 fMVAVar_kfhits = float(kfhits);
00574 fMVAVar_gsfchi2 = gsfchi2;
00575
00576 fMVAVar_deta = deta;
00577 fMVAVar_dphi = dphi;
00578 fMVAVar_detacalo = detacalo;
00579
00580 fMVAVar_see = see;
00581 fMVAVar_spp = spp;
00582 fMVAVar_etawidth = etawidth;
00583 fMVAVar_phiwidth = phiwidth;
00584 fMVAVar_OneMinusE1x5E5x5 = e1x5e5x5;
00585 fMVAVar_R9 = R9;
00586
00587 fMVAVar_HoE = HoE;
00588 fMVAVar_EoP = EoP;
00589 fMVAVar_IoEmIoP = IoEmIoP;
00590 fMVAVar_eleEoPout = eleEoPout;
00591 fMVAVar_rho = rho;
00592 fMVAVar_PreShowerOverRaw= PreShowerOverRaw;
00593
00594
00595 fMVAVar_eta = eta;
00596 fMVAVar_pt = pt;
00597
00598
00599 bindVariables();
00600 Double_t mva = -9999;
00601 if (fUseBinnedVersion) {
00602 mva = fTMVAReader[GetMVABin(fMVAVar_eta,fMVAVar_pt)]->EvaluateMVA(fMethodname);
00603 } else {
00604 mva = fTMVAReader[0]->EvaluateMVA(fMethodname);
00605 }
00606
00607 if(printDebug) {
00608 cout << " *** Inside the class fMethodname " << fMethodname << endl;
00609 cout << " fbrem " << fMVAVar_fbrem
00610 << " kfchi2 " << fMVAVar_kfchi2
00611 << " mykfhits " << fMVAVar_kfhits
00612 << " gsfchi2 " << fMVAVar_gsfchi2
00613 << " deta " << fMVAVar_deta
00614 << " dphi " << fMVAVar_dphi
00615 << " detacalo " << fMVAVar_detacalo
00616 << " see " << fMVAVar_see
00617 << " spp " << fMVAVar_spp
00618 << " etawidth " << fMVAVar_etawidth
00619 << " phiwidth " << fMVAVar_phiwidth
00620 << " e1x5e5x5 " << fMVAVar_OneMinusE1x5E5x5
00621 << " R9 " << fMVAVar_R9
00622 << " HoE " << fMVAVar_HoE
00623 << " EoP " << fMVAVar_EoP
00624 << " IoEmIoP " << fMVAVar_IoEmIoP
00625 << " eleEoPout " << fMVAVar_eleEoPout
00626 << " rho " << fMVAVar_rho
00627 << " PreShowerOverRaw " << fMVAVar_PreShowerOverRaw
00628 << " eta " << fMVAVar_eta
00629 << " pt " << fMVAVar_pt << endl;
00630 cout << " ### MVA " << mva << endl;
00631 }
00632
00633
00634 return mva;
00635 }
00636
00637
00638
00639 Double_t EGammaMvaEleEstimator::mvaValue(Double_t fbrem,
00640 Double_t kfchi2,
00641 Int_t kfhits,
00642 Double_t gsfchi2,
00643 Double_t deta,
00644 Double_t dphi,
00645 Double_t detacalo,
00646
00647 Double_t see,
00648 Double_t spp,
00649 Double_t etawidth,
00650 Double_t phiwidth,
00651 Double_t OneMinusE1x5E5x5,
00652 Double_t R9,
00653
00654 Double_t HoE,
00655 Double_t EoP,
00656 Double_t IoEmIoP,
00657 Double_t eleEoPout,
00658 Double_t PreShowerOverRaw,
00659
00660 Double_t eta,
00661 Double_t pt,
00662 Bool_t printDebug) {
00663
00664 if (!fisInitialized) {
00665 std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
00666 return -9999;
00667 }
00668
00669 if (fMVAType != EGammaMvaEleEstimator::kNonTrig) {
00670 std::cout << "Error: This method should be called for kNonTrig MVA only" << endl;
00671 return -9999;
00672 }
00673
00674 fMVAVar_fbrem = fbrem;
00675 fMVAVar_kfchi2 = kfchi2;
00676 fMVAVar_kfhits = float(kfhits);
00677 fMVAVar_gsfchi2 = gsfchi2;
00678
00679 fMVAVar_deta = deta;
00680 fMVAVar_dphi = dphi;
00681 fMVAVar_detacalo = detacalo;
00682
00683
00684 fMVAVar_see = see;
00685 fMVAVar_spp = spp;
00686 fMVAVar_etawidth = etawidth;
00687 fMVAVar_phiwidth = phiwidth;
00688 fMVAVar_OneMinusE1x5E5x5 = OneMinusE1x5E5x5;
00689 fMVAVar_R9 = R9;
00690
00691
00692 fMVAVar_HoE = HoE;
00693 fMVAVar_EoP = EoP;
00694 fMVAVar_IoEmIoP = IoEmIoP;
00695 fMVAVar_eleEoPout = eleEoPout;
00696 fMVAVar_PreShowerOverRaw= PreShowerOverRaw;
00697
00698 fMVAVar_eta = eta;
00699 fMVAVar_pt = pt;
00700
00701
00702 bindVariables();
00703 Double_t mva = -9999;
00704 if (fUseBinnedVersion) {
00705 mva = fTMVAReader[GetMVABin(fMVAVar_eta,fMVAVar_pt)]->EvaluateMVA(fMethodname);
00706 } else {
00707 mva = fTMVAReader[0]->EvaluateMVA(fMethodname);
00708 }
00709
00710
00711
00712 if(printDebug) {
00713 cout << " *** Inside the class fMethodname " << fMethodname << endl;
00714 cout << " fbrem " << fMVAVar_fbrem
00715 << " kfchi2 " << fMVAVar_kfchi2
00716 << " mykfhits " << fMVAVar_kfhits
00717 << " gsfchi2 " << fMVAVar_gsfchi2
00718 << " deta " << fMVAVar_deta
00719 << " dphi " << fMVAVar_dphi
00720 << " detacalo " << fMVAVar_detacalo
00721 << " see " << fMVAVar_see
00722 << " spp " << fMVAVar_spp
00723 << " etawidth " << fMVAVar_etawidth
00724 << " phiwidth " << fMVAVar_phiwidth
00725 << " OneMinusE1x5E5x5 " << fMVAVar_OneMinusE1x5E5x5
00726 << " R9 " << fMVAVar_R9
00727 << " HoE " << fMVAVar_HoE
00728 << " EoP " << fMVAVar_EoP
00729 << " IoEmIoP " << fMVAVar_IoEmIoP
00730 << " eleEoPout " << fMVAVar_eleEoPout
00731 << " PreShowerOverRaw " << fMVAVar_PreShowerOverRaw
00732 << " eta " << fMVAVar_eta
00733 << " pt " << fMVAVar_pt << endl;
00734 cout << " ### MVA " << mva << endl;
00735 }
00736
00737
00738 return mva;
00739 }
00740
00741
00742
00743
00744 Double_t EGammaMvaEleEstimator::IDIsoCombinedMvaValue(Double_t fbrem,
00745 Double_t kfchi2,
00746 Int_t kfhits,
00747 Double_t gsfchi2,
00748 Double_t deta,
00749 Double_t dphi,
00750 Double_t detacalo,
00751 Double_t see,
00752 Double_t spp,
00753 Double_t etawidth,
00754 Double_t phiwidth,
00755 Double_t OneMinusE1x5E5x5,
00756 Double_t R9,
00757 Double_t HoE,
00758 Double_t EoP,
00759 Double_t IoEmIoP,
00760 Double_t eleEoPout,
00761 Double_t PreShowerOverRaw,
00762 Double_t d0,
00763 Double_t ip3d,
00764 Double_t ChargedIso_DR0p0To0p1,
00765 Double_t ChargedIso_DR0p1To0p2,
00766 Double_t ChargedIso_DR0p2To0p3,
00767 Double_t ChargedIso_DR0p3To0p4,
00768 Double_t ChargedIso_DR0p4To0p5,
00769 Double_t GammaIso_DR0p0To0p1,
00770 Double_t GammaIso_DR0p1To0p2,
00771 Double_t GammaIso_DR0p2To0p3,
00772 Double_t GammaIso_DR0p3To0p4,
00773 Double_t GammaIso_DR0p4To0p5,
00774 Double_t NeutralHadronIso_DR0p0To0p1,
00775 Double_t NeutralHadronIso_DR0p1To0p2,
00776 Double_t NeutralHadronIso_DR0p2To0p3,
00777 Double_t NeutralHadronIso_DR0p3To0p4,
00778 Double_t NeutralHadronIso_DR0p4To0p5,
00779 Double_t Rho,
00780 Double_t eta,
00781 Double_t pt,
00782 Bool_t printDebug) {
00783
00784 if (!fisInitialized) {
00785 std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
00786 return -9999;
00787 }
00788
00789 fMVAVar_fbrem = ( fbrem < -1.0 ) ? -1.0 : fbrem;
00790 fMVAVar_kfchi2 = ( kfchi2 > 10 ) ? 10 : kfchi2;
00791 fMVAVar_kfhits = float(kfhits);
00792 fMVAVar_gsfchi2 = ( gsfchi2 > 200 ) ? 200 : gsfchi2;
00793 fMVAVar_deta = ( fabs(deta) > 0.06 ) ? 0.06 : fabs(deta);
00794 fMVAVar_dphi = dphi;
00795 fMVAVar_detacalo = detacalo;
00796
00797 fMVAVar_see = see;
00798 fMVAVar_spp = spp;
00799 fMVAVar_etawidth = etawidth;
00800 fMVAVar_phiwidth = phiwidth;
00801 fMVAVar_OneMinusE1x5E5x5= max(min(double(OneMinusE1x5E5x5),2.0),-1.0);
00802 fMVAVar_R9 = (R9 > 5) ? 5: R9;
00803
00804 fMVAVar_HoE = HoE;
00805 fMVAVar_EoP = (EoP > 20) ? 20 : EoP;
00806 fMVAVar_IoEmIoP = IoEmIoP;
00807 fMVAVar_eleEoPout = (eleEoPout > 20) ? 20 : eleEoPout;
00808 fMVAVar_PreShowerOverRaw= PreShowerOverRaw;
00809
00810 fMVAVar_d0 = d0;
00811 fMVAVar_ip3d = ip3d;
00812
00813 fMVAVar_ChargedIso_DR0p0To0p1 = ChargedIso_DR0p0To0p1;
00814 fMVAVar_ChargedIso_DR0p1To0p2 = ChargedIso_DR0p1To0p2;
00815 fMVAVar_ChargedIso_DR0p2To0p3 = ChargedIso_DR0p2To0p3;
00816 fMVAVar_ChargedIso_DR0p3To0p4 = ChargedIso_DR0p3To0p4;
00817 fMVAVar_ChargedIso_DR0p4To0p5 = ChargedIso_DR0p4To0p5;
00818 fMVAVar_GammaIso_DR0p0To0p1 = GammaIso_DR0p0To0p1;
00819 fMVAVar_GammaIso_DR0p1To0p2 = GammaIso_DR0p1To0p2;
00820 fMVAVar_GammaIso_DR0p2To0p3 = GammaIso_DR0p2To0p3;
00821 fMVAVar_GammaIso_DR0p3To0p4 = GammaIso_DR0p3To0p4;
00822 fMVAVar_GammaIso_DR0p4To0p5 = GammaIso_DR0p4To0p5;
00823 fMVAVar_NeutralHadronIso_DR0p0To0p1 = NeutralHadronIso_DR0p0To0p1;
00824 fMVAVar_NeutralHadronIso_DR0p1To0p2 = NeutralHadronIso_DR0p1To0p2;
00825 fMVAVar_NeutralHadronIso_DR0p2To0p3 = NeutralHadronIso_DR0p2To0p3;
00826 fMVAVar_NeutralHadronIso_DR0p3To0p4 = NeutralHadronIso_DR0p3To0p4;
00827 fMVAVar_NeutralHadronIso_DR0p4To0p5 = NeutralHadronIso_DR0p4To0p5;
00828
00829 fMVAVar_rho = Rho;
00830 fMVAVar_eta = eta;
00831 fMVAVar_pt = pt;
00832
00833 Double_t mva = -9999;
00834 if (fUseBinnedVersion) {
00835 mva = fTMVAReader[GetMVABin(fMVAVar_eta,fMVAVar_pt)]->EvaluateMVA(fMethodname);
00836 } else {
00837 mva = fTMVAReader[0]->EvaluateMVA(fMethodname);
00838 }
00839
00840 if(printDebug) {
00841 cout << " *** Inside the class fMethodname " << fMethodname << endl;
00842 cout << " fbrem " << fMVAVar_fbrem
00843 << " kfchi2 " << fMVAVar_kfchi2
00844 << " mykfhits " << fMVAVar_kfhits
00845 << " gsfchi2 " << fMVAVar_gsfchi2
00846 << " deta " << fMVAVar_deta
00847 << " dphi " << fMVAVar_dphi
00848 << " detacalo " << fMVAVar_detacalo
00849 << " see " << fMVAVar_see
00850 << " spp " << fMVAVar_spp
00851 << " etawidth " << fMVAVar_etawidth
00852 << " phiwidth " << fMVAVar_phiwidth
00853 << " OneMinusE1x5E5x5 " << fMVAVar_OneMinusE1x5E5x5
00854 << " R9 " << fMVAVar_R9
00855 << " HoE " << fMVAVar_HoE
00856 << " EoP " << fMVAVar_EoP
00857 << " IoEmIoP " << fMVAVar_IoEmIoP
00858 << " eleEoPout " << fMVAVar_eleEoPout
00859 << " PreShowerOverRaw " << fMVAVar_PreShowerOverRaw
00860 << " d0 " << fMVAVar_d0
00861 << " ip3d " << fMVAVar_ip3d
00862 << " ChargedIso_DR0p0To0p1 " << ChargedIso_DR0p0To0p1
00863 << " ChargedIso_DR0p1To0p2 " << ChargedIso_DR0p1To0p2
00864 << " ChargedIso_DR0p2To0p3 " << ChargedIso_DR0p2To0p3
00865 << " ChargedIso_DR0p3To0p4 " << ChargedIso_DR0p3To0p4
00866 << " ChargedIso_DR0p4To0p5 " << ChargedIso_DR0p4To0p5
00867 << " GammaIso_DR0p0To0p1 " << GammaIso_DR0p0To0p1
00868 << " GammaIso_DR0p1To0p2 " << GammaIso_DR0p1To0p2
00869 << " GammaIso_DR0p2To0p3 " << GammaIso_DR0p2To0p3
00870 << " GammaIso_DR0p3To0p4 " << GammaIso_DR0p3To0p4
00871 << " GammaIso_DR0p4To0p5 " << GammaIso_DR0p4To0p5
00872 << " NeutralHadronIso_DR0p0To0p1 " << NeutralHadronIso_DR0p0To0p1
00873 << " NeutralHadronIso_DR0p1To0p2 " << NeutralHadronIso_DR0p1To0p2
00874 << " NeutralHadronIso_DR0p2To0p3 " << NeutralHadronIso_DR0p2To0p3
00875 << " NeutralHadronIso_DR0p3To0p4 " << NeutralHadronIso_DR0p3To0p4
00876 << " NeutralHadronIso_DR0p4To0p5 " << NeutralHadronIso_DR0p4To0p5
00877 << " Rho " << Rho
00878 << " eta " << fMVAVar_eta
00879 << " pt " << fMVAVar_pt << endl;
00880 cout << " ### MVA " << mva << endl;
00881 }
00882
00883 return mva;
00884 }
00885
00886
00887
00888
00889
00890 #ifndef STANDALONE
00891 Double_t EGammaMvaEleEstimator::isoMvaValue(Double_t Pt,
00892 Double_t Eta,
00893 Double_t Rho,
00894 ElectronEffectiveArea::ElectronEffectiveAreaTarget EATarget,
00895 Double_t ChargedIso_DR0p0To0p1,
00896 Double_t ChargedIso_DR0p1To0p2,
00897 Double_t ChargedIso_DR0p2To0p3,
00898 Double_t ChargedIso_DR0p3To0p4,
00899 Double_t ChargedIso_DR0p4To0p5,
00900 Double_t GammaIso_DR0p0To0p1,
00901 Double_t GammaIso_DR0p1To0p2,
00902 Double_t GammaIso_DR0p2To0p3,
00903 Double_t GammaIso_DR0p3To0p4,
00904 Double_t GammaIso_DR0p4To0p5,
00905 Double_t NeutralHadronIso_DR0p0To0p1,
00906 Double_t NeutralHadronIso_DR0p1To0p2,
00907 Double_t NeutralHadronIso_DR0p2To0p3,
00908 Double_t NeutralHadronIso_DR0p3To0p4,
00909 Double_t NeutralHadronIso_DR0p4To0p5,
00910 Bool_t printDebug) {
00911
00912 if (!fisInitialized) {
00913 std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
00914 return -9999;
00915 }
00916
00917 fMVAVar_ChargedIso_DR0p0To0p1 = TMath::Min((ChargedIso_DR0p0To0p1)/Pt, 2.5);
00918 fMVAVar_ChargedIso_DR0p1To0p2 = TMath::Min((ChargedIso_DR0p1To0p2)/Pt, 2.5);
00919 fMVAVar_ChargedIso_DR0p2To0p3 = TMath::Min((ChargedIso_DR0p2To0p3)/Pt, 2.5);
00920 fMVAVar_ChargedIso_DR0p3To0p4 = TMath::Min((ChargedIso_DR0p3To0p4)/Pt, 2.5);
00921 fMVAVar_ChargedIso_DR0p4To0p5 = TMath::Min((ChargedIso_DR0p4To0p5)/Pt, 2.5);
00922 fMVAVar_GammaIso_DR0p0To0p1 = TMath::Max(TMath::Min((GammaIso_DR0p0To0p1 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleGammaIsoDR0p0To0p1, Eta, EATarget))/Pt, 2.5), 0.0);
00923 fMVAVar_GammaIso_DR0p1To0p2 = TMath::Max(TMath::Min((GammaIso_DR0p1To0p2 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleGammaIsoDR0p1To0p2, Eta, EATarget))/Pt, 2.5), 0.0);
00924 fMVAVar_GammaIso_DR0p2To0p3 = TMath::Max(TMath::Min((GammaIso_DR0p2To0p3 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleGammaIsoDR0p2To0p3, Eta, EATarget))/Pt, 2.5), 0.0);
00925 fMVAVar_GammaIso_DR0p3To0p4 = TMath::Max(TMath::Min((GammaIso_DR0p3To0p4 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleGammaIsoDR0p3To0p4, Eta, EATarget))/Pt, 2.5), 0.0);
00926 fMVAVar_GammaIso_DR0p4To0p5 = TMath::Max(TMath::Min((GammaIso_DR0p4To0p5 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleGammaIsoDR0p4To0p5, Eta, EATarget))/Pt, 2.5), 0.0);
00927 fMVAVar_NeutralHadronIso_DR0p0To0p1 = TMath::Max(TMath::Min((NeutralHadronIso_DR0p0To0p1 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleNeutralHadronIsoDR0p0To0p1, Eta, EATarget))/Pt, 2.5), 0.0);
00928 fMVAVar_NeutralHadronIso_DR0p1To0p2 = TMath::Max(TMath::Min((NeutralHadronIso_DR0p1To0p2 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleNeutralHadronIsoDR0p1To0p2, Eta, EATarget))/Pt, 2.5), 0.0);
00929 fMVAVar_NeutralHadronIso_DR0p2To0p3 = TMath::Max(TMath::Min((NeutralHadronIso_DR0p2To0p3 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleNeutralHadronIsoDR0p2To0p3, Eta, EATarget))/Pt, 2.5), 0.0);
00930 fMVAVar_NeutralHadronIso_DR0p3To0p4 = TMath::Max(TMath::Min((NeutralHadronIso_DR0p3To0p4 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleNeutralHadronIsoDR0p3To0p4, Eta, EATarget))/Pt, 2.5), 0.0);
00931 fMVAVar_NeutralHadronIso_DR0p4To0p5 = TMath::Max(TMath::Min((NeutralHadronIso_DR0p4To0p5 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleNeutralHadronIsoDR0p4To0p5, Eta, EATarget))/Pt, 2.5), 0.0);
00932
00933
00934 Double_t mva = fTMVAReader[GetMVABin(Eta,Pt)]->EvaluateMVA(fMethodname);
00935
00936 if(printDebug) {
00937 cout << " *** Inside the class fMethodname " << fMethodname << " fMVAType " << fMVAType << endl;
00938 cout << "ChargedIso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): "
00939 << fMVAVar_ChargedIso_DR0p0To0p1 << " "
00940 << fMVAVar_ChargedIso_DR0p1To0p2 << " "
00941 << fMVAVar_ChargedIso_DR0p2To0p3 << " "
00942 << fMVAVar_ChargedIso_DR0p3To0p4 << " "
00943 << fMVAVar_ChargedIso_DR0p4To0p5 << endl;
00944 cout << "PF Gamma Iso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): "
00945 << fMVAVar_GammaIso_DR0p0To0p1 << " "
00946 << fMVAVar_GammaIso_DR0p1To0p2 << " "
00947 << fMVAVar_GammaIso_DR0p2To0p3 << " "
00948 << fMVAVar_GammaIso_DR0p3To0p4 << " "
00949 << fMVAVar_GammaIso_DR0p4To0p5 << endl;
00950 cout << "PF Neutral Hadron Iso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): "
00951 << fMVAVar_NeutralHadronIso_DR0p0To0p1 << " "
00952 << fMVAVar_NeutralHadronIso_DR0p1To0p2 << " "
00953 << fMVAVar_NeutralHadronIso_DR0p2To0p3 << " "
00954 << fMVAVar_NeutralHadronIso_DR0p3To0p4 << " "
00955 << fMVAVar_NeutralHadronIso_DR0p4To0p5 << " "
00956 << endl;
00957 cout << " ### MVA " << mva << endl;
00958 }
00959
00960 return mva;
00961
00962 }
00963
00964
00965
00966
00967
00968 Double_t EGammaMvaEleEstimator::mvaValue(const reco::GsfElectron& ele,
00969 const reco::Vertex& vertex,
00970 const TransientTrackBuilder& transientTrackBuilder,
00971 EcalClusterLazyTools myEcalCluster,
00972 bool printDebug) {
00973
00974 if (!fisInitialized) {
00975 std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
00976 return -9999;
00977 }
00978
00979 if ( (fMVAType != EGammaMvaEleEstimator::kTrig) && (fMVAType != EGammaMvaEleEstimator::kNonTrig )) {
00980 std::cout << "Error: This method should be called for kTrig or kNonTrig MVA only" << endl;
00981 return -9999;
00982 }
00983
00984 bool validKF= false;
00985 reco::TrackRef myTrackRef = ele.closestCtfTrackRef();
00986 validKF = (myTrackRef.isAvailable());
00987 validKF = (myTrackRef.isNonnull());
00988
00989
00990 fMVAVar_fbrem = ele.fbrem();
00991 fMVAVar_kfchi2 = (validKF) ? myTrackRef->normalizedChi2() : 0 ;
00992 fMVAVar_kfhits = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1. ;
00993 fMVAVar_kfhitsall = (validKF) ? myTrackRef->numberOfValidHits() : -1. ;
00994 fMVAVar_gsfchi2 = ele.gsfTrack()->normalizedChi2();
00995
00996
00997
00998 fMVAVar_deta = ele.deltaEtaSuperClusterTrackAtVtx();
00999 fMVAVar_dphi = ele.deltaPhiSuperClusterTrackAtVtx();
01000 fMVAVar_detacalo = ele.deltaEtaSeedClusterTrackAtCalo();
01001
01002
01003
01004 fMVAVar_see = ele.sigmaIetaIeta();
01005 std::vector<float> vCov = myEcalCluster.localCovariances(*(ele.superCluster()->seed())) ;
01006 if (!isnan(vCov[2])) fMVAVar_spp = sqrt (vCov[2]);
01007 else fMVAVar_spp = 0.;
01008
01009 fMVAVar_etawidth = ele.superCluster()->etaWidth();
01010 fMVAVar_phiwidth = ele.superCluster()->phiWidth();
01011 fMVAVar_OneMinusE1x5E5x5 = (ele.e5x5()) !=0. ? 1.-(ele.e1x5()/ele.e5x5()) : -1. ;
01012 fMVAVar_R9 = myEcalCluster.e3x3(*(ele.superCluster()->seed())) / ele.superCluster()->rawEnergy();
01013
01014
01015 fMVAVar_HoE = ele.hadronicOverEm();
01016 fMVAVar_EoP = ele.eSuperClusterOverP();
01017 fMVAVar_IoEmIoP = (1.0/ele.ecalEnergy()) - (1.0 / ele.p());
01018 fMVAVar_eleEoPout = ele.eEleClusterOverPout();
01019 fMVAVar_PreShowerOverRaw= ele.superCluster()->preshowerEnergy() / ele.superCluster()->rawEnergy();
01020
01021
01022
01023 fMVAVar_eta = ele.superCluster()->eta();
01024 fMVAVar_pt = ele.pt();
01025
01026
01027
01028
01029 if(fMVAType == kTrig) {
01030
01031 if (ele.gsfTrack().isNonnull()) {
01032 fMVAVar_d0 = (-1.0)*ele.gsfTrack()->dxy(vertex.position());
01033 } else if (ele.closestCtfTrackRef().isNonnull()) {
01034 fMVAVar_d0 = (-1.0)*ele.closestCtfTrackRef()->dxy(vertex.position());
01035 } else {
01036 fMVAVar_d0 = -9999.0;
01037 }
01038
01039
01040 fMVAVar_ip3d = -999.0;
01041 fMVAVar_ip3dSig = 0.0;
01042 if (ele.gsfTrack().isNonnull()) {
01043 const double gsfsign = ( (-ele.gsfTrack()->dxy(vertex.position())) >=0 ) ? 1. : -1.;
01044
01045 const reco::TransientTrack &tt = transientTrackBuilder.build(ele.gsfTrack());
01046 const std::pair<bool,Measurement1D> &ip3dpv = IPTools::absoluteImpactParameter3D(tt,vertex);
01047 if (ip3dpv.first) {
01048 double ip3d = gsfsign*ip3dpv.second.value();
01049 double ip3derr = ip3dpv.second.error();
01050 fMVAVar_ip3d = ip3d;
01051 fMVAVar_ip3dSig = ip3d/ip3derr;
01052 }
01053 }
01054 }
01055
01056
01057
01058 bindVariables();
01059 Double_t mva = -9999;
01060 if (fUseBinnedVersion) {
01061 mva = fTMVAReader[GetMVABin(fMVAVar_eta,fMVAVar_pt)]->EvaluateMVA(fMethodname);
01062 } else {
01063 mva = fTMVAReader[0]->EvaluateMVA(fMethodname);
01064 }
01065
01066
01067
01068 if(printDebug) {
01069 cout << " *** Inside the class fMethodname " << fMethodname << " fMVAType " << fMVAType << endl;
01070 cout << " fbrem " << fMVAVar_fbrem
01071 << " kfchi2 " << fMVAVar_kfchi2
01072 << " mykfhits " << fMVAVar_kfhits
01073 << " gsfchi2 " << fMVAVar_gsfchi2
01074 << " deta " << fMVAVar_deta
01075 << " dphi " << fMVAVar_dphi
01076 << " detacalo " << fMVAVar_detacalo
01077 << " see " << fMVAVar_see
01078 << " spp " << fMVAVar_spp
01079 << " etawidth " << fMVAVar_etawidth
01080 << " phiwidth " << fMVAVar_phiwidth
01081 << " OneMinusE1x5E5x5 " << fMVAVar_OneMinusE1x5E5x5
01082 << " R9 " << fMVAVar_R9
01083 << " HoE " << fMVAVar_HoE
01084 << " EoP " << fMVAVar_EoP
01085 << " IoEmIoP " << fMVAVar_IoEmIoP
01086 << " eleEoPout " << fMVAVar_eleEoPout
01087 << " d0 " << fMVAVar_d0
01088 << " ip3d " << fMVAVar_ip3d
01089 << " eta " << fMVAVar_eta
01090 << " pt " << fMVAVar_pt << endl;
01091 cout << " ### MVA " << mva << endl;
01092 }
01093
01094
01095
01096 return mva;
01097 }
01098
01099
01100
01101 Double_t EGammaMvaEleEstimator::mvaValue(const reco::GsfElectron& ele,
01102 const reco::Vertex& vertex,
01103 double rho,
01104
01105 EcalClusterLazyTools myEcalCluster,
01106 bool printDebug) {
01107
01108 if (!fisInitialized) {
01109 std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
01110 return -9999;
01111 }
01112
01113 if (fMVAType != EGammaMvaEleEstimator::kTrigNoIP) {
01114 std::cout << "Error: This method should be called for kTrigNoIP MVA only" << endl;
01115 return -9999;
01116 }
01117
01118 bool validKF= false;
01119 reco::TrackRef myTrackRef = ele.closestCtfTrackRef();
01120 validKF = (myTrackRef.isAvailable());
01121 validKF = (myTrackRef.isNonnull());
01122
01123
01124 fMVAVar_fbrem = ele.fbrem();
01125 fMVAVar_kfchi2 = (validKF) ? myTrackRef->normalizedChi2() : 0 ;
01126 fMVAVar_kfhits = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1. ;
01127 fMVAVar_gsfchi2 = ele.gsfTrack()->normalizedChi2();
01128
01129
01130
01131 fMVAVar_deta = ele.deltaEtaSuperClusterTrackAtVtx();
01132 fMVAVar_dphi = ele.deltaPhiSuperClusterTrackAtVtx();
01133 fMVAVar_detacalo = ele.deltaEtaSeedClusterTrackAtCalo();
01134
01135
01136
01137 fMVAVar_see = ele.sigmaIetaIeta();
01138 std::vector<float> vCov = myEcalCluster.localCovariances(*(ele.superCluster()->seed())) ;
01139 if (!isnan(vCov[2])) fMVAVar_spp = sqrt (vCov[2]);
01140 else fMVAVar_spp = 0.;
01141
01142
01143 fMVAVar_etawidth = ele.superCluster()->etaWidth();
01144 fMVAVar_phiwidth = ele.superCluster()->phiWidth();
01145 fMVAVar_OneMinusE1x5E5x5 = (ele.e5x5()) !=0. ? 1.-(ele.e1x5()/ele.e5x5()) : -1. ;
01146 fMVAVar_R9 = myEcalCluster.e3x3(*(ele.superCluster()->seed())) / ele.superCluster()->rawEnergy();
01147
01148
01149
01150 fMVAVar_HoE = ele.hadronicOverEm();
01151 fMVAVar_EoP = ele.eSuperClusterOverP();
01152 fMVAVar_IoEmIoP = (1.0/ele.superCluster()->energy()) - (1.0 / ele.gsfTrack()->p());
01153 fMVAVar_eleEoPout = ele.eEleClusterOverPout();
01154 fMVAVar_rho = rho;
01155 fMVAVar_PreShowerOverRaw= ele.superCluster()->preshowerEnergy() / ele.superCluster()->rawEnergy();
01156
01157
01158
01159 fMVAVar_eta = ele.superCluster()->eta();
01160 fMVAVar_pt = ele.pt();
01161
01162
01163
01164
01165
01166
01167 bindVariables();
01168 Double_t mva = -9999;
01169 if (fUseBinnedVersion) {
01170 mva = fTMVAReader[GetMVABin(fMVAVar_eta,fMVAVar_pt)]->EvaluateMVA(fMethodname);
01171 } else {
01172 mva = fTMVAReader[0]->EvaluateMVA(fMethodname);
01173 }
01174
01175
01176
01177 if(printDebug) {
01178 cout << " *** Inside the class fMethodname " << fMethodname << " fMVAType " << fMVAType << endl;
01179 cout << " fbrem " << fMVAVar_fbrem
01180 << " kfchi2 " << fMVAVar_kfchi2
01181 << " mykfhits " << fMVAVar_kfhits
01182 << " gsfchi2 " << fMVAVar_gsfchi2
01183 << " deta " << fMVAVar_deta
01184 << " dphi " << fMVAVar_dphi
01185 << " detacalo " << fMVAVar_detacalo
01186
01187 << " see " << fMVAVar_see
01188 << " spp " << fMVAVar_spp
01189 << " etawidth " << fMVAVar_etawidth
01190 << " phiwidth " << fMVAVar_phiwidth
01191 << " e1x5e5x5 " << fMVAVar_OneMinusE1x5E5x5
01192 << " R9 " << fMVAVar_R9
01193
01194 << " HoE " << fMVAVar_HoE
01195 << " EoP " << fMVAVar_EoP
01196 << " IoEmIoP " << fMVAVar_IoEmIoP
01197 << " eleEoPout " << fMVAVar_eleEoPout
01198 << " rho " << fMVAVar_rho
01199
01200 << " eta " << fMVAVar_eta
01201 << " pt " << fMVAVar_pt << endl;
01202 cout << " ### MVA " << mva << endl;
01203 }
01204
01205
01206
01207 return mva;
01208 }
01209
01210
01211 Double_t EGammaMvaEleEstimator::mvaValue(const pat::Electron& ele,
01212 const reco::Vertex& vertex,
01213 double rho,
01214 bool printDebug) {
01215
01216 if (!fisInitialized) {
01217 std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
01218 return -9999;
01219 }
01220
01221 bool validKF= false;
01222 reco::TrackRef myTrackRef = ele.closestCtfTrackRef();
01223 validKF = (myTrackRef.isAvailable());
01224 validKF = (myTrackRef.isNonnull());
01225
01226
01227 fMVAVar_fbrem = ele.fbrem();
01228 fMVAVar_kfchi2 = (validKF) ? myTrackRef->normalizedChi2() : 0 ;
01229 fMVAVar_kfhits = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1. ;
01230 fMVAVar_gsfchi2 = ele.gsfTrack()->normalizedChi2();
01231
01232
01233
01234 fMVAVar_deta = ele.deltaEtaSuperClusterTrackAtVtx();
01235 fMVAVar_dphi = ele.deltaPhiSuperClusterTrackAtVtx();
01236 fMVAVar_detacalo = ele.deltaEtaSeedClusterTrackAtCalo();
01237
01238
01239 fMVAVar_see = ele.sigmaIetaIeta();
01240
01241 fMVAVar_spp = ele.sigmaIphiIphi();
01242
01243 fMVAVar_etawidth = ele.superCluster()->etaWidth();
01244 fMVAVar_phiwidth = ele.superCluster()->phiWidth();
01245 fMVAVar_OneMinusE1x5E5x5 = (ele.e5x5()) !=0. ? 1.-(ele.e1x5()/ele.e5x5()) : -1. ;
01246 fMVAVar_R9 = ele.r9();
01247
01248
01249 fMVAVar_HoE = ele.hadronicOverEm();
01250 fMVAVar_EoP = ele.eSuperClusterOverP();
01251
01252
01253 if( fMVAType == kTrig || fMVAType == kNonTrig){
01254 fMVAVar_IoEmIoP = (1.0/ele.ecalEnergy()) - (1.0 / ele.p());
01255 }else{
01256 fMVAVar_IoEmIoP = (1.0/ele.superCluster()->energy()) - (1.0 / ele.gsfTrack()->p());
01257 }
01258 fMVAVar_eleEoPout = ele.eEleClusterOverPout();
01259 fMVAVar_rho = rho;
01260 fMVAVar_PreShowerOverRaw= ele.superCluster()->preshowerEnergy() / ele.superCluster()->rawEnergy();
01261
01262
01263 if(fMVAType == kTrig) {
01264
01265 if (ele.gsfTrack().isNonnull()) {
01266 fMVAVar_d0 = (-1.0)*ele.gsfTrack()->dxy(vertex.position());
01267 } else if (ele.closestCtfTrackRef().isNonnull()) {
01268 fMVAVar_d0 = (-1.0)*ele.closestCtfTrackRef()->dxy(vertex.position());
01269 } else {
01270 fMVAVar_d0 = -9999.0;
01271 }
01272
01273
01274 fMVAVar_ip3d = -999.0;
01275 fMVAVar_ip3dSig = 0.0;
01276 if (ele.gsfTrack().isNonnull()) {
01277 const double gsfsign = ( (-ele.gsfTrack()->dxy(vertex.position())) >=0 ) ? 1. : -1.;
01278
01279 std::cout << "Warning : if usePV = false when pat-electrons were produced, dB() was calculated with respect to beamspot while original mva uses primary vertex" << std::endl;
01280 double ip3d = gsfsign*ele.dB();
01281 double ip3derr = ele.edB();
01282 fMVAVar_ip3d = ip3d;
01283 fMVAVar_ip3dSig = ip3d/ip3derr;
01284 }
01285 }
01286
01287
01288 fMVAVar_eta = ele.superCluster()->eta();
01289 fMVAVar_pt = ele.pt();
01290
01291
01292 bindVariables();
01293 Double_t mva = -9999;
01294 if (fUseBinnedVersion) {
01295 mva = fTMVAReader[GetMVABin(fMVAVar_eta,fMVAVar_pt)]->EvaluateMVA(fMethodname);
01296 } else {
01297 mva = fTMVAReader[0]->EvaluateMVA(fMethodname);
01298 }
01299
01300 if(printDebug) {
01301 cout << " *** Inside the class fMethodname " << fMethodname << " fMVAType " << fMVAType << endl;
01302 cout << " fbrem " << fMVAVar_fbrem
01303 << " kfchi2 " << fMVAVar_kfchi2
01304 << " mykfhits " << fMVAVar_kfhits
01305 << " gsfchi2 " << fMVAVar_gsfchi2
01306 << " deta " << fMVAVar_deta
01307 << " dphi " << fMVAVar_dphi
01308 << " detacalo " << fMVAVar_detacalo
01309
01310 << " see " << fMVAVar_see
01311 << " spp " << fMVAVar_spp
01312 << " etawidth " << fMVAVar_etawidth
01313 << " phiwidth " << fMVAVar_phiwidth
01314 << " e1x5e5x5 " << fMVAVar_OneMinusE1x5E5x5
01315 << " R9 " << fMVAVar_R9
01316
01317 << " HoE " << fMVAVar_HoE
01318 << " EoP " << fMVAVar_EoP
01319 << " IoEmIoP " << fMVAVar_IoEmIoP
01320 << " eleEoPout " << fMVAVar_eleEoPout
01321 << " rho " << fMVAVar_rho
01322
01323 << " d0 " << fMVAVar_d0
01324 << " ip3d " << fMVAVar_ip3d
01325 << " eta " << fMVAVar_eta
01326 << " pt " << fMVAVar_pt << endl;
01327 cout << " ### MVA " << mva << endl;
01328 }
01329
01330 return mva;
01331 }
01332
01333
01334
01335 Double_t EGammaMvaEleEstimator::mvaValue(const pat::Electron& ele,
01336 double rho,
01337 bool printDebug) {
01338
01339 if (!fisInitialized) {
01340 std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
01341 return -9999;
01342 }
01343
01344 if ( (fMVAType != EGammaMvaEleEstimator::kTrigNoIP) ) {
01345 std::cout << "Error: This method should be called for kTrigNoIP mva only" << endl;
01346 return -9999;
01347 }
01348
01349
01350 bool validKF= false;
01351 reco::TrackRef myTrackRef = ele.closestCtfTrackRef();
01352 validKF = (myTrackRef.isAvailable());
01353 validKF = (myTrackRef.isNonnull());
01354
01355
01356 fMVAVar_fbrem = ele.fbrem();
01357 fMVAVar_kfchi2 = (validKF) ? myTrackRef->normalizedChi2() : 0 ;
01358 fMVAVar_kfhits = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1. ;
01359 fMVAVar_gsfchi2 = ele.gsfTrack()->normalizedChi2();
01360
01361
01362
01363 fMVAVar_deta = ele.deltaEtaSuperClusterTrackAtVtx();
01364 fMVAVar_dphi = ele.deltaPhiSuperClusterTrackAtVtx();
01365 fMVAVar_detacalo = ele.deltaEtaSeedClusterTrackAtCalo();
01366
01367
01368
01369 fMVAVar_see = ele.sigmaIetaIeta();
01370
01371 fMVAVar_spp = ele.sigmaIphiIphi();
01372
01373 fMVAVar_etawidth = ele.superCluster()->etaWidth();
01374 fMVAVar_phiwidth = ele.superCluster()->phiWidth();
01375 fMVAVar_OneMinusE1x5E5x5 = (ele.e5x5()) !=0. ? 1.-(ele.e1x5()/ele.e5x5()) : -1. ;
01376 fMVAVar_R9 = ele.r9();
01377
01378
01379 fMVAVar_HoE = ele.hadronicOverEm();
01380 fMVAVar_EoP = ele.eSuperClusterOverP();
01381 fMVAVar_IoEmIoP = (1.0/ele.superCluster()->energy()) - (1.0 / ele.gsfTrack()->p());
01382 fMVAVar_eleEoPout = ele.eEleClusterOverPout();
01383 fMVAVar_rho = rho;
01384 fMVAVar_PreShowerOverRaw= ele.superCluster()->preshowerEnergy() / ele.superCluster()->rawEnergy();
01385
01386
01387
01388 fMVAVar_eta = ele.superCluster()->eta();
01389 fMVAVar_pt = ele.pt();
01390
01391
01392
01393
01394
01395
01396 bindVariables();
01397 Double_t mva = -9999;
01398 if (fUseBinnedVersion) {
01399 mva = fTMVAReader[GetMVABin(fMVAVar_eta,fMVAVar_pt)]->EvaluateMVA(fMethodname);
01400 } else {
01401 mva = fTMVAReader[0]->EvaluateMVA(fMethodname);
01402 }
01403
01404
01405
01406 if(printDebug) {
01407 cout << " *** Inside the class fMethodname " << fMethodname << " fMVAType " << fMVAType << endl;
01408 cout << " fbrem " << fMVAVar_fbrem
01409 << " kfchi2 " << fMVAVar_kfchi2
01410 << " mykfhits " << fMVAVar_kfhits
01411 << " gsfchi2 " << fMVAVar_gsfchi2
01412 << " deta " << fMVAVar_deta
01413 << " dphi " << fMVAVar_dphi
01414 << " detacalo " << fMVAVar_detacalo
01415
01416 << " see " << fMVAVar_see
01417 << " spp " << fMVAVar_spp
01418 << " etawidth " << fMVAVar_etawidth
01419 << " phiwidth " << fMVAVar_phiwidth
01420 << " e1x5e5x5 " << fMVAVar_OneMinusE1x5E5x5
01421 << " R9 " << fMVAVar_R9
01422
01423 << " HoE " << fMVAVar_HoE
01424 << " EoP " << fMVAVar_EoP
01425 << " IoEmIoP " << fMVAVar_IoEmIoP
01426 << " eleEoPout " << fMVAVar_eleEoPout
01427 << " rho " << fMVAVar_rho
01428
01429 << " eta " << fMVAVar_eta
01430 << " pt " << fMVAVar_pt << endl;
01431 cout << " ### MVA " << mva << endl;
01432 }
01433
01434
01435
01436 return mva;
01437 }
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447 Double_t EGammaMvaEleEstimator::isoMvaValue(const reco::GsfElectron& ele,
01448 const reco::Vertex& vertex,
01449 const reco::PFCandidateCollection &PFCandidates,
01450 double Rho,
01451 ElectronEffectiveArea::ElectronEffectiveAreaTarget EATarget,
01452 const reco::GsfElectronCollection &IdentifiedElectrons,
01453 const reco::MuonCollection &IdentifiedMuons,
01454 bool printDebug) {
01455
01456 if (!fisInitialized) {
01457 std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
01458 return -9999;
01459 }
01460
01461
01462 fMVAVar_eta = ele.superCluster()->eta();
01463 fMVAVar_pt = ele.pt();
01464
01465
01466
01467
01468 Double_t tmpChargedIso_DR0p0To0p1 = 0;
01469 Double_t tmpChargedIso_DR0p1To0p2 = 0;
01470 Double_t tmpChargedIso_DR0p2To0p3 = 0;
01471 Double_t tmpChargedIso_DR0p3To0p4 = 0;
01472 Double_t tmpChargedIso_DR0p4To0p5 = 0;
01473 Double_t tmpGammaIso_DR0p0To0p1 = 0;
01474 Double_t tmpGammaIso_DR0p1To0p2 = 0;
01475 Double_t tmpGammaIso_DR0p2To0p3 = 0;
01476 Double_t tmpGammaIso_DR0p3To0p4 = 0;
01477 Double_t tmpGammaIso_DR0p4To0p5 = 0;
01478 Double_t tmpNeutralHadronIso_DR0p0To0p1 = 0;
01479 Double_t tmpNeutralHadronIso_DR0p1To0p2 = 0;
01480 Double_t tmpNeutralHadronIso_DR0p2To0p3 = 0;
01481 Double_t tmpNeutralHadronIso_DR0p3To0p4 = 0;
01482 Double_t tmpNeutralHadronIso_DR0p4To0p5 = 0;
01483
01484 double electronTrackZ = 0;
01485 if (ele.gsfTrack().isNonnull()) {
01486 electronTrackZ = ele.gsfTrack()->dz(vertex.position());
01487 } else if (ele.closestCtfTrackRef().isNonnull()) {
01488 electronTrackZ = ele.closestCtfTrackRef()->dz(vertex.position());
01489 }
01490
01491 for (reco::PFCandidateCollection::const_iterator iP = PFCandidates.begin();
01492 iP != PFCandidates.end(); ++iP) {
01493
01494
01495 if(iP->gsfTrackRef().isNonnull() && ele.gsfTrack().isNonnull() &&
01496 refToPtr(iP->gsfTrackRef()) == refToPtr(ele.gsfTrack())) continue;
01497 if(iP->trackRef().isNonnull() && ele.closestCtfTrackRef().isNonnull() &&
01498 refToPtr(iP->trackRef()) == refToPtr(ele.closestCtfTrackRef())) continue;
01499
01500
01501
01502
01503 double dr = sqrt(pow(iP->eta() - ele.eta(),2) + pow(acos(cos(iP->phi() - ele.phi())),2));
01504
01505
01506 if (dr < 1.0) {
01507 Bool_t IsLeptonFootprint = kFALSE;
01508
01509
01510
01511 for (reco::GsfElectronCollection::const_iterator iE = IdentifiedElectrons.begin();
01512 iE != IdentifiedElectrons.end(); ++iE) {
01513
01514 if(iP->gsfTrackRef().isNonnull() && iE->gsfTrack().isNonnull() &&
01515 refToPtr(iP->gsfTrackRef()) == refToPtr(iE->gsfTrack())) IsLeptonFootprint = kTRUE;
01516 if(iP->trackRef().isNonnull() && iE->closestCtfTrackRef().isNonnull() &&
01517 refToPtr(iP->trackRef()) == refToPtr(iE->closestCtfTrackRef())) IsLeptonFootprint = kTRUE;
01518
01519
01520 double tmpDR = sqrt(pow(iP->eta() - iE->eta(),2) + pow(acos(cos(iP->phi() - iE->phi())),2));
01521 if(iP->trackRef().isNonnull() && fabs(iE->superCluster()->eta()) >= 1.479
01522 && tmpDR < 0.015) IsLeptonFootprint = kTRUE;
01523 if(iP->particleId() == reco::PFCandidate::gamma && fabs(iE->superCluster()->eta()) >= 1.479
01524 && tmpDR < 0.08) IsLeptonFootprint = kTRUE;
01525 }
01526 for (reco::MuonCollection::const_iterator iM = IdentifiedMuons.begin();
01527 iM != IdentifiedMuons.end(); ++iM) {
01528
01529 if(iP->trackRef().isNonnull() && iM->innerTrack().isNonnull() &&
01530 refToPtr(iP->trackRef()) == refToPtr(iM->innerTrack())) IsLeptonFootprint = kTRUE;
01531
01532
01533 double tmpDR = sqrt(pow(iP->eta() - iM->eta(),2) + pow(acos(cos(iP->phi() - iM->phi())),2));
01534 if(iP->trackRef().isNonnull() && tmpDR < 0.01) IsLeptonFootprint = kTRUE;
01535 }
01536
01537 if (!IsLeptonFootprint) {
01538 Bool_t passVeto = kTRUE;
01539
01540 if(iP->trackRef().isNonnull()) {
01541 if (!(fabs(iP->trackRef()->dz(vertex.position()) - electronTrackZ) < 0.2)) passVeto = kFALSE;
01542
01543
01544 if (iP->particleId() == reco::PFCandidate::e || iP->particleId() == reco::PFCandidate::mu) passVeto = kFALSE;
01545
01546
01547
01548 if (fabs(fMVAVar_eta) > 1.479 && dr < 0.015) passVeto = kFALSE;
01549
01550 if (passVeto) {
01551 if (dr < 0.1) tmpChargedIso_DR0p0To0p1 += iP->pt();
01552 if (dr >= 0.1 && dr < 0.2) tmpChargedIso_DR0p1To0p2 += iP->pt();
01553 if (dr >= 0.2 && dr < 0.3) tmpChargedIso_DR0p2To0p3 += iP->pt();
01554 if (dr >= 0.3 && dr < 0.4) tmpChargedIso_DR0p3To0p4 += iP->pt();
01555 if (dr >= 0.4 && dr < 0.5) tmpChargedIso_DR0p4To0p5 += iP->pt();
01556 }
01557 }
01558
01559 else if (iP->particleId() == reco::PFCandidate::gamma) {
01560
01561
01562 if (fabs(fMVAVar_eta) > 1.479 && dr < 0.08) passVeto = kFALSE;
01563
01564 if (passVeto) {
01565 if (dr < 0.1) tmpGammaIso_DR0p0To0p1 += iP->pt();
01566 if (dr >= 0.1 && dr < 0.2) tmpGammaIso_DR0p1To0p2 += iP->pt();
01567 if (dr >= 0.2 && dr < 0.3) tmpGammaIso_DR0p2To0p3 += iP->pt();
01568 if (dr >= 0.3 && dr < 0.4) tmpGammaIso_DR0p3To0p4 += iP->pt();
01569 if (dr >= 0.4 && dr < 0.5) tmpGammaIso_DR0p4To0p5 += iP->pt();
01570 }
01571 }
01572
01573 else {
01574 if (dr < 0.1) tmpNeutralHadronIso_DR0p0To0p1 += iP->pt();
01575 if (dr >= 0.1 && dr < 0.2) tmpNeutralHadronIso_DR0p1To0p2 += iP->pt();
01576 if (dr >= 0.2 && dr < 0.3) tmpNeutralHadronIso_DR0p2To0p3 += iP->pt();
01577 if (dr >= 0.3 && dr < 0.4) tmpNeutralHadronIso_DR0p3To0p4 += iP->pt();
01578 if (dr >= 0.4 && dr < 0.5) tmpNeutralHadronIso_DR0p4To0p5 += iP->pt();
01579 }
01580 }
01581 }
01582 }
01583
01584 fMVAVar_ChargedIso_DR0p0To0p1 = TMath::Min((tmpChargedIso_DR0p0To0p1)/ele.pt(), 2.5);
01585 fMVAVar_ChargedIso_DR0p1To0p2 = TMath::Min((tmpChargedIso_DR0p1To0p2)/ele.pt(), 2.5);
01586 fMVAVar_ChargedIso_DR0p2To0p3 = TMath::Min((tmpChargedIso_DR0p2To0p3)/ele.pt(), 2.5);
01587 fMVAVar_ChargedIso_DR0p3To0p4 = TMath::Min((tmpChargedIso_DR0p3To0p4)/ele.pt(), 2.5);
01588 fMVAVar_ChargedIso_DR0p4To0p5 = TMath::Min((tmpChargedIso_DR0p4To0p5)/ele.pt(), 2.5);
01589 fMVAVar_GammaIso_DR0p0To0p1 = TMath::Max(TMath::Min((tmpGammaIso_DR0p0To0p1 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleGammaIsoDR0p0To0p1, fMVAVar_eta, EATarget))/ele.pt(), 2.5), 0.0);
01590 fMVAVar_GammaIso_DR0p1To0p2 = TMath::Max(TMath::Min((tmpGammaIso_DR0p1To0p2 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleGammaIsoDR0p1To0p2, fMVAVar_eta, EATarget))/ele.pt(), 2.5), 0.0);
01591 fMVAVar_GammaIso_DR0p2To0p3 = TMath::Max(TMath::Min((tmpGammaIso_DR0p2To0p3 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleGammaIsoDR0p2To0p3, fMVAVar_eta, EATarget))/ele.pt(), 2.5), 0.0);
01592 fMVAVar_GammaIso_DR0p3To0p4 = TMath::Max(TMath::Min((tmpGammaIso_DR0p3To0p4 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleGammaIsoDR0p3To0p4, fMVAVar_eta, EATarget))/ele.pt(), 2.5), 0.0);
01593 fMVAVar_GammaIso_DR0p4To0p5 = TMath::Max(TMath::Min((tmpGammaIso_DR0p4To0p5 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleGammaIsoDR0p4To0p5, fMVAVar_eta, EATarget))/ele.pt(), 2.5), 0.0);
01594 fMVAVar_NeutralHadronIso_DR0p0To0p1 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p0To0p1 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleNeutralHadronIsoDR0p0To0p1, fMVAVar_eta, EATarget))/ele.pt(), 2.5), 0.0);
01595 fMVAVar_NeutralHadronIso_DR0p1To0p2 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p1To0p2 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleNeutralHadronIsoDR0p1To0p2, fMVAVar_eta, EATarget))/ele.pt(), 2.5), 0.0);
01596 fMVAVar_NeutralHadronIso_DR0p2To0p3 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p2To0p3 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleNeutralHadronIsoDR0p2To0p3, fMVAVar_eta, EATarget))/ele.pt(), 2.5), 0.0);
01597 fMVAVar_NeutralHadronIso_DR0p3To0p4 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p3To0p4 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleNeutralHadronIsoDR0p3To0p4, fMVAVar_eta, EATarget))/ele.pt(), 2.5), 0.0);
01598 fMVAVar_NeutralHadronIso_DR0p4To0p5 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p4To0p5 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleNeutralHadronIsoDR0p4To0p5, fMVAVar_eta, EATarget))/ele.pt(), 2.5), 0.0);
01599
01600 if (printDebug) {
01601 cout << "UseBinnedVersion=" << fUseBinnedVersion << " -> BIN: " << fMVAVar_eta << " " << fMVAVar_pt << " : " << GetMVABin(fMVAVar_eta,fMVAVar_pt) << endl;
01602 }
01603
01604
01605 bindVariables();
01606 Double_t mva = -9999;
01607
01608
01609 if (fUseBinnedVersion) {
01610 mva = fTMVAReader[GetMVABin(fMVAVar_eta,fMVAVar_pt)]->EvaluateMVA(fMethodname);
01611 } else {
01612 mva = fTMVAReader[0]->EvaluateMVA(fMethodname);
01613 }
01614
01615
01616 if(printDebug) {
01617 cout << " *** Inside the class fMethodname " << fMethodname << " fMVAType " << fMVAType << endl;
01618 cout << "ChargedIso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): "
01619 << fMVAVar_ChargedIso_DR0p0To0p1 << " "
01620 << fMVAVar_ChargedIso_DR0p1To0p2 << " "
01621 << fMVAVar_ChargedIso_DR0p2To0p3 << " "
01622 << fMVAVar_ChargedIso_DR0p3To0p4 << " "
01623 << fMVAVar_ChargedIso_DR0p4To0p5 << endl;
01624 cout << "PF Gamma Iso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): "
01625 << fMVAVar_GammaIso_DR0p0To0p1 << " "
01626 << fMVAVar_GammaIso_DR0p1To0p2 << " "
01627 << fMVAVar_GammaIso_DR0p2To0p3 << " "
01628 << fMVAVar_GammaIso_DR0p3To0p4 << " "
01629 << fMVAVar_GammaIso_DR0p4To0p5 << endl;
01630 cout << "PF Neutral Hadron Iso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): "
01631 << fMVAVar_NeutralHadronIso_DR0p0To0p1 << " "
01632 << fMVAVar_NeutralHadronIso_DR0p1To0p2 << " "
01633 << fMVAVar_NeutralHadronIso_DR0p2To0p3 << " "
01634 << fMVAVar_NeutralHadronIso_DR0p3To0p4 << " "
01635 << fMVAVar_NeutralHadronIso_DR0p4To0p5 << " "
01636 << endl;
01637 cout << " ### MVA " << mva << endl;
01638 }
01639
01640
01641 return mva;
01642 }
01643
01644
01645
01646
01647 Double_t EGammaMvaEleEstimator::IDIsoCombinedMvaValue(const reco::GsfElectron& ele,
01648 const reco::Vertex& vertex,
01649 const TransientTrackBuilder& transientTrackBuilder,
01650 EcalClusterLazyTools myEcalCluster,
01651 const reco::PFCandidateCollection &PFCandidates,
01652 double Rho,
01653 ElectronEffectiveArea::ElectronEffectiveAreaTarget EATarget,
01654 bool printDebug) {
01655
01656 if (!fisInitialized) {
01657 std::cout << "Error: EGammaMvaEleEstimator not properly initialized.\n";
01658 return -9999;
01659 }
01660
01661 bool validKF= false;
01662 reco::TrackRef myTrackRef = ele.closestCtfTrackRef();
01663 validKF = (myTrackRef.isAvailable());
01664 validKF = (myTrackRef.isNonnull());
01665
01666
01667 fMVAVar_fbrem = (ele.fbrem() < -1. ) ? -1. : ele.fbrem();
01668 fMVAVar_kfchi2 = (validKF) ? myTrackRef->normalizedChi2() : 0 ;
01669 if (fMVAVar_kfchi2 > 10) fMVAVar_kfchi2 = 10;
01670 fMVAVar_kfhits = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1. ;
01671 fMVAVar_kfhitsall = (validKF) ? myTrackRef->numberOfValidHits() : -1. ;
01672 fMVAVar_gsfchi2 = ele.gsfTrack()->normalizedChi2();
01673 if (fMVAVar_gsfchi2 > 200) fMVAVar_gsfchi2 = 200;
01674
01675
01676
01677 fMVAVar_deta = ( fabs(ele.deltaEtaSuperClusterTrackAtVtx()) > 0.06 ) ? 0.06 : fabs(ele.deltaEtaSuperClusterTrackAtVtx());
01678 fMVAVar_dphi = ele.deltaPhiSuperClusterTrackAtVtx();
01679 fMVAVar_detacalo = ele.deltaEtaSeedClusterTrackAtCalo();
01680
01681
01682
01683 fMVAVar_see = ele.sigmaIetaIeta();
01684 std::vector<float> vCov = myEcalCluster.localCovariances(*(ele.superCluster()->seed())) ;
01685 if (!isnan(vCov[2])) fMVAVar_spp = sqrt (vCov[2]);
01686 else fMVAVar_spp = 0.;
01687
01688 fMVAVar_etawidth = ele.superCluster()->etaWidth();
01689 fMVAVar_phiwidth = ele.superCluster()->phiWidth();
01690 fMVAVar_OneMinusE1x5E5x5 = (ele.e5x5()) !=0. ? 1.-(ele.e1x5()/ele.e5x5()) : -1. ;
01691 fMVAVar_OneMinusE1x5E5x5 = max(min(double(fMVAVar_OneMinusE1x5E5x5),2.0),-1.0);
01692 fMVAVar_R9 = myEcalCluster.e3x3(*(ele.superCluster()->seed())) / ele.superCluster()->rawEnergy();
01693 if (fMVAVar_R9 > 5) fMVAVar_R9 = 5;
01694
01695
01696 fMVAVar_HoE = ele.hadronicOverEm();
01697 fMVAVar_EoP = ( ele.eSuperClusterOverP() > 20 ) ? 20 : ele.eSuperClusterOverP();
01698 fMVAVar_IoEmIoP = (1.0/ele.superCluster()->energy()) - (1.0 / ele.trackMomentumAtVtx().R());
01699 fMVAVar_eleEoPout = ( ele.eEleClusterOverPout() > 20 ) ? 20 : ele.eEleClusterOverPout();
01700 fMVAVar_PreShowerOverRaw= ele.superCluster()->preshowerEnergy() / ele.superCluster()->rawEnergy();
01701
01702
01703 fMVAVar_eta = ele.superCluster()->eta();
01704 fMVAVar_pt = ele.pt();
01705
01706
01707
01708
01709 if(fMVAType == kTrig) {
01710
01711 if (ele.gsfTrack().isNonnull()) {
01712 fMVAVar_d0 = (-1.0)*ele.gsfTrack()->dxy(vertex.position());
01713 } else if (ele.closestCtfTrackRef().isNonnull()) {
01714 fMVAVar_d0 = (-1.0)*ele.closestCtfTrackRef()->dxy(vertex.position());
01715 } else {
01716 fMVAVar_d0 = -9999.0;
01717 }
01718
01719
01720 fMVAVar_ip3d = -999.0;
01721 fMVAVar_ip3dSig = 0.0;
01722 if (ele.gsfTrack().isNonnull()) {
01723 const double gsfsign = ( (-ele.gsfTrack()->dxy(vertex.position())) >=0 ) ? 1. : -1.;
01724
01725 const reco::TransientTrack &tt = transientTrackBuilder.build(ele.gsfTrack());
01726 const std::pair<bool,Measurement1D> &ip3dpv = IPTools::absoluteImpactParameter3D(tt,vertex);
01727 if (ip3dpv.first) {
01728 double ip3d = gsfsign*ip3dpv.second.value();
01729 double ip3derr = ip3dpv.second.error();
01730 fMVAVar_ip3d = ip3d;
01731 fMVAVar_ip3dSig = ip3d/ip3derr;
01732 }
01733 }
01734 }
01735
01736
01737
01738
01739 Double_t tmpChargedIso_DR0p0To0p1 = 0;
01740 Double_t tmpChargedIso_DR0p1To0p2 = 0;
01741 Double_t tmpChargedIso_DR0p2To0p3 = 0;
01742 Double_t tmpChargedIso_DR0p3To0p4 = 0;
01743 Double_t tmpChargedIso_DR0p4To0p5 = 0;
01744 Double_t tmpGammaIso_DR0p0To0p1 = 0;
01745 Double_t tmpGammaIso_DR0p1To0p2 = 0;
01746 Double_t tmpGammaIso_DR0p2To0p3 = 0;
01747 Double_t tmpGammaIso_DR0p3To0p4 = 0;
01748 Double_t tmpGammaIso_DR0p4To0p5 = 0;
01749 Double_t tmpNeutralHadronIso_DR0p0To0p1 = 0;
01750 Double_t tmpNeutralHadronIso_DR0p1To0p2 = 0;
01751 Double_t tmpNeutralHadronIso_DR0p2To0p3 = 0;
01752 Double_t tmpNeutralHadronIso_DR0p3To0p4 = 0;
01753 Double_t tmpNeutralHadronIso_DR0p4To0p5 = 0;
01754
01755 for (reco::PFCandidateCollection::const_iterator iP = PFCandidates.begin();
01756 iP != PFCandidates.end(); ++iP) {
01757
01758 double dr = sqrt(pow(iP->eta() - ele.eta(),2) + pow(acos(cos(iP->phi() - ele.phi())),2));
01759
01760 Bool_t passVeto = kTRUE;
01761
01762 if(iP->trackRef().isNonnull()) {
01763
01764
01765
01766
01767
01768 if (iP->particleId() == reco::PFCandidate::e || iP->particleId() == reco::PFCandidate::mu) passVeto = kFALSE;
01769
01770
01771
01772 if (fabs(fMVAVar_eta) > 1.479 && dr < 0.015) passVeto = kFALSE;
01773
01774 if (passVeto) {
01775 if (dr < 0.1) tmpChargedIso_DR0p0To0p1 += iP->pt();
01776 if (dr >= 0.1 && dr < 0.2) tmpChargedIso_DR0p1To0p2 += iP->pt();
01777 if (dr >= 0.2 && dr < 0.3) tmpChargedIso_DR0p2To0p3 += iP->pt();
01778 if (dr >= 0.3 && dr < 0.4) tmpChargedIso_DR0p3To0p4 += iP->pt();
01779 if (dr >= 0.4 && dr < 0.5) tmpChargedIso_DR0p4To0p5 += iP->pt();
01780 }
01781 }
01782
01783 else if (iP->particleId() == reco::PFCandidate::gamma) {
01784
01785
01786 if (fabs(fMVAVar_eta) > 1.479 && dr < 0.08) passVeto = kFALSE;
01787
01788 if (passVeto) {
01789 if (dr < 0.1) tmpGammaIso_DR0p0To0p1 += iP->pt();
01790 if (dr >= 0.1 && dr < 0.2) tmpGammaIso_DR0p1To0p2 += iP->pt();
01791 if (dr >= 0.2 && dr < 0.3) tmpGammaIso_DR0p2To0p3 += iP->pt();
01792 if (dr >= 0.3 && dr < 0.4) tmpGammaIso_DR0p3To0p4 += iP->pt();
01793 if (dr >= 0.4 && dr < 0.5) tmpGammaIso_DR0p4To0p5 += iP->pt();
01794 }
01795 }
01796
01797 else {
01798 if (dr < 0.1) tmpNeutralHadronIso_DR0p0To0p1 += iP->pt();
01799 if (dr >= 0.1 && dr < 0.2) tmpNeutralHadronIso_DR0p1To0p2 += iP->pt();
01800 if (dr >= 0.2 && dr < 0.3) tmpNeutralHadronIso_DR0p2To0p3 += iP->pt();
01801 if (dr >= 0.3 && dr < 0.4) tmpNeutralHadronIso_DR0p3To0p4 += iP->pt();
01802 if (dr >= 0.4 && dr < 0.5) tmpNeutralHadronIso_DR0p4To0p5 += iP->pt();
01803 }
01804 }
01805
01806 if (fMVAType == kTrigIDIsoCombinedPUCorrected) {
01807 fMVAVar_ChargedIso_DR0p0To0p1 = TMath::Min((tmpChargedIso_DR0p0To0p1)/ele.pt(), 2.5);
01808 fMVAVar_ChargedIso_DR0p1To0p2 = TMath::Min((tmpChargedIso_DR0p1To0p2)/ele.pt(), 2.5);
01809 fMVAVar_ChargedIso_DR0p2To0p3 = TMath::Min((tmpChargedIso_DR0p2To0p3)/ele.pt(), 2.5);
01810 fMVAVar_ChargedIso_DR0p3To0p4 = TMath::Min((tmpChargedIso_DR0p3To0p4)/ele.pt(), 2.5);
01811 fMVAVar_ChargedIso_DR0p4To0p5 = TMath::Min((tmpChargedIso_DR0p4To0p5)/ele.pt(), 2.5);
01812 fMVAVar_GammaIso_DR0p0To0p1 = TMath::Max(TMath::Min((tmpGammaIso_DR0p0To0p1 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleGammaIsoDR0p0To0p1, fMVAVar_eta, EATarget))/ele.pt(), 2.5), 0.0);
01813 fMVAVar_GammaIso_DR0p1To0p2 = TMath::Max(TMath::Min((tmpGammaIso_DR0p1To0p2 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleGammaIsoDR0p1To0p2, fMVAVar_eta, EATarget))/ele.pt(), 2.5), 0.0);
01814 fMVAVar_GammaIso_DR0p2To0p3 = TMath::Max(TMath::Min((tmpGammaIso_DR0p2To0p3 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleGammaIsoDR0p2To0p3, fMVAVar_eta, EATarget))/ele.pt(), 2.5), 0.0);
01815 fMVAVar_GammaIso_DR0p3To0p4 = TMath::Max(TMath::Min((tmpGammaIso_DR0p3To0p4 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleGammaIsoDR0p3To0p4, fMVAVar_eta, EATarget))/ele.pt(), 2.5), 0.0);
01816 fMVAVar_GammaIso_DR0p4To0p5 = TMath::Max(TMath::Min((tmpGammaIso_DR0p4To0p5 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleGammaIsoDR0p4To0p5, fMVAVar_eta, EATarget))/ele.pt(), 2.5), 0.0);
01817 fMVAVar_NeutralHadronIso_DR0p0To0p1 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p0To0p1 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleNeutralHadronIsoDR0p0To0p1, fMVAVar_eta, EATarget))/ele.pt(), 2.5), 0.0);
01818 fMVAVar_NeutralHadronIso_DR0p1To0p2 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p1To0p2 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleNeutralHadronIsoDR0p1To0p2, fMVAVar_eta, EATarget))/ele.pt(), 2.5), 0.0);
01819 fMVAVar_NeutralHadronIso_DR0p2To0p3 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p2To0p3 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleNeutralHadronIsoDR0p2To0p3, fMVAVar_eta, EATarget))/ele.pt(), 2.5), 0.0);
01820 fMVAVar_NeutralHadronIso_DR0p3To0p4 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p3To0p4 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleNeutralHadronIsoDR0p3To0p4, fMVAVar_eta, EATarget))/ele.pt(), 2.5), 0.0);
01821 fMVAVar_NeutralHadronIso_DR0p4To0p5 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p4To0p5 - Rho*ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleNeutralHadronIsoDR0p4To0p5, fMVAVar_eta, EATarget))/ele.pt(), 2.5), 0.0);
01822 } else if (fMVAType == kTrigIDIsoCombined) {
01823 fMVAVar_ChargedIso_DR0p0To0p1 = TMath::Min((tmpChargedIso_DR0p0To0p1)/ele.pt(), 2.5);
01824 fMVAVar_ChargedIso_DR0p1To0p2 = TMath::Min((tmpChargedIso_DR0p1To0p2)/ele.pt(), 2.5);
01825 fMVAVar_ChargedIso_DR0p2To0p3 = TMath::Min((tmpChargedIso_DR0p2To0p3)/ele.pt(), 2.5);
01826 fMVAVar_ChargedIso_DR0p3To0p4 = TMath::Min((tmpChargedIso_DR0p3To0p4)/ele.pt(), 2.5);
01827 fMVAVar_ChargedIso_DR0p4To0p5 = TMath::Min((tmpChargedIso_DR0p4To0p5)/ele.pt(), 2.5);
01828 fMVAVar_GammaIso_DR0p0To0p1 = TMath::Max(TMath::Min((tmpGammaIso_DR0p0To0p1)/ele.pt(), 2.5), 0.0);
01829 fMVAVar_GammaIso_DR0p1To0p2 = TMath::Max(TMath::Min((tmpGammaIso_DR0p1To0p2)/ele.pt(), 2.5), 0.0);
01830 fMVAVar_GammaIso_DR0p2To0p3 = TMath::Max(TMath::Min((tmpGammaIso_DR0p2To0p3)/ele.pt(), 2.5), 0.0);
01831 fMVAVar_GammaIso_DR0p3To0p4 = TMath::Max(TMath::Min((tmpGammaIso_DR0p3To0p4)/ele.pt(), 2.5), 0.0);
01832 fMVAVar_GammaIso_DR0p4To0p5 = TMath::Max(TMath::Min((tmpGammaIso_DR0p4To0p5)/ele.pt(), 2.5), 0.0);
01833 fMVAVar_NeutralHadronIso_DR0p0To0p1 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p0To0p1)/ele.pt(), 2.5), 0.0);
01834 fMVAVar_NeutralHadronIso_DR0p1To0p2 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p1To0p2)/ele.pt(), 2.5), 0.0);
01835 fMVAVar_NeutralHadronIso_DR0p2To0p3 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p2To0p3)/ele.pt(), 2.5), 0.0);
01836 fMVAVar_NeutralHadronIso_DR0p3To0p4 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p3To0p4)/ele.pt(), 2.5), 0.0);
01837 fMVAVar_NeutralHadronIso_DR0p4To0p5 = TMath::Max(TMath::Min((tmpNeutralHadronIso_DR0p4To0p5)/ele.pt(), 2.5), 0.0);
01838 fMVAVar_rho = Rho;
01839 } else {
01840 cout << "Warning: Type " << fMVAType << " is not supported.\n";
01841 }
01842
01843
01844 Double_t mva = -9999;
01845 if (fUseBinnedVersion) {
01846 mva = fTMVAReader[GetMVABin(fMVAVar_eta,fMVAVar_pt)]->EvaluateMVA(fMethodname);
01847 } else {
01848 mva = fTMVAReader[0]->EvaluateMVA(fMethodname);
01849 }
01850
01851
01852
01853 if(printDebug) {
01854 cout << " *** Inside the class fMethodname " << fMethodname << " fMVAType " << fMVAType << endl;
01855 cout << " fbrem " << fMVAVar_fbrem
01856 << " kfchi2 " << fMVAVar_kfchi2
01857 << " mykfhits " << fMVAVar_kfhits
01858 << " gsfchi2 " << fMVAVar_gsfchi2
01859 << " deta " << fMVAVar_deta
01860 << " dphi " << fMVAVar_dphi
01861 << " detacalo " << fMVAVar_detacalo
01862 << " see " << fMVAVar_see
01863 << " spp " << fMVAVar_spp
01864 << " etawidth " << fMVAVar_etawidth
01865 << " phiwidth " << fMVAVar_phiwidth
01866 << " OneMinusE1x5E5x5 " << fMVAVar_OneMinusE1x5E5x5
01867 << " R9 " << fMVAVar_R9
01868 << " HoE " << fMVAVar_HoE
01869 << " EoP " << fMVAVar_EoP
01870 << " IoEmIoP " << fMVAVar_IoEmIoP
01871 << " eleEoPout " << fMVAVar_eleEoPout
01872 << " d0 " << fMVAVar_d0
01873 << " ip3d " << fMVAVar_ip3d
01874 << " eta " << fMVAVar_eta
01875 << " pt " << fMVAVar_pt << endl;
01876 cout << "ChargedIso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): "
01877 << fMVAVar_ChargedIso_DR0p0To0p1 << " "
01878 << fMVAVar_ChargedIso_DR0p1To0p2 << " "
01879 << fMVAVar_ChargedIso_DR0p2To0p3 << " "
01880 << fMVAVar_ChargedIso_DR0p3To0p4 << " "
01881 << fMVAVar_ChargedIso_DR0p4To0p5 << endl;
01882 cout << "PF Gamma Iso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): "
01883 << fMVAVar_GammaIso_DR0p0To0p1 << " "
01884 << fMVAVar_GammaIso_DR0p1To0p2 << " "
01885 << fMVAVar_GammaIso_DR0p2To0p3 << " "
01886 << fMVAVar_GammaIso_DR0p3To0p4 << " "
01887 << fMVAVar_GammaIso_DR0p4To0p5 << endl;
01888 cout << "PF Neutral Hadron Iso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): "
01889 << fMVAVar_NeutralHadronIso_DR0p0To0p1 << " "
01890 << fMVAVar_NeutralHadronIso_DR0p1To0p2 << " "
01891 << fMVAVar_NeutralHadronIso_DR0p2To0p3 << " "
01892 << fMVAVar_NeutralHadronIso_DR0p3To0p4 << " "
01893 << fMVAVar_NeutralHadronIso_DR0p4To0p5 << " "
01894 << endl;
01895 cout << "Rho : " << Rho << endl;
01896 cout << " ### MVA " << mva << endl;
01897 }
01898
01899
01900
01901 return mva;
01902 }
01903
01904
01905
01906
01907 #endif
01908
01909 void EGammaMvaEleEstimator::bindVariables() {
01910
01911
01912
01913
01914 if(fMVAVar_fbrem < -1.)
01915 fMVAVar_fbrem = -1.;
01916
01917 fMVAVar_deta = fabs(fMVAVar_deta);
01918 if(fMVAVar_deta > 0.06)
01919 fMVAVar_deta = 0.06;
01920
01921
01922 fMVAVar_dphi = fabs(fMVAVar_dphi);
01923 if(fMVAVar_dphi > 0.6)
01924 fMVAVar_dphi = 0.6;
01925
01926
01927 if(fMVAVar_EoP > 20.)
01928 fMVAVar_EoP = 20.;
01929
01930 if(fMVAVar_eleEoPout > 20.)
01931 fMVAVar_eleEoPout = 20.;
01932
01933
01934 fMVAVar_detacalo = fabs(fMVAVar_detacalo);
01935 if(fMVAVar_detacalo > 0.2)
01936 fMVAVar_detacalo = 0.2;
01937
01938 if(fMVAVar_OneMinusE1x5E5x5 < -1.)
01939 fMVAVar_OneMinusE1x5E5x5 = -1;
01940
01941 if(fMVAVar_OneMinusE1x5E5x5 > 2.)
01942 fMVAVar_OneMinusE1x5E5x5 = 2.;
01943
01944
01945
01946 if(fMVAVar_R9 > 5)
01947 fMVAVar_R9 = 5;
01948
01949 if(fMVAVar_gsfchi2 > 200.)
01950 fMVAVar_gsfchi2 = 200;
01951
01952
01953 if(fMVAVar_kfchi2 > 10.)
01954 fMVAVar_kfchi2 = 10.;
01955
01956
01957
01958 if(std::isnan(fMVAVar_spp))
01959 fMVAVar_spp = 0.;
01960
01961
01962 return;
01963 }
01964
01965
01966
01967
01968
01969
01970
01971