From 25d40f693a1a59e30bb32315c8e1c81e52b5890b Mon Sep 17 00:00:00 2001
From: Susumu Oda <susumu.oda@cern.ch>
Date: Tue, 30 Jun 2020 18:47:50 +0200
Subject: [PATCH] Replace a static local variable by a mutable atomic memeber
 variable in the TRT_StrawStatus class.

---
 .../TRT_CalibAlgs/TRT_CalibAlgs/TRT_StrawStatus.h            | 5 ++++-
 .../InDetCalibAlgs/TRT_CalibAlgs/src/TRT_StrawStatus.cxx     | 5 ++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/TRT_CalibAlgs/TRT_StrawStatus.h b/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/TRT_CalibAlgs/TRT_StrawStatus.h
index 5bd87a20787..8c2bb4a9163 100644
--- a/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/TRT_CalibAlgs/TRT_StrawStatus.h
+++ b/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/TRT_CalibAlgs/TRT_StrawStatus.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
 */
 
 ///////////////////////////////////////////////////////////////////
@@ -27,6 +27,7 @@
 #include <string>
 #include <vector>
 #include <array>
+#include <atomic>
 
 class AtlasDetectorID;
 class Identifier;
@@ -112,6 +113,8 @@ namespace InDet
 
       /** member variables for algorithm properties: */
       int m_printDetailedInformation;
+
+      mutable std::atomic<int> m_printStatusCount{0};
     }; 
 } // end of namespace
 
diff --git a/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/src/TRT_StrawStatus.cxx b/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/src/TRT_StrawStatus.cxx
index 8c2eee00af5..83ec8b08bd3 100644
--- a/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/src/TRT_StrawStatus.cxx
+++ b/InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/src/TRT_StrawStatus.cxx
@@ -358,12 +358,11 @@ void InDet::TRT_StrawStatus::printDetailedInformation() {
             int chip, HVpad;    
             m_TRTStrawNeighbourSvc->getChip(id, chip);
             m_TRTStrawNeighbourSvc->getPad(id, HVpad);
-            static int printStatusCount(0);
-            if (!printStatusCount) {
+            if (!m_printStatusCount) {
                 ATH_MSG_INFO( "if the code crashes on the next line, there is a problem with m_TRTStrawStatusSummarySvc not being loaded " );
                 ATH_MSG_INFO( "in that case, running with reco turned on normally solves the problem, know of no better solution at the moment" );
                 ATH_MSG_INFO( "if you do not need the detailed print information, you can also just set printDetailedInformation to 0 to avoid this crash" ); 
-                printStatusCount++;
+                m_printStatusCount++;
             }
             int status = m_TRTStrawStatusSummaryTool->get_status( id );  
             int statusTemporary = m_TRTStrawStatusSummaryTool->getStatus( id );
-- 
GitLab