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.21 by khahn, Sun May 20 19:08:58 2012 UTC vs.
Revision 1.27 by khahn, Mon May 28 16:34:44 2012 UTC

# Line 25 | Line 25 | extern vector<bool> PFnoPUflag;
25  
26   //--------------------------------------------------------------------------------------------------
27   Float_t computePFMuonIso(const mithep::Muon *muon,
28 <                         const mithep::Vertex & vtx,
28 >                         const mithep::Vertex * vtx,
29                           const mithep::Array<mithep::PFCandidate> * fPFCandidates,
30                           const Double_t dRMax)
31   //--------------------------------------------------------------------------------------------------
# Line 34 | Line 34 | Float_t computePFMuonIso(const mithep::M
34    const Double_t neuPtMin = 1.0;
35    const Double_t dzMax    = 0.1;
36      
37 <  Double_t zLepton = (muon->BestTrk()) ? muon->BestTrk()->DzCorrected(vtx) : 0.0;
37 >  Double_t zLepton = (muon->BestTrk()) ? muon->BestTrk()->DzCorrected(*vtx) : 0.0;
38    
39    Float_t iso=0;
40    for(UInt_t ipf=0; ipf<fPFCandidates->GetEntries(); ipf++) {
# Line 46 | Line 46 | Float_t computePFMuonIso(const mithep::M
46      if(pfcand->TrackerTrk() && muon->TrackerTrk() && (pfcand->TrackerTrk()==muon->TrackerTrk())) continue;
47      
48      // dz cut
49 <    Double_t dz = (pfcand->BestTrk()) ? fabs(pfcand->BestTrk()->DzCorrected(vtx) - zLepton) : 0;
49 >    Double_t dz = (pfcand->BestTrk()) ? fabs(pfcand->BestTrk()->DzCorrected(*vtx) - zLepton) : 0;
50      if(dz >= dzMax) continue;
51      
52      // check iso cone
# Line 60 | Line 60 | Float_t computePFMuonIso(const mithep::M
60  
61   //--------------------------------------------------------------------------------------------------
62   Float_t computePFEleIso(const mithep::Electron *electron,
63 <                        const mithep::Vertex & fVertex,
63 >                        const mithep::Vertex * fVertex,
64                          const mithep::Array<mithep::PFCandidate> * fPFCandidates,
65                          const Double_t dRMax)
66   //--------------------------------------------------------------------------------------------------
# Line 69 | Line 69 | Float_t computePFEleIso(const mithep::El
69    const Double_t neuPtMin = 1.0;
70    const Double_t dzMax    = 0.1;
71      
72 <  Double_t zLepton = (electron->BestTrk()) ? electron->BestTrk()->DzCorrected(fVertex) : 0.0;
72 >  Double_t zLepton = (electron->BestTrk()) ? electron->BestTrk()->DzCorrected(*fVertex) : 0.0;
73    
74    Float_t iso=0;
75    for(UInt_t ipf=0; ipf<fPFCandidates->GetEntries(); ipf++) {
# Line 78 | Line 78 | Float_t computePFEleIso(const mithep::El
78      if(!pfcand->HasTrk() && (pfcand->Pt()<=neuPtMin)) continue;  // pT cut on neutral particles
79      
80      // dz cut
81 <    Double_t dz = (pfcand->BestTrk()) ? fabs(pfcand->BestTrk()->DzCorrected(fVertex) - zLepton) : 0;
81 >    Double_t dz = (pfcand->BestTrk()) ? fabs(pfcand->BestTrk()->DzCorrected(*fVertex) - zLepton) : 0;
82      if(dz >= dzMax) continue;
83      
84      // remove THE electron
# Line 182 | Line 182 | bool pairwiseIsoSelection( ControlFlags
182   //--------------------------------------------------------------------------------------------------
183   SelectionStatus muonIsoSelection(ControlFlags &ctrl,
184                                   const mithep::Muon * mu,
185 <                                 const mithep::Vertex & vtx,
185 >                                 const mithep::Vertex * vtx,
186                                   const mithep::Array<mithep::PFCandidate> * fPFCandidateCol   )
187   //--------------------------------------------------------------------------------------------------
188   {
# Line 212 | Line 212 | SelectionStatus muonIsoSelection(Control
212   //--------------------------------------------------------------------------------------------------
213   SelectionStatus electronIsoSelection(ControlFlags &ctrl,
214                                       const mithep::Electron * ele,
215 <                                     const mithep::Vertex &fVertex,
215 >                                     const mithep::Vertex *fVertex,
216                                       const mithep::Array<mithep::PFCandidate> * fPFCandidates)
217   //--------------------------------------------------------------------------------------------------
218   {
# Line 254 | Line 254 | bool noIso(ControlFlags &, vector<Simple
254   //--------------------------------------------------------------------------------------------------
255   SelectionStatus muonIsoMVASelection(ControlFlags &ctrl,
256                                      const mithep::Muon * mu,
257 <                                    const mithep::Vertex & vtx,
257 >                                    const mithep::Vertex * vtx,
258                                      const mithep::Array<mithep::PFCandidate> * fPFCandidates,
259                                      const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
260                                      mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
# Line 468 | Line 468 | SelectionStatus muonIsoMVASelection(Cont
468    double rho = 0;
469    if (!(isnan(fPUEnergyDensity->At(0)->Rho()) || isinf(fPUEnergyDensity->At(0)->Rho())))
470      rho = fPUEnergyDensity->At(0)->Rho();
471 +
472   //   if (!(isnan(fPUEnergyDensity->At(0)->RhoLowEta()) || isinf(fPUEnergyDensity->At(0)->RhoLowEta())))
473   //     rho = fPUEnergyDensity->At(0)->RhoLowEta();
474    
# Line 595 | Line 596 | SelectionStatus muonIsoMVASelection(Cont
596   //--------------------------------------------------------------------------------------------------
597   SelectionStatus muonIsoMVASelection(ControlFlags &ctrl,
598                                      const mithep::Muon * mu,
599 <                                    const mithep::Vertex & vtx,
599 >                                    const mithep::Vertex * vtx,
600                                      const mithep::Array<mithep::PFCandidate> * fPFCandidates,
601                                      float rho,
602                                      //const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
# Line 957 | Line 958 | void initMuonIsoMVA() {
958   //--------------------------------------------------------------------------------------------------
959   double  muonPFIso04(ControlFlags &ctrl,
960                      const mithep::Muon * mu,
961 <                    const mithep::Vertex & vtx,
961 >                    const mithep::Vertex * vtx,
962                      const mithep::Array<mithep::PFCandidate> * fPFCandidates,
963                      const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
964                      mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
# Line 1033 | Line 1034 | double  muonPFIso04(ControlFlags &ctrl,
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)
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)
# Line 1110 | Line 1115 | double  muonPFIso04(ControlFlags &ctrl,
1115    }
1116  
1117    double rho=0;
1118 <  if (!(isnan(fPUEnergyDensity->At(0)->Rho()) || isinf(fPUEnergyDensity->At(0)->Rho())))
1119 <    rho = fPUEnergyDensity->At(0)->Rho();
1120 <
1121 <  // WARNING!!!!  
1122 <  // hardcode for sync ...
1123 <  EffectiveAreaVersion = muT.kMuEAData2011;
1124 <  // WARNING!!!!  
1125 <
1126 <
1118 >  if( (EffectiveAreaVersion == mithep::MuonTools::kMuEAFall11MC) ||
1119 >      (EffectiveAreaVersion == mithep::MuonTools::kMuEAData2011) ) {
1120 >    if (!(isnan(fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25()) ||
1121 >          isinf(fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25())))
1122 >      rho = fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25();
1123 >    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
1124 >    EffectiveAreaVersion  = mithep::MuonTools::kMuEAData2011;
1125 >    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
1126 >  } else {
1127 >    if (!(isnan(fPUEnergyDensity->At(0)->RhoKt6PFJetsCentralNeutral()) ||
1128 >          isinf(fPUEnergyDensity->At(0)->RhoKt6PFJetsCentralNeutral())))
1129 >      rho = fPUEnergyDensity->At(0)->RhoKt6PFJetsCentralNeutral();
1130 >    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
1131 >    EffectiveAreaVersion  = mithep::MuonTools::kMuEAData2011;
1132 >    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
1133 >  }
1134 >  if(ctrl.debug) cout << "rho: " << rho << endl;
1135  
1136    double pfIso = fChargedIso + fmax(0.0,(fGammaIso + fNeutralHadronIso
1137                                          -rho*muT.MuonEffectiveArea(muT.kMuGammaAndNeutralHadronIso04,
# Line 1137 | Line 1150 | double  muonPFIso04(ControlFlags &ctrl,
1150   // hacked version
1151   double  muonPFIso04(ControlFlags &ctrl,
1152                      const mithep::Muon * mu,
1153 <                    const mithep::Vertex & vtx,
1153 >                    const mithep::Vertex * vtx,
1154                      const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1155                      float rho,
1156                      mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
# Line 1313 | Line 1326 | double  muonPFIso04(ControlFlags &ctrl,
1326   //--------------------------------------------------------------------------------------------------
1327   SelectionStatus muonReferenceIsoSelection(ControlFlags &ctrl,
1328                                            const mithep::Muon * mu,
1329 <                                          const mithep::Vertex & vtx,
1329 >                                          const mithep::Vertex * vtx,
1330                                            const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1331                                            const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
1332                                            mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
# Line 1349 | Line 1362 | SelectionStatus muonReferenceIsoSelectio
1362   // hacked version
1363   SelectionStatus muonReferenceIsoSelection(ControlFlags &ctrl,
1364                                            const mithep::Muon * mu,
1365 <                                          const mithep::Vertex & vtx,
1365 >                                          const mithep::Vertex * vtx,
1366                                            const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1367                                            float rho,
1368                                            mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
# Line 1386 | Line 1399 | SelectionStatus muonReferenceIsoSelectio
1399   //--------------------------------------------------------------------------------------------------
1400   SelectionStatus electronIsoMVASelection(ControlFlags &ctrl,
1401                                          const mithep::Electron * ele,
1402 <                                        const mithep::Vertex & vtx,
1402 >                                        const mithep::Vertex * vtx,
1403                                          const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1404                                          const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
1405                                          mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
# Line 1478 | Line 1491 | SelectionStatus electronIsoMVASelection(
1491  
1492      if(ctrl.debug) {
1493        cout << "pf :: type: " << pf->PFType() << "\tpt: " << pf->Pt();
1494 <      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(vtx);
1494 >      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(*vtx);
1495        cout << endl;
1496      }
1497  
# Line 1805 | Line 1818 | SelectionStatus electronIsoMVASelection(
1818   //--------------------------------------------------------------------------------------------------
1819   SelectionStatus electronIsoMVASelection(ControlFlags &ctrl,
1820                                          const mithep::Electron * ele,
1821 <                                        const mithep::Vertex & vtx,
1821 >                                        const mithep::Vertex * vtx,
1822                                          const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1823                                          float rho,
1824                                          //const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
# Line 1902 | Line 1915 | SelectionStatus electronIsoMVASelection(
1915  
1916      if(ctrl.debug) {
1917        cout << "pf :: type: " << pf->PFType() << "\tpt: " << pf->Pt();
1918 <      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(vtx);
1918 >      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(*vtx);
1919        cout << endl;
1920      }
1921  
# Line 2244 | Line 2257 | void initElectronIsoMVA() {
2257  
2258  
2259   //--------------------------------------------------------------------------------------------------
2247 // hacked version
2260   float electronPFIso04(ControlFlags &ctrl,
2261                        const mithep::Electron * ele,
2262 <                      const mithep::Vertex & vtx,
2262 >                      const mithep::Vertex * vtx,
2263                        const mithep::Array<mithep::PFCandidate> * fPFCandidates,
2264                        const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
2265                        mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
# Line 2255 | Line 2267 | float electronPFIso04(ControlFlags &ctrl
2267                        vector<const mithep::Electron*> electronsToVeto)
2268   //--------------------------------------------------------------------------------------------------
2269   {
2270 <
2270 >  /*
2271    if( ctrl.debug ) {
2272      cout << "electronIsoMVASelection :: muons to veto " << endl;
2273      for( int i=0; i<muonsToVeto.size(); i++ ) {
# Line 2275 | Line 2287 | float electronPFIso04(ControlFlags &ctrl
2287             << endl;
2288      }
2289    }
2290 <
2290 >  */
2291  
2292    //
2293    // final iso
# Line 2301 | Line 2313 | float electronPFIso04(ControlFlags &ctrl
2313  
2314      if(ctrl.debug) {
2315        cout << "pf :: type: " << pf->PFType() << "\tpt: " << pf->Pt() << "\tdR: " << dr;
2316 <      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(vtx)
2316 >      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(*vtx)
2317                                       << "\ttrk: " << pf->HasTrackerTrk()
2318                                       << "\tgsf: " << pf->HasGsfTrk();
2319        
# Line 2395 | Line 2407 | float electronPFIso04(ControlFlags &ctrl
2407  
2408        // Veto any PFmuon, or PFEle
2409        if (abs(pf->PFType()) == PFCandidate::eElectron || abs(pf->PFType()) == PFCandidate::eMuon) {
2410 <         cout << "\t skipping, pf is and ele or mu .." <<endl;
2410 >        if( ctrl.debug ) cout << "\t skipping, pf is and ele or mu .." <<endl;
2411          continue;
2412        }
2413  
# Line 2441 | Line 2453 | float electronPFIso04(ControlFlags &ctrl
2453  
2454  
2455    double rho=0;
2456 <  if (!(isnan(fPUEnergyDensity->At(0)->Rho()) || isinf(fPUEnergyDensity->At(0)->Rho())))
2457 <    rho = fPUEnergyDensity->At(0)->Rho();
2458 <
2459 <  // WARNING!!!!  
2460 <  // hardcode for sync ...
2461 <  EffectiveAreaVersion = eleT.kEleEAData2011;
2462 <  // WARNING!!!!  
2463 <
2456 >  if( (EffectiveAreaVersion == mithep::ElectronTools::kEleEAFall11MC) ||
2457 >      (EffectiveAreaVersion == mithep::ElectronTools::kEleEAData2011) ) {
2458 >    if (!(isnan(fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25()) ||
2459 >          isinf(fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25())))
2460 >      rho = fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25();
2461 >    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
2462 >    EffectiveAreaVersion  = mithep::ElectronTools::kEleEAData2011;
2463 >    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
2464 >  } else {
2465 >    if (!(isnan(fPUEnergyDensity->At(0)->RhoKt6PFJets()) ||
2466 >          isinf(fPUEnergyDensity->At(0)->RhoKt6PFJets())))
2467 >      rho = fPUEnergyDensity->At(0)->RhoKt6PFJets();
2468 >    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
2469 >    EffectiveAreaVersion  = mithep::ElectronTools::kEleEAData2011;
2470 >    // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
2471 >  }
2472 >  if(ctrl.debug) cout << "rho: " << rho << endl;
2473  
2474    double pfIso = fChargedIso + fmax(0.0,(fGammaIso + fNeutralHadronIso
2475                                          -rho*eleT.ElectronEffectiveArea(eleT.kEleGammaAndNeutralHadronIso04,
# Line 2467 | Line 2488 | float electronPFIso04(ControlFlags &ctrl
2488   // hacked version
2489   float electronPFIso04(ControlFlags &ctrl,
2490                        const mithep::Electron * ele,
2491 <                      const mithep::Vertex & vtx,
2491 >                      const mithep::Vertex * vtx,
2492                        const mithep::Array<mithep::PFCandidate> * fPFCandidates,
2493                        float rho,
2494                        mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
# Line 2521 | Line 2542 | float electronPFIso04(ControlFlags &ctrl
2542  
2543      if(ctrl.debug) {
2544        cout << "pf :: type: " << pf->PFType() << "\tpt: " << pf->Pt() << "\tdR: " << dr;
2545 <      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(vtx)
2545 >      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(*vtx)
2546                                       << "\ttrk: " << pf->HasTrackerTrk()
2547                                       << "\tgsf: " << pf->HasGsfTrk();
2548        
# Line 2615 | Line 2636 | float electronPFIso04(ControlFlags &ctrl
2636  
2637        // Veto any PFmuon, or PFEle
2638        if (abs(pf->PFType()) == PFCandidate::eElectron || abs(pf->PFType()) == PFCandidate::eMuon) {
2639 <         cout << "\t skipping, pf is and ele or mu .." <<endl;
2639 >        if( ctrl.debug ) cout << "\t skipping, pf is and ele or mu .." <<endl;
2640          continue;
2641        }
2642  
# Line 2684 | Line 2705 | float electronPFIso04(ControlFlags &ctrl
2705   //--------------------------------------------------------------------------------------------------
2706   SelectionStatus electronReferenceIsoSelection(ControlFlags &ctrl,
2707                                                const mithep::Electron * ele,
2708 <                                              const mithep::Vertex & vtx,
2708 >                                              const mithep::Vertex * vtx,
2709                                                const mithep::Array<mithep::PFCandidate> * fPFCandidates,
2710                                                const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
2711                                                mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
# Line 2720 | Line 2741 | SelectionStatus electronReferenceIsoSele
2741   // hacked version
2742   SelectionStatus electronReferenceIsoSelection(ControlFlags &ctrl,
2743                                                const mithep::Electron * ele,
2744 <                                              const mithep::Vertex & vtx,
2744 >                                              const mithep::Vertex * vtx,
2745                                                const mithep::Array<mithep::PFCandidate> * fPFCandidates,
2746                                                float rho,
2747                                                mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines