4 |
|
#include "MitPhysics/Utils/interface/MVATools.h" |
5 |
|
#include "MitPhysics/Utils/interface/ElectronTools.h" |
6 |
|
#include "MitPhysics/Utils/interface/IsolationTools.h" |
7 |
+ |
#include "MitAna/DataTree/interface/PFCandidateCol.h" |
8 |
|
#include "MitAna/DataTree/interface/StableData.h" |
9 |
+ |
#include <TMath.h> |
10 |
|
#include <TFile.h> |
11 |
|
#include <TRandom3.h> |
12 |
+ |
#include <TSystem.h> |
13 |
|
#include "TMVA/Tools.h"//MVA |
14 |
|
#include "TMVA/Reader.h"//MVA |
15 |
|
|
16 |
+ |
|
17 |
|
ClassImp(mithep::MVATools) |
18 |
|
|
19 |
|
using namespace mithep; |
24 |
|
fReaderEndcap(0), |
25 |
|
fReaderBarrel(0), |
26 |
|
|
27 |
+ |
fMVAType (MVATools::kNone) |
28 |
+ |
|
29 |
+ |
// ------------------------------------------------------------------------------ |
30 |
+ |
// fab: These guys should all go away.... |
31 |
|
//MVA Variables v4 |
32 |
< |
HoE(0), |
33 |
< |
covIEtaIEta(0), |
34 |
< |
tIso1abs(0), |
35 |
< |
tIso3abs(0), |
36 |
< |
tIso2abs(0), |
37 |
< |
R9(0), |
38 |
< |
|
39 |
< |
absIsoEcal(0), |
40 |
< |
absIsoHcal(0), |
41 |
< |
RelEMax(0), |
42 |
< |
RelETop(0), |
43 |
< |
RelEBottom(0), |
44 |
< |
RelELeft(0), |
45 |
< |
RelERight(0), |
46 |
< |
RelE2x5Max(0), |
47 |
< |
RelE2x5Top(0), |
48 |
< |
RelE2x5Bottom(0), |
49 |
< |
RelE2x5Left(0), |
50 |
< |
RelE2x5Right(0), |
51 |
< |
RelE5x5(0), |
52 |
< |
|
53 |
< |
EtaWidth(0), |
54 |
< |
PhiWidth(0), |
55 |
< |
CoviEtaiPhi(0), |
56 |
< |
CoviPhiiPhi(0), |
57 |
< |
|
58 |
< |
NVertexes(0), |
59 |
< |
RelPreshowerEnergy(0), |
60 |
< |
|
61 |
< |
//MVA v2 and v1 |
62 |
< |
RelIsoEcal(0), |
63 |
< |
RelIsoHcal(0), |
64 |
< |
tIso1(0), |
65 |
< |
tIso3(0), |
66 |
< |
tIso2(0) |
32 |
> |
// HoE(0), |
33 |
> |
// covIEtaIEta(0), |
34 |
> |
// tIso1abs(0), |
35 |
> |
// tIso3abs(0), |
36 |
> |
// tIso2abs(0), |
37 |
> |
// R9(0), |
38 |
> |
|
39 |
> |
// absIsoEcal(0), |
40 |
> |
// absIsoHcal(0), |
41 |
> |
// RelEMax(0), |
42 |
> |
// RelETop(0), |
43 |
> |
// RelEBottom(0), |
44 |
> |
// RelELeft(0), |
45 |
> |
// RelERight(0), |
46 |
> |
// RelE2x5Max(0), |
47 |
> |
// RelE2x5Top(0), |
48 |
> |
// RelE2x5Bottom(0), |
49 |
> |
// RelE2x5Left(0), |
50 |
> |
// RelE2x5Right(0), |
51 |
> |
// RelE5x5(0), |
52 |
> |
|
53 |
> |
// EtaWidth(0), |
54 |
> |
// PhiWidth(0), |
55 |
> |
// CoviEtaiPhi(0), |
56 |
> |
// CoviPhiiPhi(0), |
57 |
> |
|
58 |
> |
// NVertexes(0), |
59 |
> |
// RelPreshowerEnergy(0), |
60 |
> |
|
61 |
> |
// //MVA v2 and v1 |
62 |
> |
// RelIsoEcal(0), |
63 |
> |
// RelIsoHcal(0), |
64 |
> |
// tIso1(0), |
65 |
> |
// tIso3(0), |
66 |
> |
// tIso2(0), |
67 |
> |
// ScEta(0.) |
68 |
> |
|
69 |
|
{ |
70 |
|
// Constructor. |
71 |
|
} |
72 |
|
|
73 |
|
//-------------------------------------------------------------------------------------------------- |
74 |
< |
void MVATools::InitializeMVA(int VariableType, TString EndcapWeights,TString BarrelWeights) { |
74 |
> |
void MVATools::InitializeMVA(MVATools::IdMVAType type) { |
75 |
|
|
76 |
+ |
fMVAType = type; |
77 |
+ |
|
78 |
|
if (fReaderEndcap) delete fReaderEndcap; |
79 |
|
if (fReaderBarrel) delete fReaderBarrel; |
80 |
+ |
|
81 |
+ |
// no MVA needed if none requested |
82 |
+ |
if( type == kNone ) { |
83 |
+ |
return; |
84 |
+ |
} |
85 |
|
|
86 |
|
fReaderEndcap = new TMVA::Reader( "!Color:!Silent:Error" ); |
87 |
|
fReaderBarrel = new TMVA::Reader( "!Color:!Silent:Error" ); |
88 |
+ |
|
89 |
+ |
TString BarrelWeights; |
90 |
+ |
TString EndcapWeights; |
91 |
+ |
|
92 |
+ |
std::vector<std::string> varNames; // tmp vector to push_back variable names |
93 |
+ |
varNames.resize(0); |
94 |
|
|
95 |
< |
TMVA::Reader *readers[2]; |
73 |
< |
readers[0] = fReaderEndcap; |
74 |
< |
readers[1] = fReaderBarrel; |
75 |
< |
|
76 |
< |
for (UInt_t i=0; i<2; ++i) { |
77 |
< |
|
78 |
< |
if(VariableType==0||VariableType==1||VariableType==2){ |
79 |
< |
readers[i]->AddVariable( "HoE", &HoE ); |
80 |
< |
readers[i]->AddVariable( "covIEtaIEta", &covIEtaIEta ); |
81 |
< |
readers[i]->AddVariable( "tIso1", &tIso1 ); |
82 |
< |
readers[i]->AddVariable( "tIso3", &tIso3 ); |
83 |
< |
readers[i]->AddVariable( "tIso2", &tIso2 ); |
84 |
< |
readers[i]->AddVariable( "R9", &R9 ); |
85 |
< |
} |
95 |
> |
switch (type) { |
96 |
|
|
97 |
< |
if(VariableType==3||VariableType==4){ |
98 |
< |
readers[i]->AddVariable( "HoE", &HoE ); |
99 |
< |
readers[i]->AddVariable( "covIEtaIEta", &covIEtaIEta ); |
100 |
< |
readers[i]->AddVariable( "tIso1abs", &tIso1abs ); |
101 |
< |
readers[i]->AddVariable( "tIso3abs", &tIso3abs ); |
102 |
< |
readers[i]->AddVariable( "tIso2abs", &tIso2abs ); |
103 |
< |
readers[i]->AddVariable( "R9", &R9 ); |
97 |
> |
case k2011IdMVA: |
98 |
> |
|
99 |
> |
EndcapWeights = (gSystem->Getenv("CMSSW_BASE")+ |
100 |
> |
TString("/src/MitPhysics/data/TMVAClassificationPhotonID_")+ |
101 |
> |
TString("Endcap_PassPreSel_Variable_10_BDTnCuts2000_BDT.")+ |
102 |
> |
TString("weights.xml")); |
103 |
> |
BarrelWeights = (gSystem->Getenv("CMSSW_BASE")+ |
104 |
> |
TString("/src/MitPhysics/data/TMVAClassificationPhotonID_")+ |
105 |
> |
TString("Barrel_PassPreSel_Variable_10_BDTnCuts2000_BDT.")+ |
106 |
> |
TString("weights.xml")); |
107 |
> |
|
108 |
> |
// set up the variable names |
109 |
> |
mvaVars.resize(12); |
110 |
> |
varNames.push_back("HoE" ); |
111 |
> |
varNames.push_back("covIEtaIEta"); |
112 |
> |
varNames.push_back("tIso1abs" ); |
113 |
> |
varNames.push_back("tIso3abs" ); |
114 |
> |
varNames.push_back("tIso2abs" ); |
115 |
> |
varNames.push_back("R9" ); |
116 |
> |
varNames.push_back("absIsoEcal" ); |
117 |
> |
varNames.push_back("absIsoHcal" ); |
118 |
> |
varNames.push_back("NVertexes" ); |
119 |
> |
varNames.push_back("ScEta" ); |
120 |
> |
varNames.push_back("EtaWidth" ); |
121 |
> |
varNames.push_back("PhiWidth" ); |
122 |
> |
|
123 |
> |
for( unsigned int iV = 0; iV < mvaVars.size(); ++iV) { |
124 |
> |
mvaVarMapEB.insert( std::pair<std::string,float*>(varNames[iV], &(mvaVars[iV])) ); |
125 |
> |
mvaVarMapEE.insert( std::pair<std::string,float*>(varNames[iV], &(mvaVars[iV])) ); |
126 |
|
} |
127 |
|
|
128 |
< |
if(VariableType==1||VariableType==2){ |
129 |
< |
readers[i]->AddVariable( "RelIsoEcal", &RelIsoEcal ); |
130 |
< |
readers[i]->AddVariable( "RelIsoHcal", &RelIsoHcal ); |
131 |
< |
readers[i]->AddVariable( "RelEMax", &RelEMax ); |
100 |
< |
readers[i]->AddVariable( "RelETop", &RelETop ); |
101 |
< |
readers[i]->AddVariable( "RelEBottom", &RelEBottom ); |
102 |
< |
readers[i]->AddVariable( "RelELeft", &RelELeft ); |
103 |
< |
readers[i]->AddVariable( "RelERight", &RelERight ); |
104 |
< |
readers[i]->AddVariable( "RelE2x5Max", &RelE2x5Max ); |
105 |
< |
readers[i]->AddVariable( "RelE2x5Top", &RelE2x5Top ); |
106 |
< |
readers[i]->AddVariable( "RelE2x5Bottom", &RelE2x5Bottom ); |
107 |
< |
readers[i]->AddVariable( "RelE2x5Left", &RelE2x5Left ); |
108 |
< |
readers[i]->AddVariable( "RelE2x5Right", &RelE2x5Right ); |
109 |
< |
readers[i]->AddVariable( "RelE5x5", &RelE5x5 ); |
110 |
< |
} |
128 |
> |
break; |
129 |
> |
|
130 |
> |
case k2012IdMVA: |
131 |
> |
case k2012IdMVA_globe: |
132 |
|
|
133 |
< |
if(VariableType==3||VariableType==4){ |
134 |
< |
readers[i]->AddVariable( "absIsoEcal", &absIsoEcal ); |
135 |
< |
readers[i]->AddVariable( "absIsoHcal", &absIsoHcal ); |
136 |
< |
readers[i]->AddVariable( "RelEMax", &RelEMax ); |
137 |
< |
readers[i]->AddVariable( "RelETop", &RelEBottom); |
138 |
< |
readers[i]->AddVariable( "RelEBottom", &RelEBottom ); |
139 |
< |
readers[i]->AddVariable( "RelELeft", &RelELeft ); |
140 |
< |
readers[i]->AddVariable( "RelERight", &RelERight ); |
141 |
< |
readers[i]->AddVariable( "RelE2x5Max", &RelE2x5Max ); |
142 |
< |
readers[i]->AddVariable( "RelE2x5Top", &RelE2x5Top ); |
143 |
< |
readers[i]->AddVariable( "RelE2x5Bottom", &RelE2x5Bottom ); |
144 |
< |
readers[i]->AddVariable( "RelE2x5Left", &RelE2x5Left ); |
145 |
< |
readers[i]->AddVariable( "RelE2x5Right", &RelE2x5Right ); |
146 |
< |
readers[i]->AddVariable( "RelE5x5", &RelE5x5 ); |
133 |
> |
EndcapWeights = (gSystem->Getenv("CMSSW_BASE")+ |
134 |
> |
TString("/src/MitPhysics/data/")+ |
135 |
> |
TString("2012ICHEP_PhotonID_Endcap_BDT.")+ |
136 |
> |
TString("weights_PSCorr.xml")); |
137 |
> |
BarrelWeights = (gSystem->Getenv("CMSSW_BASE")+ |
138 |
> |
TString("/src/MitPhysics/data/")+ |
139 |
> |
TString("2012ICHEP_PhotonID_Barrel_BDT.")+ |
140 |
> |
TString("weights.xml")); |
141 |
> |
|
142 |
> |
mvaVars.resize(12); |
143 |
> |
varNames.push_back("ph.r9" ); |
144 |
> |
varNames.push_back("ph.sigietaieta" ); |
145 |
> |
varNames.push_back("ph.scetawidth" ); |
146 |
> |
varNames.push_back("ph.scphiwidth" ); |
147 |
> |
varNames.push_back("ph.idmva_CoviEtaiPhi" ); |
148 |
> |
varNames.push_back("ph.idmva_s4ratio" ); |
149 |
> |
varNames.push_back("ph.idmva_GammaIso" ); |
150 |
> |
varNames.push_back("ph.idmva_ChargedIso_selvtx" ); |
151 |
> |
varNames.push_back("ph.idmva_ChargedIso_worstvtx" ); |
152 |
> |
varNames.push_back("ph.sceta" ); |
153 |
> |
varNames.push_back("rho" ); |
154 |
> |
varNames.push_back("ph.idmva_PsEffWidthSigmaRR" ); |
155 |
> |
|
156 |
> |
for( unsigned int iV = 0; iV < mvaVars.size() - 1; ++iV) { |
157 |
> |
mvaVarMapEB.insert( std::pair<std::string,float*>(varNames[iV], &(mvaVars[iV])) ); |
158 |
> |
mvaVarMapEE.insert( std::pair<std::string,float*>(varNames[iV], &(mvaVars[iV])) ); |
159 |
|
} |
160 |
|
|
161 |
< |
if(VariableType==2||VariableType==3||VariableType==4){ |
162 |
< |
readers[i]->AddVariable( "EtaWidth", &EtaWidth ); |
163 |
< |
readers[i]->AddVariable( "PhiWidth", &PhiWidth ); |
164 |
< |
readers[i]->AddVariable( "CoviEtaiPhi", &CoviEtaiPhi ); |
165 |
< |
readers[i]->AddVariable( "CoviPhiiPhi", &CoviPhiiPhi ); |
166 |
< |
if(VariableType==4){ |
167 |
< |
readers[i]->AddVariable( "NVertexes", &NVertexes ); |
168 |
< |
} |
169 |
< |
if(i==0){ |
137 |
< |
readers[i]->AddVariable( "RelPreshowerEnergy", &RelPreshowerEnergy ); |
138 |
< |
} |
139 |
< |
} |
161 |
> |
// pre-shower only used for Endcaps |
162 |
> |
mvaVarMapEE.insert( std::pair<std::string,float*> ( varNames[mvaVars.size() - 1], &(mvaVars[mvaVars.size() - 1]) ) ); |
163 |
> |
|
164 |
> |
break; |
165 |
> |
|
166 |
> |
default: |
167 |
> |
// no variables... better never called.. |
168 |
> |
std::cerr<<" MVATools: Trying to initialize with unknown type."<<std::endl; |
169 |
> |
break; |
170 |
|
} |
171 |
+ |
|
172 |
+ |
|
173 |
+ |
// looping over both maps and adding Vars to BDT readers |
174 |
+ |
for(std::map<std::string,float*>::const_iterator it = mvaVarMapEB.begin(); it != mvaVarMapEB.end(); ++it) |
175 |
+ |
fReaderBarrel -> AddVariable( (it->first).c_str(), it->second); |
176 |
+ |
for(std::map<std::string,float*>::const_iterator it = mvaVarMapEE.begin(); it != mvaVarMapEE.end(); ++it) |
177 |
+ |
fReaderEndcap -> AddVariable( (it->first).c_str(), it->second); |
178 |
|
|
179 |
|
fReaderEndcap->BookMVA("BDT method",EndcapWeights); |
180 |
|
fReaderBarrel->BookMVA("BDT method",BarrelWeights); |
184 |
|
|
185 |
|
} |
186 |
|
|
187 |
< |
Bool_t MVATools::PassMVASelection(const Photon* p,const Vertex* vtx,const TrackCol* trackCol,const VertexCol* vtxCol,Double_t _tRho,const ElectronCol* els,Float_t bdtCutBarrel, Float_t bdtCutEndcap) { |
187 |
> |
// //-------------------------------------------------------------------------------------------------- |
188 |
> |
// void MVATools::InitializeMVA(int VariableType, TString EndcapWeights,TString BarrelWeights) { |
189 |
|
|
190 |
< |
//initilize the bool value |
191 |
< |
PassMVA=kFALSE; |
190 |
> |
// if (fReaderEndcap) delete fReaderEndcap; |
191 |
> |
// if (fReaderBarrel) delete fReaderBarrel; |
192 |
|
|
193 |
< |
Float_t photon_bdt = MVATools::GetMVAbdtValue(p,vtx,trackCol,vtxCol, _tRho,els); |
193 |
> |
// fReaderEndcap = new TMVA::Reader( "!Color:!Silent:Error" ); |
194 |
> |
// fReaderBarrel = new TMVA::Reader( "!Color:!Silent:Error" ); |
195 |
|
|
196 |
< |
if (isbarrel) { |
197 |
< |
if(bdt>bdtCutBarrel){ |
198 |
< |
PassMVA=kTRUE; |
199 |
< |
} |
200 |
< |
} |
201 |
< |
else { |
202 |
< |
if(bdt>bdtCutEndcap){ |
203 |
< |
PassMVA=kTRUE; |
204 |
< |
} |
205 |
< |
} |
206 |
< |
return PassMVA; |
207 |
< |
} |
196 |
> |
// TMVA::Reader *readers[2]; |
197 |
> |
// readers[0] = fReaderEndcap; |
198 |
> |
// readers[1] = fReaderBarrel; |
199 |
> |
|
200 |
> |
// for (UInt_t i=0; i<2; ++i) { |
201 |
> |
|
202 |
> |
// if(VariableType==0||VariableType==1||VariableType==2){ |
203 |
> |
// readers[i]->AddVariable( "HoE", &HoE ); |
204 |
> |
// readers[i]->AddVariable( "covIEtaIEta", &covIEtaIEta ); |
205 |
> |
// readers[i]->AddVariable( "tIso1", &tIso1 ); |
206 |
> |
// readers[i]->AddVariable( "tIso3", &tIso3 ); |
207 |
> |
// readers[i]->AddVariable( "tIso2", &tIso2 ); |
208 |
> |
// readers[i]->AddVariable( "R9", &R9 ); |
209 |
> |
// } |
210 |
> |
|
211 |
> |
// if(VariableType==3||VariableType==4){ |
212 |
> |
// readers[i]->AddVariable( "HoE", &HoE ); |
213 |
> |
// readers[i]->AddVariable( "covIEtaIEta", &covIEtaIEta ); |
214 |
> |
// readers[i]->AddVariable( "tIso1abs", &tIso1abs ); |
215 |
> |
// readers[i]->AddVariable( "tIso3abs", &tIso3abs ); |
216 |
> |
// readers[i]->AddVariable( "tIso2abs", &tIso2abs ); |
217 |
> |
// readers[i]->AddVariable( "R9", &R9 ); |
218 |
> |
// } |
219 |
> |
|
220 |
> |
// if(VariableType==1||VariableType==2){ |
221 |
> |
// readers[i]->AddVariable( "RelIsoEcal", &RelIsoEcal ); |
222 |
> |
// readers[i]->AddVariable( "RelIsoHcal", &RelIsoHcal ); |
223 |
> |
// readers[i]->AddVariable( "RelEMax", &RelEMax ); |
224 |
> |
// readers[i]->AddVariable( "RelETop", &RelETop ); |
225 |
> |
// readers[i]->AddVariable( "RelEBottom", &RelEBottom ); |
226 |
> |
// readers[i]->AddVariable( "RelELeft", &RelELeft ); |
227 |
> |
// readers[i]->AddVariable( "RelERight", &RelERight ); |
228 |
> |
// readers[i]->AddVariable( "RelE2x5Max", &RelE2x5Max ); |
229 |
> |
// readers[i]->AddVariable( "RelE2x5Top", &RelE2x5Top ); |
230 |
> |
// readers[i]->AddVariable( "RelE2x5Bottom", &RelE2x5Bottom ); |
231 |
> |
// readers[i]->AddVariable( "RelE2x5Left", &RelE2x5Left ); |
232 |
> |
// readers[i]->AddVariable( "RelE2x5Right", &RelE2x5Right ); |
233 |
> |
// readers[i]->AddVariable( "RelE5x5", &RelE5x5 ); |
234 |
> |
// } |
235 |
> |
|
236 |
> |
// if(VariableType==3||VariableType==4){ |
237 |
> |
// readers[i]->AddVariable( "absIsoEcal", &absIsoEcal ); |
238 |
> |
// readers[i]->AddVariable( "absIsoHcal", &absIsoHcal ); |
239 |
> |
// readers[i]->AddVariable( "RelEMax", &RelEMax ); |
240 |
> |
// readers[i]->AddVariable( "RelETop", &RelEBottom); |
241 |
> |
// readers[i]->AddVariable( "RelEBottom", &RelEBottom ); |
242 |
> |
// readers[i]->AddVariable( "RelELeft", &RelELeft ); |
243 |
> |
// readers[i]->AddVariable( "RelERight", &RelERight ); |
244 |
> |
// readers[i]->AddVariable( "RelE2x5Max", &RelE2x5Max ); |
245 |
> |
// readers[i]->AddVariable( "RelE2x5Top", &RelE2x5Top ); |
246 |
> |
// readers[i]->AddVariable( "RelE2x5Bottom", &RelE2x5Bottom ); |
247 |
> |
// readers[i]->AddVariable( "RelE2x5Left", &RelE2x5Left ); |
248 |
> |
// readers[i]->AddVariable( "RelE2x5Right", &RelE2x5Right ); |
249 |
> |
// readers[i]->AddVariable( "RelE5x5", &RelE5x5 ); |
250 |
> |
// } |
251 |
> |
|
252 |
> |
// if(VariableType==2||VariableType==3||VariableType==4){ |
253 |
> |
// readers[i]->AddVariable( "EtaWidth", &EtaWidth ); |
254 |
> |
// readers[i]->AddVariable( "PhiWidth", &PhiWidth ); |
255 |
> |
// readers[i]->AddVariable( "CoviEtaiPhi", &CoviEtaiPhi ); |
256 |
> |
// readers[i]->AddVariable( "CoviPhiiPhi", &CoviPhiiPhi ); |
257 |
> |
// if(VariableType==4){ |
258 |
> |
// readers[i]->AddVariable( "NVertexes", &NVertexes ); |
259 |
> |
// } |
260 |
> |
// if(i==0){ |
261 |
> |
// readers[i]->AddVariable( "RelPreshowerEnergy", &RelPreshowerEnergy ); |
262 |
> |
// } |
263 |
> |
// } |
264 |
> |
|
265 |
> |
// if(VariableType==6){ |
266 |
> |
// readers[i]->AddVariable( "HoE", &HoE ); |
267 |
> |
// readers[i]->AddVariable( "covIEtaIEta", &covIEtaIEta ); |
268 |
> |
// readers[i]->AddVariable( "tIso1abs", &tIso1abs ); |
269 |
> |
// readers[i]->AddVariable( "tIso3abs", &tIso3abs ); |
270 |
> |
// readers[i]->AddVariable( "tIso2abs", &tIso2abs ); |
271 |
> |
// readers[i]->AddVariable( "R9", &R9 ); |
272 |
> |
// readers[i]->AddVariable( "absIsoEcal", &absIsoEcal ); |
273 |
> |
// readers[i]->AddVariable( "absIsoHcal", &absIsoHcal ); |
274 |
> |
// readers[i]->AddVariable( "RelE5x5", &RelE5x5 ); |
275 |
> |
// readers[i]->AddVariable( "EtaWidth", &EtaWidth ); |
276 |
> |
// readers[i]->AddVariable( "PhiWidth", &PhiWidth ); |
277 |
> |
// readers[i]->AddVariable( "CoviEtaiPhi", &CoviEtaiPhi ); |
278 |
> |
// readers[i]->AddVariable( "CoviPhiiPhi", &CoviPhiiPhi ); |
279 |
> |
// readers[i]->AddVariable( "NVertexes", &NVertexes ); |
280 |
> |
// if(i==0){ |
281 |
> |
// readers[i]->AddVariable( "RelPreshowerEnergy", &RelPreshowerEnergy ); |
282 |
> |
// } |
283 |
> |
// } |
284 |
> |
|
285 |
> |
// if(VariableType==7){ |
286 |
> |
// readers[i]->AddVariable( "HoE", &HoE ); |
287 |
> |
// readers[i]->AddVariable( "covIEtaIEta", &covIEtaIEta ); |
288 |
> |
// readers[i]->AddVariable( "tIso1abs", &tIso1abs ); |
289 |
> |
// readers[i]->AddVariable( "tIso3abs", &tIso3abs ); |
290 |
> |
// readers[i]->AddVariable( "tIso2abs", &tIso2abs ); |
291 |
> |
// readers[i]->AddVariable( "R9", &R9 ); |
292 |
> |
// readers[i]->AddVariable( "absIsoEcal", &absIsoEcal ); |
293 |
> |
// readers[i]->AddVariable( "absIsoHcal", &absIsoHcal ); |
294 |
> |
// readers[i]->AddVariable( "NVertexes", &NVertexes ); |
295 |
> |
// readers[i]->AddVariable( "ScEta", &ScEta ); |
296 |
> |
// } |
297 |
> |
|
298 |
> |
// if(VariableType==10){ |
299 |
> |
// readers[i]->AddVariable( "HoE", &HoE ); |
300 |
> |
// readers[i]->AddVariable( "covIEtaIEta", &covIEtaIEta ); |
301 |
> |
// readers[i]->AddVariable( "tIso1abs", &tIso1abs ); |
302 |
> |
// readers[i]->AddVariable( "tIso3abs", &tIso3abs ); |
303 |
> |
// readers[i]->AddVariable( "tIso2abs", &tIso2abs ); |
304 |
> |
// readers[i]->AddVariable( "R9", &R9 ); |
305 |
> |
// readers[i]->AddVariable( "absIsoEcal", &absIsoEcal ); |
306 |
> |
// readers[i]->AddVariable( "absIsoHcal", &absIsoHcal ); |
307 |
> |
// readers[i]->AddVariable( "NVertexes", &NVertexes ); |
308 |
> |
// readers[i]->AddVariable( "ScEta", &ScEta ); |
309 |
> |
// readers[i]->AddVariable( "EtaWidth", &EtaWidth ); |
310 |
> |
// readers[i]->AddVariable( "PhiWidth", &PhiWidth ); |
311 |
> |
// } |
312 |
> |
|
313 |
> |
// if(VariableType==1201){ |
314 |
> |
// /*readers[i]->AddVariable( "myphoton_pfchargedisogood03", &myphoton_pfchargedisogood03); |
315 |
> |
// readers[i]->AddVariable( "myphoton_pfchargedisobad03", &myphoton_pfchargedisobad03); |
316 |
> |
// readers[i]->AddVariable( "myphoton_pfphotoniso03", &myphoton_pfphotoniso03 ); |
317 |
> |
// readers[i]->AddVariable( "myphoton_sieie", &myphoton_sieie ); |
318 |
> |
// readers[i]->AddVariable( "myphoton_sieip", &myphoton_sieip ); |
319 |
> |
// readers[i]->AddVariable( "myphoton_etawidth", &myphoton_etawidth ); |
320 |
> |
// readers[i]->AddVariable( "myphoton_phiwidth", &myphoton_phiwidth ); |
321 |
> |
// readers[i]->AddVariable( "myphoton_r9", &myphoton_r9 ); |
322 |
> |
// readers[i]->AddVariable( "myphoton_s4ratio", &myphoton_s4ratio ); |
323 |
> |
// readers[i]->AddVariable( "myphoton_SCeta", &myphoton_SCeta ); |
324 |
> |
// readers[i]->AddVariable( "event_rho", &event_rho ); |
325 |
> |
// if(i==0){ |
326 |
> |
// readers[i]->AddVariable( "myphoton_ESEffSigmaRR", &myphoton_ESEffSigmaRR); |
327 |
> |
// }*/ |
328 |
> |
// readers[i]->AddVariable( "ph.r9", &myphoton_r9 ); |
329 |
> |
// readers[i]->AddVariable( "ph.sigietaieta", &myphoton_sieie ); |
330 |
> |
// readers[i]->AddVariable( "ph.scetawidth", &myphoton_etawidth ); |
331 |
> |
// readers[i]->AddVariable( "ph.scphiwidth", &myphoton_phiwidth ); |
332 |
> |
// readers[i]->AddVariable( "ph.idmva_CoviEtaiPhi", &myphoton_sieip ); |
333 |
> |
// readers[i]->AddVariable( "ph.idmva_s4ratio", &myphoton_s4ratio ); |
334 |
> |
// readers[i]->AddVariable( "ph.idmva_GammaIso", &myphoton_pfphotoniso03 ); |
335 |
> |
// readers[i]->AddVariable( "ph.idmva_ChargedIso_selvtx", &myphoton_pfchargedisogood03); |
336 |
> |
// readers[i]->AddVariable( "ph.idmva_ChargedIso_worstvtx", &myphoton_pfchargedisobad03); |
337 |
> |
// readers[i]->AddVariable( "ph.sceta", &myphoton_SCeta ); |
338 |
> |
// readers[i]->AddVariable( "rho", &event_rho ); |
339 |
> |
// if(i==0){ |
340 |
> |
// //readers[i]->AddVariable( "1.00023*ph.idmva_PsEffWidthSigmaRR + 0.0913", &myphoton_ESEffSigmaRR); |
341 |
> |
// readers[i]->AddVariable( "ph.idmva_PsEffWidthSigmaRR", &myphoton_ESEffSigmaRR); |
342 |
> |
// } |
343 |
> |
// } |
344 |
> |
|
345 |
> |
// } |
346 |
> |
|
347 |
> |
// fReaderEndcap->BookMVA("BDT method",EndcapWeights); |
348 |
> |
// fReaderBarrel->BookMVA("BDT method",BarrelWeights); |
349 |
> |
|
350 |
> |
// assert(fReaderEndcap); |
351 |
> |
// assert(fReaderBarrel); |
352 |
> |
|
353 |
> |
// } |
354 |
> |
|
355 |
> |
// *** REMOVED THIS COMPLETELY. If a module wants to cut on BDT, it should 1,) compute the BDT value (using GetMVAbdtValue(...) ) and then make the cut itself... |
356 |
|
|
357 |
< |
//--------------------------------------------------------------------------------- |
171 |
< |
Int_t MVATools::PassElectronVetoInt(const Photon* p, const ElectronCol* els) { |
357 |
> |
// Bool_t MVATools::PassMVASelection(const Photon* p,const Vertex* vtx,const TrackCol* trackCol,const VertexCol* vtxCol,Double_t _tRho,Float_t bdtCutBarrel, Float_t bdtCutEndcap, const ElectronCol* els, Bool_t applyElectronVeto) { |
358 |
|
|
359 |
< |
// these values are taken from the H2GGlobe code... (actually from Marco/s mail) |
360 |
< |
float cic4_allcuts_temp_sublead[] = { |
175 |
< |
3.8, 2.2, 1.77, 1.29, |
176 |
< |
11.7, 3.4, 3.9, 1.84, |
177 |
< |
3.5, 2.2, 2.3, 1.45, |
178 |
< |
0.0106, 0.0097, 0.028, 0.027, |
179 |
< |
0.082, 0.062, 0.065, 0.048, |
180 |
< |
0.94, 0.36, 0.94, 0.32, |
181 |
< |
1., 0.062, 0.97, 0.97, |
182 |
< |
1.5, 1.5, 1.5, 1.5 }; // the last line is PixelmatchVeto and un-used |
183 |
< |
|
184 |
< |
//initilize the bool value |
185 |
< |
PassElecVetoInt=0; |
186 |
< |
|
187 |
< |
dRTrack = PhotonTools::ElectronVetoCiC(p, els); |
188 |
< |
|
189 |
< |
ScEta_MVA=p->SCluster()->Eta(); |
190 |
< |
|
191 |
< |
isbarrel = (fabs(ScEta_MVA)<1.4442); |
192 |
< |
|
193 |
< |
R9 = p->R9(); |
194 |
< |
|
195 |
< |
// check which category it is ... |
196 |
< |
_tCat = 1; |
197 |
< |
if ( !isbarrel ) _tCat = 3; |
198 |
< |
if ( R9 < 0.94 ) _tCat++; |
199 |
< |
|
200 |
< |
//Electron Veto |
201 |
< |
if(dRTrack > cic4_allcuts_temp_sublead[_tCat-1+6*4]){ |
202 |
< |
PassElecVetoInt=1; |
203 |
< |
} |
359 |
> |
// //initilize the bool value |
360 |
> |
// PassMVA=kFALSE; |
361 |
|
|
362 |
< |
return PassElecVetoInt; |
362 |
> |
// Float_t photon_bdt = MVATools::GetMVAbdtValue_2011(p,vtx,trackCol,vtxCol, _tRho, els, applyElectronVeto); |
363 |
|
|
364 |
< |
} |
364 |
> |
// if (isbarrel) { |
365 |
> |
// if(photon_bdt>bdtCutBarrel){ |
366 |
> |
// PassMVA=kTRUE; |
367 |
> |
// } |
368 |
> |
// } |
369 |
> |
// else { |
370 |
> |
// if(photon_bdt>bdtCutEndcap){ |
371 |
> |
// PassMVA=kTRUE; |
372 |
> |
// } |
373 |
> |
// } |
374 |
> |
// return PassMVA; |
375 |
> |
// } |
376 |
|
|
377 |
< |
//-------------------------------------------------------------------------------------------------- |
377 |
> |
// //--------------------------------------------------------------------------------- |
378 |
> |
// Int_t MVATools::PassElectronVetoInt(const Photon* p, const ElectronCol* els) { |
379 |
> |
|
380 |
> |
// // these values are taken from the H2GGlobe code... (actually from Marco/s mail) |
381 |
> |
// float cic4_allcuts_temp_sublead[] = { |
382 |
> |
// 3.8, 2.2, 1.77, 1.29, |
383 |
> |
// 11.7, 3.4, 3.9, 1.84, |
384 |
> |
// 3.5, 2.2, 2.3, 1.45, |
385 |
> |
// 0.0106, 0.0097, 0.028, 0.027, |
386 |
> |
// 0.082, 0.062, 0.065, 0.048, |
387 |
> |
// 0.94, 0.36, 0.94, 0.32, |
388 |
> |
// 1., 0.062, 0.97, 0.97, |
389 |
> |
// 1.5, 1.5, 1.5, 1.5 }; // the last line is PixelmatchVeto and un-used |
390 |
> |
|
391 |
> |
// //initilize the bool value |
392 |
> |
// PassElecVetoInt=0; |
393 |
> |
|
394 |
> |
// dRTrack = PhotonTools::ElectronVetoCiC(p, els); |
395 |
> |
|
396 |
> |
// ScEta_MVA=p->SCluster()->Eta(); |
397 |
> |
|
398 |
> |
// isbarrel = (fabs(ScEta_MVA)<1.4442); |
399 |
|
|
400 |
< |
Float_t MVATools::GetMVAbdtValue(const Photon* p,const Vertex* vtx,const TrackCol* trackCol,const VertexCol* vtxCol,Double_t _tRho,const ElectronCol* els) { |
400 |
> |
// R9 = p->R9(); |
401 |
> |
// //R9 = p->E33()/p->SCluster()->RawEnergy(); |
402 |
|
|
403 |
< |
//get the variables used to compute MVA variables |
404 |
< |
ecalIso3 = p->EcalRecHitIsoDr03(); |
405 |
< |
ecalIso4 = p->EcalRecHitIsoDr04(); |
406 |
< |
hcalIso4 = p->HcalTowerSumEtDr04(); |
217 |
< |
|
218 |
< |
wVtxInd = 0; |
219 |
< |
|
220 |
< |
trackIso1 = IsolationTools::CiCTrackIsolation(p,vtx, 0.3, 0.02, 0.0, 0.0, 0.1, 1.0, trackCol);//Question Ming:whyfPV->At(0) instead of selected vertex using ranking method? |
221 |
< |
|
222 |
< |
// track iso only |
223 |
< |
trackIso3 = IsolationTools::CiCTrackIsolation(p,vtx, 0.3, 0.02, 0.0, 0.0, 0.1, 1.0, trackCol); |
224 |
< |
|
225 |
< |
// track iso worst vtx |
226 |
< |
trackIso2 = IsolationTools::CiCTrackIsolation(p,vtx, 0.4, 0.02, 0.0, 0.0, 0.1, 1.0, trackCol, &wVtxInd,vtxCol); |
227 |
< |
|
228 |
< |
combIso1 = ecalIso3+hcalIso4+trackIso1 - 0.17*_tRho; |
229 |
< |
combIso2 = ecalIso4+hcalIso4+trackIso2 - 0.52*_tRho; |
230 |
< |
|
231 |
< |
RawEnergy = p->SCluster()->RawEnergy(); |
232 |
< |
|
233 |
< |
dRTrack = PhotonTools::ElectronVetoCiC(p, els); |
234 |
< |
|
235 |
< |
//mva varialbes v1 and v2 |
236 |
< |
tIso1 = (combIso1) *50./p->Et(); |
237 |
< |
tIso3 = (trackIso3)*50./p->Et(); |
238 |
< |
tIso2 = (combIso2) *50./(p->MomVtx(vtxCol->At(wVtxInd)->Position()).Pt()); |
239 |
< |
RelIsoEcal=(ecalIso3-0.17*_tRho)/p->Et(); |
240 |
< |
RelIsoHcal=(hcalIso4-0.17*_tRho)/p->Et(); |
241 |
< |
|
242 |
< |
//compute mva variables for v3 |
243 |
< |
HoE = p->HadOverEm(); |
244 |
< |
covIEtaIEta = p->CoviEtaiEta(); |
245 |
< |
tIso1abs = combIso1; |
246 |
< |
tIso3abs = trackIso3; |
247 |
< |
tIso2abs = combIso2; |
248 |
< |
R9 = p->R9(); |
249 |
< |
|
250 |
< |
absIsoEcal=(ecalIso3-0.17*_tRho); |
251 |
< |
absIsoHcal=(hcalIso4-0.17*_tRho); |
252 |
< |
RelEMax=p->SCluster()->Seed()->EMax()/RawEnergy; |
253 |
< |
RelETop=p->SCluster()->Seed()->ETop()/RawEnergy; |
254 |
< |
RelEBottom=p->SCluster()->Seed()->EBottom()/RawEnergy; |
255 |
< |
RelELeft=p->SCluster()->Seed()->ELeft()/RawEnergy; |
256 |
< |
RelERight=p->SCluster()->Seed()->ERight()/RawEnergy; |
257 |
< |
RelE2x5Max=p->SCluster()->Seed()->E2x5Max()/RawEnergy; |
258 |
< |
RelE2x5Top=p->SCluster()->Seed()->E2x5Top()/RawEnergy; |
259 |
< |
RelE2x5Bottom=p->SCluster()->Seed()->E2x5Bottom()/RawEnergy; |
260 |
< |
RelE2x5Left=p->SCluster()->Seed()->E2x5Left()/RawEnergy; |
261 |
< |
RelE2x5Right=p->SCluster()->Seed()->E2x5Right()/RawEnergy; |
262 |
< |
RelE5x5=p->SCluster()->Seed()->E5x5()/RawEnergy; |
263 |
< |
|
264 |
< |
EtaWidth=p->SCluster()->EtaWidth(); |
265 |
< |
PhiWidth=p->SCluster()->PhiWidth(); |
266 |
< |
CoviEtaiPhi=p->SCluster()->Seed()->CoviEtaiPhi(); |
267 |
< |
CoviPhiiPhi=p->SCluster()->Seed()->CoviPhiiPhi(); |
268 |
< |
|
269 |
< |
RelPreshowerEnergy=p->SCluster()->PreshowerEnergy()/RawEnergy; |
270 |
< |
NVertexes=vtxCol->GetEntries(); |
271 |
< |
|
272 |
< |
//spectator variables |
273 |
< |
Pt_MVA=p->Pt(); |
274 |
< |
ScEta_MVA=p->SCluster()->Eta(); |
403 |
> |
// // check which category it is ... |
404 |
> |
// _tCat = 1; |
405 |
> |
// if ( !isbarrel ) _tCat = 3; |
406 |
> |
// if ( R9 < 0.94 ) _tCat++; |
407 |
|
|
408 |
< |
isbarrel = (fabs(ScEta_MVA)<1.4442); |
408 |
> |
// //Electron Veto |
409 |
> |
// if(dRTrack > cic4_allcuts_temp_sublead[_tCat-1+6*4]){ |
410 |
> |
// PassElecVetoInt=1; |
411 |
> |
// } |
412 |
|
|
413 |
< |
if (isbarrel) { |
279 |
< |
reader = fReaderBarrel; |
280 |
< |
} |
281 |
< |
else { |
282 |
< |
reader = fReaderEndcap; |
283 |
< |
} |
413 |
> |
// return PassElecVetoInt; |
414 |
|
|
415 |
< |
assert(reader); |
415 |
> |
// } |
416 |
> |
|
417 |
> |
//-------------------------------------------------------------------------------------------------- |
418 |
|
|
287 |
– |
bdt = reader->EvaluateMVA("BDT method"); |
419 |
|
|
420 |
< |
printf("HoE: %f\n",HoE); |
421 |
< |
printf("covIEtaIEta: %f\n",covIEtaIEta); |
422 |
< |
printf("tIso1abs: %f\n",tIso1abs); |
423 |
< |
printf("tIso3abs: %f\n",tIso3abs); |
424 |
< |
printf("tIso2abs: %f\n",tIso2abs); |
425 |
< |
|
295 |
< |
printf("absIsoEcal: %f\n",absIsoEcal); |
296 |
< |
printf("absIsoHcal: %f\n",absIsoHcal); |
297 |
< |
printf("RelEMax: %f\n",RelEMax); |
298 |
< |
printf("RelETop: %f\n",RelETop); |
299 |
< |
printf("RelEBottom: %f\n",RelEBottom); |
300 |
< |
printf("RelELeft: %f\n",RelELeft); |
301 |
< |
printf("RelERight: %f\n",RelERight); |
302 |
< |
printf("RelE2x5Max: %f\n",RelE2x5Max); |
303 |
< |
printf("RelE2x5Top: %f\n",RelE2x5Top); |
304 |
< |
printf("RelE2x5Bottom: %f\n",RelE2x5Bottom); |
305 |
< |
printf("RelE2x5Left: %f\n",RelE2x5Left); |
306 |
< |
printf("RelE2x5Right;: %f\n",RelE2x5Right); |
307 |
< |
printf("RelE5x5: %f\n",RelE5x5); |
308 |
< |
|
309 |
< |
printf("EtaWidth: %f\n",EtaWidth); |
310 |
< |
printf("PhiWidth: %f\n",PhiWidth); |
311 |
< |
printf("CoviEtaiPhi: %f\n",CoviEtaiPhi); |
312 |
< |
printf("CoviPhiiPhi: %f\n",CoviPhiiPhi); |
420 |
> |
Double_t MVATools::GetMVAbdtValue(const Photon* p, const Vertex* vtx, const TrackCol* trackCol, const VertexCol* vtxCol, Double_t _tRho, const PFCandidateCol *fPFCands, const ElectronCol* els, Bool_t applyElectronVeto) { |
421 |
> |
|
422 |
> |
// if there's no reader, or the type is kNone, return the default values of -99. |
423 |
> |
if( ( !fReaderBarrel || !fReaderEndcap ) || fMVAType == kNone ) return -99.; |
424 |
> |
|
425 |
> |
// we compute the variable names... make sure no confilcts when adding new variables... |
426 |
|
|
427 |
< |
if (!isbarrel) { |
428 |
< |
printf("RelPreshowerEnergy: %f\n",RelPreshowerEnergy); |
427 |
> |
// check if it's a Barrel or EE photon |
428 |
> |
bool isBarrel = ( p->SCluster()->AbsEta() < 1.5 ); |
429 |
> |
|
430 |
> |
std::map<std::string,float*>* theVars = ( isBarrel ? &mvaVarMapEB : &mvaVarMapEB ); |
431 |
> |
|
432 |
> |
// loop over all the variables in the map... and keep count (to make sure we have filled all variables) |
433 |
> |
unsigned int varCounter = 0; |
434 |
> |
for( std::map<std::string,float*>::const_iterator iV = theVars->begin(); iV != theVars->end(); ++iV ) { |
435 |
> |
|
436 |
> |
TString theVarName = TString(iV->first); |
437 |
> |
float* theVarValue = iV->second; // pointer to the variable... |
438 |
> |
|
439 |
> |
if( |
440 |
> |
!theVarName.CompareTo("HoE") |
441 |
> |
) { |
442 |
> |
(*theVarValue) = p->HadOverEm(); |
443 |
> |
varCounter++; |
444 |
> |
} else if ( |
445 |
> |
!theVarName.CompareTo("covIEtaIEta") || !theVarName.CompareTo("ph.sigietaieta") |
446 |
> |
) { |
447 |
> |
(*theVarValue) = p->CoviEtaiEta(); |
448 |
> |
varCounter++; |
449 |
> |
} else if ( |
450 |
> |
!theVarName.CompareTo("R9") || !theVarName.CompareTo("ph.r9") |
451 |
> |
) { |
452 |
> |
(*theVarValue) = p->R9(); |
453 |
> |
varCounter++; |
454 |
> |
} else if ( |
455 |
> |
!theVarName.CompareTo("ScEta") || !theVarName.CompareTo("ph.sceta") |
456 |
> |
) { |
457 |
> |
(*theVarValue) = p->SCluster()->Eta(); |
458 |
> |
varCounter++; |
459 |
> |
} else if ( |
460 |
> |
!theVarName.CompareTo("rho") |
461 |
> |
) { |
462 |
> |
(*theVarValue) = _tRho; |
463 |
> |
varCounter++; |
464 |
> |
} else if ( |
465 |
> |
!theVarName.CompareTo("tIso1abs") |
466 |
> |
) { |
467 |
> |
double _ecalIso3 = p->EcalRecHitIsoDr03(); |
468 |
> |
double _hcalIso4 = p->HcalTowerSumEtDr04(); |
469 |
> |
double _trackIso1 = IsolationTools::CiCTrackIsolation(p,vtx, 0.3, 0.02, 0.0, 0.0, 0.1, 1.0, trackCol, NULL, NULL, (!applyElectronVeto ? els : NULL) );//Question Ming:whyfPV->At(0) instead of selected vertex using ranking method? |
470 |
> |
(*theVarValue) = _ecalIso3+_hcalIso4+_trackIso1 - 0.17*_tRho; |
471 |
> |
varCounter++; |
472 |
> |
} else if ( |
473 |
> |
!theVarName.CompareTo("tIso2abs") |
474 |
> |
) { |
475 |
> |
double _ecalIso4 = p->EcalRecHitIsoDr04(); |
476 |
> |
double _hcalIso4 = p->HcalTowerSumEtDr04(); |
477 |
> |
unsigned int wVtxInd = 0; |
478 |
> |
double _trackIso2 = IsolationTools::CiCTrackIsolation(p,vtx, 0.4, 0.02, 0.0, 0.0, 0.1, 1.0, trackCol, &wVtxInd,vtxCol, (!applyElectronVeto ? els : NULL) ); |
479 |
> |
(*theVarValue) = _ecalIso4+_hcalIso4+_trackIso2 - 0.52*_tRho; |
480 |
> |
varCounter++; |
481 |
> |
} else if ( |
482 |
> |
!theVarName.CompareTo("tIso3abs") |
483 |
> |
) { |
484 |
> |
(*theVarValue) = IsolationTools::CiCTrackIsolation(p,vtx, 0.3, 0.02, 0.0, 0.0, 0.1, 1.0, trackCol, NULL, NULL, (!applyElectronVeto ? els : NULL) ); |
485 |
> |
varCounter++; |
486 |
> |
} else if ( |
487 |
> |
!theVarName.CompareTo("absIsoEcal") |
488 |
> |
) { |
489 |
> |
double _ecalIso3 = p->EcalRecHitIsoDr03(); |
490 |
> |
(*theVarValue) = (_ecalIso3-0.17*_tRho); |
491 |
> |
varCounter++; |
492 |
> |
} else if ( |
493 |
> |
!theVarName.CompareTo("absIsoHcal") |
494 |
> |
) { |
495 |
> |
double _hcalIso4 = p->HcalTowerSumEtDr04(); |
496 |
> |
(*theVarValue) = (_hcalIso4-0.17*_tRho); |
497 |
> |
varCounter++; |
498 |
> |
} else if ( |
499 |
> |
!theVarName.CompareTo("NVertexes") |
500 |
> |
) { |
501 |
> |
|
502 |
> |
(*theVarValue) = vtxCol->GetEntries(); |
503 |
> |
varCounter++; |
504 |
> |
} else if ( |
505 |
> |
!theVarName.CompareTo("EtaWidth") || !!theVarName.CompareTo("ph.scetawidth") |
506 |
> |
) { |
507 |
> |
(*theVarValue) = p->EtaWidth(); |
508 |
> |
varCounter++; |
509 |
> |
} else if ( |
510 |
> |
!theVarName.CompareTo("PhiWidth") || !!theVarName.CompareTo("ph.scphiwidth") |
511 |
> |
) { |
512 |
> |
(*theVarValue) = p->PhiWidth(); |
513 |
> |
varCounter++; |
514 |
> |
|
515 |
> |
} else if ( |
516 |
> |
!theVarName.CompareTo("ph.idmva_CoviEtaiPhi") |
517 |
> |
) { |
518 |
> |
(*theVarValue) = p->SCluster()->Seed()->CoviEtaiPhi(); |
519 |
> |
varCounter++; |
520 |
> |
} else if ( |
521 |
> |
!theVarName.CompareTo("ph.idmva_s4ratio") |
522 |
> |
) { |
523 |
> |
(*theVarValue) = p->S4Ratio(); |
524 |
> |
varCounter++; |
525 |
> |
} else if ( |
526 |
> |
!theVarName.CompareTo("ph.idmva_GammaIso") |
527 |
> |
) { |
528 |
> |
(*theVarValue) = IsolationTools::PFGammaIsolation(p,0.3,0,fPFCands); |
529 |
> |
varCounter++; |
530 |
> |
} else if ( |
531 |
> |
!theVarName.CompareTo("ph.idmva_ChargedIso_selvtx") |
532 |
> |
) { |
533 |
> |
(*theVarValue) = IsolationTools::PFChargedIsolation(p,vtx,0.3,0,fPFCands); |
534 |
> |
varCounter++; |
535 |
> |
} else if ( |
536 |
> |
!theVarName.CompareTo("ph.idmva_ChargedIso_worstvtx") |
537 |
> |
) { |
538 |
> |
unsigned int wVtxInd = 0; |
539 |
> |
(*theVarValue) = IsolationTools::PFChargedIsolation(p,vtx,0.3,0,fPFCands,&wVtxInd,vtxCol); |
540 |
> |
varCounter++; |
541 |
> |
} else if ( |
542 |
> |
!theVarName.CompareTo("ph.idmva_PsEffWidthSigmaRR") |
543 |
> |
) { |
544 |
> |
(*theVarValue) = p->EffSigmaRR(); |
545 |
> |
varCounter++; |
546 |
> |
} else { |
547 |
> |
// a variable is not know... copmplain! |
548 |
> |
std::cerr<<" ERROR: MVA Evaluation called with unknown variable name >"<<theVarName<<">."<<std::endl; |
549 |
> |
} |
550 |
|
} |
551 |
|
|
552 |
< |
return bdt; |
552 |
> |
// now all the variables should be filled... check! |
553 |
> |
if( varCounter != theVars->size() ) |
554 |
> |
std::cerr<<" ERROR: MVA Evaludation called and not all variables are filled."<<std::endl; |
555 |
> |
|
556 |
> |
// we're ready to compute the MVA value |
557 |
> |
TMVA::Reader* reader = NULL; |
558 |
> |
if (isBarrel) |
559 |
> |
reader = fReaderBarrel; |
560 |
> |
else |
561 |
> |
reader = fReaderEndcap; |
562 |
> |
|
563 |
> |
assert(reader); |
564 |
> |
|
565 |
> |
return (reader->EvaluateMVA("BDT method")); |
566 |
|
} |
567 |
+ |
|
568 |
+ |
// Float_t MVATools::GetMVAbdtValue_2012_globe(const Photon* p,const Vertex* vtx,const TrackCol* trackCol,const VertexCol* vtxCol,Double_t _tRho, const PFCandidateCol *fPFCands,const ElectronCol* els,Bool_t applyElectronVeto) { |
569 |
+ |
|
570 |
+ |
// //get the variables used to compute MVA variables |
571 |
+ |
// ecalIso3 = p->EcalRecHitIsoDr03(); |
572 |
+ |
// ecalIso4 = p->EcalRecHitIsoDr04(); |
573 |
+ |
// hcalIso4 = p->HcalTowerSumEtDr04(); |
574 |
+ |
|
575 |
+ |
// wVtxInd = 0; |
576 |
+ |
|
577 |
+ |
// trackIso1 = IsolationTools::CiCTrackIsolation(p,vtx, 0.3, 0.02, 0.0, 0.0, 0.1, 1.0, trackCol, NULL, NULL, (!applyElectronVeto ? els : NULL) );//Question Ming:whyfPV->At(0) instead of selected vertex using ranking method? |
578 |
+ |
|
579 |
+ |
// // track iso worst vtx |
580 |
+ |
// trackIso2 = IsolationTools::CiCTrackIsolation(p,vtx, 0.4, 0.02, 0.0, 0.0, 0.1, 1.0, trackCol, &wVtxInd,vtxCol, (!applyElectronVeto ? els : NULL) ); |
581 |
+ |
|
582 |
+ |
// combIso1 = ecalIso3+hcalIso4+trackIso1 - 0.17*_tRho; |
583 |
+ |
// combIso2 = ecalIso4+hcalIso4+trackIso2 - 0.52*_tRho; |
584 |
+ |
|
585 |
+ |
// RawEnergy = p->SCluster()->RawEnergy(); |
586 |
+ |
|
587 |
+ |
// ScEta = p->SCluster()->Eta(); |
588 |
+ |
|
589 |
+ |
// //mva varialbes v1 and v2 |
590 |
+ |
// tIso1 = (combIso1) *50./p->Et(); |
591 |
+ |
// tIso3 = (trackIso1)*50./p->Et(); |
592 |
+ |
// tIso2 = (combIso2) *50./(p->MomVtx(vtxCol->At(wVtxInd)->Position()).Pt()); |
593 |
+ |
// RelIsoEcal=(ecalIso3-0.17*_tRho)/p->Et(); |
594 |
+ |
// RelIsoHcal=(hcalIso4-0.17*_tRho)/p->Et(); |
595 |
+ |
|
596 |
+ |
// //compute mva variables for v3 |
597 |
+ |
// HoE = p->HadOverEm(); |
598 |
+ |
// covIEtaIEta = p->CoviEtaiEta(); |
599 |
+ |
// tIso1abs = combIso1; |
600 |
+ |
// tIso3abs = trackIso1; |
601 |
+ |
// tIso2abs = combIso2; |
602 |
+ |
// R9 = p->R9(); |
603 |
+ |
|
604 |
+ |
// absIsoEcal=(ecalIso3-0.17*_tRho); |
605 |
+ |
// absIsoHcal=(hcalIso4-0.17*_tRho); |
606 |
+ |
// RelEMax=p->SCluster()->Seed()->EMax()/RawEnergy; |
607 |
+ |
// RelETop=p->SCluster()->Seed()->ETop()/RawEnergy; |
608 |
+ |
// RelEBottom=p->SCluster()->Seed()->EBottom()/RawEnergy; |
609 |
+ |
// RelELeft=p->SCluster()->Seed()->ELeft()/RawEnergy; |
610 |
+ |
// RelERight=p->SCluster()->Seed()->ERight()/RawEnergy; |
611 |
+ |
// RelE2x5Max=p->SCluster()->Seed()->E2x5Max()/RawEnergy; |
612 |
+ |
// RelE2x5Top=p->SCluster()->Seed()->E2x5Top()/RawEnergy; |
613 |
+ |
// RelE2x5Bottom=p->SCluster()->Seed()->E2x5Bottom()/RawEnergy; |
614 |
+ |
// RelE2x5Left=p->SCluster()->Seed()->E2x5Left()/RawEnergy; |
615 |
+ |
// RelE2x5Right=p->SCluster()->Seed()->E2x5Right()/RawEnergy; |
616 |
+ |
// RelE5x5=p->SCluster()->Seed()->E5x5()/RawEnergy; |
617 |
+ |
|
618 |
+ |
// EtaWidth=p->EtaWidth(); |
619 |
+ |
// PhiWidth=p->PhiWidth(); |
620 |
+ |
// CoviEtaiPhi=p->SCluster()->Seed()->CoviEtaiPhi(); |
621 |
+ |
// CoviPhiiPhi=p->SCluster()->Seed()->CoviPhiiPhi(); |
622 |
+ |
|
623 |
+ |
// RelPreshowerEnergy=p->SCluster()->PreshowerEnergy()/RawEnergy; |
624 |
+ |
// NVertexes=vtxCol->GetEntries(); |
625 |
+ |
|
626 |
+ |
// //spectator variables |
627 |
+ |
// Pt_MVA=p->Pt(); |
628 |
+ |
// ScEta_MVA=p->SCluster()->Eta(); |
629 |
+ |
|
630 |
+ |
// // |
631 |
+ |
|
632 |
+ |
// isbarrel = (fabs(ScEta_MVA)<1.4442); |
633 |
+ |
|
634 |
+ |
// //variable 1201 |
635 |
+ |
// myphoton_pfchargedisogood03=IsolationTools::PFChargedIsolation(p,vtx,0.3,0,fPFCands); |
636 |
+ |
// myphoton_pfchargedisobad03=IsolationTools::PFChargedIsolation(p,vtx,0.3,0,fPFCands,&wVtxInd,vtxCol); |
637 |
+ |
// myphoton_pfphotoniso03=IsolationTools::PFGammaIsolation(p,0.3,0,fPFCands); |
638 |
+ |
// myphoton_sieie=covIEtaIEta; |
639 |
+ |
// myphoton_sieip=CoviEtaiPhi; |
640 |
+ |
// myphoton_etawidth=EtaWidth; |
641 |
+ |
// myphoton_phiwidth=PhiWidth; |
642 |
+ |
// myphoton_r9=R9; |
643 |
+ |
// myphoton_s4ratio=p->S4Ratio(); |
644 |
+ |
// myphoton_SCeta=ScEta_MVA; |
645 |
+ |
// event_rho= _tRho; |
646 |
+ |
|
647 |
+ |
// myphoton_ESEffSigmaRR=-99; |
648 |
+ |
|
649 |
+ |
// if(!isbarrel){ |
650 |
+ |
// myphoton_ESEffSigmaRR=p->EffSigmaRR(); |
651 |
+ |
// } |
652 |
+ |
|
653 |
+ |
// if (isbarrel) { |
654 |
+ |
// reader = fReaderBarrel; |
655 |
+ |
// } |
656 |
+ |
// else { |
657 |
+ |
// reader = fReaderEndcap; |
658 |
+ |
// } |
659 |
+ |
|
660 |
+ |
// assert(reader); |
661 |
+ |
|
662 |
+ |
// double bdt = reader->EvaluateMVA("BDT method"); |
663 |
+ |
|
664 |
+ |
// /* printf("HoE: %f\n",HoE); |
665 |
+ |
// printf("covIEtaIEta: %f\n",covIEtaIEta); |
666 |
+ |
// printf("tIso1abs: %f\n",tIso1abs); |
667 |
+ |
// printf("tIso3abs: %f\n",tIso3abs); |
668 |
+ |
// printf("tIso2abs: %f\n",tIso2abs); |
669 |
+ |
|
670 |
+ |
// printf("absIsoEcal: %f\n",absIsoEcal); |
671 |
+ |
// printf("absIsoHcal: %f\n",absIsoHcal); |
672 |
+ |
// printf("RelEMax: %f\n",RelEMax); |
673 |
+ |
// printf("RelETop: %f\n",RelETop); |
674 |
+ |
// printf("RelEBottom: %f\n",RelEBottom); |
675 |
+ |
// printf("RelELeft: %f\n",RelELeft); |
676 |
+ |
// printf("RelERight: %f\n",RelERight); |
677 |
+ |
// printf("RelE2x5Max: %f\n",RelE2x5Max); |
678 |
+ |
// printf("RelE2x5Top: %f\n",RelE2x5Top); |
679 |
+ |
// printf("RelE2x5Bottom: %f\n",RelE2x5Bottom); |
680 |
+ |
// printf("RelE2x5Left: %f\n",RelE2x5Left); |
681 |
+ |
// printf("RelE2x5Right;: %f\n",RelE2x5Right); |
682 |
+ |
// printf("RelE5x5: %f\n",RelE5x5); |
683 |
+ |
|
684 |
+ |
// printf("EtaWidth: %f\n",EtaWidth); |
685 |
+ |
// printf("PhiWidth: %f\n",PhiWidth); |
686 |
+ |
// printf("CoviEtaiPhi: %f\n",CoviEtaiPhi); |
687 |
+ |
// printf("CoviPhiiPhi: %f\n",CoviPhiiPhi); |
688 |
+ |
|
689 |
+ |
// if (!isbarrel) { |
690 |
+ |
// printf("RelPreshowerEnergy: %f\n",RelPreshowerEnergy); |
691 |
+ |
// }*/ |
692 |
+ |
|
693 |
+ |
// return bdt; |
694 |
+ |
// } |
695 |
+ |
|
696 |
+ |
// Float_t MVATools::GetMVAbdtValue_2011(const Photon* p,const Vertex* vtx,const TrackCol* trackCol,const VertexCol* vtxCol,Double_t _tRho,const ElectronCol* els,Bool_t applyElectronVeto) { |
697 |
+ |
|
698 |
+ |
// //get the variables used to compute MVA variables |
699 |
+ |
// ecalIso3 = p->EcalRecHitIsoDr03(); |
700 |
+ |
// ecalIso4 = p->EcalRecHitIsoDr04(); |
701 |
+ |
// hcalIso4 = p->HcalTowerSumEtDr04(); |
702 |
+ |
|
703 |
+ |
// wVtxInd = 0; |
704 |
+ |
|
705 |
+ |
// trackIso1 = IsolationTools::CiCTrackIsolation(p,vtx, 0.3, 0.02, 0.0, 0.0, 0.1, 1.0, trackCol, NULL, NULL, (!applyElectronVeto ? els : NULL) );//Question Ming:whyfPV->At(0) instead of selected vertex using ranking method? |
706 |
+ |
|
707 |
+ |
// // track iso worst vtx |
708 |
+ |
// trackIso2 = IsolationTools::CiCTrackIsolation(p,vtx, 0.4, 0.02, 0.0, 0.0, 0.1, 1.0, trackCol, &wVtxInd,vtxCol, (!applyElectronVeto ? els : NULL) ); |
709 |
+ |
|
710 |
+ |
// combIso1 = ecalIso3+hcalIso4+trackIso1 - 0.17*_tRho; |
711 |
+ |
// combIso2 = ecalIso4+hcalIso4+trackIso2 - 0.52*_tRho; |
712 |
+ |
|
713 |
+ |
// RawEnergy = p->SCluster()->RawEnergy(); |
714 |
+ |
|
715 |
+ |
// ScEta = p->SCluster()->Eta(); |
716 |
+ |
|
717 |
+ |
// //mva varialbes v1 and v2 |
718 |
+ |
// tIso1 = (combIso1) *50./p->Et(); |
719 |
+ |
// tIso3 = (trackIso1)*50./p->Et(); |
720 |
+ |
// tIso2 = (combIso2) *50./(p->MomVtx(vtxCol->At(wVtxInd)->Position()).Pt()); |
721 |
+ |
// RelIsoEcal=(ecalIso3-0.17*_tRho)/p->Et(); |
722 |
+ |
// RelIsoHcal=(hcalIso4-0.17*_tRho)/p->Et(); |
723 |
+ |
|
724 |
+ |
// //compute mva variables for v3 |
725 |
+ |
// HoE = p->HadOverEm(); |
726 |
+ |
// covIEtaIEta = p->CoviEtaiEta(); |
727 |
+ |
// tIso1abs = combIso1; |
728 |
+ |
// tIso3abs = trackIso1; |
729 |
+ |
// tIso2abs = combIso2; |
730 |
+ |
// R9 = p->R9(); |
731 |
+ |
|
732 |
+ |
// absIsoEcal=(ecalIso3-0.17*_tRho); |
733 |
+ |
// absIsoHcal=(hcalIso4-0.17*_tRho); |
734 |
+ |
// RelEMax=p->SCluster()->Seed()->EMax()/RawEnergy; |
735 |
+ |
// RelETop=p->SCluster()->Seed()->ETop()/RawEnergy; |
736 |
+ |
// RelEBottom=p->SCluster()->Seed()->EBottom()/RawEnergy; |
737 |
+ |
// RelELeft=p->SCluster()->Seed()->ELeft()/RawEnergy; |
738 |
+ |
// RelERight=p->SCluster()->Seed()->ERight()/RawEnergy; |
739 |
+ |
// RelE2x5Max=p->SCluster()->Seed()->E2x5Max()/RawEnergy; |
740 |
+ |
// RelE2x5Top=p->SCluster()->Seed()->E2x5Top()/RawEnergy; |
741 |
+ |
// RelE2x5Bottom=p->SCluster()->Seed()->E2x5Bottom()/RawEnergy; |
742 |
+ |
// RelE2x5Left=p->SCluster()->Seed()->E2x5Left()/RawEnergy; |
743 |
+ |
// RelE2x5Right=p->SCluster()->Seed()->E2x5Right()/RawEnergy; |
744 |
+ |
// RelE5x5=p->SCluster()->Seed()->E5x5()/RawEnergy; |
745 |
+ |
|
746 |
+ |
// EtaWidth=p->EtaWidth(); |
747 |
+ |
// PhiWidth=p->PhiWidth(); |
748 |
+ |
// CoviEtaiPhi=p->SCluster()->Seed()->CoviEtaiPhi(); |
749 |
+ |
// CoviPhiiPhi=p->SCluster()->Seed()->CoviPhiiPhi(); |
750 |
+ |
|
751 |
+ |
// RelPreshowerEnergy=p->SCluster()->PreshowerEnergy()/RawEnergy; |
752 |
+ |
// NVertexes=vtxCol->GetEntries(); |
753 |
+ |
|
754 |
+ |
// //spectator variables |
755 |
+ |
// Pt_MVA=p->Pt(); |
756 |
+ |
// ScEta_MVA=p->SCluster()->Eta(); |
757 |
+ |
|
758 |
+ |
// // |
759 |
+ |
|
760 |
+ |
// isbarrel = (fabs(ScEta_MVA)<1.4442); |
761 |
+ |
|
762 |
+ |
// if (isbarrel) { |
763 |
+ |
// reader = fReaderBarrel; |
764 |
+ |
// } |
765 |
+ |
// else { |
766 |
+ |
// reader = fReaderEndcap; |
767 |
+ |
// } |
768 |
+ |
|
769 |
+ |
// assert(reader); |
770 |
+ |
|
771 |
+ |
// double bdt = reader->EvaluateMVA("BDT method"); |
772 |
+ |
|
773 |
+ |
// /* printf("HoE: %f\n",HoE); |
774 |
+ |
// printf("covIEtaIEta: %f\n",covIEtaIEta); |
775 |
+ |
// printf("tIso1abs: %f\n",tIso1abs); |
776 |
+ |
// printf("tIso3abs: %f\n",tIso3abs); |
777 |
+ |
// printf("tIso2abs: %f\n",tIso2abs); |
778 |
+ |
|
779 |
+ |
// printf("absIsoEcal: %f\n",absIsoEcal); |
780 |
+ |
// printf("absIsoHcal: %f\n",absIsoHcal); |
781 |
+ |
// printf("RelEMax: %f\n",RelEMax); |
782 |
+ |
// printf("RelETop: %f\n",RelETop); |
783 |
+ |
// printf("RelEBottom: %f\n",RelEBottom); |
784 |
+ |
// printf("RelELeft: %f\n",RelELeft); |
785 |
+ |
// printf("RelERight: %f\n",RelERight); |
786 |
+ |
// printf("RelE2x5Max: %f\n",RelE2x5Max); |
787 |
+ |
// printf("RelE2x5Top: %f\n",RelE2x5Top); |
788 |
+ |
// printf("RelE2x5Bottom: %f\n",RelE2x5Bottom); |
789 |
+ |
// printf("RelE2x5Left: %f\n",RelE2x5Left); |
790 |
+ |
// printf("RelE2x5Right;: %f\n",RelE2x5Right); |
791 |
+ |
// printf("RelE5x5: %f\n",RelE5x5); |
792 |
+ |
|
793 |
+ |
// printf("EtaWidth: %f\n",EtaWidth); |
794 |
+ |
// printf("PhiWidth: %f\n",PhiWidth); |
795 |
+ |
// printf("CoviEtaiPhi: %f\n",CoviEtaiPhi); |
796 |
+ |
// printf("CoviPhiiPhi: %f\n",CoviPhiiPhi); |
797 |
+ |
|
798 |
+ |
// if (!isbarrel) { |
799 |
+ |
// printf("RelPreshowerEnergy: %f\n",RelPreshowerEnergy); |
800 |
+ |
// }*/ |
801 |
+ |
|
802 |
+ |
// return bdt; |
803 |
+ |
// } |