ATLAS Offline Software
Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
CaloSwEtaoff_v3::Builder Class Reference

Helper class for calculating the energy interpolation table. More...

Inheritance diagram for CaloSwEtaoff_v3::Builder:
Collaboration diagram for CaloSwEtaoff_v3::Builder:

Public Member Functions

 Builder (const CxxUtils::Array< 4 > &correction, const CxxUtils::Array< 2 > &regions, const CxxUtils::Array< 2 > &forms, float aeta, float u, int region_ndx)
 Constructor. More...
 
virtual float calculate (int energy_ndx, bool &good) const
 Calculate the correction for tabulated energy ENERGY_NDX. More...
 

Static Private Member Functions

static float calc0 (float aeta, float u, const CaloRec::Array< 2 > &coef)
 Evaluate the function Form 0. More...
 
static float calc3 (float aeta, float u, const CaloRec::Array< 2 > &coef)
 Evaluate the function Form 3. More...
 
static float calc4 (float aeta, float u, const CaloRec::Array< 2 > &coef)
 Evaluate the function Form 4. More...
 
static float calc5 (float aeta, float u, const CaloRec::Array< 2 > &coef)
 Evaluate the function Form 5. More...
 
static float calc10 (float aeta, float u, const CaloRec::Array< 2 > &coef)
 Evaluate the function Form 10. More...
 
static float calc11 (float aeta, float u, const CaloRec::Array< 2 > &coef)
 Evaluate the function Form 11. More...
 
static float calc13 (float aeta, float u, const CaloRec::Array< 2 > &coef, float xlo, float xhi)
 Evaluate the function Form 13. More...
 

Private Attributes

const CxxUtils::Array< 4 > & m_correction
 
const CxxUtils::Array< 2 > & m_regions
 Table of regions. More...
 
const CxxUtils::Array< 2 > & m_forms
 Functional form per region. More...
 
int m_region_ndx
 The index of the region in which we're evaluating the correction. More...
 
float m_aeta
 The abs(eta) at which the correction is being evaluated (in cal-local coordinates). More...
 
float m_u
 The fractional offset in the cell of this cluster. More...
 
int m_form
 The index of the functional form we're evaluating. More...
 

Detailed Description

Helper class for calculating the energy interpolation table.

Definition at line 172 of file CaloSwEtaoff_v3.h.

Constructor & Destructor Documentation

◆ Builder()

CaloSwEtaoff_v3::Builder::Builder ( const CxxUtils::Array< 4 > &  correction,
const CxxUtils::Array< 2 > &  regions,
const CxxUtils::Array< 2 > &  forms,
float  aeta,
float  u,
int  region_ndx 
)

Constructor.

Constructor for energy interpolation table helper class.

Gets correction information, the abs(eta) at which the correction is being evaluated (in cal-local coordinates), the fractional cell offset u, and the index of the region for this correction.

Parameters
correctionTabulated arrays of function parameters.
regionsTable of regions.
formsFunctional form per region.
aetaThe absolute value of \(\eta\) at which the correction is being evaluated (in cal-local coordinates).
uThe fractional offset of the cluster within the cell.
region_ndxThe index of the region within which the correction is being evaluated.

Definition at line 129 of file CaloSwEtaoff_v3.cxx.

136  m_regions (regions),
137  m_forms (forms),
138  m_region_ndx (region_ndx),
139  m_aeta (aeta),
140  m_u (u),
141  m_form (regions[region_ndx][REG_FORM])
142 {
143 }

Member Function Documentation

◆ calc0()

float CaloSwEtaoff_v3::Builder::calc0 ( float  aeta,
float  u,
const CaloRec::Array< 2 > &  coef 
)
staticprivate

Evaluate the function Form 0.

Evaluate the correction function for Form 0.

Parameters
aetaThe \(|\eta|\) of the cluster being corrected.
uThe fractional offset of the cluster within the cell.
coefArray of polynomial coefficients for each parameter.

Definition at line 268 of file CaloSwEtaoff_v3.cxx.

271 {
272  const unsigned int NPAR = 5;
273  double pars[NPAR];
274  poly_eval (aeta, coef, NPAR, pars);
275  double c = (u>=0) ? pars[2] : pars[3];
276  return pars[0] * (std::atan (pars[1] * u) + c*u + pars[4]);
277 }

◆ calc10()

float CaloSwEtaoff_v3::Builder::calc10 ( float  aeta,
float  u,
const CaloRec::Array< 2 > &  coef 
)
staticprivate

Evaluate the function Form 10.

