ATLAS Offline Software
Loading...
Searching...
No Matches
PUCorrection::PU3DCorrectionHelper Struct Reference

#include <PUResidual3DCorrection.h>

Collaboration diagram for PUCorrection::PU3DCorrectionHelper:

Public Member Functions

 ~PU3DCorrectionHelper ()
float correctedPt (float pt, float eta, float area, float rho, float mu, int NPV) const
 Main function which returns the corrected pT.
float correctionFactor (float pt, float eta, float area, float rho, float mu, int NPV) const
 same as above but returns the ration pT_corrected/pT_uncorrected
float correction3D (float pt, float eta, float mu, int NPV) const
 calculate the mu,NPV dependent part of the correction.
float deltaPtCorrection (float pt, float eta) const
 IMPORTANT : the pt must be given in GeV.
void loadParameters (const std::string &fileName, const std::string &param3D_name="param3D", const std::string &paramDelta_name="paramDeltaPt", const std::string &etaBins_name="etaBins")
 Loads the calib constants from histograms in TFile named fileName.
void setupClosestNonEmptyBins ()
float correction3D_noextrap (float pt, float eta, float mu, int NPV) const
 calculate the mu,NPV dependent part of the correction (this is only used for tests and validation)
IMPORTANT : the pt must be given in GeV
float correction3D_interp (float pt, float eta, float mu, int NPV) const

Public Attributes

std::unique_ptr< TAxis > m_etaBins
std::vector< std::unique_ptr< TH2D > > m_3Dp0_vs_muNPV
std::vector< std::unique_ptr< TH2D > > m_3Dp1_vs_muNPV
std::vector< std::unique_ptr< TH2D > > m_3Dp2_vs_muNPV
TH2D * m_ref3DHisto = nullptr
bool m_use3Dp2 =true
std::unique_ptr< TH1F > m_Dptp0_vs_eta =nullptr
std::unique_ptr< TH1F > m_Dptp1_vs_eta =nullptr
float m_maxPt =170.0
float m_rhoEnergyScale = 0.001
float m_pTEnergyScale = 0.001
bool m_applyDeltaPtTerm = true
std::vector< std::vector< int > > m_closestNonEmpty

Detailed Description

Definition at line 28 of file PUResidual3DCorrection.h.

Constructor & Destructor Documentation

◆ ~PU3DCorrectionHelper()

PUCorrection::PU3DCorrectionHelper::~PU3DCorrectionHelper ( )
inline

Definition at line 30 of file PUResidual3DCorrection.h.

30 {
31
32 }

Member Function Documentation

◆ correctedPt()

float PUCorrection::PU3DCorrectionHelper::correctedPt ( float pt,
float eta,
float area,
float rho,
float mu,
int NPV ) const
inline

Main function which returns the corrected pT.

Definition at line 35 of file PUResidual3DCorrection.h.

35 {
36 float areaCorr = area*rho*m_rhoEnergyScale;
37
38 float pt_ref = pt*m_pTEnergyScale ;
39 float calibration3D = correction3D(pt_ref - areaCorr ,
40 eta,
41 mu,
42 NPV);
43 pt_ref = pt_ref - areaCorr - calibration3D;
44 float deltaPt = 0.0;
46 deltaPt = deltaPtCorrection( pt_ref, eta );
47 }
48
49 return (pt*m_pTEnergyScale -areaCorr - calibration3D + deltaPt)/m_pTEnergyScale;
50 }
Scalar eta() const
pseudorapidity method
double area(double R)
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure deltaPt
float deltaPtCorrection(float pt, float eta) const
IMPORTANT : the pt must be given in GeV.
float correction3D(float pt, float eta, float mu, int NPV) const
calculate the mu,NPV dependent part of the correction.

◆ correction3D()

float PUCorrection::PU3DCorrectionHelper::correction3D ( float pt,
float eta,
float mu,
int NPV ) const
inline

calculate the mu,NPV dependent part of the correction.

IMPORTANT : the pt must be given in GeV

Definition at line 62 of file PUResidual3DCorrection.h.

