ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/LeptonSelection/src/FSR.cc
(Generate patch)

Comparing UserCode/MitHzz4l/LeptonSelection/src/FSR.cc (file contents):
Revision 1.3 by khahn, Sun Jun 3 15:51:51 2012 UTC vs.
Revision 1.4 by khahn, Tue Jun 5 19:35:47 2012 UTC

# Line 8 | Line 8
8   using namespace std;
9  
10   extern vector<bool> PFnoPUflag;
11 // TMPTMPTMP -- global for FSR study
12 // extern std::vector< std::vector<int> > gammaMatches;
13 // TMPTMPTMP -- global for FSR study
11  
12   //--------------------------------------------------------------------------------------------------
13   // typeI = PF IDed photons.  NB : repurpose PFnoPUflag, flip for recovered photons  
# Line 22 | Line 19 | bool recover_typeI_Photon( ControlFlags
19                             vector<SimpleLepton> &lepvec,
20                             const mithep::Array<mithep::PFCandidate> * pfArr,
21                             const mithep::Array<mithep::Electron> *eleArr,
22 <                           TLorentzVector * Zvec )
22 >                           TLorentzVector * Zvec,
23 >                           vector<const mithep::PFCandidate*> &photonsToVeto )
24   //--------------------------------------------------------------------------------------------------
25   {
26 +  if( lepvec[electronIndex].fsrRecoveryAttempted ) return false;
27 +
28    vector<int> photonIndices;
29    for( int i=0; i<pfArr->GetEntries(); i++ ) {
30      if( !(PFnoPUflag[i])) continue; // my PF no PU hack
# Line 33 | Line 33 | bool recover_typeI_Photon( ControlFlags
33          pf->Pt() > 2.0 && fabs(pf->Eta()) < 2.4 ) {
34  
35        if( ctrl.debug ) std::cerr << "FSR :: pass preselection ... pt: "<< pf->Pt() << std::endl;
36 <      float dR = mithep::MathUtils::DeltaR(pf->Phi(),pf->Eta(), el->Phi(), el->Eta());
36 >      //      float dR = mithep::MathUtils::DeltaR(pf->Phi(),pf->Eta(), el->Phi(), el->Eta());
37 >      float dR = mithep::MathUtils::DeltaR(pf->Phi(),pf->Eta(),
38 >                                           lepvec[electronIndex].vec.Phi(), lepvec[electronIndex].vec.Eta());
39        if( ctrl.debug ) std::cerr << "FSR :: dR = " << dR << std::endl;
40  
39      /*
40      //
41      // check that input electron is the closest lepton to this photon
42      //
43      bool found_closer_lepton=false;
44      for( int j=0; j<lepvec.size(); j++ ) {
45        if( j == electronIndex ) continue;
46        if( !(lepvec[j].status.looseIDAndPre()) ) continue;
47        float tmp_dR =  mithep::MathUtils::DeltaR(pf->Phi(),pf->Eta(),
48                                                  lepvec[j].vec.Phi(), lepvec[j].vec.Eta());
49        if( tmp_dR < dR ) {
50          if(ctrl.debug) cout << "FSR :: found closer lepton (j="<<j<<" : "
51                              <<tmp_dR<<" vs "<<dR<<") skipping..." << endl;  
52        found_closer_lepton=true;
53        break;
54        }
55      }
56      if( found_closer_lepton ) return false;
57      */
58
41        //
42        // veto if close to an electron SC
43        //
# Line 81 | Line 63 | bool recover_typeI_Photon( ControlFlags
63        if( flagEleSC ) continue;
64        if( ctrl.debug ) std::cerr << "FSR :: not matched to an ele SC ... " << std::endl;
65  
66 +
67 +      //
68 +      // check that input electron is the closest lepton to this photon
69 +      //
70 +      bool found_closer_lepton=false;
71 +      for( int j=0; j<lepvec.size(); j++ ) {
72 +        if( j == electronIndex ) continue;
73 +        if( !(lepvec[j].status.looseIDAndPre()) ) continue;
74 +        float tmp_dR =  mithep::MathUtils::DeltaR(pf->Phi(),pf->Eta(),
75 +                                                  lepvec[j].vec.Phi(), lepvec[j].vec.Eta());
76 +        if( tmp_dR < dR ) {
77 +          if(ctrl.debug) cout << "FSR :: found closer lepton (j="<<j<<" : "
78 +                              <<tmp_dR<<" vs "<<dR<<") skipping..." << endl;  
79 +        found_closer_lepton=true;
80 +        break;
81 +        }
82 +      }
83 +      if( found_closer_lepton ) continue;
84 +
85 +
86        //
87        // Z mass OK?
88        //
# Line 106 | Line 108 | bool recover_typeI_Photon( ControlFlags
108        //      
109        // "need tighter cuts for other photons ..."
110        //
111 <      //      if( dR < 0.5 && pf->Pt() > 4. && dbetaCorrectedIsoDr03(ctrl, pf, el, pfArr) < 1.0) {
112 <      if( dR < 0.5 && pf->Pt() > 4. && betaCorrectedIsoDr03(ctrl, pf, el, pfArr) < 1.0) {
111 >      if( dR < 0.5 && pf->Pt() > 4. && dbetaCorrectedIsoDr03(ctrl, pf, el, pfArr) < 1.0) {
112 >      //      if( dR < 0.5 && pf->Pt() > 4. && nonCorrectedIsoDr03(ctrl, pf, el, pfArr) < 1.0) {
113          if( ctrl.debug ) std::cerr << "FSR :: tighter cuts, pushing  ... " << std::endl;
114          photonIndices.push_back(i);
115        }
# Line 131 | Line 133 | bool recover_typeI_Photon( ControlFlags
133  
134    const mithep::PFCandidate * thepf;
135    if( highest_pt > 4. ) {
136 <    thepf  = (mithep::PFCandidate*)(pfArr->At(highest_pt_index));
136 >    thepf  = (const mithep::PFCandidate*)(pfArr->At(highest_pt_index));
137      // "... remove it from lepton isolation ..."
138 <    PFnoPUflag[highest_pt_index] = 0;
138 >    //    PFnoPUflag[highest_pt_index] = 0;
139      // TMP, commented flip above for FSR study
140      // gammaMatches[highest_pt_index].push_back(lepvec[electronIndex].index);
141 +    photonsToVeto.push_back(thepf);
142    } else if( smallest_dR != 999. ) {
143 <    thepf  = (mithep::PFCandidate*)(pfArr->At(smallest_dR_index));
143 >    thepf  = (const mithep::PFCandidate*)(pfArr->At(smallest_dR_index));
144      // "... remove it from lepton isolation ..."
145 <    PFnoPUflag[smallest_dR_index] = 0;
145 >    // PFnoPUflag[smallest_dR_index] = 0;
146      // TMP, commented flip above for FSR study
147      // gammaMatches[smallest_dR_index].push_back(lepvec[electronIndex].index);
148 +    photonsToVeto.push_back(thepf);
149    } else {
150      return false;
151    }
# Line 157 | Line 161 | bool recover_typeI_Photon( ControlFlags
161      //                      newelvec.Eta(),
162      //                      newelvec.Phi());
163      lepvec[electronIndex].vec += phvec;
164 +    lepvec[electronIndex].fsrRecoveryAttempted = true;
165      return true;      
166    }
167    return false;
# Line 174 | Line 179 | bool recover_typeI_Photon( ControlFlags
179                             vector<SimpleLepton> &lepvec,
180                             const mithep::Array<mithep::PFCandidate> * pfArr,
181                             const mithep::Array<mithep::Electron> *eleArr,
182 <                           TLorentzVector * Zvec )
182 >                           TLorentzVector * Zvec,
183 >                           vector<const mithep::PFCandidate*> &photonsToVeto )
184   //--------------------------------------------------------------------------------------------------
185   {
186 +  if( lepvec[muonIndex].fsrRecoveryAttempted ) return false;
187 +
188    vector<int> photonIndices;
189    for( int i=0; i<pfArr->GetEntries(); i++ ) {
190      if( !(PFnoPUflag[i])) continue; // my PF no PU hack
# Line 185 | Line 193 | bool recover_typeI_Photon( ControlFlags
193          pf->Pt() > 2.0 && fabs(pf->Eta()) < 2.4 ) {
194  
195        if( ctrl.debug ) std::cerr << "FSR :: pass preselection ... pt: "<< pf->Pt() << std::endl;
196 <      float dR = mithep::MathUtils::DeltaR(pf->Phi(),pf->Eta(), mu->Phi(), mu->Eta());
196 >      //      float dR = mithep::MathUtils::DeltaR(pf->Phi(),pf->Eta(), mu->Phi(), mu->Eta());
197 >      float dR = mithep::MathUtils::DeltaR(pf->Phi(),pf->Eta(),
198 >                                           lepvec[muonIndex].vec.Phi(), lepvec[muonIndex].vec.Eta());
199        if( ctrl.debug ) std::cerr << "FSR :: dR = " << dR << std::endl;
200  
191      /*
192      //
193      // check that input electron is the closest lepton to this photon
194      //
195      bool found_closer_lepton=false;
196      for( int j=0; j<lepvec.size(); j++ ) {
197        if( j == muonIndex ) continue;
198        if( !(lepvec[j].status.looseIDAndPre()) ) continue;
199        float tmp_dR =  mithep::MathUtils::DeltaR(pf->Phi(),pf->Eta(),
200                                                  lepvec[j].vec.Phi(), lepvec[j].vec.Eta());
201        if( tmp_dR < dR ) {
202          if(ctrl.debug) cout << "FSR :: found closer lepton (j="<<j<<" : "
203                              <<tmp_dR<<" vs "<<dR<<") skipping..." << endl;  
204          found_closer_lepton=true;
205          break;
206        }
207      }
208      if( found_closer_lepton ) return false;
209      */
210
201        //
202        // veto if close to an electron SC
203        //
# Line 233 | Line 223 | bool recover_typeI_Photon( ControlFlags
223        if( flagEleSC ) continue;
224        if( ctrl.debug ) std::cerr << "FSR :: not matched to an ele SC ... " << std::endl;
225  
226 +
227 +      //
228 +      // check that input muon is the closest lepton to this photon
229 +      //
230 +      bool found_closer_lepton=false;
231 +      for( int j=0; j<lepvec.size(); j++ ) {
232 +        if( j == muonIndex ) continue;
233 +        if( !(lepvec[j].status.looseIDAndPre()) ) continue;
234 +        float tmp_dR =  mithep::MathUtils::DeltaR(pf->Phi(),pf->Eta(),
235 +                                                  lepvec[j].vec.Phi(), lepvec[j].vec.Eta());
236 +        if( tmp_dR < dR ) {
237 +          if(ctrl.debug) cout << "FSR :: found closer lepton (j="<<j<<" : "
238 +                              <<tmp_dR<<" vs "<<dR<<") skipping..." << endl;  
239 +          found_closer_lepton=true;
240 +          break;
241 +        }
242 +      }
243 +      if( found_closer_lepton ) continue;
244 +
245 +
246 +
247        //
248        // Z mass OK?
249        //
# Line 258 | Line 269 | bool recover_typeI_Photon( ControlFlags
269        // "need tighter cuts for other photons ..."
270        //
271        if( ctrl.debug ) std::cerr << "FSR :: pass tighter?, pT: " << pf->Pt() << std::endl;
272 <      //      if( dR < 0.5 && pf->Pt() > 4. && dbetaCorrectedIsoDr03(ctrl, pf, mu, pfArr) < 1.0) {
273 <      if( dR < 0.5 && pf->Pt() > 4. && betaCorrectedIsoDr03(ctrl, pf, mu, pfArr) < 1.0) {
272 >      if( dR < 0.5 && pf->Pt() > 4. && dbetaCorrectedIsoDr03(ctrl, pf, mu, pfArr) < 1.0) {
273 >      //      if( dR < 0.5 && pf->Pt() > 4. && nonCorrectedIsoDr03(ctrl, pf, mu, pfArr) < 1.0) {
274          if( ctrl.debug ) std::cerr << "FSR :: tighter cuts, pushing index= " << i  << std::endl;
275          photonIndices.push_back(i);
276        }
# Line 284 | Line 295 | bool recover_typeI_Photon( ControlFlags
295    const mithep::PFCandidate * thepf;
296    if( highest_pt > 4. ) {
297      if(ctrl.debug) std::cerr << "FSR :: taking highest pt gamma, index = " <<  highest_pt_index << endl;
298 <    thepf  = (mithep::PFCandidate*)(pfArr->At(highest_pt_index));
298 >    thepf  = (const mithep::PFCandidate*)(pfArr->At(highest_pt_index));
299      // "... remove it from lepton isolation ..."
300 <    PFnoPUflag[highest_pt_index] = 0;
300 >    //    PFnoPUflag[highest_pt_index] = 0;
301      // TMP, commented flip above for FSR study
302      // gammaMatches[highest_pt_index].push_back(lepvec[muonIndex].index);
303 +    photonsToVeto.push_back(thepf);
304    } else if( smallest_dR != 999. ) {
305      if(ctrl.debug) std::cerr << "FSR :: taking smallest dR gamma, index = " <<  highest_pt_index << endl;
306 <    thepf  = (mithep::PFCandidate*)(pfArr->At(smallest_dR_index));
306 >    thepf  = (const mithep::PFCandidate*)(pfArr->At(smallest_dR_index));
307      // "... remove it from lepton isolation ..."
308 <    PFnoPUflag[smallest_dR_index] = 0;
308 >    //    PFnoPUflag[smallest_dR_index] = 0;
309      // TMP, commented flip above for FSR study
310      //gammaMatches[smallest_dR_index].push_back(lepvec[muonIndex].index);
311 +    photonsToVeto.push_back(thepf);
312    } else {
313      return false;
314    }
# Line 314 | Line 327 | bool recover_typeI_Photon( ControlFlags
327      //                      newmuvec.Eta(),
328      //                      newmuvec.Phi());
329      lepvec[muonIndex].vec += phvec;
330 +    lepvec[muonIndex].fsrRecoveryAttempted = true;
331      return true;      
332    }
333    return false;
# Line 360 | Line 374 | bool recover_typeII_Photon( ControlFlags
374        pvec.SetPtEtaPhiM( phpt,mu->Eta(),mu->Phi(),0.);
375        lepvec[muonIndex].vec += pvec;
376        if(ctrl.debug) cout << "FSR :: t2, new pt " <<  lepvec[muonIndex].vec.Pt() << endl;
377 +      lepvec[muonIndex].fsrRecoveryAttempted = true;  
378        return true;
379      }
380    }
381    
367  lepvec[muonIndex].fsrRecoveryAttempted = true;  
382    return false;
383   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines