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.8 by khahn, Wed May 2 17:50:58 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 530 | Line 537 | SelectionStatus muonIsoMVASelection(Cont
537                                               ctrl.debug);
538  
539    SelectionStatus status;
540 <  bool pass = false;
540 >  bool pass;
541  
542 +  pass = false;
543    if( mu->IsGlobalMuon() && mu->IsTrackerMuon()
544 <      && fabs(mu->Eta()) <= 1.5 && mu->Pt() <= 10 && mvaval >= MUON_ISOMVA_FORPFID_CUT_BIN0)   pass = true;
544 >      && fabs(mu->Eta()) <= 1.5 && mu->Pt() <= 10 && mvaval >= MUON_ISOMVA_LOOSE_FORPFID_CUT_BIN0)   pass = true;
545    else if( mu->IsGlobalMuon() && mu->IsTrackerMuon()
546 <           && fabs(mu->Eta()) <= 1.5 && mu->Pt() > 10 && mvaval >= MUON_ISOMVA_FORPFID_CUT_BIN1)  pass = true;
546 >           && fabs(mu->Eta()) <= 1.5 && mu->Pt() > 10 && mvaval >= MUON_ISOMVA_LOOSE_FORPFID_CUT_BIN1)  pass = true;
547    else if( mu->IsGlobalMuon() && mu->IsTrackerMuon()
548 <           && fabs(mu->Eta()) > 1.5 && mu->Pt() <= 10 && mvaval >= MUON_ISOMVA_FORPFID_CUT_BIN2)  pass = true;
548 >           && fabs(mu->Eta()) > 1.5 && mu->Pt() <= 10 && mvaval >= MUON_ISOMVA_LOOSE_FORPFID_CUT_BIN2)  pass = true;
549    else if( mu->IsGlobalMuon() && mu->IsTrackerMuon()
550 <           && fabs(mu->Eta()) > 1.5 && mu->Pt() > 10 && mvaval >= MUON_ISOMVA_FORPFID_CUT_BIN3)  pass = true;
551 <  else if( !(mu->IsGlobalMuon()) && mu->IsTrackerMuon()
552 <            && mvaval >= MUON_ISOMVA_FORPFID_CUT_BIN4)
553 <    pass = true;
550 >           && fabs(mu->Eta()) > 1.5 && mu->Pt() > 10 && mvaval >= MUON_ISOMVA_LOOSE_FORPFID_CUT_BIN3)  pass = true;
551 >  else if( !(mu->IsGlobalMuon()) && mu->IsTrackerMuon() && mvaval >= MUON_ISOMVA_LOOSE_FORPFID_CUT_BIN4)  pass = true;
552 >  else if( mu->IsGlobalMuon() && !(mu->IsTrackerMuon()) && mvaval >= MUON_ISOMVA_LOOSE_FORPFID_CUT_BIN5)  pass = true;
553 >  if( pass ) status.orStatus(SelectionStatus::LOOSEISO);
554  
555 +  pass = false;
556 +  if( mu->IsGlobalMuon() && mu->IsTrackerMuon()
557 +      && fabs(mu->Eta()) <= 1.5 && mu->Pt() <= 10 && mvaval >= MUON_ISOMVA_TIGHT_FORPFID_CUT_BIN0)   pass = true;
558 +  else if( mu->IsGlobalMuon() && mu->IsTrackerMuon()
559 +           && fabs(mu->Eta()) <= 1.5 && mu->Pt() > 10 && mvaval >= MUON_ISOMVA_TIGHT_FORPFID_CUT_BIN1)  pass = true;
560 +  else if( mu->IsGlobalMuon() && mu->IsTrackerMuon()
561 +           && fabs(mu->Eta()) > 1.5 && mu->Pt() <= 10 && mvaval >= MUON_ISOMVA_TIGHT_FORPFID_CUT_BIN2)  pass = true;
562 +  else if( mu->IsGlobalMuon() && mu->IsTrackerMuon()
563 +           && fabs(mu->Eta()) > 1.5 && mu->Pt() > 10 && mvaval >= MUON_ISOMVA_TIGHT_FORPFID_CUT_BIN3)  pass = true;
564 +  else if( !(mu->IsGlobalMuon()) && mu->IsTrackerMuon() && mvaval >= MUON_ISOMVA_TIGHT_FORPFID_CUT_BIN4)  pass = true;
565 +  else if( mu->IsGlobalMuon() && !(mu->IsTrackerMuon()) && mvaval >= MUON_ISOMVA_TIGHT_FORPFID_CUT_BIN5)  pass = true;
566 +  if( pass ) status.orStatus(SelectionStatus::TIGHTISO);
567  
568 <  pass &= (fChargedIso_DR0p0To0p1 + fChargedIso_DR0p1To0p2 + fChargedIso_DR0p2To0p3 < 0.7);
568 >  //  pass &= (fChargedIso_DR0p0To0p1 + fChargedIso_DR0p1To0p2 + fChargedIso_DR0p2To0p3 < 0.7);
569  
550  if( pass ) {
551    status.orStatus(SelectionStatus::LOOSEISO);
552    status.orStatus(SelectionStatus::TIGHTISO);
553  }
570    if(ctrl.debug) cout << "returning status : " << hex << status.getStatus() << dec << endl;
571    return status;
572  
# Line 573 | Line 589 | void initMuonIsoMVA() {
589   }
590  
591  
592 + //--------------------------------------------------------------------------------------------------
593 + double  muonPFIso04(ControlFlags &ctrl,
594 +                    const mithep::Muon * mu,
595 +                    const mithep::Vertex & vtx,
596 +                    const mithep::Array<mithep::PFCandidate> * fPFCandidates,
597 +                    const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
598 +                    mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
599 +                    vector<const mithep::Muon*> muonsToVeto,
600 +                    vector<const mithep::Electron*> electronsToVeto)
601 + //--------------------------------------------------------------------------------------------------
602 + {
603 +  
604 +  if( ctrl.debug ) {
605 +    cout << "muonIsoMVASelection :: muons to veto " << endl;
606 +    for( int i=0; i<muonsToVeto.size(); i++ ) {
607 +      const mithep::Muon * vmu = muonsToVeto[i];
608 +      cout << "\tpt: " << vmu->Pt()
609 +           << "\teta: " << vmu->Eta()
610 +           << "\tphi: " << vmu->Phi()
611 +           << endl;
612 +    }
613 +    cout << "muonIsoMVASelection :: electrson to veto " << endl;
614 +    for( int i=0; i<electronsToVeto.size(); i++ ) {
615 +      const mithep::Electron * vel = electronsToVeto[i];
616 +      cout << "\tpt: " << vel->Pt()
617 +           << "\teta: " << vel->Eta()
618 +           << "\tphi: " << vel->Phi()
619 +           << endl;
620 +    }
621 +  }
622 +
623 +  //
624 +  // final iso
625 +  //
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  = 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
872 +    //
873 +    if (pf->Charge() != 0 && (pf->HasTrackerTrk()||pf->HasGsfTrk()) ) {
874 +
875 +      if( dr < 0.01 ) continue; // only for muon iso mva?
876 +      if (abs(pf->PFType()) == PFCandidate::eElectron || abs(pf->PFType()) == PFCandidate::eMuon) continue;
877 +
878 +      if( pf->HasTrackerTrk() ) {
879 +        if (abs(pf->TrackerTrk()->DzCorrected(vtx)) > 0.2) continue;
880 +        if( ctrl.debug ) cout << "charged:: " << pf->PFType() << " " << pf->Pt() << " "
881 +                              << abs(pf->TrackerTrk()->DzCorrected(vtx)) << " "
882 +                              << dr << endl;
883 +      }
884 +      if( pf->HasGsfTrk() ) {
885 +        if (abs(pf->GsfTrk()->DzCorrected(vtx)) > 0.2) continue;
886 +        if( ctrl.debug ) cout << "charged:: " << pf->PFType() << " " << pf->Pt() << " "
887 +                              << abs(pf->GsfTrk()->DzCorrected(vtx)) << " "
888 +                              << dr << endl;
889 +      }
890 +
891 +
892 +      fChargedIso += pf->Pt();
893 +    }
894 +
895 +    //
896 +    // Gamma Iso
897 +    //
898 +    else if (abs(pf->PFType()) == PFCandidate::eGamma) {
899 +      fGammaIso += pf->Pt();
900 +    }
901 +
902 +    //
903 +    // Other Neutrals
904 +    //
905 +    else {
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();
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 +
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 +  SelectionStatus status;
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 +  
991 +  if( pass ) {
992 +    status.orStatus(SelectionStatus::LOOSEISO);
993 +    status.orStatus(SelectionStatus::TIGHTISO);
994 +  }
995 +  if(ctrl.debug) cout << "returning status : " << hex << status.getStatus() << dec << endl;
996 +  return status;
997 +  
998 + }
999 +
1000 +
1001  
1002   //--------------------------------------------------------------------------------------------------
1003   SelectionStatus electronIsoMVASelection(ControlFlags &ctrl,
# Line 713 | 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 732 | Line 1158 | SelectionStatus electronIsoMVASelection(
1158            IsLeptonFootprint = kTRUE;
1159          }
1160        } // loop over muons
1161 <
1161 >      */
1162  
1163      if (IsLeptonFootprint)
1164        continue;
# Line 931 | Line 1357 | SelectionStatus electronIsoMVASelection(
1357    if (subdet == 0 && ptBin == 1) MVABin = 3;
1358    if (subdet == 1 && ptBin == 1) MVABin = 4;
1359    if (subdet == 2 && ptBin == 1) MVABin = 5;
934
935  if( MVABin == 0 && mvaval > ELECTRON_ISOMVA_CUT_BIN0 ) pass = true;
936  if( MVABin == 1 && mvaval > ELECTRON_ISOMVA_CUT_BIN1 ) pass = true;
937  if( MVABin == 2 && mvaval > ELECTRON_ISOMVA_CUT_BIN2 ) pass = true;
938  if( MVABin == 3 && mvaval > ELECTRON_ISOMVA_CUT_BIN3 ) pass = true;
939  if( MVABin == 4 && mvaval > ELECTRON_ISOMVA_CUT_BIN4 ) pass = true;
940  if( MVABin == 5 && mvaval > ELECTRON_ISOMVA_CUT_BIN5 ) pass = true;
1360  
1361 <  // pre-selection iso ...
1362 <  pass &= (fChargedIso_DR0p0To0p1 + fChargedIso_DR0p1To0p2 + fChargedIso_DR0p2To0p3 < 0.7);
1361 >  pass = false;
1362 >  if( MVABin == 0 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_BIN0 ) pass = true;
1363 >  if( MVABin == 1 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_BIN1 ) pass = true;
1364 >  if( MVABin == 2 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_BIN2 ) pass = true;
1365 >  if( MVABin == 3 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_BIN3 ) pass = true;
1366 >  if( MVABin == 4 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_BIN4 ) pass = true;
1367 >  if( MVABin == 5 && mvaval > ELECTRON_LOOSE_ISOMVA_CUT_BIN5 ) pass = true;
1368 >  if( pass ) status.orStatus(SelectionStatus::LOOSEISO);
1369 >
1370 >  pass = false;
1371 >  if( MVABin == 0 && mvaval > ELECTRON_TIGHT_ISOMVA_CUT_BIN0 ) pass = true;
1372 >  if( MVABin == 1 && mvaval > ELECTRON_TIGHT_ISOMVA_CUT_BIN1 ) pass = true;
1373 >  if( MVABin == 2 && mvaval > ELECTRON_TIGHT_ISOMVA_CUT_BIN2 ) pass = true;
1374 >  if( MVABin == 3 && mvaval > ELECTRON_TIGHT_ISOMVA_CUT_BIN3 ) pass = true;
1375 >  if( MVABin == 4 && mvaval > ELECTRON_TIGHT_ISOMVA_CUT_BIN4 ) pass = true;
1376 >  if( MVABin == 5 && mvaval > ELECTRON_TIGHT_ISOMVA_CUT_BIN5 ) pass = true;
1377 >  if( pass ) status.orStatus(SelectionStatus::TIGHTISO);
1378  
945  if( pass ) {
946    status.orStatus(SelectionStatus::LOOSEISO);
947    status.orStatus(SelectionStatus::TIGHTISO);
948  }
1379    if(ctrl.debug) cout << "returning status : " << hex << status.getStatus() << dec << endl;
1380    return status;
1381 <
1381 >  
1382   }
1383  
1384  
# Line 965 | Line 1395 | void initElectronIsoMVA() {
1395                          mithep::ElectronIDMVA::kIsoRingsV0,
1396                          kTRUE, weightFiles);
1397   }
1398 +
1399 +
1400 +
1401 + //--------------------------------------------------------------------------------------------------
1402 + float electronPFIso04(ControlFlags &ctrl,
1403 +                                const mithep::Electron * ele,
1404 +                                const mithep::Vertex & vtx,
1405 +                                const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1406 +                                const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
1407 +                                mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
1408 +                                vector<const mithep::Muon*> muonsToVeto,
1409 +                                vector<const mithep::Electron*> electronsToVeto)
1410 + //--------------------------------------------------------------------------------------------------
1411 + {
1412 +
1413 +  if( ctrl.debug ) {
1414 +    cout << "electronIsoMVASelection :: muons to veto " << endl;
1415 +    for( int i=0; i<muonsToVeto.size(); i++ ) {
1416 +      const mithep::Muon * vmu = muonsToVeto[i];
1417 +      cout << "\tpt: " << vmu->Pt()
1418 +           << "\teta: " << vmu->Eta()
1419 +           << "\tphi: " << vmu->Phi()
1420 +           << endl;
1421 +    }
1422 +    cout << "electronIsoMVASelection :: electrson to veto " << endl;
1423 +    for( int i=0; i<electronsToVeto.size(); i++ ) {
1424 +      const mithep::Electron * vel = electronsToVeto[i];
1425 +      cout << "\tpt: " << vel->Pt()
1426 +           << "\teta: " << vel->Eta()
1427 +           << "\tphi: " << vel->Phi()
1428 +           << "\ttrk: " << vel->TrackerTrk()
1429 +           << endl;
1430 +    }
1431 +  }
1432 +
1433 +
1434 +  //
1435 +  // final iso
1436 +  //
1437 +  Double_t fChargedIso = 0.0;
1438 +  Double_t fGammaIso = 0.0;
1439 +  Double_t fNeutralHadronIso = 0.0;
1440 +
1441 +
1442 +  //
1443 +  //Loop over PF Candidates
1444 +  //
1445 +  for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
1446 +    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
1447 +    Double_t deta = (ele->Eta() - pf->Eta());
1448 +    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(ele->Phi()),Double_t(pf->Phi()));
1449 +    Double_t dr = mithep::MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta());
1450 +    if (dr >= 0.4) continue;
1451 +    if(ctrl.debug) {
1452 +      cout << "pf :: type: " << pf->PFType() << "\tpt: " << pf->Pt();
1453 +      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(vtx);
1454 +      cout << endl;
1455 +    }
1456 +
1457 +
1458 +    if ( (pf->HasTrackerTrk() && (pf->TrackerTrk() == ele->TrackerTrk())) ||
1459 +         (pf->HasGsfTrk() && (pf->GsfTrk() == ele->GsfTrk()))) continue;
1460 +    
1461 +
1462 +    //
1463 +    // Lepton Footprint Removal
1464 +    //
1465 +    Bool_t IsLeptonFootprint = kFALSE;
1466 +    if (dr < 1.0) {
1467 +
1468 +      //
1469 +      // Check for electrons
1470 +      //
1471 +      for (Int_t q=0; q < electronsToVeto.size(); ++q) {
1472 +        const mithep::Electron *tmpele = electronsToVeto[q];
1473 +        // 4l electron
1474 +        if( pf->HasTrackerTrk()  ) {
1475 +          if( pf->TrackerTrk() == tmpele->TrackerTrk() ) {
1476 +            if( ctrl.debug) cout << "\tcharged tktrk, matches 4L ele ..." << endl;
1477 +            IsLeptonFootprint = kTRUE;
1478 +          }
1479 +        }
1480 +        if( pf->HasGsfTrk()  ) {
1481 +          if( pf->GsfTrk() == tmpele->GsfTrk() ) {
1482 +            if( ctrl.debug) cout << "\tcharged gsftrk, matches 4L ele ..." << endl;
1483 +            IsLeptonFootprint = kTRUE;
1484 +          }
1485 +        }
1486 +        // PF charged
1487 +        if (pf->Charge() != 0 && fabs(tmpele->SCluster()->Eta()) > 1.479
1488 +            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.015) {
1489 +          if( ctrl.debug) cout << "\tcharged trk, dR matches 4L ele ..." << endl;
1490 +          IsLeptonFootprint = kTRUE;
1491 +        }
1492 +        // PF gamma
1493 +        if (abs(pf->PFType()) == PFCandidate::eGamma && fabs(tmpele->SCluster()->Eta()) > 1.479
1494 +            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.08) {
1495 +          if( ctrl.debug) cout << "\tPF gamma, matches 4L ele ..." << endl;
1496 +          IsLeptonFootprint = kTRUE;
1497 +        }
1498 +      } // loop over electrons
1499 +
1500 +
1501 +      //
1502 +      // Check for muons
1503 +      //
1504 +      for (Int_t q=0; q < muonsToVeto.size(); ++q) {
1505 +        const mithep::Muon *tmpmu = muonsToVeto[q];
1506 +        // 4l muon
1507 +        if( pf->HasTrackerTrk() ) {
1508 +          if (pf->TrackerTrk() == tmpmu->TrackerTrk() ){
1509 +            if( ctrl.debug) cout << "\tmatches 4L mu ..." << endl;
1510 +            IsLeptonFootprint = kTRUE;
1511 +          }
1512 +        }
1513 +        // PF charged
1514 +        if (pf->Charge() != 0 && mithep::MathUtils::DeltaR(tmpmu->Phi(),tmpmu->Eta(), pf->Phi(), pf->Eta()) < 0.01) {
1515 +          if( ctrl.debug) cout << "\tcharged trk, dR matches 4L mu ..." << endl;
1516 +          IsLeptonFootprint = kTRUE;
1517 +        }
1518 +      } // loop over muons
1519 +
1520 +
1521 +    if (IsLeptonFootprint)
1522 +      continue;
1523 +
1524 +    //
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 +      fGammaIso += pf->Pt();
1558 +    }
1559 +
1560 +    //
1561 +    // Neutral Iso
1562 +    //
1563 +    else {
1564 +      if( ctrl.debug) cout << "neutral:: " << pf->Pt() << " "
1565 +                           << dr << endl;
1566 +        fNeutralHadronIso += pf->Pt();
1567 +    }
1568 +
1569 +    }
1570 +
1571 +  }
1572 +
1573 +  double rho = 0;
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 +  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 +
1631 +
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 +    //
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 electronReferenceIsoSelection(ControlFlags &ctrl,
1794 +                                              const mithep::Electron * ele,
1795 +                                              const mithep::Vertex & vtx,
1796 +                                              const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1797 +                                              const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
1798 +                                              mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
1799 +                                              vector<const mithep::Muon*> muonsToVeto,
1800 +                                              vector<const mithep::Electron*> electronsToVeto)
1801 + //--------------------------------------------------------------------------------------------------
1802 + {
1803 +
1804 +  SelectionStatus status;
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 +
1847 +  if( pass ) {
1848 +    status.orStatus(SelectionStatus::LOOSEISO);
1849 +    status.orStatus(SelectionStatus::TIGHTISO);
1850 +  }
1851 +  if(ctrl.debug) cout << "returning status : " << hex << status.getStatus() << dec << endl;
1852 +  return status;
1853 +
1854 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines