]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/sim/AliHLTSimulation.h
HLTqadm
[u/mrichter/AliRoot.git] / HLT / sim / AliHLTSimulation.h
1 //-*- Mode: C++ -*-
2 // $Id$
3
4 #ifndef ALIHLTSIMULATION_H
5 #define ALIHLTSIMULATION_H
6 /* This file is property of and copyright by the ALICE HLT Project        * 
7  * ALICE Experiment at CERN, All rights reserved.                         *
8  * See cxx source for full Copyright notice                               */
9
10 /// @file   AliHLTSimulation.h
11 /// @author Matthias Richter
12 /// @date   
13 /// @brief  Binding class for HLT simulation in AliRoot
14 ///
15
16 /**
17  * @defgroup alihlt_aliroot_simulation HLT simulation in AliRoot
18  * This section describes the the simulation of the HLT in AliRoot.
19  *
20  * @section alihlt_aliroot_simulation_intro General Remarks
21  * HLT has a special role in the normal data flow  of simulation and
22  * reconstruction. Since the HLT reconstruction and analysis runs on-line
23  * on the HLT farm, the raw data produced by HLT as a detector contains
24  * already reconstructed events. Consequently, the HLT response has to be
25  * simulated as well as the data of all other detectors. Since the detector
26  * data is needed, the HLT simulation is run at the end of AliSimulation.
27  * As a matter of fact, HLT always reconstructs data, <em><b>HLT simulation
28  * </b></em> means <em><b>HLT reconstruction embedded into AliRoot</b></em>.
29  *
30  * @section alihlt_aliroot_simulation_steering Steering
31  * The AliHLTSimulation class is the steering class called from AliSimulation.
32  * An instance of AliHLTSystem is used to run the chains defined by the
33  * available libraries or a AliHLTConfiguration configuration macro.
34  *
35  * The libraries to be loaded can be specified as an option to AliSimulation.
36  * <pre>
37  * AliSimulation sim;
38  * sim.SetRunHLT("libAliHLTSample.so");
39  * </pre>
40  * @see AliHLTSimulation for further details
41  *
42  * @section alihlt_aliroot_simulation_running Running
43  * The actual chains to be run depend on the HLT library modules which 
44  * are loaded to the system. There is a default collection of libraries 
45  * defined in AliHLTSystem::fgkHLTDefaultLibs. The default libraries are 
46  * loaded if nothing else is specified. The libraries implement \em agents 
47  * (AliHLTModuleAgent childs) describing the properties of a module.
48  *
49  * @section alihlt_aliroot_simulation_examples Examples
50  * - @ref tut_simulation 
51  *
52  * @ingroup alihlt_system
53  */
54
55 #include "TObject.h"
56 #include "TString.h"
57 class AliRunLoader;
58 class AliHLTPluginBase;
59 class AliRawReader;
60 class AliSimulation;
61 class AliHLTSystem;
62
63 /**
64  * @class AliHLTSimulation
65  * Plugin for HLT reconstruction embedded into <tt>AliSimulation</tt>.
66  *
67  * The libraries to be loaded can be specified as an option to AliSimulation.
68  * <pre>
69  * AliSimulation sim;
70  * sim.SetRunHLT("libAliHLTSample.so");
71  * </pre>
72  * will only load <tt>libAliHLTSample.so</tt>
73  *
74  * Other available options:
75  * \li loglevel=<i>level</i>                                            <br>
76  *     logging level for this processing, default level is 0x79 filtering
77  *     out everything below level 'warning'. 0x7c allows info messages as
78  *     well, 0x3f is the highest loglevel.
79  * \li alilog=off                                                       <br>
80  *     disable redirection of log messages to AliLog class
81  * \li config=<i>macro</i>                                              <br>
82  *     configuration macro: normal ROOT macro defining HLT component
83  *     configurations by means of AliHLTConfiguration.
84  * \li chains=<i>configuration</i>                                      <br>
85  *     comma separated list of configurations to be run during simulation
86  * \li events=<i>n</i>
87  *     number of events to simulate
88  *
89  *  @ingroup alihlt_aliroot_simulation
90  */
91 class AliHLTSimulation : public TObject {
92  public:
93   /** create an instance of the class */
94   static AliHLTSimulation* CreateInstance();
95
96   /** delete an instance */
97   static int DeleteInstance(AliHLTSimulation* pSim);
98
99   /** init simulation */
100   int Init(AliRunLoader* pRunLoader, const char* options);
101
102   int ConfigureHLTSystem(AliHLTSystem* pSystem, const char* options, AliRunLoader* pRunLoader, AliRawReader* pRawReader) const;
103
104   /** run simulation with an instance of the run loader */
105   int Run(AliRunLoader* pRunLoader);
106
107   /// run reconstruction cycle for AliHLTSystem
108   int RunHLTSystem(AliHLTSystem* pSystem, AliRunLoader* pRunLoader, AliRawReader* pRawReader) const;
109
110   enum EOptions {
111     // indicate that only one chain should be run, behavior before Dec 2010
112     kOneChain = BIT(15)
113   };
114
115  private:
116   /** standard constructor */
117   AliHLTSimulation();
118   /** copy constructor prohibited */
119   AliHLTSimulation(const AliHLTSimulation&);
120   /** assignment operator prohibited */
121   AliHLTSimulation& operator=(const AliHLTSimulation&);
122   /** standard destructor */
123   ~AliHLTSimulation();
124
125   /* current options */
126   TString fOptions;                                                   //!transient
127
128   /** base class for AliRoot HLT plugins */
129   AliHLTPluginBase* fpPluginBase;                                     //!transient
130
131   /** RAW reader instance for chains which need RAW data as input */
132   AliRawReader* fpRawReader;                                          //!transient
133
134   /// number of events to run
135   int fNEvents; //! number of events
136
137   ClassDef(AliHLTSimulation, 0)
138 };
139
140 #define ALIHLTSIMULATION_LIBRARY             "libHLTsim.so"
141 #define ALIHLTSIMULATION_LIBRARY_VERSION     1
142 #define ALIHLTSIMULATION_CREATE_INSTANCE     "AliHLTSimulationCreateInstance"
143 #define ALIHLTSIMULATION_DELETE_INSTANCE     "AliHLTSimulationDeleteInstance"
144 #define ALIHLTSIMULATION_SETUP               "AliHLTSimulationSetup"
145 #define ALIHLTSIMULATION_INIT                "AliHLTSimulationInit"
146 #define ALIHLTSIMULATION_RUN                 "AliHLTSimulationRun"
147 #define ALIHLTSIMULATION_GET_LIBRARY_VERSION "AliHLTSimulationGetLibraryVersion"
148
149 #ifdef __cplusplus
150 extern "C" {
151 #endif
152   typedef AliHLTSimulation* (*AliHLTSimulationCreateInstance_t)();
153   typedef int (*AliHLTSimulationDeleteInstance_t)(AliHLTSimulation* pSim);
154   typedef int (*AliHLTSimulationSetup_t)(AliHLTSimulation* pHLTSim, AliSimulation* pSim, const char* options);
155   typedef int (*AliHLTSimulationInit_t)(AliHLTSimulation* pSim, AliRunLoader* pRunLoader, const char* options);
156   typedef int (*AliHLTSimulationRun_t)(AliHLTSimulation* pSim, AliRunLoader* pRunLoader);
157   typedef int (*AliHLTSimulationGetLibraryVersion_t)();
158   typedef int (*AliHLTSimulationInitOCDB_t)(AliHLTSimulation* pSim);
159
160   /**
161    * Create an instance of the AliHLTSimulation class
162    */
163   AliHLTSimulation* AliHLTSimulationCreateInstance();
164   /**
165    * Delete an instance of the AliHLTSimulation class
166    */
167   int AliHLTSimulationDeleteInstance(AliHLTSimulation* pSim);
168   /**
169    * Setup the HLT simulation.
170    * Setup is done right after the creation. To be called before
171    * the actual AliSimulation starts when the OCDB is not yet locked.
172    */
173   int AliHLTSimulationSetup(AliHLTSimulation* pHLTSim, AliSimulation* pSim, const char* options);
174   /**
175    * Set options for an instance.
176    * Init is invoked right before running HLT simulation, i.e. after all
177    * the other AliSimulation was done
178    */
179   int AliHLTSimulationInit(AliHLTSimulation* pSim, AliRunLoader* pRunLoader, const char* options);
180   /**
181    * Run simulation for an instance and run loader
182    */
183   int AliHLTSimulationRun(AliHLTSimulation* pSim, AliRunLoader* pRunLoader);
184   /**
185    * Get version no of the library/class interface
186    */
187   int AliHLTSimulationGetLibraryVersion();
188 #ifdef __cplusplus
189 }
190 #endif
191
192 #endif