| The Gaudi Framework v27r1

- 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 "GaudiKernel/Kernel.h"
3 #include "GaudiKernel/ISvcLocator.h"
4 #include "GaudiKernel/IMessageSvc.h"
5 #include "GaudiKernel/IJobOptionsSvc.h"
6 #include "GaudiKernel/IAlgManager.h"
7 #include "GaudiKernel/IAuditorSvc.h"
8 #include "GaudiKernel/IDataProviderSvc.h"
9 #include "GaudiKernel/IDataManagerSvc.h"
10 #include "GaudiKernel/IConversionSvc.h"
11 #include "GaudiKernel/IHistogramSvc.h"
12 #include "GaudiKernel/INTupleSvc.h"
13 #include "GaudiKernel/IRndmGenSvc.h"
14 #include "GaudiKernel/IToolSvc.h"
15 #include "GaudiKernel/IExceptionSvc.h"
16 #include "GaudiKernel/IAlgContextSvc.h"
17 #include "GaudiKernel/IProperty.h"
18
19 #include "GaudiKernel/Algorithm.h"
20 #include "GaudiKernel/PropertyMgr.h"
21 #include "GaudiKernel/MsgStream.h"
22 #include "GaudiKernel/Chrono.h"
23 #include "GaudiKernel/Stat.h"
24 #include "GaudiKernel/GaudiException.h"
25 #include "GaudiKernel/ServiceLocatorHelper.h"
26 #include "GaudiKernel/ThreadGaudi.h"
27 #include "GaudiKernel/Guards.h"
28 #include "GaudiKernel/AlgTool.h"
29 #include "GaudiKernel/ToolHandle.h"
30 #include "GaudiKernel/DataHandleHolderVisitor.h"
31
32 #include "GaudiKernel/DataObjIDProperty.h"
33 #include "GaudiKernel/StringKey.h"
34
35 namespace {
36 template <StatusCode (Algorithm::*f)(), typename C > bool for_algorithms(C& c) {
37 return std::accumulate( std::begin(c), std::end(c), true,
38 [](bool b, Algorithm* a) { return (a->*f)().isSuccess() && b; } );
39 }
40 }
41
42 // Constructor
43 Algorithm::Algorithm( const std::string& name, ISvcLocator *pSvcLocator,
44 const std::string& version)
45 : m_event_context(nullptr),
46 m_name(name),
47 m_version(version),
48 m_index(0), // incremented by AlgResourcePool
49 m_pSvcLocator(pSvcLocator),
50 m_propertyMgr( new PropertyMgr() )
51 {
52
53 // Declare common Algorithm properties with their defaults
54 declareProperty( "OutputLevel", m_outputLevel = MSG::NIL);
55 declareProperty( "Enable", m_isEnabled = true);
56 declareProperty( "ErrorMax", m_errorMax = 1);
57 declareProperty( "ErrorCounter", m_errorCount = 0);
58
59 // FIXME: this should eventually be deprecated
60 //declare Extra input and output properties
61 declareProperty( "ExtraInputs", m_extInputDataObjs);
62 declareProperty( "ExtraOutputs", m_extOutputDataObjs);
63
64 // Auditor monitoring properties
65
66 // Get the default setting for service auditing from the AppMgr
67 declareProperty( "AuditAlgorithms", m_auditInit );
68
69 bool audit(false);
70 auto appMgr = serviceLocator()->service<IProperty>("ApplicationMgr");
71 if (appMgr) {
72 const Property& prop = appMgr->getProperty("AuditAlgorithms");
73 Property &pr = const_cast<Property&>(prop);
74 if (m_name != "IncidentSvc") setProperty( pr ).ignore();
75 audit = m_auditInit.value();
76 }
77
78 declareProperty( "AuditInitialize" , m_auditorInitialize = audit ) ;
79 declareProperty( "AuditReinitialize", m_auditorReinitialize = audit ) ;
80 declareProperty( "AuditRestart" , m_auditorRestart = audit ) ;
81 declareProperty( "AuditExecute" , m_auditorExecute = audit ) ;
82 declareProperty( "AuditFinalize" , m_auditorFinalize = audit ) ;
83 declareProperty( "AuditBeginRun" , m_auditorBeginRun = audit ) ;
84 declareProperty( "AuditEndRun" , m_auditorEndRun = audit ) ;
85 declareProperty( "AuditStart" , m_auditorStart = audit ) ;
86 declareProperty( "AuditStop" , m_auditorStop = audit ) ;
87 declareProperty( "Timeline" , m_doTimeline = true ) ;
88
89 declareProperty( "MonitorService" , m_monitorSvcName = "MonitorSvc" );
90
91 declareProperty
92 ( "RegisterForContextService" ,
93 m_registerContext ,
94 "The flag to enforce the registration for Algorithm Context Service") ;
95
96 declareProperty( "IsClonable" , m_isClonable = false, "Thread-safe enough for cloning?" );
97 declareProperty( "Cardinality" , m_cardinality = 1, "How many clones to create" );
98 declareProperty( "NeededResources" , m_neededResources = std::vector<std::string>() );
99
100 // update handlers.
101 m_outputLevel.declareUpdateHandler([this](Property&) { this->updateMsgStreamOutputLevel(this->m_outputLevel); } );
102 }
103
104 // IAlgorithm implementation
105 StatusCode Algorithm::sysInitialize() {
106
107 // Bypass the initialization if the algorithm
108 // has already been initialized.
109 if ( Gaudi::StateMachine::INITIALIZED <= FSMState() ) return StatusCode::SUCCESS;
110
111 // Set the Algorithm's properties
112 StatusCode sc = setProperties();
113 if( sc.isFailure() ) return StatusCode::FAILURE;
114
115 // Bypass the initialization if the algorithm is disabled.
116 // Need to do this after setProperties.
117 if ( !isEnabled( ) ) return StatusCode::SUCCESS;
118
119 m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::INITIALIZE,m_state);
120
121 // TODO: (MCl) where shoud we do this? initialize or start?
122 // Reset Error count
123 //m_errorCount = 0;
124
125 // lock the context service
126 Gaudi::Utils::AlgContext cnt
127 ( this , registerContext() ? contextSvc().get() : nullptr ) ;
128
129 // Get WhiteBoard interface if implemented by EventDataSvc
130 m_WB = service("EventDataSvc");
131
132 //check whether timeline should be done
133 m_doTimeline = timelineSvc()->isEnabled();
134
135 // Invoke initialize() method of the derived class inside a try/catch clause
136 try {
137
138 { // limit the scope of the guard
139 Gaudi::Guards::AuditorGuard guard
140 ( this,
141 // check if we want to audit the initialize
142 (m_auditorInitialize) ? auditorSvc().get() : nullptr,
143 IAuditor::Initialize);
144 // Invoke the initialize() method of the derived class
145 sc = initialize();
146 }
147
148 if( sc.isSuccess() ) {
149 // Now initialize care of any sub-algorithms
150 bool fail(false);
151 for (auto& it : m_subAlgms ) {
152 if (it->sysInitialize().isFailure()) fail = true;
153 }
154 if( fail ) {
155 sc = StatusCode::FAILURE;
156 error() << " Error initializing one or several sub-algorithms"
157 << endmsg;
158 } else {
159 // Update the state.
160 m_state = m_targetState;
161 }
162 }
163 }
164 catch ( const GaudiException& Exception )
165 {
166 fatal() << " Exception with tag=" << Exception.tag()
167 << " is caught " << endmsg;
168 error() << Exception << endmsg;
169 Stat stat( chronoSvc() , Exception.tag() );
170 sc = StatusCode::FAILURE;
171 }
172 catch( const std::exception& Exception )
173 {
174 fatal() << " Standard std::exception is caught " << endmsg;
175 error() << Exception.what() << endmsg;
176 Stat stat( chronoSvc() , "*std::exception*" );
177 sc = StatusCode::FAILURE;
178 }
179 catch(...)
180 {
181 fatal() << "UNKNOWN Exception is caught " << endmsg;
182 Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
183 sc = StatusCode::FAILURE;
184 }
185
186 // If Cardinality is 0, bring the value to 1
187 if (m_cardinality == 0 ) {
188 m_cardinality = 1;
189 }
190 // Set IsClonable to true if the Cardinality is greater than one
191 else if (m_cardinality > 1 ) {
192 m_isClonable = true;
193 }
194
195 //
197 //
198
199 if (UNLIKELY(msgLevel(MSG::DEBUG))) {
200 debug() << "input handles: " << inputHandles().size() << endmsg;
201 debug() << "output handles: " << outputHandles().size() << endmsg;
202 }
203
204 if (m_updateDataHandles)
205 acceptDHVisitor(m_updateDataHandles.get());
206
207 // visit all sub-algs and tools, build full set
208 DHHVisitor avis(m_inputDataObjs, m_outputDataObjs);
209 acceptDHVisitor(&avis);
210
211 if (UNLIKELY(msgLevel(MSG::DEBUG))) {
212 debug() << "Data Deps for " << name();
213 for (auto h : m_inputDataObjs) {
214 debug() << "\n + INPUT " << h;
215 }
216 for (auto h : m_outputDataObjs) {
217 debug() << "\n + OUTPUT " << h;
218 }
219 debug() << endmsg;
220 }
221
222 return sc;
223 }
224
225 void
226 Algorithm::acceptDHVisitor(IDataHandleVisitor *vis) const {
227 vis->visit(this);
228
229 // loop through tools
230 for (auto tool : tools()) {
231 AlgTool* at = dynamic_cast<AlgTool*>(tool);
232 vis->visit(at);
233 }
234
235 // loop through sub-algs
236 for (auto alg : *subAlgorithms()) {
237 vis->visit(alg);
238 }
239
240 }
241
242 // IAlgorithm implementation
243 StatusCode Algorithm::sysStart() {
244
245 // Bypass the startup if already running or disabled.
246 if ( Gaudi::StateMachine::RUNNING == FSMState() ||
247 !isEnabled() ) return StatusCode::SUCCESS;
248
249 m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::START,m_state);
250
251 // TODO: (MCl) where shoud we do this? initialize or start?
252 // Reset Error count
253 m_errorCount = 0;
254
255 // lock the context service
256 Gaudi::Utils::AlgContext cnt
257 ( this , registerContext() ? contextSvc().get() : nullptr ) ;
258
259 StatusCode sc(StatusCode::FAILURE);
260 // Invoke start() method of the derived class inside a try/catch clause
261 try
262 {
263 { // limit the scope of the guard
264 Gaudi::Guards::AuditorGuard guard
265 (this,
266 // check if we want to audit the initialize
267 (m_auditorStart) ? auditorSvc().get() : nullptr,
268 IAuditor::Start);
269 // Invoke the start() method of the derived class
270 sc = start();
271 }
272 if( sc.isSuccess() ) {
273
274 // Now start any sub-algorithms
275 if( !for_algorithms<&Algorithm::sysStart>( m_subAlgms ) ) {
276 sc = StatusCode::FAILURE;
277 error() << " Error starting one or several sub-algorithms"
278 << endmsg;
279 } else {
280 // Update the state.
281 m_state = m_targetState;
282 }
283 }
284 }
285 catch ( const GaudiException& Exception )
286 {
287 fatal() << "in sysStart(): exception with tag=" << Exception.tag()
288 << " is caught" << endmsg;
289 error() << Exception << endmsg;
290 Stat stat( chronoSvc() , Exception.tag() );
291 sc = StatusCode::FAILURE;
292 }
293 catch( const std::exception& Exception )
294 {
295 fatal() << "in sysStart(): standard std::exception is caught" << endmsg;
296 error() << Exception.what() << endmsg;
297 Stat stat( chronoSvc() , "*std::exception*" );
298 sc = StatusCode::FAILURE;
299 }
300 catch(...)
301 {
302 fatal() << "in sysStart(): UNKNOWN Exception is caught" << endmsg;
303 Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
304 sc = StatusCode::FAILURE;
305 }
306
307 return sc;
308 }
309
310 // IAlgorithm implementation
311 StatusCode Algorithm::sysReinitialize() {
312
313 // Bypass the initialization if the algorithm is disabled.
314 if ( !isEnabled( ) ) return StatusCode::SUCCESS;
315
316 // Check that the current status is the correct one.
317 if ( Gaudi::StateMachine::INITIALIZED != FSMState() ) {
318 error()
319 << "sysReinitialize(): cannot reinitialize algorithm not initialized"
320 << endmsg;
321 return StatusCode::FAILURE;
322 }
323
324 // Reset Error count
325 // m_errorCount = 0; // done during start
326
327 // lock the context service
328 Gaudi::Utils::AlgContext cnt
329 ( this , registerContext() ? contextSvc().get() : nullptr ) ;
330
331 StatusCode sc(StatusCode::SUCCESS);
332 // Invoke reinitialize() method of the derived class inside a try/catch clause
333 try {
334 { // limit the scope of the guard
335 Gaudi::Guards::AuditorGuard guard(this,
336 // check if we want to audit the initialize
337 (m_auditorReinitialize) ? auditorSvc().get() : nullptr,
338 IAuditor::ReInitialize);
339 // Invoke the reinitialize() method of the derived class
340 sc = reinitialize();
341 }
342 if( sc.isSuccess() ) {
343
344 // Now initialize care of any sub-algorithms
345 if ( !for_algorithms<&Algorithm::sysReinitialize>( m_subAlgms ) ) {
346 sc = StatusCode::FAILURE;
347 error()
348 << "sysReinitialize(): Error reinitializing one or several "
349 << "sub-algorithms" << endmsg;
350 }
351 }
352 }
353 catch ( const GaudiException& Exception )
354 {
355 fatal() << "sysReinitialize(): Exception with tag=" << Exception.tag()
356 << " is caught" << endmsg;
357 error() << Exception << endmsg;
358 Stat stat( chronoSvc() , Exception.tag() );
359 sc = StatusCode::FAILURE;
360 }
361 catch( const std::exception& Exception )
362 {
363 fatal() << "sysReinitialize(): Standard std::exception is caught" << endmsg;
364 error() << Exception.what() << endmsg;
365 Stat stat( chronoSvc() , "*std::exception*" );
366 sc = StatusCode::FAILURE;
367 }
368 catch(...)
369 {
370 fatal() << "sysReinitialize(): UNKNOWN Exception is caught" << endmsg;
371 Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
372 sc = StatusCode::FAILURE;
373 }
374
375 return sc;
376 }
377
378 // IAlgorithm implementation
379 StatusCode Algorithm::sysRestart() {
380
381 // Bypass the initialization if the algorithm is disabled.
382 if ( !isEnabled( ) ) return StatusCode::SUCCESS;
383
384 // Check that the current status is the correct one.
385 if ( Gaudi::StateMachine::RUNNING != FSMState() ) {
386 error() << "sysRestart(): cannot restart algorithm not started" << endmsg;
387 return StatusCode::FAILURE;
388 }
389
390 // Reset Error count
391 m_errorCount = 0;
392
393 // lock the context service
394 Gaudi::Utils::AlgContext cnt
395 ( this , registerContext() ? contextSvc().get() : nullptr ) ;
396
397 StatusCode sc(StatusCode::FAILURE);
398 // Invoke reinitialize() method of the derived class inside a try/catch clause
399 try {
400 { // limit the scope of the guard
401 Gaudi::Guards::AuditorGuard guard(this,
402 // check if we want to audit the initialize
403 (m_auditorRestart) ? auditorSvc().get() : nullptr,
404 IAuditor::ReStart);
405 // Invoke the reinitialize() method of the derived class
406 sc = restart();
407 }
408 if( sc.isSuccess() ) {
409
410 // Now initialize care of any sub-algorithms
411 if( !for_algorithms<&Algorithm::sysRestart>( m_subAlgms ) ) {
412 sc = StatusCode::FAILURE;
413 error() << "sysRestart(): Error restarting one or several sub-algorithms" << endmsg;
414 }
415 }
416 }
417 catch ( const GaudiException& Exception )
418 {
419 fatal() << "sysRestart(): Exception with tag=" << Exception.tag()
420 << " is caught" << endmsg;
421 error() << Exception << endmsg;
422 Stat stat( chronoSvc() , Exception.tag() );
423 sc = StatusCode::FAILURE;
424 }
425 catch( const std::exception& Exception )
426 {
427 fatal() << "sysRestart(): Standard std::exception is caught" << endmsg;
428 error() << Exception.what() << endmsg;
429 Stat stat( chronoSvc() , "*std::exception*" );
430 sc = StatusCode::FAILURE;
431 }
432 catch(...)
433 {
434 fatal() << "sysRestart(): UNKNOWN Exception is caught" << endmsg;
435 Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
436 sc = StatusCode::FAILURE;
437 }
438
439 return sc;
440 }
441
442 // IAlgorithm implementation
443 StatusCode Algorithm::sysBeginRun() {
444
445 // Bypass the beginRun if the algorithm is disabled.
446 if ( !isEnabled( ) ) return StatusCode::SUCCESS;
447
448 // Reset Error count
449 m_errorCount = 0;
450
451 // lock the context service
452 Gaudi::Utils::AlgContext cnt
453 ( this , registerContext() ? contextSvc().get() : nullptr ) ;
454
455 StatusCode sc(StatusCode::FAILURE);
456 // Invoke beginRun() method of the derived class inside a try/catch clause
457 try {
458 { // limit the scope of the guard
459 Gaudi::Guards::AuditorGuard guard(this,
460 // check if we want to audit the initialize
461 (m_auditorBeginRun) ? auditorSvc().get() : nullptr,
462 IAuditor::BeginRun);
463 // Invoke the beginRun() method of the derived class
464 sc = beginRun();
465 }
466 if( sc.isSuccess() ) {
467
468 // Now call beginRun for any sub-algorithms
469 if( !for_algorithms<&Algorithm::sysBeginRun>( m_subAlgms ) ) {
470 sc = StatusCode::FAILURE;
471 error() << " Error executing BeginRun for one or several sub-algorithms"
472 << endmsg;
473 }
474 }
475 }
476 catch ( const GaudiException& Exception )
477 {
478 fatal() << " Exception with tag=" << Exception.tag()
479 << " is caught " << endmsg;
480 error() << Exception << endmsg;
481 Stat stat( chronoSvc() , Exception.tag() );
482 sc = StatusCode::FAILURE;
483 }
484 catch( const std::exception& Exception )
485 {
486 fatal() << " Standard std::exception is caught " << endmsg;
487 error() << Exception.what() << endmsg;
488 Stat stat( chronoSvc() , "*std::exception*" );
489 sc = StatusCode::FAILURE;
490 }
491 catch(...)
492 {
493 fatal() << "UNKNOWN Exception is caught " << endmsg;
494 Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
495 sc = StatusCode::FAILURE;
496 }
497 return sc;
498 }
499
500 StatusCode Algorithm::beginRun() {
501 return StatusCode::SUCCESS;
502 }
503
504 // IAlgorithm implementation
505 StatusCode Algorithm::sysEndRun() {
506
507 // Bypass the endRun if the algorithm is disabled.
508 if ( !isEnabled( ) ) return StatusCode::SUCCESS;
509
510 // Reset Error count
511 m_errorCount = 0;
512
513 // lock the context service
514 Gaudi::Utils::AlgContext cnt
515 ( this , registerContext() ? contextSvc().get() : nullptr ) ;
516
517 // Invoke endRun() method of the derived class inside a try/catch clause
518 StatusCode sc(StatusCode::FAILURE);
519 try {
520 { // limit the scope of the guard
521 Gaudi::Guards::AuditorGuard guard(this,
522 // check if we want to audit the initialize
523 (m_auditorEndRun) ? auditorSvc().get() : nullptr,
524 IAuditor::EndRun);
525 // Invoke the endRun() method of the derived class
526 sc = endRun();
527 }
528 if( sc.isSuccess() ) {
529
530 // Now call endRun for any sub-algorithms
531 if( !for_algorithms<&Algorithm::sysEndRun>( m_subAlgms ) ) {
532 sc = StatusCode::FAILURE;
533 error() << " Error calling endRun for one or several sub-algorithms"
534 << endmsg;
535 }
536 }
537 }
538 catch ( const GaudiException& Exception )
539 {
540 fatal() << " Exception with tag=" << Exception.tag()
541 << " is caught " << endmsg;
542 error() << Exception << endmsg;
543 Stat stat( chronoSvc() , Exception.tag() );
544 sc = StatusCode::FAILURE;
545 }
546 catch( const std::exception& Exception )
547 {
548 fatal() << " Standard std::exception is caught " << endmsg;
549 error() << Exception.what() << endmsg;
550 Stat stat( chronoSvc() , "*std::exception*" );
551 sc = StatusCode::FAILURE;
552 }
553 catch(...)
554 {
555 fatal() << "UNKNOWN Exception is caught " << endmsg;
556 Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
557 sc = StatusCode::FAILURE;
558 }
559 return sc;
560 }
561
562 StatusCode Algorithm::endRun() {
563 return StatusCode::SUCCESS;
564 }
565
566
567 StatusCode Algorithm::sysExecute() {
568 if (!isEnabled()) {
569 if ( msgLevel(MSG::VERBOSE) ) {
570 verbose() << ".sysExecute(): is not enabled. Skip execution" << endmsg;
571 }
572 return StatusCode::SUCCESS;
573 }
574
575 StatusCode status;
576
577 // Should performance profile be performed ?
578 // invoke execute() method of Algorithm class
579 // and catch all uncaught exceptions
580
581 // lock the context service
582 Gaudi::Utils::AlgContext cnt
583 ( this , registerContext() ? contextSvc().get() : nullptr ) ;
584
585 // HiveWhiteBoard stuff here
586 if(m_WB.isValid()) m_WB->selectStore(getContext() ? getContext()->slot() : 0).ignore();
587
588 Gaudi::Guards::AuditorGuard guard(this,
589 // check if we want to audit the initialize
590 (m_auditorExecute) ? auditorSvc().get() : nullptr,
591 IAuditor::Execute,
592 status);
593
594 TimelineEvent timeline;
595 timeline.algorithm = this->name();
596 // timeline.thread = getContext() ? getContext()->m_thread_id : 0;
597 timeline.thread = pthread_self();
598 timeline.slot = getContext() ? getContext()->slot() : 0;
599 timeline.event = getContext() ? getContext()->evt() : 0;
600
601 try {
602
603 if(UNLIKELY(m_doTimeline))
604 timeline.start = Clock::now();
605 status = execute();
606
607 if(UNLIKELY(m_doTimeline))
608 timeline.end = Clock::now();
609
610 setExecuted(true); // set the executed flag
611
612 if (status.isFailure()) {
613 status = exceptionSvc()->handleErr(*this,status);
614 }
615
616 }
617 catch( const GaudiException& Exception )
618 {
619 setExecuted(true); // set the executed flag
620
621 if (Exception.code() == StatusCode::FAILURE) {
622 fatal();
623 } else {
624 error() << " Recoverable";
625 }
626
627 msgStream() << " Exception with tag=" << Exception.tag()
628 << " is caught " << endmsg;
629
630 error() << Exception << endmsg;
631
632 //Stat stat( chronoSvc() , Exception.tag() ) ;
633 status = exceptionSvc()->handle(*this,Exception);
634 }
635 catch( const std::exception& Exception )
636 {
637 setExecuted(true); // set the executed flag
638
639 fatal() << " Standard std::exception is caught " << endmsg;
640 error() << Exception.what() << endmsg;
641 //Stat stat( chronoSvc() , "*std::exception*" ) ;
642 status = exceptionSvc()->handle(*this,Exception);
643 }
644 catch(...)
645 {
646 setExecuted(true); // set the executed flag
647
648 fatal() << "UNKNOWN Exception is caught " << endmsg;
649 //Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
650
651 status = exceptionSvc()->handle(*this);
652 }
653
654 if(UNLIKELY(m_doTimeline))
655 timelineSvc()->registerTimelineEvent(timeline);
656
657 if( status.isFailure() ) {
658 // Increment the error count
659 m_errorCount++;
660 // Check if maximum is exeeded
661 if( m_errorCount < m_errorMax ) {
662 warning() << "Continuing from error (cnt=" << m_errorCount
663 << ", max=" << m_errorMax << ")" << endmsg;
664 // convert to success
665 status = StatusCode::SUCCESS;
666 }
667 }
668 return status;
669 }
670
671 // IAlgorithm implementation
672 StatusCode Algorithm::sysStop() {
673
674 // Bypass the startup if already running or disabled.
675 if ( Gaudi::StateMachine::INITIALIZED == FSMState() ||
676 !isEnabled() ) return StatusCode::SUCCESS;
677
678 m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::STOP,m_state);
679
680 // lock the context service
681 Gaudi::Utils::AlgContext cnt
682 ( this , registerContext() ? contextSvc().get() : nullptr ) ;
683
684 StatusCode sc(StatusCode::FAILURE);
685 // Invoke stop() method of the derived class inside a try/catch clause
686 try {
687 // Stop first any sub-algorithms (in reverse order -- not?)
688 for_algorithms<&Algorithm::sysStop>( m_subAlgms );
689 { // limit the scope of the guard
690 Gaudi::Guards::AuditorGuard guard(this,
691 // check if we want to audit the initialize
692 (m_auditorStop) ? auditorSvc().get() : nullptr,
693 IAuditor::Stop);
694
695 // Invoke the stop() method of the derived class
696 sc = stop();
697 }
698 if( sc.isSuccess() ) {
699 // Update the state.
700 m_state = m_targetState;
701 }
702 }
703 catch ( const GaudiException& Exception ) {
704 fatal() << "in sysStop(): exception with tag=" << Exception.tag()
705 << " is caught" << endmsg;
706 error() << Exception << endmsg;
707 Stat stat( chronoSvc() , Exception.tag() );
708 sc = StatusCode::FAILURE;
709 }
710 catch( const std::exception& Exception ) {
711 fatal() << "in sysStop(): standard std::exception is caught" << endmsg;
712 error() << Exception.what() << endmsg;
713 Stat stat( chronoSvc() , "*std::exception*" );
714 sc = StatusCode::FAILURE;
715 }
716 catch(...) {
717 fatal() << "in sysStop(): UNKNOWN Exception is caught" << endmsg;
718 Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
719 sc = StatusCode::FAILURE;
720 }
721
722 return sc;
723 }
724
725 StatusCode Algorithm::sysFinalize() {
726
727 // Bypass the finalialization if the algorithm hasn't been initilized.
728 if ( Gaudi::StateMachine::CONFIGURED == FSMState() ||
729 !isEnabled() ) return StatusCode::SUCCESS;
730
731 m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::FINALIZE,m_state);
732
733 // lock the context service
734 Gaudi::Utils::AlgContext cnt
735 ( this , registerContext() ? contextSvc().get() : nullptr ) ;
736
737 StatusCode sc(StatusCode::FAILURE);
738 // Invoke finalize() method of the derived class inside a try/catch clause
739 try {
740 // Order changed (bug #3903 overview: finalize and nested algorithms)
741 // Finalize first any sub-algorithms (it can be done more than once)
742 bool ok = for_algorithms<&Algorithm::sysFinalize>( m_subAlgms );
743 { // limit the scope of the guard
744 Gaudi::Guards::AuditorGuard guard(this,
745 // check if we want to audit the initialize
746 (m_auditorFinalize) ? auditorSvc().get() : nullptr,
747 IAuditor::Finalize);
748 // Invoke the finalize() method of the derived class
749 sc = finalize();
750 }
751 if (!ok) sc = StatusCode::FAILURE;
752
753 if( sc.isSuccess() ) {
754
755 // Release all sub-algorithms
756 for (auto& it : m_subAlgms ) it->release();
757 // Indicate that this Algorithm has been finalized to prevent duplicate attempts
758 m_state = m_targetState;
759 }
760 }
761 catch( const GaudiException& Exception )
762 {
763 fatal() << " Exception with tag=" << Exception.tag()
764 << " is caught " << endmsg;
765 error() << Exception << endmsg;
766 Stat stat( chronoSvc() , Exception.tag() ) ;
767 sc = StatusCode::FAILURE;
768 }
769 catch( const std::exception& Exception )
770 {
771 fatal() << " Standard std::exception is caught " << endmsg;
772 error() << Exception.what() << endmsg;
773 Stat stat( chronoSvc() , "*std::exception*" ) ;
774 sc = StatusCode::FAILURE;
775 }
776 catch( ... )
777 {
778 fatal() << "UNKNOWN Exception is caught " << endmsg;
779 Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
780 sc = StatusCode::FAILURE;
781 }
782 return sc;
783 }
784
785 StatusCode Algorithm::reinitialize() {
786 /* @TODO
787 * MCl 2008-10-23: the implementation of reinitialize as finalize+initialize
788 * is causing too many problems
789 *
790 // Default implementation is finalize+initialize
791 StatusCode sc = finalize();
792 if (sc.isFailure()) {
793 error() << "reinitialize(): cannot be finalized" << endmsg;
794 return sc;
795 }
796 sc = initialize();
797 if (sc.isFailure()) {
798 error() << "reinitialize(): cannot be initialized" << endmsg;
799 return sc;
800 }
801 */
802 return StatusCode::SUCCESS;
803 }
804
805 StatusCode Algorithm::restart() {
806 // Default implementation is stop+start
807 StatusCode sc = stop();
808 if (sc.isFailure()) {
809 error() << "restart(): cannot be stopped" << endmsg;
810 return sc;
811 }
812 sc = start();
813 if (sc.isFailure()) {
814 error() << "restart(): cannot be started" << endmsg;
815 return sc;
816 }
817 return StatusCode::SUCCESS;
818 }
819
820 const std::string& Algorithm::name() const {
821 return m_name.str();
822 }
823
824 const Gaudi::StringKey& Algorithm::nameKey() const {
825 return m_name;
826 }
827
828 const std::string& Algorithm::version() const {
829 return m_version;
830 }
831
832 unsigned int Algorithm::index() const {
833 return m_index;
834 }
835
836 void Algorithm::setIndex(const unsigned int& idx) {
837 m_index = idx;
838 }
839
840 bool Algorithm::isExecuted() const {
841 return m_isExecuted;
842 }
843
844 void Algorithm::setExecuted( bool state ) {
845 m_isExecuted = state;
846 }
847
848 void Algorithm::resetExecuted() {
849 m_isExecuted = false;
850 m_filterPassed = true;
851 }
852
853 bool Algorithm::isEnabled() const {
854 return m_isEnabled;
855 }
856
857 bool Algorithm::filterPassed() const {
858 return m_filterPassed;
859 }
860
861 void Algorithm::setFilterPassed( bool state ) {
862 m_filterPassed = state;
863 }
864
865 const std::vector<Algorithm*>* Algorithm::subAlgorithms( ) const {
866 return &m_subAlgms;
867 }
868
869 std::vector<Algorithm*>* Algorithm::subAlgorithms( ) {
870 return &m_subAlgms;
871 }
872
873
874 #define serviceAccessor(METHOD,INTERFACE,NAME,MEMBER) \
875 SmartIF<INTERFACE>& Algorithm::METHOD() const { \
876 if ( !MEMBER ) { \
877 MEMBER = service(NAME); \
878 if( !MEMBER ) { \
879 throw GaudiException("Service [" NAME "] not found", name(), StatusCode::FAILURE); \
880 } \
881 } \
882 return MEMBER; \
883 }
884
885 serviceAccessor(auditorSvc, IAuditorSvc, "AuditorSvc", m_pAuditorSvc)
886 serviceAccessor(chronoSvc, IChronoStatSvc, "ChronoStatSvc", m_CSS)
887 serviceAccessor(detSvc, IDataProviderSvc, "DetectorDataSvc", m_DDS)
888 serviceAccessor(detCnvSvc, IConversionSvc, "DetectorPersistencySvc", m_DCS)
889 serviceAccessor(eventSvc, IDataProviderSvc, "EventDataSvc", m_EDS)
890 serviceAccessor(whiteboard, IHiveWhiteBoard, "EventDataSvc", m_WB)
891 serviceAccessor(eventCnvSvc, IConversionSvc, "EventPersistencySvc", m_ECS)
892 serviceAccessor(histoSvc, IHistogramSvc, "HistogramDataSvc", m_HDS)
893 serviceAccessor(exceptionSvc, IExceptionSvc, "ExceptionSvc", m_EXS)
894 serviceAccessor(ntupleSvc, INTupleSvc, "NTupleSvc", m_NTS)
895 serviceAccessor(randSvc, IRndmGenSvc, "RndmGenSvc", m_RGS)
896 serviceAccessor(toolSvc, IToolSvc, "ToolSvc", m_ptoolSvc)
897 serviceAccessor(contextSvc, IAlgContextSvc,"AlgContextSvc", m_contextSvc)
898 serviceAccessor(timelineSvc, ITimelineSvc,"TimelineSvc", m_timelineSvc)
899
900 // Obsoleted name, kept due to the backwards compatibility
901 SmartIF<IChronoStatSvc>& Algorithm::chronoStatService() const {
902 return chronoSvc();
903 }
904 // Obsoleted name, kept due to the backwards compatibility
905 SmartIF<IDataProviderSvc>& Algorithm::detDataService() const {
906 return detSvc();
907 }
908 // Obsoleted name, kept due to the backwards compatibility
909 SmartIF<IConversionSvc>& Algorithm::detDataCnvService() const {
910 return detCnvSvc();
911 }
912 // Obsoleted name, kept due to the backwards compatibility
913 SmartIF<IDataProviderSvc>& Algorithm::eventDataService() const {
914 return eventSvc();
915 }
916 // Obsoleted name, kept due to the backwards compatibility
917 SmartIF<IConversionSvc>& Algorithm::eventDataCnvService() const {
918 return eventCnvSvc();
919 }
920 // Obsoleted name, kept due to the backwards compatibility
921 SmartIF<IHistogramSvc>& Algorithm::histogramDataService() const {
922 return histoSvc();
923 }
924 // Obsoleted name, kept due to the backwards compatibility
925 SmartIF<INTupleSvc>& Algorithm::ntupleService() const {
926 return ntupleSvc();
927 }
928
929 SmartIF<ISvcLocator>& Algorithm::serviceLocator() const {
930 return *const_cast<SmartIF<ISvcLocator>*>(&m_pSvcLocator);
931 }
932
933 // Use the job options service to set declared properties
934 StatusCode Algorithm::setProperties() {
935 if( !m_pSvcLocator ) return StatusCode::FAILURE;
936 auto jos = m_pSvcLocator->service<IJobOptionsSvc>("JobOptionsSvc");
937 if( !jos ) return StatusCode::FAILURE;
938 // set first generic Properties
939 StatusCode sc = jos->setMyProperties( getGaudiThreadGenericName(name()), this );
940 if( sc.isFailure() ) return StatusCode::FAILURE;
941
942 // set specific Properties
943 if (isGaudiThreaded(name())) {
944 if(jos->setMyProperties( name(), this ).isFailure()) {
945 return StatusCode::FAILURE;
946 }
947 }
948 if (m_outputLevel == MSG::NIL)
949 m_outputLevel = msgLevel();
950 else
951 updateMsgStreamOutputLevel( m_outputLevel );
952 return sc;
953 }
954
955 StatusCode Algorithm::createSubAlgorithm(const std::string& type,
956 const std::string& name,
957 Algorithm*& pSubAlgorithm) {
958 if( !m_pSvcLocator ) return StatusCode::FAILURE;
959
960 SmartIF<IAlgManager> am(m_pSvcLocator);
961 if ( !am ) return StatusCode::FAILURE;
962
963 // Maybe modify the AppMgr interface to return Algorithm* ??
964 IAlgorithm *tmp;
965 StatusCode sc = am->createAlgorithm
966 (type, name+getGaudiThreadIDfromName(Algorithm::name()), tmp);
967 if( sc.isFailure() ) return StatusCode::FAILURE;
968
969 try{
970 pSubAlgorithm = dynamic_cast<Algorithm*>(tmp);
971 m_subAlgms.push_back(pSubAlgorithm);
972 } catch(...){
973 sc = StatusCode::FAILURE;
974 }
975 return sc;
976 }
977
978 // IProperty implementation
979 // Delegate to the Property manager
980 StatusCode Algorithm::setProperty(const Property& p) {
981 return m_propertyMgr->setProperty(p);
982 }
983 StatusCode Algorithm::setProperty(const std::string& s) {
984 return m_propertyMgr->setProperty(s);
985 }
986 StatusCode Algorithm::setProperty(const std::string& n, const std::string& v) {
987 return m_propertyMgr->setProperty(n,v);
988 }
989 StatusCode Algorithm::getProperty(Property* p) const {
990 return m_propertyMgr->getProperty(p);
991 }
992 const Property& Algorithm::getProperty( const std::string& name) const{
993 return m_propertyMgr->getProperty(name);
994 }
995 StatusCode Algorithm::getProperty(const std::string& n, std::string& v ) const {
996 return m_propertyMgr->getProperty(n,v);
997 }
998 const std::vector<Property*>& Algorithm::getProperties( ) const {
999 return m_propertyMgr->getProperties();
1000 }
1001 bool Algorithm::hasProperty(const std::string& name) const {
1002 return m_propertyMgr->hasProperty(name);
1003 }
1004
1005 void Algorithm::initToolHandles() const{
1006
1007 IAlgTool* tool(0);
1008 for (auto thArr : m_toolHandleArrays) {
1009 if (! thArr->retrieved()) {
1010 if (UNLIKELY(msgLevel(MSG::DEBUG)))
1011 debug() << "ToolHandleArray " << thArr->propertyName()
1012 << " not used: not registering any of its Tools" << endmsg;
1013 } else {
1014 if (UNLIKELY(msgLevel(MSG::DEBUG)))
1015 debug() << "Registering all Tools in ToolHandleArray "
1016 << thArr->propertyName() ;
1017 for (auto th_name : thArr->typesAndNames()) {
1018 if (UNLIKELY(msgLevel(MSG::DEBUG)))
1019 debug() << std::endl << " + " << th_name;
1020 if (toolSvc()->retrieveTool(th_name, tool, this).isSuccess()) {
1021 if (UNLIKELY(msgLevel(MSG::DEBUG)))
1022 debug() << " (private)";
1023 m_tools.push_back(tool);
1024 } else if (toolSvc()->retrieveTool(th_name, tool, 0).isSuccess()) {
1025 if (UNLIKELY(msgLevel(MSG::DEBUG)))
1026 debug() << " (public)";
1027 m_tools.push_back(tool);
1028 } else {
1029 if (UNLIKELY(msgLevel(MSG::DEBUG)))
1030 debug() << " - ERROR" << endmsg;
1031 warning() << "Error retrieving Tool " << th_name
1032 << " in ToolHandleArray" << thArr->propertyName()
1033 << ". Not registered" << endmsg;
1034 }
1035 }
1036 if (UNLIKELY(msgLevel(MSG::DEBUG))) debug() << endmsg;
1037 }
1038 }
1039
1040 for(auto th : m_toolHandles){
1041 tool = th->get();
1042 if(tool){
1043 if (UNLIKELY(msgLevel(MSG::DEBUG)))
1044 debug() << "Adding "
1045 << (th->isPublic() ? "public" : "private" )
1046 << " ToolHandle tool " << tool->name()
1047 << " (" << tool->type() << ")" << endmsg;
1048 m_tools.push_back(tool);
1049 } else {
1050 if (UNLIKELY(msgLevel(MSG::DEBUG)))
1051 debug() << "ToolHandle " << th->typeAndName() << " not used" << endmsg;
1052 }
1053 }
1054
1055 m_toolHandlesInit = true;
1056 }
1057
1058 const std::vector<IAlgTool *> & Algorithm::tools() const {
1059 if(UNLIKELY(!m_toolHandlesInit)) initToolHandles();
1060 return m_tools;
1061 }
1062
1063 std::vector<IAlgTool *> & Algorithm::tools() {
1064 if(UNLIKELY(!m_toolHandlesInit)) initToolHandles();
1065 return m_tools;
1066 }
1067
1072 StatusCode
1073 Algorithm::service_i(const std::string& svcName,
1074 bool createIf,
1075 const InterfaceID& iid,
1076 void** ppSvc) const {
1077 const ServiceLocatorHelper helper(*serviceLocator(), *this);
1078 return helper.getService(svcName, createIf, iid, ppSvc);
1079 }
1080
1081 StatusCode
1082 Algorithm::service_i(const std::string& svcType,
1083 const std::string& svcName,
1084 const InterfaceID& iid,
1085 void** ppSvc) const {
1086 const ServiceLocatorHelper helper(*serviceLocator(), *this);
1087 return helper.createService(svcType, svcName, iid, ppSvc);
1088 }
1089
1090 SmartIF<IService> Algorithm::service(const std::string& name, const bool createIf, const bool quiet) const {
1091 const ServiceLocatorHelper helper(*serviceLocator(), *this);
1092 return helper.service(name, quiet, createIf);
1093 }
1094
1095 //-----------------------------------------------------------------------------
1096 void
1097 Algorithm::commitHandles() {
1098 //-----------------------------------------------------------------------------
1099
1100 for (auto h : m_outputHandles) {
1101 h->commit();
1102 }
1103
1104 for (auto t : m_tools) {
1105 AlgTool* at = dynamic_cast<AlgTool*>(t);
1106 if (at != 0) at->commitHandles();
1107 }
1108
1109 for (auto& a : m_subAlgms ) {
1110 a->commitHandles();
1111 }
1112
1113 }
1114
1115 void
1116 Algorithm::registerTool(IAlgTool * tool) const {
1117 if (msgLevel(MSG::DEBUG)) {
1118 debug() << "Registering tool " << tool->name() << endmsg;
1119 }
1120 m_tools.push_back(tool);
1121 }
1122
1123
1124 void
1125 Algorithm::deregisterTool(IAlgTool * tool) const {
1126 std::vector<IAlgTool *>::iterator it = std::find(m_tools.begin(),
1127 m_tools.end(), tool);
1128 if (it != m_tools.end()) {
1129 if (msgLevel(MSG::DEBUG))
1130 debug() << "De-Registering tool " << tool->name() << endmsg;
1131 m_tools.erase(it);
1132 } else {
1133 if (msgLevel(MSG::DEBUG))
1134 debug() << "Could not de-register tool " << tool->name() << endmsg;
1135 }
1136 }
Algorithm::endRun
StatusCode endRun() override
Algorithm end run. This method is called at the end of the event loop.
Definition: Algorithm.cpp:562
compareRootHistos.state
tuple state
Definition: compareRootHistos.py:348
IAuditor::Start
Definition: IAuditor.h:31
Gaudi::Utils::setProperty
StatusCode setProperty(IProperty *component, const std::string &name, const TYPE &value, const std::string &doc)
simple function to set the property of the given object from the value
Definition: Property.h:1187
Algorithm::resetExecuted
void resetExecuted() override
Reset the executed state of the Algorithm for the duration of the current event.
Definition: Algorithm.cpp:848
IToolSvc
The interface implemented by the IToolSvc base class.
Definition: IToolSvc.h:18
IAuditor::BeginRun
Definition: IAuditor.h:28
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:126
ServiceLocatorHelper
an helper to share the implementation of service() among the various kernel base classes ...
Definition: ServiceLocatorHelper.h:17
Gaudi::StateMachine::INITIALIZED
Definition: StateMachine.h:15
Algorithm.h
SmartIF
Small smart pointer class with automatic reference counting for IInterface.
Definition: IConverter.h:14
Kernel.h
Algorithm::eventDataCnvService
SmartIF< IConversionSvc > & eventDataCnvService() const
Obsoleted name, kept due to the backwards compatibility.
Definition: Algorithm.cpp:917
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
AnalysisTest.initialize
def initialize()
Definition: AnalysisTest.py:12
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:1097
Algorithm::sysEndRun
StatusCode sysEndRun() override
endRun method invoked by the framework.
Definition: Algorithm.cpp:505
HistogramDataSvc
m_CSS m_DCS m_WB HistogramDataSvc
Definition: Algorithm.cpp:892
Algorithm::createSubAlgorithm
StatusCode createSubAlgorithm(const std::string &type, const std::string &name, Algorithm *&pSubAlg)
Create a sub algorithm.
Definition: Algorithm.cpp:955
Gaudi::StateMachine::CONFIGURED
Definition: StateMachine.h:14
Gaudi::Utils::AlgContext
Helper "sentry" class to automatize the safe register/unregister the algorithm's context.
Definition: IAlgContextSvc.h:79
Algorithm::initToolHandles
void initToolHandles() const
Definition: Algorithm.cpp:1005
Algorithm::version
const std::string & version() const override
Definition: Algorithm.cpp:828
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
IConversionSvc
Definition: IConversionSvc.h:37
MsgStream.h
IAuditor::Stop
Definition: IAuditor.h:32
AlgTool::commitHandles
void commitHandles() override
Definition: AlgTool.cpp:579
Gaudi::StateMachine::FINALIZE
Definition: StateMachine.h:28
Algorithm::setProperties
StatusCode setProperties()
Set the algorithm's properties.
Definition: Algorithm.cpp:934
Stat
Small wrapper class for easy manipulation with generic counters and IStatSvc&ICounterSvc interface...
Definition: Stat.h:46
IAuditor::ReInitialize
Definition: IAuditor.h:26
Algorithm::sysBeginRun
StatusCode sysBeginRun() override
beginRun method invoked by the framework.
Definition: Algorithm.cpp:443
IAuditorSvc.h
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
AlgTool.h
Algorithm::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition: Algorithm.cpp:929
gaudirun.c
tuple c
Definition: gaudirun.py:391
Algorithm::setProperty
StatusCode setProperty(const Property &p) override
Implementation of IProperty::setProperty.
Definition: Algorithm.cpp:980
MSG::DEBUG
Definition: IMessageSvc.h:18
std::endl
T endl(T...args)
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:1073
TimelineEvent::algorithm
std::string algorithm
Definition: ITimelineSvc.h:23
TimelineEvent::event
uint event
Definition: ITimelineSvc.h:21
Algorithm::filterPassed
bool filterPassed() const override
Did this algorithm pass or fail its filter criterion for the last event?
Definition: Algorithm.cpp:857
Chrono.h
TimelineEvent::thread
uint thread
Definition: ITimelineSvc.h:19
std::end
T end(T...args)
IDataProviderSvc
Data provider interface definition.
Definition: IDataProviderSvc.h:45
TimelineEvent
Definition: ITimelineSvc.h:18
Algorithm::setIndex
void setIndex(const unsigned int &idx) override
set instantiation index of Alg
Definition: Algorithm.cpp:836
MSG::VERBOSE
Definition: IMessageSvc.h:17
merge_files.sc
int sc
Definition: merge_files.py:167
PropertyMgr
Property manager helper class.
Definition: PropertyMgr.h:37
IToolSvc.h
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
EventDataSvc
m_CSS m_DCS EventDataSvc
Definition: Algorithm.cpp:890
GaudiPluginService.cpluginsvc.n
list n
Definition: cpluginsvc.py:217
Algorithm::detDataService
SmartIF< IDataProviderSvc > & detDataService() const
Obsoleted name, kept due to the backwards compatibility.
Definition: Algorithm.cpp:905
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
ToolSvc
This service manages tools.
Definition: ToolSvc.h:23
IAuditor::ReStart
Definition: IAuditor.h:33
Gaudi::StringKey
The helper class to represent the efficient "key" for access.
Definition: StringKey.h:35
GaudiException::code
virtual const StatusCode & code() const
StatusCode for Exception.
Definition: GaudiException.h:127
AlgContextSvc
Definition: AlgContextSvc.h:28
Algorithm::sysRestart
StatusCode sysRestart() override
Restart method invoked by the framework.
Definition: Algorithm.cpp:379
Algorithm::detDataCnvService
SmartIF< IConversionSvc > & detDataCnvService() const
Obsoleted name, kept due to the backwards compatibility.
Definition: Algorithm.cpp:909
INamedInterface::name
virtual const std::string & name() const =0
Retrieve the name of the instance.
std::string
STL class.
RndmGenSvc
Random Generator service definition.
Definition: RndmGenSvc.h:49
AnalysisTest.execute
def execute()
Definition: AnalysisTest.py:25
Algorithm::registerTool
void registerTool(IAlgTool *tool) const
Definition: Algorithm.cpp:1116
INTupleSvc
Definition: INTupleSvc.h:37
Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:820
AthenaScenario.whiteboard
tuple whiteboard
Definition: AthenaScenario.py:77
IChronoStatSvc
The IChronoStatSvc is the interface implemented by the ChronoStatService.
Definition: IChronoStatSvc.h:33
TimelineEvent::end
time_point end
Definition: ITimelineSvc.h:26
IDataHandleVisitor::visit
virtual void visit(const IDataHandleHolder *)=0
InterfaceID
Interface ID class.
Definition: IInterface.h:30
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:844
IDataProviderSvc.h
IJobOptionsSvc
Main interface for the JobOptions service.
Definition: IJobOptionsSvc.h:20
gaudirun.type
string type
Definition: gaudirun.py:151
Algorithm::getProperty
StatusCode getProperty(Property *p) const override
Implementation of IProperty::getProperty.
Definition: Algorithm.cpp:989
StatusCode::FAILURE
Definition: StatusCode.h:29
Algorithm::sysReinitialize
StatusCode sysReinitialize() override
Reinitialization method invoked by the framework.
Definition: Algorithm.cpp:311
std::exception::what
T what(T...args)
IRndmGenSvc
Random Generator service interface definition Definition of a interface for a service to access rando...
Definition: IRndmGenSvc.h:35
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Algorithm::sysExecute
StatusCode sysExecute() override
The actions to be performed by the algorithm on an event.
Definition: Algorithm.cpp:567
GaudiException.h
Algorithm::isExecuted
bool isExecuted() const override
Has this algorithm been executed since the last reset?
Definition: Algorithm.cpp:840
IAuditor::Finalize
Definition: IAuditor.h:30
Algorithm::beginRun
StatusCode beginRun() override
Algorithm begin run.
Definition: Algorithm.cpp:500
Algorithm::nameKey
const Gaudi::StringKey & nameKey() const override
Definition: Algorithm.cpp:824
Algorithm::sysStart
StatusCode sysStart() override
Reinitialization method invoked by the framework.
Definition: Algorithm.cpp:243
ExceptionSvc
Simple implementation of IExceptionSvc abstract interface.
Definition: ExceptionSvc.h:19
Algorithm::index
unsigned int index() const override
Definition: Algorithm.cpp:832
Algorithm::sysFinalize
StatusCode sysFinalize() override
System finalization.
Definition: Algorithm.cpp:725
HiveAlgSequencer.h
tuple h
Definition: HiveAlgSequencer.py:24
MSG::NIL
Definition: IMessageSvc.h:16
serviceAccessor
serviceAccessor(auditorSvc, IAuditorSvc,"AuditorSvc", m_pAuditorSvc) serviceAccessor(chronoSvc
Guards.h
DHHVisitor
Definition: DataHandleHolderVisitor.h:9
StringKey.h
GaudiException::tag
virtual const std::string & tag() const
name tag for the exception, or exception type
Definition: GaudiException.h:119
IHistogramSvc
Definition of the IHistogramSvc interface class.
Definition: IHistogramSvc.h:47
IMessageSvc.h
DataHandleHolderVisitor.h
Algorithm::getProperties
const std::vector< Property * > & getProperties() const override
Implementation of IProperty::getProperties.
Definition: Algorithm.cpp:998
ITimelineSvc
Definition: ITimelineSvc.h:29
IHiveWhiteBoard
Definition: IHiveWhiteBoard.h:18
std::exception
STL class.
IAlgorithm
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:25
Algorithm::Algorithm
Algorithm(const std::string &name, ISvcLocator *svcloc, const std::string &version=PACKAGE_VERSION)
Constructor.
Definition: Algorithm.cpp:43
IAuditor::Initialize
Definition: IAuditor.h:25
DataObjIDProperty.h
Gaudi::StateMachine::STOP
Definition: StateMachine.h:27
TimelineEvent::start
time_point start
Definition: ITimelineSvc.h:25
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:865
IAlgContextSvc.h
Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:74
std::find
T find(T...args)
Gaudi::StateMachine::RUNNING
Definition: StateMachine.h:16
IProperty.h
Property
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:38
std::vector< std::string >
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:1125
NTupleSvc
NTuple service.
Definition: NTupleSvc.h:24
IConversionSvc.h
Algorithm::isEnabled
bool isEnabled() const override
Is this algorithm enabled or disabled?
Definition: Algorithm.cpp:853
DetectorPersistencySvc
m_CSS DetectorPersistencySvc
Definition: Algorithm.cpp:888
std::begin
T begin(T...args)
std::chrono::high_resolution_clock::now
T now(T...args)
TimelineEvent::slot
uint slot
Definition: ITimelineSvc.h:20
Algorithm::restart
StatusCode restart() override
the default (empty) implementation of IStateful::restart() method
Definition: Algorithm.cpp:805
Algorithm::acceptDHVisitor
virtual void acceptDHVisitor(IDataHandleVisitor *) const override
Definition: Algorithm.cpp:226
PropertyMgr.h
AlgTool
Base class from which all the concrete tool classes should be derived.
Definition: AlgTool.h:45
IAlgTool
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
ToolHandle.h
IAuditor::Execute
Definition: IAuditor.h:27
Algorithm::hasProperty
bool hasProperty(const std::string &name) const override
Implementation of IProperty::hasProperty.
Definition: Algorithm.cpp:1001
gaudirun.s
string s
Definition: gaudirun.py:245
Gaudi::StateMachine::START
Definition: StateMachine.h:26
ServiceLocatorHelper.h
Stat.h
IOTest.appMgr
tuple appMgr
Definition: IOTest.py:83
IAlgContextSvc
An abstract interface for Algorithm Context Service.
Definition: IAlgContextSvc.h:23
IAlgManager.h
IAuditor::EndRun
Definition: IAuditor.h:29
Algorithm::eventDataService
SmartIF< IDataProviderSvc > & eventDataService() const
Obsoleted name, kept due to the backwards compatibility.
Definition: Algorithm.cpp:913
Algorithm::histogramDataService
SmartIF< IHistogramSvc > & histogramDataService() const
Obsoleted name, kept due to the backwards compatibility.
Definition: Algorithm.cpp:921
Algorithm::service
StatusCode service(const std::string &name, T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
Definition: Algorithm.h:232
std::accumulate
T accumulate(T...args)
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:108
Algorithm::tools
const std::vector< IAlgTool * > & tools() const
Definition: Algorithm.cpp:1058
IProperty
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:21
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
IAuditorSvc
The interface implemented by the IAuditorSvc base class.
Definition: IAuditorSvc.h:15
Algorithm::ntupleService
SmartIF< INTupleSvc > & ntupleService() const
Obsoleted name, kept due to the backwards compatibility.
Definition: Algorithm.cpp:925
Algorithm::sysInitialize
StatusCode sysInitialize() override
Initialization method invoked by the framework.
Definition: Algorithm.cpp:105
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:785
Algorithm::setFilterPassed
void setFilterPassed(bool state) override
Set the filter passed flag to the specified state.
Definition: Algorithm.cpp:861
ISvcLocator.h
TimelineSvc
Definition: TimelineSvc.h:12
IExceptionSvc
The abstract interface for exception handling service.
Definition: IExceptionSvc.h:24
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
IOTest.start
tuple start
Definition: IOTest.py:88
ChronoStatSvc
The Chrono & Stat Sservice: service implements the IChronoStatSvc interface and provides the basic ch...
Definition: ChronoStatSvc.h:33
Algorithm::sysStop
StatusCode sysStop() override
System stop.
Definition: Algorithm.cpp:672
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