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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines