| The Gaudi Framework v28r2-patches (bc4ad17a)

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

- File List
- File Members

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