]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCDigitReaderUnpacked.cxx
b9fc2e1d58b848f0746b931f791a3f4d6d2cfeb7
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCDigitReaderUnpacked.cxx
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
20 ///////////////////////////////////////////////////////////////////////////////
21 //                                                                           //
22 // class for reading unpacked data for the HLT                               //
23 //                                                                           //
24 ///////////////////////////////////////////////////////////////////////////////
25
26 #if __GNUC__== 3
27 using namespace std;
28 #endif
29
30 #include "AliHLTTPCDigitReaderUnpacked.h"
31 #include "AliHLTTPCDigitData.h"
32 #include "AliHLTTPCRawDataFormat.h"
33
34 #include "AliHLTTPCLogging.h"
35
36 #include <stdlib.h>
37 #include <errno.h>
38
39 ClassImp(AliHLTTPCDigitReaderUnpacked)
40
41 AliHLTTPCDigitReaderUnpacked::AliHLTTPCDigitReaderUnpacked(){
42   fBin = 0;
43   fRow = 0;
44   fFirstRow = 0;
45   fLastRow = 0;
46 }
47
48 AliHLTTPCDigitReaderUnpacked::~AliHLTTPCDigitReaderUnpacked(){
49 }
50
51 int AliHLTTPCDigitReaderUnpacked::InitBlock(void* ptr,unsigned long size, Int_t firstrow, Int_t lastrow){
52   AliHLTTPCUnpackedRawData *tmpptr;
53   fPtr = ptr;
54   fSize = size;
55
56   tmpptr = (AliHLTTPCUnpackedRawData*) fPtr;
57   fDigitRowData = (AliHLTTPCDigitRowData*) tmpptr->fDigits;
58   fActRowData = (AliHLTTPCDigitRowData*) fDigitRowData;
59
60   fBin = -1;
61
62   fFirstRow = firstrow;
63   fLastRow = lastrow;
64   return 0;
65   fRow = fFirstRow; 
66
67   if ((Int_t)fActRowData->fRow != fRow){
68       LOG(AliHLTTPCLog::kWarning,"AliHLTTPCDigitReaderUnpacked::Next","Digits") << "Row number should match!" << fActRowData->fRow << " " << fRow << ENDLOG;
69   }
70 }
71
72 bool AliHLTTPCDigitReaderUnpacked::Next(){
73   bool rreadvalue = true;
74
75   fBin++;
76
77   if ( fBin >= (Int_t)fActRowData->fNDigit ){
78
79     fRow++;
80
81     if ((fRow >= fFirstRow) && (fRow <= fLastRow)){
82
83       //new row 
84       Byte_t *tmp = (Byte_t*) fActRowData;
85       Int_t size = sizeof(AliHLTTPCDigitRowData) + fActRowData->fNDigit*sizeof(AliHLTTPCDigitData);
86       tmp += size;
87       fActRowData = (AliHLTTPCDigitRowData*) tmp;
88      
89       if (((Byte_t*)fPtr) + fSize <= tmp){
90         rreadvalue = false;
91         return rreadvalue;
92       }
93
94       fBin = 0;
95     }
96     else {
97       rreadvalue = false;
98       return rreadvalue;
99     }
100     
101     if ((Int_t)fActRowData->fRow != fRow){
102       LOG(AliHLTTPCLog::kWarning,"AliHLTTPCDigitReaderUnpacked::Next","Digits") << "Row number should match!" << fActRowData->fRow << " " << fRow << ENDLOG;
103     }
104   }
105
106   fData = fActRowData->fDigitData;
107  
108   return rreadvalue;
109 }
110
111 int AliHLTTPCDigitReaderUnpacked::GetRow(){
112   int rrow;
113   rrow = fRow;
114   return rrow;
115 }
116
117 int AliHLTTPCDigitReaderUnpacked::GetPad(){
118   int rpad;
119   rpad = (int)fData[fBin].fPad;
120   return rpad   ;
121 }
122
123 int AliHLTTPCDigitReaderUnpacked::GetSignal(){ 
124   int rsignal;
125   rsignal = (int)fData[fBin].fCharge;
126   return rsignal;
127 }
128
129 int AliHLTTPCDigitReaderUnpacked::GetTime(){
130   int rtime;
131   rtime = (int)fData[fBin].fTime;
132   return rtime;
133 }