LCOV - code coverage report
Current view: top level - HLT/TPCLib/comp - AliHLTTPCDataCompressionComponent.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 2 50.0 %
Date: 2016-06-14 17:26:59 Functions: 1 6 16.7 %

          Line data    Source code
       1             : //-*- Mode: C++ -*-
       2             : // $Id$
       3             : #ifndef ALIHLTTPCDATACOMPRESSIONCOMPONENT_H
       4             : #define ALIHLTTPCDATACOMPRESSIONCOMPONENT_H
       5             : //* This file is property of and copyright by the                          * 
       6             : //* ALICE Experiment at CERN, All rights reserved.                         *
       7             : //* See cxx source for full Copyright notice                               *
       8             : 
       9             : /// @file   AliHLTTPCDataCompressionComponent.h
      10             : /// @author Matthias Richter
      11             : /// @date   2011-08-08
      12             : /// @brief  TPC component for data compression
      13             : ///
      14             : 
      15             : #include "AliHLTProcessor.h"
      16             : #include "TString.h"
      17             : #include "AliHLTTrackGeometry.h"
      18             : #include "AliHLTSpacePointContainer.h"
      19             : #include <vector>
      20             : 
      21             : class AliHLTGlobalBarrelTrack;
      22             : class AliHLTComponentBenchmark;
      23             : class AliHLTSpacePointContainer;
      24             : class AliHLTDataDeflater;
      25             : class AliHLTTPCClusterTransformation;
      26             : class TH1F;
      27             : 
      28             : /**
      29             :  * @class AliHLTTPCDataCompressionComponent
      30             :  * One single component to carry out different types and levels of compression
      31             :  * of TPC data.
      32             :  *
      33             :  * <h2>General properties:</h2>
      34             :  * The component subscribes to the output of the HW cluster finder (emulator)
      35             :  * and performs various types of dat compressions. For each input block a
      36             :  * block of compressed clusters is created. If track model compression is
      37             :  * enabled, all clusters associated to a track are stored in a separate
      38             :  * block together with the tracks. Those clusters are removed from the cluster
      39             :  * blocks of the individual partitions.
      40             :  *
      41             :  * Component ID: \b TPCDataCompressor      <br>
      42             :  * Library: \b libAliHLTTPC.so     <br>
      43             :  * Input Data Types:  <br>
      44             :  *  -  AliHLTTPCDefinitions::HWClustersDataType()
      45             :  *  -  AliHLTTPCDefinitions::ClustersDataType()
      46             :  *  -  kAliHLTDataTypeTrack|kAliHLTDataOriginTPC
      47             :  * Output Data Types: <br>
      48             :  *  -  AliHLTTPCDefinitions::RemainingClustersCompressedDataType());
      49             :  *  -  AliHLTTPCDefinitions::RemainingClusterIdsDataType());     
      50             :  *  -  AliHLTTPCDefinitions::ClusterIdTracksDataType()
      51             :  *  -  AliHLTTPCDefinitions::ClusterTracksCompressedDataType()
      52             :  *  -  AliHLTTPCDefinitions::RawClustersDataTypeNotCompressed()); //Used if we cannot compress
      53             :  *
      54             :  * <h2>Data Formats</h2>
      55             :  * Two formats for compressed clusters can be used.
      56             :  * <h3>Format v1</h3>
      57             :  * Format v1 stores the cluster parameters with the following precision:
      58             :  * <pre>
      59             :  *   padrow number & local padrow in partition    &   6 \\ 
      60             :  *   pad position  & pitch 0.4/0.6 cm -> 1/60     &  14 \\ 
      61             :  *   timebin       & 0.25cm/timebin   -> 1/25     &  15 \\ 
      62             :  *   sigmaY2       &                              &   8 \\ 
      63             :  *   sigmaZ2       &                              &   8 \\ 
      64             :  *   total charge  & encoded 10bit number         &   8 \\ 
      65             :  *   max charge    & encoded 16bit number         &  11 \\ 
      66             :  * <pre>
      67             :  * For the padrow, only the difference to the last padrow is stored. The
      68             :  * clusters are ordered by padrow such that there are only positive differences.
      69             :  *
      70             :  * <h3>Format v2</h3>
      71             :  * Format v2 uses the same parameters as v1 but treats single-pad clusters
      72             :  * specially. Furthermore it stores the differences of pad and time with respect
      73             :  * to the previous cluster. The difference is calculated on integers after the
      74             :  * scale and lossy conversion of the float values to integer numbers. Format v2
      75             :  * prepares all parameters for optimal huffman compression.
      76             :  *
      77             :  * <h2>Mandatory arguments:</h2>
      78             :  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
      79             :  *
      80             :  * <h2>Optional arguments:</h2>
      81             :  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
      82             :  * \li -mode     <i> number  </i> <br>
      83             :  *      compression mode                                             <br>
      84             :  *      1 compressed format version 1                                <br>
      85             :  *      2 compressed format version 1 & track model compression      <br>
      86             :  *      3 compressed format version 2                                <br>
      87             :  *      4 compressed format version 2 & track model compression      <br>
      88             :  * \li -deflater-mode     <i> number  </i>                           <br>
      89             :  *      data deflater mode                                           <br>
      90             :  *      0 no data deflation                                          <br>
      91             :  *      1 simple deflation (AliHLTDataDeflaterSimple)                <br>
      92             :  *      2 huffman deflation (AliHLTDataDeflaterHuffman)              <br>
      93             :  * \li -histogram-file     <i> file  </i>                            <br>
      94             :  *      file to store internal histograms at the end
      95             :  *
      96             :  * <h2>Configuration:</h2>
      97             :  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
      98             :  *
      99             :  * <h2>Default CDB entries:</h2>
     100             :  * - HLT/ConfigTPC/TPCDataCompressor
     101             :  * - HLT/ConfigTPC/TPCDataCompressorHuffmanTables
     102             :  *
     103             :  * <h2>Performance:</h2>
     104             :  *
     105             :  * <h2>Memory consumption:</h2>
     106             :  *
     107             :  * <h2>Output size:</h2>
     108             :  *
     109             :  *
     110             :  * @ingroup alihlt_tpc
     111             :  */
     112             : class AliHLTTPCDataCompressionComponent : public AliHLTProcessor {
     113             : public:
     114             :   /// standard constructor
     115             :   AliHLTTPCDataCompressionComponent();
     116             :   /// destructor
     117             :   ~AliHLTTPCDataCompressionComponent();
     118             : 
     119             :   enum {
     120             :     kCompressionModeNone=0,
     121             :     kCompressionModeV1,
     122             :     kCompressionModeV1TrackModel,
     123             :     kCompressionModeV2,
     124             :     kCompressionModeV2TrackModel,
     125             :     kNofCompressionModes    
     126             :   };
     127             : 
     128             :   enum {
     129             :     kDeflaterModeNone=0,
     130             :     kDeflaterModeSimple,
     131             :     kDeflaterModeHuffman,
     132             :     kDeflaterModeHuffmanTrainer,
     133             :     kNofDeflaterModes
     134             :   };
     135             : 
     136             :   /// inherited from AliHLTComponent: id of the component
     137             :   virtual const char* GetComponentID();
     138             : 
     139             :   /// inherited from AliHLTComponent: list of data types in the vector reference
     140             :   void GetInputDataTypes( AliHLTComponentDataTypeList& );
     141             : 
     142             :   /// inherited from AliHLTComponent: output data type of the component.
     143             :   AliHLTComponentDataType GetOutputDataType();
     144             : 
     145             :   /// inherited from AliHLTComponent: multiple output data types of the component.
     146             :   int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
     147             : 
     148             :   /// inherited from AliHLTComponent: output data size estimator
     149             :   void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
     150             : 
     151             :   /// inherited from AliHLTComponent: spawn function.
     152             :   virtual AliHLTComponent* Spawn();
     153             : 
     154             :   /// inherited from AliHLTComponent: list of OCDB objects
     155             :   void GetOCDBObjectDescription(TMap* const targetMap);
     156             : 
     157             :   struct AliHLTTPCTrackModelBlock {
     158             :     AliHLTUInt8_t  fVersion;             //! version of the header
     159             :     AliHLTUInt8_t  fDeflaterMode;        //! deflater mode
     160             :     AliHLTUInt16_t fTrackCount;          //! number of tracks in the block
     161             :     AliHLTUInt16_t fClusterCount;        //! number of clusters in the block
     162             :     AliHLTUInt16_t fGlobalParameterCnt;  //! number of global parameters
     163             :     float          fGlobalParameters[1]; //! array of global parameters
     164             :   };
     165             : 
     166             : protected:
     167             :   /// inherited from AliHLTProcessor: data processing
     168             :   int DoEvent( const AliHLTComponentEventData& evtData, 
     169             :                const AliHLTComponentBlockData* blocks, 
     170             :                AliHLTComponentTriggerData& trigData,
     171             :                AliHLTUInt8_t* outputPtr, 
     172             :                AliHLTUInt32_t& size,
     173             :                AliHLTComponentBlockDataList& outputBlocks );
     174             :   using AliHLTProcessor::DoEvent;
     175             : 
     176             :   /// inherited from AliHLTComponent: component initialisation and argument scan.
     177             :   int DoInit( int argc, const char** argv );
     178             : 
     179             :   /// inherited from AliHLTComponent: component cleanup
     180             :   int DoDeinit();
     181             : 
     182             :   /// inherited from AliHLTComponent: argument scan
     183             :   int ScanConfigurationArgument(int argc, const char** argv);
     184             : 
     185             :   int ProcessTrackClusters(AliHLTGlobalBarrelTrack* pTracks, unsigned nofTracks,
     186             :                            AliHLTTrackGeometry::AliHLTTrackGrid* pTrackIndex,
     187             :                            const vector<int>& trackIndexMap,
     188             :                            AliHLTSpacePointContainer::AliHLTSpacePointPropertyGrid* pClusterIndex,
     189             :                            AliHLTSpacePointContainer* pClusters,
     190             :                            int slice, int partition) const;
     191             : 
     192             :   int ProcessRemainingClusters(AliHLTGlobalBarrelTrack* pTracks, unsigned nofTracks,
     193             :                                AliHLTTrackGeometry::AliHLTTrackGrid* pTrackIndex,
     194             :                                const vector<int>& trackIndexMap,
     195             :                                AliHLTSpacePointContainer::AliHLTSpacePointPropertyGrid* pClusterIndex,
     196             :                                AliHLTSpacePointContainer* pClusters,
     197             :                                int slice, int partition) const;
     198             : 
     199             :   int FindCellClusters(int trackId, int padrow, float pad, float time,
     200             :                        AliHLTSpacePointContainer::AliHLTSpacePointPropertyGrid* pClusterIndex,
     201             :                        AliHLTSpacePointContainer* pClusters,
     202             :                        AliHLTTrackGeometry::AliHLTTrackPoint* pTrackPoint,
     203             :                        AliHLTUInt32_t clusterId=~(AliHLTUInt32_t)0) const;
     204             : 
     205             :   int WriteTrackClusters(const vector<AliHLTGlobalBarrelTrack>& tracks,
     206             :                          AliHLTSpacePointContainer* pSpacePoints,
     207             :                          AliHLTDataDeflater* pDeflater,
     208             :                          AliHLTUInt8_t* outputPtr,
     209             :                          AliHLTUInt32_t capacity) const;
     210             : 
     211             : private:
     212             :   AliHLTTPCDataCompressionComponent(const AliHLTTPCDataCompressionComponent&);
     213             :   AliHLTTPCDataCompressionComponent& operator=(const AliHLTTPCDataCompressionComponent&);
     214             : 
     215             :   int InitDeflater(int mode);
     216             : 
     217             :   /// calculate correction factor and offset for a linear approximation of the
     218             :   /// drift time transformation, separately for A and C side
     219             :   int InitDriftTimeTransformation();
     220             :   /// calculate correction factor and offset for a linear approximation of the
     221             :   /// drift time transformation by just probing the range of timebins
     222             :   int CalculateDriftTimeTransformation(AliHLTTPCClusterTransformation& transform, int slice, int padrow,
     223             :                                        float& m, float& n) const;
     224             : 
     225           0 :   AliHLTComponentBenchmark* GetBenchmarkInstance() const {return fpBenchmark;}
     226             : 
     227             :   int fMode; //! mode
     228             :   int fDeflaterMode; //! deflater mode
     229             :   int fVerificationMode; //! mode for verification and unit tests
     230             :   int fCreateFlags; //! Store cluster flags in compressed data
     231             : 
     232             :   float fMaxDeltaPad; //! maximum deviation in pad
     233             :   float fMaxDeltaTime; //! maximum deviation in time
     234             : 
     235             :   /// input raw cluster handler
     236             :   AliHLTSpacePointContainer* fRawInputClusters; //! input raw cluster handler
     237             :   /// input cluster handler
     238             :   AliHLTSpacePointContainer* fInputClusters; //! input cluster handler
     239             : 
     240             :   /// index grid for tracks store track id for padrow crossings
     241             :   AliHLTTrackGeometry::AliHLTTrackGrid* fTrackGrid; //! index grid for tracks
     242             : 
     243             :   /// index grid for clusters
     244             :   AliHLTSpacePointContainer::AliHLTSpacePointPropertyGrid* fSpacePointGrid; //! index grid for clusters
     245             : 
     246             :   /// deflater
     247             :   AliHLTDataDeflater* fpDataDeflater; //! deflater for raw clusters
     248             : 
     249             :   /// compression factor histogram
     250             :   TH1F* fHistoCompFactor; //! histogram of compression factor
     251             :   TH1F* fHistoResidualPad; //! histogram for pad residual
     252             :   TH1F* fHistoResidualTime; //! histogram for time residual
     253             :   TH1F* fHistoClustersOnTracks; //! clusters on tracks for track model compression
     254             :   TH1F* fHistoClusterRatio; //! fraction of clusters assigned to the track model compression
     255             :   TH1F* fHistoTrackClusterRatio; //! fraction of track clusters assigned to the track model compression
     256             :   TString fHistogramFile; //! file to save histogram
     257             :   TString fTrainingTableOutput; //! output file for huffman tables in training mode
     258             : 
     259             :   /// benchmark
     260             :   AliHLTComponentBenchmark* fpBenchmark; //! benchmark instance
     261             : 
     262             :   /// temporary array of ids of associated cluster ids
     263             :   vector<AliHLTUInt32_t>* fpWrittenAssociatedClusterIds; //!
     264             : 
     265             :   float fDriftTimeFactorA; //! drift time A side
     266             :   float fDriftTimeOffsetA; //! drift time A side
     267             :   float fDriftTimeFactorC; //! drift time C side
     268             :   float fDriftTimeOffsetC; //! drift time C side
     269             : 
     270             :   /// verbosity
     271             :   int fVerbosity; // verbosity for debug printout
     272             : 
     273           6 :   ClassDef(AliHLTTPCDataCompressionComponent, 0)
     274             : };
     275             : 
     276             : #endif //ALIHLTTPCDATACOMPRESSIONCOMPONENT_H

Generated by: LCOV version 1.11