Skip to content
Snippets Groups Projects
Commit d02a2f20 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

TrigServices: Enable static thread checker

Mark a few methods as non-thread safe. `TrigCOOLUpdateHelper` cannot use
the recommended way to access conditions via a `ReadCondHandle` as the
information needs to be read before the first event. However, the COOL
folder (/TRIGGER/HLT/COOLUPDATE) never changes during the run and thus
it is safe to use the old-style `DataHandle` access to the conditions
object.

Also apply some general cleanup to the code using C++17 features.
parent 59463c12
No related branches found
No related tags found
9 merge requests!58791DataQualityConfigurations: Modify L1Calo config for web display,!46784MuonCondInterface: Enable thread-safety checking.,!46776Updated LArMonitoring config file for WD to match new files produced using MT,!45405updated ART test cron job,!42417Draft: DIRE and VINCIA Base Fragments for Pythia 8.3,!28528Revert 63f845ae,!27054Atr20369 210,!26342Monopole: Handle fractionally charged particles,!23773TrigServices: Enable static thread checker
HLT/Trigger/TrigControl/TrigServices
...@@ -389,7 +389,7 @@ StatusCode HltEventLoopMgr::prepareForRun(const ptree& pt) ...@@ -389,7 +389,7 @@ StatusCode HltEventLoopMgr::prepareForRun(const ptree& pt)
ATH_CHECK(ita->sysBeginRun()); // TEMPORARY: beginRun is deprecated ATH_CHECK(ita->sysBeginRun()); // TEMPORARY: beginRun is deprecated
} }
// Initialize COOL helper (needs to be done after IOVDbSvc has loaded all folders) // Initialize COOL helper (needs to be done after IOVDbSvc has loaded all folders)
m_coolHelper->readFolderInfo(); ATH_CHECK(m_coolHelper->readFolderInfo());
// close any open files (e.g. THistSvc) // close any open files (e.g. THistSvc)
ATH_CHECK(m_ioCompMgr->io_finalize()); ATH_CHECK(m_ioCompMgr->io_finalize());
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "AthenaBaseComps/AthService.h" #include "AthenaBaseComps/AthService.h"
#include "AthenaKernel/EventContextClid.h" #include "AthenaKernel/EventContextClid.h"
#include "AthenaKernel/Timeout.h" #include "AthenaKernel/Timeout.h"
#include "CxxUtils/checker_macros.h"
#include "EventInfo/EventInfo.h" #include "EventInfo/EventInfo.h"
#include "EventInfo/EventID.h" // number_type #include "EventInfo/EventID.h" // number_type
#include "StoreGate/ReadHandleKey.h" #include "StoreGate/ReadHandleKey.h"
...@@ -83,7 +84,7 @@ public: ...@@ -83,7 +84,7 @@ public:
/// @name State transitions of ITrigEventLoopMgr interface /// @name State transitions of ITrigEventLoopMgr interface
///@{ ///@{
virtual StatusCode prepareForRun(const boost::property_tree::ptree& pt); virtual StatusCode prepareForRun ATLAS_NOT_THREAD_SAFE (const boost::property_tree::ptree& pt);
virtual StatusCode hltUpdateAfterFork(const boost::property_tree::ptree& pt); virtual StatusCode hltUpdateAfterFork(const boost::property_tree::ptree& pt);
///@} ///@}
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "AthenaKernel/IOVRange.h" #include "AthenaKernel/IOVRange.h"
#include "AthenaPoolUtilities/CondAttrListCollection.h" #include "AthenaPoolUtilities/CondAttrListCollection.h"
#include "CoralBase/AttributeListException.h" #include "CoralBase/AttributeListException.h"
#include "StoreGate/DataHandle.h"
// TDAQ includes // TDAQ includes
#include "CTPfragment/CTPfragment.h" #include "CTPfragment/CTPfragment.h"
...@@ -33,8 +34,6 @@ TrigCOOLUpdateHelper::TrigCOOLUpdateHelper(const std::string &type, ...@@ -33,8 +34,6 @@ TrigCOOLUpdateHelper::TrigCOOLUpdateHelper(const std::string &type,
m_robDataProviderSvc("ROBDataProviderSvc", name) m_robDataProviderSvc("ROBDataProviderSvc", name)
{} {}
TrigCOOLUpdateHelper::~TrigCOOLUpdateHelper()
{}
StatusCode TrigCOOLUpdateHelper::initialize() StatusCode TrigCOOLUpdateHelper::initialize()
{ {
...@@ -42,11 +41,6 @@ StatusCode TrigCOOLUpdateHelper::initialize() ...@@ -42,11 +41,6 @@ StatusCode TrigCOOLUpdateHelper::initialize()
service("IOVSvc", m_iovSvc, /*createIf=*/false).ignore(); service("IOVSvc", m_iovSvc, /*createIf=*/false).ignore();
service("IOVDbSvc", m_iovDbSvc, /*createIf=*/false).ignore(); service("IOVDbSvc", m_iovDbSvc, /*createIf=*/false).ignore();
// Register DataHandle with COOLUPDATE folder
if (!m_coolFolderName.empty()) {
ATH_CHECK( detStore()->regHandle(m_folderMapHandle, m_coolFolderName) );
}
if (!m_monTool.empty()) ATH_CHECK(m_monTool.retrieve()); if (!m_monTool.empty()) ATH_CHECK(m_monTool.retrieve());
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
...@@ -77,9 +71,9 @@ StatusCode TrigCOOLUpdateHelper::stop() ...@@ -77,9 +71,9 @@ StatusCode TrigCOOLUpdateHelper::stop()
// Read COOL folder info // Read COOL folder info
// Loop over all registered keys and get folder name and CLID // Loop over all registered keys and get folder name and CLID
//========================================================================= //=========================================================================
void TrigCOOLUpdateHelper::readFolderInfo() StatusCode TrigCOOLUpdateHelper::readFolderInfo()
{ {
if (m_iovDbSvc==0) return; if (m_iovDbSvc==nullptr) return StatusCode::SUCCESS;
m_folderInfo.clear(); m_folderInfo.clear();
// Loop over all keys registered with IOVDbSvc // Loop over all keys registered with IOVDbSvc
...@@ -99,18 +93,23 @@ void TrigCOOLUpdateHelper::readFolderInfo() ...@@ -99,18 +93,23 @@ void TrigCOOLUpdateHelper::readFolderInfo()
CLID clid = detStore()->clid(key); CLID clid = detStore()->clid(key);
if (clid!=CLID_NULL) if (clid!=CLID_NULL)
m_folderInfo.insert(FolderInfoMap::value_type(foldername,FolderInfo(clid, key))); m_folderInfo.insert({foldername, FolderInfo(clid, key)});
else else
ATH_MSG_ERROR("Cannot find CLID for " << key); ATH_MSG_ERROR("Cannot find CLID for " << key);
} }
if (!m_coolFolderName.empty()) { if (!m_coolFolderName.empty()) {
// Read COOL folder map
const DataHandle<CondAttrListCollection> folderMapHandle;
ATH_CHECK( detStore()->regHandle(folderMapHandle, m_coolFolderName) );
ATH_MSG_INFO("COOL folder map in " << m_coolFolderName << ":"); ATH_MSG_INFO("COOL folder map in " << m_coolFolderName << ":");
for (CondAttrListCollection::const_iterator c = m_folderMapHandle->begin(); for (auto const& [idx, attr] : *folderMapHandle) {
c != m_folderMapHandle->end(); ++c) { m_folderNames[idx] = attr["FolderName"].data<std::string>();
ATH_MSG_INFO(" (" << c->first << ") " << c->second["FolderName"].data<std::string>()); ATH_MSG_INFO(" (" << idx << ") " << m_folderNames[idx]);
} }
} }
return StatusCode::SUCCESS;
} }
StatusCode TrigCOOLUpdateHelper::resetFolders(const std::vector<std::string>& folders, StatusCode TrigCOOLUpdateHelper::resetFolders(const std::vector<std::string>& folders,
...@@ -134,13 +133,13 @@ StatusCode TrigCOOLUpdateHelper::resetFolder(const std::string& folder, ...@@ -134,13 +133,13 @@ StatusCode TrigCOOLUpdateHelper::resetFolder(const std::string& folder,
{ {
// Force a reset of folders by setting an IOVRange in the past // Force a reset of folders by setting an IOVRange in the past
if (m_iovSvc==0 || m_iovDbSvc==0) return StatusCode::SUCCESS; if (m_iovSvc==nullptr || m_iovDbSvc==nullptr) return StatusCode::SUCCESS;
// Set IOV in the past to trigger reload in IOVSvc // Set IOV in the past to trigger reload in IOVSvc
IOVRange iov_range(IOVTime(currentRun-2, 0), IOVRange iov_range(IOVTime(currentRun-2, 0),
IOVTime(currentRun-1, 0)); IOVTime(currentRun-1, 0));
FolderInfoMap::const_iterator f = m_folderInfo.find(folder); const auto& f = m_folderInfo.find(folder);
if ( f==m_folderInfo.end() ) { if ( f==m_folderInfo.end() ) {
ATH_MSG_DEBUG("Folder " << folder << " not registered with IOVDbSvc"); ATH_MSG_DEBUG("Folder " << folder << " not registered with IOVDbSvc");
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
...@@ -216,7 +215,7 @@ StatusCode TrigCOOLUpdateHelper::hltCoolUpdate(const EventContext& ctx) ...@@ -216,7 +215,7 @@ StatusCode TrigCOOLUpdateHelper::hltCoolUpdate(const EventContext& ctx)
StatusCode TrigCOOLUpdateHelper::hltCoolUpdate(const std::string& folderName, const EventContext& ctx) StatusCode TrigCOOLUpdateHelper::hltCoolUpdate(const std::string& folderName, const EventContext& ctx)
{ {
if ( m_iovSvc==0 || m_coolFolderName.empty() ) { if ( m_iovSvc==nullptr || m_coolFolderName.empty() ) {
ATH_MSG_DEBUG("Passive mode. Not updating COOL folders"); ATH_MSG_DEBUG("Passive mode. Not updating COOL folders");
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
} }
...@@ -232,23 +231,21 @@ StatusCode TrigCOOLUpdateHelper::hltCoolUpdate(const std::string& folderName, co ...@@ -232,23 +231,21 @@ StatusCode TrigCOOLUpdateHelper::hltCoolUpdate(const std::string& folderName, co
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
} }
StatusCode TrigCOOLUpdateHelper::getFolderName(CTPfragment::FolderIndex idx, std::string& folderName) StatusCode TrigCOOLUpdateHelper::getFolderName(CTPfragment::FolderIndex idx, std::string& folderName) const
{ {
if (m_coolFolderName.empty()) return StatusCode::SUCCESS; if (m_coolFolderName.empty()) return StatusCode::SUCCESS;
if (!m_folderMapHandle.isInitialized()) { const auto& itr = m_folderNames.find(idx);
ATH_MSG_ERROR("DataHandle for '" << m_coolFolderName << "' not initialized."); if (itr==m_folderNames.end()) {
return StatusCode::FAILURE;
}
try {
folderName = m_folderMapHandle->attributeList(idx)["FolderName"].data<std::string>();
}
catch (coral::AttributeListException &) {
ATH_MSG_ERROR(m_coolFolderName << " does not contain a folder for index/channel " << idx ATH_MSG_ERROR(m_coolFolderName << " does not contain a folder for index/channel " << idx
<< ". Existing folders are:"); << ". Existing folders are:");
m_folderMapHandle->dump(); for (auto const& [idx, name] : m_folderNames) {
ATH_MSG_INFO(" (" << idx << ") " << name);
}
return StatusCode::FAILURE; return StatusCode::FAILURE;
} }
folderName = itr->second;
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
} }
......
...@@ -21,17 +21,15 @@ ...@@ -21,17 +21,15 @@
#include "AthenaBaseComps/AthAlgTool.h" #include "AthenaBaseComps/AthAlgTool.h"
#include "AthenaMonitoring/Monitored.h" #include "AthenaMonitoring/Monitored.h"
#include "CxxUtils/checker_macros.h"
#include "EventInfo/EventID.h" #include "EventInfo/EventID.h"
#include "StoreGate/DataHandle.h"
#include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h" #include "ByteStreamCnvSvcBase/IROBDataProviderSvc.h"
// TDAQ includes // TDAQ includes
#include "CTPfragment/CTPExtraWordsFormat.h" #include "CTPfragment/CTPExtraWordsFormat.h"
class TH1F;
class IIOVSvc; class IIOVSvc;
class IIOVDbSvc; class IIOVDbSvc;
class CondAttrListCollection;
/** /**
* Struct to hold CLID <-> folder name mapping * Struct to hold CLID <-> folder name mapping
...@@ -64,7 +62,6 @@ struct FolderUpdate { ...@@ -64,7 +62,6 @@ struct FolderUpdate {
class TrigCOOLUpdateHelper : public AthAlgTool { class TrigCOOLUpdateHelper : public AthAlgTool {
public: public:
TrigCOOLUpdateHelper(const std::string& type, const std::string& name, const IInterface* parent); TrigCOOLUpdateHelper(const std::string& type, const std::string& name, const IInterface* parent);
virtual ~TrigCOOLUpdateHelper();
virtual StatusCode initialize() override; virtual StatusCode initialize() override;
virtual StatusCode start() override; virtual StatusCode start() override;
...@@ -88,7 +85,7 @@ public: ...@@ -88,7 +85,7 @@ public:
* @param idx Folder index * @param idx Folder index
* @param folderName Returns folder name * @param folderName Returns folder name
*/ */
StatusCode getFolderName(CTPfragment::FolderIndex idx, std::string& folderName); StatusCode getFolderName(CTPfragment::FolderIndex idx, std::string& folderName) const;
/** /**
* @brief Schedule COOL folder updates according to extra payload in CTP fragment * @brief Schedule COOL folder updates according to extra payload in CTP fragment
...@@ -98,7 +95,7 @@ public: ...@@ -98,7 +95,7 @@ public:
/** /**
* @brief Read information about existing COOL folders * @brief Read information about existing COOL folders
*/ */
void readFolderInfo(); StatusCode readFolderInfo ATLAS_NOT_THREAD_SAFE ();
private: private:
/** /**
...@@ -119,15 +116,18 @@ private: ...@@ -119,15 +116,18 @@ private:
StatusCode resetFolders(const std::vector<std::string>& folders, EventID::number_type currentRun, StatusCode resetFolders(const std::vector<std::string>& folders, EventID::number_type currentRun,
bool dropObject = false); bool dropObject = false);
typedef std::map<std::string, FolderInfo> FolderInfoMap; /// CLID/name mapping of COOL folders
FolderInfoMap m_folderInfo; //!< COOL folder info std::map<std::string, FolderInfo> m_folderInfo;
const DataHandle<CondAttrListCollection> m_folderMapHandle; /// Map to store scheduled/done COOL folder updates
std::map<CTPfragment::FolderIndex, FolderUpdate> m_folderUpdates; std::map<CTPfragment::FolderIndex, FolderUpdate> m_folderUpdates;
/// Map to store the folder update index -> name mapping
std::map<CTPfragment::FolderIndex, std::string> m_folderNames;
// Services and Tools // Services and Tools
IIOVSvc* m_iovSvc{0}; IIOVSvc* m_iovSvc{nullptr};
IIOVDbSvc* m_iovDbSvc{0}; IIOVDbSvc* m_iovDbSvc{nullptr};
ServiceHandle<IROBDataProviderSvc> m_robDataProviderSvc; ServiceHandle<IROBDataProviderSvc> m_robDataProviderSvc;
// Properties // Properties
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment