ATLAS Offline Software
Loading...
Searching...
No Matches
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*/
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
43
46using CLHEP::pi;
47using CLHEP::twopi;
48
49
50namespace {
51
52
53const double deta = 0.2;
54const double dphi = twopi / 64. ;
55
56
57} // anonymous namespace
58
59
64{
66 ATH_CHECK( m_cells_name.initialize() );
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);
142 const CxxUtils::Array<2> correction = m_correction (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
162StatusCode
164 (const std::string& name)
165{
166 return this->setProperty (StringProperty ("cells_name", name));
167}
168
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
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
Initialize method.
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.
Constant< CxxUtils::Array< 2 > > m_correction
Calibration constant: The tabulated array of correction weights, A and alpha.
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