diff --git a/DataQuality/GoodRunsLists/CMakeLists.txt b/DataQuality/GoodRunsLists/CMakeLists.txt index 8e1ad7e2869af262738f0fbbc9efeae2f69f2e23..5d4b3d496744ea22b91f50bbec7903f81c861715 100644 --- a/DataQuality/GoodRunsLists/CMakeLists.txt +++ b/DataQuality/GoodRunsLists/CMakeLists.txt @@ -26,7 +26,7 @@ atlas_add_library( GoodRunsListsLib INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} PRIVATE_INCLUDE_DIRS ${LIBXML2_INCLUDE_DIRS} LINK_LIBRARIES ${ROOT_LIBRARIES} AsgTools xAODEventInfo AsgAnalysisInterfaces - AnaAlgorithmLib EventBookkeeperToolsLib ${extra_libs} + AnaAlgorithmLib EventBookkeeperToolsLib CxxUtils ${extra_libs} PRIVATE_LINK_LIBRARIES ${LIBXML2_LIBRARIES} PathResolver ) if( NOT XAOD_STANDALONE ) diff --git a/DataQuality/GoodRunsLists/GoodRunsLists/ATLAS_CHECK_THREAD_SAFETY b/DataQuality/GoodRunsLists/GoodRunsLists/ATLAS_CHECK_THREAD_SAFETY new file mode 100644 index 0000000000000000000000000000000000000000..d430133c6643605c5de0780842dddc4ee4cff54e --- /dev/null +++ b/DataQuality/GoodRunsLists/GoodRunsLists/ATLAS_CHECK_THREAD_SAFETY @@ -0,0 +1 @@ +DataQuality/GoodRunsLists diff --git a/DataQuality/GoodRunsLists/GoodRunsLists/TGoodRunsList.h b/DataQuality/GoodRunsLists/GoodRunsLists/TGoodRunsList.h index 2312597aaabdf3d631946d5b62ebc9952abfa05f..ec27a8cb7f12e6bd7fcad1749e40f1c864d77474 100644 --- a/DataQuality/GoodRunsLists/GoodRunsLists/TGoodRunsList.h +++ b/DataQuality/GoodRunsLists/GoodRunsLists/TGoodRunsList.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ @@ -14,6 +14,7 @@ #define __TGoodRunsList__ #include "GoodRunsLists/TGoodRun.h" +#include "CxxUtils/checker_macros.h" #include "TNamed.h" #include "TString.h" #include <map> @@ -30,9 +31,6 @@ namespace Root { TGoodRunsList(const char* name); virtual ~TGoodRunsList(); - TGoodRunsList(const Root::TGoodRunsList& other) ; - TGoodRunsList& operator=(const TGoodRunsList& other) ; - void AddGRL(const TGoodRunsList& other); const Root::TGoodRunsList GetOverlapWith(const TGoodRunsList& other) const ; const Root::TGoodRunsList GetSumWith(const TGoodRunsList& other) const ; @@ -40,12 +38,12 @@ namespace Root { const Root::TGoodRunsList GetPartNotIn(const TGoodRunsList& other) const ; Bool_t HasTriggerInfo() const; - Bool_t HasRun( const Int_t& runnr ) const; - Bool_t HasRunLumiBlock( const Int_t& runnr, const Int_t& lumiblocknr ) const ; + Bool_t HasRun( Int_t runnr ) const; + Bool_t HasRunLumiBlock( Int_t runnr, Int_t lumiblocknr ) const ; Bool_t HasSameGRLInfo( const TGoodRunsList& other ) const; Bool_t HasOverlapWith( const TGoodRunsList& other, bool verb=false ) const; - void AddRunLumiBlock( const Int_t& runnr, const Int_t& lumiblocknr ); + void AddRunLumiBlock( Int_t runnr, Int_t lumiblocknr ); inline void SetVersion(const TString& version) { m_version = version; } inline void AddMetaData(const TString& key, const TString& value) { m_metadata[key] = value; } inline void SetMetaData(const std::map<TString,TString>& metadata) { m_metadata = metadata; } @@ -59,24 +57,19 @@ namespace Root { void Summary(Bool_t verbose = kFALSE) const; Bool_t IsEmpty() const; - const std::vector<int> GetRunlist() const; - const std::vector<Root::TGoodRun> GetGoodRuns() const; - const std::vector<std::string> GetTriggerList() const; - const std::vector<std::string> GetStreamList() const; + std::vector<int> GetRunlist() const; + std::vector<Root::TGoodRun> GetGoodRuns() const; + std::vector<std::string> GetTriggerList() const; + std::vector<std::string> GetStreamList() const; - const TString GetSuggestedName() const; + TString GetSuggestedName() const; void Compress(); private: TString m_version; std::map<TString,TString> m_metadata; - Bool_t m_checkGRLInfo; - - mutable Bool_t m_hasRun; - mutable Bool_t m_hasLB; - mutable Int_t m_prevRun; - mutable Int_t m_prevLB; + bool m_checkGRLInfo{false}; ClassDef(TGoodRunsList,1) }; diff --git a/DataQuality/GoodRunsLists/GoodRunsLists/TGoodRunsListWriter.h b/DataQuality/GoodRunsLists/GoodRunsLists/TGoodRunsListWriter.h index 9c2348091ba674af99ea1b9b2a891cec12441388..1b7c949768246d1345f4fbf33764ce9a2c3f20bb 100644 --- a/DataQuality/GoodRunsLists/GoodRunsLists/TGoodRunsListWriter.h +++ b/DataQuality/GoodRunsLists/GoodRunsLists/TGoodRunsListWriter.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ @@ -20,6 +20,7 @@ #include "TObject.h" #include "TString.h" +#include "CxxUtils/checker_macros.h" #include "GoodRunsLists/TMsgLogger.h" #include "GoodRunsLists/TGoodRunsList.h" #include "GoodRunsLists/TGRLCollection.h" @@ -34,7 +35,7 @@ namespace Root { class TGoodRun; class TGoodRunsList; - class TGoodRunsListWriter : public TObject { + class ATLAS_NOT_THREAD_SAFE TGoodRunsListWriter : public TObject { public: diff --git a/DataQuality/GoodRunsLists/Root/TGoodRunsList.cxx b/DataQuality/GoodRunsLists/Root/TGoodRunsList.cxx index 6d2307b8849f15e995dc4de826a083bedb214e60..159d755a113012bcbe192a60fe2a05fa62821d2a 100644 --- a/DataQuality/GoodRunsLists/Root/TGoodRunsList.cxx +++ b/DataQuality/GoodRunsLists/Root/TGoodRunsList.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ #include <iostream> @@ -12,13 +12,7 @@ ClassImp(Root::TGoodRunsList) Root::TGoodRunsList::TGoodRunsList() - : std::map<Int_t,TGoodRun>() - , TNamed("noname","notitle") - , m_checkGRLInfo(kFALSE) - , m_hasRun(kFALSE) - , m_hasLB(kFALSE) - , m_prevRun(-10) - , m_prevLB(-10) + : TGoodRunsList("noname") { } @@ -26,11 +20,6 @@ Root::TGoodRunsList::TGoodRunsList() Root::TGoodRunsList::TGoodRunsList( const char* name ) : std::map<Int_t,TGoodRun>() , TNamed(name,"notitle") - , m_checkGRLInfo(kFALSE) - , m_hasRun(kFALSE) - , m_hasLB(kFALSE) - , m_prevRun(-10) - , m_prevLB(-10) { } @@ -39,41 +28,7 @@ Root::TGoodRunsList::~TGoodRunsList() { } - -Root::TGoodRunsList::TGoodRunsList(const Root::TGoodRunsList& other) - : std::map<Int_t,TGoodRun>(other) - , TNamed(other) - , m_version(other.m_version) - , m_metadata(other.m_metadata) - , m_checkGRLInfo(other.m_checkGRLInfo) - , m_hasRun(other.m_hasRun) - , m_hasLB(other.m_hasLB) - , m_prevRun(other.m_prevRun) - , m_prevLB(other.m_prevLB) -{ -} - - -Root::TGoodRunsList& -Root::TGoodRunsList::operator=(const Root::TGoodRunsList& other) -{ - if (&other==this) { - return *this ; - } - std::map<Int_t,TGoodRun>::operator=(other); - TNamed::operator=(other); - m_version = other.m_version; - m_metadata = other.m_metadata; - m_checkGRLInfo = other.m_checkGRLInfo; - m_hasRun = other.m_hasRun; - m_hasLB = other.m_hasLB; - m_prevRun = other.m_prevRun; - m_prevLB = other.m_prevLB; - return *this ; -} - - -void +void Root::TGoodRunsList::AddGRL(const TGoodRunsList& other) { // ensure version and name are identical @@ -256,42 +211,17 @@ Root::TGoodRunsList::GetPartNotIn(const Root::TGoodRunsList& other) const Bool_t -Root::TGoodRunsList::HasRun( const Int_t& runnr ) const +Root::TGoodRunsList::HasRun( Int_t runnr ) const { - // run searched same as previous run? - if ( runnr==m_prevRun ) - { - return m_hasRun; - } - - // rationale: I need to reset the previous lumiblock here in order - // to ensure that the first lumiblock on each run gets tested. - m_prevRun=runnr; - m_prevLB = -10; - m_hasRun = ( this->find(runnr)!=this->end() ); - return m_hasRun; + return ( this->find(runnr)!=this->end() ); } Bool_t -Root::TGoodRunsList::HasRunLumiBlock( const Int_t& runnr, const Int_t& lumiblocknr ) const +Root::TGoodRunsList::HasRunLumiBlock( Int_t runnr, Int_t lumiblocknr ) const { - Bool_t pass = kFALSE; - - if (this->HasRun(runnr)) { - // rationale: this uses the cached result of the last lumi-block - // query. if we switched runs, m_prevLB will have been set to - // an invalid value in HasRun to force a re-read. - if (lumiblocknr==m_prevLB) - { - return m_hasLB; - } - m_prevLB = lumiblocknr; - m_hasLB = (this->find(runnr))->second.HasLB( lumiblocknr ); - pass = m_hasLB; - } - - return pass; + const auto run = this->find(runnr); + return ( run!=this->end() && run->second.HasLB( lumiblocknr ) ); } @@ -343,57 +273,49 @@ Root::TGoodRunsList::Summary(Bool_t verbose /*= kFALSE*/) const } -const std::vector<int> +std::vector<int> Root::TGoodRunsList::GetRunlist() const { std::vector<int> runlist; - - std::map<Int_t,Root::TGoodRun>::const_iterator itr = this->begin(); - std::map<Int_t,Root::TGoodRun>::const_iterator end = this->end(); - for (; itr!=end; ++itr) runlist.push_back(itr->first); + for (const auto& [runno, run] : *this) runlist.push_back(runno); return runlist; } -const std::vector<Root::TGoodRun> +std::vector<Root::TGoodRun> Root::TGoodRunsList::GetGoodRuns() const { std::vector<Root::TGoodRun> runlist; - - std::map<Int_t,Root::TGoodRun>::const_iterator itr = this->begin(); - std::map<Int_t,Root::TGoodRun>::const_iterator end = this->end(); - for (; itr!=end; ++itr) runlist.push_back(itr->second); + for (const auto& [runno, run] : *this) runlist.push_back(run); return runlist; } -const std::vector<std::string> +std::vector<std::string> Root::TGoodRunsList::GetTriggerList() const { std::vector<std::string> triggerchains; - std::map<TString,TString>::const_iterator itr = m_metadata.begin(); - for (; itr!=m_metadata.end(); ++itr) { - TString triggername = itr->first; + for (const auto& [key, value] : m_metadata) { + TString triggername = key; triggername.ToLower(); - if (triggername.BeginsWith("trigger") && itr->second.Length()>0) triggerchains.push_back(itr->second.Data()); + if (triggername.BeginsWith("trigger") && value.Length()>0) triggerchains.push_back(value.Data()); } return triggerchains; } -const std::vector<std::string> +std::vector<std::string> Root::TGoodRunsList::GetStreamList() const { std::vector<std::string> streamlist; - std::map<TString,TString>::const_iterator itr = m_metadata.begin(); - for (; itr!=m_metadata.end(); ++itr) { - TString streamname = itr->first; + for (const auto& [key, value] : m_metadata) { + TString streamname = key; streamname.ToLower(); - if (streamname.BeginsWith("stream") && itr->second.Length()>0) streamlist.push_back(itr->second.Data()); + if (streamname.BeginsWith("stream") && value.Length()>0) streamlist.push_back(value.Data()); } return streamlist; } @@ -464,7 +386,7 @@ Root::TGoodRunsList::IsEmpty() const } -const TString +TString Root::TGoodRunsList::GetSuggestedName() const { if (this->IsEmpty()) return "grl_empty"; @@ -488,7 +410,7 @@ Root::TGoodRunsList::GetSuggestedName() const void -Root::TGoodRunsList::AddRunLumiBlock( const Int_t& runnr, const Int_t& lumiblocknr ) +Root::TGoodRunsList::AddRunLumiBlock( Int_t runnr, Int_t lumiblocknr ) { if (runnr<0 || lumiblocknr<0) return; if (this->HasRunLumiBlock(runnr,lumiblocknr)) return; @@ -506,8 +428,6 @@ Root::TGoodRunsList::AddRunLumiBlock( const Int_t& runnr, const Int_t& lumiblock void Root::TGoodRunsList::Compress() { - std::map< Int_t, TGoodRun >::iterator itr = this->begin(); - for (; itr!=this->end(); ++itr) - itr->second.Compress(); + for (auto& [runno, run] : *this) run.Compress(); } diff --git a/LumiBlock/LumiCalc/CMakeLists.txt b/LumiBlock/LumiCalc/CMakeLists.txt index 356c2f846cf5b958be8f7260d8bc90c1ea3ef0dd..ae37adad9209dc0cb89ec0d6a7174d605128922e 100644 --- a/LumiBlock/LumiCalc/CMakeLists.txt +++ b/LumiBlock/LumiCalc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration # Declare the package name: atlas_subdir( LumiCalc ) @@ -16,7 +16,7 @@ atlas_add_library( LumiBlockCoolQuery src/LumiBlockCollectionConverter.cxx PUBLIC_HEADERS LumiCalc INCLUDE_DIRS ${COOL_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${COOL_LIBRARIES} ${ROOT_LIBRARIES} AthenaKernel GoodRunsListsLib LumiBlockData xAODLuminosity ) + LINK_LIBRARIES ${COOL_LIBRARIES} ${ROOT_LIBRARIES} AthenaKernel CxxUtils GoodRunsListsLib LumiBlockData xAODLuminosity ) atlas_add_executable( iLumiCalc src/iLumiCalc.cxx diff --git a/LumiBlock/LumiCalc/LumiCalc/LumiBlockCollectionConverter.h b/LumiBlock/LumiCalc/LumiCalc/LumiBlockCollectionConverter.h index 7052d7fe84cd6eff3de1b815a8468842d1723952..a2388ecee64faa57cf1725b4306d99f42200f682 100644 --- a/LumiBlock/LumiCalc/LumiCalc/LumiBlockCollectionConverter.h +++ b/LumiBlock/LumiCalc/LumiCalc/LumiBlockCollectionConverter.h @@ -17,6 +17,8 @@ #include <vector> #include "TString.h" +#include "CxxUtils/checker_macros.h" + namespace Root { class TGoodRunsList; class TGRLCollection; @@ -28,7 +30,7 @@ class LumiBlockCollection; typedef std::map<TString,TString> grlmetadatamap; -class LumiBlockCollectionConverter { +class ATLAS_NOT_THREAD_SAFE LumiBlockCollectionConverter { public: diff --git a/LumiBlock/LumiCalc/LumiCalc/LumiBlockRangeContainerConverter.h b/LumiBlock/LumiCalc/LumiCalc/LumiBlockRangeContainerConverter.h index c95b60bbc581a3e7e4fa886c90cb19c595cb831b..29baf0240d35bb463836685bcab872bef3063f6f 100644 --- a/LumiBlock/LumiCalc/LumiCalc/LumiBlockRangeContainerConverter.h +++ b/LumiBlock/LumiCalc/LumiCalc/LumiBlockRangeContainerConverter.h @@ -25,12 +25,13 @@ namespace Root { class TGoodRunsListWriter; } +#include "CxxUtils/checker_macros.h" #include "xAODLuminosity/LumiBlockRangeContainer.h" #include "xAODLuminosity/LumiBlockRangeAuxContainer.h" typedef std::map<TString,TString> grlmetadatamap; -class LumiBlockRangeContainerConverter { +class ATLAS_NOT_THREAD_SAFE LumiBlockRangeContainerConverter { public: diff --git a/LumiBlock/LumiCalc/LumiCalc/LumiCalculator.h b/LumiBlock/LumiCalc/LumiCalc/LumiCalculator.h index d18fc84e72ac49103ce43a35c41116f74e3fd405..1b4c7493a520fbc4bfa29a091df2bbca8c764796 100644 --- a/LumiBlock/LumiCalc/LumiCalc/LumiCalculator.h +++ b/LumiBlock/LumiCalc/LumiCalc/LumiCalculator.h @@ -1,11 +1,11 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ #ifndef LUMICALC_LUMICALCULATOR_H #define LUMICALC_LUMICALCULATOR_H - +#include "CxxUtils/checker_macros.h" #include "LumiCalc/CoolQuery.h" #include "LumiCalc/LumiBlockRangeContainerConverter.h" #include <vector> @@ -31,7 +31,7 @@ class LumiCalculator{ void UseLumiMethod(const std::string& method);// i.e. COOL Folder channel void UseLumiChannel(int chan); void UseLiveTrigger(bool live, std::string& livetrigger); - void IntegrateLumi(const xAOD::LumiBlockRangeContainer * iovc, const std::string& triggerchain); + void IntegrateLumi ATLAS_NOT_THREAD_SAFE (const xAOD::LumiBlockRangeContainer * iovc, const std::string& triggerchain); void SetCollName(const std::string& lbcollname); void setTree(TTree * tree = 0); diff --git a/LumiBlock/LumiCalc/src/LumiCalculator.cxx b/LumiBlock/LumiCalc/src/LumiCalculator.cxx index 7b79eb00494740a07430ced0692acc31c9c3fe54..7c4fe3f51b59e142ca905b4eec320e60c64871a9 100644 --- a/LumiBlock/LumiCalc/src/LumiCalculator.cxx +++ b/LumiBlock/LumiCalc/src/LumiCalculator.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ #include "LumiCalc/LumiCalculator.h" @@ -284,7 +284,7 @@ TTree * LumiCalculator::getTree(){ } //______________________________________________________________________________ -void LumiCalculator::IntegrateLumi(const xAOD::LumiBlockRangeContainer * iovc, const std::string& triggerchain){ +void LumiCalculator::IntegrateLumi ATLAS_NOT_THREAD_SAFE (const xAOD::LumiBlockRangeContainer * iovc, const std::string& triggerchain){ CoolQuery * cq_lumi = NULL;