LCOV - code coverage report
Current view: top level - HLT/BASE/util - AliHLTDataGenerator.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 1 100.0 %
Date: 2016-06-14 17:26:59 Functions: 1 5 20.0 %

          Line data    Source code
       1             : // -*- Mode: C++ -*-
       2             : // $Id$
       3             : 
       4             : #ifndef ALIHLTDATAGENERATOR_H
       5             : #define ALIHLTDATAGENERATOR_H
       6             : //* This file is property of and copyright by the                          * 
       7             : //* ALICE Experiment at CERN, All rights reserved.                         *
       8             : //* See cxx source for full Copyright notice                               *
       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             : 
      17             : #include "AliHLTProcessor.h"
      18             : 
      19             : class TRandom;
      20             : 
      21             : /**
      22             :  * @class AliHLTDataGenerator
      23             :  * An HLT data source component to produce random data.
      24             :  *
      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             :  *
      34             :  * Component ID: \b DataGenerator <br>
      35             :  * Library: \b libAliHLTUtil.
      36             :  *
      37             :  * Mandatory arguments: <br>
      38             :  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
      39             :  *
      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
      46             :  *      prepended by '0x'
      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
      55             :  *
      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
      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)
      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.
      69             :  *
      70             :  * @ingroup alihlt_util_components
      71             :  */
      72             : class AliHLTDataGenerator : public AliHLTProcessor  {
      73             :  public:
      74             :   /** standard constructor */
      75             :   AliHLTDataGenerator();
      76             :   /** destructor */
      77             :   virtual ~AliHLTDataGenerator();
      78             : 
      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();
      85             : 
      86             :  protected:
      87             :   int DoInit( int argc, const char** argv );
      88             :   int DoDeinit();
      89             :   int DoEvent( const AliHLTComponentEventData& evtData,
      90             :                const AliHLTComponentBlockData* blocks, 
      91             :                AliHLTComponentTriggerData& trigData,
      92             :                AliHLTUInt8_t* outputPtr, 
      93             :                AliHLTUInt32_t& size,
      94             :                AliHLTComponentBlockDataList& outputBlocks );
      95             : 
      96             :   using AliHLTProcessor::DoEvent;
      97             : 
      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             : 
     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             : 
     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             : 
     140             :   // mode 1: just fake data independent of the input data
     141             : 
     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
     154             : 
     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             : 
     162             :   /** random number generator */
     163             :   TRandom* fpDice;                                                  //! transient
     164             : 
     165           8 :   ClassDef(AliHLTDataGenerator, 0)
     166             : };
     167             : #endif

Generated by: LCOV version 1.11