62 {
63 pt = pt < 1 ? 1 : pt;
64 int muNPVbin = std::as_const(m_ref3DHisto)->FindBin(mu, NPV);
65 int etaBin = m_etaBins->FindFixBin(std::abs(eta)) - 1;
66 float t0 = m_3Dp0_vs_muNPV[ etaBin ]->GetBinContent(muNPVbin);
67 if(t0 <= -999.9) {
68 muNPVbin = m_closestNonEmpty[etaBin][muNPVbin];
69 }
70
71 float p0 = m_3Dp0_vs_muNPV[ etaBin ]->GetBinContent(muNPVbin);
72 float p1 = m_3Dp1_vs_muNPV[ etaBin ]->GetBinContent(muNPVbin);
73
74 if(m_use3Dp2) {
75 float p2= m_3Dp2_vs_muNPV[ etaBin ]->GetBinContent(muNPVbin) ;
76 return p0+p1*pt+p2*log(pt);
77 }
78 return p0+p1*pt;
79 }
static Double_t t0
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin
std::vector< std::unique_ptr< TH2D > > m_3Dp0_vs_muNPV
std::vector< std::unique_ptr< TH2D > > m_3Dp2_vs_muNPV
std::vector< std::unique_ptr< TH2D > > m_3Dp1_vs_muNPV
std::vector< std::vector< int > > m_closestNonEmpty

◆ correction3D_interp()

float PUCorrection::PU3DCorrectionHelper::correction3D_interp ( float pt,
float eta,
float mu,
int NPV ) const
inline

Definition at line 246 of file PUResidual3DCorrection.h.

246 {
247 int etaBin = m_etaBins->FindFixBin(std::abs(eta)) - 1;
248 float p0 = m_3Dp0_vs_muNPV[ etaBin ]->Interpolate(mu, NPV);
249 float p1 = m_3Dp1_vs_muNPV[ etaBin ]->Interpolate(mu,NPV);
250
251 if ( (p0<= -999.9) || (p1<=-999.9) ) return 0;
252
253 if(m_use3Dp2) {
254 float p2= m_3Dp2_vs_muNPV[ etaBin ]->Interpolate(mu,NPV) ;
255 if ( p2<=-999.9 ) return 0;
256 return p0+p1*log(pt-p2);
257 }
258 return p0+p1*pt;
259 }

◆ correction3D_noextrap()

float PUCorrection::PU3DCorrectionHelper::correction3D_noextrap ( float pt,
float eta,
float mu,
int NPV ) const
inline

calculate the mu,NPV dependent part of the correction (this is only used for tests and validation)
IMPORTANT : the pt must be given in GeV

Definition at line 227 of file PUResidual3DCorrection.h.

227 {
228 int muNPVbin = m_ref3DHisto->FindBin(mu, NPV);
229 int etaBin = m_etaBins->FindFixBin(std::abs(eta)) - 1;
230 float p0 = m_3Dp0_vs_muNPV[ etaBin ]->GetBinContent(muNPVbin);
231 float p1 = m_3Dp1_vs_muNPV[ etaBin ]->GetBinContent(muNPVbin);
232
233
234 if ( (p0<= -999.9) || (p1<=-999.9) ) return 0;
235
236 if(m_use3Dp2) {
237 float p2= m_3Dp2_vs_muNPV[ etaBin ]->GetBinContent(muNPVbin) ;
238 if ( p2<=-999.9 ) return 0;
239 return p0+p1*log(pt-p2);
240 }
241 return p0+p1*pt;
242 }

◆ correctionFactor()

float PUCorrection::PU3DCorrectionHelper::correctionFactor ( float pt,
float eta,
float area,
float rho,
float mu,
int NPV ) const
inline

same as above but returns the ration pT_corrected/pT_uncorrected

Definition at line 53 of file PUResidual3DCorrection.h.

53 {
54 float ptCorr = correctedPt(pt,eta,area,rho,mu,NPV);
55 return ptCorr/pt;
56 }
float correctedPt(float pt, float eta, float area, float rho, float mu, int NPV) const
Main function which returns the corrected pT.

◆ deltaPtCorrection()

float PUCorrection::PU3DCorrectionHelper::deltaPtCorrection ( float pt,
float eta ) const
inline

IMPORTANT : the pt must be given in GeV.

Definition at line 84 of file PUResidual3DCorrection.h.

