Skip to content
Snippets Groups Projects
Commit b7b78d38 authored by Scott Snyder's avatar Scott Snyder Committed by Graeme Stewart
Browse files

'Comply with ATLAS naming conventions.' (CaloClusterMatching-00-00-04)

	* Tagging CaloClusterMatching-00-00-04.
	* Comply with ATLAS naming conventions.
	* Tagging CaloClusterMatching-00-00-03.
	* Fix coverity warning 111040 (potential memory leak).


Former-commit-id: 499f4c8aecf438f4f9e18e2fa29c772e3082aa9f
parent ea21c2bc
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@ atlas_depends_on_subdirs( PUBLIC
GaudiKernel
PRIVATE
Control/AthenaBaseComps
Control/CxxUtils
Event/xAOD/xAODCore )
# Component(s) in the package:
......
......@@ -16,6 +16,7 @@ use AsgTools AsgTools-* Control/AthToolSupport
private
use xAODCore xAODCore-* Event/xAOD
use AthenaBaseComps AthenaBaseComps-* Control
use CxxUtils CxxUtils-* Control
end_private
......
......@@ -17,6 +17,7 @@
// FrameWork includes
#include "GaudiKernel/IToolSvc.h"
#include "TopoClusterMap.h"
#include "CxxUtils/make_unique.h"
#include <algorithm>
#include <utility>
......@@ -81,10 +82,10 @@ namespace ClusterMatching {
const CaloClusterContainer* topoclusters(nullptr);
ATH_CHECK( evtStore()->retrieve(topoclusters,m_clustersIn) );
TopoClusterMap* tcmap = new TopoClusterMap;
auto tcmap = CxxUtils::make_unique<TopoClusterMap>();
ATH_CHECK( tcmap->SetTopoClusters(topoclusters) );
ATH_CHECK( evtStore()->record(tcmap,m_mapName) );
ATH_CHECK( evtStore()->record(std::move(tcmap),m_mapName) );
return StatusCode::SUCCESS;
}
......
......@@ -23,12 +23,12 @@ bool CompareClusterET (const xAOD::CaloCluster* c1, const xAOD::CaloCluster* c2)
TopoClusterMap::TopoClusterMap(float minEta, float minPhi, float maxEta, float maxPhi,
float dEta, float dPhi)
{
_minEta = minEta;
_minPhi = minPhi;
_maxEta = maxEta;
_maxPhi = maxPhi;
_dEta = dEta;
_dPhi = dPhi;
m_minEta = minEta;
m_minPhi = minPhi;
m_maxEta = maxEta;
m_maxPhi = maxPhi;
m_dEta = dEta;
m_dPhi = dPhi;
}
//Destructor.
......@@ -53,7 +53,7 @@ StatusCode TopoClusterMap::SetTopoClusters(const xAOD::CaloClusterContainer *inp
phi = cc->phi();
//Put it in appropriate vector.
_map[GetEtaPhiKeys(eta,phi).first][GetEtaPhiKeys(eta,phi).second].push_back(cc);
m_map[GetEtaPhiKeys(eta,phi).first][GetEtaPhiKeys(eta,phi).second].push_back(cc);
}
SortGridVectors();
......@@ -67,7 +67,7 @@ void TopoClusterMap::InsertTopoCluster(xAOD::CaloCluster* topo) {
double eta(topo->phi()), phi(topo->phi());
//Put it in appropriate vector.
_map.at(GetEtaPhiKeys(eta,phi).first).at(GetEtaPhiKeys(eta,phi).second).push_back(topo);
m_map.at(GetEtaPhiKeys(eta,phi).first).at(GetEtaPhiKeys(eta,phi).second).push_back(topo);
//Re-sort the vector according to Et.
SortGridVector(GetEtaPhiKeys(eta,phi).first, GetEtaPhiKeys(eta,phi).second);
......@@ -77,38 +77,38 @@ void TopoClusterMap::InsertTopoCluster(xAOD::CaloCluster* topo) {
//Boolean comparison somewhere here that sorts vectors in grid by Et.
void TopoClusterMap::SortGridVectors() {
for (int i = 0; i <= (GetEtaPhiKeys(_maxEta, _maxPhi).first); i++)
for (int j = 0; j <= (GetEtaPhiKeys(_maxEta, _maxPhi).second); j++)
for (int i = 0; i <= (GetEtaPhiKeys(m_maxEta, m_maxPhi).first); i++)
for (int j = 0; j <= (GetEtaPhiKeys(m_maxEta, m_maxPhi).second); j++)
SortGridVector(i,j);
}
void TopoClusterMap::SortGridVector(int eta_key, int phi_key) {
if (_map[eta_key][phi_key].size()>0)
sort( _map[eta_key][phi_key].begin(), _map[eta_key][phi_key].end(), CompareClusterET );
if (m_map[eta_key][phi_key].size()>0)
sort( m_map[eta_key][phi_key].begin(), m_map[eta_key][phi_key].end(), CompareClusterET );
}
void TopoClusterMap::ClearMap() {
for (int i = 0; i <= (GetEtaPhiKeys(_maxEta, _maxPhi).first); i++)
for (int j = 0; j <= (GetEtaPhiKeys(_maxEta, _maxPhi).second); j++)
_map[i][j].clear();
for (int i = 0; i <= (GetEtaPhiKeys(m_maxEta, m_maxPhi).first); i++)
for (int j = 0; j <= (GetEtaPhiKeys(m_maxEta, m_maxPhi).second); j++)
m_map[i][j].clear();
}
// void TopoClusterMap::DumpMapContents() {
// for (int i = 0; i <= (GetEtaPhiKeys(_maxEta, _maxPhi).first); i++)
// for (int j = 0; j <= (GetEtaPhiKeys(_maxEta, _maxPhi).second); j++) {
// ATH_MSG_DEBUG("Size of topocluster vector at (" << i << "," << j << "): " << _map[i][j].size());
// if (_map[i][j].size()) {
// for (int i = 0; i <= (GetEtaPhiKeys(m_maxEta, m_maxPhi).first); i++)
// for (int j = 0; j <= (GetEtaPhiKeys(m_maxEta, m_maxPhi).second); j++) {
// ATH_MSG_DEBUG("Size of topocluster vector at (" << i << "," << j << "): " << m_map[i][j].size());
// if (m_map[i][j].size()) {
// ATH_MSG_DEBUG("Contents of vector:");
// for (unsigned int k = 0; k < _map[i][j].size(); k++) {
// //ATH_MSG_DEBUG("E: %f, eta: %f, phi: %f, Pt: %f \n",(_map[i][j])[k]->e(), (_map[i][j])[k]->eta(), (_map[i][j])[k]->phi(), (_map[i][j])[k]->pt());
// ATH_MSG_DEBUG("E: " << (_map[i][j])[k]->e()
// << ", eta: " << (_map[i][j])[k]->eta()
// << ", phi: " << (_map[i][j])[k]->phi()
// << ", Pt: " << (_map[i][j])[k]->pt());
// for (unsigned int k = 0; k < m_map[i][j].size(); k++) {
// //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());
// ATH_MSG_DEBUG("E: " << (m_map[i][j])[k]->e()
// << ", eta: " << (m_map[i][j])[k]->eta()
// << ", phi: " << (m_map[i][j])[k]->phi()
// << ", Pt: " << (m_map[i][j])[k]->pt());
// }
// }
// }
......@@ -152,14 +152,14 @@ std::vector<const xAOD::CaloCluster*> TopoClusterMap::RetrieveTopoClusters(doubl
for (int ieta = lower_keys.first; ieta <= upper_keys.first; ieta++)
for (int iphi = lower_keys.second; iphi <= upper_keys.second; iphi++)
clusters.insert(clusters.end(), _map.at(ieta).at(iphi).begin(), _map.at(ieta).at(iphi).end());
clusters.insert(clusters.end(), m_map.at(ieta).at(iphi).begin(), m_map.at(ieta).at(iphi).end());
//Re-sort vector according to Et and return it.
sort( clusters.begin(), clusters.end(), CompareClusterET );
} else {
clusters = _map.at(GetEtaPhiKeys(eta,phi).first).at(GetEtaPhiKeys(eta,phi).second);
clusters = m_map.at(GetEtaPhiKeys(eta,phi).first).at(GetEtaPhiKeys(eta,phi).second);
}
return clusters;
......
......@@ -36,7 +36,7 @@ class TopoClusterMap {
//Function to set TopoClusters.
StatusCode SetTopoClusters(const xAOD::CaloClusterContainer*);
TopoCluster2DMap& RetrieveMap() {return _map;}
TopoCluster2DMap& RetrieveMap() {return m_map;}
//Routine to retrieve vector of TopoClusters for a given Pt region.
std::vector<const xAOD::CaloCluster*> RetrieveTopoClusters(double eta, double phi,
......@@ -50,23 +50,23 @@ class TopoClusterMap {
//Routine to retrieve vector of TopoClusters for a given (eta, phi) region.
inline std::vector<const xAOD::CaloCluster*> RetrieveTopoClusters(int eta_key, int phi_key) const
{
return _map.at(eta_key).at(phi_key);
return m_map.at(eta_key).at(phi_key);
}
//Private routine to translate an input eta, phi into integer keys for map.
inline std::pair<int,int> GetEtaPhiKeys(double eta, double phi) const {
//Some checks on eta, phi values.
if (eta > _maxEta) eta = _maxEta;
if (eta < _minEta) eta = _minEta;
if (phi > _maxPhi) phi = _maxPhi;
if (phi < _minPhi) phi = _minPhi;
if (eta > m_maxEta) eta = m_maxEta;
if (eta < m_minEta) eta = m_minEta;
if (phi > m_maxPhi) phi = m_maxPhi;
if (phi < m_minPhi) phi = m_minPhi;
//Need some warnings against max/min eta, phi here, I think.
int eta_key = (int)((eta-_minEta)/_dEta);
int eta_key = (int)((eta-m_minEta)/m_dEta);
//NOTE: May have to account for phi wraparound here.
int phi_key = (int)((phi-_minPhi)/_dPhi);
int phi_key = (int)((phi-m_minPhi)/m_dPhi);
return std::pair<int,int>(eta_key,phi_key);
......@@ -76,11 +76,11 @@ class TopoClusterMap {
private:
TopoCluster2DMap _map;
TopoCluster2DMap m_map;
//Map granularity and range.
double _minEta, _minPhi, _maxEta, _maxPhi;
double _dEta, _dPhi;
double m_minEta, m_minPhi, m_maxEta, m_maxPhi;
double m_dEta, m_dPhi;
//Routine to sort topocluster grid elements by Pt.
void SortGridVectors();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment