From 0ec1f9eb83a35f1dc0f511792c4180b019c6480d Mon Sep 17 00:00:00 2001 From: christos <christos@cern.ch> Date: Sat, 11 Jul 2020 00:40:02 +0100 Subject: [PATCH] CaloDmDetDescr add ATLAS_CHECK_THREAD_SAFETY --- .../CaloDmDetDescr/ATLAS_CHECK_THREAD_SAFETY | 1 + .../CaloDmDetDescr/CaloDmDescrManager.h | 3 +-- .../CaloDmDetDescr/src/CaloDmDescrManager.cxx | 21 +++++++------------ 3 files changed, 9 insertions(+), 16 deletions(-) create mode 100644 Calorimeter/CaloDmDetDescr/CaloDmDetDescr/ATLAS_CHECK_THREAD_SAFETY diff --git a/Calorimeter/CaloDmDetDescr/CaloDmDetDescr/ATLAS_CHECK_THREAD_SAFETY b/Calorimeter/CaloDmDetDescr/CaloDmDetDescr/ATLAS_CHECK_THREAD_SAFETY new file mode 100644 index 00000000000..6797cd81544 --- /dev/null +++ b/Calorimeter/CaloDmDetDescr/CaloDmDetDescr/ATLAS_CHECK_THREAD_SAFETY @@ -0,0 +1 @@ +Calorimeter/CaloDmDetDescr diff --git a/Calorimeter/CaloDmDetDescr/CaloDmDetDescr/CaloDmDescrManager.h b/Calorimeter/CaloDmDetDescr/CaloDmDetDescr/CaloDmDescrManager.h index acaa8e2fc22..466c5cbbcc4 100755 --- a/Calorimeter/CaloDmDetDescr/CaloDmDetDescr/CaloDmDescrManager.h +++ b/Calorimeter/CaloDmDetDescr/CaloDmDetDescr/CaloDmDescrManager.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /* **************************************************************************** @@ -157,7 +157,6 @@ class CaloDmDescrManager { const CaloDM_ID* m_caloDM_ID; const AtlasDetectorID* m_id_helper; StoreGateSvc* m_detStore; - static CaloDmDescrManager* s_instance; CaloDmDescrElement* build_element(const Identifier& cellId, const CaloDmRegion *myRegion); StatusCode load_regions(std::string DmRegionFileName); diff --git a/Calorimeter/CaloDmDetDescr/src/CaloDmDescrManager.cxx b/Calorimeter/CaloDmDetDescr/src/CaloDmDescrManager.cxx index 28b9482c605..0da40d9aec5 100755 --- a/Calorimeter/CaloDmDetDescr/src/CaloDmDescrManager.cxx +++ b/Calorimeter/CaloDmDetDescr/src/CaloDmDescrManager.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /* **************************************************************************** @@ -28,15 +28,11 @@ #include <fstream> #include <string> #include <vector> -#include <map> #include <cmath> #define MAX_BUFFER_LEN 1024 #undef DEBUG -CaloDmDescrManager* CaloDmDescrManager::s_instance = 0; - - /* ************************************************************************** ************************************************************************** */ @@ -69,11 +65,8 @@ CaloDmDescrManager::~CaloDmDescrManager() ************************************************************************** */ const CaloDmDescrManager* CaloDmDescrManager::instance() { - if(s_instance==0) - { - s_instance = new CaloDmDescrManager(); - } - return s_instance; + static const CaloDmDescrManager s_instance; + return &s_instance; } @@ -146,13 +139,13 @@ CaloDmDescrElement* CaloDmDescrManager::get_element(const Identifier& cellId) co hash = m_caloDM_ID->lar_zone_hash_max() + m_caloDM_ID->tile_zone_hash(cellId); } else { std::cout << "CaloDmDescrManager::get_element-> Error! Wrong dead material identifier! " << m_id_helper->show_to_string(cellId) << std::endl; - return 0; + return nullptr; } if(hash < m_DmElementVector.size()) { return m_DmElementVector[hash]; } else { std::cout << "CaloDmDescrManager::get_element-> Error! Bad hash id for dead material identifier " << hash << std::endl; - return 0; + return nullptr; } } @@ -199,13 +192,13 @@ CaloDmRegion* CaloDmDescrManager::get_dm_region(const Identifier& cellId) const hash_reg = m_caloDM_ID->lar_region_hash_max() + m_caloDM_ID->tile_region_hash(id_reg); } else { std::cout << "CaloDmDescrManager::get_dm_region-> Error! Wrong dead material identifier! " << m_id_helper->show_to_string(cellId) << std::endl; - return 0; + return nullptr; } if(hash_reg < m_DmRegionVector.size()) { return m_DmRegionVector[hash_reg]; } else { std::cout << "CaloDmDescrManager::get_dm_region-> Error! Bad region hash id!" << m_id_helper->show_to_string(cellId) << std::endl; - return 0; + return nullptr; } } -- GitLab