ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/LeptonSelection/src/IsolationSelection.cc
(Generate patch)

Comparing UserCode/MitHzz4l/LeptonSelection/src/IsolationSelection.cc (file contents):
Revision 1.20 by khahn, Mon May 14 18:01:02 2012 UTC vs.
Revision 1.29 by khahn, Sun Jun 3 15:51:51 2012 UTC

# Line 25 | Line 25 | extern vector<bool> PFnoPUflag;
25  
26   //--------------------------------------------------------------------------------------------------
27   Float_t computePFMuonIso(const mithep::Muon *muon,
28 <                         const mithep::Vertex & vtx,
28 >                         const mithep::Vertex * vtx,
29                           const mithep::Array<mithep::PFCandidate> * fPFCandidates,
30                           const Double_t dRMax)
31   //--------------------------------------------------------------------------------------------------
# Line 34 | Line 34 | Float_t computePFMuonIso(const mithep::M
34    const Double_t neuPtMin = 1.0;
35    const Double_t dzMax    = 0.1;
36      
37 <  Double_t zLepton = (muon->BestTrk()) ? muon->BestTrk()->DzCorrected(vtx) : 0.0;
37 >  Double_t zLepton = (muon->BestTrk()) ? muon->BestTrk()->DzCorrected(*vtx) : 0.0;
38    
39    Float_t iso=0;
40    for(UInt_t ipf=0; ipf<fPFCandidates->GetEntries(); ipf++) {
# Line 46 | Line 46 | Float_t computePFMuonIso(const mithep::M
46      if(pfcand->TrackerTrk() && muon->TrackerTrk() && (pfcand->TrackerTrk()==muon->TrackerTrk())) continue;
47      
48      // dz cut
49 <    Double_t dz = (pfcand->BestTrk()) ? fabs(pfcand->BestTrk()->DzCorrected(vtx) - zLepton) : 0;
49 >    Double_t dz = (pfcand->BestTrk()) ? fabs(pfcand->BestTrk()->DzCorrected(*vtx) - zLepton) : 0;
50      if(dz >= dzMax) continue;
51      
52      // check iso cone
# Line 60 | Line 60 | Float_t computePFMuonIso(const mithep::M
60  
61   //--------------------------------------------------------------------------------------------------
62   Float_t computePFEleIso(const mithep::Electron *electron,
63 <                        const mithep::Vertex & fVertex,
63 >                        const mithep::Vertex * fVertex,
64                          const mithep::Array<mithep::PFCandidate> * fPFCandidates,
65                          const Double_t dRMax)
66   //--------------------------------------------------------------------------------------------------
# Line 69 | Line 69 | Float_t computePFEleIso(const mithep::El
69    const Double_t neuPtMin = 1.0;
70    const Double_t dzMax    = 0.1;
71      
72 <  Double_t zLepton = (electron->BestTrk()) ? electron->BestTrk()->DzCorrected(fVertex) : 0.0;
72 >  Double_t zLepton = (electron->BestTrk()) ? electron->BestTrk()->DzCorrected(*fVertex) : 0.0;
73    
74    Float_t iso=0;
75    for(UInt_t ipf=0; ipf<fPFCandidates->GetEntries(); ipf++) {
# Line 78 | Line 78 | Float_t computePFEleIso(const mithep::El
78      if(!pfcand->HasTrk() && (pfcand->Pt()<=neuPtMin)) continue;  // pT cut on neutral particles
79      
80      // dz cut
81 <    Double_t dz = (pfcand->BestTrk()) ? fabs(pfcand->BestTrk()->DzCorrected(fVertex) - zLepton) : 0;
81 >    Double_t dz = (pfcand->BestTrk()) ? fabs(pfcand->BestTrk()->DzCorrected(*fVertex) - zLepton) : 0;
82      if(dz >= dzMax) continue;
83      
84      // remove THE electron
# Line 182 | Line 182 | bool pairwiseIsoSelection( ControlFlags
182   //--------------------------------------------------------------------------------------------------
183   SelectionStatus muonIsoSelection(ControlFlags &ctrl,
184                                   const mithep::Muon * mu,
185 <                                 const mithep::Vertex & vtx,
185 >                                 const mithep::Vertex * vtx,
186                                   const mithep::Array<mithep::PFCandidate> * fPFCandidateCol   )
187   //--------------------------------------------------------------------------------------------------
188   {
# Line 212 | Line 212 | SelectionStatus muonIsoSelection(Control
212   //--------------------------------------------------------------------------------------------------
213   SelectionStatus electronIsoSelection(ControlFlags &ctrl,
214                                       const mithep::Electron * ele,
215 <                                     const mithep::Vertex &fVertex,
215 >                                     const mithep::Vertex *fVertex,
216                                       const mithep::Array<mithep::PFCandidate> * fPFCandidates)
217   //--------------------------------------------------------------------------------------------------
218   {
# Line 227 | Line 227 | SelectionStatus electronIsoSelection(Con
227    if( ele->IsEB() && ele->Pt() < 20 && reliso > PFISO_ELE_LOOSE_EB_LOWPT ) {
228      failiso = true;
229    }
230  if(ctrl.debug) cout << "before iso check ..." << endl;
230    if( !(ele->IsEB()) && ele->Pt() > 20 && reliso > PFISO_ELE_LOOSE_EE_HIGHPT ) {
232    if(ctrl.debug) cout << "\tit fails ..." << endl;
231      failiso = true;
232    }
233    if( !(ele->IsEB()) && ele->Pt() < 20 && reliso > PFISO_ELE_LOOSE_EE_LOWPT ) {
# Line 252 | Line 250 | bool noIso(ControlFlags &, vector<Simple
250          return true;
251   }
252  
253 +
254   //--------------------------------------------------------------------------------------------------
255   SelectionStatus muonIsoMVASelection(ControlFlags &ctrl,
256                                      const mithep::Muon * mu,
257 <                                    const mithep::Vertex & vtx,
257 >                                    const mithep::Vertex * vtx,
258                                      const mithep::Array<mithep::PFCandidate> * fPFCandidates,
259                                      const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
260                                      mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
# Line 339 | Line 338 | SelectionStatus muonIsoMVASelection(Cont
338    //Loop over PF Candidates
339    //
340    for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
341 +
342 +    if( !(PFnoPUflag[k]) ) continue; // my PF no PU hack
343 +
344      const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
345  
346      Double_t deta = (mu->Eta() - pf->Eta());
347      Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(mu->Phi()),Double_t(pf->Phi()));
348      Double_t dr = mithep::MathUtils::DeltaR(mu->Phi(),mu->Eta(), pf->Phi(), pf->Eta());
349 <    if (dr > 0.5) continue;
348 <    if (dr < 0.01) continue;
349 >    if (dr > 1.0) continue;
350  
351      if (pf->HasTrackerTrk() && (pf->TrackerTrk() == mu->TrackerTrk()) ) continue;
352  
# Line 379 | Line 380 | SelectionStatus muonIsoMVASelection(Cont
380            IsLeptonFootprint = kTRUE;
381        } // loop over electrons
382        
383 <      /*
383 >      /* KH - commented for sync
384        //
385        // Check for muons
386        //
# Line 413 | Line 414 | SelectionStatus muonIsoMVASelection(Cont
414   //                            << abs(pf->TrackerTrk()->DzCorrected(vtx)) << " "
415   //                            << dr << endl;
416   //       }
417 <
417 > //       if( pf->HasGsfTrk() ) {
418 > //      if (abs(pf->GsfTrk()->DzCorrected(vtx)) > 0.2) continue;
419 > //      if( ctrl.debug ) cout << "charged:: " << pf->PFType() << " " << pf->Pt() << " "
420 > //                            << abs(pf->GsfTrk()->DzCorrected(vtx)) << " "
421 > //                            << dr << endl;
422 > //       }
423  
424        // Footprint Veto
425        if (dr < 0.1) tmpChargedIso_DR0p0To0p1 += pf->Pt();
# Line 460 | Line 466 | SelectionStatus muonIsoMVASelection(Cont
466  
467  
468    double rho = 0;
469 < //   if (!(isnan(fPUEnergyDensity->At(0)->Rho()) || isinf(fPUEnergyDensity->At(0)->Rho())))
470 < //     rho = fPUEnergyDensity->At(0)->Rho();
471 <  if (!(isnan(fPUEnergyDensity->At(0)->RhoLowEta()) || isinf(fPUEnergyDensity->At(0)->RhoLowEta())))
472 <    rho = fPUEnergyDensity->At(0)->RhoLowEta();
469 >  if (!(isnan(fPUEnergyDensity->At(0)->Rho()) || isinf(fPUEnergyDensity->At(0)->Rho())))
470 >    rho = fPUEnergyDensity->At(0)->Rho();
471 >
472 > //   if (!(isnan(fPUEnergyDensity->At(0)->RhoLowEta()) || isinf(fPUEnergyDensity->At(0)->RhoLowEta())))
473 > //     rho = fPUEnergyDensity->At(0)->RhoLowEta();
474    
475    // WARNING!!!!  
476    // hardcode for sync ...
# Line 547 | Line 554 | SelectionStatus muonIsoMVASelection(Cont
554  
555    pass = false;
556    if( mu->IsGlobalMuon() && mu->IsTrackerMuon()
557 <      && fabs(mu->Eta()) <= 1.5 && mu->Pt() <= 10 && mvaval >= MUON_ISOMVA_LOOSE_FORPFID_CUT_BIN0)   pass = true;
557 >      && fabs(mu->Eta()) <= 1.5 && mu->Pt() <= 10 && mvaval >= MUON_ISOMVA_LOOSE_FORPFID_CUT_OPT_BIN0)   pass = true;
558    else if( mu->IsGlobalMuon() && mu->IsTrackerMuon()
559 <           && fabs(mu->Eta()) <= 1.5 && mu->Pt() > 10 && mvaval >= MUON_ISOMVA_LOOSE_FORPFID_CUT_BIN1)  pass = true;
559 >           && fabs(mu->Eta()) <= 1.5 && mu->Pt() > 10 && mvaval >= MUON_ISOMVA_LOOSE_FORPFID_CUT_OPT_BIN1)  pass = true;
560    else if( mu->IsGlobalMuon() && mu->IsTrackerMuon()
561 <           && fabs(mu->Eta()) > 1.5 && mu->Pt() <= 10 && mvaval >= MUON_ISOMVA_LOOSE_FORPFID_CUT_BIN2)  pass = true;
561 >           && fabs(mu->Eta()) > 1.5 && mu->Pt() <= 10 && mvaval >= MUON_ISOMVA_LOOSE_FORPFID_CUT_OPT_BIN2)  pass = true;
562    else if( mu->IsGlobalMuon() && mu->IsTrackerMuon()
563 <           && fabs(mu->Eta()) > 1.5 && mu->Pt() > 10 && mvaval >= MUON_ISOMVA_LOOSE_FORPFID_CUT_BIN3)  pass = true;
564 <  else if( !(mu->IsGlobalMuon()) && mu->IsTrackerMuon() && mvaval >= MUON_ISOMVA_LOOSE_FORPFID_CUT_BIN4)  pass = true;
565 <  else if( mu->IsGlobalMuon() && !(mu->IsTrackerMuon()) && mvaval >= MUON_ISOMVA_LOOSE_FORPFID_CUT_BIN5)  pass = true;
563 >           && fabs(mu->Eta()) > 1.5 && mu->Pt() > 10 && mvaval >= MUON_ISOMVA_LOOSE_FORPFID_CUT_OPT_BIN3)  pass = true;
564 >  else if( !(mu->IsGlobalMuon()) && mu->IsTrackerMuon() && mvaval >= MUON_ISOMVA_LOOSE_FORPFID_CUT_OPT_BIN4)  pass = true;
565 >  else if( mu->IsGlobalMuon() && !(mu->IsTrackerMuon()) && mvaval >= MUON_ISOMVA_LOOSE_FORPFID_CUT_OPT_BIN5)  pass = true;
566    if( pass ) status.orStatus(SelectionStatus::LOOSEISO);
567  
568 +  /*
569    pass = false;
570    if( mu->IsGlobalMuon() && mu->IsTrackerMuon()
571        && fabs(mu->Eta()) <= 1.5 && mu->Pt() <= 10 && mvaval >= MUON_ISOMVA_TIGHT_FORPFID_CUT_BIN0)   pass = true;
# Line 570 | Line 578 | SelectionStatus muonIsoMVASelection(Cont
578    else if( !(mu->IsGlobalMuon()) && mu->IsTrackerMuon() && mvaval >= MUON_ISOMVA_TIGHT_FORPFID_CUT_BIN4)  pass = true;
579    else if( mu->IsGlobalMuon() && !(mu->IsTrackerMuon()) && mvaval >= MUON_ISOMVA_TIGHT_FORPFID_CUT_BIN5)  pass = true;
580    if( pass ) status.orStatus(SelectionStatus::TIGHTISO);
581 +  */
582  
583    //  pass &= (fChargedIso_DR0p0To0p1 + fChargedIso_DR0p1To0p2 + fChargedIso_DR0p2To0p3 < 0.7);
584  
585 <  if(ctrl.debug) cout << "returning status : " << hex << status.getStatus() << dec << endl;
585 >  status.isoMVA = mvaval;
586 >
587 >  if(ctrl.debug)  {
588 >    cout << "returning status : " << hex << status.getStatus() << dec << endl;
589 >    cout << "MVAVAL : " << status.isoMVA << endl;
590 >  }
591    return status;
592  
593   }
# Line 582 | Line 596 | SelectionStatus muonIsoMVASelection(Cont
596   //--------------------------------------------------------------------------------------------------
597   SelectionStatus muonIsoMVASelection(ControlFlags &ctrl,
598                                      const mithep::Muon * mu,
599 <                                    const mithep::Vertex & vtx,
599 >                                    const mithep::Vertex * vtx,
600                                      const mithep::Array<mithep::PFCandidate> * fPFCandidates,
601                                      float rho,
602                                      //const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
# Line 939 | Line 953 | void initMuonIsoMVA() {
953   }
954  
955  
956 +
957 +
958   //--------------------------------------------------------------------------------------------------
959   double  muonPFIso04(ControlFlags &ctrl,
960                      const mithep::Muon * mu,
961 <                    const mithep::Vertex & vtx,
961 >                    const mithep::Vertex * vtx,
962                      const mithep::Array<mithep::PFCandidate> * fPFCandidates,
963                      const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
964                      mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
# Line 950 | Line 966 | double  muonPFIso04(ControlFlags &ctrl,
966                      vector<const mithep::Electron*> electronsToVeto)
967   //--------------------------------------------------------------------------------------------------
968   {
969 +
970 +  extern double gChargedIso;  
971 +  extern double  gGammaIso;      
972 +  extern double  gNeutralIso;
973    
974    if( ctrl.debug ) {
975      cout << "muonIsoMVASelection :: muons to veto " << endl;
# Line 981 | Line 1001 | double  muonPFIso04(ControlFlags &ctrl,
1001    //Loop over PF Candidates
1002    //
1003    for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
1004 +
1005 +    if( !(PFnoPUflag[k]) ) continue; // my PF no PU hack
1006      const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
1007  
1008      Double_t deta = (mu->Eta() - pf->Eta());
# Line 1012 | Line 1034 | double  muonPFIso04(ControlFlags &ctrl,
1034          }
1035          // PF charged
1036          if (pf->Charge() != 0 && fabs(tmpele->SCluster()->Eta()) > 1.479
1037 <            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.015)
1037 >            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.015) {
1038 >          if( ctrl.debug) cout << "\tcharged trk, dR ("
1039 >                               << mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta())
1040 >                               << " matches 4L ele ..." << endl;
1041            IsLeptonFootprint = kTRUE;
1042 +        }
1043          // PF gamma
1044          if (abs(pf->PFType()) == PFCandidate::eGamma && fabs(tmpele->SCluster()->Eta()) > 1.479
1045              && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.08)
1046            IsLeptonFootprint = kTRUE;
1047        } // loop over electrons
1048  
1049 <      // KH, comment to sync
1024 <      /*
1049 >      /* KH - comment for sync      
1050        //
1051        // Check for muons
1052        //
# Line 1044 | Line 1069 | double  muonPFIso04(ControlFlags &ctrl,
1069      //
1070      // Charged Iso
1071      //
1072 <    if (pf->Charge() != 0 ) {
1072 >    if (pf->Charge() != 0 && (pf->HasTrackerTrk()||pf->HasGsfTrk()) ) {
1073  
1074        //if( dr < 0.01 ) continue; // only for muon iso mva?
1075        if (abs(pf->PFType()) == PFCandidate::eElectron || abs(pf->PFType()) == PFCandidate::eMuon) continue;
1076  
1077 <      if( pf->HasTrackerTrk() ) {
1078 <        if (abs(pf->TrackerTrk()->DzCorrected(vtx)) > 0.2) continue;
1079 <        if( ctrl.debug ) cout << "charged:: " << pf->PFType() << " " << pf->Pt() << " "
1080 <                              << abs(pf->TrackerTrk()->DzCorrected(vtx)) << " "
1081 <                              << dr << endl;
1082 <      }
1083 <      if( pf->HasGsfTrk() ) {
1084 <        if (abs(pf->GsfTrk()->DzCorrected(vtx)) > 0.2) continue;
1085 <        if( ctrl.debug ) cout << "charged:: " << pf->PFType() << " " << pf->Pt() << " "
1086 <                              << abs(pf->GsfTrk()->DzCorrected(vtx)) << " "
1087 <                              << dr << endl;
1088 <      }
1077 >
1078 > //       if( pf->HasTrackerTrk() ) {
1079 > //      if (abs(pf->TrackerTrk()->DzCorrected(vtx)) > 0.2) continue;
1080 > //      if( ctrl.debug ) cout << "charged:: " << pf->PFType() << " " << pf->Pt() << " "
1081 > //                            << abs(pf->TrackerTrk()->DzCorrected(vtx)) << " "
1082 > //                            << dr << endl;
1083 > //       }
1084 > //       if( pf->HasGsfTrk() ) {
1085 > //      if (abs(pf->GsfTrk()->DzCorrected(vtx)) > 0.2) continue;
1086 > //      if( ctrl.debug ) cout << "charged:: " << pf->PFType() << " " << pf->Pt() << " "
1087 > //                            << abs(pf->GsfTrk()->DzCorrected(vtx)) << " "
1088 > //                            << dr << endl;
1089 > //       }
1090  
1091  
1092        fChargedIso += pf->Pt();
# Line 1087 | Line 1113 | double  muonPFIso04(ControlFlags &ctrl,
1113      }
1114      
1115    }
1090  
1091  double rho = 0;
1092  //   if (!(isnan(fPUEnergyDensity->At(0)->Rho()) || isinf(fPUEnergyDensity->At(0)->Rho())))
1093  //     rho = fPUEnergyDensity->At(0)->Rho();
1094  if (!(isnan(fPUEnergyDensity->At(0)->RhoLowEta()) || isinf(fPUEnergyDensity->At(0)->RhoLowEta())))
1095    rho = fPUEnergyDensity->At(0)->RhoLowEta();
1096
1097  // WARNING!!!!  
1098  // hardcode for sync ...
1099  EffectiveAreaVersion = muT.kMuEAData2011;
1100  // WARNING!!!!  
1116  
1117 +  double rho=0;
1118 +  if( (EffectiveAreaVersion == mithep::MuonTools::kMuEAFall11MC) ||
1119 +      (EffectiveAreaVersion == mithep::MuonTools::kMuEAData2011) ) {
1120 +    if (!(isnan(fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25()) ||
1121 +          isinf(fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25())))
1122 +      rho = fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25();
1123 +    //rho = fPUEnergyDensity->At(0)->Rho();
1124 +    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
1125 +    EffectiveAreaVersion  = mithep::MuonTools::kMuEAData2011;
1126 +    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
1127 +  } else {
1128 +    if (!(isnan(fPUEnergyDensity->At(0)->RhoKt6PFJetsCentralNeutral()) ||
1129 +          isinf(fPUEnergyDensity->At(0)->RhoKt6PFJetsCentralNeutral())))
1130 +      rho = fPUEnergyDensity->At(0)->RhoKt6PFJetsCentralNeutral();
1131 +    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
1132 +    EffectiveAreaVersion  = mithep::MuonTools::kMuEAData2012;
1133 +    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
1134 +  }
1135 +  if(ctrl.debug) cout << "rho: " << rho << endl;
1136  
1137    double pfIso = fChargedIso + fmax(0.0,(fGammaIso + fNeutralHadronIso
1138                                          -rho*muT.MuonEffectiveArea(muT.kMuGammaAndNeutralHadronIso04,
1139                                                                     mu->Eta(),EffectiveAreaVersion)));
1106
1140    gChargedIso = fChargedIso;
1141 <  gGammaIso = fGammaIso;
1142 <  gNeutralIso = fNeutralHadronIso;  
1141 >  gGammaIso   = fGammaIso;
1142 >  gNeutralIso = fNeutralHadronIso;
1143 >  
1144    return pfIso;
1145   }
1146  
1147  
1148 +
1149 +
1150   //--------------------------------------------------------------------------------------------------
1151   // hacked version
1152   double  muonPFIso04(ControlFlags &ctrl,
1153                      const mithep::Muon * mu,
1154 <                    const mithep::Vertex & vtx,
1154 >                    const mithep::Vertex * vtx,
1155                      const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1156                      float rho,
1157                      mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
# Line 1291 | Line 1327 | double  muonPFIso04(ControlFlags &ctrl,
1327   //--------------------------------------------------------------------------------------------------
1328   SelectionStatus muonReferenceIsoSelection(ControlFlags &ctrl,
1329                                            const mithep::Muon * mu,
1330 <                                          const mithep::Vertex & vtx,
1330 >                                          const mithep::Vertex * vtx,
1331                                            const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1332                                            const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
1333                                            mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
# Line 1327 | Line 1363 | SelectionStatus muonReferenceIsoSelectio
1363   // hacked version
1364   SelectionStatus muonReferenceIsoSelection(ControlFlags &ctrl,
1365                                            const mithep::Muon * mu,
1366 <                                          const mithep::Vertex & vtx,
1366 >                                          const mithep::Vertex * vtx,
1367                                            const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1368                                            float rho,
1369                                            mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
# Line 1360 | Line 1396 | SelectionStatus muonReferenceIsoSelectio
1396  
1397  
1398  
1399 +
1400   //--------------------------------------------------------------------------------------------------
1401   SelectionStatus electronIsoMVASelection(ControlFlags &ctrl,
1402                                          const mithep::Electron * ele,
1403 <                                        const mithep::Vertex & vtx,
1403 >                                        const mithep::Vertex * vtx,
1404                                          const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1405                                          const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
1406                                          mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
# Line 1402 | Line 1439 | SelectionStatus electronIsoMVASelection(
1439    Double_t tmpChargedIso_DR0p2To0p3  = 0;
1440    Double_t tmpChargedIso_DR0p3To0p4  = 0;
1441    Double_t tmpChargedIso_DR0p4To0p5  = 0;
1405  Double_t tmpChargedIso_DR0p5To0p7  = 0;
1442  
1443    Double_t tmpGammaIso_DR0p0To0p1  = 0;
1444    Double_t tmpGammaIso_DR0p1To0p2  = 0;
1445    Double_t tmpGammaIso_DR0p2To0p3  = 0;
1446    Double_t tmpGammaIso_DR0p3To0p4  = 0;
1447    Double_t tmpGammaIso_DR0p4To0p5  = 0;
1448 <  Double_t tmpGammaIso_DR0p5To0p7  = 0;
1448 >
1449  
1450    Double_t tmpNeutralHadronIso_DR0p0To0p1  = 0;
1451    Double_t tmpNeutralHadronIso_DR0p1To0p2  = 0;
1452    Double_t tmpNeutralHadronIso_DR0p2To0p3  = 0;
1453    Double_t tmpNeutralHadronIso_DR0p3To0p4  = 0;
1454    Double_t tmpNeutralHadronIso_DR0p4To0p5  = 0;
1419  Double_t tmpNeutralHadronIso_DR0p5To0p7  = 0;
1455  
1456          
1457  
# Line 1453 | Line 1488 | SelectionStatus electronIsoMVASelection(
1488      Double_t deta = (ele->Eta() - pf->Eta());
1489      Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(ele->Phi()),Double_t(pf->Phi()));
1490      Double_t dr = mithep::MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta());
1491 <    if (dr > 0.5) continue;
1491 >    if (dr > 1.0) continue;
1492 >
1493      if(ctrl.debug) {
1494        cout << "pf :: type: " << pf->PFType() << "\tpt: " << pf->Pt();
1495 <      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(vtx);
1495 >      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(*vtx);
1496        cout << endl;
1497      }
1498  
# Line 1471 | Line 1507 | SelectionStatus electronIsoMVASelection(
1507      Bool_t IsLeptonFootprint = kFALSE;
1508      if (dr < 1.0) {
1509  
1510 +
1511        //
1512        // Check for electrons
1513        //
1514 +
1515        for (Int_t q=0; q < electronsToVeto.size(); ++q) {
1516          const mithep::Electron *tmpele = electronsToVeto[q];
1517 +        double tmpdr = mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta());
1518 +
1519          // 4l electron
1520          if( pf->HasTrackerTrk()  ) {
1521            if( pf->TrackerTrk() == tmpele->TrackerTrk() ) {
# Line 1490 | Line 1530 | SelectionStatus electronIsoMVASelection(
1530            }
1531          }
1532          // PF charged
1533 <        if (pf->Charge() != 0 && fabs(tmpele->SCluster()->Eta()) >= 1.479
1494 <            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.015) {
1533 >        if (pf->Charge() != 0 && fabs(tmpele->SCluster()->Eta()) >= 1.479 && tmpdr < 0.015) {
1534            if( ctrl.debug) cout << "\tcharged trk, dR matches 4L ele ..." << endl;
1535            IsLeptonFootprint = kTRUE;
1536          }
1537          // PF gamma
1538          if (abs(pf->PFType()) == PFCandidate::eGamma && fabs(tmpele->SCluster()->Eta()) >= 1.479
1539 <            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.08) {
1539 >            && tmpdr < 0.08) {
1540            if( ctrl.debug) cout << "\tPF gamma, matches 4L ele ..." << endl;
1541            IsLeptonFootprint = kTRUE;
1542          }
1543        } // loop over electrons
1544  
1545 +
1546        /* KH - comment for sync            
1547        //
1548        // Check for muons
# Line 1553 | Line 1593 | SelectionStatus electronIsoMVASelection(
1593        if (dr >= 0.2 && dr < 0.3) tmpChargedIso_DR0p2To0p3 += pf->Pt();
1594        if (dr >= 0.3 && dr < 0.4) tmpChargedIso_DR0p3To0p4 += pf->Pt();
1595        if (dr >= 0.4 && dr < 0.5) tmpChargedIso_DR0p4To0p5 += pf->Pt();
1556      if (dr >= 0.5 && dr < 0.7) tmpChargedIso_DR0p5To0p7 += pf->Pt();
1596  
1597      }
1598  
# Line 1562 | Line 1601 | SelectionStatus electronIsoMVASelection(
1601      //
1602      else if (abs(pf->PFType()) == PFCandidate::eGamma) {
1603  
1604 <      if (fabs(ele->SCluster()->Eta()) > 1.479) {
1566 <        if (mithep::MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta()) < 0.08) continue;
1567 <      }
1604 >      if (fabs(ele->SCluster()->Eta()) > 1.479 && dr < 0.08) continue;
1605  
1606        if( ctrl.debug) cout << "gamma:: " << pf->Pt() << " "
1607                             << dr << endl;
# Line 1574 | Line 1611 | SelectionStatus electronIsoMVASelection(
1611        if (dr >= 0.2 && dr < 0.3) tmpGammaIso_DR0p2To0p3 += pf->Pt();
1612        if (dr >= 0.3 && dr < 0.4) tmpGammaIso_DR0p3To0p4 += pf->Pt();
1613        if (dr >= 0.4 && dr < 0.5) tmpGammaIso_DR0p4To0p5 += pf->Pt();
1577      if (dr >= 0.5 && dr < 0.7) tmpGammaIso_DR0p5To0p7 += pf->Pt();
1578
1614      }
1615  
1616      //
# Line 1589 | Line 1624 | SelectionStatus electronIsoMVASelection(
1624        if (dr >= 0.2 && dr < 0.3) tmpNeutralHadronIso_DR0p2To0p3 += pf->Pt();
1625        if (dr >= 0.3 && dr < 0.4) tmpNeutralHadronIso_DR0p3To0p4 += pf->Pt();
1626        if (dr >= 0.4 && dr < 0.5) tmpNeutralHadronIso_DR0p4To0p5 += pf->Pt();
1592      if (dr >= 0.5 && dr < 0.7) tmpNeutralHadronIso_DR0p5To0p7 += pf->Pt();
1627      }
1628  
1629      }
# Line 1602 | Line 1636 | SelectionStatus electronIsoMVASelection(
1636    fChargedIso_DR0p3To0p4   = fmin((tmpChargedIso_DR0p3To0p4)/ele->Pt(), 2.5);
1637    fChargedIso_DR0p4To0p5   = fmin((tmpChargedIso_DR0p4To0p5)/ele->Pt(), 2.5);
1638  
1639 <  double rho = 0;
1640 < //   if (!(isnan(fPUEnergyDensity->At(0)->Rho()) || isinf(fPUEnergyDensity->At(0)->Rho())))
1641 < //     rho = fPUEnergyDensity->At(0)->Rho();
1642 <  if (!(isnan(fPUEnergyDensity->At(0)->RhoLowEta()) || isinf(fPUEnergyDensity->At(0)->RhoLowEta())))
1643 <    rho = fPUEnergyDensity->At(0)->RhoLowEta();
1639 >  if(ctrl.debug) {
1640 >    cout << "fChargedIso_DR0p0To0p1 : " << fChargedIso_DR0p0To0p1  << endl;
1641 >    cout << "fChargedIso_DR0p1To0p2 : " << fChargedIso_DR0p1To0p2  << endl;
1642 >    cout << "fChargedIso_DR0p2To0p3 : " << fChargedIso_DR0p2To0p3  << endl;
1643 >    cout << "fChargedIso_DR0p3To0p4 : " << fChargedIso_DR0p3To0p4  << endl;
1644 >    cout << "fChargedIso_DR0p4To0p5 : " << fChargedIso_DR0p4To0p5  << endl;
1645 >  }
1646 >
1647  
1648 +  double rho = 0;
1649 +  if (!(isnan(fPUEnergyDensity->At(0)->Rho()) || isinf(fPUEnergyDensity->At(0)->Rho())))
1650 +    rho = fPUEnergyDensity->At(0)->Rho();
1651 +  //   if (!(isnan(fPUEnergyDensity->At(0)->RhoLowEta()) || isinf(fPUEnergyDensity->At(0)->RhoLowEta())))
1652 +  //     rho = fPUEnergyDensity->At(0)->RhoLowEta();
1653 +  
1654    // WARNING!!!!  
1655    // hardcode for sync ...
1656 <  //  EffectiveAreaVersion = eleT.kEleEAData2011;
1614 <  EffectiveAreaVersion = eleT.kEleEAFall11MC;
1656 >  EffectiveAreaVersion = eleT.kEleEAData2011;
1657    // WARNING!!!!  
1658  
1659    if( ctrl.debug) {
# Line 1668 | Line 1710 | SelectionStatus electronIsoMVASelection(
1710                               ,0.0);
1711  
1712  
1713 +  if( ctrl.debug) {
1714 +    cout << "fGammaIso_DR0p0To0p1: " << fGammaIso_DR0p0To0p1 << endl;
1715 +    cout << "fGammaIso_DR0p1To0p2: " << fGammaIso_DR0p1To0p2 << endl;
1716 +    cout << "fGammaIso_DR0p2To0p3: " << fGammaIso_DR0p2To0p3 << endl;
1717 +    cout << "fGammaIso_DR0p3To0p4: " << fGammaIso_DR0p3To0p4 << endl;
1718 +    cout << "fGammaIso_DR0p4To0p5: " << fGammaIso_DR0p4To0p5 << endl;
1719 +  }
1720 +
1721    fNeutralHadronIso_DR0p0To0p1 = fmax(fmin((tmpNeutralHadronIso_DR0p0To0p1
1722                                            -rho*eleT.ElectronEffectiveArea(eleT.kEleNeutralHadronIsoDR0p0To0p1,
1723                                                                   ele->SCluster()->Eta(),EffectiveAreaVersion))/ele->Pt()
# Line 1694 | Line 1744 | SelectionStatus electronIsoMVASelection(
1744                                           , 2.5)
1745                                       , 0.0);
1746  
1747 +  if( ctrl.debug) {
1748 +    cout << "fNeutralHadronIso_DR0p0To0p1: " << fNeutralHadronIso_DR0p0To0p1 << endl;
1749 +    cout << "fNeutralHadronIso_DR0p1To0p2: " << fNeutralHadronIso_DR0p1To0p2 << endl;
1750 +    cout << "fNeutralHadronIso_DR0p2To0p3: " << fNeutralHadronIso_DR0p2To0p3 << endl;
1751 +    cout << "fNeutralHadronIso_DR0p3To0p4: " << fNeutralHadronIso_DR0p3To0p4 << endl;
1752 +    cout << "fNeutralHadronIso_DR0p4To0p5: " << fNeutralHadronIso_DR0p4To0p5 << endl;
1753 +  }
1754 +
1755    double mvaval = eleIsoMVA->MVAValue_IsoRings( ele->Pt(),
1756                                                  ele->SCluster()->Eta(),
1757                                                  fChargedIso_DR0p0To0p1,
# Line 1714 | Line 1772 | SelectionStatus electronIsoMVASelection(
1772                                                  ctrl.debug);
1773  
1774    SelectionStatus status;
1775 +  status.isoMVA = mvaval;
1776    bool pass = false;
1777  
1778    Int_t subdet = 0;
1779    if (fabs(ele->SCluster()->Eta()) < 0.8) subdet = 0;
1780    else if (fabs(ele->SCluster()->Eta()) < 1.479) subdet = 1;
1781    else subdet = 2;
1782 +
1783    Int_t ptBin = 0;
1784 <  if (ele->Pt() > 10.0) ptBin = 1;
1784 >  if (ele->Pt() >= 10.0) ptBin = 1;
1785    
1786    Int_t MVABin = -1;
1787    if (subdet == 0 && ptBin == 0) MVABin = 0;
# Line 1732 | Line 1792 | SelectionStatus electronIsoMVASelection(
1792    if (subdet == 2 && ptBin == 1) MVABin = 5;
1793  
1794    pass = false;
1795 <  if( MVABin == 0 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_BIN0 ) pass = true;
1796 <  if( MVABin == 1 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_BIN1 ) pass = true;
1797 <  if( MVABin == 2 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_BIN2 ) pass = true;
1798 <  if( MVABin == 3 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_BIN3 ) pass = true;
1799 <  if( MVABin == 4 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_BIN4 ) pass = true;
1800 <  if( MVABin == 5 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_BIN5 ) pass = true;
1795 >  if( MVABin == 0 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_OPT_BIN0 ) pass = true;
1796 >  if( MVABin == 1 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_OPT_BIN1 ) pass = true;
1797 >  if( MVABin == 2 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_OPT_BIN2 ) pass = true;
1798 >  if( MVABin == 3 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_OPT_BIN3 ) pass = true;
1799 >  if( MVABin == 4 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_OPT_BIN4 ) pass = true;
1800 >  if( MVABin == 5 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_OPT_BIN5 ) pass = true;
1801 >  //  pass &= (fChargedIso_DR0p0To0p1 + fChargedIso_DR0p1To0p2 + fChargedIso_DR0p2To0p3 < 0.7);
1802    if( pass ) status.orStatus(SelectionStatus::LOOSEISO);
1803  
1804   //   pass = false;
# Line 1755 | Line 1816 | SelectionStatus electronIsoMVASelection(
1816   }
1817  
1818  
1758
1819   //--------------------------------------------------------------------------------------------------
1820   SelectionStatus electronIsoMVASelection(ControlFlags &ctrl,
1821                                          const mithep::Electron * ele,
1822 <                                        const mithep::Vertex & vtx,
1822 >                                        const mithep::Vertex * vtx,
1823                                          const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1824                                          float rho,
1825                                          //const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
# Line 1856 | Line 1916 | SelectionStatus electronIsoMVASelection(
1916  
1917      if(ctrl.debug) {
1918        cout << "pf :: type: " << pf->PFType() << "\tpt: " << pf->Pt();
1919 <      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(vtx);
1919 >      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(*vtx);
1920        cout << endl;
1921      }
1922  
# Line 2196 | Line 2256 | void initElectronIsoMVA() {
2256  
2257  
2258  
2259 +
2260   //--------------------------------------------------------------------------------------------------
2261   float electronPFIso04(ControlFlags &ctrl,
2262 <                                const mithep::Electron * ele,
2263 <                                const mithep::Vertex & vtx,
2264 <                                const mithep::Array<mithep::PFCandidate> * fPFCandidates,
2265 <                                const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
2266 <                                mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
2267 <                                vector<const mithep::Muon*> muonsToVeto,
2268 <                                vector<const mithep::Electron*> electronsToVeto)
2262 >                      const mithep::Electron * ele,
2263 >                      const mithep::Vertex * vtx,
2264 >                      const mithep::Array<mithep::PFCandidate> * fPFCandidates,
2265 >                      const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
2266 >                      mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
2267 >                      vector<const mithep::Muon*> muonsToVeto,
2268 >                      vector<const mithep::Electron*> electronsToVeto)
2269   //--------------------------------------------------------------------------------------------------
2270   {
2271 <
2271 >  /*
2272    if( ctrl.debug ) {
2273      cout << "electronIsoMVASelection :: muons to veto " << endl;
2274      for( int i=0; i<muonsToVeto.size(); i++ ) {
# Line 2217 | Line 2278 | float electronPFIso04(ControlFlags &ctrl
2278             << "\tphi: " << vmu->Phi()
2279             << endl;
2280      }
2281 <    cout << "electronIsoMVASelection :: electrson to veto " << endl;
2281 >    cout << "electronIsoMVASelection :: electrons to veto " << endl;
2282      for( int i=0; i<electronsToVeto.size(); i++ ) {
2283        const mithep::Electron * vel = electronsToVeto[i];
2284        cout << "\tpt: " << vel->Pt()
# Line 2227 | Line 2288 | float electronPFIso04(ControlFlags &ctrl
2288             << endl;
2289      }
2290    }
2291 <
2291 >  */
2292  
2293    //
2294    // final iso
# Line 2241 | Line 2302 | float electronPFIso04(ControlFlags &ctrl
2302    //Loop over PF Candidates
2303    //
2304    for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2305 +
2306 +
2307      const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
2308      Double_t deta = (ele->Eta() - pf->Eta());
2309      Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(ele->Phi()),Double_t(pf->Phi()));
2310      Double_t dr = mithep::MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta());
2311 <    if (dr >= 0.4) continue;
2311 >
2312 >    if (dr > 0.4) continue;
2313 >    if( !(PFnoPUflag[k]) ) continue; // my PF no PU hack
2314 >
2315      if(ctrl.debug) {
2316 <      cout << "pf :: type: " << pf->PFType() << "\tpt: " << pf->Pt();
2317 <      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(vtx);
2316 >      cout << "pf :: type: " << pf->PFType() << "\tpt: " << pf->Pt() << "\tdR: " << dr;
2317 >      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(*vtx)
2318 >                                     << "\ttrk: " << pf->HasTrackerTrk()
2319 >                                     << "\tgsf: " << pf->HasGsfTrk();
2320 >      
2321        cout << endl;
2322      }
2323  
2324  
2325 <    if ( (pf->HasTrackerTrk() && (pf->TrackerTrk() == ele->TrackerTrk())) ||
2326 <         (pf->HasGsfTrk() && (pf->GsfTrk() == ele->GsfTrk()))) continue;
2327 <    
2325 >    //
2326 >    // sync : I don't think theyre doing this ...
2327 >    //
2328 >    //     if ( (pf->HasTrackerTrk() && (pf->TrackerTrk() == ele->TrackerTrk())) ||
2329 >    //   (pf->HasGsfTrk() && (pf->GsfTrk() == ele->GsfTrk()))) {
2330 >    //       if( ctrl.debug ) cout << "\tskipping, matches to the electron ..."  << endl;
2331 >    //       continue;
2332 >    //     }
2333 >
2334  
2335      //
2336      // Lepton Footprint Removal
# Line 2268 | Line 2343 | float electronPFIso04(ControlFlags &ctrl
2343        //
2344        for (Int_t q=0; q < electronsToVeto.size(); ++q) {
2345          const mithep::Electron *tmpele = electronsToVeto[q];
2346 +        /*
2347          // 4l electron
2348          if( pf->HasTrackerTrk()  ) {
2349            if( pf->TrackerTrk() == tmpele->TrackerTrk() ) {
# Line 2281 | Line 2357 | float electronPFIso04(ControlFlags &ctrl
2357              IsLeptonFootprint = kTRUE;
2358            }
2359          }
2360 +        */
2361          // PF charged
2362          if (pf->Charge() != 0 && fabs(tmpele->SCluster()->Eta()) > 1.479
2363              && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.015) {
# Line 2295 | Line 2372 | float electronPFIso04(ControlFlags &ctrl
2372          }
2373        } // loop over electrons
2374  
2375 <
2375 >      /* KH - comment for sync            
2376        //
2377        // Check for muons
2378        //
# Line 2314 | Line 2391 | float electronPFIso04(ControlFlags &ctrl
2391            IsLeptonFootprint = kTRUE;
2392          }
2393        } // loop over muons
2394 <
2394 >      */
2395  
2396      if (IsLeptonFootprint)
2397        continue;
# Line 2322 | Line 2399 | float electronPFIso04(ControlFlags &ctrl
2399      //
2400      // Charged Iso
2401      //
2402 <    if (pf->Charge() != 0 ) {
2402 >    if (pf->Charge() != 0 && (pf->HasTrackerTrk()||pf->HasGsfTrk()) ) {
2403  
2404 <      if( pf->HasTrackerTrk() )
2405 <        if (abs(pf->TrackerTrk()->DzCorrected(vtx)) > 0.2) continue;
2406 <      if( pf->HasGsfTrk() )
2407 <        if (abs(pf->GsfTrk()->DzCorrected(vtx)) > 0.2) continue;
2404 > //       if( pf->HasTrackerTrk() )
2405 > //      if (abs(pf->TrackerTrk()->DzCorrected(vtx)) > 0.2) continue;
2406 > //       if( pf->HasGsfTrk() )
2407 > //      if (abs(pf->GsfTrk()->DzCorrected(vtx)) > 0.2) continue;
2408  
2409        // Veto any PFmuon, or PFEle
2410 <      if (abs(pf->PFType()) == PFCandidate::eElectron || abs(pf->PFType()) == PFCandidate::eMuon) continue;
2410 >      if (abs(pf->PFType()) == PFCandidate::eElectron || abs(pf->PFType()) == PFCandidate::eMuon) {
2411 >        if( ctrl.debug ) cout << "\t skipping, pf is and ele or mu .." <<endl;
2412 >        continue;
2413 >      }
2414  
2415        // Footprint Veto
2416        if (fabs(ele->SCluster()->Eta()) > 1.479 && dr < 0.015) continue;
# Line 2353 | Line 2433 | float electronPFIso04(ControlFlags &ctrl
2433        if( ctrl.debug) cout << "gamma:: " << pf->Pt() << " "
2434                             << dr << endl;
2435        // KH, add to sync
2436 <      //      if( pf->Pt() > 0.5 )
2436 >      //      if( pf->Pt() > 0.5 )
2437          fGammaIso += pf->Pt();
2438      }
2439  
# Line 2364 | Line 2444 | float electronPFIso04(ControlFlags &ctrl
2444        if( ctrl.debug) cout << "neutral:: " << pf->Pt() << " "
2445                             << dr << endl;
2446        // KH, add to sync
2447 <      //      if( pf->Pt() > 0.5 )
2447 >      //      if( pf->Pt() > 0.5 )
2448          fNeutralHadronIso += pf->Pt();
2449      }
2450  
# Line 2372 | Line 2452 | float electronPFIso04(ControlFlags &ctrl
2452  
2453    }
2454  
2375  double rho = 0;
2376 //   if (!(isnan(fPUEnergyDensity->At(0)->Rho()) || isinf(fPUEnergyDensity->At(0)->Rho())))
2377 //     rho = fPUEnergyDensity->At(0)->Rho();
2378  if (!(isnan(fPUEnergyDensity->At(0)->RhoLowEta()) || isinf(fPUEnergyDensity->At(0)->RhoLowEta())))
2379    rho = fPUEnergyDensity->At(0)->RhoLowEta();
2380
2381  // WARNING!!!!  
2382  // hardcode for sync ...
2383  EffectiveAreaVersion = eleT.kEleEAData2011;
2384  // WARNING!!!!  
2455  
2456 +  double rho=0;
2457 +  if( (EffectiveAreaVersion == mithep::ElectronTools::kEleEAFall11MC) ||
2458 +      (EffectiveAreaVersion == mithep::ElectronTools::kEleEAData2011) ) {
2459 +    if (!(isnan(fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25()) ||
2460 +          isinf(fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25())))
2461 +      rho = fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25();
2462 +    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
2463 +    EffectiveAreaVersion  = mithep::ElectronTools::kEleEAData2011;
2464 +    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
2465 +  } else {
2466 +    if (!(isnan(fPUEnergyDensity->At(0)->RhoKt6PFJets()) ||
2467 +          isinf(fPUEnergyDensity->At(0)->RhoKt6PFJets())))
2468 +      rho = fPUEnergyDensity->At(0)->RhoKt6PFJets();
2469 +    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
2470 +    EffectiveAreaVersion  = mithep::ElectronTools::kEleEAData2012;
2471 +    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
2472 +  }
2473 +  if(ctrl.debug) cout << "rho: " << rho << endl;
2474  
2475    double pfIso = fChargedIso + fmax(0.0,(fGammaIso + fNeutralHadronIso
2476                                          -rho*eleT.ElectronEffectiveArea(eleT.kEleGammaAndNeutralHadronIso04,
2477                                                                     ele->Eta(),EffectiveAreaVersion)));
2478  
2479 +
2480    gChargedIso = fChargedIso;
2481    gGammaIso = fGammaIso;
2482    gNeutralIso = fNeutralHadronIso;  
2394
2483    return pfIso;
2484   }
2485  
2486 +
2487 +
2488   //--------------------------------------------------------------------------------------------------
2489   // hacked version
2490   float electronPFIso04(ControlFlags &ctrl,
2491                        const mithep::Electron * ele,
2492 <                      const mithep::Vertex & vtx,
2492 >                      const mithep::Vertex * vtx,
2493                        const mithep::Array<mithep::PFCandidate> * fPFCandidates,
2494                        float rho,
2495                        mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
# Line 2453 | Line 2543 | float electronPFIso04(ControlFlags &ctrl
2543  
2544      if(ctrl.debug) {
2545        cout << "pf :: type: " << pf->PFType() << "\tpt: " << pf->Pt() << "\tdR: " << dr;
2546 <      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(vtx)
2546 >      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(*vtx)
2547                                       << "\ttrk: " << pf->HasTrackerTrk()
2548                                       << "\tgsf: " << pf->HasGsfTrk();
2549        
# Line 2547 | Line 2637 | float electronPFIso04(ControlFlags &ctrl
2637  
2638        // Veto any PFmuon, or PFEle
2639        if (abs(pf->PFType()) == PFCandidate::eElectron || abs(pf->PFType()) == PFCandidate::eMuon) {
2640 <         cout << "\t skipping, pf is and ele or mu .." <<endl;
2640 >        if( ctrl.debug ) cout << "\t skipping, pf is and ele or mu .." <<endl;
2641          continue;
2642        }
2643  
# Line 2616 | Line 2706 | float electronPFIso04(ControlFlags &ctrl
2706   //--------------------------------------------------------------------------------------------------
2707   SelectionStatus electronReferenceIsoSelection(ControlFlags &ctrl,
2708                                                const mithep::Electron * ele,
2709 <                                              const mithep::Vertex & vtx,
2709 >                                              const mithep::Vertex * vtx,
2710                                                const mithep::Array<mithep::PFCandidate> * fPFCandidates,
2711                                                const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
2712                                                mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
# Line 2652 | Line 2742 | SelectionStatus electronReferenceIsoSele
2742   // hacked version
2743   SelectionStatus electronReferenceIsoSelection(ControlFlags &ctrl,
2744                                                const mithep::Electron * ele,
2745 <                                              const mithep::Vertex & vtx,
2745 >                                              const mithep::Vertex * vtx,
2746                                                const mithep::Array<mithep::PFCandidate> * fPFCandidates,
2747                                                float rho,
2748                                                mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
# Line 2680 | Line 2770 | SelectionStatus electronReferenceIsoSele
2770    return status;
2771  
2772   }
2773 +
2774 +
2775 +
2776 + //--------------------------------------------------------------------------------------------------
2777 + double  dbetaCorrectedIsoDr03(ControlFlags & ctrl,
2778 +                              const mithep::PFCandidate * photon,
2779 +                              const mithep::Muon * lepton,
2780 +                              const mithep::Array<mithep::PFCandidate> * fPFCandidates)
2781 + //--------------------------------------------------------------------------------------------------
2782 + {
2783 +
2784 +  //
2785 +  // final iso
2786 +  //
2787 +  Double_t fChargedIso  = 0.0;
2788 +  Double_t fGammaIso  = 0.0;
2789 +  Double_t fNeutralHadronIso  = 0.0;
2790 +  Double_t fpfPU  = 0.0;
2791 +
2792 +  //
2793 +  // Loop over PF Candidates
2794 +  //
2795 +  for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2796 +
2797 +    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
2798 +    
2799 +    Double_t deta = (photon->Eta() - pf->Eta());
2800 +    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(photon->Phi()),Double_t(pf->Phi()));
2801 +    Double_t dr = mithep::MathUtils::DeltaR(photon->Phi(),photon->Eta(), pf->Phi(), pf->Eta());
2802 +    if (dr > 0.3) continue;
2803 +
2804 +    if( !(PFnoPUflag[k]) && pf->Charge() != 0 ) {
2805 +      if( pf->Pt() >= 0.2 && dr > 0.01 )
2806 +        fpfPU += pf->Pt();
2807 +      continue;
2808 +    }
2809 +    
2810 +    //
2811 +    // skip this photon
2812 +    //
2813 +    if( abs(pf->PFType()) == mithep::PFCandidate::eGamma &&
2814 +        pf->Et() == photon->Et() ) continue;
2815 +    
2816 +      
2817 +    //
2818 +    // Charged Iso
2819 +    //
2820 +    if (pf->Charge() != 0 ) {
2821 +      if( dr > 0.01 && pf->Pt() >= 0.2 &&
2822 +          !(pf->TrackerTrk() == lepton->TrackerTrk()) )
2823 +        fChargedIso += pf->Pt();
2824 +    }
2825 +    
2826 +    //
2827 +    // Gamma Iso
2828 +    //
2829 +    else if (abs(pf->PFType()) == mithep::PFCandidate::eGamma) {
2830 +      if( pf->Pt() > 0.5 && dr > 0.01)
2831 +        fGammaIso += pf->Pt();
2832 +    }
2833 +    
2834 +    //
2835 +    // Other Neutrals
2836 +    //
2837 +    else {
2838 +      if( pf->Pt() > 0.5 && dr > 0.01)
2839 +        fNeutralHadronIso += pf->Pt();
2840 +    }
2841 +    
2842 +  }
2843 +  
2844 +  if( ctrl.debug ) {
2845 +    cout << "photon dbetaIso :: " << endl;
2846 +    cout << "\tfChargedIso: " << fChargedIso
2847 +         << "\tfGammaIso: " << fGammaIso
2848 +         << "\tfNeutralHadronIso: " << fNeutralHadronIso
2849 +         << "\tfpfPU: " << fpfPU
2850 +         << endl;
2851 +  }
2852 +  double pfIso = fChargedIso + fGammaIso + fNeutralHadronIso - 0.5*fpfPU;
2853 +  return pfIso/photon->Pt();
2854 + }
2855 +
2856 +
2857 + //--------------------------------------------------------------------------------------------------
2858 + double  dbetaCorrectedIsoDr03(ControlFlags & ctrl,
2859 +                              const mithep::PFCandidate * photon,
2860 +                              const mithep::Electron * lepton,
2861 +                              const mithep::Array<mithep::PFCandidate> * fPFCandidates)
2862 + //--------------------------------------------------------------------------------------------------
2863 + {
2864 +
2865 +  //
2866 +  // final iso
2867 +  //
2868 +  Double_t fChargedIso  = 0.0;
2869 +  Double_t fGammaIso  = 0.0;
2870 +  Double_t fNeutralHadronIso  = 0.0;
2871 +  Double_t fpfPU  = 0.0;
2872 +
2873 +  //
2874 +  // Loop over PF Candidates
2875 +  //
2876 +  for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2877 +
2878 +    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
2879 +    
2880 +    Double_t deta = (photon->Eta() - pf->Eta());
2881 +    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(photon->Phi()),Double_t(pf->Phi()));
2882 +    Double_t dr = mithep::MathUtils::DeltaR(photon->Phi(),photon->Eta(), pf->Phi(), pf->Eta());
2883 +    if (dr > 0.3) continue;
2884 +
2885 +    if( !(PFnoPUflag[k]) && pf->Charge() != 0 ) {
2886 +      if( pf->Pt() >= 0.2 && dr > 0.01 )
2887 +        fpfPU += pf->Pt();
2888 +      continue;
2889 +    }
2890 +    
2891 +    //
2892 +    // skip this photon
2893 +    //
2894 +    if( abs(pf->PFType()) == mithep::PFCandidate::eGamma &&
2895 +        pf->Et() == photon->Et() ) continue;
2896 +    
2897 +      
2898 +    //
2899 +    // Charged Iso
2900 +    //
2901 +    if (pf->Charge() != 0 ) {
2902 +      if( dr > 0.01 && pf->Pt() >= 0.2 &&
2903 +          !(pf->TrackerTrk() == lepton->TrackerTrk()) )
2904 +        fChargedIso += pf->Pt();
2905 +    }
2906 +    
2907 +    //
2908 +    // Gamma Iso
2909 +    //
2910 +    else if (abs(pf->PFType()) == mithep::PFCandidate::eGamma) {
2911 +      if( pf->Pt() > 0.5 && dr > 0.01)
2912 +        fGammaIso += pf->Pt();
2913 +    }
2914 +    
2915 +    //
2916 +    // Other Neutrals
2917 +    //
2918 +    else {
2919 +      if( pf->Pt() > 0.5 && dr > 0.01)
2920 +        fNeutralHadronIso += pf->Pt();
2921 +    }
2922 +    
2923 +  }
2924 +  
2925 +  if( ctrl.debug ) {
2926 +    cout << "photon dbetaIso :: " << endl;
2927 +    cout << "\tfChargedIso: " << fChargedIso
2928 +         << "\tfGammaIso: " << fGammaIso
2929 +         << "\tfNeutralHadronIso: " << fNeutralHadronIso
2930 +         << "\tfpfPU: " << fpfPU
2931 +         << endl;
2932 +  }
2933 +  double pfIso = fChargedIso + fGammaIso + fNeutralHadronIso - 0.5*fpfPU;
2934 +  return pfIso/photon->Pt();
2935 + }
2936 +
2937 +
2938 +
2939 +
2940 +
2941 + //--------------------------------------------------------------------------------------------------
2942 + double  betaCorrectedIsoDr03(ControlFlags & ctrl,
2943 +                             const mithep::PFCandidate * photon,
2944 +                             const mithep::Muon * lepton,
2945 +                             const mithep::Array<mithep::PFCandidate> * fPFCandidates)
2946 + //--------------------------------------------------------------------------------------------------
2947 + {
2948 +
2949 +  //
2950 +  // final iso
2951 +  //
2952 +  Double_t fChargedIso  = 0.0;
2953 +  Double_t fGammaIso  = 0.0;
2954 +  Double_t fNeutralHadronIso  = 0.0;
2955 +  Double_t fpfPU  = 0.0;
2956 +
2957 +  //
2958 +  // Loop over PF Candidates
2959 +  //
2960 +  for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2961 +
2962 +    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
2963 +    
2964 +    Double_t deta = (photon->Eta() - pf->Eta());
2965 +    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(photon->Phi()),Double_t(pf->Phi()));
2966 +    Double_t dr = mithep::MathUtils::DeltaR(photon->Phi(),photon->Eta(), pf->Phi(), pf->Eta());
2967 +    if (dr > 0.3) continue;
2968 +
2969 +    if( !(PFnoPUflag[k]) && pf->Charge() != 0 ) {
2970 +      if( pf->Pt() >= 0.2 && dr > 0.01 )
2971 +        fpfPU += pf->Pt();
2972 +      continue;
2973 +    }
2974 +    
2975 +    //
2976 +    // skip this photon
2977 +    //
2978 +    if( abs(pf->PFType()) == mithep::PFCandidate::eGamma &&
2979 +        pf->Et() == photon->Et() ) continue;
2980 +    
2981 +      
2982 +    //
2983 +    // Charged Iso
2984 +    //
2985 +    if (pf->Charge() != 0 ) {
2986 +      if( dr > 0.01 && pf->Pt() >= 0.2 &&
2987 +          !(pf->TrackerTrk() == lepton->TrackerTrk()) )
2988 +        fChargedIso += pf->Pt();
2989 +    }
2990 +    
2991 +    //
2992 +    // Gamma Iso
2993 +    //
2994 +    else if (abs(pf->PFType()) == mithep::PFCandidate::eGamma) {
2995 +      if( pf->Pt() > 0.5 && dr > 0.01)
2996 +        fGammaIso += pf->Pt();
2997 +    }
2998 +    
2999 +    //
3000 +    // Other Neutrals
3001 +    //
3002 +    else {
3003 +      if( pf->Pt() > 0.5 && dr > 0.01)
3004 +        fNeutralHadronIso += pf->Pt();
3005 +    }
3006 +    
3007 +  }
3008 +  
3009 +  if( ctrl.debug ) {
3010 +    cout << "photon dbetaIso :: " << endl;
3011 +    cout << "\tfChargedIso: " << fChargedIso
3012 +         << "\tfGammaIso: " << fGammaIso
3013 +         << "\tfNeutralHadronIso: " << fNeutralHadronIso
3014 +         << "\tfpfPU: " << fpfPU
3015 +         << endl;
3016 +  }
3017 +  double pfIso = fChargedIso + fGammaIso + fNeutralHadronIso + fpfPU;
3018 +  return pfIso/photon->Pt();
3019 + }
3020 +
3021 +
3022 + //--------------------------------------------------------------------------------------------------
3023 + double  betaCorrectedIsoDr03(ControlFlags & ctrl,
3024 +                              const mithep::PFCandidate * photon,
3025 +                              const mithep::Electron * lepton,
3026 +                              const mithep::Array<mithep::PFCandidate> * fPFCandidates)
3027 + //--------------------------------------------------------------------------------------------------
3028 + {
3029 +
3030 +  //
3031 +  // final iso
3032 +  //
3033 +  Double_t fChargedIso  = 0.0;
3034 +  Double_t fGammaIso  = 0.0;
3035 +  Double_t fNeutralHadronIso  = 0.0;
3036 +  Double_t fpfPU  = 0.0;
3037 +
3038 +  //
3039 +  // Loop over PF Candidates
3040 +  //
3041 +  for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
3042 +
3043 +    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
3044 +    
3045 +    Double_t deta = (photon->Eta() - pf->Eta());
3046 +    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(photon->Phi()),Double_t(pf->Phi()));
3047 +    Double_t dr = mithep::MathUtils::DeltaR(photon->Phi(),photon->Eta(), pf->Phi(), pf->Eta());
3048 +    if (dr > 0.3) continue;
3049 +
3050 +    if( !(PFnoPUflag[k]) && pf->Charge() != 0 ) {
3051 +      if( pf->Pt() >= 0.2 && dr > 0.01 )
3052 +        fpfPU += pf->Pt();
3053 +      continue;
3054 +    }
3055 +    
3056 +    //
3057 +    // skip this photon
3058 +    //
3059 +    if( abs(pf->PFType()) == mithep::PFCandidate::eGamma &&
3060 +        pf->Et() == photon->Et() ) continue;
3061 +    
3062 +      
3063 +    //
3064 +    // Charged Iso
3065 +    //
3066 +    if (pf->Charge() != 0 ) {
3067 +      if( dr > 0.01 && pf->Pt() >= 0.2 &&
3068 +          !(pf->TrackerTrk() == lepton->TrackerTrk()) )
3069 +        fChargedIso += pf->Pt();
3070 +    }
3071 +    
3072 +    //
3073 +    // Gamma Iso
3074 +    //
3075 +    else if (abs(pf->PFType()) == mithep::PFCandidate::eGamma) {
3076 +      if( pf->Pt() > 0.5 && dr > 0.01)
3077 +        fGammaIso += pf->Pt();
3078 +    }
3079 +    
3080 +    //
3081 +    // Other Neutrals
3082 +    //
3083 +    else {
3084 +      if( pf->Pt() > 0.5 && dr > 0.01)
3085 +        fNeutralHadronIso += pf->Pt();
3086 +    }
3087 +    
3088 +  }
3089 +  
3090 +  if( ctrl.debug ) {
3091 +    cout << "photon dbetaIso :: " << endl;
3092 +    cout << "\tfChargedIso: " << fChargedIso
3093 +         << "\tfGammaIso: " << fGammaIso
3094 +         << "\tfNeutralHadronIso: " << fNeutralHadronIso
3095 +         << "\tfpfPU: " << fpfPU
3096 +         << endl;
3097 +  }
3098 +  double pfIso = fChargedIso + fGammaIso + fNeutralHadronIso + fpfPU;
3099 +  return pfIso/photon->Pt();
3100 + }
3101 +
3102 +
3103 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines