]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/rec/AliHLTReconstructor.h
909b4258c943d4cd803c2cf127cbe7c5f072ab72
[u/mrichter/AliRoot.git] / HLT / rec / AliHLTReconstructor.h
1 // @(#) $Id$
2
3 #ifndef ALIHLTRECONSTRUCTOR_H
4 #define ALIHLTRECONSTRUCTOR_H
5 //* This file is property of and copyright by the ALICE HLT Project        * 
6 //* ALICE Experiment at CERN, All rights reserved.                         *
7 //* See cxx source for full Copyright notice                               *
8
9 /** @file   AliHLTReconstructor.h
10     @author Matthias Richter
11     @date   
12     @brief  Binding class for HLT simulation in AliRoot
13 */
14
15 #include "AliReconstructor.h"
16 #include "AliHLTReconstructorBase.h"
17
18 class AliHLTSystem;
19 class AliRawReader;
20 class AliESDEvent;
21 class AliHLTOUT;
22 class AliHLTEsdManager;
23 /**
24  * @defgroup alihlt_aliroot_reconstruction AliRoot reconstruction.
25  *
26  * Like all other ALICE detectors, HLT utilizes the AliReconstruction interface
27  * to implement a plugin for the AliRoot reconstruction. The reconstructor can be
28  * used to
29  * - run HLT analysis chains in the AliRoot reconstruction <br>
30  *   This option is mainly intended for the development and debugging cycle. HLT
31  *   chains can be defined by means of AliHLTConfiguration and can be run either
32  *   stand-alone or embedded into the AliReconstruction cycle.
33  * - run the default analysis chains <br>
34  *   HLT modules can define default analysis chains to be run during AliRoot
35  *   reconstruction.
36  * - handle the HLTOUT data<br>
37  *   The HLT output stream contains multiple data blocks produced by the various
38  *   components of the HLT chain. Each block might need different and even
39  *   detector specific processing, like e.g. the processing of ESD objects or the
40  *   handling of compressed data.
41  *
42  * The AliHLTReconstructor provides the main interface for this group.
43  * @ingroup alihlt_system
44  */
45
46 /**
47  * @class AliHLTReconstructor
48  * AliRoot event reconstruction plug-in for the HLT.
49  * The AliHLTReconstructor holds an instance of the @ref AliHLTSystem
50  * steering class. The actual reconstruction depends on the loaded component
51  * libraries. Each library must implement a module agent (@ref AliHLTModuleAgent)
52  * in order to provide information on the supported features and the
53  * configurations to be run.
54  *
55  * The AliHLTReconstructor provides both the functionality to run customized
56  * analysis chains and the treatment of the HLTOUT data.
57  *
58  * @section sec_alihltreconstructor_options Options
59  * The default component libraries which are loaded through the initialization
60  * are determined by the @ref AliHLTSystem::fgkHLTDefaultLibs array. The library
61  * loading can be overridden by an option to the AliHLTReconstructor through the
62  * <tt>SetOption</tt> method of <tt>AliReconstruction</tt>, e.g.
63  * <pre>
64  * AliReconstruction rec;
65  * rec.SetOption("HLT", "libAliHLTSample.so");
66  * </pre>
67  * will only load <tt>libAliHLTSample.so</tt>
68  * 
69  * Optional arguments:<br>
70  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
71  * \li loglevel=<i>level</i><br>
72  *     level can be a hex number encoding the @ref AliHLTComponentLogSeverity
73  * \li alilog=off <br>
74  *     disables the logging of HLT log messages through <tt>AliLog</tt> <br>
75  *
76  * For further information on the AliRoot reconstruction refer to the AliRoot
77  * documentation, namely <tt>AliReconstruction</tt>.
78  *
79  * @section sec_alihltreconstructor_chains Custom reconstruction chains
80  * In order to run an HLT chain during the AliRoot reconstruction, a chain
81  * configuration must be defined. This can be done by
82  * - specifying a configuration macro defining a configuration macro and
83  *   the name of the chain as parameters
84  *   <pre>
85  *   rec.SetOption("HLT", "config=[macro.C] chains=[name]")
86  *   </pre>
87  * - providing the configuration and the name by the module agent.
88  *   AliHLTModuleAgent and the functions AliHLTModuleAgent::CreateConfigurations
89  *   and AliHLTModuleAgent::GetReconstructionChains
90  *
91  * @section sec_alihltreconstructor_hltout Treatment of HLTOUT data.
92  * The HLTOUT data is a collation of output blocks produced by the various
93  * components running in an HLT chain. Typically its the output of the last
94  * component(s) in the chain, or components specifically connected to the HLT
95  * output.
96  *
97  * The treatment of the HLTOUT data blocks is implemented in handlers of type
98  * AliHLTOUTHandler. The AliHLTModuleAgent of the module  creates the appropriate
99  * handler for a data block.
100  * The data type of the individual blocks is set by the producer component and
101  * specifies the nature of the data processing. There are 5 overall groups:
102  * - output is in ESD format:
103  *      @ref sec_alihltreconstructor_hltout_esd
104  * - data describes DDL raw format:
105  *      @ref sec_alihltreconstructor_hltout_rawreader
106  * - pre-analyzed data to be fed into the normal reconstruction:
107  *      @ref sec_alihltreconstructor_hltout_rawstream
108  * - data is fed into an analysis chain:
109  *      @ref sec_alihltreconstructor_hltout_chain
110  * - detector specific handler:
111  *      @ref sec_alihltreconstructor_hltout_proprietary
112  *
113  * @subsection sec_alihltreconstructor_hltout_esd ESD HLTOUT data
114  * The framework implements a standard handling of ESD data
115  * blocks of type ::kAliHLTDataTypeESDTree {ESD_TREE:ANY}. \em ANY can be
116  * any detector origin. Each ESD block contains the data of only one event,
117  * the ESDs are merged by the AliHLTEsdManager and written to files of the
118  * naming scheme AliHLT\em DET ESDs.root. The first ESD block is also copied
119  * to the hltEsd provided by the AliReconstruction. This is a temporary
120  * solution as the handling and merging of HLT ESDs is under discussion.
121  * At the time of writing (May 08) only the TPC HLT components produce ESD
122  * blocks.
123  * The module agent can provide a handler for multiple ESD data blocks, e.g.
124  * for merging within one event prior to the writing. Instead of the individual
125  * ESDs the one provided by the handler is passed to the AliHLTEsdManager. The
126  * handler is of type \link AliHLTModuleAgent::AliHLTOUTHandlerType kEsd \endlink.
127  *
128  * @subsection sec_alihltreconstructor_hltout_rawreader DDL raw HLTOUT data
129  * The HLT can perform selective readout and produces a reduced amount of data
130  * in the original raw ddl format. In order to feed this data from the HLTOUT
131  * DDL links into the normal reconstruction, a handler of type 
132  * \link AliHLTModuleAgent::AliHLTOUTHandlerType kRawReader \endlink must be
133  * implemented and provided by the
134  * module agent. The handler has to derive the original equipment id from the
135  * data type and specification of the block. The offline reconstruction does
136  * not need to be changed or adapted at all. See AliRawReaderHLT for details.
137  *
138  * @subsection sec_alihltreconstructor_hltout_rawstream Preprocessed Raw HLTOUT data
139  * Handlers of type \link AliHLTModuleAgent::AliHLTOUTHandlerType kRawStream \endlink
140  * are foreseen though at the time of writing (May 08) the
141  * concept is not fixed. Advanced data compression algorithms can produce a
142  * raw data format which is not convertible into the raw DDL data, e.g. lossy
143  * compression techniques storing clusters parametrized regarding to tracks. A
144  * specific RawStream is needed here since the data is detector specific and the
145  * first stage of the offline reconstruction might need some adaptions.
146  *
147  * @subsection sec_alihltreconstructor_hltout_chain HLTOUT data fed into a chain
148  * At the time of writing (May 08), handler type 
149  * \link AliHLTModuleAgent::AliHLTOUTHandlerType kChain \endlink
150  * is foreseen but not yet implemented. Has to be discussed.
151  *
152  * @subsection sec_alihltreconstructor_hltout_proprietary Proprietary HLTOUT data
153  * This is a handler of proprietary detector data. Handlers of type 
154  * \link AliHLTModuleAgent::AliHLTOUTHandlerType kProprietary \endlink
155  * do not have any standard output to the framework. Data can be processed and
156  * stored to files.
157  *
158  * @section sec_alihltreconstructor_helper Tools and helper functions
159  * Some helper functions of the AliHLTReconstruction can be used in stand-alone
160  * mode. Remember to Init() the reconstructor.
161  * <pre>
162  * {
163  * gSystem->Load("libHLTrec.so");
164  * AliHLTReconstructor rec;
165  * rec.Init();
166  * // do something
167  * }
168  * </pre>
169  * @subsection sec_alihltreconstructor_hltout_standalone Stand-alone HLTOUT processing
170  * - HLTOUT processing from a digit file:
171  * <pre>
172  *  void ProcessHLTOUT(const char*, AliESDEvent*) const;
173  * </pre>
174  * - HLTOUT processing from an AliRawReader
175  * <pre>
176  *  void ProcessHLTOUT(AliRawReader*, AliESDEvent*) const;
177  * </pre>
178  *
179  * @ingroup alihlt_aliroot_reconstruction
180  * @section sec_alihltreconstructor_members Class members
181  */
182 class AliHLTReconstructor: public AliReconstructor, public AliHLTReconstructorBase {
183 public:
184   /** standard constructor */
185   AliHLTReconstructor();
186   /** constructor */
187   AliHLTReconstructor(const char* options);
188   /** destructor */
189   virtual ~AliHLTReconstructor();
190
191   /** init the reconstructor */
192   void Init();
193
194   /** init the reconstructor */
195   void Init(const char* options);
196
197   /**
198    * This Reconstructor function is not applicable for the AliHLTReconstructor
199    * as it gets a detector specific digits tree. But HLT processes all detectors.
200    * Furthermore it's purely simulated data. <br>
201    * The function forwards to the default bahavior of AliReconstructor but gives
202    * a warning if there were options set, i.e. the user runs customized
203    * reconstruction.
204    *
205    * @note HLT reconstruction on simulated data is processed at the end of
206    * simulation. <br>
207    */
208   void Reconstruct(TTree* digitsTree, TTree* clustersTree) const;
209
210   /**
211    * Reconstruction from RAW data.
212    * The rawReader holds data for all detectors and this version of Reconstruct
213    * is thus applicable for the HLT. The clustersTree is just ignored.
214    */
215   void Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const;
216
217   /**
218    * This function treats the simulated HLTOUT data.
219    * Opens a handler for simulated HLTOUT data and forwards to ::ProcessHLTOUT.
220    */
221   void FillESD(TTree* digitsTree, TTree* clustersTree, AliESDEvent* esd) const;
222
223   /**
224    * Process the raw HLTOUT data and fill ESD.
225    * Opens a handler for raw HLTOUT data and forwards to ::ProcessHLTOUT.
226    */
227   void FillESD(AliRawReader* rawReader, TTree* clustersTree, AliESDEvent* esd) const;
228
229   /**
230    * Process HLTOUT data and fill ESD.
231    * This is the final treatment of the HLTOUT data, either simulated or real.
232    * HLTOUT data is stored in HOMER format, the AliHLTOUT object provides the interface
233    * to the individual data blocks.
234    *
235    * During reconstruction (::Reconstruct), module or user defined chains can be
236    * processed and may add additional data to the HLTOUT object. This data is then
237    * treated in the same way.
238    */
239   void ProcessHLTOUT(AliHLTOUT* pHLTOUT, AliESDEvent* esd, bool bVerbose=false) const;
240
241   /**
242    * Process HLTOUT data.
243    * Open digit file and process the HLTOUT digit data.
244    * This function is mostly intended for debugging purposes and stand-alone
245    * processing of the output from the simulation. Loops over all events.
246    * @param digitFile        path of the digit file
247    * @param pEsd             optional ESD to be filled
248    */
249   void ProcessHLTOUT(const char* digitFile="HLT.Digits.root", AliESDEvent* pEsd=NULL) const;
250
251   /**
252    * Process HLTOUT data.
253    * Process the HLTOUT from the raw reader.
254    * This function is mostly intended for debugging purposes and stand-alone
255    * processing of simulated or real raw data. 
256    * \em Note: Loops over all events, i.e. the current event of the the raw
257    * reader will change. Not to be called inside the normal AliRoot processsing.
258    * @param pRawReader       raw reader instance
259    * @param pEsd             optional ESD to be filled
260    */
261   void ProcessHLTOUT(AliRawReader* pRawReader, AliESDEvent* pEsd=NULL) const;
262
263   /**
264    * Print a short info about the HLTOUT content.
265    */
266   void PrintHLTOUTContent(AliHLTOUT* pHLTOUT) const;
267
268 private:
269   /** copy constructor prohibited */
270   AliHLTReconstructor(const AliHLTReconstructor& src);
271   /** assignment operator prohibited */
272   AliHLTReconstructor& operator=(const AliHLTReconstructor& src);
273
274   /** function pointer: processing of HLTOUT data */
275   void* fFctProcessHLTOUT; //!transient
276
277   /** ESD manger instance for this reconstruction */
278   AliHLTEsdManager* fpEsdManager; //!transient
279
280   ClassDef(AliHLTReconstructor, 5)   // class for the HLT reconstruction
281
282 };
283
284 typedef AliHLTReconstructor AliL3Reconstructor; // for backward compatibility
285
286 #endif