EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairTask.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairTask.cxx
1 // -------------------------------------------------------------------------
2 // ----- FairTask source file -----
3 // ----- Created 12/01/04 by M. Al-Turany / D. Bertini -----
4 // -------------------------------------------------------------------------
5 
6 #include "FairTask.h"
7 #include "FairLogger.h"
8 
9 #include <iostream>
10 using std::cout;
11 using std::endl;
12 
13 // ----- Default constructor -------------------------------------------
15  : TTask(),
16  fVerbose(0),
17  fInputPersistance(-1),
18  fLogger(FairLogger::GetLogger())
19 {
20 }
21 // -------------------------------------------------------------------------
22 
23 
24 
25 // ----- Standard constructor ------------------------------------------
26 FairTask::FairTask(const char* name, Int_t iVerbose)
27  : TTask(name, "FairTask"),
28  fVerbose(iVerbose),
29  fInputPersistance(-1),
30  fLogger(FairLogger::GetLogger())
31 {
32 
33 }
34 // -------------------------------------------------------------------------
35 
36 
37 
38 // ----- Destructor ----------------------------------------------------
40 // -------------------------------------------------------------------------
41 
42 
43 
44 // ----- Public method InitTask ----------------------------------------
46 {
47  if ( ! fActive ) { return; }
48  InitStatus tStat = Init();
49  if ( tStat == kFATAL ) {
50  fLogger->Fatal(MESSAGE_ORIGIN,"Initialization of Task %s failed fatally", fName.Data());
51  }
52  if ( tStat == kERROR ) { fActive = kFALSE; }
53  InitTasks();
54 }
55 // -------------------------------------------------------------------------
56 
57 
58 
59 // ----- Public method ReInitTask --------------------------------------
61 {
62  if ( ! fActive ) { return; }
63  InitStatus tStat = ReInit();
64  if ( tStat == kFATAL ) {
65  fLogger->Fatal(MESSAGE_ORIGIN,"Reinitialization of Task %s failed fatally", fName.Data());
66  }
67  if ( tStat == kERROR ) { fActive = kFALSE; }
68  ReInitTasks();
69 }
70 // -------------------------------------------------------------------------
71 
72 
73 
74 // ----- Public method SetParTask --------------------------------------
76 {
77  if ( ! fActive ) { return; }
79  SetParTasks();
80 }
81 // -------------------------------------------------------------------------
82 
83 // ----- Public method FinishEvent -------------------------------------
85 {
86  if ( ! fActive ) { return; }
87  FinishEvents();
88  // FinishTasks();
89 }
90 
91 // ----- Public method FinishTask -------------------------------------
93 {
94  if ( ! fActive ) { return; }
95  Finish();
96  FinishTasks();
97 }
98 // -------------------------------------------------------------------------
99 
100 
101 
102 // ----- Public method SetVerbose --------------------------------------
103 void FairTask::SetVerbose(Int_t iVerbose)
104 {
105  fVerbose = iVerbose;
106  TIter next(GetListOfTasks());
107  FairTask* task;
108  while((task=dynamic_cast <FairTask*> (next()))) { task->SetVerbose(iVerbose); }
109 }
110 // -------------------------------------------------------------------------
111 
112 
113 
114 
115 // ----- Protected method InitTasks ------------------------------------
117 {
118  TIter next(GetListOfTasks());
119  FairTask* task;
120  while( ( task=dynamic_cast<FairTask*>(next()) ) ) { task->InitTask(); }
121 }
122 // -------------------------------------------------------------------------
123 
124 
125 
126 // ----- Protected method ReInitTasks ----------------------------------
128 {
129  TIter next(GetListOfTasks());
130  FairTask* task;
131  while( ( task=dynamic_cast<FairTask*>(next()) ) ) { task->ReInitTask(); }
132 }
133 // -------------------------------------------------------------------------
134 
135 
136 
137 // ----- Protected method SetParTasks ----------------------------------
139 {
140  TIter next(GetListOfTasks());
141  FairTask* task;
142  while( ( task=dynamic_cast<FairTask*>(next()) ) ) { task->SetParTask(); }
143 }
144 // -------------------------------------------------------------------------
145 
146 
147 
148 // ----- Protected method FinishTasks ----------------------------------
150 {
151  TIter next(GetListOfTasks());
152  FairTask* task;
153  while( ( task=dynamic_cast<FairTask*>(next()) ) ) { task->FinishTask(); }
154  while( ( task=dynamic_cast<FairTask*>(next()) ) ) { task->Finish(); }
155 }
156 // -------------------------------------------------------------------------
157 
158 // ----- Protected method FinishEvents ----------------------------------
160 {
161  TIter next(GetListOfTasks());
162  FairTask* task;
163  while( ( task=dynamic_cast<FairTask*>(next()) ) ) { task->FinishEvent(); }
164 }
165 // -------------------------------------------------------------------------
166 
167