Evaluate the correction function for Form 10.

Parameters
aetaThe \(|\eta|\) of the cluster being corrected.
uThe fractional offset of the cluster within the cell.
coefArray of polynomial coefficients for each parameter.

Definition at line 345 of file CaloSwEtaoff_v3.cxx.

348 {
349  const unsigned int NPAR = 7;
350  double pars[NPAR];
351  poly_eval (aeta, coef, NPAR, pars);
352  double c = pars[2];
353  if (u < 0)
354  c = -c - 2*std::atan(pars[1]);
355 
356  double offs = pars[0] * (atan (pars[1] * u) + c*u + pars[3]) +
357  pars[4] * std::cos (u * pars[5] * M_PI + pars[6]);
358  if (u > 0.9 || u < -0.9) {
359  double xdiff = pars[4] * (std::cos (pars[5] * M_PI + pars[6]) -
360  std::cos (- pars[5] * M_PI + pars[6]));
361  if (u > 0.9)
362  offs -= (u-0.9)*(1./0.1) * xdiff/2;
363  else
364  offs += (-0.9-u)*(1./0.1) * xdiff/2;
365  }
366  return offs;
367 }

◆ calc11()

float CaloSwEtaoff_v3::Builder::calc11 ( float  aeta,
float  u,
const CaloRec::Array< 2 > &  coef 
)
staticprivate

Evaluate the function Form 11.

Evaluate the correction function for Form 11.

Parameters
aetaThe \(|\eta|\) of the cluster being corrected.
uThe fractional offset of the cluster within the cell.
coefArray of polynomial coefficients for each parameter.

Definition at line 376 of file CaloSwEtaoff_v3.cxx.

379 {
380  const unsigned int NPAR = 8;
381  double pars[NPAR];
382  poly_eval (aeta, coef, NPAR, pars);
383  double c = (u>=0) ? pars[2] : pars[3];
384  return pars[0] * (std::atan (pars[1] * u) + c*u + pars[4])
385  + pars[5] * std::cos (u * pars[6] * M_PI + pars[7]);
386 }

◆ calc13()

float CaloSwEtaoff_v3::Builder::calc13 ( float  aeta,
float  u,
const CaloRec::Array< 2 > &  coef,
float  xlo,
float  xhi 
)
staticprivate

Evaluate the function Form 13.

Evaluate the correction function for Form 5.

Parameters
aetaThe \(|\eta|\) of the cluster being corrected.
uThe fractional offset of the cluster within the cell.
coefArray of polynomial coefficients for each parameter.

Definition at line 395 of file CaloSwEtaoff_v3.cxx.

400 {
401  const unsigned int NPAR = 1;
402  double pars[NPAR];
403  float x = (aeta - xlo) / (xhi - xlo) ;
404  poly_eval (x, coef, NPAR, pars);
405  return pars[0];
406 }

◆ calc3()

float CaloSwEtaoff_v3::Builder::calc3 ( float  aeta,
float  u,
const CaloRec::Array< 2 > &  coef 
)
staticprivate

Evaluate the function Form 3.

Evaluate the correction function for Form 3.

Parameters
aetaThe \(|\eta|\) of the cluster being corrected.
uThe fractional offset of the cluster within the cell.
coefArray of polynomial coefficients for each parameter.

Definition at line 286 of file CaloSwEtaoff_v3.cxx.

289 {
290  const unsigned int NPAR = 4;
291  double pars[NPAR];
292  poly_eval (aeta, coef, NPAR, pars);
293  double c = pars[2];
294  if (u < 0)
295  c = -c - 2*std::atan(pars[1]);
296  return pars[0] * (std::atan (pars[1] * u) + c*u + pars[3]);
297 }

◆ calc4()

float CaloSwEtaoff_v3::Builder::calc4 ( float  aeta,
float  u,
const CaloRec::Array< 2 > &  coef 
)
staticprivate

Evaluate the function Form 4.

Evaluate the correction function for Form 4.

Parameters
aetaThe \(|\eta|\) of the cluster being corrected.
uThe fractional offset of the cluster within the cell.
coefArray of polynomial coefficients for each parameter.

Definition at line 306 of file CaloSwEtaoff_v3.cxx.

309 {
310  const unsigned int NPAR = 3;
311  double pars[NPAR];
312  poly_eval (aeta, coef, NPAR, pars);
313  double b = std::max ((double)pars[1], 1e-5);
314  double atanb = std::atan(b);
315  double sq = std::sqrt (b/atanb - 1);
316  double den = (sq/b*atanb - std::atan(sq));
317  return pars[0]* ((- std::atan (b*u) + u*atanb) / den +
318  pars[2]*(1-std::abs(u)));
319 }

