| The Gaudi Framework v30r0 (c919700c)

- 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. First initialize ToolHandles if needed
182 try {
183 if ( !m_toolHandlesInit ) initToolHandles();
184 } catch ( const GaudiException& Exception ) {
185 error() << "Failing initializing ToolHandles : " << Exception << endmsg;
186 return StatusCode::FAILURE;
187 }
188 DHHVisitor avis( m_inputDataObjs, m_outputDataObjs );
189 acceptDHVisitor( &avis );
190
191 // check for implicit circular data deps from child Algs/AlgTools
192 for ( auto& h : m_outputDataObjs ) {
193 auto i = m_inputDataObjs.find( h );
194 if ( i != m_inputDataObjs.end() ) {
195 if ( m_filterCircDeps ) {
196 warning() << "Implicit circular data dependency detected for id " << h << endmsg;
197 m_inputDataObjs.erase( i );
198 } else {
199 error() << "Implicit circular data dependency detected for id " << h << endmsg;
200 sc = StatusCode::FAILURE;
201 }
202 }
203 }
204
205 if ( !sc ) return sc;
206
207 if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) {
208 // sort out DataObjects by path so that logging is reproducable
209 // we define a little helper creating an ordered set from a non ordered one
210 auto sort = []( const DataObjID a, const DataObjID b ) -> bool { return a.fullKey() < b.fullKey(); };
211 auto orderset = [&sort]( const DataObjIDColl& in ) -> std::set<DataObjID, decltype( sort )> {
212 return {in.begin(), in.end(), sort};
213 };
214 // Logging
215 debug() << "Data Deps for " << name();
216 for ( auto h : orderset( m_inputDataObjs ) ) {
217 debug() << "\n + INPUT " << h;
218 }
219 for ( auto id : orderset( avis.ignoredInpKeys() ) ) {
220 debug() << "\n + INPUT IGNORED " << id;
221 }
222 for ( auto h : orderset( m_outputDataObjs ) ) {
223 debug() << "\n + OUTPUT " << h;
224 }
225 for ( auto id : orderset( avis.ignoredOutKeys() ) ) {
226 debug() << "\n + OUTPUT IGNORED " << id;
227 }
228 debug() << endmsg;
229 }
230
231 // initialize handles
232 initDataHandleHolder();
233
234 return sc;
235 }
236
237 void Algorithm::acceptDHVisitor( IDataHandleVisitor* vis ) const
238 {
239
240 vis->visit( this );
241
242 // loop through tools
243 for ( auto tool : tools() ) vis->visit( dynamic_cast<AlgTool*>( tool ) );
244
245 // loop through sub-algs
246 for ( auto alg : *subAlgorithms() ) vis->visit( alg );
247 }
248
249 // IAlgorithm implementation
250 StatusCode Algorithm::sysStart()
251 {
252
253 // Bypass the startup if already running or disabled.
254 if ( Gaudi::StateMachine::RUNNING == FSMState() || !isEnabled() ) return StatusCode::SUCCESS;
255
256 m_targetState = Gaudi::StateMachine::ChangeState( Gaudi::StateMachine::START, m_state );
257
258 // lock the context service
259 Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr );
260
261 StatusCode sc( StatusCode::FAILURE );
262 // Invoke start() method of the derived class inside a try/catch clause
263 try {
264 { // limit the scope of the guard
265 Gaudi::Guards::AuditorGuard guard( this,
266 // check if we want to audit the initialize
267 ( m_auditorStart ) ? auditorSvc().get() : nullptr, IAuditor::Start );
268 // Invoke the start() method of the derived class
269 sc = start();
270 }
271 if ( sc.isSuccess() ) {
272
273 // Now start any sub-algorithms
274 if ( !for_algorithms<&Algorithm::sysStart>( m_subAlgms ) ) {
275 sc = StatusCode::FAILURE;
276 error() << " Error starting one or several sub-algorithms" << endmsg;
277 } else {
278 // Update the state.
279 m_state = m_targetState;
280 }
281 }
282 } catch ( const GaudiException& Exception ) {
283 fatal() << "in sysStart(): exception with tag=" << Exception.tag() << " is caught" << endmsg;
284 error() << Exception << endmsg;
285 Stat stat( chronoSvc(), Exception.tag() );
286 sc = StatusCode::FAILURE;
287 } catch ( const std::exception& Exception ) {
288 fatal() << "in sysStart(): standard std::exception is caught" << endmsg;
289 error() << Exception.what() << endmsg;
290 Stat stat( chronoSvc(), "*std::exception*" );
291 sc = StatusCode::FAILURE;
292 } catch ( ... ) {
293 fatal() << "in sysStart(): UNKNOWN Exception is caught" << endmsg;
294 Stat stat( chronoSvc(), "*UNKNOWN Exception*" );
295 sc = StatusCode::FAILURE;
296 }
297
298 return sc;
299 }
300
301 // IAlgorithm implementation
302 StatusCode Algorithm::sysReinitialize()
303 {
304
305 // Bypass the initialization if the algorithm is disabled.
306 if ( !isEnabled() ) return StatusCode::SUCCESS;
307
308 // Check that the current status is the correct one.
309 if ( Gaudi::StateMachine::INITIALIZED != FSMState() ) {
310 error() << "sysReinitialize(): cannot reinitialize algorithm not initialized" << endmsg;
311 return StatusCode::FAILURE;
312 }
313
314 // Reset Error count
315 // m_errorCount = 0; // done during start
316
317 // lock the context service
318 Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr );
319
320 StatusCode sc( StatusCode::SUCCESS );
321 // Invoke reinitialize() method of the derived class inside a try/catch clause
322 try {
323 { // limit the scope of the guard
324 Gaudi::Guards::AuditorGuard guard( this,
325 // check if we want to audit the initialize
326 ( m_auditorReinitialize ) ? auditorSvc().get() : nullptr,
327 IAuditor::ReInitialize );
328 // Invoke the reinitialize() method of the derived class
329 sc = reinitialize();
330 }
331 if ( sc.isSuccess() ) {
332
333 // Now initialize care of any sub-algorithms
334 if ( !for_algorithms<&Algorithm::sysReinitialize>( m_subAlgms ) ) {
335 sc = StatusCode::FAILURE;
336 error() << "sysReinitialize(): Error reinitializing one or several "
337 << "sub-algorithms" << endmsg;
338 }
339 }
340 } catch ( const GaudiException& Exception ) {
341 fatal() << "sysReinitialize(): Exception with tag=" << Exception.tag() << " is caught" << endmsg;
342 error() << Exception << endmsg;
343 Stat stat( chronoSvc(), Exception.tag() );
344 sc = StatusCode::FAILURE;
345 } catch ( const std::exception& Exception ) {
346 fatal() << "sysReinitialize(): Standard std::exception is caught" << endmsg;
347 error() << Exception.what() << endmsg;
348 Stat stat( chronoSvc(), "*std::exception*" );
349 sc = StatusCode::FAILURE;
350 } catch ( ... ) {
351 fatal() << "sysReinitialize(): UNKNOWN Exception is caught" << endmsg;
352 Stat stat( chronoSvc(), "*UNKNOWN Exception*" );
353 sc = StatusCode::FAILURE;
354 }
355
356 return sc;
357 }
358
359 // IAlgorithm implementation
360 StatusCode Algorithm::sysRestart()
361 {
362
363 // Bypass the initialization if the algorithm is disabled.
364 if ( !isEnabled() ) return StatusCode::SUCCESS;
365
366 // Check that the current status is the correct one.
367 if ( Gaudi::StateMachine::RUNNING != FSMState() ) {
368 error() << "sysRestart(): cannot restart algorithm not started" << endmsg;
369 return StatusCode::FAILURE;
370 }
371
372 // lock the context service
373 Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr );
374
375 StatusCode sc( StatusCode::FAILURE );
376 // Invoke reinitialize() method of the derived class inside a try/catch clause
377 try {
378 { // limit the scope of the guard
379 Gaudi::Guards::AuditorGuard guard( this,
380 // check if we want to audit the initialize
381 ( m_auditorRestart ) ? auditorSvc().get() : nullptr, IAuditor::ReStart );
382 // Invoke the reinitialize() method of the derived class
383 sc = restart();
384 }
385 if ( sc.isSuccess() ) {
386
387 // Now initialize care of any sub-algorithms
388 if ( !for_algorithms<&Algorithm::sysRestart>( m_subAlgms ) ) {
389 sc = StatusCode::FAILURE;
390 error() << "sysRestart(): Error restarting one or several sub-algorithms" << endmsg;
391 }
392 }
393 } catch ( const GaudiException& Exception ) {
394 fatal() << "sysRestart(): Exception with tag=" << Exception.tag() << " is caught" << endmsg;
395 error() << Exception << endmsg;
396 Stat stat( chronoSvc(), Exception.tag() );
397 sc = StatusCode::FAILURE;
398 } catch ( const std::exception& Exception ) {
399 fatal() << "sysRestart(): Standard std::exception is caught" << endmsg;
400 error() << Exception.what() << endmsg;
401 Stat stat( chronoSvc(), "*std::exception*" );
402 sc = StatusCode::FAILURE;
403 } catch ( ... ) {
404 fatal() << "sysRestart(): UNKNOWN Exception is caught" << endmsg;
405 Stat stat( chronoSvc(), "*UNKNOWN Exception*" );
406 sc = StatusCode::FAILURE;
407 }
408
409 return sc;
410 }
411
412 // IAlgorithm implementation
413 StatusCode Algorithm::sysBeginRun()
414 {
415
416 // Bypass the beginRun if the algorithm is disabled.
417 if ( !isEnabled() ) return StatusCode::SUCCESS;
418
419 // lock the context service
420 Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr );
421
422 StatusCode sc( StatusCode::FAILURE );
423 // Invoke beginRun() method of the derived class inside a try/catch clause
424 try {
425 { // limit the scope of the guard
426 Gaudi::Guards::AuditorGuard guard( this,
427 // check if we want to audit the initialize
428 ( m_auditorBeginRun ) ? auditorSvc().get() : nullptr, IAuditor::BeginRun );
429 // Invoke the beginRun() method of the derived class
430 sc = beginRun();
431 }
432 if ( sc.isSuccess() ) {
433
434 // Now call beginRun for any sub-algorithms
435 if ( !for_algorithms<&Algorithm::sysBeginRun>( m_subAlgms ) ) {
436 sc = StatusCode::FAILURE;
437 error() << " Error executing BeginRun for one or several sub-algorithms" << endmsg;
438 }
439 }
440 } catch ( const GaudiException& Exception ) {
441 fatal() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
442 error() << Exception << endmsg;
443 Stat stat( chronoSvc(), Exception.tag() );
444 sc = StatusCode::FAILURE;
445 } catch ( const std::exception& Exception ) {
446 fatal() << " Standard std::exception is caught " << endmsg;
447 error() << Exception.what() << endmsg;
448 Stat stat( chronoSvc(), "*std::exception*" );
449 sc = StatusCode::FAILURE;
450 } catch ( ... ) {
451 fatal() << "UNKNOWN Exception is caught " << endmsg;
452 Stat stat( chronoSvc(), "*UNKNOWN Exception*" );
453 sc = StatusCode::FAILURE;
454 }
455 return sc;
456 }
457
458 StatusCode Algorithm::beginRun() { return StatusCode::SUCCESS; }
459
460 // IAlgorithm implementation
461 StatusCode Algorithm::sysEndRun()
462 {
463
464 // Bypass the endRun if the algorithm is disabled.
465 if ( !isEnabled() ) return StatusCode::SUCCESS;
466
467 // lock the context service
468 Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr );
469
470 // Invoke endRun() method of the derived class inside a try/catch clause
471 StatusCode sc( StatusCode::FAILURE );
472 try {
473 { // limit the scope of the guard
474 Gaudi::Guards::AuditorGuard guard( this,
475 // check if we want to audit the initialize
476 ( m_auditorEndRun ) ? auditorSvc().get() : nullptr, IAuditor::EndRun );
477 // Invoke the endRun() method of the derived class
478 sc = endRun();
479 }
480 if ( sc.isSuccess() ) {
481
482 // Now call endRun for any sub-algorithms
483 if ( !for_algorithms<&Algorithm::sysEndRun>( m_subAlgms ) ) {
484 sc = StatusCode::FAILURE;
485 error() << " Error calling endRun for one or several sub-algorithms" << endmsg;
486 }
487 }
488 } catch ( const GaudiException& Exception ) {
489 fatal() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
490 error() << Exception << endmsg;
491 Stat stat( chronoSvc(), Exception.tag() );
492 sc = StatusCode::FAILURE;
493 } catch ( const std::exception& Exception ) {
494 fatal() << " Standard std::exception is caught " << endmsg;
495 error() << Exception.what() << endmsg;
496 Stat stat( chronoSvc(), "*std::exception*" );
497 sc = StatusCode::FAILURE;
498 } catch ( ... ) {
499 fatal() << "UNKNOWN Exception is caught " << endmsg;
500 Stat stat( chronoSvc(), "*UNKNOWN Exception*" );
501 sc = StatusCode::FAILURE;
502 }
503 return sc;
504 }
505
506 StatusCode Algorithm::endRun() { return StatusCode::SUCCESS; }
507
508 StatusCode Algorithm::sysExecute( const EventContext& ctx )
509 {
510
511 m_event_context = ctx;
512
513 if ( !isEnabled() ) {
514 if ( msgLevel( MSG::VERBOSE ) ) {
515 verbose() << ".sysExecute(): is not enabled. Skip execution" << endmsg;
516 }
517 return StatusCode::SUCCESS;
518 }
519
520 StatusCode status;
521
522 // Should performance profile be performed ?
523 // invoke execute() method of Algorithm class
524 // and catch all uncaught exceptions
525
526 // lock the context service
527 Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr );
528
529 Gaudi::Guards::AuditorGuard guard( this,
530 // check if we want to audit the initialize
531 ( m_auditorExecute ) ? auditorSvc().get() : nullptr, IAuditor::Execute, status );
532
533 TimelineEvent timeline;
534 timeline.algorithm = this->name();
535 timeline.thread = pthread_self();
536 timeline.slot = ctx.slot();
537 timeline.event = ctx.evt();
538
539 try {
540
541 if ( UNLIKELY( m_doTimeline ) ) timeline.start = Clock::now();
542
543 status = execute();
544
545 if ( UNLIKELY( m_doTimeline ) ) timeline.end = Clock::now();
546
547 setExecuted( true ); // set the executed flag
548
549 if ( status.isFailure() ) {
550 status = exceptionSvc()->handleErr( *this, status );
551 }
552
553 } catch ( const GaudiException& Exception ) {
554 setExecuted( true ); // set the executed flag
555
556 if ( Exception.code() == StatusCode::FAILURE ) {
557 fatal();
558 } else {
559 error() << " Recoverable";
560 }
561
562 msgStream() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
563
564 error() << Exception << endmsg;
565
566 // Stat stat( chronoSvc() , Exception.tag() ) ;
567 status = exceptionSvc()->handle( *this, Exception );
568 } catch ( const std::exception& Exception ) {
569 setExecuted( true ); // set the executed flag
570
571 fatal() << " Standard std::exception is caught " << endmsg;
572 error() << Exception.what() << endmsg;
573 // Stat stat( chronoSvc() , "*std::exception*" ) ;
574 status = exceptionSvc()->handle( *this, Exception );
575 } catch ( ... ) {
576 setExecuted( true ); // set the executed flag
577
578 fatal() << "UNKNOWN Exception is caught " << endmsg;
579 // Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
580
581 status = exceptionSvc()->handle( *this );
582 }
583
584 if ( UNLIKELY( m_doTimeline ) ) timelineSvc()->registerTimelineEvent( timeline );
585
586 if ( status.isFailure() ) {
587 // Increment the error count
588 unsigned int nerr = m_aess->incrementErrorCount( this );
589 // Check if maximum is exeeded
590 if ( nerr < m_errorMax ) {
591 warning() << "Continuing from error (cnt=" << nerr << ", max=" << m_errorMax << ")" << endmsg;
592 // convert to success
593 status = StatusCode::SUCCESS;
594 } else {
595 error() << "Maximum number of errors (" << m_errorMax << ") reached." << endmsg;
596 }
597 }
598 return status;
599 }
600
601 // IAlgorithm implementation
602 StatusCode Algorithm::sysStop()
603 {
604
605 // Bypass the startup if already running or disabled.
606 if ( Gaudi::StateMachine::INITIALIZED == FSMState() || !isEnabled() ) return StatusCode::SUCCESS;
607
608 m_targetState = Gaudi::StateMachine::ChangeState( Gaudi::StateMachine::STOP, m_state );
609
610 // lock the context service
611 Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr );
612
613 StatusCode sc( StatusCode::FAILURE );
614 // Invoke stop() method of the derived class inside a try/catch clause
615 try {
616 // Stop first any sub-algorithms (in reverse order -- not?)
617 for_algorithms<&Algorithm::sysStop>( m_subAlgms );
618 { // limit the scope of the guard
619 Gaudi::Guards::AuditorGuard guard( this,
620 // check if we want to audit the initialize
621 ( m_auditorStop ) ? auditorSvc().get() : nullptr, IAuditor::Stop );
622
623 // Invoke the stop() method of the derived class
624 sc = stop();
625 }
626 if ( sc.isSuccess() ) {
627 // Update the state.
628 m_state = m_targetState;
629 }
630 } catch ( const GaudiException& Exception ) {
631 fatal() << "in sysStop(): exception with tag=" << Exception.tag() << " is caught" << endmsg;
632 error() << Exception << endmsg;
633 Stat stat( chronoSvc(), Exception.tag() );
634 sc = StatusCode::FAILURE;
635 } catch ( const std::exception& Exception ) {
636 fatal() << "in sysStop(): standard std::exception is caught" << endmsg;
637 error() << Exception.what() << endmsg;
638 Stat stat( chronoSvc(), "*std::exception*" );
639 sc = StatusCode::FAILURE;
640 } catch ( ... ) {
641 fatal() << "in sysStop(): UNKNOWN Exception is caught" << endmsg;
642 Stat stat( chronoSvc(), "*UNKNOWN Exception*" );
643 sc = StatusCode::FAILURE;
644 }
645
646 return sc;
647 }
648
649 StatusCode Algorithm::sysFinalize()
650 {
651
652 // Bypass the finalialization if the algorithm hasn't been initilized.
653 if ( Gaudi::StateMachine::CONFIGURED == FSMState() || !isEnabled() ) return StatusCode::SUCCESS;
654
655 m_targetState = Gaudi::StateMachine::ChangeState( Gaudi::StateMachine::FINALIZE, m_state );
656
657 // lock the context service
658 Gaudi::Utils::AlgContext cnt( this, registerContext() ? contextSvc().get() : nullptr );
659
660 StatusCode sc( StatusCode::FAILURE );
661 // Invoke finalize() method of the derived class inside a try/catch clause
662 try {
663 // Order changed (bug #3903 overview: finalize and nested algorithms)
664 // Finalize first any sub-algorithms (it can be done more than once)
665 bool ok = for_algorithms<&Algorithm::sysFinalize>( m_subAlgms );
666 { // limit the scope of the guard
667 Gaudi::Guards::AuditorGuard guard( this,
668 // check if we want to audit the initialize
669 ( m_auditorFinalize ) ? auditorSvc().get() : nullptr, IAuditor::Finalize );
670 // Invoke the finalize() method of the derived class
671 sc = finalize();
672 }
673 if ( !ok ) sc = StatusCode::FAILURE;
674
675 if ( sc.isSuccess() ) {
676
677 // Release all sub-algorithms
678 for ( auto& it : m_subAlgms ) it->release();
679 // Indicate that this Algorithm has been finalized to prevent duplicate attempts
680 m_state = m_targetState;
681 }
682 } catch ( const GaudiException& Exception ) {
683 fatal() << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
684 error() << Exception << endmsg;
685 Stat stat( chronoSvc(), Exception.tag() );
686 sc = StatusCode::FAILURE;
687 } catch ( const std::exception& Exception ) {
688 fatal() << " Standard std::exception is caught " << endmsg;
689 error() << Exception.what() << endmsg;
690 Stat stat( chronoSvc(), "*std::exception*" );
691 sc = StatusCode::FAILURE;
692 } catch ( ... ) {
693 fatal() << "UNKNOWN Exception is caught " << endmsg;
694 Stat stat( chronoSvc(), "*UNKNOWN Exception*" );
695 sc = StatusCode::FAILURE;
696 }
697 return sc;
698 }
699
700 StatusCode Algorithm::reinitialize()
701 {
702 /* @TODO
703 * MCl 2008-10-23: the implementation of reinitialize as finalize+initialize
704 * is causing too many problems
705 *
706 // Default implementation is finalize+initialize
707 StatusCode sc = finalize();
708 if (sc.isFailure()) {
709 error() << "reinitialize(): cannot be finalized" << endmsg;
710 return sc;
711 }
712 sc = initialize();
713 if (sc.isFailure()) {
714 error() << "reinitialize(): cannot be initialized" << endmsg;
715 return sc;
716 }
717 */
718 return StatusCode::SUCCESS;
719 }
720
721 StatusCode Algorithm::restart()
722 {
723 // Default implementation is stop+start
724 StatusCode sc = stop();
725 if ( sc.isFailure() ) {
726 error() << "restart(): cannot be stopped" << endmsg;
727 return sc;
728 }
729 sc = start();
730 if ( sc.isFailure() ) {
731 error() << "restart(): cannot be started" << endmsg;
732 return sc;
733 }
734 return StatusCode::SUCCESS;
735 }
736
737 const std::string& Algorithm::name() const { return m_name.str(); }
738
739 const Gaudi::StringKey& Algorithm::nameKey() const { return m_name; }
740
741 const std::string& Algorithm::version() const { return m_version; }
742
743 unsigned int Algorithm::index() const { return m_index; }
744
745 void Algorithm::setIndex( const unsigned int& idx ) { m_index = idx; }
746
747 bool Algorithm::isExecuted() const
748 {
749 const EventContext& context = Gaudi::Hive::currentContext();
750 return algExecStateSvc()->algExecState( (IAlgorithm*)this, context ).state() == AlgExecState::State::Done;
751 }
752
753 void Algorithm::setExecuted( bool state ) const
754 {
755 const EventContext& context = Gaudi::Hive::currentContext();
756 AlgExecState::State s = state ? AlgExecState::State::Done : AlgExecState::State::None;
757 algExecStateSvc()->algExecState( const_cast<IAlgorithm*>( (const IAlgorithm*)this ), context ).setState( s );
758 }
759
760 void Algorithm::resetExecuted()
761 {
762 const EventContext& context = Gaudi::Hive::currentContext();
763 return algExecStateSvc()->algExecState( (IAlgorithm*)this, context ).reset();
764 }
765
766 bool Algorithm::isEnabled() const { return m_isEnabled; }
767
768 bool Algorithm::filterPassed() const
769 {
770 const EventContext& context = Gaudi::Hive::currentContext();
771 return algExecStateSvc()->algExecState( (IAlgorithm*)this, context ).filterPassed();
772 }
773
774 void Algorithm::setFilterPassed( bool state ) const
775 {
776 const EventContext& context = Gaudi::Hive::currentContext();
777 algExecStateSvc()
778 ->algExecState( const_cast<IAlgorithm*>( (const IAlgorithm*)this ), context )
779 .setFilterPassed( state );
780 }
781
782 const std::vector<Algorithm*>* Algorithm::subAlgorithms() const { return &m_subAlgms; }
783
784 std::vector<Algorithm*>* Algorithm::subAlgorithms() { return &m_subAlgms; }
785
786 template <typename IFace>
787 SmartIF<IFace>& Algorithm::get_svc_( SmartIF<IFace>& p, const char* service_name ) const
788 {
789 if ( UNLIKELY( !p ) ) {
790 p = this->service( service_name );
791 if ( !p ) {
792 throw GaudiException( "Service [" + std::string{service_name} + "] not found", this->name(),
793 StatusCode::FAILURE );
794 }
795 }
796 return p;
797 }
798
799 SmartIF<IAlgExecStateSvc>& Algorithm::algExecStateSvc() const { return get_svc_( m_aess, "AlgExecStateSvc" ); }
800 SmartIF<IAuditorSvc>& Algorithm::auditorSvc() const { return get_svc_( m_pAuditorSvc, "AuditorSvc" ); }
801 SmartIF<IChronoStatSvc>& Algorithm::chronoSvc() const { return get_svc_( m_CSS, "ChronoStatSvc" ); }
802 SmartIF<IDataProviderSvc>& Algorithm::detSvc() const { return get_svc_( m_DDS, "DetectorDataSvc" ); }
803 SmartIF<IConversionSvc>& Algorithm::detCnvSvc() const { return get_svc_( m_DCS, "DetectorPersistencySvc" ); }
804 SmartIF<IDataProviderSvc>& Algorithm::eventSvc() const { return get_svc_( m_EDS, "EventDataSvc" ); }
805 SmartIF<IConversionSvc>& Algorithm::eventCnvSvc() const { return get_svc_( m_ECS, "EventPersistencySvc" ); }
806 SmartIF<IHistogramSvc>& Algorithm::histoSvc() const { return get_svc_( m_HDS, "HistogramDataSvc" ); }
807 SmartIF<INTupleSvc>& Algorithm::ntupleSvc() const { return get_svc_( m_NTS, "NTupleSvc" ); }
808 SmartIF<IRndmGenSvc>& Algorithm::randSvc() const { return get_svc_( m_RGS, "RndmGenSvc" ); }
809 SmartIF<IToolSvc>& Algorithm::toolSvc() const { return get_svc_( m_ptoolSvc, "ToolSvc" ); }
810 SmartIF<IExceptionSvc>& Algorithm::exceptionSvc() const { return get_svc_( m_EXS, "ExceptionSvc" ); }
811 SmartIF<IAlgContextSvc>& Algorithm::contextSvc() const { return get_svc_( m_contextSvc, "AlgContextSvc" ); }
812 SmartIF<ITimelineSvc>& Algorithm::timelineSvc() const { return get_svc_( m_timelineSvc, "TimelineSvc" ); }
813 SmartIF<IHiveWhiteBoard>& Algorithm::whiteboard() const { return get_svc_( m_WB, "EventDataSvc" ); }
814
815 SmartIF<ISvcLocator>& Algorithm::serviceLocator() const { return *const_cast<SmartIF<ISvcLocator>*>( &m_pSvcLocator ); }
816
817 // Use the job options service to set declared properties
818 StatusCode Algorithm::setProperties()
819 {
820 if ( !m_pSvcLocator ) return StatusCode::FAILURE;
821 auto jos = m_pSvcLocator->service<IJobOptionsSvc>( "JobOptionsSvc" );
822 if ( !jos ) return StatusCode::FAILURE;
823
824 // this initializes the messaging, in case property update handlers need to print
825 // and update the property value bypassing the update handler
826 m_outputLevel.value() = setUpMessaging();
827
828 // set first generic Properties
829 StatusCode sc = jos->setMyProperties( getGaudiThreadGenericName( name() ), this );
830 if ( sc.isFailure() ) return StatusCode::FAILURE;
831
832 // set specific Properties
833 if ( isGaudiThreaded( name() ) ) {
834 if ( jos->setMyProperties( name(), this ).isFailure() ) {
835 return StatusCode::FAILURE;
836 }
837 }
838
839 return sc;
840 }
841
842 StatusCode Algorithm::createSubAlgorithm( const std::string& type, const std::string& name, Algorithm*& pSubAlgorithm )
843 {
844 if ( !m_pSvcLocator ) return StatusCode::FAILURE;
845
846 SmartIF<IAlgManager> am( m_pSvcLocator );
847 if ( !am ) return StatusCode::FAILURE;
848
849 // Maybe modify the AppMgr interface to return Algorithm* ??
850 IAlgorithm* tmp;
851 StatusCode sc = am->createAlgorithm( type, name + getGaudiThreadIDfromName( Algorithm::name() ), tmp );
852 if ( sc.isFailure() ) return StatusCode::FAILURE;
853
854 try {
855 pSubAlgorithm = dynamic_cast<Algorithm*>( tmp );
856 m_subAlgms.push_back( pSubAlgorithm );
857 } catch ( ... ) {
858 sc = StatusCode::FAILURE;
859 }
860 return sc;
861 }
862
863 void Algorithm::initToolHandles() const
864 {
865
866 IAlgTool* tool = nullptr;
867 for ( auto thArr : m_toolHandleArrays ) {
868 if ( !thArr->retrieved() ) {
869 if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) )
870 debug() << "ToolHandleArray " << thArr->propertyName() << " not used: not registering any of its Tools"
871 << endmsg;
872 } else {
873 if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) )
874 debug() << "Registering all Tools in ToolHandleArray " << thArr->propertyName() << endmsg;
875 // Iterate over its tools:
876 for ( auto toolHandle : thArr->getBaseArray() ) {
877 // Try to cast it into a BaseToolHandle pointer:
878 BaseToolHandle* bth = dynamic_cast<BaseToolHandle*>( toolHandle );
879 if ( bth ) {
880 // If the cast was successful, the code is pretty simple:
881 tool = bth->get();
882 if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) {
883 debug() << "Adding " << ( bth->isPublic() ? "public" : "private" ) << " ToolHandle tool " << tool->name()
884 << " (" << tool->type() << ") from ToolHandleArray " << thArr->propertyName() << endmsg;
885 }
886 m_tools.push_back( tool );
887 } else {
888 // If it wasn't for some strange reason, then fall back on the
889 // logic implemented previously:
890 if ( toolSvc()->retrieveTool( toolHandle->typeAndName(), tool, this, false ).isSuccess() ) {
891 if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) {
892 debug() << "Adding private"
893 << " ToolHandle tool " << tool->name() << " (" << tool->type() << ") from ToolHandleArray "
894 << thArr->propertyName() << endmsg;
895 }
896 m_tools.push_back( tool );
897 } else if ( toolSvc()->retrieveTool( toolHandle->typeAndName(), tool, 0, false ).isSuccess() ) {
898 if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) {
899 debug() << "Adding public"
900 << " ToolHandle tool " << tool->name() << " (" << tool->type() << ") from ToolHandleArray "
901 << thArr->propertyName() << endmsg;
902 }
903 m_tools.push_back( tool );
904 } else {
905 warning() << "Error retrieving Tool " << toolHandle->typeAndName() << " in ToolHandleArray "
906 << thArr->propertyName() << ". Not registered" << endmsg;
907 }
908 }
909 }
910 }
911 }
912
913 for ( auto th : m_toolHandles ) {
914 if ( !th->isEnabled() ) {
915 if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) && !th->typeAndName().empty() )
916 debug() << "ToolHandle " << th->typeAndName() << " not used" << endmsg;
917 continue;
918 }
919 if ( !th->get() ) {
920 auto sc = th->retrieve();
921 if ( UNLIKELY( sc.isFailure() ) ) {
922 throw GaudiException( "Failed to retrieve tool " + th->typeAndName(), this->name(), StatusCode::FAILURE );
923 }
924 }
925 tool = th->get();
926 if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) )
927 debug() << "Adding " << ( th->isPublic() ? "public" : "private" ) << " ToolHandle tool " << tool->name() << " ("
928 << tool->type() << ")" << endmsg;
929 m_tools.push_back( tool );
930 }
931
932 m_toolHandlesInit = true;
933 }
934
935 const std::vector<IAlgTool*>& Algorithm::tools() const
936 {
937 if ( UNLIKELY( !m_toolHandlesInit ) ) initToolHandles();
938 return m_tools;
939 }
940
941 std::vector<IAlgTool*>& Algorithm::tools()
942 {
943 if ( UNLIKELY( !m_toolHandlesInit ) ) initToolHandles();
944 return m_tools;
945 }
946
951 StatusCode Algorithm::service_i( const std::string& svcName, bool createIf, const InterfaceID& iid, void** ppSvc ) const
952 {
953 const ServiceLocatorHelper helper( *serviceLocator(), *this );
954 return helper.getService( svcName, createIf, iid, ppSvc );
955 }
956
957 StatusCode Algorithm::service_i( const std::string& svcType, const std::string& svcName, const InterfaceID& iid,
958 void** ppSvc ) const
959 {
960 const ServiceLocatorHelper helper( *serviceLocator(), *this );
961 return helper.createService( svcType, svcName, iid, ppSvc );
962 }
963
964 SmartIF<IService> Algorithm::service( const std::string& name, const bool createIf, const bool quiet ) const
965 {
966 const ServiceLocatorHelper helper( *serviceLocator(), *this );
967 return helper.service( name, quiet, createIf );
968 }
969
970 //-----------------------------------------------------------------------------
971 void Algorithm::commitHandles()
972 {
973 //-----------------------------------------------------------------------------
974
975 for ( auto h : outputHandles() ) {
976 if ( h->commit().isFailure() ) {
977 throw GaudiException( "Failed to commit output handle [" + h->fullKey().fullKey() + "]", this->name(),
978 StatusCode::FAILURE );
979 }
980 }
981
982 for ( auto t : m_tools ) {
983 AlgTool* at = dynamic_cast<AlgTool*>( t );
984 if ( at != 0 ) at->commitHandles();
985 }
986
987 for ( auto& a : m_subAlgms ) {
988 a->commitHandles();
989 }
990 }
991
992 void Algorithm::registerTool( IAlgTool* tool ) const
993 {
994 if ( msgLevel( MSG::DEBUG ) ) {
995 debug() << "Registering tool " << tool->name() << endmsg;
996 }
997 m_tools.push_back( tool );
998 }
999
1000 void Algorithm::deregisterTool( IAlgTool* tool ) const
1001 {
1002 std::vector<IAlgTool*>::iterator it = std::find( m_tools.begin(), m_tools.end(), tool );
1003 if ( it != m_tools.end() ) {
1004 if ( msgLevel( MSG::DEBUG ) ) debug() << "De-Registering tool " << tool->name() << endmsg;
1005 m_tools.erase( it );
1006 } else {
1007 if ( msgLevel( MSG::DEBUG ) ) debug() << "Could not de-register tool " << tool->name() << endmsg;
1008 }
1009 }
1010
1011 std::ostream& Algorithm::toControlFlowExpression( std::ostream& os ) const
1012 {
1013 return os << type() << "('" << name() << "')";
1014 }
1015
1016 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:506
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:760
IAuditor::BeginRun
Definition: IAuditor.h:25
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:128
StatusCode::SUCCESS
Definition: StatusCode.h:29
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:811
Gaudi::StateMachine::INITIALIZED
Definition: StateMachine.h:17
Algorithm::ntupleSvc
SmartIF< INTupleSvc > & ntupleSvc() const
The standard N tuple service.
Definition: Algorithm.cpp:807
Algorithm.h
Algorithm::detCnvSvc
SmartIF< IConversionSvc > & detCnvSvc() const
The standard detector data persistency conversion service.
Definition: Algorithm.cpp:803
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:808
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:971
Algorithm::sysEndRun
StatusCode sysEndRun() override
endRun method invoked by the framework.
Definition: Algorithm.cpp:461
Algorithm::createSubAlgorithm
StatusCode createSubAlgorithm(const std::string &type, const std::string &name, Algorithm *&pSubAlg)
Create a sub algorithm.
Definition: Algorithm.cpp:842
Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:737
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:863
Algorithm::histoSvc
SmartIF< IHistogramSvc > & histoSvc() const
The standard histogram service.
Definition: Algorithm.cpp:806
Algorithm::setFilterPassed
void setFilterPassed(bool state) const override
Set the filter passed flag to the specified state.
Definition: Algorithm.cpp:774
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
compareRootHistos.state
state
Definition: compareRootHistos.py:424
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:237
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:747
Algorithm::eventSvc
SmartIF< IDataProviderSvc > & eventSvc() const
The standard event data service.
Definition: Algorithm.cpp:804
DataObjID
Definition: DataObjID.h:37
MsgStream.h
IAuditor::Stop
Definition: IAuditor.h:25
AlgTool::commitHandles
void commitHandles() override
Definition: AlgTool.cpp:539
TimelineEvent::thread
pthread_t thread
Definition: ITimelineSvc.h:14
IAlgTool::type
virtual const std::string & type() const =0
The type of an AlgTool, meaning the concrete AlgTool class.
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:1011
Gaudi::StateMachine::FINALIZE
Definition: StateMachine.h:30
Algorithm::setProperties
StatusCode setProperties()
Set the algorithm&#39;s properties.
Definition: Algorithm.cpp:818
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:413
IAuditorSvc.h
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:50
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:809
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:951
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:805
TimelineEvent
Definition: ITimelineSvc.h:13
Algorithm::setIndex
void setIndex(const unsigned int &idx) override
set instantiation index of Alg
Definition: Algorithm.cpp:745
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:1016
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:61
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:799
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:360
Algorithm::index
unsigned int index() const override
Definition: Algorithm.cpp:743
EventContext::evt
ContextEvt_t evt() const
Definition: EventContext.h:39
std::string
STL class.
Algorithm::registerTool
void registerTool(IAlgTool *tool) const
Definition: Algorithm.cpp:992
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:766
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:302
std::exception::what
T what(T...args)
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
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:458
Algorithm::sysStart
StatusCode sysStart() override
Reinitialization method invoked by the framework.
Definition: Algorithm.cpp:250
Algorithm::sysFinalize
StatusCode sysFinalize() override
System finalization.
Definition: Algorithm.cpp:649
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:810
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:815
Gaudi::StateMachine::STOP
Definition: StateMachine.h:29
Algorithm::version
const std::string & version() const override
Definition: Algorithm.cpp:741
TimelineEvent::start
time_point start
Definition: ITimelineSvc.h:20
Algorithm::whiteboard
SmartIF< IHiveWhiteBoard > & whiteboard() const
Definition: Algorithm.cpp:813
Algorithm::get_svc_
SmartIF< IFace > & get_svc_(SmartIF< IFace > &p, const char *service_name) const
Definition: Algorithm.cpp:787
Algorithm::auditorSvc
SmartIF< IAuditorSvc > & auditorSvc() const
The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Definition: Algorithm.cpp:800
Algorithm::detSvc
SmartIF< IDataProviderSvc > & detSvc() const
The standard detector data service.
Definition: Algorithm.cpp:802
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:782
IAlgContextSvc.h
Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:79
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:801
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:1000
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:721
Algorithm::filterPassed
bool filterPassed() const override
Did this algorithm pass or fail its filter criterion for the last event?
Definition: Algorithm.cpp:768
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:753
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:80
StatusCode::FAILURE
Definition: StatusCode.h:29
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:233
std::accumulate
T accumulate(T...args)
Algorithm::tools
const std::vector< IAlgTool * > & tools() const
Definition: Algorithm.cpp:935
Algorithm::nameKey
const Gaudi::StringKey & nameKey() const override
Definition: Algorithm.cpp:739
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:700
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:508
Algorithm::sysStop
StatusCode sysStop() override
System stop.
Definition: Algorithm.cpp:602
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:812