The Gaudi Framework  v29r0 (ff2e7097)
Gaudi::RootPerfMonSvc Class Reference

Description: More...

#include <src/RootPerfMonSvc.h>

Inheritance diagram for Gaudi::RootPerfMonSvc:
Collaboration diagram for Gaudi::RootPerfMonSvc:

Public Member Functions

 ~RootPerfMonSvc () override=default
 Standard destructor. More...
 
StatusCode error (const std::string &msg)
 Standard way to print errors. More...
 
StatusCode initialize () override
 Service overload: initialize the service. More...
 
StatusCode finalize () override
 Service overload: Finalize the service. More...
 
void handle (const Incident &incident) override
 IIncidentListener override: Inform that a new incident has occurred. More...
 
StatusCode stop () override
 
- Public Member Functions inherited from extends< Service, IIncidentListener >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from Service
const std::stringname () const override
 Retrieve name of the service. More...
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service. More...
 
StatusCode sysStart () override
 Initialize Service. More...
 
StatusCode sysStop () override
 Initialize Service. More...
 
StatusCode sysFinalize () override
 Finalize Service. More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. More...
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
 Declare used tool. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 PropertyHolder ()=default
 
 ~PropertyHolder () override=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none") const
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p) override
 set the property form another property More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 set the property from name and the value More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &name) const override
 get the property by name More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (const std::string &name) const override
 Return true if we have a property with the given name. More...
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, GaudiHandleBase &ref, const std::string &doc="none")
 Specializations for various GaudiHandles. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, GaudiHandleArrayBase &ref, const std::string &doc="none")
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, DataObjectHandleBase &ref, const std::string &doc="none")
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const __attribute__((deprecated))
 Backward compatibility function for getting the output level. More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces... >
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

Protected Types

enum  EventType { EVENT = 1, FSR = 2 }
 

Protected Member Functions

virtual void record (EventType eventType)
 
MsgStreamlog () const
 Helper: Use message streamer. More...
 
- Protected Member Functions inherited from Service
 ~Service () override
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBaseproperty (const std::string &name) const
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Protected Attributes

Gaudi::Property< std::stringm_ioPerfStats
 
Gaudi::Property< std::stringm_setStreams {this, "Streams", "", ""}
 
Gaudi::Property< std::stringm_basketSize {this, "BasketSize", "", ""}
 
Gaudi::Property< std::stringm_bufferSize {this, "BufferSize", "", ""}
 
Gaudi::Property< std::stringm_splitLevel {this, "SplitLevel", "", ""}
 
SmartIF< IIncidentSvcm_incidentSvc
 Reference to incident service. More...
 
std::unique_ptr< MsgStreamm_log
 Message streamer. More...
 
TTree * m_perfTree
 
std::unique_ptr< TFile > m_perfFile
 
std::set< std::stringm_outputs
 
Int_t m_eventType
 
ULong_t m_utime
 
ULong_t m_stime
 
ULong_t m_vsize
 
Long_t m_eventNumber
 
Long_t m_rss
 
Long_t m_time
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::Property< int > m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
 
Gaudi::Property< bool > m_auditInit {this, "AuditServices", false, "[[deprecated]] unused"}
 
Gaudi::Property< bool > m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
 
Gaudi::Property< bool > m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
 
Gaudi::Property< bool > m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
 
Gaudi::Property< bool > m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
 
Gaudi::Property< bool > m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
 
Gaudi::Property< bool > m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service. More...
 

Additional Inherited Members

- Public Types inherited from extends< Service, IIncidentListener >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
- Public Types inherited from Service
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > Factory
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 

Detailed Description

Description:

RootPerfMonSvc class implementation definition.

Author
Markus Frank, Ivan Valencik
Version
1.0
Date
20/12/2009

Definition at line 40 of file RootPerfMonSvc.h.

Member Enumeration Documentation

enum Gaudi::RootPerfMonSvc::EventType
protected
Enumerator
EVENT 
FSR 

Definition at line 67 of file RootPerfMonSvc.h.

Constructor & Destructor Documentation

Gaudi::RootPerfMonSvc::~RootPerfMonSvc ( )
overridedefault

Standard destructor.

Member Function Documentation

StatusCode RootPerfMonSvc::error ( const std::string msg)

Standard way to print errors.

after the printout an exception is thrown.

Parameters
msg[IN] Message string to be printed.
Returns
Status code returning failure.

Definition at line 33 of file RootPerfMonSvc.cpp.

