29 |
|
|
30 |
|
//-------------------------------------------------------------------------------------------------- |
31 |
|
Met RecoilTools::pfRecoil(Double_t iVisPt,Double_t iVisPhi,Double_t iVisSumEt, |
32 |
< |
const PFMet *iMet) { |
33 |
< |
Met lPFMet(iMet->Px(),iMet->Py()); |
34 |
< |
lPFMet.SetSumEt(iMet->SumEt()); |
32 |
> |
const PFCandidateCol *iCands) { |
33 |
> |
double lSumEt = 0; |
34 |
> |
FourVectorM lVec(0,0,0,0); |
35 |
> |
for(UInt_t i0 = 0; i0 < iCands->GetEntries(); i0++) { lVec -= iCands->At(i0)->Mom(); lSumEt += iCands->At(i0)->Et();} |
36 |
> |
Met lPFMet(lVec.Px(),lVec.Py()); |
37 |
> |
lPFMet.SetSumEt(lSumEt); |
38 |
|
lPFMet.SetMex (lPFMet.Mex()+iVisPt*cos(iVisPhi)); |
39 |
|
lPFMet.SetMey (lPFMet.Mey()+iVisPt*sin(iVisPhi)); |
40 |
|
lPFMet.SetSumEt(lPFMet.SumEt()-iVisSumEt); |
45 |
|
double trkMetx = 0; |
46 |
|
double trkMety = 0; |
47 |
|
double trkSumEt = 0; |
48 |
< |
for(UInt_t i=0; i<iCands->GetEntries(); ++i) { |
49 |
< |
const PFCandidate *pfcand = iCands->At(i); |
50 |
< |
if( (pfcand->HasTrackerTrk() && (fabs(pfcand->TrackerTrk()->DzCorrected(*iVertex))< iDZCut)) ) { |
51 |
< |
//(pfcand->HasGsfTrk() && (fabs(pfcand->GsfTrk()->DzCorrected(*iVertex)) < iDZCut)) ) { |
48 |
> |
for(UInt_t i0=0; i0<iCands->GetEntries(); i0++) { |
49 |
> |
const PFCandidate *pfcand = iCands->At(i0); |
50 |
> |
if( (pfcand->HasTrackerTrk() && (fabs(pfcand->TrackerTrk()->DzCorrected(*iVertex))< iDZCut)) || |
51 |
> |
(pfcand->HasGsfTrk() && (fabs(pfcand->GsfTrk()->DzCorrected(*iVertex)) < iDZCut)) ) { |
52 |
|
trkMetx -= pfcand->Px(); |
53 |
|
trkMety -= pfcand->Py(); |
54 |
|
trkSumEt += pfcand->Pt(); |
79 |
|
FourVectorM lVec(0,0,0,0); |
80 |
|
double lPt = fJetIDMVA->correctedPt(iJet,iJetCorrector,iPUEnergyDensity); |
81 |
|
if(iJet->RawMom().Pt() < 10) lPt = TMath::Max(iJet->RawMom().Pt()-iJet->JetArea()*iPUEnergyDensity->At(0)->Rho(),0.); |
82 |
< |
lPt *= (iJet->NeutralEmEnergy()/iJet->E() + iJet->NeutralHadronEnergy()/iJet->E()); |
82 |
> |
lPt *= (iJet->NeutralEmEnergy()/iJet->RawMom().E() + iJet->NeutralHadronEnergy()/iJet->RawMom().E()); |
83 |
|
lVec.SetPt(lPt); lVec.SetEta(iJet->Eta()); lVec.SetPhi(iJet->Phi()); lVec.SetM(iJet->Mass()); |
84 |
|
if(iSign > 0) iVec -= lVec; |
85 |
|
if(iSign < 0) iVec += lVec; |
91 |
|
|
92 |
|
//-------------------------------------------------------------------------------------------------- |
93 |
|
//Corrected Jets |
94 |
< |
void RecoilTools::addNeut(const PFJet *iJet,FourVectorM &iVec,Double_t &iSumEt,int iSign) { |
94 |
> |
void RecoilTools::addNeut(const PFJet *iJet,FourVectorM &iVec,Double_t &iSumEt,double iRho,int iSign) { |
95 |
|
FourVectorM lVec(0,0,0,0); |
96 |
|
double lPt = iJet->Pt(); |
97 |
< |
if(iJet->RawMom().Pt() < 10) lPt = iJet->RawMom().Pt()*iJet->L1OffsetCorrectionScale(); |
97 |
> |
if(iJet->RawMom().Pt() < 10) lPt = TMath::Max(iJet->RawMom().Pt()-iJet->JetArea()*iRho,0.);//to be fixed |
98 |
> |
//if(iJet->RawMom().Pt() < 10) lPt = iJet->RawMom().Pt()*iJet->L1OffsetCorrectionScale(); |
99 |
|
lPt *= (iJet->NeutralEmEnergy()/iJet->RawMom().E() + iJet->NeutralHadronEnergy()/iJet->RawMom().E()); |
100 |
|
lVec.SetPt(lPt); lVec.SetEta(iJet->Eta()); lVec.SetPhi(iJet->Phi()); lVec.SetM(iJet->Mass()); |
101 |
|
if(iSign > 0) iVec -= lVec; |
118 |
|
const Track* pTrack = pPF->TrackerTrk(); |
119 |
|
if(pPF->GsfTrk()) pTrack = pPF->GsfTrk(); |
120 |
|
if(pTrack == 0 ) continue; |
121 |
< |
if( !((pPF->HasTrackerTrk() && (fabs(pPF->TrackerTrk()->DzCorrected(*iVertex))<iDZCut)) || |
121 |
> |
lSumEt += pPF->Pt(); //=> another bug |
122 |
> |
if( !((pPF->HasTrackerTrk() && (fabs(pPF->TrackerTrk()->DzCorrected(*iVertex))<iDZCut)) || |
123 |
|
(pPF->HasGsfTrk() && (fabs(pPF->GsfTrk()->DzCorrected(*iVertex)) <iDZCut)))) continue; |
124 |
|
lVec -= pPF->Mom(); |
120 |
– |
lSumEt += pPF->Pt(); |
125 |
|
} |
126 |
|
int lNPass = 0; |
127 |
|
for(UInt_t i0 = 0; i0 < iJets->GetEntries(); i0++) { |
128 |
|
const PFJet *pJet = iJets->At(i0); |
129 |
|
if(!filter(pJet,iPhi1,iEta1,iPhi2,iEta2)) continue; //Quick cleaning==> if not done already |
130 |
+ |
if(fJetIDMVA->pass(pJet,iVertex,iVertices,iJetCorrector,iPileupEnergyDensity)) |
131 |
+ |
std::cout << " =====> Jet Passes Id : " << pJet->Pt() << " -- " << pJet->Eta() << " --- " << fJetIDMVA->pass(pJet,iVertex,iVertices,iJetCorrector,iPileupEnergyDensity) << std::endl; |
132 |
+ |
if(!fJetIDMVA->pass(pJet,iVertex,iVertices,iJetCorrector,iPileupEnergyDensity)) |
133 |
+ |
std::cout << " =====> Jet Fails Id : " << pJet->Pt() << " -- " << pJet->Eta() << " --- " << fJetIDMVA->pass(pJet,iVertex,iVertices,iJetCorrector,iPileupEnergyDensity) << std::endl; |
134 |
+ |
|
135 |
|
if(!fJetIDMVA->pass(pJet,iVertex,iVertices,iJetCorrector,iPileupEnergyDensity)) continue; |
136 |
|
addNeut(pJet,lVec,lSumEt,iJetCorrector,iPileupEnergyDensity); |
137 |
|
lNPass++; |
143 |
|
//-------------------------------------------------------------------------------------------------- |
144 |
|
//Corrected Jets |
145 |
|
Met RecoilTools::NoPUMet( const PFJetCol *iJets, |
146 |
< |
const PFCandidateCol *iCands,const Vertex *iVertex,const VertexCol *iVertices, |
146 |
> |
const PFCandidateCol *iCands,const Vertex *iVertex,const VertexCol *iVertices,Double_t iRho, |
147 |
|
Double_t iPhi1,Double_t iEta1,Double_t iPhi2,Double_t iEta2,Double_t iDZCut) { |
148 |
|
|
149 |
|
FourVectorM lVec (0,0,0,0); double lSumEt = 0; |
152 |
|
const Track* pTrack = pPF->TrackerTrk(); |
153 |
|
if(pPF->GsfTrk()) pTrack = pPF->GsfTrk(); |
154 |
|
if(pTrack == 0 ) continue; |
155 |
+ |
lSumEt += pPF->Pt(); //=> another bug |
156 |
|
if( !((pPF->HasTrackerTrk() && (fabs(pPF->TrackerTrk()->DzCorrected(*iVertex))<iDZCut)) || |
157 |
|
(pPF->HasGsfTrk() && (fabs(pPF->GsfTrk()->DzCorrected(*iVertex)) <iDZCut)))) continue; |
158 |
|
lVec -= pPF->Mom(); |
149 |
– |
lSumEt += pPF->Pt(); |
159 |
|
} |
160 |
|
for(UInt_t i0 = 0; i0 < iJets->GetEntries(); i0++) { |
161 |
|
const PFJet *pJet = iJets->At(i0); |
153 |
– |
if(!fJetIDMVA->pass(pJet,iVertex,iVertices)) continue; |
162 |
|
if(!filter(pJet,iPhi1,iEta1,iPhi2,iEta2)) continue; //Quick cleaning==> if not done already |
163 |
< |
addNeut(pJet,lVec,lSumEt); |
163 |
> |
if(fJetIDMVA->pass(pJet,iVertex,iVertices)) |
164 |
> |
std::cout << " =====> Jet Passes Id : " << pJet->Pt() << " -- " << pJet->Eta() << " --- " << fJetIDMVA->pass(pJet,iVertex,iVertices) << std::endl; |
165 |
> |
if(!fJetIDMVA->pass(pJet,iVertex,iVertices)) |
166 |
> |
std::cout << " =====> Jet Fails Id : " << pJet->Pt() << " -- " << pJet->Eta() << " --- " << fJetIDMVA->pass(pJet,iVertex,iVertices) << std::endl; |
167 |
> |
if(!fJetIDMVA->pass(pJet,iVertex,iVertices)) continue; |
168 |
> |
addNeut(pJet,lVec,lSumEt,iRho); |
169 |
|
} |
170 |
|
Met lMet(lVec.Px(),lVec.Py()); |
171 |
|
lMet.SetSumEt(lSumEt); |
190 |
|
//Corrected Jets |
191 |
|
Met RecoilTools::NoPURecoil(Double_t iVisPt,Double_t iVisPhi,Double_t iVisSumEt, |
192 |
|
const PFJetCol *iJets,const PFCandidateCol *iCands, |
193 |
< |
const Vertex *iVertex,const VertexCol *iVertices, |
193 |
> |
const Vertex *iVertex,const VertexCol *iVertices,Double_t iRho, |
194 |
|
Double_t iPhi1,Double_t iEta1,Double_t iPhi2,Double_t iEta2, |
195 |
|
Double_t iDZCut) { |
196 |
|
|
197 |
< |
Met lNoPUMet = NoPUMet(iJets,iCands,iVertex,iVertices,iPhi1,iEta1,iPhi2,iEta2,iDZCut); |
197 |
> |
Met lNoPUMet = NoPUMet(iJets,iCands,iVertex,iVertices,iRho,iPhi1,iEta1,iPhi2,iEta2,iDZCut); |
198 |
|
lNoPUMet.SetMex (lNoPUMet.Mex()+iVisPt*cos(iVisPhi)); |
199 |
|
lNoPUMet.SetMey (lNoPUMet.Mey()+iVisPt*sin(iVisPhi)); |
200 |
|
lNoPUMet.SetSumEt(lNoPUMet.SumEt()-iVisSumEt); |
239 |
|
//-------------------------------------------------------------------------------------------------- |
240 |
|
//Corrected jets |
241 |
|
Met RecoilTools::PUCMet( const PFJetCol *iJets,const PFCandidateCol *iCands, |
242 |
< |
const Vertex *iVertex,const VertexCol *iVertices, |
242 |
> |
const Vertex *iVertex,const VertexCol *iVertices,Double_t iRho, |
243 |
|
Double_t iPhi1,Double_t iEta1,Double_t iPhi2,Double_t iEta2, |
244 |
|
Double_t iDZCut) { |
245 |
|
|
265 |
|
if(!JetTools::passPFLooseId(pJet)) continue; |
266 |
|
if(fJetIDMVA->pass(pJet,iVertex,iVertices)) continue; |
267 |
|
if(!filter(pJet,iPhi1,iEta1,iPhi2,iEta2)) continue; //Quick cleaning==> if not done already |
268 |
< |
addNeut(pJet,lVec,lSumEt,-1); |
268 |
> |
addNeut(pJet,lVec,lSumEt,iRho,-1); |
269 |
|
} |
270 |
|
Met lMet(lVec.Px(),lVec.Py()); |
271 |
|
lMet.SetSumEt(lSumEt); |
291 |
|
Met RecoilTools::PUCRecoil(Double_t iVisPt,Double_t iVisPhi,Double_t iVisSumEt, |
292 |
|
const PFJetCol *iJets, |
293 |
|
const PFCandidateCol *iCands,const Vertex *iVertex, |
294 |
< |
const VertexCol *iVertices, |
294 |
> |
const VertexCol *iVertices,Double_t iRho, |
295 |
|
Double_t iPhi1,Double_t iEta1,Double_t iPhi2,Double_t iEta2, |
296 |
|
Double_t iDZCut) { |
297 |
< |
Met lPUCMet = PUCMet(iJets,iCands,iVertex,iVertices,iPhi1,iEta1,iPhi2,iEta2,iDZCut); |
297 |
> |
Met lPUCMet = PUCMet(iJets,iCands,iVertex,iVertices,iRho,iPhi1,iEta1,iPhi2,iEta2,iDZCut); |
298 |
|
lPUCMet.SetMex (lPUCMet.Mex()+iVisPt*cos(iVisPhi)); |
299 |
|
lPUCMet.SetMey (lPUCMet.Mey()+iVisPt*sin(iVisPhi)); |
300 |
|
lPUCMet.SetSumEt(lPUCMet.SumEt()-iVisSumEt); |
333 |
|
//-------------------------------------------------------------------------------------------------- |
334 |
|
//Corrected Jets |
335 |
|
Met RecoilTools::PUMet( const PFJetCol *iJets, |
336 |
< |
const PFCandidateCol *iCands,const Vertex *iVertex,const VertexCol *iVertices, |
336 |
> |
const PFCandidateCol *iCands,const Vertex *iVertex,const VertexCol *iVertices,Double_t iRho, |
337 |
|
Double_t iPhi1,Double_t iEta1,Double_t iPhi2,Double_t iEta2, |
338 |
|
Double_t iDZCut) { |
339 |
|
|
353 |
|
if(!JetTools::passPFLooseId(pJet)) continue; |
354 |
|
if(!filter(pJet,iPhi1,iEta1,iPhi2,iEta2)) continue; //Quick cleaning |
355 |
|
if(fJetIDMVA->pass(pJet,iVertex,iVertices)) continue; |
356 |
< |
addNeut(pJet,lVec,lSumEt); |
356 |
> |
addNeut(pJet,lVec,lSumEt,iRho); |
357 |
|
} |
358 |
|
Met lMet(lVec.Px(),lVec.Py()); |
359 |
|
lMet.SetSumEt(lSumEt); |
377 |
|
//Corrected Jets |
378 |
|
Met RecoilTools::PURecoil(Double_t iVisPt,Double_t iVisPhi,Double_t iVisSumEt, |
379 |
|
const PFJetCol *iJets, |
380 |
< |
const PFCandidateCol *iCands,const Vertex *iVertex,const VertexCol *iVertices, |
380 |
> |
const PFCandidateCol *iCands,const Vertex *iVertex,const VertexCol *iVertices,Double_t iRho, |
381 |
|
Double_t iPhi1,Double_t iEta1,Double_t iPhi2,Double_t iEta2, |
382 |
|
Double_t iDZCut) { |
383 |
< |
Met lPUMet = PUMet(iJets,iCands,iVertex,iVertices,iPhi1,iEta1,iPhi2,iEta2,iDZCut); |
383 |
> |
Met lPUMet = PUMet(iJets,iCands,iVertex,iVertices,iRho,iPhi1,iEta1,iPhi2,iEta2,iDZCut); |
384 |
|
lPUMet.SetMex (lPUMet.Mex()+iVisPt*cos(iVisPhi)); |
385 |
|
lPUMet.SetMey (lPUMet.Mey()+iVisPt*sin(iVisPhi)); |
386 |
|
lPUMet.SetSumEt(lPUMet.SumEt()-iVisSumEt); |