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