5#ifndef JETCALIBTOOLS_PURESIDUAL3DCORRECTION_H
6#define JETCALIBTOOLS_PURESIDUAL3DCORRECTION_H
43 pt_ref = pt_ref - areaCorr - calibration3D;
64 int muNPVbin = std::as_const(
m_ref3DHisto)->FindBin(mu, NPV);
76 return p0+p1*pt+p2*log(pt);
95 const std::string ¶m3D_name =
"param3D",
96 const std::string ¶mDelta_name =
"paramDeltaPt",
97 const std::string &etaBins_name =
"etaBins"
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());
105 TList *param3D_p0 = (TList*) param3D_l->At(0);
107 TList *param3D_p1 = (TList*) param3D_l->At(1);
110 TList *param3D_p2 =
nullptr;
112 param3D_p2 = (TList*) param3D_l->At(2);
116 for(
size_t i=0 ; i<(etaBins_v->size()-1); i++){
128 TList* paramDelta_l = (TList*) tmpF->Get(paramDelta_name.c_str());
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();
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;
162 float x0 = xax->GetBinCenter(xi);
163 float y0 = yax->GetBinCenter(yi);
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;
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;}
234 if ( (p0<= -999.9) || (p1<=-999.9) )
return 0;
238 if ( p2<=-999.9 )
return 0;
239 return p0+p1*log(pt-p2);
251 if ( (p0<= -999.9) || (p1<=-999.9) )
return 0;
255 if ( p2<=-999.9 )
return 0;
256 return p0+p1*log(pt-p2);
Scalar eta() const
pseudorapidity method
float deltaPtCorrection(float pt, float eta) const
IMPORTANT : the pt must be given in GeV.
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
std::unique_ptr< TAxis > m_etaBins
std::unique_ptr< TH1F > m_Dptp0_vs_eta
std::vector< std::unique_ptr< TH2D > > m_3Dp0_vs_muNPV
float correctedPt(float pt, float eta, float area, float rho, float mu, int NPV) const
Main function which returns the corrected pT.
float correction3D_interp(float pt, float eta, float mu, int NPV) const
float correction3D(float pt, float eta, float mu, int NPV) const
calculate the mu,NPV dependent part of the correction.
void setupClosestNonEmptyBins()
std::vector< std::unique_ptr< TH2D > > m_3Dp2_vs_muNPV
std::vector< std::unique_ptr< TH2D > > m_3Dp1_vs_muNPV
void loadParameters(const std::string &fileName, const std::string ¶m3D_name="param3D", const std::string ¶mDelta_name="paramDeltaPt", const std::string &etaBins_name="etaBins")
Loads the calib constants from histograms in TFile named fileName.
std::vector< std::vector< int > > m_closestNonEmpty
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) ...
std::unique_ptr< TH1F > m_Dptp1_vs_eta