The Gaudi Framework  v37r0 (b608885e)
Algorithm.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #include <Gaudi/Algorithm.h>
12 
13 #include <algorithm>
14 #include <numeric>
15 #include <set>
16 
27 #include "GaudiKernel/INTupleSvc.h"
30 #include "GaudiKernel/IToolSvc.h"
31 #include "GaudiKernel/Kernel.h"
32 
33 #include "GaudiKernel/AlgTool.h"
34 #include "GaudiKernel/Chrono.h"
37 #include "GaudiKernel/Guards.h"
38 #include "GaudiKernel/MsgStream.h"
40 #include "GaudiKernel/Stat.h"
41 #include "GaudiKernel/StringKey.h"
42 #include "GaudiKernel/ToolHandle.h"
43 
44 namespace Gaudi {
45  namespace Details {
47  assert( loc != nullptr );
48  Gaudi::Property<bool> audit{ false };
49  auto appMgr = loc->service<IProperty>( "ApplicationMgr" );
50  if ( appMgr && appMgr->hasProperty( "AuditAlgorithms" ) ) {
51  audit.assign( appMgr->getProperty( "AuditAlgorithms" ) );
52  }
53  return audit.value();
54  }
55  } // namespace Details
56 
57  // IAlgorithm implementation
59 
60  // Bypass the initialization if the algorithm
61  // has already been initialized.
63 
64  // this initializes the messaging, in case property update handlers need to print
65  // and update the property value bypassing the update handler
67 
68  // Set the Algorithm's properties
69  bindPropertiesTo( serviceLocator()->getOptsSvc() );
70 
71  // Bypass the initialization if the algorithm is disabled.
72  // Need to do this after setProperties.
73  if ( !isEnabled() ) return StatusCode::SUCCESS;
74 
76 
77  // TODO: (MCl) where should we do this? initialize or start?
78  // Reset Error count
79  // m_errorCount = 0;
80 
81  // lock the context service
82  Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr );
83 
84  // Get WhiteBoard interface if implemented by EventDataSvc
85  m_WB = service( "EventDataSvc" );
86 
87  // check whether timeline should be done
88  m_doTimeline = timelineSvc()->isEnabled();
89 
90  StatusCode sc;
91  // Invoke initialize() method of the derived class inside a try/catch clause
92  try {
93 
94  { // limit the scope of the guard
95  Gaudi::Guards::AuditorGuard guard( this,
96  // check if we want to audit the initialize
97  ( m_auditorInitialize ) ? auditorSvc().get() : nullptr,
99  // Invoke the initialize() method of the derived class
100  sc = initialize();
101  }
102 
103  if ( sc.isSuccess() ) {
104  // Update the state.
106  }
107  } catch ( const GaudiException& Exception ) {
108  fatal() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
109  error() << Exception << endmsg;
110  Stat stat( chronoSvc(), Exception.tag() );
111  sc = StatusCode::FAILURE;
112  } catch ( const std::exception& Exception ) {
113  fatal() << " Standard std::exception is caught " << endmsg;
114  error() << Exception.what() << endmsg;
115  Stat stat( chronoSvc(), "*std::exception*" );
116  sc = StatusCode::FAILURE;
117  } catch ( ... ) {
118  fatal() << "UNKNOWN Exception is caught " << endmsg;
119  Stat stat( chronoSvc(), "*UNKNOWN Exception*" );
120  sc = StatusCode::FAILURE;
121  }
122 
123  algExecStateSvc()->addAlg( this );
124 
125  //
127  //
128 
129  // ignore this step if we're a Sequence
130  if ( this->isSequence() ) { return sc; }
131 
132  if ( msgLevel( MSG::DEBUG ) ) {
133  debug() << "input handles: " << inputHandles().size() << endmsg;
134  debug() << "output handles: " << outputHandles().size() << endmsg;
135  }
136 
137  // check for explicit circular data dependencies in declared handles
139  for ( auto& h : outputHandles() ) {
140  if ( !h->objKey().empty() ) out.emplace( h->fullKey() );
141  }
142  for ( auto& h : inputHandles() ) {
143  if ( !h->objKey().empty() && out.find( h->fullKey() ) != out.end() ) {
144  // TODO: this case leads to a segfault as the SC, seemingly, is not propagated up properly
145  error() << "Explicit circular data dependency detected for id " << h->fullKey() << endmsg;
146  sc = StatusCode::FAILURE;
147  }
148  }
149 
150  if ( !sc ) return sc;
151 
153 
154  // visit all sub-algs and tools, build full set. First initialize ToolHandles if needed
155  try {
157  } catch ( const GaudiException& Exception ) {
158  error() << "Failing initializing ToolHandles : " << Exception << endmsg;
159  return StatusCode::FAILURE;
160  }
162  acceptDHVisitor( &avis );
163 
164  // check for implicit circular data deps from child Algs/AlgTools
165  for ( auto& h : m_outputDataObjs ) {
166  auto i = m_inputDataObjs.find( h );
167  if ( i != m_inputDataObjs.end() ) {
168  if ( m_filterCircDeps ) {
169  warning() << "Implicit circular data dependency detected for id " << h << endmsg;
170  m_inputDataObjs.erase( i );
171  } else {
172  error() << "Implicit circular data dependency detected for id " << h << endmsg;
173  sc = StatusCode::FAILURE;
174  }
175  }
176  }
177 
178  if ( !sc ) return sc;
179 
180  if ( msgLevel( MSG::DEBUG ) && !avis.empty() ) { debug() << "data dependencies:" << avis << endmsg; }
181 
182  // initialize handles
184 
185  return sc;
186  }
187 
189  vis->visit( this );
190 
191  // loop through tools
192  for ( auto tool : tools() ) vis->visit( dynamic_cast<AlgTool*>( tool ) );
193  }
194 
195  // IAlgorithm implementation
197 
198  // Bypass the startup if already running or disabled.
200 
202 
203  // lock the context service
204  Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr );
205 
207  // Invoke start() method of the derived class inside a try/catch clause
208  try {
209  { // limit the scope of the guard
210  Gaudi::Guards::AuditorGuard guard( this,
211  // check if we want to audit the initialize
212  ( m_auditorStart ) ? auditorSvc().get() : nullptr, IAuditor::Start );
213  // Invoke the start() method of the derived class
214  sc = start();
215  }
216  if ( sc.isSuccess() ) {
217  // Update the state.
219  }
220  } catch ( const GaudiException& Exception ) {
221  fatal() << "in sysStart(): exception with tag=" << Exception.tag() << " is caught" << endmsg;
222  error() << Exception << endmsg;
223  Stat stat( chronoSvc(), Exception.tag() );
224  sc = StatusCode::FAILURE;
225  } catch ( const std::exception& Exception ) {
226  fatal() << "in sysStart(): standard std::exception is caught" << endmsg;
227  error() << Exception.what() << endmsg;
228  Stat stat( chronoSvc(), "*std::exception*" );
229  sc = StatusCode::FAILURE;
230  } catch ( ... ) {
231  fatal() << "in sysStart(): UNKNOWN Exception is caught" << endmsg;
232  Stat stat( chronoSvc(), "*UNKNOWN Exception*" );
233  sc = StatusCode::FAILURE;
234  }
235 
236  return sc;
237  }
238 
239  // IAlgorithm implementation
241 
242  // Bypass the initialization if the algorithm is disabled.
243  if ( !isEnabled() ) return StatusCode::SUCCESS;
244 
245  // Check that the current status is the correct one.
247  error() << "sysReinitialize(): cannot reinitialize algorithm not initialized" << endmsg;
248  return StatusCode::FAILURE;
249  }
250 
251  // Reset Error count
252  // m_errorCount = 0; // done during start
253 
254  // lock the context service
255  Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr );
256 
258  // Invoke reinitialize() method of the derived class inside a try/catch clause
259  try {
260  Gaudi::Guards::AuditorGuard guard( this,
261  // check if we want to audit the initialize
262  ( m_auditorReinitialize ) ? auditorSvc().get() : nullptr,
264  // Invoke the reinitialize() method of the derived class
265  sc = reinitialize();
266  } catch ( const GaudiException& Exception ) {
267  fatal() << "sysReinitialize(): Exception with tag=" << Exception.tag() << " is caught" << endmsg;
268  error() << Exception << endmsg;
269  Stat stat( chronoSvc(), Exception.tag() );
270  sc = StatusCode::FAILURE;
271  } catch ( const std::exception& Exception ) {
272  fatal() << "sysReinitialize(): Standard std::exception is caught" << endmsg;
273  error() << Exception.what() << endmsg;
274  Stat stat( chronoSvc(), "*std::exception*" );
275  sc = StatusCode::FAILURE;
276  } catch ( ... ) {
277  fatal() << "sysReinitialize(): UNKNOWN Exception is caught" << endmsg;
278  Stat stat( chronoSvc(), "*UNKNOWN Exception*" );
279  sc = StatusCode::FAILURE;
280  }
281 
282  return sc;
283  }
284 
285  // IAlgorithm implementation
287 
288  // Bypass the initialization if the algorithm is disabled.
289  if ( !isEnabled() ) return StatusCode::SUCCESS;
290 
291  // Check that the current status is the correct one.
293  error() << "sysRestart(): cannot restart algorithm not started" << endmsg;
294  return StatusCode::FAILURE;
295  }
296 
297  // lock the context service
298  Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr );
299 
301  // Invoke reinitialize() method of the derived class inside a try/catch clause
302  try {
303  Gaudi::Guards::AuditorGuard guard( this,
304  // check if we want to audit the initialize
305  ( m_auditorRestart ) ? auditorSvc().get() : nullptr, IAuditor::ReStart );
306  // Invoke the reinitialize() method of the derived class
307  sc = restart();
308  } catch ( const GaudiException& Exception ) {
309  fatal() << "sysRestart(): Exception with tag=" << Exception.tag() << " is caught" << endmsg;
310  error() << Exception << endmsg;
311  Stat stat( chronoSvc(), Exception.tag() );
312  sc = StatusCode::FAILURE;
313  } catch ( const std::exception& Exception ) {
314  fatal() << "sysRestart(): Standard std::exception is caught" << endmsg;
315  error() << Exception.what() << endmsg;
316  Stat stat( chronoSvc(), "*std::exception*" );
317  sc = StatusCode::FAILURE;
318  } catch ( ... ) {
319  fatal() << "sysRestart(): UNKNOWN Exception is caught" << endmsg;
320  Stat stat( chronoSvc(), "*UNKNOWN Exception*" );
321  sc = StatusCode::FAILURE;
322  }
323 
324  return sc;
325  }
326 
328  if ( !isEnabled() ) {
329  if ( msgLevel( MSG::VERBOSE ) ) { verbose() << ".sysExecute(): is not enabled. Skip execution" << endmsg; }
330  return StatusCode::SUCCESS;
331  }
332 
333  AlgExecState& algState = execState( ctx );
334  algState.setState( AlgExecState::State::Executing );
335  StatusCode status;
336 
337  // Should performance profile be performed ?
338  // invoke execute() method of Algorithm class
339  // and catch all uncaught exceptions
340 
341  // lock the context service
342  Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr, ctx );
343 
344  Gaudi::Guards::AuditorGuard guard( this,
345  // check if we want to audit the initialize
346  ( m_auditorExecute ) ? auditorSvc().get() : nullptr, IAuditor::Execute, status );
347 
348  try {
349  ITimelineSvc::TimelineRecorder timelineRecoder;
350  if ( m_doTimeline ) { timelineRecoder = timelineSvc()->getRecorder( name(), ctx ); }
351 
352  status = execute( ctx );
353 
355  algState.setFilterPassed( false );
356  } else if ( status.isFailure() ) {
357  status = exceptionSvc()->handleErr( *this, status );
358  }
359 
360  } catch ( const GaudiException& Exception ) {
361 
362  if ( Exception.code() == StatusCode::FAILURE ) {
363  fatal();
364  } else {
365  error() << " Recoverable";
366  }
367 
368  msgStream() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
369 
370  error() << Exception << endmsg;
371 
372  // Stat stat( chronoSvc() , Exception.tag() ) ;
373  status = exceptionSvc()->handle( *this, Exception );
374  } catch ( const std::exception& Exception ) {
375 
376  fatal() << " Standard std::exception is caught " << endmsg;
377  error() << Exception.what() << endmsg;
378  // Stat stat( chronoSvc() , "*std::exception*" ) ;
379  status = exceptionSvc()->handle( *this, Exception );
380  } catch ( ... ) {
381 
382  fatal() << "UNKNOWN Exception is caught " << endmsg;
383  // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
384 
385  status = exceptionSvc()->handle( *this );
386  }
387 
388  if ( status.isFailure() ) {
389  // Increment the error count
390  unsigned int nerr = m_aess->incrementErrorCount( this );
391  // Check if maximum is exeeded
392  if ( nerr < m_errorMax ) {
393  warning() << "Continuing from error (cnt=" << nerr << ", max=" << m_errorMax << ")" << endmsg;
394  // convert to success
395  status = StatusCode::SUCCESS;
396  } else {
397  error() << "Maximum number of errors (" << m_errorMax << ") reached." << endmsg;
398  }
399  }
400 
401  algState.setState( AlgExecState::State::Done, status );
402 
403  return status;
404  }
405 
406  // IAlgorithm implementation
408 
409  // Bypass the startup if already running or disabled.
411 
413 
414  // lock the context service
415  Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr );
416 
418  // Invoke stop() method of the derived class inside a try/catch clause
419  try {
420  { // limit the scope of the guard
421  Gaudi::Guards::AuditorGuard guard( this,
422  // check if we want to audit the initialize
423  ( m_auditorStop ) ? auditorSvc().get() : nullptr, IAuditor::Stop );
424 
425  // Invoke the stop() method of the derived class
426  sc = stop();
427  }
428  if ( sc.isSuccess() ) {
429  // Update the state.
431  }
432  } catch ( const GaudiException& Exception ) {
433  fatal() << "in sysStop(): exception with tag=" << Exception.tag() << " is caught" << endmsg;
434  error() << Exception << endmsg;
435  Stat stat( chronoSvc(), Exception.tag() );
436  sc = StatusCode::FAILURE;
437  } catch ( const std::exception& Exception ) {
438  fatal() << "in sysStop(): standard std::exception is caught" << endmsg;
439  error() << Exception.what() << endmsg;
440  Stat stat( chronoSvc(), "*std::exception*" );
441  sc = StatusCode::FAILURE;
442  } catch ( ... ) {
443  fatal() << "in sysStop(): UNKNOWN Exception is caught" << endmsg;
444  Stat stat( chronoSvc(), "*UNKNOWN Exception*" );
445  sc = StatusCode::FAILURE;
446  }
447 
448  return sc;
449  }
450 
452 
453  // Bypass the finalialization if the algorithm hasn't been initilized.
455 
457 
458  // lock the context service
459  Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr );
460 
462  // Invoke finalize() method of the derived class inside a try/catch clause
463  try {
464  { // limit the scope of the guard
465  Gaudi::Guards::AuditorGuard guard( this,
466  // check if we want to audit the initialize
467  ( m_auditorFinalize ) ? auditorSvc().get() : nullptr, IAuditor::Finalize );
468  // Invoke the finalize() method of the derived class
469  sc = finalize();
470  }
471  if ( sc.isSuccess() ) {
472  // Indicate that this Algorithm has been finalized to prevent duplicate attempts
474  }
475  } catch ( const GaudiException& Exception ) {
476  fatal() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
477  error() << Exception << endmsg;
478  Stat stat( chronoSvc(), Exception.tag() );
479  sc = StatusCode::FAILURE;
480  } catch ( const std::exception& Exception ) {
481  fatal() << " Standard std::exception is caught " << endmsg;
482  error() << Exception.what() << endmsg;
483  Stat stat( chronoSvc(), "*std::exception*" );
484  sc = StatusCode::FAILURE;
485  } catch ( ... ) {
486  fatal() << "UNKNOWN Exception is caught " << endmsg;
487  Stat stat( chronoSvc(), "*UNKNOWN Exception*" );
488  sc = StatusCode::FAILURE;
489  }
490  return sc;
491  }
492 
494  /* @TODO
495  * MCl 2008-10-23: the implementation of reinitialize as finalize+initialize
496  * is causing too many problems
497  *
498  // Default implementation is finalize+initialize
499  StatusCode sc = finalize();
500  if (sc.isFailure()) {
501  error() << "reinitialize(): cannot be finalized" << endmsg;
502  return sc;
503  }
504  sc = initialize();
505  if (sc.isFailure()) {
506  error() << "reinitialize(): cannot be initialized" << endmsg;
507  return sc;
508  }
509  */
510  return StatusCode::SUCCESS;
511  }
512 
514  // Default implementation is stop+start
515  StatusCode sc = stop();
516  if ( sc.isFailure() ) {
517  error() << "restart(): cannot be stopped" << endmsg;
518  return sc;
519  }
520  sc = start();
521  if ( sc.isFailure() ) {
522  error() << "restart(): cannot be started" << endmsg;
523  return sc;
524  }
525  return StatusCode::SUCCESS;
526  }
527 
528  const std::string& Algorithm::name() const { return m_name.str(); }
529 
530  const Gaudi::StringKey& Algorithm::nameKey() const { return m_name; }
531 
532  const std::string& Algorithm::version() const { return m_version; }
533 
534  unsigned int Algorithm::index() const { return m_index; }
535 
536  void Algorithm::setIndex( const unsigned int& idx ) { m_index = idx; }
537 
538  bool Algorithm::isEnabled() const { return m_isEnabled; }
539 
541  return algExecStateSvc()->algExecState( const_cast<IAlgorithm*>( (const IAlgorithm*)this ), ctx );
542  }
543 
544  template <typename IFace>
545  SmartIF<IFace>& Algorithm::get_svc_( SmartIF<IFace>& p, const char* service_name ) const {
546  if ( !p ) {
547  p = this->service( service_name );
548  if ( !p ) {
549  throw GaudiException( "Service [" + std::string{ service_name } + "] not found", this->name(),
551  }
552  }
553  return p;
554  }
555 
556  SmartIF<IAlgExecStateSvc>& Algorithm::algExecStateSvc() const { return get_svc_( m_aess, "AlgExecStateSvc" ); }
557  SmartIF<IAuditorSvc>& Algorithm::auditorSvc() const { return get_svc_( m_pAuditorSvc, "AuditorSvc" ); }
558  SmartIF<IChronoStatSvc>& Algorithm::chronoSvc() const { return get_svc_( m_CSS, "ChronoStatSvc" ); }
559  SmartIF<IDataProviderSvc>& Algorithm::detSvc() const { return get_svc_( m_DDS, "DetectorDataSvc" ); }
560  SmartIF<IConversionSvc>& Algorithm::detCnvSvc() const { return get_svc_( m_DCS, "DetectorPersistencySvc" ); }
561  SmartIF<IDataProviderSvc>& Algorithm::eventSvc() const { return get_svc_( m_EDS, "EventDataSvc" ); }
562  SmartIF<IConversionSvc>& Algorithm::eventCnvSvc() const { return get_svc_( m_ECS, "EventPersistencySvc" ); }
563  SmartIF<IHistogramSvc>& Algorithm::histoSvc() const { return get_svc_( m_HDS, "HistogramDataSvc" ); }
564  SmartIF<INTupleSvc>& Algorithm::ntupleSvc() const { return get_svc_( m_NTS, "NTupleSvc" ); }
565  SmartIF<IRndmGenSvc>& Algorithm::randSvc() const { return get_svc_( m_RGS, "RndmGenSvc" ); }
566  SmartIF<IToolSvc>& Algorithm::toolSvc() const { return get_svc_( m_ptoolSvc, "ToolSvc" ); }
567  SmartIF<IExceptionSvc>& Algorithm::exceptionSvc() const { return get_svc_( m_EXS, "ExceptionSvc" ); }
568  SmartIF<IAlgContextSvc>& Algorithm::contextSvc() const { return get_svc_( m_contextSvc, "AlgContextSvc" ); }
570  SmartIF<IHiveWhiteBoard>& Algorithm::whiteboard() const { return get_svc_( m_WB, "EventDataSvc" ); }
571 
573  return *const_cast<SmartIF<ISvcLocator>*>( &m_pSvcLocator );
574  }
575 
577 
578  auto init_one = [&]( BaseToolHandle* th ) {
579  if ( !th->isEnabled() ) {
580  if ( msgLevel( MSG::DEBUG ) && !th->typeAndName().empty() )
581  debug() << "ToolHandle " << th->typeAndName() << " not used" << endmsg;
582  return;
583  }
584  if ( !th->get() ) {
585  auto sc = th->retrieve();
586  if ( sc.isFailure() ) {
587  throw GaudiException( "Failed to retrieve tool " + th->typeAndName(), this->name(), StatusCode::FAILURE );
588  }
589  }
590  auto tool = th->get();
591  if ( msgLevel( MSG::DEBUG ) )
592  debug() << "Adding " << ( th->isPublic() ? "public" : "private" ) << " ToolHandle tool " << tool->name() << " ("
593  << tool->type() << ")" << endmsg;
595  };
596 
597  for ( auto thArr : m_toolHandleArrays ) {
598  if ( msgLevel( MSG::DEBUG ) )
599  debug() << "Registering all Tools in ToolHandleArray " << thArr->propertyName() << endmsg;
600  // Iterate over its tools:
601  for ( auto toolHandle : thArr->getBaseArray() ) {
602  BaseToolHandle* bth = dynamic_cast<BaseToolHandle*>( toolHandle );
603  if ( bth ) {
604  init_one( bth );
605  } else {
606  error() << "Error retrieving ToolHandle " << toolHandle->typeAndName() << " in ToolHandleArray "
607  << thArr->propertyName() << ". Not registered" << endmsg;
608  }
609  }
610  }
611 
612  for ( BaseToolHandle* th : m_toolHandles ) init_one( th );
613 
614  m_toolHandlesInit = true;
615  }
616 
619  return m_tools;
620  }
621 
624  return m_tools;
625  }
626 
631  StatusCode Algorithm::service_i( std::string_view svcName, bool createIf, const InterfaceID& iid,
632  void** ppSvc ) const {
633  const ServiceLocatorHelper helper( *serviceLocator(), *this );
634  return helper.getService( svcName, createIf, iid, ppSvc );
635  }
636 
637  StatusCode Algorithm::service_i( std::string_view svcType, std::string_view svcName, const InterfaceID& iid,
638  void** ppSvc ) const {
639  const ServiceLocatorHelper helper( *serviceLocator(), *this );
640  return helper.createService( svcType, svcName, iid, ppSvc );
641  }
642 
643  SmartIF<IService> Algorithm::service( std::string_view name, const bool createIf, const bool quiet ) const {
644  const ServiceLocatorHelper helper( *serviceLocator(), *this );
645  return helper.service( name, quiet, createIf );
646  }
647 
649  if ( msgLevel( MSG::DEBUG ) ) { debug() << "Registering tool " << tool->name() << endmsg; }
651  }
652 
655  if ( it != m_tools.end() ) {
656  if ( msgLevel( MSG::DEBUG ) ) debug() << "De-Registering tool " << tool->name() << endmsg;
657  m_tools.erase( it );
658  } else {
659  if ( msgLevel( MSG::DEBUG ) ) debug() << "Could not de-register tool " << tool->name() << endmsg;
660  }
661  }
662 
664  return os << type() << "('" << name() << "')";
665  }
666 
667  unsigned int Algorithm::errorCount() const { return m_aess->algErrorCount( static_cast<const IAlgorithm*>( this ) ); }
668 } // namespace Gaudi
Gaudi::Algorithm::nameKey
const Gaudi::StringKey & nameKey() const override
Definition: Algorithm.cpp:530
ServiceLocatorHelper::service
SmartIF< IService > service(std::string_view name, const bool quiet=false, const bool createIf=true) const
Definition: ServiceLocatorHelper.cpp:50
MSG::DEBUG
@ DEBUG
Definition: IMessageSvc.h:25
Gaudi::Algorithm::m_pSvcLocator
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Definition: Algorithm.h:474
IAuditor::ReStart
@ ReStart
Definition: IAuditor.h:34
Gaudi::Algorithm::m_auditorExecute
Gaudi::Property< bool > m_auditorExecute
Definition: Algorithm.h:497
Gaudi::Algorithm::m_RGS
SmartIF< IRndmGenSvc > m_RGS
Random Number Generator Service.
Definition: Algorithm.h:464
Gaudi::Algorithm::m_EXS
SmartIF< IExceptionSvc > m_EXS
Exception Handler Service.
Definition: Algorithm.h:465
Gaudi::Algorithm::sysExecute
StatusCode sysExecute(const EventContext &ctx) override
The actions to be performed by the algorithm on an event.
Definition: Algorithm.cpp:327
IAlgManager.h
std::string
STL class.
IAlgTool
Definition: IAlgTool.h:33
Gaudi::Algorithm::index
unsigned int index() const override
Definition: Algorithm.cpp:534
Gaudi::Algorithm::contextSvc
SmartIF< IAlgContextSvc > & contextSvc() const
get Algorithm Context Service
Definition: Algorithm.cpp:568
Gaudi::Algorithm::toolSvc
SmartIF< IToolSvc > & toolSvc() const
The standard ToolSvc service, Return a pointer to the service if present.
Definition: Algorithm.cpp:566
std::exception
STL class.
Gaudi::Algorithm::randSvc
SmartIF< IRndmGenSvc > & randSvc() const
The standard RandomGen service, Return a pointer to the service if present.
Definition: Algorithm.cpp:565
IAuditor::Execute
@ Execute
Definition: IAuditor.h:34
Gaudi::Algorithm::m_errorMax
Gaudi::Property< unsigned int > m_errorMax
Definition: Algorithm.h:488
Gaudi::Algorithm::acceptDHVisitor
void acceptDHVisitor(IDataHandleVisitor *) const override
Definition: Algorithm.cpp:188
bug_34121.name
name
Definition: bug_34121.py:20
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:528
Gaudi::Algorithm::eventSvc
SmartIF< IDataProviderSvc > & eventSvc() const
The standard event data service.
Definition: Algorithm.cpp:561
Gaudi::Algorithm::m_pAuditorSvc
SmartIF< IAuditorSvc > m_pAuditorSvc
Auditor Service.
Definition: Algorithm.h:466
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:314
Gaudi::Algorithm::m_state
Gaudi::StateMachine::State m_state
flag indicating whether ToolHandle tools have been added to m_tools
Definition: Algorithm.h:527
std::unordered_set< DataObjID, DataObjID_Hasher >
DHHVisitor::empty
bool empty() const
return true if no DataHandle was found
Definition: DataHandleHolderVisitor.cpp:122
GaudiException.h
Gaudi::Algorithm::type
const std::string & type() const override
The type of the algorithm object.
Definition: Algorithm.h:165
Gaudi::Algorithm::m_isEnabled
Gaudi::Property< bool > m_isEnabled
Definition: Algorithm.h:486
std::vector< IAlgTool * >
Gaudi::StateMachine::FINALIZE
@ FINALIZE
Definition: StateMachine.h:38
std::unordered_set::find
T find(T... args)
Gaudi::Algorithm::sysRestart
StatusCode sysRestart() override
Restart method invoked by the framework.
Definition: Algorithm.cpp:286
ISvcLocator
Definition: ISvcLocator.h:46
Gaudi::Algorithm::initialize
StatusCode initialize() override
the default (empty) implementation of IStateful::initialize() method
Definition: Algorithm.h:178
GaudiException
Definition: GaudiException.h:31
Gaudi::Algorithm::histoSvc
SmartIF< IHistogramSvc > & histoSvc() const
The standard histogram service.
Definition: Algorithm.cpp:563
IRndmGenSvc.h
Gaudi::Algorithm::m_doTimeline
Gaudi::Property< bool > m_doTimeline
Definition: Algorithm.h:503
Gaudi::Algorithm::m_ptoolSvc
SmartIF< IToolSvc > m_ptoolSvc
ToolSvc Service.
Definition: Algorithm.h:467
Gaudi::Algorithm::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition: Algorithm.cpp:572
Gaudi::Algorithm::auditorSvc
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Algorithm.cpp:557
StringKey.h
std::unique_ptr::get
T get(T... args)
Gaudi::Algorithm::detSvc
SmartIF< IDataProviderSvc > & detSvc() const
The standard detector data service.
Definition: Algorithm.cpp:559
Gaudi::Algorithm::m_auditorReinitialize
Gaudi::Property< bool > m_auditorReinitialize
Definition: Algorithm.h:494
Gaudi::Algorithm::m_WB
SmartIF< IHiveWhiteBoard > m_WB
Event data service (whiteboard)
Definition: Algorithm.h:457
Gaudi::Functional::FilterDecision::FAILED
@ FAILED
DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >::outputHandles
std::vector< Gaudi::DataHandle * > outputHandles() const override
Definition: DataHandleHolderBase.h:41
Gaudi::Algorithm::m_HDS
SmartIF< IHistogramSvc > m_HDS
Histogram data service.
Definition: Algorithm.h:461
Gaudi::Algorithm::m_CSS
SmartIF< IChronoStatSvc > m_CSS
Chrono & Stat Service.
Definition: Algorithm.h:463
Gaudi::Algorithm::m_updateDataHandles
std::unique_ptr< IDataHandleVisitor > m_updateDataHandles
Hook for for derived classes to provide a custom visitor for data handles.
Definition: Algorithm.h:478
Gaudi::Algorithm::sysStop
StatusCode sysStop() override
System stop.
Definition: Algorithm.cpp:407
Gaudi::Algorithm::start
StatusCode start() override
the default (empty) implementation of IStateful::start() method
Definition: Algorithm.h:180
Gaudi::Algorithm::eventCnvSvc
SmartIF< IConversionSvc > & eventCnvSvc() const
The standard event data persistency conversion service.
Definition: Algorithm.cpp:562
DHHVisitor
Definition: DataHandleHolderVisitor.h:21
IMessageSvc.h
CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:148
IAuditorSvc.h
IDataProviderSvc.h
IExceptionSvc.h
PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >::bindPropertiesTo
void bindPropertiesTo(Gaudi::Interfaces::IOptionsSvc &optsSvc)
Definition: PropertyHolder.h:252
DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >::m_outputDataObjs
DataObjIDColl m_outputDataObjs
Definition: DataHandleHolderBase.h:98
Gaudi::Guards::AuditorGuard
Definition: Guards.h:213
Gaudi::StateMachine::INITIALIZE
@ INITIALIZE
Definition: StateMachine.h:35
std::vector::push_back
T push_back(T... args)
Gaudi::Algorithm::chronoSvc
SmartIF< IChronoStatSvc > & chronoSvc() const
The standard Chrono & Stat service, Return a pointer to the service if present.
Definition: Algorithm.cpp:558
IToolSvc.h
Gaudi::Algorithm::deregisterTool
void deregisterTool(IAlgTool *tool) const
Definition: Algorithm.cpp:653
Gaudi::Algorithm::m_ECS
SmartIF< IConversionSvc > m_ECS
Event conversion service.
Definition: Algorithm.h:458
IProperty
Definition: IProperty.h:33
IAuditor::Finalize
@ Finalize
Definition: IAuditor.h:34
Gaudi::Algorithm::initToolHandles
void initToolHandles() const
Definition: Algorithm.cpp:576
Gaudi::Algorithm::m_auditorRestart
Gaudi::Property< bool > m_auditorRestart
Definition: Algorithm.h:496
Gaudi::Algorithm::m_auditorStop
Gaudi::Property< bool > m_auditorStop
Definition: Algorithm.h:501
Gaudi::Algorithm::whiteboard
SmartIF< IHiveWhiteBoard > & whiteboard() const
Definition: Algorithm.cpp:570
Gaudi::Algorithm::m_NTS
SmartIF< INTupleSvc > m_NTS
N tuple service.
Definition: Algorithm.h:462
Gaudi::StringKey
Definition: StringKey.h:44
Gaudi::Algorithm::m_auditorInitialize
Gaudi::Property< bool > m_auditorInitialize
Definition: Algorithm.h:492
Gaudi::Algorithm::isEnabled
bool isEnabled() const override
Is this algorithm enabled or disabled?
Definition: Algorithm.cpp:538
bug_34121.tool
tool
Definition: bug_34121.py:17
CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >::setUpMessaging
MSG::Level setUpMessaging() const
Set up local caches.
Definition: CommonMessaging.h:174
Gaudi::Functional::details::get
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))
Definition: details.h:440
Gaudi::StateMachine::CONFIGURED
@ CONFIGURED
Definition: StateMachine.h:24
GaudiPython.Pythonizations.ctx
ctx
Definition: Pythonizations.py:588
DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >::initDataHandleHolder
void initDataHandleHolder()
initializes all handles - called by the sysInitialize method of any descendant of this
Definition: DataHandleHolderBase.h:94
StatusCode
Definition: StatusCode.h:65
Gaudi::Algorithm::m_outputLevel
Gaudi::Property< int > m_outputLevel
Definition: Algorithm.h:482
IAuditor::Stop
@ Stop
Definition: IAuditor.h:34
IAlgorithm
Definition: IAlgorithm.h:38
GaudiPython.Pythonizations.execute
execute
Definition: Pythonizations.py:588
Gaudi::Algorithm::FSMState
Gaudi::StateMachine::State FSMState() const override
returns the current state of the algorithm
Definition: Algorithm.h:190
Gaudi::Algorithm::m_contextSvc
SmartIF< IAlgContextSvc > m_contextSvc
Algorithm Context Service.
Definition: Algorithm.h:469
Gaudi::Details::getDefaultAuditorValue
bool getDefaultAuditorValue(ISvcLocator *loc)
Definition: Algorithm.cpp:46
std::ostream
STL class.
Gaudi::Algorithm::execState
AlgExecState & execState(const EventContext &ctx) const override
reference to AlgExecState of Alg
Definition: Algorithm.cpp:540
IAuditor::Initialize
@ Initialize
Definition: IAuditor.h:34
IAuditor::ReInitialize
@ ReInitialize
Definition: IAuditor.h:34
Gaudi::Algorithm::sysInitialize
StatusCode sysInitialize() override
Initialization method invoked by the framework.
Definition: Algorithm.cpp:58
ITimelineSvc::TimelineRecorder
RAII helper to record timeline events.
Definition: ITimelineSvc.h:44
AlgSequencer.h
h
Definition: AlgSequencer.py:32
AlgExecState::setState
void setState(State s)
Definition: IAlgExecStateSvc.h:46
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:97
DataHandleHolderVisitor.h
Gaudi::Utils::AlgContext
Definition: IAlgContextSvc.h:84
Gaudi::Property::value
const ValueType & value() const
Definition: Property.h:239
DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >::m_inputDataObjs
DataObjIDColl m_inputDataObjs
Definition: DataHandleHolderBase.h:98
ServiceLocatorHelper
an helper to share the implementation of service() among the various kernel base classes
Definition: ServiceLocatorHelper.h:27
std::unordered_set::erase
T erase(T... args)
ServiceLocatorHelper::getService
StatusCode getService(std::string_view name, bool createIf, const InterfaceID &iid, void **ppSvc) const
Definition: ServiceLocatorHelper.h:51
Gaudi::Algorithm::m_targetState
Gaudi::StateMachine::State m_targetState
Algorithm has been initialized flag.
Definition: Algorithm.h:528
Algorithm.h
SmartIF
Definition: IConverter.h:25
Gaudi::Algorithm::version
const std::string & version() const override
Definition: Algorithm.cpp:532
Gaudi::Algorithm::m_name
Gaudi::StringKey m_name
Algorithm's name for identification.
Definition: Algorithm.h:441
genconfuser.verbose
verbose
Definition: genconfuser.py:29
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:203
Gaudi::Algorithm::tools
const std::vector< IAlgTool * > & tools() const
Definition: Algorithm.cpp:617
Gaudi::Algorithm::toControlFlowExpression
std::ostream & toControlFlowExpression(std::ostream &os) const override
Produce string represention of the control flow expression.
Definition: Algorithm.cpp:663
Gaudi::Algorithm::m_EDS
SmartIF< IDataProviderSvc > m_EDS
Event data service.
Definition: Algorithm.h:456
Gaudi::StateMachine::RUNNING
@ RUNNING
Definition: StateMachine.h:26
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
Gaudi::Algorithm::exceptionSvc
SmartIF< IExceptionSvc > & exceptionSvc() const
Get the exception Service.
Definition: Algorithm.cpp:567
Gaudi::Algorithm::m_auditorStart
Gaudi::Property< bool > m_auditorStart
Definition: Algorithm.h:500
IDataHandleVisitor
Definition: IDataHandleHolder.h:46
Stat.h
Stat
Definition: Stat.h:56
DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >::inputHandles
std::vector< Gaudi::DataHandle * > inputHandles() const override
Definition: DataHandleHolderBase.h:38
Gaudi::StateMachine::ChangeState
State GAUDI_API ChangeState(const Transition transition, const State state)
Function to get the new state according to the required transition, checking if the transition is all...
Definition: StateMachine.cpp:19
Gaudi::Algorithm::m_tools
std::vector< IAlgTool * > m_tools
Definition: Algorithm.h:447
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
Gaudi::Algorithm::algExecStateSvc
SmartIF< IAlgExecStateSvc > & algExecStateSvc() const
Definition: Algorithm.cpp:556
IAuditor::Start
@ Start
Definition: IAuditor.h:34
Gaudi::Algorithm::sysStart
StatusCode sysStart() override
Reinitialization method invoked by the framework.
Definition: Algorithm.cpp:196
Gaudi::Algorithm::m_toolHandles
std::vector< BaseToolHandle * > m_toolHandles
Definition: Algorithm.h:448
Gaudi::Algorithm::service_i
StatusCode service_i(std::string_view svcName, bool createIf, const InterfaceID &iid, void **ppSvc) const
implementation of service method
Definition: Algorithm.cpp:631
Gaudi::Algorithm::finalize
StatusCode finalize() override
the default (empty) implementation of IStateful::finalize() method
Definition: Algorithm.h:184
MSG::VERBOSE
@ VERBOSE
Definition: IMessageSvc.h:25
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
IAlgContextSvc.h
Gaudi::Algorithm::m_toolHandleArrays
std::vector< GaudiHandleArrayBase * > m_toolHandleArrays
Definition: Algorithm.h:449
AlgTool
Definition: AlgTool.h:62
BaseToolHandle
Definition: ToolHandle.h:80
Gaudi::Algorithm::sysFinalize
StatusCode sysFinalize() override
System finalization.
Definition: Algorithm.cpp:451
ServiceLocatorHelper.h
std::vector::begin
T begin(T... args)
Gaudi::Algorithm::m_timelineSvc
SmartIF< ITimelineSvc > m_timelineSvc
Timeline Service.
Definition: Algorithm.h:471
ToolHandle.h
Gaudi::Algorithm::restart
StatusCode restart() override
the default (empty) implementation of IStateful::restart() method
Definition: Algorithm.cpp:513
Gaudi::Algorithm::m_toolHandlesInit
bool m_toolHandlesInit
Definition: Algorithm.h:525
Kernel.h
Gaudi::Algorithm::service
StatusCode service(std::string_view name, T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
Definition: Algorithm.h:205
Gaudi::StateMachine::INITIALIZED
@ INITIALIZED
Definition: StateMachine.h:25
Chrono.h
Gaudi::StateMachine::START
@ START
Definition: StateMachine.h:36
EventContext
Definition: EventContext.h:34
Gaudi::Algorithm::m_version
std::string m_version
Algorithm's version.
Definition: Algorithm.h:443
Gaudi::Algorithm::m_DDS
SmartIF< IDataProviderSvc > m_DDS
Detector data service.
Definition: Algorithm.h:459
Gaudi::StringKey::str
const std::string & str() const
the actual string
Definition: StringKey.h:56
AlgTool.h
Gaudi::Algorithm::timelineSvc
SmartIF< ITimelineSvc > & timelineSvc() const
Definition: Algorithm.cpp:569
Gaudi::Algorithm::m_filterCircDeps
Gaudi::Property< bool > m_filterCircDeps
Definition: Algorithm.h:522
Gaudi::Algorithm::m_index
unsigned int m_index
Algorithm's index.
Definition: Algorithm.h:444
Gaudi::Algorithm::m_aess
SmartIF< IAlgExecStateSvc > m_aess
Alg execution state mgr.
Definition: Algorithm.h:472
std::unordered_set::end
T end(T... args)
InterfaceID
Definition: IInterface.h:39
Gaudi::Algorithm::reinitialize
StatusCode reinitialize() override
the default (empty) implementation of IStateful::reinitialize() method
Definition: Algorithm.cpp:493
AlgExecState
Definition: IAlgExecStateSvc.h:37
Gaudi::Algorithm::detCnvSvc
SmartIF< IConversionSvc > & detCnvSvc() const
The standard detector data persistency conversion service.
Definition: Algorithm.cpp:560
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
Guards.h
IConversionSvc.h
Gaudi::Algorithm::setIndex
void setIndex(const unsigned int &idx) override
set instantiation index of Alg
Definition: Algorithm.cpp:536
ISvcLocator.h
Gaudi::Algorithm::sysReinitialize
StatusCode sysReinitialize() override
Reinitialization method invoked by the framework.
Definition: Algorithm.cpp:240
Gaudi::Algorithm::registerContext
bool registerContext() const
register for Algorithm Context Service?
Definition: Algorithm.h:295
ServiceLocatorHelper::createService
StatusCode createService(std::string_view name, const InterfaceID &iid, void **ppSvc) const
Definition: ServiceLocatorHelper.cpp:33
Gaudi::Algorithm::registerTool
void registerTool(IAlgTool *tool) const
Definition: Algorithm.cpp:648
AlgExecState::setFilterPassed
void setFilterPassed(bool f=true)
Definition: IAlgExecStateSvc.h:45
Gaudi::Algorithm::stop
StatusCode stop() override
the default (empty) implementation of IStateful::stop() method
Definition: Algorithm.h:182
IOTest.appMgr
appMgr
Definition: IOTest.py:103
FunctionalFilterDecision.h
Gaudi::Algorithm::ntupleSvc
SmartIF< INTupleSvc > & ntupleSvc() const
The standard N tuple service.
Definition: Algorithm.cpp:564
Gaudi::Algorithm::get_svc_
SmartIF< IFace > & get_svc_(SmartIF< IFace > &p, const char *service_name) const
Definition: Algorithm.cpp:545
Gaudi::Algorithm::isSequence
bool isSequence() const override
Are we a Sequence?
Definition: Algorithm.h:198
Gaudi::Property< bool >
IDataManagerSvc.h
IHistogramSvc.h
Gaudi::StateMachine::STOP
@ STOP
Definition: StateMachine.h:37
INTupleSvc.h
MsgStream.h
Gaudi::Algorithm::errorCount
unsigned int errorCount() const
Get the number of failures of the algorithm.
Definition: Algorithm.cpp:667
Gaudi::Algorithm::m_DCS
SmartIF< IConversionSvc > m_DCS
Detector conversion service.
Definition: Algorithm.h:460
IDataHandleVisitor::visit
virtual void visit(const IDataHandleHolder *)=0
PrepareBase.out
out
Definition: PrepareBase.py:20
Gaudi::Algorithm::m_auditorFinalize
Gaudi::Property< bool > m_auditorFinalize
Definition: Algorithm.h:498