Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GaudiCommon< PBASE > Class Template Reference

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

#include <GaudiAlg/GaudiCommon.h>

Inheritance diagram for GaudiCommon< PBASE >:
Collaboration diagram for GaudiCommon< PBASE >:

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...
 
DataObjectput (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...
 
DataObjectput (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...
 
IUpdateManagerSvcupdMgrSvc () 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...
 
StatEntitycounter (const std::string &tag) const
 accessor to certain counter by name More...
 
StatEntitycounter (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<Gaudi::Algorithm, PBASE>::value, 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<AlgTool, PBASE>::value, 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 Servicesservices () const
 get the list of aquired services More...
 
const std::stringcontext () const
 Returns the "context" string. Used to identify different processing states. More...
 
const std::stringrootInTES () 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, StatEntityStatisticsOwn
 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< ICounterSummarySvcm_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
 
GaudiCommonoperator= (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...
 
IUpdateManagerSvcm_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::stringm_context {this, "Context", {}, "note: overridden by parent settings"}
 
Gaudi::Property< std::stringm_rootInTES {this, "RootInTES", {}, "note: overridden by parent settings"}
 
Gaudi::Property< std::stringm_header
 
Gaudi::Property< std::stringm_format1
 
Gaudi::Property< std::stringm_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 92 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 127 of file GaudiCommon.h.

template<class PBASE>
using GaudiCommon< PBASE >::base_class = PBASE
protected

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

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

storage for active services

Definition at line 129 of file GaudiCommon.h.

Definition at line 123 of file GaudiCommon.h.

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

the actual type of general counters

Definition at line 122 of file GaudiCommon.h.

Constructor & Destructor Documentation

template<class PBASE>
template<typename U = PBASE, typename = std::enable_if_t<std::is_base_of<Gaudi::Algorithm, PBASE>::value, 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 643 of file GaudiCommon.h.

643  : base_class( name, pSvcLocator ) {
645  }
PBASE base_class
Definition: GaudiCommon.h:94
void initGaudiCommonConstructor(const IInterface *parent=nullptr)
Constructor initializations.
template<class PBASE>
template<typename U = PBASE, typename = std::enable_if_t<std::is_base_of<AlgTool, PBASE>::value, 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 649 of file GaudiCommon.h.

650  : base_class( type, name, ancestor ) {
651  initGaudiCommonConstructor( this->parent() );
652  }
PBASE base_class
Definition: GaudiCommon.h:94
void initGaudiCommonConstructor(const IInterface *parent=nullptr)
Constructor initializations.
template<class PBASE>
GaudiCommon< PBASE >::GaudiCommon ( )
privatedelete
template<class PBASE>
GaudiCommon< PBASE >::GaudiCommon ( const GaudiCommon< PBASE > &  )
privatedelete

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

321  {
322  if ( svc ) {
324  if ( i == std::end( m_services ) || !GaudiCommon_details::svc_eq( *i, svc ) ) {
325  m_services.insert( i, std::move( svc ) );
326  } else {
327  this->warning() << "Service " << svc->name() << " already present -- skipping" << endmsg;
328  }
329  }
330 }
constexpr const struct GaudiCommon_details::svc_eq_t svc_eq
Services m_services
List of active services.
Definition: GaudiCommon.h:730
T end(T...args)
T lower_bound(T...args)
constexpr const struct GaudiCommon_details::svc_lt_t svc_lt
T move(T...args)
T insert(T...args)
T begin(T...args)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
template<class PBASE >
void GaudiCommon< PBASE >::Assert ( const bool  ok,
const std::string message = "",
const StatusCode  sc = StatusCodeStatusCode::FAILURE, true ) 
) const
inline

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

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

Definition at line 179 of file GaudiCommonImp.h.

179  {
180  if ( !ok ) Exception( msg, sc );
181 }
void Exception(const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
Create and (re)-throw a given GaudiException.
template<class PBASE >
void GaudiCommon< PBASE >::Assert ( const bool  ok,
const char *  message,
const StatusCode  sc = StatusCodeStatusCode::FAILURE, true ) 
) const
inline

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

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

Definition at line 186 of file GaudiCommonImp.h.

186  {
187  if ( !ok ) Exception( msg, sc );
188 }
void Exception(const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
Create and (re)-throw a given GaudiException.
template<class PBASE>
const std::string& GaudiCommon< PBASE >::context ( ) const
inline

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

Definition at line 708 of file GaudiCommon.h.

708 { return m_context; }
Gaudi::Property< std::string > m_context
Definition: GaudiCommon.h:779
template<class PBASE>
StatEntity& GaudiCommon< PBASE >::counter ( const std::string tag) const
inline

accessor to certain counter by name

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

Definition at line 507 of file GaudiCommon.h.

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

Definition at line 510 of file GaudiCommon.h.

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

accessor to all owned counters

Definition at line 485 of file GaudiCommon.h.

485 { return m_countersOwn; }
StatisticsOwn m_countersOwn
General counters.
Definition: GaudiCommon.h:741
template<class PBASE >
StatusCode GaudiCommon< PBASE >::Error ( const std::string msg,
const StatusCode  st = StatusCode::FAILURE,
const size_t  mx = 10 
) const

Print the error message and return with the given StatusCode.

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

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

Definition at line 341 of file GaudiCommon.icpp.

341  {
342  // increase local counter of errors
343  const size_t num = ++m_errors[msg];
344  // If suppressed, just return
345  if ( num > mx ) {
346  return st;
347  } else if ( UNLIKELY( num == mx ) ) // issue one-time suppression message
348  {
349  return Print( "The ERROR message is suppressed : '" + msg + "'", st, MSG::ERROR );
350  }
351  // return message
352  return Print( msg, st, MSG::ERROR );
353 }
#define UNLIKELY(x)
Definition: Kernel.h:89
Counter m_errors
Counter of errors.
Definition: GaudiCommon.h:733
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.
template<class PBASE>
bool GaudiCommon< PBASE >::errorsPrint ( ) const
inline

Print error counters at finalization ?

Definition at line 530 of file GaudiCommon.h.

530 { return m_errorsPrint; }
Gaudi::Property< bool > m_errorsPrint
Definition: GaudiCommon.h:749
template<class PBASE >
void GaudiCommon< PBASE >::Exception ( const std::string msg,
const GaudiException exc,
const StatusCode  sc = StatusCodeStatusCode::FAILURE, true ) 
) const

Create and (re)-throw a given GaudiException.

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

Definition at line 429 of file GaudiCommon.icpp.

429  {
430  // increase local counter of exceptions
431  ++m_exceptions[msg];
432  Print( "Exception (re)throw: " + msg, sc, MSG::FATAL ).ignore();
433  throw GaudiException( this->name() + ":: " + msg, this->name(), sc, exc );
434 }
Define general base for Gaudi exception.
Counter m_exceptions
Counter of exceptions.
Definition: GaudiCommon.h:739
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.
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
template<class PBASE >
void GaudiCommon< PBASE >::Exception ( const std::string msg,
const std::exception exc,
const StatusCode  sc = StatusCodeStatusCode::FAILURE, true ) 
) const

Create and (re)-throw a given exception.

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

Definition at line 441 of file GaudiCommon.icpp.

441  {
442  // increase local counter of exceptions
443  ++m_exceptions[msg];
444  Print( "Exception (re)throw: " + msg, sc, MSG::FATAL ).ignore();
445  throw GaudiException( this->name() + ":: " + msg + "(" + exc.what() + ")", "", sc );
446 }
Define general base for Gaudi exception.
Counter m_exceptions
Counter of exceptions.
Definition: GaudiCommon.h:739
T what(T...args)
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.
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
template<class PBASE >
void GaudiCommon< PBASE >::Exception ( const std::string msg = "no message",
const StatusCode  sc = StatusCodeStatusCode::FAILURE, true ) 
) const

Create and throw an exception with the given message.

See also
GaudiException
Exceptions
GaudiExceptionalways thrown!
Parameters
msgException message
scStatusCode

Definition at line 453 of file GaudiCommon.icpp.

453  {
454  // increase local counter of exceptions
455  ++m_exceptions[msg];
456  Print( "Exception throw: " + msg, sc, MSG::FATAL ).ignore();
457  throw GaudiException( this->name() + ":: " + msg, "", sc );
458 }
Define general base for Gaudi exception.
Counter m_exceptions
Counter of exceptions.
Definition: GaudiCommon.h:739
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.
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
template<class PBASE >
template<class TYPE >
bool GaudiCommon< PBASE >::exist ( IDataProviderSvc svc,
const std::string location,
const bool  useRootInTES = true 
) const
inline

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

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

Definition at line 76 of file GaudiCommonImp.h.

77  {
78  // check the environment
79  Assert( service, "exist():: IDataProvider* points to NULL!" );
80  // check the data object
82  return checker( service, fullTESLocation( location, useRootInTES ) );
83 }
Helper structure for implementation of "exists"-functions for GaudiCommon<BASE>
Definition: GetData.h:314
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.
const std::string fullTESLocation(const std::string &location, const bool useRootInTES) const
Returns the full correct event location given the rootInTes settings.
template<class PBASE >
StatusCode GaudiCommon< PBASE >::finalize ( )
override

standard finalization method

Returns
status code

Definition at line 186 of file GaudiCommon.icpp.

186  {
188 
189  // print the general information about statistical counters
190  if ( this->msgLevel( MSG::DEBUG ) || ( statPrint() && this->nCounters() > 0 ) ) {
191  // print general statistical counters
193  }
194  // add all counters to the CounterSummarySvc
195  if ( m_counterSummarySvc && this->svcLoc()->existsService( "CounterSummarySvc" ) ) {
196  if ( this->msgLevel( MSG::DEBUG ) ) this->debug() << "adding counters to CounterSummarySvc" << endmsg;
197 
199  Gaudi::Utils::RegEx::matchList counterList{m_counterList.value()};
200 
201  for ( const auto& i : m_countersOwn ) {
202  if ( statList.Or( i.first ) )
203  m_counterSummarySvc->addCounter( this->name(), i.first, i.second, Gaudi::CounterSummary::SaveStatEntity );
204  else if ( counterList.Or( i.first ) )
205  m_counterSummarySvc->addCounter( this->name(), i.first, i.second );
206  }
207  }
208  // release all located tools and services
209  if ( this->msgLevel( MSG::DEBUG ) ) {
210  this->debug() << "Tools to release :";
211  for ( const auto& i : m_managedTools ) { this->debug() << " " << i->name(); }
212  this->debug() << endmsg;
213  }
214  while ( !m_managedTools.empty() ) {
215  sc = ( releaseTool( m_managedTools.back() ) && sc ) ? StatusCode::SUCCESS : StatusCode::FAILURE;
216  }
217 
218  // release all located services
219  if ( this->msgLevel( MSG::DEBUG ) ) {
220  this->debug() << "Services to release :";
221  for ( const auto& i : m_services ) this->debug() << " " << i->name();
222  this->debug() << endmsg;
223  }
224  while ( !m_services.empty() ) {
225  sc = ( releaseSvc( m_services.front() ) && sc ) ? StatusCode::SUCCESS : StatusCode::FAILURE;
226  }
227 
228  // release the CounterSummarySvc manually
230 
231  // format printout
232  if ( !m_errors.empty() || !m_warnings.empty() || !m_exceptions.empty() ) {
233  this->always() << "Exceptions/Errors/Warnings/Infos Statistics : " << m_exceptions.size() << "/" << m_errors.size()
234  << "/" << m_warnings.size() << "/" << m_infos.size() << endmsg;
235  if ( errorsPrint() ) { printErrors(); }
236  }
237 
238  // clear *ALL* counters explicitly
239  this->clearCounters();
240  m_countersOwn.clear(); // then delete any owned counters
242  m_infos.clear();
243  m_warnings.clear();
244  m_errors.clear();
245  m_counterList.clear();
246  m_statEntityList.clear();
247 
248  // finalize base class
249  return ( sc && PBASE::finalize() ? StatusCode::SUCCESS : StatusCode::FAILURE );
250 }
Counter m_warnings
counter of warnings
Definition: GaudiCommon.h:735
T empty(T...args)
Counter m_exceptions
Counter of exceptions.
Definition: GaudiCommon.h:739
StatusCode releaseSvc(const IInterface *svc) const
manual forced (and &#39;safe&#39;) release of the service
Services m_services
List of active services.
Definition: GaudiCommon.h:730
StatisticsOwn m_countersOwn
General counters.
Definition: GaudiCommon.h:741
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
Gaudi::Property< std::vector< std::string > > m_counterList
Definition: GaudiCommon.h:795
bool statPrint() const
Print statistical counters at finalization ?
Definition: GaudiCommon.h:528
Counter m_errors
Counter of errors.
Definition: GaudiCommon.h:733
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
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
Counter m_infos
counter of infos
Definition: GaudiCommon.h:737
bool errorsPrint() const
Print error counters at finalization ?
Definition: GaudiCommon.h:530
SmartIF< ICounterSummarySvc > m_counterSummarySvc
a pointer to the CounterSummarySvc
Definition: GaudiCommon.h:134
T clear(T...args)
T size(T...args)
StatusCode releaseTool(const IAlgTool *tool) const
manual forced (and &#39;safe&#39;) release of the tool
constexpr static const auto FAILURE
Definition: StatusCode.h:86
AlgTools m_managedTools
List of active tools.
Definition: GaudiCommon.h:728
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:86
long printStat(const MSG::Level level=MSG::ALWAYS) const
perform the actual printout of statistical counters
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Gaudi::Property< std::vector< std::string > > m_statEntityList
Definition: GaudiCommon.h:797
long printErrors(const MSG::Level level=MSG::ALWAYS) const
perform the actual printout of error counters
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.

25  {
26  // The logic is:
27  // if no R.I.T., give back location
28  // if R.I.T., this is the mapping:
29  // (note that R.I.T. contains a trailing '/')
30  // location -> result
31  // -------------------------------------------------
32  // "" -> R.I.T.[:-1] ("rit")
33  // "/Event" -> R.I.T.[:-1] ("rit")
34  // "/Event/MyObj" -> R.I.T. + "MyObj" ("rit/MyObj")
35  // "MyObj" -> R.I.T. + "MyObj" ("rit/MyObj")
36  return ( !useRootInTES || rootInTES().empty()
37  ? location
38  : location.empty() || ( location == "/Event" )
39  ? rootInTES().substr( 0, rootInTES().size() - 1 )
40  : 0 == location.find( "/Event/" )
41  ? rootInTES() + location.substr( 7 )
42  : location[0] == '/' ? rootInTES() + location.substr( 1 ) : rootInTES() + location );
43 }
T empty(T...args)
const std::string & rootInTES() const
Returns the "rootInTES" string.
Definition: GaudiCommon.h:712
constexpr auto size(const C &c) noexcept(noexcept(c.size())) -> decltype(c.size())
T find(T...args)
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
GaudiExceptionfor Invalid Data Provider Service
GaudiExceptionfor invalid/unavailable data
Parameters
svcPointer to data service (data provider)
locationdata location/address in Gaudi Transient Store
useRootInTESFlag to turn on(TRUE) off(FALSE) the use of the RootInTES location property
Returns
pointer to the data object

Definition at line 50 of file GaudiCommonImp.h.

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

64  {
65  // check the environment
66  Assert( service, "get():: IDataProvider* points to NULL!" );
67  // get the helper object:
69  return getter( *this, service, fullTESLocation( location, useRootInTES ), false );
70 }
Helper structure for implementation of "get"-functions for GaudiCommon<BASE>
Definition: GaudiCommon.h:54
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.
const std::string fullTESLocation(const std::string &location, const bool useRootInTES) const
Returns the full correct event location given the rootInTes settings.
template<class PBASE >
template<class TYPE , class TYPE2 >
Gaudi::Utils::GetData< TYPE >::return_type GaudiCommon< PBASE >::getOrCreate ( IDataProviderSvc svc,
const std::string location,
const bool  useRootInTES = true 
) const
inline

Get the existing data object from Gaudi Event Transient store.

Alternatively, create new object and register it in TES and return if object does not exist.

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

Definition at line 92 of file GaudiCommonImp.h.

93  {
94  // check the environment
95  Assert( service, "getOrCreate():: svc points to NULL!" );
96  // get the helper object
98  return getter( *this, service, fullTESLocation( location, useRootInTES ), location );
99 }
Helper structure for implementation of "getOrCreate"-functions for GaudiCommon<BASE> ...
Definition: GetData.h:388
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.
const std::string fullTESLocation(const std::string &location, const bool useRootInTES) const
Returns the full correct event location given the rootInTes settings.
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
msgInfo message
stStatusCode to return
mxMaximum number of printouts for this message
Returns
The given StatusCode

Definition at line 379 of file GaudiCommon.icpp.

379  {
380  // increase local counter of warnings
381  const size_t num = ++m_infos[msg];
382  // If suppressed, just return
383  if ( num > mx ) {
384  return st;
385  } else if ( UNLIKELY( num == mx ) ) // issue one-time suppression message
386  {
387  return Print( "The INFO message is suppressed : '" + msg + "'", st, MSG::INFO );
388  }
389  // return message
390  return Print( msg, st, MSG::INFO );
391 }
#define UNLIKELY(x)
Definition: Kernel.h:89
Counter m_infos
counter of infos
Definition: GaudiCommon.h:737
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.
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  m_rootInTES = gAlg->rootInTES();
71  } else if ( const GaudiTool* gTool = dynamic_cast<const GaudiTool*>( parent ) ) {
72  m_context = gTool->context();
73  m_rootInTES = gTool->rootInTES();
74  }
75  }
76 
77  // Get the job option service
78  auto jos = PBASE::template service<IJobOptionsSvc>( "JobOptionsSvc" );
79  if ( !jos ) Exception( "Cannot get JobOptionsSvc" );
80 
81  // Get the "Context" option if in the file...
82  const auto myList = jos->getProperties( this->name() );
83  if ( myList ) {
84  // Iterate over the list to set the options
85  for ( const auto& iter : *myList ) {
86  const Gaudi::Property<std::string>* sp = dynamic_cast<const Gaudi::Property<std::string>*>( iter );
87  if ( sp ) {
88  if ( iter->name().compare( "Context" ) == 0 ) {
89  m_context = sp->value();
90  } else if ( iter->name().compare( "RootInTES" ) == 0 ) {
91  m_rootInTES = sp->value();
92  }
93  }
94  }
95  }
96 }
Gaudi::Property< std::string > m_rootInTES
Definition: GaudiCommon.h:780
Implementation of property with value of concrete type.
Definition: Property.h:352
The useful base class for data processing algorithms.
Gaudi::Property< std::string > m_context
Definition: GaudiCommon.h:779
The useful base class for tools.
Definition: GaudiTool.h:101
const ValueType & value() const
Backward compatibility (.
Definition: Property.h:525
void Exception(const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
Create and (re)-throw a given GaudiException.
template<class PBASE >
StatusCode GaudiCommon< PBASE >::initialize ( )
override

standard initialization method

Returns
status code

Definition at line 103 of file GaudiCommon.icpp.

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

Print the message and return with the given StatusCode.

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

Definition at line 398 of file GaudiCommon.icpp.

398  {
399  // perform printout ?
400  if ( !this->msgLevel( lvl ) ) { return st; } // RETURN
401 
402  // use the predefined stream
403  MsgStream& str = this->msgStream( lvl );
404  if ( typePrint() ) { str << System::typeinfoName( typeid( *this ) ) << ":: "; }
405 
406  // print the message
407  str << msg;
408 
409  // test status code
410  if ( st.isSuccess() ) {
411  } else if ( StatusCode::FAILURE != st ) {
412  str << " StatusCode=" << st.getCode();
413  } else {
414  str << " StatusCode=FAILURE";
415  }
416 
417  // perform print operation
418  str << endmsg;
419 
420  // return
421  return st;
422 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:309
bool isSuccess() const
Definition: StatusCode.h:267
bool typePrint() const
Insert the actual C++ type of the algorithm/tool in the messages ?
Definition: GaudiCommon.h:524
constexpr static const auto FAILURE
Definition: StatusCode.h:86
code_t getCode() const
Retrieve value ("checks" the StatusCode)
Definition: StatusCode.h:137
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
template<class PBASE >
long GaudiCommon< PBASE >::printErrors ( const MSG::Level  level = MSG::ALWAYS) const

perform the actual printout of error counters

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

Definition at line 497 of file GaudiCommon.icpp.

497  {
498  // format for printout
499  boost::format ftm( " #%|-10s| = %|.8s| %|23t| Message = '%s'" );
500 
501  auto print = [&]( const Counter& c, const std::string& label ) {
502  for ( const auto& i : c ) { this->msgStream( level ) << ( ftm % label % i.second % i.first ) << endmsg; }
503  };
504 
505  print( m_exceptions, "EXCEPTIONS" );
506  print( m_errors, "ERRORS" );
507  print( m_warnings, "WARNINGS" );
508  print( m_infos, "INFOS" );
509 
510  // return total number of errors+warnings+exceptions
511  return m_exceptions.size() + m_errors.size() + m_warnings.size() + m_infos.size();
512 }
Counter m_warnings
counter of warnings
Definition: GaudiCommon.h:735
Counter m_exceptions
Counter of exceptions.
Definition: GaudiCommon.h:739
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:109
std::map< std::string, unsigned int > Counter
the actual type error/warning counter
Definition: GaudiCommon.h:125
STL class.
Counter m_errors
Counter of errors.
Definition: GaudiCommon.h:733
Counter m_infos
counter of infos
Definition: GaudiCommon.h:737
T size(T...args)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
template<class PBASE >
long GaudiCommon< PBASE >::printProps ( const MSG::Level  level = MSG::ALWAYS) const

perform the actual printout of properties

perform the printout of properties

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

Definition at line 521 of file GaudiCommon.icpp.

521  {
522 
523  // print ALL properties
524  MsgStream& msg = this->msgStream( level );
525  const auto& properties = this->getProperties();
526  msg << "List of ALL properties of " << System::typeinfoName( typeid( *this ) ) << "/" << this->name()
527  << " #properties = " << properties.size() << endmsg;
528  for ( const auto& property : reverse( properties ) ) { msg << "Property ['Name': Value] = " << *property << endmsg; }
529  return properties.size();
530 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:309
::details::reverse_wrapper< T > reverse(T &&iterable)
Definition: reverse.h:49
Gaudi::Details::PropertyBase * property(const std::string &name) const
const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const override
get all properties
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
template<class PBASE >
long GaudiCommon< PBASE >::printStat ( const MSG::Level  level = MSG::ALWAYS) const

perform the actual printout of statistical counters

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

Definition at line 465 of file GaudiCommon.icpp.

465  {
466  // check how many counters think they should be printed or how many
467  // we anyway want to print
468  auto countToBePrinted = [&]() {
469  unsigned n = 0;
470  this->forEachCounter( [&n]( const std::string&, const auto& counter ) { n += counter.toBePrinted(); } );
471  return n;
472  };
473  auto nbPrintedCounters =
474  ( ( !m_printEmptyCounters && !this->msgLevel( MSG::DEBUG ) ) ? countToBePrinted() : this->nCounters() );
475  // in case nothing should be printed, let's stop here
476  if ( nbPrintedCounters == 0 ) return 0;
477  MsgStream& msg = this->msgStream( level );
478  msg << "Number of counters : " << nbPrintedCounters << "\n" << m_header.value();
479  this->forEachCounter( [&]( const std::string& label, const auto& counter ) {
480  if ( m_printEmptyCounters || this->msgLevel( MSG::DEBUG ) || counter.toBePrinted() ) {
481  std::ostringstream ost;
482  counter.print( ost, label );
483  msg << "\n" << ost.str();
484  }
485  } );
486  //
487  msg << endmsg;
488  //
489  return nbPrintedCounters;
490 }
Gaudi::Property< bool > m_printEmptyCounters
Definition: GaudiCommon.h:775
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
STL class.
StatEntity & counter(const std::string &tag) const
accessor to certain counter by name
Definition: GaudiCommon.h:507
virtual bool toBePrinted() const
hint whether we should print that counter or not.
Definition: Counters.h:641
std::ostream & print(std::ostream &o, bool tableFormat, const std::string &name, bool flag=true, std::string fmtHead="%|-48.48s|%|27t|") const
Definition: Counters.h:978
Gaudi::Property< std::string > m_header
Definition: GaudiCommon.h:781
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
template<class PBASE>
bool GaudiCommon< PBASE >::propsPrint ( ) const
inline

Print properties at initialization ?

Definition at line 526 of file GaudiCommon.h.

526 { return m_propsPrint; }
Gaudi::Property< bool > m_propsPrint
Definition: GaudiCommon.h:758
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
svcPointer to data provider service
objectData object or container to be registered
locationLocation in Gaudi Event Transient Store ("/Event" could be omitted )
useRootInTESFlag to turn on(TRUE) off(FALSE) the use of the RootInTES location property
Exceptions
GaudiExceptionfor invalid event data service
GaudiExceptionfor invalid object
GaudiExceptionfor error result from event data service
Returns
StatusCode
Return values
StatusCode::SUCCESSData was successfully placed in the TES.
StatusCode::FAILUREFailed to store data in the TES.

Definition at line 541 of file GaudiCommon.icpp.

542  {
543  // check arguments
544  Assert( svc, "put():: Invalid 'service'!" );
545  Assert( static_cast<bool>( object ), "put():: Invalid 'Object'!" );
546  Assert( !location.empty(), "put():: Invalid 'address' = '' " );
547  // final data location
548  const std::string& fullLocation = fullTESLocation( location, useRootInTES );
549  // register the object!
550  const StatusCode status = '/' == fullLocation[0] ? svc->registerObject( fullLocation, object.get() )
551  : svc->registerObject( "/Event/" + fullLocation, object.get() );
552  // check the result!
553  if ( status.isFailure() ) {
554  Exception( "put():: could not register '" + System::typeinfoName( typeid( *object ) ) + "' at address '" +
555  fullLocation + "'",
556  status );
557  }
558  if ( this->msgLevel( MSG::DEBUG ) ) {
559  Print( "The object of type '" + System::typeinfoName( typeid( *object ) ) + "' is registered in TS at address '" +
560  fullLocation + "'",
561  status, MSG::DEBUG )
562  .ignore();
563  }
564  // if we get here, ownership has been transferred to the IDataProviderSvc
565  return object.release();
566 }
T empty(T...args)
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:309
bool isFailure() const
Definition: StatusCode.h:130
STL class.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
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.
StatusCode registerObject(boost::string_ref fullPath, DataObject *pObject)
Register object with the data store.
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
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.
const std::string fullTESLocation(const std::string &location, const bool useRootInTES) const
Returns the full correct event location given the rootInTes settings.
void Exception(const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
Create and (re)-throw a given GaudiException.
template<class PBASE>
DataObject* GaudiCommon< PBASE >::put ( IDataProviderSvc svc,
DataObject object,
const std::string location,
const bool  useRootInTES = true 
) const
inline

Definition at line 266 of file GaudiCommon.h.

267  {
268  return put( svc, std::unique_ptr<DataObject>( object ), location, useRootInTES );
269  }
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.
STL class.
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
conditionthe path inside the Transient Detector Store to the condition object.
mfoptional pointer to the member function to call when the condition object is updated. If the pointer is omitted the user must explicitly provide the class name to the method.
StatusCode MyAlg::initialize(){
// ...
registerCondition("/dd/Conditions/Readout/MyDet/MyCond",&MyAlg::i_CallBack);
registerCondition<MyAlg>("/dd/Conditions/Readout/MyDet/MyOtherCond");
// ...
}

Definition at line 564 of file GaudiCommon.h.

564  {
565  updMgrSvc()->registerCondition( dynamic_cast<CallerClass*>( this ), condition, mf );
566  }
IUpdateManagerSvc * updMgrSvc() const
Short-cut to locate the Update Manager Service.
void registerCondition(CallerClass *instance, const std::string &condition="", typename ObjectMemberFunction< CallerClass >::MemberFunctionType mf=nullptr)
Register an object (algorithm instance) to the service.
template<class PBASE>
template<class CallerClass , class CondType >
void GaudiCommon< PBASE >::registerCondition ( const std::string condition,
CondType *&  condPtrDest,
StatusCode(CallerClass::*)()  mf = NULL 
)
inline

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

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

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

Definition at line 598 of file GaudiCommon.h.

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

604  {
605  updMgrSvc()->registerCondition( dynamic_cast<CallerClass*>( this ), std::string( condition ), mf );
606  }
IUpdateManagerSvc * updMgrSvc() const
Short-cut to locate the Update Manager Service.
STL class.
void registerCondition(CallerClass *instance, const std::string &condition="", typename ObjectMemberFunction< CallerClass >::MemberFunctionType mf=nullptr)
Register an object (algorithm instance) to the service.
template<class PBASE>
template<class CallerClass , class TargetClass >
void GaudiCommon< PBASE >::registerCondition ( TargetClass *  condition,
StatusCode(CallerClass::*)()  mf = NULL 
)
inline

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

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

Definition at line 623 of file GaudiCommon.h.

623  {
624  updMgrSvc()->registerCondition( dynamic_cast<CallerClass*>( this ), condition, mf );
625  }
IUpdateManagerSvc * updMgrSvc() const
Short-cut to locate the Update Manager Service.
void registerCondition(CallerClass *instance, const std::string &condition="", typename ObjectMemberFunction< CallerClass >::MemberFunctionType mf=nullptr)
Register an object (algorithm instance) to the service.
template<class PBASE >
StatusCode GaudiCommon< PBASE >::release ( const IInterface interface) const

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

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

Definition at line 261 of file GaudiCommon.icpp.

261  {
262  if ( !interface ) { return Error( "release(IInterface):: IInterface* points to NULL!" ); }
263  // dispatch between tools and services
264  const IAlgTool* algTool = dynamic_cast<const IAlgTool*>( interface );
265  // perform the actual release
266  return algTool ? releaseTool( algTool ) : releaseSvc( interface );
267 }
StatusCode releaseSvc(const IInterface *svc) const
manual forced (and &#39;safe&#39;) release of the service
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.
StatusCode releaseTool(const IAlgTool *tool) const
manual forced (and &#39;safe&#39;) release of the tool
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 302 of file GaudiCommon.icpp.

302  {
303  if ( !Svc ) return Error( "releaseSvc(IInterface):: IInterface* points to NULL!" );
304  SmartIF<IService> svc{const_cast<IInterface*>( Svc )};
305  if ( !svc ) return Warning( "releaseSvc(IInterface):: IInterface* is not a service" );
307  if ( it == m_services.end() || !GaudiCommon_details::svc_eq( *it, svc ) ) {
308  return Warning( "releaseSvc(IInterface):: IInterface* is not active" );
309  }
310  if ( this->msgLevel( MSG::DEBUG ) ) { this->debug() << "Releasing service '" << ( *it )->name() << "'" << endmsg; }
311  m_services.erase( it );
312  return StatusCode::SUCCESS;
313 }
constexpr const struct GaudiCommon_details::svc_eq_t svc_eq
Services m_services
List of active services.
Definition: GaudiCommon.h:730
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.
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
T end(T...args)
T lower_bound(T...args)
constexpr const struct GaudiCommon_details::svc_lt_t svc_lt
Definition of the basic interface.
Definition: IInterface.h:244
T erase(T...args)
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.
T begin(T...args)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
template<class PBASE >
StatusCode GaudiCommon< PBASE >::releaseTool ( const IAlgTool tool) const
protected

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

Definition at line 274 of file GaudiCommon.icpp.

274  {
275  if ( !algTool ) { return Error( "releaseTool(IAlgTool):: IAlgTool* points to NULL!" ); }
276  if ( !this->toolSvc() ) { return Error( "releaseTool(IAlgTool):: IToolSvc* points to NULL!" ); }
277  // find a tool in the list of active tools
278  auto it = std::find( m_managedTools.begin(), m_managedTools.end(), algTool );
279  if ( m_managedTools.end() == it ) { return Warning( "releaseTool(IAlgTool):: IAlgTool* is not active" ); }
280  // get the tool
281  IAlgTool* t = *it;
282  // cache name
283  const std::string name = t->name();
284  if ( this->msgLevel( MSG::DEBUG ) ) { this->debug() << "Releasing tool '" << name << "'" << endmsg; }
285  // remove the tool from the lists
286  PBASE::deregisterTool( t );
287  m_managedTools.erase( it );
288  // release tool
289  if ( this->msgLevel( MSG::DEBUG ) ) {
290  this->debug() << "The tool '" << t->name() << "' of type '" << System::typeinfoName( typeid( *t ) )
291  << "' is released" << endmsg;
292  }
293  const StatusCode sc = this->toolSvc()->releaseTool( t );
294  return sc.isSuccess() ? sc : Warning( "releaseTool(IAlgTool):: error from IToolSvc releasing " + name, sc );
295 }
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:309
bool isSuccess() const
Definition: StatusCode.h:267
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.
T end(T...args)
STL class.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
T erase(T...args)
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.
T find(T...args)
T begin(T...args)
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
AlgTools m_managedTools
List of active tools.
Definition: GaudiCommon.h:728
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
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 712 of file GaudiCommon.h.

712 { return m_rootInTES; }
Gaudi::Property< std::string > m_rootInTES
Definition: GaudiCommon.h:780
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 637 of file GaudiCommon.h.

637 { return updMgrSvc()->update( this ); }
IUpdateManagerSvc * updMgrSvc() const
Short-cut to locate the Update Manager Service.
StatusCode update(CallerClass *instance)
Update the given instance.
template<class PBASE>
const Services& GaudiCommon< PBASE >::services ( ) const
inline

get the list of aquired services

Definition at line 703 of file GaudiCommon.h.

703 { return m_services; } // get all services
Services m_services
List of active services.
Definition: GaudiCommon.h:730
template<class PBASE>
bool GaudiCommon< PBASE >::statPrint ( ) const
inline

Print statistical counters at finalization ?

Definition at line 528 of file GaudiCommon.h.

528 { return m_statPrint; }
Gaudi::Property< bool > m_statPrint
Definition: GaudiCommon.h:767
template<class PBASE >
template<class SERVICE >
SmartIF< SERVICE > GaudiCommon< PBASE >::svc ( const std::string name,
const bool  create = true 
) const
inline

A useful method for the easy location of services.

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

Definition at line 145 of file GaudiCommonImp.h.

145  {
146  Assert( this->svcLoc(), "ISvcLocator* points to NULL!" );
148  // check if we already have this service
150  if ( it != std::end( m_services ) && GaudiCommon_details::svc_eq( *it, name ) ) {
151  // Try to get the requested interface
152  s = *it;
153  // check the results
154  if ( !s ) { Exception( "svc():: Could not retrieve Svc '" + name + "'", StatusCode::FAILURE ); }
155  } else {
156  auto baseSvc = this->svcLoc()->service( name, create );
157  // Try to get the requested interface
158  s = baseSvc;
159  // check the results
160  if ( !baseSvc || !s ) { Exception( "svc():: Could not retrieve Svc '" + name + "'", StatusCode::FAILURE ); }
161  // add the tool into list of known tools, to be properly released
162  addToServiceList( baseSvc );
163  }
164  // return *VALID* located service
165  return s;
166 }
Small smart pointer class with automatic reference counting for IInterface.
Definition: IConverter.h:15
void addToServiceList(SmartIF< IService > svc) const
Add the given service to the list of acquired services.
constexpr const struct GaudiCommon_details::svc_eq_t svc_eq
Services m_services
List of active services.
Definition: GaudiCommon.h:730
T end(T...args)
T lower_bound(T...args)
constexpr const struct GaudiCommon_details::svc_lt_t svc_lt
T begin(T...args)
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.
string s
Definition: gaudirun.py:312
constexpr static const auto FAILURE
Definition: StatusCode.h:86
void Exception(const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
Create and (re)-throw a given GaudiException.
template<class PBASE >
template<class TOOL >
TOOL * GaudiCommon< PBASE >::tool ( const std::string type,
const std::string name,
const IInterface parent = 0,
bool  create = true 
) const
inline

Useful method for the easy location of tools.

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

Definition at line 105 of file GaudiCommonImp.h.

106  {
107  // for empty names delegate to another method
108  if ( name.empty() ) return tool<TOOL>( type, parent, create );
109  Assert( this->toolSvc(), "tool():: IToolSvc* points to NULL!" );
110  // get the tool from Tool Service
111  TOOL* Tool = nullptr;
112  const StatusCode sc = this->toolSvc()->retrieveTool( type, name, Tool, parent, create );
113  if ( sc.isFailure() ) { Exception( "tool():: Could not retrieve Tool '" + type + "'/'" + name + "'", sc ); }
114  if ( !Tool ) { Exception( "tool():: Could not retrieve Tool '" + type + "'/'" + name + "'" ); }
115  // insert tool into list of tools
116  PBASE::registerTool( Tool );
117  m_managedTools.push_back( Tool );
118  // return *VALID* located tool
119  return Tool;
120 }
T empty(T...args)
bool isFailure() const
Definition: StatusCode.h:130
T push_back(T...args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
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.
AlgTools m_managedTools
List of active tools.
Definition: GaudiCommon.h:728
void Exception(const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
Create and (re)-throw a given GaudiException.
template<class PBASE >
template<class TOOL >
TOOL * GaudiCommon< PBASE >::tool ( const std::string type,
const IInterface parent = 0,
bool  create = true 
) const
inline

A useful method for the easy location of tools.

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

Definition at line 126 of file GaudiCommonImp.h.

126  {
127  // check the environment
128  Assert( PBASE::toolSvc(), "IToolSvc* points to NULL!" );
129  // retrieve the tool from Tool Service
130  TOOL* Tool = nullptr;
131  const StatusCode sc = this->toolSvc()->retrieveTool( type, Tool, parent, create );
132  if ( sc.isFailure() ) { Exception( "tool():: Could not retrieve Tool '" + type + "'", sc ); }
133  if ( !Tool ) { Exception( "tool():: Could not retrieve Tool '" + type + "'" ); }
134  // add the tool into the list of known tools to be properly released
135  PBASE::registerTool( Tool );
136  m_managedTools.push_back( Tool );
137  // return *VALID* located tool
138  return Tool;
139 }
bool isFailure() const
Definition: StatusCode.h:130
T push_back(T...args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
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.
AlgTools m_managedTools
List of active tools.
Definition: GaudiCommon.h:728
void Exception(const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
Create and (re)-throw a given GaudiException.
template<class PBASE>
bool GaudiCommon< PBASE >::typePrint ( ) const
inline

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

Definition at line 524 of file GaudiCommon.h.

524 { return m_typePrint; }
Gaudi::Property< bool > m_typePrint
Definition: GaudiCommon.h:777
template<class PBASE >
IUpdateManagerSvc * GaudiCommon< PBASE >::updMgrSvc ( ) const
inline

Short-cut to locate the Update Manager Service.

Definition at line 171 of file GaudiCommonImp.h.

171  {
172  if ( !m_updMgrSvc ) { m_updMgrSvc = svc<IUpdateManagerSvc>( "UpdateManagerSvc", true ); }
173  return m_updMgrSvc;
174 }
IUpdateManagerSvc * m_updMgrSvc
Pointer to the Update Manager Service instance.
Definition: GaudiCommon.h:746
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
msgWarning message
stStatusCode to return
mxMaximum number of printouts for this message
Returns
The given StatusCode

Definition at line 360 of file GaudiCommon.icpp.

360  {
361  // increase local counter of warnings
362  const size_t num = ++m_warnings[msg];
363  // If suppressed, just return
364  if ( num > mx ) {
365  return st;
366  } else if ( UNLIKELY( num == mx ) ) // issue one-time suppression message
367  {
368  return Print( "The WARNING message is suppressed : '" + msg + "'", st, MSG::WARNING );
369  }
370  // return message
371  return Print( msg, st, MSG::WARNING );
372 }
Counter m_warnings
counter of warnings
Definition: GaudiCommon.h:735
#define UNLIKELY(x)
Definition: Kernel.h:89
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.

Member Data Documentation

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

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

If used with cause the RootInTES option to be IGNORED.

Useful to aid with code readability. e.g.

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

Definition at line 105 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 779 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 795 of file GaudiCommon.h.

template<class PBASE>
StatisticsOwn GaudiCommon< PBASE >::m_countersOwn
private

General counters.

Definition at line 741 of file GaudiCommon.h.

template<class PBASE>
std::mutex GaudiCommon< PBASE >::m_countersOwnMutex
private

The mutex for m_countersOwn.

Definition at line 743 of file GaudiCommon.h.

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

a pointer to the CounterSummarySvc

Definition at line 134 of file GaudiCommon.h.

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

Counter of errors.

Definition at line 733 of file GaudiCommon.h.

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

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

Counter of exceptions.

Definition at line 739 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 785 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 788 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 781 of file GaudiCommon.h.

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

counter of infos

Definition at line 737 of file GaudiCommon.h.

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

List of active tools.

Definition at line 728 of file GaudiCommon.h.

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

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() ) {
}
},
"print the properties of the component"}

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

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

List of active services.

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

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() ) {
}
},
"print the table of counters"}

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

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

Pointer to the Update Manager Service instance.

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

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

counter of warnings

Definition at line 735 of file GaudiCommon.h.

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

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

If used with cause the RootInTES option to be USED

Useful to aid with code readability. e.g.

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

Definition at line 117 of file GaudiCommon.h.


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