finalizing DataGenerator component producing fake data for benchmark purpose
[u/mrichter/AliRoot.git] / HLT / BASE / util / AliHLTDataGenerator.h
CommitLineData
81929b85 1// -*- Mode: C++ -*-
5566e798 2// $Id$
81929b85 3
4#ifndef ALIHLTDATAGENERATOR_H
5#define ALIHLTDATAGENERATOR_H
5566e798 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 *
81929b85 9
10/** @file AliHLTDataGenerator.h
11 @author Matthias Richter
12 @date
13 @brief An HLT file publishing (data source) component.
14 @note The class is used in Offline (AliRoot) context
15*/
16
a3c9b745 17#include "AliHLTProcessor.h"
81929b85 18
37a07d48 19class TRandom;
20
81929b85 21/**
22 * @class AliHLTDataGenerator
23 * An HLT data source component to produce random data.
24 *
37a07d48 25 * The component produces fake data blocks according to the size range
26 * or the total input size. For the former, the initial size can be set
27 * by the \em -size, \em -minsize arguments, and the range respectivly.
28 * Tn this mode, the size can be decremented (\em -decrement) after n
29 * events (\em -modulo).
30 *
31 * When producing fake blocks with respect to the total input data,
32 * \em -offset and \em -multiplier can be used to set ratio and offset.
33 *
81929b85 34 * Component ID: \b DataGenerator <br>
35 * Library: \b libAliHLTUtil.
36 *
37 * Mandatory arguments: <br>
1ac82ce6 38 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
37a07d48 39 *
40 * Optional arguments:<br>
41 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
81929b85 42 * \li -datatype <i> datatype dataorigin </i> <br>
43 * data type ID and origin, e.g. <tt>-datatype 'CLUSTERS' 'TPC ' </tt>
44 * \li -dataspec <i> specification </i> <br>
45 * data specification treated as decimal number or hex number if
46 * prepended by '0x'
37a07d48 47 * \li -size <i> size </i> <br>
48 * initial size of the data to be produced
49 * \li -range <i> n </i> <br>
50 * range of the data to be produced [size,size+range]
81929b85 51 * \li -minsize <i> size </i> <br>
52 * the minimum size of the data to be produced
53 * \li -maxsize <i> size </i> <br>
54 * the maximum size of the data to be produced, default = minsize
55 *
37a07d48 56 * \li -decrement <i> m </i> <br>
57 * subtract after \em modulo events
81929b85 58 * \li -modulo <i> n </i> <br>
37a07d48 59 * size manipulated after \em n events
60 *
61 * \li -offset <i> m </i> <br>
62 * output size = offset + factor * (total size of input blocks)
63 * \li -multiplier <i> factor </i> <br>
64 * output size = offset + factor * (total size of input blocks)
81929b85 65 *
66 * The component produces data blocks of random content and random size in the
67 * range of [\em minsize , \em maxsize ]. The size arguments can contain 'k' or
68 * 'M' to indicate kByte or MByte.
5566e798 69 *
70 * @ingroup alihlt_util_components
81929b85 71 */
a3c9b745 72class AliHLTDataGenerator : public AliHLTProcessor {
81929b85 73 public:
74 /** standard constructor */
75 AliHLTDataGenerator();
76 /** destructor */
77 virtual ~AliHLTDataGenerator();
78
79 const char* GetComponentID();
a3c9b745 80 void GetInputDataTypes( AliHLTComponentDataTypeList& list);
81929b85 81 AliHLTComponentDataType GetOutputDataType();
56951e49 82 int GetOutputDataTypes(vector<AliHLTComponentDataType>& tgtList);
81929b85 83 void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
84 AliHLTComponent* Spawn();
85
86 protected:
81929b85 87 int DoInit( int argc, const char** argv );
81929b85 88 int DoDeinit();
a3c9b745 89 int DoEvent( const AliHLTComponentEventData& evtData,
90 const AliHLTComponentBlockData* blocks,
91 AliHLTComponentTriggerData& trigData,
92 AliHLTUInt8_t* outputPtr,
93 AliHLTUInt32_t& size,
94 AliHLTComponentBlockDataList& outputBlocks );
81929b85 95
a3c9b745 96 using AliHLTProcessor::DoEvent;
a8abc5d5 97
81929b85 98 /**
99 * Scan one argument and adjacent parameters.
100 * Can be overloaded by child classes in order to add additional arguments
101 * beyond the standard arguments of the file publisher. The method is called
102 * whenever a non-standard argument is recognized.
103 * @param argc size of the argument array
104 * @param argv agument array for component initialization
105 * @return number of processed members of the argv <br>
106 * -EINVAL unknown argument <br>
107 * -EPROTO parameter for argument missing <br>
108 */
109 virtual int ScanArgument(int argc, const char** argv);
110
111 protected:
112 /**
113 * Scan a size argument.
114 * The argument is expected to be an integer, which can be suffixed by 'k'
115 * or 'M' in order to indicate the base, kByte or MByte.
116 * @param size target to store the size
117 * @param arg the argument to scan
118 */
119 int ScanSizeArgument(AliHLTUInt32_t &size, const char* arg);
120
a3c9b745 121 /**
122 * Scan a float argument.
123 * @param value target to store the size
124 * @param arg the argument to scan
125 */
126 int ScanFloatArgument(float &value, const char* arg);
127
81929b85 128 private:
129 /** prohibit copy constructor */
130 AliHLTDataGenerator(const AliHLTDataGenerator&);
131 /** prohibit assignment operator */
132 AliHLTDataGenerator& operator=(const AliHLTDataGenerator&);
133
134 /** data type */
135 AliHLTComponentDataType fDataType; //! transient
136
137 /** specification */
138 AliHLTUInt32_t fSpecification; //! transient
139
a3c9b745 140 // mode 1: just fake data independent of the input data
141
81929b85 142 /** the original size size */
143 AliHLTUInt32_t fSize; //! transient
37a07d48 144 /** range: [size, size+range] */
145 AliHLTUInt32_t fRange; //! transient
81929b85 146 /** the manipulated size */
147 AliHLTUInt32_t fCurrSize; //! transient
a3c9b745 148 /** divisor: each modulo event ignoring the input data size) */
81929b85 149 AliHLTUInt32_t fDivisor; //! transient
a3c9b745 150 /** decrement: each modulo event ignoring the input data size */
151 AliHLTUInt32_t fDecrement; //! transient
81929b85 152 /** modulo for size manipulation */
153 AliHLTUInt32_t fModulo; //! transient
154
a3c9b745 155 // mode 2: generate data depending on input data size
156
157 /** offset (generation of data from input data size) */
158 AliHLTUInt32_t fOffset; //! transient
159 /** multiplier (generation of data from input data size) */
160 float fMultiplier; //! transient
161
37a07d48 162 /** random number generator */
163 TRandom* fpDice; //! transient
a3c9b745 164
81929b85 165 ClassDef(AliHLTDataGenerator, 0)
166};
167#endif