diff --git a/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp b/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp index 75f11b2133a0eadc9ea352563dd4a8d65dfe277c..a8f02e9d9f13e4ebd5977390b4aa9193fa723ae4 100644 --- a/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp +++ b/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp @@ -162,10 +162,17 @@ StatusCode ApplicationMgr::i_startup() { log << MSG::FATAL << "Error setting OutputLevel option of MessageSvc" << endmsg; return sc; } - if ( gROOT ) { - // if ROOT is already initialized (usually it is the case) we redirect messages to MessageSvc. - s_messageSvcInstance = m_messageSvc.get(); - SetErrorHandler( ROOTErrorHandlerAdapter ); + if ( m_useMessageSvcForROOTMessages ) { + if ( gROOT ) { + // if ROOT is already initialized (usually it is the case) we redirect messages to MessageSvc. + s_messageSvcInstance = m_messageSvc.get(); + SetErrorHandler( ROOTErrorHandlerAdapter ); + } else { + log << MSG::WARNING + << "ROOT not yet initialized, we cannot override the error handler are requested " + "(UseMessageSvcForROOTMessages==true)" + << endmsg; + } } auto jobsvc = svcManager()->createService( Gaudi::Utils::TypeNameString( "JobOptionsSvc", m_jobOptionsSvcType ) ); diff --git a/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.h b/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.h index e845c60ead1ca0d10b51a242727a44d88596092c..27c3e8e89fbf7d1656dffd90a28e86d060ee630f 100644 --- a/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.h +++ b/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.h @@ -1,5 +1,5 @@ /***********************************************************************************\ -* (c) Copyright 1998-2021 CERN for the benefit of the LHCb and ATLAS collaborations * +* (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations * * * * This software is distributed under the terms of the Apache version 2 licence, * * copied verbatim in the file "LICENSE". * @@ -310,6 +310,9 @@ protected: Gaudi::Property<bool> m_printAlgsSequence{ this, "PrintAlgsSequence", false, "Print the sequence of algorithms that have been loaded." }; + Gaudi::Property<bool> m_useMessageSvcForROOTMessages{ this, "UseMessageSvcForROOTMessages", true, + "Replace ROOT error handler with MessageSvc." }; + // For concurrency bool m_useHiveAlgorithmManager; diff --git a/GaudiCoreSvc/tests/src/test_JOS/base.cpp b/GaudiCoreSvc/tests/src/test_JOS/base.cpp index 3287db4de4ee154f52ea0bd723667d6069aabebe..cb7067d18e569789399271ea7f80fc943c5a9093 100644 --- a/GaudiCoreSvc/tests/src/test_JOS/base.cpp +++ b/GaudiCoreSvc/tests/src/test_JOS/base.cpp @@ -32,7 +32,7 @@ BOOST_AUTO_TEST_CASE( JobOptionsSvc ) { BOOST_CHECK( jos.isSet( "ApplicationMgr.AppName" ) ); BOOST_CHECK_EQUAL( jos.get( "ApplicationMgr.AppName" ), "'test_JOS.exe'" ); - BOOST_CHECK_EQUAL( jos.items().size(), 97 ); + BOOST_CHECK_EQUAL( jos.items().size(), 98 ); BOOST_CHECK( !jos.has( "MyAlg.SomeOpt" ) ); BOOST_CHECK( !jos.isSet( "MyAlg.SomeOpt" ) ); @@ -41,7 +41,7 @@ BOOST_AUTO_TEST_CASE( JobOptionsSvc ) { BOOST_CHECK( jos.isSet( "MyAlg.SomeOpt" ) ); BOOST_CHECK_EQUAL( jos.get( "MyAlg.SomeOpt" ), "42" ); - BOOST_CHECK_EQUAL( jos.items().size(), 98 ); + BOOST_CHECK_EQUAL( jos.items().size(), 99 ); BOOST_CHECK_EQUAL( jos.items( [&jos]( const auto& p ) { return jos.isSet( std::get<0>( p ) ); } ).size(), 2 ); BOOST_CHECK_EQUAL( jos.items( std::regex{ ".*Level" } ).size(), 5 ); } diff --git a/GaudiExamples/tests/qmtest/refs/MetaDataSvc.ref b/GaudiExamples/tests/qmtest/refs/MetaDataSvc.ref index 37cc232ff9089ab77d1cc3ecfb16d55faa33bca8..dfe150b3c0c34c9e43bfd8332cf825b7dc213d9b 100644 --- a/GaudiExamples/tests/qmtest/refs/MetaDataSvc.ref +++ b/GaudiExamples/tests/qmtest/refs/MetaDataSvc.ref @@ -92,6 +92,7 @@ ApplicationMgr.StopOnSignal:False ApplicationMgr.SvcMapping:[ 'EvtDataSvc/EventDataSvc' , 'DetDataSvc/DetectorDataSvc' , 'HistogramSvc/HistogramDataSvc' , 'HbookCnv::PersSvc/HbookHistSvc' , 'RootHistCnv::PersSvc/RootHistSvc' , 'EvtPersistencySvc/EventPersistencySvc' , 'DetPersistencySvc/DetectorPersistencySvc' , 'HistogramPersistencySvc/HistogramPersistencySvc' ] ApplicationMgr.SvcOptMapping:[ ] ApplicationMgr.TopAlg:[ 'TupleAlg/Tuple' , 'TupleAlg2/Tuple2' , 'TupleAlg3/Tuple3' ] +ApplicationMgr.UseMessageSvcForROOTMessages:True EventDataSvc.AuditFinalize:False EventDataSvc.AuditInitialize:False EventDataSvc.AuditReinitialize:False diff --git a/GaudiExamples/tests/qmtest/refs/Properties.ref b/GaudiExamples/tests/qmtest/refs/Properties.ref index 0a3233c2da115822108c03abacc6d6b548dfac14..aed875ea68f94757e27dc2f46fee597cb8cf1d6f 100644 --- a/GaudiExamples/tests/qmtest/refs/Properties.ref +++ b/GaudiExamples/tests/qmtest/refs/Properties.ref @@ -144,6 +144,7 @@ ApplicationMgr.StopOnSignal: False ApplicationMgr.SvcMapping: [ 'EvtDataSvc/EventDataSvc' , 'DetDataSvc/DetectorDataSvc' , 'HistogramSvc/HistogramDataSvc' , 'HbookCnv::PersSvc/HbookHistSvc' , 'RootHistCnv::PersSvc/RootHistSvc' , 'EvtPersistencySvc/EventPersistencySvc' , 'DetPersistencySvc/DetectorPersistencySvc' , 'HistogramPersistencySvc/HistogramPersistencySvc' ] ApplicationMgr.SvcOptMapping: [ ] ApplicationMgr.TopAlg: [ 'PropertyAlg' , 'PropertyProxy' ] +ApplicationMgr.UseMessageSvcForROOTMessages: True AuditorSvc.Auditors: ["ChronoAuditor"] DetectorDataSvc.AllowLoadInRunning: True DetectorDataSvc.AuditFinalize: False diff --git a/GaudiExamples/tests/qmtest/refs/Properties2.ref b/GaudiExamples/tests/qmtest/refs/Properties2.ref index 0603d3b8e97cedc70d5f2b6acae39eaa6ceba42c..5bde6493fc3bde2f82b2bc1608957bf37784e105 100644 --- a/GaudiExamples/tests/qmtest/refs/Properties2.ref +++ b/GaudiExamples/tests/qmtest/refs/Properties2.ref @@ -143,6 +143,7 @@ ApplicationMgr.StopOnSignal: False ApplicationMgr.SvcMapping: [ 'EvtDataSvc/EventDataSvc' , 'DetDataSvc/DetectorDataSvc' , 'HistogramSvc/HistogramDataSvc' , 'HbookCnv::PersSvc/HbookHistSvc' , 'RootHistCnv::PersSvc/RootHistSvc' , 'EvtPersistencySvc/EventPersistencySvc' , 'DetPersistencySvc/DetectorPersistencySvc' , 'HistogramPersistencySvc/HistogramPersistencySvc' ] ApplicationMgr.SvcOptMapping: [ ] ApplicationMgr.TopAlg: [ 'PropertyAlg' , 'PropertyProxy' ] +ApplicationMgr.UseMessageSvcForROOTMessages: True AuditorSvc.Auditors: ['ChronoAuditor'] DetectorDataSvc.AllowLoadInRunning: True DetectorDataSvc.AuditFinalize: False diff --git a/GaudiExamples/tests/qmtest/refs/Properties_py.ref b/GaudiExamples/tests/qmtest/refs/Properties_py.ref index 2b1707c81dc5a95173fbeed32284402ce1a31fe9..0530997d648db2765923f742489a791241ba6c29 100644 --- a/GaudiExamples/tests/qmtest/refs/Properties_py.ref +++ b/GaudiExamples/tests/qmtest/refs/Properties_py.ref @@ -143,6 +143,7 @@ ApplicationMgr.StopOnSignal: False ApplicationMgr.SvcMapping: [ 'EvtDataSvc/EventDataSvc' , 'DetDataSvc/DetectorDataSvc' , 'HistogramSvc/HistogramDataSvc' , 'HbookCnv::PersSvc/HbookHistSvc' , 'RootHistCnv::PersSvc/RootHistSvc' , 'EvtPersistencySvc/EventPersistencySvc' , 'DetPersistencySvc/DetectorPersistencySvc' , 'HistogramPersistencySvc/HistogramPersistencySvc' ] ApplicationMgr.SvcOptMapping: [ ] ApplicationMgr.TopAlg: [ 'PropertyAlg/PropertyAlg' , 'PropertyProxy/PropertyProxy' ] +ApplicationMgr.UseMessageSvcForROOTMessages: True AuditorSvc.Auditors: ['ChronoAuditor/ChronoAuditor'] DetectorDataSvc.AllowLoadInRunning: True DetectorDataSvc.AuditFinalize: False