ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/PhotonIDMod.cc
Revision: 1.35
Committed: Thu Aug 2 12:59:10 2012 UTC (12 years, 9 months ago) by fabstoec
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_029c, Mit_029b, Mit_029a
Changes since 1.34: +28 -5 lines
Log Message:
added Rho Choice function

File Contents

# Content
1
2 // $Id: PhotonIDMod.cc,v 1.34 2012/08/02 12:30:55 fabstoec Exp $
3
4 #include "TDataMember.h"
5 #include "TTree.h"
6 #include "TRandom3.h"
7 #include "MitPhysics/Mods/interface/PhotonIDMod.h"
8 #include "MitAna/DataTree/interface/PhotonCol.h"
9 #include "MitPhysics/Init/interface/ModNames.h"
10 #include "MitPhysics/Utils/interface/IsolationTools.h"
11 #include "MitPhysics/Utils/interface/PhotonTools.h"
12
13 #include <TSystem.h>
14
15 using namespace mithep;
16
17 ClassImp(mithep::PhotonIDMod)
18
19 //--------------------------------------------------------------------------------------------------
20 PhotonIDMod::PhotonIDMod(const char *name, const char *title) :
21 BaseMod(name,title),
22 fPhotonBranchName (Names::gkPhotonBrn),
23 fGoodPhotonsName (ModNames::gkGoodPhotonsName),
24 fTrackBranchName (Names::gkTrackBrn),
25 fBeamspotBranchName(Names::gkBeamSpotBrn),
26 fPileUpDenName (Names::gkPileupEnergyDensityBrn),
27 fConversionName ("MergedConversions"),
28 fElectronName ("Electrons"),
29 fGoodElectronName ("Electrons"),
30 fPVName (Names::gkPVBeamSpotBrn),
31 // MC specific stuff...
32 fMCParticleName (Names::gkMCPartBrn),
33 fPileUpName (Names::gkPileupInfoBrn),
34 fPFCandsName ("PFCandidates"),
35
36 fPhotonIDType ("Custom"),
37 fPhotonIsoType ("Custom"),
38 fPhotonPtMin (15.0),
39 fHadOverEmMax (0.02),
40 fApplySpikeRemoval (kFALSE),
41 fApplyPixelSeed (kTRUE),
42 fApplyElectronVeto (kFALSE),
43 fInvertElectronVeto(kFALSE),
44 fApplyElectronVetoConvRecovery(kFALSE),
45 fApplyConversionId (kFALSE),
46 fApplyTriggerMatching(kFALSE),
47 fPhotonR9Min (0.5),
48 fPhIdType (kIdUndef),
49 fPhIsoType (kIsoUndef),
50 fFiduciality (kTRUE),
51 fEtaWidthEB (0.01),
52 fEtaWidthEE (0.028),
53 fAbsEtaMax (999.99),
54 fApplyR9Min (kFALSE),
55
56 fEffAreaEcalEE (0.089),
57 fEffAreaHcalEE (0.156),
58 fEffAreaTrackEE (0.261),
59
60 fEffAreaEcalEB (0.183),
61 fEffAreaHcalEB (0.062),
62 fEffAreaTrackEB (0.306),
63
64 fPhotons(0),
65 fTracks(0),
66 fBeamspots(0),
67 fPileUpDen(0),
68 fConversions(0),
69 fElectrons(0),
70 fGoodElectrons(0),
71 fPV(0),
72 fMCParticles (0),
73 fPileUp (0),
74 fPFCands (0),
75
76 // MVA ID Stuff
77 fbdtCutBarrel (0.0744), //cuts give the same effiiciency (relative to preselection) with cic
78 fbdtCutEndcap (0.0959), //cuts give the same effiiciency (relative to preselection) with cic
79
80 // ------------------------------------------------------------------------------
81 // this stuff should go away ..... (fab)
82 fVariableType (10), //please use 4 which is the correct type
83 fEndcapWeights (gSystem->Getenv("CMSSW_BASE")+TString("/src/MitPhysics/data/TMVAClassificationPhotonID_Endcap_PassPreSel_Variable_10_BDTnCuts2000_BDT.weights.xml")),
84 fBarrelWeights (gSystem->Getenv("CMSSW_BASE")+TString("/src/MitPhysics/data/TMVAClassificationPhotonID_Barrel_PassPreSel_Variable_10_BDTnCuts2000_BDT.weights.xml")),
85 // ------------------------------------------------------------------------------
86
87 fIdMVATypeName ("2011IdMVA"),
88 fIdMVAType (MVATools::k2011IdMVA),
89
90 // fDoMCR9Scaling (kFALSE),
91 // fMCR9ScaleEB (1.0),
92 // fMCR9ScaleEE (1.0),
93 // fDoMCSigIEtaIEtaScaling(kFALSE),
94 // fDoMCWidthScaling (kFALSE),
95
96 fDoMCErrScaling (kFALSE),
97 fMCErrScaleEB (1.0),
98 fMCErrScaleEE (1.0),
99
100 fPhotonsFromBranch(true),
101 fPVFromBranch (true),
102 fGoodElectronsFromBranch (kTRUE),
103 fIsData(false),
104
105 // ------------------------------------------------
106 // added by fab: smearing/scaling options...
107 fDoDataEneCorr (false),
108 fDoMCSmear (false),
109
110 fDoShowerShapeScaling (false),
111 // ------------------------------------------------
112 fDataEnCorr_EBlowEta_hR9central(0.),
113 fDataEnCorr_EBlowEta_hR9gap (0.),
114 fDataEnCorr_EBlowEta_lR9 (0.),
115 fDataEnCorr_EBhighEta_hR9 (0.),
116 fDataEnCorr_EBhighEta_lR9 (0.),
117 fDataEnCorr_EElowEta_hR9 (0.),
118 fDataEnCorr_EElowEta_lR9 (0.),
119 fDataEnCorr_EEhighEta_hR9 (0.),
120 fDataEnCorr_EEhighEta_lR9 (0.),
121 fRunStart (0),
122 fRunEnd (0),
123 fMCSmear_EBlowEta_hR9central (0.),
124 fMCSmear_EBlowEta_hR9gap (0.),
125 fMCSmear_EBlowEta_lR9 (0.),
126 fMCSmear_EBhighEta_hR9 (0.),
127 fMCSmear_EBhighEta_lR9 (0.),
128 fMCSmear_EElowEta_hR9 (0.),
129 fMCSmear_EElowEta_lR9 (0.),
130 fMCSmear_EEhighEta_hR9 (0.),
131 fMCSmear_EEhighEta_lR9 (0.),
132
133 fRng (new TRandom3()),
134
135 fRhoType (RhoUtilities::CMS_RHO_RHOKT6PFJETS)
136
137 {
138 // Constructor.
139 }
140
141 //--------------------------------------------------------------------------------------------------
142 void PhotonIDMod::Process()
143 {
144 // Process entries of the tree.
145
146 LoadEventObject(fPhotonBranchName, fPhotons);
147
148 const BaseVertex *bsp = NULL;
149 Double_t _tRho = -1.;
150 Float_t rho2012 = -99;
151 const TriggerObjectCol *trigObjs = 0;
152 if (fPhotons->GetEntries()>0) {
153 LoadEventObject(fTrackBranchName, fTracks);
154 LoadEventObject(fBeamspotBranchName, fBeamspots);
155 LoadEventObject(fPileUpDenName, fPileUpDen);
156 LoadEventObject(fConversionName, fConversions);
157 LoadEventObject(fElectronName, fElectrons);
158 LoadEventObject(fGoodElectronName, fGoodElectrons);
159 LoadEventObject(fPVName, fPV);
160 LoadEventObject(fPFCandsName, fPFCands);
161
162
163 if(fBeamspots->GetEntries() > 0)
164 bsp = fBeamspots->At(0);
165
166 if(fPileUpDen->GetEntries() > 0)
167 _tRho = (Double_t) fPileUpDen->At(0)->RhoRandomLowEta();
168
169 if (fPileUpDen->At(0)->RhoKt6PFJets()>0.) rho2012 = fPileUpDen->At(0)->RhoKt6PFJets();
170 else rho2012 = fPileUpDen->At(0)->Rho();
171
172 //get trigger object collection if trigger matching is enabled
173 if (fApplyTriggerMatching) {
174 trigObjs = GetHLTObjects(fTrigObjectsName);
175 }
176
177 }
178
179 Float_t theRho = _tRho;
180 switch (fRhoType) {
181 case RhoUtilities::CMS_RHO_RHOKT6PFJETS:
182 theRho = rho2012;
183 break;
184 case RhoUtilities::MIT_RHO_VORONOI_LOW_ETA:
185 theRho = ( fPileUpDen->GetEntries() ? fPileUpDen->At(0)->RhoLowEta(): _tRho);
186 break;
187 case RhoUtilities::MIT_RHO_VORONOI_HIGH_ETA:
188 theRho = ( fPileUpDen->GetEntries() ? fPileUpDen->At(0)->Rho() : _tRho);
189 break;
190 case RhoUtilities::MIT_RHO_RANDOM_LOW_ETA:
191 theRho = ( fPileUpDen->GetEntries() ? fPileUpDen->At(0)->RhoRandomLowEta() : _tRho);
192 break;
193 case RhoUtilities::MIT_RHO_RANDOM_HIGH_ETA:
194 theRho = ( fPileUpDen->GetEntries() ? fPileUpDen->At(0)->RhoRandom() : _tRho);
195 break;
196 default:
197 theRho = _tRho;
198 }
199
200
201 // ------------------------------------------------------------
202 // Get Event header for Run info etc.
203 const EventHeader* evtHead = this->GetEventHeader();
204 unsigned int evtNum = evtHead->EvtNum();
205 UInt_t runNumber = evtHead->RunNum();
206 Float_t _runNum = (Float_t) runNumber;
207 Float_t _lumiSec = (Float_t) evtHead->LumiSec();
208
209 PhotonOArr *GoodPhotons = new PhotonOArr;
210 GoodPhotons->SetName(fGoodPhotonsName);
211 GoodPhotons->SetOwner(kTRUE);
212
213 for (UInt_t i=0; i<fPhotons->GetEntries(); ++i) {
214 // need to cpoy the photon in order to be able to scale R9 etc.
215 Photon *ph = new Photon(*fPhotons->At(i));
216
217 if (fFiduciality == kTRUE &&
218 (ph->SCluster()->AbsEta()>=2.5 || (ph->SCluster()->AbsEta()>=1.4442 && ph->SCluster()->AbsEta()<=1.566) ) )
219 continue;
220
221 if (fInvertElectronVeto && PhotonTools::PassElectronVeto(ph,fGoodElectrons) && false) {
222 continue;
223 }
224
225 // -----------------------------------------------------------------------------------
226 // Do all the scaling ....
227 if (fDoMCErrScaling && !fIsData) {
228 if (ph->SCluster()->AbsEta()<1.5) PhotonTools::ScalePhotonError(ph,fMCErrScaleEB);
229 else PhotonTools::ScalePhotonError(ph,fMCErrScaleEE);
230 }
231
232 if (fDoShowerShapeScaling && !fIsData) {
233 PhotonTools::ScalePhotonShowerShapes(ph,fSSType);
234 }
235
236 // fab: replaced by shower-shape scaling above...
237 // if (fDoMCR9Scaling && !fIsData) {
238 // if (ph->SCluster()->AbsEta()<1.5) PhotonTools::ScalePhotonR9(ph,fMCR9ScaleEB);
239 // else PhotonTools::ScalePhotonR9(ph,fMCR9ScaleEE);
240 // }
241
242 // if (fDoMCSigIEtaIEtaScaling && !fIsData) {
243 // if (ph->SCluster()->AbsEta()<1.5) ph->SetCoviEtaiEta(0.87*ph->CoviEtaiEta() + 0.0011);
244 // else ph->SetCoviEtaiEta(0.99*ph->CoviEtaiEta());
245 // }
246
247 // if (fDoMCWidthScaling && !fIsData) {
248 // ph->SetEtaWidth(0.99*ph->EtaWidth());
249 // ph->SetPhiWidth(0.99*ph->PhiWidth());
250 // }
251
252 PhotonTools::eScaleCats escalecat = PhotonTools::EScaleCat(ph);
253
254 // now we dicide if we either scale (Data) or Smear (MC) the Photons
255 if (fIsData) {
256 if (fDoDataEneCorr) {
257 // starting with scale = 1.
258 double scaleFac = 1.;
259 // checking the run Rangees ...
260 Int_t runRange = FindRunRangeIdx(runNumber);
261 if(runRange > -1) {
262 scaleFac *= GetDataEnCorr(runRange, escalecat);
263 }
264 PhotonTools::ScalePhoton(ph, scaleFac);
265 }
266 }
267
268 if (fDoMCSmear) {
269 double width = GetMCSmearFac(escalecat);
270 if (!fIsData) {
271 // get the seed to do deterministic smearing...
272 UInt_t seedBase = (UInt_t) evtNum + (UInt_t) _runNum + (UInt_t) _lumiSec;
273 UInt_t seed = seedBase + (UInt_t) ph->E() +
274 (UInt_t) (TMath::Abs(10.*ph->SCluster()->Eta()));
275 // get the smearing for MC photons..
276 PhotonTools::SmearPhoton(ph, fRng, width, seed);
277 }
278 PhotonTools::SmearPhotonError(ph, width);
279 }
280
281 // ---------------------------------------------------------------------
282 // set the photonIdMVA value of requested...
283 double idMvaVal = fTool.GetMVAbdtValue(ph,fPV->At(0),fTracks, fPV, theRho, fPFCands, fElectrons, fApplyElectronVeto);
284 ph->SetIdMva(idMvaVal);
285
286 // ---------------------------------------------------------------------
287 // check if we use the Vgamma2011 Selection. If yes, bypass all the below...
288 if( fPhIdType == kTrivialSelection ) {
289 if( ph->Pt() > fPhotonPtMin && ph->SCluster()->AbsEta() <= fAbsEtaMax )
290 GoodPhotons->AddOwned(ph);
291 continue; // go to next Photons
292 }
293
294 // ---------------------------------------------------------------------
295 // check if we use the Vgamma2011 Selection. If yes, bypass all the below...
296 if( fPhIdType == kVgamma2011Selection ) {
297 if( ph->Pt() > fPhotonPtMin && ph->SCluster()->AbsEta() <= fAbsEtaMax && PhotonTools::PassVgamma2011Selection(ph, _tRho) )
298 GoodPhotons->AddOwned(ph);
299 continue; // go to next Photons
300 }
301
302 // ---------------------------------------------------------------------
303 // check if we use the CiC Selection. If yes, bypass all the below...
304 if(fPhIdType == kBaseLineCiC) {
305 if( PhotonTools::PassCiCSelection(ph, fPV->At(0), fTracks, fElectrons, fPV, _tRho, fPhotonPtMin, fApplyElectronVeto) )
306 GoodPhotons->AddOwned(ph);
307 continue; // go to next Photons
308 }
309
310 if(fPhIdType == kBaseLineCiCPF) {
311 if( PhotonTools::PassSinglePhotonPreselPFISO(ph,fElectrons,fConversions,bsp,fTracks,fPV->At(0),rho2012,fPFCands,fApplyElectronVeto,fInvertElectronVeto) && PhotonTools::PassCiCPFIsoSelection(ph, fPV->At(0), fPFCands, fPV, rho2012, fPhotonPtMin) )
312 GoodPhotons->AddOwned(ph);
313 continue; // go to next Photons
314 }
315 // ---------------------------------------------------------------------
316
317 //loose photon preselection for subsequent mva
318 if(fPhIdType == kMITPhSelection ) {
319 if( ph->Pt()>fPhotonPtMin && PhotonTools::PassSinglePhotonPresel(ph,fElectrons,fConversions,bsp,fTracks,fPV->At(0),_tRho,fApplyElectronVeto,fInvertElectronVeto) ) {
320 GoodPhotons->AddOwned(ph);
321 }
322 continue;
323 }
324
325 //loose photon preselection for subsequent mva
326 if(fPhIdType == kMITPFPhSelection ) {
327 if( ph->Pt()>fPhotonPtMin && PhotonTools::PassSinglePhotonPreselPFISO(ph,fElectrons,fConversions,bsp,fTracks,fPV->At(0),rho2012,fPFCands,fApplyElectronVeto,fInvertElectronVeto) ) {
328 GoodPhotons->AddOwned(ph);
329 }
330 continue;
331 }
332
333 //loose photon preselection for subsequent mva
334 if(fPhIdType == kMITPFPhSelection_NoTrigger ) {
335 if( ph->Pt()>fPhotonPtMin && PhotonTools::PassSinglePhotonPreselPFISO_NoTrigger(ph,fElectrons,fConversions,bsp,fTracks,fPV->At(0),rho2012,fPFCands,fApplyElectronVeto,fInvertElectronVeto) ) {
336 GoodPhotons->AddOwned(ph);
337 }
338 continue;
339 }
340
341
342 Bool_t isbarrel = ph->SCluster()->AbsEta()<1.5;
343
344 // add MingMings MVA ID on single Photon level
345 if(fPhIdType == kMITMVAId ) {
346 // we compute the bdt val already before, so use it ...
347 //if( ph->Pt()>fPhotonPtMin && PhotonTools::PassSinglePhotonPresel(ph,fElectrons,fConversions,bsp,fTracks,fPV->At(0),_tRho,fApplyElectronVeto) && fTool.PassMVASelection(ph, fPV->At(0) ,fTracks, fPV, _t_TRho,fbdtCutBarrel,fbdtCutEndcap, fElectrons, fApplyElectronVeto) ) {
348
349 if( ph->Pt()>fPhotonPtMin && PhotonTools::PassSinglePhotonPresel(ph,fElectrons,fConversions,bsp,fTracks,fPV->At(0),_tRho,fApplyElectronVeto) && ( ( isbarrel && ph->IdMva() > fbdtCutBarrel ) || ( ph->IdMva() > fbdtCutEndcap ) ) )
350 GoodPhotons->AddOwned(ph);
351
352 continue;
353 } // go to next Photon
354
355 if (ph->Pt() <= fPhotonPtMin)
356 continue; // add good electron
357
358 Bool_t passSpikeRemovalFilter = kTRUE;
359
360 if (ph->SCluster() && ph->SCluster()->Seed()) {
361 if(ph->SCluster()->Seed()->Energy() > 5.0 &&
362 ph->SCluster()->Seed()->EMax() / ph->SCluster()->Seed()->E3x3() > 0.95
363 ) {
364 passSpikeRemovalFilter = kFALSE;
365 }
366 }
367
368 // For Now Only use the EMax/E3x3 prescription.
369 //if(ph->SCluster()->Seed()->Energy() > 5.0 &&
370 // (1 - (ph->SCluster()->Seed()->E1x3() + ph->SCluster()->Seed()->E3x1() - 2*ph->SCluster()->Seed()->EMax())) > 0.95
371 // ) {
372 // passSpikeRemovalFilter = kFALSE;
373 //}
374
375 if (fApplySpikeRemoval && !passSpikeRemovalFilter) continue;
376
377 if (ph->HadOverEm() >= fHadOverEmMax)
378 continue;
379
380 if (fApplyPixelSeed == kTRUE &&
381 ph->HasPixelSeed() == kTRUE)
382 continue;
383
384 if (fApplyElectronVeto && !PhotonTools::PassElectronVeto(ph,fElectrons) ) continue;
385
386 if (fApplyElectronVetoConvRecovery && !PhotonTools::PassElectronVetoConvRecovery(ph,fElectrons,fConversions,bsp) ) continue;
387
388 if (fApplyConversionId && !PhotonTools::PassConversionId(ph,PhotonTools::MatchedConversion(ph,fConversions,bsp))) continue;
389
390 if (fApplyTriggerMatching && !PhotonTools::PassTriggerMatching(ph,trigObjs)) continue;
391
392 Bool_t idcut = kFALSE;
393 switch (fPhIdType) {
394 case kTight:
395 idcut = ph->IsTightPhoton();
396 break;
397 case kLoose:
398 idcut = ph->IsLoosePhoton();
399 break;
400 case kLooseEM:
401 idcut = ph->IsLooseEM();
402 break;
403 case kCustomId:
404 idcut = kTRUE;
405 default:
406 break;
407 }
408
409 if (!idcut)
410 continue;
411
412 Bool_t isocut = kFALSE;
413 switch (fPhIsoType) {
414 case kNoIso:
415 isocut = kTRUE;
416 break;
417 case kCombinedIso:
418 {
419 Double_t totalIso = ph->HollowConeTrkIsoDr04()+
420 ph->EcalRecHitIsoDr04() +
421 ph->HcalTowerSumEtDr04();
422 if (totalIso/ph->Pt() < 0.25)
423 isocut = kTRUE;
424 }
425 break;
426 case kCustomIso:
427 {
428 if ( ph->HollowConeTrkIsoDr04() < (1.5 + 0.001*ph->Pt()) && ph->EcalRecHitIsoDr04()<(2.0+0.006*ph->Pt()) && ph->HcalTowerSumEtDr04()<(2.0+0.0025*ph->Pt()) )
429 isocut = kTRUE;
430 }
431 break;
432
433 case kMITPUCorrected:
434 {
435 // compute the PU corrections only if Rho is available
436 // ... otherwise (_tRho = 0.0) it's the std isolation
437 isocut = kTRUE;
438 Double_t fEffAreaEcal = fEffAreaEcalEB;
439 Double_t fEffAreaHcal = fEffAreaHcalEB;
440 Double_t fEffAreaTrack = fEffAreaTrackEB;
441
442 if( !isbarrel ) {
443 fEffAreaEcal = fEffAreaEcalEE;
444 fEffAreaHcal = fEffAreaHcalEE;
445 fEffAreaTrack = fEffAreaTrackEE;
446 }
447
448 Double_t EcalCorrISO = ph->EcalRecHitIsoDr04();
449 if(_tRho > -0.5 ) EcalCorrISO -= _tRho * fEffAreaEcal;
450 if ( EcalCorrISO > (2.0+0.006*ph->Pt()) ) isocut = kFALSE;
451 if ( isocut || true ) {
452 Double_t HcalCorrISO = ph->HcalTowerSumEtDr04();
453 if(_tRho > -0.5 ) HcalCorrISO -= _tRho * fEffAreaHcal;
454 if ( HcalCorrISO > (2.0+0.0025*ph->Pt()) ) isocut = kFALSE;
455 }
456 if ( isocut || true ) {
457 Double_t TrackCorrISO = IsolationTools::TrackIsolationNoPV(ph, bsp, 0.4, 0.04, 0.0, 0.015, 0.1, TrackQuality::highPurity, fTracks);
458 if(_tRho > -0.5 )
459 TrackCorrISO -= _tRho * fEffAreaTrack;
460 if ( TrackCorrISO > (1.5 + 0.001*ph->Pt()) ) isocut = kFALSE;
461 }
462 break;
463 }
464 default:
465 break;
466 }
467
468 if (!isocut)
469 continue;
470
471 if ( fApplyR9Min && ph->R9() <= fPhotonR9Min)
472 continue;
473
474 if ((isbarrel && ph->CoviEtaiEta() >= fEtaWidthEB) ||
475 (!isbarrel && ph->CoviEtaiEta() >= fEtaWidthEE))
476 continue;
477
478 if (ph->AbsEta() >= fAbsEtaMax)
479 continue;
480
481 // add good electron
482 GoodPhotons->AddOwned(ph);
483 }
484
485 // sort according to pt
486 GoodPhotons->Sort();
487
488 // add to event for other modules to use
489 AddObjThisEvt(GoodPhotons);
490
491 return;
492
493 }
494
495 //--------------------------------------------------------------------------------------------------
496 void PhotonIDMod::SlaveBegin()
497 {
498 // Run startup code on the computer (slave) doing the actual analysis. Here,
499 // we just request the photon collection branch.
500
501 ReqEventObject(fPhotonBranchName, fPhotons, fPhotonsFromBranch);
502 ReqEventObject(fTrackBranchName, fTracks, kTRUE);
503 ReqEventObject(fBeamspotBranchName, fBeamspots, kTRUE);
504 ReqEventObject(fConversionName, fConversions, kTRUE);
505 ReqEventObject(fElectronName, fElectrons, kTRUE);
506 ReqEventObject(fGoodElectronName, fGoodElectrons, fGoodElectronsFromBranch);
507 ReqEventObject(fPVName, fPV, fPVFromBranch);
508 ReqEventObject(fPileUpDenName, fPileUpDen, kTRUE);
509 ReqEventObject(fPFCandsName, fPFCands, kTRUE);
510
511 if (!fIsData) {
512 ReqBranch(fPileUpName, fPileUp);
513 ReqBranch(fMCParticleName, fMCParticles);
514 }
515
516 if (fPhotonIDType.CompareTo("Tight") == 0)
517 fPhIdType = kTight;
518 else if (fPhotonIDType.CompareTo("Loose") == 0)
519 fPhIdType = kLoose;
520 else if (fPhotonIDType.CompareTo("LooseEM") == 0)
521 fPhIdType = kLooseEM;
522 else if (fPhotonIDType.CompareTo("Custom") == 0)
523 fPhIdType = kCustomId;
524 else if (fPhotonIDType.CompareTo("BaseLineCiC") == 0) {
525 fPhIdType = kBaseLineCiC;
526 fPhotonIsoType = "NoIso";
527 }
528 else if (fPhotonIDType.CompareTo("BaseLineCiCPF") == 0) {
529 fPhIdType = kBaseLineCiCPF;
530 fPhotonIsoType = "NoIso";
531 }
532 else if (fPhotonIDType.CompareTo("MITMVAId") == 0) {
533 fPhIdType = kMITMVAId;
534 fPhotonIsoType = "NoIso";
535 // this is now a 'generic' MVAId: set the MVAType using 'SetIdMVAType(const char*)' (fab)
536 //fTool.InitializeMVA(fVariableType,fEndcapWeights,fBarrelWeights); // moved down for after we know which MVA type to load...
537 }
538 else if (fPhotonIDType.CompareTo("MITSelection") == 0) {
539 fPhIdType = kMITPhSelection;
540 fPhotonIsoType = "NoIso";
541 }
542 else if (fPhotonIDType.CompareTo("MITPFSelection") == 0) {
543 fPhIdType = kMITPFPhSelection;
544 fPhotonIsoType = "NoIso";
545 }
546 else if (fPhotonIDType.CompareTo("MITPFSelection_NoTrigger") == 0) {
547 fPhIdType = kMITPFPhSelection_NoTrigger;
548 fPhotonIsoType = "NoIso";
549 }
550 else if (fPhotonIDType.CompareTo("Vgamma2011Selection") == 0) {
551 fPhIdType = kVgamma2011Selection;
552 fPhotonIsoType = "NoIso";
553 }
554 else if (fPhotonIDType.CompareTo("TrivialSelection") == 0) {
555 fPhIdType = kTrivialSelection;
556 fPhotonIsoType = "NoIso";
557 }
558 else {
559 SendError(kAbortAnalysis, "SlaveBegin",
560 "The specified photon identification %s is not defined.",
561 fPhotonIDType.Data());
562 return;
563 }
564
565 if (fPhotonIsoType.CompareTo("NoIso") == 0 )
566 fPhIsoType = kNoIso;
567 else if (fPhotonIsoType.CompareTo("CombinedIso") == 0 )
568 fPhIsoType = kCombinedIso;
569 else if (fPhotonIsoType.CompareTo("Custom") == 0 )
570 fPhIsoType = kCustomIso;
571 else if (fPhotonIsoType.CompareTo("MITPUCorrected") == 0 )
572 fPhIsoType = kMITPUCorrected;
573 else {
574 SendError(kAbortAnalysis, "SlaveBegin",
575 "The specified photon isolation %s is not defined.",
576 fPhotonIsoType.Data());
577 return;
578 }
579
580 if (fShowerShapeType.CompareTo("None") == 0)
581 fSSType = PhotonTools::kNoShowerShapeScaling;
582 else if (fShowerShapeType.CompareTo("2011ShowerShape") == 0)
583 fSSType = PhotonTools::k2011ShowerShape;
584 else if (fShowerShapeType.CompareTo("2012ShowerShape") == 0)
585 fSSType = PhotonTools::k2012ShowerShape;
586 else {
587 std::cerr<<"shower shape scale "<<fShowerShapeType<<" not implemented."<<std::endl;
588 return;
589 }
590
591 if (fIdMVATypeName.CompareTo("2011IdMVA") == 0)
592 fIdMVAType = MVATools::k2011IdMVA;
593 else if (fIdMVATypeName.CompareTo("2012IdMVA_globe") == 0)
594 fIdMVAType = MVATools::k2012IdMVA_globe;
595 else if (fIdMVATypeName.CompareTo("2012IdMVA") == 0)
596 fIdMVAType = MVATools::k2012IdMVA;
597 else if (fIdMVATypeName.CompareTo("2011IdMVA_HZg") == 0)
598 fIdMVAType = MVATools::k2011IdMVA_HZg;
599 else if (fIdMVATypeName.CompareTo("None") == 0)
600 fIdMVAType = MVATools::kNone;
601 else {
602 std::cerr<<" Id MVA "<<fIdMVATypeName<<" not implemented."<<std::endl;
603 return;
604 }
605
606 // ------------------------------------------------------------------------------------
607 // we fill ALWAYS the bdt varible with some value... so initialize the BDT if not set to 'None' (will be handeled by MVATools) (fab)
608 fTool.InitializeMVA(fIdMVAType);
609 // ------------------------------------------------------------------------------------
610
611 }
612
613
614 //---------------------------------------------------------------------------------------------------
615 Int_t PhotonIDMod::FindRunRangeIdx(UInt_t run)
616 {
617 // this routine looks for the idx of the run-range
618 Int_t runRange=-1;
619 for (UInt_t iRun = 0; iRun<fRunStart.size(); ++iRun) {
620 if (run >= fRunStart[iRun] && run <= fRunEnd[iRun]) {
621 runRange = (Int_t) iRun;
622 return runRange;
623 }
624 }
625 return runRange;
626 }
627
628 //---------------------------------------------------------------------------------------------------
629 Double_t PhotonIDMod::GetDataEnCorr(Int_t runRange, PhotonTools::eScaleCats cat)
630 {
631 switch (cat) {
632 case PhotonTools::kEBhighEtaGold:
633 return fDataEnCorr_EBhighEta_hR9[runRange];
634 case PhotonTools::kEBhighEtaBad:
635 return fDataEnCorr_EBhighEta_lR9[runRange];
636 case PhotonTools::kEBlowEtaGoldCenter:
637 return fDataEnCorr_EBlowEta_hR9central[runRange];
638 case PhotonTools::kEBlowEtaGoldGap:
639 return fDataEnCorr_EBlowEta_hR9gap[runRange];
640 case PhotonTools::kEBlowEtaBad:
641 return fDataEnCorr_EBlowEta_lR9[runRange];
642 case PhotonTools::kEEhighEtaGold:
643 return fDataEnCorr_EEhighEta_hR9[runRange];
644 case PhotonTools::kEEhighEtaBad:
645 return fDataEnCorr_EEhighEta_lR9[runRange];
646 case PhotonTools::kEElowEtaGold:
647 return fDataEnCorr_EElowEta_hR9[runRange];
648 case PhotonTools::kEElowEtaBad:
649 return fDataEnCorr_EElowEta_lR9[runRange];
650 default:
651 return 1.;
652 }
653 }
654
655 //---------------------------------------------------------------------------------------------------
656 Double_t PhotonIDMod::GetMCSmearFac(PhotonTools::eScaleCats cat)
657 {
658 switch (cat) {
659 case PhotonTools::kEBhighEtaGold:
660 return fMCSmear_EBhighEta_hR9;
661 case PhotonTools::kEBhighEtaBad:
662 return fMCSmear_EBhighEta_lR9;
663 case PhotonTools::kEBlowEtaGoldCenter:
664 return fMCSmear_EBlowEta_hR9central;
665 case PhotonTools::kEBlowEtaGoldGap:
666 return fMCSmear_EBlowEta_hR9gap;
667 case PhotonTools::kEBlowEtaBad:
668 return fMCSmear_EBlowEta_lR9;
669 case PhotonTools::kEEhighEtaGold:
670 return fMCSmear_EEhighEta_hR9;
671 case PhotonTools::kEEhighEtaBad:
672 return fMCSmear_EEhighEta_lR9;
673 case PhotonTools::kEElowEtaGold:
674 return fMCSmear_EElowEta_hR9;
675 case PhotonTools::kEElowEtaBad:
676 return fMCSmear_EElowEta_lR9;
677 default:
678 return 1.;
679 }
680 }