diff --git a/Control/AthenaMonitoring/src/AthenaMonManager.cxx b/Control/AthenaMonitoring/src/AthenaMonManager.cxx index 9e50504f57eef454d38e6ef6c5803f2289162423..8306a6575dc02fcb646570d0c6160927b79f7d39 100644 --- a/Control/AthenaMonitoring/src/AthenaMonManager.cxx +++ b/Control/AthenaMonitoring/src/AthenaMonManager.cxx @@ -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 */ #include "AthenaMonitoring/AthenaMonManager.h" @@ -16,8 +16,8 @@ #include "LWHistAthMonWrapper.h" #include "AthMonBench.h" +#include "Gaudi/Interfaces/IOptionsSvc.h" #include "GaudiKernel/IMessageSvc.h" -#include "GaudiKernel/IJobOptionsSvc.h" #include "GaudiKernel/ISvcLocator.h" #include "GaudiKernel/ITHistSvc.h" #include "GaudiKernel/MsgStream.h" @@ -472,25 +472,15 @@ initialize() m_d->m_environmentProp = Imp::s_environmentStr; // Provide a virtual Algorithm with a subset of the properties - IJobOptionsSvc* joSvc = 0; - sc = service( "JobOptionsSvc", joSvc ); - if( !sc.isSuccess() ) { - msg(MSG::ERROR) << "!! Unable to locate the JobOptionsSvc service !!" << endmsg; - return sc; - } + ServiceHandle<Gaudi::Interfaces::IOptionsSvc> joSvc("JobOptionsSvc", name()); + ATH_CHECK( joSvc.retrieve() ); ATH_MSG_DEBUG(" --> Found service \"JobOptionsSvc\""); - std::string client = name() + std::string("Properties"); + const std::string client = name() + std::string("Properties"); ATH_MSG_DEBUG(" --> Adding properties under name \"" << client << "\""); - StatusCode sc1 = joSvc->addPropertyToCatalogue( client, StringProperty("FileKey",m_d->m_fileKeyProp) ); - StatusCode sc2 = joSvc->addPropertyToCatalogue( client, StringProperty("DataType",m_d->m_dataTypeProp) ); - StatusCode sc3 = joSvc->addPropertyToCatalogue( client, StringProperty("Environment",m_d->m_environmentProp) ); - joSvc->release(); - if( !(sc1.isSuccess() && sc2.isSuccess() && sc3.isSuccess()) ) { - msg(MSG::ERROR) << "!! Unable to add properties to JobOptionsSvc service !!" << endmsg; - return StatusCode::FAILURE; - } - ATH_MSG_DEBUG(" --> Added Properties"); + joSvc->set( client + ".FileKey", m_d->m_fileKeyProp ); + joSvc->set( client + ".DataType", m_d->m_dataTypeProp ); + joSvc->set( client + ".Environment", m_d->m_environmentProp ); //Determine (globally for now), whether or not LW histograms use a //ROOT backend (necessary for online monitoring, and perhaps for diff --git a/Control/AthenaMonitoring/src/ManagedMonitorToolBase.cxx b/Control/AthenaMonitoring/src/ManagedMonitorToolBase.cxx index c3ce13f77ed8dcb1b12ccdfa7ea27c7173710e23..10e3b70046ea790a924a114f6908f417c1c669a7 100644 --- a/Control/AthenaMonitoring/src/ManagedMonitorToolBase.cxx +++ b/Control/AthenaMonitoring/src/ManagedMonitorToolBase.cxx @@ -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 */ #ifndef ManagedMonitorToolBase_CXX @@ -24,8 +24,8 @@ #include "AthMonBench.h" #include "StoreGate/ReadCondHandle.h" +#include "Gaudi/Interfaces/IOptionsSvc.h" #include "GaudiKernel/IHistogramSvc.h" -#include "GaudiKernel/IJobOptionsSvc.h" #include "GaudiKernel/IMessageSvc.h" #include "GaudiKernel/ISvcLocator.h" #include "GaudiKernel/MsgStream.h" @@ -745,21 +745,22 @@ initialize() return sc; } - ServiceHandle<IJobOptionsSvc> joSvc( "JobOptionsSvc", name() ); - sc = joSvc.retrieve(); - if( !sc.isSuccess() ) { - msg(MSG::ERROR) << "!! Unable to locate the JobOptionsSvc service !!" << endmsg; - return StatusCode::FAILURE; - } + ServiceHandle<Gaudi::Interfaces::IOptionsSvc> joSvc( "JobOptionsSvc", name() ); + ATH_CHECK( joSvc.retrieve() ); ATH_MSG_DEBUG(" --> Found service \"JobOptionsSvc\""); - std::string client( m_managerNameProp + "Properties" ); + const std::string client( m_managerNameProp + "Properties" ); ATH_MSG_DEBUG(" --> Asking for properties " << client); - sc = joSvc->setMyProperties( client, this ); - if( !sc.isSuccess() ) { - msg(MSG::ERROR) << "!! Unable to set properties in JobOptionsSvc !!" << endmsg; - } - ATH_MSG_DEBUG(" --> Set Properties in \"JobOptionsSvc\""); + + auto getProp = [this,joSvc](std::string& var, const std::string& name) { + if (joSvc->has(name)) + var = joSvc->get(name); + else + ATH_MSG_ERROR("Cannot read " << name); + }; + getProp( m_fileKey, client + ".FileKey"); + getProp( m_dataTypeStr, client + ".DataType"); + getProp( m_environmentStr, client + ".Environment"); ATH_MSG_DEBUG(" * Properties set from " << client << " to the values:\n" << " FileKey: " << m_fileKey << "\n"