84 {
85 int etabin = m_Dptp0_vs_eta->FindBin(std::abs(eta)) ;
86 float p0 = m_Dptp0_vs_eta->GetBinContent(etabin);
87 float p1 = m_Dptp1_vs_eta->GetBinContent(etabin);
88 return p0+pt*p1;
89 }

◆ loadParameters()

void PUCorrection::PU3DCorrectionHelper::loadParameters ( const std::string & fileName,
const std::string & param3D_name = "param3D",
const std::string & paramDelta_name = "paramDeltaPt",
const std::string & etaBins_name = "etaBins" )
inline

Loads the calib constants from histograms in TFile named fileName.

Definition at line 94 of file PUResidual3DCorrection.h.

98 {
99 std::unique_ptr<TFile> tmpF(TFile::Open( fileName.c_str() ));
100 std::vector<float> * etaBins_v = (std::vector<float>*)tmpF->Get(etaBins_name.c_str());
101 std::vector<double> tmp(etaBins_v->begin(), etaBins_v->end() );
102 m_etaBins.reset( new TAxis( tmp.size()-1, tmp.data() ) );
103 TList *param3D_l = (TList*) tmpF->Get(param3D_name.c_str());
104
105 TList *param3D_p0 = (TList*) param3D_l->At(0);
106 m_3Dp0_vs_muNPV.resize( param3D_p0->GetSize() );
107 TList *param3D_p1 = (TList*) param3D_l->At(1);
108 m_3Dp1_vs_muNPV.resize( param3D_p1->GetSize() );
109
110 TList *param3D_p2 = nullptr;
111 if(m_use3Dp2) {
112 param3D_p2 = (TList*) param3D_l->At(2);
113 m_3Dp2_vs_muNPV.resize( param3D_p2->GetSize() );
114 }
115
116 for(size_t i=0 ; i<(etaBins_v->size()-1); i++){
117 m_3Dp0_vs_muNPV[i].reset((TH2D*)param3D_p0->At(i));
118 m_3Dp0_vs_muNPV[i]->SetDirectory(nullptr);
119 m_3Dp1_vs_muNPV[i].reset((TH2D*)param3D_p1->At(i));
120 m_3Dp1_vs_muNPV[i]->SetDirectory(nullptr);
121 if(m_use3Dp2) {
122 m_3Dp2_vs_muNPV[i].reset( (TH2D*)param3D_p2->At(i) );
123 m_3Dp2_vs_muNPV[i]->SetDirectory(nullptr);
124 }
125 }
126 m_ref3DHisto = m_3Dp0_vs_muNPV[0].get();
127
128 TList* paramDelta_l = (TList*) tmpF->Get(paramDelta_name.c_str());
129 m_Dptp0_vs_eta.reset( (TH1F*) paramDelta_l->At(0) );
130 m_Dptp0_vs_eta->SetDirectory(nullptr);
131 m_Dptp1_vs_eta.reset( (TH1F*) paramDelta_l->At(1) ) ;
132 m_Dptp1_vs_eta->SetDirectory(nullptr);
134 }

◆ setupClosestNonEmptyBins()

void PUCorrection::PU3DCorrectionHelper::setupClosestNonEmptyBins ( )
inline

Definition at line 138 of file PUResidual3DCorrection.h.

