- moved AliHLTDisplay files from TPCLib to TPCLib/OnlineDisplay
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCDigitReaderRaw.cxx
CommitLineData
db16520a 1// $Id$
2
3/**************************************************************************
4 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * *
6 * Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
7 * Timm Steinbeck <timm@kip.uni-heidelberg.de> *
8 * Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
9 * for The ALICE Off-line Project. *
10 * *
11 * Permission to use, copy, modify and distribute this software and its *
12 * documentation strictly for non-commercial purposes is hereby granted *
13 * without fee, provided that the above copyright notice appears in all *
14 * copies and that both the copyright notice and this permission notice *
15 * appear in the supporting documentation. The authors make no claims *
16 * about the suitability of this software for any purpose. It is *
17 * provided "as is" without express or implied warranty. *
18 **************************************************************************/
19
84645eb0 20/** @file AliHLTTPCDigitReaderRaw.cxx
21 @author Timm Steinbeck
22 @date
23 @brief A digit reader implementation for the RAW data coming from the RCU.
24*/
db16520a 25
26#if __GNUC__>= 3
27using namespace std;
28#endif
29
30#if defined(HAVE_TPC_MAPPING)
31
32#include "AliHLTTPCDigitReaderRaw.h"
33#include "AliHLTTPCTransform.h"
34#include "AliHLTTPCRootTypes.h"
78b557c2 35#include "AliHLTStdIncludes.h"
db16520a 36#include "AliHLTTPCLogging.h"
37
38ClassImp(AliHLTTPCDigitReaderRaw)
39
84645eb0 40AliHLTTPCDigitReaderRaw::AliHLTTPCDigitReaderRaw( unsigned formatVersion )
41 :
42 fBuffer(NULL),
43 fBufferSize(0),
44 fPatch(-1),
45 fSlice(-1),
46 fDataFormatVersion(formatVersion),
47 fCurrentRow(0),
48 fCurrentPad(0),
49 fCurrentBin(-1),
50 fVerify(false),
51
52 // For sorting
53 fNRows(0),
54 fRowOffset(0),
55 fNMaxRows(0),
56 fNMaxPads(0),
57 fNTimeBins(0),
58 fData(NULL)
db16520a 59{
db16520a 60 if ( fDataFormatVersion==0 || fDataFormatVersion==2 )
61 {
62
63 // get max number of rows
64 for (Int_t ii=0; ii < 6; ii++)
65 if (AliHLTTPCTransform::GetNRows(ii) > fNMaxRows)
66 fNMaxRows = AliHLTTPCTransform::GetNRows(ii);
67
68 // get max number of pads
69 for (Int_t ii=0; ii < AliHLTTPCTransform::GetNRows();ii++ )
70 if (AliHLTTPCTransform::GetNPads(ii) > fNMaxPads)
71 fNMaxPads = AliHLTTPCTransform::GetNPads(ii);
72
73 // get max number of bins
74 fNTimeBins = AliHLTTPCTransform::GetNTimeBins();
75
84645eb0 76 HLTDebug("Array Borders ||| MAXPAD=%d ||| MAXROW=%d ||| MAXBIN=%d ||| MAXMUL=%d",
77 fNMaxPads, fNMaxRows, fNTimeBins, fNTimeBins*fNMaxRows*fNMaxPads);
db16520a 78
79 // init Data array
80 fData = new Int_t[ fNMaxRows*fNMaxPads*fNTimeBins ];
81 }
82}
83
84645eb0 84AliHLTTPCDigitReaderRaw::AliHLTTPCDigitReaderRaw(const AliHLTTPCDigitReaderRaw& src)
85 :
86 fBuffer(NULL),
87 fBufferSize(0),
88 fPatch(-1),
89 fSlice(-1),
90 fDataFormatVersion(src.fDataFormatVersion),
91 fCurrentRow(0),
92 fCurrentPad(0),
93 fCurrentBin(-1),
94 fVerify(false),
95
96 // For sorting
97 fNRows(0),
98 fRowOffset(0),
99 fNMaxRows(0),
100 fNMaxPads(0),
101 fNTimeBins(0),
102 fData(NULL)
103{
104 HLTFatal("copy constructor not for use");
105}
106
107AliHLTTPCDigitReaderRaw& AliHLTTPCDigitReaderRaw::operator=(const AliHLTTPCDigitReaderRaw& src)
108{
109 fBuffer=NULL;
110 fBufferSize=0;
111 fPatch=-1;
112 fSlice=-1;
113 fDataFormatVersion=src.fDataFormatVersion;
114 fCurrentRow=0;
115 fCurrentPad=0;
116 fCurrentBin=-1;
117 fVerify=false;
118
119 // For sorting
120 fNRows=0;
121 fRowOffset=0;
122 fNMaxRows=0;
123 fNMaxPads=0;
124 fNTimeBins=0;
125 fData=NULL;
126 HLTFatal("assignment operator not for use");
127 return (*this);
128}
129
db16520a 130AliHLTTPCDigitReaderRaw::~AliHLTTPCDigitReaderRaw(){
131 if ( fDataFormatVersion==0 || fDataFormatVersion==2 )
132 {
133 if ( fData )
134 delete [] fData;
135 fData = NULL;
136 }
137}
138
78b557c2 139int AliHLTTPCDigitReaderRaw::InitBlock(void* ptr,unsigned long size,Int_t firstrow,Int_t lastrow, Int_t patch, Int_t slice) {
140 return AliHLTTPCDigitReader::InitBlock(ptr, size, firstrow, lastrow, patch, slice);
141}
142
84645eb0 143int AliHLTTPCDigitReaderRaw::InitBlock(void* ptr,unsigned long size, Int_t patch, Int_t slice){
db16520a 144
145 fBuffer = (AliHLTUInt8_t*) ptr;
84645eb0 146 if (fBuffer==NULL) {
147 HLTError("invalid data buffer");
148 return -EINVAL;
149 }
db16520a 150 fBufferSize = size;
84645eb0 151 if (fBufferSize<=0) HLTWarning("no data available: zero length buffer");
db16520a 152 fPatch = patch;
153 fSlice = slice;
154 fPad = -1;
155 fRow = -1;
156
157 fAltroBlockPositionBytes = 0;
158 fAltroBlockLengthBytes = 0;
159 fAltroBlock10BitWordCnt = 0xFFFFU;
160 fAltroBlockHWAddress = 0xFFFFU;
161 fBunchPosition = 0xFFFFU;
162 fBunchTimebinStart = ~0U;
163 fBunchLength = 0;
164 fWordInBunch = (unsigned)-1;
165
84645eb0 166 Int_t firstrow=AliHLTTPCTransform::GetFirstRow(patch);
167 Int_t lastrow=AliHLTTPCTransform::GetLastRow(patch);
db16520a 168
169 if ( fDataFormatVersion==0 || fDataFormatVersion==2 )
170 {
171 fCurrentRow = 0;
172 fCurrentPad = 0;
173 fCurrentBin = -1;
174
175 fNRows = lastrow - firstrow + 1;
176
177 Int_t offset=0;
178 if (patch > 1) offset = AliHLTTPCTransform::GetFirstRow( 2 );
179
180 fRowOffset = firstrow - offset;
181 firstrow -= offset;
182 lastrow -= offset;
183
184 // Init array with -1
185 memset( fData, 0xFF, sizeof(Int_t)*(fNMaxRows*fNMaxPads*fNTimeBins) );
84645eb0 186
187 const Int_t maxErrorPrintout=20;
188 Int_t errorCount=0;
189 Int_t entryCount=0;
db16520a 190 // read data and fill in array
84645eb0 191
db16520a 192 while( RealNext()){
84645eb0 193
194 entryCount++;
db16520a 195 Int_t row = GetRealRow();
196 Int_t pad = GetRealPad();
197 Int_t bin = GetRealTime();
198
84645eb0 199// HLTFatal("Index out of array range: PAD=%d ||| ROW=%d ||| BIN=%d ||| OFFSET=%d ||| ROWOFFSET=%d", pad, row, bin, offset, fRowOffset);
db16520a 200
201 if ( row < firstrow || row > lastrow || pad > AliHLTTPCTransform::GetNPads(row + offset) || bin > fNTimeBins || pad<0 || bin<0){
202// if ( row < firstrow || row > lastrow || pad > AliHLTTPCTransform::GetNPads(row + offset) || bin > fNTimeBins){
84645eb0 203 if (errorCount++<maxErrorPrintout) {
204 HLTFatal("Index out of range. Probably wrong patch! slice %d - patch %d", slice, patch);
205 HLTFatal("PAD=%d out of %d ||| ROW=%d (%d to %d) ||| BIN=%d out of %d ||| OFFSET=%d ||| ROWOFFSET=%d",
206 pad, AliHLTTPCTransform::GetNPads(row + offset), row, firstrow, lastrow, bin, fNTimeBins,
207 offset, fRowOffset);
208
209 if ( row < firstrow || row > lastrow )
210 HLTFatal("Row out of range: %d ( %d to %d)", row, firstrow, lastrow);
211 if ( pad > AliHLTTPCTransform::GetNPads(row + offset) )
212 HLTFatal("Pad out of range: %d (pad count %d)", pad, AliHLTTPCTransform::GetNPads(row + offset));
213 if ( bin > fNTimeBins )
214 HLTFatal("Time bin out of range: %d (bin count %d)", bin, fNTimeBins);
db16520a 215 }
84645eb0 216 continue;
217 } else if ((row-fRowOffset)*fNMaxPads*fNTimeBins+ pad*fNTimeBins + bin >= fNMaxRows*fNMaxPads*fNTimeBins ) {
218 if (errorCount++<maxErrorPrintout) {
219 HLTFatal("index out of range: PAD=%d ||| ROW=%d ||| BIN=%d ||| OFFSET=%d ||| ROWOFFSET=%d", pad, row, bin, offset, fRowOffset);
db16520a 220 }
84645eb0 221 continue;
222 } else {
223 fData[ (row-fRowOffset)*fNMaxPads*fNTimeBins+ pad*fNTimeBins + bin ] = GetRealSignal() ;
db16520a 224 }
225 }
84645eb0 226 if (errorCount>0) {
227 HLTFatal("%d of %d entries out of range", errorCount, entryCount);
228 }
db16520a 229 }
230
231 return 0;
232}
233
234bool AliHLTTPCDigitReaderRaw::Next(){
235 if ( fDataFormatVersion==0 || fDataFormatVersion==2 )
236 {
237 Bool_t readvalue = kTRUE;
238 while (1) {
239 fCurrentBin++;
240 if (fCurrentBin >= fNTimeBins){
241 fCurrentBin = 0;
242 fCurrentPad++;
243
244 if (fCurrentPad >=fNMaxPads){
245 fCurrentPad = 0;
246 fCurrentRow++;
247
248 if (fCurrentRow >= fNMaxRows){
249 readvalue = kFALSE;
250 break;
251 }
252 }
253 }
254
255 if (fCurrentRow*fNMaxPads*fNTimeBins+ fCurrentPad*fNTimeBins + fCurrentBin >= fNMaxRows*fNMaxPads*fNTimeBins ) {
84645eb0 256 HLTFatal("Overflow: fCurrentRow=%d fCurrentPad=%d fCurrentBin=%d", fCurrentRow, fCurrentPad, fCurrentBin);
db16520a 257 readvalue = kFALSE;
258 break;
259 }
260
261 if (fData[ fCurrentRow*fNMaxPads*fNTimeBins + fCurrentPad*fNTimeBins + fCurrentBin ] != -1) break;
262 }
263 return readvalue;
264 }
265 else
266 return RealNext();
267}
268
269int AliHLTTPCDigitReaderRaw::GetRow(){
270 if ( fDataFormatVersion==0 || fDataFormatVersion==2 )
271 {
272 return (fCurrentRow + fRowOffset);
273 }
274 else
275 return GetRealRow();
276}
277int AliHLTTPCDigitReaderRaw::GetPad(){
278 if ( fDataFormatVersion==0 || fDataFormatVersion==2 )
279 {
280 return fCurrentPad;
281 }
282 else
283 return GetRealPad();
284}
285int AliHLTTPCDigitReaderRaw::GetSignal(){
286 if ( fDataFormatVersion==0 || fDataFormatVersion==2 )
287 {
288 return fData[ fCurrentRow*fNMaxPads*fNTimeBins+ fCurrentPad*fNTimeBins + fCurrentBin ];
289 }
290 else
291 return GetRealSignal();
292}
293int AliHLTTPCDigitReaderRaw::GetTime(){
294 if ( fDataFormatVersion==0 || fDataFormatVersion==2 )
295 {
296 return fCurrentBin;
297 }
298 else
299 return GetRealTime();
300}
301
302
303bool AliHLTTPCDigitReaderRaw::RealNext(){
304// printf( "%u %u %u %u %u\n", fBunchPosition, fBunchLength, fBunchTimebinStart, fWordInBunch, (unsigned)fAltroBlock10BitWordCnt );
305 fWordInBunch++; // use next word in bunch
306 if ( fWordInBunch==fBunchLength ) { // we have a bunch at all but have reached its end (or do not have an altro block yet)
307 if ( fBunchPosition+fBunchLength==fAltroBlock10BitWordCnt ) { // We were at the last bunch of this altro block (or do not have an altro block yet)
308 if ( !NextAltroBlock() )
309 return false;
310 fBunchPosition = 0;
311 }
312 else {
313 fBunchPosition += fBunchLength;
314 }
315 fBunchLength = GetAltroBlock10BitWord( fBunchPosition );
316 fBunchTimebinStart = GetAltroBlock10BitWord( fBunchPosition+1 );
317 fWordInBunch = 2;
318 }
84645eb0 319 //HLTDebug( "%u %u %u %u %u\n", fBunchPosition, fBunchLength, fBunchTimebinStart, fWordInBunch, (unsigned)fAltroBlock10BitWordCnt );
db16520a 320 return true;
321}
322int AliHLTTPCDigitReaderRaw::GetRealRow(){
323 return fRow;
324}
325int AliHLTTPCDigitReaderRaw::GetRealPad(){
326 return fPad;
327}
328int AliHLTTPCDigitReaderRaw::GetRealSignal(){
329 return GetAltroBlock10BitWord( fBunchPosition+fWordInBunch );
330}
331int AliHLTTPCDigitReaderRaw::GetRealTime(){
84645eb0 332 //HLTDebug( "GetRealTime: %u - %u\n", fBunchTimebinStart, fWordInBunch );
db16520a 333 return fBunchTimebinStart-(fWordInBunch-2);
334}
335
336AliHLTUInt32_t AliHLTTPCDigitReaderRaw::GetRCUTrailer(){
84645eb0 337 if (fBufferSize<=0) return 0;
338 unsigned rcuDataBlockLen = GetRCUDataBlockLength();
339 return *((AliHLTUInt32_t*)(fBuffer+fBufferSize-rcuDataBlockLen));
db16520a 340}
341
342bool AliHLTTPCDigitReaderRaw::NextAltroBlock()
343 {
84645eb0 344 if (fBufferSize<=0) return 0;
db16520a 345 if ( !fAltroBlockLengthBytes )
346 {
347 // First block in back linked list (last block in memory)
348 fAltroBlockPositionBytes = fBufferSize-GetRCUDataBlockLength();
349 }
350 else
351 {
352 if ( fAltroBlockPositionBytes<fAltroBlockLengthBytes+GetCommonDataHeaderSize() )
353 {
84645eb0 354 HLTFatal("Inconsistent Data: fAltroBlockPositionBytes=%d fAltroBlockLengthBytes=%d", fAltroBlockPositionBytes, fAltroBlockLengthBytes);
db16520a 355 }
356 if ( fAltroBlockPositionBytes<=fAltroBlockLengthBytes+GetCommonDataHeaderSize() )
357 return false; // We have reached the end of the back linked list
358 fAltroBlockPositionBytes -= fAltroBlockLengthBytes;
359 }
360
361 AliHLTUInt64_t altroTrailerWord = GetAltroBlock40BitWord( 0 );
362
363 if ( fVerify && ((altroTrailerWord & 0xFFFC000000ULL)!=0xAAA8000000ULL) )
364 {
84645eb0 365 HLTFatal("Data inconsistency in Altro Block at byte position %#x (%d): Expected 0x2AAA in high 14 bits of altro trailer word; Found %#llx (%#llx)",
366 fAltroBlockPositionBytes, fAltroBlockPositionBytes,
367 ((altroTrailerWord & 0xFFFC000000ULL) >> 26), altroTrailerWord);
db16520a 368
369
370 return false;
371 }
372
373 if ( fVerify && ((altroTrailerWord & 0x000000F000ULL)!=0x000000A000ULL) )
374 {
84645eb0 375 HLTFatal("Data inconsistency in Altro Block at byte position %#x (%d): Expected 0xA in bits 12-15 of altro trailer word; Found %#llx .",
376 fAltroBlockPositionBytes, fAltroBlockPositionBytes, ((altroTrailerWord & 0x000000F000ULL) >> 12));
db16520a 377
378 return false;
379 }
380
381 fAltroBlock10BitWordCnt = (altroTrailerWord >> 16) & 0x3FF;
382 fAltroBlockHWAddress = altroTrailerWord & 0xFFF;
383
384 // ApplyMapping
385 if (!ApplyMapping())
386 {
84645eb0 387 HLTFatal("Mapping failed Patch %d HWA %#x (%d) - maxHWA %#x (%d)",
388 fPatch, fAltroBlockHWAddress, fAltroBlockHWAddress, fMaxHWA[fPatch], fMaxHWA[fPatch]);
db16520a 389
390 }
391
392 unsigned words40Bit = fAltroBlock10BitWordCnt/4;
393 if ( fAltroBlock10BitWordCnt % 4 )
394 words40Bit++;
395 words40Bit++;
396 fAltroBlockLengthBytes = words40Bit*5;
397 if ( fAltroBlock10BitWordCnt % 4 )
398 fAltroBlock10BitFillWordCnt = 4-(fAltroBlock10BitWordCnt % 4);
399 else
400 fAltroBlock10BitFillWordCnt=0;
401 if ( fVerify )
402 {
403 for ( unsigned b = 0; b < fAltroBlock10BitFillWordCnt; b++ )
404 {
405 if ( GetAltroBlockReal10BitWord(b)!=0x2AA )
406 {
84645eb0 407 HLTFatal("Data inconsistency in trailing 10 bit fill word of Altro Block at byte position %#x (%d): Expected 0x2AA; Found %#x",
408 fAltroBlockPositionBytes, fAltroBlockPositionBytes, GetAltroBlockReal10BitWord(b));
db16520a 409
410 return false;
411 }
412 }
413 }
414 return true;
415 }
416
417AliHLTUInt32_t AliHLTTPCDigitReaderRaw::GetAltroBlockHWaddr(){
418return fAltroBlockHWAddress;
419}
420unsigned AliHLTTPCDigitReaderRaw::GetAltroBlock10BitWordCnt(){
421return fAltroBlock10BitWordCnt;
422}
423AliHLTUInt64_t AliHLTTPCDigitReaderRaw::GetAltroBlock40BitWord( unsigned long ndx ){
424AliHLTUInt64_t val=0;
425unsigned wordOffset32Bit = (ndx / 4)*5;
426switch ( ndx % 4 ) // 40 bit word index in a 4*40 bit=5*32 bit group
427 {
428 case 0:
429 val = (*(AliHLTUInt32_t*)(fBuffer+fAltroBlockPositionBytes-(wordOffset32Bit+1)*sizeof(AliHLTUInt32_t)));
430 val <<= 8;
431 val |= (*(AliHLTUInt32_t*)(fBuffer+fAltroBlockPositionBytes-(wordOffset32Bit+2)*sizeof(AliHLTUInt32_t))) >> 24;
432 break;
433 case 1:
434 val = ((*(AliHLTUInt32_t*)(fBuffer+fAltroBlockPositionBytes-(wordOffset32Bit+2)*sizeof(AliHLTUInt32_t))) & 0x00FFFFFF);
435 val <<= 16;
436 val |= ((*(AliHLTUInt32_t*)(fBuffer+fAltroBlockPositionBytes-(wordOffset32Bit+3)*sizeof(AliHLTUInt32_t))) >> 16) & 0xFFFF;
437 break;
438 case 2:
439 val = ((*(AliHLTUInt32_t*)(fBuffer+fAltroBlockPositionBytes-(wordOffset32Bit+3)*sizeof(AliHLTUInt32_t))) & 0xFFFF);
440 val <<= 24;
441 val |= ((*(AliHLTUInt32_t*)(fBuffer+fAltroBlockPositionBytes-(wordOffset32Bit+4)*sizeof(AliHLTUInt32_t))) >> 8);
442 break;
443 case 3:
444 val = ((*(AliHLTUInt32_t*)(fBuffer+fAltroBlockPositionBytes-(wordOffset32Bit+4)*sizeof(AliHLTUInt32_t))) & 0xFF);
445 val <<= 32;
446 val |= *(AliHLTUInt32_t*)(fBuffer+fAltroBlockPositionBytes-(wordOffset32Bit+5)*sizeof(AliHLTUInt32_t));
447 break;
448 }
449return val;
450}
451AliHLTUInt16_t AliHLTTPCDigitReaderRaw::GetAltroBlock10BitWord( unsigned long ndx ){
452unsigned long realNdx = ndx+fAltroBlock10BitFillWordCnt;
453unsigned long word40BitNdx = (realNdx / 4)+1;
454AliHLTUInt64_t word40Bit = GetAltroBlock40BitWord( word40BitNdx );
455switch ( realNdx % 4 )
456 {
457 case 3:
458 return word40Bit & 0x3FF;
459 case 2:
460 return (word40Bit>>10) & 0x3FF;
461 case 1:
462 return (word40Bit>>20) & 0x3FF;
463 case 0:
464 return (word40Bit>>30) & 0x3FF;
465 }
466
467 return 0xFFFF;
468}
469
470AliHLTUInt16_t AliHLTTPCDigitReaderRaw::GetAltroBlockReal10BitWord( unsigned long ndx ){
471unsigned long word40BitNdx = (ndx / 4)+1;
472AliHLTUInt64_t word40Bit = GetAltroBlock40BitWord( word40BitNdx );
473switch ( ndx % 4 )
474 {
475 case 3:
476 return word40Bit & 0x3FF;
477 case 2:
478 return (word40Bit>>10) & 0x3FF;
479 case 1:
480 return (word40Bit>>20) & 0x3FF;
481 case 0:
482 return (word40Bit>>30) & 0x3FF;
483 }
484
485 return 0xFFFF;
486}
487
488// Return length of trailing RCU data block in bytes
489unsigned AliHLTTPCDigitReaderRaw::GetRCUDataBlockLength() const
490 {
491 switch ( fDataFormatVersion )
492 {
493 case 0:
494 case 1:
495 return 4;
496 break;
497 case 2:
498 case 3:
499 return 12;
500 break;
501 default:
502 return fBufferSize;
503 }
504 }
505
506unsigned AliHLTTPCDigitReaderRaw::GetCommonDataHeaderSize() const
507 {
508 return 32;
509 }
510
511
512Bool_t AliHLTTPCDigitReaderRaw::ApplyMapping(){
513
514 if ( (unsigned)fAltroBlockHWAddress > fMaxHWA[fPatch]){
515 fPad = -1;
516 fRow = -1;
517 return kFALSE;
518 }
519
520 switch(fPatch){
521 case 0:
522 fRow = fMapping_0[(unsigned)fAltroBlockHWAddress][0];
523 fPad = fMapping_0[(unsigned)fAltroBlockHWAddress][1];
524 break;
525 case 1:
526 fRow = AliHLTTPCDigitReaderRaw::fMapping_1[(unsigned)fAltroBlockHWAddress][0];
527 fPad = AliHLTTPCDigitReaderRaw::fMapping_1[(unsigned)fAltroBlockHWAddress][1];
528#if 0
529 printf ("pad %d # row %d (hwa: %u / 0x%08X\n", fMapping_1[(unsigned)fAltroBlockHWAddress][0],fMapping_1[(unsigned)fAltroBlockHWAddress][1], (unsigned)fAltroBlockHWAddress, (unsigned)fAltroBlockHWAddress);
530 printf ("pad %d # row %d (hwa: %u / 0x%08X\n", fMapping_1[(unsigned)fAltroBlockHWAddress-1][0],fMapping_1[(unsigned)fAltroBlockHWAddress-1][1], (unsigned)fAltroBlockHWAddress-1, (unsigned)fAltroBlockHWAddress-1);
531 printf ("pad %d # row %d (hwa: %u / 0x%08X\n", fMapping_1[(unsigned)fAltroBlockHWAddress+1][0],fMapping_1[(unsigned)fAltroBlockHWAddress+1][1], (unsigned)fAltroBlockHWAddress+1, (unsigned)fAltroBlockHWAddress+1);
532#endif
533 break;
534 case 2:
535 fRow = fMapping_2[(unsigned)fAltroBlockHWAddress][0];
536 fPad = fMapping_2[(unsigned)fAltroBlockHWAddress][1];
537 break;
538 case 3:
539 fRow = fMapping_3[(unsigned)fAltroBlockHWAddress][0];
540 fPad = fMapping_3[(unsigned)fAltroBlockHWAddress][1];
541 break;
542 case 4:
543 fRow = fMapping_4[(unsigned)fAltroBlockHWAddress][0];
544 fPad = fMapping_4[(unsigned)fAltroBlockHWAddress][1];
545 break;
546 case 5:
547 fRow = fMapping_5[(unsigned)fAltroBlockHWAddress][0];
548 fPad = fMapping_5[(unsigned)fAltroBlockHWAddress][1];
549 break;
550 default:
551 fRow = -1;
552 fPad = -1;
553 return kFALSE;
554 }
555 return kTRUE;
556}
557
558
559Int_t AliHLTTPCDigitReaderRaw::GetRow( unsigned patch, unsigned hw_addr )
560{
561 if ( (unsigned)hw_addr > fMaxHWA[fPatch]){
562 return -1;
563 }
564
565 switch(fPatch){
566 case 0:
567 return fMapping_0[hw_addr][0];
568 case 1:
569 return fMapping_1[hw_addr][0];
570 case 2:
571 return fMapping_2[hw_addr][0];
572 case 3:
573 return fMapping_3[hw_addr][0];
574 case 4:
575 return fMapping_4[hw_addr][0];
576 case 5:
577 return fMapping_5[hw_addr][0];
578 default:
579 return -1;
580 }
581}
582Int_t AliHLTTPCDigitReaderRaw::GetPad( unsigned patch, unsigned hw_addr )
583{
584 if ( (unsigned)hw_addr > fMaxHWA[fPatch]){
585 return -1;
586 }
587
588 switch(fPatch){
589 case 0:
590 return fMapping_0[hw_addr][1];
591 case 1:
592 return fMapping_1[hw_addr][1];
593 case 2:
594 return fMapping_2[hw_addr][1];
595 case 3:
596 return fMapping_3[hw_addr][1];
597 case 4:
598 return fMapping_4[hw_addr][1];
599 case 5:
600 return fMapping_5[hw_addr][1];
601 default:
602 return -1;
603 }
604}
605
606unsigned AliHLTTPCDigitReaderRaw::GetMaxHWA( unsigned patch )
607{
608 if ( patch>=6 )
609 return 0;
610 return fMaxHWA[patch];
611}
612
613
614// ----- MAPPING ARRAYS
615#include "mapping_array_out.inc"
616
617#endif //#if defined(HAVE_TPC_MAPPING)