4 #ifndef ALIHLTDATAGENERATOR_H
5 #define ALIHLTDATAGENERATOR_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 *
10 /** @file AliHLTDataGenerator.h
11 @author Matthias Richter
13 @brief An HLT file publishing (data source) component.
14 @note The class is used in Offline (AliRoot) context
17 #include "AliHLTProcessor.h"
22 * @class AliHLTDataGenerator
23 * An HLT data source component to produce random data.
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).
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.
34 * Component ID: \b DataGenerator <br>
35 * Library: \b libAliHLTUtil.
37 * Mandatory arguments: <br>
38 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
40 * Optional arguments:<br>
41 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
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
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]
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
56 * \li -decrement <i> m </i> <br>
57 * subtract after \em modulo events
58 * \li -modulo <i> n </i> <br>
59 * size manipulated after \em n events
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)
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.
70 * @ingroup alihlt_util_components
72 class AliHLTDataGenerator : public AliHLTProcessor {
74 /** standard constructor */
75 AliHLTDataGenerator();
77 virtual ~AliHLTDataGenerator();
79 const char* GetComponentID();
80 void GetInputDataTypes( AliHLTComponentDataTypeList& list);
81 AliHLTComponentDataType GetOutputDataType();
82 int GetOutputDataTypes(vector<AliHLTComponentDataType>& tgtList);
83 void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
84 AliHLTComponent* Spawn();
87 int DoInit( int argc, const char** argv );
89 int DoEvent( const AliHLTComponentEventData& evtData,
90 const AliHLTComponentBlockData* blocks,
91 AliHLTComponentTriggerData& trigData,
92 AliHLTUInt8_t* outputPtr,
94 AliHLTComponentBlockDataList& outputBlocks );
96 using AliHLTProcessor::DoEvent;
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>
109 virtual int ScanArgument(int argc, const char** argv);
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
119 int ScanSizeArgument(AliHLTUInt32_t &size, const char* arg);
122 * Scan a float argument.
123 * @param value target to store the size
124 * @param arg the argument to scan
126 int ScanFloatArgument(float &value, const char* arg);
129 /** prohibit copy constructor */
130 AliHLTDataGenerator(const AliHLTDataGenerator&);
131 /** prohibit assignment operator */
132 AliHLTDataGenerator& operator=(const AliHLTDataGenerator&);
135 AliHLTComponentDataType fDataType; //! transient
138 AliHLTUInt32_t fSpecification; //! transient
140 // mode 1: just fake data independent of the input data
142 /** the original size size */
143 AliHLTUInt32_t fSize; //! transient
144 /** range: [size, size+range] */
145 AliHLTUInt32_t fRange; //! transient
146 /** the manipulated size */
147 AliHLTUInt32_t fCurrSize; //! transient
148 /** divisor: each modulo event ignoring the input data size) */
149 AliHLTUInt32_t fDivisor; //! transient
150 /** decrement: each modulo event ignoring the input data size */
151 AliHLTUInt32_t fDecrement; //! transient
152 /** modulo for size manipulation */
153 AliHLTUInt32_t fModulo; //! transient
155 // mode 2: generate data depending on input data size
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
162 /** random number generator */
163 TRandom* fpDice; //! transient
165 ClassDef(AliHLTDataGenerator, 0)