138 {
139 // Pre calculate the positions of the closest non empty bins
140
141 // we have a map (bin -> non-empty bin) for each eta slice :
142 m_closestNonEmpty.resize( m_3Dp0_vs_muNPV.size() );
143 for(size_t etabin=0; etabin< m_closestNonEmpty.size() ;etabin++ ){
144
145 TH2D *refHisto = m_3Dp0_vs_muNPV[etabin].get() ;
146 int nTot = refHisto->GetNcells();
147 TAxis * xax = refHisto->GetXaxis();
148 TAxis * yax = refHisto->GetYaxis();
149 float xscale = 1./(xax->GetXmax()-xax->GetXmin()); xscale *= xscale;
150 float yscale = 1./(yax->GetXmax()-yax->GetXmin()); yscale *= yscale;
151 int nbinX = xax->GetNbins();
152 int nbinY = yax->GetNbins();
153 // initialize the map with -1 :
154 m_closestNonEmpty[etabin].resize( nTot, -1 );
155
156 // loop over each bin
157 for(int xi=1;xi<nbinX+1;xi++) for(int yi=1;yi<nbinY+1;yi++) {
158 int bi = refHisto->GetBin(xi,yi);
159 if(refHisto->GetBinContent( bi ) >-999.) continue; // non empty bin, we don't need to find anything for it.
160
161 int clBin = -1;
162 float x0 = xax->GetBinCenter(xi);
163 float y0 = yax->GetBinCenter(yi);
164 float minDr2=1e10; // just pick a bigger value than any distance in the (mu,NPV) plan
165 // loop over other bins to find the closest non-empty :
166 for(int xj=1;xj<nbinX+1;xj++) for(int yj=1;yj<nbinY+1;yj++) {
167 int bj = refHisto->GetBin(xj,yj);
168 if(refHisto->GetBinContent( bj ) <=-999.) continue; // this is an empty bin
169 float x = xax->GetBinCenter(xj);
170 float y = yax->GetBinCenter(yj);
171 float dr2 = (x0-x)*(x0-x)*xscale+(y0-y)*(y0-y)*yscale;
172 if(dr2<minDr2){ minDr2 = dr2; clBin = bj;} // found a closest-bin candidate
173 }
174 m_closestNonEmpty[etabin][bi] = clBin;
175 }
176
177 }
178 }
#define y
#define x

Member Data Documentation

◆ m_3Dp0_vs_muNPV

std::vector<std::unique_ptr<TH2D> > PUCorrection::PU3DCorrectionHelper::m_3Dp0_vs_muNPV

Definition at line 187 of file PUResidual3DCorrection.h.

◆ m_3Dp1_vs_muNPV

std::vector<std::unique_ptr<TH2D> > PUCorrection::PU3DCorrectionHelper::m_3Dp1_vs_muNPV

Definition at line 188 of file PUResidual3DCorrection.h.

◆ m_3Dp2_vs_muNPV

std::vector<std::unique_ptr<TH2D> > PUCorrection::PU3DCorrectionHelper::m_3Dp2_vs_muNPV

Definition at line 189 of file PUResidual3DCorrection.h.

◆ m_applyDeltaPtTerm

bool PUCorrection::PU3DCorrectionHelper::m_applyDeltaPtTerm = true

Definition at line 203 of file PUResidual3DCorrection.h.

◆ m_closestNonEmpty

std::vector< std::vector<int> > PUCorrection::PU3DCorrectionHelper::m_closestNonEmpty

Definition at line 207 of file PUResidual3DCorrection.h.

◆ m_Dptp0_vs_eta

std::unique_ptr<TH1F> PUCorrection::PU3DCorrectionHelper::m_Dptp0_vs_eta =nullptr

Definition at line 194 of file PUResidual3DCorrection.h.

◆ m_Dptp1_vs_eta

std::unique_ptr<TH1F> PUCorrection::PU3DCorrectionHelper::m_Dptp1_vs_eta =nullptr

Definition at line 195 of file PUResidual3DCorrection.h.

◆ m_etaBins

std::unique_ptr<TAxis> PUCorrection::PU3DCorrectionHelper::m_etaBins

Definition at line 186 of file PUResidual3DCorrection.h.

◆ m_maxPt

float PUCorrection::PU3DCorrectionHelper::m_maxPt =170.0

Definition at line 199 of file PUResidual3DCorrection.h.

◆ m_pTEnergyScale

float PUCorrection::PU3DCorrectionHelper::m_pTEnergyScale = 0.001

Definition at line 201 of file PUResidual3DCorrection.h.

◆ m_ref3DHisto

TH2D* PUCorrection::PU3DCorrectionHelper::m_ref3DHisto = nullptr

Definition at line 190 of file PUResidual3DCorrection.h.

◆ m_rhoEnergyScale

float PUCorrection::PU3DCorrectionHelper::m_rhoEnergyScale = 0.001

Definition at line 200 of file PUResidual3DCorrection.h.

◆ m_use3Dp2

bool PUCorrection::PU3DCorrectionHelper::m_use3Dp2 =true

Definition at line 191 of file PUResidual3DCorrection.h.


The documentation for this struct was generated from the following file: