ATLAS Offline Software
Loading...
Searching...
No Matches
CaloSwGap_v2.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
31
32
33#include "CaloSwGap_v2.h"
34#include "CLHEP/Units/PhysicalConstants.h"
36#include "CaloEvent/CaloCell.h"
38#include "GaudiKernel/MsgStream.h"
39#include "GaudiKernel/StatusCode.h"
40#include <cmath>
41#include <iostream>
42#include <numbers>
43
44
47using std::numbers::pi;
48
49
50namespace {
51
52
53inline constexpr double twopi = 2*pi;
54inline constexpr double deta = 0.2;
55inline constexpr double dphi = twopi / 64. ;
56
57
58} // anonymous namespace
59
60
65{
67 ATH_CHECK( m_cells_name.initialize() );
68 return StatusCode::SUCCESS;
69}
70
71
92void CaloSwGap_v2::makeTheCorrection (const Context& myctx,
93 CaloCluster* cluster,
94 const CaloDetDescrElement*/*elt*/,
95 float eta,
96 float adj_eta,
97 float phi,
98 float /*adj_phi*/,
99 CaloSampling::CaloSample /*samp*/) const
100{
101 // ??? In principle, we should use adj_eta for the interpolation
102 // and range checks. However, the v2 corrections were derived
103 // using regular eta instead.
104 float the_aeta;
105 if (m_use_raw_eta(myctx))
106 the_aeta = std::abs (adj_eta);
107 else
108 the_aeta = std::abs (eta);
109
110 if (the_aeta < m_etamin_crack(myctx) || the_aeta > m_etamax_crack(myctx))
111 return; // no correction required
112
114
115 // Add up the tile scintillator energy in the region around the cluster.
116 double eh_scint = 0;
117 if(cc.isValid())
118 {
120 cc->beginConstCalo(CaloCell_ID::TILE);
122 cc->endConstCalo(CaloCell_ID::TILE);
123
124 for ( ; f_cell!=l_cell; ++f_cell)
125 {
126 const CaloCell* cell = (*f_cell) ;
127
128 if (CaloCell_ID::TileGap3 == cell->caloDDE()->getSampling()) {
129 double phic = cell->phi();
130 double etac = cell->eta();
131 if (phic-phi < -pi) phic = phic + twopi;
132 if (phic-phi > pi) phic = phic - twopi;
133 if (etac >= eta-deta && etac <= eta+deta) {
134 if (phic >= phi-dphi && phic <= phi+dphi) {
135 eh_scint += cell->e();
136 }
137 }
138 }
139 }
140 }
141
142 const int degree = m_degree (myctx);
143 const CxxUtils::Array<2> correction = m_correction (myctx);
144
145 // Find the correction weights.
146 float a = interpolate (correction, the_aeta, degree, 1);
147 float alpha = interpolate (correction, the_aeta, degree, 2);
148 float offset = interpolate (correction, the_aeta, degree, 3);
149
150 // The correction is a weighted sum of calorimeter and scintillator energies.
151 float ec = cluster->e();
152
153 // Sampling energies don't include scintillator contribution.
154 setenergy (cluster, a*(ec + offset));
155 cluster->setE (a*(ec + alpha*eh_scint + offset));
156}
157
158
163StatusCode
165 (const std::string& name)
166{
167 return this->setProperty (StringProperty ("cells_name", name));
168}
169
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
Constant< CxxUtils::Array< 2 > > m_correction
Calibration constant: tabulated arrays of function parameters.
EM calorimeter gap corrections.
static Double_t a
void setProperty(columnar::PythonToolHandle &self, const std::string &key, nb::object value)
#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.
virtual StatusCode initialize() override
Standard Gaudi initialize method.
Constant< float > m_etamax_crack
Constant< int > m_degree
Calibration constant: The interpolation degree.
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< float > m_etamin_crack
Calibration constants: The range over which this correction is defined.
Constant< bool > m_use_raw_eta
Calibration constant: If true, tabulated values are in terms of raw (local) eta.
SG::ReadHandleKey< CaloCellContainer > m_cells_name
Property: The name of the container in which to look to find tile cells.
virtual StatusCode setCaloCellContainerName(const std::string &name) override
Change the name of the CaloCellContainer used by this tool.
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.