diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/ATLAS_CHECK_THREAD_SAFETY b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/ATLAS_CHECK_THREAD_SAFETY new file mode 100644 index 0000000000000000000000000000000000000000..874f85699a44c20f3ea9b5c04db7142dea0243d0 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/ATLAS_CHECK_THREAD_SAFETY @@ -0,0 +1 @@ +LArCalorimeter/LArG4/LArG4Code diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/CalibrationHit.h b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/CalibrationHit.h index 316f9403f568cf1bb23a64867a2cefd57fcbfb68..340425b93c31d8b3f3d1d3a804bbd84a606db1d3 100644 --- a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/CalibrationHit.h +++ b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/CalibrationHit.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 */ // CalibrationHit.h @@ -122,7 +122,7 @@ namespace LArG4 { typedef G4THitsCollection<CalibrationHit> CalibrationHitsCollection; - extern G4Allocator<CalibrationHit> CalibrationHitAllocator; + extern thread_local G4Allocator<CalibrationHit> CalibrationHitAllocator; inline void* CalibrationHit::operator new(size_t) { diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/DerivedILArCalculatorSvcForTest.h b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/DerivedILArCalculatorSvcForTest.h index 24feb99cb1126568d287f8904d078de0f8c30d86..22f8ab1350fec512c5aae5784f4dd0bde451a323 100644 --- a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/DerivedILArCalculatorSvcForTest.h +++ b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/DerivedILArCalculatorSvcForTest.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // defining this class is just used for testing since class ILArCalculatorSvc is a abstract class which needs to be instatiated in my test code @@ -7,8 +7,8 @@ // To make matters more complicated, the classes(i.e. INamedInterface and IStateful) that IService inherits are also abstract, so I need to override the pure virtual functions in classes INamedInterface and IStateful // In addition, since INamedInterface and IStateful all inherit the class IInterface, which is abstract. Therefore, I also override the pure virtual functions in the class IInterface. -#ifndef __DERIVEDILARCALCULATORSVC_H__ -#define __DERIVEDILARCALCULATORSVC_H__ +#ifndef LARG4CODE_DERIVEDILARCALCULATORSVCFORTEST_H +#define LARG4CODE_DERIVEDILARCALCULATORSVCFORTEST_H #include "LArG4Code/ILArCalculatorSvc.h" #include "GaudiKernel/StateMachine.h" @@ -130,9 +130,9 @@ public: return Gaudi::StateMachine::State(0); } - std::string& name() const + const std::string& name() const { - static std::string Tes = "test"; + static const std::string Tes = "test"; return Tes; } diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/DerivedILArCalibCalculatorSvcForTest.h b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/DerivedILArCalibCalculatorSvcForTest.h index f44bf00a45549525fa8a7bf7b93d69dd1872aad7..f386344639562a832f15e4203beed63d02758435 100644 --- a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/DerivedILArCalibCalculatorSvcForTest.h +++ b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/DerivedILArCalibCalculatorSvcForTest.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // defining this class is just used for testing since class LArCalibCalculatorSvc is a abstract class which needs to be instatiated in my test code @@ -7,8 +7,8 @@ // To make matters more complicated, the classes(i.e. INamedInterface and IStateful) that IService inherits are also abstract, so I need to override the pure virtual functions in classes INamedInterface and IStateful // In addition, since INamedInterface and IStateful all inherit the class IInterface, which is abstract. Therefore, I also override the pure virtual functions in the class IInterface. -#ifndef __DERIVEDILARCALIBCALCULATORSVC_H__ -#define __DERIVEDILARCALIBCALCULATORSVC_H__ +#ifndef LARG4CODE_DERIVEDILARCALIBCALCULATORSVCFORTEST_H +#define LARG4CODE_DERIVEDILARCALIBCALCULATORSVCFORTEST_H #include "LArG4Code/ILArCalibCalculatorSvc.h" #include "GaudiKernel/StateMachine.h" @@ -130,9 +130,9 @@ public: return Gaudi::StateMachine::State(0); } - std::string& name() const + const std::string& name() const { - static std::string Tes = "test"; + static const std::string Tes = "test"; return Tes; } diff --git a/LArCalorimeter/LArG4/LArG4Code/src/CalibrationHit.cc b/LArCalorimeter/LArG4/LArG4Code/src/CalibrationHit.cc index 3ea60f5b1548d848ef3014984c51b922939e901f..90d001b7bbbfc0d12ae8112639299e7d021bc5ab 100644 --- a/LArCalorimeter/LArG4/LArG4Code/src/CalibrationHit.cc +++ b/LArCalorimeter/LArG4/LArG4Code/src/CalibrationHit.cc @@ -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 */ // CalibrationHit.h @@ -16,7 +16,7 @@ namespace LArG4 { - G4Allocator<CalibrationHit> CalibrationHitAllocator; + thread_local G4Allocator<CalibrationHit> CalibrationHitAllocator; void CalibrationHit::Draw() {;} diff --git a/LArCalorimeter/LArG4/LArG4Code/src/LArG4Identifier.cc b/LArCalorimeter/LArG4/LArG4Code/src/LArG4Identifier.cc index 107e3d3c5b551a0ba9e8287e5023b3d2ab4b8e7a..a959acfaf7b2c081f471fa37f393f471748e0a58 100644 --- a/LArCalorimeter/LArG4/LArG4Code/src/LArG4Identifier.cc +++ b/LArCalorimeter/LArG4/LArG4Code/src/LArG4Identifier.cc @@ -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 */ @@ -122,11 +122,7 @@ LArG4Identifier::element_type & LArG4Identifier::operator [] (size_type index) if (index >= m_fields.size ()) { - static element_type dummy = 0; - - set_last_error (field_not_found); - - return (dummy); + throw std::out_of_range ("LArG4Identifier::operator[]"); } return (m_fields[index]); @@ -355,7 +351,7 @@ void LArG4Identifier::show () const //---------------------------------------------------------------- LArG4Identifier::error_code LArG4Identifier::set_last_error (error_code code) const { - static error_code last = none; + static thread_local error_code last = none; if (code != get) { diff --git a/LArCalorimeter/LArG4/LArG4Code/test/LArG4CalibSD_gtest.cxx b/LArCalorimeter/LArG4/LArG4Code/test/LArG4CalibSD_gtest.cxx index 8baa79ded2af35d500d5f32dd3208668f81fd509..6e2382c17faf1c835bba0f770cd3f628a9a7c072 100644 --- a/LArCalorimeter/LArG4/LArG4Code/test/LArG4CalibSD_gtest.cxx +++ b/LArCalorimeter/LArG4/LArG4Code/test/LArG4CalibSD_gtest.cxx @@ -2,6 +2,9 @@ Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ +#include "CxxUtils/checker_macros.h" +ATLAS_NO_CHECK_FILE_THREAD_SAFETY; + #include "LArG4Code/LArG4CalibSD.h" #include "gtest/gtest.h" diff --git a/LArCalorimeter/LArG4/LArG4Code/test/LArG4SimpleSD_gtest.cxx b/LArCalorimeter/LArG4/LArG4Code/test/LArG4SimpleSD_gtest.cxx index 2296f3d31e029e43605e2ba2c9a7c6e43ee88b35..08b5ff3201c56e352a8f1340a86e7f224a6777c3 100644 --- a/LArCalorimeter/LArG4/LArG4Code/test/LArG4SimpleSD_gtest.cxx +++ b/LArCalorimeter/LArG4/LArG4Code/test/LArG4SimpleSD_gtest.cxx @@ -2,6 +2,9 @@ Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ +#include "CxxUtils/checker_macros.h" +ATLAS_NO_CHECK_FILE_THREAD_SAFETY; + #include "LArG4Code/LArG4SimpleSD.h" #include "gtest/gtest.h" diff --git a/LArCalorimeter/LArG4/LArG4Code/test/SDWrapper_gtest.cxx b/LArCalorimeter/LArG4/LArG4Code/test/SDWrapper_gtest.cxx index 3a4ff99cc7161c1181e6bbd411c599e10262d098..a1868ca958ffd21c0b51cb1c764357535bac1fcf 100644 --- a/LArCalorimeter/LArG4/LArG4Code/test/SDWrapper_gtest.cxx +++ b/LArCalorimeter/LArG4/LArG4Code/test/SDWrapper_gtest.cxx @@ -1,7 +1,10 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ +#include "CxxUtils/checker_macros.h" +ATLAS_NO_CHECK_FILE_THREAD_SAFETY; + #define SDWRAPPER_TEST//define the macro name to use it in the tested class SDWrapper. Using the macro name to do conditional compiling on the "private:" statement in the file SDWrapper.h #include "LArG4Code/SDWrapper.h"