]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/comp/AliHLTTPCDataCompressionMonitorComponent.h
adding further optimized compression format with additional 15% compression ratio...
[u/mrichter/AliRoot.git] / HLT / TPCLib / comp / AliHLTTPCDataCompressionMonitorComponent.h
1 //-*- Mode: C++ -*-
2 // $Id$
3 #ifndef ALIHLTTPCDATACOMPRESSIONMONITORCOMPONENT_H
4 #define ALIHLTTPCDATACOMPRESSIONMONITORCOMPONENT_H
5 //* This file is property of and copyright by the ALICE HLT Project        * 
6 //* ALICE Experiment at CERN, All rights reserved.                         *
7 //* See cxx source for full Copyright notice                               *
8
9 /// @file   AliHLTTPCDataCompressionMonitorComponent.h
10 /// @author Matthias Richter
11 /// @date   2011-09-12
12 /// @brief  TPC component for monitoring of data compression
13 ///
14
15 #include "AliHLTProcessor.h"
16 #include "TString.h"
17
18 class AliHLTTPCHWCFData;
19 class AliHLTDataInflater;
20 class AliHLTTPCTrackGeometry;
21 class AliHLTTPCHWCFSpacePointContainer;
22 class TH1;
23 class TH2;
24
25 /**
26  * @class AliHLTTPCDataCompressionMonitorComponent
27  *
28  * <h2>General properties:</h2>
29  *
30  * Component ID: \b TPCDataCompressorMonitor      <br>
31  * Library: \b libAliHLTTPC.so     <br>
32  * Input Data Types:  <br>
33  * Output Data Types: <br>
34  *
35  * <h2>Mandatory arguments:</h2>
36  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
37  *
38  * <h2>Optional arguments:</h2>
39  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
40
41  * <h2>Configuration:</h2>
42  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
43  *
44  * <h2>Default CDB entries:</h2>
45  *
46  * <h2>Performance:</h2>
47  *
48  * <h2>Memory consumption:</h2>
49  *
50  * <h2>Output size:</h2>
51  *
52  *
53  * @ingroup alihlt_tpc
54  */
55 class AliHLTTPCDataCompressionMonitorComponent : public AliHLTProcessor {
56 public:
57   /// standard constructor
58   AliHLTTPCDataCompressionMonitorComponent();
59   /// destructor
60   ~AliHLTTPCDataCompressionMonitorComponent();
61
62   /// inherited from AliHLTComponent: id of the component
63   virtual const char* GetComponentID();
64
65   /// inherited from AliHLTComponent: list of data types in the vector reference
66   void GetInputDataTypes( AliHLTComponentDataTypeList& );
67
68   /// inherited from AliHLTComponent: output data type of the component.
69   AliHLTComponentDataType GetOutputDataType();
70
71   /// inherited from AliHLTComponent: multiple output data types of the component.
72   int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
73
74   /// inherited from AliHLTComponent: output data size estimator
75   void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
76
77   /// inherited from AliHLTComponent: spawn function.
78   virtual AliHLTComponent* Spawn();
79
80   enum {
81     kHaveRawData = 0x1,
82     kHaveHWClusters = 0x2
83   };
84
85   enum {
86     kHistogramPadrow,
87     kHistogramPad,
88     kHistogramTime,
89     kHistogramSigmaY2,
90     kHistogramSigmaZ2,
91     kHistogramCharge,
92     kHistogramQMax,
93     kHistogramDeltaPadrow,
94     kHistogramDeltaPad,
95     kHistogramDeltaTime,
96     kHistogramDeltaSigmaY2,
97     kHistogramDeltaSigmaZ2,
98     kHistogramDeltaCharge,
99     kHistogramDeltaQMax,
100     kHistogramOutOfRange,
101     kNumberOfHistograms
102   };
103
104   struct AliHistogramDefinition {
105     int fId; //!
106     const char* fName; //!
107     const char* fTitle; //!
108     int fBins; //!
109     float fLowerBound; //!
110     float fUpperBound; //!
111   };
112
113   /**
114    * @class AliDataContainer
115    * Cluster read interface for monitoring.
116    * The class implements the interface to be used in the decoding
117    * of compressed TPC data.
118    */
119   class AliDataContainer : public AliHLTLogging {
120   public:
121     AliDataContainer();
122     virtual ~AliDataContainer();
123
124     struct AliClusterIdBlock {
125       AliClusterIdBlock() : fIds(NULL), fSize(0) {}
126       AliHLTUInt32_t* fIds; //!
127       AliHLTUInt32_t  fSize; //!
128     };
129
130     class iterator {
131     public:
132       iterator() : fClusterNo(-1), fData(NULL), fClusterId(kAliHLTVoidDataSpec), fSlice(-1), fPartition(-1) {}
133       iterator(AliDataContainer* pData) : fClusterNo(-1), fData(pData), fClusterId(fData?fData->GetClusterId(fClusterNo):kAliHLTVoidDataSpec), fSlice(-1), fPartition(-1) {}
134       iterator(const iterator& other) : fClusterNo(other.fClusterNo), fData(other.fData), fClusterId(other.fClusterId), fSlice(other.fSlice), fPartition(other.fPartition) {}
135       iterator& operator=(const iterator& other) {
136         fClusterNo=other.fClusterNo; fData=other.fData; fClusterId=other.fClusterId; fSlice=other.fSlice; fPartition=other.fPartition; return *this;
137       }
138       ~iterator() {}
139
140       void SetPadRow(int row)          {if (fData) fData->FillPadRow(row, fClusterId);}
141       void SetPad(float pad)           {if (fData) fData->FillPad(pad, fClusterId);}
142       void SetTime(float time)         {if (fData) fData->FillTime(time, fClusterId);}
143       void SetSigmaY2(float sigmaY2)   {if (fData) fData->FillSigmaY2(sigmaY2, fClusterId, fPartition);}
144       void SetSigmaZ2(float sigmaZ2)   {if (fData) fData->FillSigmaZ2(sigmaZ2, fClusterId);}
145       void SetCharge(unsigned charge)  {if (fData) fData->FillCharge(charge, fClusterId);}
146       void SetQMax(unsigned qmax)      {if (fData) fData->FillQMax(qmax, fClusterId);}
147
148       // switch to next cluster
149       iterator& Next(int slice, int partition) {
150         fSlice=slice; fPartition=partition; return operator++();
151       }
152       // prefix operators
153       iterator& operator++() {fClusterNo++; fClusterId=fData?fData->GetClusterId(fClusterNo):kAliHLTVoidDataSpec;return *this;}
154       iterator& operator--() {fClusterNo--; fClusterId=fData?fData->GetClusterId(fClusterNo):kAliHLTVoidDataSpec;return *this;}
155       // postfix operators
156       iterator operator++(int) {iterator i(*this); fClusterNo++; return i;}
157       iterator operator--(int) {iterator i(*this); fClusterNo--; return i;}
158
159       bool operator==(const iterator other) const {return fData==other.fData;}
160       bool operator!=(const iterator other) const {return fData!=other.fData;}
161
162     private:
163       int fClusterNo; //! cluster no in the current block
164       AliDataContainer* fData; //! pointer to actual data
165       AliHLTUInt32_t fClusterId; //! id of the cluster, from optional cluster id blocks
166       int fSlice;     //! current slice
167       int fPartition; //! current partition
168     };
169
170     /// iterator of remaining clusters block of specification
171     iterator& BeginRemainingClusterBlock(int count, AliHLTUInt32_t specification);
172     /// iterator of track model clusters
173     iterator& BeginTrackModelClusterBlock(int count);
174
175     /// add raw data bloack
176     int AddRawData(const AliHLTComponentBlockData* pDesc);
177     /// add cluster id block for remaining or track model clusters
178     int AddClusterIds(const AliHLTComponentBlockData* pDesc);
179     /// get the cluster id from the current cluster id block (optional)
180     AliHLTUInt32_t GetClusterId(int clusterNo) const;
181
182     /// internal cleanup
183     virtual void  Clear(Option_t * option="");
184     /// get histogram object
185     virtual TObject* FindObject(const char *name) const;
186     
187   protected:
188     void FillPadRow(int row, AliHLTUInt32_t clusterId);
189     void FillPad(float pad, AliHLTUInt32_t clusterId);
190     void FillTime(float time, AliHLTUInt32_t clusterId);
191     void FillSigmaY2(float sigmaY2, AliHLTUInt32_t clusterId, int partition);
192     void FillSigmaZ2(float sigmaZ2, AliHLTUInt32_t clusterId);
193     void FillCharge(unsigned charge, AliHLTUInt32_t clusterId);
194     void FillQMax(unsigned qmax, AliHLTUInt32_t clusterId);
195
196   private:
197     AliDataContainer(const AliDataContainer&);
198     AliDataContainer& operator=(const AliDataContainer&);
199
200     TObjArray* fHistograms;     //! array of histograms
201     vector<TH1*> fHistogramPointers; //! pointers to histograms
202     vector<AliClusterIdBlock> fRemainingClusterIds; //! clusters ids for remaining cluster ids
203     AliClusterIdBlock fTrackModelClusterIds; //! cluster ids for track model clusters
204     AliClusterIdBlock* fCurrentClusterIds; //! id block currently active in the iteration
205     AliHLTTPCHWCFSpacePointContainer* fRawData; //! raw data container
206     int fLastPadRow; //! last padrow
207     iterator fBegin; //!
208   };
209
210 protected:
211   /// inherited from AliHLTProcessor: data processing
212   int DoEvent( const AliHLTComponentEventData& evtData, 
213                const AliHLTComponentBlockData* blocks, 
214                AliHLTComponentTriggerData& trigData,
215                AliHLTUInt8_t* outputPtr, 
216                AliHLTUInt32_t& size,
217                AliHLTComponentBlockDataList& outputBlocks );
218   using AliHLTProcessor::DoEvent;
219
220   /// inherited from AliHLTComponent: component initialisation and argument scan.
221   int DoInit( int argc, const char** argv );
222
223   /// inherited from AliHLTComponent: component cleanup
224   int DoDeinit();
225
226   /// inherited from AliHLTComponent: argument scan
227   int ScanConfigurationArgument(int argc, const char** argv);
228
229 private:
230   AliHLTTPCDataCompressionMonitorComponent(const AliHLTTPCDataCompressionMonitorComponent&);
231   AliHLTTPCDataCompressionMonitorComponent& operator=(const AliHLTTPCDataCompressionMonitorComponent&);
232
233   AliHLTTPCHWCFData* fpHWClusterDecoder; //! data decoder for HW clusters
234
235   TH2* fHistoHWCFDataSize;         //! hwcf data size vs. event size
236   TH2* fHistoHWCFReductionFactor;  //! reduction factor vs. event size
237   TH2* fHistoNofClusters; //! number of clusters vs. event size
238   TString fHistogramFile; //! file to save histogram
239   AliDataContainer* fMonitoringContainer; //! cluster read interface for monitoring
240
241   /// verbosity
242   int fVerbosity;  //! verbosity for debug printout
243   unsigned fFlags; //! flags to indicate various conditions
244
245   static const AliHistogramDefinition fgkHistogramDefinitions[]; //! histogram definitions
246
247   ClassDef(AliHLTTPCDataCompressionMonitorComponent, 0)
248 };
249
250 #endif //ALIHLTTPCDATACOMPRESSIONMONITORCOMPONENT_H