]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTSystem.h
Coding violations corrected (I.Kisel)
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTSystem.h
CommitLineData
f23a6e1a 1// @(#) $Id$
2
3#ifndef ALIHLTSYSTEM_H
4#define ALIHLTSYSTEM_H
5/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6 * See cxx source for full Copyright notice */
7
b22e91eb 8/** @file AliHLTSystem.h
9 @author Matthias Richter
10 @date
11 @brief Global HLT module management and AliRoot integration.
12 @note The class is used in Offline (AliRoot) context
13*/
f23a6e1a 14
b22e91eb 15/**
16 * @defgroup alihlt_system HLT integration into AliRoot
17 * This section describes the HLT integration into AliRoot.
18 */
f23a6e1a 19
5ec8e281 20#include "AliHLTLogging.h"
21#include <TList.h>
f23a6e1a 22
5ec8e281 23class AliHLTComponentHandler;
24class AliHLTConfiguration;
85465857 25class AliHLTConfigurationHandler;
5ec8e281 26class AliHLTTask;
242bb794 27class AliRunLoader;
28class AliRawReader;
29class AliESD;
90ebac25 30class TObjArray;
31class TStopwatch;
f23a6e1a 32
bfccbf68 33/**
34 * @class AliHLTSystem
35 * Main class for the HLT integration into AliRoot.
36 * The class handles a list of configurations. Configurations are translated
37 * into task lists which can be executed.
38 *
b22e91eb 39 * @note This class is only used for the @ref alihlt_system.
40 *
41 * @ingroup alihlt_system
bfccbf68 42 */
5ec8e281 43class AliHLTSystem : public AliHLTLogging {
44 public:
bfccbf68 45 /** default constructor */
f23a6e1a 46 AliHLTSystem();
85869391 47 /** not a valid copy constructor, defined according to effective C++ style */
48 AliHLTSystem(const AliHLTSystem&);
49 /** not a valid assignment op, but defined according to effective C++ style */
50 AliHLTSystem& operator=(const AliHLTSystem&);
bfccbf68 51 /** destructor */
f23a6e1a 52 virtual ~AliHLTSystem();
53
bfccbf68 54 /**
55 * Pointer to an instance of @ref AliHLTComponentHandler.
3b35e87c 56 */
70ed7d01 57 AliHLTComponentHandler* fpComponentHandler; //! transient
bfccbf68 58
59 /**
60 * Pointer to an instance of @ref AliHLTConfigurationHandler.
61 */
70ed7d01 62 AliHLTConfigurationHandler* fpConfigurationHandler; //! transient
f23a6e1a 63
bfccbf68 64 /**
65 * Add a configuration to the end of the list.
66 * @param pConf pointer to configuration to add
5ec8e281 67 */
68 int AddConfiguration(AliHLTConfiguration* pConf);
69
bfccbf68 70 /**
70ed7d01 71 * Insert a configuration to the end of the list after the specified
72 * configuration.
bfccbf68 73 * @param pConf pointer to configuration to insert
74 * @param pPrec pointer to configuration to insert the new one after
5ec8e281 75 */
76 int InsertConfiguration(AliHLTConfiguration* pConf, AliHLTConfiguration* pPrec);
77
bfccbf68 78 /**
79 * Remove a configuration from the list.
80 * @param pConf pointer to configuration to delete
5ec8e281 81 */
82 int DeleteConfiguration(AliHLTConfiguration* pConf);
83
bfccbf68 84 /**
a742f6f8 85 * Build a task list
3b35e87c 86 * This method is used to build the tasks from the 'master' configuration
87 * objects which are added to the HLT system handler. This is an iterative
88 * process since the task might depend upon other configurations. For each
89 * configuration object which has not yet been converted into a task, the
90 * method will be called iteratively. Finally, after building all tasks which
91 * the current one depends on have been created, the task is inserted to the
92 * list of tasks with the InsertTask method.
a742f6f8 93 * @param pConf configuration name/id
94 */
95 int BuildTaskList(const char* pConf);
96
97 /**
98 * Build task list from a configuration object.
99 * This method is kept for backward compatibility. Use the version
100 * with the configuration name.
bfccbf68 101 * @param pConf pointer to configuration to build the task list from
5ec8e281 102 */
103 int BuildTaskList(AliHLTConfiguration* pConf);
104
bfccbf68 105 /**
106 * Clean the list of tasks and delete all the task objects.
3b35e87c 107 */
5ec8e281 108 int CleanTaskList();
109
bfccbf68 110 /**
111 * Insert a task to the task list.
112 * The method first checks whether all dependencies are resolved (i.e. exist
70ed7d01 113 * already in the task list). During this iteration the cross links between
114 * the tasks are set as well. If all dependencies are resolved, the task is
115 * added at the end of the list.
bfccbf68 116 * @param pTask pointer to task to add
3b35e87c 117 */
5ec8e281 118 int InsertTask(AliHLTTask* pTask);
119
bfccbf68 120 /**
121 * Find a task with an id.
122 * @param id CONFIGURATION id (not a COMPONENT id!)
3b35e87c 123 */
5ec8e281 124 AliHLTTask* FindTask(const char* id);
125
bfccbf68 126 /**
127 * Print the task list.
3b35e87c 128 */
5ec8e281 129 void PrintTaskList();
130
53feaef5 131 /**
132 * Run the task list.
9ce4bf4a 133 * The method checks whether the task list has already been build. If not,
134 * or the configuration list has been changed, the @ref BuildTaskList
135 * method is scalled
53feaef5 136 * All tasks of the list will be subsequently processed for each event.
137 * @param iNofEvents number of events
242bb794 138 * @return number of reconstructed events, neg error code if failed
53feaef5 139 */
140 int Run(Int_t iNofEvents=1);
141
9ce4bf4a 142 /**
143 * Init all tasks from the list.
144 * The @ref AliHLTTask::Init method is called for each task, the components
145 * will be created.
146 * @return neg error code if failed
147 */
148 int InitTasks();
149
90ebac25 150 /**
151 * Init the stopwatches for all tasks.
152 * @param pStopwatches object array of stopwatches, for types
153 * @see AliHLTComponent::AliHLTStopwatchType
154 * @return neg error code if failed
155 */
156 int InitBenchmarking(TObjArray* pStopwatches);
157
53feaef5 158 /**
159 * Start task list.
70ed7d01 160 * The @ref AliHLTTask::StartRun method is called for each task, the
161 * components will be prepared for event processing.
53feaef5 162 * @return neg error code if failed
163 */
164 int StartTasks();
165
166 /**
167 * Process task list.
168 * The @ref AliHLTTask::ProcessTask method is called for each task.
169 * @return neg error code if failed
170 */
171 int ProcessTasks(Int_t eventNo);
172
173 /**
174 * Stop task list.
175 * The @ref AliHLTTask::EndRun method is called for each task, the components
176 * will be cleaned after event processing.
177 * @return neg error code if failed
5ec8e281 178 */
53feaef5 179 int StopTasks();
5ec8e281 180
9ce4bf4a 181 /**
182 * De-init all tasks from the list.
183 * The @ref AliHLTTask::Deinit method is called for each task, the components
184 * will be deleted.
185 * @return neg error code if failed
186 */
187 int DeinitTasks();
188
189 /**
190 * The memory allocation function for components.
191 * This function is part of the running environment of the components.
192 */
193 static void* AllocMemory( void* param, unsigned long size );
194
242bb794 195 /**
196 * Reconstruction inside AliRoot.
197 * To be called by the AliHLTReconstructor plugin during the
198 * LocalReconstruction step of the AliRoot reconstruction. The latter means
199 * that all events are reconstructed at once, the event loop is internally
200 * implemented. In contrast to that, the FillESD method is called event by
201 * event. This requires an 'ESD' recorder at the end of the HLT chain, in
202 * order to have the reconstructed events available for the FillESD loop.
203 * The 'runLoader' and 'rawReader' parameters are set to all active
204 * AliHLTOfflineDataSource's and the HLT chain is processed for the given
205 * number of events. If the rawReader is NULL, reconstruction is done on
206 * simulated data, from real data if a RawReader is specified.
207 * @param nofEvents number of events
208 * @param runLoader the AliRoot runloader
209 * @param rawReader the AliRoot RawReader
210 * @return number of reconstructed events, neg. error code if failed
211 */
212 int Reconstruct(int nofEvents, AliRunLoader* runLoader,
213 AliRawReader* rawReader=NULL);
214
215 /**
216 * Fill ESD for one event.
217 * To be called by the AliHLTReconstructor plugin during the event loop
218 * and FillESD method of the AliRoot reconstruction.
219 * This method is called on event basis, and thus must copy the previously
220 * reconstructed data of the event from the 'ESD' recorder. The FillESD
221 * method of all active AliHLTOfflineDataSink's is called.
222 * @param eventNo current event no (Note: this event number is just a
223 * processing counter and is not related to the nature/
224 * origin of the event
225 * @param runLoader the AliRoot runloader
226 * @param esd an AliESD instance
227 * @return neg. error code if failed
228 */
229 int FillESD(int eventNo, AliRunLoader* runLoader, AliESD* esd);
230
231 /**
232 * Load component libraries.
233 * @param libs string of blank separated library names
234 * @return neg. error code if failed
235 */
236 int LoadComponentLibraries(const char* libs);
237
85f0cede 238 /**
239 * Find a symbol in a dynamically loaded library.
240 * @param library library
241 * @param symbol the symbol to find
242 * @return void pointer to function
243 */
244 void* FindDynamicSymbol(const char* library, const char* symbol);
245
242bb794 246 /**
247 * Prepare the HLT system for running.
248 * - module agents are requested to register configurations
249 * - task lists are built from the top configurations of the modules
250 * @return neg. error code if failed <br>
251 * -EBUSY system is in kRunning state <br>
252 */
253 int Configure(AliRunLoader* runloader=NULL);
254
255 /**
256 * Reset the HLT system.
257 * Reset is not possible while the system is in running state.
258 * @param bForce force the reset
259 * @return neg. error code if failed <br>
260 * -EBUSY system is in kRunning state <br>
261 */
262 int Reset(int bForce=0);
263
264 /**
265 * Load the configurations specified by the module agents.
266 * The runLoader is passed to the agent and allows configuration
267 * selection.
268 * @return neg. error code if failed
269 */
270 int LoadConfigurations(AliRunLoader* runloader=NULL);
271
272 /**
273 * Get the top configurations of all agents and build the task lists.
274 * @return neg. error code if failed
275 */
276 int BuildTaskListsFromTopConfigurations(AliRunLoader* runloader=NULL);
277
9253e11b 278 enum AliHLTSystemState_t {
242bb794 279 kUninitialized = 0x0,
280 kLibrariesLoaded = 0x1,
281 kConfigurationLoaded = 0x2,
282 kTaskListCreated = 0x4,
283 kReady = 0x7,
284 kRunning = 0x8,
285 kError = 0x1000
9253e11b 286 };
242bb794 287
288 /**
289 * Check status of the system.
290 * @param flag AliHLTSystemState_t value to check for
291 * @return 1 if set, 0 if not
292 */
293 int CheckStatus(int flag);
294
295 /**
296 * Get the current status.
297 * @return status flags of @ref AliHLTSystemState_t
298 */
299 int GetStatusFlags();
300
5ec8e281 301 protected:
5ec8e281 302
303 private:
242bb794 304 /**
305 * Set status flags.
306 */
307 int SetStatusFlags(int flags);
308
309 /**
310 * clear status flags.
311 */
312 int ClearStatusFlags(int flags);
313
85869391 314/* TList fConfList; */
315/* int fbListChanged; */
5ec8e281 316
242bb794 317 /** list of tasks */
70ed7d01 318 TList fTaskList; // see above
f23a6e1a 319
fc455fba 320 /** the number of instances of AliHLTSystem */
321 static int fgNofInstances; // see above
322
242bb794 323 /** state of the object */
324 int fState; // see above
325
5ec8e281 326 private:
fc455fba 327 ClassDef(AliHLTSystem, 2);
f23a6e1a 328};
329#endif
330