ATLAS Offline Software
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 */
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"
19 #include "StoreGate/ReadHandle.h"
20 #include <cmath>
21 #include <iostream>
22 
23 
24 using xAOD::CaloCluster;
26 using CLHEP::pi;
27 using CLHEP::twopi;
28 
29 
30 namespace {
31 
32 
33 const double deta = 0.2;
34 const double dphi = twopi / 64. ;
35 
36 
37 } // anonymous namespace
38 
39 
44 {
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 
175  (const std::string& name)
176 {
177  return this->setProperty (StringProperty ("cells_name", name));
178 }
179 
180 
181 bool 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 }
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
CaloSwGap_v3::initialize
virtual StatusCode initialize() override
Standard Gaudi initialize method.
Definition: CaloSwGap_v3.cxx:43
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
max
#define max(a, b)
Definition: cfImp.cxx:41
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
CaloSwGap_v3::setCaloCellContainerName
virtual StatusCode setCaloCellContainerName(const std::string &name) override
Change the name of the CaloCellContainer used by this tool.
Definition: CaloSwGap_v3.cxx:175
CaloSwGap_v3::m_etamax_crack
Constant< float > m_etamax_crack
Definition: CaloSwGap_v3.h:111
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
CaloUtils::ToolConstantsContext::ctx
const EventContext & ctx() const
Definition: ToolWithConstants.h:63
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloSwGap_v3::m_correctionGoodPhi
Constant< CxxUtils::Array< 2 > > m_correctionGoodPhi
Calibration constant: The tabulated array of correction weights, A and alpha.
Definition: CaloSwGap_v3.h:120
CaloClusterCorrection::setenergy
virtual void setenergy(xAOD::CaloCluster *cluster, float energy) const
Definition: CaloClusterCorrection.cxx:94
CaloCell.h
CaloCell_ID_FCS::TileGap3
@ TileGap3
Definition: FastCaloSim_CaloCell_ID.h:36
CaloSwGap_v3::m_cells_name
SG::ReadHandleKey< CaloCellContainer > m_cells_name
Property: The name of the container in which to look to find tile cells.
Definition: CaloSwGap_v3.h:133
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
pi
#define pi
Definition: TileMuonFitter.cxx:65
CaloClusterCorrection::initialize
virtual StatusCode initialize() override
Initialize method.
Definition: CaloClusterCorrection.cxx:47
CaloSwGap_v3::m_use_raw_eta_boundaries
Constant< bool > m_use_raw_eta_boundaries
Definition: CaloSwGap_v3.h:129
CaloSwGap_v3::m_correctionBadPhi
Constant< CxxUtils::Array< 2 > > m_correctionBadPhi
Definition: CaloSwGap_v3.h:122
lumiFormat.i
int i
Definition: lumiFormat.py:92
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CaloSwGap_v3::m_degree
Constant< int > m_degree
Calibration constant: The interpolation degree.
Definition: CaloSwGap_v3.h:115
CaloSwGap_v3::isGoodPhi
virtual bool isGoodPhi(float eta, float phi) const
Definition: CaloSwGap_v3.cxx:181
CxxUtils::Array< 2 >
CaloCluster
Principal data class for CaloCell clusters.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:79
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloCell_Base_ID::TILE
@ TILE
Definition: CaloCell_Base_ID.h:46
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
min
#define min(a, b)
Definition: cfImp.cxx:40
twopi
constexpr double twopi
Definition: VertexPointEstimator.cxx:16
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CaloCellContainer.h
CaloSwGap_v3::m_etamin_crack
Constant< float > m_etamin_crack
Calibration constants: The range over which this correction is defined.
Definition: CaloSwGap_v3.h:109
CaloSwGap_v3::m_use_raw_eta
Constant< bool > m_use_raw_eta
Calibration constant: If true, tabulated values are in terms of raw (local) eta.
Definition: CaloSwGap_v3.h:127
CaloCluster::setE
virtual void setE(double e)
Set energy.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:767
a
TList * a
Definition: liststreamerinfos.cxx:10
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
CaloCluster::eta
virtual double eta() const
Retrieve eta independent of signal state.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:755
CaloClusterCorr::interpolate
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.
Definition: interpolate.cxx:75
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
CaloCluster::e
virtual double e() const
Retrieve energy independent of signal state.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:753
CaloUtils::ToolConstantsContext
Context object for retrieving ToolConstant values.
Definition: ToolWithConstants.h:61
CaloSwGap_v3::makeTheCorrection
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.
Definition: CaloSwGap_v3.cxx:71
CaloSwGap_v3.h
ReadHandle.h
Handle class for reading from StoreGate.
interpolate.h
Polynomial interpolation in a table.
python.SystemOfUnits.degree
tuple degree
Definition: SystemOfUnits.py:106
python.handimod.cc
int cc
Definition: handimod.py:523
CaloCluster::phi
virtual double phi() const
Retrieve phi independent of signal state.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:759