89 |
|
TString BarrelWeights; |
90 |
|
TString EndcapWeights; |
91 |
|
|
92 |
– |
std::vector<std::string> varNames; // tmp vector to push_back variable names |
92 |
|
varNames.resize(0); |
93 |
|
|
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 |
+ |
std::cout<<" ... done "<<std::endl; |
130 |
+ |
|
131 |
+ |
break; |
132 |
+ |
|
133 |
|
case k2011IdMVA: |
134 |
|
|
135 |
|
EndcapWeights = (gSystem->Getenv("CMSSW_BASE")+ |
157 |
|
varNames.push_back("PhiWidth" ); |
158 |
|
|
159 |
|
for( unsigned int iV = 0; iV < mvaVars.size(); ++iV) { |
160 |
< |
mvaVarMapEB.insert( std::pair<std::string,float*>(varNames[iV], &(mvaVars[iV])) ); |
161 |
< |
mvaVarMapEE.insert( std::pair<std::string,float*>(varNames[iV], &(mvaVars[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 |
|
break; |
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,float*>(varNames[iV], &(mvaVars[iV])) ); |
194 |
< |
mvaVarMapEE.insert( std::pair<std::string,float*>(varNames[iV], &(mvaVars[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 |
> |
case k2013FinalIdMVA_8TeV: |
203 |
> |
|
204 |
> |
EndcapWeights = (gSystem->Getenv("CMSSW_BASE")+ |
205 |
> |
TString("/src/MitPhysics/data/2013FinalPaper_PhotonID_Weight/8TeV/")+ |
206 |
> |
TString("2013FinalPaper_PhotonID_Endcap_BDT_TrainRangePT15_8TeV.")+ |
207 |
> |
TString("weights.xml")); |
208 |
> |
BarrelWeights = (gSystem->Getenv("CMSSW_BASE")+ |
209 |
> |
TString("/src/MitPhysics/data/2013FinalPaper_PhotonID_Weight/8TeV/")+ |
210 |
> |
TString("2013FinalPaper_PhotonID_Barrel_BDT_TrainRangePT15_8TeV.")+ |
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,float*> ( varNames[mvaVars.size() - 1], &(mvaVars[mvaVars.size() - 1]) ) ); |
234 |
> |
mvaVarMapEE.insert( std::pair<std::string,unsigned int> ( varNames[mvaVars.size() - 1], mvaVars.size() - 1) ); |
235 |
> |
|
236 |
> |
break; |
237 |
> |
|
238 |
> |
case k2013FinalIdMVA_7TeV: |
239 |
> |
|
240 |
> |
EndcapWeights = (gSystem->Getenv("CMSSW_BASE")+ |
241 |
> |
TString("/src/MitPhysics/data/2013FinalPaper_PhotonID_Weight/7TeV/")+ |
242 |
> |
TString("2013FinalPaper_PhotonID_Endcap_BDT_TrainRangePT15_7TeV.")+ |
243 |
> |
TString("weights.xml")); |
244 |
> |
BarrelWeights = (gSystem->Getenv("CMSSW_BASE")+ |
245 |
> |
TString("/src/MitPhysics/data/2013FinalPaper_PhotonID_Weight/7TeV/")+ |
246 |
> |
TString("2013FinalPaper_PhotonID_Barrel_BDT_TrainRangePT15_7TeV.")+ |
247 |
> |
TString("weights.xml")); |
248 |
> |
|
249 |
> |
mvaVars.resize(13); |
250 |
> |
varNames.push_back("ph.scrawe" ); |
251 |
> |
varNames.push_back("ph.r9" ); |
252 |
> |
varNames.push_back("ph.sigietaieta" ); |
253 |
> |
varNames.push_back("ph.scetawidth" ); |
254 |
> |
varNames.push_back("ph.scphiwidth" ); |
255 |
> |
varNames.push_back("ph.idmva_CoviEtaiPhi" ); |
256 |
> |
varNames.push_back("ph.idmva_s4ratio" ); |
257 |
> |
varNames.push_back("ph.idmva_GammaIso" ); |
258 |
> |
varNames.push_back("ph.idmva_ChargedIso_selvtx" ); |
259 |
> |
varNames.push_back("ph.idmva_ChargedIso_worstvtx" ); |
260 |
> |
varNames.push_back("ph.sceta" ); |
261 |
> |
varNames.push_back("rho" ); |
262 |
> |
varNames.push_back("ph.idmva_PsEffWidthSigmaRR" ); |
263 |
> |
|
264 |
> |
for( unsigned int iV = 0; iV < mvaVars.size() - 1; ++iV) { |
265 |
> |
mvaVarMapEB.insert( std::pair<std::string,unsigned int>(varNames[iV], iV) ); |
266 |
> |
mvaVarMapEE.insert( std::pair<std::string,unsigned int>(varNames[iV], iV) ); |
267 |
> |
} |
268 |
> |
|
269 |
> |
// pre-shower only used for Endcaps |
270 |
> |
mvaVarMapEE.insert( std::pair<std::string,unsigned int> ( varNames[mvaVars.size() - 1], mvaVars.size() - 1) ); |
271 |
|
|
272 |
|
break; |
273 |
|
|
279 |
|
|
280 |
|
|
281 |
|
// looping over both maps and adding Vars to BDT readers |
282 |
< |
for(std::map<std::string,float*>::const_iterator it = mvaVarMapEB.begin(); it != mvaVarMapEB.end(); ++it) |
283 |
< |
fReaderBarrel -> AddVariable( (it->first).c_str(), it->second); |
284 |
< |
for(std::map<std::string,float*>::const_iterator it = mvaVarMapEE.begin(); it != mvaVarMapEE.end(); ++it) |
285 |
< |
fReaderEndcap -> AddVariable( (it->first).c_str(), it->second); |
286 |
< |
|
282 |
> |
for( unsigned int iV = 0; iV < varNames.size(); ++iV ){ |
283 |
> |
std::map<std::string,unsigned int>::const_iterator it = mvaVarMapEB.find(varNames[iV]); |
284 |
> |
if ( it != mvaVarMapEB.end() ) |
285 |
> |
fReaderBarrel -> AddVariable( (it->first).c_str(), &(mvaVars[it->second])); |
286 |
> |
it = mvaVarMapEE.find(varNames[iV]); |
287 |
> |
if ( it != mvaVarMapEE.end() ) |
288 |
> |
fReaderEndcap -> AddVariable( (it->first).c_str(), &(mvaVars[it->second])); |
289 |
> |
} |
290 |
> |
|
291 |
|
fReaderEndcap->BookMVA("BDT method",EndcapWeights); |
292 |
|
fReaderBarrel->BookMVA("BDT method",BarrelWeights); |
293 |
|
|
532 |
|
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) { |
533 |
|
|
534 |
|
// if there's no reader, or the type is kNone, return the default values of -99. |
535 |
+ |
//if( ( !fReaderBarrel || !fReaderEndcap ) ) return -199.; |
536 |
|
if( ( !fReaderBarrel || !fReaderEndcap ) || fMVAType == kNone ) return -99.; |
537 |
|
|
538 |
|
// we compute the variable names... make sure no confilcts when adding new variables... |
540 |
|
// check if it's a Barrel or EE photon |
541 |
|
bool isBarrel = ( p->SCluster()->AbsEta() < 1.5 ); |
542 |
|
|
543 |
< |
std::map<std::string,float*>* theVars = ( isBarrel ? &mvaVarMapEB : &mvaVarMapEB ); |
544 |
< |
|
543 |
> |
std::map<std::string,unsigned int>* theVars = ( isBarrel ? &mvaVarMapEB : &mvaVarMapEE ); |
544 |
> |
|
545 |
|
// loop over all the variables in the map... and keep count (to make sure we have filled all variables) |
546 |
|
unsigned int varCounter = 0; |
547 |
< |
for( std::map<std::string,float*>::const_iterator iV = theVars->begin(); iV != theVars->end(); ++iV ) { |
548 |
< |
|
547 |
> |
for( std::map<std::string,unsigned int>::const_iterator iV = theVars->begin(); iV != theVars->end(); ++iV ) { |
548 |
> |
|
549 |
|
TString theVarName = TString(iV->first); |
550 |
< |
float* theVarValue = iV->second; // pointer to the variable... |
550 |
> |
float* theVarValue = &(mvaVars[iV->second]); // pointer to the variable... |
551 |
|
|
552 |
|
if( |
553 |
|
!theVarName.CompareTo("HoE") |
555 |
|
(*theVarValue) = p->HadOverEm(); |
556 |
|
varCounter++; |
557 |
|
} else if ( |
558 |
< |
!theVarName.CompareTo("covIEtaIEta") || !theVarName.CompareTo("ph.sigietaieta") |
558 |
> |
!theVarName.CompareTo("covIEtaIEta") || !theVarName.CompareTo("ph.sigietaieta") || !theVarName.CompareTo("sigieie") |
559 |
|
) { |
560 |
|
(*theVarValue) = p->CoviEtaiEta(); |
561 |
|
varCounter++; |
562 |
|
} else if ( |
563 |
< |
!theVarName.CompareTo("R9") || !theVarName.CompareTo("ph.r9") |
563 |
> |
!theVarName.CompareTo("R9") || !theVarName.CompareTo("ph.r9") || !theVarName.CompareTo("r9") |
564 |
|
) { |
565 |
|
(*theVarValue) = p->R9(); |
566 |
|
varCounter++; |
567 |
|
} else if ( |
568 |
< |
!theVarName.CompareTo("ScEta") || !theVarName.CompareTo("ph.sceta") |
568 |
> |
!theVarName.CompareTo("ScEta") || !theVarName.CompareTo("ph.sceta") || !theVarName.CompareTo("sceta") |
569 |
|
) { |
570 |
|
(*theVarValue) = p->SCluster()->Eta(); |
571 |
|
varCounter++; |
615 |
|
(*theVarValue) = vtxCol->GetEntries(); |
616 |
|
varCounter++; |
617 |
|
} else if ( |
618 |
< |
!theVarName.CompareTo("EtaWidth") || !!theVarName.CompareTo("ph.scetawidth") |
618 |
> |
!theVarName.CompareTo("EtaWidth") || !theVarName.CompareTo("ph.scetawidth") || !theVarName.CompareTo("sigeta") |
619 |
|
) { |
620 |
|
(*theVarValue) = p->EtaWidth(); |
621 |
|
varCounter++; |
622 |
|
} else if ( |
623 |
< |
!theVarName.CompareTo("PhiWidth") || !!theVarName.CompareTo("ph.scphiwidth") |
623 |
> |
!theVarName.CompareTo("PhiWidth") || !theVarName.CompareTo("ph.scphiwidth") || !theVarName.CompareTo("sigphi") |
624 |
|
) { |
625 |
|
(*theVarValue) = p->PhiWidth(); |
626 |
|
varCounter++; |
627 |
|
|
628 |
|
} else if ( |
629 |
< |
!theVarName.CompareTo("ph.idmva_CoviEtaiPhi") |
629 |
> |
!theVarName.CompareTo("ph.idmva_CoviEtaiPhi") || !theVarName.CompareTo("covieip") |
630 |
|
) { |
631 |
|
(*theVarValue) = p->SCluster()->Seed()->CoviEtaiPhi(); |
632 |
|
varCounter++; |
633 |
|
} else if ( |
634 |
< |
!theVarName.CompareTo("ph.idmva_s4ratio") |
634 |
> |
!theVarName.CompareTo("ph.idmva_s4ratio") || !theVarName.CompareTo("s4r") |
635 |
|
) { |
636 |
|
(*theVarValue) = p->S4Ratio(); |
637 |
+ |
//(*theVarValue) = p->SCluster()->Seed()->E2x2()/p->E55(); |
638 |
|
varCounter++; |
639 |
|
} else if ( |
640 |
< |
!theVarName.CompareTo("ph.idmva_GammaIso") |
640 |
> |
!theVarName.CompareTo("ph.idmva_GammaIso") || !theVarName.CompareTo("pfgiso") |
641 |
|
) { |
642 |
|
(*theVarValue) = IsolationTools::PFGammaIsolation(p,0.3,0,fPFCands); |
643 |
|
varCounter++; |
644 |
|
} else if ( |
645 |
< |
!theVarName.CompareTo("ph.idmva_ChargedIso_selvtx") |
645 |
> |
!theVarName.CompareTo("ph.idmva_ChargedIso_selvtx") || !theVarName.CompareTo("pfciso") |
646 |
|
) { |
647 |
|
(*theVarValue) = IsolationTools::PFChargedIsolation(p,vtx,0.3,0,fPFCands); |
648 |
|
varCounter++; |
657 |
|
) { |
658 |
|
(*theVarValue) = p->EffSigmaRR(); |
659 |
|
varCounter++; |
660 |
+ |
} else if ( |
661 |
+ |
!theVarName.CompareTo("rawe")|| !theVarName.CompareTo("ph.scrawe") |
662 |
+ |
) { |
663 |
+ |
(*theVarValue) = p->SCluster()->RawEnergy(); |
664 |
+ |
varCounter++; |
665 |
|
} else { |
666 |
|
// a variable is not know... copmplain! |
667 |
|
std::cerr<<" ERROR: MVA Evaluation called with unknown variable name >"<<theVarName<<">."<<std::endl; |