]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/comp/AliHLTTPCCompDumpComponent.cxx
bugfix: missing function implemented; next strike against warnings
[u/mrichter/AliRoot.git] / HLT / TPCLib / comp / AliHLTTPCCompDumpComponent.cxx
1 // $Id$
2
3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project        * 
5 //* ALICE Experiment at CERN, All rights reserved.                         *
6 //*                                                                        *
7 //* Primary Authors: Timm Steinbeck <timm@kip.uni-heidelberg.de>           *
8 //*                  for The ALICE HLT Project.                            *
9 //*                                                                        *
10 //* Permission to use, copy, modify and distribute this software and its   *
11 //* documentation strictly for non-commercial purposes is hereby granted   *
12 //* without fee, provided that the above copyright notice appears in all   *
13 //* copies and that both the copyright notice and this permission notice   *
14 //* appear in the supporting documentation. The authors make no claims     *
15 //* about the suitability of this software for any purpose. It is          *
16 //* provided "as is" without express or implied warranty.                  *
17 //**************************************************************************
18
19 /** @file   AliHLTTPCCompDumpComponent.cxx
20     @author Timm Steinbeck
21     @date   10-08-2006
22     @brief  A copy processing component for the HLT
23             that writes the results of the Vestbo compression
24             components to humanly readable files 
25 */
26
27 #if __GNUC__ >= 3
28 using namespace std;
29 #endif
30
31 #include "AliHLTTPCCompDumpComponent.h"
32 #include "AliHLTTPCDefinitions.h"
33 #include "AliHLTTPCTrackletDataFormat.h"
34 #include "AliHLTTPCClusterDataFormat.h"
35 #include "AliHLTTPCModels.h"
36 #include "AliHLTTPCTransform.h"
37 #include "AliHLTTPCCompDataCompressorHelper.h"
38 #include <stdlib.h>
39 #include <errno.h>
40
41 // this is a global object used for automatic component registration, do not use this
42 AliHLTTPCCompDumpComponent gAliHLTTPCCompClusterDumpComponent;
43
44 ClassImp(AliHLTTPCCompDumpComponent)
45     
46 AliHLTTPCCompDumpComponent::AliHLTTPCCompDumpComponent()
47   :
48   fBitDataCurrentWord(0),
49   fBitDataCurrentPosInWord(0),
50   fBitDataCurrentInput(NULL),
51   fBitDataCurrentInputStart(NULL),
52   fBitDataCurrentInputEnd(NULL)
53     {
54       // see header file for class documentation
55     }
56
57 AliHLTTPCCompDumpComponent::~AliHLTTPCCompDumpComponent()
58     {
59       // see header file for class documentation
60     }
61
62 const char* AliHLTTPCCompDumpComponent::GetComponentID() 
63     {
64       // see header file for class documentation
65     return "TPCCompDump"; // The ID of this component
66     }
67
68 void AliHLTTPCCompDumpComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list) 
69     {
70       // see header file for class documentation
71       list.clear(); // We do not have any requirements for our input data type(s).
72       list.push_back( AliHLTTPCDefinitions::fgkClustersDataType );
73       list.push_back( AliHLTTPCDefinitions::fgkTrackSegmentsDataType );
74       list.push_back( AliHLTTPCDefinitions::fgkTracksDataType );
75       list.push_back( AliHLTTPCDefinitions::fgkClusterTracksModelDataType );
76       list.push_back( AliHLTTPCDefinitions::fgkRemainingClustersModelDataType );
77     }
78
79 AliHLTComponent_DataType AliHLTTPCCompDumpComponent::GetOutputDataType()
80     {
81       // see header file for class documentation
82       return AliHLTTPCDefinitions::fgkClusterTracksModelDataType;
83     }
84
85 void AliHLTTPCCompDumpComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) 
86     {
87       // see header file for class documentation
88       constBase = 0;
89       inputMultiplier = 1.;
90       //#warning Adapt input Multiplier to something more realistic
91     }
92
93
94 // Spawn function, return new instance of this class
95 AliHLTComponent* AliHLTTPCCompDumpComponent::Spawn()
96     {
97       // see header file for class documentation
98       return new AliHLTTPCCompDumpComponent;
99     }
100
101 void AliHLTTPCCompDumpComponent::InitBitDataInput( AliHLTUInt8_t* input, UInt_t inputSize )
102     {
103       // see header file for class documentation
104       fBitDataCurrentWord = 0;
105       fBitDataCurrentPosInWord = 7;
106       fBitDataCurrentInput = fBitDataCurrentInputStart = input;
107       fBitDataCurrentInputEnd = input+inputSize;
108       fBitDataCurrentWord = *fBitDataCurrentInput;
109     }
110
111  bool AliHLTTPCCompDumpComponent::InputBit( AliHLTUInt8_t & value )
112     {
113       // see header file for class documentation
114       if ( fBitDataCurrentInput>=fBitDataCurrentInputEnd )
115         return false;
116       value = (fBitDataCurrentWord >> fBitDataCurrentPosInWord) & 1;
117       if ( fBitDataCurrentPosInWord )
118         fBitDataCurrentPosInWord--;
119       else
120         {
121           fBitDataCurrentInput++;
122           if ( fBitDataCurrentInput<fBitDataCurrentInputEnd )
123             {
124               fBitDataCurrentWord = *fBitDataCurrentInput;
125               fBitDataCurrentPosInWord = 7;
126             }
127         }
128       return true;
129     }
130
131 bool AliHLTTPCCompDumpComponent::InputBits( AliHLTUInt8_t & value, UInt_t const & bitCount )
132     {
133       // see header file for class documentation
134       if ( bitCount>8 )
135         {
136           HLTFatal( "Internal error: Attempt to write more than 32 bits (%u)", (unsigned)bitCount );
137           return false;
138         }
139       AliHLTUInt64_t temp;
140       if ( !InputBits( temp, bitCount ) )
141         return false;
142       value = (AliHLTUInt8_t)( temp & (AliHLTUInt64_t)0xFFFFFFFFULL );
143       return true;
144     }
145
146 bool AliHLTTPCCompDumpComponent::InputBits( AliHLTUInt16_t & value, UInt_t const & bitCount )
147    {
148      // see header file for class documentation
149      if ( bitCount>16 )
150        {
151          HLTFatal( "Internal error: Attempt to write more than 32 bits (%u)", (unsigned)bitCount );
152          return false;
153        }
154      AliHLTUInt64_t temp;
155      if ( !InputBits( temp, bitCount ) )
156        return false;
157      value = (AliHLTUInt16_t)( temp & (AliHLTUInt64_t)0xFFFFFFFFULL );
158      return true;
159    }
160
161 bool AliHLTTPCCompDumpComponent::InputBits( AliHLTUInt32_t & value, UInt_t const & bitCount )
162    {
163      // see header file for class documentation
164      if ( bitCount>32 )          
165        {         
166          HLTFatal( "Internal error: Attempt to write more than 32 bits (%u)", (unsigned)bitCount );      
167          return false;   
168        }         
169      AliHLTUInt64_t temp;        
170      if ( !InputBits( temp, bitCount ) )         
171        return false;     
172      value = (AliHLTUInt32_t)( temp & (AliHLTUInt64_t)0xFFFFFFFFULL );   
173      return true;        
174    }
175
176 bool AliHLTTPCCompDumpComponent::InputBits( Int_t & value, UInt_t const & bitCount )
177    {
178      // see header file for class documentation
179      if ( bitCount>32 )
180        {
181          HLTFatal( "Internal error: Attempt to write more than 32 bits (%u)", (unsigned)bitCount );
182          return false;
183        }
184      AliHLTUInt64_t temp;
185      if ( !InputBits( temp, bitCount ) )
186        return false;
187      value = (Int_t)( temp & (AliHLTUInt64_t)0xFFFFFFFFULL );
188      return true;
189    }
190
191 bool AliHLTTPCCompDumpComponent::InputBits( AliHLTUInt64_t & value, UInt_t const & bitCount )
192    {
193      // see header file for class documentation
194      if ( bitCount>64 )
195        {
196          HLTFatal( "Internal error: Attempt to write more than 64 bits (%u)", (unsigned)bitCount );
197          return false;
198        }
199      UInt_t bitsToRead=bitCount;
200      UInt_t curBitCount;
201      value = 0;
202      while ( bitsToRead>0 )
203        {
204          if ( fBitDataCurrentInput>=fBitDataCurrentInputEnd )
205            return false;
206          if ( bitsToRead >= fBitDataCurrentPosInWord+1 )
207            curBitCount = fBitDataCurrentPosInWord+1;
208          else
209            curBitCount = bitsToRead;
210          value = (value << curBitCount) | ( (fBitDataCurrentWord >> (fBitDataCurrentPosInWord-curBitCount+1)) & ((1 << curBitCount)-1) );
211          if ( fBitDataCurrentPosInWord < curBitCount )
212            {
213              fBitDataCurrentInput++;
214              if ( fBitDataCurrentInput<fBitDataCurrentInputEnd )
215                {
216                  fBitDataCurrentWord = *fBitDataCurrentInput;
217                  fBitDataCurrentPosInWord = 7;
218                }
219            }
220          else
221            fBitDataCurrentPosInWord -= curBitCount;
222          bitsToRead -= curBitCount;
223        }
224      return true;
225    }
226
227 void AliHLTTPCCompDumpComponent::Pad8Bits()
228    {
229      // see header file for class documentation
230      if ( fBitDataCurrentPosInWord == 7 )
231        return;
232      fBitDataCurrentInput++;
233      if ( fBitDataCurrentInput<fBitDataCurrentInputEnd )
234        {
235          fBitDataCurrentWord = *fBitDataCurrentInput;
236          fBitDataCurrentPosInWord = 7;
237        }
238    }
239
240 bool AliHLTTPCCompDumpComponent::InputBytes( AliHLTUInt8_t* data, UInt_t const & byteCount )
241    {
242      // see header file for class documentation
243      Pad8Bits();
244      if ( fBitDataCurrentInput+byteCount>fBitDataCurrentInputEnd )
245        return false;
246      memcpy( data, fBitDataCurrentInput, byteCount );
247      fBitDataCurrentInput += byteCount;
248      if ( fBitDataCurrentInput<fBitDataCurrentInputEnd )
249        {
250          fBitDataCurrentWord = *fBitDataCurrentInput;
251          fBitDataCurrentPosInWord = 7;
252        }
253      return true;
254    }
255
256 int AliHLTTPCCompDumpComponent::DoInit( int argc, const char** argv )
257     {
258       // see header file for class documentation
259       //char* cpErr;
260       if ( argc )
261         {
262           Logging( kHLTLogDebug, "HLT::TPCCompDump::DoInit", "Arguments", "argv[0] == %s", argv[0] );
263           Logging(kHLTLogError, "HLT::TPCCompDump::DoInit", "Unknown Option", "Unknown option '%s'", argv[0] );
264           return EINVAL;
265         }
266       return 0;
267     }
268
269 int AliHLTTPCCompDumpComponent::DoDeinit()
270     {
271       // see header file for class documentation
272       return 0;
273     }
274
275 int AliHLTTPCCompDumpComponent::DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
276                                                    AliHLTComponent_TriggerData& /*trigData*/, AliHLTUInt8_t* , 
277                                       AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>&  )
278     {
279       // see header file for class documentation
280       // Process an event
281       // Loop over all input blocks in the event
282       for ( unsigned long n = 0; n < evtData.fBlockCnt; n++ )
283         {
284           AliHLTUInt8_t slice, patch;
285           if ( blocks[n].fDataType == AliHLTTPCDefinitions::fgkClustersDataType )
286             {
287               slice = AliHLTTPCDefinitions::GetMinSliceNr( blocks[n].fSpecification );
288               patch = AliHLTTPCDefinitions::GetMinPatchNr( blocks[n].fSpecification );
289               AliHLTTPCClusterData* clusters = (AliHLTTPCClusterData*)blocks[n].fPtr;
290               HLTInfo( "Cluster block slice %u - patch %u - %lu clusters", (unsigned)slice, (unsigned)patch, (unsigned long)clusters->fSpacePointCnt );
291               for ( unsigned long ii=0; ii<clusters->fSpacePointCnt; ii++ )
292                 {
293                   HLTInfo( "  Cluster % 5lu: fX: %f - fY: %f - fZ: %f - fZ - fID: %u (0x%08X) - fPadRow: %u - fSigmaY2: %f - fSigmaZ2: %f - fCharge: %u - fUsed: %s - fTrackN: %d", 
294                            ii, clusters->fSpacePoints[ii].fX, clusters->fSpacePoints[ii].fY, clusters->fSpacePoints[ii].fZ, clusters->fSpacePoints[ii].fID, clusters->fSpacePoints[ii].fID, (unsigned)clusters->fSpacePoints[ii].fPadRow, clusters->fSpacePoints[ii].fSigmaY2, clusters->fSpacePoints[ii].fSigmaZ2, clusters->fSpacePoints[ii].fCharge, (clusters->fSpacePoints[ii].fUsed ? "yes" : "no"), clusters->fSpacePoints[ii].fTrackN );
295 #if 0
296                   Float_t xyzG[3] = { clusters->fSpacePoints[ii].fX, clusters->fSpacePoints[ii].fY, clusters->fSpacePoints[ii].fZ };
297                   Float_t xyzR[3] = { clusters->fSpacePoints[ii].fX, clusters->fSpacePoints[ii].fY, clusters->fSpacePoints[ii].fZ };
298                   AliHLTTPCTransform::LocHLT2Global( xyzG, slice, clusters->fSpacePoints[ii].fPadRow );
299                   AliHLTTPCTransform::LocHLT2Raw( xyzG, slice, clusters->fSpacePoints[ii].fPadRow );
300                   HLTInfo( "         Global: fX: %f - fY: %f - fZ: %f - fZ", 
301                            xyzG[0], xyzG[1], xyzG[2] );
302                   HLTInfo( "            Raw: fX: %f - fY: %f - fZ: %f - fZ", 
303                            xyzR[0], xyzR[1], xyzR[2] );
304 #endif
305                 }
306               HLTInfo( "" );
307             }
308           if ( blocks[n].fDataType == AliHLTTPCDefinitions::fgkTrackSegmentsDataType ||
309                blocks[n].fDataType == AliHLTTPCDefinitions::fgkTracksDataType)
310             {
311               //fConverter.SetInputTracks( (AliHLTTPCTrackletData*)blocks[n].fPtr );
312               AliHLTUInt8_t minSlice=0xFF, maxSlice=0xFF, minPatch=0xFF, maxPatch=0xFF;
313               minSlice = AliHLTTPCDefinitions::GetMinSliceNr( blocks[n].fSpecification );
314               maxSlice = AliHLTTPCDefinitions::GetMaxSliceNr( blocks[n].fSpecification );
315               minPatch = AliHLTTPCDefinitions::GetMinPatchNr( blocks[n].fSpecification );
316               maxPatch = AliHLTTPCDefinitions::GetMaxPatchNr( blocks[n].fSpecification );
317               AliHLTTPCTrackletData* tracks = (AliHLTTPCTrackletData*)blocks[n].fPtr;
318               AliHLTTPCTrackSegmentData* tracklet = tracks->fTracklets;
319               HLTInfo( "Track block slices %u-%u - patches %u-%u - %lu tracks", 
320                        (unsigned)minSlice, (unsigned)maxSlice, (unsigned)minPatch, (unsigned)maxPatch,
321                        (unsigned long)tracks->fTrackletCnt );
322               for ( unsigned long ii=0; ii<tracks->fTrackletCnt; ii++ )
323                 {
324                   HLTInfo( "  Track % 5lu: fX: %f - fY: %f - fZ: %f - fLastX: %f - fLastY: %f - fLastZ: %f - fPt: %f - fPsi: %f - fTgl: %f - fPterr: %f - fPsierr: %f - fTglerr: %f - fCharge: %d - fNPoints: %u", 
325                            ii, tracklet->fX, tracklet->fY, tracklet->fZ, tracklet->fLastX, tracklet->fLastY, tracklet->fLastZ, tracklet->fPt, tracklet->fPsi, tracklet->fTgl, tracklet->fPterr, tracklet->fPsierr, tracklet->fTglerr, tracklet->fCharge, tracklet->fNPoints );
326                   for ( unsigned long jj=0; jj<tracklet->fNPoints; jj++ )
327                     {
328                       HLTInfo( "    Point % 5lu: %   8u / 0x%08X", jj, tracklet->fPointIDs[jj], tracklet->fPointIDs[jj] );
329                     }
330                   tracklet = (AliHLTTPCTrackSegmentData*) ( ((AliHLTUInt8_t*)tracklet)+sizeof(AliHLTTPCTrackSegmentData)+tracklet->fNPoints*sizeof(UInt_t) );
331                 }
332               
333             }
334           if ( blocks[n].fDataType == AliHLTTPCDefinitions::fgkClusterTracksModelDataType )
335             {
336               AliHLTUInt8_t minSlice=0xFF, maxSlice=0xFF, minPatch=0xFF, maxPatch=0xFF;
337               minSlice = AliHLTTPCDefinitions::GetMinSliceNr( blocks[n].fSpecification );
338               maxSlice = AliHLTTPCDefinitions::GetMaxSliceNr( blocks[n].fSpecification );
339               minPatch = AliHLTTPCDefinitions::GetMinPatchNr( blocks[n].fSpecification );
340               maxPatch = AliHLTTPCDefinitions::GetMaxPatchNr( blocks[n].fSpecification );
341               unsigned long trackletCount = (blocks[n].fSize-sizeof(AliHLTUInt32_t)) / (sizeof(AliHLTTPCTrackModel)+AliHLTTPCTransform::GetNRows()*sizeof(AliHLTTPCClusterModel) );
342               HLTInfo( "Track model block version %u slices %u-%u - patches %u-%u - %lu tracks", 
343                        (unsigned)*(AliHLTUInt32_t*)blocks[n].fPtr,
344                        (unsigned)minSlice, (unsigned)maxSlice, (unsigned)minPatch, (unsigned)maxPatch,
345                        (unsigned long)trackletCount );
346               AliHLTTPCTrackModel* trackModel = (AliHLTTPCTrackModel*)(((AliHLTUInt8_t*)blocks[n].fPtr)+sizeof(AliHLTUInt32_t));
347               for ( unsigned long ii=0; ii<trackletCount; ii++ )
348                 {
349                   unsigned clusterCount=0;
350                   AliHLTTPCClusterModel* clusters = (AliHLTTPCClusterModel*) ( ((AliHLTUInt8_t*)trackModel)+sizeof(AliHLTTPCTrackModel) );
351                   for ( unsigned long jj=0; jj<(unsigned long)AliHLTTPCTransform::GetNRows(); jj++ )
352                     {
353                       if ( clusters[jj].fPresent )
354                         clusterCount++;
355                     }
356                   HLTInfo( "  Track Model % 5lu fKappa: %f - fPhi: %f - fD: %f - fZ0: %f - fTgl: %f - #clusters: %u",
357                           ii, trackModel->fKappa, trackModel->fPhi, trackModel->fD, trackModel->fZ0, trackModel->fTgl, clusterCount );
358                   clusterCount=0;
359                   for ( unsigned long jj=0; jj<(unsigned long)AliHLTTPCTransform::GetNRows(); jj++ )
360                     {
361                       if ( clusters[jj].fPresent )
362                         {
363 #ifdef MODELDEBUG
364                           HLTInfo( "    Cluster % 05u: fID: %u (0x%08X) - fDTime: %f - fDPad: %f - fDCharge: %f - fDSigmaY: %f - fDSigmaZ: %f - fNPads: %u - fSlice: %hd - padrow: %lu - fPresent: %u",
365                                    clusterCount, clusters[jj].fID, clusters[jj].fID, clusters[jj].fDTime, clusters[jj].fDPad, clusters[jj].fDCharge, clusters[jj].fDSigmaY, clusters[jj].fDSigmaZ, clusters[jj].fNPads, clusters[jj].fSlice, jj, (unsigned)clusters[jj].fPresent );
366 #else
367                           HLTInfo( "    Cluster % 05u: fDTime: %f - fDPad: %f - fDCharge: %f - fDSigmaY: %f - fDSigmaZ: %f - fNPads: %u - fSlice: %hd - padrow: %lu - fPresent: %u",
368                                    clusterCount, clusters[jj].fDTime, clusters[jj].fDPad, clusters[jj].fDCharge, clusters[jj].fDSigmaY, clusters[jj].fDSigmaZ, clusters[jj].fNPads, clusters[jj].fSlice, jj, (unsigned)clusters[jj].fPresent );
369 #endif
370                           clusterCount++;
371                         }
372                     }
373                   
374                   trackModel = (AliHLTTPCTrackModel*) ( ((AliHLTUInt8_t*)trackModel)+sizeof(AliHLTTPCTrackModel)+AliHLTTPCTransform::GetNRows()*sizeof(AliHLTTPCClusterModel) );
375                 }
376               
377             }
378           if ( blocks[n].fDataType == AliHLTTPCDefinitions::fgkRemainingClustersModelDataType )
379             {
380               AliHLTUInt8_t minSlice=0xFF, maxSlice=0xFF, minPatch=0xFF, maxPatch=0xFF;
381               minSlice = AliHLTTPCDefinitions::GetMinSliceNr( blocks[n].fSpecification );
382               maxSlice = AliHLTTPCDefinitions::GetMaxSliceNr( blocks[n].fSpecification );
383               minPatch = AliHLTTPCDefinitions::GetMinPatchNr( blocks[n].fSpecification );
384               maxPatch = AliHLTTPCDefinitions::GetMaxPatchNr( blocks[n].fSpecification );
385               unsigned long clusterCount=0;
386               HLTInfo( "Remaining cluster model block version %u", 
387                        (unsigned)*(AliHLTUInt32_t*)blocks[n].fPtr );
388               AliHLTUInt8_t* readPtr = (AliHLTUInt8_t*)(((AliHLTUInt8_t*)blocks[n].fPtr)+sizeof(AliHLTUInt32_t));
389               for(Int_t slice=0; slice<36; slice++)
390                 {
391                   for(Int_t patch=0; patch < 6; patch++)
392                     {
393                       if ( !readPtr )
394                         {
395                           readPtr++;
396                           continue;
397                         }
398                       unsigned rows = (unsigned)*readPtr;
399                       readPtr++;
400                       for ( unsigned ii=0; ii<rows; ii++ )
401                         {
402                           AliHLTTPCRemainingRow* thisRow = (AliHLTTPCRemainingRow*)readPtr;
403                           clusterCount += thisRow->fNClusters;
404                           readPtr += sizeof(AliHLTTPCRemainingRow) + thisRow->fNClusters*sizeof(AliHLTTPCRemainingCluster);
405                         }
406                     }
407                 }
408               HLTInfo( "Remaining cluster model block slices %u-%u - patches %u-%u - %lu clusters", 
409                        (unsigned)minSlice, (unsigned)maxSlice, (unsigned)minPatch, (unsigned)maxPatch,
410                        clusterCount );
411               readPtr = (AliHLTUInt8_t*)(((AliHLTUInt8_t*)blocks[n].fPtr)+sizeof(AliHLTUInt32_t));
412               clusterCount = 0;
413               for(Int_t slice=0; slice<36; slice++)
414                 {
415                   for(Int_t patch=0; patch < 6; patch++)
416                     {
417                       if ( !readPtr )
418                         {
419                           readPtr++;
420                           continue;
421                         }
422                       unsigned rows = (unsigned)*readPtr;
423                       readPtr++;
424                       if ( rows )
425                         HLTInfo( "  Slice %d - Partition %d", slice, patch );
426                       for ( unsigned ii=0; ii<rows; ii++ )
427                         {
428                           AliHLTTPCRemainingRow* thisRow = (AliHLTTPCRemainingRow*)readPtr;
429                           for ( unsigned jj=0; jj<thisRow->fNClusters; jj++ )
430                             {
431 #ifdef MODELDEBUG
432                               HLTInfo( "    Cluster % 5lu: fID: %u (0x%08X) - fPadRow: %u - fPad: %f - fTime: %f - fSigmaY2: %f - fSigmaZ2: %f - fCharge: %hu",
433                                        clusterCount, thisRow->fClusters[jj].fID, thisRow->fClusters[jj].fID, (unsigned)thisRow->fPadRow, thisRow->fClusters[jj].fPad, thisRow->fClusters[jj].fTime, thisRow->fClusters[jj].fSigmaY2, thisRow->fClusters[jj].fSigmaZ2, thisRow->fClusters[jj].fCharge );
434 #else
435                               HLTInfo( "    Cluster % 5lu: fPadRow: %u - fPad: %f - fTime: %f - fSigmaY2: %f - fSigmaZ2: %f - fCharge: %hu",
436                                        clusterCount, (unsigned)thisRow->fPadRow, thisRow->fClusters[jj].fPad, thisRow->fClusters[jj].fTime, thisRow->fClusters[jj].fSigmaY2, thisRow->fClusters[jj].fSigmaZ2, thisRow->fClusters[jj].fCharge );
437 #endif
438                             }
439                           readPtr += sizeof(AliHLTTPCRemainingRow) + thisRow->fNClusters*sizeof(AliHLTTPCRemainingCluster);
440                         }
441                     }
442                 }
443             }
444           if ( blocks[n].fDataType == AliHLTTPCDefinitions::fgkClusterTracksCompressedDataType )
445             {
446               AliHLTUInt8_t minSlice=0xFF, maxSlice=0xFF, minPatch=0xFF, maxPatch=0xFF;
447               minSlice = AliHLTTPCDefinitions::GetMinSliceNr( blocks[n].fSpecification );
448               maxSlice = AliHLTTPCDefinitions::GetMaxSliceNr( blocks[n].fSpecification );
449               minPatch = AliHLTTPCDefinitions::GetMinPatchNr( blocks[n].fSpecification );
450               maxPatch = AliHLTTPCDefinitions::GetMaxPatchNr( blocks[n].fSpecification );
451               HLTInfo( "Track model block slices %u-%u - patches %u-%u", 
452                       (unsigned)minSlice, (unsigned)maxSlice, (unsigned)minPatch, (unsigned)maxPatch );
453               InitBitDataInput( (AliHLTUInt8_t*)blocks[n].fPtr, blocks[n].fSize );
454               HLTInfo( "Input position: %lu / %u (0x%02X)", GetCurrentByteInputPosition(), GetCurrentBitInputPosition(), (unsigned)GetCurrentInputByte() );
455               AliHLTUInt8_t version;
456               if ( !InputBits( version, 4 ) ) // Version information
457                 {
458                   HLTError( "Corrupt input data. Cannot read data version number at position %lu / %u",
459                             GetCurrentByteInputPosition(), GetCurrentBitInputPosition() );
460                   continue;
461                 }
462               HLTInfo( "Data Format Version: %u", (unsigned)version );
463               HLTInfo( "Input position: %lu / %u (0x%02X)", GetCurrentByteInputPosition(), GetCurrentBitInputPosition(), (unsigned)GetCurrentInputByte() );
464               AliHLTUInt8_t readShape;
465               if ( !InputBit( readShape ) ) // Data format flag
466                 {
467                   HLTError( "Corrupt input data. Cannot read shape flag at position %lu / %u",
468                           GetCurrentByteInputPosition(), GetCurrentBitInputPosition() );
469                   continue;
470                 }
471               HLTInfo( "Read shape: %s (%u)", (readShape ? "yes" : "no"), (unsigned)readShape );
472               HLTInfo( "Input position: %lu / %u (0x%02X)", GetCurrentByteInputPosition(), GetCurrentBitInputPosition(), (unsigned)GetCurrentInputByte() );
473               Pad8Bits();
474               HLTInfo( "Input position: %lu / %u (0x%02X)", GetCurrentByteInputPosition(), GetCurrentBitInputPosition(), (unsigned)GetCurrentInputByte() );
475               
476               
477               
478               bool inputError=false;
479               unsigned trackCount=0;
480               
481               while ( !EndOfBitInput() )
482                 {
483                   AliHLTTPCTrackModel trackModel;
484                   memset( &trackModel, 0, sizeof(trackModel) );
485                   if ( !InputBytes( (AliHLTUInt8_t*)&trackModel, sizeof(AliHLTTPCTrackModel) ) )
486                     {
487                       HLTError( "Corrupt input data. Cannot read track model data at position %lu / %u",
488                                 GetCurrentByteInputPosition(), GetCurrentBitInputPosition() );
489                       inputError = true;
490                       break;
491                     }
492                   HLTInfo( "  Track Model % 5lu fKappa: %f - fPhi: %f - fD: %f - fZ0: %f - fTgl: %f",
493                            trackCount, trackModel.fKappa, trackModel.fPhi, trackModel.fD, trackModel.fZ0, trackModel.fTgl );
494                   HLTInfo( "Input position: %lu / %u (0x%02X)", GetCurrentByteInputPosition(), GetCurrentBitInputPosition(), (unsigned)GetCurrentInputByte() );
495                   
496                   Int_t clustercount=0;
497                   for(Int_t i=0; i<AliHLTTPCTransform::GetNRows(); i++)
498                     {
499                       AliHLTTPCClusterModel cluster;
500                       memset( &cluster, 0, sizeof(cluster) );
501                       AliHLTUInt8_t present;
502                       if ( !InputBit( present ) )
503                         {
504                           HLTError( "Corrupt input data. Cannot read  cluster presence bit at position %lu / %u",
505                                     GetCurrentByteInputPosition(), GetCurrentBitInputPosition() );
506                           inputError = true;
507                           break;
508                         }
509                       HLTInfo( "Cluster %u present: %s (%u)", (unsigned)i, (present ? "yes" : "no"), (unsigned)present );
510                       HLTInfo( "Input position: %lu / %u (0x%02X)", GetCurrentByteInputPosition(), GetCurrentBitInputPosition(), (unsigned)GetCurrentInputByte() );
511                       cluster.fPresent = present;
512                       if ( !present )
513                         continue;
514                       if ( clustercount==0 )
515                         {
516                           if ( !InputBits( slice,6 ) ) //Need 6 bits to encode slice number
517                             {
518                               HLTError( "Corrupt input data. Cannot read  cluster slice number at position %lu / %u",
519                                         GetCurrentByteInputPosition(), GetCurrentBitInputPosition() );
520                               inputError = true;
521                               break;
522                             }
523                           HLTInfo( "First cluster slice: %u", (unsigned)slice );
524                           HLTInfo( "Input position: %lu / %u (0x%02X)", GetCurrentByteInputPosition(), GetCurrentBitInputPosition(), (unsigned)GetCurrentInputByte() );
525                         }
526                       else
527                         {
528                         AliHLTUInt8_t sliceChange;
529                         if ( !InputBit( sliceChange ) )
530                             {
531                               HLTError( "Corrupt input data. Cannot read cluster slice change bit at position %lu / %u",
532                                       GetCurrentByteInputPosition(), GetCurrentBitInputPosition() );
533                               inputError = true;
534                             break;
535                             }
536                         HLTInfo( "Slice change: %s (%u)", (sliceChange ? "yes" : "no"), (unsigned)sliceChange );
537                         HLTInfo( "Input position: %lu / %u (0x%02X)", GetCurrentByteInputPosition(), GetCurrentBitInputPosition(), (unsigned)GetCurrentInputByte() );
538                         if ( sliceChange )
539                           {  //Change of slice
540                             if ( !InputBits( slice, 6 ) )
541                               {
542                                 HLTError( "Corrupt input data. Cannot read  cluster slice number at position %lu / %u",
543                                           GetCurrentByteInputPosition(), GetCurrentBitInputPosition() );
544                                 inputError = true;
545                                 break;
546                                 }
547                             HLTInfo( "Changed cluster slice: %u", (unsigned)slice );
548                             HLTInfo( "Input position: %lu / %u (0x%02X)", GetCurrentByteInputPosition(), GetCurrentBitInputPosition(), (unsigned)GetCurrentInputByte() );
549                           }
550                         }
551                     HLTInfo( "Slice. %d", slice );
552                     cluster.fSlice = slice;
553                     if ( cluster.fSlice<0 || cluster.fSlice>35 )
554                         {
555                           HLTError( "Inconsistent slice number %u (track %u, cluster %d)", cluster.fSlice, trackCount, i );
556                           inputError = true;
557                           break;
558                         }
559                     AliHLTUInt8_t signBit;
560                     Int_t sign;
561                     AliHLTUInt64_t temp;
562                     Int_t val;
563                     //Read time information:
564                     if ( !InputBit( signBit ) )
565                       {
566                         HLTError( "Corrupt input data. Cannot read DTime sign bit at position %lu / %u",
567                                   GetCurrentByteInputPosition(), GetCurrentBitInputPosition() );
568                         inputError = true;
569                         break;
570                       }
571                     HLTInfo( "Input position: %lu / %u (0x%02X)", GetCurrentByteInputPosition(), GetCurrentBitInputPosition(), (unsigned)GetCurrentInputByte() );
572                     sign = signBit;
573                     sign = -1+sign*2;
574                     if ( !InputBits( temp, AliHLTTPCCompDataCompressorHelper::GetNTimeBits()-1 ) )
575                       {
576                         HLTError( "Corrupt input data. Cannot read DTime data at position %lu / %u",
577                                   GetCurrentByteInputPosition(), GetCurrentBitInputPosition() );
578                         inputError = true;
579                         break;
580                       }
581                     HLTInfo( "Input position: %lu / %u (0x%02X)", GetCurrentByteInputPosition(), GetCurrentBitInputPosition(), (unsigned)GetCurrentInputByte() );
582                     val = (Int_t)temp;
583                     cluster.fDTime = val*sign;
584                     
585                     
586                     //Read pad information:
587                     if ( !InputBit( signBit ) )
588                       {
589                         HLTError( "Corrupt input data. Cannot read DPad sign bit at position %lu / %u",
590                                   GetCurrentByteInputPosition(), GetCurrentBitInputPosition() );
591                         inputError = true;
592                         break;
593                       }
594                     HLTInfo( "Input position: %lu / %u (0x%02X)", GetCurrentByteInputPosition(), GetCurrentBitInputPosition(), (unsigned)GetCurrentInputByte() );
595                     sign = signBit;
596                     sign = -1+sign*2;
597                     if ( !InputBits( temp, AliHLTTPCCompDataCompressorHelper::GetNPadBits()-1 ) )
598                       {
599                         HLTError( "Corrupt input data. Cannot read DPad data at position %lu / %u",
600                                   GetCurrentByteInputPosition(), GetCurrentBitInputPosition() );
601                         inputError = true;
602                         break;
603                       }
604                     HLTInfo( "Input position: %lu / %u (0x%02X)", GetCurrentByteInputPosition(), GetCurrentBitInputPosition(), (unsigned)GetCurrentInputByte() );
605                     val = (Int_t)temp;
606                     cluster.fDPad = val*sign;
607                     
608                     // Read charge information:
609                     if ( !InputBits( temp, AliHLTTPCCompDataCompressorHelper::GetNChargeBits() ) )
610                       {
611                         HLTError( "Corrupt input data. Cannot read charge data at position %lu / %u",
612                                   GetCurrentByteInputPosition(), GetCurrentBitInputPosition() );
613                         inputError = true;
614                         break;
615                       }
616                     HLTInfo( "Input position: %lu / %u (0x%02X)", GetCurrentByteInputPosition(), GetCurrentBitInputPosition(), (unsigned)GetCurrentInputByte() );
617                     cluster.fDCharge = temp;
618                     
619                     if ( readShape )
620                       {
621                         // Read shape information:
622                         if ( !InputBit( signBit ) )
623                           {
624                             HLTError( "Corrupt input data. Cannot read DSigmaY sign bit at position %lu / %u",
625                                       GetCurrentByteInputPosition(), GetCurrentBitInputPosition() );
626                             inputError = true;
627                             break;
628                           }
629                         HLTInfo( "Input position: %lu / %u (0x%02X)", GetCurrentByteInputPosition(), GetCurrentBitInputPosition(), (unsigned)GetCurrentInputByte() );
630                         sign = signBit;
631                         sign = -1+sign*2;
632                         if ( !InputBits( temp, AliHLTTPCCompDataCompressorHelper::GetNShapeBits()-1 ) )
633                           {
634                             HLTError( "Corrupt input data. Cannot read DSigmaY data at position %lu / %u",
635                                       GetCurrentByteInputPosition(), GetCurrentBitInputPosition() );
636                             inputError = true;
637                             break;
638                           }
639                         HLTInfo( "Input position: %lu / %u (0x%02X)", GetCurrentByteInputPosition(), GetCurrentBitInputPosition(), (unsigned)GetCurrentInputByte() );
640                         val = (Int_t)temp;
641                         cluster.fDSigmaY = val*sign;
642                         
643                         if ( !InputBit( signBit ) )
644                           {
645                             HLTError( "Corrupt input data. Cannot read DSigmaZ sign bit at position %lu / %u",
646                                       GetCurrentByteInputPosition(), GetCurrentBitInputPosition() );
647                             inputError = true;
648                             break;
649                           }
650                         HLTInfo( "Input position: %lu / %u (0x%02X)", GetCurrentByteInputPosition(), GetCurrentBitInputPosition(), (unsigned)GetCurrentInputByte() );
651                         sign = signBit;
652                         sign = -1+sign*2;
653                         if ( !InputBits( temp, AliHLTTPCCompDataCompressorHelper::GetNShapeBits()-1 ) )
654                           {
655                             HLTError( "Corrupt input data. Cannot read DSigmaZ data at position %lu / %u",
656                                       GetCurrentByteInputPosition(), GetCurrentBitInputPosition() );
657                             inputError = true;
658                             break;
659                           }
660                         HLTInfo( "Input position: %lu / %u (0x%02X)", GetCurrentByteInputPosition(), GetCurrentBitInputPosition(), (unsigned)GetCurrentInputByte() );
661                         val = (Int_t)temp;
662                         cluster.fDSigmaZ = val*sign;
663                       }
664                     
665                     
666                     HLTInfo( "    Cluster % 05u: fDTime: %f - fDPad: %f - fDCharge: %f - fDSigmaY: %f - fDSigmaZ: %f - fNPads: %u - fSlice: %hd - padrow: %lu - fPresent: %u",
667                              clustercount, cluster.fDTime, cluster.fDPad, cluster.fDCharge, cluster.fDSigmaY, cluster.fDSigmaZ, cluster.fNPads, cluster.fSlice, (unsigned long)i, (unsigned)cluster.fPresent );
668                     
669                     
670                     clustercount++;
671                     
672                     
673                     }
674                   if ( inputError )
675                     break;
676                   Pad8Bits();
677                   HLTInfo( "Input position: %lu / %u (0x%02X)", GetCurrentByteInputPosition(), GetCurrentBitInputPosition(), (unsigned)GetCurrentInputByte() );
678                   
679                   trackCount++;
680                 }
681               if ( inputError )
682                 continue;
683               
684             }
685           if ( blocks[n].fDataType == AliHLTTPCDefinitions::fgkRemainingClustersCompressedDataType )
686             {
687               AliHLTUInt8_t* inputPtr = (AliHLTUInt8_t*)blocks[n].fPtr;
688               
689               InitBitDataInput( inputPtr, blocks[n].fSize );
690               AliHLTUInt8_t version;
691               if ( !InputBits( version, 4 ) ) // Version information
692                 {
693                   HLTError( "Corrupt input data. Cannot read data version number at position %u / %u",
694                             (unsigned)GetCurrentByteInputPosition(), (unsigned)GetCurrentBitInputPosition() );
695                   return EIO;
696                 }
697               HLTInfo( "Remaining cluster data version: %u", (unsigned)version );
698               if ( version != 0 )
699                 {
700                   HLTError( "Unsupported version %hu. Only version 0 supported currently.", version );
701                 }
702             Pad8Bits();
703             
704             unsigned long clusterCount=0;
705             for(Int_t slice=0; slice<=35; slice++)
706               {
707                 for(Int_t patch=0; patch < 6; patch++)
708                   {
709                     UInt_t i;
710                     //Write number of padrows with clusters
711                     UInt_t nRows;
712                     if ( !InputBits( nRows, 8 ) )
713                       {
714                         HLTError( "Corrupt input data. Cannot read padrow count at position %u / %u",
715                                   (unsigned)GetCurrentByteInputPosition(), (unsigned)GetCurrentBitInputPosition() );
716                         return EIO;
717                       }
718                     HLTInfo( "slice %u patch %u: %u padrows",
719                              (unsigned)slice, (unsigned)patch, (unsigned)nRows );
720                     if ( !nRows )
721                       {
722                         continue;
723                       }
724                     //HLTInfo( "  Slice %d - Partition %d", slice, patch );
725                     for ( UInt_t jj=0; jj<nRows; jj++ )
726                       {
727                         
728                         UInt_t padrow;
729                         if ( !InputBits(padrow,8) ) //Read padrow #
730                           {
731                             HLTError( "Corrupt input data. Cannot read padrow number at position %u / %u",
732                                       (unsigned)GetCurrentByteInputPosition(), (unsigned)GetCurrentBitInputPosition() );
733                             return EIO;
734                           }
735                         HLTInfo( "Padrow: %u", (unsigned)padrow );
736                         UInt_t nClusters;
737                         if ( !InputBits(nClusters,10) )//Read number of clusters on this padrow
738                           {
739                             HLTError( "Corrupt input data. Cannot read cluster count at position %u / %u",
740                                       (unsigned)GetCurrentByteInputPosition(), (unsigned)GetCurrentBitInputPosition() );
741                             return EIO;
742                           }
743                         HLTInfo( "  #Clusters: %u", (unsigned)nClusters );
744                         for ( i=0; i<nClusters; i++ )
745                             {
746                               //Read pad
747                               AliHLTTPCRemainingCluster cl;
748                               Int_t buff;
749                               if ( !InputBits(buff,AliHLTTPCCompDataCompressorHelper::GetNPadBitsRemaining()) )
750                                 {
751                                   HLTError( "Corrupt input data. Cannot read cluster pad data at position %u / %u",
752                                             (unsigned)GetCurrentByteInputPosition(), (unsigned)GetCurrentBitInputPosition() );
753                                   return EIO;
754                                 }
755                               cl.fPad = (Float_t)( ((double)buff) / AliHLTTPCCompDataCompressorHelper::GetPadPrecisionFactor() );
756                               
757                               //Read time
758                               if ( !InputBits(buff,AliHLTTPCCompDataCompressorHelper::GetNTimeBitsRemaining()) )
759                                 {
760                                   HLTError( "Corrupt input data. Cannot read cluster time data at position %u / %u",
761                                             (unsigned)GetCurrentByteInputPosition(), (unsigned)GetCurrentBitInputPosition() );
762                                   return EIO;
763                                 }
764                               cl.fTime = (Float_t)( ((double)buff) / AliHLTTPCCompDataCompressorHelper::GetTimePrecisionFactor() );
765                               
766                               //Read widths
767                               if ( !InputBits(buff,AliHLTTPCCompDataCompressorHelper::GetNShapeBitsRemaining()) )
768                                 {
769                                   HLTError( "Corrupt input data. Cannot read cluster pad width data at position %u / %u",
770                                             (unsigned)GetCurrentByteInputPosition(), (unsigned)GetCurrentBitInputPosition() );
771                                   return EIO;
772                                 }
773                               Float_t padw = (Float_t)( ((double)buff) / AliHLTTPCCompDataCompressorHelper::GetPadPrecisionFactor() );
774                             cl.fSigmaY2 = padw*padw;
775                             
776                             if ( !InputBits(buff,AliHLTTPCCompDataCompressorHelper::GetNShapeBitsRemaining()) )
777                               {
778                                 HLTError( "Corrupt input data. Cannot read cluster time width data at position %u / %u",
779                                           (unsigned)GetCurrentByteInputPosition(), (unsigned)GetCurrentBitInputPosition() );
780                                 return EIO;
781                               }
782                             Float_t timew = (Float_t)( ((double)buff) / AliHLTTPCCompDataCompressorHelper::GetTimePrecisionFactor() );
783                             cl.fSigmaZ2 = timew*timew;
784                             
785                             //Read charge 
786                             if ( !InputBits(buff,AliHLTTPCCompDataCompressorHelper::GetNChargeBits()) )
787                               {
788                                 HLTError( "Corrupt input data. Cannot read cluster charge data at position %u / %u",
789                                           (unsigned)GetCurrentByteInputPosition(), (unsigned)GetCurrentBitInputPosition() );
790                                 return EIO;
791                               }
792                             cl.fCharge = buff;
793                             
794                             HLTInfo( "  Cluster % 5lu (% 5u): fPadRow: %u - fPad: %f - fTime: %f - fSigmaY2: %f - fSigmaZ2: %f - fCharge: %hu",
795                                      clusterCount, (unsigned)i, (unsigned)padrow, cl.fPad, cl.fTime, cl.fSigmaY2, cl.fSigmaZ2, cl.fCharge );
796                             clusterCount++;
797                             }
798                       }
799                   }
800                 
801               }
802             
803             
804             }
805           
806         }
807       
808       size = 0;
809       return 0;
810     }