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.1 by mingyang, Thu Oct 13 17:28:29 2011 UTC vs.
Revision 1.16 by mingyang, Wed Jun 13 10:51:10 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 "TMVA/Tools.h"//MVA
13   #include "TMVA/Reader.h"//MVA
14  
15 +
16   ClassImp(mithep::MVATools)
17  
18   using namespace mithep;
# Line 20 | Line 23 | MVATools::MVATools():
23    fReaderEndcap(0),
24    fReaderBarrel(0),
25    
26 <  //MVA variables 0
26 >  //MVA Variables v4
27    HoE(0),
28    covIEtaIEta(0),
29 <  tIso1(0),
30 <  tIso3(0),
31 <  tIso2(0),
29 >  tIso1abs(0),
30 >  tIso3abs(0),
31 >  tIso2abs(0),
32    R9(0),
33    
34 <  //MVA variables 1
35 <  RelIsoEcal(0),
33 <  RelIsoHcal(0),
34 <  
34 >  absIsoEcal(0),
35 >  absIsoHcal(0),
36    RelEMax(0),
37    RelETop(0),
38    RelEBottom(0),
# Line 44 | Line 45 | MVATools::MVATools():
45    RelE2x5Right(0),
46    RelE5x5(0),
47    
47  //MVA variables 2
48    EtaWidth(0),
49    PhiWidth(0),
50 <  CoviEtaiPhi(0),
50 >  CoviEtaiPhi(0),
51    CoviPhiiPhi(0),
52  RelPreshowerEnergy(0)
52    
53 +  NVertexes(0),
54 +  RelPreshowerEnergy(0),
55 +
56 +  //MVA v2 and v1
57 +  RelIsoEcal(0),
58 +  RelIsoHcal(0),
59 +  tIso1(0),
60 +  tIso3(0),
61 +  tIso2(0),
62 +  ScEta(0.)
63   {
64    // Constructor.
65   }
# Line 69 | Line 78 | void MVATools::InitializeMVA(int Variabl
78    readers[1]  = fReaderBarrel;  
79    
80    for (UInt_t i=0; i<2; ++i) {
81 <    
81 >
82      if(VariableType==0||VariableType==1||VariableType==2){
83        readers[i]->AddVariable( "HoE", &HoE );
84        readers[i]->AddVariable( "covIEtaIEta", &covIEtaIEta );
# Line 79 | Line 88 | void MVATools::InitializeMVA(int Variabl
88        readers[i]->AddVariable( "R9", &R9 );
89      }
90      
91 +    if(VariableType==3||VariableType==4){
92 +      readers[i]->AddVariable( "HoE", &HoE );
93 +      readers[i]->AddVariable( "covIEtaIEta", &covIEtaIEta );
94 +      readers[i]->AddVariable( "tIso1abs", &tIso1abs );
95 +      readers[i]->AddVariable( "tIso3abs", &tIso3abs );
96 +      readers[i]->AddVariable( "tIso2abs", &tIso2abs );
97 +      readers[i]->AddVariable( "R9", &R9 );
98 +    }
99 +    
100      if(VariableType==1||VariableType==2){
101 <      readers[i]->AddVariable( "RelIsoEcal", &RelIsoEcal);
102 <      readers[i]->AddVariable( "RelIsoHcal", &RelIsoHcal);
103 <      readers[i]->AddVariable( "RelEMax", &RelEMax);
104 <      readers[i]->AddVariable( "RelETop",&RelETop);
105 <      readers[i]->AddVariable( "RelEBottom", &RelEBottom);
101 >      readers[i]->AddVariable( "RelIsoEcal", &RelIsoEcal );
102 >      readers[i]->AddVariable( "RelIsoHcal", &RelIsoHcal );
103 >      readers[i]->AddVariable( "RelEMax", &RelEMax );
104 >      readers[i]->AddVariable( "RelETop", &RelETop );
105 >      readers[i]->AddVariable( "RelEBottom", &RelEBottom );
106        readers[i]->AddVariable( "RelELeft", &RelELeft );
107 <      readers[i]->AddVariable( "RelERight", &RelERight);
107 >      readers[i]->AddVariable( "RelERight", &RelERight );
108        readers[i]->AddVariable( "RelE2x5Max", &RelE2x5Max );
109        readers[i]->AddVariable( "RelE2x5Top", &RelE2x5Top );
110        readers[i]->AddVariable( "RelE2x5Bottom", &RelE2x5Bottom );
# Line 95 | Line 113 | void MVATools::InitializeMVA(int Variabl
113        readers[i]->AddVariable( "RelE5x5", &RelE5x5 );
114      }
115      
116 <    if(VariableType==2){
116 >    if(VariableType==3||VariableType==4){
117 >      readers[i]->AddVariable( "absIsoEcal", &absIsoEcal );
118 >      readers[i]->AddVariable( "absIsoHcal", &absIsoHcal );
119 >      readers[i]->AddVariable( "RelEMax", &RelEMax );
120 >      readers[i]->AddVariable( "RelETop", &RelEBottom);
121 >      readers[i]->AddVariable( "RelEBottom", &RelEBottom );
122 >      readers[i]->AddVariable( "RelELeft", &RelELeft );
123 >      readers[i]->AddVariable( "RelERight", &RelERight );
124 >      readers[i]->AddVariable( "RelE2x5Max", &RelE2x5Max );
125 >      readers[i]->AddVariable( "RelE2x5Top", &RelE2x5Top );
126 >      readers[i]->AddVariable( "RelE2x5Bottom", &RelE2x5Bottom );
127 >      readers[i]->AddVariable( "RelE2x5Left", &RelE2x5Left );
128 >      readers[i]->AddVariable( "RelE2x5Right", &RelE2x5Right );
129 >      readers[i]->AddVariable( "RelE5x5", &RelE5x5 );
130 >    }
131 >    
132 >    if(VariableType==2||VariableType==3||VariableType==4){
133        readers[i]->AddVariable( "EtaWidth", &EtaWidth );
134        readers[i]->AddVariable( "PhiWidth", &PhiWidth );
135        readers[i]->AddVariable( "CoviEtaiPhi", &CoviEtaiPhi );
136        readers[i]->AddVariable( "CoviPhiiPhi", &CoviPhiiPhi );
137 +      if(VariableType==4){
138 +        readers[i]->AddVariable( "NVertexes", &NVertexes );
139 +      }
140        if(i==0){
141          readers[i]->AddVariable( "RelPreshowerEnergy", &RelPreshowerEnergy );
142        }
143      }
144 +
145 +    if(VariableType==6){
146 +      readers[i]->AddVariable( "HoE", &HoE );
147 +      readers[i]->AddVariable( "covIEtaIEta", &covIEtaIEta );
148 +      readers[i]->AddVariable( "tIso1abs", &tIso1abs );
149 +      readers[i]->AddVariable( "tIso3abs", &tIso3abs );
150 +      readers[i]->AddVariable( "tIso2abs", &tIso2abs );
151 +      readers[i]->AddVariable( "R9", &R9 );
152 +      readers[i]->AddVariable( "absIsoEcal", &absIsoEcal );
153 +      readers[i]->AddVariable( "absIsoHcal", &absIsoHcal );
154 +      readers[i]->AddVariable( "RelE5x5", &RelE5x5 );
155 +      readers[i]->AddVariable( "EtaWidth", &EtaWidth );
156 +      readers[i]->AddVariable( "PhiWidth", &PhiWidth );
157 +      readers[i]->AddVariable( "CoviEtaiPhi", &CoviEtaiPhi );
158 +      readers[i]->AddVariable( "CoviPhiiPhi", &CoviPhiiPhi );
159 +      readers[i]->AddVariable( "NVertexes", &NVertexes );
160 +      if(i==0){
161 +      readers[i]->AddVariable( "RelPreshowerEnergy", &RelPreshowerEnergy );
162 +      }
163 +    }
164 +    
165 +    if(VariableType==7){
166 +      readers[i]->AddVariable( "HoE", &HoE );
167 +      readers[i]->AddVariable( "covIEtaIEta", &covIEtaIEta );
168 +      readers[i]->AddVariable( "tIso1abs", &tIso1abs );
169 +      readers[i]->AddVariable( "tIso3abs", &tIso3abs );
170 +      readers[i]->AddVariable( "tIso2abs", &tIso2abs );
171 +      readers[i]->AddVariable( "R9", &R9 );
172 +      readers[i]->AddVariable( "absIsoEcal", &absIsoEcal );
173 +      readers[i]->AddVariable( "absIsoHcal", &absIsoHcal );
174 +      readers[i]->AddVariable( "NVertexes", &NVertexes );
175 +      readers[i]->AddVariable( "ScEta", &ScEta );
176 +    }    
177 +
178 +    if(VariableType==10){
179 +      readers[i]->AddVariable( "HoE", &HoE );
180 +      readers[i]->AddVariable( "covIEtaIEta", &covIEtaIEta );
181 +      readers[i]->AddVariable( "tIso1abs", &tIso1abs );
182 +      readers[i]->AddVariable( "tIso3abs", &tIso3abs );
183 +      readers[i]->AddVariable( "tIso2abs", &tIso2abs );
184 +      readers[i]->AddVariable( "R9", &R9 );
185 +      readers[i]->AddVariable( "absIsoEcal", &absIsoEcal );
186 +      readers[i]->AddVariable( "absIsoHcal", &absIsoHcal );
187 +      readers[i]->AddVariable( "NVertexes", &NVertexes );
188 +      readers[i]->AddVariable( "ScEta", &ScEta );
189 +      readers[i]->AddVariable( "EtaWidth", &EtaWidth );
190 +      readers[i]->AddVariable( "PhiWidth", &PhiWidth );      
191 +    }    
192 +
193 +    if(VariableType==1201){
194 +      /*readers[i]->AddVariable( "myphoton_pfchargedisogood03", &myphoton_pfchargedisogood03);
195 +      readers[i]->AddVariable( "myphoton_pfchargedisobad03", &myphoton_pfchargedisobad03);
196 +      readers[i]->AddVariable( "myphoton_pfphotoniso03", &myphoton_pfphotoniso03 );
197 +      readers[i]->AddVariable( "myphoton_sieie", &myphoton_sieie );
198 +      readers[i]->AddVariable( "myphoton_sieip", &myphoton_sieip );
199 +      readers[i]->AddVariable( "myphoton_etawidth", &myphoton_etawidth );
200 +      readers[i]->AddVariable( "myphoton_phiwidth", &myphoton_phiwidth );
201 +      readers[i]->AddVariable( "myphoton_r9", &myphoton_r9 );
202 +      readers[i]->AddVariable( "myphoton_s4ratio", &myphoton_s4ratio );
203 +      readers[i]->AddVariable( "myphoton_SCeta", &myphoton_SCeta );
204 +      readers[i]->AddVariable( "event_rho", &event_rho );
205 +      if(i==0){
206 +        readers[i]->AddVariable( "myphoton_ESEffSigmaRR", &myphoton_ESEffSigmaRR);
207 +        }*/
208 +      readers[i]->AddVariable( "ph.r9", &myphoton_r9 );
209 +      readers[i]->AddVariable( "ph.sigietaieta", &myphoton_sieie );
210 +      readers[i]->AddVariable( "ph.scetawidth", &myphoton_etawidth );
211 +      readers[i]->AddVariable( "ph.scphiwidth", &myphoton_phiwidth );
212 +      readers[i]->AddVariable( "ph.idmva_CoviEtaiPhi", &myphoton_sieip );
213 +      readers[i]->AddVariable( "ph.idmva_s4ratio", &myphoton_s4ratio );
214 +      readers[i]->AddVariable( "ph.idmva_GammaIso", &myphoton_pfphotoniso03 );
215 +      readers[i]->AddVariable( "ph.idmva_ChargedIso_selvtx", &myphoton_pfchargedisogood03);
216 +      readers[i]->AddVariable( "ph.idmva_ChargedIso_worstvtx", &myphoton_pfchargedisobad03);
217 +      readers[i]->AddVariable( "ph.sceta", &myphoton_SCeta );
218 +      readers[i]->AddVariable( "rho", &event_rho );
219 +      if(i==0){
220 +        //readers[i]->AddVariable( "1.00023*ph.idmva_PsEffWidthSigmaRR + 0.0913", &myphoton_ESEffSigmaRR);
221 +        readers[i]->AddVariable( "ph.idmva_PsEffWidthSigmaRR", &myphoton_ESEffSigmaRR);
222 +      }
223 +    }
224 +    
225    }
226    
227    fReaderEndcap->BookMVA("BDT method",EndcapWeights);
228    fReaderBarrel->BookMVA("BDT method",BarrelWeights);
229 <
229 >  
230    assert(fReaderEndcap);
231    assert(fReaderBarrel);
232    
233   }
234  
235 < //--------------------------------------------------------------------------------------------------
235 > 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) {
236 >  
237 >  //initilize the bool value
238 >  PassMVA=kFALSE;
239 >  
240 >  Float_t photon_bdt =  MVATools::GetMVAbdtValue_2011(p,vtx,trackCol,vtxCol, _tRho, els, applyElectronVeto);
241 >  
242 >  if (isbarrel) {
243 >    if(bdt>bdtCutBarrel){
244 >      PassMVA=kTRUE;    
245 >    }
246 >  }
247 >  else {
248 >    if(bdt>bdtCutEndcap){
249 >      PassMVA=kTRUE;    
250 >    }
251 >  }
252 >  return PassMVA;
253 > }
254  
255 < Bool_t MVATools::PassMVASelection(const Photon* p,const Vertex* vtx,const TrackCol* trackCol,const VertexCol* vtxCol,Double_t _tRho,const ElectronCol* els,double MVAPtMin) {
255 > //---------------------------------------------------------------------------------
256 > Int_t MVATools::PassElectronVetoInt(const Photon* p, const ElectronCol* els) {
257    
258    // these values are taken from the H2GGlobe code... (actually from Marco/s mail)
259    float cic4_allcuts_temp_sublead[] = {
# Line 129 | Line 266 | Bool_t MVATools::PassMVASelection(const
266      1.,          0.062,       0.97,        0.97,
267      1.5,         1.5,         1.5,         1.5 };  // the last line is PixelmatchVeto and un-used
268    
132  
269    //initilize the bool value
270 <  PassMVA=kFALSE;
271 <  PassElecVeto=kFALSE;
272 <  //Bool_t PassElecVeto=PhotonTools::PassElectronVeto(p,els);
270 >  PassElecVetoInt=0;
271 >  
272 >  dRTrack = PhotonTools::ElectronVetoCiC(p, els);
273 >  
274 >  ScEta_MVA=p->SCluster()->Eta();
275 >  
276 >  isbarrel = (fabs(ScEta_MVA)<1.4442);
277 >
278 >  R9 = p->R9();
279 >  //R9 = p->E33()/p->SCluster()->RawEnergy();
280 >  
281 >  // check which category it is ...
282 >  _tCat = 1;
283 >  if ( !isbarrel ) _tCat = 3;
284 >  if ( R9 < 0.94 ) _tCat++;
285    
286 +  //Electron Veto
287 +  if(dRTrack > cic4_allcuts_temp_sublead[_tCat-1+6*4]){
288 +    PassElecVetoInt=1;
289 +  }
290 +  
291 +  return  PassElecVetoInt;
292 +  
293 + }
294 +
295 + //--------------------------------------------------------------------------------------------------
296 +
297 + 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) {
298    
299    //get the variables used to compute MVA variables
300    ecalIso3 = p->EcalRecHitIsoDr03();
# Line 143 | Line 303 | Bool_t MVATools::PassMVASelection(const
303    
304    wVtxInd = 0;
305    
306 <  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?
307 <  
148 <  // track iso only
149 <  trackIso3 = IsolationTools::CiCTrackIsolation(p,vtx, 0.3, 0.02, 0.0, 0.0, 0.1, 1.0, trackCol);
150 <  
306 >  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?
307 >    
308    // track iso worst vtx
309 <  trackIso2 = IsolationTools::CiCTrackIsolation(p,vtx, 0.4, 0.02, 0.0, 0.0, 0.1, 1.0, trackCol, &wVtxInd,vtxCol);
309 >  trackIso2 = IsolationTools::CiCTrackIsolation(p,vtx, 0.4, 0.02, 0.0, 0.0, 0.1, 1.0, trackCol, &wVtxInd,vtxCol, (!applyElectronVeto ? els : NULL) );
310    
311    combIso1 = ecalIso3+hcalIso4+trackIso1 - 0.17*_tRho;
312    combIso2 = ecalIso4+hcalIso4+trackIso2 - 0.52*_tRho;
313    
314    RawEnergy = p->SCluster()->RawEnergy();
315    
316 <  dRTrack = PhotonTools::ElectronVetoCiC(p, els);
316 >  ScEta = p->SCluster()->Eta();
317    
318 <  //compute MVA variables 0
162 <  HoE = p->HadOverEm();
163 <  covIEtaIEta = p->CoviEtaiEta();
318 >  //mva varialbes v1 and v2
319    tIso1 = (combIso1) *50./p->Et();
320 <  tIso3 = (trackIso3)*50./p->Et();
320 >  tIso3 = (trackIso1)*50./p->Et();
321    tIso2 = (combIso2) *50./(p->MomVtx(vtxCol->At(wVtxInd)->Position()).Pt());
167  R9 = p->R9();
168  
169  //newly added MVA variables 1
322    RelIsoEcal=(ecalIso3-0.17*_tRho)/p->Et();
323    RelIsoHcal=(hcalIso4-0.17*_tRho)/p->Et();
324 <  
324 >
325 >  //compute mva variables for v3
326 >  HoE = p->HadOverEm();
327 >  covIEtaIEta = p->CoviEtaiEta();
328 >  tIso1abs = combIso1;
329 >  tIso3abs = trackIso1;
330 >  tIso2abs = combIso2;
331 >  R9 = p->R9();
332 >
333 >  absIsoEcal=(ecalIso3-0.17*_tRho);
334 >  absIsoHcal=(hcalIso4-0.17*_tRho);
335    RelEMax=p->SCluster()->Seed()->EMax()/RawEnergy;
336    RelETop=p->SCluster()->Seed()->ETop()/RawEnergy;
337    RelEBottom=p->SCluster()->Seed()->EBottom()/RawEnergy;
# Line 182 | Line 344 | Bool_t MVATools::PassMVASelection(const
344    RelE2x5Right=p->SCluster()->Seed()->E2x5Right()/RawEnergy;
345    RelE5x5=p->SCluster()->Seed()->E5x5()/RawEnergy;
346    
347 <  //newly added MVA variables 2
348 <  EtaWidth=p->SCluster()->EtaWidth();
187 <  PhiWidth=p->SCluster()->PhiWidth();
347 >  EtaWidth=p->EtaWidth();
348 >  PhiWidth=p->PhiWidth();
349    CoviEtaiPhi=p->SCluster()->Seed()->CoviEtaiPhi();
350    CoviPhiiPhi=p->SCluster()->Seed()->CoviPhiiPhi();
351 +
352    RelPreshowerEnergy=p->SCluster()->PreshowerEnergy()/RawEnergy;
353 +  NVertexes=vtxCol->GetEntries();
354    
355    //spectator variables
356    Pt_MVA=p->Pt();
357    ScEta_MVA=p->SCluster()->Eta();
358 <  
358 >
359 >  //
360 >
361    isbarrel = (fabs(ScEta_MVA)<1.4442);
362    
363 <  // check which category it is ...
364 <  _tCat = 1;
365 <  if ( !isbarrel ) _tCat = 3;
366 <  if ( R9 < 0.94 ) _tCat++;
367 <  
368 <  //Electron Veto
369 <  if(dRTrack > cic4_allcuts_temp_sublead[_tCat-1+6*4]){
370 <    PassElecVeto=kTRUE;
371 <  }
372 <  
373 <  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){
374 <    
210 <    if (isbarrel) {
211 <      reader = fReaderBarrel;
212 <    }
213 <    else {
214 <      reader = fReaderEndcap;
215 <    }
216 <    
217 <    bdt = reader->EvaluateMVA( "BDT method" );
218 <    
219 <    if (isbarrel) {
220 <      if(bdt>0.0031324){
221 <        PassMVA=kTRUE;  
222 <      }
223 <    }
224 <    else {
225 <      if(bdt>0.0086){
226 <        PassMVA=kTRUE;  
227 <      }
228 <    }
363 >  //variable 1201
364 >  myphoton_pfchargedisogood03=IsolationTools::PFChargedIsolation(p,vtx,0.3,0,fPFCands);
365 >  myphoton_pfchargedisobad03=IsolationTools::PFChargedIsolation(p,vtx,0.3,0,fPFCands,&wVtxInd,vtxCol);
366 >  myphoton_pfphotoniso03=IsolationTools::PFGammaIsolation(p,0.3,0,fPFCands);
367 >  myphoton_sieie=covIEtaIEta;
368 >  myphoton_sieip=CoviEtaiPhi;
369 >  myphoton_etawidth=EtaWidth;
370 >  myphoton_phiwidth=PhiWidth;
371 >  myphoton_r9=R9;
372 >  myphoton_s4ratio=p->S4Ratio();
373 >  myphoton_SCeta=ScEta_MVA;
374 >  event_rho= _tRho;
375  
376 <  }
231 <
232 <  return PassMVA;
233 < }
376 >  myphoton_ESEffSigmaRR=-99;
377  
378 < //---------------------------------------------------------------------------------
379 < Int_t MVATools::PassElectronVetoInt(const Photon* p, const ElectronCol* els) {
380 <  
238 <  // these values are taken from the H2GGlobe code... (actually from Marco/s mail)
239 <  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);
378 >  if(!isbarrel){
379 >    myphoton_ESEffSigmaRR=p->EffSigmaRR();
380 >  }
381    
382 <  ScEta_MVA=p->SCluster()->Eta();
382 >  if (isbarrel) {
383 >    reader = fReaderBarrel;
384 >  }
385 >  else {
386 >    reader = fReaderEndcap;
387 >  }
388    
389 <  isbarrel = (fabs(ScEta_MVA)<1.4442);
389 >  assert(reader);
390  
391 <  R9 = p->R9();
391 >  bdt = reader->EvaluateMVA("BDT method");
392 >
393 >  /* printf("HoE: %f\n",HoE);
394 >  printf("covIEtaIEta: %f\n",covIEtaIEta);
395 >  printf("tIso1abs: %f\n",tIso1abs);
396 >  printf("tIso3abs: %f\n",tIso3abs);
397 >  printf("tIso2abs: %f\n",tIso2abs);
398    
399 <  // check which category it is ...
400 <  _tCat = 1;
401 <  if ( !isbarrel ) _tCat = 3;
402 <  if ( R9 < 0.94 ) _tCat++;
399 >  printf("absIsoEcal: %f\n",absIsoEcal);
400 >  printf("absIsoHcal: %f\n",absIsoHcal);
401 >  printf("RelEMax: %f\n",RelEMax);
402 >  printf("RelETop: %f\n",RelETop);
403 >  printf("RelEBottom: %f\n",RelEBottom);
404 >  printf("RelELeft: %f\n",RelELeft);
405 >  printf("RelERight: %f\n",RelERight);
406 >  printf("RelE2x5Max: %f\n",RelE2x5Max);
407 >  printf("RelE2x5Top: %f\n",RelE2x5Top);
408 >  printf("RelE2x5Bottom: %f\n",RelE2x5Bottom);
409 >  printf("RelE2x5Left: %f\n",RelE2x5Left);
410 >  printf("RelE2x5Right;: %f\n",RelE2x5Right);
411 >  printf("RelE5x5: %f\n",RelE5x5);
412    
413 <  //Electron Veto
414 <  if(dRTrack > cic4_allcuts_temp_sublead[_tCat-1+6*4]){
415 <    PassElecVetoInt=1;
416 <  }
413 >  printf("EtaWidth: %f\n",EtaWidth);
414 >  printf("PhiWidth: %f\n",PhiWidth);
415 >  printf("CoviEtaiPhi: %f\n",CoviEtaiPhi);
416 >  printf("CoviPhiiPhi: %f\n",CoviPhiiPhi);
417    
418 <  return  PassElecVetoInt;
418 >  if (!isbarrel) {
419 >    printf("RelPreshowerEnergy: %f\n",RelPreshowerEnergy);
420 >    }*/
421    
422 +  return bdt;
423   }
424  
425 < //--------------------------------------------------------------------------------------------------
275 <
276 < Float_t MVATools::GetMVAbdtValue(const Photon* p,const Vertex* vtx,const TrackCol* trackCol,const VertexCol* vtxCol,Double_t _tRho,const ElectronCol* els) {
425 > 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) {
426    
427    //get the variables used to compute MVA variables
428    ecalIso3 = p->EcalRecHitIsoDr03();
# Line 282 | Line 431 | Float_t MVATools::GetMVAbdtValue(const P
431    
432    wVtxInd = 0;
433    
434 <  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?
435 <  
287 <  // track iso only
288 <  trackIso3 = IsolationTools::CiCTrackIsolation(p,vtx, 0.3, 0.02, 0.0, 0.0, 0.1, 1.0, trackCol);
289 <  
434 >  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?
435 >    
436    // track iso worst vtx
437 <  trackIso2 = IsolationTools::CiCTrackIsolation(p,vtx, 0.4, 0.02, 0.0, 0.0, 0.1, 1.0, trackCol, &wVtxInd,vtxCol);
437 >  trackIso2 = IsolationTools::CiCTrackIsolation(p,vtx, 0.4, 0.02, 0.0, 0.0, 0.1, 1.0, trackCol, &wVtxInd,vtxCol, (!applyElectronVeto ? els : NULL) );
438    
439    combIso1 = ecalIso3+hcalIso4+trackIso1 - 0.17*_tRho;
440    combIso2 = ecalIso4+hcalIso4+trackIso2 - 0.52*_tRho;
441    
442    RawEnergy = p->SCluster()->RawEnergy();
443    
444 <  dRTrack = PhotonTools::ElectronVetoCiC(p, els);
444 >  ScEta = p->SCluster()->Eta();
445    
446 <  //compute MVA variables 0
301 <  HoE = p->HadOverEm();
302 <  covIEtaIEta = p->CoviEtaiEta();
446 >  //mva varialbes v1 and v2
447    tIso1 = (combIso1) *50./p->Et();
448 <  tIso3 = (trackIso3)*50./p->Et();
448 >  tIso3 = (trackIso1)*50./p->Et();
449    tIso2 = (combIso2) *50./(p->MomVtx(vtxCol->At(wVtxInd)->Position()).Pt());
306  R9 = p->R9();
307  
308  //newly added MVA variables 1
450    RelIsoEcal=(ecalIso3-0.17*_tRho)/p->Et();
451    RelIsoHcal=(hcalIso4-0.17*_tRho)/p->Et();
452 <  
452 >
453 >  //compute mva variables for v3
454 >  HoE = p->HadOverEm();
455 >  covIEtaIEta = p->CoviEtaiEta();
456 >  tIso1abs = combIso1;
457 >  tIso3abs = trackIso1;
458 >  tIso2abs = combIso2;
459 >  R9 = p->R9();
460 >
461 >  absIsoEcal=(ecalIso3-0.17*_tRho);
462 >  absIsoHcal=(hcalIso4-0.17*_tRho);
463    RelEMax=p->SCluster()->Seed()->EMax()/RawEnergy;
464    RelETop=p->SCluster()->Seed()->ETop()/RawEnergy;
465    RelEBottom=p->SCluster()->Seed()->EBottom()/RawEnergy;
# Line 321 | Line 472 | Float_t MVATools::GetMVAbdtValue(const P
472    RelE2x5Right=p->SCluster()->Seed()->E2x5Right()/RawEnergy;
473    RelE5x5=p->SCluster()->Seed()->E5x5()/RawEnergy;
474    
475 <  //newly added MVA variables 2
476 <  EtaWidth=p->SCluster()->EtaWidth();
326 <  PhiWidth=p->SCluster()->PhiWidth();
475 >  EtaWidth=p->EtaWidth();
476 >  PhiWidth=p->PhiWidth();
477    CoviEtaiPhi=p->SCluster()->Seed()->CoviEtaiPhi();
478    CoviPhiiPhi=p->SCluster()->Seed()->CoviPhiiPhi();
479 +
480    RelPreshowerEnergy=p->SCluster()->PreshowerEnergy()/RawEnergy;
481 +  NVertexes=vtxCol->GetEntries();
482    
483    //spectator variables
484    Pt_MVA=p->Pt();
485    ScEta_MVA=p->SCluster()->Eta();
486 <  
486 >
487 >  //
488 >
489    isbarrel = (fabs(ScEta_MVA)<1.4442);
490    
491    if (isbarrel) {
# Line 345 | Line 499 | Float_t MVATools::GetMVAbdtValue(const P
499  
500    bdt = reader->EvaluateMVA("BDT method");
501  
502 <  /*  printf("HoE: %f\n",HoE);
502 >  /* printf("HoE: %f\n",HoE);
503    printf("covIEtaIEta: %f\n",covIEtaIEta);
504 <  printf("tIso1: %f\n",tIso1);
505 <  printf("tIso3: %f\n",tIso3);
506 <  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);
504 >  printf("tIso1abs: %f\n",tIso1abs);
505 >  printf("tIso3abs: %f\n",tIso3abs);
506 >  printf("tIso2abs: %f\n",tIso2abs);
507    
508 +  printf("absIsoEcal: %f\n",absIsoEcal);
509 +  printf("absIsoHcal: %f\n",absIsoHcal);
510    printf("RelEMax: %f\n",RelEMax);
511    printf("RelETop: %f\n",RelETop);
512    printf("RelEBottom: %f\n",RelEBottom);
# Line 372 | Line 524 | Float_t MVATools::GetMVAbdtValue(const P
524    printf("CoviEtaiPhi: %f\n",CoviEtaiPhi);
525    printf("CoviPhiiPhi: %f\n",CoviPhiiPhi);
526    
527 <  if (isbarrel) {
527 >  if (!isbarrel) {
528      printf("RelPreshowerEnergy: %f\n",RelPreshowerEnergy);
529      }*/
530    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines