ATLAS Offline Software
Loading...
Searching...
No Matches
CaloSwGap_g3.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5/********************************************************************
6
7NAME: CaloSwGap_g3.cxx
8PACKAGE: offline/Calorimeter/CaloClusterCorrection
9
10AUTHORS: L. Carminati
11CREATED: Feb 2003
12
13PURPOSE: Correction for the barrel-endcap cracks
14 Tuned using 100 GeV photons
15
16UPDATED: 10/04/03 MW
17 bug fix to take only the cells in near cluster for gap
18 correction
19
20Updated: May 5, 2004 (Sven Menke)
21 base class changed from algo to tool
22
23Updated: June, 2004 (sss)
24 Use ToolWithConstants to get correction constants.
25********************************************************************/
26
27#include "CaloSwGap_g3.h"
28
29#include "CaloEvent/CaloCell.h"
31
32#include "GaudiKernel/StatusCode.h"
33
34
35#include "CLHEP/Units/PhysicalConstants.h"
36#include "GaudiKernel/MsgStream.h"
37#include <cmath>
38#include <iostream>
39
41using CLHEP::pi;
42using CLHEP::twopi;
43
44namespace {
45
46const double deta = 0.2;
47const double dphi = twopi / 64. ;
48
49}
50
55{
57 ATH_CHECK( m_cells_name.initialize() );
58 return StatusCode::SUCCESS;
59}
60
61
63 CaloCluster* cluster) const
64{
65 float eta = cluster->eta();
66 float phi = cluster->phi();
67
68 float aeta = fabs(eta);
69
70 const float etamin_crack = m_etamin_crack (myctx);
71 const float etamax_crack = m_etamax_crack (myctx);
72 if (aeta < etamin_crack || aeta > etamax_crack)
73 return; // no correction required
74
75 const CxxUtils::Array<1> scint_weight = m_scint_weight (myctx);
76 const CxxUtils::Array<1> correction = m_correction (myctx);
77 assert (scint_weight.size() == correction.size());
78 if (correction.size() == 0) return;
79
81
82 double eh_scint = 0;
83 if(cc.isValid())
84 {
86 cc->beginConstCalo(CaloCell_ID::TILE);
88 cc->endConstCalo(CaloCell_ID::TILE);
89
90 for ( ; f_cell!=l_cell; ++f_cell)
91 {
92 const CaloCell* cell = (*f_cell) ;
93
94 int inum = cell->caloDDE()->getSampling();
95
96 if (CaloSampling::TileGap3 == inum ) {
97 double phic = cell->phi();
98 double etac = cell->eta();
99 if (phic-phi < -pi) phic = phic + twopi;
100 if (phic-phi > pi) phic = phic - twopi;
101 if (etac >= eta-deta && etac <= eta+deta) {
102 if (phic >= phi-dphi && phic <= phi+dphi) {
103 eh_scint += cell->e();
104 }
105 }
106 }
107 }
108 }
109
110 // make the correction
111 double granularity = (etamax_crack - etamin_crack)/correction.size();
112 int ind = static_cast<int> ((aeta - etamin_crack)/granularity);
113
114// Scintillator energy calibration
115 eh_scint = eh_scint * scint_weight[ind];
116
117//Correct for normalization factor total cluster energy and samplings energies
118 double energy = (cluster->e())*correction[ind];
119 setenergy(cluster,energy);
120
121// Add the scintillator energy to the cluster and correct the total energy
122 energy += eh_scint * correction[ind];
123 cluster->setE(energy);
124}
125
126
131StatusCode
133 (const std::string& name)
134{
135 return this->setProperty (StringProperty ("cells_name", name));
136}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
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 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.
virtual void makeCorrection(const Context &myctx, xAOD::CaloCluster *cluster) const override
virtual StatusCode setCaloCellContainerName(const std::string &name) override
Change the name of the CaloCellContainer used by this tool.
Constant< CxxUtils::Array< 1 > > m_correction
Constant< float > m_etamax_crack
SG::ReadHandleKey< CaloCellContainer > m_cells_name
Property: The name of the container in which to look to find tile cells.
Constant< float > m_etamin_crack
virtual StatusCode initialize() override
Standard Gaudi initialize method.
Constant< CxxUtils::Array< 1 > > m_scint_weight
Read-only multidimensional array.
unsigned int size(unsigned int dim=0) const
Return the size of the array along one dimension.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
const EventContext & ctx() const