ATLAS Offline Software
CaloSwGap_v2.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
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 
43 
44 using xAOD::CaloCluster;
46 using CLHEP::pi;
47 using CLHEP::twopi;
48 
49 
50 namespace {
51 
52 
53 const double deta = 0.2;
54 const double dphi = twopi / 64. ;
55 
56 
57 } // anonymous namespace
58 
59 
64 {
67  return StatusCode::SUCCESS;
68 }
69 
70 
92  CaloCluster* cluster,
93  const CaloDetDescrElement*/*elt*/,
94  float eta,
95  float adj_eta,
96  float phi,
97  float /*adj_phi*/,
98  CaloSampling::CaloSample /*samp*/) const
99 {
100  // ??? In principle, we should use adj_eta for the interpolation
101  // and range checks. However, the v2 corrections were derived
102  // using regular eta instead.
103  float the_aeta;
104  if (m_use_raw_eta(myctx))
105  the_aeta = std::abs (adj_eta);
106  else
107  the_aeta = std::abs (eta);
108 
109  if (the_aeta < m_etamin_crack(myctx) || the_aeta > m_etamax_crack(myctx))
110  return; // no correction required
111 
113 
114  // Add up the tile scintillator energy in the region around the cluster.
115  double eh_scint = 0;
116  if(cc.isValid())
117  {
119  cc->beginConstCalo(CaloCell_ID::TILE);
121  cc->endConstCalo(CaloCell_ID::TILE);
122 
123  for ( ; f_cell!=l_cell; ++f_cell)
124  {
125  const CaloCell* cell = (*f_cell) ;
126 
127  if (CaloCell_ID::TileGap3 == cell->caloDDE()->getSampling()) {
128  double phic = cell->phi();
129  double etac = cell->eta();
130  if (phic-phi < -pi) phic = phic + twopi;
131  if (phic-phi > pi) phic = phic - twopi;
132  if (etac >= eta-deta && etac <= eta+deta) {
133  if (phic >= phi-dphi && phic <= phi+dphi) {
134  eh_scint += cell->e();
135  }
136  }
137  }
138  }
139  }
140 
141  const int degree = m_degree (myctx);
143 
144  // Find the correction weights.
145  float a = interpolate (correction, the_aeta, degree, 1);
146  float alpha = interpolate (correction, the_aeta, degree, 2);
147  float offset = interpolate (correction, the_aeta, degree, 3);
148 
149  // The correction is a weighted sum of calorimeter and scintillator energies.
150  float ec = cluster->e();
151 
152  // Sampling energies don't include scintillator contribution.
153  setenergy (cluster, a*(ec + offset));
154  cluster->setE (a*(ec + alpha*eh_scint + offset));
155 }
156 
157 
164  (const std::string& name)
165 {
166  return this->setProperty (StringProperty ("cells_name", name));
167 }
168 
CaloSwGap_v2.h
EM calorimeter gap corrections.
CaloSwGap_v2::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_v2.h:143
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
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
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_v2::m_degree
Constant< int > m_degree
Calibration constant: The interpolation degree.
Definition: CaloSwGap_v2.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_v2::m_etamax_crack
Constant< float > m_etamax_crack
Definition: CaloSwGap_v2.h:129
tools.zlumi_mc_cf.correction
def correction(mu, runmode, campaign, run=None)
Definition: zlumi_mc_cf.py:4
CaloSwGap_v2::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_v2.h:147
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
CxxUtils::Array< 2 >
CaloSwGap_v2::initialize
virtual StatusCode initialize() override
Standard Gaudi initialize method.
Definition: CaloSwGap_v2.cxx:63
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
CaloSwGap_v2::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_v2.cxx:91
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
twopi
constexpr double twopi
Definition: VertexPointEstimator.cxx:16
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CaloCellContainer.h
CaloSwGap_v2::setCaloCellContainerName
virtual StatusCode setCaloCellContainerName(const std::string &name) override
Change the name of the CaloCellContainer used by this tool.
Definition: CaloSwGap_v2.cxx:164
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
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_v2::m_correction
Constant< CxxUtils::Array< 2 > > m_correction
Calibration constant: The tabulated array of correction weights, A and alpha.
Definition: CaloSwGap_v2.h:138
interpolate.h
Polynomial interpolation in a table.
CaloSwGap_v2::m_etamin_crack
Constant< float > m_etamin_crack
Calibration constants: The range over which this correction is defined.
Definition: CaloSwGap_v2.h:127
python.SystemOfUnits.degree
tuple degree
Definition: SystemOfUnits.py:106
python.handimod.cc
int cc
Definition: handimod.py:523