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.33 by anlevin, Wed Oct 17 01:31:22 2012 UTC vs.
Revision 1.35 by dkralph, Mon Dec 17 17:12:27 2012 UTC

# Line 9 | Line 9
9   #include "ElectronTools.h"
10   #include "ElectronIDMVA.h"
11  
12 < using namespace mithep;
13 <
14 < mithep::MuonIDMVA     * muIsoMVA;
15 < mithep::MuonTools       muT;
16 < mithep::ElectronIDMVA * eleIsoMVA;
17 < mithep::ElectronTools   eleT;
12 > MuonIDMVA     * muIsoMVA;
13 > MuonTools       muT;
14 > ElectronIDMVA * eleIsoMVA;
15 > ElectronTools   eleT;
16  
17   // global hack to sync
18   double gChargedIso;
# Line 24 | Line 22 | double gNeutralIso;
22   extern vector<bool> PFnoPUflag;
23  
24   //--------------------------------------------------------------------------------------------------
25 < Float_t computePFMuonIso(const mithep::Muon *muon,
26 <                         const mithep::Vertex * vtx,
27 <                         const mithep::Array<mithep::PFCandidate> * fPFCandidates,
25 > Float_t computePFMuonIso(const Muon *muon,
26 >                         const Vertex * vtx,
27 >                         const Array<PFCandidate> * fPFCandidates,
28                           const Double_t dRMax)
29   //--------------------------------------------------------------------------------------------------
30   {
# Line 59 | Line 57 | Float_t computePFMuonIso(const mithep::M
57   }
58  
59   //--------------------------------------------------------------------------------------------------
60 < Float_t computePFEleIso(const mithep::Electron *electron,
61 <                        const mithep::Vertex * fVertex,
62 <                        const mithep::Array<mithep::PFCandidate> * fPFCandidates,
60 > Float_t computePFEleIso(const Electron *electron,
61 >                        const Vertex * fVertex,
62 >                        const Array<PFCandidate> * fPFCandidates,
63                          const Double_t dRMax)
64   //--------------------------------------------------------------------------------------------------
65   {
# Line 101 | Line 99 | Float_t computePFEleIso(const mithep::El
99    
100    return iso;
101   };
104
105 //--------------------------------------------------------------------------------------------------
106 bool pairwiseIsoSelection( ControlFlags &ctrl,
107                           vector<SimpleLepton> &lepvec,
108                           float rho )
109 //--------------------------------------------------------------------------------------------------
110 {
111
112  bool passiso=true;
113
114  for( int i=0; i<lepvec.size(); i++ )
115    {
116      
117      if( !(lepvec[i].is4l) ) continue;
118      
119      float effArea_ecal_i, effArea_hcal_i;
120      if( lepvec[i].isEB ) {
121        if( lepvec[i].type == 11 ) {
122          effArea_ecal_i = 0.101;
123          effArea_hcal_i = 0.021;
124        } else {
125          effArea_ecal_i = 0.074;
126          effArea_hcal_i = 0.022;
127        }
128      } else {
129        if( lepvec[i].type == 11 ) {
130          effArea_ecal_i = 0.046;
131          effArea_hcal_i = 0.040;
132        } else {
133          effArea_ecal_i = 0.045;
134          effArea_hcal_i = 0.030;
135        }
136      }
137      
138      float isoEcal_corr_i = lepvec[i].isoEcal - (effArea_ecal_i*rho);
139      float isoHcal_corr_i = lepvec[i].isoHcal - (effArea_hcal_i*rho);
140
141      for( int j=i+1; j<lepvec.size(); j++ )
142        {
143
144          if( !(lepvec[j].is4l) ) continue;
145
146          float effArea_ecal_j, effArea_hcal_j;
147          if( lepvec[j].isEB ) {
148            if( lepvec[j].type == 11 ) {
149              effArea_ecal_j = 0.101;
150              effArea_hcal_j = 0.021;
151            } else {
152              effArea_ecal_j = 0.074;
153              effArea_hcal_j = 0.022;
154            }
155          } else {
156            if( lepvec[j].type == 11 ) {
157              effArea_ecal_j = 0.046;
158              effArea_hcal_j = 0.040;
159            } else {
160              effArea_ecal_j = 0.045;
161              effArea_hcal_j = 0.030;
162            }
163          }
164
165          float isoEcal_corr_j = lepvec[j].isoEcal - (effArea_ecal_j*rho);
166          float isoHcal_corr_j = lepvec[j].isoHcal - (effArea_hcal_j*rho);
167          float RIso_i = (lepvec[i].isoTrk+isoEcal_corr_i+isoHcal_corr_i)/lepvec[i].vec.Pt();
168          float RIso_j = (lepvec[j].isoTrk+isoEcal_corr_j+isoHcal_corr_j)/lepvec[j].vec.Pt();      
169          float comboIso = RIso_i + RIso_j;
170          
171          if( comboIso > 0.35 ) {
172            if( ctrl.debug ) cout << "combo failing for indices: " << i << "," << j << endl;
173            passiso = false;
174            return passiso;
175          }
176        }
177    }
178  
179  return passiso;
180 }
181
102   //--------------------------------------------------------------------------------------------------
103   SelectionStatus muonIsoSelection(ControlFlags &ctrl,
104 <                                 const mithep::Muon * mu,
105 <                                 const mithep::Vertex * vtx,
106 <                                 const mithep::Array<mithep::PFCandidate> * fPFCandidateCol   )
104 >                                 const Muon * mu,
105 >                                 const Vertex * vtx,
106 >                                 const Array<PFCandidate> * fPFCandidateCol   )
107   //--------------------------------------------------------------------------------------------------
108   {
109    float reliso = computePFMuonIso(mu,vtx,fPFCandidateCol,0.3)/mu->Pt();
# Line 211 | Line 131 | SelectionStatus muonIsoSelection(Control
131  
132   //--------------------------------------------------------------------------------------------------
133   SelectionStatus electronIsoSelection(ControlFlags &ctrl,
134 <                                     const mithep::Electron * ele,
135 <                                     const mithep::Vertex *fVertex,
136 <                                     const mithep::Array<mithep::PFCandidate> * fPFCandidates)
134 >                                     const Electron * ele,
135 >                                     const Vertex *fVertex,
136 >                                     const Array<PFCandidate> * fPFCandidates)
137   //--------------------------------------------------------------------------------------------------
138   {
139  
# Line 250 | Line 170 | bool noIso(ControlFlags &, vector<Simple
170          return true;
171   }
172  
253
173   //--------------------------------------------------------------------------------------------------
174   SelectionStatus muonIsoMVASelection(ControlFlags &ctrl,
175 <                                    const mithep::Muon * mu,
176 <                                    const mithep::Vertex * vtx,
177 <                                    const mithep::Array<mithep::PFCandidate> * fPFCandidates,
178 <                                    const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
179 <                                    mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
180 <                                    vector<const mithep::Muon*> muonsToVeto,
181 <                                    vector<const mithep::Electron*> electronsToVeto)
175 >                                    const Muon * mu,
176 >                                    const Vertex * vtx,
177 >                                    const Array<PFCandidate> * fPFCandidates,
178 >                                    const Array<PileupEnergyDensity> * fPUEnergyDensity,
179 >                                    MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
180 >                                    vector<const Muon*> muonsToVeto,
181 >                                    vector<const Electron*> electronsToVeto)
182   //--------------------------------------------------------------------------------------------------
183   {
184  
185    if( ctrl.debug ) {
186      cout << "muonIsoMVASelection :: muons to veto " << endl;
187      for( int i=0; i<muonsToVeto.size(); i++ ) {
188 <      const mithep::Muon * vmu = muonsToVeto[i];
188 >      const Muon * vmu = muonsToVeto[i];
189        cout << "\tpt: " << vmu->Pt()
190             << "\teta: " << vmu->Eta()
191             << "\tphi: " << vmu->Phi()
# Line 274 | Line 193 | SelectionStatus muonIsoMVASelection(Cont
193      }
194      cout << "muonIsoMVASelection :: electrson to veto " << endl;
195      for( int i=0; i<electronsToVeto.size(); i++ ) {
196 <      const mithep::Electron * vel = electronsToVeto[i];
196 >      const Electron * vel = electronsToVeto[i];
197        cout << "\tpt: " << vel->Pt()
198             << "\teta: " << vel->Eta()
199             << "\tphi: " << vel->Phi()
# Line 341 | Line 260 | SelectionStatus muonIsoMVASelection(Cont
260  
261      if( !(PFnoPUflag[k]) ) continue; // my PF no PU hack
262  
263 <    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
263 >    const PFCandidate *pf = (PFCandidate*)((*fPFCandidates)[k]);
264  
265      Double_t deta = (mu->Eta() - pf->Eta());
266 <    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(mu->Phi()),Double_t(pf->Phi()));
267 <    Double_t dr = mithep::MathUtils::DeltaR(mu->Phi(),mu->Eta(), pf->Phi(), pf->Eta());
266 >    Double_t dphi = MathUtils::DeltaPhi(Double_t(mu->Phi()),Double_t(pf->Phi()));
267 >    Double_t dr = MathUtils::DeltaR(mu->Phi(),mu->Eta(), pf->Phi(), pf->Eta());
268      if (dr > 1.0) continue;
269  
270      if (pf->HasTrackerTrk() && (pf->TrackerTrk() == mu->TrackerTrk()) ) continue;
# Line 360 | Line 279 | SelectionStatus muonIsoMVASelection(Cont
279        // Check for electrons
280        //
281        for (Int_t q=0; q < electronsToVeto.size(); ++q) {
282 <        const mithep::Electron *tmpele = electronsToVeto[q];
282 >        const Electron *tmpele = electronsToVeto[q];
283          // 4l electron
284          if( pf->HasTrackerTrk() ) {
285            if( pf->TrackerTrk() == tmpele->TrackerTrk() )
# Line 372 | Line 291 | SelectionStatus muonIsoMVASelection(Cont
291          }
292          // PF charged
293          if (pf->Charge() != 0 && fabs(tmpele->SCluster()->Eta()) >= 1.479
294 <            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.015)
294 >            && MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.015)
295            IsLeptonFootprint = kTRUE;
296          // PF gamma
297          if (abs(pf->PFType()) == PFCandidate::eGamma && fabs(tmpele->SCluster()->Eta()) >= 1.479
298 <            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.08)
298 >            && MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.08)
299            IsLeptonFootprint = kTRUE;
300        } // loop over electrons
301        
# Line 385 | Line 304 | SelectionStatus muonIsoMVASelection(Cont
304        // Check for muons
305        //
306        for (Int_t q=0; q < muonsToVeto.size(); ++q) {
307 <        const mithep::Muon *tmpmu = muonsToVeto[q];
307 >        const Muon *tmpmu = muonsToVeto[q];
308          // 4l muon
309          if( pf->HasTrackerTrk() ) {
310            if( pf->TrackerTrk() == tmpmu->TrackerTrk() )
311              IsLeptonFootprint = kTRUE;
312          }
313          // PF charged
314 <        if (pf->Charge() != 0 && mithep::MathUtils::DeltaR(tmpmu->Phi(),tmpmu->Eta(), pf->Phi(), pf->Eta()) < 0.01)
314 >        if (pf->Charge() != 0 && MathUtils::DeltaR(tmpmu->Phi(),tmpmu->Eta(), pf->Phi(), pf->Eta()) < 0.01)
315            IsLeptonFootprint = kTRUE;
316        } // loop over muons
317        */
# Line 595 | Line 514 | SelectionStatus muonIsoMVASelection(Cont
514  
515   //--------------------------------------------------------------------------------------------------
516   SelectionStatus muonIsoMVASelection(ControlFlags &ctrl,
517 <                                    const mithep::Muon * mu,
518 <                                    const mithep::Vertex * vtx,
519 <                                    const mithep::Array<mithep::PFCandidate> * fPFCandidates,
517 >                                    const Muon * mu,
518 >                                    const Vertex * vtx,
519 >                                    const Array<PFCandidate> * fPFCandidates,
520                                      float rho,
521 <                                    //const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
522 <                                    mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
523 <                                    vector<const mithep::Muon*> muonsToVeto,
524 <                                    vector<const mithep::Electron*> electronsToVeto)
521 >                                    //const Array<PileupEnergyDensity> * fPUEnergyDensity,
522 >                                    MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
523 >                                    vector<const Muon*> muonsToVeto,
524 >                                    vector<const Electron*> electronsToVeto)
525   //--------------------------------------------------------------------------------------------------
526   // hacked version
527   {
# Line 610 | Line 529 | SelectionStatus muonIsoMVASelection(Cont
529    if( ctrl.debug ) {
530      cout << "muonIsoMVASelection :: muons to veto " << endl;
531      for( int i=0; i<muonsToVeto.size(); i++ ) {
532 <      const mithep::Muon * vmu = muonsToVeto[i];
532 >      const Muon * vmu = muonsToVeto[i];
533        cout << "\tpt: " << vmu->Pt()
534             << "\teta: " << vmu->Eta()
535             << "\tphi: " << vmu->Phi()
# Line 618 | Line 537 | SelectionStatus muonIsoMVASelection(Cont
537      }
538      cout << "muonIsoMVASelection :: electrson to veto " << endl;
539      for( int i=0; i<electronsToVeto.size(); i++ ) {
540 <      const mithep::Electron * vel = electronsToVeto[i];
540 >      const Electron * vel = electronsToVeto[i];
541        cout << "\tpt: " << vel->Pt()
542             << "\teta: " << vel->Eta()
543             << "\tphi: " << vel->Phi()
# Line 685 | Line 604 | SelectionStatus muonIsoMVASelection(Cont
604  
605      if( !(PFnoPUflag[k]) ) continue; // my PF no PU hack
606  
607 <    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
607 >    const PFCandidate *pf = (PFCandidate*)((*fPFCandidates)[k]);
608  
609      Double_t deta = (mu->Eta() - pf->Eta());
610 <    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(mu->Phi()),Double_t(pf->Phi()));
611 <    Double_t dr = mithep::MathUtils::DeltaR(mu->Phi(),mu->Eta(), pf->Phi(), pf->Eta());
610 >    Double_t dphi = MathUtils::DeltaPhi(Double_t(mu->Phi()),Double_t(pf->Phi()));
611 >    Double_t dr = MathUtils::DeltaR(mu->Phi(),mu->Eta(), pf->Phi(), pf->Eta());
612      if (dr > 1.0) continue;
613  
614      if (pf->HasTrackerTrk() && (pf->TrackerTrk() == mu->TrackerTrk()) ) continue;
# Line 704 | Line 623 | SelectionStatus muonIsoMVASelection(Cont
623        // Check for electrons
624        //
625        for (Int_t q=0; q < electronsToVeto.size(); ++q) {
626 <        const mithep::Electron *tmpele = electronsToVeto[q];
626 >        const Electron *tmpele = electronsToVeto[q];
627          // 4l electron
628          if( pf->HasTrackerTrk() ) {
629            if( pf->TrackerTrk() == tmpele->TrackerTrk() )
# Line 716 | Line 635 | SelectionStatus muonIsoMVASelection(Cont
635          }
636          // PF charged
637          if (pf->Charge() != 0 && fabs(tmpele->SCluster()->Eta()) >= 1.479
638 <            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.015)
638 >            && MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.015)
639            IsLeptonFootprint = kTRUE;
640          // PF gamma
641          if (abs(pf->PFType()) == PFCandidate::eGamma && fabs(tmpele->SCluster()->Eta()) >= 1.479
642 <            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.08)
642 >            && MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.08)
643            IsLeptonFootprint = kTRUE;
644        } // loop over electrons
645        
# Line 729 | Line 648 | SelectionStatus muonIsoMVASelection(Cont
648        // Check for muons
649        //
650        for (Int_t q=0; q < muonsToVeto.size(); ++q) {
651 <        const mithep::Muon *tmpmu = muonsToVeto[q];
651 >        const Muon *tmpmu = muonsToVeto[q];
652          // 4l muon
653          if( pf->HasTrackerTrk() ) {
654            if( pf->TrackerTrk() == tmpmu->TrackerTrk() )
655              IsLeptonFootprint = kTRUE;
656          }
657          // PF charged
658 <        if (pf->Charge() != 0 && mithep::MathUtils::DeltaR(tmpmu->Phi(),tmpmu->Eta(), pf->Phi(), pf->Eta()) < 0.01)
658 >        if (pf->Charge() != 0 && MathUtils::DeltaR(tmpmu->Phi(),tmpmu->Eta(), pf->Phi(), pf->Eta()) < 0.01)
659            IsLeptonFootprint = kTRUE;
660        } // loop over muons
661        */
# Line 939 | Line 858 | SelectionStatus muonIsoMVASelection(Cont
858   //--------------------------------------------------------------------------------------------------
859   void initMuonIsoMVA() {
860   //--------------------------------------------------------------------------------------------------
861 <  muIsoMVA = new mithep::MuonIDMVA();
861 >  muIsoMVA = new MuonIDMVA();
862    vector<string> weightFiles;
863    weightFiles.push_back("./data/MuonIsoMVAWeights/MuonIsoMVA_BDTG_V0_barrel_lowpt.weights.xml");
864    weightFiles.push_back("./data/MuonIsoMVAWeights/MuonIsoMVA_BDTG_V0_barrel_highpt.weights.xml");
# Line 948 | Line 867 | void initMuonIsoMVA() {
867    weightFiles.push_back("./data/MuonIsoMVAWeights/MuonIsoMVA_BDTG_V0_tracker.weights.xml");
868    weightFiles.push_back("./data/MuonIsoMVAWeights/MuonIsoMVA_BDTG_V0_global.weights.xml");
869    muIsoMVA->Initialize( "MuonIsoMVA",
870 <                        mithep::MuonIDMVA::kIsoRingsV0,
870 >                        MuonIDMVA::kIsoRingsV0,
871                          kTRUE, weightFiles);
872   }
873  
874  
875  
957
876   //--------------------------------------------------------------------------------------------------
877   double  muonPFIso04(ControlFlags &ctrl,
878 <                    const mithep::Muon * mu,
879 <                    const mithep::Vertex * vtx,
880 <                    const mithep::Array<mithep::PFCandidate> * fPFCandidates,
881 <                    const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
882 <                    mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
883 <                    vector<const mithep::PFCandidate*> photonsToVeto)
878 >                    const Muon * mu,
879 >                    const Vertex * vtx,
880 >                    const Array<PFCandidate> * fPFCandidates,
881 >                    const Array<PileupEnergyDensity> * fPUEnergyDensity,
882 >                    MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
883 >                    vector<const PFCandidate*> photonsToVeto)
884   //--------------------------------------------------------------------------------------------------
885   {
886  
# Line 980 | Line 898 | double  muonPFIso04(ControlFlags &ctrl,
898    //
899    //Loop over PF Candidates
900    //
901 +  if(ctrl.debug) cout << "  muonPFIso04(): ----> " << endl;
902    for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
903  
904      if( !(PFnoPUflag[k]) ) continue; // my PF no PU hack
905 <    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
905 >    const PFCandidate *pf = (PFCandidate*)((*fPFCandidates)[k]);
906  
907      //
908      // veto FSR recovered photons
# Line 1000 | Line 919 | double  muonPFIso04(ControlFlags &ctrl,
919      //
920  
921      Double_t deta = (mu->Eta() - pf->Eta());
922 <    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(mu->Phi()),Double_t(pf->Phi()));
923 <    Double_t dr = mithep::MathUtils::DeltaR(mu->Phi(),mu->Eta(), pf->Phi(), pf->Eta());
922 >    Double_t dphi = MathUtils::DeltaPhi(Double_t(mu->Phi()),Double_t(pf->Phi()));
923 >    Double_t dr = MathUtils::DeltaR(mu->Phi(),mu->Eta(), pf->Phi(), pf->Eta());
924      if (dr > 0.4) continue;
925  
926      if (pf->HasTrackerTrk() && (pf->TrackerTrk() == mu->TrackerTrk()) ) continue;
# Line 1036 | Line 955 | double  muonPFIso04(ControlFlags &ctrl,
955    }
956  
957    double rho=0;
958 <  if( (EffectiveAreaVersion == mithep::MuonTools::kMuEAFall11MC) ||
959 <      (EffectiveAreaVersion == mithep::MuonTools::kMuEAData2011) ) {
958 >  if( (EffectiveAreaVersion == MuonTools::kMuEAFall11MC) ||
959 >      (EffectiveAreaVersion == MuonTools::kMuEAData2011) ) {
960      if (!(isnan(fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25()) ||
961            isinf(fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25())))
962        rho = fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25();
963      //rho = fPUEnergyDensity->At(0)->Rho();
964      // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
965 <    EffectiveAreaVersion  = mithep::MuonTools::kMuEAData2011;
965 >    EffectiveAreaVersion  = MuonTools::kMuEAData2011;
966      // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
967    } else {
968      if (!(isnan(fPUEnergyDensity->At(0)->RhoKt6PFJetsCentralNeutral()) ||
969            isinf(fPUEnergyDensity->At(0)->RhoKt6PFJetsCentralNeutral())))
970        rho = fPUEnergyDensity->At(0)->RhoKt6PFJetsCentralNeutral();
971      // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
972 <    EffectiveAreaVersion  = mithep::MuonTools::kMuEAData2012;
972 >    EffectiveAreaVersion  = MuonTools::kMuEAData2012;
973      // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
974    }
975 <  if(ctrl.debug) cout << "rho: " << rho << endl;
975 >  // if(ctrl.debug) cout << "    rho: " << rho << endl;
976  
977    TLorentzVector  tmpvec;
978    tmpvec.SetPtEtaPhiM(mu->Pt(),mu->Eta(),mu->Phi(),mu->Mass());
979    for( int p=0; p<photonsToVeto.size(); p++ ) {
980 <    const mithep::PFCandidate * pf  = photonsToVeto[p];
980 >    const PFCandidate * pf  = photonsToVeto[p];
981      TLorentzVector pfvec;
982      pfvec.SetPtEtaPhiM(pf->Pt(),pf->Eta(),pf->Phi(),0.);
983      tmpvec += pfvec;
# Line 1073 | Line 992 | double  muonPFIso04(ControlFlags &ctrl,
992    gNeutralIso = fNeutralHadronIso;
993    
994    if( ctrl.debug ) {
995 <    cout << "PFiso: " << pfIso
996 <         << "\tfChargedIso: " << fChargedIso
997 <         << "\tfGammaIso: " << fGammaIso
998 <         << "\tfNeutralHadronIso: " << fNeutralHadronIso
995 >    cout << "    PFiso: " << pfIso
996 >         << setw(9) << setprecision(4) << fChargedIso
997 >         << setw(9) << setprecision(4) << fGammaIso
998 >         << setw(9) << setprecision(4) << fNeutralHadronIso
999           << endl;
1000    }
1001  
1002    return pfIso;
1003   }
1004  
1086
1087
1088
1089 //--------------------------------------------------------------------------------------------------
1090 // hacked version
1091 double  muonPFIso04(ControlFlags &ctrl,
1092                    const mithep::Muon * mu,
1093                    const mithep::Vertex * vtx,
1094                    const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1095                    float rho,
1096                    mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
1097                    vector<const mithep::Muon*> muonsToVeto,
1098                    vector<const mithep::Electron*> electronsToVeto)
1099 //--------------------------------------------------------------------------------------------------
1100 {
1101
1102  extern double gChargedIso;  
1103  extern double  gGammaIso;      
1104  extern double  gNeutralIso;
1105  
1106  if( ctrl.debug ) {
1107    cout << "muonIsoMVASelection :: muons to veto " << endl;
1108    for( int i=0; i<muonsToVeto.size(); i++ ) {
1109      const mithep::Muon * vmu = muonsToVeto[i];
1110      cout << "\tpt: " << vmu->Pt()
1111           << "\teta: " << vmu->Eta()
1112           << "\tphi: " << vmu->Phi()
1113           << endl;
1114    }
1115    cout << "muonIsoMVASelection :: electrson to veto " << endl;
1116    for( int i=0; i<electronsToVeto.size(); i++ ) {
1117      const mithep::Electron * vel = electronsToVeto[i];
1118      cout << "\tpt: " << vel->Pt()
1119           << "\teta: " << vel->Eta()
1120           << "\tphi: " << vel->Phi()
1121           << endl;
1122    }
1123  }
1124
1125  //
1126  // final iso
1127  //
1128  Double_t fChargedIso  = 0.0;
1129  Double_t fGammaIso  = 0.0;
1130  Double_t fNeutralHadronIso  = 0.0;
1131
1132  //
1133  //Loop over PF Candidates
1134  //
1135  for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
1136
1137    if( !(PFnoPUflag[k]) ) continue; // my PF no PU hack
1138    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
1139
1140    Double_t deta = (mu->Eta() - pf->Eta());
1141    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(mu->Phi()),Double_t(pf->Phi()));
1142    Double_t dr = mithep::MathUtils::DeltaR(mu->Phi(),mu->Eta(), pf->Phi(), pf->Eta());
1143    if (dr > 0.4) continue;
1144
1145    if (pf->HasTrackerTrk() && (pf->TrackerTrk() == mu->TrackerTrk()) ) continue;
1146
1147    //
1148    // Lepton Footprint Removal
1149    //
1150    Bool_t IsLeptonFootprint = kFALSE;
1151    if (dr < 1.0) {
1152
1153      //
1154      // Check for electrons
1155      //
1156      for (Int_t q=0; q < electronsToVeto.size(); ++q) {
1157        const mithep::Electron *tmpele = electronsToVeto[q];
1158        // 4l electron
1159        if( pf->HasTrackerTrk() ) {
1160          if( pf->TrackerTrk() == tmpele->TrackerTrk() )
1161            IsLeptonFootprint = kTRUE;
1162        }
1163        if( pf->HasGsfTrk() ) {
1164          if( pf->GsfTrk() == tmpele->GsfTrk() )
1165            IsLeptonFootprint = kTRUE;
1166        }
1167        // PF charged
1168        if (pf->Charge() != 0 && fabs(tmpele->SCluster()->Eta()) > 1.479
1169            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.015)
1170          IsLeptonFootprint = kTRUE;
1171        // PF gamma
1172        if (abs(pf->PFType()) == PFCandidate::eGamma && fabs(tmpele->SCluster()->Eta()) > 1.479
1173            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.08)
1174          IsLeptonFootprint = kTRUE;
1175      } // loop over electrons
1176
1177      /* KH - comment for sync      
1178      //
1179      // Check for muons
1180      //
1181      for (Int_t q=0; q < muonsToVeto.size(); ++q) {
1182        const mithep::Muon *tmpmu = muonsToVeto[q];
1183        // 4l muon
1184        if( pf->HasTrackerTrk() ) {
1185          if( pf->TrackerTrk() == tmpmu->TrackerTrk() )
1186            IsLeptonFootprint = kTRUE;
1187        }
1188        // PF charged
1189        if (pf->Charge() != 0 && mithep::MathUtils::DeltaR(tmpmu->Phi(),tmpmu->Eta(), pf->Phi(), pf->Eta()) < 0.01)
1190          IsLeptonFootprint = kTRUE;
1191      } // loop over muons
1192      */
1193
1194    if (IsLeptonFootprint)
1195      continue;
1196
1197    //
1198    // Charged Iso
1199    //
1200    if (pf->Charge() != 0 && (pf->HasTrackerTrk()||pf->HasGsfTrk()) ) {
1201
1202      //if( dr < 0.01 ) continue; // only for muon iso mva?
1203      if (abs(pf->PFType()) == PFCandidate::eElectron || abs(pf->PFType()) == PFCandidate::eMuon) continue;
1204
1205
1206 //       if( pf->HasTrackerTrk() ) {
1207 //      if (abs(pf->TrackerTrk()->DzCorrected(vtx)) > 0.2) continue;
1208 //      if( ctrl.debug ) cout << "charged:: " << pf->PFType() << " " << pf->Pt() << " "
1209 //                            << abs(pf->TrackerTrk()->DzCorrected(vtx)) << " "
1210 //                            << dr << endl;
1211 //       }
1212 //       if( pf->HasGsfTrk() ) {
1213 //      if (abs(pf->GsfTrk()->DzCorrected(vtx)) > 0.2) continue;
1214 //      if( ctrl.debug ) cout << "charged:: " << pf->PFType() << " " << pf->Pt() << " "
1215 //                            << abs(pf->GsfTrk()->DzCorrected(vtx)) << " "
1216 //                            << dr << endl;
1217 //       }
1218
1219
1220      fChargedIso += pf->Pt();
1221    }
1222
1223    //
1224    // Gamma Iso
1225    //
1226    else if (abs(pf->PFType()) == PFCandidate::eGamma) {
1227      // KH, add to sync
1228      if( pf->Pt() > 0.5 )
1229      fGammaIso += pf->Pt();
1230    }
1231
1232    //
1233    // Other Neutrals
1234    //
1235    else {
1236      // KH, add to sync
1237      if( pf->Pt() > 0.5 )
1238        fNeutralHadronIso += pf->Pt();
1239    }
1240    
1241    }
1242    
1243  }
1244  
1245 //   double rho = 0;
1246 //   if (!(isnan(fPUEnergyDensity->At(0)->Rho()) || isinf(fPUEnergyDensity->At(0)->Rho())))
1247 //     rho = fPUEnergyDensity->At(0)->Rho();
1248
1249  // WARNING!!!!  
1250  // hardcode for sync ...
1251  EffectiveAreaVersion = muT.kMuEAData2011;
1252  // WARNING!!!!  
1253
1254
1255  double pfIso = fChargedIso + fmax(0.0,(fGammaIso + fNeutralHadronIso
1256                                        -rho*muT.MuonEffectiveArea(muT.kMuGammaAndNeutralHadronIso04,
1257                                                                   mu->Eta(),EffectiveAreaVersion)));
1258  gChargedIso = fChargedIso;
1259  gGammaIso   = fGammaIso;
1260  gNeutralIso = fNeutralHadronIso;
1261  
1262  return pfIso;
1263 }
1264
1265
1005   //--------------------------------------------------------------------------------------------------
1006   SelectionStatus muonReferenceIsoSelection(ControlFlags &ctrl,
1007 <                                          const mithep::Muon * mu,
1008 <                                          const mithep::Vertex * vtx,
1009 <                                          const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1010 <                                          const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
1011 <                                          mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
1012 <                                          vector<const mithep::PFCandidate*> photonsToVeto)
1007 >                                          const Muon * mu,
1008 >                                          const Vertex * vtx,
1009 >                                          const Array<PFCandidate> * fPFCandidates,
1010 >                                          const Array<PileupEnergyDensity> * fPUEnergyDensity,
1011 >                                          MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
1012 >                                          vector<const PFCandidate*> photonsToVeto)
1013   //--------------------------------------------------------------------------------------------------
1014   {
1015    
# Line 1278 | Line 1017 | SelectionStatus muonReferenceIsoSelectio
1017  
1018    double pfIso = muonPFIso04( ctrl, mu, vtx, fPFCandidates, fPUEnergyDensity,
1019                                EffectiveAreaVersion, photonsToVeto);
1281  //  cout << "--------------> setting muon isoPF04 to" << pfIso << endl;
1282  status.isoPF04 = pfIso;
1283  status.chisoPF04 = gChargedIso;
1284  status.gaisoPF04 = gGammaIso;
1285  status.neisoPF04 = gNeutralIso;
1286
1287  bool pass = false;
1288  if( (pfIso/mu->Pt()) < MUON_REFERENCE_PFISO_CUT ) pass = true;
1289
1290  if( pass ) {
1291    status.orStatus(SelectionStatus::LOOSEISO);
1292    status.orStatus(SelectionStatus::TIGHTISO);
1293  }
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 }
1301
1302
1303 //--------------------------------------------------------------------------------------------------
1304 // hacked version
1305 SelectionStatus muonReferenceIsoSelection(ControlFlags &ctrl,
1306                                          const mithep::Muon * mu,
1307                                          const mithep::Vertex * vtx,
1308                                          const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1309                                          float rho,
1310                                          mithep::MuonTools::EMuonEffectiveAreaTarget EffectiveAreaVersion,
1311                                          vector<const mithep::Muon*> muonsToVeto,
1312                                          vector<const mithep::Electron*> electronsToVeto)
1313 //--------------------------------------------------------------------------------------------------
1314 {
1315  
1316  SelectionStatus status;
1317  
1318  double pfIso = muonPFIso04( ctrl, mu, vtx, fPFCandidates, rho,
1319                              EffectiveAreaVersion, muonsToVeto ,electronsToVeto );
1320
1020    status.isoPF04 = pfIso;
1021    status.chisoPF04 = gChargedIso;
1022    status.gaisoPF04 = gGammaIso;
# Line 1330 | Line 1029 | SelectionStatus muonReferenceIsoSelectio
1029      status.orStatus(SelectionStatus::LOOSEISO);
1030      status.orStatus(SelectionStatus::TIGHTISO);
1031    }
1032 <  if(ctrl.debug) cout << "returning status : " << hex << status.getStatus() << dec << endl;
1032 >  if(ctrl.debug)
1033 >    cout << "  --> mu relpfIso: " << pfIso/mu->Pt() << ", returning status : " << hex << status.getStatus() << dec << endl;
1034    return status;
1335  
1035   }
1036  
1338
1339
1340
1037   //--------------------------------------------------------------------------------------------------
1038   SelectionStatus electronIsoMVASelection(ControlFlags &ctrl,
1039 <                                        const mithep::Electron * ele,
1040 <                                        const mithep::Vertex * vtx,
1041 <                                        const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1042 <                                        const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
1043 <                                        mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
1044 <                                        vector<const mithep::Muon*> muonsToVeto,
1045 <                                        vector<const mithep::Electron*> electronsToVeto)
1039 >                                        const Electron * ele,
1040 >                                        const Vertex * vtx,
1041 >                                        const Array<PFCandidate> * fPFCandidates,
1042 >                                        const Array<PileupEnergyDensity> * fPUEnergyDensity,
1043 >                                        ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
1044 >                                        vector<const Muon*> muonsToVeto,
1045 >                                        vector<const Electron*> electronsToVeto)
1046   //--------------------------------------------------------------------------------------------------
1047   {
1048  
1049    if( ctrl.debug ) {
1050      cout << "electronIsoMVASelection :: muons to veto " << endl;
1051      for( int i=0; i<muonsToVeto.size(); i++ ) {
1052 <      const mithep::Muon * vmu = muonsToVeto[i];
1052 >      const Muon * vmu = muonsToVeto[i];
1053        cout << "\tpt: " << vmu->Pt()
1054             << "\teta: " << vmu->Eta()
1055             << "\tphi: " << vmu->Phi()
# Line 1361 | Line 1057 | SelectionStatus electronIsoMVASelection(
1057      }
1058      cout << "electronIsoMVASelection :: electrson to veto " << endl;
1059      for( int i=0; i<electronsToVeto.size(); i++ ) {
1060 <      const mithep::Electron * vel = electronsToVeto[i];
1060 >      const Electron * vel = electronsToVeto[i];
1061        cout << "\tpt: " << vel->Pt()
1062             << "\teta: " << vel->Eta()
1063             << "\tphi: " << vel->Phi()
# Line 1425 | Line 1121 | SelectionStatus electronIsoMVASelection(
1121  
1122      if( !(PFnoPUflag[k]) ) continue; // my PF no PU hack
1123  
1124 <    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
1124 >    const PFCandidate *pf = (PFCandidate*)((*fPFCandidates)[k]);
1125      Double_t deta = (ele->Eta() - pf->Eta());
1126 <    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(ele->Phi()),Double_t(pf->Phi()));
1127 <    Double_t dr = mithep::MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta());
1126 >    Double_t dphi = MathUtils::DeltaPhi(Double_t(ele->Phi()),Double_t(pf->Phi()));
1127 >    Double_t dr = MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta());
1128      if (dr > 1.0) continue;
1129  
1130      if(ctrl.debug) {
# Line 1454 | Line 1150 | SelectionStatus electronIsoMVASelection(
1150        //
1151  
1152        for (Int_t q=0; q < electronsToVeto.size(); ++q) {
1153 <        const mithep::Electron *tmpele = electronsToVeto[q];
1154 <        double tmpdr = mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta());
1153 >        const Electron *tmpele = electronsToVeto[q];
1154 >        double tmpdr = MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta());
1155  
1156          // 4l electron
1157          if( pf->HasTrackerTrk()  ) {
# Line 1489 | Line 1185 | SelectionStatus electronIsoMVASelection(
1185        // Check for muons
1186        //
1187        for (Int_t q=0; q < muonsToVeto.size(); ++q) {
1188 <        const mithep::Muon *tmpmu = muonsToVeto[q];
1188 >        const Muon *tmpmu = muonsToVeto[q];
1189          // 4l muon
1190          if( pf->HasTrackerTrk() ) {
1191            if (pf->TrackerTrk() == tmpmu->TrackerTrk() ){
# Line 1498 | Line 1194 | SelectionStatus electronIsoMVASelection(
1194            }
1195          }
1196          // PF charged
1197 <        if (pf->Charge() != 0 && mithep::MathUtils::DeltaR(tmpmu->Phi(),tmpmu->Eta(), pf->Phi(), pf->Eta()) < 0.01) {
1197 >        if (pf->Charge() != 0 && MathUtils::DeltaR(tmpmu->Phi(),tmpmu->Eta(), pf->Phi(), pf->Eta()) < 0.01) {
1198            if( ctrl.debug) cout << "\tcharged trk, dR matches 4L mu ..." << endl;
1199            IsLeptonFootprint = kTRUE;
1200          }
# Line 1759 | Line 1455 | SelectionStatus electronIsoMVASelection(
1455  
1456   //--------------------------------------------------------------------------------------------------
1457   SelectionStatus electronIsoMVASelection(ControlFlags &ctrl,
1458 <                                        const mithep::Electron * ele,
1459 <                                        const mithep::Vertex * vtx,
1460 <                                        const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1458 >                                        const Electron * ele,
1459 >                                        const Vertex * vtx,
1460 >                                        const Array<PFCandidate> * fPFCandidates,
1461                                          float rho,
1462 <                                        //const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
1463 <                                        mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
1464 <                                        vector<const mithep::Muon*> muonsToVeto,
1465 <                                        vector<const mithep::Electron*> electronsToVeto)
1462 >                                        //const Array<PileupEnergyDensity> * fPUEnergyDensity,
1463 >                                        ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
1464 >                                        vector<const Muon*> muonsToVeto,
1465 >                                        vector<const Electron*> electronsToVeto)
1466   //--------------------------------------------------------------------------------------------------
1467   // hacked version
1468   {
# Line 1777 | Line 1473 | SelectionStatus electronIsoMVASelection(
1473    if( ctrl.debug ) {
1474      cout << "electronIsoMVASelection :: muons to veto " << endl;
1475      for( int i=0; i<muonsToVeto.size(); i++ ) {
1476 <      const mithep::Muon * vmu = muonsToVeto[i];
1476 >      const Muon * vmu = muonsToVeto[i];
1477        cout << "\tpt: " << vmu->Pt()
1478             << "\teta: " << vmu->Eta()
1479             << "\tphi: " << vmu->Phi()
# Line 1785 | Line 1481 | SelectionStatus electronIsoMVASelection(
1481      }
1482      cout << "electronIsoMVASelection :: electrson to veto " << endl;
1483      for( int i=0; i<electronsToVeto.size(); i++ ) {
1484 <      const mithep::Electron * vel = electronsToVeto[i];
1484 >      const Electron * vel = electronsToVeto[i];
1485        cout << "\tpt: " << vel->Pt()
1486             << "\teta: " << vel->Eta()
1487             << "\tphi: " << vel->Phi()
# Line 1849 | Line 1545 | SelectionStatus electronIsoMVASelection(
1545  
1546      if( !(PFnoPUflag[k]) ) continue; // my PF no PU hack
1547  
1548 <    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
1548 >    const PFCandidate *pf = (PFCandidate*)((*fPFCandidates)[k]);
1549      Double_t deta = (ele->Eta() - pf->Eta());
1550 <    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(ele->Phi()),Double_t(pf->Phi()));
1551 <    Double_t dr = mithep::MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta());
1550 >    Double_t dphi = MathUtils::DeltaPhi(Double_t(ele->Phi()),Double_t(pf->Phi()));
1551 >    Double_t dr = MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta());
1552      if (dr > 1.0) continue;
1553  
1554      if(ctrl.debug) {
# Line 1878 | Line 1574 | SelectionStatus electronIsoMVASelection(
1574        //
1575  
1576        for (Int_t q=0; q < electronsToVeto.size(); ++q) {
1577 <        const mithep::Electron *tmpele = electronsToVeto[q];
1578 <        double tmpdr = mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta());
1577 >        const Electron *tmpele = electronsToVeto[q];
1578 >        double tmpdr = MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta());
1579  
1580          // 4l electron
1581          if( pf->HasTrackerTrk()  ) {
# Line 1913 | Line 1609 | SelectionStatus electronIsoMVASelection(
1609        // Check for muons
1610        //
1611        for (Int_t q=0; q < muonsToVeto.size(); ++q) {
1612 <        const mithep::Muon *tmpmu = muonsToVeto[q];
1612 >        const Muon *tmpmu = muonsToVeto[q];
1613          // 4l muon
1614          if( pf->HasTrackerTrk() ) {
1615            if (pf->TrackerTrk() == tmpmu->TrackerTrk() ){
# Line 1922 | Line 1618 | SelectionStatus electronIsoMVASelection(
1618            }
1619          }
1620          // PF charged
1621 <        if (pf->Charge() != 0 && mithep::MathUtils::DeltaR(tmpmu->Phi(),tmpmu->Eta(), pf->Phi(), pf->Eta()) < 0.01) {
1621 >        if (pf->Charge() != 0 && MathUtils::DeltaR(tmpmu->Phi(),tmpmu->Eta(), pf->Phi(), pf->Eta()) < 0.01) {
1622            if( ctrl.debug) cout << "\tcharged trk, dR matches 4L mu ..." << endl;
1623            IsLeptonFootprint = kTRUE;
1624          }
# Line 2184 | Line 1880 | SelectionStatus electronIsoMVASelection(
1880   //--------------------------------------------------------------------------------------------------
1881   void initElectronIsoMVA() {
1882   //--------------------------------------------------------------------------------------------------
1883 <  eleIsoMVA = new mithep::ElectronIDMVA();
1883 >  eleIsoMVA = new ElectronIDMVA();
1884    vector<string> weightFiles;
1885    weightFiles.push_back("../MitPhysics/data/ElectronMVAWeights/ElectronIso_BDTG_V0_BarrelPt5To10.weights.xml");
1886    weightFiles.push_back("../MitPhysics/data/ElectronMVAWeights/ElectronIso_BDTG_V0_EndcapPt5To10.weights.xml");
1887    weightFiles.push_back("../MitPhysics/data/ElectronMVAWeights/ElectronIso_BDTG_V0_BarrelPt10ToInf.weights.xml");
1888    weightFiles.push_back("../MitPhysics/data/ElectronMVAWeights/ElectronIso_BDTG_V0_EndcapPt10ToInf.weights.xml");
1889    eleIsoMVA->Initialize( "ElectronIsoMVA",
1890 <                        mithep::ElectronIDMVA::kIsoRingsV0,
1890 >                        ElectronIDMVA::kIsoRingsV0,
1891                          kTRUE, weightFiles);
1892   }
1893  
# Line 2200 | Line 1896 | void initElectronIsoMVA() {
1896  
1897   //--------------------------------------------------------------------------------------------------
1898   float electronPFIso04(ControlFlags &ctrl,
1899 <                      const mithep::Electron * ele,
1900 <                      const mithep::Vertex * vtx,
1901 <                      const mithep::Array<mithep::PFCandidate> * fPFCandidates,
1902 <                      const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
1903 <                      mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
1904 <                      vector<const mithep::PFCandidate*> photonsToVeto)        
1899 >                      const Electron * ele,
1900 >                      const Vertex * vtx,
1901 >                      const Array<PFCandidate> * fPFCandidates,
1902 >                      const Array<PileupEnergyDensity> * fPUEnergyDensity,
1903 >                      ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
1904 >                      vector<const PFCandidate*> photonsToVeto)        
1905   //--------------------------------------------------------------------------------------------------
1906   {
1907  
# Line 2220 | Line 1916 | float electronPFIso04(ControlFlags &ctrl
1916    //
1917    //Loop over PF Candidates
1918    //
1919 +  if(ctrl.debug) cout << "  electronPFIso04(): ----> " << endl;
1920    for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
1921  
1922 <    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
1922 >    const PFCandidate *pf = (PFCandidate*)((*fPFCandidates)[k]);
1923  
1924      //
1925      // veto FSR recovered photons
# Line 2236 | Line 1933 | float electronPFIso04(ControlFlags &ctrl
1933      } if( vetoPhoton ) continue;
1934  
1935      Double_t deta = (ele->Eta() - pf->Eta());
1936 <    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(ele->Phi()),Double_t(pf->Phi()));
1937 <    Double_t dr = mithep::MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta());
1936 >    Double_t dphi = MathUtils::DeltaPhi(Double_t(ele->Phi()),Double_t(pf->Phi()));
1937 >    Double_t dr = MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta());
1938  
1939      if (dr > 0.4) continue;
1940      if( !(PFnoPUflag[k]) ) continue; // my PF no PU hack
1941  
1942 <    if(ctrl.debug) {
1943 <      cout << "pf :: type: " << pf->PFType() << "\tpt: " << pf->Pt() << "\tdR: " << dr;
1944 <      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(*vtx)
1945 <                                     << "\ttrk: " << pf->HasTrackerTrk()
1946 <                                     << "\tgsf: " << pf->HasGsfTrk();
1947 <      
1948 <      cout << endl;
2252 <    }
2253 <
2254 <
2255 <    //
2256 <    // sync : I don't think theyre doing this ...
2257 <    //
2258 <    //     if ( (pf->HasTrackerTrk() && (pf->TrackerTrk() == ele->TrackerTrk())) ||
2259 <    //   (pf->HasGsfTrk() && (pf->GsfTrk() == ele->GsfTrk()))) {
2260 <    //       if( ctrl.debug ) cout << "\tskipping, matches to the electron ..."  << endl;
2261 <    //       continue;
2262 <    //     }
2263 <
1942 >    // if(ctrl.debug) {
1943 >    //   cout << "    pf :: type: " << pf->PFType() << "\tpt: " << pf->Pt() << "\tdR: " << dr;
1944 >    //   if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(*vtx)
1945 >    //                               << "\ttrk: " << pf->HasTrackerTrk()
1946 >    //                               << "\tgsf: " << pf->HasGsfTrk();
1947 >    //   cout << endl;
1948 >    // }
1949  
1950      //
1951      // Lepton Footprint Removal
# Line 2276 | Line 1961 | float electronPFIso04(ControlFlags &ctrl
1961  
1962        // Veto any PFmuon, or PFEle
1963        if (abs(pf->PFType()) == PFCandidate::eElectron || abs(pf->PFType()) == PFCandidate::eMuon) {
1964 <        if( ctrl.debug ) cout << "\t skipping, pf is and ele or mu .." <<endl;
1964 >        // if( ctrl.debug ) cout << "    skipping, pf is an ele or mu .." <<endl;
1965          continue;
1966        }
1967  
1968        // Footprint Veto
1969        if (fabs(ele->SCluster()->Eta()) > 1.479 && dr < 0.015) continue;
1970  
1971 <      if( ctrl.debug) cout << "charged:: pt: " << pf->Pt()
1972 <                           << "\ttype: " << pf->PFType()
1973 <                           << "\ttrk: " << pf->TrackerTrk() << endl;
1971 >      // if( ctrl.debug) cout << "    charged:: pt: " << pf->Pt()
1972 >      //                           << "\ttype: " << pf->PFType()
1973 >      //                           << "\ttrk: " << pf->TrackerTrk() << endl;
1974  
1975        fChargedIso += pf->Pt();
1976      }
# Line 2296 | Line 1981 | float electronPFIso04(ControlFlags &ctrl
1981      else if (abs(pf->PFType()) == PFCandidate::eGamma) {
1982  
1983        if (fabs(ele->SCluster()->Eta()) > 1.479) {
1984 <        if (mithep::MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta()) < 0.08) continue;
1984 >        if (MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta()) < 0.08) continue;
1985        }
1986  
1987        assert(ele->HasSuperCluster());
1988        if(ele->GsfTrk()->NExpectedHitsInner()>0 && pf->MvaGamma() > 0.99 && pf->HasSCluster() && ele->SCluster() == pf->SCluster())      continue;
1989  
1990  
1991 <      if( ctrl.debug) cout << "gamma:: " << pf->Pt() << " "
1992 <                           << dr << endl;
1993 <      // KH, add to sync
1994 <      //      if( pf->Pt() > 0.5 )
2310 <        fGammaIso += pf->Pt();
1991 >      // if( ctrl.debug) cout << "    gamma:: " << pf->Pt() << " "
1992 >      //                           << dr << endl;
1993 >
1994 >      fGammaIso += pf->Pt();
1995      }
1996  
1997      //
1998      // Neutral Iso
1999      //
2000      else {
2001 <      if( ctrl.debug) cout << "neutral:: " << pf->Pt() << " "
2002 <                           << dr << endl;
2003 <      // KH, add to sync
2320 <      //      if( pf->Pt() > 0.5 )
2321 <        fNeutralHadronIso += pf->Pt();
2001 >      // if( ctrl.debug) cout << "    neutral:: " << pf->Pt() << " "
2002 >      //                           << dr << endl;
2003 >      fNeutralHadronIso += pf->Pt();
2004      }
2005  
2006      }
# Line 2327 | Line 2009 | float electronPFIso04(ControlFlags &ctrl
2009  
2010  
2011    double rho=0;
2012 <  if( (EffectiveAreaVersion == mithep::ElectronTools::kEleEAFall11MC) ||
2013 <      (EffectiveAreaVersion == mithep::ElectronTools::kEleEAData2011) ) {
2012 >  if( (EffectiveAreaVersion == ElectronTools::kEleEAFall11MC) ||
2013 >      (EffectiveAreaVersion == ElectronTools::kEleEAData2011) ) {
2014      if (!(isnan(fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25()) ||
2015            isinf(fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25())))
2016        rho = fPUEnergyDensity->At(0)->RhoKt6PFJetsForIso25();
2017      // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
2018 <    EffectiveAreaVersion  = mithep::ElectronTools::kEleEAData2011;
2018 >    EffectiveAreaVersion  = ElectronTools::kEleEAData2011;
2019      // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
2020    } else {
2021      if (!(isnan(fPUEnergyDensity->At(0)->RhoKt6PFJets()) ||
2022            isinf(fPUEnergyDensity->At(0)->RhoKt6PFJets())))
2023        rho = fPUEnergyDensity->At(0)->RhoKt6PFJets();
2024      // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
2025 <    EffectiveAreaVersion  = mithep::ElectronTools::kEleEAData2012;
2025 >    EffectiveAreaVersion  = ElectronTools::kEleEAData2012;
2026      // !!!!!!!!!!!!! TMP HACK FOR SYNC !!!!!!!!!!!!!!!!!!!!!
2027    }
2028 <  if(ctrl.debug) cout << "rho: " << rho << endl;
2028 >  // if(ctrl.debug) cout << "    rho: " << rho << endl;
2029  
2030    double pfIso = fChargedIso + fmax(0.0,(fGammaIso + fNeutralHadronIso
2031                                          -rho*eleT.ElectronEffectiveArea(eleT.kEleGammaAndNeutralHadronIso04,
# Line 2355 | Line 2037 | float electronPFIso04(ControlFlags &ctrl
2037    gNeutralIso = fNeutralHadronIso;  
2038  
2039    if( ctrl.debug ) {
2040 <    cout << "PFiso: " << pfIso
2041 <         << "\tfChargedIso: " << fChargedIso
2042 <         << "\tfGammaIso: " << fGammaIso
2043 <         << "\tfNeutralHadronIso: " << fNeutralHadronIso
2040 >    cout << "    PFiso: " << pfIso
2041 >         << setw(6) << setprecision(4) << fChargedIso
2042 >         << setw(6) << setprecision(4) << fGammaIso
2043 >         << setw(6) << setprecision(4) << fNeutralHadronIso
2044           << endl;
2045    }
2046  
2047    return pfIso;
2048   }
2049  
2368
2369
2370 //--------------------------------------------------------------------------------------------------
2371 // hacked version
2372 float electronPFIso04(ControlFlags &ctrl,
2373                      const mithep::Electron * ele,
2374                      const mithep::Vertex * vtx,
2375                      const mithep::Array<mithep::PFCandidate> * fPFCandidates,
2376                      float rho,
2377                      mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
2378                      vector<const mithep::Muon*> muonsToVeto,
2379                      vector<const mithep::Electron*> electronsToVeto)
2380 //--------------------------------------------------------------------------------------------------
2381 {
2382
2383  if( ctrl.debug ) {
2384    cout << "electronIsoMVASelection :: muons to veto " << endl;
2385    for( int i=0; i<muonsToVeto.size(); i++ ) {
2386      const mithep::Muon * vmu = muonsToVeto[i];
2387      cout << "\tpt: " << vmu->Pt()
2388           << "\teta: " << vmu->Eta()
2389           << "\tphi: " << vmu->Phi()
2390           << endl;
2391    }
2392    cout << "electronIsoMVASelection :: electrons to veto " << endl;
2393    for( int i=0; i<electronsToVeto.size(); i++ ) {
2394      const mithep::Electron * vel = electronsToVeto[i];
2395      cout << "\tpt: " << vel->Pt()
2396           << "\teta: " << vel->Eta()
2397           << "\tphi: " << vel->Phi()
2398           << "\ttrk: " << vel->TrackerTrk()
2399           << endl;
2400    }
2401  }
2402
2403
2404  //
2405  // final iso
2406  //
2407  Double_t fChargedIso = 0.0;
2408  Double_t fGammaIso = 0.0;
2409  Double_t fNeutralHadronIso = 0.0;
2410
2411
2412  //
2413  //Loop over PF Candidates
2414  //
2415  for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2416
2417
2418    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
2419    Double_t deta = (ele->Eta() - pf->Eta());
2420    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(ele->Phi()),Double_t(pf->Phi()));
2421    Double_t dr = mithep::MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta());
2422
2423    if (dr > 0.4) continue;
2424    if( !(PFnoPUflag[k]) ) continue; // my PF no PU hack
2425
2426    if(ctrl.debug) {
2427      cout << "pf :: type: " << pf->PFType() << "\tpt: " << pf->Pt() << "\tdR: " << dr;
2428      if( pf->HasTrackerTrk() ) cout << "\tdZ: " << pf->TrackerTrk()->DzCorrected(*vtx)
2429                                     << "\ttrk: " << pf->HasTrackerTrk()
2430                                     << "\tgsf: " << pf->HasGsfTrk();
2431      
2432      cout << endl;
2433    }
2434
2435
2436    //
2437    // sync : I don't think theyre doing this ...
2438    //
2439    //     if ( (pf->HasTrackerTrk() && (pf->TrackerTrk() == ele->TrackerTrk())) ||
2440    //   (pf->HasGsfTrk() && (pf->GsfTrk() == ele->GsfTrk()))) {
2441    //       if( ctrl.debug ) cout << "\tskipping, matches to the electron ..."  << endl;
2442    //       continue;
2443    //     }
2444
2445
2446    //
2447    // Lepton Footprint Removal
2448    //
2449    Bool_t IsLeptonFootprint = kFALSE;
2450    if (dr < 1.0) {
2451
2452      //
2453      // Check for electrons
2454      //
2455      for (Int_t q=0; q < electronsToVeto.size(); ++q) {
2456        const mithep::Electron *tmpele = electronsToVeto[q];
2457        /*
2458        // 4l electron
2459        if( pf->HasTrackerTrk()  ) {
2460          if( pf->TrackerTrk() == tmpele->TrackerTrk() ) {
2461            if( ctrl.debug) cout << "\tcharged tktrk, matches 4L ele ..." << endl;
2462            IsLeptonFootprint = kTRUE;
2463          }
2464        }
2465        if( pf->HasGsfTrk()  ) {
2466          if( pf->GsfTrk() == tmpele->GsfTrk() ) {
2467            if( ctrl.debug) cout << "\tcharged gsftrk, matches 4L ele ..." << endl;
2468            IsLeptonFootprint = kTRUE;
2469          }
2470        }
2471        */
2472        // PF charged
2473        if (pf->Charge() != 0 && fabs(tmpele->SCluster()->Eta()) > 1.479
2474            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.015) {
2475          if( ctrl.debug) cout << "\tcharged trk, dR matches 4L ele ..." << endl;
2476          IsLeptonFootprint = kTRUE;
2477        }
2478        // PF gamma
2479        if (abs(pf->PFType()) == PFCandidate::eGamma && fabs(tmpele->SCluster()->Eta()) > 1.479
2480            && mithep::MathUtils::DeltaR(tmpele->Phi(),tmpele->Eta(), pf->Phi(), pf->Eta()) < 0.08) {
2481          if( ctrl.debug) cout << "\tPF gamma, matches 4L ele ..." << endl;
2482          IsLeptonFootprint = kTRUE;
2483        }
2484      } // loop over electrons
2485
2486      /* KH - comment for sync            
2487      //
2488      // Check for muons
2489      //
2490      for (Int_t q=0; q < muonsToVeto.size(); ++q) {
2491        const mithep::Muon *tmpmu = muonsToVeto[q];
2492        // 4l muon
2493        if( pf->HasTrackerTrk() ) {
2494          if (pf->TrackerTrk() == tmpmu->TrackerTrk() ){
2495            if( ctrl.debug) cout << "\tmatches 4L mu ..." << endl;
2496            IsLeptonFootprint = kTRUE;
2497          }
2498        }
2499        // PF charged
2500        if (pf->Charge() != 0 && mithep::MathUtils::DeltaR(tmpmu->Phi(),tmpmu->Eta(), pf->Phi(), pf->Eta()) < 0.01) {
2501          if( ctrl.debug) cout << "\tcharged trk, dR matches 4L mu ..." << endl;
2502          IsLeptonFootprint = kTRUE;
2503        }
2504      } // loop over muons
2505      */
2506
2507    if (IsLeptonFootprint)
2508      continue;
2509
2510    //
2511    // Charged Iso
2512    //
2513    if (pf->Charge() != 0 && (pf->HasTrackerTrk()||pf->HasGsfTrk()) ) {
2514
2515 //       if( pf->HasTrackerTrk() )
2516 //      if (abs(pf->TrackerTrk()->DzCorrected(vtx)) > 0.2) continue;
2517 //       if( pf->HasGsfTrk() )
2518 //      if (abs(pf->GsfTrk()->DzCorrected(vtx)) > 0.2) continue;
2519
2520      // Veto any PFmuon, or PFEle
2521      if (abs(pf->PFType()) == PFCandidate::eElectron || abs(pf->PFType()) == PFCandidate::eMuon) {
2522        if( ctrl.debug ) cout << "\t skipping, pf is and ele or mu .." <<endl;
2523        continue;
2524      }
2525
2526      // Footprint Veto
2527      if (fabs(ele->SCluster()->Eta()) > 1.479 && dr < 0.015) continue;
2528
2529      if( ctrl.debug) cout << "charged:: pt: " << pf->Pt()
2530                           << "\ttype: " << pf->PFType()
2531                           << "\ttrk: " << pf->TrackerTrk() << endl;
2532
2533      fChargedIso += pf->Pt();
2534    }
2535
2536    //
2537    // Gamma Iso
2538    //
2539    else if (abs(pf->PFType()) == PFCandidate::eGamma) {
2540
2541      if (fabs(ele->SCluster()->Eta()) > 1.479) {
2542        if (mithep::MathUtils::DeltaR(ele->Phi(),ele->Eta(), pf->Phi(), pf->Eta()) < 0.08) continue;
2543      }
2544      if( ctrl.debug) cout << "gamma:: " << pf->Pt() << " "
2545                           << dr << endl;
2546      // KH, add to sync
2547      //      if( pf->Pt() > 0.5 )
2548        fGammaIso += pf->Pt();
2549    }
2550
2551    //
2552    // Neutral Iso
2553    //
2554    else {
2555      if( ctrl.debug) cout << "neutral:: " << pf->Pt() << " "
2556                           << dr << endl;
2557      // KH, add to sync
2558      //      if( pf->Pt() > 0.5 )
2559        fNeutralHadronIso += pf->Pt();
2560    }
2561
2562    }
2563
2564  }
2565
2566 //   double rho = 0;
2567 //   if (!(isnan(fPUEnergyDensity->At(0)->Rho()) || isinf(fPUEnergyDensity->At(0)->Rho())))
2568 //     rho = fPUEnergyDensity->At(0)->Rho();
2569
2570  // WARNING!!!!  
2571  // hardcode for sync ...
2572  EffectiveAreaVersion = eleT.kEleEAData2011;
2573  // WARNING!!!!  
2574
2575
2576  double pfIso = fChargedIso + fmax(0.0,(fGammaIso + fNeutralHadronIso
2577                                        -rho*eleT.ElectronEffectiveArea(eleT.kEleGammaAndNeutralHadronIso04,
2578                                                                   ele->Eta(),EffectiveAreaVersion)));
2579
2580
2581  gChargedIso = fChargedIso;
2582  gGammaIso = fGammaIso;
2583  gNeutralIso = fNeutralHadronIso;  
2584  return pfIso;
2585 }
2586
2587
2050   //--------------------------------------------------------------------------------------------------
2051   SelectionStatus electronReferenceIsoSelection(ControlFlags &ctrl,
2052 <                                              const mithep::Electron * ele,
2053 <                                              const mithep::Vertex * vtx,
2054 <                                              const mithep::Array<mithep::PFCandidate> * fPFCandidates,
2055 <                                              const mithep::Array<mithep::PileupEnergyDensity> * fPUEnergyDensity,
2056 <                                              mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
2057 <                                              vector<const mithep::PFCandidate*> photonsToVeto)
2052 >                                              const Electron * ele,
2053 >                                              const Vertex * vtx,
2054 >                                              const Array<PFCandidate> * fPFCandidates,
2055 >                                              const Array<PileupEnergyDensity> * fPUEnergyDensity,
2056 >                                              ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
2057 >                                              vector<const PFCandidate*> photonsToVeto)
2058   //--------------------------------------------------------------------------------------------------
2059   {
2060  
# Line 2600 | Line 2062 | SelectionStatus electronReferenceIsoSele
2062  
2063    double pfIso = electronPFIso04( ctrl, ele, vtx, fPFCandidates, fPUEnergyDensity,
2064                                    EffectiveAreaVersion, photonsToVeto);
2603  //  cout << "--------------> setting electron isoPF04 to " << pfIso << endl;
2065    status.isoPF04 = pfIso;
2066    status.chisoPF04 = gChargedIso;
2067    status.gaisoPF04 = gGammaIso;
# Line 2613 | Line 2074 | SelectionStatus electronReferenceIsoSele
2074      status.orStatus(SelectionStatus::LOOSEISO);
2075      status.orStatus(SelectionStatus::TIGHTISO);
2076    }
2077 <  if(ctrl.debug) {
2078 <    cout << "el relpfIso: " << pfIso/ele->Pt() << endl;
2618 <    cout << "returning status : " << hex << status.getStatus() << dec << endl;
2619 <  }
2077 >  if(ctrl.debug)
2078 >    cout << "  --> ele relpfIso: " << pfIso/ele->Pt() << ", returning status : " << hex << status.getStatus() << dec << endl;
2079    return status;
2621
2622 }
2623
2624
2625 //--------------------------------------------------------------------------------------------------
2626 // hacked version
2627 SelectionStatus electronReferenceIsoSelection(ControlFlags &ctrl,
2628                                              const mithep::Electron * ele,
2629                                              const mithep::Vertex * vtx,
2630                                              const mithep::Array<mithep::PFCandidate> * fPFCandidates,
2631                                              float rho,
2632                                              mithep::ElectronTools::EElectronEffectiveAreaTarget EffectiveAreaVersion,
2633                                              vector<const mithep::Muon*> muonsToVeto,
2634                                              vector<const mithep::Electron*> electronsToVeto)
2635 //--------------------------------------------------------------------------------------------------
2636 {
2637
2638  SelectionStatus status;
2639
2640  double pfIso = electronPFIso04( ctrl, ele, vtx, fPFCandidates, rho,
2641                                  EffectiveAreaVersion, muonsToVeto ,electronsToVeto );
2642  status.isoPF04 = pfIso;
2643  status.chisoPF04 = gChargedIso;
2644  status.gaisoPF04 = gGammaIso;
2645  status.neisoPF04 = gNeutralIso;
2646  bool pass = false;
2647  if( (pfIso/ele->Pt()) < ELECTRON_REFERENCE_PFISO_CUT ) pass = true;
2648
2649  if( pass ) {
2650    status.orStatus(SelectionStatus::LOOSEISO);
2651    status.orStatus(SelectionStatus::TIGHTISO);
2652  }
2653  if(ctrl.debug) cout << "returning status : " << hex << status.getStatus() << dec << endl;
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();
2080   }
2905
2906
2907
2081   //--------------------------------------------------------------------------------------------------
2082 < double  nonCorrectedIsoDr03(ControlFlags & ctrl,
2083 <                            const mithep::PFCandidate * photon,
2084 <                            const mithep::Electron * lepton,
2085 <                            const mithep::Array<mithep::PFCandidate> * fPFCandidates)
2082 > double  isoDr03ForFsr(ControlFlags & ctrl,
2083 >                      const PFCandidate * photon,
2084 >                      const ChargedParticle * lep,
2085 >                      const Array<PFCandidate> * fPFCandidates,
2086 >                      bool doDBetaCorr)
2087   //--------------------------------------------------------------------------------------------------
2088   {
2089  
# Line 2926 | Line 2100 | double  nonCorrectedIsoDr03(ControlFlags
2100    //
2101    for(int k=0; k<fPFCandidates->GetEntries(); ++k) {
2102  
2103 <    const mithep::PFCandidate *pf = (mithep::PFCandidate*)((*fPFCandidates)[k]);
2103 >    const PFCandidate *pf = (PFCandidate*)((*fPFCandidates)[k]);
2104  
2105      Double_t deta = (photon->Eta() - pf->Eta());
2106 <    Double_t dphi = mithep::MathUtils::DeltaPhi(Double_t(photon->Phi()),Double_t(pf->Phi()));
2107 <    Double_t dr = mithep::MathUtils::DeltaR(photon->Phi(),photon->Eta(), pf->Phi(), pf->Eta());
2106 >    Double_t dphi = MathUtils::DeltaPhi(Double_t(photon->Phi()),Double_t(pf->Phi()));
2107 >    Double_t dr = MathUtils::DeltaR(photon->Phi(),photon->Eta(), pf->Phi(), pf->Eta());
2108      if (dr > 0.3) continue;
2109  
2110      if( !(PFnoPUflag[k]) && pf->Charge() != 0 ) {
# Line 2942 | Line 2116 | double  nonCorrectedIsoDr03(ControlFlags
2116      //
2117      // skip this photon
2118      //
2119 <    if( abs(pf->PFType()) == mithep::PFCandidate::eGamma &&
2119 >    if( abs(pf->PFType()) == PFCandidate::eGamma &&
2120          pf->Et() == photon->Et() ) continue;
2121      
2122        
# Line 2951 | Line 2125 | double  nonCorrectedIsoDr03(ControlFlags
2125      //
2126      if (pf->Charge() != 0 ) {
2127        if( dr > 0.01 && pf->Pt() >= 0.2 &&
2128 <          !(pf->TrackerTrk() == lepton->TrackerTrk()) )
2128 >          !(pf->TrackerTrk() == lep->TrackerTrk()) )
2129          fChargedIso += pf->Pt();
2130      }
2131      
2132      //
2133      // Gamma Iso
2134      //
2135 <    else if (abs(pf->PFType()) == mithep::PFCandidate::eGamma) {
2135 >    else if (abs(pf->PFType()) == PFCandidate::eGamma) {
2136        if( pf->Pt() > 0.5 && dr > 0.01)
2137          fGammaIso += pf->Pt();
2138      }
# Line 2973 | Line 2147 | double  nonCorrectedIsoDr03(ControlFlags
2147      
2148    }
2149    
2150 <  if( ctrl.debug ) {
2151 <    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;
2150 >  if(ctrl.debug) cout << "      isoDr03ForFsr: " << setw(12) << fChargedIso << setw(12) << fGammaIso << setw(12) << fNeutralHadronIso << setw(12) << fpfPU << endl;
2151 >  double pfIso = fChargedIso + fGammaIso + fNeutralHadronIso + (doDBetaCorr ? -0.5 : 1)*fpfPU;
2152    return pfIso/photon->Pt();
2153   }
2987
2988
2989

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines