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

Comparing UserCode/MitPhysics/Utils/src/ElectronTools.cc (file contents):
Revision 1.21 by ceballos, Wed Feb 23 09:48:19 2011 UTC vs.
Revision 1.33 by sixie, Sat Dec 31 23:17:40 2011 UTC

# Line 3 | Line 3
3   #include "MitPhysics/Utils/interface/ElectronTools.h"
4   #include "MitAna/DataTree/interface/StableData.h"
5   #include <TFile.h>
6 + #include "MitPhysics/ElectronLikelihood/interface/ElectronLikelihood.h"
7 + #include "MitPhysics/ElectronLikelihood/interface/LikelihoodSwitches.h"
8 + #include "MitPhysics/ElectronLikelihood/interface/LikelihoodMeasurements.h"
9  
10   ClassImp(mithep::ElectronTools)
11  
# Line 35 | Line 38 | Bool_t ElectronTools::PassCustomID(const
38      {0.3, 0.92, 0.211, 0.0, 0.42, 0.88, 0.68, 0.0},             //eoverp
39      {0.8,0.2,0,0,0,0,0,0}};                                     //extra cuts fbrem and E_Over_P
40  
41 +  Double_t VBTFWorkingPointFakeable[6][8] = {
42 +    {0.12,  0.12,  0.12,  0.12,  0.10,   0.10,   0.10,   0.10  }, //hovere
43 +    {0.01,  0.01,  0.01,  0.01,  0.03,   0.03,   0.03,   0.03  }, //sigmaetaeta
44 +    {0.15,  0.15,  0.15,  0.15,  0.10,   0.10,   0.10,   0.10  }, //deltaphiin
45 +    {0.007, 0.007, 0.007, 0.007, 0.009,  0.009,  0.009,  0.009 }, //deltaetain
46 +    {0.0,   0.0,   0.0,   0.0,   0.0,    0.0,    0.0,    0.0   }, //eoverp
47 +    {0.0,   0.0,   0,     0,     0,      0,      0,      0     }  //extra cuts fbrem and E_Over_P
48 +  };            
49 +
50    Double_t VBTFWorkingPoint95[6][8] = {
51      {0.15,  0.15,  0.15,  0.15,  0.07,   0.07,   0.07,   0.07  }, //hovere
52      {0.01,  0.01,  0.01,  0.01,  0.03,   0.03,   0.03,   0.03  }, //sigmaetaeta
# Line 63 | Line 75 | Bool_t ElectronTools::PassCustomID(const
75    };            
76  
77    Double_t VBTFWorkingPoint80[6][8] = {
78 <    {0.04,  0.04,  0.04,  0.04,  0.025,  0.025,  0.025,  0.025}, //hovere
78 >    {0.04,  0.04,  0.04,  0.04,  0.10,   0.10,   0.10,   0.10 }, //hovere
79      {0.01,  0.01,  0.01,  0.01,  0.03,   0.03,   0.03,   0.03 }, //sigmaetaeta
80      {0.06,  0.06,  0.06,  0.06,  0.03,   0.03,   0.03,   0.03 }, //deltaphiin
81      {0.004, 0.004, 0.004, 0.004, 0.007,  0.007,  0.007,  0.007}, //deltaetain
# Line 80 | Line 92 | Bool_t ElectronTools::PassCustomID(const
92      {0.0,   0.0,   0,     0,     0,      0,      0,      0    }  //extra cuts fbrem and E_Over_P
93    };            
94  
95 +  Double_t VBTFWorkingPoint80NoHOverEE[6][8] = {
96 +    {0.04,  0.04,  0.04,  0.04,  0.10,   0.10,   0.10,   0.10 }, //hovere
97 +    {0.01,  0.01,  0.01,  0.01,  0.03,   0.03,   0.03,   0.03 }, //sigmaetaeta
98 +    {0.06,  0.06,  0.06,  0.06,  0.03,   0.03,   0.03,   0.03 }, //deltaphiin
99 +    {0.004, 0.004, 0.004, 0.004, 0.007,  0.007,  0.007,  0.007}, //deltaetain
100 +    {0.0,   0.0,   0.0,   0.0,   0.0,    0.0,    0.0,    0.0  }, //eoverp
101 +    {0.0,   0.0,   0,     0,     0,      0,      0,      0    }  //extra cuts fbrem and E_Over_P
102 +  };            
103 +
104 +  Double_t VBTFWorkingPoint70NoHOverEE[6][8] = {
105 +    {0.025, 0.025, 0.025, 0.025, 0.10,   0.10,   0.10,   0.10 }, //hovere
106 +    {0.01,  0.01,  0.01,  0.01,  0.03,   0.03,   0.03,   0.03 }, //sigmaetaeta
107 +    {0.03,  0.03,  0.03,  0.03,  0.02,   0.02,   0.02,   0.02 }, //deltaphiin
108 +    {0.004, 0.004, 0.004, 0.004, 0.005,  0.005,  0.005,  0.005}, //deltaetain
109 +    {0.0,   0.0,   0.0,   0.0,   0.0,    0.0,    0.0,    0.0  }, //eoverp
110 +    {0.0,   0.0,   0,     0,     0,      0,      0,      0    }  //extra cuts fbrem and E_Over_P
111 +  };            
112 +
113    switch (idType) {
114      case kCustomIdTight:    
115        memcpy(fCuts,tightcuts,sizeof(fCuts));
# Line 87 | Line 117 | Bool_t ElectronTools::PassCustomID(const
117      case kCustomIdLoose:
118        memcpy(fCuts,loosecuts,sizeof(fCuts));
119        break;
120 +    case kVBTFWorkingPointFakeableId:
121 +      memcpy(fCuts,VBTFWorkingPointFakeable,sizeof(fCuts));
122 +      break;
123      case kVBTFWorkingPoint95Id:
124        memcpy(fCuts,VBTFWorkingPoint95,sizeof(fCuts));
125        break;
# Line 99 | Line 132 | Bool_t ElectronTools::PassCustomID(const
132      case kVBTFWorkingPoint80Id:
133        memcpy(fCuts,VBTFWorkingPoint80,sizeof(fCuts));
134        break;
135 +    case kVBTFWorkingPointLowPtId:
136 +      if(ele->Pt() < 20)
137 +        memcpy(fCuts,VBTFWorkingPoint70NoHOverEE,sizeof(fCuts));
138 +      else
139 +        memcpy(fCuts,VBTFWorkingPoint80NoHOverEE,sizeof(fCuts));
140 +      break;
141      case kVBTFWorkingPoint70Id:
142        memcpy(fCuts,VBTFWorkingPoint70,sizeof(fCuts));
143        break;
# Line 107 | Line 146 | Bool_t ElectronTools::PassCustomID(const
146        break;
147    }
148  
110
149    // Based on RecoEgamma/ElectronIdentification/src/CutBasedElectronID.cc.
150    Double_t eOverP = ele->ESuperClusterOverP();
151    Double_t fBrem  = ele->FBrem();
# Line 135 | Line 173 | Bool_t ElectronTools::PassCustomID(const
173    Int_t eb = 1;
174    if (ele->IsEB())
175      eb = 0;
176 <
176 >
177    if (hOverE>fCuts[0][cat+4*eb])
178      return kFALSE;
179  
# Line 151 | Line 189 | Bool_t ElectronTools::PassCustomID(const
189    if(eSeedOverPin<fCuts[4][cat+4*eb])
190      return kFALSE;
191  
192 +  // Cuts only for pt<20 region and kVBTFWorkingPointLowPtId
193 +  if(ele->Pt() < 20 && idType == kVBTFWorkingPointLowPtId) {
194 +    Bool_t isGoodLowPtEl = fBrem > 0.15 ||
195 +                          (ele->SCluster()->AbsEta() < 1.0 && eOverP > 0.95);
196 +    if(!isGoodLowPtEl) return kFALSE;
197 +  }
198 +  
199    return kTRUE;
200   }
201  
# Line 252 | Line 297 | Bool_t ElectronTools::PassConversionFilt
297                                             Double_t probMin,
298                                             Double_t lxyMin,
299                                             Bool_t matchCkf,
300 <                                           Bool_t requireArbitratedMerged)
300 >                                           Bool_t requireArbitratedMerged,
301 >                                           Double_t trkptMin)
302   {
303    Bool_t isGoodConversion = kFALSE;
304  
# Line 278 | Line 324 | Bool_t ElectronTools::PassConversionFilt
324            const Track *trk = dynamic_cast<const ChargedParticle*>
325              (conversions->At(ifc)->Daughter(d))->Trk();
326            if (trk) {
327 +            if (trk->Pt()<trkptMin) isGoodConversion = kFALSE;
328              const StableData *sd = dynamic_cast<const StableData*>
329                (conversions->At(ifc)->DaughterDat(d));
330              if (sd->NWrongHits() > nWrongHitsMax)
# Line 297 | Line 344 | Bool_t ElectronTools::PassConversionFilt
344   }
345  
346   //--------------------------------------------------------------------------------------------------
347 < Bool_t ElectronTools::PassD0Cut(const Electron *ele, const VertexCol *vertices, Double_t fD0Cut)
347 > Bool_t ElectronTools::PassD0Cut(const Electron *ele, const VertexCol *vertices, Double_t fD0Cut, Int_t nVertex)
348   {
349    Bool_t d0cut = kFALSE;
350 <  // d0 cut
351 <  Double_t d0_real = 99999;
352 <  for(UInt_t i0 = 0; i0 < vertices->GetEntries(); i0++) {
353 <    if(vertices->At(i0)->NTracks() > 0){
354 <      Double_t pD0 = ele->GsfTrk()->D0Corrected(*vertices->At(i0));
355 <      d0_real = TMath::Abs(pD0);
356 <      break;
350 >
351 >  Double_t d0_real = 1e30;
352 >  if(nVertex >= 0) d0_real = TMath::Abs(ele->GsfTrk()->D0Corrected(*vertices->At(nVertex)));
353 >  else            {
354 >    Double_t distVtx = 999.0;
355 >    Int_t closestVtx = 0;
356 >    for(UInt_t nv=0; nv<vertices->GetEntries(); nv++){
357 >      double dz = TMath::Abs(ele->GsfTrk()->DzCorrected(*vertices->At(nv)));
358 >      if(dz < distVtx) {
359 >        distVtx    = dz;
360 >        closestVtx = nv;
361 >      }
362      }
363 +    d0_real = TMath::Abs(ele->GsfTrk()->D0Corrected(*vertices->At(closestVtx)));
364    }
365    if(d0_real < fD0Cut) d0cut = kTRUE;
366    
# Line 330 | Line 383 | Bool_t ElectronTools::PassD0Cut(const El
383   }
384  
385   //--------------------------------------------------------------------------------------------------
386 + Bool_t ElectronTools::PassDZCut(const Electron *ele, const VertexCol *vertices, Double_t fDZCut, Int_t nVertex)
387 + {
388 +  Bool_t dzcut = kFALSE;
389 +
390 +  Double_t distVtx = 999.0;
391 +  if(nVertex >= 0) distVtx = TMath::Abs(ele->GsfTrk()->DzCorrected(*vertices->At(nVertex)));
392 +  else {
393 +    for(UInt_t nv=0; nv<vertices->GetEntries(); nv++){
394 +      double dz = TMath::Abs(ele->GsfTrk()->DzCorrected(*vertices->At(nv)));
395 +      if(dz < distVtx) {
396 +        distVtx  = dz;
397 +      }
398 +    }
399 +  }
400 +
401 +  if(distVtx < fDZCut) dzcut = kTRUE;
402 +  
403 +  return dzcut;
404 + }
405 +
406 + //--------------------------------------------------------------------------------------------------
407   Bool_t ElectronTools::PassChargeFilter(const Electron *ele)
408   {
409    Bool_t passChargeFilter = kTRUE;
# Line 939 | Line 1013 | bool ElectronTools::compute_cut(double x
1013  
1014    return accept;
1015   }
1016 +
1017 + //--------------------------------------------------------------------------------------------------
1018 + Double_t ElectronTools::Likelihood(ElectronLikelihood *LH, const Electron *ele)
1019 + {
1020 +  if (!LH) {
1021 +    std::cout << "Error: Likelihood not properly initialized\n";
1022 +    return -9999;
1023 +  }
1024 +
1025 +  LikelihoodMeasurements measurements;
1026 +  measurements.pt = ele->Pt();
1027 +  if (ele->IsEB() && ele->AbsEta()<1.0) measurements.subdet = 0;
1028 +  else if (ele->IsEB())                 measurements.subdet = 1;
1029 +  else                                  measurements.subdet = 2;
1030 +  measurements.deltaPhi = TMath::Abs(ele->DeltaPhiSuperClusterTrackAtVtx());
1031 +  measurements.deltaEta = TMath::Abs(ele->DeltaEtaSuperClusterTrackAtVtx());
1032 +  measurements.eSeedClusterOverPout = ele->ESeedClusterOverPout();
1033 +  measurements.eSuperClusterOverP = ele->ESuperClusterOverP();
1034 +  measurements.hadronicOverEm = ele->HadronicOverEm();
1035 +  measurements.sigmaIEtaIEta = ele->CoviEtaiEta();
1036 +  measurements.sigmaIPhiIPhi = TMath::Sqrt(ele->SCluster()->Seed()->CoviPhiiPhi());
1037 +  measurements.fBrem = ele->FBrem();
1038 +  measurements.nBremClusters = ele->NumberOfClusters() - 1;
1039 +  //measurements.OneOverEMinusOneOverP = (1.0 / ele->SCluster()->Energy()) - (1.0 / ele->BestTrk()->P());
1040 +  measurements.OneOverEMinusOneOverP = (1.0 / ele->ESuperClusterOverP() / ele->BestTrk()->P()) - (1.0 / ele->BestTrk()->P());
1041 +  double likelihood = LH->result(measurements);
1042 +
1043 +  double newLik = 0.0;
1044 +  if     (likelihood<=0) newLik = -20.0;
1045 +  else if(likelihood>=1) newLik =  20.0;
1046 +  else                   newLik = log(likelihood/(1.0-likelihood));
1047 +
1048 +  Bool_t isDebug = kFALSE;
1049 +  if(isDebug == kTRUE){
1050 +    printf("LIKELIHOOD: %f %d %f %f %f %f %f %f %f %f %d %f %f %f - %f %f\n",measurements.pt,measurements.subdet,
1051 +    measurements.deltaPhi          ,measurements.deltaEta      ,measurements.eSeedClusterOverPout,
1052 +    measurements.eSuperClusterOverP,measurements.hadronicOverEm,measurements.sigmaIEtaIEta,
1053 +    measurements.sigmaIPhiIPhi     ,measurements.fBrem         ,measurements.nBremClusters,
1054 +    measurements.OneOverEMinusOneOverP,ele->SCluster()->Energy(),ele->BestTrk()->P(),
1055 +    likelihood,newLik);
1056 +  }
1057 +
1058 +  return newLik;
1059 +
1060 + }
1061 +
1062 + Double_t ElectronTools::ElectronEffectiveArea(EElectronEffectiveAreaType type, Double_t Eta) {
1063 +
1064 +  Double_t EffectiveArea = 0;
1065 +
1066 +  if (fabs(Eta) < 1.0) {
1067 +    if (type == kEleChargedIso03) EffectiveArea = 0.000;
1068 +    if (type == kEleNeutralHadronIso03) EffectiveArea = 0.017;
1069 +    if (type == kEleGammaIso03) EffectiveArea = 0.045;
1070 +    if (type == kEleGammaIsoVetoEtaStrip03) EffectiveArea = 0.014;
1071 +    if (type == kEleChargedIso04) EffectiveArea = 0.000;
1072 +    if (type == kEleNeutralHadronIso04) EffectiveArea = 0.034;
1073 +    if (type == kEleGammaIso04) EffectiveArea = 0.079;
1074 +    if (type == kEleGammaIsoVetoEtaStrip04) EffectiveArea = 0.014;
1075 +    if (type == kEleNeutralHadronIso007) EffectiveArea = 0.000;
1076 +    if (type == kEleHoverE) EffectiveArea = 0.00016;
1077 +    if (type == kEleHcalDepth1OverEcal) EffectiveArea = 0.00016;
1078 +    if (type == kEleHcalDepth2OverEcal) EffectiveArea = 0.00000;    
1079 +  } else if (fabs(Eta) >= 1.0 && fabs(Eta) < 1.479 ) {
1080 +    if (type == kEleChargedIso03) EffectiveArea = 0.000;
1081 +    if (type == kEleNeutralHadronIso03) EffectiveArea = 0.025;
1082 +    if (type == kEleGammaIso03) EffectiveArea = 0.052;
1083 +    if (type == kEleGammaIsoVetoEtaStrip03) EffectiveArea = 0.030;
1084 +    if (type == kEleChargedIso04) EffectiveArea = 0.000;
1085 +    if (type == kEleNeutralHadronIso04) EffectiveArea = 0.050;
1086 +    if (type == kEleGammaIso04) EffectiveArea = 0.073;
1087 +    if (type == kEleGammaIsoVetoEtaStrip04) EffectiveArea = 0.030;
1088 +    if (type == kEleNeutralHadronIso007) EffectiveArea = 0.000;
1089 +    if (type == kEleHoverE) EffectiveArea = 0.00022;
1090 +    if (type == kEleHcalDepth1OverEcal) EffectiveArea = 0.00022;
1091 +    if (type == kEleHcalDepth2OverEcal) EffectiveArea = 0.00000;    
1092 +  } else if (fabs(Eta) >= 1.479 && fabs(Eta) < 2.0 ) {
1093 +    if (type == kEleChargedIso03) EffectiveArea = 0.000;
1094 +    if (type == kEleNeutralHadronIso03) EffectiveArea = 0.030;
1095 +    if (type == kEleGammaIso03) EffectiveArea = 0.170;
1096 +    if (type == kEleGammaIsoVetoEtaStrip03) EffectiveArea = 0.134;
1097 +    if (type == kEleChargedIso04) EffectiveArea = 0.000;
1098 +    if (type == kEleNeutralHadronIso04) EffectiveArea = 0.060;
1099 +    if (type == kEleGammaIso04) EffectiveArea = 0.187;
1100 +    if (type == kEleGammaIsoVetoEtaStrip04) EffectiveArea = 0.134;
1101 +    if (type == kEleNeutralHadronIso007) EffectiveArea = 0.000;
1102 +    if (type == kEleHoverE) EffectiveArea = 0.00030;
1103 +    if (type == kEleHcalDepth1OverEcal) EffectiveArea = 0.00026;
1104 +    if (type == kEleHcalDepth2OverEcal) EffectiveArea = 0.00002;        
1105 +  } else if (fabs(Eta) >= 2.0 && fabs(Eta) < 2.25 ) {
1106 +    if (type == kEleChargedIso03) EffectiveArea = 0.000;
1107 +    if (type == kEleNeutralHadronIso03) EffectiveArea = 0.022;
1108 +    if (type == kEleGammaIso03) EffectiveArea = 0.623;
1109 +    if (type == kEleGammaIsoVetoEtaStrip03) EffectiveArea = 0.516;
1110 +    if (type == kEleChargedIso04) EffectiveArea = 0.000;
1111 +    if (type == kEleNeutralHadronIso04) EffectiveArea = 0.055;
1112 +    if (type == kEleGammaIso04) EffectiveArea = 0.659;
1113 +    if (type == kEleGammaIsoVetoEtaStrip04) EffectiveArea = 0.517;
1114 +    if (type == kEleNeutralHadronIso007) EffectiveArea = 0.000;
1115 +    if (type == kEleHoverE) EffectiveArea = 0.00054;
1116 +    if (type == kEleHcalDepth1OverEcal) EffectiveArea = 0.00045;
1117 +    if (type == kEleHcalDepth2OverEcal) EffectiveArea = 0.00003;
1118 +  } else if (fabs(Eta) >= 2.25 && fabs(Eta) < 2.5 ) {
1119 +    if (type == kEleChargedIso03) EffectiveArea = 0.000;
1120 +    if (type == kEleNeutralHadronIso03) EffectiveArea = 0.018;
1121 +    if (type == kEleGammaIso03) EffectiveArea = 1.198;
1122 +    if (type == kEleGammaIsoVetoEtaStrip03) EffectiveArea = 1.049;
1123 +    if (type == kEleChargedIso04) EffectiveArea = 0.000;
1124 +    if (type == kEleNeutralHadronIso04) EffectiveArea = 0.073;
1125 +    if (type == kEleGammaIso04) EffectiveArea = 1.258;
1126 +    if (type == kEleGammaIsoVetoEtaStrip04) EffectiveArea = 1.051;
1127 +    if (type == kEleNeutralHadronIso007) EffectiveArea = 0.000;
1128 +    if (type == kEleHoverE) EffectiveArea = 0.00082;
1129 +    if (type == kEleHcalDepth1OverEcal) EffectiveArea = 0.00066;
1130 +    if (type == kEleHcalDepth2OverEcal) EffectiveArea = 0.00004;
1131 +  }
1132 +    
1133 +  return EffectiveArea;  
1134 + }
1135 +
1136 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines