21 #include "TDirectory.h"    26 using namespace Gaudi;
    27 typedef const string& 
CSTR;
    29 #define S_OK StatusCode::SUCCESS    30 #define S_FAIL StatusCode::FAILURE    49   if ( !status.
isSuccess() ) 
return error( 
"Failed to initialize Service base class." );
    51   m_incidentSvc = service( 
"IncidentSvc" );
    52   if ( !m_incidentSvc ) 
return error( 
"Unable to localize interface from service:IncidentSvc" );
    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 );
    58   if ( m_ioPerfStats.empty() ) 
return error( 
"Performance monitoring file IOPerfStats was not defined." );
    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." );
    64   if ( !( m_perfTree = 
new TTree( 
"T", 
"performance measurement" ) ) ) 
return error( 
"Could not create tree." );
    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" );
    72   m_perfTree->Branch( 
"event_number", &m_eventNumber, 
"event_number/L" );
    73   m_perfTree->Branch( 
"event_type", &m_eventType, 
"event_type/I" );
    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";
    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 );
    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;
   101 void RootPerfMonSvc::handle( 
const Incident& incident )
   104   if ( !t.
compare( IncidentType::BeginEvent ) ) {
   109   if ( !t.
compare( 
"CONNECTED_OUTPUT" ) ) {
   110     m_outputs.insert( incident.
source() );
   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 ) ) {
   125       map->Add( 
new TObjString( fn ), 
new TObjString( text ) );
   128   TDirectory::TContext ctxt( m_perfFile.get() );
   129   map->Write( 
"Outputs", TObject::kSingleKey );
   139   m_incidentSvc.reset();
 
Definition of the MsgStream class used to transmit messages. 
StatusCode initialize() override
const std::string & type() const 
Access to the incident type. 
StatusCode finalize() override
const std::string & source() const 
Access to the source of the incident. 
bool isSuccess() const 
Test for a status code of SUCCESS. 
This class is used for returning status codes from appropriate routines. 
Base class for all Incidents (computing events). 
Helper functions to set/get the application return code. 
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.