]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/tracking-ca/AliHLTTPCCAInputDataCompressorComponent.cxx
extra benchmarks are added
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCAInputDataCompressorComponent.cxx
CommitLineData
751d16ac 1// **************************************************************************
2// This file is property of and copyright by the ALICE HLT Project *
3// ALICE Experiment at CERN, All rights reserved. *
4// *
5// Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
6// Ivan Kisel <kisel@kip.uni-heidelberg.de> *
7// for The ALICE HLT Project. *
8// *
9// Permission to use, copy, modify and distribute this software and its *
10// documentation strictly for non-commercial purposes is hereby granted *
11// without fee, provided that the above copyright notice appears in all *
12// copies and that both the copyright notice and this permission notice *
13// appear in the supporting documentation. The authors make no claims *
14// about the suitability of this software for any purpose. It is *
15// provided "as is" without express or implied warranty. *
16// *
17//***************************************************************************
18
19
20///////////////////////////////////////////////////////////////////////////////
21// //
22// a TPC tracker processing component for the HLT based on CA by Ivan Kisel //
23// //
24///////////////////////////////////////////////////////////////////////////////
25
26#if __GNUC__>= 3
27using namespace std;
28#endif
29
30#include "AliHLTTPCCAInputDataCompressorComponent.h"
31#include "AliHLTTPCCACompressedInputData.h"
32#include "AliHLTTPCTransform.h"
33#include "AliHLTTPCClusterDataFormat.h"
34#include "AliHLTTPCSpacePointData.h"
35#include "AliHLTTPCDefinitions.h"
36#include "AliHLTTPCCADef.h"
751d16ac 37
38
39const AliHLTComponentDataType AliHLTTPCCADefinitions::fgkCompressedInputDataType = AliHLTComponentDataTypeInitializer( "CAINPACK", kAliHLTDataOriginTPC );
40
41/** ROOT macro for the implementation of ROOT specific class methods */
42ClassImp( AliHLTTPCCAInputDataCompressorComponent )
43
44AliHLTTPCCAInputDataCompressorComponent::AliHLTTPCCAInputDataCompressorComponent()
45 :
46 AliHLTProcessor(),
57a4102f 47 fBenchmark("CAInputCompressor")
751d16ac 48{
49 // see header file for class documentation
50 // or
51 // refer to README to build package
52 // or
53 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
54}
55
56AliHLTTPCCAInputDataCompressorComponent::AliHLTTPCCAInputDataCompressorComponent( const AliHLTTPCCAInputDataCompressorComponent& )
57 :
58 AliHLTProcessor(),
57a4102f 59 fBenchmark("CAInputCompressor")
751d16ac 60{
61 // see header file for class documentation
62 HLTFatal( "copy constructor untested" );
63}
64
65AliHLTTPCCAInputDataCompressorComponent& AliHLTTPCCAInputDataCompressorComponent::operator=( const AliHLTTPCCAInputDataCompressorComponent& )
66{
67 // see header file for class documentation
68 HLTFatal( "assignment operator untested" );
69 return *this;
70}
71
72AliHLTTPCCAInputDataCompressorComponent::~AliHLTTPCCAInputDataCompressorComponent()
73{
74 // see header file for class documentation
75}
76
77//
78// Public functions to implement AliHLTComponent's interface.
79// These functions are required for the registration process
80//
81
82const char* AliHLTTPCCAInputDataCompressorComponent::GetComponentID()
83{
84 // see header file for class documentation
85 return "TPCCAInputDataCompressor";
86}
87
88void AliHLTTPCCAInputDataCompressorComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list )
89{
90 // see header file for class documentation
91 list.clear();
92 list.push_back( AliHLTTPCDefinitions::fgkClustersDataType );
93}
94
95AliHLTComponentDataType AliHLTTPCCAInputDataCompressorComponent::GetOutputDataType()
96{
97 // see header file for class documentation
98 return AliHLTTPCCADefinitions::fgkCompressedInputDataType;
99}
100
101void AliHLTTPCCAInputDataCompressorComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
102{
103 // define guess for the output data size
104 constBase = 200; // minimum size
105 inputMultiplier = 0.25; // size relative to input
106}
107
108AliHLTComponent* AliHLTTPCCAInputDataCompressorComponent::Spawn()
109{
110 // see header file for class documentation
111 return new AliHLTTPCCAInputDataCompressorComponent;
112}
113
114
115
116
117int AliHLTTPCCAInputDataCompressorComponent::DoInit( int /*argc*/, const char** /*argv*/ )
118{
119 // Configure the CA tracker component
57a4102f 120 fBenchmark.Reset();
121 fBenchmark.SetTimer(0,"total");
122 fBenchmark.SetTimer(1,"reco");
751d16ac 123 return 0;
124}
125
126
127int AliHLTTPCCAInputDataCompressorComponent::DoDeinit()
128{
129 // see header file for class documentation
130 return 0;
131}
132
133
134
135int AliHLTTPCCAInputDataCompressorComponent::Reconfigure( const char* /*cdbEntry*/, const char* /*chainId*/ )
136{
137 // Reconfigure the component from OCDB .
138 return 0;
139}
140
141
142
143int AliHLTTPCCAInputDataCompressorComponent::DoEvent
144(
145 const AliHLTComponentEventData& evtData,
146 const AliHLTComponentBlockData* blocks,
147 AliHLTComponentTriggerData& /*trigData*/,
148 AliHLTUInt8_t* outputPtr,
149 AliHLTUInt32_t& size,
150 vector<AliHLTComponentBlockData>& outputBlocks )
151{
152 //* process event
153
154 AliHLTUInt32_t maxBufferSize = size;
155 size = 0; // output size
156
157 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) ) {
158 return 0;
159 }
160
57a4102f 161 fBenchmark.StartNewEvent();
162 fBenchmark.Start(0);
751d16ac 163
164 // Preprocess the data for CA Slice Tracker
165
166 if ( evtData.fBlockCnt <= 0 ) {
167 HLTWarning( "no blocks in event" );
168 return 0;
169 }
170
171 Int_t ret = 0;
172
751d16ac 173 Int_t outTotalSize = 0;
174 Int_t minSlice = 100;
175 Int_t maxSlice = -1;
176
177 for ( unsigned long ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) {
178 const AliHLTComponentBlockData* iter = blocks + ndx;
179 if ( iter->fDataType != AliHLTTPCDefinitions::fgkClustersDataType ) continue;
180
57a4102f 181 fBenchmark.AddInput(iter->fSize);
182
751d16ac 183 if( minSlice>AliHLTTPCDefinitions::GetMinSliceNr( *iter ) ) minSlice = AliHLTTPCDefinitions::GetMinSliceNr( *iter ) ;
184 if( maxSlice<AliHLTTPCDefinitions::GetMaxSliceNr( *iter ) ) maxSlice = AliHLTTPCDefinitions::GetMaxSliceNr( *iter ) ;
2f516e61 185
751d16ac 186
2f516e61 187 AliHLTUInt32_t dSize = 0;
57a4102f 188
189 fBenchmark.Start(1);
190
2f516e61 191 ret = Compress( ( AliHLTTPCClusterData* )( iter->fPtr ), maxBufferSize - outTotalSize,
192 outputPtr+outTotalSize,
193 dSize );
57a4102f 194 fBenchmark.Stop(1);
195
2f516e61 196 if ( ret!=0 ){
197 HLTWarning( "Output buffer size exceed (buffer size %d, current size %d)", maxBufferSize );
751d16ac 198 break;
199 }
2f516e61 200
751d16ac 201 AliHLTComponentBlockData bd;
202 FillBlockData( bd );
203 bd.fOffset = outTotalSize;
204 bd.fSize = dSize;
205 bd.fSpecification = iter->fSpecification;
206 bd.fDataType = GetOutputDataType();
207 outputBlocks.push_back( bd );
2f516e61 208 outTotalSize+=dSize;
57a4102f 209 fBenchmark.AddOutput(bd.fSize);
751d16ac 210 }
211
212 size = outTotalSize;
213
57a4102f 214 fBenchmark.Stop(0);
751d16ac 215
751d16ac 216 if( maxSlice<0 ) minSlice = -1;
751d16ac 217
57a4102f 218 // Set log level to "Warning" for on-line system monitorin
751d16ac 219
57a4102f 220 if( minSlice!=maxSlice ) fBenchmark.SetName(Form("CAInputDataCompressor, slices %d-%d", minSlice, maxSlice));
221 else fBenchmark.SetName(Form("CAInputDataCompressor, slice %d", minSlice));
222
223 HLTInfo( fBenchmark.GetStatistics());
751d16ac 224 return ret;
225}
226
227
2f516e61 228
229int AliHLTTPCCAInputDataCompressorComponent::Compress( AliHLTTPCClusterData* inputPtr,
230 AliHLTUInt32_t maxBufferSize,
231 AliHLTUInt8_t* outputPtr,
232 AliHLTUInt32_t& outputSize
233 )
234{
235 // Preprocess the data for CA Slice Tracker
236
237 Int_t ret = 0;
238 outputSize = 0;
239
240 AliHLTTPCCACompressedCluster *outCluster = (AliHLTTPCCACompressedCluster*)( outputPtr );
241 AliHLTTPCCACompressedClusterRow *outRow = 0;
242
243 UShort_t oldId = 0;
244
245 for ( unsigned int i = 0; i < inputPtr->fSpacePointCnt; i++ ){
246 AliHLTTPCSpacePointData *cluster = &( inputPtr->fSpacePoints[i] );
247 UInt_t origId = cluster->fID;
248 UInt_t patch = (origId>>22)&0x7;
249 UInt_t slice = origId>>25;
250 UInt_t row = cluster->fPadRow;
251 Double_t rowX = AliHLTTPCTransform::Row2X( row );
252 row = row - AliHLTTPCTransform::GetFirstRow( patch );
253 UShort_t id = (UShort_t)( (slice<<10) +(patch<<6) + row );
254 if( i==0 || id!= oldId ){
255 // fill new row header
256 outRow = (AliHLTTPCCACompressedClusterRow*) outCluster;
257 outCluster = outRow->fClusters;
258 outputSize+= ( ( AliHLTUInt8_t * )outCluster ) - (( AliHLTUInt8_t * )outRow);
64fc3975 259 if ( outputSize > maxBufferSize ){
2f516e61 260 ret = -ENOSPC;
261 outputSize=0;
262 break;
263 }
264 outRow->fSlicePatchRowID = id;
265 outRow->fNClusters = 0;
266 oldId = id;
267 //cout<<"Fill row: s "<<slice<<" p "<<patch<<" r "<<row<<" x "<<outRow->fX<<":"<<endl;
268 }
269
270 // pack the cluster
271 {
272 // get coordinates in [um]
273
274 Double_t x = (cluster->fX - rowX )*1.e4 + 32768.;
275 Double_t y = (cluster->fY)*1.e4 + 8388608.;
276 Double_t z = (cluster->fZ)*1.e4 + 8388608.;
277
278 // truncate if necessary
279 if( x<0 ) x = 0; else if( x > 0x0000FFFF ) x = 0x0000FFFF;
280 if( y<0 ) y = 0; else if( y > 0x00FFFFFF ) y = 0x00FFFFFF;
281 if( z<0 ) z = 0; else if( z > 0x00FFFFFF ) z = 0x00FFFFFF;
282
283 UInt_t ix0 = ( (UInt_t) x )&0x000000FF;
284 UInt_t ix1 = (( (UInt_t) x )&0x0000FF00 )>>8;
285 UInt_t iy = ( (UInt_t) y )&0x00FFFFFF;
286 UInt_t iz = ( (UInt_t) z )&0x00FFFFFF;
287
288 outputSize+= sizeof( AliHLTTPCCACompressedCluster );
64fc3975 289 if ( outputSize > maxBufferSize ){
2f516e61 290 outputSize = 0;
291 ret = -ENOSPC;
292 break;
293 }
294 outCluster->fP0 = (ix0<<24) + iy;
295 outCluster->fP1 = (ix1<<24) + iz;
296 outCluster++;
297 outRow->fNClusters++;
298 //cout<<"clu "<<outRow->fNClusters-1<<": "<<cluster->fX<<" "<<cluster->fY<<" "<<cluster->fZ<<" "<<cluster->fID<<endl;
299 }
300 }
301
302 return ret;
303}