]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/comp/AliHLTTPCDataCompressionMonitorComponent.h
update of histograms; using TH*D to avoid saturation (Alberica)
[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 class TH3;
25
26 /**
27  * @class AliHLTTPCDataCompressionMonitorComponent
28  *
29  * <h2>General properties:</h2>
30  *
31  * Component ID: \b TPCDataCompressorMonitor      <br>
32  * Library: \b libAliHLTTPC.so     <br>
33  * Input Data Types:  <br>
34  * Output Data Types: <br>
35  *
36  * <h2>Mandatory arguments:</h2>
37  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
38  *
39  * <h2>Optional arguments:</h2>
40  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
41
42  * <h2>Configuration:</h2>
43  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
44  *
45  * <h2>Default CDB entries:</h2>
46  *
47  * <h2>Performance:</h2>
48  *
49  * <h2>Memory consumption:</h2>
50  *
51  * <h2>Output size:</h2>
52  *
53  *
54  * @ingroup alihlt_tpc
55  */
56 class AliHLTTPCDataCompressionMonitorComponent : public AliHLTProcessor {
57 public:
58   /// standard constructor
59   AliHLTTPCDataCompressionMonitorComponent();
60   /// destructor
61   ~AliHLTTPCDataCompressionMonitorComponent();
62
63   /// inherited from AliHLTComponent: id of the component
64   virtual const char* GetComponentID();
65
66   /// inherited from AliHLTComponent: list of data types in the vector reference
67   void GetInputDataTypes( AliHLTComponentDataTypeList& );
68
69   /// inherited from AliHLTComponent: output data type of the component.
70   AliHLTComponentDataType GetOutputDataType();
71
72   /// inherited from AliHLTComponent: multiple output data types of the component.
73   int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
74
75   /// inherited from AliHLTComponent: output data size estimator
76   void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
77
78   /// inherited from AliHLTComponent: spawn function.
79   virtual AliHLTComponent* Spawn();
80
81   enum {
82     kHaveRawData = 0x1,
83     kHaveHWClusters = 0x2
84   };
85
86   enum {
87     kPublishOff      = 0,
88     kPublishSeparate = 1,
89     kPublishList     = 2,
90     kPublishArray    = 3,
91     kPublishInvalid  = 4    
92   };
93
94   enum {
95     kHistogramPadrow,
96     kHistogramPad,
97     kHistogramTime,
98     kHistogramSigmaY2,
99     kHistogramSigmaZ2,
100     kHistogramCharge,
101     kHistogramQMax,
102     kHistogramDeltaPadrow,
103     kHistogramDeltaPad,
104     kHistogramDeltaTime,
105     kHistogramDeltaSigmaY2,
106     kHistogramDeltaSigmaZ2,
107     kHistogramDeltaCharge,
108     kHistogramDeltaQMax,
109     kHistogramOutOfRange,
110     kNumberOfHistograms
111   };
112   enum {
113     kHistogramQMaxSector,
114     kHistogramSigmaY2Sector,
115     kHistogramSigmaZ2Sector,
116     kHistogramXY,
117     kNumberOfHistograms2D
118   };
119   enum {
120     kHistogramPadrowPadSector,
121     kNumberOfHistograms3D
122   };
123
124   struct AliHistogramDefinition {
125     int fId; //!
126     const char* fName; //!
127     const char* fTitle; //!
128     int fBins; //!
129     float fLowerBound; //!
130     float fUpperBound; //!
131   };
132   struct AliHistogramDefinition2D {
133     int fId; //!
134     const char* fName; //!
135     const char* fTitle; //!
136     int fBinsX; //!
137     float fLowerBoundX; //!
138     float fUpperBoundX; //!
139     int fBinsY; //!
140     float fLowerBoundY; //!
141     float fUpperBoundY; //!
142   };
143   struct AliHistogramDefinition3D {
144     int fId; //!
145     const char* fName; //!
146     const char* fTitle; //!
147     int fBinsX; //!
148     float fLowerBoundX; //!
149     float fUpperBoundX; //!
150     int fBinsY; //!
151     float fLowerBoundY; //!
152     float fUpperBoundY; //!
153     int fBinsZ; //!
154     float fLowerBoundZ; //!
155     float fUpperBoundZ; //!
156   };
157
158   /**
159    * @class AliDataContainer
160    * Cluster read interface for monitoring.
161    * The class implements the interface to be used in the decoding
162    * of compressed TPC data.
163    */
164   class AliDataContainer : public AliHLTLogging {
165   public:
166     AliDataContainer();
167     virtual ~AliDataContainer();
168
169     struct AliClusterIdBlock {
170       AliClusterIdBlock() : fIds(NULL), fSize(0) {}
171       AliHLTUInt32_t* fIds; //!
172       AliHLTUInt32_t  fSize; //!
173     };
174
175     class iterator {
176     public:
177       iterator() : fClusterNo(-1), fData(NULL), fClusterId(kAliHLTVoidDataSpec), fSlice(-1), fPartition(-1) {}
178       iterator(AliDataContainer* pData) : fClusterNo(-1), fData(pData), fClusterId(fData?fData->GetClusterId(fClusterNo):kAliHLTVoidDataSpec), fSlice(-1), fPartition(-1) {}
179       iterator(const iterator& other) : fClusterNo(other.fClusterNo), fData(other.fData), fClusterId(other.fClusterId), fSlice(other.fSlice), fPartition(other.fPartition) {}
180       iterator& operator=(const iterator& other) {
181         fClusterNo=other.fClusterNo; fData=other.fData; fClusterId=other.fClusterId; fSlice=other.fSlice; fPartition=other.fPartition; return *this;
182       }
183       ~iterator() {}
184
185       void SetPadRow(int row)             {if (fData) fData->FillPadRow(row, fSlice, fClusterId);}
186       void SetPad(float pad)              {if (fData) fData->FillPad(pad, fClusterId);}
187       void SetTime(float time)            {if (fData) fData->FillTime(time, fClusterId);}
188       void SetSigmaY2(float sigmaY2)      {if (fData) fData->FillSigmaY2(sigmaY2, fClusterId, fPartition);}
189       void SetSigmaZ2(float sigmaZ2)      {if (fData) fData->FillSigmaZ2(sigmaZ2, fClusterId);}
190       void SetCharge(unsigned charge)     {if (fData) fData->FillCharge(charge, fClusterId);}
191       void SetQMax(unsigned qmax)         {if (fData) fData->FillQMax(qmax, fClusterId);}
192
193       // switch to next cluster
194       iterator& Next(int slice, int partition) {
195         fSlice=slice; fPartition=partition; return operator++();
196       }
197       // prefix operators
198       iterator& operator++() {fClusterNo++; fClusterId=fData?fData->GetClusterId(fClusterNo):kAliHLTVoidDataSpec;return *this;}
199       iterator& operator--() {fClusterNo--; fClusterId=fData?fData->GetClusterId(fClusterNo):kAliHLTVoidDataSpec;return *this;}
200       // postfix operators
201       iterator operator++(int) {iterator i(*this); fClusterNo++; return i;}
202       iterator operator--(int) {iterator i(*this); fClusterNo--; return i;}
203
204       bool operator==(const iterator other) const {return fData==other.fData;}
205       bool operator!=(const iterator other) const {return fData!=other.fData;}
206
207     private:
208       int fClusterNo; //! cluster no in the current block
209       AliDataContainer* fData; //! pointer to actual data
210       AliHLTUInt32_t fClusterId; //! id of the cluster, from optional cluster id blocks
211       int fSlice;     //! current slice
212       int fPartition; //! current partition
213     };
214
215     /// iterator of remaining clusters block of specification
216     iterator& BeginRemainingClusterBlock(int count, AliHLTUInt32_t specification);
217     /// iterator of track model clusters
218     iterator& BeginTrackModelClusterBlock(int count);
219
220     /// add raw data bloack
221     int AddRawData(const AliHLTComponentBlockData* pDesc);
222     /// add cluster id block for remaining or track model clusters
223     int AddClusterIds(const AliHLTComponentBlockData* pDesc);
224     /// get the cluster id from the current cluster id block (optional)
225     AliHLTUInt32_t GetClusterId(int clusterNo) const;
226
227     /// internal cleanup
228     virtual void  Clear(Option_t * option="");
229     /// get histogram object
230     virtual TObject* FindObject(const char *name) const;
231     
232   protected:
233     void FillPadRow(int row, int slice, AliHLTUInt32_t clusterId);
234     void FillPad(float pad, AliHLTUInt32_t clusterId);
235     void FillTime(float time, AliHLTUInt32_t clusterId);
236     void FillSigmaY2(float sigmaY2, AliHLTUInt32_t clusterId, int partition);
237     void FillSigmaZ2(float sigmaZ2, AliHLTUInt32_t clusterId);
238     void FillCharge(unsigned charge, AliHLTUInt32_t clusterId);
239     void FillQMax(unsigned qmax, AliHLTUInt32_t clusterId);
240
241   private:
242     AliDataContainer(const AliDataContainer&);
243     AliDataContainer& operator=(const AliDataContainer&);
244
245     TObjArray* fHistograms;     //! array of histograms
246     TObjArray* fHistograms2D;     //! array of histograms
247     TObjArray* fHistograms3D;     //! array of histograms
248     vector<TH1*> fHistogramPointers; //! pointers to histograms
249     vector<TH2*> fHistogram2DPointers; //! pointers to histograms
250     vector<TH3*> fHistogram3DPointers; //! pointers to histograms
251     vector<AliClusterIdBlock> fRemainingClusterIds; //! clusters ids for remaining cluster ids
252     AliClusterIdBlock fTrackModelClusterIds; //! cluster ids for track model clusters
253     AliClusterIdBlock* fCurrentClusterIds; //! id block currently active in the iteration
254     AliHLTTPCHWCFSpacePointContainer* fRawData; //! raw data container
255     int fLastPadRow; //! last padrow
256     int fSector; //! sector
257     iterator fBegin; //!
258   };
259
260 protected:
261   /// inherited from AliHLTProcessor: data processing
262   int DoEvent( const AliHLTComponentEventData& evtData, 
263                const AliHLTComponentBlockData* blocks, 
264                AliHLTComponentTriggerData& trigData,
265                AliHLTUInt8_t* outputPtr, 
266                AliHLTUInt32_t& size,
267                AliHLTComponentBlockDataList& outputBlocks );
268   using AliHLTProcessor::DoEvent;
269
270   /// inherited from AliHLTComponent: component initialisation and argument scan.
271   int DoInit( int argc, const char** argv );
272
273   /// inherited from AliHLTComponent: component cleanup
274   int DoDeinit();
275
276   /// inherited from AliHLTComponent: argument scan
277   int ScanConfigurationArgument(int argc, const char** argv);
278
279   /// publish to output
280   int Publish(int mode);
281     
282 private:
283   AliHLTTPCDataCompressionMonitorComponent(const AliHLTTPCDataCompressionMonitorComponent&);
284   AliHLTTPCDataCompressionMonitorComponent& operator=(const AliHLTTPCDataCompressionMonitorComponent&);
285
286   AliHLTTPCHWCFData* fpHWClusterDecoder; //! data decoder for HW clusters
287
288   TH2* fHistoHWCFDataSize;         //! hwcf data size vs. event size
289   TH2* fHistoHWCFReductionFactor;  //! reduction factor vs. event size
290   TH2* fHistoNofClusters; //! number of clusters vs. event size
291   TH2* fHistoNofClustersReductionFactor;  //! reduction factor vs. number of clusters
292   TString fHistogramFile; //! file to save histogram
293   AliDataContainer* fMonitoringContainer; //! cluster read interface for monitoring
294
295   /// verbosity
296   int fVerbosity;  //! verbosity for debug printout
297   unsigned fFlags; //! flags to indicate various conditions
298   int fPublishingMode; //! publishing mode
299
300   static const AliHistogramDefinition fgkHistogramDefinitions[]; //! histogram definitions
301   static const AliHistogramDefinition2D fgkHistogramDefinitions2D[]; //! histogram definitions
302   static const AliHistogramDefinition3D fgkHistogramDefinitions3D[]; //! histogram definitions
303
304   ClassDef(AliHLTTPCDataCompressionMonitorComponent, 0)
305 };
306
307 #endif //ALIHLTTPCDATACOMPRESSIONMONITORCOMPONENT_H