]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/benchmark/AliHLTBenchExternalTrackComponent.h
Renaming AliHLTReconstructorBase to AliHLTPluginBase to reflect the
[u/mrichter/AliRoot.git] / HLT / benchmark / AliHLTBenchExternalTrackComponent.h
1 //-*- Mode: C++ -*-
2 // $Id$
3
4 #ifndef ALIHLTBENCHEXTERNALTRACKCOMPONENT_H
5 #define ALIHLTBENCHEXTERNALTRACKCOMPONENT_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   AliHLTBenchExternalTrackComponent.h
11     @author Matthias Richter
12     @date   2008-10-30
13     @brief  Benchmark component for AliExternalTrackParam transportation.
14 */
15
16 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt   
17
18 #include "AliHLTProcessor.h"
19
20 class AliExternalTrackParam;
21 class AliHLTExternalTrackParam;
22 class TClonesArray;
23 class TObjArray;
24 class TRandom;
25 class TList;
26
27 /**
28  * @class AliHLTBenchExternalTrackComponent
29  * A component publishing arrays of randomly filled AliExternalTrackParam
30  * structures in different forms. Currently supported is TClonesArray,
31  * TObjArray, and C Array.
32  * 
33  * The component can both publish and receive data blocks. If data blocks
34  * are available on the input, the array is restored and forwarded in the
35  * specified publishing mode with specified compression level.
36  *
37  * <h2>General properties:</h2>
38  *
39  * Component ID: \b BenchmarkAliExternalTrackParam <br>
40  * Library: \b libAliHLTBenchmark.so     <br>
41  * Input Data Types: ::kAliHLTDataTypeTrack, ::kAliHLTDataTypeTObjArray <br>
42  * Output Data Types: ::kAliHLTDataTypeTrack, ::kAliHLTDataTypeTObjArray <br>
43  *
44  * <h2>Mandatory arguments:</h2>
45  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
46  * By default, publishing of the array is switched off. It has to be enabled
47  * by one of the three options
48  * \li -tobjarray <br>
49  *      publish TObjArray
50  * \li -tclonesarray <br>
51  *      publish TClonesArray
52  * \li -carray <br>
53  *      publish as C-array
54  *
55  * <h2>Optional arguments:</h2>
56  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
57  * \li -maxsize      <i> max array size  </i> <br>
58  * \li -minsize      <i> min array size  </i> <br>
59  *
60  * \li -rangemodulo  <i> count  </i> <br>
61  *      number of events after which the range is changed
62  * \li -rangeoffset  <i> offset  </i> <br>
63  *      offset is added to min and max range after the specified number of
64  *      events. Idially, this offset is negative, causing decreasing range
65  *      over run time.
66  * \li -rangefactor  <i> factor  </i> <br>
67  *      min and max range are multiplied by the factor (float) after the
68  *      specified number of events.
69  *
70  * \li -verbosity      <i> level  </i> <br>
71  *      different levels of verbosity: 0 (default) is silent
72  *
73  * <h2>Configuration:</h2>
74  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
75  *
76  * <h2>Default CDB entries:</h2>
77  * The component has no default CDB entries.
78  *
79  * <h2>Performance:</h2>
80  * 
81  *
82  * <h2>Memory consumption:</h2>
83  * 
84  *
85  * <h2>Output size:</h2>
86  * 
87  *
88  * By using the range alterator options, the range can be changed after a
89  * certain number of events.
90  *
91  * @ingroup alihlt_benchmark_components
92  */
93 class AliHLTBenchExternalTrackComponent : public AliHLTProcessor {
94  public:
95   /** default constructor */
96   AliHLTBenchExternalTrackComponent();
97   /** destructor */
98   virtual ~AliHLTBenchExternalTrackComponent();
99
100   // interface functions: property getters
101   const char* GetComponentID();
102   void GetInputDataTypes(AliHLTComponentDataTypeList& list);
103   AliHLTComponentDataType GetOutputDataType();
104   int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
105   void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
106   AliHLTComponent* Spawn();
107
108   /**
109    * Fill members of the track object with random float values.
110    * @param track     reference to AliExternalTrackParam object
111    * @param fillCov   number of elements of the covar members to be filled
112    *                  max 15
113    */
114   static int FillRandom(AliExternalTrackParam* track, int fillCov=15);
115
116   /**
117    * Serialize an object or clones array of AliExternalTrackParam objects
118    * to a buffer using the definition AliHLTExternalTrackParam.
119    * @param pArray    the array
120    * @param buffer    target buffer
121    * @param size      buffer size
122    * @return bytes filled to the buffer, neg. error code if failed
123    */
124   static int SerializeToStruct(const TObjArray* pArray, AliHLTUInt8_t* buffer, unsigned int size);
125
126   /**
127    * Translate AliHLTExternalTrackParam struct into objects.
128    * The TObjArray can also be a TClonesArray and must have enough capacity.
129    */
130   static int ReadFromStruct(TObjArray* pTgtArray, AliHLTExternalTrackParam* pArray, unsigned int arraySize);
131
132   /**
133    * Calculate a crc checksum for the object array
134    */
135   static AliHLTUInt32_t CalcChecksum(const TObjArray* pArray);
136
137   /**
138    * Compare two arrays of AliExternalTrackParamElements
139    */
140   static bool Compare(const TObjArray* array1, const TObjArray* array2);
141
142   /**
143    * Find object in the registry
144    */
145   static TObject* FindObject(AliHLTUInt32_t id);
146
147   enum {
148     kPublishingOff = 0,
149     ktobjarray = 1,
150     ktclonesarray,
151     kcarray,
152   };
153
154  protected:
155   // interface functions: processing
156   int DoInit(int argc, const char** argv);
157   int DoDeinit();
158   int DoEvent( const AliHLTComponentEventData& evtData,
159                const AliHLTComponentBlockData* blocks, 
160                AliHLTComponentTriggerData& trigData,
161                AliHLTUInt8_t* outputPtr, 
162                AliHLTUInt32_t& size,
163                AliHLTComponentBlockDataList& outputBlocks );
164
165   /**
166    * Register object and create reference id
167    * The registry is used for consistency checks in a single threaded system.
168    * The dump component can access the original object and compare the two.
169    */
170   AliHLTUInt32_t Register(TObject* pObject);
171
172   /**
173    * Remove object from registry
174    */
175   int Unregister(TObject* pObject);
176  
177  private:
178   /** copy constructor prohibited */
179   AliHLTBenchExternalTrackComponent(const AliHLTBenchExternalTrackComponent&);
180   /** assignment operator prohibited */
181   AliHLTBenchExternalTrackComponent& operator=(const AliHLTBenchExternalTrackComponent&);
182
183   /** verbosity */
184   int fVerbosity; //!transient
185
186   /** disable global object registry, no check pf received objects */
187   bool fDisableRegistry; //! transient
188
189   /** publishing mode: off, ktclonesarray, ktobjarray, kcarray */
190   int fMode; //! transient
191
192   /** maximum array size */
193   int fMaxSize; //! transient
194
195   /** minimum array size */
196   int fMinSize; //! transient
197
198   /** event count for the next automatic change of range */
199   int fEventModulo;
200
201   /** offset is added to range after fEventModulo events */
202   int fRangeOffset;
203
204   /** range is multiplied after fEventModulo events */
205   float fRangeMultiplicator;
206
207   /** the internal array */
208   TClonesArray* fpTcArray; //! transient
209
210   /** TObjArray this publishing mode was used */
211   TObjArray* fpTObjArray; //! transient
212
213   /** random number generator */
214   TRandom* fpDice; //! transient
215
216   /** registry of object arrays */
217   static TList* fgpRegistry; //! transient
218
219   ClassDef(AliHLTBenchExternalTrackComponent, 0);
220 };
221
222 #endif