ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
RecoTools
CaloClusterMatching
src
TopoClusterMap.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
CaloClusterMatching/TopoClusterMap.h
"
6
7
#include "
xAODCaloEvent/CaloCluster.h
"
8
#include "
xAODCaloEvent/CaloClusterKineHelper.h
"
9
10
bool
CompareClusterET
(
const
xAOD::CaloCluster
* c1,
const
xAOD::CaloCluster
* c2)
11
{
12
13
double
Et1(c1->e()/cosh(c1->eta())), Et2(c2->e()/cosh(c2->eta()));
14
return
Et1 > Et2;
15
16
}
17
19
//Athena interfaces.
21
22
//Constructor.
23
TopoClusterMap::TopoClusterMap
(
float
minEta,
float
minPhi,
float
maxEta,
float
maxPhi,
24
float
dEta,
float
dPhi)
25
{
26
m_minEta
= minEta;
27
m_minPhi
= minPhi;
28
m_maxEta
= maxEta;
29
m_maxPhi
= maxPhi;
30
m_dEta
= dEta;
31
m_dPhi
= dPhi;
32
}
33
34
//Destructor.
35
TopoClusterMap::~TopoClusterMap
() =
default
;
36
38
//Functional routines.
40
41
StatusCode
TopoClusterMap::SetTopoClusters
(
const
xAOD::CaloClusterContainer
*inputTopoClusterContainer)
42
43
{
44
45
double
eta
,
phi
;
46
47
for
(
const
auto
*
const
cc : *inputTopoClusterContainer)
48
{
49
//Retrieve eta, phi from ith topocluster.
50
eta
= cc->eta();
51
phi
= cc->phi();
52
53
//Put it in appropriate vector.
54
m_map
[
GetEtaPhiKeys
(
eta
,
phi
).first][
GetEtaPhiKeys
(
eta
,
phi
).second].push_back(cc);
55
}
56
57
SortGridVectors
();
58
59
return
StatusCode::SUCCESS;
60
}
61
62
void
TopoClusterMap::InsertTopoCluster
(
xAOD::CaloCluster
* topo) {
63
64
//Retrieve eta, phi from ith topocluster.
65
double
eta
(topo->phi()),
phi
(topo->phi());
66
67
//Put it in appropriate vector.
68
m_map
.at(
GetEtaPhiKeys
(
eta
,
phi
).first).at(
GetEtaPhiKeys
(
eta
,
phi
).second).push_back(topo);
69
70
//Re-sort the vector according to Et.
71
SortGridVector
(
GetEtaPhiKeys
(
eta
,
phi
).first,
GetEtaPhiKeys
(
eta
,
phi
).second);
72
73
}
74
75
//Boolean comparison somewhere here that sorts vectors in grid by Et.
76
void
TopoClusterMap::SortGridVectors
() {
77
78
for
(
int
i = 0; i <= (
GetEtaPhiKeys
(
m_maxEta
,
m_maxPhi
).first); i++)
79
for
(
int
j = 0; j <= (
GetEtaPhiKeys
(
m_maxEta
,
m_maxPhi
).second); j++)
80
SortGridVector
(i,j);
81
82
}
83
84
void
TopoClusterMap::SortGridVector
(
int
eta_key,
int
phi_key) {
85
86
if
(!
m_map
[eta_key][phi_key].
empty
())
87
sort
(
m_map
[eta_key][phi_key].begin(),
m_map
[eta_key][phi_key].end(),
CompareClusterET
);
88
}
89
90
void
TopoClusterMap::ClearMap
() {
91
92
for
(
int
i = 0; i <= (
GetEtaPhiKeys
(
m_maxEta
,
m_maxPhi
).first); i++)
93
for
(
int
j = 0; j <= (
GetEtaPhiKeys
(
m_maxEta
,
m_maxPhi
).second); j++)
94
m_map
[i][j].
clear
();
95
}
96
97
// void TopoClusterMap::DumpMapContents() {
98
99
// for (int i = 0; i <= (GetEtaPhiKeys(m_maxEta, m_maxPhi).first); i++)
100
// for (int j = 0; j <= (GetEtaPhiKeys(m_maxEta, m_maxPhi).second); j++) {
101
// ATH_MSG_DEBUG("Size of topocluster vector at (" << i << "," << j << "): " << m_map[i][j].size());
102
// if (m_map[i][j].size()) {
103
// ATH_MSG_DEBUG("Contents of vector:");
104
// for (unsigned int k = 0; k < m_map[i][j].size(); k++) {
105
// //ATH_MSG_DEBUG("E: %f, eta: %f, phi: %f, Pt: %f \n",(m_map[i][j])[k]->e(), (m_map[i][j])[k]->eta(), (m_map[i][j])[k]->phi(), (m_map[i][j])[k]->pt());
106
// ATH_MSG_DEBUG("E: " << (m_map[i][j])[k]->e()
107
// << ", eta: " << (m_map[i][j])[k]->eta()
108
// << ", phi: " << (m_map[i][j])[k]->phi()
109
// << ", Pt: " << (m_map[i][j])[k]->pt());
110
// }
111
// }
112
// }
113
114
115
// }
116
117
//Routine to retrieve vector of TopoClusters for a given cluster Pt.
118
std::vector<const xAOD::CaloCluster*>
TopoClusterMap::RetrieveTopoClusters
(
double
eta
,
119
double
phi
,
120
double
Pt)
const
121
{
122
123
if
((Pt * 1e-3) < 15) {
124
return
RetrieveTopoClusters
(
eta
,
phi
, 0.2, 0.2);
125
}
126
else
if
((Pt * 1e-3) < 50) {
127
return
RetrieveTopoClusters
(
eta
,
phi
, 0.2, 0.4);
128
}
129
else
{
130
return
RetrieveTopoClusters
(
eta
,
phi
, 0.2, 0.6);
131
}
132
133
}
134
135
136
//Routine to retrieve vector of TopoClusters for a given (eta, phi) region.
137
std::vector<const xAOD::CaloCluster*>
TopoClusterMap::RetrieveTopoClusters
(
double
eta
,
double
phi
,
138
double
dEta,
139
double
dPhi)
const
140
{
141
142
std::vector<const xAOD::CaloCluster*> clusters;
143
144
//Need to be able to search within a broad window, then merge all vectors
145
//within that window together.
146
if
(dEta > 0. && dPhi > 0.) {
147
148
std::pair<double,double> lower_keys =
GetEtaPhiKeys
(
eta
-(dEta/2.),
phi
-(dPhi/2.));
149
std::pair<double,double> upper_keys =
GetEtaPhiKeys
(
eta
+(dEta/2.),
phi
+(dPhi/2.));
150
151
for
(
int
ieta = lower_keys.first; ieta <= upper_keys.first; ieta++)
152
for
(
int
iphi = lower_keys.second; iphi <= upper_keys.second; iphi++)
153
clusters.insert(clusters.end(),
m_map
.at(ieta).at(iphi).begin(),
m_map
.at(ieta).at(iphi).end());
154
155
156
//Re-sort vector according to Et and return it.
157
sort
( clusters.begin(), clusters.end(),
CompareClusterET
);
158
159
}
else
{
160
clusters =
m_map
.at(
GetEtaPhiKeys
(
eta
,
phi
).first).at(
GetEtaPhiKeys
(
eta
,
phi
).second);
161
}
162
163
return
clusters;
164
165
}
166
167
double
TopoClusterMap::GetLArThirdLayerRatio
(
const
xAOD::CaloCluster
*clus)
168
{
169
170
double
totalEnergy(0.), thirdLayerEnergy(0.);
171
172
if
(clus->
inBarrel
()) {
173
totalEnergy += clus->
eSample
(CaloSampling::PreSamplerB);
174
totalEnergy += clus->
eSample
(CaloSampling::EMB1);
175
totalEnergy += clus->
eSample
(CaloSampling::EMB2);
176
totalEnergy += clus->
eSample
(CaloSampling::EMB3);
177
178
thirdLayerEnergy += clus->
eSample
(CaloSampling::EMB3);
179
}
180
181
if
(clus->
inEndcap
()) {
182
totalEnergy += clus->
eSample
(CaloSampling::PreSamplerE);
183
totalEnergy += clus->
eSample
(CaloSampling::EME1);
184
totalEnergy += clus->
eSample
(CaloSampling::EME2);
185
totalEnergy += clus->
eSample
(CaloSampling::EME3);
186
187
thirdLayerEnergy += clus->
eSample
(CaloSampling::EME3);
188
189
}
190
191
if
(totalEnergy == 0)
return
0;
192
return
(thirdLayerEnergy / totalEnergy);
193
194
195
}
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
CaloClusterKineHelper.h
CaloCluster.h
sort
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Definition
DVL_algorithms.h:554
clear
void clear()
Empty the pool.
CompareClusterET
bool CompareClusterET(const xAOD::CaloCluster *c1, const xAOD::CaloCluster *c2)
Definition
TopoClusterMap.cxx:10
TopoClusterMap.h
empty
static const Attributes_t empty
Definition
XmlStreamer.cxx:16
TopoClusterMap::GetLArThirdLayerRatio
static double GetLArThirdLayerRatio(const xAOD::CaloCluster *)
Definition
TopoClusterMap.cxx:167
TopoClusterMap::TopoClusterMap
TopoClusterMap(float minEta=-6., float minPhi=-3.2, float maxEta=6., float maxPhi=3.2, float dEta=0.3, float dPhi=0.1)
Definition
TopoClusterMap.cxx:23
TopoClusterMap::m_dPhi
double m_dPhi
Definition
TopoClusterMap.h:83
TopoClusterMap::GetEtaPhiKeys
std::pair< int, int > GetEtaPhiKeys(double eta, double phi) const
Definition
TopoClusterMap.h:57
TopoClusterMap::m_maxPhi
double m_maxPhi
Definition
TopoClusterMap.h:82
TopoClusterMap::m_minPhi
double m_minPhi
Definition
TopoClusterMap.h:82
TopoClusterMap::m_dEta
double m_dEta
Definition
TopoClusterMap.h:83
TopoClusterMap::SetTopoClusters
StatusCode SetTopoClusters(const xAOD::CaloClusterContainer *)
Definition
TopoClusterMap.cxx:41
TopoClusterMap::SortGridVectors
void SortGridVectors()
Definition
TopoClusterMap.cxx:76
TopoClusterMap::m_minEta
double m_minEta
Definition
TopoClusterMap.h:82
TopoClusterMap::ClearMap
void ClearMap()
Definition
TopoClusterMap.cxx:90
TopoClusterMap::InsertTopoCluster
void InsertTopoCluster(xAOD::CaloCluster *)
interface methods
Definition
TopoClusterMap.cxx:62
TopoClusterMap::m_maxEta
double m_maxEta
Definition
TopoClusterMap.h:82
TopoClusterMap::m_map
TopoCluster2DMap m_map
Definition
TopoClusterMap.h:79
TopoClusterMap::~TopoClusterMap
~TopoClusterMap()
TopoClusterMap::SortGridVector
void SortGridVector(int eta_key, int phi_key)
Definition
TopoClusterMap.cxx:84
TopoClusterMap::RetrieveTopoClusters
std::vector< const xAOD::CaloCluster * > RetrieveTopoClusters(double eta, double phi, double Pt) const
Definition
TopoClusterMap.cxx:118
xAOD::CaloCluster_v1::inBarrel
bool inBarrel() const
Returns true if at least one clustered cell in the barrel.
Definition
CaloCluster_v1.h:887
xAOD::CaloCluster_v1::eSample
float eSample(const CaloSample sampling) const
Definition
CaloCluster_v1.cxx:514
xAOD::CaloCluster_v1::inEndcap
bool inEndcap() const
Returns true if at least one clustered cell in the endcap.
Definition
CaloCluster_v1.h:892
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
xAOD::CaloClusterContainer
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloClusterContainer.h:17
Generated on
for ATLAS Offline Software by
1.17.0