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.27 by khahn, Mon May 28 16:34:44 2012 UTC vs.
Revision 1.32 by anlevin, Fri Oct 5 09:22:32 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      //
# Line 1100 | Line 1024 | double  muonPFIso04(ControlFlags &ctrl,
1024        if( pf->Pt() > 0.5 )
1025        fGammaIso += pf->Pt();
1026      }
1027 <
1027 >    
1028      //
1029      // Other Neutrals
1030      //
1031      else {
1108      // KH, add to sync
1032        if( pf->Pt() > 0.5 )
1033          fNeutralHadronIso += pf->Pt();
1034      }
1112    
1113    }
1114    
1035    }
1036  
1037    double rho=0;
# Line 1120 | Line 1040 | double  muonPFIso04(ControlFlags &ctrl,
1040      if (!(isnan(fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25()) ||
1041            isinf(fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25())))
1042        rho = fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25();
1043 +    //rho = fPUEnergyDensity->At(0)->Rho();
1044      // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
1045      EffectiveAreaVersion  = mithep::MuonTools::kMuEAData2011;
1046      // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
# Line 1128 | Line 1049 | double  muonPFIso04(ControlFlags &ctrl,
1049            isinf(fPUEnergyDensity->At(0)->RhoKt6PFJetsCentralNeutral())))
1050        rho = fPUEnergyDensity->At(0)->RhoKt6PFJetsCentralNeutral();
1051      // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
1052 <    EffectiveAreaVersion  = mithep::MuonTools::kMuEAData2011;
1052 >    EffectiveAreaVersion  = mithep::MuonTools::kMuEAData2012;
1053      // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
1054    }
1055    if(ctrl.debug) cout << "rho: " << rho << endl;
1056  
1057 +  TLorentzVector  tmpvec;
1058 +  tmpvec.SetPtEtaPhiM(mu->Pt(),mu->Eta(),mu->Phi(),mu->Mass());
1059 +  for( int p=0; p<photonsToVeto.size(); p++ ) {
1060 +    const mithep::PFCandidate * pf  = photonsToVeto[p];
1061 +    TLorentzVector pfvec;
1062 +    pfvec.SetPtEtaPhiM(pf->Pt(),pf->Eta(),pf->Phi(),0.);
1063 +    tmpvec += pfvec;
1064 +  }
1065 +
1066    double pfIso = fChargedIso + fmax(0.0,(fGammaIso + fNeutralHadronIso
1067                                          -rho*muT.MuonEffectiveArea(muT.kMuGammaAndNeutralHadronIso04,
1068 <                                                                   mu->Eta(),EffectiveAreaVersion)));
1068 >                                                                   //tmpvec.Eta(),EffectiveAreaVersion)));
1069 >                                                                   mu->Eta(),EffectiveAreaVersion)));
1070    gChargedIso = fChargedIso;
1071    gGammaIso   = fGammaIso;
1072    gNeutralIso = fNeutralHadronIso;
1073    
1074 +  if( ctrl.debug ) {
1075 +    cout << "PFiso: " << pfIso
1076 +         << "\tfChargedIso: " << fChargedIso
1077 +         << "\tfGammaIso: " << fGammaIso
1078 +         << "\tfNeutralHadronIso: " << fNeutralHadronIso
1079 +         << endl;
1080 +  }
1081 +
1082    return pfIso;
1083   }
1084  
# Line 1330 | Line 1269 | SelectionStatus muonReferenceIsoSelectio
1269                                            const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1270                                            const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
1271                                            mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
1272 <                                          vector<const mithep::Muon*> muonsToVeto,
1334 <                                          vector<const mithep::Electron*> electronsToVeto)
1272 >                                          vector<const mithep::PFCandidate*> photonsToVeto)
1273   //--------------------------------------------------------------------------------------------------
1274   {
1275    
1276    SelectionStatus status;
1277  
1278    double pfIso = muonPFIso04( ctrl, mu, vtx, fPFCandidates, fPUEnergyDensity,
1279 <                              EffectiveAreaVersion, muonsToVeto ,electronsToVeto );
1279 >                              EffectiveAreaVersion, photonsToVeto);
1280    //  cout << "--------------> setting muon isoPF04 to" << pfIso << endl;
1281    status.isoPF04 = pfIso;
1282    status.chisoPF04 = gChargedIso;
# Line 1352 | Line 1290 | SelectionStatus muonReferenceIsoSelectio
1290      status.orStatus(SelectionStatus::LOOSEISO);
1291      status.orStatus(SelectionStatus::TIGHTISO);
1292    }
1293 <  if(ctrl.debug) cout << "returning status : " << hex << status.getStatus() << dec << endl;
1293 >  if(ctrl.debug) {
1294 >    cout << "mu relpfIso: " << pfIso/mu->Pt() << endl;
1295 >    cout << "returning status : " << hex << status.getStatus() << dec << endl;
1296 >  }
1297    return status;
1298    
1299   }
# Line 2263 | Line 2204 | float electronPFIso04(ControlFlags &ctrl
2204                        const mithep::Array<mithep::PFCandidate> * fPFCandidates,
2205                        const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
2206                        mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
2207 <                      vector<const mithep::Muon*> muonsToVeto,
2267 <                      vector<const mithep::Electron*> electronsToVeto)
2207 >                      vector<const mithep::PFCandidate*> photonsToVeto)        
2208   //--------------------------------------------------------------------------------------------------
2209   {
2270  /*
2271  if( ctrl.debug ) {
2272    cout << "electronIsoMVASelection :: muons to veto " << endl;
2273    for( int i=0; i<muonsToVeto.size(); i++ ) {
2274      const mithep::Muon * vmu = muonsToVeto[i];
2275      cout << "\tpt: " << vmu->Pt()
2276           << "\teta: " << vmu->Eta()
2277           << "\tphi: " << vmu->Phi()
2278           << endl;
2279    }
2280    cout << "electronIsoMVASelection :: electrons to veto " << endl;
2281    for( int i=0; i<electronsToVeto.size(); i++ ) {
2282      const mithep::Electron * vel = electronsToVeto[i];
2283      cout << "\tpt: " << vel->Pt()
2284           << "\teta: " << vel->Eta()
2285           << "\tphi: " << vel->Phi()
2286           << "\ttrk: " << vel->TrackerTrk()
2287           << endl;
2288    }
2289  }
2290  */
2210  
2211    //
2212    // final iso
# Line 2302 | Line 2221 | float electronPFIso04(ControlFlags &ctrl
2221    //
2222    for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2223  
2305
2224      const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
2225 +
2226 +    //
2227 +    // veto FSR recovered photons
2228 +    //
2229 +    bool vetoPhoton = false;
2230 +    for( int p=0; p<photonsToVeto.size(); p++ ) {
2231 +      if( pf == photonsToVeto[p] ) {
2232 +        vetoPhoton = true;
2233 +        break;
2234 +      }
2235 +    } if( vetoPhoton ) continue;
2236 +
2237      Double_t deta = (ele->Eta() - pf->Eta());
2238      Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(ele->Phi()),Double_t(pf->Phi()));
2239      Double_t dr = mithep::MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta());
# Line 2337 | Line 2267 | float electronPFIso04(ControlFlags &ctrl
2267      Bool_t IsLeptonFootprint = kFALSE;
2268      if (dr < 1.0) {
2269  
2340      //
2341      // Check for electrons
2342      //
2343      for (Int_t q=0; q < electronsToVeto.size(); ++q) {
2344        const mithep::Electron *tmpele = electronsToVeto[q];
2345        /*
2346        // 4l electron
2347        if( pf->HasTrackerTrk()  ) {
2348          if( pf->TrackerTrk() == tmpele->TrackerTrk() ) {
2349            if( ctrl.debug) cout << "\tcharged tktrk, matches 4L ele ..." << endl;
2350            IsLeptonFootprint = kTRUE;
2351          }
2352        }
2353        if( pf->HasGsfTrk()  ) {
2354          if( pf->GsfTrk() == tmpele->GsfTrk() ) {
2355            if( ctrl.debug) cout << "\tcharged gsftrk, matches 4L ele ..." << endl;
2356            IsLeptonFootprint = kTRUE;
2357          }
2358        }
2359        */
2360        // PF charged
2361        if (pf->Charge() != 0 && fabs(tmpele->SCluster()->Eta()) > 1.479
2362            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.015) {
2363          if( ctrl.debug) cout << "\tcharged trk, dR matches 4L ele ..." << endl;
2364          IsLeptonFootprint = kTRUE;
2365        }
2366        // PF gamma
2367        if (abs(pf->PFType()) == PFCandidate::eGamma && fabs(tmpele->SCluster()->Eta()) > 1.479
2368            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.08) {
2369          if( ctrl.debug) cout << "\tPF gamma, matches 4L ele ..." << endl;
2370          IsLeptonFootprint = kTRUE;
2371        }
2372      } // loop over electrons
2373
2374      /* KH - comment for sync            
2375      //
2376      // Check for muons
2377      //
2378      for (Int_t q=0; q < muonsToVeto.size(); ++q) {
2379        const mithep::Muon *tmpmu = muonsToVeto[q];
2380        // 4l muon
2381        if( pf->HasTrackerTrk() ) {
2382          if (pf->TrackerTrk() == tmpmu->TrackerTrk() ){
2383            if( ctrl.debug) cout << "\tmatches 4L mu ..." << endl;
2384            IsLeptonFootprint = kTRUE;
2385          }
2386        }
2387        // PF charged
2388        if (pf->Charge() != 0 && mithep::MathUtils::DeltaR(tmpmu->Phi(),tmpmu->Eta(), pf->Phi(), pf->Eta()) < 0.01) {
2389          if( ctrl.debug) cout << "\tcharged trk, dR matches 4L mu ..." << endl;
2390          IsLeptonFootprint = kTRUE;
2391        }
2392      } // loop over muons
2393      */
2394
2395    if (IsLeptonFootprint)
2396      continue;
2270  
2271      //
2272      // Charged Iso
2273      //
2274      if (pf->Charge() != 0 && (pf->HasTrackerTrk()||pf->HasGsfTrk()) ) {
2275  
2403 //       if( pf->HasTrackerTrk() )
2404 //      if (abs(pf->TrackerTrk()->DzCorrected(vtx)) > 0.2) continue;
2405 //       if( pf->HasGsfTrk() )
2406 //      if (abs(pf->GsfTrk()->DzCorrected(vtx)) > 0.2) continue;
2407
2276        // Veto any PFmuon, or PFEle
2277        if (abs(pf->PFType()) == PFCandidate::eElectron || abs(pf->PFType()) == PFCandidate::eMuon) {
2278          if( ctrl.debug ) cout << "\t skipping, pf is and ele or mu .." <<endl;
# Line 2429 | Line 2297 | float electronPFIso04(ControlFlags &ctrl
2297        if (fabs(ele->SCluster()->Eta()) > 1.479) {
2298          if (mithep::MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta()) < 0.08) continue;
2299        }
2300 +
2301 +      assert(ele->HasSuperCluster());
2302 +      if(ele->GsfTrk()->NExpectedHitsInner()>0 && pf->MvaGamma() > 0.99 && pf->HasSCluster() && ele->SCluster() == pf->SCluster())      continue;
2303 +
2304 +
2305        if( ctrl.debug) cout << "gamma:: " << pf->Pt() << " "
2306                             << dr << endl;
2307        // KH, add to sync
# Line 2466 | Line 2339 | float electronPFIso04(ControlFlags &ctrl
2339            isinf(fPUEnergyDensity->At(0)->RhoKt6PFJets())))
2340        rho = fPUEnergyDensity->At(0)->RhoKt6PFJets();
2341      // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
2342 <    EffectiveAreaVersion  = mithep::ElectronTools::kEleEAData2011;
2342 >    EffectiveAreaVersion  = mithep::ElectronTools::kEleEAData2012;
2343      // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
2344    }
2345    if(ctrl.debug) cout << "rho: " << rho << endl;
# Line 2479 | Line 2352 | float electronPFIso04(ControlFlags &ctrl
2352    gChargedIso = fChargedIso;
2353    gGammaIso = fGammaIso;
2354    gNeutralIso = fNeutralHadronIso;  
2355 +
2356 +  if( ctrl.debug ) {
2357 +    cout << "PFiso: " << pfIso
2358 +         << "\tfChargedIso: " << fChargedIso
2359 +         << "\tfGammaIso: " << fGammaIso
2360 +         << "\tfNeutralHadronIso: " << fNeutralHadronIso
2361 +         << endl;
2362 +  }
2363 +
2364    return pfIso;
2365   }
2366  
# Line 2709 | Line 2591 | SelectionStatus electronReferenceIsoSele
2591                                                const mithep::Array<mithep::PFCandidate> * fPFCandidates,
2592                                                const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
2593                                                mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
2594 <                                              vector<const mithep::Muon*> muonsToVeto,
2713 <                                              vector<const mithep::Electron*> electronsToVeto)
2594 >                                              vector<const mithep::PFCandidate*> photonsToVeto)
2595   //--------------------------------------------------------------------------------------------------
2596   {
2597  
2598    SelectionStatus status;
2599  
2600    double pfIso = electronPFIso04( ctrl, ele, vtx, fPFCandidates, fPUEnergyDensity,
2601 <                                  EffectiveAreaVersion, muonsToVeto ,electronsToVeto );
2601 >                                  EffectiveAreaVersion, photonsToVeto);
2602    //  cout << "--------------> setting electron isoPF04 to " << pfIso << endl;
2603    status.isoPF04 = pfIso;
2604    status.chisoPF04 = gChargedIso;
# Line 2731 | Line 2612 | SelectionStatus electronReferenceIsoSele
2612      status.orStatus(SelectionStatus::LOOSEISO);
2613      status.orStatus(SelectionStatus::TIGHTISO);
2614    }
2615 <  if(ctrl.debug) cout << "returning status : " << hex << status.getStatus() << dec << endl;
2615 >  if(ctrl.debug) {
2616 >    cout << "el relpfIso: " << pfIso/ele->Pt() << endl;
2617 >    cout << "returning status : " << hex << status.getStatus() << dec << endl;
2618 >  }
2619    return status;
2620  
2621   }
# Line 2769 | Line 2653 | SelectionStatus electronReferenceIsoSele
2653    return status;
2654  
2655   }
2656 +
2657 +
2658 +
2659 + //--------------------------------------------------------------------------------------------------
2660 + double  dbetaCorrectedIsoDr03(ControlFlags & ctrl,
2661 +                              const mithep::PFCandidate * photon,
2662 +                              const mithep::Muon * lepton,
2663 +                              const mithep::Array<mithep::PFCandidate> * fPFCandidates)
2664 + //--------------------------------------------------------------------------------------------------
2665 + {
2666 +
2667 +  //
2668 +  // final iso
2669 +  //
2670 +  Double_t fChargedIso  = 0.0;
2671 +  Double_t fGammaIso  = 0.0;
2672 +  Double_t fNeutralHadronIso  = 0.0;
2673 +  Double_t fpfPU  = 0.0;
2674 +
2675 +  //
2676 +  // Loop over PF Candidates
2677 +  //
2678 +  for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2679 +
2680 +    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
2681 +    
2682 +    Double_t deta = (photon->Eta() - pf->Eta());
2683 +    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(photon->Phi()),Double_t(pf->Phi()));
2684 +    Double_t dr = mithep::MathUtils::DeltaR(photon->Phi(),photon->Eta(), pf->Phi(), pf->Eta());
2685 +    if (dr > 0.3) continue;
2686 +
2687 +    if( !(PFnoPUflag[k]) && pf->Charge() != 0 ) {
2688 +      if( pf->Pt() >= 0.2 && dr > 0.01 )
2689 +        fpfPU += pf->Pt();
2690 +      continue;
2691 +    }
2692 +    
2693 +    //
2694 +    // skip this photon
2695 +    //
2696 +    if( abs(pf->PFType()) == mithep::PFCandidate::eGamma &&
2697 +        pf->Et() == photon->Et() ) continue;
2698 +    
2699 +      
2700 +    //
2701 +    // Charged Iso
2702 +    //
2703 +    if (pf->Charge() != 0 ) {
2704 +      if( dr > 0.01 && pf->Pt() >= 0.2 &&
2705 +          !(pf->TrackerTrk() == lepton->TrackerTrk()) )
2706 +        fChargedIso += pf->Pt();
2707 +    }
2708 +    
2709 +    //
2710 +    // Gamma Iso
2711 +    //
2712 +    else if (abs(pf->PFType()) == mithep::PFCandidate::eGamma) {
2713 +      if( pf->Pt() > 0.5 && dr > 0.01)
2714 +        fGammaIso += pf->Pt();
2715 +    }
2716 +    
2717 +    //
2718 +    // Other Neutrals
2719 +    //
2720 +    else {
2721 +      if( pf->Pt() > 0.5 && dr > 0.01)
2722 +        fNeutralHadronIso += pf->Pt();
2723 +    }
2724 +    
2725 +  }
2726 +  
2727 +  if( ctrl.debug ) {
2728 +    cout << "photon dbetaIso :: " << endl;
2729 +    cout << "\tfChargedIso: " << fChargedIso
2730 +         << "\tfGammaIso: " << fGammaIso
2731 +         << "\tfNeutralHadronIso: " << fNeutralHadronIso
2732 +         << "\tfpfPU: " << fpfPU
2733 +         << endl;
2734 +  }
2735 +  double pfIso = fChargedIso + fGammaIso + fNeutralHadronIso - 0.5*fpfPU;
2736 +  return pfIso/photon->Pt();
2737 + }
2738 +
2739 +
2740 + //--------------------------------------------------------------------------------------------------
2741 + double  dbetaCorrectedIsoDr03(ControlFlags & ctrl,
2742 +                              const mithep::PFCandidate * photon,
2743 +                              const mithep::Electron * lepton,
2744 +                              const mithep::Array<mithep::PFCandidate> * fPFCandidates)
2745 + //--------------------------------------------------------------------------------------------------
2746 + {
2747 +
2748 +  //
2749 +  // final iso
2750 +  //
2751 +  Double_t fChargedIso  = 0.0;
2752 +  Double_t fGammaIso  = 0.0;
2753 +  Double_t fNeutralHadronIso  = 0.0;
2754 +  Double_t fpfPU  = 0.0;
2755 +
2756 +  //
2757 +  // Loop over PF Candidates
2758 +  //
2759 +  for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2760 +
2761 +    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
2762 +    
2763 +    Double_t deta = (photon->Eta() - pf->Eta());
2764 +    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(photon->Phi()),Double_t(pf->Phi()));
2765 +    Double_t dr = mithep::MathUtils::DeltaR(photon->Phi(),photon->Eta(), pf->Phi(), pf->Eta());
2766 +    if (dr > 0.3) continue;
2767 +
2768 +    if( !(PFnoPUflag[k]) && pf->Charge() != 0 ) {
2769 +      if( pf->Pt() >= 0.2 && dr > 0.01 )
2770 +        fpfPU += pf->Pt();
2771 +      continue;
2772 +    }
2773 +    
2774 +    //
2775 +    // skip this photon
2776 +    //
2777 +    if( abs(pf->PFType()) == mithep::PFCandidate::eGamma &&
2778 +        pf->Et() == photon->Et() ) continue;
2779 +    
2780 +      
2781 +    //
2782 +    // Charged Iso
2783 +    //
2784 +    if (pf->Charge() != 0 ) {
2785 +      if( dr > 0.01 && pf->Pt() >= 0.2 &&
2786 +          !(pf->TrackerTrk() == lepton->TrackerTrk()) )
2787 +        fChargedIso += pf->Pt();
2788 +    }
2789 +    
2790 +    //
2791 +    // Gamma Iso
2792 +    //
2793 +    else if (abs(pf->PFType()) == mithep::PFCandidate::eGamma) {
2794 +      if( pf->Pt() > 0.5 && dr > 0.01)
2795 +        fGammaIso += pf->Pt();
2796 +    }
2797 +    
2798 +    //
2799 +    // Other Neutrals
2800 +    //
2801 +    else {
2802 +      if( pf->Pt() > 0.5 && dr > 0.01)
2803 +        fNeutralHadronIso += pf->Pt();
2804 +    }
2805 +    
2806 +  }
2807 +  
2808 +  if( ctrl.debug ) {
2809 +    cout << "photon dbetaIso :: " << endl;
2810 +    cout << "\tfChargedIso: " << fChargedIso
2811 +         << "\tfGammaIso: " << fGammaIso
2812 +         << "\tfNeutralHadronIso: " << fNeutralHadronIso
2813 +         << "\tfpfPU: " << fpfPU
2814 +         << endl;
2815 +  }
2816 +  double pfIso = fChargedIso + fGammaIso + fNeutralHadronIso - 0.5*fpfPU;
2817 +  return pfIso/photon->Pt();
2818 + }
2819 +
2820 +
2821 +
2822 +
2823 +
2824 + //--------------------------------------------------------------------------------------------------
2825 + double  nonCorrectedIsoDr03(ControlFlags & ctrl,
2826 +                            const mithep::PFCandidate * photon,
2827 +                            const mithep::Muon * lepton,
2828 +                            const mithep::Array<mithep::PFCandidate> * fPFCandidates)
2829 + //--------------------------------------------------------------------------------------------------
2830 + {
2831 +
2832 +  //
2833 +  // final iso
2834 +  //
2835 +  Double_t fChargedIso  = 0.0;
2836 +  Double_t fGammaIso  = 0.0;
2837 +  Double_t fNeutralHadronIso  = 0.0;
2838 +  Double_t fpfPU  = 0.0;
2839 +
2840 +  //
2841 +  // Loop over PF Candidates
2842 +  //
2843 +  for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2844 +
2845 +    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
2846 +
2847 +    Double_t deta = (photon->Eta() - pf->Eta());
2848 +    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(photon->Phi()),Double_t(pf->Phi()));
2849 +    Double_t dr = mithep::MathUtils::DeltaR(photon->Phi(),photon->Eta(), pf->Phi(), pf->Eta());
2850 +    if (dr > 0.3) continue;
2851 +
2852 +    if( !(PFnoPUflag[k]) && pf->Charge() != 0 ) {
2853 +      if( pf->Pt() >= 0.2 && dr > 0.01 )
2854 +        fpfPU += pf->Pt();
2855 +      continue;
2856 +    }
2857 +    
2858 +    //
2859 +    // skip this photon
2860 +    //
2861 +    if( abs(pf->PFType()) == mithep::PFCandidate::eGamma &&
2862 +        pf->Et() == photon->Et() ) continue;
2863 +    
2864 +      
2865 +    //
2866 +    // Charged Iso
2867 +    //
2868 +    if (pf->Charge() != 0 ) {
2869 +      if( dr > 0.01 && pf->Pt() >= 0.2 &&
2870 +          !(pf->TrackerTrk() == lepton->TrackerTrk()) )
2871 +        fChargedIso += pf->Pt();
2872 +    }
2873 +    
2874 +    //
2875 +    // Gamma Iso
2876 +    //
2877 +    else if (abs(pf->PFType()) == mithep::PFCandidate::eGamma) {
2878 +      if( pf->Pt() > 0.5 && dr > 0.01)
2879 +        fGammaIso += pf->Pt();
2880 +    }
2881 +    
2882 +    //
2883 +    // Other Neutrals
2884 +    //
2885 +    else {
2886 +      if( pf->Pt() > 0.5 && dr > 0.01)
2887 +        fNeutralHadronIso += pf->Pt();
2888 +    }
2889 +    
2890 +  }
2891 +  
2892 +  if( ctrl.debug ) {
2893 +    cout << "photon dbetaIso :: " << endl;
2894 +    cout << "\tfChargedIso: " << fChargedIso
2895 +         << "\tfGammaIso: " << fGammaIso
2896 +         << "\tfNeutralHadronIso: " << fNeutralHadronIso
2897 +         << "\tfpfPU: " << fpfPU
2898 +         << endl;
2899 +  }
2900 +  double pfIso = fChargedIso + fGammaIso + fNeutralHadronIso + fpfPU;
2901 +  return pfIso/photon->Pt();
2902 + }
2903 +
2904 +
2905 +
2906 + //--------------------------------------------------------------------------------------------------
2907 + double  nonCorrectedIsoDr03(ControlFlags & ctrl,
2908 +                            const mithep::PFCandidate * photon,
2909 +                            const mithep::Electron * lepton,
2910 +                            const mithep::Array<mithep::PFCandidate> * fPFCandidates)
2911 + //--------------------------------------------------------------------------------------------------
2912 + {
2913 +
2914 +  //
2915 +  // final iso
2916 +  //
2917 +  Double_t fChargedIso  = 0.0;
2918 +  Double_t fGammaIso  = 0.0;
2919 +  Double_t fNeutralHadronIso  = 0.0;
2920 +  Double_t fpfPU  = 0.0;
2921 +
2922 +  //
2923 +  // Loop over PF Candidates
2924 +  //
2925 +  for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2926 +
2927 +    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
2928 +
2929 +    Double_t deta = (photon->Eta() - pf->Eta());
2930 +    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(photon->Phi()),Double_t(pf->Phi()));
2931 +    Double_t dr = mithep::MathUtils::DeltaR(photon->Phi(),photon->Eta(), pf->Phi(), pf->Eta());
2932 +    if (dr > 0.3) continue;
2933 +
2934 +    if( !(PFnoPUflag[k]) && pf->Charge() != 0 ) {
2935 +      if( pf->Pt() >= 0.2 && dr > 0.01 )
2936 +        fpfPU += pf->Pt();
2937 +      continue;
2938 +    }
2939 +    
2940 +    //
2941 +    // skip this photon
2942 +    //
2943 +    if( abs(pf->PFType()) == mithep::PFCandidate::eGamma &&
2944 +        pf->Et() == photon->Et() ) continue;
2945 +    
2946 +      
2947 +    //
2948 +    // Charged Iso
2949 +    //
2950 +    if (pf->Charge() != 0 ) {
2951 +      if( dr > 0.01 && pf->Pt() >= 0.2 &&
2952 +          !(pf->TrackerTrk() == lepton->TrackerTrk()) )
2953 +        fChargedIso += pf->Pt();
2954 +    }
2955 +    
2956 +    //
2957 +    // Gamma Iso
2958 +    //
2959 +    else if (abs(pf->PFType()) == mithep::PFCandidate::eGamma) {
2960 +      if( pf->Pt() > 0.5 && dr > 0.01)
2961 +        fGammaIso += pf->Pt();
2962 +    }
2963 +    
2964 +    //
2965 +    // Other Neutrals
2966 +    //
2967 +    else {
2968 +      if( pf->Pt() > 0.5 && dr > 0.01)
2969 +        fNeutralHadronIso += pf->Pt();
2970 +    }
2971 +    
2972 +  }
2973 +  
2974 +  if( ctrl.debug ) {
2975 +    cout << "photon dbetaIso :: " << endl;
2976 +    cout << "\tfChargedIso: " << fChargedIso
2977 +         << "\tfGammaIso: " << fGammaIso
2978 +         << "\tfNeutralHadronIso: " << fNeutralHadronIso
2979 +         << "\tfpfPU: " << fpfPU
2980 +         << endl;
2981 +  }
2982 +  double pfIso = fChargedIso + fGammaIso + fNeutralHadronIso + fpfPU;
2983 +  return pfIso/photon->Pt();
2984 + }
2985 +
2986 +
2987 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines