6 |
|
|
7 |
|
using namespace mithep; |
8 |
|
|
9 |
< |
RecoilTools::RecoilTools(TString iJetLowPtMVAFile,TString iJetHighPtMVAFile,TString iCutFile) { |
9 |
> |
RecoilTools::RecoilTools(TString iJetLowPtMVAFile,TString iJetHighPtMVAFile,TString iCutFile,bool i42) { |
10 |
|
fJetIDMVA = new JetIDMVA(); |
11 |
< |
fJetIDMVA->Initialize( JetIDMVA::kLoose,iJetLowPtMVAFile,iJetHighPtMVAFile,JetIDMVA::kBaseline,iCutFile); |
11 |
> |
fJetIDMVA->Initialize( JetIDMVA::kMET,iJetLowPtMVAFile,iJetHighPtMVAFile,JetIDMVA::kBaseline,iCutFile); |
12 |
> |
f42 = i42; |
13 |
|
} |
14 |
|
//-------------------------------------------------------------------------------------------------- |
15 |
|
RecoilTools::~RecoilTools() { |
27 |
|
if(pDR2 < 0.5) return false; |
28 |
|
return true; |
29 |
|
} |
30 |
< |
|
30 |
> |
//-------------------------------------------------------------------------------------------------- |
31 |
> |
bool RecoilTools::filter(const PFCandidate *iCand,Double_t iPhi1,Double_t iEta1,Double_t iPhi2,Double_t iEta2) { |
32 |
> |
double pDEta1 = iCand->Eta() - iEta1; |
33 |
> |
double pDPhi1 = fabs(iCand->Phi() - iPhi1); if(pDPhi1 > 2.*TMath::Pi()-pDPhi1) pDPhi1 = 2.*TMath::Pi()-pDPhi1; |
34 |
> |
double pDR1 = sqrt(pDEta1*pDEta1 + pDPhi1*pDPhi1); |
35 |
> |
if(pDR1 < 0.3) return false; |
36 |
> |
double pDEta2 = iCand->Eta() - iEta2; |
37 |
> |
double pDPhi2 = fabs(iCand->Phi() - iPhi2); if(pDPhi2 > 2.*TMath::Pi()-pDPhi2) pDPhi2 = 2.*TMath::Pi()-pDPhi2; |
38 |
> |
double pDR2 = sqrt(pDEta2*pDEta2 + pDPhi2*pDPhi2); |
39 |
> |
if(pDR2 < 0.3) return false; |
40 |
> |
return true; |
41 |
> |
} |
42 |
|
//-------------------------------------------------------------------------------------------------- |
43 |
|
Met RecoilTools::pfRecoil(Double_t iVisPt,Double_t iVisPhi,Double_t iVisSumEt, |
44 |
< |
const PFMet *iMet) { |
45 |
< |
Met lPFMet(iMet->Px(),iMet->Py()); |
46 |
< |
lPFMet.SetSumEt(iMet->SumEt()); |
44 |
> |
const PFCandidateCol *iCands) { |
45 |
> |
double lSumEt = 0; |
46 |
> |
FourVectorM lVec(0,0,0,0); |
47 |
> |
for(UInt_t i0 = 0; i0 < iCands->GetEntries(); i0++) { |
48 |
> |
lVec -= iCands->At(i0)->Mom(); |
49 |
> |
lSumEt += iCands->At(i0)->Pt(); |
50 |
> |
} |
51 |
> |
Met lPFMet(lVec.Px(),lVec.Py()); |
52 |
> |
lPFMet.SetSumEt(lSumEt); |
53 |
|
lPFMet.SetMex (lPFMet.Mex()+iVisPt*cos(iVisPhi)); |
54 |
|
lPFMet.SetMey (lPFMet.Mey()+iVisPt*sin(iVisPhi)); |
55 |
|
lPFMet.SetSumEt(lPFMet.SumEt()-iVisSumEt); |
56 |
|
return lPFMet; |
57 |
|
} |
58 |
|
//-------------------------------------------------------------------------------------------------- |
59 |
+ |
Met RecoilTools::pfRecoil(double iPhi1,double iEta1,double iPhi2,double iEta2, |
60 |
+ |
const PFCandidateCol *iCands) { |
61 |
+ |
double lSumEt = 0; |
62 |
+ |
FourVectorM lVec(0,0,0,0); |
63 |
+ |
for(UInt_t i0 = 0; i0 < iCands->GetEntries(); i0++) { |
64 |
+ |
const PFCandidate *pfcand = iCands->At(i0); |
65 |
+ |
if(!filter(pfcand,iPhi1,iEta1,iPhi2,iEta2)) continue; |
66 |
+ |
lVec -= pfcand->Mom(); |
67 |
+ |
lSumEt += pfcand->Pt(); |
68 |
+ |
} |
69 |
+ |
Met lPFMet(lVec.Px(),lVec.Py()); |
70 |
+ |
lPFMet.SetSumEt(lSumEt); |
71 |
+ |
return lPFMet; |
72 |
+ |
|
73 |
+ |
} |
74 |
+ |
//-------------------------------------------------------------------------------------------------- |
75 |
+ |
void RecoilTools::addType1(FourVectorM &iVec,Double_t &iSumEt, |
76 |
+ |
const PFJetCol *iJets,FactorizedJetCorrector *iJetCorrector,const PileupEnergyDensityCol *iPUEnergyDensity, |
77 |
+ |
double iPhi1,double iEta1,double iPhi2,double iEta2) { |
78 |
+ |
for(UInt_t i0 = 0; i0 < iJets->GetEntries(); i0++) { |
79 |
+ |
const PFJet *pJet = iJets->At(i0); |
80 |
+ |
if(!JetTools::passPFLooseId(pJet)) continue; |
81 |
+ |
if(!filter(pJet,iPhi1,iEta1,iPhi2,iEta2)) continue; |
82 |
+ |
if(fJetIDMVA->correctedPt(pJet,iJetCorrector,iPUEnergyDensity) < 10) continue; |
83 |
+ |
double lPt = fJetIDMVA->correctedPt(pJet,iJetCorrector,iPUEnergyDensity,RhoUtilities::DEFAULT,100); |
84 |
+ |
FourVectorM pVec(0,0,0,0); |
85 |
+ |
pVec.SetPt(lPt); pVec.SetEta(pJet->Eta()); pVec.SetPhi(pJet->Phi()); pVec.SetM(pJet->Mass()); |
86 |
+ |
iVec -= pVec; |
87 |
+ |
iSumEt += pVec.Pt(); |
88 |
+ |
} |
89 |
+ |
} |
90 |
+ |
//-------------------------------------------------------------------------------------------------- |
91 |
+ |
Met RecoilTools::pfRecoilType1(Double_t iVisPt,Double_t iVisPhi,Double_t iVisSumEt, |
92 |
+ |
const PFCandidateCol *iCands,const PFJetCol *iJets, |
93 |
+ |
FactorizedJetCorrector *iJetCorrector,const PileupEnergyDensityCol *iPUEnergyDensity, |
94 |
+ |
double iPhi1,double iEta1,double iPhi2,double iEta2) { |
95 |
+ |
double lSumEt = 0; |
96 |
+ |
FourVectorM lVec(0,0,0,0); |
97 |
+ |
for(UInt_t i0 = 0; i0 < iCands->GetEntries(); i0++) { |
98 |
+ |
lVec -= iCands->At(i0)->Mom(); |
99 |
+ |
lSumEt += iCands->At(i0)->Pt(); |
100 |
+ |
} |
101 |
+ |
addType1(lVec,lSumEt,iJets,iJetCorrector,iPUEnergyDensity,iPhi1,iEta1,iPhi2,iEta2); |
102 |
+ |
Met lPFMet(lVec.Px(),lVec.Py()); |
103 |
+ |
lPFMet.SetSumEt(lSumEt); |
104 |
+ |
lPFMet.SetMex (lPFMet.Mex()+iVisPt*cos(iVisPhi)); |
105 |
+ |
lPFMet.SetMey (lPFMet.Mey()+iVisPt*sin(iVisPhi)); |
106 |
+ |
lPFMet.SetSumEt(lPFMet.SumEt()-iVisSumEt); |
107 |
+ |
return lPFMet; |
108 |
+ |
} |
109 |
+ |
//-------------------------------------------------------------------------------------------------- |
110 |
+ |
Met RecoilTools::pfCone(double iPhi1,double iEta1, |
111 |
+ |
const PFCandidateCol *iCands) { |
112 |
+ |
double lSumEt = 0; |
113 |
+ |
FourVectorM lVec(0,0,0,0); |
114 |
+ |
for(UInt_t i0 = 0; i0 < iCands->GetEntries(); i0++) { |
115 |
+ |
const PFCandidate *pfcand = iCands->At(i0); |
116 |
+ |
if(filter(pfcand,iPhi1,iEta1,100,100)) continue; |
117 |
+ |
lVec += pfcand->Mom(); |
118 |
+ |
lSumEt += pfcand->Pt(); |
119 |
+ |
} |
120 |
+ |
Met lPFMet(lVec.Px(),lVec.Py()); |
121 |
+ |
lPFMet.SetSumEt(lSumEt); |
122 |
+ |
return lPFMet; |
123 |
+ |
} |
124 |
+ |
//-------------------------------------------------------------------------------------------------- |
125 |
|
Met RecoilTools::trackMet(const PFCandidateCol *iCands,const Vertex *iVertex,Double_t iDZCut) { |
126 |
|
double trkMetx = 0; |
127 |
|
double trkMety = 0; |
128 |
|
double trkSumEt = 0; |
129 |
< |
for(UInt_t i=0; i<iCands->GetEntries(); ++i) { |
130 |
< |
const PFCandidate *pfcand = iCands->At(i); |
129 |
> |
for(UInt_t i0=0; i0<iCands->GetEntries(); i0++) { |
130 |
> |
const PFCandidate *pfcand = iCands->At(i0); |
131 |
> |
double lDZ = -999; |
132 |
> |
if(pfcand->HasTrackerTrk()) lDZ = fabs(pfcand->TrackerTrk()->DzCorrected(*iVertex));// |
133 |
> |
else if(pfcand->HasGsfTrk()) lDZ = fabs(pfcand->GsfTrk() ->DzCorrected(*iVertex)); |
134 |
> |
if( fabs(lDZ) > iDZCut) continue; |
135 |
> |
trkMetx -= pfcand->Px(); |
136 |
> |
trkMety -= pfcand->Py(); |
137 |
> |
trkSumEt += pfcand->Pt(); |
138 |
> |
} |
139 |
> |
Met lMet(trkMetx,trkMety); |
140 |
> |
lMet.SetSumEt(trkSumEt); |
141 |
> |
return lMet; |
142 |
> |
} |
143 |
> |
//-------------------------------------------------------------------------------------------------- |
144 |
> |
Met RecoilTools::trackRecoil(double iPhi1,double iEta1,double iPhi2,double iEta2,const PFCandidateCol *iCands,const Vertex *iVertex,Double_t iDZCut) { |
145 |
> |
double trkMetx = 0; |
146 |
> |
double trkMety = 0; |
147 |
> |
double trkSumEt = 0; |
148 |
> |
for(UInt_t i0=0; i0<iCands->GetEntries(); i0++) { |
149 |
> |
const PFCandidate *pfcand = iCands->At(i0); |
150 |
> |
if(!filter(pfcand,iPhi1,iEta1,iPhi2,iEta2)) continue; |
151 |
|
if( (pfcand->HasTrackerTrk() && (fabs(pfcand->TrackerTrk()->DzCorrected(*iVertex))< iDZCut)) || |
152 |
< |
(pfcand->HasGsfTrk() && (fabs(pfcand->GsfTrk()->DzCorrected(*iVertex)) < iDZCut)) ) { |
152 |
> |
(pfcand->HasGsfTrk() && (fabs(pfcand->GsfTrk()->DzCorrected(*iVertex)) < iDZCut)) ) { |
153 |
|
trkMetx -= pfcand->Px(); |
154 |
|
trkMety -= pfcand->Py(); |
155 |
|
trkSumEt += pfcand->Pt(); |
159 |
|
lMet.SetSumEt(trkSumEt); |
160 |
|
return lMet; |
161 |
|
} |
58 |
– |
|
162 |
|
//-------------------------------------------------------------------------------------------------- |
163 |
|
//Compute the recoil => here this requires the vector sum of the visible components |
164 |
|
//VisPt => Vector sum pT of the visible non-recoiling components |
177 |
|
FactorizedJetCorrector *iJetCorrector,const PileupEnergyDensityCol *iPUEnergyDensity, |
178 |
|
int iSign) { |
179 |
|
FourVectorM lVec(0,0,0,0); |
180 |
< |
double lPt = fJetIDMVA->correctedPt(iJet,iJetCorrector,iPUEnergyDensity); |
181 |
< |
lPt *= (iJet->NeutralEmEnergy()/iJet->E() + iJet->NeutralHadronEnergy()/iJet->E()); |
180 |
> |
double lPt = fJetIDMVA->correctedPt(iJet,iJetCorrector,iPUEnergyDensity); |
181 |
> |
double lFrac = (iJet->NeutralEmEnergy()/iJet->RawMom().E() + iJet->NeutralHadronEnergy()/iJet->RawMom().E()); |
182 |
> |
if(fabs(iJet->Eta()) > 2.5 && !f42) lFrac = 1.; |
183 |
> |
lPt *= lFrac; |
184 |
|
lVec.SetPt(lPt); lVec.SetEta(iJet->Eta()); lVec.SetPhi(iJet->Phi()); lVec.SetM(iJet->Mass()); |
185 |
|
if(iSign > 0) iVec -= lVec; |
186 |
|
if(iSign < 0) iVec += lVec; |
187 |
< |
iSumEt += lPt; |
187 |
> |
//iSumEt += lPt; |
188 |
|
//=== Above was a bug in the training |
189 |
< |
//if(iSign > 0) iSumEt += lPt; |
190 |
< |
//if(iSign < 0) iSumEt -= lPt; |
189 |
> |
if(iSign > 0) iSumEt += lPt; |
190 |
> |
if(iSign < 0) iSumEt -= lPt; |
191 |
|
} |
192 |
|
|
193 |
|
//-------------------------------------------------------------------------------------------------- |
194 |
|
//Corrected Jets |
195 |
< |
void RecoilTools::addNeut(const PFJet *iJet,FourVectorM &iVec,Double_t &iSumEt,int iSign) { |
195 |
> |
void RecoilTools::addNeut(const PFJet *iJet,FourVectorM &iVec,Double_t &iSumEt,double iRho,int iSign) { |
196 |
|
FourVectorM lVec(0,0,0,0); |
197 |
|
double lPt = iJet->Pt(); |
198 |
< |
lPt *= (iJet->NeutralEmEnergy()/iJet->E() + iJet->NeutralHadronEnergy()/iJet->E()); |
198 |
> |
//if(iJet->RawMom().Pt() < 10) lPt = TMath::Max(iJet->RawMom().Pt()-iJet->JetArea()*iRho,0.);//to be fixed |
199 |
> |
//if(iJet->RawMom().Pt() < 10) lPt = iJet->RawMom().Pt()*iJet->L1OffsetCorrectionScale(); |
200 |
> |
lPt *= (iJet->NeutralEmEnergy()/iJet->RawMom().E() + iJet->NeutralHadronEnergy()/iJet->RawMom().E()); |
201 |
|
lVec.SetPt(lPt); lVec.SetEta(iJet->Eta()); lVec.SetPhi(iJet->Phi()); lVec.SetM(iJet->Mass()); |
202 |
|
if(iSign > 0) iVec -= lVec; |
203 |
|
if(iSign < 0) iVec += lVec; |
204 |
< |
iSumEt += lPt; |
204 |
> |
//iSumEt += lPt; |
205 |
|
//=== Above was a bug in the training |
206 |
< |
//if(iSign > 0) iSumEt += lPt; |
207 |
< |
//if(iSign < 0) iSumEt -= lPt; |
206 |
> |
if(iSign > 0) iSumEt += lPt; |
207 |
> |
if(iSign < 0) iSumEt -= lPt; |
208 |
|
} |
209 |
|
|
210 |
|
//-------------------------------------------------------------------------------------------------- |
216 |
|
FourVectorM lVec (0,0,0,0); double lSumEt = 0; |
217 |
|
for(UInt_t i0 = 0; i0 < iCands->GetEntries(); i0++) { |
218 |
|
const PFCandidate *pPF = iCands->At(i0); |
219 |
< |
const Track* pTrack = pPF->TrackerTrk(); |
220 |
< |
if(pPF->GsfTrk()) pTrack = pPF->GsfTrk(); |
221 |
< |
if(pTrack == 0 ) continue; |
222 |
< |
if( !((pPF->HasTrackerTrk() && (fabs(pPF->TrackerTrk()->DzCorrected(*iVertex))<iDZCut)) || |
223 |
< |
(pPF->HasGsfTrk() && (fabs(pPF->GsfTrk()->DzCorrected(*iVertex)) <iDZCut)))) continue; |
219 |
> |
double lDZ = 999; |
220 |
> |
if(pPF->HasTrackerTrk()) lDZ = fabs(pPF->TrackerTrk()->DzCorrected(*iVertex));// |
221 |
> |
else if(pPF->HasGsfTrk()) lDZ = fabs(pPF->GsfTrk() ->DzCorrected(*iVertex)); |
222 |
> |
if( fabs(lDZ) > iDZCut) continue; |
223 |
> |
lSumEt += pPF->Pt(); |
224 |
|
lVec -= pPF->Mom(); |
118 |
– |
lSumEt += pPF->Pt(); |
225 |
|
} |
226 |
|
int lNPass = 0; |
227 |
|
for(UInt_t i0 = 0; i0 < iJets->GetEntries(); i0++) { |
228 |
|
const PFJet *pJet = iJets->At(i0); |
229 |
< |
if(!filter(pJet,iPhi1,iEta1,iPhi2,iEta2)) continue; //Quick cleaning==> if not done already |
229 |
> |
if(!JetTools::passPFLooseId(pJet)) continue; |
230 |
> |
if(!filter(pJet,iPhi1,iEta1,iPhi2,iEta2)) continue; |
231 |
> |
if(!fJetIDMVA->passPt(pJet,iJetCorrector,iPileupEnergyDensity)) continue; |
232 |
|
if(!fJetIDMVA->pass(pJet,iVertex,iVertices,iJetCorrector,iPileupEnergyDensity)) continue; |
233 |
+ |
double pDPhi1 = fabs(pJet->Phi() - iPhi1); if(pDPhi1 > 2.*TMath::Pi()-pDPhi1) pDPhi1 = 2.*TMath::Pi()-pDPhi1; |
234 |
+ |
double pDPhi2 = fabs(pJet->Phi() - iPhi2); if(pDPhi2 > 2.*TMath::Pi()-pDPhi2) pDPhi2 = 2.*TMath::Pi()-pDPhi2; |
235 |
|
addNeut(pJet,lVec,lSumEt,iJetCorrector,iPileupEnergyDensity); |
236 |
|
lNPass++; |
237 |
|
} |
239 |
|
lMet.SetSumEt( lSumEt); |
240 |
|
return lMet; |
241 |
|
} |
242 |
< |
//-------------------------------------------------------------------------------------------------- |
242 |
> |
//------------------------------------------------------------------------------------------------- |
243 |
|
//Corrected Jets |
244 |
|
Met RecoilTools::NoPUMet( const PFJetCol *iJets, |
245 |
< |
const PFCandidateCol *iCands,const Vertex *iVertex,const VertexCol *iVertices, |
245 |
> |
const PFCandidateCol *iCands,const Vertex *iVertex,const VertexCol *iVertices,Double_t iRho, |
246 |
|
Double_t iPhi1,Double_t iEta1,Double_t iPhi2,Double_t iEta2,Double_t iDZCut) { |
247 |
|
|
248 |
|
FourVectorM lVec (0,0,0,0); double lSumEt = 0; |
249 |
|
for(UInt_t i0 = 0; i0 < iCands->GetEntries(); i0++) { |
250 |
|
const PFCandidate *pPF = iCands->At(i0); |
251 |
< |
const Track* pTrack = pPF->TrackerTrk(); |
252 |
< |
if(pPF->GsfTrk()) pTrack = pPF->GsfTrk(); |
253 |
< |
if(pTrack == 0 ) continue; |
254 |
< |
if( !((pPF->HasTrackerTrk() && (fabs(pPF->TrackerTrk()->DzCorrected(*iVertex))<iDZCut)) || |
145 |
< |
(pPF->HasGsfTrk() && (fabs(pPF->GsfTrk()->DzCorrected(*iVertex)) <iDZCut)))) continue; |
251 |
> |
double lDZ = 999; |
252 |
> |
if(pPF->HasTrackerTrk()) lDZ = fabs(pPF->TrackerTrk()->DzCorrected(*iVertex));// |
253 |
> |
else if(pPF->HasGsfTrk()) lDZ = fabs(pPF->GsfTrk() ->DzCorrected(*iVertex)); |
254 |
> |
if( fabs(lDZ) > iDZCut) continue; |
255 |
|
lVec -= pPF->Mom(); |
256 |
< |
lSumEt += pPF->Pt(); |
256 |
> |
lSumEt += pPF->Pt(); |
257 |
|
} |
258 |
|
for(UInt_t i0 = 0; i0 < iJets->GetEntries(); i0++) { |
259 |
|
const PFJet *pJet = iJets->At(i0); |
260 |
+ |
if(!filter(pJet,iPhi1,iEta1,iPhi2,iEta2)) continue; |
261 |
+ |
if(!fJetIDMVA->passPt(pJet)) continue; |
262 |
|
if(!fJetIDMVA->pass(pJet,iVertex,iVertices)) continue; |
263 |
< |
if(!filter(pJet,iPhi1,iEta1,iPhi2,iEta2)) continue; //Quick cleaning==> if not done already |
153 |
< |
addNeut(pJet,lVec,lSumEt); |
263 |
> |
addNeut(pJet,lVec,lSumEt,iRho); |
264 |
|
} |
265 |
|
Met lMet(lVec.Px(),lVec.Py()); |
266 |
|
lMet.SetSumEt(lSumEt); |
267 |
|
return lMet; |
268 |
|
} |
269 |
|
//-------------------------------------------------------------------------------------------------- |
270 |
+ |
Met RecoilTools::NoPURecoil(Double_t iPhi1,Double_t iEta1,Double_t iPhi2,Double_t iEta2, |
271 |
+ |
const PFJetCol *iJets, |
272 |
+ |
const PFCandidateCol *iCands , |
273 |
+ |
const Vertex *iVertex,const VertexCol *iVertices, |
274 |
+ |
FactorizedJetCorrector *iJetCorrector, |
275 |
+ |
const PileupEnergyDensityCol *iPileupEnergyDensity,Double_t iDZCut) { |
276 |
+ |
|
277 |
+ |
FourVectorM lVec (0,0,0,0); double lSumEt = 0; |
278 |
+ |
for(UInt_t i0 = 0; i0 < iCands->GetEntries(); i0++) { |
279 |
+ |
const PFCandidate *pPF = iCands->At(i0); |
280 |
+ |
if(!filter(pPF,iPhi1,iEta1,iPhi2,iEta2)) continue; |
281 |
+ |
double lDZ = 999; |
282 |
+ |
if(pPF->HasTrackerTrk()) lDZ = fabs(pPF->TrackerTrk()->DzCorrected(*iVertex));// |
283 |
+ |
else if(pPF->HasGsfTrk()) lDZ = fabs(pPF->GsfTrk() ->DzCorrected(*iVertex)); |
284 |
+ |
if( fabs(lDZ) > iDZCut) continue; |
285 |
+ |
lSumEt += pPF->Pt(); |
286 |
+ |
lVec -= pPF->Mom(); |
287 |
+ |
} |
288 |
+ |
int lNPass = 0; |
289 |
+ |
for(UInt_t i0 = 0; i0 < iJets->GetEntries(); i0++) { |
290 |
+ |
const PFJet *pJet = iJets->At(i0); |
291 |
+ |
if(!filter(pJet,iPhi1,iEta1,iPhi2,iEta2)) continue; |
292 |
+ |
if(!fJetIDMVA->passPt(pJet,iJetCorrector,iPileupEnergyDensity)) continue; |
293 |
+ |
if(iJetCorrector != 0 && iPileupEnergyDensity != 0) if(!fJetIDMVA->pass(pJet,iVertex,iVertices,iJetCorrector,iPileupEnergyDensity)) continue; |
294 |
+ |
if(iJetCorrector == 0 || iPileupEnergyDensity == 0) if(!fJetIDMVA->pass(pJet,iVertex,iVertices)) continue; |
295 |
+ |
if(iJetCorrector != 0 && iPileupEnergyDensity != 0) addNeut(pJet,lVec,lSumEt,iJetCorrector,iPileupEnergyDensity); |
296 |
+ |
if(iJetCorrector == 0 || iPileupEnergyDensity == 0) addNeut(pJet,lVec,lSumEt,1.); |
297 |
+ |
lNPass++; |
298 |
+ |
} |
299 |
+ |
Met lMet(lVec.Px(),lVec.Py()); |
300 |
+ |
lMet.SetSumEt( lSumEt); |
301 |
+ |
return lMet; |
302 |
+ |
} |
303 |
+ |
|
304 |
+ |
//-------------------------------------------------------------------------------------------------- |
305 |
|
Met RecoilTools::NoPURecoil(Double_t iVisPt,Double_t iVisPhi,Double_t iVisSumEt, |
306 |
|
const PFJetCol *iJets,FactorizedJetCorrector *iJetCorrector, |
307 |
|
const PileupEnergyDensityCol *iPileupEnergyDensity, |
320 |
|
//Corrected Jets |
321 |
|
Met RecoilTools::NoPURecoil(Double_t iVisPt,Double_t iVisPhi,Double_t iVisSumEt, |
322 |
|
const PFJetCol *iJets,const PFCandidateCol *iCands, |
323 |
< |
const Vertex *iVertex,const VertexCol *iVertices, |
323 |
> |
const Vertex *iVertex,const VertexCol *iVertices,Double_t iRho, |
324 |
|
Double_t iPhi1,Double_t iEta1,Double_t iPhi2,Double_t iEta2, |
325 |
|
Double_t iDZCut) { |
326 |
|
|
327 |
< |
Met lNoPUMet = NoPUMet(iJets,iCands,iVertex,iVertices,iPhi1,iEta1,iPhi2,iEta2,iDZCut); |
327 |
> |
Met lNoPUMet = NoPUMet(iJets,iCands,iVertex,iVertices,iRho,iPhi1,iEta1,iPhi2,iEta2,iDZCut); |
328 |
|
lNoPUMet.SetMex (lNoPUMet.Mex()+iVisPt*cos(iVisPhi)); |
329 |
|
lNoPUMet.SetMey (lNoPUMet.Mey()+iVisPt*sin(iVisPhi)); |
330 |
|
lNoPUMet.SetSumEt(lNoPUMet.SumEt()-iVisSumEt); |
350 |
|
pPF->PFType() == PFCandidate::eHadronHF )) |
351 |
|
{lVec -= pPF->Mom(); lSumEt += pPF->Pt();} |
352 |
|
if(pTrack == 0 ) continue; |
353 |
< |
if( !((pPF->HasTrackerTrk() && (fabs(pPF->TrackerTrk()->DzCorrected(*iVertex))<iDZCut)) || |
354 |
< |
(pPF->HasGsfTrk() && (fabs(pPF->GsfTrk()->DzCorrected(*iVertex)) <iDZCut)))) continue; |
353 |
> |
double lDZ = 999; |
354 |
> |
if(pPF->HasTrackerTrk()) lDZ = fabs(pPF->TrackerTrk()->DzCorrected(*iVertex));// |
355 |
> |
else if(pPF->HasGsfTrk()) lDZ = fabs(pPF->GsfTrk() ->DzCorrected(*iVertex)); |
356 |
> |
if( fabs(lDZ) > iDZCut) continue; |
357 |
|
lVec -= pPF->Mom(); |
358 |
|
lSumEt += pPF->Pt(); |
359 |
|
} |
360 |
|
for(UInt_t i0 = 0; i0 < iJets->GetEntries(); i0++) { |
361 |
|
const PFJet *pJet = iJets->At(i0); |
362 |
|
if(!JetTools::passPFLooseId(pJet)) continue; |
363 |
+ |
if(!fJetIDMVA->passPt(pJet,iJetCorrector,iPileupEnergyDensity)) continue; |
364 |
|
if(fJetIDMVA->pass(pJet,iVertex,iVertices,iJetCorrector,iPileupEnergyDensity)) continue; |
365 |
< |
if(!filter(pJet,iPhi1,iEta1,iPhi2,iEta2)) continue; //Quick cleaning==> if not done already |
365 |
> |
if(!filter(pJet,iPhi1,iEta1,iPhi2,iEta2)) continue; |
366 |
|
addNeut(pJet,lVec,lSumEt,iJetCorrector,iPileupEnergyDensity,-1); |
367 |
|
} |
368 |
|
Met lMet(lVec.Px(),lVec.Py()); |
372 |
|
//-------------------------------------------------------------------------------------------------- |
373 |
|
//Corrected jets |
374 |
|
Met RecoilTools::PUCMet( const PFJetCol *iJets,const PFCandidateCol *iCands, |
375 |
< |
const Vertex *iVertex,const VertexCol *iVertices, |
375 |
> |
const Vertex *iVertex,const VertexCol *iVertices,Double_t iRho, |
376 |
|
Double_t iPhi1,Double_t iEta1,Double_t iPhi2,Double_t iEta2, |
377 |
|
Double_t iDZCut) { |
378 |
|
|
388 |
|
pPF->PFType() == PFCandidate::eHadronHF )) |
389 |
|
{lVec -= pPF->Mom(); lSumEt += pPF->Pt();} |
390 |
|
if(pTrack == 0 ) continue; |
391 |
< |
if( !((pPF->HasTrackerTrk() && (fabs(pPF->TrackerTrk()->DzCorrected(*iVertex))<iDZCut)) || |
392 |
< |
(pPF->HasGsfTrk() && (fabs(pPF->GsfTrk()->DzCorrected(*iVertex)) <iDZCut)))) continue; |
391 |
> |
double lDZ = 999; |
392 |
> |
if(pPF->HasTrackerTrk()) lDZ = fabs(pPF->TrackerTrk()->DzCorrected(*iVertex));// |
393 |
> |
else if(pPF->HasGsfTrk()) lDZ = fabs(pPF->GsfTrk() ->DzCorrected(*iVertex)); |
394 |
> |
if( fabs(lDZ) > iDZCut) continue; |
395 |
|
lVec -= pPF->Mom(); |
396 |
|
lSumEt += pPF->Pt(); |
397 |
|
} |
398 |
|
for(UInt_t i0 = 0; i0 < iJets->GetEntries(); i0++) { |
399 |
|
const PFJet *pJet = iJets->At(i0); |
400 |
|
if(!JetTools::passPFLooseId(pJet)) continue; |
401 |
+ |
if(!fJetIDMVA->passPt(pJet)) continue; |
402 |
|
if(fJetIDMVA->pass(pJet,iVertex,iVertices)) continue; |
403 |
|
if(!filter(pJet,iPhi1,iEta1,iPhi2,iEta2)) continue; //Quick cleaning==> if not done already |
404 |
< |
addNeut(pJet,lVec,lSumEt,-1); |
404 |
> |
addNeut(pJet,lVec,lSumEt,iRho,-1); |
405 |
> |
} |
406 |
> |
Met lMet(lVec.Px(),lVec.Py()); |
407 |
> |
lMet.SetSumEt(lSumEt); |
408 |
> |
return lMet; |
409 |
> |
} |
410 |
> |
//-------------------------------------------------------------------------------------------------- |
411 |
> |
Met RecoilTools::PUCRecoil( Double_t iPhi1,Double_t iEta1,Double_t iPhi2,Double_t iEta2, |
412 |
> |
const PFJetCol *iJets, |
413 |
> |
const PFCandidateCol *iCands , |
414 |
> |
const Vertex *iVertex,const VertexCol *iVertices, |
415 |
> |
FactorizedJetCorrector *iJetCorrector, |
416 |
> |
const PileupEnergyDensityCol *iPileupEnergyDensity,Double_t iDZCut) { |
417 |
> |
|
418 |
> |
|
419 |
> |
FourVectorM lVec (0,0,0,0); double lSumEt = 0; |
420 |
> |
for(UInt_t i0 = 0; i0 < iCands->GetEntries(); i0++) { |
421 |
> |
const PFCandidate *pPF = iCands->At(i0); |
422 |
> |
if(!filter(pPF,iPhi1,iEta1,iPhi2,iEta2)) continue; |
423 |
> |
const Track* pTrack = pPF->TrackerTrk(); |
424 |
> |
if(pPF->GsfTrk()) pTrack = pPF->GsfTrk(); |
425 |
> |
if(pTrack == 0 && |
426 |
> |
(pPF->PFType() == PFCandidate::eGamma || |
427 |
> |
pPF->PFType() == PFCandidate::eEGammaHF || |
428 |
> |
pPF->PFType() == PFCandidate::eNeutralHadron || |
429 |
> |
pPF->PFType() == PFCandidate::eHadronHF )) |
430 |
> |
{lVec -= pPF->Mom(); lSumEt += pPF->Pt();} |
431 |
> |
if(pTrack == 0 ) continue; |
432 |
> |
double lDZ = 999; |
433 |
> |
if(pPF->HasTrackerTrk()) lDZ = fabs(pPF->TrackerTrk()->DzCorrected(*iVertex));// |
434 |
> |
else if(pPF->HasGsfTrk()) lDZ = fabs(pPF->GsfTrk() ->DzCorrected(*iVertex)); |
435 |
> |
if( fabs(lDZ) > iDZCut) continue; |
436 |
> |
lVec -= pPF->Mom(); |
437 |
> |
lSumEt += pPF->Pt(); |
438 |
> |
} |
439 |
> |
for(UInt_t i0 = 0; i0 < iJets->GetEntries(); i0++) { |
440 |
> |
const PFJet *pJet = iJets->At(i0); |
441 |
> |
if(!filter(pJet,iPhi1,iEta1,iPhi2,iEta2)) continue; //Quick cleaning==> if not done already |
442 |
> |
if(!fJetIDMVA->passPt(pJet,iJetCorrector,iPileupEnergyDensity)) continue; |
443 |
> |
if(!JetTools::passPFLooseId(pJet)) continue; |
444 |
> |
if(iJetCorrector != 0 && iPileupEnergyDensity != 0) if(fJetIDMVA->pass(pJet,iVertex,iVertices,iJetCorrector,iPileupEnergyDensity)) continue; |
445 |
> |
if(iJetCorrector == 0 || iPileupEnergyDensity == 0) if(fJetIDMVA->pass(pJet,iVertex,iVertices)) continue; |
446 |
> |
if(iJetCorrector != 0 && iPileupEnergyDensity != 0) addNeut(pJet,lVec,lSumEt,iJetCorrector,iPileupEnergyDensity,-1); |
447 |
> |
if(iJetCorrector == 0 || iPileupEnergyDensity == 0) addNeut(pJet,lVec,lSumEt,1,-1); |
448 |
|
} |
449 |
|
Met lMet(lVec.Px(),lVec.Py()); |
450 |
|
lMet.SetSumEt(lSumEt); |
470 |
|
Met RecoilTools::PUCRecoil(Double_t iVisPt,Double_t iVisPhi,Double_t iVisSumEt, |
471 |
|
const PFJetCol *iJets, |
472 |
|
const PFCandidateCol *iCands,const Vertex *iVertex, |
473 |
< |
const VertexCol *iVertices, |
473 |
> |
const VertexCol *iVertices,Double_t iRho, |
474 |
|
Double_t iPhi1,Double_t iEta1,Double_t iPhi2,Double_t iEta2, |
475 |
|
Double_t iDZCut) { |
476 |
< |
Met lPUCMet = PUCMet(iJets,iCands,iVertex,iVertices,iPhi1,iEta1,iPhi2,iEta2,iDZCut); |
476 |
> |
Met lPUCMet = PUCMet(iJets,iCands,iVertex,iVertices,iRho,iPhi1,iEta1,iPhi2,iEta2,iDZCut); |
477 |
|
lPUCMet.SetMex (lPUCMet.Mex()+iVisPt*cos(iVisPhi)); |
478 |
|
lPUCMet.SetMey (lPUCMet.Mey()+iVisPt*sin(iVisPhi)); |
479 |
|
lPUCMet.SetSumEt(lPUCMet.SumEt()-iVisSumEt); |
493 |
|
const Track* pTrack = pPF->TrackerTrk(); |
494 |
|
if(pPF->GsfTrk()) pTrack = pPF->GsfTrk(); |
495 |
|
if(pTrack == 0 ) continue; |
496 |
< |
if( ((pPF->HasTrackerTrk() && (fabs(pPF->TrackerTrk()->DzCorrected(*iVertex))<iDZCut)) || |
497 |
< |
(pPF->HasGsfTrk() && (fabs(pPF->GsfTrk()->DzCorrected(*iVertex)) <iDZCut)))) continue; |
496 |
> |
double lDZ = 999; |
497 |
> |
if(pPF->HasTrackerTrk()) lDZ = fabs(pPF->TrackerTrk()->DzCorrected(*iVertex));// |
498 |
> |
else if(pPF->HasGsfTrk()) lDZ = fabs(pPF->GsfTrk() ->DzCorrected(*iVertex)); |
499 |
> |
if( fabs(lDZ) < iDZCut) continue; |
500 |
|
lVec -= pPF->Mom(); |
501 |
|
lSumEt += pPF->Pt(); |
502 |
|
} |
503 |
|
for(UInt_t i0 = 0; i0 < iJets->GetEntries(); i0++) { |
504 |
|
const PFJet *pJet = iJets->At(i0); |
505 |
|
if(!JetTools::passPFLooseId(pJet)) continue; |
506 |
< |
if(!filter(pJet,iPhi1,iEta1,iPhi2,iEta2)) continue; //Quick cleaning |
506 |
> |
if(!fJetIDMVA->passPt(pJet,iJetCorrector,iPileupEnergyDensity)) continue; |
507 |
> |
if(!filter(pJet,iPhi1,iEta1,iPhi2,iEta2)) continue; |
508 |
|
if(fJetIDMVA->pass(pJet,iVertex,iVertices,iJetCorrector,iPileupEnergyDensity)) continue; |
509 |
|
addNeut(pJet,lVec,lSumEt,iJetCorrector,iPileupEnergyDensity); |
510 |
|
} |
515 |
|
//-------------------------------------------------------------------------------------------------- |
516 |
|
//Corrected Jets |
517 |
|
Met RecoilTools::PUMet( const PFJetCol *iJets, |
518 |
< |
const PFCandidateCol *iCands,const Vertex *iVertex,const VertexCol *iVertices, |
518 |
> |
const PFCandidateCol *iCands,const Vertex *iVertex,const VertexCol *iVertices,Double_t iRho, |
519 |
|
Double_t iPhi1,Double_t iEta1,Double_t iPhi2,Double_t iEta2, |
520 |
|
Double_t iDZCut) { |
521 |
|
|
525 |
|
const Track* pTrack = pPF->TrackerTrk(); |
526 |
|
if(pPF->GsfTrk()) pTrack = pPF->GsfTrk(); |
527 |
|
if(pTrack == 0 ) continue; |
528 |
< |
if( ((pPF->HasTrackerTrk() && (fabs(pPF->TrackerTrk()->DzCorrected(*iVertex))<iDZCut)) || |
529 |
< |
(pPF->HasGsfTrk() && (fabs(pPF->GsfTrk()->DzCorrected(*iVertex)) <iDZCut)))) continue; |
528 |
> |
double lDZ = 999; |
529 |
> |
if(pPF->HasTrackerTrk()) lDZ = fabs(pPF->TrackerTrk()->DzCorrected(*iVertex));// |
530 |
> |
else if(pPF->HasGsfTrk()) lDZ = fabs(pPF->GsfTrk() ->DzCorrected(*iVertex)); |
531 |
> |
if( fabs(lDZ) < iDZCut) continue; |
532 |
|
lVec -= pPF->Mom(); |
533 |
|
lSumEt += pPF->Pt(); |
534 |
|
} |
535 |
|
for(UInt_t i0 = 0; i0 < iJets->GetEntries(); i0++) { |
536 |
|
const PFJet *pJet = iJets->At(i0); |
537 |
|
if(!JetTools::passPFLooseId(pJet)) continue; |
538 |
+ |
if(!fJetIDMVA->passPt(pJet)) continue; |
539 |
|
if(!filter(pJet,iPhi1,iEta1,iPhi2,iEta2)) continue; //Quick cleaning |
540 |
|
if(fJetIDMVA->pass(pJet,iVertex,iVertices)) continue; |
541 |
< |
addNeut(pJet,lVec,lSumEt); |
541 |
> |
addNeut(pJet,lVec,lSumEt,iRho); |
542 |
> |
} |
543 |
> |
Met lMet(lVec.Px(),lVec.Py()); |
544 |
> |
lMet.SetSumEt(lSumEt); |
545 |
> |
return lMet; |
546 |
> |
} |
547 |
> |
//-------------------------------------------------------------------------------------------------- |
548 |
> |
Met RecoilTools::PUMet( Double_t iPhi1,Double_t iEta1,Double_t iPhi2,Double_t iEta2, |
549 |
> |
const PFJetCol *iJets, |
550 |
> |
const PFCandidateCol *iCands , |
551 |
> |
const Vertex *iVertex,const VertexCol *iVertices, |
552 |
> |
FactorizedJetCorrector *iJetCorrector, |
553 |
> |
const PileupEnergyDensityCol *iPileupEnergyDensity,Double_t iDZCut) { |
554 |
> |
|
555 |
> |
FourVectorM lVec (0,0,0,0); double lSumEt = 0; |
556 |
> |
for(UInt_t i0 = 0; i0 < iCands->GetEntries(); i0++) { |
557 |
> |
const PFCandidate *pPF = iCands->At(i0); |
558 |
> |
if(!filter(pPF,iPhi1,iEta1,iPhi2,iEta2)) continue; |
559 |
> |
const Track* pTrack = pPF->TrackerTrk(); |
560 |
> |
if(pPF->GsfTrk()) pTrack = pPF->GsfTrk(); |
561 |
> |
if(pTrack == 0 ) continue; |
562 |
> |
double lDZ = 999; |
563 |
> |
if(pPF->HasTrackerTrk()) lDZ = fabs(pPF->TrackerTrk()->DzCorrected(*iVertex));// |
564 |
> |
else if(pPF->HasGsfTrk()) lDZ = fabs(pPF->GsfTrk() ->DzCorrected(*iVertex)); |
565 |
> |
if( fabs(lDZ) < iDZCut) continue; |
566 |
> |
lVec -= pPF->Mom(); |
567 |
> |
lSumEt += pPF->Pt(); |
568 |
> |
} |
569 |
> |
for(UInt_t i0 = 0; i0 < iJets->GetEntries(); i0++) { |
570 |
> |
const PFJet *pJet = iJets->At(i0); |
571 |
> |
if(!JetTools::passPFLooseId(pJet)) continue; |
572 |
> |
if(!fJetIDMVA->passPt(pJet,iJetCorrector,iPileupEnergyDensity)) continue; |
573 |
> |
if(!filter(pJet,iPhi1,iEta1,iPhi2,iEta2)) continue; //Quick cleaning |
574 |
> |
if(fJetIDMVA->pass(pJet,iVertex,iVertices,iJetCorrector,iPileupEnergyDensity)) continue; |
575 |
> |
addNeut(pJet,lVec,lSumEt,iJetCorrector,iPileupEnergyDensity); |
576 |
|
} |
577 |
|
Met lMet(lVec.Px(),lVec.Py()); |
578 |
|
lMet.SetSumEt(lSumEt); |
596 |
|
//Corrected Jets |
597 |
|
Met RecoilTools::PURecoil(Double_t iVisPt,Double_t iVisPhi,Double_t iVisSumEt, |
598 |
|
const PFJetCol *iJets, |
599 |
< |
const PFCandidateCol *iCands,const Vertex *iVertex,const VertexCol *iVertices, |
599 |
> |
const PFCandidateCol *iCands,const Vertex *iVertex,const VertexCol *iVertices,Double_t iRho, |
600 |
|
Double_t iPhi1,Double_t iEta1,Double_t iPhi2,Double_t iEta2, |
601 |
|
Double_t iDZCut) { |
602 |
< |
Met lPUMet = PUMet(iJets,iCands,iVertex,iVertices,iPhi1,iEta1,iPhi2,iEta2,iDZCut); |
602 |
> |
Met lPUMet = PUMet(iJets,iCands,iVertex,iVertices,iRho,iPhi1,iEta1,iPhi2,iEta2,iDZCut); |
603 |
|
lPUMet.SetMex (lPUMet.Mex()+iVisPt*cos(iVisPhi)); |
604 |
|
lPUMet.SetMey (lPUMet.Mey()+iVisPt*sin(iVisPhi)); |
605 |
|
lPUMet.SetSumEt(lPUMet.SumEt()-iVisSumEt); |