| The Gaudi Framework v32r1 (f65d50dc)

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, std::unique_ptr< DataObject > object, const std::string &location, const bool useRootInTES=true) const
| Register a data object or container into Gaudi Event Transient Store. More...
DataObject * | put (IDataProviderSvc *svc, DataObject *object, const std::string &location, const bool useRootInTES=true) const
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...
WARN_UNUSED 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...
WARN_UNUSED 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...
WARN_UNUSED 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...
WARN_UNUSED 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...
StatEntity & | counter (const std::string &tag) const
| accessor to certain counter by name More...
StatEntity & | counter (const std::string &tag)
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, typename = std::enable_if_t<std::is_base_of_v<Gaudi::Algorithm, PBASE>, U>>
| 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, typename = std::enable_if_t<std::is_base_of_v<AlgTool, PBASE>, U>>
| 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...
Public Member Functions inherited from FixTESPath< PBASE >
| FixTESPath (const std::string &name, ISvcLocator *pSvcLocator)
| Algorithm constructor - the SFINAE constraint below ensures that this is constructor is only defined if BASE derives from Algorithm. More...
| FixTESPath (const std::string &type, const std::string &name, const IInterface *ancestor)
| Tool constructor - SFINAE-ed to insure this constructor is only defined if BASE derives from AlgTool. More...
StatusCode | initialize () override
const std::string & | rootInTES () const
| Returns the "rootInTES" string. More...
std::string | fullTESLocation (std::string_view location, bool useRootInTES) const
| Returns the full correct event location given the rootInTes settings. More...

## Protected Types
using | base_class = FixTESPath< PBASE >
typedef std::map< std::string, StatEntity > | StatisticsOwn
| the actual type of general counters More...
typedef std::map< std::string, std::reference_wrapper< Gaudi::Accumulators::PrintableCounter > > | Statistics
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
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
StatisticsOwn | countersOwn () const
| accessor to all owned counters More...
| GaudiCommon ()=delete
| GaudiCommon (const GaudiCommon &)=delete
GaudiCommon & | operator= (const GaudiCommon &)=delete
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...
StatisticsOwn | m_countersOwn
| General counters. More...
std::mutex | m_countersOwnMutex
| The mutex for m_countersOwn. More...
IUpdateManagerSvc * | m_updMgrSvc = nullptr
| Pointer to the Update Manager Service instance. More...
Gaudi::Property< bool > | m_errorsPrint
Gaudi::Property< bool > | m_propsPrint
Gaudi::Property< bool > | m_statPrint
Gaudi::Property< bool > | m_printEmptyCounters
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_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 91 of file GaudiCommon.h.

## Member Typedef Documentation

## ◆ AlgTools

template<class PBASE>

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

storage for active tools

Definition at line 126 of file GaudiCommon.h.

## ◆ base_class

template<class PBASE>

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

Definition at line 93 of file GaudiCommon.h.

## ◆ Counter

template<class PBASE>

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

the actual type error/warning counter

Definition at line 124 of file GaudiCommon.h.

## ◆ Services

template<class PBASE>

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

storage for active services

Definition at line 128 of file GaudiCommon.h.

## ◆ Statistics

template<class PBASE>

typedef std::map<std::string, std::reference_wrapper<Gaudi::Accumulators::PrintableCounter> > GaudiCommon< PBASE >::Statistics
| protected

Definition at line 122 of file GaudiCommon.h.

## ◆ StatisticsOwn

template<class PBASE>

typedef std::map<std::string, StatEntity> GaudiCommon< PBASE >::StatisticsOwn
| protected

the actual type of general counters

Definition at line 121 of file GaudiCommon.h.

## Constructor & Destructor Documentation

## ◆ GaudiCommon() [1/4]

template<class PBASE>
template<typename U = PBASE, typename = std::enable_if_t<std::is_base_of_v<Gaudi::Algorithm, PBASE>, U>>

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

642 : base_class( name, pSvcLocator ) {
643 initGaudiCommonConstructor();
644 }
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
GaudiCommon::base_class
FixTESPath< PBASE > base_class
Definition: GaudiCommon.h:93
GaudiCommon::initGaudiCommonConstructor
void initGaudiCommonConstructor(const IInterface *parent=nullptr)
Constructor initializations.
Definition: GaudiCommon.icpp:65

## ◆ GaudiCommon() [2/4]

template<class PBASE>
template<typename U = PBASE, typename = std::enable_if_t<std::is_base_of_v<AlgTool, PBASE>, U>>

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

649 : base_class( type, name, ancestor ) {
650 initGaudiCommonConstructor( this->parent() );
651 }
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
GaudiCommon::base_class
FixTESPath< PBASE > base_class
Definition: GaudiCommon.h:93
gaudirun.type
type
Definition: gaudirun.py:142
GaudiCommon::initGaudiCommonConstructor
void initGaudiCommonConstructor(const IInterface *parent=nullptr)
Constructor initializations.
Definition: GaudiCommon.icpp:65

## ◆ GaudiCommon() [3/4]

template<class PBASE>

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

## ◆ GaudiCommon() [4/4]

template<class PBASE>

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

## Member Function Documentation

## ◆ addToServiceList()

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 266 of file GaudiCommon.icpp.

266 {
267 if ( svc ) {
268 auto i = std::lower_bound( std::begin( m_services ), std::end( m_services ), svc, GaudiCommon_details::svc_lt );
269 if ( i == std::end( m_services ) || !GaudiCommon_details::svc_eq( *i, svc ) ) {
270 m_services.insert( i, std::move( svc ) );
271 } else {
272 this->warning() << "Service " << svc->name() << " already present -- skipping" << endmsg;
273 }
274 }
275 }
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:720
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
GaudiCommon::svc
SmartIF< SERVICE > svc(const std::string &name, const bool create=true) const
A useful method for the easy location of services.
Definition: GaudiCommonImp.h:121
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:192

## ◆ Assert() [1/2]

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 155 of file GaudiCommonImp.h.

155 {
156 if ( !ok ) Exception( msg, sc );
157 }
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:374
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8

## ◆ Assert() [2/2]

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 162 of file GaudiCommonImp.h.

162 {
163 if ( !ok ) Exception( msg, sc );
164 }
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:374
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8

## ◆ context()

template<class PBASE>

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

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

Definition at line 707 of file GaudiCommon.h.