34 {
35  if ( m_log ) {
36  log() << MSG::ERROR << "Error: " << msg << endmsg;
37  return S_FAIL;
38  }
39  MsgStream m( msgSvc(), name() );
40  m << MSG::ERROR << "Error: " << msg << endmsg;
41  return S_FAIL;
42 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
#define S_FAIL
constexpr double m
Definition: SystemOfUnits.h:94
MsgStream & log() const
Helper: Use message streamer.
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
std::unique_ptr< MsgStream > m_log
Message streamer.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode RootPerfMonSvc::finalize ( )
override

Service overload: Finalize the service.

Definition at line 134 of file RootPerfMonSvc.cpp.

135 {
136  record( FSR );
137  log() << MSG::INFO;
138  m_log.reset();
140 
141  m_perfFile->Write();
142  m_perfFile->Close();
143  m_perfFile.reset();
144 
145  return Service::finalize();
146 }
StatusCode finalize() override
Definition: Service.cpp:174
std::unique_ptr< TFile > m_perfFile
virtual void record(EventType eventType)
SmartIF< IIncidentSvc > m_incidentSvc
Reference to incident service.
T reset(T...args)
MsgStream & log() const
Helper: Use message streamer.
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:92
std::unique_ptr< MsgStream > m_log
Message streamer.
void RootPerfMonSvc::handle ( const Incident incident)
override

IIncidentListener override: Inform that a new incident has occurred.

Definition at line 101 of file RootPerfMonSvc.cpp.

102 {
103  std::string t = incident.type();
104  if ( !t.compare( IncidentType::BeginEvent ) ) {
105  m_eventNumber++;
106  record( EVENT );
107  return;
108  }
109  if ( !t.compare( "CONNECTED_OUTPUT" ) ) {
110  m_outputs.insert( incident.source() );
111  }
112 }
const std::string & type() const
Access to the incident type.
Definition: Incident.h:41
const std::string & source() const
Access to the source of the incident.
Definition: Incident.h:47
virtual void record(EventType eventType)
STL class.
T insert(T...args)
std::set< std::string > m_outputs
T compare(T...args)
StatusCode RootPerfMonSvc::initialize ( )
override

Service overload: initialize the service.

Definition at line 45 of file RootPerfMonSvc.cpp.

46 {
47  string cname;
49  if ( !status.isSuccess() ) return error( "Failed to initialize Service base class." );
50  m_log.reset( new MsgStream( msgSvc(), name() ) );
51  m_incidentSvc = service( "IncidentSvc" );
52  if ( !m_incidentSvc ) return error( "Unable to localize interface from service:IncidentSvc" );
53 
54  m_incidentSvc->addListener( this, IncidentType::BeginEvent, 1, false, false );
55  m_incidentSvc->addListener( this, "NEW_STREAM", 1, false, false );
56  m_incidentSvc->addListener( this, "CONNECTED_OUTPUT", 1, false, false );
57 
58  if ( m_ioPerfStats.empty() ) return error( "Performance monitoring file IOPerfStats was not defined." );
59 
60  TDirectory::TContext ctxt( nullptr );
61  m_perfFile.reset( new TFile( m_ioPerfStats.value().c_str(), "RECREATE" ) );
62  if ( !m_perfFile ) return error( "Could not create ROOT file." );
63 
64  if ( !( m_perfTree = new TTree( "T", "performance measurement" ) ) ) return error( "Could not create tree." );
65 
66  m_perfTree->Branch( "utime", &m_utime, "utime/l" );
67  m_perfTree->Branch( "stime", &m_stime, "stime/l" );
68  m_perfTree->Branch( "vsize", &m_vsize, "vsize/l" );
69  m_perfTree->Branch( "rss", &m_rss, "rss/L" );
70  m_perfTree->Branch( "time", &m_time, "time/L" );
71  m_eventNumber = 0;
72  m_perfTree->Branch( "event_number", &m_eventNumber, "event_number/L" );
73  m_perfTree->Branch( "event_type", &m_eventType, "event_type/I" );
74 
75  if ( m_setStreams.empty() ) m_setStreams = "undefined";
76  if ( m_basketSize.empty() ) m_basketSize = "undefined";
77  if ( m_bufferSize.empty() ) m_bufferSize = "undefined";
78  if ( m_splitLevel.empty() ) m_splitLevel = "undefined";
79 
80  auto map = new TMap();
81  map->Add( new TObjString( "streams" ), new TObjString( m_setStreams.value().c_str() ) );
82  map->Add( new TObjString( "basket_size" ), new TObjString( m_basketSize.value().c_str() ) );
83  map->Add( new TObjString( "buffer_size" ), new TObjString( m_bufferSize.value().c_str() ) );
84  map->Add( new TObjString( "split_level" ), new TObjString( m_splitLevel.value().c_str() ) );
85  map->Write( "params", TObject::kSingleKey );
86  return S_OK;
87 }
Gaudi::Property< std::string > m_basketSize
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
StatusCode initialize() override
Definition: Service.cpp:64
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
std::unique_ptr< TFile > m_perfFile
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
#define S_OK
STL class.
SmartIF< IIncidentSvc > m_incidentSvc
Reference to incident service.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
T reset(T...args)
Gaudi::Property< std::string > m_splitLevel
virtual void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false)=0
Add listener.
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Gaudi::Property< std::string > m_ioPerfStats
Gaudi::Property< std::string > m_bufferSize
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: Service.h:85
Gaudi::Property< std::string > m_setStreams
std::unique_ptr< MsgStream > m_log
Message streamer.
MsgStream& Gaudi::RootPerfMonSvc::log ( ) const
inlineprotected

