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