707 { return m_context; }
GaudiCommon::m_context
Gaudi::Property< std::string > m_context
Definition: GaudiCommon.h:769

## ◆ counter() [1/2]

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

506 {
507 return const_cast<GaudiCommon<PBASE>*>( this )->counter( tag );
508 }
GaudiCommon::counter
StatEntity & counter(const std::string &tag) const
accessor to certain counter by name
Definition: GaudiCommon.h:506
GaudiCommon
Implements the common functionality between GaudiTools and GaudiAlgorithms.
Definition: GaudiCommon.h:91

## ◆ counter() [2/2]

template<class PBASE>

StatEntity& GaudiCommon< PBASE >::counter | ( | const std::string & | tag | ) |
| inline

Definition at line 509 of file GaudiCommon.h.

509 {
510 std::lock_guard<std::mutex> lock( m_countersOwnMutex );
511 // Return referenced StatEntity if it already exists, else create it
512 auto p = this->findCounter( tag );
513 if ( !p ) {
514 auto& counter = m_countersOwn[tag];
515 this->declareCounter( tag, counter );
516 return counter;
517 }
518 return m_countersOwn[tag];
519 }
GaudiCommon::m_countersOwn
StatisticsOwn m_countersOwn
General counters.
Definition: GaudiCommon.h:731
std::lock
T lock(T... args)
GaudiCommon::m_countersOwnMutex
std::mutex m_countersOwnMutex
The mutex for m_countersOwn.
Definition: GaudiCommon.h:733
GaudiCommon::counter
StatEntity & counter(const std::string &tag) const
accessor to certain counter by name
Definition: GaudiCommon.h:506
std::lock_guard

## ◆ countersOwn()

template<class PBASE>

StatisticsOwn GaudiCommon< PBASE >::countersOwn | ( |  | ) | const
| inline private

accessor to all owned counters

Definition at line 484 of file GaudiCommon.h.

484 { return m_countersOwn; }
GaudiCommon::m_countersOwn
StatisticsOwn m_countersOwn
General counters.
Definition: GaudiCommon.h:731

## ◆ Error()

template<class PBASE >

StatusCode GaudiCommon< PBASE >::Error | ( | const std::string & | msg,
|  | const StatusCode | st = `StatusCode::FAILURE`,
|  | const size_t | mx = `10`
| ) |  | const

Print the error message and return with the given StatusCode.

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

