| The Gaudi Framework v29r0 (ff2e7097)

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

- File List
- File Members

Algorithm.cpp
Go to the documentation of this file.
1 #include <algorithm>
2 #include <numeric>
3 #include <set>
4
5 #include "GaudiKernel/IAlgContextSvc.h"
6 #include "GaudiKernel/IAlgManager.h"
7 #include "GaudiKernel/IAuditorSvc.h"
8 #include "GaudiKernel/IConversionSvc.h"
9 #include "GaudiKernel/IDataManagerSvc.h"
10 #include "GaudiKernel/IDataProviderSvc.h"
11 #include "GaudiKernel/IExceptionSvc.h"
12 #include "GaudiKernel/IHistogramSvc.h"
13 #include "GaudiKernel/IJobOptionsSvc.h"
14 #include "GaudiKernel/IMessageSvc.h"
15 #include "GaudiKernel/INTupleSvc.h"
16 #include "GaudiKernel/IRndmGenSvc.h"
17 #include "GaudiKernel/ISvcLocator.h"
18 #include "GaudiKernel/IToolSvc.h"
19 #include "GaudiKernel/Kernel.h"
20 #include "GaudiKernel/ThreadLocalContext.h"
21
22 #include "GaudiKernel/AlgTool.h"
23 #include "GaudiKernel/Chrono.h"
24 #include "GaudiKernel/DataHandleHolderVisitor.h"
25 #include "GaudiKernel/GaudiException.h"
26 #include "GaudiKernel/Guards.h"
27 #include "GaudiKernel/MsgStream.h"
28 #include "GaudiKernel/ServiceLocatorHelper.h"
29 #include "GaudiKernel/Stat.h"
30 #include "GaudiKernel/StringKey.h"
31 #include "GaudiKernel/ThreadGaudi.h"
32 #include "GaudiKernel/ToolHandle.h"
33
34 #include "GaudiKernel/Algorithm.h"
35
36 namespace
37 {
38 template <StatusCode ( Algorithm::*f )(), typename C>
39 bool for_algorithms( C& c )
40 {
41 return std::accumulate( std::begin( c ), std::end( c ), true,
42 []( bool b, Algorithm* a ) { return ( a->*f )().isSuccess() && b; } );
43 }
44 }
45
46 // Constructor
47 Algorithm::Algorithm( const std::string& name, ISvcLocator* pSvcLocator, const std::string& version )
48 : m_name( name )
49 , m_version( version )
50 , m_index( 0 )
51 , // incremented by AlgResourcePool
52 m_pSvcLocator( pSvcLocator )
53 {
54 // Auditor monitoring properties
55 // Initialize the default value from ApplicationMgr AuditAlgorithms
56 Gaudi::Property<bool> audit( false );
57 auto appMgr = serviceLocator()->service<IProperty>( "ApplicationMgr" );
58 if ( appMgr && appMgr->hasProperty( "AuditAlgorithms" ) ) {
59 audit.assign( appMgr->getProperty( "AuditAlgorithms" ) );
60 }
61 m_auditInit = audit;
62 m_auditorInitialize = audit;
63 m_auditorReinitialize = audit;
64 m_auditorRestart = audit;
65 m_auditorExecute = audit;
66 m_auditorFinalize = audit;
67 m_auditorBeginRun = audit;
68 m_auditorEndRun = audit;
69 m_auditorStart = audit;
70 m_auditorStop = audit;
71
72 // update handlers.
73 m_outputLevel.declareUpdateHandler(
74 [this]( Gaudi::Details::PropertyBase& ) { this->updateMsgStreamOutputLevel( this->m_outputLevel ); } );
75 }
76
77 // IAlgorithm implementation
78 StatusCode Algorithm::sysInitialize()
79 {
80
81 // Bypass the initialization if the algorithm
82 // has already been initialized.
83 if ( Gaudi::StateMachine::INITIALIZED <= FSMState() ) return StatusCode::SUCCESS;
84
85 // Set the Algorithm's properties
86 if ( !setProperties() ) return StatusCode::FAILURE;
87
88 // Bypass the initialization if the algorithm is disabled.
89 // Need to do this after setProperties.
90 if ( !isEnabled() ) return StatusCode::SUCCESS;
91
92 m_targetState = Gaudi::StateMachine::ChangeState( Gaudi::StateMachine::INITIALIZE, m_state );
93
94 // TODO: (MCl) where shoud we do this? initialize or start?
95 // Reset Error count
96 // m_errorCount = 0;
97
98 // lock the context service
99 Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr );
100
101 // Get WhiteBoard interface if implemented by EventDataSvc
102 m_WB = service( "EventDataSvc" );
103
104 // check whether timeline should be done
105 m_doTimeline = timelineSvc()->isEnabled();
106
107 StatusCode sc;
108 // Invoke initialize() method of the derived class inside a try/catch clause
109 try {
110
111 { // limit the scope of the guard
112 Gaudi::Guards::AuditorGuard guard( this,
113 // check if we want to audit the initialize
114 ( m_auditorInitialize ) ? auditorSvc().get() : nullptr, IAuditor::Initialize );
115 // Invoke the initialize() method of the derived class
116 sc = initialize();
117 }
118
119 if ( sc.isSuccess() ) {
120 // Now initialize care of any sub-algorithms
121 bool fail( false );
122 for ( auto& it : m_subAlgms ) {
123 if ( it->sysInitialize().isFailure() ) fail = true;
124 }
125 if ( fail ) {
126 sc = StatusCode::FAILURE;
127 error() << " Error initializing one or several sub-algorithms" << endmsg;
128 } else {
129 // Update the state.
130 m_state = m_targetState;
131 }
132 }
133 } catch ( const GaudiException& Exception ) {
134 fatal() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
135 error() << Exception << endmsg;
136 Stat stat( chronoSvc(), Exception.tag() );
137 sc = StatusCode::FAILURE;
138 } catch ( const std::exception& Exception ) {
139 fatal() << " Standard std::exception is caught " << endmsg;
140 error() << Exception.what() << endmsg;
141 Stat stat( chronoSvc(), "*std::exception*" );
142 sc = StatusCode::FAILURE;
143 } catch ( ... ) {
144 fatal() << "UNKNOWN Exception is caught " << endmsg;
145 Stat stat( chronoSvc(), "*UNKNOWN Exception*" );
146 sc = StatusCode::FAILURE;
147 }
148
149 algExecStateSvc()->addAlg( this );
150
151 //
153 //
154
155 // ignore this step if we're a Sequence
156 if ( this->isSequence() ) {
157 return sc;
158 }
159
160 if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) {
161 debug() << "input handles: " << inputHandles().size() << endmsg;
162 debug() << "output handles: " << outputHandles().size() << endmsg;
163 }
164
165 // check for explicit circular data dependencies in declared handles
166 DataObjIDColl out;
167 for ( auto& h : outputHandles() ) {
168 if ( !h->objKey().empty() ) out.emplace( h->fullKey() );
169 }
170 for ( auto& h : inputHandles() ) {
171 if ( !h->objKey().empty() && out.find( h->fullKey() ) != out.end() ) {
172 error() << "Explicit circular data dependency detected for id " << h->fullKey() << endmsg;
173 sc = StatusCode::FAILURE;
174 }
175 }
176
177 if ( !sc ) return sc;
178
179 if ( m_updateDataHandles ) acceptDHVisitor( m_updateDataHandles.get() );
180
181 // visit all sub-algs and tools, build full set
182 DHHVisitor avis( m_inputDataObjs, m_outputDataObjs );
183 acceptDHVisitor( &avis );
184
185 // check for implicit circular data deps from child Algs/AlgTools
186 for ( auto& h : m_outputDataObjs ) {
187 auto i = m_inputDataObjs.find( h );
188 if ( i != m_inputDataObjs.end() ) {
189 if ( m_filterCircDeps ) {
190 warning() << "Implicit circular data dependency detected for id " << h << endmsg;
191 m_inputDataObjs.erase( i );
192 } else {
193 error() << "Implicit circular data dependency detected for id " << h << endmsg;
194 sc = StatusCode::FAILURE;
195 }
196 }
197 }
198
199 if ( !sc ) return sc;
200
201 if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) {
202 // sort out DataObjects by path so that logging is reproducable
203 // we define a little helper creating an ordered set from a non ordered one
204 auto sort = []( const DataObjID a, const DataObjID b ) -> bool { return a.fullKey() < b.fullKey(); };
205 auto orderset = [&sort]( const DataObjIDColl& in ) -> std::set<DataObjID, decltype( sort )> {
206 return {in.begin(), in.end(), sort};
207 };
208 // Logging
209 debug() << "Data Deps for " << name();
210 for ( auto h : orderset( m_inputDataObjs ) ) {
211 debug() << "\n + INPUT " << h;
212 }
213 for ( auto id : orderset( avis.ignoredInpKeys() ) ) {
214 debug() << "\n + INPUT IGNORED " << id;
215 }
216 for ( auto h : orderset( m_outputDataObjs ) ) {
217 debug() << "\n + OUTPUT " << h;
218 }
219 for ( auto id : orderset( avis.ignoredOutKeys() ) ) {
220 debug() << "\n + OUTPUT IGNORED " << id;
221 }
222 debug() << endmsg;
223 }
224
225 // initialize handles
226 initDataHandleHolder();
227
228 return sc;
229 }
230
231 void Algorithm::acceptDHVisitor( IDataHandleVisitor* vis ) const
232 {
233
234 vis->visit( this );
235
236 // loop through tools
237 for ( auto tool : tools() ) vis->visit( dynamic_cast<AlgTool*>( tool ) );
238
239 // loop through sub-algs
240 for ( auto alg : *subAlgorithms() ) vis->visit( alg );
241 }
242
243 // IAlgorithm implementation
244 StatusCode Algorithm::sysStart()
245 {
246
247 // Bypass the startup if already running or disabled.
248 if ( Gaudi::StateMachine::RUNNING == FSMState() || !isEnabled() ) return StatusCode::SUCCESS;
249
250 m_targetState = Gaudi::StateMachine::ChangeState( Gaudi::StateMachine::START, m_state );
251
252 // lock the context service
253 Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr );
254
255 StatusCode sc( StatusCode::FAILURE );
256 // Invoke start() method of the derived class inside a try/catch clause
257 try {
258 { // limit the scope of the guard
259 Gaudi::Guards::AuditorGuard guard( this,
260 // check if we want to audit the initialize
261 ( m_auditorStart ) ? auditorSvc().get() : nullptr, IAuditor::Start );
262 // Invoke the start() method of the derived class
263 sc = start();
264 }
265 if ( sc.isSuccess() ) {
266
267 // Now start any sub-algorithms
268 if ( !for_algorithms<&Algorithm::sysStart>( m_subAlgms ) ) {
269 sc = StatusCode::FAILURE;
270 error() << " Error starting one or several sub-algorithms" << endmsg;
271 } else {
272 // Update the state.
273 m_state = m_targetState;
274 }
275 }
276 } catch ( const GaudiException& Exception ) {
277 fatal() << "in sysStart(): exception with tag=" << Exception.tag() << " is caught" << endmsg;
278 error() << Exception << endmsg;
279 Stat stat( chronoSvc(), Exception.tag() );
280 sc = StatusCode::FAILURE;
281 } catch ( const std::exception& Exception ) {
282 fatal() << "in sysStart(): standard std::exception is caught" << endmsg;
283 error() << Exception.what() << endmsg;
284 Stat stat( chronoSvc(), "*std::exception*" );
285 sc = StatusCode::FAILURE;
286 } catch ( ... ) {
287 fatal() << "in sysStart(): UNKNOWN Exception is caught" << endmsg;
288 Stat stat( chronoSvc(), "*UNKNOWN Exception*" );
289 sc = StatusCode::FAILURE;
290 }
291
292 return sc;
293 }
294
295 // IAlgorithm implementation
296 StatusCode Algorithm::sysReinitialize()
297 {
298
299 // Bypass the initialization if the algorithm is disabled.
300 if ( !isEnabled() ) return StatusCode::SUCCESS;
301
302 // Check that the current status is the correct one.
303 if ( Gaudi::StateMachine::INITIALIZED != FSMState() ) {
304 error() << "sysReinitialize(): cannot reinitialize algorithm not initialized" << endmsg;
305 return StatusCode::FAILURE;
306 }
307
308 // Reset Error count
309 // m_errorCount = 0; // done during start
310
311 // lock the context service
312 Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr );
313
314 StatusCode sc( StatusCode::SUCCESS );
315 // Invoke reinitialize() method of the derived class inside a try/catch clause
316 try {
317 { // limit the scope of the guard
318 Gaudi::Guards::AuditorGuard guard( this,
319 // check if we want to audit the initialize
320 ( m_auditorReinitialize ) ? auditorSvc().get() : nullptr,
321 IAuditor::ReInitialize );
322 // Invoke the reinitialize() method of the derived class
323 sc = reinitialize();
324 }
325 if ( sc.isSuccess() ) {
326
327 // Now initialize care of any sub-algorithms
328 if ( !for_algorithms<&Algorithm::sysReinitialize>( m_subAlgms ) ) {
329 sc = StatusCode::FAILURE;
330 error() << "sysReinitialize(): Error reinitializing one or several "
331 << "sub-algorithms" << endmsg;
332 }
333 }
334 } catch ( const GaudiException& Exception ) {
335 fatal() << "sysReinitialize(): Exception with tag=" << Exception.tag() << " is caught" << endmsg;
336 error() << Exception << endmsg;
337 Stat stat( chronoSvc(), Exception.tag() );
338 sc = StatusCode::FAILURE;
339 } catch ( const std::exception& Exception ) {
340 fatal() << "sysReinitialize(): Standard std::exception is caught" << endmsg;
341 error() << Exception.what() << endmsg;
342 Stat stat( chronoSvc(), "*std::exception*" );
343 sc = StatusCode::FAILURE;
344 } catch ( ... ) {
345 fatal() << "sysReinitialize(): UNKNOWN Exception is caught" << endmsg;
346 Stat stat( chronoSvc(), "*UNKNOWN Exception*" );
347 sc = StatusCode::FAILURE;
348 }
349
350 return sc;
351 }
352
353 // IAlgorithm implementation
354 StatusCode Algorithm::sysRestart()
355 {
356
357 // Bypass the initialization if the algorithm is disabled.
358 if ( !isEnabled() ) return StatusCode::SUCCESS;
359
360 // Check that the current status is the correct one.
361 if ( Gaudi::StateMachine::RUNNING != FSMState() ) {
362 error() << "sysRestart(): cannot restart algorithm not started" << endmsg;
363 return StatusCode::FAILURE;
364 }
365
366 // lock the context service
367 Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr );
368
369 StatusCode sc( StatusCode::FAILURE );
370 // Invoke reinitialize() method of the derived class inside a try/catch clause
371 try {
372 { // limit the scope of the guard
373 Gaudi::Guards::AuditorGuard guard( this,
374 // check if we want to audit the initialize
375 ( m_auditorRestart ) ? auditorSvc().get() : nullptr, IAuditor::ReStart );
376 // Invoke the reinitialize() method of the derived class
377 sc = restart();
378 }
379 if ( sc.isSuccess() ) {
380
381 // Now initialize care of any sub-algorithms
382 if ( !for_algorithms<&Algorithm::sysRestart>( m_subAlgms ) ) {
383 sc = StatusCode::FAILURE;
384 error() << "sysRestart(): Error restarting one or several sub-algorithms" << endmsg;
385 }
386 }
387 } catch ( const GaudiException& Exception ) {
388 fatal() << "sysRestart(): Exception with tag=" << Exception.tag() << " is caught" << endmsg;
389 error() << Exception << endmsg;
390 Stat stat( chronoSvc(), Exception.tag() );
391 sc = StatusCode::FAILURE;
392 } catch ( const std::exception& Exception ) {
393 fatal() << "sysRestart(): Standard std::exception is caught" << endmsg;
394 error() << Exception.what() << endmsg;
395 Stat stat( chronoSvc(), "*std::exception*" );
396 sc = StatusCode::FAILURE;
397 } catch ( ... ) {
398 fatal() << "sysRestart(): UNKNOWN Exception is caught" << endmsg;
399 Stat stat( chronoSvc(), "*UNKNOWN Exception*" );
400 sc = StatusCode::FAILURE;
401 }
402
403 return sc;
404 }
405
406 // IAlgorithm implementation
407 StatusCode Algorithm::sysBeginRun()
408 {
409
410 // Bypass the beginRun if the algorithm is disabled.
411 if ( !isEnabled() ) return StatusCode::SUCCESS;
412
413 // lock the context service
414 Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr );
415
416 StatusCode sc( StatusCode::FAILURE );
417 // Invoke beginRun() method of the derived class inside a try/catch clause
418 try {
419 { // limit the scope of the guard
420 Gaudi::Guards::AuditorGuard guard( this,
421 // check if we want to audit the initialize
422 ( m_auditorBeginRun ) ? auditorSvc().get() : nullptr, IAuditor::BeginRun );
423 // Invoke the beginRun() method of the derived class
424 sc = beginRun();
425 }
426 if ( sc.isSuccess() ) {
427
428 // Now call beginRun for any sub-algorithms
429 if ( !for_algorithms<&Algorithm::sysBeginRun>( m_subAlgms ) ) {
430 sc = StatusCode::FAILURE;
431 error() << " Error executing BeginRun for one or several sub-algorithms" << endmsg;
432 }
433 }
434 } catch ( const GaudiException& Exception ) {
435 fatal() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
436 error() << Exception << endmsg;
437 Stat stat( chronoSvc(), Exception.tag() );
438 sc = StatusCode::FAILURE;
439 } catch ( const std::exception& Exception ) {
440 fatal() << " Standard std::exception is caught " << endmsg;
441 error() << Exception.what() << endmsg;
442 Stat stat( chronoSvc(), "*std::exception*" );
443 sc = StatusCode::FAILURE;
444 } catch ( ... ) {
445 fatal() << "UNKNOWN Exception is caught " << endmsg;
446 Stat stat( chronoSvc(), "*UNKNOWN Exception*" );
447 sc = StatusCode::FAILURE;
448 }
449 return sc;
450 }
451
452 StatusCode Algorithm::beginRun() { return StatusCode::SUCCESS; }
453
454 // IAlgorithm implementation
455 StatusCode Algorithm::sysEndRun()
456 {
457
458 // Bypass the endRun if the algorithm is disabled.
459 if ( !isEnabled() ) return StatusCode::SUCCESS;
460
461 // lock the context service
462 Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr );
463
464 // Invoke endRun() method of the derived class inside a try/catch clause
465 StatusCode sc( StatusCode::FAILURE );
466 try {
467 { // limit the scope of the guard
468 Gaudi::Guards::AuditorGuard guard( this,
469 // check if we want to audit the initialize
470 ( m_auditorEndRun ) ? auditorSvc().get() : nullptr, IAuditor::EndRun );
471 // Invoke the endRun() method of the derived class
472 sc = endRun();
473 }
474 if ( sc.isSuccess() ) {
475
476 // Now call endRun for any sub-algorithms
477 if ( !for_algorithms<&Algorithm::sysEndRun>( m_subAlgms ) ) {
478 sc = StatusCode::FAILURE;
479 error() << " Error calling endRun for one or several sub-algorithms" << endmsg;
480 }
481 }
482 } catch ( const GaudiException& Exception ) {
483 fatal() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
484 error() << Exception << endmsg;
485 Stat stat( chronoSvc(), Exception.tag() );
486 sc = StatusCode::FAILURE;
487 } catch ( const std::exception& Exception ) {
488 fatal() << " Standard std::exception is caught " << endmsg;
489 error() << Exception.what() << endmsg;
490 Stat stat( chronoSvc(), "*std::exception*" );
491 sc = StatusCode::FAILURE;
492 } catch ( ... ) {
493 fatal() << "UNKNOWN Exception is caught " << endmsg;
494 Stat stat( chronoSvc(), "*UNKNOWN Exception*" );
495 sc = StatusCode::FAILURE;
496 }
497 return sc;
498 }
499
500 StatusCode Algorithm::endRun() { return StatusCode::SUCCESS; }
501
502 StatusCode Algorithm::sysExecute( const EventContext& ctx )
503 {
504
505 m_event_context = ctx;
506
507 if ( !isEnabled() ) {
508 if ( msgLevel( MSG::VERBOSE ) ) {
509 verbose() << ".sysExecute(): is not enabled. Skip execution" << endmsg;
510 }
511 return StatusCode::SUCCESS;
512 }
513
514 StatusCode status;
515
516 // Should performance profile be performed ?
517 // invoke execute() method of Algorithm class
518 // and catch all uncaught exceptions
519
520 // lock the context service
521 Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr );
522
523 Gaudi::Guards::AuditorGuard guard( this,
524 // check if we want to audit the initialize
525 ( m_auditorExecute ) ? auditorSvc().get() : nullptr, IAuditor::Execute, status );
526
527 TimelineEvent timeline;
528 timeline.algorithm = this->name();
529 timeline.thread = pthread_self();
530 timeline.slot = ctx.slot();
531 timeline.event = ctx.evt();
532
533 try {
534
535 if ( UNLIKELY( m_doTimeline ) ) timeline.start = Clock::now();
536
537 status = execute();
538
539 if ( UNLIKELY( m_doTimeline ) ) timeline.end = Clock::now();
540
541 setExecuted( true ); // set the executed flag
542
543 if ( status.isFailure() ) {
544 status = exceptionSvc()->handleErr( *this, status );
545 }
546
547 } catch ( const GaudiException& Exception ) {
548 setExecuted( true ); // set the executed flag
549
550 if ( Exception.code() == StatusCode::FAILURE ) {
551 fatal();
552 } else {
553 error() << " Recoverable";
554 }
555
556 msgStream() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
557
558 error() << Exception << endmsg;
559
560 // Stat stat( chronoSvc() , Exception.tag() ) ;
561 status = exceptionSvc()->handle( *this, Exception );
562 } catch ( const std::exception& Exception ) {
563 setExecuted( true ); // set the executed flag
564
565 fatal() << " Standard std::exception is caught " << endmsg;
566 error() << Exception.what() << endmsg;
567 // Stat stat( chronoSvc() , "*std::exception*" ) ;
568 status = exceptionSvc()->handle( *this, Exception );
569 } catch ( ... ) {
570 setExecuted( true ); // set the executed flag
571
572 fatal() << "UNKNOWN Exception is caught " << endmsg;
573 // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
574
575 status = exceptionSvc()->handle( *this );
576 }
577
578 if ( UNLIKELY( m_doTimeline ) ) timelineSvc()->registerTimelineEvent( timeline );
579
580 if ( status.isFailure() ) {
581 // Increment the error count
582 unsigned int nerr = m_aess->incrementErrorCount( this );
583 // Check if maximum is exeeded
584 if ( nerr < m_errorMax ) {
585 warning() << "Continuing from error (cnt=" << nerr << ", max=" << m_errorMax << ")" << endmsg;
586 // convert to success
587 status = StatusCode::SUCCESS;
588 } else {
589 error() << "Maximum number of errors (" << m_errorMax << ") reached." << endmsg;
590 }
591 }
592 return status;
593 }
594
595 // IAlgorithm implementation
596 StatusCode Algorithm::sysStop()
597 {
598
599 // Bypass the startup if already running or disabled.
600 if ( Gaudi::StateMachine::INITIALIZED == FSMState() || !isEnabled() ) return StatusCode::SUCCESS;
601
602 m_targetState = Gaudi::StateMachine::ChangeState( Gaudi::StateMachine::STOP, m_state );
603
604 // lock the context service
605 Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr );
606
607 StatusCode sc( StatusCode::FAILURE );
608 // Invoke stop() method of the derived class inside a try/catch clause
609 try {
610 // Stop first any sub-algorithms (in reverse order -- not?)
611 for_algorithms<&Algorithm::sysStop>( m_subAlgms );
612 { // limit the scope of the guard
613 Gaudi::Guards::AuditorGuard guard( this,
614 // check if we want to audit the initialize
615 ( m_auditorStop ) ? auditorSvc().get() : nullptr, IAuditor::Stop );
616
617 // Invoke the stop() method of the derived class
618 sc = stop();
619 }
620 if ( sc.isSuccess() ) {
621 // Update the state.
622 m_state = m_targetState;
623 }
624 } catch ( const GaudiException& Exception ) {
625 fatal() << "in sysStop(): exception with tag=" << Exception.tag() << " is caught" << endmsg;
626 error() << Exception << endmsg;
627 Stat stat( chronoSvc(), Exception.tag() );
628 sc = StatusCode::FAILURE;
629 } catch ( const std::exception& Exception ) {
630 fatal() << "in sysStop(): standard std::exception is caught" << endmsg;
631 error() << Exception.what() << endmsg;
632 Stat stat( chronoSvc(), "*std::exception*" );
633 sc = StatusCode::FAILURE;
634 } catch ( ... ) {
635 fatal() << "in sysStop(): UNKNOWN Exception is caught" << endmsg;
636 Stat stat( chronoSvc(), "*UNKNOWN Exception*" );
637 sc = StatusCode::FAILURE;
638 }
639
640 return sc;
641 }
642
643 StatusCode Algorithm::sysFinalize()
644 {
645
646 // Bypass the finalialization if the algorithm hasn't been initilized.
647 if ( Gaudi::StateMachine::CONFIGURED == FSMState() || !isEnabled() ) return StatusCode::SUCCESS;
648
649 m_targetState = Gaudi::StateMachine::ChangeState( Gaudi::StateMachine::FINALIZE, m_state );
650
651 // lock the context service
652 Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr );
653
654 StatusCode sc( StatusCode::FAILURE );
655 // Invoke finalize() method of the derived class inside a try/catch clause
656 try {
657 // Order changed (bug #3903 overview: finalize and nested algorithms)
658 // Finalize first any sub-algorithms (it can be done more than once)
659 bool ok = for_algorithms<&Algorithm::sysFinalize>( m_subAlgms );
660 { // limit the scope of the guard
661 Gaudi::Guards::AuditorGuard guard( this,
662 // check if we want to audit the initialize
663 ( m_auditorFinalize ) ? auditorSvc().get() : nullptr, IAuditor::Finalize );
664 // Invoke the finalize() method of the derived class
665 sc = finalize();
666 }
667 if ( !ok ) sc = StatusCode::FAILURE;
668
669 if ( sc.isSuccess() ) {
670
671 // Release all sub-algorithms
672 for ( auto& it : m_subAlgms ) it->release();
673 // Indicate that this Algorithm has been finalized to prevent duplicate attempts
674 m_state = m_targetState;
675 }
676 } catch ( const GaudiException& Exception ) {
677 fatal() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
678 error() << Exception << endmsg;
679 Stat stat( chronoSvc(), Exception.tag() );
680 sc = StatusCode::FAILURE;
681 } catch ( const std::exception& Exception ) {
682 fatal() << " Standard std::exception is caught " << endmsg;
683 error() << Exception.what() << endmsg;
684 Stat stat( chronoSvc(), "*std::exception*" );
685 sc = StatusCode::FAILURE;
686 } catch ( ... ) {
687 fatal() << "UNKNOWN Exception is caught " << endmsg;
688 Stat stat( chronoSvc(), "*UNKNOWN Exception*" );
689 sc = StatusCode::FAILURE;
690 }
691 return sc;
692 }
693
694 StatusCode Algorithm::reinitialize()
695 {
696 /* @TODO
697 * MCl 2008-10-23: the implementation of reinitialize as finalize+initialize
698 * is causing too many problems
699 *
700 // Default implementation is finalize+initialize
701 StatusCode sc = finalize();
702 if (sc.isFailure()) {
703 error() << "reinitialize(): cannot be finalized" << endmsg;
704 return sc;
705 }
706 sc = initialize();
707 if (sc.isFailure()) {
708 error() << "reinitialize(): cannot be initialized" << endmsg;
709 return sc;
710 }
711 */
712 return StatusCode::SUCCESS;
713 }
714
715 StatusCode Algorithm::restart()
716 {
717 // Default implementation is stop+start
718 StatusCode sc = stop();
719 if ( sc.isFailure() ) {
720 error() << "restart(): cannot be stopped" << endmsg;
721 return sc;
722 }
723 sc = start();
724 if ( sc.isFailure() ) {
725 error() << "restart(): cannot be started" << endmsg;
726 return sc;
727 }
728 return StatusCode::SUCCESS;
729 }
730
731 const std::string& Algorithm::name() const { return m_name.str(); }
732
733 const Gaudi::StringKey& Algorithm::nameKey() const { return m_name; }
734
735 const std::string& Algorithm::version() const { return m_version; }
736
737 unsigned int Algorithm::index() const { return m_index; }
738
739 void Algorithm::setIndex( const unsigned int& idx ) { m_index = idx; }
740
741 bool Algorithm::isExecuted() const
742 {
743 const EventContext& context = Gaudi::Hive::currentContext();
744 return algExecStateSvc()->algExecState( (IAlgorithm*)this, context ).state() == AlgExecState::State::Done;
745 }
746
747 void Algorithm::setExecuted( bool state ) const
748 {
749 const EventContext& context = Gaudi::Hive::currentContext();
750 AlgExecState::State s = state ? AlgExecState::State::Done : AlgExecState::State::None;
751 algExecStateSvc()->algExecState( const_cast<IAlgorithm*>( (const IAlgorithm*)this ), context ).setState( s );
752 }
753
754 void Algorithm::resetExecuted()
755 {
756 const EventContext& context = Gaudi::Hive::currentContext();
757 return algExecStateSvc()->algExecState( (IAlgorithm*)this, context ).reset();
758 }
759
760 bool Algorithm::isEnabled() const { return m_isEnabled; }
761
762 bool Algorithm::filterPassed() const
763 {
764 const EventContext& context = Gaudi::Hive::currentContext();
765 return algExecStateSvc()->algExecState( (IAlgorithm*)this, context ).filterPassed();
766 }
767
768 void Algorithm::setFilterPassed( bool state ) const
769 {
770 const EventContext& context = Gaudi::Hive::currentContext();
771 algExecStateSvc()
772 ->algExecState( const_cast<IAlgorithm*>( (const IAlgorithm*)this ), context )
773 .setFilterPassed( state );
774 }
775
776 const std::vector<Algorithm*>* Algorithm::subAlgorithms() const { return &m_subAlgms; }
777
778 std::vector<Algorithm*>* Algorithm::subAlgorithms() { return &m_subAlgms; }
779
780 template <typename IFace>
781 SmartIF<IFace>& Algorithm::get_svc_( SmartIF<IFace>& p, const char* service_name ) const
782 {
783 if ( UNLIKELY( !p ) ) {
784 p = this->service( service_name );
785 if ( !p ) {
786 throw GaudiException( "Service [" + std::string{service_name} + "] not found", this->name(),
787 StatusCode::FAILURE );
788 }
789 }
790 return p;
791 }
792
793 SmartIF<IAlgExecStateSvc>& Algorithm::algExecStateSvc() const { return get_svc_( m_aess, "AlgExecStateSvc" ); }
794 SmartIF<IAuditorSvc>& Algorithm::auditorSvc() const { return get_svc_( m_pAuditorSvc, "AuditorSvc" ); }
795 SmartIF<IChronoStatSvc>& Algorithm::chronoSvc() const { return get_svc_( m_CSS, "ChronoStatSvc" ); }
796 SmartIF<IDataProviderSvc>& Algorithm::detSvc() const { return get_svc_( m_DDS, "DetectorDataSvc" ); }
797 SmartIF<IConversionSvc>& Algorithm::detCnvSvc() const { return get_svc_( m_DCS, "DetectorPersistencySvc" ); }
798 SmartIF<IDataProviderSvc>& Algorithm::eventSvc() const { return get_svc_( m_EDS, "EventDataSvc" ); }
799 SmartIF<IConversionSvc>& Algorithm::eventCnvSvc() const { return get_svc_( m_ECS, "EventPersistencySvc" ); }
800 SmartIF<IHistogramSvc>& Algorithm::histoSvc() const { return get_svc_( m_HDS, "HistogramDataSvc" ); }
801 SmartIF<INTupleSvc>& Algorithm::ntupleSvc() const { return get_svc_( m_NTS, "NTupleSvc" ); }
802 SmartIF<IRndmGenSvc>& Algorithm::randSvc() const { return get_svc_( m_RGS, "RndmGenSvc" ); }
803 SmartIF<IToolSvc>& Algorithm::toolSvc() const { return get_svc_( m_ptoolSvc, "ToolSvc" ); }
804 SmartIF<IExceptionSvc>& Algorithm::exceptionSvc() const { return get_svc_( m_EXS, "ExceptionSvc" ); }
805 SmartIF<IAlgContextSvc>& Algorithm::contextSvc() const { return get_svc_( m_contextSvc, "AlgContextSvc" ); }
806 SmartIF<ITimelineSvc>& Algorithm::timelineSvc() const { return get_svc_( m_timelineSvc, "TimelineSvc" ); }
807 SmartIF<IHiveWhiteBoard>& Algorithm::whiteboard() const { return get_svc_( m_WB, "EventDataSvc" ); }
808
809 SmartIF<ISvcLocator>& Algorithm::serviceLocator() const { return *const_cast<SmartIF<ISvcLocator>*>( &m_pSvcLocator ); }
810
811 // Use the job options service to set declared properties
812 StatusCode Algorithm::setProperties()
813 {
814 if ( !m_pSvcLocator ) return StatusCode::FAILURE;
815 auto jos = m_pSvcLocator->service<IJobOptionsSvc>( "JobOptionsSvc" );
816 if ( !jos ) return StatusCode::FAILURE;
817 // set first generic Properties
818 StatusCode sc = jos->setMyProperties( getGaudiThreadGenericName( name() ), this );
819 if ( sc.isFailure() ) return StatusCode::FAILURE;
820
821 // set specific Properties
822 if ( isGaudiThreaded( name() ) ) {
823 if ( jos->setMyProperties( name(), this ).isFailure() ) {
824 return StatusCode::FAILURE;
825 }
826 }
827
828 // initialize output level (except for MessageSvc)
829 if ( m_outputLevel == MSG::NIL ) // if not defined (via options)
830 m_outputLevel = msgLevel(); // set it from MessageSvc
831 else // otherwise notify MessageSvc
832 updateMsgStreamOutputLevel( m_outputLevel );
833
834 return sc;
835 }
836
837 StatusCode Algorithm::createSubAlgorithm( const std::string& type, const std::string& name, Algorithm*& pSubAlgorithm )
838 {
839 if ( !m_pSvcLocator ) return StatusCode::FAILURE;
840
841 SmartIF<IAlgManager> am( m_pSvcLocator );
842 if ( !am ) return StatusCode::FAILURE;
843
844 // Maybe modify the AppMgr interface to return Algorithm* ??
845 IAlgorithm* tmp;
846 StatusCode sc = am->createAlgorithm( type, name + getGaudiThreadIDfromName( Algorithm::name() ), tmp );
847 if ( sc.isFailure() ) return StatusCode::FAILURE;
848
849 try {
850 pSubAlgorithm = dynamic_cast<Algorithm*>( tmp );
851 m_subAlgms.push_back( pSubAlgorithm );
852 } catch ( ... ) {
853 sc = StatusCode::FAILURE;
854 }
855 return sc;
856 }
857
858 void Algorithm::initToolHandles() const
859 {
860
861 IAlgTool* tool( 0 );
862 for ( auto thArr : m_toolHandleArrays ) {
863 if ( !thArr->retrieved() ) {
864 if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) )
865 debug() << "ToolHandleArray " << thArr->propertyName() << " not used: not registering any of its Tools"
866 << endmsg;
867 } else {
868 if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) )
869 debug() << "Registering all Tools in ToolHandleArray " << thArr->propertyName() << endmsg;
870 // Iterate over its tools:
871 for ( auto toolHandle : thArr->getBaseArray() ) {
872 // Try to cast it into a BaseToolHandle pointer:
873 BaseToolHandle* bth = dynamic_cast<BaseToolHandle*>( toolHandle );
874 if ( bth ) {
875 // If the cast was successful, the code is pretty simple:
876 tool = bth->get();
877 if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) {
878 debug() << "Adding " << ( bth->isPublic() ? "public" : "private" ) << " ToolHandle tool " << tool->name()
879 << " (" << tool->type() << ") from ToolHandleArray " << thArr->propertyName() << endmsg;
880 }
881 m_tools.push_back( tool );
882 } else {
883 // If it wasn't for some strange reason, then fall back on the
884 // logic implemented previously:
885 if ( toolSvc()->retrieveTool( toolHandle->typeAndName(), tool, this, false ).isSuccess() ) {
886 if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) {
887 debug() << "Adding private"
888 << " ToolHandle tool " << tool->name() << " (" << tool->type() << ") from ToolHandleArray "
889 << thArr->propertyName() << endmsg;
890 }
891 m_tools.push_back( tool );
892 } else if ( toolSvc()->retrieveTool( toolHandle->typeAndName(), tool, 0, false ).isSuccess() ) {
893 if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) {
894 debug() << "Adding public"
895 << " ToolHandle tool " << tool->name() << " (" << tool->type() << ") from ToolHandleArray "
896 << thArr->propertyName() << endmsg;
897 }
898 m_tools.push_back( tool );
899 } else {
900 warning() << "Error retrieving Tool " << toolHandle->typeAndName() << " in ToolHandleArray "
901 << thArr->propertyName() << ". Not registered" << endmsg;
902 }
903 }
904 }
905 }
906 }
907
908 for ( auto th : m_toolHandles ) {
909 tool = th->get();
910 if ( tool ) {
911 if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) )
912 debug() << "Adding " << ( th->isPublic() ? "public" : "private" ) << " ToolHandle tool " << tool->name() << " ("
913 << tool->type() << ")" << endmsg;
914 m_tools.push_back( tool );
915 } else {
916 if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) debug() << "ToolHandle " << th->typeAndName() << " not used" << endmsg;
917 }
918 }
919
920 m_toolHandlesInit = true;
921 }
922
923 const std::vector<IAlgTool*>& Algorithm::tools() const
924 {
925 if ( UNLIKELY( !m_toolHandlesInit ) ) initToolHandles();
926 return m_tools;
927 }
928
929 std::vector<IAlgTool*>& Algorithm::tools()
930 {
931 if ( UNLIKELY( !m_toolHandlesInit ) ) initToolHandles();
932 return m_tools;
933 }
934
939 StatusCode Algorithm::service_i( const std::string& svcName, bool createIf, const InterfaceID& iid, void** ppSvc ) const
940 {
941 const ServiceLocatorHelper helper( *serviceLocator(), *this );
942 return helper.getService( svcName, createIf, iid, ppSvc );
943 }
944
945 StatusCode Algorithm::service_i( const std::string& svcType, const std::string& svcName, const InterfaceID& iid,
946 void** ppSvc ) const
947 {
948 const ServiceLocatorHelper helper( *serviceLocator(), *this );
949 return helper.createService( svcType, svcName, iid, ppSvc );
950 }
951
952 SmartIF<IService> Algorithm::service( const std::string& name, const bool createIf, const bool quiet ) const
953 {
954 const ServiceLocatorHelper helper( *serviceLocator(), *this );
955 return helper.service( name, quiet, createIf );
956 }
957
958 //-----------------------------------------------------------------------------
959 void Algorithm::commitHandles()
960 {
961 //-----------------------------------------------------------------------------
962
963 for ( auto h : outputHandles() ) {
964 h->commit();
965 }
966
967 for ( auto t : m_tools ) {
968 AlgTool* at = dynamic_cast<AlgTool*>( t );
969 if ( at != 0 ) at->commitHandles();
970 }
971
972 for ( auto& a : m_subAlgms ) {
973 a->commitHandles();
974 }
975 }
976
977 void Algorithm::registerTool( IAlgTool* tool ) const
978 {
979 if ( msgLevel( MSG::DEBUG ) ) {
980 debug() << "Registering tool " << tool->name() << endmsg;
981 }
982 m_tools.push_back( tool );
983 }
984
985 void Algorithm::deregisterTool( IAlgTool* tool ) const
986 {
987 std::vector<IAlgTool*>::iterator it = std::find( m_tools.begin(), m_tools.end(), tool );
988 if ( it != m_tools.end() ) {
989 if ( msgLevel( MSG::DEBUG ) ) debug() << "De-Registering tool " << tool->name() << endmsg;
990 m_tools.erase( it );
991 } else {
992 if ( msgLevel( MSG::DEBUG ) ) debug() << "Could not de-register tool " << tool->name() << endmsg;
993 }
994 }
995
996 std::ostream& Algorithm::toControlFlowExpression( std::ostream& os ) const
997 {
998 return os << type() << "('" << name() << "')";
999 }
1000
1001 unsigned int Algorithm::errorCount() const { return m_aess->algErrorCount( static_cast<const IAlgorithm*>( this ) ); }
Algorithm::endRun
StatusCode endRun() override
Algorithm end run. This method is called at the end of the event loop.
Definition: Algorithm.cpp:500
IAuditor::Start
Definition: IAuditor.h:25
Algorithm::resetExecuted
void resetExecuted() override
Reset the executed state of the Algorithm for the duration of the current event.
Definition: Algorithm.cpp:754
IAuditor::BeginRun
Definition: IAuditor.h:25
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:128
ServiceLocatorHelper
an helper to share the implementation of service() among the various kernel base classes ...
Definition: ServiceLocatorHelper.h:17
Algorithm::contextSvc
SmartIF< IAlgContextSvc > & contextSvc() const
get Algorithm Context Service
Definition: Algorithm.cpp:805
Gaudi::StateMachine::INITIALIZED
Definition: StateMachine.h:17
StatusCode::SUCCESS
Definition: StatusCode.h:31
Algorithm::ntupleSvc
SmartIF< INTupleSvc > & ntupleSvc() const
The standard N tuple service.
Definition: Algorithm.cpp:801
Algorithm.h
Algorithm::detCnvSvc
SmartIF< IConversionSvc > & detCnvSvc() const
The standard detector data persistency conversion service.
Definition: Algorithm.cpp:797
SmartIF
Small smart pointer class with automatic reference counting for IInterface.
Definition: IConverter.h:15
Kernel.h
Algorithm::randSvc
SmartIF< IRndmGenSvc > & randSvc() const
The standard RandomGen service, Return a pointer to the service if present.
Definition: Algorithm.cpp:802
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:22
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
Algorithm::commitHandles
void commitHandles() override
Definition: Algorithm.cpp:959
Algorithm::sysEndRun
StatusCode sysEndRun() override
endRun method invoked by the framework.
Definition: Algorithm.cpp:455
Algorithm::createSubAlgorithm
StatusCode createSubAlgorithm(const std::string &type, const std::string &name, Algorithm *&pSubAlg)
Create a sub algorithm.
Definition: Algorithm.cpp:837
Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:731
gaudirun.c
c
Definition: gaudirun.py:407
Gaudi::StateMachine::CONFIGURED
Definition: StateMachine.h:16
Gaudi::Utils::AlgContext
Helper "sentry" class to automatize the safe register/unregister the algorithm&#39;s context.
Definition: IAlgContextSvc.h:77
Algorithm::initToolHandles
void initToolHandles() const
Definition: Algorithm.cpp:858
Algorithm::histoSvc
SmartIF< IHistogramSvc > & histoSvc() const
The standard histogram service.
Definition: Algorithm.cpp:800
Algorithm::setFilterPassed
void setFilterPassed(bool state) const override
Set the filter passed flag to the specified state.
Definition: Algorithm.cpp:768
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
StatusCode::FAILURE
Definition: StatusCode.h:31
compareRootHistos.state
state
Definition: compareRootHistos.py:422
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:319
Algorithm::acceptDHVisitor
virtual void acceptDHVisitor(IDataHandleVisitor *) const override
Definition: Algorithm.cpp:231
EventContext::slot
ContextID_t slot() const
Definition: EventContext.h:40
Algorithm::isExecuted
bool isExecuted() const override
Has this algorithm been executed since the last reset?
Definition: Algorithm.cpp:741
Algorithm::eventSvc
SmartIF< IDataProviderSvc > & eventSvc() const
The standard event data service.
Definition: Algorithm.cpp:798
DataObjID
Definition: DataObjID.h:37
MsgStream.h
IAuditor::Stop
Definition: IAuditor.h:25
AlgTool::commitHandles
void commitHandles() override
Definition: AlgTool.cpp:530
TimelineEvent::thread
pthread_t thread
Definition: ITimelineSvc.h:14
ToolHandleInfo::isPublic
bool isPublic() const noexcept
Definition: ToolHandle.h:37
Algorithm::toControlFlowExpression
std::ostream & toControlFlowExpression(std::ostream &os) const override
Produce string represention of the control flow expression.
Definition: Algorithm.cpp:996
Gaudi::StateMachine::FINALIZE
Definition: StateMachine.h:30
Algorithm::setProperties
StatusCode setProperties()
Set the algorithm&#39;s properties.
Definition: Algorithm.cpp:812
Gaudi::Functional::execute
StatusCode execute() override final
Stat
Small wrapper class for easy manipulation with generic counters and IStatSvc&ICounterSvc interface...
Definition: Stat.h:46
IAuditor::ReInitialize
Definition: IAuditor.h:25
Algorithm::sysBeginRun
StatusCode sysBeginRun() override
beginRun method invoked by the framework.
Definition: Algorithm.cpp:407
IAuditorSvc.h
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
AlgTool.h
ThreadLocalContext.h
MSG::DEBUG
Definition: IMessageSvc.h:16
Algorithm::toolSvc
SmartIF< IToolSvc > & toolSvc() const
The standard ToolSvc service, Return a pointer to the service if present.
Definition: Algorithm.cpp:803
Algorithm::service_i
StatusCode service_i(const std::string &svcName, bool createIf, const InterfaceID &iid, void **ppSvc) const
implementation of service method
Definition: Algorithm.cpp:939
BaseToolHandle
Non-templated base class for actual ToolHandle<T>.
Definition: ToolHandle.h:67
TimelineEvent::algorithm
std::string algorithm
Definition: ITimelineSvc.h:18
TimelineEvent::event
uint event
Definition: ITimelineSvc.h:16
Chrono.h
std::end
T end(T...args)
Algorithm::eventCnvSvc
SmartIF< IConversionSvc > & eventCnvSvc() const
The standard event data persistency conversion service.
Definition: Algorithm.cpp:799
TimelineEvent
Definition: ITimelineSvc.h:13
Algorithm::setIndex
void setIndex(const unsigned int &idx) override
set instantiation index of Alg
Definition: Algorithm.cpp:739
MSG::VERBOSE
Definition: IMessageSvc.h:16
IToolSvc.h
Algorithm::errorCount
unsigned int errorCount() const
Get the number of failures of the algorithm.
Definition: Algorithm.cpp:1001
EventContext
This class represents an entry point to all the event specific data.
Definition: EventContext.h:24
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
ThreadGaudi.h
isGaudiThreaded
GAUDI_API bool isGaudiThreaded(const std::string &name)
test if current Gaudi object is running /will run in a thread
Definition: ThreadGaudi.cpp:76
IAuditor::ReStart
Definition: IAuditor.h:25
Gaudi::StringKey
The helper class to represent the efficient "key" for access.
Definition: StringKey.h:35
Algorithm::algExecStateSvc
SmartIF< IAlgExecStateSvc > & algExecStateSvc() const
Definition: Algorithm.cpp:793
GaudiException::code
virtual const StatusCode & code() const
StatusCode for Exception.
Definition: GaudiException.h:119
Algorithm::sysRestart
StatusCode sysRestart() override
Restart method invoked by the framework.
Definition: Algorithm.cpp:354
Algorithm::index
unsigned int index() const override
Definition: Algorithm.cpp:737
EventContext::evt
ContextEvt_t evt() const
Definition: EventContext.h:39
std::string
STL class.
Algorithm::registerTool
void registerTool(IAlgTool *tool) const
Definition: Algorithm.cpp:977
TimelineEvent::end
time_point end
Definition: ITimelineSvc.h:21
IDataHandleVisitor::visit
virtual void visit(const IDataHandleHolder *)=0
InterfaceID
Interface ID class.
Definition: IInterface.h:29
Algorithm::isEnabled
bool isEnabled() const override
Is this algorithm enabled or disabled?
Definition: Algorithm.cpp:760
Gaudi::StateMachine::INITIALIZE
Definition: StateMachine.h:27
IDataManagerSvc.h
IDataProviderSvc.h
IJobOptionsSvc
Main interface for the JobOptions service.
Definition: IJobOptionsSvc.h:20
Algorithm::sysReinitialize
StatusCode sysReinitialize() override
Reinitialization method invoked by the framework.
Definition: Algorithm.cpp:296
std::exception::what
T what(T...args)
HiveAlgSequencer.h
h
Definition: HiveAlgSequencer.py:24
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
GaudiException.h
gaudirun.type
type
Definition: gaudirun.py:133
IAuditor::Finalize
Definition: IAuditor.h:25
Algorithm::beginRun
StatusCode beginRun() override
Algorithm begin run.
Definition: Algorithm.cpp:452
Algorithm::sysStart
StatusCode sysStart() override
Reinitialization method invoked by the framework.
Definition: Algorithm.cpp:244
Algorithm::sysFinalize
StatusCode sysFinalize() override
System finalization.
Definition: Algorithm.cpp:643
MSG::NIL
Definition: IMessageSvc.h:16
Guards.h
Gaudi::Hive::currentContext
GAUDI_API const EventContext & currentContext()
Definition: ThreadLocalContext.cpp:24
IOTest.start
start
Definition: IOTest.py:99
DHHVisitor
Definition: DataHandleHolderVisitor.h:8
StringKey.h
GaudiException::tag
virtual const std::string & tag() const
name tag for the exception, or exception type
Definition: GaudiException.h:109
Algorithm::exceptionSvc
SmartIF< IExceptionSvc > & exceptionSvc() const
Get the exception Service.
Definition: Algorithm.cpp:804
std::unordered_set< DataObjID, DataObjID_Hasher >
IMessageSvc.h
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
DataHandleHolderVisitor.h
std::exception
STL class.
IAlgorithm
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:28
Algorithm::Algorithm
Algorithm(const std::string &name, ISvcLocator *svcloc, const std::string &version=PACKAGE_VERSION)
Constructor.
Definition: Algorithm.cpp:47
IAuditor::Initialize
Definition: IAuditor.h:25
Algorithm::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition: Algorithm.cpp:809
Gaudi::StateMachine::STOP
Definition: StateMachine.h:29
Algorithm::version
const std::string & version() const override
Definition: Algorithm.cpp:735
TimelineEvent::start
time_point start
Definition: ITimelineSvc.h:20
Algorithm::whiteboard
SmartIF< IHiveWhiteBoard > & whiteboard() const
Definition: Algorithm.cpp:807
Algorithm::get_svc_
SmartIF< IFace > & get_svc_(SmartIF< IFace > &p, const char *service_name) const
Definition: Algorithm.cpp:781
Algorithm::auditorSvc
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Algorithm.cpp:794
Algorithm::detSvc
SmartIF< IDataProviderSvc > & detSvc() const
The standard detector data service.
Definition: Algorithm.cpp:796
IDataHandleVisitor
Definition: IDataHandleHolder.h:38
Algorithm::subAlgorithms
const std::vector< Algorithm * > * subAlgorithms() const
List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms.
Definition: Algorithm.cpp:776
IAlgContextSvc.h
Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:78
std::unordered_set::find
T find(T...args)
Gaudi::StateMachine::RUNNING
Definition: StateMachine.h:18
std::set
STL class.
Algorithm::chronoSvc
SmartIF< IChronoStatSvc > & chronoSvc() const
The standard Chrono & Stat service, Return a pointer to the service if present.
Definition: Algorithm.cpp:795
std::vector< Algorithm * >
IRndmGenSvc.h
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:11
Algorithm::deregisterTool
void deregisterTool(IAlgTool *tool) const
Definition: Algorithm.cpp:985
IConversionSvc.h
std::begin
T begin(T...args)
genconfuser.verbose
verbose
Definition: genconfuser.py:19
std::chrono::high_resolution_clock::now
T now(T...args)
TimelineEvent::slot
uint slot
Definition: ITimelineSvc.h:15
Algorithm::restart
StatusCode restart() override
the default (empty) implementation of IStateful::restart() method
Definition: Algorithm.cpp:715
Algorithm::filterPassed
bool filterPassed() const override
Did this algorithm pass or fail its filter criterion for the last event?
Definition: Algorithm.cpp:762
AlgTool
Base class from which all the concrete tool classes should be derived.
Definition: AlgTool.h:48
IAlgTool
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
ToolHandle.h
IAuditor::Execute
Definition: IAuditor.h:25
std::unordered_set::emplace
T emplace(T...args)
IOTest.appMgr
appMgr
Definition: IOTest.py:94
gaudirun.s
string s
Definition: gaudirun.py:253
Gaudi::StateMachine::START
Definition: StateMachine.h:28
Algorithm::setExecuted
void setExecuted(bool state) const override
Set the executed flag to the specified state.
Definition: Algorithm.cpp:747
ServiceLocatorHelper.h
Stat.h
AlgExecState::State
State
Definition: IAlgExecStateSvc.h:30
IAlgManager.h
IAuditor::EndRun
Definition: IAuditor.h:25
std::sort
T sort(T...args)
BaseToolHandle::get
const IAlgTool * get() const
Definition: ToolHandle.h:78
Algorithm::service
StatusCode service(const std::string &name, T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: Algorithm.h:231
std::accumulate
T accumulate(T...args)
Algorithm::tools
const std::vector< IAlgTool * > & tools() const
Definition: Algorithm.cpp:923
Algorithm::nameKey
const Gaudi::StringKey & nameKey() const override
Definition: Algorithm.cpp:733
IProperty
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:20
Gaudi::Guards::AuditorGuard
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:215
DataObjID::fullKey
std::string fullKey() const
Definition: DataObjID.cpp:54
Algorithm::sysInitialize
StatusCode sysInitialize() override
Initialization method invoked by the framework.
Definition: Algorithm.cpp:78
getGaudiThreadIDfromName
GAUDI_API std::string getGaudiThreadIDfromName(const std::string &name)
helper function to extract Gaudi Thread ID from thread copy name
Definition: ThreadGaudi.cpp:27
Algorithm::reinitialize
StatusCode reinitialize() override
the default (empty) implementation of IStateful::reinitialize() method
Definition: Algorithm.cpp:694
std::ostream
STL class.
ISvcLocator.h
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
INamedInterface::name
virtual const std::string & name() const =0
Retrieve the name of the instance.
Algorithm::sysExecute
StatusCode sysExecute(const EventContext &ctx) override
The actions to be performed by the algorithm on an event.
Definition: Algorithm.cpp:502
Algorithm::sysStop
StatusCode sysStop() override
System stop.
Definition: Algorithm.cpp:596
getGaudiThreadGenericName
GAUDI_API std::string getGaudiThreadGenericName(const std::string &name)
helper function to extract Gaudi instance name from thread copy name
Definition: ThreadGaudi.cpp:52
IExceptionSvc.h
INTupleSvc.h
IHistogramSvc.h
IJobOptionsSvc.h
Algorithm::timelineSvc
SmartIF< ITimelineSvc > & timelineSvc() const
Definition: Algorithm.cpp:806