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.29 by khahn, Sun Jun 3 15:51:51 2012 UTC vs.
Revision 1.33 by anlevin, Wed Oct 17 01:31:22 2012 UTC

# Line 962 | Line 962 | double  muonPFIso04(ControlFlags &ctrl,
962                      const mithep::Array<mithep::PFCandidate> * fPFCandidates,
963                      const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
964                      mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
965 <                    vector<const mithep::Muon*> muonsToVeto,
966 <                    vector<const mithep::Electron*> electronsToVeto)
965 >                    vector<const mithep::PFCandidate*> photonsToVeto)
966   //--------------------------------------------------------------------------------------------------
967   {
968  
969    extern double gChargedIso;  
970    extern double  gGammaIso;      
971    extern double  gNeutralIso;
973  
974  if( ctrl.debug ) {
975    cout << "muonIsoMVASelection :: muons to veto " << endl;
976    for( int i=0; i<muonsToVeto.size(); i++ ) {
977      const mithep::Muon * vmu = muonsToVeto[i];
978      cout << "\tpt: " << vmu->Pt()
979           << "\teta: " << vmu->Eta()
980           << "\tphi: " << vmu->Phi()
981           << endl;
982    }
983    cout << "muonIsoMVASelection :: electrson to veto " << endl;
984    for( int i=0; i<electronsToVeto.size(); i++ ) {
985      const mithep::Electron * vel = electronsToVeto[i];
986      cout << "\tpt: " << vel->Pt()
987           << "\teta: " << vel->Eta()
988           << "\tphi: " << vel->Phi()
989           << endl;
990    }
991  }
972  
973    //
974    // final iso
# Line 1005 | Line 985 | double  muonPFIso04(ControlFlags &ctrl,
985      if( !(PFnoPUflag[k]) ) continue; // my PF no PU hack
986      const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
987  
988 +    //
989 +    // veto FSR recovered photons
990 +    //
991 +    bool vetoPhoton = false;
992 +    for( int p=0; p<photonsToVeto.size(); p++ ) {
993 +      if( pf == photonsToVeto[p] ) {
994 +        vetoPhoton = true;
995 +        break;
996 +      }
997 +    } if( vetoPhoton ) continue;
998 +    //
999 +    //
1000 +    //
1001 +
1002      Double_t deta = (mu->Eta() - pf->Eta());
1003      Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(mu->Phi()),Double_t(pf->Phi()));
1004      Double_t dr = mithep::MathUtils::DeltaR(mu->Phi(),mu->Eta(), pf->Phi(), pf->Eta());
# Line 1013 | Line 1007 | double  muonPFIso04(ControlFlags &ctrl,
1007      if (pf->HasTrackerTrk() && (pf->TrackerTrk() == mu->TrackerTrk()) ) continue;
1008  
1009      //
1016    // Lepton Footprint Removal
1017    //
1018    Bool_t IsLeptonFootprint = kFALSE;
1019    if (dr < 1.0) {
1020
1021      //
1022      // Check for electrons
1023      //
1024      for (Int_t q=0; q < electronsToVeto.size(); ++q) {
1025        const mithep::Electron *tmpele = electronsToVeto[q];
1026        // 4l electron
1027        if( pf->HasTrackerTrk() ) {
1028          if( pf->TrackerTrk() == tmpele->TrackerTrk() )
1029            IsLeptonFootprint = kTRUE;
1030        }
1031        if( pf->HasGsfTrk() ) {
1032          if( pf->GsfTrk() == tmpele->GsfTrk() )
1033            IsLeptonFootprint = kTRUE;
1034        }
1035        // PF charged
1036        if (pf->Charge() != 0 && fabs(tmpele->SCluster()->Eta()) > 1.479
1037            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.015) {
1038          if( ctrl.debug) cout << "\tcharged trk, dR ("
1039                               << mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta())
1040                               << " matches 4L ele ..." << endl;
1041          IsLeptonFootprint = kTRUE;
1042        }
1043        // PF gamma
1044        if (abs(pf->PFType()) == PFCandidate::eGamma && fabs(tmpele->SCluster()->Eta()) > 1.479
1045            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.08)
1046          IsLeptonFootprint = kTRUE;
1047      } // loop over electrons
1048
1049      /* KH - comment for sync      
1050      //
1051      // Check for muons
1052      //
1053      for (Int_t q=0; q < muonsToVeto.size(); ++q) {
1054        const mithep::Muon *tmpmu = muonsToVeto[q];
1055        // 4l muon
1056        if( pf->HasTrackerTrk() ) {
1057          if( pf->TrackerTrk() == tmpmu->TrackerTrk() )
1058            IsLeptonFootprint = kTRUE;
1059        }
1060        // PF charged
1061        if (pf->Charge() != 0 && mithep::MathUtils::DeltaR(tmpmu->Phi(),tmpmu->Eta(), pf->Phi(), pf->Eta()) < 0.01)
1062          IsLeptonFootprint = kTRUE;
1063      } // loop over muons
1064      */
1065
1066    if (IsLeptonFootprint)
1067      continue;
1068
1069    //
1010      // Charged Iso
1011      //
1012      if (pf->Charge() != 0 && (pf->HasTrackerTrk()||pf->HasGsfTrk()) ) {
1013  
1014        //if( dr < 0.01 ) continue; // only for muon iso mva?
1015        if (abs(pf->PFType()) == PFCandidate::eElectron || abs(pf->PFType()) == PFCandidate::eMuon) continue;
1076
1077
1078 //       if( pf->HasTrackerTrk() ) {
1079 //      if (abs(pf->TrackerTrk()->DzCorrected(vtx)) > 0.2) continue;
1080 //      if( ctrl.debug ) cout << "charged:: " << pf->PFType() << " " << pf->Pt() << " "
1081 //                            << abs(pf->TrackerTrk()->DzCorrected(vtx)) << " "
1082 //                            << dr << endl;
1083 //       }
1084 //       if( pf->HasGsfTrk() ) {
1085 //      if (abs(pf->GsfTrk()->DzCorrected(vtx)) > 0.2) continue;
1086 //      if( ctrl.debug ) cout << "charged:: " << pf->PFType() << " " << pf->Pt() << " "
1087 //                            << abs(pf->GsfTrk()->DzCorrected(vtx)) << " "
1088 //                            << dr << endl;
1089 //       }
1090
1091
1016        fChargedIso += pf->Pt();
1017      }
1018 <
1018 >    
1019      //
1020      // Gamma Iso
1021      //
1022      else if (abs(pf->PFType()) == PFCandidate::eGamma) {
1023        // KH, add to sync
1024 <      if( pf->Pt() > 0.5 )
1024 >      if( pf->Pt() > 0.5 && dr > 0.01)
1025        fGammaIso += pf->Pt();
1026      }
1027 <
1027 >    
1028      //
1029      // Other Neutrals
1030      //
1031      else {
1032 <      // KH, add to sync
1033 <      if( pf->Pt() > 0.5 )
1032 >    
1033 >      if( pf->Pt() > 0.5  && dr > 0.01)
1034          fNeutralHadronIso += pf->Pt();
1035      }
1112    
1113    }
1114    
1036    }
1037  
1038    double rho=0;
# Line 1134 | Line 1055 | double  muonPFIso04(ControlFlags &ctrl,
1055    }
1056    if(ctrl.debug) cout << "rho: " << rho << endl;
1057  
1058 +  TLorentzVector  tmpvec;
1059 +  tmpvec.SetPtEtaPhiM(mu->Pt(),mu->Eta(),mu->Phi(),mu->Mass());
1060 +  for( int p=0; p<photonsToVeto.size(); p++ ) {
1061 +    const mithep::PFCandidate * pf  = photonsToVeto[p];
1062 +    TLorentzVector pfvec;
1063 +    pfvec.SetPtEtaPhiM(pf->Pt(),pf->Eta(),pf->Phi(),0.);
1064 +    tmpvec += pfvec;
1065 +  }
1066 +
1067    double pfIso = fChargedIso + fmax(0.0,(fGammaIso + fNeutralHadronIso
1068                                          -rho*muT.MuonEffectiveArea(muT.kMuGammaAndNeutralHadronIso04,
1069 <                                                                   mu->Eta(),EffectiveAreaVersion)));
1069 >                                                                   //tmpvec.Eta(),EffectiveAreaVersion)));
1070 >                                                                   mu->Eta(),EffectiveAreaVersion)));
1071    gChargedIso = fChargedIso;
1072    gGammaIso   = fGammaIso;
1073    gNeutralIso = fNeutralHadronIso;
1074    
1075 +  if( ctrl.debug ) {
1076 +    cout << "PFiso: " << pfIso
1077 +         << "\tfChargedIso: " << fChargedIso
1078 +         << "\tfGammaIso: " << fGammaIso
1079 +         << "\tfNeutralHadronIso: " << fNeutralHadronIso
1080 +         << endl;
1081 +  }
1082 +
1083    return pfIso;
1084   }
1085  
# Line 1331 | Line 1270 | SelectionStatus muonReferenceIsoSelectio
1270                                            const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1271                                            const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
1272                                            mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
1273 <                                          vector<const mithep::Muon*> muonsToVeto,
1335 <                                          vector<const mithep::Electron*> electronsToVeto)
1273 >                                          vector<const mithep::PFCandidate*> photonsToVeto)
1274   //--------------------------------------------------------------------------------------------------
1275   {
1276    
1277    SelectionStatus status;
1278  
1279    double pfIso = muonPFIso04( ctrl, mu, vtx, fPFCandidates, fPUEnergyDensity,
1280 <                              EffectiveAreaVersion, muonsToVeto ,electronsToVeto );
1280 >                              EffectiveAreaVersion, photonsToVeto);
1281    //  cout << "--------------> setting muon isoPF04 to" << pfIso << endl;
1282    status.isoPF04 = pfIso;
1283    status.chisoPF04 = gChargedIso;
# Line 1348 | Line 1286 | SelectionStatus muonReferenceIsoSelectio
1286  
1287    bool pass = false;
1288    if( (pfIso/mu->Pt()) < MUON_REFERENCE_PFISO_CUT ) pass = true;
1289 <  
1289 >
1290    if( pass ) {
1291      status.orStatus(SelectionStatus::LOOSEISO);
1292      status.orStatus(SelectionStatus::TIGHTISO);
1293    }
1294 <  if(ctrl.debug) cout << "returning status : " << hex << status.getStatus() << dec << endl;
1294 >  if(ctrl.debug) {
1295 >    cout << "mu relpfIso: " << pfIso/mu->Pt() << endl;
1296 >    cout << "returning status : " << hex << status.getStatus() << dec << endl;
1297 >  }
1298    return status;
1299    
1300   }
# Line 2264 | Line 2205 | float electronPFIso04(ControlFlags &ctrl
2205                        const mithep::Array<mithep::PFCandidate> * fPFCandidates,
2206                        const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
2207                        mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
2208 <                      vector<const mithep::Muon*> muonsToVeto,
2268 <                      vector<const mithep::Electron*> electronsToVeto)
2208 >                      vector<const mithep::PFCandidate*> photonsToVeto)        
2209   //--------------------------------------------------------------------------------------------------
2210   {
2271  /*
2272  if( ctrl.debug ) {
2273    cout << "electronIsoMVASelection :: muons to veto " << endl;
2274    for( int i=0; i<muonsToVeto.size(); i++ ) {
2275      const mithep::Muon * vmu = muonsToVeto[i];
2276      cout << "\tpt: " << vmu->Pt()
2277           << "\teta: " << vmu->Eta()
2278           << "\tphi: " << vmu->Phi()
2279           << endl;
2280    }
2281    cout << "electronIsoMVASelection :: electrons to veto " << endl;
2282    for( int i=0; i<electronsToVeto.size(); i++ ) {
2283      const mithep::Electron * vel = electronsToVeto[i];
2284      cout << "\tpt: " << vel->Pt()
2285           << "\teta: " << vel->Eta()
2286           << "\tphi: " << vel->Phi()
2287           << "\ttrk: " << vel->TrackerTrk()
2288           << endl;
2289    }
2290  }
2291  */
2211  
2212    //
2213    // final iso
# Line 2303 | Line 2222 | float electronPFIso04(ControlFlags &ctrl
2222    //
2223    for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2224  
2306
2225      const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
2226 +
2227 +    //
2228 +    // veto FSR recovered photons
2229 +    //
2230 +    bool vetoPhoton = false;
2231 +    for( int p=0; p<photonsToVeto.size(); p++ ) {
2232 +      if( pf == photonsToVeto[p] ) {
2233 +        vetoPhoton = true;
2234 +        break;
2235 +      }
2236 +    } if( vetoPhoton ) continue;
2237 +
2238      Double_t deta = (ele->Eta() - pf->Eta());
2239      Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(ele->Phi()),Double_t(pf->Phi()));
2240      Double_t dr = mithep::MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta());
# Line 2338 | Line 2268 | float electronPFIso04(ControlFlags &ctrl
2268      Bool_t IsLeptonFootprint = kFALSE;
2269      if (dr < 1.0) {
2270  
2341      //
2342      // Check for electrons
2343      //
2344      for (Int_t q=0; q < electronsToVeto.size(); ++q) {
2345        const mithep::Electron *tmpele = electronsToVeto[q];
2346        /*
2347        // 4l electron
2348        if( pf->HasTrackerTrk()  ) {
2349          if( pf->TrackerTrk() == tmpele->TrackerTrk() ) {
2350            if( ctrl.debug) cout << "\tcharged tktrk, matches 4L ele ..." << endl;
2351            IsLeptonFootprint = kTRUE;
2352          }
2353        }
2354        if( pf->HasGsfTrk()  ) {
2355          if( pf->GsfTrk() == tmpele->GsfTrk() ) {
2356            if( ctrl.debug) cout << "\tcharged gsftrk, matches 4L ele ..." << endl;
2357            IsLeptonFootprint = kTRUE;
2358          }
2359        }
2360        */
2361        // PF charged
2362        if (pf->Charge() != 0 && fabs(tmpele->SCluster()->Eta()) > 1.479
2363            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.015) {
2364          if( ctrl.debug) cout << "\tcharged trk, dR matches 4L ele ..." << endl;
2365          IsLeptonFootprint = kTRUE;
2366        }
2367        // PF gamma
2368        if (abs(pf->PFType()) == PFCandidate::eGamma && fabs(tmpele->SCluster()->Eta()) > 1.479
2369            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.08) {
2370          if( ctrl.debug) cout << "\tPF gamma, matches 4L ele ..." << endl;
2371          IsLeptonFootprint = kTRUE;
2372        }
2373      } // loop over electrons
2374
2375      /* KH - comment for sync            
2376      //
2377      // Check for muons
2378      //
2379      for (Int_t q=0; q < muonsToVeto.size(); ++q) {
2380        const mithep::Muon *tmpmu = muonsToVeto[q];
2381        // 4l muon
2382        if( pf->HasTrackerTrk() ) {
2383          if (pf->TrackerTrk() == tmpmu->TrackerTrk() ){
2384            if( ctrl.debug) cout << "\tmatches 4L mu ..." << endl;
2385            IsLeptonFootprint = kTRUE;
2386          }
2387        }
2388        // PF charged
2389        if (pf->Charge() != 0 && mithep::MathUtils::DeltaR(tmpmu->Phi(),tmpmu->Eta(), pf->Phi(), pf->Eta()) < 0.01) {
2390          if( ctrl.debug) cout << "\tcharged trk, dR matches 4L mu ..." << endl;
2391          IsLeptonFootprint = kTRUE;
2392        }
2393      } // loop over muons
2394      */
2395
2396    if (IsLeptonFootprint)
2397      continue;
2271  
2272      //
2273      // Charged Iso
2274      //
2275      if (pf->Charge() != 0 && (pf->HasTrackerTrk()||pf->HasGsfTrk()) ) {
2276  
2404 //       if( pf->HasTrackerTrk() )
2405 //      if (abs(pf->TrackerTrk()->DzCorrected(vtx)) > 0.2) continue;
2406 //       if( pf->HasGsfTrk() )
2407 //      if (abs(pf->GsfTrk()->DzCorrected(vtx)) > 0.2) continue;
2408
2277        // Veto any PFmuon, or PFEle
2278        if (abs(pf->PFType()) == PFCandidate::eElectron || abs(pf->PFType()) == PFCandidate::eMuon) {
2279          if( ctrl.debug ) cout << "\t skipping, pf is and ele or mu .." <<endl;
# Line 2430 | Line 2298 | float electronPFIso04(ControlFlags &ctrl
2298        if (fabs(ele->SCluster()->Eta()) > 1.479) {
2299          if (mithep::MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta()) < 0.08) continue;
2300        }
2301 +
2302 +      assert(ele->HasSuperCluster());
2303 +      if(ele->GsfTrk()->NExpectedHitsInner()>0 && pf->MvaGamma() > 0.99 && pf->HasSCluster() && ele->SCluster() == pf->SCluster())      continue;
2304 +
2305 +
2306        if( ctrl.debug) cout << "gamma:: " << pf->Pt() << " "
2307                             << dr << endl;
2308        // KH, add to sync
# Line 2480 | Line 2353 | float electronPFIso04(ControlFlags &ctrl
2353    gChargedIso = fChargedIso;
2354    gGammaIso = fGammaIso;
2355    gNeutralIso = fNeutralHadronIso;  
2356 +
2357 +  if( ctrl.debug ) {
2358 +    cout << "PFiso: " << pfIso
2359 +         << "\tfChargedIso: " << fChargedIso
2360 +         << "\tfGammaIso: " << fGammaIso
2361 +         << "\tfNeutralHadronIso: " << fNeutralHadronIso
2362 +         << endl;
2363 +  }
2364 +
2365    return pfIso;
2366   }
2367  
# Line 2710 | Line 2592 | SelectionStatus electronReferenceIsoSele
2592                                                const mithep::Array<mithep::PFCandidate> * fPFCandidates,
2593                                                const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
2594                                                mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
2595 <                                              vector<const mithep::Muon*> muonsToVeto,
2714 <                                              vector<const mithep::Electron*> electronsToVeto)
2595 >                                              vector<const mithep::PFCandidate*> photonsToVeto)
2596   //--------------------------------------------------------------------------------------------------
2597   {
2598  
2599    SelectionStatus status;
2600  
2601    double pfIso = electronPFIso04( ctrl, ele, vtx, fPFCandidates, fPUEnergyDensity,
2602 <                                  EffectiveAreaVersion, muonsToVeto ,electronsToVeto );
2602 >                                  EffectiveAreaVersion, photonsToVeto);
2603    //  cout << "--------------> setting electron isoPF04 to " << pfIso << endl;
2604    status.isoPF04 = pfIso;
2605    status.chisoPF04 = gChargedIso;
# Line 2732 | Line 2613 | SelectionStatus electronReferenceIsoSele
2613      status.orStatus(SelectionStatus::LOOSEISO);
2614      status.orStatus(SelectionStatus::TIGHTISO);
2615    }
2616 <  if(ctrl.debug) cout << "returning status : " << hex << status.getStatus() << dec << endl;
2616 >  if(ctrl.debug) {
2617 >    cout << "el relpfIso: " << pfIso/ele->Pt() << endl;
2618 >    cout << "returning status : " << hex << status.getStatus() << dec << endl;
2619 >  }
2620    return status;
2621  
2622   }
# Line 2939 | Line 2823 | double  dbetaCorrectedIsoDr03(ControlFla
2823  
2824  
2825   //--------------------------------------------------------------------------------------------------
2826 < double  betaCorrectedIsoDr03(ControlFlags & ctrl,
2827 <                             const mithep::PFCandidate * photon,
2828 <                             const mithep::Muon * lepton,
2829 <                             const mithep::Array<mithep::PFCandidate> * fPFCandidates)
2826 > double  nonCorrectedIsoDr03(ControlFlags & ctrl,
2827 >                            const mithep::PFCandidate * photon,
2828 >                            const mithep::Muon * lepton,
2829 >                            const mithep::Array<mithep::PFCandidate> * fPFCandidates)
2830   //--------------------------------------------------------------------------------------------------
2831   {
2832  
# Line 2960 | Line 2844 | double  betaCorrectedIsoDr03(ControlFlag
2844    for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2845  
2846      const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
2847 <    
2847 >
2848      Double_t deta = (photon->Eta() - pf->Eta());
2849      Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(photon->Phi()),Double_t(pf->Phi()));
2850      Double_t dr = mithep::MathUtils::DeltaR(photon->Phi(),photon->Eta(), pf->Phi(), pf->Eta());
# Line 3013 | Line 2897 | double  betaCorrectedIsoDr03(ControlFlag
2897           << "\tfNeutralHadronIso: " << fNeutralHadronIso
2898           << "\tfpfPU: " << fpfPU
2899           << endl;
2900 <  }
2900 >  }  
2901 >
2902    double pfIso = fChargedIso + fGammaIso + fNeutralHadronIso + fpfPU;
2903    return pfIso/photon->Pt();
2904   }
2905  
2906  
2907 +
2908   //--------------------------------------------------------------------------------------------------
2909 < double  betaCorrectedIsoDr03(ControlFlags & ctrl,
2910 <                              const mithep::PFCandidate * photon,
2911 <                              const mithep::Electron * lepton,
2912 <                              const mithep::Array<mithep::PFCandidate> * fPFCandidates)
2909 > double  nonCorrectedIsoDr03(ControlFlags & ctrl,
2910 >                            const mithep::PFCandidate * photon,
2911 >                            const mithep::Electron * lepton,
2912 >                            const mithep::Array<mithep::PFCandidate> * fPFCandidates)
2913   //--------------------------------------------------------------------------------------------------
2914   {
2915  
# Line 3041 | Line 2927 | double  betaCorrectedIsoDr03(ControlFlag
2927    for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2928  
2929      const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
2930 <    
2930 >
2931      Double_t deta = (photon->Eta() - pf->Eta());
2932      Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(photon->Phi()),Double_t(pf->Phi()));
2933      Double_t dr = mithep::MathUtils::DeltaR(photon->Phi(),photon->Eta(), pf->Phi(), pf->Eta());

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines