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.12 by khahn, Sun May 6 12:44:45 2012 UTC vs.
Revision 1.17 by khahn, Fri May 11 20:26:43 2012 UTC

# Line 16 | Line 16 | mithep::MuonTools       muT;
16   mithep::ElectronIDMVA * eleIsoMVA;
17   mithep::ElectronTools   eleT;
18  
19 + // global hack to sync
20 + double gChargedIso;
21 + double gGammaIso;
22 + double gNeutralIso;
23 +
24 +
25   //--------------------------------------------------------------------------------------------------
26   Float_t computePFMuonIso(const mithep::Muon *muon,
27                           const mithep::Vertex & vtx,
# Line 157 | Line 163 | bool pairwiseIsoSelection( ControlFlags
163  
164            float isoEcal_corr_j = lepvec[j].isoEcal - (effArea_ecal_j*rho);
165            float isoHcal_corr_j = lepvec[j].isoHcal - (effArea_hcal_j*rho);
166 <          float RIso_i = (lepvec[i].isoTrk+isoEcal_corr_i+isoHcal_corr_i)/lepvec[i].vec->Pt();
167 <          float RIso_j = (lepvec[j].isoTrk+isoEcal_corr_j+isoHcal_corr_j)/lepvec[j].vec->Pt();      
166 >          float RIso_i = (lepvec[i].isoTrk+isoEcal_corr_i+isoHcal_corr_i)/lepvec[i].vec.Pt();
167 >          float RIso_j = (lepvec[j].isoTrk+isoEcal_corr_j+isoHcal_corr_j)/lepvec[j].vec.Pt();      
168            float comboIso = RIso_i + RIso_j;
169            
170            if( comboIso > 0.35 ) {
# Line 371 | Line 377 | SelectionStatus muonIsoMVASelection(Cont
377            IsLeptonFootprint = kTRUE;
378        } // loop over electrons
379        
380 +      /* KH - commented for sync
381        //
382        // Check for muons
383        //
# Line 385 | Line 392 | SelectionStatus muonIsoMVASelection(Cont
392          if (pf->Charge() != 0 && mithep::MathUtils::DeltaR(tmpmu->Phi(),tmpmu->Eta(), pf->Phi(), pf->Eta()) < 0.01)
393            IsLeptonFootprint = kTRUE;
394        } // loop over muons
395 <
395 >      */
396  
397      if (IsLeptonFootprint)
398        continue;
# Line 662 | Line 669 | double  muonPFIso04(ControlFlags &ctrl,
669              && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.08)
670            IsLeptonFootprint = kTRUE;
671        } // loop over electrons
672 <      
672 >
673 >      // KH, comment to sync
674 >      /*
675        //
676        // Check for muons
677        //
# Line 677 | Line 686 | double  muonPFIso04(ControlFlags &ctrl,
686          if (pf->Charge() != 0 && mithep::MathUtils::DeltaR(tmpmu->Phi(),tmpmu->Eta(), pf->Phi(), pf->Eta()) < 0.01)
687            IsLeptonFootprint = kTRUE;
688        } // loop over muons
689 +      */
690 +
691 +    if (IsLeptonFootprint)
692 +      continue;
693 +
694 +    //
695 +    // Charged Iso
696 +    //
697 +    if (pf->Charge() != 0 ) {
698 +
699 +      //if( dr < 0.01 ) continue; // only for muon iso mva?
700 +      if (abs(pf->PFType()) == PFCandidate::eElectron || abs(pf->PFType()) == PFCandidate::eMuon) continue;
701 +
702 +      if( pf->HasTrackerTrk() ) {
703 +        if (abs(pf->TrackerTrk()->DzCorrected(vtx)) > 0.2) continue;
704 +        if( ctrl.debug ) cout << "charged:: " << pf->PFType() << " " << pf->Pt() << " "
705 +                              << abs(pf->TrackerTrk()->DzCorrected(vtx)) << " "
706 +                              << dr << endl;
707 +      }
708 +      if( pf->HasGsfTrk() ) {
709 +        if (abs(pf->GsfTrk()->DzCorrected(vtx)) > 0.2) continue;
710 +        if( ctrl.debug ) cout << "charged:: " << pf->PFType() << " " << pf->Pt() << " "
711 +                              << abs(pf->GsfTrk()->DzCorrected(vtx)) << " "
712 +                              << dr << endl;
713 +      }
714  
715  
716 +      fChargedIso += pf->Pt();
717 +    }
718 +
719 +    //
720 +    // Gamma Iso
721 +    //
722 +    else if (abs(pf->PFType()) == PFCandidate::eGamma) {
723 +      // KH, add to sync
724 +      if( pf->Pt() > 0.5 )
725 +      fGammaIso += pf->Pt();
726 +    }
727 +
728 +    //
729 +    // Other Neutrals
730 +    //
731 +    else {
732 +      // KH, add to sync
733 +      if( pf->Pt() > 0.5 )
734 +        fNeutralHadronIso += pf->Pt();
735 +    }
736 +    
737 +    }
738 +    
739 +  }
740 +  
741 +  double rho = 0;
742 + //   if (!(isnan(fPUEnergyDensity->At(0)->Rho()) || isinf(fPUEnergyDensity->At(0)->Rho())))
743 + //     rho = fPUEnergyDensity->At(0)->Rho();
744 +  if (!(isnan(fPUEnergyDensity->At(0)->RhoLowEta()) || isinf(fPUEnergyDensity->At(0)->RhoLowEta())))
745 +    rho = fPUEnergyDensity->At(0)->RhoLowEta();
746 +
747 +  // WARNING!!!!  
748 +  // hardcode for sync ...
749 +  EffectiveAreaVersion = muT.kMuEAData2011;
750 +  // WARNING!!!!  
751 +
752 +
753 +  double pfIso = fChargedIso + max(0.0,(fGammaIso + fNeutralHadronIso
754 +                                        -rho*muT.MuonEffectiveArea(muT.kMuGammaAndNeutralHadronIso04,
755 +                                                                   mu->Eta(),EffectiveAreaVersion)));
756 +
757 +  gChargedIso = fChargedIso;
758 +  gGammaIso = fGammaIso;
759 +  gNeutralIso = fNeutralHadronIso;  
760 +  return pfIso;
761 + }
762 +
763 +
764 + //--------------------------------------------------------------------------------------------------
765 + // hacked version
766 + double  muonPFIso04(ControlFlags &ctrl,
767 +                    const mithep::Muon * mu,
768 +                    const mithep::Vertex & vtx,
769 +                    const mithep::Array<mithep::PFCandidate> * fPFCandidates,
770 +                    float rho,
771 +                    mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
772 +                    vector<const mithep::Muon*> muonsToVeto,
773 +                    vector<const mithep::Electron*> electronsToVeto)
774 + //--------------------------------------------------------------------------------------------------
775 + {
776 +
777 +  extern double gChargedIso;  
778 +  extern double  gGammaIso;      
779 +  extern double  gNeutralIso;
780 +  
781 +  if( ctrl.debug ) {
782 +    cout << "muonIsoMVASelection :: muons to veto " << endl;
783 +    for( int i=0; i<muonsToVeto.size(); i++ ) {
784 +      const mithep::Muon * vmu = muonsToVeto[i];
785 +      cout << "\tpt: " << vmu->Pt()
786 +           << "\teta: " << vmu->Eta()
787 +           << "\tphi: " << vmu->Phi()
788 +           << endl;
789 +    }
790 +    cout << "muonIsoMVASelection :: electrson to veto " << endl;
791 +    for( int i=0; i<electronsToVeto.size(); i++ ) {
792 +      const mithep::Electron * vel = electronsToVeto[i];
793 +      cout << "\tpt: " << vel->Pt()
794 +           << "\teta: " << vel->Eta()
795 +           << "\tphi: " << vel->Phi()
796 +           << endl;
797 +    }
798 +  }
799 +
800 +  //
801 +  // final iso
802 +  //
803 +  Double_t fChargedIso  = 0.0;
804 +  Double_t fGammaIso  = 0.0;
805 +  Double_t fNeutralHadronIso  = 0.0;
806 +
807 +  //
808 +  //Loop over PF Candidates
809 +  //
810 +  for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
811 +    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
812 +
813 +    Double_t deta = (mu->Eta() - pf->Eta());
814 +    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(mu->Phi()),Double_t(pf->Phi()));
815 +    Double_t dr = mithep::MathUtils::DeltaR(mu->Phi(),mu->Eta(), pf->Phi(), pf->Eta());
816 +    if (dr > 0.4) continue;
817 +
818 +    if (pf->HasTrackerTrk() && (pf->TrackerTrk() == mu->TrackerTrk()) ) continue;
819 +
820 +    //
821 +    // Lepton Footprint Removal
822 +    //
823 +    Bool_t IsLeptonFootprint = kFALSE;
824 +    if (dr < 1.0) {
825 +
826 +      //
827 +      // Check for electrons
828 +      //
829 +      for (Int_t q=0; q < electronsToVeto.size(); ++q) {
830 +        const mithep::Electron *tmpele = electronsToVeto[q];
831 +        // 4l electron
832 +        if( pf->HasTrackerTrk() ) {
833 +          if( pf->TrackerTrk() == tmpele->TrackerTrk() )
834 +            IsLeptonFootprint = kTRUE;
835 +        }
836 +        if( pf->HasGsfTrk() ) {
837 +          if( pf->GsfTrk() == tmpele->GsfTrk() )
838 +            IsLeptonFootprint = kTRUE;
839 +        }
840 +        // PF charged
841 +        if (pf->Charge() != 0 && fabs(tmpele->SCluster()->Eta()) > 1.479
842 +            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.015)
843 +          IsLeptonFootprint = kTRUE;
844 +        // PF gamma
845 +        if (abs(pf->PFType()) == PFCandidate::eGamma && fabs(tmpele->SCluster()->Eta()) > 1.479
846 +            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.08)
847 +          IsLeptonFootprint = kTRUE;
848 +      } // loop over electrons
849 +
850 +      /* KH - comment for sync      
851 +      //
852 +      // Check for muons
853 +      //
854 +      for (Int_t q=0; q < muonsToVeto.size(); ++q) {
855 +        const mithep::Muon *tmpmu = muonsToVeto[q];
856 +        // 4l muon
857 +        if( pf->HasTrackerTrk() ) {
858 +          if( pf->TrackerTrk() == tmpmu->TrackerTrk() )
859 +            IsLeptonFootprint = kTRUE;
860 +        }
861 +        // PF charged
862 +        if (pf->Charge() != 0 && mithep::MathUtils::DeltaR(tmpmu->Phi(),tmpmu->Eta(), pf->Phi(), pf->Eta()) < 0.01)
863 +          IsLeptonFootprint = kTRUE;
864 +      } // loop over muons
865 +      */
866 +
867      if (IsLeptonFootprint)
868        continue;
869  
870      //
871 <    // Charged Iso Rings
871 >    // Charged Iso
872      //
873      if (pf->Charge() != 0 && (pf->HasTrackerTrk()||pf->HasGsfTrk()) ) {
874  
# Line 715 | Line 900 | double  muonPFIso04(ControlFlags &ctrl,
900      }
901  
902      //
903 <    // Other Neutral Iso Rings
903 >    // Other Neutrals
904      //
905      else {
906 <      fNeutralHadronIso += pf->Pt();
906 >      // KH, add to sync
907 >      if( pf->Pt() > 0.5 )
908 >        fNeutralHadronIso += pf->Pt();
909      }
910      
911      }
912      
913    }
914    
915 <  double rho = 0;
916 <  if (!(isnan(fPUEnergyDensity->At(0)->Rho()) || isinf(fPUEnergyDensity->At(0)->Rho())))
917 <    rho = fPUEnergyDensity->At(0)->Rho();
915 > //   double rho = 0;
916 > //   if (!(isnan(fPUEnergyDensity->At(0)->Rho()) || isinf(fPUEnergyDensity->At(0)->Rho())))
917 > //     rho = fPUEnergyDensity->At(0)->Rho();
918  
919    // WARNING!!!!  
920    // hardcode for sync ...
# Line 738 | Line 925 | double  muonPFIso04(ControlFlags &ctrl,
925    double pfIso = fChargedIso + max(0.0,(fGammaIso + fNeutralHadronIso
926                                          -rho*muT.MuonEffectiveArea(muT.kMuGammaAndNeutralHadronIso04,
927                                                                     mu->Eta(),EffectiveAreaVersion)));
928 +  gChargedIso = fChargedIso;
929 +  gGammaIso   = fGammaIso;
930 +  gNeutralIso = fNeutralHadronIso;
931    
932    return pfIso;
933   }
934  
935 +
936   //--------------------------------------------------------------------------------------------------
937   SelectionStatus muonReferenceIsoSelection(ControlFlags &ctrl,
938                                            const mithep::Muon * mu,
# Line 755 | Line 946 | SelectionStatus muonReferenceIsoSelectio
946   {
947    
948    SelectionStatus status;
949 <  
949 >
950    double pfIso = muonPFIso04( ctrl, mu, vtx, fPFCandidates, fPUEnergyDensity,
951                                EffectiveAreaVersion, muonsToVeto ,electronsToVeto );
952 +  cout << "--------------> setting muon isoPF04 to" << pfIso << endl;
953 +  status.isoPF04 = pfIso;
954 +  status.chisoPF04 = gChargedIso;
955 +  status.gaisoPF04 = gGammaIso;
956 +  status.neisoPF04 = gNeutralIso;
957 +
958 +  bool pass = false;
959 +  if( (pfIso/mu->Pt()) < MUON_REFERENCE_PFISO_CUT ) pass = true;
960 +  
961 +  if( pass ) {
962 +    status.orStatus(SelectionStatus::LOOSEISO);
963 +    status.orStatus(SelectionStatus::TIGHTISO);
964 +  }
965 +  if(ctrl.debug) cout << "returning status : " << hex << status.getStatus() << dec << endl;
966 +  return status;
967 +  
968 + }
969 +
970 +
971 + //--------------------------------------------------------------------------------------------------
972 + // hacked version
973 + SelectionStatus muonReferenceIsoSelection(ControlFlags &ctrl,
974 +                                          const mithep::Muon * mu,
975 +                                          const mithep::Vertex & vtx,
976 +                                          const mithep::Array<mithep::PFCandidate> * fPFCandidates,
977 +                                          float rho,
978 +                                          mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
979 +                                          vector<const mithep::Muon*> muonsToVeto,
980 +                                          vector<const mithep::Electron*> electronsToVeto)
981 + //--------------------------------------------------------------------------------------------------
982 + {
983 +  
984 +  SelectionStatus status;
985 +  
986 +  double pfIso = muonPFIso04( ctrl, mu, vtx, fPFCandidates, rho,
987 +                              EffectiveAreaVersion, muonsToVeto ,electronsToVeto );
988    bool pass = false;
989    if( (pfIso/mu->Pt()) < MUON_REFERENCE_PFISO_CUT ) pass = true;
990    
# Line 911 | Line 1138 | SelectionStatus electronIsoMVASelection(
1138            IsLeptonFootprint = kTRUE;
1139          }
1140        } // loop over electrons
1141 <      
1141 >
1142 >      /* KH - comment for sync            
1143        //
1144        // Check for muons
1145        //
# Line 930 | Line 1158 | SelectionStatus electronIsoMVASelection(
1158            IsLeptonFootprint = kTRUE;
1159          }
1160        } // loop over muons
1161 <
1161 >      */
1162  
1163      if (IsLeptonFootprint)
1164        continue;
# Line 1268 | Line 1496 | float electronPFIso04(ControlFlags &ctrl
1496            IsLeptonFootprint = kTRUE;
1497          }
1498        } // loop over electrons
1499 <      
1499 >
1500 >
1501        //
1502        // Check for muons
1503        //
# Line 1293 | Line 1522 | float electronPFIso04(ControlFlags &ctrl
1522        continue;
1523  
1524      //
1525 <    // Charged Iso Rings
1525 >    // Charged Iso
1526 >    //
1527 >    if (pf->Charge() != 0 ) {
1528 >
1529 >      if( pf->HasTrackerTrk() )
1530 >        if (abs(pf->TrackerTrk()->DzCorrected(vtx)) > 0.2) continue;
1531 >      if( pf->HasGsfTrk() )
1532 >        if (abs(pf->GsfTrk()->DzCorrected(vtx)) > 0.2) continue;
1533 >
1534 >      // Veto any PFmuon, or PFEle
1535 >      if (abs(pf->PFType()) == PFCandidate::eElectron || abs(pf->PFType()) == PFCandidate::eMuon) continue;
1536 >
1537 >      // Footprint Veto
1538 >      if (fabs(ele->SCluster()->Eta()) > 1.479 && dr < 0.015) continue;
1539 >
1540 >      if( ctrl.debug) cout << "charged:: pt: " << pf->Pt()
1541 >                           << "\ttype: " << pf->PFType()
1542 >                           << "\ttrk: " << pf->TrackerTrk() << endl;
1543 >
1544 >      fChargedIso += pf->Pt();
1545 >    }
1546 >
1547 >    //
1548 >    // Gamma Iso
1549 >    //
1550 >    else if (abs(pf->PFType()) == PFCandidate::eGamma) {
1551 >
1552 >      if (fabs(ele->SCluster()->Eta()) > 1.479) {
1553 >        if (mithep::MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta()) < 0.08) continue;
1554 >      }
1555 >      if( ctrl.debug) cout << "gamma:: " << pf->Pt() << " "
1556 >                           << dr << endl;
1557 >      if( pf->Pt() > 0.5 )
1558 >        fGammaIso += pf->Pt();
1559 >    }
1560 >
1561 >    //
1562 >    // Neutral Iso
1563 >    //
1564 >    else {
1565 >      if( ctrl.debug) cout << "neutral:: " << pf->Pt() << " "
1566 >                           << dr << endl;
1567 >      if( pf->Pt() > 0.5 )
1568 >        fNeutralHadronIso += pf->Pt();
1569 >    }
1570 >
1571 >    }
1572 >
1573 >  }
1574 >
1575 >  double rho = 0;
1576 > //   if (!(isnan(fPUEnergyDensity->At(0)->Rho()) || isinf(fPUEnergyDensity->At(0)->Rho())))
1577 > //     rho = fPUEnergyDensity->At(0)->Rho();
1578 >  if (!(isnan(fPUEnergyDensity->At(0)->RhoLowEta()) || isinf(fPUEnergyDensity->At(0)->RhoLowEta())))
1579 >    rho = fPUEnergyDensity->At(0)->RhoLowEta();
1580 >
1581 >  // WARNING!!!!  
1582 >  // hardcode for sync ...
1583 >  EffectiveAreaVersion = eleT.kEleEAData2011;
1584 >  // WARNING!!!!  
1585 >
1586 >
1587 >  double pfIso = fChargedIso +
1588 >    max(0.0,fGammaIso -rho*eleT.ElectronEffectiveArea(eleT.kEleGammaIso04,
1589 >                                                ele->Eta(),EffectiveAreaVersion)) +
1590 >    max(0.0,fNeutralHadronIso -rho*eleT.ElectronEffectiveArea(eleT.kEleNeutralHadronIso04,
1591 >                                                        ele->Eta(),EffectiveAreaVersion)) ;
1592 >
1593 >  gChargedIso = fChargedIso;
1594 >  gGammaIso = fGammaIso;
1595 >  gNeutralIso = fNeutralHadronIso;  
1596 >
1597 >  return pfIso;
1598 > }
1599 >
1600 > //--------------------------------------------------------------------------------------------------
1601 > // hacked version
1602 > float electronPFIso04(ControlFlags &ctrl,
1603 >                      const mithep::Electron * ele,
1604 >                      const mithep::Vertex & vtx,
1605 >                      const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1606 >                      float rho,
1607 >                      mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
1608 >                      vector<const mithep::Muon*> muonsToVeto,
1609 >                      vector<const mithep::Electron*> electronsToVeto)
1610 > //--------------------------------------------------------------------------------------------------
1611 > {
1612 >
1613 >  if( ctrl.debug ) {
1614 >    cout << "electronIsoMVASelection :: muons to veto " << endl;
1615 >    for( int i=0; i<muonsToVeto.size(); i++ ) {
1616 >      const mithep::Muon * vmu = muonsToVeto[i];
1617 >      cout << "\tpt: " << vmu->Pt()
1618 >           << "\teta: " << vmu->Eta()
1619 >           << "\tphi: " << vmu->Phi()
1620 >           << endl;
1621 >    }
1622 >    cout << "electronIsoMVASelection :: electrson to veto " << endl;
1623 >    for( int i=0; i<electronsToVeto.size(); i++ ) {
1624 >      const mithep::Electron * vel = electronsToVeto[i];
1625 >      cout << "\tpt: " << vel->Pt()
1626 >           << "\teta: " << vel->Eta()
1627 >           << "\tphi: " << vel->Phi()
1628 >           << "\ttrk: " << vel->TrackerTrk()
1629 >           << endl;
1630 >    }
1631 >  }
1632 >
1633 >
1634 >  //
1635 >  // final iso
1636 >  //
1637 >  Double_t fChargedIso = 0.0;
1638 >  Double_t fGammaIso = 0.0;
1639 >  Double_t fNeutralHadronIso = 0.0;
1640 >
1641 >
1642 >  //
1643 >  //Loop over PF Candidates
1644 >  //
1645 >  for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
1646 >    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
1647 >    Double_t deta = (ele->Eta() - pf->Eta());
1648 >    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(ele->Phi()),Double_t(pf->Phi()));
1649 >    Double_t dr = mithep::MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta());
1650 >    if (dr >= 0.4) continue;
1651 >    if(ctrl.debug) {
1652 >      cout << "pf :: type: " << pf->PFType() << "\tpt: " << pf->Pt();
1653 >      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(vtx);
1654 >      cout << endl;
1655 >    }
1656 >
1657 >
1658 >    if ( (pf->HasTrackerTrk() && (pf->TrackerTrk() == ele->TrackerTrk())) ||
1659 >         (pf->HasGsfTrk() && (pf->GsfTrk() == ele->GsfTrk()))) continue;
1660 >    
1661 >
1662 >    //
1663 >    // Lepton Footprint Removal
1664 >    //
1665 >    Bool_t IsLeptonFootprint = kFALSE;
1666 >    if (dr < 1.0) {
1667 >
1668 >      //
1669 >      // Check for electrons
1670 >      //
1671 >      for (Int_t q=0; q < electronsToVeto.size(); ++q) {
1672 >        const mithep::Electron *tmpele = electronsToVeto[q];
1673 >        // 4l electron
1674 >        if( pf->HasTrackerTrk()  ) {
1675 >          if( pf->TrackerTrk() == tmpele->TrackerTrk() ) {
1676 >            if( ctrl.debug) cout << "\tcharged tktrk, matches 4L ele ..." << endl;
1677 >            IsLeptonFootprint = kTRUE;
1678 >          }
1679 >        }
1680 >        if( pf->HasGsfTrk()  ) {
1681 >          if( pf->GsfTrk() == tmpele->GsfTrk() ) {
1682 >            if( ctrl.debug) cout << "\tcharged gsftrk, matches 4L ele ..." << endl;
1683 >            IsLeptonFootprint = kTRUE;
1684 >          }
1685 >        }
1686 >        // PF charged
1687 >        if (pf->Charge() != 0 && fabs(tmpele->SCluster()->Eta()) > 1.479
1688 >            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.015) {
1689 >          if( ctrl.debug) cout << "\tcharged trk, dR matches 4L ele ..." << endl;
1690 >          IsLeptonFootprint = kTRUE;
1691 >        }
1692 >        // PF gamma
1693 >        if (abs(pf->PFType()) == PFCandidate::eGamma && fabs(tmpele->SCluster()->Eta()) > 1.479
1694 >            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.08) {
1695 >          if( ctrl.debug) cout << "\tPF gamma, matches 4L ele ..." << endl;
1696 >          IsLeptonFootprint = kTRUE;
1697 >        }
1698 >      } // loop over electrons
1699 >
1700 >      /* KH - comment for sync            
1701 >      //
1702 >      // Check for muons
1703 >      //
1704 >      for (Int_t q=0; q < muonsToVeto.size(); ++q) {
1705 >        const mithep::Muon *tmpmu = muonsToVeto[q];
1706 >        // 4l muon
1707 >        if( pf->HasTrackerTrk() ) {
1708 >          if (pf->TrackerTrk() == tmpmu->TrackerTrk() ){
1709 >            if( ctrl.debug) cout << "\tmatches 4L mu ..." << endl;
1710 >            IsLeptonFootprint = kTRUE;
1711 >          }
1712 >        }
1713 >        // PF charged
1714 >        if (pf->Charge() != 0 && mithep::MathUtils::DeltaR(tmpmu->Phi(),tmpmu->Eta(), pf->Phi(), pf->Eta()) < 0.01) {
1715 >          if( ctrl.debug) cout << "\tcharged trk, dR matches 4L mu ..." << endl;
1716 >          IsLeptonFootprint = kTRUE;
1717 >        }
1718 >      } // loop over muons
1719 >      */
1720 >
1721 >    if (IsLeptonFootprint)
1722 >      continue;
1723 >
1724 >    //
1725 >    // Charged Iso
1726      //
1727      if (pf->Charge() != 0 && (pf->HasTrackerTrk()||pf->HasGsfTrk()) ) {
1728  
# Line 1334 | Line 1763 | float electronPFIso04(ControlFlags &ctrl
1763      else {
1764        if( ctrl.debug) cout << "neutral:: " << pf->Pt() << " "
1765                             << dr << endl;
1766 <      fNeutralHadronIso += pf->Pt();
1766 >      // KH, add to sync
1767 >      if( pf->Pt() > 0.5 )
1768 >        fNeutralHadronIso += pf->Pt();
1769      }
1770  
1771      }
1772  
1773    }
1774  
1775 <  double rho = 0;
1776 <  if (!(isnan(fPUEnergyDensity->At(0)->Rho()) || isinf(fPUEnergyDensity->At(0)->Rho())))
1777 <    rho = fPUEnergyDensity->At(0)->Rho();
1775 > //   double rho = 0;
1776 > //   if (!(isnan(fPUEnergyDensity->At(0)->Rho()) || isinf(fPUEnergyDensity->At(0)->Rho())))
1777 > //     rho = fPUEnergyDensity->At(0)->Rho();
1778  
1779    // WARNING!!!!  
1780    // hardcode for sync ...
# Line 1359 | Line 1790 | float electronPFIso04(ControlFlags &ctrl
1790    return pfIso;
1791   }
1792  
1793 +
1794   //--------------------------------------------------------------------------------------------------
1795   SelectionStatus electronReferenceIsoSelection(ControlFlags &ctrl,
1796                                                const mithep::Electron * ele,
# Line 1375 | Line 1807 | SelectionStatus electronReferenceIsoSele
1807  
1808    double pfIso = electronPFIso04( ctrl, ele, vtx, fPFCandidates, fPUEnergyDensity,
1809                                    EffectiveAreaVersion, muonsToVeto ,electronsToVeto );
1810 +  cout << "--------------> setting electron isoPF04 to " << pfIso << endl;
1811 +  status.isoPF04 = pfIso;
1812 +  status.chisoPF04 = gChargedIso;
1813 +  status.gaisoPF04 = gGammaIso;
1814 +  status.neisoPF04 = gNeutralIso;
1815 +
1816 +  bool pass = false;
1817 +  if( (pfIso/ele->Pt()) < ELECTRON_REFERENCE_PFISO_CUT ) pass = true;
1818 +
1819 +  if( pass ) {
1820 +    status.orStatus(SelectionStatus::LOOSEISO);
1821 +    status.orStatus(SelectionStatus::TIGHTISO);
1822 +  }
1823 +  if(ctrl.debug) cout << "returning status : " << hex << status.getStatus() << dec << endl;
1824 +  return status;
1825 +
1826 + }
1827 +
1828 +
1829 + //--------------------------------------------------------------------------------------------------
1830 + // hacked version
1831 + SelectionStatus electronReferenceIsoSelection(ControlFlags &ctrl,
1832 +                                              const mithep::Electron * ele,
1833 +                                              const mithep::Vertex & vtx,
1834 +                                              const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1835 +                                              float rho,
1836 +                                              mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
1837 +                                              vector<const mithep::Muon*> muonsToVeto,
1838 +                                              vector<const mithep::Electron*> electronsToVeto)
1839 + //--------------------------------------------------------------------------------------------------
1840 + {
1841 +
1842 +  SelectionStatus status;
1843 +
1844 +  double pfIso = electronPFIso04( ctrl, ele, vtx, fPFCandidates, rho,
1845 +                                  EffectiveAreaVersion, muonsToVeto ,electronsToVeto );
1846    bool pass = false;
1847    if( (pfIso/ele->Pt()) < ELECTRON_REFERENCE_PFISO_CUT ) pass = true;
1848  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines