]>
Commit | Line | Data |
---|---|---|
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> | |
c043fa2c | 29 | #include <TString.h> |
f23a6e1a | 30 | |
5ec8e281 | 31 | class AliHLTComponentHandler; |
32 | class AliHLTConfiguration; | |
85465857 | 33 | class AliHLTConfigurationHandler; |
5ec8e281 | 34 | class AliHLTTask; |
242bb794 | 35 | class AliRunLoader; |
36 | class AliRawReader; | |
af885e0f | 37 | class AliESDEvent; |
90ebac25 | 38 | class TObjArray; |
39 | class TStopwatch; | |
f23a6e1a | 40 | |
bfccbf68 | 41 | /** |
42 | * @class AliHLTSystem | |
43 | * Main class for the HLT integration into AliRoot. | |
44 | * The class handles a list of configurations. Configurations are translated | |
45 | * into task lists which can be executed. | |
46 | * | |
b22e91eb | 47 | * @note This class is only used for the @ref alihlt_system. |
48 | * | |
49 | * @ingroup alihlt_system | |
bfccbf68 | 50 | */ |
5ec8e281 | 51 | class AliHLTSystem : public AliHLTLogging { |
52 | public: | |
bfccbf68 | 53 | /** default constructor */ |
f23a6e1a | 54 | AliHLTSystem(); |
bfccbf68 | 55 | /** destructor */ |
f23a6e1a | 56 | virtual ~AliHLTSystem(); |
57 | ||
bfccbf68 | 58 | /** |
59 | * Pointer to an instance of @ref AliHLTComponentHandler. | |
3b35e87c | 60 | */ |
70ed7d01 | 61 | AliHLTComponentHandler* fpComponentHandler; //! transient |
bfccbf68 | 62 | |
63 | /** | |
64 | * Pointer to an instance of @ref AliHLTConfigurationHandler. | |
65 | */ | |
70ed7d01 | 66 | AliHLTConfigurationHandler* fpConfigurationHandler; //! transient |
f23a6e1a | 67 | |
bfccbf68 | 68 | /** |
69 | * Add a configuration to the end of the list. | |
70 | * @param pConf pointer to configuration to add | |
5ec8e281 | 71 | */ |
72 | int AddConfiguration(AliHLTConfiguration* pConf); | |
73 | ||
bfccbf68 | 74 | /** |
70ed7d01 | 75 | * Insert a configuration to the end of the list after the specified |
76 | * configuration. | |
bfccbf68 | 77 | * @param pConf pointer to configuration to insert |
78 | * @param pPrec pointer to configuration to insert the new one after | |
5ec8e281 | 79 | */ |
80 | int InsertConfiguration(AliHLTConfiguration* pConf, AliHLTConfiguration* pPrec); | |
81 | ||
bfccbf68 | 82 | /** |
83 | * Remove a configuration from the list. | |
84 | * @param pConf pointer to configuration to delete | |
5ec8e281 | 85 | */ |
86 | int DeleteConfiguration(AliHLTConfiguration* pConf); | |
87 | ||
bfccbf68 | 88 | /** |
a742f6f8 | 89 | * Build a task list |
3b35e87c | 90 | * This method is used to build the tasks from the 'master' configuration |
91 | * objects which are added to the HLT system handler. This is an iterative | |
92 | * process since the task might depend upon other configurations. For each | |
93 | * configuration object which has not yet been converted into a task, the | |
94 | * method will be called iteratively. Finally, after building all tasks which | |
95 | * the current one depends on have been created, the task is inserted to the | |
96 | * list of tasks with the InsertTask method. | |
a742f6f8 | 97 | * @param pConf configuration name/id |
98 | */ | |
99 | int BuildTaskList(const char* pConf); | |
100 | ||
101 | /** | |
102 | * Build task list from a configuration object. | |
103 | * This method is kept for backward compatibility. Use the version | |
104 | * with the configuration name. | |
bfccbf68 | 105 | * @param pConf pointer to configuration to build the task list from |
5ec8e281 | 106 | */ |
107 | int BuildTaskList(AliHLTConfiguration* pConf); | |
108 | ||
bfccbf68 | 109 | /** |
110 | * Clean the list of tasks and delete all the task objects. | |
3b35e87c | 111 | */ |
5ec8e281 | 112 | int CleanTaskList(); |
113 | ||
bfccbf68 | 114 | /** |
115 | * Insert a task to the task list. | |
116 | * The method first checks whether all dependencies are resolved (i.e. exist | |
70ed7d01 | 117 | * already in the task list). During this iteration the cross links between |
118 | * the tasks are set as well. If all dependencies are resolved, the task is | |
119 | * added at the end of the list. | |
bfccbf68 | 120 | * @param pTask pointer to task to add |
3b35e87c | 121 | */ |
5ec8e281 | 122 | int InsertTask(AliHLTTask* pTask); |
123 | ||
bfccbf68 | 124 | /** |
125 | * Find a task with an id. | |
126 | * @param id CONFIGURATION id (not a COMPONENT id!) | |
3b35e87c | 127 | */ |
5ec8e281 | 128 | AliHLTTask* FindTask(const char* id); |
129 | ||
bfccbf68 | 130 | /** |
131 | * Print the task list. | |
3b35e87c | 132 | */ |
5ec8e281 | 133 | void PrintTaskList(); |
134 | ||
53feaef5 | 135 | /** |
136 | * Run the task list. | |
9ce4bf4a | 137 | * The method checks whether the task list has already been build. If not, |
138 | * or the configuration list has been changed, the @ref BuildTaskList | |
dee38f1b | 139 | * method is called. <br> |
53feaef5 | 140 | * All tasks of the list will be subsequently processed for each event. |
dee38f1b | 141 | * The system can remain started if the \em bStop parameter is 0. In that |
142 | * case the system just waits for the next event. A specific call with | |
143 | * nofEvents==0 is needed to execute the stop sequence. | |
53feaef5 | 144 | * @param iNofEvents number of events |
dee38f1b | 145 | * @param bStop stop the chain after processing |
242bb794 | 146 | * @return number of reconstructed events, neg error code if failed |
53feaef5 | 147 | */ |
dee38f1b | 148 | int Run(Int_t iNofEvents=1, int bStop=1); |
53feaef5 | 149 | |
9ce4bf4a | 150 | /** |
151 | * Init all tasks from the list. | |
152 | * The @ref AliHLTTask::Init method is called for each task, the components | |
153 | * will be created. | |
154 | * @return neg error code if failed | |
155 | */ | |
156 | int InitTasks(); | |
157 | ||
90ebac25 | 158 | /** |
159 | * Init the stopwatches for all tasks. | |
160 | * @param pStopwatches object array of stopwatches, for types | |
161 | * @see AliHLTComponent::AliHLTStopwatchType | |
162 | * @return neg error code if failed | |
163 | */ | |
164 | int InitBenchmarking(TObjArray* pStopwatches); | |
165 | ||
dee38f1b | 166 | /** |
167 | * Print benchmarking summary. | |
168 | * Optionak: clean up stop watches. | |
169 | * @param pStopwatches object array of stopwatches | |
170 | * @param bClean delete stop watches if 1 | |
171 | * @return neg error code if failed | |
172 | */ | |
173 | int PrintBenchmarking(TObjArray* pStopwatches, int bClean=0); | |
174 | ||
53feaef5 | 175 | /** |
176 | * Start task list. | |
70ed7d01 | 177 | * The @ref AliHLTTask::StartRun method is called for each task, the |
178 | * components will be prepared for event processing. | |
53feaef5 | 179 | * @return neg error code if failed |
180 | */ | |
181 | int StartTasks(); | |
182 | ||
183 | /** | |
184 | * Process task list. | |
185 | * The @ref AliHLTTask::ProcessTask method is called for each task. | |
186 | * @return neg error code if failed | |
187 | */ | |
188 | int ProcessTasks(Int_t eventNo); | |
189 | ||
190 | /** | |
191 | * Stop task list. | |
192 | * The @ref AliHLTTask::EndRun method is called for each task, the components | |
193 | * will be cleaned after event processing. | |
194 | * @return neg error code if failed | |
5ec8e281 | 195 | */ |
53feaef5 | 196 | int StopTasks(); |
5ec8e281 | 197 | |
9ce4bf4a | 198 | /** |
199 | * De-init all tasks from the list. | |
200 | * The @ref AliHLTTask::Deinit method is called for each task, the components | |
201 | * will be deleted. | |
202 | * @return neg error code if failed | |
203 | */ | |
204 | int DeinitTasks(); | |
205 | ||
206 | /** | |
207 | * The memory allocation function for components. | |
208 | * This function is part of the running environment of the components. | |
209 | */ | |
210 | static void* AllocMemory( void* param, unsigned long size ); | |
211 | ||
242bb794 | 212 | /** |
dee38f1b | 213 | * AliRoot embedded reconstruction. |
214 | * Main entry point to execute the HLT reconstruction from AliRoot. Called | |
215 | * either by the AliHLTReconstructor plugin during AliRoot reconstruction | |
216 | * of raw data, or AliHLTSimulation during simulation of data. | |
217 | * | |
218 | * The two cases are distinguished by the availablility of the run loader | |
219 | * and raw reader. | |
220 | * - AliRoot simulation: run loader is available and is propagated to the | |
221 | * module agents (AliHLTModuleAgent) to generate the corresponding | |
222 | * configurations and chains, and to the AliHLTOfflineSource components. | |
223 | * - AliRoot reconstruction: raw reader is available and is propagated to | |
224 | * the agents and AliHLTOfflineSource components. | |
225 | * | |
226 | * The system remains started after the processing and just waits for the | |
227 | * next event. A specific call with nofEvents==0 is needed to execute the | |
228 | * stop sequence. | |
229 | * | |
242bb794 | 230 | * The 'runLoader' and 'rawReader' parameters are set to all active |
231 | * AliHLTOfflineDataSource's and the HLT chain is processed for the given | |
232 | * number of events. If the rawReader is NULL, reconstruction is done on | |
233 | * simulated data, from real data if a RawReader is specified. | |
234 | * @param nofEvents number of events | |
235 | * @param runLoader the AliRoot runloader | |
236 | * @param rawReader the AliRoot RawReader | |
237 | * @return number of reconstructed events, neg. error code if failed | |
238 | */ | |
239 | int Reconstruct(int nofEvents, AliRunLoader* runLoader, | |
240 | AliRawReader* rawReader=NULL); | |
241 | ||
242 | /** | |
243 | * Fill ESD for one event. | |
244 | * To be called by the AliHLTReconstructor plugin during the event loop | |
245 | * and FillESD method of the AliRoot reconstruction. | |
246 | * This method is called on event basis, and thus must copy the previously | |
247 | * reconstructed data of the event from the 'ESD' recorder. The FillESD | |
248 | * method of all active AliHLTOfflineDataSink's is called. | |
249 | * @param eventNo current event no (Note: this event number is just a | |
250 | * processing counter and is not related to the nature/ | |
251 | * origin of the event | |
252 | * @param runLoader the AliRoot runloader | |
af885e0f | 253 | * @param esd an AliESDEvent instance |
242bb794 | 254 | * @return neg. error code if failed |
255 | */ | |
af885e0f | 256 | int FillESD(int eventNo, AliRunLoader* runLoader, AliESDEvent* esd); |
242bb794 | 257 | |
258 | /** | |
259 | * Load component libraries. | |
260 | * @param libs string of blank separated library names | |
261 | * @return neg. error code if failed | |
262 | */ | |
263 | int LoadComponentLibraries(const char* libs); | |
264 | ||
85f0cede | 265 | /** |
266 | * Find a symbol in a dynamically loaded library. | |
267 | * @param library library | |
268 | * @param symbol the symbol to find | |
269 | * @return void pointer to function | |
270 | */ | |
271 | void* FindDynamicSymbol(const char* library, const char* symbol); | |
272 | ||
242bb794 | 273 | /** |
274 | * Prepare the HLT system for running. | |
275 | * - module agents are requested to register configurations | |
276 | * - task lists are built from the top configurations of the modules | |
c043fa2c | 277 | * |
dee38f1b | 278 | * @param rawReader instance of the raw reader or NULL |
c043fa2c | 279 | * @param runloader optional instance of the run loader |
242bb794 | 280 | * @return neg. error code if failed <br> |
281 | * -EBUSY system is in kRunning state <br> | |
282 | */ | |
dee38f1b | 283 | int Configure(AliRawReader* rawReader, AliRunLoader* runloader=NULL); |
242bb794 | 284 | |
dee38f1b | 285 | /** |
286 | * Old method kept for backward compatibilty. | |
287 | * | |
288 | * @param runloader optional instance of the run loader | |
289 | * @return neg. error code if failed <br> | |
290 | * -EBUSY system is in kRunning state <br> | |
291 | */ | |
292 | int Configure(AliRunLoader* runloader=NULL); | |
c043fa2c | 293 | |
294 | /** | |
295 | * Scan options. | |
296 | * Known options | |
297 | * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formating --> | |
298 | * \li loglevel=<i>level</i> <br> | |
299 | * logging level for this processing | |
dba03d72 | 300 | * \li frameworklog=<i>level</i> <br> |
301 | * logging level for framework classes | |
c043fa2c | 302 | * \li alilog=off |
303 | * disable redirection of log messages to AliLog class | |
304 | * \li config=<i>macro</i> | |
305 | * configuration macro | |
dee38f1b | 306 | * \li chains=<i>configuration</i> |
c043fa2c | 307 | * comma separated list of configurations to be run during local |
308 | * reconstruction | |
dba03d72 | 309 | * \li libmode=<i>static,dynamic(default)</i> |
310 | * libraries are persistent if loaded in mode <i>static</i>, i.e. they | |
311 | * can't be unloaded | |
c043fa2c | 312 | */ |
313 | int ScanOptions(const char* options); | |
314 | ||
242bb794 | 315 | /** |
316 | * Reset the HLT system. | |
317 | * Reset is not possible while the system is in running state. | |
318 | * @param bForce force the reset | |
319 | * @return neg. error code if failed <br> | |
320 | * -EBUSY system is in kRunning state <br> | |
321 | */ | |
322 | int Reset(int bForce=0); | |
323 | ||
324 | /** | |
325 | * Load the configurations specified by the module agents. | |
326 | * The runLoader is passed to the agent and allows configuration | |
327 | * selection. | |
dee38f1b | 328 | * @param rawReader instance of the raw reader or NULL |
329 | * @param runloader optional instance of the run loader | |
242bb794 | 330 | * @return neg. error code if failed |
331 | */ | |
dee38f1b | 332 | int LoadConfigurations(AliRawReader* rawReader, AliRunLoader* runloader=NULL); |
242bb794 | 333 | |
334 | /** | |
335 | * Get the top configurations of all agents and build the task lists. | |
dee38f1b | 336 | * @param rawReader instance of the raw reader or NULL |
337 | * @param runloader optional instance of the run loader | |
242bb794 | 338 | * @return neg. error code if failed |
339 | */ | |
f3506ea2 | 340 | int BuildTaskListsFromReconstructionChains(AliRawReader* rawReader, |
341 | AliRunLoader* runloader=NULL); | |
242bb794 | 342 | |
9253e11b | 343 | enum AliHLTSystemState_t { |
242bb794 | 344 | kUninitialized = 0x0, |
345 | kLibrariesLoaded = 0x1, | |
346 | kConfigurationLoaded = 0x2, | |
347 | kTaskListCreated = 0x4, | |
348 | kReady = 0x7, | |
dee38f1b | 349 | kStarted = 0x8, |
350 | kRunning = 0x10, | |
242bb794 | 351 | kError = 0x1000 |
9253e11b | 352 | }; |
242bb794 | 353 | |
354 | /** | |
355 | * Check status of the system. | |
356 | * @param flag AliHLTSystemState_t value to check for | |
357 | * @return 1 if set, 0 if not | |
358 | */ | |
359 | int CheckStatus(int flag); | |
360 | ||
361 | /** | |
362 | * Get the current status. | |
363 | * @return status flags of @ref AliHLTSystemState_t | |
364 | */ | |
365 | int GetStatusFlags(); | |
366 | ||
5ec8e281 | 367 | protected: |
5ec8e281 | 368 | |
369 | private: | |
c043fa2c | 370 | /** copy constructor prohibited */ |
371 | AliHLTSystem(const AliHLTSystem&); | |
372 | /** assignment operator prohibited */ | |
373 | AliHLTSystem& operator=(const AliHLTSystem&); | |
374 | ||
242bb794 | 375 | /** |
376 | * Set status flags. | |
377 | */ | |
378 | int SetStatusFlags(int flags); | |
379 | ||
380 | /** | |
381 | * clear status flags. | |
382 | */ | |
383 | int ClearStatusFlags(int flags); | |
384 | ||
dba03d72 | 385 | /** |
386 | * Set logging level for framework classes. | |
387 | * This sets the local logging level of this instance and all subsequent | |
388 | * framework classes to \em level. | |
389 | * @param level local logging level for the framework classes | |
390 | */ | |
391 | void SetFrameworkLog(AliHLTComponentLogSeverity level); | |
c043fa2c | 392 | |
85869391 | 393 | /* TList fConfList; */ |
394 | /* int fbListChanged; */ | |
5ec8e281 | 395 | |
242bb794 | 396 | /** list of tasks */ |
70ed7d01 | 397 | TList fTaskList; // see above |
f23a6e1a | 398 | |
fc455fba | 399 | /** the number of instances of AliHLTSystem */ |
400 | static int fgNofInstances; // see above | |
401 | ||
242bb794 | 402 | /** state of the object */ |
403 | int fState; // see above | |
404 | ||
dee38f1b | 405 | /** chains to be run during reconstruction */ |
406 | TString fChains; //!transient | |
407 | ||
408 | /* array of stopwatches */ | |
409 | TObjArray* fStopwatches; //!transient | |
410 | ||
411 | /* number of events processed in total */ | |
412 | int fEventCount; //!transient | |
413 | ||
414 | /* number of events processed successfully */ | |
415 | int fGoodEvents; //!transient | |
c043fa2c | 416 | |
5ec8e281 | 417 | private: |
dee38f1b | 418 | ClassDef(AliHLTSystem, 4); |
f23a6e1a | 419 | }; |
f23a6e1a | 420 | |
c043fa2c | 421 | #endif |