make iterattion to next cluster structure better suited for decoding
[u/mrichter/AliRoot.git] / HLT / TPCLib / comp / AliHLTTPCDataCompressionMonitorComponent.h
CommitLineData
76c437dc 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
18class AliHLTTPCHWCFData;
6776da52 19class AliHLTDataInflater;
eb51a006 20class AliHLTTPCTrackGeometry;
779a5a62 21class AliHLTTPCHWCFSpacePointContainer;
76c437dc 22class TH1;
23class 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 */
55class AliHLTTPCDataCompressionMonitorComponent : public AliHLTProcessor {
56public:
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
779a5a62 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 kNumberOfHistograms
101 };
102
103 struct AliHistogramDefinition {
104 int fId; //!
105 const char* fName; //!
106 const char* fTitle; //!
107 int fBins; //!
108 float fLowerBound; //!
109 float fUpperBound; //!
110 };
111
112 /**
113 * @class AliDataContainer
114 * Cluster read interface for monitoring.
115 * The class implements the interface to be used in the decoding
116 * of compressed TPC data.
117 */
118 class AliDataContainer {
119 public:
120 AliDataContainer();
121 virtual ~AliDataContainer();
122
123 struct AliClusterIdBlock {
124 AliClusterIdBlock() : fIds(NULL), fSize(0) {}
125 AliHLTUInt32_t* fIds; //!
126 AliHLTUInt32_t fSize; //!
127 };
128
129 class iterator {
130 public:
bf1a9c81 131 iterator() : fClusterNo(-1), fData(NULL), fClusterId(kAliHLTVoidDataSpec) {}
132 iterator(AliDataContainer* pData) : fClusterNo(-1), fData(pData), fClusterId(fData?fData->GetClusterId(fClusterNo):kAliHLTVoidDataSpec) {}
779a5a62 133 iterator(const iterator& other) : fClusterNo(other.fClusterNo), fData(other.fData), fClusterId(other.fClusterId) {}
134 iterator& operator=(const iterator& other) {
135 fClusterNo=other.fClusterNo; fData=other.fData; fClusterId=other.fClusterId; return *this;
136 }
137 ~iterator() {}
138
139 void SetPadRow(int row) {if (fData) fData->FillPadRow(row, fClusterId);}
140 void SetPad(float pad) {if (fData) fData->FillPad(pad, fClusterId);}
141 void SetTime(float time) {if (fData) fData->FillTime(time, fClusterId);}
142 void SetSigmaY2(float sigmaY2) {if (fData) fData->FillSigmaY2(sigmaY2, fClusterId);}
143 void SetSigmaZ2(float sigmaZ2) {if (fData) fData->FillSigmaZ2(sigmaZ2, fClusterId);}
144 void SetCharge(unsigned charge) {if (fData) fData->FillCharge(charge, fClusterId);}
145 void SetQMax(unsigned qmax) {if (fData) fData->FillQMax(qmax, fClusterId);}
146
f899e060 147 // switch to next cluster
148 iterator& Next(int /*slice*/, int /*partition*/) {return operator++();}
779a5a62 149 // prefix operators
150 iterator& operator++() {fClusterNo++; fClusterId=fData?fData->GetClusterId(fClusterNo):kAliHLTVoidDataSpec;return *this;}
151 iterator& operator--() {fClusterNo--; fClusterId=fData?fData->GetClusterId(fClusterNo):kAliHLTVoidDataSpec;return *this;}
152 // postfix operators
153 iterator operator++(int) {iterator i(*this); fClusterNo++; return i;}
154 iterator operator--(int) {iterator i(*this); fClusterNo--; return i;}
155
156 bool operator==(const iterator other) const {return fData==other.fData;}
157 bool operator!=(const iterator other) const {return fData!=other.fData;}
158
159 private:
160 int fClusterNo; //! cluster no in the current block
161 AliDataContainer* fData; //! pointer to actual data
162 AliHLTUInt32_t fClusterId; //! id of the cluster, from optional cluster id blocks
163 };
164
165 /// iterator of remaining clusters block of specification
166 iterator& BeginRemainingClusterBlock(int count, AliHLTUInt32_t specification);
167 /// iterator of track model clusters
168 iterator& BeginTrackModelClusterBlock(int count);
779a5a62 169
170 /// add raw data bloack
171 int AddRawData(const AliHLTComponentBlockData* pDesc);
172 /// add cluster id block for remaining or track model clusters
173 int AddClusterIds(const AliHLTComponentBlockData* pDesc);
174 /// get the cluster id from the current cluster id block (optional)
175 AliHLTUInt32_t GetClusterId(int clusterNo) const;
176
177 /// internal cleanup
178 virtual void Clear(Option_t * option="");
179 /// get histogram object
180 virtual TObject* FindObject(const char *name) const;
181
182 protected:
183 void FillPadRow(int row, AliHLTUInt32_t clusterId);
184 void FillPad(float pad, AliHLTUInt32_t clusterId);
185 void FillTime(float time, AliHLTUInt32_t clusterId);
186 void FillSigmaY2(float sigmaY2, AliHLTUInt32_t clusterId);
187 void FillSigmaZ2(float sigmaZ2, AliHLTUInt32_t clusterId);
188 void FillCharge(unsigned charge, AliHLTUInt32_t clusterId);
189 void FillQMax(unsigned qmax, AliHLTUInt32_t clusterId);
190
191 private:
192 AliDataContainer(const AliDataContainer&);
193 AliDataContainer& operator=(const AliDataContainer&);
194
195 TObjArray* fHistograms; //! array of histograms
196 vector<TH1*> fHistogramPointers; //! pointers to histograms
197 vector<AliClusterIdBlock> fRemainingClusterIds; //! clusters ids for remaining cluster ids
198 AliClusterIdBlock fTrackModelClusterIds; //! cluster ids for track model clusters
199 AliClusterIdBlock* fCurrentClusterIds; //! id block currently active in the iteration
200 AliHLTTPCHWCFSpacePointContainer* fRawData; //! raw data container
201 iterator fBegin; //!
202 iterator fEnd; //!
203 };
204
76c437dc 205protected:
206 /// inherited from AliHLTProcessor: data processing
207 int DoEvent( const AliHLTComponentEventData& evtData,
208 const AliHLTComponentBlockData* blocks,
209 AliHLTComponentTriggerData& trigData,
210 AliHLTUInt8_t* outputPtr,
211 AliHLTUInt32_t& size,
212 AliHLTComponentBlockDataList& outputBlocks );
213 using AliHLTProcessor::DoEvent;
214
215 /// inherited from AliHLTComponent: component initialisation and argument scan.
216 int DoInit( int argc, const char** argv );
217
218 /// inherited from AliHLTComponent: component cleanup
219 int DoDeinit();
220
221 /// inherited from AliHLTComponent: argument scan
222 int ScanConfigurationArgument(int argc, const char** argv);
223
224private:
225 AliHLTTPCDataCompressionMonitorComponent(const AliHLTTPCDataCompressionMonitorComponent&);
226 AliHLTTPCDataCompressionMonitorComponent& operator=(const AliHLTTPCDataCompressionMonitorComponent&);
227
228 AliHLTTPCHWCFData* fpHWClusterDecoder; //! data decoder for HW clusters
229
230 TH2* fHistoHWCFDataSize; //! hwcf data size vs. event size
231 TH2* fHistoHWCFReductionFactor; //! reduction factor vs. event size
232 TH2* fHistoNofClusters; //! number of clusters vs. event size
233 TString fHistogramFile; //! file to save histogram
779a5a62 234 AliDataContainer* fMonitoringContainer; //! cluster read interface for monitoring
76c437dc 235
236 /// verbosity
237 int fVerbosity; //! verbosity for debug printout
238 unsigned fFlags; //! flags to indicate various conditions
239
779a5a62 240 static const AliHistogramDefinition fgkHistogramDefinitions[]; //! histogram definitions
241
76c437dc 242 ClassDef(AliHLTTPCDataCompressionMonitorComponent, 0)
243};
244
245#endif //ALIHLTTPCDATACOMPRESSIONMONITORCOMPONENT_H