]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/RCU/AliHLTAltroGenerator.h
- AliHLTReconstructor: added helper functions to run HLTOUT processing stand alone
[u/mrichter/AliRoot.git] / HLT / RCU / AliHLTAltroGenerator.h
CommitLineData
c3800c65 1//-*- Mode: C++ -*-
2// $Id$
3
4#ifndef ALIHLTALTROGENERATOR_H
5#define ALIHLTALTROGENERATOR_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 AliHLTAltroGenerator.h
11 @author Matthias Richter
12 @date
13 @brief Simulation class of 10/40bit Altro Data.
14*/
15
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
22#include "AliHLTDataTypes.h"
23#include "AliHLTLogging.h"
24#include <vector>
25#include <ostream>
26
27class AliRawDataHeader;
28class TArrayS;
29class TArrayC;
30class TRandom;
31
32/**
33 * @class AliHLTAltroGenerator
34 */
35class AliHLTAltroGenerator : AliHLTLogging {
36 public:
37 /** constructor */
38 AliHLTAltroGenerator(int maxChannels=1000,
39 int maxBunches=50,
40 int maxBunchLength=10,
41 int maxTimebin=1024,
42 int maxSignal=500);
43 /** destructor */
44 virtual ~AliHLTAltroGenerator();
45
46 /**
47 * Generate a new event.
48 * Simulate new data and store internally in plain format.
49 *
50 * @return size of the encoded data in byte. If the CDH and/or RCU
51 * trailer was set, the size includes those.
52 */
53 int Generate();
54
55 /**
56 * Get the number of 40bit Altro words of the current data set.
57 * @return number of 40bit Altro words.
58 */
59 int GetNof40BitAltroWords() const;
60
61 /**
62 * Get the data size of the current data set.
63 * @return size of the encoded data in byte. If the CDH and/or RCU
64 * trailer was set, the size includes those.
65 */
66 int GetDataSize();
67
68 /**
69 * Get the simulated data.
70 * Get a pointer to the internal buffer. The buffer is filled with
71 * the encoded data from the previous simulation.
72 * @param pBuffer target variable to receive the pointer
73 * @return size in byte, neg. error if failed
74 */
75 int GetData(AliHLTUInt8_t* &pBuffer);
76
77 /**
78 * Get the simulated data.
79 * The provided buffer is filled with the encoded data from the
80 * previous simulation.
81 * @param pBuffer target variable to receive the pointer
032c5e5e 82 * @param size size of the target buffer
c3800c65 83 * @return size in byte, neg. error if failed
84 */
85 int GetData(AliHLTUInt8_t* pBuffer, int size);
86
87 /**
88 * Set the Common Data Header.
89 * @param pCDH the CDH
90 * @param size size of the header in byte
91 * @return neg. error code if failed
92 */
93 int SetCDH(AliRawDataHeader* pCDH, int size);
94
95 /**
96 * Set the RCU trailer.
97 * @param pTrailer the trailer
98 * @param size size of the header in byte
99 * @return neg. error code if failed
100 */
101 int SetRCUTrailer(AliHLTUInt8_t* pTrailer, int size);
102
103 /**
104 * Get list of channels in the current data set.
105 */
106 int GetChannels(vector<AliHLTUInt16_t> list);
107
108 /**
109 * Set array of channels for sorting of channels.
110 * The encoded data will be sorted according to the specified
111 * list.
112 * @param array array of channels
113 * @param arraySize size of the array
114 */
115 int SetSorting(AliHLTUInt16_t *array, int arraySize);
116
117 /**
118 * Get a random number in the given range.
119 */
120 int GetRandom(int min, int max);
121
122 /**
123 * Set parsing direction for the Next functions.
124 * @param direction @ref AliHLTAltroGenerator::kBackwards (default),
125 * @ref AliHLTAltroGenerator::kForwards
126 */
127 void SetDirection(int direction) {fDirection=direction;}
128
129 /**
130 * Position at the next signal.
131 * The function follows the pure stream model.
132 * @return true if there is a new signal available
133 */
134 bool Next();
135
136 /**
137 * Get the current signal.
138 * The current time value can be retrieved by ::GetStartTime or
139 * ::GetEndTime which return both the current time in the stream
140 * model.
141 * @return signal value
142 */
143 AliHLTUInt16_t GetSignal();
144
145 /**
146 * Position at the beginning of the next channel.
147 * Depending on the mode, the function works either back or
148 * forwards.
149 * @return true if there is a new channel available
150 */
151 bool NextChannel();
152
153 /**
154 * Get the hardware address of the current channel.
155 */
156 AliHLTUInt16_t GetHwAddress();
157
158 /**
159 * Get bunch count of the current channel
160 */
161 int GetBunchCount();
162
163 /**
164 * Position at the beginning of the next bunch.
165 * Depending on the mode, the function works either back or
166 * forwards.
167 * @return true if there is a new bunch available
168 */
169 bool NextBunch();
170
171 /**
172 * Get size of the current bunch.
173 */
174 AliHLTUInt16_t GetBunchSize();
175
176 /**
177 * Get start time of the current bunch or signal.
178 */
179 AliHLTUInt16_t GetStartTime();
180
181 /**
182 * Get end time of the current bunch or signal.
183 */
184 AliHLTUInt16_t GetEndTime();
185
186 /**
187 * Get pointer to signals of current bunch.
188 * The signals are always in ascending order.
189 */
190 const Short_t* GetSignals();
191
192 /**
193 * Reset the internal position variables.
194 */
195 int Reset();
196
197 /**
198 * Rewind stream position for Next funxtions
199 */
200 int Rewind();
201
202 /**
203 * Print content of simulated data to cout.
204 */
205 void Print();
206
207 /**
208 * Printout of simulated data.
209 */
210 friend ostream &operator<<(ostream &str, AliHLTAltroGenerator &generator);
211
212 enum {
213 kBackwards = 0,
214 kForwards = 1
215 };
216
217 protected:
218
219 private:
220 /** copy constructor prohibited */
221 AliHLTAltroGenerator(const AliHLTAltroGenerator&);
222 /** assignment operator prohibited */
223 AliHLTAltroGenerator& operator=(const AliHLTAltroGenerator&);
224
225 /**
226 * Encode the simulated data into Altro format
227 */
228 int EncodeData(AliHLTUInt8_t* pBuffer, int size);
229
230 /// internal data buffer
231 TArrayC* fpData; //!transient
232
233 /// array of simulated data
234 TArrayS* fpSimData; //! transient
235
236 struct AliChannelPosition {
237 AliHLTUInt16_t fChannel; //! transient
238 int fPosition; //! transient
239 int fEnd; //! transient
240 };
241
242 /// channels and their positions in the simulated data
243 vector<AliChannelPosition> fChannelPositions; //! transient
244
245 /// the Altro payload in the simulated data
246 int fNof10BitWords; //! transient
247
248 /// the Common Data Header
249 AliRawDataHeader* fpCDH; //!transient
250
251 /// size of the Common Data Header in byte
252 int fCDHSize; //! transient
253
254 /// the RCU trailer
255 AliHLTUInt8_t* fpTrailer; //!transient
256
257 /// size of the trailer
258 int fTrailerSize; //!transient
259
260 /// maximum number of channels
261 int fMaxChannels; //! transient
262
263 /// maximum number of bunches
264 int fMaxBunches; //! transient
265
266 /// maximum bunche length
267 int fMaxBunchLength; //! transient
268
269 /// max timebin
270 int fMaxTimebin; //!transient
271
272 /// maximum signal
273 int fMaxSignal; // transient
274
275 /// the random number generator
276 TRandom* fpRand; //! transient
277
278 /// direction of parsing
279 int fDirection; //! transient
280
281 /// current channel position for the Next functions
282 int fCurrentPosition; //! transient
283
284 /// current bunch position in the simulated data
285 int fCurrentBunch; //! transient
286
287 /// current offset in the current bunch
288 int fCurrentTimeOffset; //! transient
289
290 ClassDef(AliHLTAltroGenerator, 0);
291};
292
293#endif