Helper: Use message streamer.

Definition at line 73 of file RootPerfMonSvc.h.

73 { return *m_log; }
std::unique_ptr< MsgStream > m_log
Message streamer.
void RootPerfMonSvc::record ( EventType  eventType)
protectedvirtual

Definition at line 89 of file RootPerfMonSvc.cpp.

90 {
91  SysProcStat data;
92  m_eventType = eventType;
93  m_utime = (ULong_t)data.utime;
94  m_stime = (ULong_t)data.stime;
95  m_vsize = (ULong_t)data.vsize;
96  m_rss = (Long_t)data.rss;
97  m_time = (Long_t)data.time;
98  m_perfTree->Fill();
99 }
long unsigned stime
Definition: SysProcStat.h:18
long unsigned vsize
Definition: SysProcStat.h:18
long unsigned utime
Definition: SysProcStat.h:18
StatusCode RootPerfMonSvc::stop ( )
override

Definition at line 115 of file RootPerfMonSvc.cpp.

116 {
117  char text[64];
118  record( FSR );
119  auto map = new TMap();
120  for ( const auto& i : m_outputs ) {
121  const char* fn = i.c_str();
122  Long_t id, siz, flags, tim;
123  if ( 0 == gSystem->GetPathInfo( fn, &id, &siz, &flags, &tim ) ) {
124  ::sprintf( text, "%ld", siz );
125  map->Add( new TObjString( fn ), new TObjString( text ) );
126  }
127  }
128  TDirectory::TContext ctxt( m_perfFile.get() );
129  map->Write( "Outputs", TObject::kSingleKey );
130  return S_OK;
131 }
std::unique_ptr< TFile > m_perfFile
virtual void record(EventType eventType)
#define S_OK
STL class.
T get(T...args)
std::set< std::string > m_outputs

Member Data Documentation

Gaudi::Property<std::string> Gaudi::RootPerfMonSvc::m_basketSize {this, "BasketSize", "", ""}
protected

Definition at line 47 of file RootPerfMonSvc.h.

Gaudi::Property<std::string> Gaudi::RootPerfMonSvc::m_bufferSize {this, "BufferSize", "", ""}
protected

Definition at line 48 of file RootPerfMonSvc.h.

Long_t Gaudi::RootPerfMonSvc::m_eventNumber
protected

Definition at line 64 of file RootPerfMonSvc.h.

Int_t Gaudi::RootPerfMonSvc::m_eventType
protected

Definition at line 62 of file RootPerfMonSvc.h.

SmartIF<IIncidentSvc> Gaudi::RootPerfMonSvc::m_incidentSvc
protected

Reference to incident service.

Definition at line 52 of file RootPerfMonSvc.h.

Gaudi::Property<std::string> Gaudi::RootPerfMonSvc::m_ioPerfStats
protected
Initial value:
{this, "IOPerfStats", "",
"Enable TTree IOperfStats if not empty; otherwise perf stat file name"}

Definition at line 43 of file RootPerfMonSvc.h.

std::unique_ptr<MsgStream> Gaudi::RootPerfMonSvc::m_log
protected

Message streamer.

Definition at line 54 of file RootPerfMonSvc.h.

std::set<std::string> Gaudi::RootPerfMonSvc::m_outputs
protected

Definition at line 60 of file RootPerfMonSvc.h.

std::unique_ptr<TFile> Gaudi::RootPerfMonSvc::m_perfFile
protected

Definition at line 58 of file RootPerfMonSvc.h.

TTree* Gaudi::RootPerfMonSvc::m_perfTree
protected

Definition at line 56 of file RootPerfMonSvc.h.

Long_t Gaudi::RootPerfMonSvc::m_rss
protected

Definition at line 64 of file RootPerfMonSvc.h.

Gaudi::Property<std::string> Gaudi::RootPerfMonSvc::m_setStreams {this, "Streams", "", ""}
protected

Definition at line 46 of file RootPerfMonSvc.h.

Gaudi::Property<std::string> Gaudi::RootPerfMonSvc::m_splitLevel {this, "SplitLevel", "", ""}
protected

Definition at line 49 of file RootPerfMonSvc.h.

ULong_t Gaudi::RootPerfMonSvc::m_stime
protected

Definition at line 63 of file RootPerfMonSvc.h.

Long_t Gaudi::RootPerfMonSvc::m_time
protected

Definition at line 64 of file RootPerfMonSvc.h.

ULong_t Gaudi::RootPerfMonSvc::m_utime
protected

Definition at line 63 of file RootPerfMonSvc.h.

ULong_t Gaudi::RootPerfMonSvc::m_vsize
protected

Definition at line 63 of file RootPerfMonSvc.h.


The documentation for this class was generated from the following files: