]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCDigitReaderUnpacked.cxx
Bugfix, comparison of string -sorted was not correct.
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCDigitReaderUnpacked.cxx
CommitLineData
a38a7850 1// $Id$
2
67fada6b 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: Matthias Richter <Matthias.Richter@ift.uib.no> *
8// Timm Steinbeck <timm@kip.uni-heidelberg.de> *
9// Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
10// for The ALICE HLT Project. *
11// *
12// Permission to use, copy, modify and distribute this software and its *
13// documentation strictly for non-commercial purposes is hereby granted *
14// without fee, provided that the above copyright notice appears in all *
15// copies and that both the copyright notice and this permission notice *
16// appear in the supporting documentation. The authors make no claims *
17// about the suitability of this software for any purpose. It is *
18// provided "as is" without express or implied warranty. *
19//*************************************************************************/
a38a7850 20
84645eb0 21/** @file AliHLTTPCDigitReaderUnpacked.cxx
22 @author Timm Steinbeck, Jochen Thaeder, Matthias Richter
23 @date
24 @brief A digit reader implementation for unpacked TPC data.
25*/
a38a7850 26
27#if __GNUC__== 3
28using namespace std;
29#endif
30
67fada6b 31#include <cassert>
a38a7850 32#include "AliHLTTPCDigitReaderUnpacked.h"
33#include "AliHLTTPCDigitData.h"
84645eb0 34#include "AliHLTTPCTransform.h"
35#include "AliHLTStdIncludes.h"
a38a7850 36
84645eb0 37ClassImp(AliHLTTPCDigitReaderUnpacked)
a38a7850 38
84645eb0 39AliHLTTPCDigitReaderUnpacked::AliHLTTPCDigitReaderUnpacked()
40 :
41 fDigitRowData(NULL),
42 fActRowData(NULL),
43 fData(NULL),
44 fPtr(NULL),
45 fSize(0),
46 fBin(0),
47 fRow(0),
48 fFirstRow(0),
49 fLastRow(0)
50{
5df0cbb9 51 // see header file for class documentation
52 // or
53 // refer to README to build package
54 // or
55 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
84645eb0 56}
a38a7850 57
a38a7850 58AliHLTTPCDigitReaderUnpacked::~AliHLTTPCDigitReaderUnpacked(){
5df0cbb9 59 // see header file for class documentation
a38a7850 60}
61
84645eb0 62int AliHLTTPCDigitReaderUnpacked::InitBlock(void* ptr,unsigned long size, Int_t patch, Int_t slice){
5df0cbb9 63 // see header file for class documentation
67fada6b 64 int iResult=0;
5df0cbb9 65 AliHLTTPCUnpackedRawData *tmpptr=NULL;
a38a7850 66 fPtr = ptr;
67 fSize = size;
68
d3905cf0 69 tmpptr = reinterpret_cast<AliHLTTPCUnpackedRawData*>(fPtr);
a38a7850 70 fDigitRowData = (AliHLTTPCDigitRowData*) tmpptr->fDigits;
67fada6b 71 fActRowData = fDigitRowData;
a38a7850 72
95e36f3d 73 while (fActRowData && ((iResult=GetNextRowData(fActRowData))>=0)) {/* empty body */};
67fada6b 74
75 if (iResult>=0) {
76 fActRowData = fDigitRowData;
a38a7850 77 fBin = -1;
78
055fed30 79 int dummy=0;
80 AliHLTTPCTransform::Slice2Sector(slice, AliHLTTPCTransform::GetFirstRow(patch), dummy, fFirstRow);
81 AliHLTTPCTransform::Slice2Sector(slice, AliHLTTPCTransform::GetLastRow(patch), dummy, fLastRow);
84645eb0 82
a38a7850 83 fRow = fFirstRow;
84
85 if ((Int_t)fActRowData->fRow != fRow){
84645eb0 86 HLTWarning("Row number should match! fActRowData->fRow=%d fRow=%d", fActRowData->fRow, fRow);
a38a7850 87 }
67fada6b 88 } else {
89 fActRowData=NULL;
90 }
91 return iResult;
92}
93
94int AliHLTTPCDigitReaderUnpacked::GetNextRowData(AliHLTTPCDigitRowData*& pRow) const
95{
96 // get new row data from the current row data
97 int iResult=0;
98 AliHLTTPCDigitRowData* pCurrent=pRow;
99 assert(pCurrent);
100 pRow=NULL;
101 Byte_t *tmp = (Byte_t*) pCurrent;
102 Int_t size = sizeof(AliHLTTPCDigitRowData) + pCurrent->fNDigit*sizeof(AliHLTTPCDigitData);
103 tmp += size;
104 pRow = reinterpret_cast<AliHLTTPCDigitRowData*>(tmp);
105
106 // check if the new pointer is within the range
107 if (((Byte_t*)fPtr) + fSize <= tmp){
108 if (((Byte_t*)fPtr) + fSize < tmp) {
109 // if the increment does not match exactly there is a format error
110 HLTError("input format not recognized: buffer %p %d, current row data %p, %d digits", fPtr, fSize, pCurrent, pCurrent->fNDigit);
111 iResult=-EBADF;
112 }
113 pRow=NULL;
114 } else {
115 // check if the current row structure has the right format
116 size = sizeof(AliHLTTPCDigitRowData) + pRow->fNDigit*sizeof(AliHLTTPCDigitData);
117 tmp += size;
118 if (((Byte_t*)fPtr) + fSize < tmp){
119 HLTError("Current row data not recognized %p (buffer %p %d) %d digits", pRow, fPtr, fSize, pRow->fNDigit);
120 pRow=NULL;
121 iResult=-EBADF;
122 }
123 }
124
125 return iResult;
a38a7850 126}
127
f44e97dc 128bool AliHLTTPCDigitReaderUnpacked::NextSignal(){
5df0cbb9 129 // see header file for class documentation
67fada6b 130 if (fActRowData==NULL) return false;
131
a38a7850 132 bool rreadvalue = true;
133
134 fBin++;
135
136 if ( fBin >= (Int_t)fActRowData->fNDigit ){
a38a7850 137 fRow++;
a38a7850 138 if ((fRow >= fFirstRow) && (fRow <= fLastRow)){
139
140 //new row
67fada6b 141 if (GetNextRowData(fActRowData)<0) {
a38a7850 142 rreadvalue = false;
143 return rreadvalue;
144 }
145
146 fBin = 0;
147 }
148 else {
149 rreadvalue = false;
150 return rreadvalue;
151 }
afa4418c 152 if(!fActRowData){
153 return false;
154 }
a38a7850 155 if ((Int_t)fActRowData->fRow != fRow){
84645eb0 156 HLTWarning("Row number should match! fActRowData->fRow=%d fRow=%d", fActRowData->fRow, fRow);
a38a7850 157 }
158 }
159
160 fData = fActRowData->fDigitData;
161
162 return rreadvalue;
163}
164
165int AliHLTTPCDigitReaderUnpacked::GetRow(){
5df0cbb9 166 // see header file for class documentation
a38a7850 167 int rrow;
168 rrow = fRow;
169 return rrow;
170}
171
172int AliHLTTPCDigitReaderUnpacked::GetPad(){
5df0cbb9 173 // see header file for class documentation
67fada6b 174 assert(fData);
f44e97dc 175 if (!fData) return -1;
a38a7850 176 int rpad;
177 rpad = (int)fData[fBin].fPad;
178 return rpad ;
179}
180
181int AliHLTTPCDigitReaderUnpacked::GetSignal(){
5df0cbb9 182 // see header file for class documentation
67fada6b 183 assert(fData);
f44e97dc 184 if (!fData) return -1;
a38a7850 185 int rsignal;
186 rsignal = (int)fData[fBin].fCharge;
187 return rsignal;
188}
189
190int AliHLTTPCDigitReaderUnpacked::GetTime(){
5df0cbb9 191 // see header file for class documentation
67fada6b 192 assert(fData);
f44e97dc 193 if (!fData) return -1;
a38a7850 194 int rtime;
195 rtime = (int)fData[fBin].fTime;
196 return rtime;
197}