8 |
|
|
9 |
|
extern vector<bool> PFnoPUflag; |
10 |
|
|
11 |
< |
void addPhoton(EventData &ret, TLorentzVector &pvec) |
11 |
> |
//---------------------------------------------------------------------------------------- |
12 |
> |
void addPhotonToEventData(EventData &ret, TLorentzVector &pvec) |
13 |
> |
// |
14 |
> |
// add a photon to the list of fsr photons in the EventData |
15 |
> |
// |
16 |
|
{ |
17 |
|
assert(ret.fsrPhotons.size() < 3); |
18 |
|
SimpleLepton photon; |
24 |
|
if(ret.fsrPhotons.size() > 1) |
25 |
|
if(dr(ret.fsrPhotons[1], photon) < 0.01) return; |
26 |
|
|
23 |
– |
// cout << " possibly adding photon: " |
24 |
– |
// << setw(12) << pvec.Pt() |
25 |
– |
// << " existing: " |
26 |
– |
// << setw(12) << ( (ret.fsrPhotons.size() > 0) ? ret.fsrPhotons[0].vec.Pt() : -1 ) |
27 |
– |
// << setw(12) << ( (ret.fsrPhotons.size() > 1) ? ret.fsrPhotons[1].vec.Pt() : -1 ) |
28 |
– |
// << endl; |
29 |
– |
|
27 |
|
if(ret.fsrPhotons.size() == 2) { |
28 |
|
// only want to save two, so if there's already two in the vector, store the highest two out of the three photons |
29 |
|
sort( ret.fsrPhotons.begin(), ret.fsrPhotons.end(), SimpleLepton::lep_pt_sort ); |
35 |
|
} else |
36 |
|
ret.fsrPhotons.push_back(photon); |
37 |
|
sort( ret.fsrPhotons.begin(), ret.fsrPhotons.end(), SimpleLepton::lep_pt_sort ); |
41 |
– |
// cout << " possibly added photon: " |
42 |
– |
// << setw(12) << pvec.Pt() |
43 |
– |
// << " existing: " |
44 |
– |
// << setw(12) << ( (ret.fsrPhotons.size() > 0) ? ret.fsrPhotons[0].vec.Pt() : -1 ) |
45 |
– |
// << setw(12) << ( (ret.fsrPhotons.size() > 1) ? ret.fsrPhotons[1].vec.Pt() : -1 ) |
46 |
– |
// << endl; |
38 |
|
} |
39 |
|
//-------------------------------------------------------------------------------------------------- |
40 |
< |
// typeI = PF IDed photons. NB : repurpose PFnoPUflag, flip for recovered photons |
41 |
< |
// so that they are skipped in the isolation calculation |
42 |
< |
//-------------------------------------------------------------------------------------------------- |
43 |
< |
bool recover_typeI_Photon( ControlFlags & ctrl, |
44 |
< |
EventData &ret, |
45 |
< |
Electron * el, |
46 |
< |
const int electronIndex, |
47 |
< |
vector<SimpleLepton> &lepvec, |
48 |
< |
const Array<PFCandidate> * pfArr, |
49 |
< |
const Array<Electron> *eleArr, |
59 |
< |
TLorentzVector * Zvec, |
60 |
< |
vector<const PFCandidate*> &photonsToVeto ) |
40 |
> |
// typeI = PF IDed photons. |
41 |
> |
//---------------------------------------------------------------------------------------- |
42 |
> |
pair<TLorentzVector,int> findFsrPhoton( ControlFlags & ctrl, |
43 |
> |
EventData &ret, |
44 |
> |
const ChargedParticle *lep, // the non-constant copy of lepvec[i] (or [j]) |
45 |
> |
const int lepIndex, |
46 |
> |
vector<SimpleLepton> &lepvec, // really lepvec_i (or _j) |
47 |
> |
const Array<PFCandidate> * pfArr, |
48 |
> |
const Array<Electron> *eleArr, |
49 |
> |
TLorentzVector * Zvec) |
50 |
|
//-------------------------------------------------------------------------------------------------- |
51 |
|
{ |
52 |
< |
if( lepvec[electronIndex].fsrRecoveryAttempted ) return false; |
52 |
> |
if( lepvec[lepIndex].fsrRecoveryAttempted ) return pair<TLorentzVector,int>(TLorentzVector(0,0,0,0), -1); |
53 |
|
|
54 |
< |
vector<int> photonIndices; |
54 |
> |
vector<PFCandidate> photons; |
55 |
> |
vector<int> photonIndices; // index in the PFCandidate Array (wrong pT for muons FSRs) |
56 |
|
for( int i=0; i<pfArr->GetEntries(); i++ ) { |
57 |
|
if( !(PFnoPUflag[i])) continue; |
58 |
< |
const PFCandidate *pf = (PFCandidate*)((*pfArr)[i]); |
59 |
< |
if( abs(pf->PFType()) == PFCandidate::eGamma && |
70 |
< |
pf->Pt() > 2.0 && fabs(pf->Eta()) < 2.4 ) { |
71 |
< |
|
72 |
< |
if( ctrl.debug ) cout << " FSR :: pass preselection ... pt: "<< pf->Pt() << endl; |
73 |
< |
// float dR = MathUtils::DeltaR(pf->Phi(),pf->Eta(), el->Phi(), el->Eta()); |
74 |
< |
float dR = MathUtils::DeltaR(pf->Phi(),pf->Eta(), |
75 |
< |
lepvec[electronIndex].vec.Phi(), lepvec[electronIndex].vec.Eta()); |
76 |
< |
if( ctrl.debug ) cout << " FSR :: dR = " << dR << endl; |
77 |
< |
|
78 |
< |
// |
79 |
< |
// veto if close to an electron SC |
80 |
< |
// |
81 |
< |
bool flagEleSC = false; |
82 |
< |
for( int j=0; j<lepvec.size(); j++ ) { |
83 |
< |
if( !(abs(lepvec[j].type) == 11 ) ) continue; |
84 |
< |
if( !(lepvec[j].status.looseIDAndPre()) ) continue; |
85 |
< |
double eeta=lepvec[j].vec.Eta(); double ephi=lepvec[j].vec.Phi(); |
86 |
< |
float dPhi = fabs(MathUtils::DeltaPhi(pf->Phi(),ephi)); |
87 |
< |
float dEta = fabs(pf->Eta()-eeta); |
88 |
< |
float dR = MathUtils::DeltaR(pf->Phi(),pf->Eta(), ephi, eeta); |
89 |
< |
if(ctrl.debug) cout << " FSR :: comparing to ele, dPhi: " << dPhi |
90 |
< |
<< "\tdEta: " << dEta |
91 |
< |
<< "\tetaPH: " << pf->Eta() |
92 |
< |
<< "\tetaELH: " << eeta |
93 |
< |
<< "\tdR:" << dR << endl; |
94 |
< |
if( (dPhi<2.&& dEta<0.05) || dR<0.15 ) { |
95 |
< |
flagEleSC = true; |
96 |
< |
break; |
97 |
< |
} |
98 |
< |
if( flagEleSC ) break; |
99 |
< |
} |
100 |
< |
if( flagEleSC ) continue; |
101 |
< |
if( ctrl.debug ) cout << " FSR :: not matched to an ele SC ... " << endl; |
58 |
> |
const PFCandidate *pfOrig = (PFCandidate*)((*pfArr)[i]); |
59 |
> |
PFCandidate pf(*pfOrig); |
60 |
|
|
61 |
< |
|
62 |
< |
// |
63 |
< |
// check that input electron is the closest lepton to this photon |
64 |
< |
// |
65 |
< |
bool found_closer_lepton=false; |
66 |
< |
for( int j=0; j<lepvec.size(); j++ ) { |
67 |
< |
if( j == electronIndex ) continue; |
68 |
< |
if( !(lepvec[j].status.looseIDAndPre()) ) continue; |
69 |
< |
float tmp_dR = MathUtils::DeltaR(pf->Phi(),pf->Eta(), |
70 |
< |
lepvec[j].vec.Phi(), lepvec[j].vec.Eta()); |
71 |
< |
if( tmp_dR < dR ) { |
72 |
< |
if(ctrl.debug) cout << " FSR :: found closer lepton (j="<<j<<" : " |
73 |
< |
<<tmp_dR<<" vs "<<dR<<") skipping..." << endl; |
74 |
< |
found_closer_lepton=true; |
61 |
> |
bool isMuonFsr(false); |
62 |
> |
if(abs(pf.PFType())==PFCandidate::eMuon && pf.EECal()>0) { |
63 |
> |
TLorentzVector pfvec; |
64 |
> |
pfvec.SetPtEtaPhiM(pf.EECal()*pf.Pt()/pf.P(), pf.Eta(), pf.Phi(), 0); |
65 |
> |
pf.SetMom(pfvec.Px(), pfvec.Py(), pfvec.Pz(), pfvec.E()); |
66 |
> |
pf.SetPFType(PFCandidate::eGamma); |
67 |
> |
isMuonFsr = true; |
68 |
> |
} |
69 |
> |
|
70 |
> |
if(abs(pf.PFType()) != PFCandidate::eGamma) continue; |
71 |
> |
if(pf.Pt() <= 2 ) continue; |
72 |
> |
if(fabs(pf.Eta()) >= 2.4 ) continue; |
73 |
> |
|
74 |
> |
float dR = MathUtils::DeltaR(pf.Phi(),pf.Eta(), lepvec[lepIndex].vec.Phi(), lepvec[lepIndex].vec.Eta()); |
75 |
> |
|
76 |
> |
if( ctrl.debug ) { |
77 |
> |
cout << " --> pass pre, " << setprecision(5) << pf.Pt() << " " << dR; |
78 |
> |
if(isMuonFsr) cout << " (muon fsr)"; |
79 |
> |
cout << endl; |
80 |
> |
} |
81 |
> |
|
82 |
> |
// veto if close to an electron SC |
83 |
> |
bool flagEleSC = false; |
84 |
> |
for( int j=0; j<lepvec.size(); j++ ) { |
85 |
> |
if( !(abs(lepvec[j].type) == 11 ) ) continue; |
86 |
> |
if( !(lepvec[j].status.looseIDAndPre()) ) continue; |
87 |
> |
double eeta=lepvec[j].vec.Eta(); double ephi=lepvec[j].vec.Phi(); |
88 |
> |
float dPhi = fabs(MathUtils::DeltaPhi(pf.Phi(),ephi)); |
89 |
> |
float dEta = fabs(pf.Eta()-eeta); |
90 |
> |
float sc_dR = MathUtils::DeltaR(pf.Phi(),pf.Eta(), ephi, eeta); |
91 |
> |
if(ctrl.debug) cout << " sc_dR:" << sc_dR << endl; |
92 |
> |
if( (dPhi<2.&& dEta<0.05) || sc_dR<0.15 ) { |
93 |
> |
flagEleSC = true; |
94 |
|
break; |
118 |
– |
} |
119 |
– |
} |
120 |
– |
if( found_closer_lepton ) continue; |
121 |
– |
|
122 |
– |
|
123 |
– |
// |
124 |
– |
// Z mass OK? |
125 |
– |
// |
126 |
– |
TLorentzVector pvec; |
127 |
– |
pvec.SetPtEtaPhiM( pf->Pt(), pf->Eta(), pf->Phi(), 0.); |
128 |
– |
float newMass = (pvec + *Zvec).M(); |
129 |
– |
if( !( newMass > 4. && |
130 |
– |
newMass < 100. && |
131 |
– |
(fabs(newMass-Z_MASS) < fabs(Zvec->M()-Z_MASS)) |
132 |
– |
) ) continue; |
133 |
– |
if( ctrl.debug ) cout << " FSR :: improved Zmass ... " << |
134 |
– |
Zvec->M() << " -> " << newMass << endl; |
135 |
– |
|
136 |
– |
|
137 |
– |
// |
138 |
– |
// "keep all photons close to one of the 4L electrons ..." |
139 |
– |
// |
140 |
– |
if( dR < 0.07 ) { |
141 |
– |
if( ctrl.debug ) cout << " FSR :: dR < 0.07, pushing ... " << endl; |
142 |
– |
photonIndices.push_back(i); |
95 |
|
} |
96 |
+ |
if( flagEleSC ) break; |
97 |
+ |
} |
98 |
+ |
if( flagEleSC ) continue; |
99 |
+ |
if( ctrl.debug ) cout << " no match SC" << endl; |
100 |
|
|
101 |
< |
// |
102 |
< |
// "need tighter cuts for other photons ..." |
103 |
< |
// |
104 |
< |
//if( dR < 0.5 && pf->Pt() > 4. && dbetaCorrectedIsoDr03(ctrl, pf, el, pfArr) < 1.0) { |
105 |
< |
if( dR < 0.5 && pf->Pt() > 4. && nonCorrectedIsoDr03(ctrl, pf, el, pfArr) < 1.0) { |
106 |
< |
if( ctrl.debug ) cout << " FSR :: tighter cuts, pushing ... " << endl; |
107 |
< |
photonIndices.push_back(i); |
101 |
> |
// check that input lepton is the closest lepton to this photon |
102 |
> |
bool found_closer_lepton=false; |
103 |
> |
for( int j=0; j<lepvec.size(); j++ ) { |
104 |
> |
if( j == lepIndex ) continue; |
105 |
> |
if( !(lepvec[j].status.looseIDAndPre()) ) continue; |
106 |
> |
float tmp_dR = MathUtils::DeltaR(pf.Phi(),pf.Eta(), |
107 |
> |
lepvec[j].vec.Phi(), lepvec[j].vec.Eta()); |
108 |
> |
if( tmp_dR < dR ) { |
109 |
> |
if(ctrl.debug) cout << " found closer lepton (j=" << j << " : " << tmp_dR << " vs " << dR << ") skipping..." << endl; |
110 |
> |
found_closer_lepton=true; |
111 |
> |
break; |
112 |
|
} |
113 |
|
} |
114 |
< |
} |
114 |
> |
if( found_closer_lepton ) continue; |
115 |
|
|
116 |
< |
float highest_pt = -1; int highest_pt_index=-1; |
117 |
< |
float smallest_dR = 999.; int smallest_dR_index=-1; |
118 |
< |
for( int i=0; i<photonIndices.size(); i++ ) { |
119 |
< |
const PFCandidate *pf = (PFCandidate*)(pfArr->At(photonIndices[i])); |
120 |
< |
float dR = MathUtils::DeltaR(pf->Phi(),pf->Eta(), el->Phi(), el->Eta()); |
121 |
< |
if( pf->Pt() > highest_pt ) { |
122 |
< |
highest_pt_index = photonIndices[i]; |
123 |
< |
highest_pt = pf->Pt(); |
124 |
< |
} |
125 |
< |
if( dR < smallest_dR ) { |
126 |
< |
smallest_dR_index = photonIndices[i]; |
127 |
< |
smallest_dR = dR; |
116 |
> |
// Z mass OK? |
117 |
> |
TLorentzVector pvec; |
118 |
> |
pvec.SetPtEtaPhiM( pf.Pt(), pf.Eta(), pf.Phi(), 0.); |
119 |
> |
float newMass = (pvec + *Zvec).M(); |
120 |
> |
if( !( newMass > 4. && |
121 |
> |
newMass < 100. && |
122 |
> |
(fabs(newMass-Z_MASS) < fabs(Zvec->M()-Z_MASS)) |
123 |
> |
) ) continue; |
124 |
> |
if( ctrl.debug ) cout << " better mass " << Zvec->M() << " -> " << newMass << endl; |
125 |
> |
|
126 |
> |
// "keep all photons close to one of the 4L leptons ..." |
127 |
> |
bool use(false); |
128 |
> |
if(dR < 0.07) { |
129 |
> |
if( ctrl.debug ) cout << " push loose " << i << endl; |
130 |
> |
use = true; |
131 |
> |
} else if(dR<0.5 && pf.Pt()>4 && isoDr03ForFsr(ctrl, &pf, lep, pfArr, false) < 1) { // "need tighter cuts for other photons ..." |
132 |
> |
if( ctrl.debug ) cout << " push tight " << i << endl; |
133 |
> |
use = true; |
134 |
> |
} |
135 |
> |
if(use) { |
136 |
> |
photons.push_back(pf); |
137 |
> |
photonIndices.push_back(i); // note: will *not* have the right kinematics for muon fsr candidates |
138 |
|
} |
139 |
|
} |
140 |
|
|
141 |
< |
const PFCandidate * thepf; |
142 |
< |
if( highest_pt > 4. ) { |
143 |
< |
thepf = (const PFCandidate*)(pfArr->At(highest_pt_index)); |
144 |
< |
// "... remove it from lepton isolation ..." |
145 |
< |
// PFnoPUflag[highest_pt_index] = 0; |
146 |
< |
// TMP, commented flip above for FSR study |
147 |
< |
// gammaMatches[highest_pt_index].push_back(lepvec[electronIndex].index); |
148 |
< |
photonsToVeto.push_back(thepf); |
149 |
< |
} else if( smallest_dR != 999. ) { |
150 |
< |
thepf = (const PFCandidate*)(pfArr->At(smallest_dR_index)); |
151 |
< |
// "... remove it from lepton isolation ..." |
152 |
< |
// PFnoPUflag[smallest_dR_index] = 0; |
153 |
< |
// TMP, commented flip above for FSR study |
154 |
< |
// gammaMatches[smallest_dR_index].push_back(lepvec[electronIndex].index); |
155 |
< |
photonsToVeto.push_back(thepf); |
156 |
< |
} else { |
187 |
< |
return false; |
188 |
< |
} |
189 |
< |
|
190 |
< |
if( thepf != NULL ) { |
191 |
< |
// add to the electron |
192 |
< |
TLorentzVector elvec,phvec,newelvec; |
193 |
< |
elvec.SetPtEtaPhiM( el->Pt(), el->Eta(), el->Phi(), ELECTRON_MASS); |
194 |
< |
phvec.SetPtEtaPhiM( thepf->Pt(), thepf->Eta(), thepf->Phi(), 0.); |
195 |
< |
addPhoton(ret,phvec); |
196 |
< |
newelvec = elvec+phvec; |
197 |
< |
// don't update the electron object, just simplelepton |
198 |
< |
// el->SetPtEtaPhi (newelvec.Pt(), |
199 |
< |
// newelvec.Eta(), |
200 |
< |
// newelvec.Phi()); |
201 |
< |
lepvec[electronIndex].vec += phvec; |
202 |
< |
lepvec[electronIndex].fsrRecoveryAttempted = true; |
203 |
< |
return true; |
204 |
< |
} |
205 |
< |
return false; |
206 |
< |
} |
207 |
< |
|
208 |
< |
|
209 |
< |
|
210 |
< |
//-------------------------------------------------------------------------------------------------- |
211 |
< |
// typeI = PF IDed photons. NB : repurpose PFnoPUflag, flip for recovered photons |
212 |
< |
// so that they are skipped in the isolation calculation |
213 |
< |
//-------------------------------------------------------------------------------------------------- |
214 |
< |
bool recover_typeI_Photon( ControlFlags & ctrl, |
215 |
< |
EventData &ret, |
216 |
< |
Muon * mu, |
217 |
< |
const int muonIndex, |
218 |
< |
vector<SimpleLepton> &lepvec, |
219 |
< |
const Array<PFCandidate> * pfArr, |
220 |
< |
const Array<Electron> *eleArr, |
221 |
< |
TLorentzVector * Zvec, |
222 |
< |
vector<const PFCandidate*> &photonsToVeto ) |
223 |
< |
//-------------------------------------------------------------------------------------------------- |
224 |
< |
{ |
225 |
< |
if( lepvec[muonIndex].fsrRecoveryAttempted ) return false; |
226 |
< |
|
227 |
< |
vector<int> photonIndices; |
228 |
< |
for( int i=0; i<pfArr->GetEntries(); i++ ) { |
229 |
< |
if( !(PFnoPUflag[i])) continue; |
230 |
< |
const PFCandidate *pf = (PFCandidate*)((*pfArr)[i]); |
231 |
< |
if( abs(pf->PFType()) == PFCandidate::eGamma && |
232 |
< |
pf->Pt() > 2.0 && fabs(pf->Eta()) < 2.4 ) { |
233 |
< |
|
234 |
< |
if( ctrl.debug ) cout << " FSR :: pass preselection ... pt: "<< pf->Pt() << endl; |
235 |
< |
// float dR = MathUtils::DeltaR(pf->Phi(),pf->Eta(), mu->Phi(), mu->Eta()); |
236 |
< |
float dR = MathUtils::DeltaR(pf->Phi(),pf->Eta(), |
237 |
< |
lepvec[muonIndex].vec.Phi(), lepvec[muonIndex].vec.Eta()); |
238 |
< |
if( ctrl.debug ) cout << " FSR :: dR = " << dR << endl; |
239 |
< |
|
240 |
< |
// |
241 |
< |
// veto if close to an electron SC |
242 |
< |
// |
243 |
< |
bool flagEleSC = false; |
244 |
< |
for( int j=0; j<lepvec.size(); j++ ) { |
245 |
< |
if( !(abs(lepvec[j].type) == 11 ) ) continue; |
246 |
< |
if( !(lepvec[j].status.looseIDAndPre()) ) continue; |
247 |
< |
double eeta=lepvec[j].vec.Eta(); double ephi=lepvec[j].vec.Phi(); |
248 |
< |
float dPhi = fabs(MathUtils::DeltaPhi(pf->Phi(),ephi)); |
249 |
< |
float dEta = fabs(pf->Eta()-eeta); |
250 |
< |
float dR = MathUtils::DeltaR(pf->Phi(),pf->Eta(), ephi, eeta); |
251 |
< |
if(ctrl.debug) cout << " FSR :: comparing to ele, dPhi: " << dPhi |
252 |
< |
<< "\tdEta: " << dEta |
253 |
< |
<< "\tetaPH: " << pf->Eta() |
254 |
< |
<< "\tetaELH: " << eeta |
255 |
< |
<< "\tdR:" << dR << endl; |
256 |
< |
if( (dPhi<2.&& dEta<0.05) || dR<0.15 ) { |
257 |
< |
flagEleSC = true; |
258 |
< |
break; |
259 |
< |
} |
260 |
< |
if( flagEleSC ) break; |
261 |
< |
} |
262 |
< |
if( flagEleSC ) continue; |
263 |
< |
if( ctrl.debug ) cout << " FSR :: not matched to an ele SC ... " << endl; |
264 |
< |
|
265 |
< |
|
266 |
< |
// |
267 |
< |
// check that input muon is the closest lepton to this photon |
268 |
< |
// |
269 |
< |
bool found_closer_lepton=false; |
270 |
< |
for( int j=0; j<lepvec.size(); j++ ) { |
271 |
< |
if( j == muonIndex ) continue; |
272 |
< |
if( !(lepvec[j].status.looseIDAndPre()) ) continue; |
273 |
< |
float tmp_dR = MathUtils::DeltaR(pf->Phi(),pf->Eta(), |
274 |
< |
lepvec[j].vec.Phi(), lepvec[j].vec.Eta()); |
275 |
< |
if( tmp_dR < dR ) { |
276 |
< |
if(ctrl.debug) cout << " FSR :: found closer lepton (j="<<j<<" : " |
277 |
< |
<<tmp_dR<<" vs "<<dR<<") skipping..." << endl; |
278 |
< |
found_closer_lepton=true; |
279 |
< |
break; |
280 |
< |
} |
281 |
< |
} |
282 |
< |
if( found_closer_lepton ) continue; |
283 |
< |
|
284 |
< |
|
285 |
< |
|
286 |
< |
// |
287 |
< |
// Z mass OK? |
288 |
< |
// |
289 |
< |
TLorentzVector pvec; |
290 |
< |
pvec.SetPtEtaPhiM( pf->Pt(), pf->Eta(), pf->Phi(), 0.); |
291 |
< |
float newMass = (pvec + *Zvec).M(); |
292 |
< |
if( !( newMass > 4. && |
293 |
< |
newMass < 100. && |
294 |
< |
(fabs(newMass-Z_MASS) < fabs(Zvec->M()-Z_MASS)) |
295 |
< |
) ) continue; |
296 |
< |
if( ctrl.debug ) cout << " FSR :: improved Zmass ... " << |
297 |
< |
Zvec->M() << " -> " << newMass << endl; |
298 |
< |
|
299 |
< |
// |
300 |
< |
// "keep all photons close to one of the 4L muons ..." |
301 |
< |
// |
302 |
< |
if( dR < 0.07 ) { |
303 |
< |
if( ctrl.debug ) cout << " FSR :: dR < 0.07, pushing ... " << endl; |
304 |
< |
photonIndices.push_back(i); |
305 |
< |
} |
306 |
< |
|
307 |
< |
// |
308 |
< |
// "need tighter cuts for other photons ..." |
309 |
< |
// |
310 |
< |
if( ctrl.debug ) cout << " FSR :: pass tighter?, pT: " << pf->Pt() << endl; |
311 |
< |
// if( dR < 0.5 && pf->Pt() > 4. && dbetaCorrectedIsoDr03(ctrl, pf, mu, pfArr) < 1.0) { |
312 |
< |
if( dR < 0.5 && pf->Pt() > 4. && nonCorrectedIsoDr03(ctrl, pf, mu, pfArr) < 1.0) { |
313 |
< |
if( ctrl.debug ) cout << " FSR :: tighter cuts, pushing index= " << i << endl; |
314 |
< |
photonIndices.push_back(i); |
315 |
< |
} |
316 |
< |
} |
317 |
< |
} |
318 |
< |
|
319 |
< |
float highest_pt = -1; int highest_pt_index=-1; |
320 |
< |
float smallest_dR = 999.; int smallest_dR_index=-1; |
321 |
< |
for( int i=0; i<photonIndices.size(); i++ ) { |
322 |
< |
const PFCandidate *pf = (PFCandidate*)(pfArr->At(photonIndices[i])); |
323 |
< |
float dR = MathUtils::DeltaR(pf->Phi(),pf->Eta(), mu->Phi(), mu->Eta()); |
324 |
< |
if( pf->Pt() > highest_pt ) { |
325 |
< |
highest_pt_index = photonIndices[i]; |
326 |
< |
highest_pt = pf->Pt(); |
327 |
< |
} |
328 |
< |
if( dR < smallest_dR ) { |
329 |
< |
smallest_dR_index = photonIndices[i]; |
330 |
< |
smallest_dR = dR; |
141 |
> |
// choose the best one |
142 |
> |
float highest_pt(-1),smallest_dR(9999999); |
143 |
> |
int highest_pt_index(-1),smallest_dR_index(-1); |
144 |
> |
PFCandidate *hiPtPf(NULL),*smallDrPf(NULL); |
145 |
> |
for( int i=0; i<photons.size(); i++ ) { |
146 |
> |
const PFCandidate pfPhoton = photons[i]; |
147 |
> |
if(pfPhoton.Pt() > highest_pt) { |
148 |
> |
highest_pt_index = photonIndices[i]; // index in the PFCandidate Array (wrong pT for muons FSRs) |
149 |
> |
highest_pt = pfPhoton.Pt(); |
150 |
> |
hiPtPf = &photons[i]; |
151 |
> |
} |
152 |
> |
float this_dR = MathUtils::DeltaR(pfPhoton.Phi(), pfPhoton.Eta(), lep->Phi(), lep->Eta()); |
153 |
> |
if(this_dR < smallest_dR) { |
154 |
> |
smallest_dR_index = photonIndices[i]; // index in the PFCandidate Array (wrong pT for muons FSRs) |
155 |
> |
smallest_dR = this_dR; |
156 |
> |
smallDrPf = &photons[i]; |
157 |
|
} |
158 |
|
} |
159 |
|
|
160 |
< |
const PFCandidate * thepf; |
161 |
< |
if( highest_pt > 4. ) { |
162 |
< |
if(ctrl.debug) cout << " FSR :: taking highest pt gamma, index = " << highest_pt_index << endl; |
163 |
< |
thepf = (const PFCandidate*)(pfArr->At(highest_pt_index)); |
164 |
< |
// "... remove it from lepton isolation ..." |
165 |
< |
// PFnoPUflag[highest_pt_index] = 0; |
166 |
< |
// TMP, commented flip above for FSR study |
167 |
< |
// gammaMatches[highest_pt_index].push_back(lepvec[muonIndex].index); |
168 |
< |
photonsToVeto.push_back(thepf); |
169 |
< |
} else if( smallest_dR != 999. ) { |
344 |
< |
if(ctrl.debug) cout << " FSR :: taking smallest dR gamma, index = " << highest_pt_index << endl; |
345 |
< |
thepf = (const PFCandidate*)(pfArr->At(smallest_dR_index)); |
346 |
< |
// "... remove it from lepton isolation ..." |
347 |
< |
// PFnoPUflag[smallest_dR_index] = 0; |
348 |
< |
// TMP, commented flip above for FSR study |
349 |
< |
//gammaMatches[smallest_dR_index].push_back(lepvec[muonIndex].index); |
350 |
< |
photonsToVeto.push_back(thepf); |
160 |
> |
const PFCandidate *pfBest(NULL); |
161 |
> |
int iPfOrig(-1); // index of the final photon in the original PFCandidate array |
162 |
> |
if(highest_pt > 4) { |
163 |
> |
if(ctrl.debug) cout << " using hi pt " << highest_pt_index << endl; |
164 |
> |
pfBest = hiPtPf; |
165 |
> |
iPfOrig = highest_pt_index; |
166 |
> |
} else if(smallest_dR < 99999) { |
167 |
> |
if(ctrl.debug) cout << " using small dR " << smallest_dR_index << endl; |
168 |
> |
pfBest = smallDrPf; |
169 |
> |
iPfOrig = smallest_dR_index; |
170 |
|
} else { |
171 |
< |
return false; |
353 |
< |
} |
354 |
< |
|
355 |
< |
TLorentzVector pvec; |
356 |
< |
if( thepf != NULL ) { |
357 |
< |
// add to the muon |
358 |
< |
if( ctrl.debug ) cout << " FSR :: before return, oldpT=" << mu->Pt() << endl; |
359 |
< |
TLorentzVector muvec,phvec,newmuvec; |
360 |
< |
muvec.SetPtEtaPhiM( mu->Pt(), mu->Eta(), mu->Phi(), MUON_MASS); |
361 |
< |
phvec.SetPtEtaPhiM( thepf->Pt(), thepf->Eta(), thepf->Phi(), 0.); |
362 |
< |
addPhoton(ret,phvec); |
363 |
< |
pvec = phvec; |
364 |
< |
newmuvec = muvec+phvec; |
365 |
< |
// don't update the muon object, just simplelepton |
366 |
< |
// mu->SetPtEtaPhi (newmuvec.Pt(), |
367 |
< |
// newmuvec.Eta(), |
368 |
< |
// newmuvec.Phi()); |
369 |
< |
lepvec[muonIndex].vec += phvec; |
370 |
< |
lepvec[muonIndex].fsrRecoveryAttempted = true; |
371 |
< |
return true; |
372 |
< |
} |
373 |
< |
return false; |
374 |
< |
} |
375 |
< |
|
376 |
< |
|
377 |
< |
|
378 |
< |
//-------------------------------------------------------------------------------------------------- |
379 |
< |
// typeII = "PFClusters linked to muons" |
380 |
< |
//-------------------------------------------------------------------------------------------------- |
381 |
< |
bool recover_typeII_Photon( ControlFlags & ctrl, |
382 |
< |
EventData &ret, |
383 |
< |
Muon * mu, |
384 |
< |
const int muonIndex, |
385 |
< |
vector<SimpleLepton> &lepvec, |
386 |
< |
const Array<PFCandidate> * pfArr ) |
387 |
< |
//-------------------------------------------------------------------------------------------------- |
388 |
< |
{ |
389 |
< |
if( lepvec[muonIndex].fsrRecoveryAttempted ) return false; |
390 |
< |
|
391 |
< |
bool foundPF=false; |
392 |
< |
const PFCandidate * thepf; |
393 |
< |
for( int i=0; i<pfArr->GetEntries(); i++ ) { |
394 |
< |
if( !(PFnoPUflag[i])) continue; |
395 |
< |
const PFCandidate *pf = (PFCandidate*)((*pfArr)[i]); |
396 |
< |
if( abs(pf->PFType()) == PFCandidate::eMuon |
397 |
< |
&& (mu->TrackerTrk()==pf->TrackerTrk())) |
398 |
< |
{ |
399 |
< |
if(ctrl.debug) cout << " FSR :: t2, found pf muon, pt " << mu->Pt() << endl; |
400 |
< |
foundPF = true; |
401 |
< |
thepf = pf; |
402 |
< |
break; |
403 |
< |
} |
404 |
< |
} |
405 |
< |
|
406 |
< |
if( foundPF ) { |
407 |
< |
double sintet = thepf->Pt()/thepf->E(); |
408 |
< |
double phpt = thepf->EECal() * sintet; |
409 |
< |
if ( thepf->EECal() >= 2.0 && phpt >= 2.0 ) { |
410 |
< |
// don't update the muon object, just simplelepton |
411 |
< |
// mu->SetPtEtaPhi (mu->Pt()+phpt, |
412 |
< |
// mu->Eta(), |
413 |
< |
// mu->Phi()); |
414 |
< |
TLorentzVector pvec; |
415 |
< |
pvec.SetPtEtaPhiM( phpt,mu->Eta(),mu->Phi(),0.); |
416 |
< |
addPhoton(ret,pvec); |
417 |
< |
lepvec[muonIndex].vec += pvec; |
418 |
< |
if(ctrl.debug) cout << " FSR :: t2, new pt " << lepvec[muonIndex].vec.Pt() << endl; |
419 |
< |
lepvec[muonIndex].fsrRecoveryAttempted = true; |
420 |
< |
return true; |
421 |
< |
} |
171 |
> |
return pair<TLorentzVector,int>(TLorentzVector(0,0,0,0), -1); |
172 |
|
} |
173 |
|
|
174 |
< |
return false; |
174 |
> |
// add to the lepton |
175 |
> |
assert(pfBest); |
176 |
> |
TLorentzVector phvec; |
177 |
> |
phvec.SetPtEtaPhiM( pfBest->Pt(), pfBest->Eta(), pfBest->Phi(), 0); |
178 |
> |
return pair<TLorentzVector,int>(phvec, iPfOrig); |
179 |
|
} |