3 //*************************************************************************
4 // This file is property of and copyright by the ALICE HLT Project *
5 // ALICE Experiment at CERN, All rights reserved. *
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. *
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 //*************************************************************************/
21 /** @file AliHLTTPCDigitReaderUnpacked.cxx
22 @author Timm Steinbeck, Jochen Thaeder, Matthias Richter
24 @brief A digit reader implementation for unpacked TPC data.
32 #include "AliHLTTPCDigitReaderUnpacked.h"
33 #include "AliHLTTPCDigitData.h"
34 #include "AliHLTTPCTransform.h"
35 #include "AliHLTStdIncludes.h"
37 ClassImp(AliHLTTPCDigitReaderUnpacked)
39 AliHLTTPCDigitReaderUnpacked::AliHLTTPCDigitReaderUnpacked()
51 // see header file for class documentation
53 // refer to README to build package
55 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
58 AliHLTTPCDigitReaderUnpacked::~AliHLTTPCDigitReaderUnpacked(){
59 // see header file for class documentation
62 int AliHLTTPCDigitReaderUnpacked::InitBlock(void* ptr,unsigned long size, Int_t patch, Int_t slice){
63 // see header file for class documentation
65 AliHLTTPCUnpackedRawData *tmpptr=NULL;
69 tmpptr = reinterpret_cast<AliHLTTPCUnpackedRawData*>(fPtr);
70 fDigitRowData = (AliHLTTPCDigitRowData*) tmpptr->fDigits;
71 fActRowData = fDigitRowData;
73 while (fActRowData && ((iResult=GetNextRowData(fActRowData))>=0));
76 fActRowData = fDigitRowData;
80 AliHLTTPCTransform::Slice2Sector(slice, AliHLTTPCTransform::GetFirstRow(patch), dummy, fFirstRow);
81 AliHLTTPCTransform::Slice2Sector(slice, AliHLTTPCTransform::GetLastRow(patch), dummy, fLastRow);
85 if ((Int_t)fActRowData->fRow != fRow){
86 HLTWarning("Row number should match! fActRowData->fRow=%d fRow=%d", fActRowData->fRow, fRow);
94 int AliHLTTPCDigitReaderUnpacked::GetNextRowData(AliHLTTPCDigitRowData*& pRow) const
96 // get new row data from the current row data
98 AliHLTTPCDigitRowData* pCurrent=pRow;
101 Byte_t *tmp = (Byte_t*) pCurrent;
102 Int_t size = sizeof(AliHLTTPCDigitRowData) + pCurrent->fNDigit*sizeof(AliHLTTPCDigitData);
104 pRow = reinterpret_cast<AliHLTTPCDigitRowData*>(tmp);
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);
115 // check if the current row structure has the right format
116 size = sizeof(AliHLTTPCDigitRowData) + pRow->fNDigit*sizeof(AliHLTTPCDigitData);
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);
128 bool AliHLTTPCDigitReaderUnpacked::NextSignal(){
129 // see header file for class documentation
130 if (fActRowData==NULL) return false;
132 bool rreadvalue = true;
136 if ( fBin >= (Int_t)fActRowData->fNDigit ){
138 if ((fRow >= fFirstRow) && (fRow <= fLastRow)){
141 if (GetNextRowData(fActRowData)<0) {
155 if ((Int_t)fActRowData->fRow != fRow){
156 HLTWarning("Row number should match! fActRowData->fRow=%d fRow=%d", fActRowData->fRow, fRow);
160 fData = fActRowData->fDigitData;
165 int AliHLTTPCDigitReaderUnpacked::GetRow(){
166 // see header file for class documentation
172 int AliHLTTPCDigitReaderUnpacked::GetPad(){
173 // see header file for class documentation
175 if (!fData) return -1;
177 rpad = (int)fData[fBin].fPad;
181 int AliHLTTPCDigitReaderUnpacked::GetSignal(){
182 // see header file for class documentation
184 if (!fData) return -1;
186 rsignal = (int)fData[fBin].fCharge;
190 int AliHLTTPCDigitReaderUnpacked::GetTime(){
191 // see header file for class documentation
193 if (!fData) return -1;
195 rtime = (int)fData[fBin].fTime;