ATLAS Offline Software
Loading...
Searching...
No Matches
CaloSwGap_v3.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
11
12#include "CaloSwGap_v3.h"
13#include "CLHEP/Units/PhysicalConstants.h"
15#include "CaloEvent/CaloCell.h"
17#include "GaudiKernel/MsgStream.h"
18#include "GaudiKernel/StatusCode.h"
20#include <cmath>
21#include <iostream>
22#include <numbers>
23
24
27using std::numbers::pi;
28
29
30namespace {
31
32
33inline constexpr double twopi = 2*pi;
34inline constexpr double deta = 0.2;
35inline constexpr double dphi = twopi / 64. ;
36
37
38} // anonymous namespace
39
40
45{
47 ATH_CHECK( m_cells_name.initialize() );
48 return StatusCode::SUCCESS;
49}
50
51
72void CaloSwGap_v3::makeTheCorrection (const Context& myctx,
73 CaloCluster* cluster,
74 const CaloDetDescrElement*/*elt*/,
75 float eta,
76 float adj_eta,
77 float /*phi*/,
78 float /*adj_phi*/,
79 CaloSampling::CaloSample /*samp*/) const
80{
81#if 0
82 float the_aeta;
83 float the_phi;
84 if (m_use_raw_eta){
85 the_aeta = std::abs (adj_eta);
86 the_phi = adj_phi;
87 }else{
88 the_aeta = std::abs (eta);
89 the_phi = phi;
90 }
91#endif
92 float the_aeta_boundaries;
93 if (m_use_raw_eta_boundaries(myctx))
94 the_aeta_boundaries = std::abs (adj_eta);
95 else
96 the_aeta_boundaries = std::abs (eta);
97
98 if (the_aeta_boundaries < m_etamin_crack(myctx) ||
99 the_aeta_boundaries > m_etamax_crack(myctx))
100 {
101 return; // no correction required
102 }
103
104 // use cluster positions from now on
105 float eta_clus = cluster->eta();
106 float phi_clus = cluster->phi();
107
109
110 // Add up the tile scintillator energy in the region around the cluster.
111 double eh_scint = 0;
112 if(cc.isValid())
113 {
115 cc->beginConstCalo(CaloCell_ID::TILE);
117 cc->endConstCalo(CaloCell_ID::TILE);
118
119 for ( ; f_cell!=l_cell; ++f_cell)
120 {
121 const CaloCell* cell = (*f_cell) ;
122
123 if (CaloCell_ID::TileGap3 == cell->caloDDE()->getSampling()) {
124 double phic = cell->phi();
125 double etac = cell->eta();
126
127 float diffeta = etac-eta_clus;
128 float diffphi = phic-phi_clus;
129 if (diffphi < -pi) diffphi += twopi;
130 if (diffphi > pi) diffphi -= twopi;
131
132 if(fabs(diffeta)<deta && fabs(diffphi)<dphi){
133 eh_scint += cell->e();
134 }
135 }
136 }
137 }
138
139
140 // Find the correction weights: depends on phi position
141 float a = 0.;
142 float alpha = 0.;
143 float offset = 0.;
144
145 if(isGoodPhi(eta_clus,phi_clus)){
146 const int degree = m_degree (myctx);
147 const CxxUtils::Array<2> correctionGoodPhi = m_correctionGoodPhi(myctx);
148 a = interpolate (correctionGoodPhi, fabs(eta_clus), degree, 1);
149 alpha = interpolate (correctionGoodPhi, fabs(eta_clus), degree, 2);
150 offset = interpolate (correctionGoodPhi, fabs(eta_clus), degree, 3);
151 }
152 else{
153 const int degree = m_degree (myctx);
154 const CxxUtils::Array<2> correctionBadPhi = m_correctionBadPhi(myctx);
155 a = interpolate (correctionBadPhi, fabs(eta_clus), degree, 1);
156 alpha = interpolate (correctionBadPhi, fabs(eta_clus), degree, 2);
157 offset = interpolate (correctionBadPhi, fabs(eta_clus), degree, 3);
158 }
159
160
161 // The correction is a weighted sum of calorimeter and scintillator energies.
162 float ec = cluster->e();
163
164 // Sampling energies don't include scintillator contribution.
165 setenergy (cluster, a*(ec + offset));
166 cluster->setE (a*(ec + alpha*eh_scint + offset));
167}
168
169
174StatusCode
176 (const std::string& name)
177{
178 return this->setProperty (StringProperty ("cells_name", name));
179}
180
181
182bool CaloSwGap_v3::isGoodPhi(float eta, float phi) const{
183
184 // get position of missing TG3 cells
185 const int NBad = 8;
186 int emptyTGEtaPosind[NBad] = {3,12,23,30,35,44,53,60};
187 float emptyTGEtaPos[NBad];
188 int emptyTGEtaNegind[NBad] = {4,13,20,28,37,45,54,61};
189 float emptyTGEtaNeg[NBad];
190
191 int Nmodules = 64;
192 float modSize = twopi / Nmodules;
193 float offset = modSize/2.;
194
195 for(int i=0;i<NBad;i++){
196 float shift = (emptyTGEtaPosind[i]-1)*modSize;
197 if(shift>pi) shift-=twopi;
198 emptyTGEtaPos[i] = offset + shift;
199
200 shift = (emptyTGEtaNegind[i]-1)*modSize;
201 if(shift>pi) shift-=twopi;
202 emptyTGEtaNeg[i] = offset + shift;
203 }
204
205 // now test whether the current position matches
206 // the bad TG3 cells position
207
208 if(eta>0){
209 for(int ipos=0;ipos<NBad;ipos++){
210 float min = emptyTGEtaPos[ipos]-0.05;
211 float max = emptyTGEtaPos[ipos]+0.05;
212 if(phi>min && phi<max) {
213 return false;
214 }
215 }
216 }
217 if(eta<0){
218 for(int ipos=0;ipos<NBad;ipos++){
219 float min = emptyTGEtaNeg[ipos]-0.05;
220 float max = emptyTGEtaNeg[ipos]+0.05;
221 if(phi>min && phi<max) {
222 return false;
223 }
224 }
225 }
226
227 return true;
228
229}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
Sandrine should document this.
static Double_t a
void setProperty(columnar::PythonToolHandle &self, const std::string &key, nb::object value)
Handle class for reading from StoreGate.
#define pi
constexpr double twopi
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41
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 double eta() const
Retrieve eta independent of signal state.
virtual double phi() const
Retrieve phi independent of signal state.
virtual void setE(double e)
Set energy.
This class groups all DetDescr information related to a CaloCell.
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_etamax_crack
Constant< bool > m_use_raw_eta_boundaries
virtual bool isGoodPhi(float eta, float phi) const
virtual StatusCode setCaloCellContainerName(const std::string &name) override
Change the name of the CaloCellContainer used by this tool.
virtual StatusCode initialize() override
Standard Gaudi initialize method.
Constant< float > m_etamin_crack
Calibration constants: The range over which this correction is defined.
Constant< CxxUtils::Array< 2 > > m_correctionGoodPhi
Calibration constant: The tabulated array of correction weights, A and alpha.
Constant< CxxUtils::Array< 2 > > m_correctionBadPhi
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.
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.