39#define ON_DEBUG if ( m_outputLevel <= MSG::DEBUG )
40#define ON_VERBOSE if ( m_outputLevel <= MSG::VERBOSE )
46 static IMessageSvc* s_messageSvcInstance{
nullptr };
48 static ErrorHandlerFunc_t s_originalRootErrorHandler{
nullptr };
51 void ROOTErrorHandlerAdapter(
int level, Bool_t abort,
const char* location,
const char* msg ) {
52 if ( s_messageSvcInstance ) {
54 if ( level >= gErrorIgnoreLevel ) {
59 int msgLevel = std::min<int>( level / 1000 + 2,
MSG::FATAL );
60 if ( msgLevel >= s_messageSvcInstance->outputLevel( location ) ) {
61 s_messageSvcInstance->reportMessage(
Message{ location, msgLevel, msg }, msgLevel );
66 if ( s_originalRootErrorHandler ) {
68 s_originalRootErrorHandler( level, abort, location, msg );
71 ROOT::Internal::MinimalErrorHandler( level, abort, location, msg );
102 "Aliases of algorithm types, to replace an algorithm type for every instance" );
108 "DetDataSvc/DetectorDataSvc",
109 "HistogramSvc/HistogramDataSvc",
110 "HbookCnv::PersSvc/HbookHistSvc",
111 "RootHistCnv::PersSvc/RootHistSvc",
112 "EvtPersistencySvc/EventPersistencySvc",
113 "DetPersistencySvc/DetectorPersistencySvc",
114 "HistogramPersistencySvc/HistogramPersistencySvc" };
119 if (
auto output = base_class::i_cast( iid ) ) {
return output; }
161 log <<
MSG::FATAL <<
"Error setting OutputLevel option of MessageSvc" <<
endmsg;
168 s_originalRootErrorHandler = SetErrorHandler( ROOTErrorHandlerAdapter );
171 <<
"ROOT not yet initialized, we cannot override the error handler are requested "
172 "(UseMessageSvcForROOTMessages==true)"
185 if ( !jobOptsIProp ) {
191 log <<
MSG::FATAL <<
"Error setting TYPE option in JobOptionsSvc" <<
endmsg;
198 log <<
MSG::FATAL <<
"Error setting JobOptionsPreAction option in JobOptionsSvc" <<
endmsg;
206 log <<
MSG::FATAL <<
"Error setting JobOptionsPostAction option in JobOptionsSvc" <<
endmsg;
214 log <<
MSG::FATAL <<
"Error setting PATH option in JobOptionsSvc" <<
endmsg;
217 }
else if (
isEnvSet(
"JOBOPTPATH" ) ) {
220 log <<
MSG::FATAL <<
"Error setting PATH option in JobOptionsSvc from env" <<
endmsg;
226 log <<
MSG::FATAL <<
"Error setting PATH option in JobOptionsSvc to default" <<
endmsg;
230 jobOptsIProp.reset();
234 auto msgSvcIProp = msgsvc.as<
IProperty>();
238 sc = jobsvc->sysInitialize();
243 sc = msgsvc->sysInitialize();
291 <<
"=================================================================="
292 <<
"==================================================================" << std::endl
301#if GAUDI_PATCH_VERSION
311 <<
"=================================================================="
312 <<
"==================================================================" <<
endmsg;
319 <<
" #properties = " << properties.size() <<
endmsg;
320 for (
const auto&
property : properties ) { log <<
"Property ['Name': Value] = " << *
property <<
endmsg; }
325 const std::string&
name = var.first;
326 const std::string& value = var.second;
337 log <<
MSG::ERROR <<
"configure: declaring svc type:'" << j <<
"' failed." <<
endmsg;
364 log <<
MSG::ERROR <<
"Failure during external service association" <<
endmsg;
389 log <<
MSG::FATAL <<
"Error retrieving Runable: " <<
m_runableType.value() <<
"\n Check option ApplicationMgr."
396 <<
"\n Check option ApplicationMgr." <<
m_eventLoopMgr.name() <<
"\n No events will be processed." <<
endmsg;
416 log <<
MSG::INFO <<
"Application Manager Configured successfully" <<
endmsg;
433 std::string svcname(
"Gaudi::Utils::StopSignalHandler" );
436 log <<
MSG::INFO <<
"Cannot instantiate " << svcname <<
"signals will be ignored" <<
endmsg;
462 log <<
MSG::INFO <<
"Application Manager Initialized successfully" <<
endmsg;
496 log <<
MSG::INFO <<
"Application Manager Started successfully" <<
endmsg;
537 .andThen( [&]() {
return m_svcLocator->service(
"JobOptionsSvc" )->sysStop(); } )
542 log <<
MSG::INFO <<
"Application Manager Stopped successfully" <<
endmsg;
585 log <<
MSG::INFO <<
"Application Manager Finalized successfully" <<
endmsg;
609 log <<
MSG::INFO <<
"Application Manager Terminated successfully" <<
endmsg;
611 log <<
MSG::INFO <<
"Application Manager Terminated successfully with a user requested ScheduledStop" <<
endmsg;
619 opts.set(
"MessageSvc.AuditFinalize",
"false" );
621 opts.set(
"JobOptionsSvc.AuditFinalize",
"false" );
625 if ( s_originalRootErrorHandler ) {
626 SetErrorHandler( s_originalRootErrorHandler );
627 s_originalRootErrorHandler =
nullptr;
630 s_messageSvcInstance =
nullptr;
634 log <<
MSG::ERROR <<
"Could not get the IService interface of the MessageSvc" <<
endmsg;
636 svc->sysFinalize().ignore();
643 log <<
MSG::ERROR <<
"Could not get the IService interface of the JobOptionsSvc" <<
endmsg;
645 svc->sysFinalize().ignore();
727 if ( ignoreFailures ) {
785 std::stringstream ss;
786 ss <<
"createEventContext: Invalid state \"" <<
FSMState() <<
'"';
821 throw GaudiException(
"Cannot reinitialize application if not INITIALIZED or RUNNING",
832 sc =
m_svcLocator->service(
"JobOptionsSvc" )->sysReinitialize();
835 log <<
MSG::INFO <<
"Application Manager Reinitialized successfully" <<
endmsg;
854 sc =
m_svcLocator->service(
"JobOptionsSvc" )->sysRestart();
863 if ( props ) props->setProperty( p ).ignore();
869 throw GaudiException(
"Failed to create ext services",
"MinimalEventLoopMgr::createSvcNameListHandler",
876 auto it = theNames.begin();
877 auto et = theNames.end();
878 while ( result.
isSuccess() && it != et ) {
880 if ( ( result =
svcManager()->addService( item, ServiceManager::DEFAULT_SVC_PRIORITY ) ).isFailure() ) {
882 log <<
MSG::ERROR <<
"decodeCreateSvcNameList: Cannot create service " << item.
type() <<
"/" << item.
name()
896 throw GaudiException(
"Failed to declare ext services",
"MinimalEventLoopMgr::extSvcNameListHandler",
906 auto it = theNames.begin();
907 auto et = theNames.end();
908 while ( result.
isSuccess() && it != et ) {
911 if ( ( result =
svcManager()->addService( item, ServiceManager::DEFAULT_SVC_PRIORITY ) ).isFailure() ) {
913 log <<
MSG::ERROR <<
"decodeExtSvcNameList: Cannot create service " << item.
type() <<
"/" << item.
name()
917 if ( ( result =
svcManager()->declareSvcType( item.
name(), item.
type() ) ).isFailure() ) {
919 log <<
MSG::ERROR <<
"decodeExtSvcNameList: Cannot declare service " << item.
type() <<
"/" << item.
name()
939 std::vector<std::string> newList;
940 std::map<std::string, unsigned int> dllInList, duplicateList;
943 if ( 0 == dllInList[it] ) {
944 newList.push_back( it );
954 ON_DEBUG if ( !duplicateList.empty() ) {
955 log <<
MSG::DEBUG <<
"Removed duplicate entries for modules : ";
956 for (
auto it = duplicateList.begin(); it != duplicateList.end(); ++it ) {
957 log << it->first <<
"(" << 1 + it->second <<
")";
958 if ( it != --duplicateList.end() ) log <<
", ";
963 const std::vector<std::string>& theNames = newList;
968 std::vector<std::string> successNames, failNames;
969 for (
const auto& it : theNames ) {
974 failNames.push_back( it );
977 successNames.push_back( it );
983 if ( !successNames.empty() ) {
984 log <<
MSG::INFO <<
"Successfully loaded modules : ";
985 for (
auto it = successNames.begin(); it != successNames.end(); it++ ) {
987 if ( ( it + 1 ) != successNames.end() ) log <<
", ";
996 for (
auto it = failNames.begin(); it != failNames.end(); it++ ) {
998 if ( ( it + 1 ) != failNames.end() ) log <<
", ";
1007 for (
auto& mgrItem :
m_managers ) { mgrItem.second->outputLevelUpdate(); }
1016 for (
int i = 0; i < indent; ++i ) log <<
" ";
1017 log << algname <<
endmsg;
1018 auto prop = algmgr->algorithm<
IProperty>( algname, false );
1022 if ( prop->getProperty( &p ).isSuccess() ) {
1023 for (
auto& subalgname : p.value() ) { printAlgsSequencesHelper( algmgr, subalgname, log, indent + 1 ); }
1033 log <<
MSG::ALWAYS <<
"****************************** Algorithm Sequence ****************************" <<
endmsg;
1035 log <<
MSG::ALWAYS <<
"******************************************************************************" <<
endmsg;
GAUDI_API bool isEnvSet(const char *var)
Check if an environment variable is set or not.
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
#define GAUDI_MAJOR_VERSION
#define GAUDI_MINOR_VERSION
#define GAUDI_PATCH_VERSION
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
#define DECLARE_OBJECT_FACTORY(x)
The AlgorithmManager class is in charge of the creation of concrete instances of Algorithms.
AlgTypeAliasesMap & typeAliases()
The Application Manager class.
Gaudi::Property< std::string > m_jobOptionsType
SmartIF< IRunable > m_runable
Reference to the runable object.
Gaudi::Property< bool > m_printAlgsSequence
SmartIF< IQueueingEventProcessor > m_queueingProcessor
Reference to a queueing processing manager object.
Gaudi::Property< int > m_returnCode
Property to record the error conditions occurring during the running.
Gaudi::Property< std::vector< std::string > > m_svcMapping
Gaudi::Property< bool > m_useMessageSvcForROOTMessages
std::optional< Gaudi::Interfaces::IQueueingEventProcessor::ResultType > pop() override
Gaudi::Property< std::vector< std::string > > m_dllNameList
Gaudi::StateMachine::State m_targetState
Internal State.
Gaudi::Property< std::string > m_runableType
Gaudi::Property< bool > m_actHistory
void createSvcNameListHandler(Gaudi::Details::PropertyBase &)
std::vector< std::string > m_okDlls
names of successfully loaded dlls
StatusCode GoToState(Gaudi::StateMachine::State state, bool ignoreFailures=false)
Reach a state from current state (whichever it is) going through the correct transitions.
Gaudi::Property< bool > m_propertiesPrint
SmartIF< ISvcLocator > m_svcLocator
Reference to its own service locator (must be instantiated prior to any service!)
StatusCode run() override
ApplicationMgr(IInterface *=nullptr)
StatusCode finalize() override
Gaudi::Property< std::vector< std::string > > m_extSvcNameList
StatusCode nextEvent(int maxevt) override
Gaudi::Property< std::string > m_jobOptionsPath
SmartIF< DLLClassManager > m_classManager
Reference to the class manager.
StatusCode terminate() override
StatusCode initialize() override
StatusCode stopRun() override
implementation of IEventProcessor::stopRun()
SmartIF< ISvcLocator > & serviceLocator() const override
Needed to locate the message service.
StatusCode sysStop() override
SmartIF< IMessageSvc > m_messageSvc
Reference to the message service.
Gaudi::Property< std::vector< std::string > > m_svcOptMapping
SmartIF< IAlgManager > & algManager()
StatusCode executeEvent(EventContext &&ctx) override
implementation of IEventProcessor::executeEvent(void*)
void const * i_cast(const InterfaceID &iid) const override
void evtLoopPropertyHandler(Gaudi::Details::PropertyBase &theProp)
Gaudi::Property< std::string > m_eventLoopMgr
const std::string & name() const override
StatusCode sysRestart() override
Gaudi::Property< std::string > m_appVersion
StatusCode sysReinitialize() override
StatusCode decodeDllNameList()
Gaudi::Property< std::vector< std::string > > m_topAlgNameList
Gaudi::Property< bool > m_extSvcCreates
Gaudi::Property< std::vector< std::string > > m_createSvcNameList
Gaudi::Property< std::map< std::string, std::string > > m_environment
EventContext createEventContext() override
implementation of IEventProcessor::createEventContext()
Gaudi::Property< std::string > m_jobOptionsPreAction
StatusCode reinitialize() override
Gaudi::Property< bool > m_loopCheck
Gaudi::Property< std::string > m_appName
void extSvcNameListHandler(Gaudi::Details::PropertyBase &theProp)
Gaudi::StateMachine::State targetFSMState() const override
StatusCode restart() override
StatusCode stop() override
void printAlgsSequences()
Print the sequence of algorithms that have been loaded.
StatusCode executeRun(int evtmax) override
implementation of IEventProcessor::executeRun(int)
static auto i_delegateToEvtProc(SELF *self, PIMPL &member, std::string_view method_name, METHOD &&method, ARGS &&... args)
Helper to delegate calls to event processor implementation.
Gaudi::Property< bool > m_stopOnSignal
Property to enable/disable the "stop on signal" service.
Gaudi::StateMachine::State FSMState() const override
StatusCode i_startup()
Internal startup routine.
Gaudi::StateMachine::State m_state
Internal State.
StatusCode start() override
void outputLevelUpdate() override
Function to call to update the outputLevel of the components (after a change in MessageSvc).
StatusCode decodeExtSvcNameList()
Gaudi::Property< std::string > m_jobOptionsSvcType
void push(EventContext &&ctx) override
StatusCode decodeCreateSvcNameList()
void dllNameListHandler(Gaudi::Details::PropertyBase &theProp)
Gaudi::Property< int > m_outputLevel
ManagersMap m_managers
Map of known component managers.
bool empty() const override
StatusCode configure() override
StatusCode sysStart() override
SmartIF< ISvcManager > & svcManager()
SmartIF< IEventProcessor > m_processingMgr
Reference to processing manager object.
Gaudi::Property< std::string > m_jobOptionsPostAction
Gaudi::Property< std::string > m_messageSvcType
MSG::Level resetMessaging()
This class represents an entry point to all the event specific data.
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Implementation of property with value of concrete type.
std::string format(bool local, std::string spec="%c") const
Format the time using strftime.
static Time current()
Returns the current time.
Helper class to parse a string of format "type/name".
const std::string & type() const
const std::string & name() const
Define general base for Gaudi exception.
Definition of the basic interface.
static const InterfaceID & interfaceID()
Return an instance of InterfaceID identifying the interface.
The IMessage is the interface implemented by the message service.
The IProperty is the basic interface for all components which have properties that can be set or get.
StatusCode setProperty(const Gaudi::Details::PropertyBase &p)
Set the property from a property.
General service interface definition.
virtual StatusCode finalize()=0
Finalize (from INITIALIZED to CONFIGURED).
virtual StatusCode restart()=0
Initialization (from RUNNING to RUNNING, via INITIALIZED).
virtual StatusCode reinitialize()=0
Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
virtual StatusCode start()=0
Start (from INITIALIZED to RUNNING).
virtual StatusCode stop()=0
Stop (from RUNNING to INITIALIZED).
virtual StatusCode initialize()=0
Initialization (from CONFIGURED to INITIALIZED).
virtual StatusCode removeService(IService *svc)=0
Remove a service from the "active" list of services of the factory.
virtual void setLoopCheckEnabled(bool en=true)=0
Set the value of the initialization loop check flag.
virtual SmartIF< IService > & createService(const Gaudi::Utils::TypeNameString &nametype)=0
Creates and instance of a service type that has been declared beforehand and assigns it a name.
virtual StatusCode addService(IService *svc, int prio=DEFAULT_SVC_PRIORITY)=0
Add a service to the "active" list of services of the factory.
constexpr unsigned long id() const
get the interface identifier
Definition of the MsgStream class used to transmit messages.
Gaudi::Details::PropertyBase * property(std::string_view name) const
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Details::PropertyBase &prop)
void bindPropertiesTo(Gaudi::Interfaces::IOptionsSvc &optsSvc)
const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const override
StatusCode setProperty(const Gaudi::Details::PropertyBase &p)
The ServiceManager class is in charge of the creation of concrete instances of Services.
Small smart pointer class with automatic reference counting for IInterface.
TYPE * get() const
Get interface pointer.
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
This class is used for returning status codes from appropriate routines.
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
StatusCode andThen(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a success result.
constexpr static const auto SUCCESS
constexpr static const auto FAILURE
constexpr int ScheduledStop
constexpr int FinalizationFailure
Error codes for operation failures.
State
Allowed states for classes implementing the state machine (ApplicationMgr, Algorithm,...
GAUDI_API bool isEnvSet(const char *var)
Check if an environment variable is set or not.
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
GAUDI_API std::vector< std::string > getEnv()
get all environment variables
GAUDI_API const std::string & hostName()
Host name.
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
GAUDI_API int setEnv(const std::string &name, const std::string &value, int overwrite=1)
Set an environment variables.
virtual std::optional< ResultType > pop()=0
Get the next available result.
virtual bool empty() const =0
Tell if the processor has events in the queues.
virtual void push(EventContext &&ctx)=0
Schedule the processing of an event.
static const InterfaceID & interfaceID()