Gaudi Framework, version v24r2

Home   Generated: Wed Dec 4 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Private Attributes | List of all members
GaudiCommon< PBASE > Class Template Reference

Implements the common functionality between GaudiTools and GaudiAlgorithms. More...

#include <GaudiAlg/GaudiCommon.h>

Inheritance diagram for GaudiCommon< PBASE >:
Inheritance graph
[legend]
Collaboration diagram for GaudiCommon< PBASE >:
Collaboration graph
[legend]

Public Member Functions

template<class TYPE >
Gaudi::Utils::GetData< TYPE >
::return_type 
get (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Templated access to the data in Gaudi Transient Store.
 
template<class TYPE >
Gaudi::Utils::GetData< TYPE >
::return_type 
getIfExists (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Quicker version of the get function which bypasses the check on the retrieved data.
 
template<class TYPE >
bool exist (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Check the existence of a data object or container in the Gaudi Transient Event Store.
 
template<class TYPE , class TYPE2 >
Gaudi::Utils::GetData< TYPE >
::return_type 
getOrCreate (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
 Get the existing data object from Gaudi Event Transient store.
 
DataObjectput (IDataProviderSvc *svc, DataObject *object, const std::string &location, const bool useRootInTES=true) const
 Register a data object or container into Gaudi Event Transient Store.
 
template<class TOOL >
TOOL * tool (const std::string &type, const std::string &name, const IInterface *parent=0, bool create=true) const
 Useful method for the easy location of tools.
 
template<class TOOL >
TOOL * tool (const std::string &type, const IInterface *parent=0, bool create=true) const
 A useful method for the easy location of tools.
 
template<class SERVICE >
SmartIF< SERVICE > svc (const std::string &name, const bool create=true) const
 A useful method for the easy location of services.
 
IUpdateManagerSvcupdMgrSvc () const
 Short-cut to locate the Update Manager Service.
 
StatusCode Error (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
 Print the error message and return with the given StatusCode.
 
StatusCode Warning (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
 Print the warning message and return with the given StatusCode.
 
StatusCode Info (const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const size_t mx=10) const
 Print the info message and return with the given StatusCode.
 
StatusCode Print (const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const MSG::Level lev=MSG::INFO) const
 Print the message and return with the given StatusCode.
 
void Assert (const bool ok, const std::string &message="", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Assertion - throw exception if the given condition is not fulfilled.
 
void Assert (const bool ok, const char *message, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Assertion - throw exception if the given condition is not fulfilled.
 
void Exception (const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Create and (re)-throw a given GaudiException.
 
void Exception (const std::string &msg, const std::exception &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Create and (re)-throw a given exception.
 
void Exception (const std::string &msg="no message", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Create and throw an exception with the given message.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream ( MSG::ALWAYS )
 
MsgStreamfatal () const
 shortcut for the method msgStream ( MSG::FATAL )
 
MsgStreamerr () const
 shortcut for the method msgStream ( MSG::ERROR )
 
MsgStreamerror () const
 shortcut for the method msgStream ( MSG::ERROR )
 
MsgStreamwarning () const
 shortcut for the method msgStream ( MSG::WARNING )
 
MsgStreaminfo () const
 shortcut for the method msgStream ( MSG::INFO )
 
MsgStreamdebug () const
 shortcut for the method msgStream ( MSG::DEBUG )
 
MsgStreamverbose () const
 shortcut for the method msgStream ( MSG::VERBOSE )
 
MsgStreammsg () const
 shortcut for the method msgStream ( MSG::INFO )
 
const Statisticscounters () const
 accessor to all counters
 
StatEntitycounter (const std::string &tag) const
 accessor to certain counter by name
 
MSG::Level msgLevel () const
 The current message service output level.
 
bool msgLevel (const MSG::Level level) const
 Test the output level.
 
void resetMsgStream () const
 Reset (delete) the current message stream object.
 
bool typePrint () const
 Insert the actual C++ type of the algorithm/tool in the messages ?
 
bool propsPrint () const
 Print properties at initialization ?
 
bool statPrint () const
 Print statistical counters at finalization ?
 
bool errorsPrint () const
 Print error counters at finalization ?
 
long printStat (const MSG::Level level=MSG::ALWAYS) const
 perform the actual printout of statistical counters
 
long printErrors (const MSG::Level level=MSG::ALWAYS) const
 perform the actual printout of error counters
 
long printProps (const MSG::Level level=MSG::ALWAYS) const
 perform the actual printout of properties
 
template<class CallerClass >
void registerCondition (const std::string &condition, StatusCode(CallerClass::*mf)()=NULL)
 register the current instance to the UpdateManagerSvc as a consumer for a condition.
 
template<class CallerClass , class CondType >
void registerCondition (const std::string &condition, CondType *&condPtrDest, StatusCode(CallerClass::*mf)()=NULL)
 register the current instance to the UpdateManagerSvc as a consumer for a condition.
 
template<class CallerClass >
void registerCondition (char *condition, StatusCode(CallerClass::*mf)()=NULL)
 just to avoid conflicts with the version using a pointer to a template class.
 
template<class CallerClass , class TargetClass >
void registerCondition (TargetClass *condition, StatusCode(CallerClass::*mf)()=NULL)
 register the current instance to the UpdateManagerSvc as a consumer for a condition.
 
StatusCode runUpdate ()
 asks the UpdateManagerSvc to perform an update of the instance (if needed) without waiting the next BeginEvent incident.
 
 GaudiCommon (const std::string &name, ISvcLocator *pSvcLocator)
 Algorithm constructor.
 
 GaudiCommon (const std::string &type, const std::string &name, const IInterface *parent)
 Tool constructor.
 
virtual StatusCode initialize ()
 standard initialization method
 
virtual StatusCode finalize ()
 standard finalization method
 
StatusCode release (const IInterface *interface) const
 Manual forced (and 'safe') release of the active tool or service.
 
virtual unsigned long release ()
 Un-hide IInterface::release (ICC warning #1125)
 
const AlgToolstools () const
 get the list of aquired tools
 
const Servicesservices () const
 get the list of aquired services
 
const std::stringcontext () const
 Returns the "context" string. Used to identify different processing states.
 
const std::stringrootInTES () const
 Returns the "rootInTES" string.
 
double globalTimeOffset () const
 Returns the "globalTimeOffset" double.
 
const std::string fullTESLocation (const std::string &location, const bool useRootInTES) const
 Returns the full correct event location given the rootInTes settings.
 

Protected Types

typedef std::map< std::string,
StatEntity
Statistics
 the actual type of general counters
 
typedef std::map< std::string,
unsigned int
Counter
 the actual type error/warning counter
 
typedef std::vector< IAlgTool * > AlgTools
 storage for active tools
 
typedef GaudiUtils::HashMap
< std::string, SmartIF
< IService > > 
Services
 storage for active services
 

Protected Member Functions

virtual ~GaudiCommon ()
 Destructor.
 
StatusCode releaseTool (const IAlgTool *tool) const
 manual forced (and 'safe') release of the tool
 
StatusCode releaseSvc (const IInterface *svc) const
 manual forced (and 'safe') release of the service
 

Protected Attributes

ICounterSummarySvcm_counterSummarySvc
 a pointer to the CounterSummarySvc
 
std::vector< std::stringm_counterList
 list of counters to declare. Set by property CounterList. This can be a regular expression.
 
std::vector< std::stringm_statEntityList
 

Static Protected Attributes

static const bool IgnoreRootInTES = false
 Simple definition to be used with the new useRootInTES argument get<TYPE> and put methods.
 
static const bool UseRootInTES = true
 Simple definition to be used with the new useRootInTES argument get<TYPE> and put methods.
 

Private Member Functions

void msgLevelHandler (Property &theProp)
 Handle method for changes in the Messaging levels.
 
 GaudiCommon ()
 
 GaudiCommon (const GaudiCommon &)
 
GaudiCommonoperator= (const GaudiCommon &)
 
void printErrorHandler (Property &)
 handler for "ErrorPrint" property
 
void printPropsHandler (Property &)
 handler for "PropertiesPrint" property
 
void printStatHandler (Property &)
 handler for "StatPrint" property
 
void addToToolList (IAlgTool *tool) const
 Add the given tool to the list of acquired tools.
 
void addToServiceList (const SmartIF< IService > &svc) const
 Add the given service to the list of acquired services.
 
void initGaudiCommonConstructor (const IInterface *parent=0)
 Constructor initializations.
 

Private Attributes

MSG::Level m_msgLevel
 The message level.
 
MsgStreamm_msgStream
 The predefined message stream.
 
AlgTools m_tools
 List of active tools.
 
Services m_services
 List of active services.
 
Counter m_errors
 Counter of errors.
 
Counter m_warnings
 counter of warnings
 
Counter m_infos
 counter of infos
 
Counter m_exceptions
 Counter of exceptions.
 
Statistics m_counters
 General counters.
 
IUpdateManagerSvcm_updMgrSvc
 Pointer to the Update Manager Service instance.
 
bool m_typePrint
 insert the actual C++ type of the algorithm in the messages?
 
bool m_propsPrint
 print properties at initialization?
 
bool m_statPrint
 print counters at finalization ?
 
bool m_errorsPrint
 print warning and error counters at finalization ?
 
std::string m_context
 The context string.
 
std::string m_rootInTES
 The rootInTES string.
 
std::string m_rootOnTES
 The rootOnTES string.
 
double m_globalTimeOffset
 The globalTimeOffset value.
 
std::string m_header
 the header row
 
std::string m_format1
 format for regular statistical printout rows
 
std::string m_format2
 format for "efficiency" statistical printout rows
 
bool m_useEffFormat
 flag to use the special "efficiency" format
 

Detailed Description

template<class PBASE>
class GaudiCommon< PBASE >

Implements the common functionality between GaudiTools and GaudiAlgorithms.

Author
Chris Jones Chris.nosp@m.toph.nosp@m.er.Ro.nosp@m.b.Jo.nosp@m.nes@c.nosp@m.ern..nosp@m.ch
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@i.nosp@m.tep..nosp@m.ru
Rob Lambert Rob.L.nosp@m.ambe.nosp@m.rt@ce.nosp@m.rn.c.nosp@m.h
Date
2009-08-04

Definition at line 59 of file GaudiCommon.h.

Member Typedef Documentation

template<class PBASE>
typedef std::vector<IAlgTool*> GaudiCommon< PBASE >::AlgTools
protected

storage for active tools

Definition at line 92 of file GaudiCommon.h.

template<class PBASE>
typedef std::map<std::string,unsigned int> GaudiCommon< PBASE >::Counter
protected

the actual type error/warning counter

Definition at line 90 of file GaudiCommon.h.

template<class PBASE>
typedef GaudiUtils::HashMap<std::string, SmartIF<IService> > GaudiCommon< PBASE >::Services
protected

storage for active services

Definition at line 94 of file GaudiCommon.h.

template<class PBASE>
typedef std::map<std::string,StatEntity> GaudiCommon< PBASE >::Statistics
protected

the actual type of general counters

Definition at line 88 of file GaudiCommon.h.

Constructor & Destructor Documentation

template<class PBASE>
GaudiCommon< PBASE >::GaudiCommon ( const std::string name,
ISvcLocator pSvcLocator 
)

Algorithm constructor.

template<class PBASE>
GaudiCommon< PBASE >::GaudiCommon ( const std::string type,
const std::string name,
const IInterface parent 
)

Tool constructor.

template<class PBASE>
virtual GaudiCommon< PBASE >::~GaudiCommon ( )
inlineprotectedvirtual

Destructor.

Definition at line 698 of file GaudiCommon.h.

template<class PBASE>
GaudiCommon< PBASE >::GaudiCommon ( )
private
template<class PBASE>
GaudiCommon< PBASE >::GaudiCommon ( const GaudiCommon< PBASE > &  )
private

Member Function Documentation

template<class PBASE >
void GaudiCommon< PBASE >::addToServiceList ( const SmartIF< IService > &  svc) const
private

Add the given service to the list of acquired services.

Definition at line 466 of file GaudiCommon.icpp.

{
if (svc.isValid()) {
m_services[svc->name()] = svc;
}
}
template<class PBASE >
void GaudiCommon< PBASE >::addToToolList ( IAlgTool tool) const
private

Add the given tool to the list of acquired tools.

Definition at line 448 of file GaudiCommon.icpp.

{
if( 0 != tool ) {
if ( this->msgLevel ( MSG::DEBUG ) ) {
this->debug() << "The tool of type '"
<< System::typeinfoName(typeid(*tool))
<< "' has been added with the name '"
<< tool->name() << "'" << endmsg ;
}
m_tools.push_back( tool ) ;
}
}
template<class PBASE>
MsgStream& GaudiCommon< PBASE >::always ( ) const
inline

shortcut for the method msgStream ( MSG::ALWAYS )

Definition at line 487 of file GaudiCommon.h.

{ return msgStream ( MSG::ALWAYS ) ; }
template<class PBASE >
void GaudiCommon< PBASE >::Assert ( const bool  ok,
const std::string message = "",
const StatusCode  sc = StatusCode(StatusCode::FAILURE, true) 
) const
inline

Assertion - throw exception if the given condition is not fulfilled.

See Also
GaudiException
Exceptions
Exceptionfor invalid condition
Parameters
okCondition which should be "true"
messageMessage to be associated with the exception

Definition at line 238 of file GaudiCommonImp.h.

{
if (!ok) Exception( msg , sc );
}
template<class PBASE >
void GaudiCommon< PBASE >::Assert ( const bool  ok,
const char *  message,
const StatusCode  sc = StatusCode(StatusCode::FAILURE, true) 
) const
inline

Assertion - throw exception if the given condition is not fulfilled.

See Also
GaudiException
Exceptions
Exceptionfor invalid condition
Parameters
okCondition which should be "true"
messageMessage to be associated with the exception

Definition at line 256 of file GaudiCommonImp.h.

{
if (!ok) Exception( msg , sc );
}
template<class PBASE>
const std::string& GaudiCommon< PBASE >::context ( ) const
inline

Returns the "context" string. Used to identify different processing states.

Definition at line 754 of file GaudiCommon.h.

{ return m_context; }
template<class PBASE>
StatEntity& GaudiCommon< PBASE >::counter ( const std::string tag) const
inline

accessor to certain counter by name

if ( OK ) { ++counter("OK") ; }
// additive counter ('Flag')
counter("#Tracks") += tracks->size() ;
// multiplicative counter ('Weight')
counter("ProbTot") *= probability ;
See Also
StatEntuty
Parameters
tagcounter name
Returns
the counter itself

Definition at line 526 of file GaudiCommon.h.

{ return m_counters[tag] ; }
template<class PBASE>
const Statistics& GaudiCommon< PBASE >::counters ( ) const
inline

accessor to all counters

Definition at line 507 of file GaudiCommon.h.

{ return m_counters ; }
template<class PBASE>
MsgStream& GaudiCommon< PBASE >::debug ( ) const
inline

shortcut for the method msgStream ( MSG::DEBUG )

Definition at line 499 of file GaudiCommon.h.

{ return msgStream ( MSG::DEBUG ) ; }
template<class PBASE>
MsgStream& GaudiCommon< PBASE >::err ( ) const
inline

shortcut for the method msgStream ( MSG::ERROR )

Definition at line 491 of file GaudiCommon.h.

{ return msgStream ( MSG::ERROR ) ; }
template<class PBASE >
StatusCode GaudiCommon< PBASE >::Error ( const std::string msg,
const StatusCode  st = StatusCode::FAILURE,
const size_t  mx = 10 
) const

Print the error message and return with the given StatusCode.

Also performs statistical analysis of the error messages and suppression after the defined number of error instances.

if( a < 0 ) { return Error("a is negative!") ;}
if( b < 0 ) { return Error("b is illegal!" , StatusCode(25) );
if( c < 0 )
{ return Error("c is negative" , StatusCode(35) , 50 );
See Also
MsgStream
IMessageSvc
StatusCode
Parameters
msgError message
stStatusCode to return
mxMaximum number of printouts for this message
Returns
StatusCode

Definition at line 482 of file GaudiCommon.icpp.

{
// increase local counter of errors
const size_t num = ++m_errors[msg] ;
// If suppressed, just return
if ( num > mx ) { return st ; }
else if ( num == mx ) // issue one-time suppression message
{ return Print ( "The ERROR message is suppressed : '" +
msg + "'" , st , MSG::ERROR ) ; }
// return message
return Print ( msg , st , MSG::ERROR ) ;
}
template<class PBASE>
MsgStream& GaudiCommon< PBASE >::error ( ) const
inline

shortcut for the method msgStream ( MSG::ERROR )

Definition at line 493 of file GaudiCommon.h.

{ return msgStream ( MSG::ERROR ) ; }
template<class PBASE>
bool GaudiCommon< PBASE >::errorsPrint ( ) const
inline

Print error counters at finalization ?

Definition at line 552 of file GaudiCommon.h.

{ return m_errorsPrint ; }
template<class PBASE >
void GaudiCommon< PBASE >::Exception ( const std::string msg,
const GaudiException exc,
const StatusCode  sc = StatusCode(StatusCode::FAILURE, true) 
) const

Create and (re)-throw a given GaudiException.

See Also
GaudiException
Exceptions
GaudiExceptionalways thrown!
Parameters
msgException message
exc(previous) exception of type GaudiException

Definition at line 573 of file GaudiCommon.icpp.

{
// increase local counter of exceptions
Print ( "Exception (re)throw: " + msg , sc , MSG::FATAL ).ignore();
throw GaudiException( this->name() + ":: " + msg , this->name() , sc, exc);
}
template<class PBASE >
void GaudiCommon< PBASE >::Exception ( const std::string msg,
const std::exception exc,
const StatusCode  sc = StatusCode(StatusCode::FAILURE, true) 
) const

Create and (re)-throw a given exception.

See Also
GaudiException
Exceptions
std::exceptionalways thrown!
Parameters
msgException message
exc(previous) exception of type std::exception
scStatusCode

Definition at line 588 of file GaudiCommon.icpp.

{
// increase local counter of exceptions
Print ( "Exception (re)throw: " + msg , sc , MSG::FATAL ).ignore();
throw GaudiException( this->name() + ":: " + msg+"("+exc.what()+")", "", sc );
}
template<class PBASE >
void GaudiCommon< PBASE >::Exception ( const std::string msg = "no message",
const StatusCode  sc = StatusCode(StatusCode::FAILURE, true) 
) const

Create and throw an exception with the given message.

See Also
GaudiException
Exceptions
GaudiExceptionalways thrown!
Parameters
msgException message
scStatusCode

Definition at line 603 of file GaudiCommon.icpp.

{
// increase local counter of exceptions
Print ( "Exception throw: " + msg , sc , MSG::FATAL ).ignore();
throw GaudiException( this->name() + ":: " + msg , "", sc );
}
template<class PBASE >
template<class TYPE >
bool GaudiCommon< PBASE >::exist ( IDataProviderSvc svc,
const std::string location,
const bool  useRootInTES = true 
) const
inline

Check the existence of a data object or container in the Gaudi Transient Event Store.

bool a1 = exist<DataObject>( evtSvc() , "/Event/MyObject" ) ;
bool a2 = exist<MyHits> ( evtSvc() , "/Event/MyHits" ) ;
Attention
The method respects the setting of the job option RootInTES by prepending the value of this to the data location that is passed. The default setting for RootInTES is "" so has no effect. This behavior can be suppressed by passing the argument useRootInTES = false
Parameters
svcPointer to data provider service
locationAddress in Gaudi Transient Store
useRootInTESFlag to turn on(TRUE) off(FALSE) the use of the RootInTES location property
Returns
Boolean indicating status of the request
Return values
trueData object or container exists and implements a proper interface
trueFailed to locate the data object or container

Definition at line 91 of file GaudiCommonImp.h.

{
// check the environment
Assert( 0 != service , "exist():: IDataProvider* points to NULL!" ) ;
// check the data object
Gaudi::Utils::CheckData<TYPE> checker ;
return checker ( service,
fullTESLocation ( location , useRootInTES ) ) ;
}
template<class PBASE>
MsgStream& GaudiCommon< PBASE >::fatal ( ) const
inline

shortcut for the method msgStream ( MSG::FATAL )

Definition at line 489 of file GaudiCommon.h.

{ return msgStream ( MSG::FATAL ) ; }
template<class PBASE >
StatusCode GaudiCommon< PBASE >::finalize ( )
virtual

standard finalization method

Returns
status code

Reimplemented in GaudiHistos< GaudiAlgorithm >, GaudiHistos< GaudiTool >, GaudiTuples< GaudiHistoTool >, GaudiTuples< GaudiHistoAlg >, GaudiAlgorithm, GaudiTool, GaudiHistoTool, GaudiTupleTool, GaudiTupleAlg, GaudiHistoAlg, FuncMinimum, SequencerTimerTool, EqSolver, GaudiSequencer, RecordOutputStream, ReplayOutputStream, and Prescaler.

Definition at line 277 of file GaudiCommon.icpp.

{
// print the general information about statistical counters
if ( msgLevel(MSG::DEBUG) || (statPrint() && !counters().empty()) )
{
// print general statistical counters
}
//add all counters to the CounterSummarySvc
if(m_counterSummarySvc && this->svcLoc()->existsService("CounterSummarySvc"))
{
if ( msgLevel(MSG::DEBUG) ) debug() << "adding counters to CounterSummarySvc" << endmsg;
for(Statistics::const_iterator i=this->counters().begin();
i!=this->counters().end();
i++)
{
m_counterSummarySvc->addCounter(this->name(),i->first,i->second,
m_counterSummarySvc->addCounter(this->name(),i->first,i->second);
}
}
// release all located tools and services
{
debug() << "Tools to release :";
i != m_tools.end(); ++i )
{
debug() << " " << (*i)->name();
}
debug() << endmsg;
}
while ( !m_tools.empty() ) { sc = sc && releaseTool( m_tools.back() ) ; }
// release all located services
{
debug() << "Services to release :";
i != m_services.end(); ++i )
{
debug() << " " << (*i).first;
}
debug() << endmsg;
}
while ( !m_services.empty() ) { sc = sc && releaseSvc( m_services.begin()->second ) ; }
//release the CounterSummarySvc manually
{
}
// format printout
{
always() << "Exceptions/Errors/Warnings/Infos Statistics : "
<< m_exceptions .size () << "/"
<< m_errors .size () << "/"
<< m_warnings .size () << "/"
<< m_infos .size () << endmsg ;
if ( errorsPrint() ) { printErrors () ; }
}
// delete the MsgStream
// clear *ALL* counters explicitly
// finalize base class
return sc && PBASE::finalize();
}
template<class PBASE >
const std::string GaudiCommon< PBASE >::fullTESLocation ( const std::string location,
const bool  useRootInTES 
) const
inline

Returns the full correct event location given the rootInTes settings.

Definition at line 25 of file GaudiCommonImp.h.

{
// The logic is:
// if no R.I.T., give back location
// if R.I.T., this is the mapping:
// (note that R.I.T. contains a trailing '/')
// location -> result
// -------------------------------------------------
// "" -> R.I.T.[:-1] ("rit")
// "/Event" -> R.I.T.[:-1] ("rit")
// "/Event/MyObj" -> R.I.T. + "MyObj" ("rit/MyObj")
// "MyObj" -> R.I.T. + "MyObj" ("rit/MyObj")
return ( !useRootInTES || rootInTES().empty() ?
location
:
location.empty() || ( location == "/Event" ) ?
rootInTES().substr(0,rootInTES().size()-1)
:
0 == location.find("/Event/") ?
rootInTES() + location.substr(7)
:
rootInTES() + location );
}
template<class PBASE >
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type GaudiCommon< PBASE >::get ( IDataProviderSvc svc,
const std::string location,
const bool  useRootInTES = true 
) const
inline

Templated access to the data in Gaudi Transient Store.

Quick and safe access to the data in Gaudi transient store. The method located the data at given address and perform the debug printout about located data

// Will access MCHits from the given location
MCHits* hits = get<MCHits>( evtSvc () , "MC/Hits" );
Attention
The method respects the setting of the job option RootInTES by prepending the value of this to the data location that is passed. The default setting for RootInTES is "" so has no effect. This behavior can be suppressed by passing the argument useRootInTES = false
See Also
IDataProviderSvc
SmartDataPtr
Exceptions
GaudiExceptionfor Invalid Data Provider Service
GaudiExceptionfor invalid/unavailable data
Parameters
svcPointer to data service (data provider)
locationdata location/address in Gaudi Transient Store
useRootInTESFlag to turn on(TRUE) off(FALSE) the use of the RootInTES location property
Returns
pointer to the data object

Definition at line 55 of file GaudiCommonImp.h.

{
// check the environment
Assert( 0 != service , "get():: IDataProvider* points to NULL!" ) ;
// get the helper object:
Gaudi::Utils::GetData<TYPE> getter ;
return getter ( *this ,
service ,
fullTESLocation ( location , useRootInTES ) ) ;
}
template<class PBASE >
template<class TYPE >
Gaudi::Utils::GetData< TYPE >::return_type GaudiCommon< PBASE >::getIfExists ( IDataProviderSvc svc,
const std::string location,
const bool  useRootInTES = true 
) const
inline

Quicker version of the get function which bypasses the check on the retrieved data.

Definition at line 73 of file GaudiCommonImp.h.

{
// check the environment
Assert( 0 != service , "get():: IDataProvider* points to NULL!" ) ;
// get the helper object:
Gaudi::Utils::GetData<TYPE> getter ;
return getter ( *this ,
service ,
fullTESLocation ( location , useRootInTES ),
false) ;
}
template<class PBASE >
template<class TYPE , class TYPE2 >
Gaudi::Utils::GetData< TYPE >::return_type GaudiCommon< PBASE >::getOrCreate ( IDataProviderSvc svc,
const std::string location,
const bool  useRootInTES = true 
) const
inline

Get the existing data object from Gaudi Event Transient store.

  Alternatively, create new object and register it in TES
  and return if object does not exist.
MyHits* hits = getOrCreate<MyHits,MyHits>( evtSvc() , "/Event/MyHits" ) ;
Attention
The method respects the setting of the job option RootInTES by prepending the value of this to the data location that is passed. The default setting for RootInTES is "" so has no effect. This behavior can be suppressed by passing the argument useRootInTES = false
Exceptions
GaudiExceptionfor Invalid Data Provider Service
GaudiExceptionfor invalid/unavailable data
Parameters
svcPointer to data provider service
locationLocation in Gaudi Transient Event Store
useRootInTESFlag to turn on(TRUE) off(FALSE) the use of the RootInTES location property
Returns
A valid pointer to the data object

Definition at line 110 of file GaudiCommonImp.h.

{
// check the environment
Assert ( 0 != service , "getOrCreate():: svc points to NULL!" ) ;
// get the helper object
Gaudi::Utils::GetOrCreateData<TYPE,TYPE2> getter ;
return getter ( *this ,
service ,
fullTESLocation( location, useRootInTES ) ,
location ) ;
}
template<class PBASE>
double GaudiCommon< PBASE >::globalTimeOffset ( ) const
inline

Returns the "globalTimeOffset" double.

Definition at line 760 of file GaudiCommon.h.

{ return m_globalTimeOffset; }
template<class PBASE >
StatusCode GaudiCommon< PBASE >::Info ( const std::string msg,
const StatusCode  st = StatusCode::SUCCESS,
const size_t  mx = 10 
) const

Print the info message and return with the given StatusCode.

Also performs statistical analysis of the error messages and suppression after the defined number of instances.

See Also
MsgStream
IMessageSvc
StatusCode
GaudiCommon::Warning
Parameters
msgInfo message
stStatusCode to return
mxMaximum number of printouts for this message
Returns
The given StatusCode

Definition at line 524 of file GaudiCommon.icpp.

{
// increase local counter of warnings
const size_t num = ++m_infos[msg] ;
// If suppressed, just return
if ( num > mx ) { return st ; }
else if ( num == mx ) // issue one-time suppression message
{ return Print ( "The INFO message is suppressed : '" +
msg + "'" , st , MSG::INFO ) ; }
// return message
return Print ( msg , st , MSG::INFO ) ;
}
template<class PBASE>
MsgStream& GaudiCommon< PBASE >::info ( ) const
inline

shortcut for the method msgStream ( MSG::INFO )

Definition at line 497 of file GaudiCommon.h.

{ return msgStream ( MSG::INFO ) ; }
template<class PBASE >
void GaudiCommon< PBASE >::initGaudiCommonConstructor ( const IInterface parent = 0)
private

Constructor initializations.

< flag to use the special "efficiency" format

Definition at line 63 of file GaudiCommon.icpp.

{
// initialise data members
m_typePrint = true;
m_propsPrint = false;
m_statPrint = true;
m_errorsPrint = true;
m_context = "" ;
m_rootInTES = "" ;
//data members for the CounterSummarySvc
// printout of counters:
// the header row for counters printout
m_header = " | Counter | # | sum | mean/eff^* | rms/err^* | min | max |" ;
// format for regular statistical printout rows
m_format1 = " | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |" ;
// format for "efficiency" statistical printout rows
m_format2 = " |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |" ;
// flag to use the special "efficiency" format
m_useEffFormat = true ;
// job options
// print error counters at finalization ?
this->declareProperty
( "ErrorsPrint" , m_errorsPrint ,
"Print the statistics of errors/warnings/exceptions")
-> declareUpdateHandler
// print properties at initialization?
this->declareProperty
( "PropertiesPrint" , m_propsPrint ,
"Print the properties of the component ")
-> declareUpdateHandler
// print statistical counters at finalization ?
this->declareProperty
( "StatPrint" , m_statPrint ,
"Print the table of counters" )
-> declareUpdateHandler
// insert the actual C++ type of the algorithm or tool in the messages?
this->declareProperty
( "TypePrint" , m_typePrint ,
"Add the actal C++ component type into the messages" ) ;
// context
this->declareProperty ( "Context" , m_context ) ;
// root in TES
this->declareProperty ( "RootInTES" , m_rootInTES ) ;
// root on TES ( temporary )
this->declareProperty ( "RootOnTES" , m_rootOnTES ) ;
// global time offset
this->declareProperty ( "GlobalTimeOffset", m_globalTimeOffset ) ;
// the header row for counters printout
this->declareProperty
( "StatTableHeader" , m_header ,
"The header row for the output Stat-table" ) ;
// format for regular statistical printout rows
this->declareProperty
( "RegularRowFormat" , m_format1 ,
"The format for the regular row in the output Stat-table" ) ;
// format for "efficiency" statistical printout rows
this->declareProperty
( "EfficiencyRowFormat" , m_format2 ,
"The format for the regular row in the output Stat-table" ) ;
// flag to use the special "efficiency" format
this->declareProperty
( "UseEfficiencyRowFormat" , m_useEffFormat ,
"Use the special format for printout of efficiency counters" ) ;
//declare the list of simple counters to write.
this->declareProperty(
"CounterList",
"RegEx list, of simple integer counters for CounterSummary.");
//declare the list of stat entities to write.
this->declareProperty(
"StatEntityList",
m_statEntityList=std::vector<std::string>(0),
"RegEx list, of StatEntity counters for CounterSummary.");
// add handler for message level changes
this->outputLevelProperty().declareUpdateHandler( &GaudiCommon<PBASE>::msgLevelHandler, this );
// setup context from parent if available
if ( parent )
{
if ( const GaudiAlgorithm* gAlg = dynamic_cast<const GaudiAlgorithm*>(parent) )
{
m_context = gAlg->context();
m_rootInTES = gAlg->rootInTES();
m_globalTimeOffset = gAlg->globalTimeOffset();
}
else if ( const GaudiTool* gTool = dynamic_cast<const GaudiTool*> (parent) )
{
m_context = gTool->context();
m_rootInTES = gTool->rootInTES();
m_globalTimeOffset = gTool->globalTimeOffset();
}
}
// Get the job option service
SmartIF<IJobOptionsSvc> jos(PBASE::service("JobOptionsSvc"));
if (!jos.isValid()) Exception("Cannot get JobOptionsSvc");
// Get the "Context" option if in the file...
const std::vector<const Property*>* myList = jos->getProperties( this->name() );
if ( 0 != myList )
{
// Iterate over the list to set the options
iter != myList->end();
++iter )
{
const StringProperty* sp = dynamic_cast<const StringProperty*>(*iter);
if ( 0 != sp )
{
if ( "Context" == (*iter)->name() )
{
m_context = sp->value();
} else if ( "RootInTES" == (*iter)->name() ) {
m_rootInTES = sp->value();
} else if ( "GlobalTimeOffset" == (*iter)->name() ) {
m_globalTimeOffset = atof( sp->value().c_str() );
}
}
}
}
}
template<class PBASE >
StatusCode GaudiCommon< PBASE >::initialize ( )
virtual

standard initialization method

Returns
status code

Reimplemented in GaudiHistos< GaudiAlgorithm >, GaudiHistos< GaudiTool >, GaudiTuples< GaudiHistoTool >, GaudiTuples< GaudiHistoAlg >, GaudiTool, GaudiAlgorithm, GaudiHistoTool, GaudiTupleTool, GaudiTupleAlg, GaudiHistoAlg, FuncMinimum, SequencerTimerTool, EqSolver, GaudiSequencer, RecordOutputStream, Prescaler, and ReplayOutputStream.

Definition at line 215 of file GaudiCommon.icpp.

{
// initialize base class
if ( sc.isFailure() )
{ return Error ( "Failed to initialise base class PBASE", sc ) ; }
// some debug printout
{
debug() << "Initialize base class GaudiCommon<" << System::typeinfoName(typeid(PBASE)) << ">" << endmsg;
if ( !context().empty() )
debug() << "Created with context = '" << context() << "'" << endmsg;
}
// some temporary checks to see if people are using RootOnTES and warn if so
// TO BE REMOVED ASAP ...
if ( m_rootInTES.empty() && !m_rootOnTES.empty() )
{
Warning( "RootOnTES option is OBSOLETE -> Use RootInTES instead. RootInTES has been updated to "
}
else if ( !m_rootInTES.empty() && !m_rootOnTES.empty() )
{
Warning( "Options RootOnTES AND RootInTES are defined ! Use RootInTES. RootOnTES is ignored",
}
// Check rootInTES ends with a /
if ( !m_rootInTES.empty() &&
m_rootInTES.substr(m_rootInTES.size()-1) != "/" ) m_rootInTES += "/";
//Set up the CounterSummarySvc May need to be changed
this->svcLoc()->service("CounterSummarySvc",m_counterSummarySvc,false).ignore() ;
{
if (m_counterSummarySvc==NULL )
debug() << "could not locate CounterSummarySvc, no counter summary will be made" << endmsg;
else debug() << "found CounterSummarySvc OK" << endmsg;
}
// properties will be printed if asked for or in "MSG::DEBUG" mode
return sc;
}
template<class PBASE>
MsgStream& GaudiCommon< PBASE >::msg ( ) const
inline

shortcut for the method msgStream ( MSG::INFO )

Definition at line 503 of file GaudiCommon.h.

{ return msgStream ( MSG::INFO ) ; }
template<class PBASE>
MSG::Level GaudiCommon< PBASE >::msgLevel ( ) const
inline

The current message service output level.

Returns
The current message level

Definition at line 532 of file GaudiCommon.h.

{ return m_msgLevel ; }
template<class PBASE>
bool GaudiCommon< PBASE >::msgLevel ( const MSG::Level  level) const
inline

Test the output level.

Parameters
levelThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "level" will be printed
trueMessages at level "level" will NOT be printed

Definition at line 539 of file GaudiCommon.h.

{ return msgLevel() <= level ; }
template<class PBASE >
void GaudiCommon< PBASE >::msgLevelHandler ( Property theProp)
private

Handle method for changes in the Messaging levels.

Called whenever the property "OutputLevel" changes to perform all necessary actions locally.

Parameters
thePropReference to the Property that has changed

Definition at line 731 of file GaudiCommon.icpp.

{
// Force a new MsgStream object, to pick up the new settings
// adjust internal message level
this->outputLevel() < (int) MSG::NIL ? MSG::NIL :
this->outputLevel() >= (int) MSG::NUM_LEVELS ? MSG::ALWAYS :
MSG::Level( this->outputLevel() ) ;
// Keep MessageSvc up to date if needed
if ( this->msgSvc()->outputLevel(this->name()) != this->outputLevel() )
{
this->msgSvc()->setOutputLevel( this->name(), this->outputLevel() );
}
// printout message
{
debug() << "Property update for "
<< theProp.name() << " : new value = " << this->outputLevel() << endmsg;
}
}
template<class PBASE >
MsgStream & GaudiCommon< PBASE >::msgStream ( const MSG::Level  level) const
inline

Predefined configurable message stream for the efficient printouts.

if ( a < 0 ) { msgStream( MSG::ERROR ) << "a = " << endmsg ; }
Returns
Reference to the predefined stream

Definition at line 228 of file GaudiCommonImp.h.

{
if ( !m_msgStream )
{ m_msgStream = new MsgStream ( PBASE::msgSvc() , this->name() ) ; }
return *m_msgStream << level ;
}
template<class PBASE>
GaudiCommon& GaudiCommon< PBASE >::operator= ( const GaudiCommon< PBASE > &  )
private
template<class PBASE >
StatusCode GaudiCommon< PBASE >::Print ( const std::string msg,
const StatusCode  st = StatusCode::SUCCESS,
const MSG::Level  lev = MSG::INFO 
) const

Print the message and return with the given StatusCode.

See Also
MsgStream
IMessageSvc
StatusCode
Parameters
msgMessage to print
stStatusCode to return
levPrintout level for the given message
Returns
The given StatusCode

Definition at line 544 of file GaudiCommon.icpp.

{
// perform printout ?
if ( !msgLevel( lvl ) ) { return st ; } // RETURN
// use the predefined stream
MsgStream& str = msgStream( lvl ) ;
if ( typePrint() ) { str << System::typeinfoName(typeid(*this)) << ":: " ; }
// print the message
str << msg ;
// test status code
if ( st.isSuccess() ) { }
else if ( StatusCode::FAILURE != st.getCode() )
{ str << " StatusCode=" << st.getCode() ; }
else
{ str << " StatusCode=FAILURE" ; }
// perform print operation
str << endmsg ;
// return
return st;
}
template<class PBASE >
void GaudiCommon< PBASE >::printErrorHandler ( Property )
private

handler for "ErrorPrint" property

Definition at line 798 of file GaudiCommon.icpp.

{
// no action if not yet initialized
if ( this -> FSMState() < Gaudi::StateMachine::INITIALIZED ) { return ; }
if ( this -> errorsPrint() ) { this -> printErrors () ; }
}
template<class PBASE >
long GaudiCommon< PBASE >::printErrors ( const MSG::Level  level = MSG::ALWAYS) const

perform the actual printout of error counters

Parameters
levelThe message level to print at
Returns
number of error counters

Definition at line 648 of file GaudiCommon.icpp.

{
// format for printout
boost::format ftm ( " %s = %|.8s| %|23t| Message = '%s'" );
{ // print exceptions
excp != m_exceptions.end() ; ++excp )
{
<< ( ftm % "#EXCEPTIONS" % excp->second % excp->first )
<< endmsg;
}
}
{ // print errors
error != m_errors.end() ; ++error )
{
<< ( ftm % "#ERRORS " % error->second % error->first )
<< endmsg;
}
}
{ // print warnings
{
<< ( ftm % "#WARNINGS " % warning->second % warning->first )
<< endmsg;
}
}
{ // print warnings
info != m_infos.end() ; ++info )
{
<< ( ftm % "#INFOS " % info->second % info->first )
<< endmsg;
}
}
// return total number of errors+warnings+exceptions
return
m_errors .size () +
m_infos .size () ;
}
template<class PBASE >
long GaudiCommon< PBASE >::printProps ( const MSG::Level  level = MSG::ALWAYS) const

perform the actual printout of properties

perform the printout of properties

Parameters
levelThe message level to print at
Returns
number of properties
number of error counters

Definition at line 705 of file GaudiCommon.icpp.

{
// print ALL properties
typedef std::vector<Property*> Properties;
const Properties& properties = this->getProperties() ;
msg << "List of ALL properties of "
<< System::typeinfoName( typeid( *this ) ) << "/" << this->name()
<< " #properties = " << properties.size() << endmsg ;
for ( Properties::const_reverse_iterator property
= properties.rbegin() ;
properties.rend() != property ; ++property )
{
msg << "Property ['Name': Value] = "
<< ( **property)
<< endmsg ;
}
return properties.size() ;
}
template<class PBASE >
void GaudiCommon< PBASE >::printPropsHandler ( Property )
private

handler for "PropertiesPrint" property

Definition at line 808 of file GaudiCommon.icpp.

{
// no action if not yet initialized
if ( this -> FSMState() < Gaudi::StateMachine::INITIALIZED ) { return ; }
if ( this -> propsPrint() ) { this -> printProps ( MSG::ALWAYS ) ; }
}
template<class PBASE >
long GaudiCommon< PBASE >::printStat ( const MSG::Level  level = MSG::ALWAYS) const

perform the actual printout of statistical counters

Parameters
levelThe message level to print at
Returns
number of active statistical counters

Definition at line 617 of file GaudiCommon.icpp.

{
// print statistics
if ( counters().empty() ) { return 0 ; }
//
msg << "Number of counters : " << counters().size() ;
//
if ( !counters().empty() ) { msg << std::endl << m_header ; }
//
for ( Statistics::const_iterator entry = counters().begin() ;
counters().end() != entry ; ++entry )
{
msg << std::endl
( entry -> first ,
entry -> second ,
}
//
msg << endmsg ;
//
return counters().size() ;
}
template<class PBASE >
void GaudiCommon< PBASE >::printStatHandler ( Property )
private

handler for "StatPrint" property

Definition at line 818 of file GaudiCommon.icpp.

{
// no action if not yet initialized
if ( this -> FSMState() < Gaudi::StateMachine::INITIALIZED ) { return ; }
if ( this -> statPrint() ) { this -> printStat ( MSG::ALWAYS ) ; }
}
template<class PBASE>
bool GaudiCommon< PBASE >::propsPrint ( ) const
inline

Print properties at initialization ?

Definition at line 548 of file GaudiCommon.h.

{ return m_propsPrint ; }
template<class PBASE >
DataObject * GaudiCommon< PBASE >::put ( IDataProviderSvc svc,
DataObject object,
const std::string location,
const bool  useRootInTES = true 
) const

Register a data object or container into Gaudi Event Transient Store.

See Also
IDataProviderSvc
Attention
The method respects the setting of the job option RootInTES by prepending the value of this to the data location that is passed. The default setting for RootInTES is "" so has no effect. This behavior can be suppressed by passing the argument useRootInTES = false
Parameters
svcPointer to data provider service
objectData object or container to be registered
locationLocation in Gaudi Event Transient Store ("/Event" could be omitted )
useRootInTESFlag to turn on(TRUE) off(FALSE) the use of the RootInTES location property
Exceptions
GaudiExceptionfor invalid event data service
GaudiExceptionfor invalid object
GaudiExceptionfor error result from event data service
Returns
StatusCode
Return values
StatusCode::SUCCESSData was successfully placed in the TES.
StatusCode::FAILUREFailed to store data in the TES.

Definition at line 765 of file GaudiCommon.icpp.

{
// check arguments
Assert ( 0 != svc , "put():: Invalid 'service'!" ) ;
Assert ( 0 != object , "put():: Invalid 'Object'!" ) ;
Assert ( !location.empty() , "put():: Invalid 'address' = '' " ) ;
// final data location
const std::string & fullLocation = fullTESLocation( location, useRootInTES );
// register the object!
const StatusCode status = '/' == fullLocation[0] ?
svc -> registerObject( fullLocation , object ) :
svc -> registerObject( "/Event/" + fullLocation , object ) ;
// check the result!
if ( status.isFailure() )
{ Exception ( "put():: could not register '" +
System::typeinfoName( typeid( *object ) ) +
"' at address '" + fullLocation + "'" , status ) ; }
if ( msgLevel( MSG::DEBUG ) )
{ Print( "The object of type '" +
System::typeinfoName( typeid( *object ) ) +
"' is registered in TS at address '"
+ fullLocation + "'" , status , MSG::DEBUG ).ignore() ; }
return object;
}
template<class PBASE>
template<class CallerClass >
void GaudiCommon< PBASE >::registerCondition ( const std::string condition,
StatusCode(CallerClass::*)()  mf = NULL 
)
inline

register the current instance to the UpdateManagerSvc as a consumer for a condition.

Parameters
conditionthe path inside the Transient Detector Store to the condition object.
mfoptional pointer to the member function to call when the condition object is updated. If the pointer is omitted the user must explicitly provide the class name to the method.
// ...
registerCondition("/dd/Conditions/Readout/MyDet/MyCond",&MyAlg::i_CallBack);
registerCondition<MyAlg>("/dd/Conditions/Readout/MyDet/MyOtherCond");
// ...
}

Definition at line 595 of file GaudiCommon.h.

{
updMgrSvc()->registerCondition(dynamic_cast<CallerClass*>(this),condition,mf);
}
template<class PBASE>
template<class CallerClass , class CondType >
void GaudiCommon< PBASE >::registerCondition ( const std::string condition,
CondType *&  condPtrDest,
StatusCode(CallerClass::*)()  mf = NULL 
)
inline

register the current instance to the UpdateManagerSvc as a consumer for a condition.

This version of the method allow the user to specify where to put a copy of the pointer to the condition object.

Parameters
conditionthe path inside the Transient Detector Store to the condition object.
condPtrDestpointer to fill with the location of the condition object. Note: the pointer can be safely used only in the execute method or in the member function triggered by the update.
mfoptional pointer to the member function to call when the condition object is updated. If the pointer is omitted the user must explicitly provide the class name to the method.
class MyAlg: public GaudiAlgorithm {
// ...
public:
virtual StatusCode i_CallBack();
private:
Condition *m_MyCond;
SpecialCondition *m_MyOtherCond;
// ...
};
// ...
registerCondition("/dd/Conditions/Readout/MyDet/MyCond",m_MyCond,&MyAlg::i_CallBack);
registerCondition<MyAlg>("/dd/Conditions/Readout/MyDet/MyOtherCond",m_MyOtherCond);
// ...
}

Definition at line 629 of file GaudiCommon.h.

{
updMgrSvc()->registerCondition(dynamic_cast<CallerClass*>(this),condition,mf,condPtrDest);
}
template<class PBASE>
template<class CallerClass >
void GaudiCommon< PBASE >::registerCondition ( char *  condition,
StatusCode(CallerClass::*)()  mf = NULL 
)
inline

just to avoid conflicts with the version using a pointer to a template class.

Definition at line 635 of file GaudiCommon.h.

{
updMgrSvc()->registerCondition(dynamic_cast<CallerClass*>(this),std::string(condition),mf);
}
template<class PBASE>
template<class CallerClass , class TargetClass >
void GaudiCommon< PBASE >::registerCondition ( TargetClass *  condition,
StatusCode(CallerClass::*)()  mf = NULL 
)
inline

register the current instance to the UpdateManagerSvc as a consumer for a condition.

Parameters
conditionthe path inside the Transient Detector Store to the condition object.
mfoptional pointer to the member function to call when the condition object is updated. If the pointer is omitted the user must explicitly provide the class name to the method.
// ...
registerCondition("/dd/Conditions/Readout/MyDet/MyCond",&MyAlg::i_CallBack);
registerCondition<MyAlg>("/dd/Conditions/Readout/MyDet/MyOtherCond");
// ...
}

Definition at line 654 of file GaudiCommon.h.

{
updMgrSvc()->registerCondition(dynamic_cast<CallerClass*>(this),condition,mf);
}
template<class PBASE >
StatusCode GaudiCommon< PBASE >::release ( const IInterface interface) const

Manual forced (and 'safe') release of the active tool or service.

IMyTool* mytool = tool<IMyTool>( .... ) ;
mytool->spendCPUtime() ;
release ( mytool ) ;
IMySvc* msvc = svc<IMySvc>( .... ) ;
msvc->spendCPUtime() ;
release ( msvc ) ;
Parameters
interfaceInterface pointer to the interface to be released
Returns
StatusCode
Return values
StatusCode::SUCCESSTool or service was successfully released
StatusCode::FAILUREError releasing too or service

Definition at line 371 of file GaudiCommon.icpp.

{
if ( 0 == interface )
{ return Error ( "release(IInterface):: IInterface* points to NULL!" ) ; }
// dispatch between tools and services
const IAlgTool* algTool = dynamic_cast<const IAlgTool*>( interface ) ;
// perform the actual release
return 0 != algTool ? releaseTool( algTool ) : releaseSvc( interface ) ;
}
template<class PBASE>
virtual unsigned long GaudiCommon< PBASE >::release ( )
inlinevirtual

Un-hide IInterface::release (ICC warning #1125)

Definition at line 733 of file GaudiCommon.h.

{ return PBASE::release(); }
template<class PBASE >
StatusCode GaudiCommon< PBASE >::releaseSvc ( const IInterface svc) const
protected

manual forced (and 'safe') release of the service

Definition at line 423 of file GaudiCommon.icpp.

{
if( 0 == Svc ) {
return Error ( "releaseSvc(IInterface):: IInterface* points to NULL!" ) ;
}
SmartIF<IService> svc(const_cast<IInterface*>(Svc));
if (svc.isValid()) {
Services::iterator it = m_services.find(svc->name());
if (it == m_services.end()) {
return Warning( "releaseSvc(IInterface):: IInterface* is not active" );
}
if ( msgLevel(MSG::DEBUG) ) {
debug() << "Releasing service '" << it->first << "'" << endmsg;
}
}
return Warning( "releaseSvc(IInterface):: IInterface* is not a service" );
}
template<class PBASE >
StatusCode GaudiCommon< PBASE >::releaseTool ( const IAlgTool tool) const
protected

manual forced (and 'safe') release of the tool

Definition at line 386 of file GaudiCommon.icpp.

{
if( 0 == algTool )
{ return Error ( "releaseTool(IAlgTool):: IAlgTool* points to NULL!" ) ; }
if( this->toolSvc() == 0 )
{ return Error ( "releaseTool(IAlgTool):: IToolSvc* points to NULL!" ) ; }
// find a tool in the list of active tools
std::find( m_tools.rbegin() , m_tools.rend() , algTool ) ;
if( m_tools.rend() == it )
{ return Warning("releaseTool(IAlgTool):: IAlgTool* is not active" ) ; }
// get the tool
IAlgTool* t = *it ;
// cache name
const std::string name = t->name();
{ debug() << "Releasing tool '" << name << "'" << endmsg; }
// remove the tool from the lists
m_tools.erase( --it.base() ) ;
// release tool
if ( msgLevel(MSG::DEBUG) ) {
this->debug() << "The tool '" << t->name() << "' of type '"
<< System::typeinfoName(typeid(*t))
<< "' is released" << endmsg;
}
const StatusCode sc = this->toolSvc()->releaseTool( t ) ;
if ( sc.isFailure() )
{ return Warning ( "releaseTool(IAlgTool):: error from IToolSvc whilst releasing "+name , sc ) ; }
// return final status code
return sc ;
}
template<class PBASE >
void GaudiCommon< PBASE >::resetMsgStream ( ) const
inline

Reset (delete) the current message stream object.

Useful for example to force a new object following a change in the message level settings

Definition at line 248 of file GaudiCommonImp.h.

{
if ( 0 != m_msgStream ) { delete m_msgStream; m_msgStream = 0; }
}
template<class PBASE>
const std::string& GaudiCommon< PBASE >::rootInTES ( ) const
inline

Returns the "rootInTES" string.

Used as the directory root in the TES for which all data access refers to (both saving and retrieving).

Definition at line 758 of file GaudiCommon.h.

{ return m_rootInTES; }
template<class PBASE>
StatusCode GaudiCommon< PBASE >::runUpdate ( )
inline

asks the UpdateManagerSvc to perform an update of the instance (if needed) without waiting the next BeginEvent incident.

It is useful if the instance can be instantiated after a BeginEvent incident, and used before the next one (for example with tools).

// ...
return runUpdate();
}

Definition at line 668 of file GaudiCommon.h.

{ return updMgrSvc()->update(this); }
template<class PBASE>
const Services& GaudiCommon< PBASE >::services ( ) const
inline

get the list of aquired services

Definition at line 740 of file GaudiCommon.h.

{ return m_services ; } // get all services
template<class PBASE>
bool GaudiCommon< PBASE >::statPrint ( ) const
inline

Print statistical counters at finalization ?

Definition at line 550 of file GaudiCommon.h.

{ return m_statPrint ; }
template<class PBASE >
template<class SERVICE >
SmartIF< SERVICE > GaudiCommon< PBASE >::svc ( const std::string name,
const bool  create = true 
) const
inline

A useful method for the easy location of services.

IMyService* mySvc = svc<IMyService>( "MyServiceType" );
Attention
The services located with this method will be released automatically
See Also
IService
ISevcLocator
Service
Exceptions
GaudiExceptionfor error in Algorithms::service
GaudiExceptionfor invalid service
Parameters
nameservice type name
createFlag for creation of non-existing services
Returns
A pointer to the service

Definition at line 184 of file GaudiCommonImp.h.

{
Assert ( this->svcLoc() != 0, "ISvcLocator* points to NULL!" );
// check if we already have this service
if (it != m_services.end()) {
// Try to get the requested interface
s = it->second;
// check the results
if ( !s.isValid() ) {
Exception ("svc():: Could not retrieve Svc '" + name + "'", StatusCode::FAILURE);
}
} else {
SmartIF<IService>& baseSvc = this->svcLoc()->service(name, create);
// Try to get the requested interface
s = baseSvc;
// check the results
if ( !baseSvc.isValid() || !s.isValid() ) {
Exception ("svc():: Could not retrieve Svc '" + name + "'", StatusCode::FAILURE);
}
// add the tool into list of known tools, to be properly released
addToServiceList(baseSvc);
}
// return *VALID* located service
return s;
}
template<class PBASE >
template<class TOOL >
TOOL * GaudiCommon< PBASE >::tool ( const std::string type,
const std::string name,
const IInterface parent = 0,
bool  create = true 
) const
inline

Useful method for the easy location of tools.

IMyTool* myTool =
tool<IMyTool>( "MyToolType", "MyToolName", this );
Attention
The tools located with this method will be released automatically
See Also
IToolSvc
IAlgTool
Exceptions
GaudiExceptionfor invalid Tool Service
GaudiExceptionfor error from Tool Service
GaudiExceptionfor invalid tool
Parameters
typeTool type
nameTool name
parentTool parent
createFlag for creation of nonexisting tools
Returns
A pointer to the tool

Definition at line 128 of file GaudiCommonImp.h.

{
TOOL* Tool = 0 ;
// for empty names delegate to another method
if ( name.empty() )
{
Tool = tool<TOOL>( type , parent , create ) ;
}
else
{
Assert( this->toolSvc() != 0, "tool():: IToolSvc* points to NULL!" ) ;
// get the tool from Tool Service
const StatusCode sc =
this->toolSvc()->retrieveTool ( type , name , Tool , parent , create ) ;
if ( sc.isFailure() )
{ Exception("tool():: Could not retrieve Tool '" + type + "'/'" + name + "'", sc ) ; }
if ( 0 == Tool )
{ Exception("tool():: Could not retrieve Tool '" + type + "'/'" + name + "'" ) ; }
// add the tool into list of known tools to be properly released
addToToolList( Tool );
}
// return *VALID* located tool
return Tool ;
}
template<class PBASE >
template<class TOOL >
TOOL * GaudiCommon< PBASE >::tool ( const std::string type,
const IInterface parent = 0,
bool  create = true 
) const
inline

A useful method for the easy location of tools.

IMyTool* myTool = tool<IMyTool>( "PublicToolType" );
Attention
The tools located with this method will be released automatically
See Also
IToolSvc
IAlgTool
Exceptions
GaudiExceptionfor invalid Tool Service
GaudiExceptionfor error from Tool Service
GaudiExceptionfor invalid tool
Parameters
typeTool type, could be of "Type/Name" format
parentTool parent
createFlag for creation of non-existing tools
Returns
A pointer to the tool

Definition at line 160 of file GaudiCommonImp.h.

{
// check the environment
Assert ( PBASE::toolSvc() != 0, "IToolSvc* points to NULL!" );
// retrieve the tool from Tool Service
TOOL* Tool = 0 ;
const StatusCode sc =
this->toolSvc() -> retrieveTool ( type, Tool, parent , create );
if ( sc.isFailure() )
{ Exception("tool():: Could not retrieve Tool '" + type + "'", sc ) ; }
if ( 0 == Tool )
{ Exception("tool():: Could not retrieve Tool '" + type + "'" ) ; }
// add the tool into the list of known tools to be properly released
addToToolList( Tool );
// return *VALID* located tool
return Tool ;
}
template<class PBASE>
const AlgTools& GaudiCommon< PBASE >::tools ( ) const
inline

get the list of aquired tools

Definition at line 738 of file GaudiCommon.h.

{ return m_tools ; } // get all tools
template<class PBASE>
bool GaudiCommon< PBASE >::typePrint ( ) const
inline

Insert the actual C++ type of the algorithm/tool in the messages ?

Definition at line 546 of file GaudiCommon.h.

{ return m_typePrint ; }
template<class PBASE >
IUpdateManagerSvc * GaudiCommon< PBASE >::updMgrSvc ( ) const
inline

Short-cut to locate the Update Manager Service.

Definition at line 217 of file GaudiCommonImp.h.

{
if ( !m_updMgrSvc )
{ m_updMgrSvc = svc<IUpdateManagerSvc>("UpdateManagerSvc",true); }
return m_updMgrSvc ;
}
template<class PBASE>
MsgStream& GaudiCommon< PBASE >::verbose ( ) const
inline

shortcut for the method msgStream ( MSG::VERBOSE )

Definition at line 501 of file GaudiCommon.h.

{ return msgStream ( MSG::VERBOSE ) ; }
template<class PBASE >
StatusCode GaudiCommon< PBASE >::Warning ( const std::string msg,
const StatusCode  st = StatusCode::FAILURE,
const size_t  mx = 10 
) const

Print the warning message and return with the given StatusCode.

Also performs statistical analysis of the error messages and suppression after the defined number of error instances.

if( a < 0 ) { return Warning("a is negative!") ;}
if( b < 0 ) { return Warning("b is illegal!" , StatusCode(25) );
if( c < 0 )
{ return Warning("c is negative" , StatusCode(35) , 50 );
See Also
MsgStream
IMessageSvc
StatusCode
Parameters
msgWarning message
stStatusCode to return
mxMaximum number of printouts for this message
Returns
The given StatusCode

Definition at line 503 of file GaudiCommon.icpp.

{
// increase local counter of warnings
const size_t num = ++m_warnings[msg] ;
// If suppressed, just return
if ( num > mx ) { return st ; }
else if ( num == mx ) // issue one-time suppression message
{ return Print ( "The WARNING message is suppressed : '" +
msg + "'" , st , MSG::WARNING ) ; }
// return message
return Print ( msg , st , MSG::WARNING ) ;
}
template<class PBASE>
MsgStream& GaudiCommon< PBASE >::warning ( ) const
inline

shortcut for the method msgStream ( MSG::WARNING )

Definition at line 495 of file GaudiCommon.h.

{ return msgStream ( MSG::WARNING ) ; }

Member Data Documentation

template<class PBASE>
const bool GaudiCommon< PBASE >::IgnoreRootInTES = false
staticprotected

Simple definition to be used with the new useRootInTES argument get<TYPE> and put methods.

If used with cause the RootInTES option to be IGNORED.

Useful to aid with code readability. e.g.

// Get data, ignoring the setting of rootInTES()
MyData * data = get<MyData>( "/Event/MyData", IgnoreRootInTES );

Definition at line 71 of file GaudiCommon.h.

template<class PBASE>
std::string GaudiCommon< PBASE >::m_context
private

The context string.

Definition at line 813 of file GaudiCommon.h.

template<class PBASE>
std::vector<std::string> GaudiCommon< PBASE >::m_counterList
protected

list of counters to declare. Set by property CounterList. This can be a regular expression.

Definition at line 100 of file GaudiCommon.h.

template<class PBASE>
Statistics GaudiCommon< PBASE >::m_counters
mutableprivate

General counters.

Definition at line 798 of file GaudiCommon.h.

template<class PBASE>
ICounterSummarySvc* GaudiCommon< PBASE >::m_counterSummarySvc
protected

a pointer to the CounterSummarySvc

Definition at line 98 of file GaudiCommon.h.

template<class PBASE>
Counter GaudiCommon< PBASE >::m_errors
mutableprivate

Counter of errors.

Definition at line 790 of file GaudiCommon.h.

template<class PBASE>
bool GaudiCommon< PBASE >::m_errorsPrint
private

print warning and error counters at finalization ?

Definition at line 810 of file GaudiCommon.h.

template<class PBASE>
Counter GaudiCommon< PBASE >::m_exceptions
mutableprivate

Counter of exceptions.

Definition at line 796 of file GaudiCommon.h.

template<class PBASE>
std::string GaudiCommon< PBASE >::m_format1
private

format for regular statistical printout rows

Definition at line 826 of file GaudiCommon.h.

template<class PBASE>
std::string GaudiCommon< PBASE >::m_format2
private

format for "efficiency" statistical printout rows

Definition at line 828 of file GaudiCommon.h.

template<class PBASE>
double GaudiCommon< PBASE >::m_globalTimeOffset
private

The globalTimeOffset value.

Definition at line 821 of file GaudiCommon.h.

template<class PBASE>
std::string GaudiCommon< PBASE >::m_header
private

the header row

Definition at line 824 of file GaudiCommon.h.

template<class PBASE>
Counter GaudiCommon< PBASE >::m_infos
mutableprivate

counter of infos

Definition at line 794 of file GaudiCommon.h.

template<class PBASE>
MSG::Level GaudiCommon< PBASE >::m_msgLevel
private

The message level.

Definition at line 780 of file GaudiCommon.h.

template<class PBASE>
MsgStream* GaudiCommon< PBASE >::m_msgStream
mutableprivate

The predefined message stream.

Definition at line 783 of file GaudiCommon.h.

template<class PBASE>
bool GaudiCommon< PBASE >::m_propsPrint
private

print properties at initialization?

Definition at line 806 of file GaudiCommon.h.

template<class PBASE>
std::string GaudiCommon< PBASE >::m_rootInTES
private

The rootInTES string.

Definition at line 815 of file GaudiCommon.h.

template<class PBASE>
std::string GaudiCommon< PBASE >::m_rootOnTES
private

The rootOnTES string.

Note, this job option is OBSOLETE, but retained temporarily to allow easy migration. Please update your code to use RootInTES instead. This option will be removed at some point.

Definition at line 819 of file GaudiCommon.h.

template<class PBASE>
Services GaudiCommon< PBASE >::m_services
mutableprivate

List of active services.

Definition at line 787 of file GaudiCommon.h.

template<class PBASE>
std::vector<std::string> GaudiCommon< PBASE >::m_statEntityList
protected

Definition at line 102 of file GaudiCommon.h.

template<class PBASE>
bool GaudiCommon< PBASE >::m_statPrint
private

print counters at finalization ?

Definition at line 808 of file GaudiCommon.h.

template<class PBASE>
AlgTools GaudiCommon< PBASE >::m_tools
mutableprivate

List of active tools.

Definition at line 785 of file GaudiCommon.h.

template<class PBASE>
bool GaudiCommon< PBASE >::m_typePrint
private

insert the actual C++ type of the algorithm in the messages?

Definition at line 804 of file GaudiCommon.h.

template<class PBASE>
IUpdateManagerSvc* GaudiCommon< PBASE >::m_updMgrSvc
mutableprivate

Pointer to the Update Manager Service instance.

Definition at line 801 of file GaudiCommon.h.

template<class PBASE>
bool GaudiCommon< PBASE >::m_useEffFormat
private

flag to use the special "efficiency" format

Definition at line 830 of file GaudiCommon.h.

template<class PBASE>
Counter GaudiCommon< PBASE >::m_warnings
mutableprivate

counter of warnings

Definition at line 792 of file GaudiCommon.h.

template<class PBASE>
const bool GaudiCommon< PBASE >::UseRootInTES = true
staticprotected

Simple definition to be used with the new useRootInTES argument get<TYPE> and put methods.

If used with cause the RootInTES option to be USED

Useful to aid with code readability. e.g.

// Get data, using the setting of rootInTES()
MyData * data = get<MyData>( "/Event/MyData", UseRootInTES );
// note the default setting is true, so this is equivalent to
MyData * data = get<MyData>( "/Event/MyData" );

Definition at line 83 of file GaudiCommon.h.


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

Generated at Wed Dec 4 2013 14:33:15 for Gaudi Framework, version v24r2 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004