ATLAS Offline Software
Loading...
Searching...
No Matches
CaloSwGap_v3.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 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
23
26using CLHEP::pi;
27using CLHEP::twopi;
28
29
30namespace {
31
32
33const double deta = 0.2;
34const double dphi = twopi / 64. ;
35
36
37} // anonymous namespace
38
39
44{
46 ATH_CHECK( m_cells_name.initialize() );
47 return StatusCode::SUCCESS;
48}
49
50
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#if 0
81 float the_aeta;
82 float the_phi;
83 if (m_use_raw_eta){
84 the_aeta = std::abs (adj_eta);
85 the_phi = adj_phi;
86 }else{
87 the_aeta = std::abs (eta);
88 the_phi = phi;
89 }
90#endif
91 float the_aeta_boundaries;
92 if (m_use_raw_eta_boundaries(myctx))
93 the_aeta_boundaries = std::abs (adj_eta);
94 else
95 the_aeta_boundaries = std::abs (eta);
96
97 if (the_aeta_boundaries < m_etamin_crack(myctx) ||
98 the_aeta_boundaries > m_etamax_crack(myctx))
99 {
100 return; // no correction required
101 }
102
103 // use cluster positions from now on
104 float eta_clus = cluster->eta();
105 float phi_clus = cluster->phi();
106
108
109 // Add up the tile scintillator energy in the region around the cluster.
110 double eh_scint = 0;
111 if(cc.isValid())
112 {
114 cc->beginConstCalo(CaloCell_ID::TILE);
116 cc->endConstCalo(CaloCell_ID::TILE);
117
118 for ( ; f_cell!=l_cell; ++f_cell)
119 {
120 const CaloCell* cell = (*f_cell) ;
121
122 if (CaloCell_ID::TileGap3 == cell->caloDDE()->getSampling()) {
123 double phic = cell->phi();
124 double etac = cell->eta();
125
126 float diffeta = etac-eta_clus;
127 float diffphi = phic-phi_clus;
128 if (diffphi < -pi) diffphi += twopi;
129 if (diffphi > pi) diffphi -= twopi;
130
131 if(fabs(diffeta)<deta && fabs(diffphi)<dphi){
132 eh_scint += cell->e();
133 }
134 }
135 }
136 }
137
138
139 // Find the correction weights: depends on phi position
140 float a = 0.;
141 float alpha = 0.;
142 float offset = 0.;
143
144 if(isGoodPhi(eta_clus,phi_clus)){
145 const int degree = m_degree (myctx);
146 const CxxUtils::Array<2> correctionGoodPhi = m_correctionGoodPhi(myctx);
147 a = interpolate (correctionGoodPhi, fabs(eta_clus), degree, 1);
148 alpha = interpolate (correctionGoodPhi, fabs(eta_clus), degree, 2);
149 offset = interpolate (correctionGoodPhi, fabs(eta_clus), degree, 3);
150 }
151 else{
152 const int degree = m_degree (myctx);
153 const CxxUtils::Array<2> correctionBadPhi = m_correctionBadPhi(myctx);
154 a = interpolate (correctionBadPhi, fabs(eta_clus), degree, 1);
155 alpha = interpolate (correctionBadPhi, fabs(eta_clus), degree, 2);
156 offset = interpolate (correctionBadPhi, fabs(eta_clus), degree, 3);
157 }
158
159
160 // The correction is a weighted sum of calorimeter and scintillator energies.
161 float ec = cluster->e();
162
163 // Sampling energies don't include scintillator contribution.
164 setenergy (cluster, a*(ec + offset));
165 cluster->setE (a*(ec + alpha*eh_scint + offset));
166}
167
168
173StatusCode
175 (const std::string& name)
176{
177 return this->setProperty (StringProperty ("cells_name", name));
178}
179
180
181bool CaloSwGap_v3::isGoodPhi(float eta, float phi) const{
182
183 // get position of missing TG3 cells
184 const int NBad = 8;
185 int emptyTGEtaPosind[NBad] = {3,12,23,30,35,44,53,60};
186 float emptyTGEtaPos[NBad];
187 int emptyTGEtaNegind[NBad] = {4,13,20,28,37,45,54,61};
188 float emptyTGEtaNeg[NBad];
189
190 int Nmodules = 64;
191 float modSize = twopi / Nmodules;
192 float offset = modSize/2.;
193
194 for(int i=0;i<NBad;i++){
195 float shift = (emptyTGEtaPosind[i]-1)*modSize;
196 if(shift>pi) shift-=twopi;
197 emptyTGEtaPos[i] = offset + shift;
198
199 shift = (emptyTGEtaNegind[i]-1)*modSize;
200 if(shift>pi) shift-=twopi;
201 emptyTGEtaNeg[i] = offset + shift;
202 }
203
204 // now test whether the current position matches
205 // the bad TG3 cells position
206
207 if(eta>0){
208 for(int ipos=0;ipos<NBad;ipos++){
209 float min = emptyTGEtaPos[ipos]-0.05;
210 float max = emptyTGEtaPos[ipos]+0.05;
211 if(phi>min && phi<max) {
212 return false;
213 }
214 }
215 }
216 if(eta<0){
217 for(int ipos=0;ipos<NBad;ipos++){
218 float min = emptyTGEtaNeg[ipos]-0.05;
219 float max = emptyTGEtaNeg[ipos]+0.05;
220 if(phi>min && phi<max) {
221 return false;
222 }
223 }
224 }
225
226 return true;
227
228}
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
Initialize method.
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.
const EventContext & ctx() const