◆ calc5()

float CaloSwEtaoff_v3::Builder::calc5 ( float  aeta,
float  u,
const CaloRec::Array< 2 > &  coef 
)
staticprivate

Evaluate the function Form 5.

Evaluate the correction function for Form 4.

Parameters
aetaThe \(|\eta|\) of the cluster being corrected.
uThe fractional offset of the cluster within the cell.
coefArray of polynomial coefficients for each parameter.

Definition at line 328 of file CaloSwEtaoff_v3.cxx.

331 {
332  const unsigned int NPAR = 1;
333  double pars[NPAR];
334  poly_eval (aeta, coef, NPAR, pars);
335  return pars[0];
336 }

◆ calculate()

float CaloSwEtaoff_v3::Builder::calculate ( int  energy_ndx,
bool &  good 
) const
virtual

Calculate the correction for tabulated energy ENERGY_NDX.

Calculate the correction for one tabulated energy index.

Parameters
energy_ndxThe tabulated energy index for which the correction should be calculated.
good[out]Set to true if the calculation succeeded.

Definition at line 152 of file CaloSwEtaoff_v3.cxx.

153 {
154  // Find the proper array of coefficients.
156 
157  // If we don't have coefficients for this energy/region, skip it.
158  if (coef[0].end()[-1] == 0) {
159  good = false;
160  return 0;
161  }
162 
163  // Which functional form to use?
164  int form;
165  if (m_forms.size() != 0 && m_forms.size(1) != 0)
166  form = m_forms[m_region_ndx][energy_ndx];
167  else
168  form = m_form;
169 
170  // Evaluate the correction!
171  good = true;
172  float ret = 0;
173 
174  // Required just for case 13
175  float xlo=0 ;
176  float xhi=0 ;
177  unsigned int reg_n = m_regions.size();
178 
179  switch (form) {
180  case 0:
181  ret = calc0 (m_aeta, m_u, coef);
182  break;
183  case 3:
184  ret = calc3 (m_aeta, m_u, coef);
185  break;
186  case 4:
187  ret = calc4 (m_aeta, m_u, coef);
188  break;
189  case 5:
190  ret = calc5 (m_aeta, m_u, coef);
191  break;
192  case 10:
193  ret = calc10 (m_aeta, m_u, coef);
194  break;
195  case 11:
196  ret = calc11 (m_aeta, m_u, coef);
197  break;
198  case 13:
199 
200  for (unsigned int i=0; i < reg_n; i++) {
201  if (m_aeta >= m_regions[i][REG_LO] && m_aeta < m_regions[i][REG_HI])
202  {
203  xlo = m_regions[i][REG_LO] ;
204  xhi = m_regions[i][REG_HI] ;
205  }
206  }
207 
208  ret = calc13 (m_aeta, m_u, coef, xlo, xhi);
209  break;
210  default:
211  abort();
212  }
213 
214  // Protection against correction blowing up due to numerical
215  // problems in calculating the polynomial interpolation.
216  if (fabs(ret) > 0.025) {
217  ret = 0;
218  good = false;
219  }
220 
221  return ret;
222 }

Member Data Documentation

◆ m_aeta

float CaloSwEtaoff_v3::Builder::m_aeta
private

The abs(eta) at which the correction is being evaluated (in cal-local coordinates).

Definition at line 227 of file CaloSwEtaoff_v3.h.

◆ m_correction

const CxxUtils::Array<4>& CaloSwEtaoff_v3::Builder::m_correction
private

Definition at line 214 of file CaloSwEtaoff_v3.h.

◆ m_form

int CaloSwEtaoff_v3::Builder::m_form
private

The index of the functional form we're evaluating.

Definition at line 233 of file CaloSwEtaoff_v3.h.

◆ m_forms

const CxxUtils::Array<2>& CaloSwEtaoff_v3::Builder::m_forms
private

Functional form per region.

Definition at line 220 of file CaloSwEtaoff_v3.h.

◆ m_region_ndx

int CaloSwEtaoff_v3::Builder::m_region_ndx
private

The index of the region in which we're evaluating the correction.

Definition at line 223 of file CaloSwEtaoff_v3.h.

◆ m_regions

const CxxUtils::Array<2>& CaloSwEtaoff_v3::Builder::m_regions
private

Table of regions.

Definition at line 217 of file CaloSwEtaoff_v3.h.

◆ m_u

float CaloSwEtaoff_v3::Builder::m_u
private

The fractional offset in the cell of this cluster.

Definition at line 230 of file CaloSwEtaoff_v3.h.


The documentation for this class was generated from the following files:
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
CaloSwEtaoff_v3::Builder::calc4
static float calc4(float aeta, float u, const CaloRec::Array< 2 > &coef)
Evaluate the function Form 4.
Definition: CaloSwEtaoff_v3.cxx:306
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
CaloSwEtaoff_v3::REG_LO
@ REG_LO
Definition: CaloSwEtaoff_v3.h:268
CxxUtils::Array::size
unsigned int size(unsigned int dim=0) const
Return the size of the array along one dimension.
M_PI
#define M_PI
Definition: ActiveFraction.h:11
CaloSwEtaoff_v3::Builder::calc13
static float calc13(float aeta, float u, const CaloRec::Array< 2 > &coef, float xlo, float xhi)
Evaluate the function Form 13.
Definition: CaloSwEtaoff_v3.cxx:395
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
CaloSwEtaoff_v3::Builder::calc11
static float calc11(float aeta, float u, const CaloRec::Array< 2 > &coef)
Evaluate the function Form 11.
Definition: CaloSwEtaoff_v3.cxx:376
x
#define x
CaloSwEtaoff_v3::Builder::calc0
static float calc0(float aeta, float u, const CaloRec::Array< 2 > &coef)
Evaluate the function Form 0.
Definition: CaloSwEtaoff_v3.cxx:268
CaloSwEtaoff_v3::REG_FORM
@ REG_FORM
Definition: CaloSwEtaoff_v3.h:270
CaloSwEtaoff_v3::Builder::m_correction
const CxxUtils::Array< 4 > & m_correction
Definition: CaloSwEtaoff_v3.h:214
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
CaloSwEtaoff_v3::Builder::m_u
float m_u
The fractional offset in the cell of this cluster.
Definition: CaloSwEtaoff_v3.h:230
tools.zlumi_mc_cf.correction
def correction(mu, runmode, campaign, run=None)
Definition: zlumi_mc_cf.py:4
CaloSwEtaoff_v3::Builder::calc3
static float calc3(float aeta, float u, const CaloRec::Array< 2 > &coef)
Evaluate the function Form 3.
Definition: CaloSwEtaoff_v3.cxx:286
WritePulseShapeToCool.xhi
xhi
Definition: WritePulseShapeToCool.py:152
CaloSwEtaoff_v3::REG_HI
@ REG_HI
Definition: CaloSwEtaoff_v3.h:269
lumiFormat.i
int i
Definition: lumiFormat.py:85
CaloSwEtaoff_v3::Builder::m_regions
const CxxUtils::Array< 2 > & m_regions
Table of regions.
Definition: CaloSwEtaoff_v3.h:217
CaloSwEtaoff_v3::Builder::m_aeta
float m_aeta
The abs(eta) at which the correction is being evaluated (in cal-local coordinates).
Definition: CaloSwEtaoff_v3.h:227
CaloSwEtaoff_v3::Builder::calc5
static float calc5(float aeta, float u, const CaloRec::Array< 2 > &coef)
Evaluate the function Form 5.
Definition: CaloSwEtaoff_v3.cxx:328
sq
#define sq(x)
Definition: CurvedSegmentFinder.cxx:6
CxxUtils::Array
Read-only multidimensional array.
Definition: Control/CxxUtils/CxxUtils/Array.h:138
WritePulseShapeToCool.xlo
xlo
Definition: WritePulseShapeToCool.py:133
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
ReadBchFromCool.good
good
Definition: ReadBchFromCool.py:433
CaloSwEtaoff_v3::Builder::calc10
static float calc10(float aeta, float u, const CaloRec::Array< 2 > &coef)
Evaluate the function Form 10.
Definition: CaloSwEtaoff_v3.cxx:345
CaloSwEtaoff_v3::Builder::m_region_ndx
int m_region_ndx
The index of the region in which we're evaluating the correction.
Definition: CaloSwEtaoff_v3.h:223
python.compressB64.c
def c
Definition: compressB64.py:93
CaloSwEtaoff_v3::Builder::m_forms
const CxxUtils::Array< 2 > & m_forms
Functional form per region.
Definition: CaloSwEtaoff_v3.h:220
WriteCalibToCool.coef
coef
Definition: WriteCalibToCool.py:582
CaloSwEtaoff_v3::Builder::m_form
int m_form
The index of the functional form we're evaluating.
Definition: CaloSwEtaoff_v3.h:233