ATLAS Offline Software
TopoClusterMap.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 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.
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.
36 
38 //Functional routines.
40 
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 
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 
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 {
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  return (thirdLayerEnergy / totalEnergy);
192 
193 
194 }
xAOD::CaloCluster_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: CaloCluster_v1.cxx:256
CaloClusterKineHelper.h
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
TopoClusterMap::GetLArThirdLayerRatio
static double GetLArThirdLayerRatio(const xAOD::CaloCluster *)
Definition: TopoClusterMap.cxx:167
constants.EMB1
int EMB1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:53
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
TopoClusterMap::m_map
TopoCluster2DMap m_map
Definition: TopoClusterMap.h:79
TopoClusterMap::SortGridVectors
void SortGridVectors()
Definition: TopoClusterMap.cxx:76
extractSporadic.c1
c1
Definition: extractSporadic.py:134
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
TopoClusterMap::m_dEta
double m_dEta
Definition: TopoClusterMap.h:83
TopoClusterMap::SetTopoClusters
StatusCode SetTopoClusters(const xAOD::CaloClusterContainer *)
Definition: TopoClusterMap.cxx:41
TopoClusterMap::m_minPhi
double m_minPhi
Definition: TopoClusterMap.h:82
empty
bool empty(TH1 *h)
Definition: computils.cxx:294
TopoClusterMap::InsertTopoCluster
void InsertTopoCluster(xAOD::CaloCluster *)
interface methods
Definition: TopoClusterMap.cxx:62
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
PUfitVar::maxEta
constexpr float maxEta
Definition: GepMETPufitAlg.cxx:13
TopoClusterMap::m_minEta
double m_minEta
Definition: TopoClusterMap.h:82
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
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
xAOD::CaloCluster_v1::inEndcap
bool inEndcap() const
Returns true if at least one clustered cell in the endcap.
Definition: CaloCluster_v1.h:901
constants.EMB2
int EMB2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:54
lumiFormat.i
int i
Definition: lumiFormat.py:92
CaloCluster.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TauGNNUtils::Variables::Track::dPhi
bool dPhi(const xAOD::TauJet &tau, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:530
xAOD::CaloCluster_v1::inBarrel
bool inBarrel() const
Returns true if at least one clustered cell in the barrel.
Definition: CaloCluster_v1.h:896
TopoClusterMap::m_dPhi
double m_dPhi
Definition: TopoClusterMap.h:83
constants.EME1
int EME1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:55
TopoClusterMap::SortGridVector
void SortGridVector(int eta_key, int phi_key)
Definition: TopoClusterMap.cxx:84
TopoClusterMap::GetEtaPhiKeys
std::pair< int, int > GetEtaPhiKeys(double eta, double phi) const
Definition: TopoClusterMap.h:57
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
TopoClusterMap::ClearMap
void ClearMap()
Definition: TopoClusterMap.cxx:90
TopoClusterMap.h
TopoClusterMap::~TopoClusterMap
~TopoClusterMap()
CaloCell_ID_FCS::EME3
@ EME3
Definition: FastCaloSim_CaloCell_ID.h:26
compileRPVLLRates.c2
c2
Definition: compileRPVLLRates.py:361
xAOD::CaloCluster_v1::eSample
float eSample(const CaloSample sampling) const
Definition: CaloCluster_v1.cxx:521
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
Prompt::Def::Pt
@ Pt
Definition: VarHolder.h:76
VKalVrtAthena::varHolder_detail::clear
void clear(T &var)
Definition: NtupleVars.h:48
TopoClusterMap::m_maxEta
double m_maxEta
Definition: TopoClusterMap.h:82
CaloCell_ID_FCS::PreSamplerE
@ PreSamplerE
Definition: FastCaloSim_CaloCell_ID.h:23
CaloCell_ID_FCS::PreSamplerB
@ PreSamplerB
Definition: FastCaloSim_CaloCell_ID.h:19
DeMoScan.first
bool first
Definition: DeMoScan.py:534
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
TopoClusterMap::RetrieveTopoClusters
std::vector< const xAOD::CaloCluster * > RetrieveTopoClusters(double eta, double phi, double Pt) const
Definition: TopoClusterMap.cxx:118
TauGNNUtils::Variables::Track::dEta
bool dEta(const xAOD::TauJet &tau, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:525
CaloCell_ID_FCS::EMB3
@ EMB3
Definition: FastCaloSim_CaloCell_ID.h:22
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56
CompareClusterET
bool CompareClusterET(const xAOD::CaloCluster *c1, const xAOD::CaloCluster *c2)
Definition: TopoClusterMap.cxx:10
TopoClusterMap::m_maxPhi
double m_maxPhi
Definition: TopoClusterMap.h:82
python.handimod.cc
int cc
Definition: handimod.py:523