| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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 >:
[legend]
Collaboration diagram for GaudiCommon< PBASE >:
[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. More...
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. More...
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. More...
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. More...
DataObject * | 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. More...
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. More...
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. More...
template<class SERVICE >
SmartIF< SERVICE > | svc (const std::string &name, const bool create=true) const
| A useful method for the easy location of services. More...
IUpdateManagerSvc * | updMgrSvc () const
| Short-cut to locate the Update Manager Service. More...
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. More...
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. More...
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. More...
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. More...
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. More...
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. More...
void | Exception (const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
| Create and (re)-throw a given GaudiException. More...
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. More...
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. More...
const Statistics & | counters () const
| accessor to all counters More...
StatEntity & | counter (const std::string &tag) const
| accessor to certain counter by name More...
bool | typePrint () const
| Insert the actual C++ type of the algorithm/tool in the messages ? More...
bool | propsPrint () const
| Print properties at initialization ? More...
bool | statPrint () const
| Print statistical counters at finalization ? More...
bool | errorsPrint () const
| Print error counters at finalization ? More...
long | printStat (const MSG::Level level=MSG::ALWAYS) const
| perform the actual printout of statistical counters More...
long | printErrors (const MSG::Level level=MSG::ALWAYS) const
| perform the actual printout of error counters More...
long | printProps (const MSG::Level level=MSG::ALWAYS) const
| perform the actual printout of properties More...
template<class CallerClass >
void | registerCondition (const std::string &condition, StatusCode(CallerClass::*mf)()=nullptr)
| register the current instance to the UpdateManagerSvc as a consumer for a condition. More...
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. More...
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. More...
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. More...
StatusCode | runUpdate ()
| asks the UpdateManagerSvc to perform an update of the instance (if needed) without waiting the next BeginEvent incident. More...
template<typename U = PBASE, class = typename std::enable_if<std::is_base_of<Algorithm, PBASE>::value, U>::type>
| GaudiCommon (const std::string &name, ISvcLocator *pSvcLocator)
| Algorithm constructor - the SFINAE constraint below ensures that this is constructor is only defined if PBASE derives from Algorithm. More...
template<typename U = PBASE, class = typename std::enable_if<std::is_base_of<AlgTool, PBASE>::value, U>::type>
| GaudiCommon (const std::string &type, const std::string &name, const IInterface *ancestor)
| Tool constructor - SFINAE-ed to insure this constructor is only defined if PBASE derives from AlgTool. More...
StatusCode | initialize () override
| standard initialization method More...
StatusCode | finalize () override
| standard finalization method More...
StatusCode | release (const IInterface *interface) const
| Manual forced (and 'safe') release of the active tool or service. More...
const Services & | services () const
| get the list of aquired services More...
const std::string & | context () const
| Returns the "context" string. Used to identify different processing states. More...
const std::string & | rootInTES () const
| Returns the "rootInTES" string. More...
const std::string | fullTESLocation (const std::string &location, const bool useRootInTES) const
| Returns the full correct event location given the rootInTes settings. More...

## Protected Types
using | base_class = PBASE
typedef std::map< std::string, StatEntity > | Statistics
| the actual type of general counters More...
typedef std::map< std::string, unsigned int > | Counter
| the actual type error/warning counter More...
typedef std::vector< IAlgTool * > | AlgTools
| storage for active tools More...
typedef std::vector< SmartIF< IService > > | Services
| storage for active services More...

## Protected Member Functions
| ~GaudiCommon () override=default
| Destructor. More...
StatusCode | releaseTool (const IAlgTool *tool) const
| manual forced (and 'safe') release of the tool More...
StatusCode | releaseSvc (const IInterface *svc) const
| manual forced (and 'safe') release of the service More...

## Protected Attributes
SmartIF< ICounterSummarySvc > | m_counterSummarySvc
| a pointer to the CounterSummarySvc More...

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

## Private Member Functions
| GaudiCommon ()=delete
| GaudiCommon (const GaudiCommon &)=delete
GaudiCommon & | operator= (const GaudiCommon &)=delete
void | printErrorHandler (Gaudi::Details::PropertyBase &)
| handler for "ErrorPrint" property More...
void | printPropsHandler (Gaudi::Details::PropertyBase &)
| handler for "PropertiesPrint" property More...
void | printStatHandler (Gaudi::Details::PropertyBase &)
| handler for "StatPrint" property More...
void | addToServiceList (SmartIF< IService > svc) const
| Add the given service to the list of acquired services. More...
void | initGaudiCommonConstructor (const IInterface *parent=nullptr)
| Constructor initializations. More...

## Private Attributes
AlgTools | m_managedTools
| List of active tools. More...
Services | m_services
| List of active services. More...
Counter | m_errors
| Counter of errors. More...
Counter | m_warnings
| counter of warnings More...
Counter | m_infos
| counter of infos More...
Counter | m_exceptions
| Counter of exceptions. More...
Statistics | m_counters
| General counters. More...
IUpdateManagerSvc * | m_updMgrSvc = nullptr
| Pointer to the Update Manager Service instance. More...
Gaudi::Property< bool > | m_errorsPrint {this, "ErrorsPrint", true, "print the statistics of errors/warnings/exceptions"}
Gaudi::Property< bool > | m_propsPrint {this, "PropertiesPrint", false, "print the properties of the component"}
Gaudi::Property< bool > | m_statPrint {this, "StatPrint", true, "print the table of counters"}
Gaudi::Property< bool > | m_typePrint {this, "TypePrint", true, "add the actual C++ component type into the messages"}
Gaudi::Property< std::string > | m_context {this, "Context", {}, "note: overridden by parent settings"}
Gaudi::Property< std::string > | m_rootInTES {this, "RootInTES", {}, "note: overridden by parent settings"}
Gaudi::Property< std::string > | m_header
Gaudi::Property< std::string > | m_format1
Gaudi::Property< std::string > | m_format2
Gaudi::Property< bool > | m_useEffFormat
Gaudi::Property< std::vector< std::string > > | m_counterList
Gaudi::Property< std::vector< std::string > > | m_statEntityList

## 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 80 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 115 of file GaudiCommon.h.

template<class PBASE>

using GaudiCommon< PBASE >::base_class = PBASE
| protected

Definition at line 83 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 113 of file GaudiCommon.h.

template<class PBASE>

typedef std::vector<SmartIF<IService> > GaudiCommon< PBASE >::Services
| protected

storage for active services

Definition at line 117 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 111 of file GaudiCommon.h.

## Constructor & Destructor Documentation

template<class PBASE>
template<typename U = PBASE, class = typename std::enable_if<std::is_base_of<Algorithm, PBASE>::value, U>::type>

GaudiCommon< PBASE >::GaudiCommon | ( | const std::string & | name,
|  | ISvcLocator * | pSvcLocator
| ) |  |
| inline

Algorithm constructor - the SFINAE constraint below ensures that this is constructor is only defined if PBASE derives from Algorithm.

Definition at line 611 of file GaudiCommon.h.

611 : base_class( name, pSvcLocator )
612 {
613 initGaudiCommonConstructor();
614 }
GaudiCommon::base_class
PBASE base_class
Definition: GaudiCommon.h:83
GaudiCommon::initGaudiCommonConstructor
void initGaudiCommonConstructor(const IInterface *parent=nullptr)
Constructor initializations.
Definition: GaudiCommon.icpp:65
template<class PBASE>
template<typename U = PBASE, class = typename std::enable_if<std::is_base_of<AlgTool, PBASE>::value, U>::type>

GaudiCommon< PBASE >::GaudiCommon | ( | const std::string & | type,
|  | const std::string & | name,
|  | const IInterface * | ancestor
| ) |  |
| inline

Tool constructor - SFINAE-ed to insure this constructor is only defined if PBASE derives from AlgTool.

Definition at line 618 of file GaudiCommon.h.

619 : base_class( type, name, ancestor )
620 {
621 initGaudiCommonConstructor( this->parent() );
622 }
GaudiCommon::base_class
PBASE base_class
Definition: GaudiCommon.h:83
GaudiCommon::initGaudiCommonConstructor
void initGaudiCommonConstructor(const IInterface *parent=nullptr)
Constructor initializations.
Definition: GaudiCommon.icpp:65
template<class PBASE>

GaudiCommon< PBASE >::~GaudiCommon | ( |  | ) |
| override protected default

Destructor.

template<class PBASE>

GaudiCommon< PBASE >::GaudiCommon | ( |  | ) |
| private delete

template<class PBASE>

GaudiCommon< PBASE >::GaudiCommon | ( | const GaudiCommon< PBASE > & |  | ) |
| private delete

## Member Function Documentation

template<class PBASE >

void GaudiCommon< PBASE >::addToServiceList | ( | SmartIF< IService > | svc | ) | const
| private

Add the given service to the list of acquired services.

Definition at line 362 of file GaudiCommon.icpp.

363 {
364 if ( svc ) {
365 auto i = std::lower_bound( std::begin( m_services ), std::end( m_services ), svc, GaudiCommon_details::svc_lt );
366 if ( i == std::end( m_services ) || !GaudiCommon_details::svc_eq( *i, svc ) ) {
367 m_services.insert( i, std::move( svc ) );
368 } else {
369 this->warning() << "Service " << svc->name() << " already present -- skipping" << endmsg;
370 }
371 }
372 }
GaudiCommon_details::svc_eq
constexpr const struct GaudiCommon_details::svc_eq_t svc_eq
GaudiCommon::m_services
Services m_services
List of active services.
Definition: GaudiCommon.h:726
std::end
T end(T...args)
std::lower_bound
T lower_bound(T...args)
GaudiCommon_details::svc_lt
constexpr const struct GaudiCommon_details::svc_lt_t svc_lt
std::move
T move(T...args)
std::vector::insert
T insert(T...args)
std::begin
T begin(T...args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
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

  Exception | for invalid condition

Parameters

  ok | Condition which should be "true"
  message | Message to be associated with the exception

Definition at line 200 of file GaudiCommonImp.h.

201 {
202 if ( !ok ) Exception( msg, sc );
203 }
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
GaudiCommon::Exception
void Exception(const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
Create and (re)-throw a given GaudiException.
Definition: GaudiCommon.icpp:479
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

  Exception | for invalid condition

Parameters

  ok | Condition which should be "true"
  message | Message to be associated with the exception

Definition at line 208 of file GaudiCommonImp.h.

209 {
210 if ( !ok ) Exception( msg, sc );
211 }
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
GaudiCommon::Exception
void Exception(const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
Create and (re)-throw a given GaudiException.
Definition: GaudiCommon.icpp:479
template<class PBASE>

const std::string& GaudiCommon< PBASE >::context | ( |  | ) | const
| inline

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

Definition at line 704 of file GaudiCommon.h.

704 { return m_context; }
GaudiCommon::m_context
Gaudi::Property< std::string > m_context
Definition: GaudiCommon.h:748
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

  tag | counter name

Returns
  the counter itself

Definition at line 484 of file GaudiCommon.h.

484 { return m_counters[tag]; }
GaudiCommon::m_counters
Statistics m_counters
General counters.
Definition: GaudiCommon.h:737
template<class PBASE>

const Statistics& GaudiCommon< PBASE >::counters | ( |  | ) | const
| inline

accessor to all counters

Definition at line 465 of file GaudiCommon.h.

465 { return m_counters; }
GaudiCommon::m_counters
Statistics m_counters
General counters.
Definition: GaudiCommon.h:737
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

  msg | Error message
  st | StatusCode to return
  mx | Maximum number of printouts for this message

Returns
  StatusCode

Definition at line 383 of file GaudiCommon.icpp.

384 {
385 // increase local counter of errors
386 const size_t num = ++m_errors[msg];
387 // If suppressed, just return
388 if ( num > mx ) {
389 return st;
390 } else if ( UNLIKELY( num == mx ) ) // issue one-time suppression message
391 {
392 return Print( "The ERROR message is suppressed : '" + msg + "'", st, MSG::ERROR );
393 }
394 // return message
395 return Print( msg, st, MSG::ERROR );
396 }
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:128
GaudiCommon::m_errors
Counter m_errors
Counter of errors.
Definition: GaudiCommon.h:729
GaudiCommon::Print
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.
Definition: GaudiCommon.icpp:443
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
MSG::ERROR
Definition: IMessageSvc.h:16
template<class PBASE>

bool GaudiCommon< PBASE >::errorsPrint | ( |  | ) | const
| inline

Print error counters at finalization ?

Definition at line 494 of file GaudiCommon.h.

494 { return m_errorsPrint; }
GaudiCommon::m_errorsPrint
Gaudi::Property< bool > m_errorsPrint
Definition: GaudiCommon.h:743
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

  GaudiException | always thrown!

Parameters

  msg | Exception message
  exc | (previous) exception of type GaudiException

Definition at line 479 of file GaudiCommon.icpp.

480 {
481 // increase local counter of exceptions
482 ++m_exceptions[msg];
483 Print( "Exception (re)throw: " + msg, sc, MSG::FATAL ).ignore();
484 throw GaudiException( this->name() + ":: " + msg, this->name(), sc, exc );
485 }
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:22
GaudiCommon::m_exceptions
Counter m_exceptions
Counter of exceptions.
Definition: GaudiCommon.h:735
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
MSG::FATAL
Definition: IMessageSvc.h:16
GaudiCommon::Print
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.
Definition: GaudiCommon.icpp:443
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:109
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::exception | always thrown!

Parameters

  msg | Exception message
  exc | (previous) exception of type std::exception
  sc | StatusCode

Definition at line 492 of file GaudiCommon.icpp.

493 {
494 // increase local counter of exceptions
495 ++m_exceptions[msg];
496 Print( "Exception (re)throw: " + msg, sc, MSG::FATAL ).ignore();
497 throw GaudiException( this->name() + ":: " + msg + "(" + exc.what() + ")", "", sc );
498 }
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:22
GaudiCommon::m_exceptions
Counter m_exceptions
Counter of exceptions.
Definition: GaudiCommon.h:735
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
MSG::FATAL
Definition: IMessageSvc.h:16
std::exception::what
T what(T...args)
GaudiCommon::Print
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.
Definition: GaudiCommon.icpp:443
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:109
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

  GaudiException | always thrown!

Parameters

  msg | Exception message
  sc | StatusCode

Definition at line 505 of file GaudiCommon.icpp.

506 {
507 // increase local counter of exceptions
508 ++m_exceptions[msg];
509 Print( "Exception throw: " + msg, sc, MSG::FATAL ).ignore();
510 throw GaudiException( this->name() + ":: " + msg, "", sc );
511 }
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:22
GaudiCommon::m_exceptions
Counter m_exceptions
Counter of exceptions.
Definition: GaudiCommon.h:735
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
MSG::FATAL
Definition: IMessageSvc.h:16
GaudiCommon::Print
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.
Definition: GaudiCommon.icpp:443
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:109
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

  svc | Pointer to data provider service
  location | Address in Gaudi Transient Store
  useRootInTES | Flag to turn on(TRUE) off(FALSE) the use of the RootInTES location property

Returns
  Boolean indicating status of the request

Return values

  true | Data object or container exists and implements a proper interface
  true | Failed to locate the data object or container

Definition at line 78 of file GaudiCommonImp.h.

80 {
81 // check the environment
82 Assert( service, "exist():: IDataProvider* points to NULL!" );
83 // check the data object
84 Gaudi::Utils::CheckData<TYPE> checker;
85 return checker( service, fullTESLocation( location, useRootInTES ) );
86 }
Gaudi::Utils::CheckData
Helper structure for implementation of "exists"-functions for GaudiCommon<BASE>
Definition: GetData.h:337
GaudiCommon::Assert
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.
Definition: GaudiCommonImp.h:200
GaudiCommon::fullTESLocation
const std::string fullTESLocation(const std::string &location, const bool useRootInTES) const
Returns the full correct event location given the rootInTes settings.
Definition: GaudiCommonImp.h:24
template<class PBASE >

StatusCode GaudiCommon< PBASE >::finalize | ( |  | ) |
| override

standard finalization method

Returns
  status code

Definition at line 208 of file GaudiCommon.icpp.

209 {
210 StatusCode sc = StatusCode::SUCCESS;
211
212 // print the general information about statistical counters
213 if ( this->msgLevel( MSG::DEBUG ) || ( statPrint() && !counters().empty() ) ) {
214 // print general statistical counters
215 printStat( statPrint() ? MSG::ALWAYS : MSG::DEBUG );
216 }
217 // add all counters to the CounterSummarySvc
218 if ( m_counterSummarySvc && this->svcLoc()->existsService( "CounterSummarySvc" ) ) {
219 if ( this->msgLevel( MSG::DEBUG ) ) this->debug() << "adding counters to CounterSummarySvc" << endmsg;
220
221 Gaudi::Utils::RegEx::matchList statList{m_statEntityList.value()};
222 Gaudi::Utils::RegEx::matchList counterList{m_counterList.value()};
223
224 for ( const auto& i : this->counters() ) {
225 if ( statList.Or( i.first ) )
226 m_counterSummarySvc->addCounter( this->name(), i.first, i.second, Gaudi::CounterSummary::SaveStatEntity );
227 else if ( counterList.Or( i.first ) )
228 m_counterSummarySvc->addCounter( this->name(), i.first, i.second );
229 }
230 }
231 // release all located tools and services
232 if ( this->msgLevel( MSG::DEBUG ) ) {
233 this->debug() << "Tools to release :";
234 for ( const auto& i : m_managedTools ) {
235 this->debug() << " " << i->name();
236 }
237 this->debug() << endmsg;
238 }
239 while ( !m_managedTools.empty() ) {
240 sc = releaseTool( m_managedTools.back() ) && sc;
241 }
242
243 // release all located services
244 if ( this->msgLevel( MSG::DEBUG ) ) {
245 this->debug() << "Services to release :";
246 for ( const auto& i : m_services ) this->debug() << " " << i->name();
247 this->debug() << endmsg;
248 }
249 while ( !m_services.empty() ) {
250 sc = releaseSvc( m_services.front() ) && sc;
251 }
252
253 // release the CounterSummarySvc manually
254 m_counterSummarySvc.reset();
255
256 // format printout
257 if ( !m_errors.empty() || !m_warnings.empty() || !m_exceptions.empty() ) {
258 this->always() << "Exceptions/Errors/Warnings/Infos Statistics : " << m_exceptions.size() << "/" << m_errors.size()
259 << "/" << m_warnings.size() << "/" << m_infos.size() << endmsg;
260 if ( errorsPrint() ) {
261 printErrors();
262 }
263 }
264
265 // clear *ALL* counters explicitly
266 m_counters.clear();
267 m_exceptions.clear();
268 m_infos.clear();
269 m_warnings.clear();
270 m_errors.clear();
271 m_counterList.clear();
272 m_statEntityList.clear();
273
274 // finalize base class
275 return sc && PBASE::finalize();
276 }
GaudiCommon::m_warnings
Counter m_warnings
counter of warnings
Definition: GaudiCommon.h:731
StatusCode::SUCCESS
Definition: StatusCode.h:31
std::map::empty
T empty(T...args)
GaudiCommon::m_exceptions
Counter m_exceptions
Counter of exceptions.
Definition: GaudiCommon.h:735
GaudiCommon::releaseSvc
StatusCode releaseSvc(const IInterface *svc) const
manual forced (and &#39;safe&#39;) release of the service
Definition: GaudiCommon.icpp:340
GaudiCommon::m_services
Services m_services
List of active services.
Definition: GaudiCommon.h:726
Gaudi::Utils::RegEx::matchList
Definition: RegEx.h:27
MSG::DEBUG
Definition: IMessageSvc.h:16
GaudiCommon::m_counters
Statistics m_counters
General counters.
Definition: GaudiCommon.h:737
GaudiCommon::counters
const Statistics & counters() const
accessor to all counters
Definition: GaudiCommon.h:465
GaudiCommon::m_counterList
Gaudi::Property< std::vector< std::string > > m_counterList
Definition: GaudiCommon.h:765
GaudiCommon::statPrint
bool statPrint() const
Print statistical counters at finalization ?
Definition: GaudiCommon.h:492
Gaudi::CounterSummary::SaveStatEntity
store only the flag()
Definition: ICounterSummarySvc.h:19
GaudiCommon::m_errors
Counter m_errors
Counter of errors.
Definition: GaudiCommon.h:729
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
ICounterSummarySvc::addCounter
virtual void addCounter(const std::string, const std::string name, const StatEntity &, const Gaudi::CounterSummary::SaveType saveType=Gaudi::CounterSummary::SaveSimpleCounter)=0
declare a counter, StatEntity, to be filled in the Counter summary
GaudiCommon::m_infos
Counter m_infos
counter of infos
Definition: GaudiCommon.h:733
GaudiCommon::errorsPrint
bool errorsPrint() const
Print error counters at finalization ?
Definition: GaudiCommon.h:494
GaudiCommon::m_counterSummarySvc
SmartIF< ICounterSummarySvc > m_counterSummarySvc
a pointer to the CounterSummarySvc
Definition: GaudiCommon.h:122
std::map::clear
T clear(T...args)
std::map::size
T size(T...args)
GaudiCommon::releaseTool
StatusCode releaseTool(const IAlgTool *tool) const
manual forced (and &#39;safe&#39;) release of the tool
Definition: GaudiCommon.icpp:303
GaudiCommon::m_managedTools
AlgTools m_managedTools
List of active tools.
Definition: GaudiCommon.h:724
SmartIF::reset
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:92
GaudiCommon::printStat
long printStat(const MSG::Level level=MSG::ALWAYS) const
perform the actual printout of statistical counters
Definition: GaudiCommon.icpp:518
MSG::ALWAYS
Definition: IMessageSvc.h:16
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
GaudiCommon::m_statEntityList
Gaudi::Property< std::vector< std::string > > m_statEntityList
Definition: GaudiCommon.h:767
GaudiCommon::printErrors
long printErrors(const MSG::Level level=MSG::ALWAYS) const
perform the actual printout of error counters
Definition: GaudiCommon.icpp:547
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 24 of file GaudiCommonImp.h.

26 {
27 // The logic is:
28 // if no R.I.T., give back location
29 // if R.I.T., this is the mapping:
30 // (note that R.I.T. contains a trailing '/')
31 // location -> result
32 // -------------------------------------------------
33 // "" -> R.I.T.[:-1] ("rit")
34 // "/Event" -> R.I.T.[:-1] ("rit")
35 // "/Event/MyObj" -> R.I.T. + "MyObj" ("rit/MyObj")
36 // "MyObj" -> R.I.T. + "MyObj" ("rit/MyObj")
37 return ( !useRootInTES || rootInTES().empty()
38 ? location
39 : location.empty() || ( location == "/Event" )
40 ? rootInTES().substr( 0, rootInTES().size() - 1 )
41 : 0 == location.find( "/Event/" )
42 ? rootInTES() + location.substr( 7 )
43 : location[0] == '/' ? rootInTES() + location.substr( 1 ) : rootInTES() + location );
44 }
std::string::empty
T empty(T...args)
GaudiCommon::rootInTES
const std::string & rootInTES() const
Returns the "rootInTES" string.
Definition: GaudiCommon.h:708
GaudiPython.HistoUtils.location
location
Definition: HistoUtils.py:899
std::string::find
T find(T...args)
std::string::substr
T substr(T...args)
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

  GaudiException | for Invalid Data Provider Service
  GaudiException | for invalid/unavailable data

Parameters

  svc | Pointer to data service (data provider)
  location | data location/address in Gaudi Transient Store
  useRootInTES | Flag to turn on(TRUE) off(FALSE) the use of the RootInTES location property

Returns
  pointer to the data object

Definition at line 51 of file GaudiCommonImp.h.

52 {
53 // check the environment
54 Assert( service, "get():: IDataProvider* points to NULL!" );
55 // get the helper object:
56 Gaudi::Utils::GetData<TYPE> getter;
57 return getter( *this, service, fullTESLocation( location, useRootInTES ) );
58 }
Gaudi::Utils::GetData
Helper structure for implementation of "get"-functions for GaudiCommon<BASE>
Definition: GaudiCommon.h:41
GaudiCommon::Assert
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.
Definition: GaudiCommonImp.h:200
GaudiCommon::fullTESLocation
const std::string fullTESLocation(const std::string &location, const bool useRootInTES) const
Returns the full correct event location given the rootInTes settings.
Definition: GaudiCommonImp.h:24
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 65 of file GaudiCommonImp.h.

66 {
67 // check the environment
68 Assert( service, "get():: IDataProvider* points to NULL!" );
69 // get the helper object:
70 Gaudi::Utils::GetData<TYPE> getter;
71 return getter( *this, service, fullTESLocation( location, useRootInTES ), false );
72 }
Gaudi::Utils::GetData
Helper structure for implementation of "get"-functions for GaudiCommon<BASE>
Definition: GaudiCommon.h:41
GaudiCommon::Assert
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.
Definition: GaudiCommonImp.h:200
GaudiCommon::fullTESLocation
const std::string fullTESLocation(const std::string &location, const bool useRootInTES) const
Returns the full correct event location given the rootInTes settings.
Definition: GaudiCommonImp.h:24
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

  GaudiException | for Invalid Data Provider Service
  GaudiException | for invalid/unavailable data

Parameters

  svc | Pointer to data provider service
  location | Location in Gaudi Transient Event Store
  useRootInTES | Flag to turn on(TRUE) off(FALSE) the use of the RootInTES location property

Returns
  A valid pointer to the data object

Definition at line 95 of file GaudiCommonImp.h.

96 {
97 // check the environment
98 Assert( service, "getOrCreate():: svc points to NULL!" );
99 // get the helper object
100 Gaudi::Utils::GetOrCreateData<TYPE, TYPE2> getter;
101 return getter( *this, service, fullTESLocation( location, useRootInTES ), location );
102 }
Gaudi::Utils::GetOrCreateData
Helper structure for implementation of "getOrCreate"-functions for GaudiCommon<BASE> ...
Definition: GetData.h:420
GaudiCommon::Assert
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.
Definition: GaudiCommonImp.h:200
GaudiCommon::fullTESLocation
const std::string fullTESLocation(const std::string &location, const bool useRootInTES) const
Returns the full correct event location given the rootInTes settings.
Definition: GaudiCommonImp.h:24
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 info messages and suppression after the defined number of instances.

See also
  MsgStream
  IMessageSvc
  StatusCode
  GaudiCommon::Warning

Parameters

  msg | Info message
  st | StatusCode to return
  mx | Maximum number of printouts for this message

Returns
  The given StatusCode

Definition at line 423 of file GaudiCommon.icpp.

424 {
425 // increase local counter of warnings
426 const size_t num = ++m_infos[msg];
427 // If suppressed, just return
428 if ( num > mx ) {
429 return st;
430 } else if ( UNLIKELY( num == mx ) ) // issue one-time suppression message
431 {
432 return Print( "The INFO message is suppressed : '" + msg + "'", st, MSG::INFO );
433 }
434 // return message
435 return Print( msg, st, MSG::INFO );
436 }
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:128
GaudiCommon::m_infos
Counter m_infos
counter of infos
Definition: GaudiCommon.h:733
GaudiCommon::Print
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.
Definition: GaudiCommon.icpp:443
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
MSG::INFO
Definition: IMessageSvc.h:16
template<class PBASE >

void GaudiCommon< PBASE >::initGaudiCommonConstructor | ( | const IInterface * | parent = `nullptr` | ) |
| private

Constructor initializations.

Definition at line 65 of file GaudiCommon.icpp.

66 {
67 m_errorsPrint.declareUpdateHandler( &GaudiCommon<PBASE>::printErrorHandler, this );
68 m_propsPrint.declareUpdateHandler( &GaudiCommon<PBASE>::printPropsHandler, this );
69 m_statPrint.declareUpdateHandler( &GaudiCommon<PBASE>::printStatHandler, this );
70
71 // setup context from parent if available
72 if ( parent ) {
73 if ( const GaudiAlgorithm* gAlg = dynamic_cast<const GaudiAlgorithm*>( parent ) ) {
74 m_context = gAlg->context();
75 m_rootInTES = gAlg->rootInTES();
76 } else if ( const GaudiTool* gTool = dynamic_cast<const GaudiTool*>( parent ) ) {
77 m_context = gTool->context();
78 m_rootInTES = gTool->rootInTES();
79 }
80 }
81
82 // Get the job option service
83 auto jos = PBASE::template service<IJobOptionsSvc>( "JobOptionsSvc" );
84 if ( !jos ) Exception( "Cannot get JobOptionsSvc" );
85
86 // Get the "Context" option if in the file...
87 const auto myList = jos->getProperties( this->name() );
88 if ( myList ) {
89 // Iterate over the list to set the options
90 for ( const auto& iter : *myList ) {
91 const Gaudi::Property<std::string>* sp = dynamic_cast<const Gaudi::Property<std::string>*>( iter );
92 if ( sp ) {
93 if ( iter->name().compare( "Context" ) == 0 ) {
94 m_context = sp->value();
95 } else if ( iter->name().compare( "RootInTES" ) == 0 ) {
96 m_rootInTES = sp->value();
97 }
98 }
99 }
100 }
101 }
GaudiCommon::m_rootInTES
Gaudi::Property< std::string > m_rootInTES
Definition: GaudiCommon.h:749
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:319
GaudiCommon::m_errorsPrint
Gaudi::Property< bool > m_errorsPrint
Definition: GaudiCommon.h:743
boost::spirit
Definition: iter_pos.hpp:13
GaudiAlgorithm
The useful base class for data processing algorithms.
Definition: GaudiAlgorithm.h:94
GaudiCommon::m_statPrint
Gaudi::Property< bool > m_statPrint
Definition: GaudiCommon.h:745
GaudiCommon::m_propsPrint
Gaudi::Property< bool > m_propsPrint
Definition: GaudiCommon.h:744
GaudiCommon::m_context
Gaudi::Property< std::string > m_context
Definition: GaudiCommon.h:748
GaudiTool
The useful base class for tools.
Definition: GaudiTool.h:101
GaudiCommon
Implements the common functionality between GaudiTools and GaudiAlgorithms.
Definition: GaudiCommon.h:80
Gaudi::Property::value
const ValueType & value() const
Backward compatibility (.
Definition: Property.h:479
GaudiCommon::Exception
void Exception(const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
Create and (re)-throw a given GaudiException.
Definition: GaudiCommon.icpp:479
template<class PBASE >

StatusCode GaudiCommon< PBASE >::initialize | ( |  | ) |
| override

standard initialization method

Returns
  status code

Definition at line 114 of file GaudiCommon.icpp.

115 {
116
117 // initialize base class
118 const StatusCode sc = PBASE::initialize();
119 if ( sc.isFailure() ) {
120 return Error( "Failed to initialise base class PBASE", sc );
121 }
122
123 // some debug printout
124 if ( this->msgLevel( MSG::DEBUG ) ) {
125 this->debug() << "Initialize base class GaudiCommon<" << System::typeinfoName( typeid( PBASE ) ) << ">" << endmsg;
126 if ( !context().empty() ) this->debug() << "Created with context = '" << context() << "'" << endmsg;
127 }
128
129 // Check rootInTES ends with a /
130 if ( !m_rootInTES.empty() && m_rootInTES[m_rootInTES.size() - 1] != '/' ) m_rootInTES = m_rootInTES + "/";
131
132 // Set up the CounterSummarySvc May need to be changed
133 m_counterSummarySvc = this->svcLoc()->service( "CounterSummarySvc", false );
134 if ( this->msgLevel( MSG::DEBUG ) ) {
135 if ( !m_counterSummarySvc )
136 this->debug() << "could not locate CounterSummarySvc, no counter summary will be made" << endmsg;
137 else
138 this->debug() << "found CounterSummarySvc OK" << endmsg;
139 }
140
141 // properties will be printed if asked for or in "MSG::DEBUG" mode
142 if ( propsPrint() ) {
143 printProps( MSG::ALWAYS );
144 } else if ( this->msgLevel( MSG::DEBUG ) ) {
145 printProps( MSG::DEBUG );
146 }
147
148 // update DataHandles to point to full TES location
149
150 // get root of DataManager
151 SmartIF<IDataManagerSvc> dataMgrSvc( PBASE::evtSvc() );
152 auto rootName = dataMgrSvc->rootName();
153 if ( !rootName.empty() && '/' != rootName.back() ) rootName += "/";
154
155 auto fixLocation = [this, rootName]( const std::string& location ) -> std::string {
156 auto tokens = boost::tokenizer<boost::char_separator<char>>{location, boost::char_separator<char>{":"}};
157 auto result =
158 std::accumulate( tokens.begin(), tokens.end(), std::string{}, [&]( std::string s, const std::string& tok ) {
159 std::string r = fullTESLocation( tok, UseRootInTES );
160 // check whether we have an absolute path if yes use it - else prepend DataManager Root
161 if ( r[0] != '/' ) r = rootName + r;
162 return s.empty() ? r : s + ':' + r;
163 } );
164 if ( result != location && this->msgLevel( MSG::DEBUG ) )
165 this->debug() << "Changing " << location << " to " << result << endmsg;
166 return result;
167 };
168
169 class DHHFixer : public IDataHandleVisitor
170 {
171 public:
172 DHHFixer( std::function<std::string( const std::string& )> f ) : m_f( std::move( f ) ) {}
173 void visit( const IDataHandleHolder* idhh ) override
174 {
175 if ( !idhh ) return;
176
177 std::string r;
178 for ( auto h : idhh->inputHandles() ) {
179 r = m_f( h->objKey() );
180 if ( r != h->objKey() ) h->updateKey( r );
181 }
182 for ( auto h : idhh->outputHandles() ) {
183 r = m_f( h->objKey() );
184 if ( r != h->objKey() ) h->updateKey( r );
185 }
186 }
187
188 private:
189 std::function<std::string( const std::string& )> m_f;
190 };
191
192 this->m_updateDataHandles = std::make_unique<DHHFixer>( fixLocation );
193
194 return sc;
195 }
SmartIF< IDataManagerSvc >
std::string::empty
T empty(T...args)
GaudiCommon::m_rootInTES
Gaudi::Property< std::string > m_rootInTES
Definition: GaudiCommon.h:749
std::function
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:329
GaudiCommon::Error
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.
Definition: GaudiCommon.icpp:383
GaudiPython.HistoUtils.location
location
Definition: HistoUtils.py:899
MSG::DEBUG
Definition: IMessageSvc.h:16
std
STL namespace.
GaudiCommon::context
const std::string & context() const
Returns the "context" string. Used to identify different processing states.
Definition: GaudiCommon.h:704
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
std::string
STL class.
IDataHandleHolder::inputHandles
virtual std::vector< Gaudi::DataHandle * > inputHandles() const =0
IDataHandleHolder::outputHandles
virtual std::vector< Gaudi::DataHandle * > outputHandles() const =0
IDataHandleHolder
Definition: IDataHandleHolder.h:14
HiveAlgSequencer.h
h
Definition: HiveAlgSequencer.py:24
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
GaudiCommon::propsPrint
bool propsPrint() const
Print properties at initialization ?
Definition: GaudiCommon.h:490
GaudiCommon::UseRootInTES
static const bool UseRootInTES
Simple definition to be used with the new useRootInTES argument get<TYPE> and put methods...
Definition: GaudiCommon.h:106
GaudiCommon::m_counterSummarySvc
SmartIF< ICounterSummarySvc > m_counterSummarySvc
a pointer to the CounterSummarySvc
Definition: GaudiCommon.h:122
std::move
T move(T...args)
IDataHandleVisitor
Definition: IDataHandleHolder.h:38
gaudirun.s
string s
Definition: gaudirun.py:253
GaudiCommon::fullTESLocation
const std::string fullTESLocation(const std::string &location, const bool useRootInTES) const
Returns the full correct event location given the rootInTes settings.
Definition: GaudiCommonImp.h:24
std::accumulate
T accumulate(T...args)
GaudiCommon::printProps
long printProps(const MSG::Level level=MSG::ALWAYS) const
perform the actual printout of properties
Definition: GaudiCommon.icpp:574
MSG::ALWAYS
Definition: IMessageSvc.h:16
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
template<class PBASE>

GaudiCommon& GaudiCommon< PBASE >::operator= | ( | const GaudiCommon< PBASE > & |  | ) |
| private delete

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

  msg | Message to print
  st | StatusCode to return
  lev | Printout level for the given message

Returns
  The given StatusCode

Definition at line 443 of file GaudiCommon.icpp.

444 {
445 // perform printout ?
446 if ( !this->msgLevel( lvl ) ) {
447 return st;
448 } // RETURN
449
450 // use the predefined stream
451 MsgStream& str = this->msgStream( lvl );
452 if ( typePrint() ) {
453 str << System::typeinfoName( typeid( *this ) ) << ":: ";
454 }
455
456 // print the message
457 str << msg;
458
459 // test status code
460 if ( st.isSuccess() ) {
461 } else if ( StatusCode::FAILURE != st.getCode() ) {
462 str << " StatusCode=" << st.getCode();
463 } else {
464 str << " StatusCode=FAILURE";
465 }
466
467 // perform print operation
468 str << endmsg;
469
470 // return
471 return st;
472 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
StatusCode::FAILURE
Definition: StatusCode.h:31
StatusCode::getCode
unsigned long getCode() const
Get the status code by value.
Definition: StatusCode.h:94
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:329
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
GaudiCommon::typePrint
bool typePrint() const
Insert the actual C++ type of the algorithm/tool in the messages ?
Definition: GaudiCommon.h:488
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
template<class PBASE >

void GaudiCommon< PBASE >::printErrorHandler | ( | Gaudi::Details::PropertyBase & |  | ) |
| private

handler for "ErrorPrint" property

Definition at line 629 of file GaudiCommon.icpp.

630 {
631 // no action if not yet initialized
632 if ( this->FSMState() < Gaudi::StateMachine::INITIALIZED ) {
633 return;
634 }
635 if ( this->errorsPrint() ) {
636 this->printErrors();
637 }
638 }
Gaudi::StateMachine::INITIALIZED
Definition: StateMachine.h:17
GaudiCommon::errorsPrint
bool errorsPrint() const
Print error counters at finalization ?
Definition: GaudiCommon.h:494
GaudiCommon::printErrors
long printErrors(const MSG::Level level=MSG::ALWAYS) const
perform the actual printout of error counters
Definition: GaudiCommon.icpp:547
template<class PBASE >

long GaudiCommon< PBASE >::printErrors | ( | const MSG::Level | level = `MSG::ALWAYS` | ) | const

perform the actual printout of error counters

Parameters

  level | The message level to print at

Returns
  number of error counters

Definition at line 547 of file GaudiCommon.icpp.

548 {
549 // format for printout
550 boost::format ftm( " #%|-10s| = %|.8s| %|23t| Message = '%s'" );
551
552 auto print = [&]( const Counter& c, const std::string& label ) {
553 for ( const auto& i : c ) {
554 this->msgStream( level ) << ( ftm % label % i.second % i.first ) << endmsg;
555 }
556 };
557
558 print( m_exceptions, "EXCEPTIONS" );
559 print( m_errors, "ERRORS" );
560 print( m_warnings, "WARNINGS" );
561 print( m_infos, "INFOS" );
562
563 // return total number of errors+warnings+exceptions
564 return m_exceptions.size() + m_errors.size() + m_warnings.size() + m_infos.size();
565 }
GaudiCommon::m_warnings
Counter m_warnings
counter of warnings
Definition: GaudiCommon.h:731
GaudiCommon::m_exceptions
Counter m_exceptions
Counter of exceptions.
Definition: GaudiCommon.h:735
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:120
gaudirun.c
c
Definition: gaudirun.py:407
GaudiCommon::Counter
std::map< std::string, unsigned int > Counter
the actual type error/warning counter
Definition: GaudiCommon.h:113
std::string
STL class.
GaudiCommon::m_errors
Counter m_errors
Counter of errors.
Definition: GaudiCommon.h:729
GaudiCommon::m_infos
Counter m_infos
counter of infos
Definition: GaudiCommon.h:733
std::map::size
T size(T...args)
print
void print(string text)
Definition: mergesort.cpp:30
gaudirun.level
level
Definition: gaudirun.py:271
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
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

  level | The message level to print at

Returns
  number of properties
  number of error counters

Definition at line 574 of file GaudiCommon.icpp.

575 {
576
577 // print ALL properties
578 MsgStream& msg = this->msgStream( level );
579 const auto& properties = this->getProperties();
580 msg << "List of ALL properties of " << System::typeinfoName( typeid( *this ) ) << "/" << this->name()
581 << " #properties = " << properties.size() << endmsg;
582 for ( const auto& property : reverse( properties ) ) {
583 msg << "Property ['Name': Value] = " << *property << endmsg;
584 }
585 return properties.size();
586 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:329
property
Gaudi::Details::PropertyBase * property(const std::string &name) const
reverse
reverse_wrapper< T > reverse(T &&iterable)
Definition: reverse.h:35
gaudiComponentHelp.properties
properties
Definition: gaudiComponentHelp.py:41
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
gaudirun.level
level
Definition: gaudirun.py:271
getProperties
const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const override
get all properties
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
template<class PBASE >

void GaudiCommon< PBASE >::printPropsHandler | ( | Gaudi::Details::PropertyBase & |  | ) |
| private

handler for "PropertiesPrint" property

Definition at line 643 of file GaudiCommon.icpp.

644 {
645 // no action if not yet initialized
646 if ( this->FSMState() < Gaudi::StateMachine::INITIALIZED ) {
647 return;
648 }
649 if ( this->propsPrint() ) {
650 this->printProps( MSG::ALWAYS );
651 }
652 }
Gaudi::StateMachine::INITIALIZED
Definition: StateMachine.h:17
GaudiCommon::propsPrint
bool propsPrint() const
Print properties at initialization ?
Definition: GaudiCommon.h:490
GaudiCommon::printProps
long printProps(const MSG::Level level=MSG::ALWAYS) const
perform the actual printout of properties
Definition: GaudiCommon.icpp:574
MSG::ALWAYS
Definition: IMessageSvc.h:16
template<class PBASE >

long GaudiCommon< PBASE >::printStat | ( | const MSG::Level | level = `MSG::ALWAYS` | ) | const

perform the actual printout of statistical counters

Parameters

  level | The message level to print at

Returns
  number of active statistical counters

Definition at line 518 of file GaudiCommon.icpp.

519 {
520 // print statistics
521 if ( counters().empty() ) {
522 return 0;
523 }
524 MsgStream& msg = this->msgStream( level );
525 //
526 msg << "Number of counters : " << counters().size();
527 //
528 if ( !counters().empty() ) {
529 msg << std::endl << m_header.value();
530 }
531 //
532 for ( const auto& entry : counters() ) {
533 msg << std::endl
534 << Gaudi::Utils::formatAsTableRow( entry.first, entry.second, m_useEffFormat, m_format1, m_format2 );
535 }
536 //
537 msg << endmsg;
538 //
539 return counters().size();
540 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
std::endl
T endl(T...args)
GaudiCommon::counters
const Statistics & counters() const
accessor to all counters
Definition: GaudiCommon.h:465
GaudiCommon::m_format2
Gaudi::Property< std::string > m_format2
Definition: GaudiCommon.h:758
GaudiCommon::m_format1
Gaudi::Property< std::string > m_format1
Definition: GaudiCommon.h:755
Gaudi::Utils::formatAsTableRow
GAUDI_API std::string formatAsTableRow(const StatEntity &counter, const bool flag, const std::string &format1=" |%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |", const std::string &format2="*|%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%| ----- | ----- |")
print the counter in a form of the table row
Definition: StatEntity.cpp:305
GaudiCommon::m_useEffFormat
Gaudi::Property< bool > m_useEffFormat
Definition: GaudiCommon.h:762
GaudiCommon::m_header
Gaudi::Property< std::string > m_header
Definition: GaudiCommon.h:751
std::map::size
T size(T...args)
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
gaudirun.level
level
Definition: gaudirun.py:271
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
template<class PBASE >

void GaudiCommon< PBASE >::printStatHandler | ( | Gaudi::Details::PropertyBase & |  | ) |
| private

handler for "StatPrint" property

Definition at line 657 of file GaudiCommon.icpp.

658 {
659 // no action if not yet initialized
660 if ( this->FSMState() < Gaudi::StateMachine::INITIALIZED ) {
661 return;
662 }
663 if ( this->statPrint() ) {
664 this->printStat( MSG::ALWAYS );
665 }
666 }
Gaudi::StateMachine::INITIALIZED
Definition: StateMachine.h:17
GaudiCommon::statPrint
bool statPrint() const
Print statistical counters at finalization ?
Definition: GaudiCommon.h:492
GaudiCommon::printStat
long printStat(const MSG::Level level=MSG::ALWAYS) const
perform the actual printout of statistical counters
Definition: GaudiCommon.icpp:518
MSG::ALWAYS
Definition: IMessageSvc.h:16
template<class PBASE>

bool GaudiCommon< PBASE >::propsPrint | ( |  | ) | const
| inline

Print properties at initialization ?

Definition at line 490 of file GaudiCommon.h.

490 { return m_propsPrint; }
GaudiCommon::m_propsPrint
Gaudi::Property< bool > m_propsPrint
Definition: GaudiCommon.h:744
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

  svc | Pointer to data provider service
  object | Data object or container to be registered
  location | Location in Gaudi Event Transient Store ("/Event" could be omitted )
  useRootInTES | Flag to turn on(TRUE) off(FALSE) the use of the RootInTES location property

Exceptions

  GaudiException | for invalid event data service
  GaudiException | for invalid object
  GaudiException | for error result from event data service

Returns
  StatusCode

Return values

  StatusCode::SUCCESS | Data was successfully placed in the TES.
  StatusCode::FAILURE | Failed to store data in the TES.

Definition at line 597 of file GaudiCommon.icpp.

599 {
600 // check arguments
601 Assert( svc, "put():: Invalid 'service'!" );
602 Assert( object, "put():: Invalid 'Object'!" );
603 Assert( !location.empty(), "put():: Invalid 'address' = '' " );
604 // final data location
605 const std::string& fullLocation = fullTESLocation( location, useRootInTES );
606 // register the object!
607 const StatusCode status = '/' == fullLocation[0] ? svc->registerObject( fullLocation, object )
608 : svc->registerObject( "/Event/" + fullLocation, object );
609 // check the result!
610 if ( status.isFailure() ) {
611 Exception( "put():: could not register '" + System::typeinfoName( typeid( *object ) ) + "' at address '" +
612 fullLocation + "'",
613 status );
614 }
615 if ( this->msgLevel( MSG::DEBUG ) ) {
616 Print( "The object of type '" + System::typeinfoName( typeid( *object ) ) + "' is registered in TS at address '" +
617 fullLocation + "'",
618 status, MSG::DEBUG )
619 .ignore();
620 }
621 return object;
622 }
std::string::empty
T empty(T...args)
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:329
MSG::DEBUG
Definition: IMessageSvc.h:16
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
std::string
STL class.
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
GaudiCommon::Print
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.
Definition: GaudiCommon.icpp:443
GaudiCommon::Assert
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.
Definition: GaudiCommonImp.h:200
GaudiCommon::fullTESLocation
const std::string fullTESLocation(const std::string &location, const bool useRootInTES) const
Returns the full correct event location given the rootInTes settings.
Definition: GaudiCommonImp.h:24
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:109
IDataProviderSvc::registerObject
virtual StatusCode registerObject(const std::string &fullPath, DataObject *pObject)=0
Register object with the data store.
GaudiCommon::Exception
void Exception(const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
Create and (re)-throw a given GaudiException.
Definition: GaudiCommon.icpp:479
template<class PBASE>
template<class CallerClass >

void GaudiCommon< PBASE >::registerCondition | ( | const std::string & | condition,
|  | StatusCode(CallerClass::*)() | mf = `nullptr`
| ) |  |
| inline

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

Parameters

  condition | the path inside the Transient Detector Store to the condition object.
  mf | optional 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. StatusCode MyAlg::initialize(){ // ... registerCondition("/dd/Conditions/Readout/MyDet/MyCond",&MyAlg::i_CallBack); registerCondition<MyAlg>("/dd/Conditions/Readout/MyDet/MyOtherCond"); // ... return StatusCode.SUCCESS; }

Definition at line 528 of file GaudiCommon.h.

529 {
530 updMgrSvc()->registerCondition( dynamic_cast<CallerClass*>( this ), condition, mf );
531 }
GaudiCommon::updMgrSvc
IUpdateManagerSvc * updMgrSvc() const
Short-cut to locate the Update Manager Service.
Definition: GaudiCommonImp.h:189
IUpdateManagerSvc::registerCondition
void registerCondition(CallerClass *instance, const std::string &condition="", typename ObjectMemberFunction< CallerClass >::MemberFunctionType mf=nullptr)
Register an object (algorithm instance) to the service.
Definition: IUpdateManagerSvc.h:182
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

  condition | the path inside the Transient Detector Store to the condition object.
  condPtrDest | pointer 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.
  mf | optional 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; // ... }; StatusCode MyAlg::initialize(){ // ... registerCondition("/dd/Conditions/Readout/MyDet/MyCond",m_MyCond,&MyAlg::i_CallBack); registerCondition<MyAlg>("/dd/Conditions/Readout/MyDet/MyOtherCond",m_MyOtherCond); // ... return StatusCode.SUCCESS; }

Definition at line 563 of file GaudiCommon.h.

565 {
566 updMgrSvc()->registerCondition( dynamic_cast<CallerClass*>( this ), condition, mf, condPtrDest );
567 }
GaudiCommon::updMgrSvc
IUpdateManagerSvc * updMgrSvc() const
Short-cut to locate the Update Manager Service.
Definition: GaudiCommonImp.h:189
IUpdateManagerSvc::registerCondition
void registerCondition(CallerClass *instance, const std::string &condition="", typename ObjectMemberFunction< CallerClass >::MemberFunctionType mf=nullptr)
Register an object (algorithm instance) to the service.
Definition: IUpdateManagerSvc.h:182
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 570 of file GaudiCommon.h.

571 {
572 updMgrSvc()->registerCondition( dynamic_cast<CallerClass*>( this ), std::string( condition ), mf );
573 }
GaudiCommon::updMgrSvc
IUpdateManagerSvc * updMgrSvc() const
Short-cut to locate the Update Manager Service.
Definition: GaudiCommonImp.h:189
std::string
STL class.
IUpdateManagerSvc::registerCondition
void registerCondition(CallerClass *instance, const std::string &condition="", typename ObjectMemberFunction< CallerClass >::MemberFunctionType mf=nullptr)
Register an object (algorithm instance) to the service.
Definition: IUpdateManagerSvc.h:182
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

  condition | the path inside the Transient Detector Store to the condition object.
  mf | optional 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. StatusCode MyAlg::initialize(){ // ... registerCondition("/dd/Conditions/Readout/MyDet/MyCond",&MyAlg::i_CallBack); registerCondition<MyAlg>("/dd/Conditions/Readout/MyDet/MyOtherCond"); // ... return StatusCode.SUCCESS; }

Definition at line 590 of file GaudiCommon.h.

591 {
592 updMgrSvc()->registerCondition( dynamic_cast<CallerClass*>( this ), condition, mf );
593 }
GaudiCommon::updMgrSvc
IUpdateManagerSvc * updMgrSvc() const
Short-cut to locate the Update Manager Service.
Definition: GaudiCommonImp.h:189
IUpdateManagerSvc::registerCondition
void registerCondition(CallerClass *instance, const std::string &condition="", typename ObjectMemberFunction< CallerClass >::MemberFunctionType mf=nullptr)
Register an object (algorithm instance) to the service.
Definition: IUpdateManagerSvc.h:182
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

  interface | Interface pointer to the interface to be released

Returns
  StatusCode

Return values

  StatusCode::SUCCESS | Tool or service was successfully released
  StatusCode::FAILURE | Error releasing too or service

Definition at line 287 of file GaudiCommon.icpp.

288 {
289 if ( !interface ) {
290 return Error( "release(IInterface):: IInterface* points to NULL!" );
291 }
292 // dispatch between tools and services
293 const IAlgTool* algTool = dynamic_cast<const IAlgTool*>( interface );
294 // perform the actual release
295 return algTool ? releaseTool( algTool ) : releaseSvc( interface );
296 }
GaudiCommon::releaseSvc
StatusCode releaseSvc(const IInterface *svc) const
manual forced (and &#39;safe&#39;) release of the service
Definition: GaudiCommon.icpp:340
GaudiCommon::Error
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.
Definition: GaudiCommon.icpp:383
GaudiCommon::releaseTool
StatusCode releaseTool(const IAlgTool *tool) const
manual forced (and &#39;safe&#39;) release of the tool
Definition: GaudiCommon.icpp:303
IAlgTool
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
template<class PBASE >

StatusCode GaudiCommon< PBASE >::releaseSvc | ( | const IInterface * | svc | ) | const
| protected

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

Definition at line 340 of file GaudiCommon.icpp.

341 {
342 if ( !Svc ) return Error( "releaseSvc(IInterface):: IInterface* points to NULL!" );
343 SmartIF<IService> svc{const_cast<IInterface*>( Svc )};
344 if ( !svc ) return Warning( "releaseSvc(IInterface):: IInterface* is not a service" );
345 auto it = std::lower_bound( std::begin( m_services ), std::end( m_services ), svc, GaudiCommon_details::svc_lt );
346 if ( it == m_services.end() || !GaudiCommon_details::svc_eq( *it, svc ) ) {
347 return Warning( "releaseSvc(IInterface):: IInterface* is not active" );
348 }
349 if ( this->msgLevel( MSG::DEBUG ) ) {
350 this->debug() << "Releasing service '" << ( *it )->name() << "'" << endmsg;
351 }
352 m_services.erase( it );
353 return StatusCode::SUCCESS;
354 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
SmartIF< IService >
GaudiCommon_details::svc_eq
constexpr const struct GaudiCommon_details::svc_eq_t svc_eq
GaudiCommon::m_services
Services m_services
List of active services.
Definition: GaudiCommon.h:726
GaudiCommon::Error
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.
Definition: GaudiCommon.icpp:383
MSG::DEBUG
Definition: IMessageSvc.h:16
std::end
T end(T...args)
std::lower_bound
T lower_bound(T...args)
GaudiCommon_details::svc_lt
constexpr const struct GaudiCommon_details::svc_lt_t svc_lt
IInterface
Definition of the basic interface.
Definition: IInterface.h:277
std::vector::erase
T erase(T...args)
GaudiCommon::Warning
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.
Definition: GaudiCommon.icpp:403
std::begin
T begin(T...args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
template<class PBASE >

StatusCode GaudiCommon< PBASE >::releaseTool | ( | const IAlgTool * | tool | ) | const
| protected

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

Definition at line 303 of file GaudiCommon.icpp.

304 {
305 if ( !algTool ) {
306 return Error( "releaseTool(IAlgTool):: IAlgTool* points to NULL!" );
307 }
308 if ( !this->toolSvc() ) {
309 return Error( "releaseTool(IAlgTool):: IToolSvc* points to NULL!" );
310 }
311 // find a tool in the list of active tools
312 auto it = std::find( m_managedTools.begin(), m_managedTools.end(), algTool );
313 if ( m_managedTools.end() == it ) {
314 return Warning( "releaseTool(IAlgTool):: IAlgTool* is not active" );
315 }
316 // get the tool
317 IAlgTool* t = *it;
318 // cache name
319 const std::string name = t->name();
320 if ( this->msgLevel( MSG::DEBUG ) ) {
321 this->debug() << "Releasing tool '" << name << "'" << endmsg;
322 }
323 // remove the tool from the lists
324 PBASE::deregisterTool( t );
325 m_managedTools.erase( it );
326 // release tool
327 if ( this->msgLevel( MSG::DEBUG ) ) {
328 this->debug() << "The tool '" << t->name() << "' of type '" << System::typeinfoName( typeid( *t ) )
329 << "' is released" << endmsg;
330 }
331 const StatusCode sc = this->toolSvc()->releaseTool( t );
332 return sc.isSuccess() ? sc : Warning( "releaseTool(IAlgTool):: error from IToolSvc releasing " + name, sc );
333 }
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:329
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
GaudiCommon::Error
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.
Definition: GaudiCommon.icpp:383
MSG::DEBUG
Definition: IMessageSvc.h:16
std::vector::end
T end(T...args)
std::string
STL class.
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
std::vector::erase
T erase(T...args)
GaudiCommon::Warning
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.
Definition: GaudiCommon.icpp:403
std::find
T find(T...args)
std::vector::begin
T begin(T...args)
IAlgTool
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
GaudiCommon::m_managedTools
AlgTools m_managedTools
List of active tools.
Definition: GaudiCommon.h:724
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
INamedInterface::name
virtual const std::string & name() const =0
Retrieve the name of the instance.
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 708 of file GaudiCommon.h.

708 { return m_rootInTES; }
GaudiCommon::m_rootInTES
Gaudi::Property< std::string > m_rootInTES
Definition: GaudiCommon.h:749
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).

StatusCode MyTool::initialize(){
// ...
return runUpdate();
}

Definition at line 605 of file GaudiCommon.h.

605 { return updMgrSvc()->update( this ); }
GaudiCommon::updMgrSvc
IUpdateManagerSvc * updMgrSvc() const
Short-cut to locate the Update Manager Service.
Definition: GaudiCommonImp.h:189
IUpdateManagerSvc::update
StatusCode update(CallerClass *instance)
Update the given instance.
Definition: IUpdateManagerSvc.h:254
template<class PBASE>

const Services& GaudiCommon< PBASE >::services | ( |  | ) | const
| inline

get the list of aquired services

Definition at line 690 of file GaudiCommon.h.

690 { return m_services; } // get all services
GaudiCommon::m_services
Services m_services
List of active services.
Definition: GaudiCommon.h:726
template<class PBASE>

bool GaudiCommon< PBASE >::statPrint | ( |  | ) | const
| inline

Print statistical counters at finalization ?

Definition at line 492 of file GaudiCommon.h.

492 { return m_statPrint; }
GaudiCommon::m_statPrint
Gaudi::Property< bool > m_statPrint
Definition: GaudiCommon.h:745
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

  GaudiException | for error in Algorithms::service
  GaudiException | for invalid service

Parameters

  name | service type name
  create | Flag for creation of non-existing services

Returns
  A pointer to the service

Definition at line 158 of file GaudiCommonImp.h.

159 {
160 Assert( this->svcLoc(), "ISvcLocator* points to NULL!" );
161 SmartIF<SERVICE> s;
162 // check if we already have this service
163 auto it = std::lower_bound( std::begin( m_services ), std::end( m_services ), name, GaudiCommon_details::svc_lt );
164 if ( it != std::end( m_services ) && GaudiCommon_details::svc_eq( *it, name ) ) {
165 // Try to get the requested interface
166 s = *it;
167 // check the results
168 if ( !s ) {
169 Exception( "svc():: Could not retrieve Svc '" + name + "'", StatusCode::FAILURE );
170 }
171 } else {
172 auto baseSvc = this->svcLoc()->service( name, create );
173 // Try to get the requested interface
174 s = baseSvc;
175 // check the results
176 if ( !baseSvc || !s ) {
177 Exception( "svc():: Could not retrieve Svc '" + name + "'", StatusCode::FAILURE );
178 }
179 // add the tool into list of known tools, to be properly released
180 addToServiceList( baseSvc );
181 }
182 // return *VALID* located service
183 return s;
184 }
SmartIF
Small smart pointer class with automatic reference counting for IInterface.
Definition: IConverter.h:15
StatusCode::FAILURE
Definition: StatusCode.h:31
GaudiCommon::addToServiceList
void addToServiceList(SmartIF< IService > svc) const
Add the given service to the list of acquired services.
Definition: GaudiCommon.icpp:362
GaudiCommon_details::svc_eq
constexpr const struct GaudiCommon_details::svc_eq_t svc_eq
GaudiCommon::m_services
Services m_services
List of active services.
Definition: GaudiCommon.h:726
std::end
T end(T...args)
std::lower_bound
T lower_bound(T...args)
GaudiCommon_details::svc_lt
constexpr const struct GaudiCommon_details::svc_lt_t svc_lt
std::begin
T begin(T...args)
GaudiCommon::Assert
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.
Definition: GaudiCommonImp.h:200
gaudirun.s
string s
Definition: gaudirun.py:253
GaudiCommon::Exception
void Exception(const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
Create and (re)-throw a given GaudiException.
Definition: GaudiCommon.icpp:479
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

  GaudiException | for invalid Tool Service
  GaudiException | for error from Tool Service
  GaudiException | for invalid tool

Parameters

  type | Tool type
  name | Tool name
  parent | Tool parent
  create | Flag for creation of nonexisting tools

Returns
  A pointer to the tool

Definition at line 108 of file GaudiCommonImp.h.

110 {
111 // for empty names delegate to another method
112 if ( name.empty() ) return tool<TOOL>( type, parent, create );
113 Assert( this->toolSvc(), "tool():: IToolSvc* points to NULL!" );
114 // get the tool from Tool Service
115 TOOL* Tool = nullptr;
116 const StatusCode sc = this->toolSvc()->retrieveTool( type, name, Tool, parent, create );
117 if ( sc.isFailure() ) {
118 Exception( "tool():: Could not retrieve Tool '" + type + "'/'" + name + "'", sc );
119 }
120 if ( !Tool ) {
121 Exception( "tool():: Could not retrieve Tool '" + type + "'/'" + name + "'" );
122 }
123 // insert tool into list of tools
124 PBASE::registerTool( Tool );
125 m_managedTools.push_back( Tool );
126 // return *VALID* located tool
127 return Tool;
128 }
std::string::empty
T empty(T...args)
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
std::vector::push_back
T push_back(T...args)
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
GaudiCommon::Assert
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.
Definition: GaudiCommonImp.h:200
GaudiCommon::m_managedTools
AlgTools m_managedTools
List of active tools.
Definition: GaudiCommon.h:724
GaudiCommon::Exception
void Exception(const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
Create and (re)-throw a given GaudiException.
Definition: GaudiCommon.icpp:479
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

  GaudiException | for invalid Tool Service
  GaudiException | for error from Tool Service
  GaudiException | for invalid tool

Parameters

  type | Tool type, could be of "Type/Name" format
  parent | Tool parent
  create | Flag for creation of non-existing tools

Returns
  A pointer to the tool

Definition at line 134 of file GaudiCommonImp.h.

135 {
136 // check the environment
137 Assert( PBASE::toolSvc(), "IToolSvc* points to NULL!" );
138 // retrieve the tool from Tool Service
139 TOOL* Tool = nullptr;
140 const StatusCode sc = this->toolSvc()->retrieveTool( type, Tool, parent, create );
141 if ( sc.isFailure() ) {
142 Exception( "tool():: Could not retrieve Tool '" + type + "'", sc );
143 }
144 if ( !Tool ) {
145 Exception( "tool():: Could not retrieve Tool '" + type + "'" );
146 }
147 // add the tool into the list of known tools to be properly released
148 PBASE::registerTool( Tool );
149 m_managedTools.push_back( Tool );
150 // return *VALID* located tool
151 return Tool;
152 }
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
std::vector::push_back
T push_back(T...args)
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
GaudiCommon::Assert
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.
Definition: GaudiCommonImp.h:200
GaudiCommon::m_managedTools
AlgTools m_managedTools
List of active tools.
Definition: GaudiCommon.h:724
GaudiCommon::Exception
void Exception(const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
Create and (re)-throw a given GaudiException.
Definition: GaudiCommon.icpp:479
template<class PBASE>

bool GaudiCommon< PBASE >::typePrint | ( |  | ) | const
| inline

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

Definition at line 488 of file GaudiCommon.h.

488 { return m_typePrint; }
GaudiCommon::m_typePrint
Gaudi::Property< bool > m_typePrint
Definition: GaudiCommon.h:746
template<class PBASE >

IUpdateManagerSvc * GaudiCommon< PBASE >::updMgrSvc | ( |  | ) | const
| inline

Short-cut to locate the Update Manager Service.

Definition at line 189 of file GaudiCommonImp.h.

190 {
191 if ( !m_updMgrSvc ) {
192 m_updMgrSvc = svc<IUpdateManagerSvc>( "UpdateManagerSvc", true );
193 }
194 return m_updMgrSvc;
195 }
GaudiCommon::m_updMgrSvc
IUpdateManagerSvc * m_updMgrSvc
Pointer to the Update Manager Service instance.
Definition: GaudiCommon.h:740
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 warning 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

  msg | Warning message
  st | StatusCode to return
  mx | Maximum number of printouts for this message

Returns
  The given StatusCode

Definition at line 403 of file GaudiCommon.icpp.

404 {
405 // increase local counter of warnings
406 const size_t num = ++m_warnings[msg];
407 // If suppressed, just return
408 if ( num > mx ) {
409 return st;
410 } else if ( UNLIKELY( num == mx ) ) // issue one-time suppression message
411 {
412 return Print( "The WARNING message is suppressed : '" + msg + "'", st, MSG::WARNING );
413 }
414 // return message
415 return Print( msg, st, MSG::WARNING );
416 }
GaudiCommon::m_warnings
Counter m_warnings
counter of warnings
Definition: GaudiCommon.h:731
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:128
GaudiCommon::Print
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.
Definition: GaudiCommon.icpp:443
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
MSG::WARNING
Definition: IMessageSvc.h:16

## Member Data Documentation

template<class PBASE>

const bool GaudiCommon< PBASE >::IgnoreRootInTES = false
| static protected

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 94 of file GaudiCommon.h.

template<class PBASE>

Gaudi::Property<std::string> GaudiCommon< PBASE >::m_context {this, "Context", {}, "note: overridden by parent settings"}
| private

Definition at line 748 of file GaudiCommon.h.

template<class PBASE>

Gaudi::Property<std::vector<std::string> > GaudiCommon< PBASE >::m_counterList
| private

Initial value:
{
this, "CounterList", {".*"}, "RegEx list, of simple integer counters for CounterSummary"}

Definition at line 765 of file GaudiCommon.h.

template<class PBASE>

Statistics GaudiCommon< PBASE >::m_counters
| mutable private

General counters.

Definition at line 737 of file GaudiCommon.h.

template<class PBASE>

SmartIF<ICounterSummarySvc> GaudiCommon< PBASE >::m_counterSummarySvc
| protected

a pointer to the CounterSummarySvc

Definition at line 122 of file GaudiCommon.h.

template<class PBASE>

Counter GaudiCommon< PBASE >::m_errors
| mutable private

Counter of errors.

Definition at line 729 of file GaudiCommon.h.

template<class PBASE>

Gaudi::Property<bool> GaudiCommon< PBASE >::m_errorsPrint {this, "ErrorsPrint", true, "print the statistics of errors/warnings/exceptions"}
| private

Definition at line 743 of file GaudiCommon.h.

template<class PBASE>

Counter GaudiCommon< PBASE >::m_exceptions
| mutable private

Counter of exceptions.

Definition at line 735 of file GaudiCommon.h.

template<class PBASE>

Gaudi::Property<std::string> GaudiCommon< PBASE >::m_format1
| private

Initial value:
{
this, "RegularRowFormat", " | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |",
"the format for regular row in the output Stat-table"}

Definition at line 755 of file GaudiCommon.h.

template<class PBASE>

Gaudi::Property<std::string> GaudiCommon< PBASE >::m_format2
| private

Initial value:
{
this, "EfficiencyRowFormat",
" |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |",
"The format for \"efficiency\" row in the output Stat-table"}

Definition at line 758 of file GaudiCommon.h.

template<class PBASE>

Gaudi::Property<std::string> GaudiCommon< PBASE >::m_header
| private

Initial value:
{this, "StatTableHeader",
" | Counter | # | "
" sum | mean/eff^* | rms/err^* | min | max |",
"the header row for the output Stat-table"}

Definition at line 751 of file GaudiCommon.h.

template<class PBASE>

Counter GaudiCommon< PBASE >::m_infos
| mutable private

counter of infos

Definition at line 733 of file GaudiCommon.h.

template<class PBASE>

AlgTools GaudiCommon< PBASE >::m_managedTools
| mutable private

List of active tools.

Definition at line 724 of file GaudiCommon.h.

template<class PBASE>

Gaudi::Property<bool> GaudiCommon< PBASE >::m_propsPrint {this, "PropertiesPrint", false, "print the properties of the component"}
| private

Definition at line 744 of file GaudiCommon.h.

template<class PBASE>

Gaudi::Property<std::string> GaudiCommon< PBASE >::m_rootInTES {this, "RootInTES", {}, "note: overridden by parent settings"}
| private

Definition at line 749 of file GaudiCommon.h.

template<class PBASE>

Services GaudiCommon< PBASE >::m_services
| mutable private

List of active services.

Definition at line 726 of file GaudiCommon.h.

template<class PBASE>

Gaudi::Property<std::vector<std::string> > GaudiCommon< PBASE >::m_statEntityList
| private

Initial value:
{
this, "StatEntityList", {}, "RegEx list, of StatEntity counters for CounterSummary"}

Definition at line 767 of file GaudiCommon.h.

template<class PBASE>

Gaudi::Property<bool> GaudiCommon< PBASE >::m_statPrint {this, "StatPrint", true, "print the table of counters"}
| private

Definition at line 745 of file GaudiCommon.h.

template<class PBASE>

Gaudi::Property<bool> GaudiCommon< PBASE >::m_typePrint {this, "TypePrint", true, "add the actual C++ component type into the messages"}
| private

Definition at line 746 of file GaudiCommon.h.

template<class PBASE>

IUpdateManagerSvc* GaudiCommon< PBASE >::m_updMgrSvc = nullptr
| mutable private

Pointer to the Update Manager Service instance.

Definition at line 740 of file GaudiCommon.h.

template<class PBASE>

Gaudi::Property<bool> GaudiCommon< PBASE >::m_useEffFormat
| private

Initial value:
{this, "UseEfficiencyRowFormat", true,
"use the special format for printout of efficiency counters"}

Definition at line 762 of file GaudiCommon.h.

template<class PBASE>

Counter GaudiCommon< PBASE >::m_warnings
| mutable private

counter of warnings

Definition at line 731 of file GaudiCommon.h.

template<class PBASE>

const bool GaudiCommon< PBASE >::UseRootInTES = true
| static protected

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 106 of file GaudiCommon.h.

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

- GaudiAlg/GaudiAlg/GaudiCommon.h
- GaudiAlg/GaudiAlg/GaudiCommonImp.h
- GaudiAlg/src/lib/GaudiCommon.icpp