if( a < 0 ) { return Error("a is negative!") ;}
if( b < 0 ) { return Error("b is illegal!" , StatusCode(25) );
if( c < 0 )
{ return Error("c is negative" , StatusCode(35) , 50 );

See also
  MsgStream
  IMessageSvc
  StatusCode

Parameters

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

Returns
  StatusCode

Definition at line 286 of file GaudiCommon.icpp.

286 {
287 // increase local counter of errors
288 const size_t num = ++m_errors[msg];
289 // If suppressed, just return
290 if ( num > mx ) {
291 return st;
292 } else if ( UNLIKELY( num == mx ) ) // issue one-time suppression message
293 {
294 return Print( "The ERROR message is suppressed : '" + msg + "'", st, MSG::ERROR );
295 }
296 // return message
297 return Print( msg, st, MSG::ERROR );
298 }
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:96
GaudiCommon::m_errors
Counter m_errors
Counter of errors.
Definition: GaudiCommon.h:723
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
MSG::ERROR
Definition: IMessageSvc.h:15
GaudiCommon::Print
WARN_UNUSED 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:343

## ◆ errorsPrint()

template<class PBASE>

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

Print error counters at finalization ?

Definition at line 529 of file GaudiCommon.h.

529 { return m_errorsPrint; }
GaudiCommon::m_errorsPrint
Gaudi::Property< bool > m_errorsPrint
Definition: GaudiCommon.h:739

## ◆ Exception() [1/3]

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 374 of file GaudiCommon.icpp.

374 {
375 // increase local counter of exceptions
376 ++m_exceptions[msg];
377 Print( "Exception (re)throw: " + msg, sc, MSG::FATAL ).ignore();
378 throw GaudiException( this->name() + ":: " + msg, this->name(), sc, exc );
379 }
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:21
GaudiCommon::m_exceptions
Counter m_exceptions
Counter of exceptions.
Definition: GaudiCommon.h:729
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
MSG::FATAL
Definition: IMessageSvc.h:15
StatusCode::ignore
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
GaudiCommon::Print
WARN_UNUSED 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:343

## ◆ Exception() [2/3]

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 386 of file GaudiCommon.icpp.

386 {
387 // increase local counter of exceptions
388 ++m_exceptions[msg];
389 Print( "Exception (re)throw: " + msg, sc, MSG::FATAL ).ignore();
390 throw GaudiException( this->name() + ":: " + msg + "(" + exc.what() + ")", "", sc );
391 }
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:21
GaudiCommon::m_exceptions
Counter m_exceptions
Counter of exceptions.
Definition: GaudiCommon.h:729
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
MSG::FATAL
Definition: IMessageSvc.h:15
std::exception::what
T what(T... args)
StatusCode::ignore
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
GaudiCommon::Print
WARN_UNUSED 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:343

## ◆ Exception() [3/3]

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 398 of file GaudiCommon.icpp.

398 {
399 // increase local counter of exceptions
400 ++m_exceptions[msg];
401 Print( "Exception throw: " + msg, sc, MSG::FATAL ).ignore();
402 throw GaudiException( this->name() + ":: " + msg, "", sc );
403 }
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:21
GaudiCommon::m_exceptions
Counter m_exceptions
Counter of exceptions.
Definition: GaudiCommon.h:729
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
MSG::FATAL
Definition: IMessageSvc.h:15
StatusCode::ignore
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
GaudiCommon::Print
WARN_UNUSED 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:343

## ◆ exist()

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 52 of file GaudiCommonImp.h.

53 {
54 // check the environment
55 Assert( service, "exist():: IDataProvider* points to NULL!" );
56 // check the data object
57 Gaudi::Utils::CheckData<TYPE> checker;
58 return checker( service, this->fullTESLocation( location, useRootInTES ) );
59 }
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:155
Gaudi::Utils::CheckData
Helper structure for implementation of "exists"-functions for GaudiCommon<BASE>
Definition: GetData.h:314
FixTESPath< PBASE >::fullTESLocation
std::string fullTESLocation(std::string_view location, bool useRootInTES) const
Returns the full correct event location given the rootInTes settings.
Definition: FixTESPath.h:55

## ◆ finalize()

template<class PBASE >

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

standard finalization method

Returns
  status code

Definition at line 131 of file GaudiCommon.icpp.

131 {
132 StatusCode sc = StatusCode::SUCCESS;
133
134 // print the general information about statistical counters
135 if ( this->msgLevel( MSG::DEBUG ) || ( statPrint() && this->nCounters() > 0 ) ) {
136 // print general statistical counters
137 printStat( statPrint() ? MSG::ALWAYS : MSG::DEBUG );
138 }
139 // add all counters to the CounterSummarySvc
140 if ( m_counterSummarySvc && this->svcLoc()->existsService( "CounterSummarySvc" ) ) {
141 if ( this->msgLevel( MSG::DEBUG ) ) this->debug() << "adding counters to CounterSummarySvc" << endmsg;
142
143 Gaudi::Utils::RegEx::matchList statList{m_statEntityList.value()};
144 Gaudi::Utils::RegEx::matchList counterList{m_counterList.value()};
145
146 for ( const auto& i : m_countersOwn ) {
147 if ( statList.Or( i.first ) )
148 m_counterSummarySvc->addCounter( this->name(), i.first, i.second, Gaudi::CounterSummary::SaveStatEntity );
149 else if ( counterList.Or( i.first ) )
150 m_counterSummarySvc->addCounter( this->name(), i.first, i.second );
151 }
152 }
153 // release all located tools and services
154 if ( this->msgLevel( MSG::DEBUG ) ) {
155 this->debug() << "Tools to release :";
156 for ( const auto& i : m_managedTools ) { this->debug() << " " << i->name(); }
157 this->debug() << endmsg;
158 }
159 while ( !m_managedTools.empty() ) {
160 sc = ( releaseTool( m_managedTools.back() ) && sc ) ? StatusCode::SUCCESS : StatusCode::FAILURE;
161 }
162
163 // release all located services
164 if ( this->msgLevel( MSG::DEBUG ) ) {
165 this->debug() << "Services to release :";
166 for ( const auto& i : m_services ) this->debug() << " " << i->name();
167 this->debug() << endmsg;
168 }
169 while ( !m_services.empty() ) {
170 sc = ( releaseSvc( m_services.front() ) && sc ) ? StatusCode::SUCCESS : StatusCode::FAILURE;
171 }
172
173 // release the CounterSummarySvc manually
174 m_counterSummarySvc.reset();
175
176 // format printout
177 if ( !m_errors.empty() || !m_warnings.empty() || !m_exceptions.empty() ) {
178 this->always() << "Exceptions/Errors/Warnings/Infos Statistics : " << m_exceptions.size() << "/" << m_errors.size()
179 << "/" << m_warnings.size() << "/" << m_infos.size() << endmsg;
180 if ( errorsPrint() ) { printErrors(); }
181 }
182
183 // clear *ALL* counters explicitly
184 this->clearCounters();
185 m_countersOwn.clear(); // then delete any owned counters
186 m_exceptions.clear();
187 m_infos.clear();
188 m_warnings.clear();
189 m_errors.clear();
190 m_counterList.clear();
191 m_statEntityList.clear();
192
193 // finalize base class
194 return ( sc && base_class::finalize() ? StatusCode::SUCCESS : StatusCode::FAILURE );
195 }
GaudiCommon::m_warnings
Counter m_warnings
counter of warnings
Definition: GaudiCommon.h:725
std::vector::empty
T empty(T... args)
GaudiCommon::statPrint
bool statPrint() const
Print statistical counters at finalization ?
Definition: GaudiCommon.h:527
GaudiCommon::m_exceptions
Counter m_exceptions
Counter of exceptions.
Definition: GaudiCommon.h:729
GaudiCommon::errorsPrint
bool errorsPrint() const
Print error counters at finalization ?
Definition: GaudiCommon.h:529
GaudiCommon::printStat
long printStat(const MSG::Level level=MSG::ALWAYS) const
perform the actual printout of statistical counters
Definition: GaudiCommon.icpp:410
std::vector::front
T front(T... args)
GaudiCommon::m_services
Services m_services
List of active services.
Definition: GaudiCommon.h:720
Gaudi::Utils::RegEx::matchList
Definition: RegEx.h:24
GaudiCommon::m_countersOwn
StatisticsOwn m_countersOwn
General counters.
Definition: GaudiCommon.h:731
MSG::DEBUG
Definition: IMessageSvc.h:15
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
GaudiCommon::printErrors
long printErrors(const MSG::Level level=MSG::ALWAYS) const
perform the actual printout of error counters
Definition: GaudiCommon.icpp:442
GaudiCommon::m_counterList
Gaudi::Property< std::vector< std::string > > m_counterList
Definition: GaudiCommon.h:784
Gaudi::CounterSummary::SaveStatEntity
store only the flag()
Definition: ICounterSummarySvc.h:17
GaudiCommon::m_errors
Counter m_errors
Counter of errors.
Definition: GaudiCommon.h:723
GaudiCommon::releaseTool
StatusCode releaseTool(const IAlgTool *tool) const
manual forced (and 'safe') release of the tool
Definition: GaudiCommon.icpp:219
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
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:727
GaudiCommon::releaseSvc
StatusCode releaseSvc(const IInterface *svc) const
manual forced (and 'safe') release of the service
Definition: GaudiCommon.icpp:247
GaudiCommon::m_counterSummarySvc
SmartIF< ICounterSummarySvc > m_counterSummarySvc
a pointer to the CounterSummarySvc
Definition: GaudiCommon.h:133
std::map::clear
T clear(T... args)
std::map::size
T size(T... args)
std::vector::back
T back(T... args)
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
GaudiCommon::m_managedTools
AlgTools m_managedTools
List of active tools.
Definition: GaudiCommon.h:718
SmartIF::reset
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:86
MSG::ALWAYS
Definition: IMessageSvc.h:15
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
GaudiCommon::m_statEntityList
Gaudi::Property< std::vector< std::string > > m_statEntityList
Definition: GaudiCommon.h:786

## ◆ get()

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 26 of file GaudiCommonImp.h.

26 {
27 // check the environment
28 Assert( service, "get():: IDataProvider* points to NULL!" );
29 // get the helper object:
30 Gaudi::Utils::GetData<TYPE> getter;
31 return getter( *this, service, this->fullTESLocation( location, useRootInTES ) );
32 }
Gaudi::Utils::GetData
Helper structure for implementation of "get"-functions for GaudiCommon<BASE>
Definition: GaudiCommon.h:53
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:155
FixTESPath< PBASE >::fullTESLocation
std::string fullTESLocation(std::string_view location, bool useRootInTES) const
Returns the full correct event location given the rootInTes settings.
Definition: FixTESPath.h:55

## ◆ getIfExists()

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 39 of file GaudiCommonImp.h.

40 {
41 // check the environment
42 Assert( service, "get():: IDataProvider* points to NULL!" );
43 // get the helper object:
44 Gaudi::Utils::GetData<TYPE> getter;
45 return getter( *this, service, this->fullTESLocation( location, useRootInTES ), false );
46 }
Gaudi::Utils::GetData
Helper structure for implementation of "get"-functions for GaudiCommon<BASE>
Definition: GaudiCommon.h:53
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:155
FixTESPath< PBASE >::fullTESLocation
std::string fullTESLocation(std::string_view location, bool useRootInTES) const
Returns the full correct event location given the rootInTes settings.
Definition: FixTESPath.h:55

## ◆ getOrCreate()

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 68 of file GaudiCommonImp.h.

69 {
70 // check the environment
71 Assert( service, "getOrCreate():: svc points to NULL!" );
72 // get the helper object
73 Gaudi::Utils::GetOrCreateData<TYPE, TYPE2> getter;
74 return getter( *this, service, this->fullTESLocation( location, useRootInTES ), location );
75 }
GaudiPython.HistoUtils.location
location
Definition: HistoUtils.py:936
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:155
Gaudi::Utils::GetOrCreateData
Helper structure for implementation of "getOrCreate"-functions for GaudiCommon<BASE>
Definition: GetData.h:388
FixTESPath< PBASE >::fullTESLocation
std::string fullTESLocation(std::string_view location, bool useRootInTES) const
Returns the full correct event location given the rootInTes settings.
Definition: FixTESPath.h:55

## ◆ Info()

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 324 of file GaudiCommon.icpp.

324 {
325 // increase local counter of warnings
326 const size_t num = ++m_infos[msg];
327 // If suppressed, just return
328 if ( num > mx ) {
329 return st;
330 } else if ( UNLIKELY( num == mx ) ) // issue one-time suppression message
331 {
332 return Print( "The INFO message is suppressed : '" + msg + "'", st, MSG::INFO );
333 }
334 // return message
335 return Print( msg, st, MSG::INFO );
336 }
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:96
GaudiCommon::m_infos
Counter m_infos
counter of infos
Definition: GaudiCommon.h:727
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
GaudiCommon::Print
WARN_UNUSED 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:343
MSG::INFO
Definition: IMessageSvc.h:15

## ◆ initGaudiCommonConstructor()

template<class PBASE >

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

Constructor initializations.

Definition at line 65 of file GaudiCommon.icpp.

65 {
66 // setup context from parent if available
67 if ( parent ) {
68 if ( const GaudiAlgorithm* gAlg = dynamic_cast<const GaudiAlgorithm*>( parent ) ) {
69 m_context = gAlg->context();
70 } else if ( const GaudiTool* gTool = dynamic_cast<const GaudiTool*>( parent ) ) {
71 m_context = gTool->context();
72 }
73 }
74
75 // Get the job option service
76 auto jos = PBASE::template service<IJobOptionsSvc>( "JobOptionsSvc" );
77 if ( !jos ) Exception( "Cannot get JobOptionsSvc" );
78
79 // Get the "Context" option if in the file...
80 const auto myList = jos->getProperties( this->name() );
81 if ( myList ) {
82 // Iterate over the list to set the options
83 for ( const auto& iter : *myList ) {
84 const Gaudi::Property<std::string>* sp = dynamic_cast<const Gaudi::Property<std::string>*>( iter );
85 if ( sp && iter->name().compare( "Context" ) == 0 ) { m_context = sp->value(); }
86 }
87 }
88 }
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:352
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:374
boost::spirit
Definition: iter_pos.hpp:14
GaudiAlgorithm
The useful base class for data processing algorithms.
Definition: GaudiAlgorithm.h:94
GaudiCommon::m_context
Gaudi::Property< std::string > m_context
Definition: GaudiCommon.h:769
GaudiTool
The useful base class for tools.
Definition: GaudiTool.h:101

## ◆ initialize()

template<class PBASE >

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

standard initialization method

Returns
  status code

Definition at line 95 of file GaudiCommon.icpp.

95 {
96
97 // initialize base class
98 const StatusCode sc = base_class::initialize();
99 if ( sc.isFailure() ) { return Error( "Failed to initialise base class PBASE", sc ); }
100
101 // some debug printout
102 if ( this->msgLevel( MSG::DEBUG ) ) {
103 this->debug() << "Initialize base class GaudiCommon<" << System::typeinfoName( typeid( PBASE ) ) << ">" << endmsg;
104 if ( !context().empty() ) this->debug() << "Created with context = '" << context() << "'" << endmsg;
105 }
106
107 // Set up the CounterSummarySvc May need to be changed
108 m_counterSummarySvc = this->svcLoc()->service( "CounterSummarySvc", false );
109 if ( this->msgLevel( MSG::DEBUG ) ) {
110 if ( !m_counterSummarySvc )
111 this->debug() << "could not locate CounterSummarySvc, no counter summary will be made" << endmsg;
112 else
113 this->debug() << "found CounterSummarySvc OK" << endmsg;
114 }
115
116 // properties will be printed if asked for or in "MSG::DEBUG" mode
117 if ( propsPrint() ) {
118 printProps( MSG::ALWAYS );
119 } else if ( this->msgLevel( MSG::DEBUG ) ) {
120 printProps( MSG::DEBUG );
121 }
122
123 return sc;
124 }
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:298
MSG::DEBUG
Definition: IMessageSvc.h:15
GaudiCommon::Error
WARN_UNUSED 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:286
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
GaudiCommon::printProps
long printProps(const MSG::Level level=MSG::ALWAYS) const
perform the actual printout of properties
Definition: GaudiCommon.icpp:466
GaudiCommon::m_counterSummarySvc
SmartIF< ICounterSummarySvc > m_counterSummarySvc
a pointer to the CounterSummarySvc
Definition: GaudiCommon.h:133
GaudiCommon::context
const std::string & context() const
Returns the "context" string. Used to identify different processing states.
Definition: GaudiCommon.h:707
GaudiCommon::propsPrint
bool propsPrint() const
Print properties at initialization ?
Definition: GaudiCommon.h:525
FixTESPath< PBASE >::initialize
StatusCode initialize() override
Definition: FixTESPath.h:39
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:130
MSG::ALWAYS
Definition: IMessageSvc.h:15
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ operator=()

template<class PBASE>

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

## ◆ Print()

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 343 of file GaudiCommon.icpp.

343 {
344 // perform printout ?
345 if ( !this->msgLevel( lvl ) ) { return st; } // RETURN
346
347 // use the predefined stream
348 MsgStream& str = this->msgStream( lvl );
349 if ( typePrint() ) { str << System::typeinfoName( typeid( *this ) ) << ":: "; }
350
351 // print the message
352 str << msg;
353
354 // test status code
355 if ( st.isSuccess() ) {
356 } else if ( StatusCode::FAILURE != st ) {
357 str << " StatusCode=" << st.getCode();
358 } else {
359 str << " StatusCode=FAILURE";
360 }
361
362 // perform print operation
363 str << endmsg;
364
365 // return
366 return st;
367 }
StatusCode::getCode
code_t getCode() const
Retrieve value ("checks" the StatusCode)
Definition: StatusCode.h:137
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:298
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:267
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
GaudiCommon::typePrint
bool typePrint() const
Insert the actual C++ type of the algorithm/tool in the messages ?
Definition: GaudiCommon.h:523

## ◆ printErrors()

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 442 of file GaudiCommon.icpp.

442 {
443 // format for printout
444 boost::format ftm( " #%|-10s| = %|.8s| %|23t| Message = '%s'" );
445
446 auto print = [&]( const Counter& c, const std::string& label ) {
447 for ( const auto& i : c ) { this->msgStream( level ) << ( ftm % label % i.second % i.first ) << endmsg; }
448 };
449
450 print( m_exceptions, "EXCEPTIONS" );
451 print( m_errors, "ERRORS" );
452 print( m_warnings, "WARNINGS" );
453 print( m_infos, "INFOS" );
454
455 // return total number of errors+warnings+exceptions
456 return m_exceptions.size() + m_errors.size() + m_warnings.size() + m_infos.size();
457 }
GaudiCommon::m_warnings
Counter m_warnings
counter of warnings
Definition: GaudiCommon.h:725
GaudiCommon::m_exceptions
Counter m_exceptions
Counter of exceptions.
Definition: GaudiCommon.h:729
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:109
gaudirun.c
c
Definition: gaudirun.py:487
GaudiCommon::Counter
std::map< std::string, unsigned int > Counter
the actual type error/warning counter
Definition: GaudiCommon.h:124
std::string
STL class.
GaudiCommon::m_errors
Counter m_errors
Counter of errors.
Definition: GaudiCommon.h:723
GaudiCommon::m_infos
Counter m_infos
counter of infos
Definition: GaudiCommon.h:727
std::map::size
T size(T... args)
gaudirun.level
level
Definition: gaudirun.py:334
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ printProps()

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 466 of file GaudiCommon.icpp.

466 {
467
468 // print ALL properties
469 MsgStream& msg = this->msgStream( level );
470 const auto& properties = this->getProperties();
471 msg << "List of ALL properties of " << System::typeinfoName( typeid( *this ) ) << "/" << this->name()
472 << " #properties = " << properties.size() << endmsg;
473 for ( const auto& property : reverse( properties ) ) { msg << "Property ['Name': Value] = " << *property << endmsg; }
474 return properties.size();
475 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:298
reverse
::details::reverse_wrapper< T > reverse(T &&iterable)
Definition: reverse.h:49
gaudiComponentHelp.properties
properties
Definition: gaudiComponentHelp.py:51
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
gaudirun.level
level
Definition: gaudirun.py:334
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ printStat()

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 410 of file GaudiCommon.icpp.

410 {
411 // check how many counters think they should be printed or how many
412 // we anyway want to print
413 auto countToBePrinted = [&]() {
414 unsigned n = 0;
415 this->forEachCounter( [&n]( const std::string&, const auto& counter ) { n += counter.toBePrinted(); } );
416 return n;
417 };
418 auto nbPrintedCounters =
419 ( ( !m_printEmptyCounters && !this->msgLevel( MSG::DEBUG ) ) ? countToBePrinted() : this->nCounters() );
420 // in case nothing should be printed, let's stop here
421 if ( nbPrintedCounters == 0 ) return 0;
422 MsgStream& msg = this->msgStream( level );
423 msg << "Number of counters : " << nbPrintedCounters << "\n" << m_header.value();
424 this->forEachCounter( [&]( const std::string& label, const auto& counter ) {
425 if ( m_printEmptyCounters || this->msgLevel( MSG::DEBUG ) || counter.toBePrinted() ) {
426 std::ostringstream ost;
427 counter.print( ost, label );
428 msg << "\n" << ost.str();
429 }
430 } );
431 //
432 msg << endmsg;
433 //
434 return nbPrintedCounters;
435 }
GaudiCommon::m_printEmptyCounters
Gaudi::Property< bool > m_printEmptyCounters
Definition: GaudiCommon.h:765
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MSG::DEBUG
Definition: IMessageSvc.h:15
std::string
STL class.
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:210
std::ostringstream
STL class.
std::ostringstream::str
T str(T... args)
GaudiCommon::counter
StatEntity & counter(const std::string &tag) const
accessor to certain counter by name
Definition: GaudiCommon.h:506
GaudiCommon::m_header
Gaudi::Property< std::string > m_header
Definition: GaudiCommon.h:770
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
gaudirun.level
level
Definition: gaudirun.py:334
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ propsPrint()

template<class PBASE>

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

Print properties at initialization ?

Definition at line 525 of file GaudiCommon.h.

525 { return m_propsPrint; }
GaudiCommon::m_propsPrint
Gaudi::Property< bool > m_propsPrint
Definition: GaudiCommon.h:748

## ◆ put() [1/2]

template<class PBASE >

DataObject * GaudiCommon< PBASE >::put | ( | IDataProviderSvc * | svc,
|  | std::unique_ptr< 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 486 of file GaudiCommon.icpp.

487 {
488 // check arguments
489 Assert( svc, "put():: Invalid 'service'!" );
490 Assert( static_cast<bool>( object ), "put():: Invalid 'Object'!" );
491 Assert( !location.empty(), "put():: Invalid 'address' = '' " );
492 // final data location
493 const std::string& fullLocation = this->fullTESLocation( location, useRootInTES );
494 // register the object!
495 const StatusCode status = '/' == fullLocation[0] ? svc->registerObject( fullLocation, object.get() )
496 : svc->registerObject( "/Event/" + fullLocation, object.get() );
497 // check the result!
498 DataObject& obj = *object;
499 if ( status.isFailure() ) {
500 Exception( "put():: could not register '" + System::typeinfoName( typeid( obj ) ) + "' at address '" +
501 fullLocation + "'",
502 status );
503 }
504 if ( this->msgLevel( MSG::DEBUG ) ) {
505 Print( "The object of type '" + System::typeinfoName( typeid( obj ) ) + "' is registered in TS at address '" +
506 fullLocation + "'",
507 status, MSG::DEBUG )
508 .ignore();
509 }
510 // if we get here, ownership has been transferred to the IDataProviderSvc
511 return object.release();
512 }
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:298
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:374
GaudiPython.HistoUtils.location
location
Definition: HistoUtils.py:936
MSG::DEBUG
Definition: IMessageSvc.h:15
std::string
STL class.
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:155
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
GaudiCommon::get
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.
Definition: GaudiCommonImp.h:26
GaudiCommon::svc
SmartIF< SERVICE > svc(const std::string &name, const bool create=true) const
A useful method for the easy location of services.
Definition: GaudiCommonImp.h:121
StatusCode::ignore
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
FixTESPath< PBASE >::fullTESLocation
std::string fullTESLocation(std::string_view location, bool useRootInTES) const
Returns the full correct event location given the rootInTes settings.
Definition: FixTESPath.h:55
GaudiCommon::Print
WARN_UNUSED 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:343
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:130
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30

## ◆ put() [2/2]

template<class PBASE>

DataObject* GaudiCommon< PBASE >::put | ( | IDataProviderSvc * | svc,
|  | DataObject * | object,
|  | const std::string & | location,
|  | const bool | useRootInTES = `true`
| ) |  | const
| inline

Definition at line 265 of file GaudiCommon.h.

266 {
267 return put( svc, std::unique_ptr<DataObject>( object ), location, useRootInTES );
268 }
GaudiPython.HistoUtils.location
location
Definition: HistoUtils.py:936
GaudiCommon::put
DataObject * put(IDataProviderSvc *svc, std::unique_ptr< DataObject > object, const std::string &location, const bool useRootInTES=true) const
Register a data object or container into Gaudi Event Transient Store.
Definition: GaudiCommon.icpp:486
GaudiCommon::svc
SmartIF< SERVICE > svc(const std::string &name, const bool create=true) const
A useful method for the easy location of services.
Definition: GaudiCommonImp.h:121
std::unique_ptr
STL class.

## ◆ registerCondition() [1/4]

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

563 {
564 updMgrSvc()->registerCondition( dynamic_cast<CallerClass*>( this ), condition, mf );
565 }
GaudiCommon::updMgrSvc
IUpdateManagerSvc * updMgrSvc() const
Short-cut to locate the Update Manager Service.
Definition: GaudiCommonImp.h:147
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:168

## ◆ registerCondition() [2/4]

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

598 {
599 updMgrSvc()->registerCondition( dynamic_cast<CallerClass*>( this ), condition, mf, condPtrDest );
600 }
GaudiCommon::updMgrSvc
IUpdateManagerSvc * updMgrSvc() const
Short-cut to locate the Update Manager Service.
Definition: GaudiCommonImp.h:147
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:168

## ◆ registerCondition() [3/4]

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

603 {
604 updMgrSvc()->registerCondition( dynamic_cast<CallerClass*>( this ), std::string( condition ), mf );
605 }
GaudiCommon::updMgrSvc
IUpdateManagerSvc * updMgrSvc() const
Short-cut to locate the Update Manager Service.
Definition: GaudiCommonImp.h:147
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:168

## ◆ registerCondition() [4/4]

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

622 {
623 updMgrSvc()->registerCondition( dynamic_cast<CallerClass*>( this ), condition, mf );
624 }
GaudiCommon::updMgrSvc
IUpdateManagerSvc * updMgrSvc() const
Short-cut to locate the Update Manager Service.
Definition: GaudiCommonImp.h:147
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:168

## ◆ release()

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 206 of file GaudiCommon.icpp.

206 {
207 if ( !interface ) { return Error( "release(IInterface):: IInterface* points to NULL!" ); }
208 // dispatch between tools and services
209 const IAlgTool* algTool = dynamic_cast<const IAlgTool*>( interface );
210 // perform the actual release
211 return algTool ? releaseTool( algTool ) : releaseSvc( interface );
212 }
GaudiCommon::Error
WARN_UNUSED 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:286
GaudiCommon::releaseTool
StatusCode releaseTool(const IAlgTool *tool) const
manual forced (and 'safe') release of the tool
Definition: GaudiCommon.icpp:219
GaudiCommon::releaseSvc
StatusCode releaseSvc(const IInterface *svc) const
manual forced (and 'safe') release of the service
Definition: GaudiCommon.icpp:247
IAlgTool
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23

## ◆ releaseSvc()

template<class PBASE >

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

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

Definition at line 247 of file GaudiCommon.icpp.

247 {
248 if ( !Svc ) return Error( "releaseSvc(IInterface):: IInterface* points to NULL!" );
249 SmartIF<IService> svc{const_cast<IInterface*>( Svc )};
250 if ( !svc ) return Warning( "releaseSvc(IInterface):: IInterface* is not a service" );
251 auto it = std::lower_bound( std::begin( m_services ), std::end( m_services ), svc, GaudiCommon_details::svc_lt );
252 if ( it == m_services.end() || !GaudiCommon_details::svc_eq( *it, svc ) ) {
253 return Warning( "releaseSvc(IInterface):: IInterface* is not active" );
254 }
255 if ( this->msgLevel( MSG::DEBUG ) ) { this->debug() << "Releasing service '" << ( *it )->name() << "'" << endmsg; }
256 m_services.erase( it );
257 return StatusCode::SUCCESS;
258 }
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:720
MSG::DEBUG
Definition: IMessageSvc.h:15
GaudiCommon::Error
WARN_UNUSED 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:286
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
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
GaudiCommon::svc
SmartIF< SERVICE > svc(const std::string &name, const bool create=true) const
A useful method for the easy location of services.
Definition: GaudiCommonImp.h:121
std::vector::erase
T erase(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:192
GaudiCommon::Warning
WARN_UNUSED 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:305

## ◆ releaseTool()

template<class PBASE >

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

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

Definition at line 219 of file GaudiCommon.icpp.

219 {
220 if ( !algTool ) { return Error( "releaseTool(IAlgTool):: IAlgTool* points to NULL!" ); }
221 if ( !this->toolSvc() ) { return Error( "releaseTool(IAlgTool):: IToolSvc* points to NULL!" ); }
222 // find a tool in the list of active tools
223 auto it = std::find( m_managedTools.begin(), m_managedTools.end(), algTool );
224 if ( m_managedTools.end() == it ) { return Warning( "releaseTool(IAlgTool):: IAlgTool* is not active" ); }
225 // get the tool
226 IAlgTool* t = *it;
227 // cache name
228 const std::string name = t->name();
229 if ( this->msgLevel( MSG::DEBUG ) ) { this->debug() << "Releasing tool '" << name << "'" << endmsg; }
230 // remove the tool from the lists
231 base_class::deregisterTool( t );
232 m_managedTools.erase( it );
233 // release tool
234 if ( this->msgLevel( MSG::DEBUG ) ) {
235 this->debug() << "The tool '" << t->name() << "' of type '" << System::typeinfoName( typeid( *t ) )
236 << "' is released" << endmsg;
237 }
238 const StatusCode sc = this->toolSvc()->releaseTool( t );
239 return sc.isSuccess() ? sc : Warning( "releaseTool(IAlgTool):: error from IToolSvc releasing " + name, sc );
240 }
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:298
MSG::DEBUG
Definition: IMessageSvc.h:15
GaudiCommon::Error
WARN_UNUSED 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:286
std::vector::end
T end(T... args)
INamedInterface::name
virtual const std::string & name() const =0
Retrieve the name of the instance.
std::string
STL class.
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
std::vector::erase
T erase(T... args)
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:267
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:718
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
GaudiCommon::Warning
WARN_UNUSED 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:305

## ◆ runUpdate()

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

636 { return updMgrSvc()->update( this ); }
GaudiCommon::updMgrSvc
IUpdateManagerSvc * updMgrSvc() const
Short-cut to locate the Update Manager Service.
Definition: GaudiCommonImp.h:147
IUpdateManagerSvc::update
StatusCode update(CallerClass *instance)
Update the given instance.
Definition: IUpdateManagerSvc.h:234

## ◆ services()

template<class PBASE>

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

get the list of aquired services

Definition at line 702 of file GaudiCommon.h.

702 { return m_services; } // get all services
GaudiCommon::m_services
Services m_services
List of active services.
Definition: GaudiCommon.h:720

## ◆ statPrint()

template<class PBASE>

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

Print statistical counters at finalization ?

Definition at line 527 of file GaudiCommon.h.

527 { return m_statPrint; }
GaudiCommon::m_statPrint
Gaudi::Property< bool > m_statPrint
Definition: GaudiCommon.h:757

## ◆ svc()

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 121 of file GaudiCommonImp.h.

121 {
122 Assert( this->svcLoc(), "ISvcLocator* points to NULL!" );
123 SmartIF<SERVICE> s;
124 // check if we already have this service
125 auto it = std::lower_bound( std::begin( m_services ), std::end( m_services ), name, GaudiCommon_details::svc_lt );
126 if ( it != std::end( m_services ) && GaudiCommon_details::svc_eq( *it, name ) ) {
127 // Try to get the requested interface
128 s = *it;
129 // check the results
130 if ( !s ) { Exception( "svc():: Could not retrieve Svc '" + name + "'", StatusCode::FAILURE ); }
131 } else {
132 auto baseSvc = this->svcLoc()->service( name, create );
133 // Try to get the requested interface
134 s = baseSvc;
135 // check the results
136 if ( !baseSvc || !s ) { Exception( "svc():: Could not retrieve Svc '" + name + "'", StatusCode::FAILURE ); }
137 // add the tool into list of known tools, to be properly released
138 addToServiceList( baseSvc );
139 }
140 // return *VALID* located service
141 return s;
142 }
SmartIF
Small smart pointer class with automatic reference counting for IInterface.
Definition: IConverter.h:15
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
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:720
GaudiCommon::addToServiceList
void addToServiceList(SmartIF< IService > svc) const
Add the given service to the list of acquired services.
Definition: GaudiCommon.icpp:266
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:374
std::end
T end(T... args)
std::lower_bound
T lower_bound(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:155
GaudiCommon_details::svc_lt
constexpr const struct GaudiCommon_details::svc_lt_t svc_lt
std::begin
T begin(T... args)
gaudirun.s
string s
Definition: gaudirun.py:316
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86

## ◆ tool() [1/2]

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 81 of file GaudiCommonImp.h.

82 {
83 // for empty names delegate to another method
84 if ( name.empty() ) return tool<TOOL>( type, parent, create );
85 Assert( this->toolSvc(), "tool():: IToolSvc* points to NULL!" );
86 // get the tool from Tool Service
87 TOOL* Tool = nullptr;
88 const StatusCode sc = this->toolSvc()->retrieveTool( type, name, Tool, parent, create );
89 if ( sc.isFailure() ) { Exception( "tool():: Could not retrieve Tool '" + type + "'/'" + name + "'", sc ); }
90 if ( !Tool ) { Exception( "tool():: Could not retrieve Tool '" + type + "'/'" + name + "'" ); }
91 // insert tool into list of tools
92 PBASE::registerTool( Tool );
93 m_managedTools.push_back( Tool );
94 // return *VALID* located tool
95 return Tool;
96 }
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
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:374
std::vector::push_back
T push_back(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:155
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
gaudirun.type
type
Definition: gaudirun.py:142
GaudiCommon::m_managedTools
AlgTools m_managedTools
List of active tools.
Definition: GaudiCommon.h:718
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:130

## ◆ tool() [2/2]

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 102 of file GaudiCommonImp.h.

102 {
103 // check the environment
104 Assert( PBASE::toolSvc(), "IToolSvc* points to NULL!" );
105 // retrieve the tool from Tool Service
106 TOOL* Tool = nullptr;
107 const StatusCode sc = this->toolSvc()->retrieveTool( type, Tool, parent, create );
108 if ( sc.isFailure() ) { Exception( "tool():: Could not retrieve Tool '" + type + "'", sc ); }
109 if ( !Tool ) { Exception( "tool():: Could not retrieve Tool '" + type + "'" ); }
110 // add the tool into the list of known tools to be properly released
111 PBASE::registerTool( Tool );
112 m_managedTools.push_back( Tool );
113 // return *VALID* located tool
114 return Tool;
115 }
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:374
std::vector::push_back
T push_back(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:155
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
gaudirun.type
type
Definition: gaudirun.py:142
GaudiCommon::m_managedTools
AlgTools m_managedTools
List of active tools.
Definition: GaudiCommon.h:718
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:130

## ◆ typePrint()

template<class PBASE>

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

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

Definition at line 523 of file GaudiCommon.h.

523 { return m_typePrint; }
GaudiCommon::m_typePrint
Gaudi::Property< bool > m_typePrint
Definition: GaudiCommon.h:767

## ◆ updMgrSvc()

template<class PBASE >

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

Short-cut to locate the Update Manager Service.

Definition at line 147 of file GaudiCommonImp.h.

147 {
148 if ( !m_updMgrSvc ) { m_updMgrSvc = svc<IUpdateManagerSvc>( "UpdateManagerSvc", true ); }
149 return m_updMgrSvc;
150 }
GaudiCommon::m_updMgrSvc
IUpdateManagerSvc * m_updMgrSvc
Pointer to the Update Manager Service instance.
Definition: GaudiCommon.h:736

## ◆ Warning()

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 305 of file GaudiCommon.icpp.

305 {
306 // increase local counter of warnings
307 const size_t num = ++m_warnings[msg];
308 // If suppressed, just return
309 if ( num > mx ) {
310 return st;
311 } else if ( UNLIKELY( num == mx ) ) // issue one-time suppression message
312 {
313 return Print( "The WARNING message is suppressed : '" + msg + "'", st, MSG::WARNING );
314 }
315 // return message
316 return Print( msg, st, MSG::WARNING );
317 }
GaudiCommon::m_warnings
Counter m_warnings
counter of warnings
Definition: GaudiCommon.h:725
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:96
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
GaudiCommon::Print
WARN_UNUSED 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:343
MSG::WARNING
Definition: IMessageSvc.h:15

## Member Data Documentation

## ◆ IgnoreRootInTES

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

## ◆ m_context

template<class PBASE>

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

Definition at line 769 of file GaudiCommon.h.

## ◆ m_counterList

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

## ◆ m_countersOwn

template<class PBASE>

StatisticsOwn GaudiCommon< PBASE >::m_countersOwn
| private

General counters.

Definition at line 731 of file GaudiCommon.h.

## ◆ m_countersOwnMutex

template<class PBASE>

std::mutex GaudiCommon< PBASE >::m_countersOwnMutex
| private

The mutex for m_countersOwn.

Definition at line 733 of file GaudiCommon.h.

## ◆ m_counterSummarySvc

template<class PBASE>

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

a pointer to the CounterSummarySvc

Definition at line 133 of file GaudiCommon.h.

## ◆ m_errors

template<class PBASE>

Counter GaudiCommon< PBASE >::m_errors
| mutable private

Counter of errors.

Definition at line 723 of file GaudiCommon.h.

## ◆ m_errorsPrint

template<class PBASE>

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

Initial value:
{this, "ErrorsPrint", true,
[this]( auto& ) {
if ( this->FSMState() >= Gaudi::StateMachine::INITIALIZED &&
this->errorsPrint() ) {
this->printErrors();
}
},
"print the statistics of errors/warnings/exceptions"}

Definition at line 739 of file GaudiCommon.h.

## ◆ m_exceptions

template<class PBASE>

Counter GaudiCommon< PBASE >::m_exceptions
| mutable private

Counter of exceptions.

Definition at line 729 of file GaudiCommon.h.

## ◆ m_format1

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

## ◆ m_format2

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

## ◆ m_header

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

## ◆ m_infos

template<class PBASE>

Counter GaudiCommon< PBASE >::m_infos
| mutable private

counter of infos

Definition at line 727 of file GaudiCommon.h.

## ◆ m_managedTools

template<class PBASE>

AlgTools GaudiCommon< PBASE >::m_managedTools
| mutable private

List of active tools.

Definition at line 718 of file GaudiCommon.h.

## ◆ m_printEmptyCounters

template<class PBASE>

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

Initial value:
{this, "PrintEmptyCounters", false,
"force printing of empty counters, otherwise only printed in DEBUG mode"}

Definition at line 765 of file GaudiCommon.h.

## ◆ m_propsPrint

template<class PBASE>

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

Initial value:
{this, "PropertiesPrint", false,
[this]( auto& ) {
if ( this->FSMState() >= Gaudi::StateMachine::INITIALIZED &&
this->propsPrint() ) {
this->printProps( MSG::ALWAYS );
}
},
"print the properties of the component"}

Definition at line 748 of file GaudiCommon.h.

## ◆ m_services

template<class PBASE>

Services GaudiCommon< PBASE >::m_services
| mutable private

List of active services.

Definition at line 720 of file GaudiCommon.h.

## ◆ m_statEntityList

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

## ◆ m_statPrint

template<class PBASE>

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

Initial value:
{this, "StatPrint", true,
[this]( auto& ) {
if ( this->FSMState() >= Gaudi::StateMachine::INITIALIZED && this->statPrint() ) {
this->printStat( MSG::ALWAYS );
}
},
"print the table of counters"}

Definition at line 757 of file GaudiCommon.h.

## ◆ m_typePrint

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

## ◆ m_updMgrSvc

template<class PBASE>

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

Pointer to the Update Manager Service instance.

Definition at line 736 of file GaudiCommon.h.

## ◆ m_useEffFormat

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

## ◆ m_warnings

template<class PBASE>

Counter GaudiCommon< PBASE >::m_warnings
| mutable private

counter of warnings

Definition at line 725 of file GaudiCommon.h.

## ◆ UseRootInTES

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 116 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