ATLAS Offline Software
Loading...
Searching...
No Matches
CaloTopoEMGap.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
12
13#include "CaloTopoEMGap.h"
14#include "CLHEP/Units/PhysicalConstants.h"
16#include "CaloEvent/CaloCell.h"
19#include <cmath>
20#include <iostream>
21#include <numbers>
22
23
26using std::numbers::pi;
27
28
29namespace {
30
31
32inline constexpr double twopi = 2*pi;
33inline constexpr double deta = 0.2;
34inline constexpr double dphi = twopi / 64. ;
35
36
37} // anonymous namespace
38
39
44{
46 ATH_CHECK( m_cells.initialize() );
47 return StatusCode::SUCCESS;
48}
49
50
71void CaloTopoEMGap::makeTheCorrection (const Context& myctx,
72 CaloCluster* cluster,
73 const CaloDetDescrElement*/*elt*/,
74 float eta,
75 float adj_eta,
76 float phi,
77 float /*adj_phi*/,
78 CaloSampling::CaloSample /*samp*/) const
79{
80 // ??? In principle, we should use adj_eta for the interpolation
81 // and range checks. However, the v2 corrections were derived
82 // using regular eta instead.
83 float the_aeta;
84 if (m_use_raw_eta(myctx))
85 the_aeta = std::abs (adj_eta);
86 else
87 the_aeta = std::abs (eta);
88
89 if (the_aeta < m_etamin_crack(myctx) || the_aeta > m_etamax_crack(myctx))
90 return; // no correction required
91
93
94 // Add up the tile scintillator energy in the region around the cluster.
95 double eh_scint = 0;
96 if(cc.isValid())
97 {
99 cc->beginConstCalo(CaloCell_ID::TILE);
101 cc->endConstCalo(CaloCell_ID::TILE);
102
103 for ( ; f_cell!=l_cell; ++f_cell)
104 {
105 const CaloCell* cell = (*f_cell) ;
106
107 if (CaloCell_ID::TileGap3 == cell->caloDDE()->getSampling()) {
108 double phic = cell->phi();
109 double etac = cell->eta();
110 if (phic-phi < -pi) phic = phic + twopi;
111 if (phic-phi > pi) phic = phic - twopi;
112 if (etac >= eta-deta && etac <= eta+deta) {
113 if (phic >= phi-dphi && phic <= phi+dphi) {
114 eh_scint += cell->e();
115 }
116 }
117 }
118 }
119 }
120
121 const CxxUtils::Array<2> correction = m_correction (myctx);
122 const int degree = m_degree (myctx);
123
124 // Find the correction weights.
125 float par0 = interpolate (correction, the_aeta, degree, 1);
126 float par1 = interpolate (correction, the_aeta, degree, 2);
127 float par2 = interpolate (correction, the_aeta, degree, 3);
128 float par3 = interpolate (correction, the_aeta, degree, 4);
129
130 // The correction is a weighted sum of calorimeter and scintillator energies.
131 float ec = cluster->e();
132
133 float a = ec/par0;
134 //float b = 0;
135
136 //if (a > 1.0) b = par0*log(a) + par0;
137
138 // Sampling energies don't include scintillator contribution.
139 setenergy (cluster, par1*(ec + a + par3));
140 cluster->setE (par1*(ec + a + par2*eh_scint + par3));
141}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
static Double_t a
Handle class for reading from StoreGate.
#define pi
constexpr double twopi
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
virtual void setenergy(xAOD::CaloCluster *cluster, float energy) const
virtual StatusCode initialize() override
Principal data class for CaloCell clusters.
virtual double e() const
Retrieve energy independent of signal state.
virtual void setE(double e)
Set energy.
This class groups all DetDescr information related to a CaloCell.
SG::ReadHandleKey< CaloCellContainer > m_cells
Constant< int > m_degree
Calibration constant: The interpolation degree.
virtual StatusCode initialize() override
Standard Gaudi initialize method.
Constant< bool > m_use_raw_eta
Calibration constant: If true, tabulated values are in terms of raw (local) eta.
Constant< float > m_etamax_crack
Constant< float > m_etamin_crack
Calibration constants: The range over which this correction is defined.
virtual void makeTheCorrection(const Context &myctx, xAOD::CaloCluster *cluster, const CaloDetDescrElement *elt, float eta, float adj_eta, float phi, float adj_phi, CaloSampling::CaloSample samp) const override
Virtual function for the correction-specific code.
Constant< CxxUtils::Array< 2 > > m_correction
Calibration constant: The tabulated array of correction weights, A and alpha.
Read-only multidimensional array.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
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 > &regions=CaloRec::Array< 1 >(), int n_points=-1, bool fixZero=false)
Polynomial interpolation in a table.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.