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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines