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, DataObject *object, const std::string &location, const bool useRootInTES=true) const
 Register a data object or container into Gaudi Event Transient Store. More...
 
template<class TOOL >
TOOL * tool (const std::string &type, const std::string &name, const IInterface *parent=0, bool create=true) const
 Useful method for the easy location of tools. More...
 
template<class TOOL >
TOOL * tool (const std::string &type, const IInterface *parent=0, bool create=true) const
 A useful method for the easy location of tools. More...
 
template<class SERVICE >
SmartIF< SERVICE > svc (const std::string &name, const bool create=true) const
 A useful method for the easy location of services. More...
 
IUpdateManagerSvcupdMgrSvc () const
 Short-cut to locate the Update Manager Service. More...
 
StatusCode Error (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
 Print the error message and return with the given StatusCode. More...
 
StatusCode Warning (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
 Print the warning message and return with the given StatusCode. More...
 
StatusCode Info (const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const size_t mx=10) const
 Print the info message and return with the given StatusCode. More...
 
StatusCode Print (const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const MSG::Level lev=MSG::INFO) const
 Print the message and return with the given StatusCode. More...
 
void Assert (const bool ok, const std::string &message="", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Assertion - throw exception if the given condition is not fulfilled. More...
 
void Assert (const bool ok, const char *message, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Assertion - throw exception if the given condition is not fulfilled. More...
 
void Exception (const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Create and (re)-throw a given GaudiException. More...
 
void Exception (const std::string &msg, const std::exception &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Create and (re)-throw a given exception. More...
 
void Exception (const std::string &msg="no message", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
 Create and throw an exception with the given message. More...
 
const Statisticscounters () const
 accessor to all counters More...
 
StatEntitycounter (const std::string &tag) const
 accessor to certain counter by name More...
 
bool typePrint () const
 Insert the actual C++ type of the algorithm/tool in the messages ? More...
 
bool propsPrint () const
 Print properties at initialization ? More...
 
bool statPrint () const
 Print statistical counters at finalization ? More...
 
bool errorsPrint () const
 Print error counters at finalization ? More...
 
long printStat (const MSG::Level level=MSG::ALWAYS) const
 perform the actual printout of statistical counters More...
 
long printErrors (const MSG::Level level=MSG::ALWAYS) const
 perform the actual printout of error counters More...
 
long printProps (const MSG::Level level=MSG::ALWAYS) const
 perform the actual printout of properties More...
 
template<class CallerClass >
void registerCondition (const std::string &condition, StatusCode(CallerClass::*mf)()=nullptr)
 register the current instance to the UpdateManagerSvc as a consumer for a condition. More...
 
template<class CallerClass , class CondType >
void registerCondition (const std::string &condition, CondType *&condPtrDest, StatusCode(CallerClass::*mf)()=NULL)
 register the current instance to the UpdateManagerSvc as a consumer for a condition. More...
 
template<class CallerClass >
void registerCondition (char *condition, StatusCode(CallerClass::*mf)()=NULL)
 just to avoid conflicts with the version using a pointer to a template class. More...
 
template<class CallerClass , class TargetClass >
void registerCondition (TargetClass *condition, StatusCode(CallerClass::*mf)()=NULL)
 register the current instance to the UpdateManagerSvc as a consumer for a condition. More...
 
StatusCode runUpdate ()
 asks the UpdateManagerSvc to perform an update of the instance (if needed) without waiting the next BeginEvent incident. More...
 
 GaudiCommon (const std::string &name, ISvcLocator *pSvcLocator)
 Algorithm constructor. More...
 
 GaudiCommon (const std::string &type, const std::string &name, const IInterface *parent)
 Tool constructor. 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, StatEntityStatistics
 the actual type of general counters More...
 
typedef std::map< std::string, unsigned int > Counter
 the actual type error/warning counter More...
 
typedef std::vector< IAlgTool * > AlgTools
 storage for active tools More...
 
typedef std::vector< SmartIF< IService > > Services
 storage for active services More...
 

Protected Member Functions

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

Protected Attributes

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

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

Private Attributes

AlgTools m_managedTools
 List of active tools. More...
 
Services m_services
 List of active services. More...
 
Counter m_errors
 Counter of errors. More...
 
Counter m_warnings
 counter of warnings More...
 
Counter m_infos
 counter of infos More...
 
Counter m_exceptions
 Counter of exceptions. More...
 
Statistics m_counters
 General counters. More...
 
IUpdateManagerSvcm_updMgrSvc = nullptr
 Pointer to the Update Manager Service instance. More...
 
Gaudi::Property< bool > m_errorsPrint {this, "ErrorsPrint", true, "print the statistics of errors/warnings/exceptions"}
 
Gaudi::Property< bool > m_propsPrint {this, "PropertiesPrint", false, "print the properties of the component"}
 
Gaudi::Property< bool > m_statPrint {this, "StatPrint", true, "print the table of counters"}
 
Gaudi::Property< bool > m_typePrint {this, "TypePrint", true, "add the actual C++ component type into the messages"}
 
Gaudi::Property< std::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 80 of file GaudiCommon.h.

Member Typedef Documentation

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

storage for active tools

Definition at line 115 of file GaudiCommon.h.

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

Definition at line 83 of file GaudiCommon.h.

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

the actual type error/warning counter

Definition at line 113 of file GaudiCommon.h.

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

storage for active services

Definition at line 117 of file GaudiCommon.h.

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

the actual type of general counters

Definition at line 111 of file GaudiCommon.h.

Constructor & Destructor Documentation

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

Algorithm constructor.

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

Tool constructor.

template<class PBASE>
GaudiCommon< PBASE >::~GaudiCommon ( )
overrideprotecteddefault

Destructor.

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

360 {
361  if ( svc ) {
363  if ( i == std::end( m_services ) || !GaudiCommon_details::svc_eq( *i, svc ) ) {
364  m_services.insert( i, std::move( svc ) );
365  } else {
366  this->warning() << "Service " << svc->name() << " already present -- skipping" << endmsg;
367  }
368  }
369 }
constexpr const struct GaudiCommon_details::svc_eq_t svc_eq
Services m_services
List of active services.
Definition: GaudiCommon.h:714
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:244
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 224 of file GaudiCommonImp.h.

227 {
228  if (!ok) Exception( msg , sc );
229 }
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 234 of file GaudiCommonImp.h.

237 {
238  if (!ok) Exception( msg , sc );
239 }
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 692 of file GaudiCommon.h.

692 { return m_context; }
Gaudi::Property< std::string > m_context
Definition: GaudiCommon.h:736
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 484 of file GaudiCommon.h.

484 { return m_counters[tag]; }
Statistics m_counters
General counters.
Definition: GaudiCommon.h:725
template<class PBASE>
const Statistics& GaudiCommon< PBASE >::counters ( ) const
inline

accessor to all counters

Definition at line 465 of file GaudiCommon.h.

465 { return m_counters; }
Statistics m_counters
General counters.
Definition: GaudiCommon.h:725
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 380 of file GaudiCommon.icpp.

381 {
382  // increase local counter of errors
383  const size_t num = ++m_errors[msg];
384  // If suppressed, just return
385  if ( num > mx ) {
386  return st;
387  } else if ( UNLIKELY( num == mx ) ) // issue one-time suppression message
388  {
389  return Print( "The ERROR message is suppressed : '" + msg + "'", st, MSG::ERROR );
390  }
391  // return message
392  return Print( msg, st, MSG::ERROR );
393 }
#define UNLIKELY(x)
Definition: Kernel.h:126
Counter m_errors
Counter of errors.
Definition: GaudiCommon.h:717
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 494 of file GaudiCommon.h.

494 { return m_errorsPrint; }
Gaudi::Property< bool > m_errorsPrint
Definition: GaudiCommon.h:731
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 476 of file GaudiCommon.icpp.

477 {
478  // increase local counter of exceptions
479  ++m_exceptions[msg];
480  Print( "Exception (re)throw: " + msg, sc, MSG::FATAL ).ignore();
481  throw GaudiException( this->name() + ":: " + msg, this->name(), sc, exc );
482 }
Define general base for Gaudi exception.
Counter m_exceptions
Counter of exceptions.
Definition: GaudiCommon.h:723
StatusCode Print(const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const MSG::Level lev=MSG::INFO) const
Print the message and return with the given StatusCode.
void ignore() const
Definition: StatusCode.h:106
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 489 of file GaudiCommon.icpp.

490 {
491  // increase local counter of exceptions
492  ++m_exceptions[msg];
493  Print( "Exception (re)throw: " + msg, sc, MSG::FATAL ).ignore();
494  throw GaudiException( this->name() + ":: " + msg + "(" + exc.what() + ")", "", sc );
495 }
Define general base for Gaudi exception.
Counter m_exceptions
Counter of exceptions.
Definition: GaudiCommon.h:723
T what(T...args)
StatusCode Print(const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const MSG::Level lev=MSG::INFO) const
Print the message and return with the given StatusCode.
void ignore() const
Definition: StatusCode.h:106
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 502 of file GaudiCommon.icpp.

503 {
504  // increase local counter of exceptions
505  ++m_exceptions[msg];
506  Print( "Exception throw: " + msg, sc, MSG::FATAL ).ignore();
507  throw GaudiException( this->name() + ":: " + msg, "", sc );
508 }
Define general base for Gaudi exception.
Counter m_exceptions
Counter of exceptions.
Definition: GaudiCommon.h:723
StatusCode Print(const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const MSG::Level lev=MSG::INFO) const
Print the message and return with the given StatusCode.
void ignore() const
Definition: StatusCode.h:106
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 92 of file GaudiCommonImp.h.

95 {
96  // check the environment
97  Assert( service , "exist():: IDataProvider* points to NULL!" ) ;
98  // check the data object
100  return checker ( service,
101  fullTESLocation ( location , useRootInTES ) ) ;
102 }
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 205 of file GaudiCommon.icpp.

206 {
208 
209  // print the general information about statistical counters
210  if ( this->msgLevel( MSG::DEBUG ) || ( statPrint() && !counters().empty() ) ) {
211  // print general statistical counters
213  }
214  // add all counters to the CounterSummarySvc
215  if ( m_counterSummarySvc && this->svcLoc()->existsService( "CounterSummarySvc" ) ) {
216  if ( this->msgLevel( MSG::DEBUG ) ) this->debug() << "adding counters to CounterSummarySvc" << endmsg;
217 
219  Gaudi::Utils::RegEx::matchList counterList{m_counterList.value()};
220 
221  for ( const auto& i : this->counters() ) {
222  if ( statList.Or( i.first ) )
223  m_counterSummarySvc->addCounter( this->name(), i.first, i.second, Gaudi::CounterSummary::SaveStatEntity );
224  else if ( counterList.Or( i.first ) )
225  m_counterSummarySvc->addCounter( this->name(), i.first, i.second );
226  }
227  }
228  // release all located tools and services
229  if ( this->msgLevel( MSG::DEBUG ) ) {
230  this->debug() << "Tools to release :";
231  for ( const auto& i : m_managedTools ) {
232  this->debug() << " " << i->name();
233  }
234  this->debug() << endmsg;
235  }
236  while ( !m_managedTools.empty() ) {
237  sc = releaseTool( m_managedTools.back() ) && sc;
238  }
239 
240  // release all located services
241  if ( this->msgLevel( MSG::DEBUG ) ) {
242  this->debug() << "Services to release :";
243  for ( const auto& i : m_services ) this->debug() << " " << i->name();
244  this->debug() << endmsg;
245  }
246  while ( !m_services.empty() ) {
247  sc = releaseSvc( m_services.front() ) && sc;
248  }
249 
250  // release the CounterSummarySvc manually
252 
253  // format printout
254  if ( !m_errors.empty() || !m_warnings.empty() || !m_exceptions.empty() ) {
255  this->always() << "Exceptions/Errors/Warnings/Infos Statistics : " << m_exceptions.size() << "/" << m_errors.size()
256  << "/" << m_warnings.size() << "/" << m_infos.size() << endmsg;
257  if ( errorsPrint() ) {
258  printErrors();
259  }
260  }
261 
262  // clear *ALL* counters explicitly
263  m_counters.clear();
265  m_infos.clear();
266  m_warnings.clear();
267  m_errors.clear();
268  m_counterList.clear();
269  m_statEntityList.clear();
270 
271  // finalize base class
272  return sc && PBASE::finalize();
273 }
Counter m_warnings
counter of warnings
Definition: GaudiCommon.h:719
T empty(T...args)
Counter m_exceptions
Counter of exceptions.
Definition: GaudiCommon.h:723
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:714
Statistics m_counters
General counters.
Definition: GaudiCommon.h:725
const Statistics & counters() const
accessor to all counters
Definition: GaudiCommon.h:465
Gaudi::Property< std::vector< std::string > > m_counterList
Definition: GaudiCommon.h:753
bool statPrint() const
Print statistical counters at finalization ?
Definition: GaudiCommon.h:492
Counter m_errors
Counter of errors.
Definition: GaudiCommon.h:717
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
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:721
bool errorsPrint() const
Print error counters at finalization ?
Definition: GaudiCommon.h:494
SmartIF< ICounterSummarySvc > m_counterSummarySvc
a pointer to the CounterSummarySvc
Definition: GaudiCommon.h:122
T clear(T...args)
T size(T...args)
StatusCode releaseTool(const IAlgTool *tool) const
manual forced (and &#39;safe&#39;) release of the tool
AlgTools m_managedTools
List of active tools.
Definition: GaudiCommon.h:712
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:88
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:244
Gaudi::Property< std::vector< std::string > > m_statEntityList
Definition: GaudiCommon.h:755
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 25 of file GaudiCommonImp.h.

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

59 {
60  // check the environment
61  Assert( service , "get():: IDataProvider* points to NULL!" ) ;
62  // get the helper object:
64  return getter ( *this ,
65  service ,
66  fullTESLocation ( location , useRootInTES ) ) ;
67 }
Helper structure for implementation of "get"-functions for GaudiCommon<BASE>
Definition: GaudiCommon.h:41
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 74 of file GaudiCommonImp.h.

77 {
78  // check the environment
79  Assert( service , "get():: IDataProvider* points to NULL!" ) ;
80  // get the helper object:
82  return getter ( *this ,
83  service ,
84  fullTESLocation ( location , useRootInTES ),
85  false) ;
86 }
Helper structure for implementation of "get"-functions for GaudiCommon<BASE>
Definition: GaudiCommon.h:41
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 111 of file GaudiCommonImp.h.

114 {
115  // check the environment
116  Assert ( service , "getOrCreate():: svc points to NULL!" ) ;
117  // get the helper object
119  return getter ( *this ,
120  service ,
121  fullTESLocation( location, useRootInTES ) ,
122  location ) ;
123 }
Helper structure for implementation of "getOrCreate"-functions for GaudiCommon<BASE> ...
Definition: GetData.h:402
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 420 of file GaudiCommon.icpp.

421 {
422  // increase local counter of warnings
423  const size_t num = ++m_infos[msg];
424  // If suppressed, just return
425  if ( num > mx ) {
426  return st;
427  } else if ( UNLIKELY( num == mx ) ) // issue one-time suppression message
428  {
429  return Print( "The INFO message is suppressed : '" + msg + "'", st, MSG::INFO );
430  }
431  // return message
432  return Print( msg, st, MSG::INFO );
433 }
#define UNLIKELY(x)
Definition: Kernel.h:126
Counter m_infos
counter of infos
Definition: GaudiCommon.h:721
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 = 0)
private

Constructor initializations.

Definition at line 63 of file GaudiCommon.icpp.

64 {
65  m_errorsPrint.declareUpdateHandler( &GaudiCommon<PBASE>::printErrorHandler, this );
66  m_propsPrint.declareUpdateHandler( &GaudiCommon<PBASE>::printPropsHandler, this );
67  m_statPrint.declareUpdateHandler( &GaudiCommon<PBASE>::printStatHandler, this );
68 
69  // setup context from parent if available
70  if ( parent ) {
71  if ( const GaudiAlgorithm* gAlg = dynamic_cast<const GaudiAlgorithm*>( parent ) ) {
72  m_context = gAlg->context();
73  m_rootInTES = gAlg->rootInTES();
74  } else if ( const GaudiTool* gTool = dynamic_cast<const GaudiTool*>( parent ) ) {
75  m_context = gTool->context();
76  m_rootInTES = gTool->rootInTES();
77  }
78  }
79 
80  // Get the job option service
81  SmartIF<IJobOptionsSvc> jos( PBASE::service( "JobOptionsSvc" ) );
82  if ( !jos.isValid() ) Exception( "Cannot get JobOptionsSvc" );
83 
84  // Get the "Context" option if in the file...
85  const auto myList = jos->getProperties( this->name() );
86  if ( myList ) {
87  // Iterate over the list to set the options
88  for ( const auto& iter : *myList ) {
89  const Gaudi::Property<std::string>* sp = dynamic_cast<const Gaudi::Property<std::string>*>( iter );
90  if ( sp ) {
91  if ( iter->name().compare( "Context" ) == 0 ) {
92  m_context = sp->value();
93  } else if ( iter->name().compare( "RootInTES" ) == 0 ) {
94  m_rootInTES = sp->value();
95  }
96  }
97  }
98  }
99 }
Gaudi::Property< std::string > m_rootInTES
Definition: GaudiCommon.h:737
Implementation of property with value of concrete type.
Definition: Property.h:313
Gaudi::Property< bool > m_errorsPrint
Definition: GaudiCommon.h:731
The useful base class for data processing algorithms.
Gaudi::Property< bool > m_statPrint
Definition: GaudiCommon.h:733
Gaudi::Property< bool > m_propsPrint
Definition: GaudiCommon.h:732
Gaudi::Property< std::string > m_context
Definition: GaudiCommon.h:736
The useful base class for tools.
Definition: GaudiTool.h:101
Implements the common functionality between GaudiTools and GaudiAlgorithms.
Definition: GaudiCommon.h:80
const ValueType & value() const
Backward compatibility (.
Definition: Property.h:462
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 112 of file GaudiCommon.icpp.

113 {
114 
115  // initialize base class
116  const StatusCode sc = PBASE::initialize();
117  if ( sc.isFailure() ) {
118  return Error( "Failed to initialise base class PBASE", sc );
119  }
120 
121  // some debug printout
122  if ( this->msgLevel( MSG::DEBUG ) ) {
123  this->debug() << "Initialize base class GaudiCommon<" << System::typeinfoName( typeid( PBASE ) ) << ">" << endmsg;
124  if ( !context().empty() ) this->debug() << "Created with context = '" << context() << "'" << endmsg;
125  }
126 
127  // Check rootInTES ends with a /
128  if ( !m_rootInTES.empty() && m_rootInTES[m_rootInTES.size() - 1] != '/' ) m_rootInTES = m_rootInTES + "/";
129 
130  // Set up the CounterSummarySvc May need to be changed
131  m_counterSummarySvc = this->svcLoc()->service( "CounterSummarySvc", false );
132  if ( this->msgLevel( MSG::DEBUG ) ) {
133  if ( !m_counterSummarySvc )
134  this->debug() << "could not locate CounterSummarySvc, no counter summary will be made" << endmsg;
135  else
136  this->debug() << "found CounterSummarySvc OK" << endmsg;
137  }
138 
139  // properties will be printed if asked for or in "MSG::DEBUG" mode
140  if ( propsPrint() ) {
142  } else if ( this->msgLevel( MSG::DEBUG ) ) {
144  }
145 
146  // update DataHandles to point to full TES location
147 
148  // get root of DataManager
149  SmartIF<IDataManagerSvc> dataMgrSvc( PBASE::evtSvc() );
150  std::string rootName( dataMgrSvc->rootName() );
151  if ( "" != rootName && '/' != rootName[rootName.size() - 1] ) {
152  rootName = rootName + "/";
153  }
154 
155  auto fixLocation = [this, rootName]( const std::string& location ) -> std::string {
157  // check whether we have an absolute path if yes return it - else prepend DataManager Root
158  result = ( result[0] == '/' ? result : rootName + result );
159 
160  if ( result != location && this->msgLevel( MSG::DEBUG ) )
161  this->debug() << "Changing " << location << " to " << result << endmsg;
162 
163  return result;
164  };
165 
166  class DHHFixer : public IDataHandleVisitor
167  {
168  public:
169  DHHFixer( std::function<std::string( const std::string& )> f ) : m_f( f ) {}
170  void visit( const IDataHandleHolder* idhh ) override
171  {
172  if ( idhh == 0 ) return;
173 
174  std::string r;
175  for ( auto h : idhh->inputHandles() ) {
176  r = m_f( h->objKey() );
177  if ( r != h->objKey() ) h->updateKey( r );
178  }
179  for ( auto h : idhh->outputHandles() ) {
180  r = m_f( h->objKey() );
181  if ( r != h->objKey() ) h->updateKey( r );
182  }
183  }
184 
185  private:
187  };
188 
189  this->m_updateDataHandles.reset( new DHHFixer( fixLocation ) );
190 
191  return sc;
192 }
Gaudi::Property< std::string > m_rootInTES
Definition: GaudiCommon.h:737
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:299
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.
const std::string & context() const
Returns the "context" string. Used to identify different processing states.
Definition: GaudiCommon.h:692
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:84
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:26
bool propsPrint() const
Print properties at initialization ?
Definition: GaudiCommon.h:490
static const bool UseRootInTES
Simple definition to be used with the new useRootInTES argument get<TYPE> and put methods...
Definition: GaudiCommon.h:106
SmartIF< ICounterSummarySvc > m_counterSummarySvc
a pointer to the CounterSummarySvc
Definition: GaudiCommon.h:122
const std::string fullTESLocation(const std::string &location, const bool useRootInTES) const
Returns the full correct event location given the rootInTes settings.
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:244
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 440 of file GaudiCommon.icpp.

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

handler for "ErrorPrint" property

Definition at line 626 of file GaudiCommon.icpp.

627 {
628  // no action if not yet initialized
629  if ( this->FSMState() < Gaudi::StateMachine::INITIALIZED ) {
630  return;
631  }
632  if ( this->errorsPrint() ) {
633  this->printErrors();
634  }
635 }
bool errorsPrint() const
Print error counters at finalization ?
Definition: GaudiCommon.h:494
long printErrors(const MSG::Level level=MSG::ALWAYS) const
perform the actual printout of error counters
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 544 of file GaudiCommon.icpp.

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

572 {
573 
574  // print ALL properties
575  MsgStream& msg = this->msgStream( level );
576  const auto& properties = this->getProperties();
577  msg << "List of ALL properties of " << System::typeinfoName( typeid( *this ) ) << "/" << this->name()
578  << " #properties = " << properties.size() << endmsg;
579  for ( const auto& property : reverse( properties ) ) {
580  msg << "Property ['Name': Value] = " << *property << endmsg;
581  }
582  return properties.size();
583 }
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:299
Gaudi::Details::PropertyBase * property(const std::string &name) const
reverse_wrapper< T > reverse(T &&iterable)
Definition: reverse.h:32
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:244
template<class PBASE >
void GaudiCommon< PBASE >::printPropsHandler ( Gaudi::Details::PropertyBase )
private

handler for "PropertiesPrint" property

Definition at line 640 of file GaudiCommon.icpp.

641 {
642  // no action if not yet initialized
643  if ( this->FSMState() < Gaudi::StateMachine::INITIALIZED ) {
644  return;
645  }
646  if ( this->propsPrint() ) {
647  this->printProps( MSG::ALWAYS );
648  }
649 }
bool propsPrint() const
Print properties at initialization ?
Definition: GaudiCommon.h:490
long printProps(const MSG::Level level=MSG::ALWAYS) const
perform the actual printout of properties
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 515 of file GaudiCommon.icpp.

516 {
517  // print statistics
518  if ( counters().empty() ) {
519  return 0;
520  }
521  MsgStream& msg = this->msgStream( level );
522  //
523  msg << "Number of counters : " << counters().size();
524  //
525  if ( !counters().empty() ) {
526  msg << std::endl << m_header.value();
527  }
528  //
529  for ( const auto& entry : counters() ) {
530  msg << std::endl
531  << Gaudi::Utils::formatAsTableRow( entry.first, entry.second, m_useEffFormat, m_format1, m_format2 );
532  }
533  //
534  msg << endmsg;
535  //
536  return counters().size();
537 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
T endl(T...args)
const Statistics & counters() const
accessor to all counters
Definition: GaudiCommon.h:465
Gaudi::Property< std::string > m_format2
Definition: GaudiCommon.h:746
Gaudi::Property< std::string > m_format1
Definition: GaudiCommon.h:743
GAUDI_API std::string formatAsTableRow(const StatEntity &counter, const bool flag, const std::string &format1=" |%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |", const std::string &format2="*|%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%| ----- | ----- |")
print the counter in a form of the table row
Definition: StatEntity.cpp:299
Gaudi::Property< bool > m_useEffFormat
Definition: GaudiCommon.h:750
Gaudi::Property< std::string > m_header
Definition: GaudiCommon.h:739
T size(T...args)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
template<class PBASE >
void GaudiCommon< PBASE >::printStatHandler ( Gaudi::Details::PropertyBase )
private

handler for "StatPrint" property

Definition at line 654 of file GaudiCommon.icpp.

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

Print properties at initialization ?

Definition at line 490 of file GaudiCommon.h.

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

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

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

Definition at line 594 of file GaudiCommon.icpp.

596 {
597  // check arguments
598  Assert( svc, "put():: Invalid 'service'!" );
599  Assert( object, "put():: Invalid 'Object'!" );
600  Assert( !location.empty(), "put():: Invalid 'address' = '' " );
601  // final data location
602  const std::string& fullLocation = fullTESLocation( location, useRootInTES );
603  // register the object!
604  const StatusCode status = '/' == fullLocation[0] ? svc->registerObject( fullLocation, object )
605  : svc->registerObject( "/Event/" + fullLocation, object );
606  // check the result!
607  if ( status.isFailure() ) {
608  Exception( "put():: could not register '" + System::typeinfoName( typeid( *object ) ) + "' at address '" +
609  fullLocation + "'",
610  status );
611  }
612  if ( this->msgLevel( MSG::DEBUG ) ) {
613  Print( "The object of type '" + System::typeinfoName( typeid( *object ) ) + "' is registered in TS at address '" +
614  fullLocation + "'",
615  status, MSG::DEBUG )
616  .ignore();
617  }
618  return object;
619 }
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:299
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:84
STL class.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode Print(const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const MSG::Level lev=MSG::INFO) const
Print the message and return with the given StatusCode.
void Assert(const bool ok, const std::string &message="", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
Assertion - throw exception if the given condition is not fulfilled.
const std::string fullTESLocation(const std::string &location, const bool useRootInTES) const
Returns the full correct event location given the rootInTes settings.
void ignore() const
Definition: StatusCode.h:106
virtual StatusCode registerObject(const std::string &fullPath, DataObject *pObject)=0
Register object with the data store.
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 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 528 of file GaudiCommon.h.

529  {
530  updMgrSvc()->registerCondition( dynamic_cast<CallerClass*>( this ), condition, mf );
531  }
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 563 of file GaudiCommon.h.

565  {
566  updMgrSvc()->registerCondition( dynamic_cast<CallerClass*>( this ), condition, mf, condPtrDest );
567  }
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 570 of file GaudiCommon.h.

571  {
572  updMgrSvc()->registerCondition( dynamic_cast<CallerClass*>( this ), std::string( condition ), mf );
573  }
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 590 of file GaudiCommon.h.

591  {
592  updMgrSvc()->registerCondition( dynamic_cast<CallerClass*>( this ), condition, mf );
593  }
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 284 of file GaudiCommon.icpp.

285 {
286  if ( !interface ) {
287  return Error( "release(IInterface):: IInterface* points to NULL!" );
288  }
289  // dispatch between tools and services
290  const IAlgTool* algTool = dynamic_cast<const IAlgTool*>( interface );
291  // perform the actual release
292  return algTool ? releaseTool( algTool ) : releaseSvc( interface );
293 }
StatusCode releaseSvc(const IInterface *svc) const
manual forced (and &#39;safe&#39;) release of the service
StatusCode Error(const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
Print the error message and return with the given StatusCode.
StatusCode 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 337 of file GaudiCommon.icpp.

338 {
339  if ( !Svc ) return Error( "releaseSvc(IInterface):: IInterface* points to NULL!" );
340  SmartIF<IService> svc{const_cast<IInterface*>( Svc )};
341  if ( !svc ) return Warning( "releaseSvc(IInterface):: IInterface* is not a service" );
343  if ( it == m_services.end() || !GaudiCommon_details::svc_eq( *it, svc ) ) {
344  return Warning( "releaseSvc(IInterface):: IInterface* is not active" );
345  }
346  if ( this->msgLevel( MSG::DEBUG ) ) {
347  this->debug() << "Releasing service '" << ( *it )->name() << "'" << endmsg;
348  }
349  m_services.erase( it );
350  return StatusCode::SUCCESS;
351 }
constexpr const struct GaudiCommon_details::svc_eq_t svc_eq
Services m_services
List of active services.
Definition: GaudiCommon.h:714
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)
T lower_bound(T...args)
constexpr const struct GaudiCommon_details::svc_lt_t svc_lt
Definition of the basic interface.
Definition: IInterface.h:234
T erase(T...args)
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:244
template<class PBASE >
StatusCode GaudiCommon< PBASE >::releaseTool ( const IAlgTool tool) const
protected

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

Definition at line 300 of file GaudiCommon.icpp.

301 {
302  if ( !algTool ) {
303  return Error( "releaseTool(IAlgTool):: IAlgTool* points to NULL!" );
304  }
305  if ( !this->toolSvc() ) {
306  return Error( "releaseTool(IAlgTool):: IToolSvc* points to NULL!" );
307  }
308  // find a tool in the list of active tools
309  auto it = std::find( m_managedTools.begin(), m_managedTools.end(), algTool );
310  if ( m_managedTools.end() == it ) {
311  return Warning( "releaseTool(IAlgTool):: IAlgTool* is not active" );
312  }
313  // get the tool
314  IAlgTool* t = *it;
315  // cache name
316  const std::string name = t->name();
317  if ( this->msgLevel( MSG::DEBUG ) ) {
318  this->debug() << "Releasing tool '" << name << "'" << endmsg;
319  }
320  // remove the tool from the lists
321  PBASE::deregisterTool( t );
322  m_managedTools.erase( it );
323  // release tool
324  if ( this->msgLevel( MSG::DEBUG ) ) {
325  this->debug() << "The tool '" << t->name() << "' of type '" << System::typeinfoName( typeid( *t ) )
326  << "' is released" << endmsg;
327  }
328  const StatusCode sc = this->toolSvc()->releaseTool( t );
329  return sc.isSuccess() ? sc : Warning( "releaseTool(IAlgTool):: error from IToolSvc releasing " + name, sc );
330 }
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:299
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
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:26
T erase(T...args)
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:712
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
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 696 of file GaudiCommon.h.

696 { return m_rootInTES; }
Gaudi::Property< std::string > m_rootInTES
Definition: GaudiCommon.h:737
template<class PBASE>
StatusCode GaudiCommon< PBASE >::runUpdate ( )
inline

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

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

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

Definition at line 605 of file GaudiCommon.h.

605 { return updMgrSvc()->update( this ); }
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 678 of file GaudiCommon.h.

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

Print statistical counters at finalization ?

Definition at line 492 of file GaudiCommon.h.

492 { return m_statPrint; }
Gaudi::Property< bool > m_statPrint
Definition: GaudiCommon.h:733
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 181 of file GaudiCommonImp.h.

183 {
184  Assert ( this->svcLoc(), "ISvcLocator* points to NULL!" );
186  // check if we already have this service
188  if ( it != std::end(m_services) && GaudiCommon_details::svc_eq(*it,name) ) {
189  // Try to get the requested interface
190  s = *it;
191  // check the results
192  if ( !s ) {
193  Exception ("svc():: Could not retrieve Svc '" + name + "'", StatusCode::FAILURE);
194  }
195  } else {
196  auto baseSvc = this->svcLoc()->service(name, create);
197  // Try to get the requested interface
198  s = baseSvc;
199  // check the results
200  if ( !baseSvc || !s ) {
201  Exception ("svc():: Could not retrieve Svc '" + name + "'", StatusCode::FAILURE);
202  }
203  // add the tool into list of known tools, to be properly released
204  addToServiceList(baseSvc);
205  }
206  // return *VALID* located service
207  return s;
208 }
Small smart pointer class with automatic reference counting for IInterface.
Definition: IConverter.h:14
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:714
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:245
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 129 of file GaudiCommonImp.h.

133 {
134  // for empty names delegate to another method
135  if ( name.empty() ) return tool<TOOL>( type , parent , create ) ;
136  Assert( this->toolSvc(), "tool():: IToolSvc* points to NULL!" ) ;
137  // get the tool from Tool Service
138  TOOL* Tool = nullptr ;
139  const StatusCode sc =
140  this->toolSvc()->retrieveTool ( type , name , Tool , parent , create ) ;
141  if ( sc.isFailure() )
142  { Exception("tool():: Could not retrieve Tool '" + type + "'/'" + name + "'", sc ) ; }
143  if ( !Tool )
144  { Exception("tool():: Could not retrieve Tool '" + type + "'/'" + name + "'" ) ; }
145  // insert tool into list of tools
146  PBASE::registerTool(Tool);
148  // return *VALID* located tool
149  return Tool ;
150 }
T empty(T...args)
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:84
T push_back(T...args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
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:712
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 156 of file GaudiCommonImp.h.

159 {
160  // check the environment
161  Assert ( PBASE::toolSvc(), "IToolSvc* points to NULL!" );
162  // retrieve the tool from Tool Service
163  TOOL* Tool = nullptr ;
164  const StatusCode sc =
165  this->toolSvc() -> retrieveTool ( type, Tool, parent , create );
166  if ( sc.isFailure() )
167  { Exception("tool():: Could not retrieve Tool '" + type + "'", sc ) ; }
168  if ( !Tool )
169  { Exception("tool():: Could not retrieve Tool '" + type + "'" ) ; }
170  // add the tool into the list of known tools to be properly released
171  PBASE::registerTool(Tool);
173  // return *VALID* located tool
174  return Tool ;
175 }
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:84
T push_back(T...args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
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:712
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 488 of file GaudiCommon.h.

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

Short-cut to locate the Update Manager Service.

Definition at line 214 of file GaudiCommonImp.h.

215 {
216  if ( !m_updMgrSvc )
217  { m_updMgrSvc = svc<IUpdateManagerSvc>("UpdateManagerSvc",true); }
218  return m_updMgrSvc ;
219 }
IUpdateManagerSvc * m_updMgrSvc
Pointer to the Update Manager Service instance.
Definition: GaudiCommon.h:728
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 400 of file GaudiCommon.icpp.

401 {
402  // increase local counter of warnings
403  const size_t num = ++m_warnings[msg];
404  // If suppressed, just return
405  if ( num > mx ) {
406  return st;
407  } else if ( UNLIKELY( num == mx ) ) // issue one-time suppression message
408  {
409  return Print( "The WARNING message is suppressed : '" + msg + "'", st, MSG::WARNING );
410  }
411  // return message
412  return Print( msg, st, MSG::WARNING );
413 }
Counter m_warnings
counter of warnings
Definition: GaudiCommon.h:719
#define UNLIKELY(x)
Definition: Kernel.h:126
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 94 of file GaudiCommon.h.

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

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

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

General counters.

Definition at line 725 of file GaudiCommon.h.

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

a pointer to the CounterSummarySvc

Definition at line 122 of file GaudiCommon.h.

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

Counter of errors.

Definition at line 717 of file GaudiCommon.h.

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

Definition at line 731 of file GaudiCommon.h.

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

Counter of exceptions.

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

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

counter of infos

Definition at line 721 of file GaudiCommon.h.

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

List of active tools.

Definition at line 712 of file GaudiCommon.h.

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

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

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

List of active services.

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

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

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

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

Pointer to the Update Manager Service instance.

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

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

counter of warnings

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


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