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.33 by anlevin, Wed Oct 17 01:31:22 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,
965 <                    vector<const mithep::Muon*> muonsToVeto,
950 <                    vector<const mithep::Electron*> electronsToVeto)
965 >                    vector<const mithep::PFCandidate*> photonsToVeto)
966   //--------------------------------------------------------------------------------------------------
967   {
968 <  
969 <  if( ctrl.debug ) {
970 <    cout << "muonIsoMVASelection :: muons to veto " << endl;
971 <    for( int i=0; i<muonsToVeto.size(); i++ ) {
957 <      const mithep::Muon * vmu = muonsToVeto[i];
958 <      cout << "\tpt: " << vmu->Pt()
959 <           << "\teta: " << vmu->Eta()
960 <           << "\tphi: " << vmu->Phi()
961 <           << endl;
962 <    }
963 <    cout << "muonIsoMVASelection :: electrson to veto " << endl;
964 <    for( int i=0; i<electronsToVeto.size(); i++ ) {
965 <      const mithep::Electron * vel = electronsToVeto[i];
966 <      cout << "\tpt: " << vel->Pt()
967 <           << "\teta: " << vel->Eta()
968 <           << "\tphi: " << vel->Phi()
969 <           << endl;
970 <    }
971 <  }
968 >
969 >  extern double gChargedIso;  
970 >  extern double  gGammaIso;      
971 >  extern double  gNeutralIso;
972  
973    //
974    // final iso
# Line 981 | Line 981 | double  muonPFIso04(ControlFlags &ctrl,
981    //Loop over PF Candidates
982    //
983    for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
984 +
985 +    if( !(PFnoPUflag[k]) ) continue; // my PF no PU hack
986      const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
987  
988 +    //
989 +    // veto FSR recovered photons
990 +    //
991 +    bool vetoPhoton = false;
992 +    for( int p=0; p<photonsToVeto.size(); p++ ) {
993 +      if( pf == photonsToVeto[p] ) {
994 +        vetoPhoton = true;
995 +        break;
996 +      }
997 +    } if( vetoPhoton ) continue;
998 +    //
999 +    //
1000 +    //
1001 +
1002      Double_t deta = (mu->Eta() - pf->Eta());
1003      Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(mu->Phi()),Double_t(pf->Phi()));
1004      Double_t dr = mithep::MathUtils::DeltaR(mu->Phi(),mu->Eta(), pf->Phi(), pf->Eta());
# Line 991 | Line 1007 | double  muonPFIso04(ControlFlags &ctrl,
1007      if (pf->HasTrackerTrk() && (pf->TrackerTrk() == mu->TrackerTrk()) ) continue;
1008  
1009      //
994    // Lepton Footprint Removal
995    //
996    Bool_t IsLeptonFootprint = kFALSE;
997    if (dr < 1.0) {
998
999      //
1000      // Check for electrons
1001      //
1002      for (Int_t q=0; q < electronsToVeto.size(); ++q) {
1003        const mithep::Electron *tmpele = electronsToVeto[q];
1004        // 4l electron
1005        if( pf->HasTrackerTrk() ) {
1006          if( pf->TrackerTrk() == tmpele->TrackerTrk() )
1007            IsLeptonFootprint = kTRUE;
1008        }
1009        if( pf->HasGsfTrk() ) {
1010          if( pf->GsfTrk() == tmpele->GsfTrk() )
1011            IsLeptonFootprint = kTRUE;
1012        }
1013        // PF charged
1014        if (pf->Charge() != 0 && fabs(tmpele->SCluster()->Eta()) > 1.479
1015            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.015)
1016          IsLeptonFootprint = kTRUE;
1017        // PF gamma
1018        if (abs(pf->PFType()) == PFCandidate::eGamma && fabs(tmpele->SCluster()->Eta()) > 1.479
1019            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.08)
1020          IsLeptonFootprint = kTRUE;
1021      } // loop over electrons
1022
1023      // KH, comment to sync
1024      /*
1025      //
1026      // Check for muons
1027      //
1028      for (Int_t q=0; q < muonsToVeto.size(); ++q) {
1029        const mithep::Muon *tmpmu = muonsToVeto[q];
1030        // 4l muon
1031        if( pf->HasTrackerTrk() ) {
1032          if( pf->TrackerTrk() == tmpmu->TrackerTrk() )
1033            IsLeptonFootprint = kTRUE;
1034        }
1035        // PF charged
1036        if (pf->Charge() != 0 && mithep::MathUtils::DeltaR(tmpmu->Phi(),tmpmu->Eta(), pf->Phi(), pf->Eta()) < 0.01)
1037          IsLeptonFootprint = kTRUE;
1038      } // loop over muons
1039      */
1040
1041    if (IsLeptonFootprint)
1042      continue;
1043
1044    //
1010      // Charged Iso
1011      //
1012 <    if (pf->Charge() != 0 ) {
1012 >    if (pf->Charge() != 0 && (pf->HasTrackerTrk()||pf->HasGsfTrk()) ) {
1013  
1014        //if( dr < 0.01 ) continue; // only for muon iso mva?
1015        if (abs(pf->PFType()) == PFCandidate::eElectron || abs(pf->PFType()) == PFCandidate::eMuon) continue;
1051
1052      if( pf->HasTrackerTrk() ) {
1053        if (abs(pf->TrackerTrk()->DzCorrected(vtx)) > 0.2) continue;
1054        if( ctrl.debug ) cout << "charged:: " << pf->PFType() << " " << pf->Pt() << " "
1055                              << abs(pf->TrackerTrk()->DzCorrected(vtx)) << " "
1056                              << dr << endl;
1057      }
1058      if( pf->HasGsfTrk() ) {
1059        if (abs(pf->GsfTrk()->DzCorrected(vtx)) > 0.2) continue;
1060        if( ctrl.debug ) cout << "charged:: " << pf->PFType() << " " << pf->Pt() << " "
1061                              << abs(pf->GsfTrk()->DzCorrected(vtx)) << " "
1062                              << dr << endl;
1063      }
1064
1065
1016        fChargedIso += pf->Pt();
1017      }
1018 <
1018 >    
1019      //
1020      // Gamma Iso
1021      //
1022      else if (abs(pf->PFType()) == PFCandidate::eGamma) {
1023        // KH, add to sync
1024 <      if( pf->Pt() > 0.5 )
1024 >      if( pf->Pt() > 0.5 && dr > 0.01)
1025        fGammaIso += pf->Pt();
1026      }
1027 <
1027 >    
1028      //
1029      // Other Neutrals
1030      //
1031      else {
1032 <      // KH, add to sync
1033 <      if( pf->Pt() > 0.5 )
1032 >    
1033 >      if( pf->Pt() > 0.5  && dr > 0.01)
1034          fNeutralHadronIso += pf->Pt();
1035      }
1086    
1087    }
1088    
1036    }
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!!!!  
1037  
1038 +  double rho=0;
1039 +  if( (EffectiveAreaVersion == mithep::MuonTools::kMuEAFall11MC) ||
1040 +      (EffectiveAreaVersion == mithep::MuonTools::kMuEAData2011) ) {
1041 +    if (!(isnan(fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25()) ||
1042 +          isinf(fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25())))
1043 +      rho = fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25();
1044 +    //rho = fPUEnergyDensity->At(0)->Rho();
1045 +    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
1046 +    EffectiveAreaVersion  = mithep::MuonTools::kMuEAData2011;
1047 +    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
1048 +  } else {
1049 +    if (!(isnan(fPUEnergyDensity->At(0)->RhoKt6PFJetsCentralNeutral()) ||
1050 +          isinf(fPUEnergyDensity->At(0)->RhoKt6PFJetsCentralNeutral())))
1051 +      rho = fPUEnergyDensity->At(0)->RhoKt6PFJetsCentralNeutral();
1052 +    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
1053 +    EffectiveAreaVersion  = mithep::MuonTools::kMuEAData2012;
1054 +    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
1055 +  }
1056 +  if(ctrl.debug) cout << "rho: " << rho << endl;
1057 +
1058 +  TLorentzVector  tmpvec;
1059 +  tmpvec.SetPtEtaPhiM(mu->Pt(),mu->Eta(),mu->Phi(),mu->Mass());
1060 +  for( int p=0; p<photonsToVeto.size(); p++ ) {
1061 +    const mithep::PFCandidate * pf  = photonsToVeto[p];
1062 +    TLorentzVector pfvec;
1063 +    pfvec.SetPtEtaPhiM(pf->Pt(),pf->Eta(),pf->Phi(),0.);
1064 +    tmpvec += pfvec;
1065 +  }
1066  
1067    double pfIso = fChargedIso + fmax(0.0,(fGammaIso + fNeutralHadronIso
1068                                          -rho*muT.MuonEffectiveArea(muT.kMuGammaAndNeutralHadronIso04,
1069 <                                                                   mu->Eta(),EffectiveAreaVersion)));
1070 <
1069 >                                                                   //tmpvec.Eta(),EffectiveAreaVersion)));
1070 >                                                                   mu->Eta(),EffectiveAreaVersion)));
1071    gChargedIso = fChargedIso;
1072 <  gGammaIso = fGammaIso;
1073 <  gNeutralIso = fNeutralHadronIso;  
1072 >  gGammaIso   = fGammaIso;
1073 >  gNeutralIso = fNeutralHadronIso;
1074 >  
1075 >  if( ctrl.debug ) {
1076 >    cout << "PFiso: " << pfIso
1077 >         << "\tfChargedIso: " << fChargedIso
1078 >         << "\tfGammaIso: " << fGammaIso
1079 >         << "\tfNeutralHadronIso: " << fNeutralHadronIso
1080 >         << endl;
1081 >  }
1082 >
1083    return pfIso;
1084   }
1085  
1086  
1087 +
1088 +
1089   //--------------------------------------------------------------------------------------------------
1090   // hacked version
1091   double  muonPFIso04(ControlFlags &ctrl,
1092                      const mithep::Muon * mu,
1093 <                    const mithep::Vertex & vtx,
1093 >                    const mithep::Vertex * vtx,
1094                      const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1095                      float rho,
1096                      mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
# Line 1291 | Line 1266 | double  muonPFIso04(ControlFlags &ctrl,
1266   //--------------------------------------------------------------------------------------------------
1267   SelectionStatus muonReferenceIsoSelection(ControlFlags &ctrl,
1268                                            const mithep::Muon * mu,
1269 <                                          const mithep::Vertex & vtx,
1269 >                                          const mithep::Vertex * vtx,
1270                                            const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1271                                            const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
1272                                            mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
1273 <                                          vector<const mithep::Muon*> muonsToVeto,
1299 <                                          vector<const mithep::Electron*> electronsToVeto)
1273 >                                          vector<const mithep::PFCandidate*> photonsToVeto)
1274   //--------------------------------------------------------------------------------------------------
1275   {
1276    
1277    SelectionStatus status;
1278  
1279    double pfIso = muonPFIso04( ctrl, mu, vtx, fPFCandidates, fPUEnergyDensity,
1280 <                              EffectiveAreaVersion, muonsToVeto ,electronsToVeto );
1280 >                              EffectiveAreaVersion, photonsToVeto);
1281    //  cout << "--------------> setting muon isoPF04 to" << pfIso << endl;
1282    status.isoPF04 = pfIso;
1283    status.chisoPF04 = gChargedIso;
# Line 1312 | Line 1286 | SelectionStatus muonReferenceIsoSelectio
1286  
1287    bool pass = false;
1288    if( (pfIso/mu->Pt()) < MUON_REFERENCE_PFISO_CUT ) pass = true;
1289 <  
1289 >
1290    if( pass ) {
1291      status.orStatus(SelectionStatus::LOOSEISO);
1292      status.orStatus(SelectionStatus::TIGHTISO);
1293    }
1294 <  if(ctrl.debug) cout << "returning status : " << hex << status.getStatus() << dec << endl;
1294 >  if(ctrl.debug) {
1295 >    cout << "mu relpfIso: " << pfIso/mu->Pt() << endl;
1296 >    cout << "returning status : " << hex << status.getStatus() << dec << endl;
1297 >  }
1298    return status;
1299    
1300   }
# Line 1327 | Line 1304 | SelectionStatus muonReferenceIsoSelectio
1304   // hacked version
1305   SelectionStatus muonReferenceIsoSelection(ControlFlags &ctrl,
1306                                            const mithep::Muon * mu,
1307 <                                          const mithep::Vertex & vtx,
1307 >                                          const mithep::Vertex * vtx,
1308                                            const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1309                                            float rho,
1310                                            mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
# Line 1360 | Line 1337 | SelectionStatus muonReferenceIsoSelectio
1337  
1338  
1339  
1340 +
1341   //--------------------------------------------------------------------------------------------------
1342   SelectionStatus electronIsoMVASelection(ControlFlags &ctrl,
1343                                          const mithep::Electron * ele,
1344 <                                        const mithep::Vertex & vtx,
1344 >                                        const mithep::Vertex * vtx,
1345                                          const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1346                                          const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
1347                                          mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
# Line 1402 | Line 1380 | SelectionStatus electronIsoMVASelection(
1380    Double_t tmpChargedIso_DR0p2To0p3  = 0;
1381    Double_t tmpChargedIso_DR0p3To0p4  = 0;
1382    Double_t tmpChargedIso_DR0p4To0p5  = 0;
1405  Double_t tmpChargedIso_DR0p5To0p7  = 0;
1383  
1384    Double_t tmpGammaIso_DR0p0To0p1  = 0;
1385    Double_t tmpGammaIso_DR0p1To0p2  = 0;
1386    Double_t tmpGammaIso_DR0p2To0p3  = 0;
1387    Double_t tmpGammaIso_DR0p3To0p4  = 0;
1388    Double_t tmpGammaIso_DR0p4To0p5  = 0;
1389 <  Double_t tmpGammaIso_DR0p5To0p7  = 0;
1389 >
1390  
1391    Double_t tmpNeutralHadronIso_DR0p0To0p1  = 0;
1392    Double_t tmpNeutralHadronIso_DR0p1To0p2  = 0;
1393    Double_t tmpNeutralHadronIso_DR0p2To0p3  = 0;
1394    Double_t tmpNeutralHadronIso_DR0p3To0p4  = 0;
1395    Double_t tmpNeutralHadronIso_DR0p4To0p5  = 0;
1419  Double_t tmpNeutralHadronIso_DR0p5To0p7  = 0;
1396  
1397          
1398  
# Line 1453 | Line 1429 | SelectionStatus electronIsoMVASelection(
1429      Double_t deta = (ele->Eta() - pf->Eta());
1430      Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(ele->Phi()),Double_t(pf->Phi()));
1431      Double_t dr = mithep::MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta());
1432 <    if (dr > 0.5) continue;
1432 >    if (dr > 1.0) continue;
1433 >
1434      if(ctrl.debug) {
1435        cout << "pf :: type: " << pf->PFType() << "\tpt: " << pf->Pt();
1436 <      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(vtx);
1436 >      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(*vtx);
1437        cout << endl;
1438      }
1439  
# Line 1471 | Line 1448 | SelectionStatus electronIsoMVASelection(
1448      Bool_t IsLeptonFootprint = kFALSE;
1449      if (dr < 1.0) {
1450  
1451 +
1452        //
1453        // Check for electrons
1454        //
1455 +
1456        for (Int_t q=0; q < electronsToVeto.size(); ++q) {
1457          const mithep::Electron *tmpele = electronsToVeto[q];
1458 +        double tmpdr = mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta());
1459 +
1460          // 4l electron
1461          if( pf->HasTrackerTrk()  ) {
1462            if( pf->TrackerTrk() == tmpele->TrackerTrk() ) {
# Line 1490 | Line 1471 | SelectionStatus electronIsoMVASelection(
1471            }
1472          }
1473          // PF charged
1474 <        if (pf->Charge() != 0 && fabs(tmpele->SCluster()->Eta()) >= 1.479
1494 <            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.015) {
1474 >        if (pf->Charge() != 0 && fabs(tmpele->SCluster()->Eta()) >= 1.479 && tmpdr < 0.015) {
1475            if( ctrl.debug) cout << "\tcharged trk, dR matches 4L ele ..." << endl;
1476            IsLeptonFootprint = kTRUE;
1477          }
1478          // PF gamma
1479          if (abs(pf->PFType()) == PFCandidate::eGamma && fabs(tmpele->SCluster()->Eta()) >= 1.479
1480 <            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.08) {
1480 >            && tmpdr < 0.08) {
1481            if( ctrl.debug) cout << "\tPF gamma, matches 4L ele ..." << endl;
1482            IsLeptonFootprint = kTRUE;
1483          }
1484        } // loop over electrons
1485  
1486 +
1487        /* KH - comment for sync            
1488        //
1489        // Check for muons
# Line 1553 | Line 1534 | SelectionStatus electronIsoMVASelection(
1534        if (dr >= 0.2 && dr < 0.3) tmpChargedIso_DR0p2To0p3 += pf->Pt();
1535        if (dr >= 0.3 && dr < 0.4) tmpChargedIso_DR0p3To0p4 += pf->Pt();
1536        if (dr >= 0.4 && dr < 0.5) tmpChargedIso_DR0p4To0p5 += pf->Pt();
1556      if (dr >= 0.5 && dr < 0.7) tmpChargedIso_DR0p5To0p7 += pf->Pt();
1537  
1538      }
1539  
# Line 1562 | Line 1542 | SelectionStatus electronIsoMVASelection(
1542      //
1543      else if (abs(pf->PFType()) == PFCandidate::eGamma) {
1544  
1545 <      if (fabs(ele->SCluster()->Eta()) > 1.479) {
1566 <        if (mithep::MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta()) < 0.08) continue;
1567 <      }
1545 >      if (fabs(ele->SCluster()->Eta()) > 1.479 && dr < 0.08) continue;
1546  
1547        if( ctrl.debug) cout << "gamma:: " << pf->Pt() << " "
1548                             << dr << endl;
# Line 1574 | Line 1552 | SelectionStatus electronIsoMVASelection(
1552        if (dr >= 0.2 && dr < 0.3) tmpGammaIso_DR0p2To0p3 += pf->Pt();
1553        if (dr >= 0.3 && dr < 0.4) tmpGammaIso_DR0p3To0p4 += pf->Pt();
1554        if (dr >= 0.4 && dr < 0.5) tmpGammaIso_DR0p4To0p5 += pf->Pt();
1577      if (dr >= 0.5 && dr < 0.7) tmpGammaIso_DR0p5To0p7 += pf->Pt();
1578
1555      }
1556  
1557      //
# Line 1589 | Line 1565 | SelectionStatus electronIsoMVASelection(
1565        if (dr >= 0.2 && dr < 0.3) tmpNeutralHadronIso_DR0p2To0p3 += pf->Pt();
1566        if (dr >= 0.3 && dr < 0.4) tmpNeutralHadronIso_DR0p3To0p4 += pf->Pt();
1567        if (dr >= 0.4 && dr < 0.5) tmpNeutralHadronIso_DR0p4To0p5 += pf->Pt();
1592      if (dr >= 0.5 && dr < 0.7) tmpNeutralHadronIso_DR0p5To0p7 += pf->Pt();
1568      }
1569  
1570      }
# Line 1602 | Line 1577 | SelectionStatus electronIsoMVASelection(
1577    fChargedIso_DR0p3To0p4   = fmin((tmpChargedIso_DR0p3To0p4)/ele->Pt(), 2.5);
1578    fChargedIso_DR0p4To0p5   = fmin((tmpChargedIso_DR0p4To0p5)/ele->Pt(), 2.5);
1579  
1580 <  double rho = 0;
1581 < //   if (!(isnan(fPUEnergyDensity->At(0)->Rho()) || isinf(fPUEnergyDensity->At(0)->Rho())))
1582 < //     rho = fPUEnergyDensity->At(0)->Rho();
1583 <  if (!(isnan(fPUEnergyDensity->At(0)->RhoLowEta()) || isinf(fPUEnergyDensity->At(0)->RhoLowEta())))
1584 <    rho = fPUEnergyDensity->At(0)->RhoLowEta();
1580 >  if(ctrl.debug) {
1581 >    cout << "fChargedIso_DR0p0To0p1 : " << fChargedIso_DR0p0To0p1  << endl;
1582 >    cout << "fChargedIso_DR0p1To0p2 : " << fChargedIso_DR0p1To0p2  << endl;
1583 >    cout << "fChargedIso_DR0p2To0p3 : " << fChargedIso_DR0p2To0p3  << endl;
1584 >    cout << "fChargedIso_DR0p3To0p4 : " << fChargedIso_DR0p3To0p4  << endl;
1585 >    cout << "fChargedIso_DR0p4To0p5 : " << fChargedIso_DR0p4To0p5  << endl;
1586 >  }
1587  
1588 +
1589 +  double rho = 0;
1590 +  if (!(isnan(fPUEnergyDensity->At(0)->Rho()) || isinf(fPUEnergyDensity->At(0)->Rho())))
1591 +    rho = fPUEnergyDensity->At(0)->Rho();
1592 +  //   if (!(isnan(fPUEnergyDensity->At(0)->RhoLowEta()) || isinf(fPUEnergyDensity->At(0)->RhoLowEta())))
1593 +  //     rho = fPUEnergyDensity->At(0)->RhoLowEta();
1594 +  
1595    // WARNING!!!!  
1596    // hardcode for sync ...
1597 <  //  EffectiveAreaVersion = eleT.kEleEAData2011;
1614 <  EffectiveAreaVersion = eleT.kEleEAFall11MC;
1597 >  EffectiveAreaVersion = eleT.kEleEAData2011;
1598    // WARNING!!!!  
1599  
1600    if( ctrl.debug) {
# Line 1668 | Line 1651 | SelectionStatus electronIsoMVASelection(
1651                               ,0.0);
1652  
1653  
1654 +  if( ctrl.debug) {
1655 +    cout << "fGammaIso_DR0p0To0p1: " << fGammaIso_DR0p0To0p1 << endl;
1656 +    cout << "fGammaIso_DR0p1To0p2: " << fGammaIso_DR0p1To0p2 << endl;
1657 +    cout << "fGammaIso_DR0p2To0p3: " << fGammaIso_DR0p2To0p3 << endl;
1658 +    cout << "fGammaIso_DR0p3To0p4: " << fGammaIso_DR0p3To0p4 << endl;
1659 +    cout << "fGammaIso_DR0p4To0p5: " << fGammaIso_DR0p4To0p5 << endl;
1660 +  }
1661 +
1662    fNeutralHadronIso_DR0p0To0p1 = fmax(fmin((tmpNeutralHadronIso_DR0p0To0p1
1663                                            -rho*eleT.ElectronEffectiveArea(eleT.kEleNeutralHadronIsoDR0p0To0p1,
1664                                                                   ele->SCluster()->Eta(),EffectiveAreaVersion))/ele->Pt()
# Line 1694 | Line 1685 | SelectionStatus electronIsoMVASelection(
1685                                           , 2.5)
1686                                       , 0.0);
1687  
1688 +  if( ctrl.debug) {
1689 +    cout << "fNeutralHadronIso_DR0p0To0p1: " << fNeutralHadronIso_DR0p0To0p1 << endl;
1690 +    cout << "fNeutralHadronIso_DR0p1To0p2: " << fNeutralHadronIso_DR0p1To0p2 << endl;
1691 +    cout << "fNeutralHadronIso_DR0p2To0p3: " << fNeutralHadronIso_DR0p2To0p3 << endl;
1692 +    cout << "fNeutralHadronIso_DR0p3To0p4: " << fNeutralHadronIso_DR0p3To0p4 << endl;
1693 +    cout << "fNeutralHadronIso_DR0p4To0p5: " << fNeutralHadronIso_DR0p4To0p5 << endl;
1694 +  }
1695 +
1696    double mvaval = eleIsoMVA->MVAValue_IsoRings( ele->Pt(),
1697                                                  ele->SCluster()->Eta(),
1698                                                  fChargedIso_DR0p0To0p1,
# Line 1714 | Line 1713 | SelectionStatus electronIsoMVASelection(
1713                                                  ctrl.debug);
1714  
1715    SelectionStatus status;
1716 +  status.isoMVA = mvaval;
1717    bool pass = false;
1718  
1719    Int_t subdet = 0;
1720    if (fabs(ele->SCluster()->Eta()) < 0.8) subdet = 0;
1721    else if (fabs(ele->SCluster()->Eta()) < 1.479) subdet = 1;
1722    else subdet = 2;
1723 +
1724    Int_t ptBin = 0;
1725 <  if (ele->Pt() > 10.0) ptBin = 1;
1725 >  if (ele->Pt() >= 10.0) ptBin = 1;
1726    
1727    Int_t MVABin = -1;
1728    if (subdet == 0 && ptBin == 0) MVABin = 0;
# Line 1732 | Line 1733 | SelectionStatus electronIsoMVASelection(
1733    if (subdet == 2 && ptBin == 1) MVABin = 5;
1734  
1735    pass = false;
1736 <  if( MVABin == 0 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_BIN0 ) pass = true;
1737 <  if( MVABin == 1 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_BIN1 ) pass = true;
1738 <  if( MVABin == 2 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_BIN2 ) pass = true;
1739 <  if( MVABin == 3 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_BIN3 ) pass = true;
1740 <  if( MVABin == 4 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_BIN4 ) pass = true;
1741 <  if( MVABin == 5 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_BIN5 ) pass = true;
1736 >  if( MVABin == 0 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_OPT_BIN0 ) pass = true;
1737 >  if( MVABin == 1 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_OPT_BIN1 ) pass = true;
1738 >  if( MVABin == 2 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_OPT_BIN2 ) pass = true;
1739 >  if( MVABin == 3 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_OPT_BIN3 ) pass = true;
1740 >  if( MVABin == 4 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_OPT_BIN4 ) pass = true;
1741 >  if( MVABin == 5 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_OPT_BIN5 ) pass = true;
1742 >  //  pass &= (fChargedIso_DR0p0To0p1 + fChargedIso_DR0p1To0p2 + fChargedIso_DR0p2To0p3 < 0.7);
1743    if( pass ) status.orStatus(SelectionStatus::LOOSEISO);
1744  
1745   //   pass = false;
# Line 1755 | Line 1757 | SelectionStatus electronIsoMVASelection(
1757   }
1758  
1759  
1758
1760   //--------------------------------------------------------------------------------------------------
1761   SelectionStatus electronIsoMVASelection(ControlFlags &ctrl,
1762                                          const mithep::Electron * ele,
1763 <                                        const mithep::Vertex & vtx,
1763 >                                        const mithep::Vertex * vtx,
1764                                          const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1765                                          float rho,
1766                                          //const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
# Line 1856 | Line 1857 | SelectionStatus electronIsoMVASelection(
1857  
1858      if(ctrl.debug) {
1859        cout << "pf :: type: " << pf->PFType() << "\tpt: " << pf->Pt();
1860 <      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(vtx);
1860 >      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(*vtx);
1861        cout << endl;
1862      }
1863  
# Line 2196 | Line 2197 | void initElectronIsoMVA() {
2197  
2198  
2199  
2200 +
2201   //--------------------------------------------------------------------------------------------------
2202   float electronPFIso04(ControlFlags &ctrl,
2203 <                                const mithep::Electron * ele,
2204 <                                const mithep::Vertex & vtx,
2205 <                                const mithep::Array<mithep::PFCandidate> * fPFCandidates,
2206 <                                const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
2207 <                                mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
2208 <                                vector<const mithep::Muon*> muonsToVeto,
2207 <                                vector<const mithep::Electron*> electronsToVeto)
2203 >                      const mithep::Electron * ele,
2204 >                      const mithep::Vertex * vtx,
2205 >                      const mithep::Array<mithep::PFCandidate> * fPFCandidates,
2206 >                      const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
2207 >                      mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
2208 >                      vector<const mithep::PFCandidate*> photonsToVeto)        
2209   //--------------------------------------------------------------------------------------------------
2210   {
2211  
2211  if( ctrl.debug ) {
2212    cout << "electronIsoMVASelection :: muons to veto " << endl;
2213    for( int i=0; i<muonsToVeto.size(); i++ ) {
2214      const mithep::Muon * vmu = muonsToVeto[i];
2215      cout << "\tpt: " << vmu->Pt()
2216           << "\teta: " << vmu->Eta()
2217           << "\tphi: " << vmu->Phi()
2218           << endl;
2219    }
2220    cout << "electronIsoMVASelection :: electrson to veto " << endl;
2221    for( int i=0; i<electronsToVeto.size(); i++ ) {
2222      const mithep::Electron * vel = electronsToVeto[i];
2223      cout << "\tpt: " << vel->Pt()
2224           << "\teta: " << vel->Eta()
2225           << "\tphi: " << vel->Phi()
2226           << "\ttrk: " << vel->TrackerTrk()
2227           << endl;
2228    }
2229  }
2230
2231
2212    //
2213    // final iso
2214    //
# Line 2241 | Line 2221 | float electronPFIso04(ControlFlags &ctrl
2221    //Loop over PF Candidates
2222    //
2223    for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2224 +
2225      const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
2226 +
2227 +    //
2228 +    // veto FSR recovered photons
2229 +    //
2230 +    bool vetoPhoton = false;
2231 +    for( int p=0; p<photonsToVeto.size(); p++ ) {
2232 +      if( pf == photonsToVeto[p] ) {
2233 +        vetoPhoton = true;
2234 +        break;
2235 +      }
2236 +    } if( vetoPhoton ) continue;
2237 +
2238      Double_t deta = (ele->Eta() - pf->Eta());
2239      Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(ele->Phi()),Double_t(pf->Phi()));
2240      Double_t dr = mithep::MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta());
2241 <    if (dr >= 0.4) continue;
2241 >
2242 >    if (dr > 0.4) continue;
2243 >    if( !(PFnoPUflag[k]) ) continue; // my PF no PU hack
2244 >
2245      if(ctrl.debug) {
2246 <      cout << "pf :: type: " << pf->PFType() << "\tpt: " << pf->Pt();
2247 <      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(vtx);
2246 >      cout << "pf :: type: " << pf->PFType() << "\tpt: " << pf->Pt() << "\tdR: " << dr;
2247 >      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(*vtx)
2248 >                                     << "\ttrk: " << pf->HasTrackerTrk()
2249 >                                     << "\tgsf: " << pf->HasGsfTrk();
2250 >      
2251        cout << endl;
2252      }
2253  
2254  
2255 <    if ( (pf->HasTrackerTrk() && (pf->TrackerTrk() == ele->TrackerTrk())) ||
2256 <         (pf->HasGsfTrk() && (pf->GsfTrk() == ele->GsfTrk()))) continue;
2257 <    
2255 >    //
2256 >    // sync : I don't think theyre doing this ...
2257 >    //
2258 >    //     if ( (pf->HasTrackerTrk() && (pf->TrackerTrk() == ele->TrackerTrk())) ||
2259 >    //   (pf->HasGsfTrk() && (pf->GsfTrk() == ele->GsfTrk()))) {
2260 >    //       if( ctrl.debug ) cout << "\tskipping, matches to the electron ..."  << endl;
2261 >    //       continue;
2262 >    //     }
2263 >
2264  
2265      //
2266      // Lepton Footprint Removal
# Line 2263 | Line 2268 | float electronPFIso04(ControlFlags &ctrl
2268      Bool_t IsLeptonFootprint = kFALSE;
2269      if (dr < 1.0) {
2270  
2266      //
2267      // Check for electrons
2268      //
2269      for (Int_t q=0; q < electronsToVeto.size(); ++q) {
2270        const mithep::Electron *tmpele = electronsToVeto[q];
2271        // 4l electron
2272        if( pf->HasTrackerTrk()  ) {
2273          if( pf->TrackerTrk() == tmpele->TrackerTrk() ) {
2274            if( ctrl.debug) cout << "\tcharged tktrk, matches 4L ele ..." << endl;
2275            IsLeptonFootprint = kTRUE;
2276          }
2277        }
2278        if( pf->HasGsfTrk()  ) {
2279          if( pf->GsfTrk() == tmpele->GsfTrk() ) {
2280            if( ctrl.debug) cout << "\tcharged gsftrk, matches 4L ele ..." << endl;
2281            IsLeptonFootprint = kTRUE;
2282          }
2283        }
2284        // PF charged
2285        if (pf->Charge() != 0 && fabs(tmpele->SCluster()->Eta()) > 1.479
2286            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.015) {
2287          if( ctrl.debug) cout << "\tcharged trk, dR matches 4L ele ..." << endl;
2288          IsLeptonFootprint = kTRUE;
2289        }
2290        // PF gamma
2291        if (abs(pf->PFType()) == PFCandidate::eGamma && fabs(tmpele->SCluster()->Eta()) > 1.479
2292            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.08) {
2293          if( ctrl.debug) cout << "\tPF gamma, matches 4L ele ..." << endl;
2294          IsLeptonFootprint = kTRUE;
2295        }
2296      } // loop over electrons
2297
2298
2299      //
2300      // Check for muons
2301      //
2302      for (Int_t q=0; q < muonsToVeto.size(); ++q) {
2303        const mithep::Muon *tmpmu = muonsToVeto[q];
2304        // 4l muon
2305        if( pf->HasTrackerTrk() ) {
2306          if (pf->TrackerTrk() == tmpmu->TrackerTrk() ){
2307            if( ctrl.debug) cout << "\tmatches 4L mu ..." << endl;
2308            IsLeptonFootprint = kTRUE;
2309          }
2310        }
2311        // PF charged
2312        if (pf->Charge() != 0 && mithep::MathUtils::DeltaR(tmpmu->Phi(),tmpmu->Eta(), pf->Phi(), pf->Eta()) < 0.01) {
2313          if( ctrl.debug) cout << "\tcharged trk, dR matches 4L mu ..." << endl;
2314          IsLeptonFootprint = kTRUE;
2315        }
2316      } // loop over muons
2317
2318
2319    if (IsLeptonFootprint)
2320      continue;
2271  
2272      //
2273      // Charged Iso
2274      //
2275 <    if (pf->Charge() != 0 ) {
2326 <
2327 <      if( pf->HasTrackerTrk() )
2328 <        if (abs(pf->TrackerTrk()->DzCorrected(vtx)) > 0.2) continue;
2329 <      if( pf->HasGsfTrk() )
2330 <        if (abs(pf->GsfTrk()->DzCorrected(vtx)) > 0.2) continue;
2275 >    if (pf->Charge() != 0 && (pf->HasTrackerTrk()||pf->HasGsfTrk()) ) {
2276  
2277        // Veto any PFmuon, or PFEle
2278 <      if (abs(pf->PFType()) == PFCandidate::eElectron || abs(pf->PFType()) == PFCandidate::eMuon) continue;
2278 >      if (abs(pf->PFType()) == PFCandidate::eElectron || abs(pf->PFType()) == PFCandidate::eMuon) {
2279 >        if( ctrl.debug ) cout << "\t skipping, pf is and ele or mu .." <<endl;
2280 >        continue;
2281 >      }
2282  
2283        // Footprint Veto
2284        if (fabs(ele->SCluster()->Eta()) > 1.479 && dr < 0.015) continue;
# Line 2350 | Line 2298 | float electronPFIso04(ControlFlags &ctrl
2298        if (fabs(ele->SCluster()->Eta()) > 1.479) {
2299          if (mithep::MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta()) < 0.08) continue;
2300        }
2301 +
2302 +      assert(ele->HasSuperCluster());
2303 +      if(ele->GsfTrk()->NExpectedHitsInner()>0 && pf->MvaGamma() > 0.99 && pf->HasSCluster() && ele->SCluster() == pf->SCluster())      continue;
2304 +
2305 +
2306        if( ctrl.debug) cout << "gamma:: " << pf->Pt() << " "
2307                             << dr << endl;
2308        // KH, add to sync
2309 <      //      if( pf->Pt() > 0.5 )
2309 >      //      if( pf->Pt() > 0.5 )
2310          fGammaIso += pf->Pt();
2311      }
2312  
# Line 2364 | Line 2317 | float electronPFIso04(ControlFlags &ctrl
2317        if( ctrl.debug) cout << "neutral:: " << pf->Pt() << " "
2318                             << dr << endl;
2319        // KH, add to sync
2320 <      //      if( pf->Pt() > 0.5 )
2320 >      //      if( pf->Pt() > 0.5 )
2321          fNeutralHadronIso += pf->Pt();
2322      }
2323  
# Line 2372 | Line 2325 | float electronPFIso04(ControlFlags &ctrl
2325  
2326    }
2327  
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!!!!  
2328  
2329 +  double rho=0;
2330 +  if( (EffectiveAreaVersion == mithep::ElectronTools::kEleEAFall11MC) ||
2331 +      (EffectiveAreaVersion == mithep::ElectronTools::kEleEAData2011) ) {
2332 +    if (!(isnan(fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25()) ||
2333 +          isinf(fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25())))
2334 +      rho = fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25();
2335 +    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
2336 +    EffectiveAreaVersion  = mithep::ElectronTools::kEleEAData2011;
2337 +    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
2338 +  } else {
2339 +    if (!(isnan(fPUEnergyDensity->At(0)->RhoKt6PFJets()) ||
2340 +          isinf(fPUEnergyDensity->At(0)->RhoKt6PFJets())))
2341 +      rho = fPUEnergyDensity->At(0)->RhoKt6PFJets();
2342 +    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
2343 +    EffectiveAreaVersion  = mithep::ElectronTools::kEleEAData2012;
2344 +    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
2345 +  }
2346 +  if(ctrl.debug) cout << "rho: " << rho << endl;
2347  
2348    double pfIso = fChargedIso + fmax(0.0,(fGammaIso + fNeutralHadronIso
2349                                          -rho*eleT.ElectronEffectiveArea(eleT.kEleGammaAndNeutralHadronIso04,
2350                                                                     ele->Eta(),EffectiveAreaVersion)));
2351  
2352 +
2353    gChargedIso = fChargedIso;
2354    gGammaIso = fGammaIso;
2355    gNeutralIso = fNeutralHadronIso;  
2356  
2357 +  if( ctrl.debug ) {
2358 +    cout << "PFiso: " << pfIso
2359 +         << "\tfChargedIso: " << fChargedIso
2360 +         << "\tfGammaIso: " << fGammaIso
2361 +         << "\tfNeutralHadronIso: " << fNeutralHadronIso
2362 +         << endl;
2363 +  }
2364 +
2365    return pfIso;
2366   }
2367  
2368 +
2369 +
2370   //--------------------------------------------------------------------------------------------------
2371   // hacked version
2372   float electronPFIso04(ControlFlags &ctrl,
2373                        const mithep::Electron * ele,
2374 <                      const mithep::Vertex & vtx,
2374 >                      const mithep::Vertex * vtx,
2375                        const mithep::Array<mithep::PFCandidate> * fPFCandidates,
2376                        float rho,
2377                        mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
# Line 2453 | Line 2425 | float electronPFIso04(ControlFlags &ctrl
2425  
2426      if(ctrl.debug) {
2427        cout << "pf :: type: " << pf->PFType() << "\tpt: " << pf->Pt() << "\tdR: " << dr;
2428 <      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(vtx)
2428 >      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(*vtx)
2429                                       << "\ttrk: " << pf->HasTrackerTrk()
2430                                       << "\tgsf: " << pf->HasGsfTrk();
2431        
# Line 2547 | Line 2519 | float electronPFIso04(ControlFlags &ctrl
2519  
2520        // Veto any PFmuon, or PFEle
2521        if (abs(pf->PFType()) == PFCandidate::eElectron || abs(pf->PFType()) == PFCandidate::eMuon) {
2522 <         cout << "\t skipping, pf is and ele or mu .." <<endl;
2522 >        if( ctrl.debug ) cout << "\t skipping, pf is and ele or mu .." <<endl;
2523          continue;
2524        }
2525  
# Line 2616 | Line 2588 | float electronPFIso04(ControlFlags &ctrl
2588   //--------------------------------------------------------------------------------------------------
2589   SelectionStatus electronReferenceIsoSelection(ControlFlags &ctrl,
2590                                                const mithep::Electron * ele,
2591 <                                              const mithep::Vertex & vtx,
2591 >                                              const mithep::Vertex * vtx,
2592                                                const mithep::Array<mithep::PFCandidate> * fPFCandidates,
2593                                                const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
2594                                                mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
2595 <                                              vector<const mithep::Muon*> muonsToVeto,
2624 <                                              vector<const mithep::Electron*> electronsToVeto)
2595 >                                              vector<const mithep::PFCandidate*> photonsToVeto)
2596   //--------------------------------------------------------------------------------------------------
2597   {
2598  
2599    SelectionStatus status;
2600  
2601    double pfIso = electronPFIso04( ctrl, ele, vtx, fPFCandidates, fPUEnergyDensity,
2602 <                                  EffectiveAreaVersion, muonsToVeto ,electronsToVeto );
2602 >                                  EffectiveAreaVersion, photonsToVeto);
2603    //  cout << "--------------> setting electron isoPF04 to " << pfIso << endl;
2604    status.isoPF04 = pfIso;
2605    status.chisoPF04 = gChargedIso;
# Line 2642 | Line 2613 | SelectionStatus electronReferenceIsoSele
2613      status.orStatus(SelectionStatus::LOOSEISO);
2614      status.orStatus(SelectionStatus::TIGHTISO);
2615    }
2616 <  if(ctrl.debug) cout << "returning status : " << hex << status.getStatus() << dec << endl;
2616 >  if(ctrl.debug) {
2617 >    cout << "el relpfIso: " << pfIso/ele->Pt() << endl;
2618 >    cout << "returning status : " << hex << status.getStatus() << dec << endl;
2619 >  }
2620    return status;
2621  
2622   }
# Line 2652 | Line 2626 | SelectionStatus electronReferenceIsoSele
2626   // hacked version
2627   SelectionStatus electronReferenceIsoSelection(ControlFlags &ctrl,
2628                                                const mithep::Electron * ele,
2629 <                                              const mithep::Vertex & vtx,
2629 >                                              const mithep::Vertex * vtx,
2630                                                const mithep::Array<mithep::PFCandidate> * fPFCandidates,
2631                                                float rho,
2632                                                mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
# Line 2680 | Line 2654 | SelectionStatus electronReferenceIsoSele
2654    return status;
2655  
2656   }
2657 +
2658 +
2659 +
2660 + //--------------------------------------------------------------------------------------------------
2661 + double  dbetaCorrectedIsoDr03(ControlFlags & ctrl,
2662 +                              const mithep::PFCandidate * photon,
2663 +                              const mithep::Muon * lepton,
2664 +                              const mithep::Array<mithep::PFCandidate> * fPFCandidates)
2665 + //--------------------------------------------------------------------------------------------------
2666 + {
2667 +
2668 +  //
2669 +  // final iso
2670 +  //
2671 +  Double_t fChargedIso  = 0.0;
2672 +  Double_t fGammaIso  = 0.0;
2673 +  Double_t fNeutralHadronIso  = 0.0;
2674 +  Double_t fpfPU  = 0.0;
2675 +
2676 +  //
2677 +  // Loop over PF Candidates
2678 +  //
2679 +  for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2680 +
2681 +    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
2682 +    
2683 +    Double_t deta = (photon->Eta() - pf->Eta());
2684 +    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(photon->Phi()),Double_t(pf->Phi()));
2685 +    Double_t dr = mithep::MathUtils::DeltaR(photon->Phi(),photon->Eta(), pf->Phi(), pf->Eta());
2686 +    if (dr > 0.3) continue;
2687 +
2688 +    if( !(PFnoPUflag[k]) && pf->Charge() != 0 ) {
2689 +      if( pf->Pt() >= 0.2 && dr > 0.01 )
2690 +        fpfPU += pf->Pt();
2691 +      continue;
2692 +    }
2693 +    
2694 +    //
2695 +    // skip this photon
2696 +    //
2697 +    if( abs(pf->PFType()) == mithep::PFCandidate::eGamma &&
2698 +        pf->Et() == photon->Et() ) continue;
2699 +    
2700 +      
2701 +    //
2702 +    // Charged Iso
2703 +    //
2704 +    if (pf->Charge() != 0 ) {
2705 +      if( dr > 0.01 && pf->Pt() >= 0.2 &&
2706 +          !(pf->TrackerTrk() == lepton->TrackerTrk()) )
2707 +        fChargedIso += pf->Pt();
2708 +    }
2709 +    
2710 +    //
2711 +    // Gamma Iso
2712 +    //
2713 +    else if (abs(pf->PFType()) == mithep::PFCandidate::eGamma) {
2714 +      if( pf->Pt() > 0.5 && dr > 0.01)
2715 +        fGammaIso += pf->Pt();
2716 +    }
2717 +    
2718 +    //
2719 +    // Other Neutrals
2720 +    //
2721 +    else {
2722 +      if( pf->Pt() > 0.5 && dr > 0.01)
2723 +        fNeutralHadronIso += pf->Pt();
2724 +    }
2725 +    
2726 +  }
2727 +  
2728 +  if( ctrl.debug ) {
2729 +    cout << "photon dbetaIso :: " << endl;
2730 +    cout << "\tfChargedIso: " << fChargedIso
2731 +         << "\tfGammaIso: " << fGammaIso
2732 +         << "\tfNeutralHadronIso: " << fNeutralHadronIso
2733 +         << "\tfpfPU: " << fpfPU
2734 +         << endl;
2735 +  }
2736 +  double pfIso = fChargedIso + fGammaIso + fNeutralHadronIso - 0.5*fpfPU;
2737 +  return pfIso/photon->Pt();
2738 + }
2739 +
2740 +
2741 + //--------------------------------------------------------------------------------------------------
2742 + double  dbetaCorrectedIsoDr03(ControlFlags & ctrl,
2743 +                              const mithep::PFCandidate * photon,
2744 +                              const mithep::Electron * lepton,
2745 +                              const mithep::Array<mithep::PFCandidate> * fPFCandidates)
2746 + //--------------------------------------------------------------------------------------------------
2747 + {
2748 +
2749 +  //
2750 +  // final iso
2751 +  //
2752 +  Double_t fChargedIso  = 0.0;
2753 +  Double_t fGammaIso  = 0.0;
2754 +  Double_t fNeutralHadronIso  = 0.0;
2755 +  Double_t fpfPU  = 0.0;
2756 +
2757 +  //
2758 +  // Loop over PF Candidates
2759 +  //
2760 +  for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2761 +
2762 +    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
2763 +    
2764 +    Double_t deta = (photon->Eta() - pf->Eta());
2765 +    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(photon->Phi()),Double_t(pf->Phi()));
2766 +    Double_t dr = mithep::MathUtils::DeltaR(photon->Phi(),photon->Eta(), pf->Phi(), pf->Eta());
2767 +    if (dr > 0.3) continue;
2768 +
2769 +    if( !(PFnoPUflag[k]) && pf->Charge() != 0 ) {
2770 +      if( pf->Pt() >= 0.2 && dr > 0.01 )
2771 +        fpfPU += pf->Pt();
2772 +      continue;
2773 +    }
2774 +    
2775 +    //
2776 +    // skip this photon
2777 +    //
2778 +    if( abs(pf->PFType()) == mithep::PFCandidate::eGamma &&
2779 +        pf->Et() == photon->Et() ) continue;
2780 +    
2781 +      
2782 +    //
2783 +    // Charged Iso
2784 +    //
2785 +    if (pf->Charge() != 0 ) {
2786 +      if( dr > 0.01 && pf->Pt() >= 0.2 &&
2787 +          !(pf->TrackerTrk() == lepton->TrackerTrk()) )
2788 +        fChargedIso += pf->Pt();
2789 +    }
2790 +    
2791 +    //
2792 +    // Gamma Iso
2793 +    //
2794 +    else if (abs(pf->PFType()) == mithep::PFCandidate::eGamma) {
2795 +      if( pf->Pt() > 0.5 && dr > 0.01)
2796 +        fGammaIso += pf->Pt();
2797 +    }
2798 +    
2799 +    //
2800 +    // Other Neutrals
2801 +    //
2802 +    else {
2803 +      if( pf->Pt() > 0.5 && dr > 0.01)
2804 +        fNeutralHadronIso += pf->Pt();
2805 +    }
2806 +    
2807 +  }
2808 +  
2809 +  if( ctrl.debug ) {
2810 +    cout << "photon dbetaIso :: " << endl;
2811 +    cout << "\tfChargedIso: " << fChargedIso
2812 +         << "\tfGammaIso: " << fGammaIso
2813 +         << "\tfNeutralHadronIso: " << fNeutralHadronIso
2814 +         << "\tfpfPU: " << fpfPU
2815 +         << endl;
2816 +  }
2817 +  double pfIso = fChargedIso + fGammaIso + fNeutralHadronIso - 0.5*fpfPU;
2818 +  return pfIso/photon->Pt();
2819 + }
2820 +
2821 +
2822 +
2823 +
2824 +
2825 + //--------------------------------------------------------------------------------------------------
2826 + double  nonCorrectedIsoDr03(ControlFlags & ctrl,
2827 +                            const mithep::PFCandidate * photon,
2828 +                            const mithep::Muon * lepton,
2829 +                            const mithep::Array<mithep::PFCandidate> * fPFCandidates)
2830 + //--------------------------------------------------------------------------------------------------
2831 + {
2832 +
2833 +  //
2834 +  // final iso
2835 +  //
2836 +  Double_t fChargedIso  = 0.0;
2837 +  Double_t fGammaIso  = 0.0;
2838 +  Double_t fNeutralHadronIso  = 0.0;
2839 +  Double_t fpfPU  = 0.0;
2840 +
2841 +  //
2842 +  // Loop over PF Candidates
2843 +  //
2844 +  for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2845 +
2846 +    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
2847 +
2848 +    Double_t deta = (photon->Eta() - pf->Eta());
2849 +    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(photon->Phi()),Double_t(pf->Phi()));
2850 +    Double_t dr = mithep::MathUtils::DeltaR(photon->Phi(),photon->Eta(), pf->Phi(), pf->Eta());
2851 +    if (dr > 0.3) continue;
2852 +
2853 +    if( !(PFnoPUflag[k]) && pf->Charge() != 0 ) {
2854 +      if( pf->Pt() >= 0.2 && dr > 0.01 )
2855 +        fpfPU += pf->Pt();
2856 +      continue;
2857 +    }
2858 +    
2859 +    //
2860 +    // skip this photon
2861 +    //
2862 +    if( abs(pf->PFType()) == mithep::PFCandidate::eGamma &&
2863 +        pf->Et() == photon->Et() ) continue;
2864 +    
2865 +      
2866 +    //
2867 +    // Charged Iso
2868 +    //
2869 +    if (pf->Charge() != 0 ) {
2870 +      if( dr > 0.01 && pf->Pt() >= 0.2 &&
2871 +          !(pf->TrackerTrk() == lepton->TrackerTrk()) )
2872 +        fChargedIso += pf->Pt();
2873 +    }
2874 +    
2875 +    //
2876 +    // Gamma Iso
2877 +    //
2878 +    else if (abs(pf->PFType()) == mithep::PFCandidate::eGamma) {
2879 +      if( pf->Pt() > 0.5 && dr > 0.01)
2880 +        fGammaIso += pf->Pt();
2881 +    }
2882 +    
2883 +    //
2884 +    // Other Neutrals
2885 +    //
2886 +    else {
2887 +      if( pf->Pt() > 0.5 && dr > 0.01)
2888 +        fNeutralHadronIso += pf->Pt();
2889 +    }
2890 +    
2891 +  }
2892 +  
2893 +  if( ctrl.debug ) {
2894 +    cout << "photon dbetaIso :: " << endl;
2895 +    cout << "\tfChargedIso: " << fChargedIso
2896 +         << "\tfGammaIso: " << fGammaIso
2897 +         << "\tfNeutralHadronIso: " << fNeutralHadronIso
2898 +         << "\tfpfPU: " << fpfPU
2899 +         << endl;
2900 +  }  
2901 +
2902 +  double pfIso = fChargedIso + fGammaIso + fNeutralHadronIso + fpfPU;
2903 +  return pfIso/photon->Pt();
2904 + }
2905 +
2906 +
2907 +
2908 + //--------------------------------------------------------------------------------------------------
2909 + double  nonCorrectedIsoDr03(ControlFlags & ctrl,
2910 +                            const mithep::PFCandidate * photon,
2911 +                            const mithep::Electron * lepton,
2912 +                            const mithep::Array<mithep::PFCandidate> * fPFCandidates)
2913 + //--------------------------------------------------------------------------------------------------
2914 + {
2915 +
2916 +  //
2917 +  // final iso
2918 +  //
2919 +  Double_t fChargedIso  = 0.0;
2920 +  Double_t fGammaIso  = 0.0;
2921 +  Double_t fNeutralHadronIso  = 0.0;
2922 +  Double_t fpfPU  = 0.0;
2923 +
2924 +  //
2925 +  // Loop over PF Candidates
2926 +  //
2927 +  for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2928 +
2929 +    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
2930 +
2931 +    Double_t deta = (photon->Eta() - pf->Eta());
2932 +    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(photon->Phi()),Double_t(pf->Phi()));
2933 +    Double_t dr = mithep::MathUtils::DeltaR(photon->Phi(),photon->Eta(), pf->Phi(), pf->Eta());
2934 +    if (dr > 0.3) continue;
2935 +
2936 +    if( !(PFnoPUflag[k]) && pf->Charge() != 0 ) {
2937 +      if( pf->Pt() >= 0.2 && dr > 0.01 )
2938 +        fpfPU += pf->Pt();
2939 +      continue;
2940 +    }
2941 +    
2942 +    //
2943 +    // skip this photon
2944 +    //
2945 +    if( abs(pf->PFType()) == mithep::PFCandidate::eGamma &&
2946 +        pf->Et() == photon->Et() ) continue;
2947 +    
2948 +      
2949 +    //
2950 +    // Charged Iso
2951 +    //
2952 +    if (pf->Charge() != 0 ) {
2953 +      if( dr > 0.01 && pf->Pt() >= 0.2 &&
2954 +          !(pf->TrackerTrk() == lepton->TrackerTrk()) )
2955 +        fChargedIso += pf->Pt();
2956 +    }
2957 +    
2958 +    //
2959 +    // Gamma Iso
2960 +    //
2961 +    else if (abs(pf->PFType()) == mithep::PFCandidate::eGamma) {
2962 +      if( pf->Pt() > 0.5 && dr > 0.01)
2963 +        fGammaIso += pf->Pt();
2964 +    }
2965 +    
2966 +    //
2967 +    // Other Neutrals
2968 +    //
2969 +    else {
2970 +      if( pf->Pt() > 0.5 && dr > 0.01)
2971 +        fNeutralHadronIso += pf->Pt();
2972 +    }
2973 +    
2974 +  }
2975 +  
2976 +  if( ctrl.debug ) {
2977 +    cout << "photon dbetaIso :: " << endl;
2978 +    cout << "\tfChargedIso: " << fChargedIso
2979 +         << "\tfGammaIso: " << fGammaIso
2980 +         << "\tfNeutralHadronIso: " << fNeutralHadronIso
2981 +         << "\tfpfPU: " << fpfPU
2982 +         << endl;
2983 +  }
2984 +  double pfIso = fChargedIso + fGammaIso + fNeutralHadronIso + fpfPU;
2985 +  return pfIso/photon->Pt();
2986 + }
2987 +
2988 +
2989 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines