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.10 by khahn, Sat May 5 13:09:05 2012 UTC vs.
Revision 1.16 by khahn, Thu May 10 22:53:21 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 612 | Line 619 | double  muonPFIso04(ControlFlags &ctrl,
619             << endl;
620      }
621    }
615  bool failiso=false;
622  
623    //
624 <  // tmp iso
624 >  // final iso
625    //
626 <  Double_t tmpChargedIso        = 0;
627 <  Double_t tmpGammaIso          = 0;
628 <  Double_t tmpNeutralHadronIso  = 0;
626 >  Double_t fChargedIso  = 0.0;
627 >  Double_t fGammaIso  = 0.0;
628 >  Double_t fNeutralHadronIso  = 0.0;
629 >
630 >  //
631 >  //Loop over PF Candidates
632 >  //
633 >  for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
634 >    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
635 >
636 >    Double_t deta = (mu->Eta() - pf->Eta());
637 >    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(mu->Phi()),Double_t(pf->Phi()));
638 >    Double_t dr = mithep::MathUtils::DeltaR(mu->Phi(),mu->Eta(), pf->Phi(), pf->Eta());
639 >    if (dr > 0.4) continue;
640 >
641 >    if (pf->HasTrackerTrk() && (pf->TrackerTrk() == mu->TrackerTrk()) ) continue;
642 >
643 >    //
644 >    // Lepton Footprint Removal
645 >    //
646 >    Bool_t IsLeptonFootprint = kFALSE;
647 >    if (dr < 1.0) {
648 >
649 >      //
650 >      // Check for electrons
651 >      //
652 >      for (Int_t q=0; q < electronsToVeto.size(); ++q) {
653 >        const mithep::Electron *tmpele = electronsToVeto[q];
654 >        // 4l electron
655 >        if( pf->HasTrackerTrk() ) {
656 >          if( pf->TrackerTrk() == tmpele->TrackerTrk() )
657 >            IsLeptonFootprint = kTRUE;
658 >        }
659 >        if( pf->HasGsfTrk() ) {
660 >          if( pf->GsfTrk() == tmpele->GsfTrk() )
661 >            IsLeptonFootprint = kTRUE;
662 >        }
663 >        // PF charged
664 >        if (pf->Charge() != 0 && fabs(tmpele->SCluster()->Eta()) > 1.479
665 >            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.015)
666 >          IsLeptonFootprint = kTRUE;
667 >        // PF gamma
668 >        if (abs(pf->PFType()) == PFCandidate::eGamma && fabs(tmpele->SCluster()->Eta()) > 1.479
669 >            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.08)
670 >          IsLeptonFootprint = kTRUE;
671 >      } // loop over electrons
672 >
673 >      // KH, comment to sync
674 >      /*
675 >      //
676 >      // Check for muons
677 >      //
678 >      for (Int_t q=0; q < muonsToVeto.size(); ++q) {
679 >        const mithep::Muon *tmpmu = muonsToVeto[q];
680 >        // 4l muon
681 >        if( pf->HasTrackerTrk() ) {
682 >          if( pf->TrackerTrk() == tmpmu->TrackerTrk() )
683 >            IsLeptonFootprint = kTRUE;
684 >        }
685 >        // PF charged
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;
804 <  Double_t fGammaIso;
805 <  Double_t fNeutralHadronIso;
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
# Line 670 | Line 846 | double  muonPFIso04(ControlFlags &ctrl,
846              && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.08)
847            IsLeptonFootprint = kTRUE;
848        } // loop over electrons
849 <      
849 >
850 >      /* KH - comment for sync      
851        //
852        // Check for muons
853        //
# Line 685 | Line 862 | double  muonPFIso04(ControlFlags &ctrl,
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 <
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 712 | Line 889 | double  muonPFIso04(ControlFlags &ctrl,
889        }
890  
891  
892 <      tmpChargedIso += pf->Pt();
892 >      fChargedIso += pf->Pt();
893      }
894  
895      //
896      // Gamma Iso
897      //
898      else if (abs(pf->PFType()) == PFCandidate::eGamma) {
899 <      tmpGammaIso += pf->Pt();
899 >      fGammaIso += pf->Pt();
900      }
901  
902      //
903 <    // Other Neutral Iso Rings
903 >    // Other Neutrals
904      //
905      else {
906 <      tmpNeutralHadronIso += pf->Pt();
906 >      // KH, add to sync
907 >      if( pf->Pt() > 0.5 )
908 >        fNeutralHadronIso += pf->Pt();
909      }
910      
911      }
912      
913    }
914    
915 <  fChargedIso   = mu->Pt() * min((tmpChargedIso)/mu->Pt(), 2.5);
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 ...
921 >  EffectiveAreaVersion = muT.kMuEAData2011;
922 >  // WARNING!!!!  
923 >
924 >
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 <  double rho = 0;
936 <  if (!(isnan(fPUEnergyDensity->At(0)->Rho()) || isinf(fPUEnergyDensity->At(0)->Rho())))
937 <    rho = fPUEnergyDensity->At(0)->Rho();
935 >
936 > //--------------------------------------------------------------------------------------------------
937 > SelectionStatus muonReferenceIsoSelection(ControlFlags &ctrl,
938 >                                          const mithep::Muon * mu,
939 >                                          const mithep::Vertex & vtx,
940 >                                          const mithep::Array<mithep::PFCandidate> * fPFCandidates,
941 >                                          const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
942 >                                          mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
943 >                                          vector<const mithep::Muon*> muonsToVeto,
944 >                                          vector<const mithep::Electron*> electronsToVeto)
945 > //--------------------------------------------------------------------------------------------------
946 > {
947    
948 <
744 <  fGammaIso = mu->Pt()*max(min((tmpGammaIso
745 <                                -rho*muT.MuonEffectiveArea(muT.kMuGammaIso04,mu->Eta(),EffectiveAreaVersion))/mu->Pt()
746 <                               ,2.5)
747 <                           ,0.0);
748 <  fNeutralHadronIso = mu->Pt()*max(min((tmpNeutralHadronIso
749 <                                        -rho*muT.MuonEffectiveArea(muT.kMuNeutralIso04,
750 <                                                                   mu->Eta(),EffectiveAreaVersion))/mu->Pt()
751 <                                       , 2.5)
752 <                                   , 0.0);
948 >  SelectionStatus status;
949  
950 <  double pfIso = fChargedIso + fGammaIso + fNeutralHadronIso;
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    
756  return pfIso;
968   }
969  
970 +
971   //--------------------------------------------------------------------------------------------------
972 < SelectionStatus muonIsoReferenceSelection(ControlFlags &ctrl,
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 <                                          const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
977 >                                          float rho,
978                                            mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
979                                            vector<const mithep::Muon*> muonsToVeto,
980                                            vector<const mithep::Electron*> electronsToVeto)
# Line 770 | Line 983 | SelectionStatus muonIsoReferenceSelectio
983    
984    SelectionStatus status;
985    
986 <  double pfIso = muonPFIso04( ctrl, mu, vtx, fPFCandidates, fPUEnergyDensity,
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;
# Line 925 | 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 944 | Line 1158 | SelectionStatus electronIsoMVASelection(
1158            IsLeptonFootprint = kTRUE;
1159          }
1160        } // loop over muons
1161 <
1161 >      */
1162  
1163      if (IsLeptonFootprint)
1164        continue;
# Line 1216 | Line 1430 | float electronPFIso04(ControlFlags &ctrl
1430      }
1431    }
1432  
1219  bool failiso=false;
1220
1221  //
1222  // tmp iso
1223  //
1224  Double_t tmpChargedIso        = 0;
1225  Double_t tmpGammaIso          = 0;
1226  Double_t tmpNeutralHadronIso  = 0;
1433  
1434    //
1435    // final iso
1436    //
1437 <  Double_t fChargedIso;
1438 <  Double_t fGammaIso;
1439 <  Double_t fNeutralHadronIso;
1437 >  Double_t fChargedIso = 0.0;
1438 >  Double_t fGammaIso = 0.0;
1439 >  Double_t fNeutralHadronIso = 0.0;
1440  
1441  
1442    //
# Line 1290 | Line 1496 | float electronPFIso04(ControlFlags &ctrl
1496            IsLeptonFootprint = kTRUE;
1497          }
1498        } // loop over electrons
1499 <      
1499 >
1500 >
1501        //
1502        // Check for muons
1503        //
# Line 1315 | Line 1522 | float electronPFIso04(ControlFlags &ctrl
1522        continue;
1523  
1524      //
1525 <    // Charged Iso Rings
1525 >    // Charged Iso
1526      //
1527 <    if (pf->Charge() != 0 && (pf->HasTrackerTrk()||pf->HasGsfTrk()) ) {
1527 >    if (pf->Charge() != 0 ) {
1528  
1529        if( pf->HasTrackerTrk() )
1530          if (abs(pf->TrackerTrk()->DzCorrected(vtx)) > 0.2) continue;
# Line 1334 | Line 1541 | float electronPFIso04(ControlFlags &ctrl
1541                             << "\ttype: " << pf->PFType()
1542                             << "\ttrk: " << pf->TrackerTrk() << endl;
1543  
1544 <      tmpChargedIso += pf->Pt();
1544 >      fChargedIso += pf->Pt();
1545      }
1546  
1547      //
# Line 1347 | Line 1554 | float electronPFIso04(ControlFlags &ctrl
1554        }
1555        if( ctrl.debug) cout << "gamma:: " << pf->Pt() << " "
1556                             << dr << endl;
1557 <      tmpGammaIso += pf->Pt();
1557 >      fGammaIso += pf->Pt();
1558      }
1559  
1560      //
# Line 1356 | Line 1563 | float electronPFIso04(ControlFlags &ctrl
1563      else {
1564        if( ctrl.debug) cout << "neutral:: " << pf->Pt() << " "
1565                             << dr << endl;
1566 <      tmpNeutralHadronIso += pf->Pt();
1566 >        fNeutralHadronIso += pf->Pt();
1567      }
1568  
1569      }
1570  
1571    }
1572  
1366  fChargedIso   = ele->Pt()*min((tmpChargedIso)/ele->Pt(), 2.5);
1367
1573    double rho = 0;
1574 <  if (!(isnan(fPUEnergyDensity->At(0)->Rho()) || isinf(fPUEnergyDensity->At(0)->Rho())))
1575 <    rho = fPUEnergyDensity->At(0)->Rho();
1574 > //   if (!(isnan(fPUEnergyDensity->At(0)->Rho()) || isinf(fPUEnergyDensity->At(0)->Rho())))
1575 > //     rho = fPUEnergyDensity->At(0)->Rho();
1576 >  if (!(isnan(fPUEnergyDensity->At(0)->RhoLowEta()) || isinf(fPUEnergyDensity->At(0)->RhoLowEta())))
1577 >    rho = fPUEnergyDensity->At(0)->RhoLowEta();
1578 >
1579 >  // WARNING!!!!  
1580 >  // hardcode for sync ...
1581 >  EffectiveAreaVersion = eleT.kEleEAData2011;
1582 >  // WARNING!!!!  
1583 >
1584 >
1585 >  double pfIso = fChargedIso +
1586 >    max(0.0,fGammaIso -rho*eleT.ElectronEffectiveArea(eleT.kEleGammaIso04,
1587 >                                                ele->Eta(),EffectiveAreaVersion)) +
1588 >    max(0.0,fNeutralHadronIso -rho*eleT.ElectronEffectiveArea(eleT.kEleNeutralHadronIso04,
1589 >                                                        ele->Eta(),EffectiveAreaVersion)) ;
1590 >
1591 >  gChargedIso = fChargedIso;
1592 >  gGammaIso = fGammaIso;
1593 >  gNeutralIso = fNeutralHadronIso;  
1594  
1595 <  if( ctrl.debug) {
1596 <    cout << "RHO: " << rho << endl;
1597 <    cout << "eta: " << ele->SCluster()->Eta() << endl;
1598 <    cout << "target: " << EffectiveAreaVersion << endl;
1599 <    cout << "effA 0-1: " << eleT.ElectronEffectiveArea(eleT.kEleNeutralHadronIsoDR0p0To0p1,
1600 <                                                       ele->SCluster()->Eta(),
1601 <                                                       EffectiveAreaVersion)
1602 <         << endl;
1603 <    cout << "effA 1-2: " << eleT.ElectronEffectiveArea(eleT.kEleNeutralHadronIsoDR0p1To0p2,
1604 <                                                       ele->SCluster()->Eta(),
1605 <                                                       EffectiveAreaVersion)
1606 <         << endl;
1607 <    cout << "effA 2-3: " << eleT.ElectronEffectiveArea(eleT.kEleNeutralHadronIsoDR0p2To0p3,
1608 <                                                       ele->SCluster()->Eta(),
1609 <                                                       EffectiveAreaVersion)
1610 <         << endl;
1611 <    cout << "effA 3-4: " << eleT.ElectronEffectiveArea(eleT.kEleNeutralHadronIsoDR0p3To0p4,
1612 <                                                       ele->SCluster()->Eta(),
1613 <                                                       EffectiveAreaVersion)
1614 <         << endl;
1595 >  return pfIso;
1596 > }
1597 >
1598 > //--------------------------------------------------------------------------------------------------
1599 > // hacked version
1600 > float electronPFIso04(ControlFlags &ctrl,
1601 >                      const mithep::Electron * ele,
1602 >                      const mithep::Vertex & vtx,
1603 >                      const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1604 >                      float rho,
1605 >                      mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
1606 >                      vector<const mithep::Muon*> muonsToVeto,
1607 >                      vector<const mithep::Electron*> electronsToVeto)
1608 > //--------------------------------------------------------------------------------------------------
1609 > {
1610 >
1611 >  if( ctrl.debug ) {
1612 >    cout << "electronIsoMVASelection :: muons to veto " << endl;
1613 >    for( int i=0; i<muonsToVeto.size(); i++ ) {
1614 >      const mithep::Muon * vmu = muonsToVeto[i];
1615 >      cout << "\tpt: " << vmu->Pt()
1616 >           << "\teta: " << vmu->Eta()
1617 >           << "\tphi: " << vmu->Phi()
1618 >           << endl;
1619 >    }
1620 >    cout << "electronIsoMVASelection :: electrson to veto " << endl;
1621 >    for( int i=0; i<electronsToVeto.size(); i++ ) {
1622 >      const mithep::Electron * vel = electronsToVeto[i];
1623 >      cout << "\tpt: " << vel->Pt()
1624 >           << "\teta: " << vel->Eta()
1625 >           << "\tphi: " << vel->Phi()
1626 >           << "\ttrk: " << vel->TrackerTrk()
1627 >           << endl;
1628 >    }
1629    }
1630  
1394  fGammaIso = ele->Pt()*max(min((tmpGammaIso
1395                       -rho*eleT.ElectronEffectiveArea(eleT.kEleGammaIso04,
1396                                                       ele->SCluster()->Eta(),
1397                                                       EffectiveAreaVersion))/ele->Pt()
1398                      ,2.5)
1399                  ,0.0);
1400  fNeutralHadronIso = ele->Pt()*max(min((tmpNeutralHadronIso
1401                               -rho*eleT.ElectronEffectiveArea(eleT.kEleNeutralHadronIso04,
1402                                                               ele->SCluster()->Eta(),EffectiveAreaVersion))/ele->Pt()
1403                              , 2.5)
1404                          , 0.0);
1631  
1632 <  double pfiso = fChargedIso + fGammaIso + fNeutralHadronIso;
1632 >  //
1633 >  // final iso
1634 >  //
1635 >  Double_t fChargedIso = 0.0;
1636 >  Double_t fGammaIso = 0.0;
1637 >  Double_t fNeutralHadronIso = 0.0;
1638 >
1639 >
1640 >  //
1641 >  //Loop over PF Candidates
1642 >  //
1643 >  for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
1644 >    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
1645 >    Double_t deta = (ele->Eta() - pf->Eta());
1646 >    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(ele->Phi()),Double_t(pf->Phi()));
1647 >    Double_t dr = mithep::MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta());
1648 >    if (dr >= 0.4) continue;
1649 >    if(ctrl.debug) {
1650 >      cout << "pf :: type: " << pf->PFType() << "\tpt: " << pf->Pt();
1651 >      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(vtx);
1652 >      cout << endl;
1653 >    }
1654 >
1655 >
1656 >    if ( (pf->HasTrackerTrk() && (pf->TrackerTrk() == ele->TrackerTrk())) ||
1657 >         (pf->HasGsfTrk() && (pf->GsfTrk() == ele->GsfTrk()))) continue;
1658 >    
1659 >
1660 >    //
1661 >    // Lepton Footprint Removal
1662 >    //
1663 >    Bool_t IsLeptonFootprint = kFALSE;
1664 >    if (dr < 1.0) {
1665 >
1666 >      //
1667 >      // Check for electrons
1668 >      //
1669 >      for (Int_t q=0; q < electronsToVeto.size(); ++q) {
1670 >        const mithep::Electron *tmpele = electronsToVeto[q];
1671 >        // 4l electron
1672 >        if( pf->HasTrackerTrk()  ) {
1673 >          if( pf->TrackerTrk() == tmpele->TrackerTrk() ) {
1674 >            if( ctrl.debug) cout << "\tcharged tktrk, matches 4L ele ..." << endl;
1675 >            IsLeptonFootprint = kTRUE;
1676 >          }
1677 >        }
1678 >        if( pf->HasGsfTrk()  ) {
1679 >          if( pf->GsfTrk() == tmpele->GsfTrk() ) {
1680 >            if( ctrl.debug) cout << "\tcharged gsftrk, matches 4L ele ..." << endl;
1681 >            IsLeptonFootprint = kTRUE;
1682 >          }
1683 >        }
1684 >        // PF charged
1685 >        if (pf->Charge() != 0 && fabs(tmpele->SCluster()->Eta()) > 1.479
1686 >            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.015) {
1687 >          if( ctrl.debug) cout << "\tcharged trk, dR matches 4L ele ..." << endl;
1688 >          IsLeptonFootprint = kTRUE;
1689 >        }
1690 >        // PF gamma
1691 >        if (abs(pf->PFType()) == PFCandidate::eGamma && fabs(tmpele->SCluster()->Eta()) > 1.479
1692 >            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.08) {
1693 >          if( ctrl.debug) cout << "\tPF gamma, matches 4L ele ..." << endl;
1694 >          IsLeptonFootprint = kTRUE;
1695 >        }
1696 >      } // loop over electrons
1697 >
1698 >      /* KH - comment for sync            
1699 >      //
1700 >      // Check for muons
1701 >      //
1702 >      for (Int_t q=0; q < muonsToVeto.size(); ++q) {
1703 >        const mithep::Muon *tmpmu = muonsToVeto[q];
1704 >        // 4l muon
1705 >        if( pf->HasTrackerTrk() ) {
1706 >          if (pf->TrackerTrk() == tmpmu->TrackerTrk() ){
1707 >            if( ctrl.debug) cout << "\tmatches 4L mu ..." << endl;
1708 >            IsLeptonFootprint = kTRUE;
1709 >          }
1710 >        }
1711 >        // PF charged
1712 >        if (pf->Charge() != 0 && mithep::MathUtils::DeltaR(tmpmu->Phi(),tmpmu->Eta(), pf->Phi(), pf->Eta()) < 0.01) {
1713 >          if( ctrl.debug) cout << "\tcharged trk, dR matches 4L mu ..." << endl;
1714 >          IsLeptonFootprint = kTRUE;
1715 >        }
1716 >      } // loop over muons
1717 >      */
1718 >
1719 >    if (IsLeptonFootprint)
1720 >      continue;
1721 >
1722 >    //
1723 >    // Charged Iso
1724 >    //
1725 >    if (pf->Charge() != 0 && (pf->HasTrackerTrk()||pf->HasGsfTrk()) ) {
1726 >
1727 >      if( pf->HasTrackerTrk() )
1728 >        if (abs(pf->TrackerTrk()->DzCorrected(vtx)) > 0.2) continue;
1729 >      if( pf->HasGsfTrk() )
1730 >        if (abs(pf->GsfTrk()->DzCorrected(vtx)) > 0.2) continue;
1731 >
1732 >      // Veto any PFmuon, or PFEle
1733 >      if (abs(pf->PFType()) == PFCandidate::eElectron || abs(pf->PFType()) == PFCandidate::eMuon) continue;
1734 >
1735 >      // Footprint Veto
1736 >      if (fabs(ele->SCluster()->Eta()) > 1.479 && dr < 0.015) continue;
1737 >
1738 >      if( ctrl.debug) cout << "charged:: pt: " << pf->Pt()
1739 >                           << "\ttype: " << pf->PFType()
1740 >                           << "\ttrk: " << pf->TrackerTrk() << endl;
1741 >
1742 >      fChargedIso += pf->Pt();
1743 >    }
1744 >
1745 >    //
1746 >    // Gamma Iso
1747 >    //
1748 >    else if (abs(pf->PFType()) == PFCandidate::eGamma) {
1749 >
1750 >      if (fabs(ele->SCluster()->Eta()) > 1.479) {
1751 >        if (mithep::MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta()) < 0.08) continue;
1752 >      }
1753 >      if( ctrl.debug) cout << "gamma:: " << pf->Pt() << " "
1754 >                           << dr << endl;
1755 >      fGammaIso += pf->Pt();
1756 >    }
1757  
1758 <  return pfiso;
1758 >    //
1759 >    // Neutral Iso
1760 >    //
1761 >    else {
1762 >      if( ctrl.debug) cout << "neutral:: " << pf->Pt() << " "
1763 >                           << dr << endl;
1764 >      // KH, add to sync
1765 >      if( pf->Pt() > 0.5 )
1766 >        fNeutralHadronIso += pf->Pt();
1767 >    }
1768 >
1769 >    }
1770 >
1771 >  }
1772 >
1773 > //   double rho = 0;
1774 > //   if (!(isnan(fPUEnergyDensity->At(0)->Rho()) || isinf(fPUEnergyDensity->At(0)->Rho())))
1775 > //     rho = fPUEnergyDensity->At(0)->Rho();
1776 >
1777 >  // WARNING!!!!  
1778 >  // hardcode for sync ...
1779 >  EffectiveAreaVersion = eleT.kEleEAData2011;
1780 >  // WARNING!!!!  
1781 >
1782 >
1783 >  double pfIso = fChargedIso +
1784 >    max(0.0,fGammaIso -rho*eleT.ElectronEffectiveArea(eleT.kEleGammaIso04,
1785 >                                                ele->Eta(),EffectiveAreaVersion)) +
1786 >    max(0.0,fNeutralHadronIso -rho*eleT.ElectronEffectiveArea(eleT.kEleNeutralHadronIso04,
1787 >                                                        ele->Eta(),EffectiveAreaVersion)) ;
1788 >  return pfIso;
1789   }
1790  
1791 +
1792   //--------------------------------------------------------------------------------------------------
1793 < SelectionStatus electronIsoReferenceSelection(ControlFlags &ctrl,
1793 > SelectionStatus electronReferenceIsoSelection(ControlFlags &ctrl,
1794                                                const mithep::Electron * ele,
1795                                                const mithep::Vertex & vtx,
1796                                                const mithep::Array<mithep::PFCandidate> * fPFCandidates,
# Line 1424 | Line 1805 | SelectionStatus electronIsoReferenceSele
1805  
1806    double pfIso = electronPFIso04( ctrl, ele, vtx, fPFCandidates, fPUEnergyDensity,
1807                                    EffectiveAreaVersion, muonsToVeto ,electronsToVeto );
1808 +  cout << "--------------> setting electron isoPF04 to " << pfIso << endl;
1809 +  status.isoPF04 = pfIso;
1810 +  status.chisoPF04 = gChargedIso;
1811 +  status.gaisoPF04 = gGammaIso;
1812 +  status.neisoPF04 = gNeutralIso;
1813 +
1814 +  bool pass = false;
1815 +  if( (pfIso/ele->Pt()) < ELECTRON_REFERENCE_PFISO_CUT ) pass = true;
1816 +
1817 +  if( pass ) {
1818 +    status.orStatus(SelectionStatus::LOOSEISO);
1819 +    status.orStatus(SelectionStatus::TIGHTISO);
1820 +  }
1821 +  if(ctrl.debug) cout << "returning status : " << hex << status.getStatus() << dec << endl;
1822 +  return status;
1823 +
1824 + }
1825 +
1826 +
1827 + //--------------------------------------------------------------------------------------------------
1828 + // hacked version
1829 + SelectionStatus electronReferenceIsoSelection(ControlFlags &ctrl,
1830 +                                              const mithep::Electron * ele,
1831 +                                              const mithep::Vertex & vtx,
1832 +                                              const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1833 +                                              float rho,
1834 +                                              mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
1835 +                                              vector<const mithep::Muon*> muonsToVeto,
1836 +                                              vector<const mithep::Electron*> electronsToVeto)
1837 + //--------------------------------------------------------------------------------------------------
1838 + {
1839 +
1840 +  SelectionStatus status;
1841 +
1842 +  double pfIso = electronPFIso04( ctrl, ele, vtx, fPFCandidates, rho,
1843 +                                  EffectiveAreaVersion, muonsToVeto ,electronsToVeto );
1844    bool pass = false;
1845    if( (pfIso/ele->Pt()) < ELECTRON_REFERENCE_PFISO_CUT ) pass = true;
1846  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines