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.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 1120 | Line 1041 | double  muonPFIso04(ControlFlags &ctrl,
1041      if (!(isnan(fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25()) ||
1042            isinf(fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25())))
1043        rho = fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25();
1044 +    //rho = fPUEnergyDensity->At(0)->Rho();
1045      // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
1046      EffectiveAreaVersion  = mithep::MuonTools::kMuEAData2011;
1047      // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
# Line 1128 | Line 1050 | double  muonPFIso04(ControlFlags &ctrl,
1050            isinf(fPUEnergyDensity->At(0)->RhoKt6PFJetsCentralNeutral())))
1051        rho = fPUEnergyDensity->At(0)->RhoKt6PFJetsCentralNeutral();
1052      // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
1053 <    EffectiveAreaVersion  = mithep::MuonTools::kMuEAData2011;
1053 >    EffectiveAreaVersion  = mithep::MuonTools::kMuEAData2012;
1054      // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
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 1330 | 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,
1334 <                                          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 1347 | 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 2263 | 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,
2267 <                      vector<const mithep::Electron*> electronsToVeto)
2208 >                      vector<const mithep::PFCandidate*> photonsToVeto)        
2209   //--------------------------------------------------------------------------------------------------
2210   {
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  */
2211  
2212    //
2213    // final iso
# Line 2302 | Line 2222 | float electronPFIso04(ControlFlags &ctrl
2222    //
2223    for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2224  
2305
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 2337 | Line 2268 | float electronPFIso04(ControlFlags &ctrl
2268      Bool_t IsLeptonFootprint = kFALSE;
2269      if (dr < 1.0) {
2270  
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;
2271  
2272      //
2273      // Charged Iso
2274      //
2275      if (pf->Charge() != 0 && (pf->HasTrackerTrk()||pf->HasGsfTrk()) ) {
2276  
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
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 2429 | 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 2466 | Line 2340 | float electronPFIso04(ControlFlags &ctrl
2340            isinf(fPUEnergyDensity->At(0)->RhoKt6PFJets())))
2341        rho = fPUEnergyDensity->At(0)->RhoKt6PFJets();
2342      // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
2343 <    EffectiveAreaVersion  = mithep::ElectronTools::kEleEAData2011;
2343 >    EffectiveAreaVersion  = mithep::ElectronTools::kEleEAData2012;
2344      // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
2345    }
2346    if(ctrl.debug) cout << "rho: " << rho << endl;
# Line 2479 | 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 2709 | 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,
2713 <                                              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 2731 | 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 2769 | Line 2654 | SelectionStatus electronReferenceIsoSele
2654    return status;
2655  
2656   }
2657 +
2658 +
2659 +
2660 + //--------------------------------------------------------------------------------------------------
2661 + double  dbetaCorrectedIsoDr03(ControlFlags & ctrl,
2662 +                              const mithep::PFCandidate * photon,
2663 +                              const mithep::Muon * lepton,
2664 +                              const mithep::Array<mithep::PFCandidate> * fPFCandidates)
2665 + //--------------------------------------------------------------------------------------------------
2666 + {
2667 +
2668 +  //
2669 +  // final iso
2670 +  //
2671 +  Double_t fChargedIso  = 0.0;
2672 +  Double_t fGammaIso  = 0.0;
2673 +  Double_t fNeutralHadronIso  = 0.0;
2674 +  Double_t fpfPU  = 0.0;
2675 +
2676 +  //
2677 +  // Loop over PF Candidates
2678 +  //
2679 +  for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2680 +
2681 +    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
2682 +    
2683 +    Double_t deta = (photon->Eta() - pf->Eta());
2684 +    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(photon->Phi()),Double_t(pf->Phi()));
2685 +    Double_t dr = mithep::MathUtils::DeltaR(photon->Phi(),photon->Eta(), pf->Phi(), pf->Eta());
2686 +    if (dr > 0.3) continue;
2687 +
2688 +    if( !(PFnoPUflag[k]) && pf->Charge() != 0 ) {
2689 +      if( pf->Pt() >= 0.2 && dr > 0.01 )
2690 +        fpfPU += pf->Pt();
2691 +      continue;
2692 +    }
2693 +    
2694 +    //
2695 +    // skip this photon
2696 +    //
2697 +    if( abs(pf->PFType()) == mithep::PFCandidate::eGamma &&
2698 +        pf->Et() == photon->Et() ) continue;
2699 +    
2700 +      
2701 +    //
2702 +    // Charged Iso
2703 +    //
2704 +    if (pf->Charge() != 0 ) {
2705 +      if( dr > 0.01 && pf->Pt() >= 0.2 &&
2706 +          !(pf->TrackerTrk() == lepton->TrackerTrk()) )
2707 +        fChargedIso += pf->Pt();
2708 +    }
2709 +    
2710 +    //
2711 +    // Gamma Iso
2712 +    //
2713 +    else if (abs(pf->PFType()) == mithep::PFCandidate::eGamma) {
2714 +      if( pf->Pt() > 0.5 && dr > 0.01)
2715 +        fGammaIso += pf->Pt();
2716 +    }
2717 +    
2718 +    //
2719 +    // Other Neutrals
2720 +    //
2721 +    else {
2722 +      if( pf->Pt() > 0.5 && dr > 0.01)
2723 +        fNeutralHadronIso += pf->Pt();
2724 +    }
2725 +    
2726 +  }
2727 +  
2728 +  if( ctrl.debug ) {
2729 +    cout << "photon dbetaIso :: " << endl;
2730 +    cout << "\tfChargedIso: " << fChargedIso
2731 +         << "\tfGammaIso: " << fGammaIso
2732 +         << "\tfNeutralHadronIso: " << fNeutralHadronIso
2733 +         << "\tfpfPU: " << fpfPU
2734 +         << endl;
2735 +  }
2736 +  double pfIso = fChargedIso + fGammaIso + fNeutralHadronIso - 0.5*fpfPU;
2737 +  return pfIso/photon->Pt();
2738 + }
2739 +
2740 +
2741 + //--------------------------------------------------------------------------------------------------
2742 + double  dbetaCorrectedIsoDr03(ControlFlags & ctrl,
2743 +                              const mithep::PFCandidate * photon,
2744 +                              const mithep::Electron * lepton,
2745 +                              const mithep::Array<mithep::PFCandidate> * fPFCandidates)
2746 + //--------------------------------------------------------------------------------------------------
2747 + {
2748 +
2749 +  //
2750 +  // final iso
2751 +  //
2752 +  Double_t fChargedIso  = 0.0;
2753 +  Double_t fGammaIso  = 0.0;
2754 +  Double_t fNeutralHadronIso  = 0.0;
2755 +  Double_t fpfPU  = 0.0;
2756 +
2757 +  //
2758 +  // Loop over PF Candidates
2759 +  //
2760 +  for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2761 +
2762 +    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
2763 +    
2764 +    Double_t deta = (photon->Eta() - pf->Eta());
2765 +    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(photon->Phi()),Double_t(pf->Phi()));
2766 +    Double_t dr = mithep::MathUtils::DeltaR(photon->Phi(),photon->Eta(), pf->Phi(), pf->Eta());
2767 +    if (dr > 0.3) continue;
2768 +
2769 +    if( !(PFnoPUflag[k]) && pf->Charge() != 0 ) {
2770 +      if( pf->Pt() >= 0.2 && dr > 0.01 )
2771 +        fpfPU += pf->Pt();
2772 +      continue;
2773 +    }
2774 +    
2775 +    //
2776 +    // skip this photon
2777 +    //
2778 +    if( abs(pf->PFType()) == mithep::PFCandidate::eGamma &&
2779 +        pf->Et() == photon->Et() ) continue;
2780 +    
2781 +      
2782 +    //
2783 +    // Charged Iso
2784 +    //
2785 +    if (pf->Charge() != 0 ) {
2786 +      if( dr > 0.01 && pf->Pt() >= 0.2 &&
2787 +          !(pf->TrackerTrk() == lepton->TrackerTrk()) )
2788 +        fChargedIso += pf->Pt();
2789 +    }
2790 +    
2791 +    //
2792 +    // Gamma Iso
2793 +    //
2794 +    else if (abs(pf->PFType()) == mithep::PFCandidate::eGamma) {
2795 +      if( pf->Pt() > 0.5 && dr > 0.01)
2796 +        fGammaIso += pf->Pt();
2797 +    }
2798 +    
2799 +    //
2800 +    // Other Neutrals
2801 +    //
2802 +    else {
2803 +      if( pf->Pt() > 0.5 && dr > 0.01)
2804 +        fNeutralHadronIso += pf->Pt();
2805 +    }
2806 +    
2807 +  }
2808 +  
2809 +  if( ctrl.debug ) {
2810 +    cout << "photon dbetaIso :: " << endl;
2811 +    cout << "\tfChargedIso: " << fChargedIso
2812 +         << "\tfGammaIso: " << fGammaIso
2813 +         << "\tfNeutralHadronIso: " << fNeutralHadronIso
2814 +         << "\tfpfPU: " << fpfPU
2815 +         << endl;
2816 +  }
2817 +  double pfIso = fChargedIso + fGammaIso + fNeutralHadronIso - 0.5*fpfPU;
2818 +  return pfIso/photon->Pt();
2819 + }
2820 +
2821 +
2822 +
2823 +
2824 +
2825 + //--------------------------------------------------------------------------------------------------
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 +
2833 +  //
2834 +  // final iso
2835 +  //
2836 +  Double_t fChargedIso  = 0.0;
2837 +  Double_t fGammaIso  = 0.0;
2838 +  Double_t fNeutralHadronIso  = 0.0;
2839 +  Double_t fpfPU  = 0.0;
2840 +
2841 +  //
2842 +  // Loop over PF Candidates
2843 +  //
2844 +  for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2845 +
2846 +    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
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());
2851 +    if (dr > 0.3) continue;
2852 +
2853 +    if( !(PFnoPUflag[k]) && pf->Charge() != 0 ) {
2854 +      if( pf->Pt() >= 0.2 && dr > 0.01 )
2855 +        fpfPU += pf->Pt();
2856 +      continue;
2857 +    }
2858 +    
2859 +    //
2860 +    // skip this photon
2861 +    //
2862 +    if( abs(pf->PFType()) == mithep::PFCandidate::eGamma &&
2863 +        pf->Et() == photon->Et() ) continue;
2864 +    
2865 +      
2866 +    //
2867 +    // Charged Iso
2868 +    //
2869 +    if (pf->Charge() != 0 ) {
2870 +      if( dr > 0.01 && pf->Pt() >= 0.2 &&
2871 +          !(pf->TrackerTrk() == lepton->TrackerTrk()) )
2872 +        fChargedIso += pf->Pt();
2873 +    }
2874 +    
2875 +    //
2876 +    // Gamma Iso
2877 +    //
2878 +    else if (abs(pf->PFType()) == mithep::PFCandidate::eGamma) {
2879 +      if( pf->Pt() > 0.5 && dr > 0.01)
2880 +        fGammaIso += pf->Pt();
2881 +    }
2882 +    
2883 +    //
2884 +    // Other Neutrals
2885 +    //
2886 +    else {
2887 +      if( pf->Pt() > 0.5 && dr > 0.01)
2888 +        fNeutralHadronIso += pf->Pt();
2889 +    }
2890 +    
2891 +  }
2892 +  
2893 +  if( ctrl.debug ) {
2894 +    cout << "photon dbetaIso :: " << endl;
2895 +    cout << "\tfChargedIso: " << fChargedIso
2896 +         << "\tfGammaIso: " << fGammaIso
2897 +         << "\tfNeutralHadronIso: " << fNeutralHadronIso
2898 +         << "\tfpfPU: " << fpfPU
2899 +         << endl;
2900 +  }  
2901 +
2902 +  double pfIso = fChargedIso + fGammaIso + fNeutralHadronIso + fpfPU;
2903 +  return pfIso/photon->Pt();
2904 + }
2905 +
2906 +
2907 +
2908 + //--------------------------------------------------------------------------------------------------
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 +
2916 +  //
2917 +  // final iso
2918 +  //
2919 +  Double_t fChargedIso  = 0.0;
2920 +  Double_t fGammaIso  = 0.0;
2921 +  Double_t fNeutralHadronIso  = 0.0;
2922 +  Double_t fpfPU  = 0.0;
2923 +
2924 +  //
2925 +  // Loop over PF Candidates
2926 +  //
2927 +  for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2928 +
2929 +    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
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());
2934 +    if (dr > 0.3) continue;
2935 +
2936 +    if( !(PFnoPUflag[k]) && pf->Charge() != 0 ) {
2937 +      if( pf->Pt() >= 0.2 && dr > 0.01 )
2938 +        fpfPU += pf->Pt();
2939 +      continue;
2940 +    }
2941 +    
2942 +    //
2943 +    // skip this photon
2944 +    //
2945 +    if( abs(pf->PFType()) == mithep::PFCandidate::eGamma &&
2946 +        pf->Et() == photon->Et() ) continue;
2947 +    
2948 +      
2949 +    //
2950 +    // Charged Iso
2951 +    //
2952 +    if (pf->Charge() != 0 ) {
2953 +      if( dr > 0.01 && pf->Pt() >= 0.2 &&
2954 +          !(pf->TrackerTrk() == lepton->TrackerTrk()) )
2955 +        fChargedIso += pf->Pt();
2956 +    }
2957 +    
2958 +    //
2959 +    // Gamma Iso
2960 +    //
2961 +    else if (abs(pf->PFType()) == mithep::PFCandidate::eGamma) {
2962 +      if( pf->Pt() > 0.5 && dr > 0.01)
2963 +        fGammaIso += pf->Pt();
2964 +    }
2965 +    
2966 +    //
2967 +    // Other Neutrals
2968 +    //
2969 +    else {
2970 +      if( pf->Pt() > 0.5 && dr > 0.01)
2971 +        fNeutralHadronIso += pf->Pt();
2972 +    }
2973 +    
2974 +  }
2975 +  
2976 +  if( ctrl.debug ) {
2977 +    cout << "photon dbetaIso :: " << endl;
2978 +    cout << "\tfChargedIso: " << fChargedIso
2979 +         << "\tfGammaIso: " << fGammaIso
2980 +         << "\tfNeutralHadronIso: " << fNeutralHadronIso
2981 +         << "\tfpfPU: " << fpfPU
2982 +         << endl;
2983 +  }
2984 +  double pfIso = fChargedIso + fGammaIso + fNeutralHadronIso + fpfPU;
2985 +  return pfIso/photon->Pt();
2986 + }
2987 +
2988 +
2989 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines