8#include "CaloDetDescr/CaloDetDescrElement.h"
18 CHECK(base_class::initialize());
20 return StatusCode::SUCCESS;
27 return StatusCode::SUCCESS;
34 const void *arg)
const{
50 << clus->
energy(CaloSampling::PreSamplerB) );
52 << clus->
energy(CaloSampling::EMB1) );
54 << clus->
energy(CaloSampling::EMB2) );
56 << clus->
energy(CaloSampling::EMB3) );
58 << clus->
energy(CaloSampling::PreSamplerE) );
60 << clus->
energy(CaloSampling::EME1) );
62 << clus->
energy(CaloSampling::EME2) );
64 << clus->
energy(CaloSampling::EME3) );
68 ATH_MSG_DEBUG(
"[GOOD]: seedCell location and selected eta range agree" );
71 ATH_MSG_DEBUG(
"[BAD]: seedCell location and selected eta range disagree !!" );
80 double elt_eta = caloDDE->
eta();
81 double elt_deta = caloDDE->
deta();
85 double u = 2*(
eta-elt_eta)/elt_deta;
88 double elt_eta_raw = clus->
rawEta();
90 if(elt_eta_raw<0.) u=-u;
99 double aeta = fabs(
eta - elt_eta + elt_eta_raw);
113 unsigned int nreg =
regions.size();
116 for (
unsigned int i=0; i<nreg; i++) {
132 u = fmod(aeta,cellsize)/cellsize*2 - 1;
135 float energy = clus->
energy();
141 unsigned int n_energies = energies.
size();
142 unsigned int shape[] = {n_energies, 2};
148 unsigned int beg = 0;
149 unsigned int end = n_energies;
150 if(energy <= energies[0])
152 else if(energy >= energies[n_energies-1])
157 for (
unsigned int i=beg; i<end; i++)
158 docalc(i, *builder, energies, corrtab, n_good);
162 while (n_good==0 && beg>0) {
164 docalc (beg, *builder, energies, corrtab, n_good);
166 while (n_good == 0 && end<n_energies) {
167 docalc(end, *builder, energies, corrtab, n_good);
183 else if(energy<=corrtab[0][0]){
186 else if(energy>=corrtab[n_good-1][0]) {
187 offs=corrtab[n_good-1][1];
221 corrtab[n_good][0] = energies[i];
223 corrtab[n_good][1] = builder.calculate (i, good);
255 if(coef[0].end()[-1]==0) {
263 if (forms.
size(0) != 0 && forms.
size(1) != 0)
305 const unsigned int NPAR = 5;
308 unsigned int degree = coef.size(1);
309 for (
unsigned int i=0; i < NPAR; i++) {
311 double out = xcoef[0];
312 for (
unsigned int j=1; j<degree; j++)
313 out = out * aeta + xcoef[j];
317 double c = (u>=0) ? pars[2] : pars[3];
318 return pars[0] * (std::atan (pars[1] * u) + c*u + pars[4]);
328 const unsigned int NPAR = 4;
331 unsigned int degree = coef.size(1);
332 for (
unsigned int i=0; i < NPAR; i++) {
334 double out = xcoef[0];
335 for (
unsigned int j=1; j<degree; j++)
336 out = out * aeta + xcoef[j];
342 c = -c - 2*std::atan(pars[1]);
343 return pars[0] * (std::atan (pars[1] * u) + c*u + pars[3]);
353 const unsigned int NPAR = 3;
356 unsigned int degree = coef.size(1);
357 for (
unsigned int i=0; i < NPAR; i++) {
359 double out = xcoef[0];
360 for (
unsigned int j=1; j<degree; j++)
361 out = out * aeta + xcoef[j];
365 double b = std::max ((
double)pars[1], 1e-5);
366 double atanb = std::atan(b);
367 double sq = std::sqrt (b/atanb - 1);
368 double den = (
sq/b*atanb - std::atan(
sq));
369 return pars[0]* ((- std::atan (b*u) + u*atanb) / den +
370 pars[2]*(1-std::abs(u)));
380 const unsigned int NPAR = 1;
384 unsigned int degree = coef.size(1);
385 for (
unsigned int i=0; i < NPAR; i++) {
387 double out = xcoef[0];
388 for (
unsigned int j=1; j<degree; j++)
389 out = out * aeta + xcoef[j];
403 const unsigned int NPAR = 7;
406 unsigned int degree = coef.size(1);
407 for (
unsigned int i=0; i < NPAR; i++) {
409 double out = xcoef[0];
410 for (
unsigned int j=1; j<degree; j++)
411 out = out * aeta + xcoef[j];
417 c = -c - 2*std::atan(pars[1]);
419 double offs = pars[0] * (atan (pars[1] * u) + c*u + pars[3]) +
420 pars[4] * std::cos (u * pars[5] *
M_PI + pars[6]);
421 if (u > 0.9 || u < -0.9) {
422 double xdiff = pars[4] * (std::cos (pars[5] *
M_PI + pars[6]) -
423 std::cos (- pars[5] *
M_PI + pars[6]));
425 offs -= (u-0.9)/0.1 * xdiff/2;
427 offs += (-0.9-u)/0.1 * xdiff/2;
439 const unsigned int NPAR = 8;
442 unsigned int degree = coef.size(1);
443 for (
unsigned int i=0; i < NPAR; i++) {
445 double out = xcoef[0];
446 for (
unsigned int j=1; j<degree; j++)
447 out = out * aeta + xcoef[j];
451 double c = (u>=0) ? pars[2] : pars[3];
452 return pars[0] * (std::atan (pars[1] * u) + c*u + pars[4])
453 + pars[5] * std::cos (u * pars[6] *
M_PI + pars[7]);
Scalar eta() const
pseudorapidity method
Definition of CaloDetDescriptor.
#define CHECK(...)
Evaluate an expression and check for errors.
static const std::vector< std::string > regions
Helper, used to calculate the values of the energy interpolation table.
This class groups all DetDescr information related to a CaloCell.
float eta() const
cell eta
float deta() const
cell deta
const CaloDetDescriptor * descriptor() const
cell descriptor
bool is_lar_em_barrel() const
descriptor belongs to EM barrel
bool is_lar_em_endcap() const
descriptor belongs to EM end cap
Read-only multidimensional array.
unsigned int size(unsigned int dim=0) const
Return the size of the array along one dimension.
Read-write multidimensional array.
float calc4(float, float, const CaloRec::Array< 2 > &) const
float calc0(float, float, const CaloRec::Array< 2 > &) const
Builder(const EgammaSshapeCalibration &, double, double, int)
Constructor.
const EgammaSshapeCalibration & m_corr
float calc11(float, float, const CaloRec::Array< 2 > &) const
float calc10(float, float, const CaloRec::Array< 2 > &) const
virtual float calculate(int energy_ndx, bool &good) const
Calculate the correction for tabulated energy ENERGY_NDX.
float calc5(float, float, const CaloRec::Array< 2 > &) const
float calc3(float, float, const CaloRec::Array< 2 > &) const
Constant< CxxUtils::Array< 1 > > m_energies
Table of energies at which the correction was tabulated.
virtual void makeCorrection(xAOD::TrigEMCluster *, const void *) const override
Virtual function from IEgammaCalibration.
void docalc(int, const CaloClusterCorrectionCommon::TableBuilder &, const CxxUtils::Array< 1 > &, CxxUtils::WritableArray< 2 > &, int &) const
virtual StatusCode finalize() override
Finalization of the tool.
Constant< int > m_energy_degree
Degree of the polynomial interpolation in energy.
Constant< bool > m_isRange_barrel
virtual StatusCode initialize() override
Initialization of the tool.
Constant< CxxUtils::Array< 2 > > m_regions
Calibration constant: table of regions.
float rawEta() const
get Raw Eta (no calibration)
void setEta(float)
set Eta (calibrated)
float eta() const
get Eta (calibrated)
float energy() const
get Energy (calibrated)
Polynomial interpolation in a table.
float interpolate(const CaloRec::Array< 2 > &a, float x, unsigned int degree, unsigned int ycol=1, const CaloRec::Array< 1 > ®ions=CaloRec::Array< 1 >(), int n_points=-1, bool fixZero=false)
Polynomial interpolation in a table.
TrigEMCluster_v1 TrigEMCluster
Define the latest version of the trigger EM cluster class.