ATLAS Offline Software
Loading...
Searching...
No Matches
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
6
9
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.
23TopoClusterMap::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.
36
38//Functional routines.
40
41StatusCode 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
58
59 return StatusCode::SUCCESS;
60}
61
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.
72
73}
74
75//Boolean comparison somewhere here that sorts vectors in grid by Et.
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
84void 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
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.
118std::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.
137std::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
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}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
bool CompareClusterET(const xAOD::CaloCluster *c1, const xAOD::CaloCluster *c2)
static const Attributes_t empty
static double GetLArThirdLayerRatio(const xAOD::CaloCluster *)
TopoClusterMap(float minEta=-6., float minPhi=-3.2, float maxEta=6., float maxPhi=3.2, float dEta=0.3, float dPhi=0.1)
std::pair< int, int > GetEtaPhiKeys(double eta, double phi) const
StatusCode SetTopoClusters(const xAOD::CaloClusterContainer *)
void InsertTopoCluster(xAOD::CaloCluster *)
interface methods
TopoCluster2DMap m_map
void SortGridVector(int eta_key, int phi_key)
std::vector< const xAOD::CaloCluster * > RetrieveTopoClusters(double eta, double phi, double Pt) const
bool inBarrel() const
Returns true if at least one clustered cell in the barrel.
float eSample(const CaloSample sampling) const
bool inEndcap() const
Returns true if at least one clustered cell in the endcap.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.