ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Utils/src/MVATools.cc
(Generate patch)

Comparing UserCode/MitPhysics/Utils/src/MVATools.cc (file contents):
Revision 1.6 by mingyang, Wed Dec 7 00:45:17 2011 UTC vs.
Revision 1.21 by mingyang, Tue Jul 30 21:08:50 2013 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines