From 2d80b77b4552c851b9b8e0402878e522edeb3f79 Mon Sep 17 00:00:00 2001
From: Susumu Oda <susumu.oda@cern.ch>
Date: Tue, 30 Jun 2020 12:35:25 +0000
Subject: [PATCH] Add ATLAS_NO_CHECK_FILE_THREAD_SAFETY to
 InDetGlobalBCMTool.h/cxx because this class uses static unsigned int
 bcid_max. This variable is used in global bcid_select method. This method is
 used for positions_C[gain].remove_if(bcid_select).

---
 .../ATLAS_CHECK_THREAD_SAFETY                 |  1 +
 .../src/InDetGlobalBCMTool.cxx                | 21 ++++++++++---------
 .../src/InDetGlobalBCMTool.h                  |  5 +++--
 3 files changed, 15 insertions(+), 12 deletions(-)
 create mode 100644 InnerDetector/InDetMonitoring/InDetGlobalMonitoring/ATLAS_CHECK_THREAD_SAFETY

diff --git a/InnerDetector/InDetMonitoring/InDetGlobalMonitoring/ATLAS_CHECK_THREAD_SAFETY b/InnerDetector/InDetMonitoring/InDetGlobalMonitoring/ATLAS_CHECK_THREAD_SAFETY
new file mode 100644
index 00000000000..f100eb8b183
--- /dev/null
+++ b/InnerDetector/InDetMonitoring/InDetGlobalMonitoring/ATLAS_CHECK_THREAD_SAFETY
@@ -0,0 +1 @@
+InnerDetector/InDetMonitoring/InDetGlobalMonitoring
diff --git a/InnerDetector/InDetMonitoring/InDetGlobalMonitoring/src/InDetGlobalBCMTool.cxx b/InnerDetector/InDetMonitoring/InDetGlobalMonitoring/src/InDetGlobalBCMTool.cxx
index 3fbd71a2b27..2d2661de030 100755
--- a/InnerDetector/InDetMonitoring/InDetGlobalMonitoring/src/InDetGlobalBCMTool.cxx
+++ b/InnerDetector/InDetMonitoring/InDetGlobalMonitoring/src/InDetGlobalBCMTool.cxx
@@ -1,4 +1,3 @@
-
 /*
   Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 */
@@ -46,14 +45,13 @@ using namespace TMath;
 #define BCM_LVL1A 18
 
 //Some variables
-static unsigned int bcid_start 				= 0; //to choose the first bcid displayed
-static unsigned int bcids_displayed 			= 3570; //to choose the number of bcids displayed when bcid as x-axis
-static unsigned int bcid_max 				= 0;
-static signed int ecr_start                             = 0;    //to chose the first ECR displayed
-static unsigned int ecrs_displayed                      = 256;  //to chose the number of ecrs displayed when ECR as X-axis
+static const unsigned int bcid_start 				= 0; //to choose the first bcid displayed
+static const unsigned int bcids_displayed 			= 3570; //to choose the number of bcids displayed when bcid as x-axis
+static const signed int ecr_start                             = 0;    //to chose the first ECR displayed
+static const unsigned int ecrs_displayed                      = 256;  //to chose the number of ecrs displayed when ECR as X-axis
 static const unsigned int bc_readout			= 31;   // length of read out per L1A, at the moment 31 BCs re read out
-static unsigned int lb_start 				= 0;
-static unsigned int lb_max				= 5000;
+static const unsigned int lb_start 				= 0;
+static const unsigned int lb_max				= 5000;
 
 // the declare property can be used to make variables accessible through python
 InDetGlobalBCMTool::InDetGlobalBCMTool(
@@ -592,7 +590,7 @@ bool deltat_data::operator<(const deltat_data &data){
 }
 
 bool bcid_select(const deltat_data &data){
-  return (data.bcid <bcid_max);
+  return (data.bcid <data.bcid_max);
 }
 
 StatusCode InDetGlobalBCMTool::fillHistograms(){
@@ -1069,7 +1067,10 @@ StatusCode InDetGlobalBCMTool::fillHistograms(){
 	    }
 	  }//end of bcid if
 	}//end of c loop
-	bcid_max=(positions_A[gain].front()).bcid;
+    // Need to set bcid_max before using bcid_select method
+    for (deltat_data& data : positions_C[gain]) {
+      data.bcid_max = (positions_A[gain].front()).bcid;
+    }
 	positions_C[gain].remove_if(bcid_select);
 	positions_A[gain].pop_front();
       }//end of a loop
diff --git a/InnerDetector/InDetMonitoring/InDetGlobalMonitoring/src/InDetGlobalBCMTool.h b/InnerDetector/InDetMonitoring/InDetGlobalMonitoring/src/InDetGlobalBCMTool.h
index 639076d4089..d580920fa54 100755
--- a/InnerDetector/InDetMonitoring/InDetGlobalMonitoring/src/InDetGlobalBCMTool.h
+++ b/InnerDetector/InDetMonitoring/InDetGlobalMonitoring/src/InDetGlobalBCMTool.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
 */
 
 /** @file InDetGlobalBCMTool.h
@@ -141,10 +141,11 @@ private:
     class deltat_data{
     public: 
       unsigned int bcid;
+      unsigned int bcid_max;
       unsigned int ecr;
       unsigned int position;
       unsigned int detector;
-	unsigned int lvl1a;
+      unsigned int lvl1a;
       deltat_data();
       bool operator<(const deltat_data &data);
       // deltat_data min(const deltat_data &data);
-- 
GitLab