]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCDigitReaderDecoder.cxx
added consistency check for track parameters when reading data into a TrackArray
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCDigitReaderDecoder.cxx
CommitLineData
7e914051 1// $Id$
f8121cb1 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: 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//**************************************************************************
20
21/** @file AliHLTTPCDigitReaderDecoder.cxx
22 @author Kenneth Aamodt, Matthias Richter
23 @date
24 @brief DigitReader implementation for the fast ALTRO Decoder
25*/
26
27#if __GNUC__>= 3
28using namespace std;
29#endif
30
7c9a4e09 31#include <cassert>
f8121cb1 32#include "AliHLTTPCDigitReaderDecoder.h"
7dceaa9b 33#include "AliHLTTPCMapping.h"
f8121cb1 34#include "AliAltroDecoder.h"
35#include "AliAltroData.h"
36#include "AliAltroBunch.h"
092a1374 37#include "AliHLTTPCTransform.h"
f8121cb1 38
39ClassImp(AliHLTTPCDigitReaderDecoder)
40
41AliHLTTPCDigitReaderDecoder::AliHLTTPCDigitReaderDecoder()
42 :
7dceaa9b 43 AliHLTTPCDigitReader(),
44 fAltroDecoder(NULL),
45 fAltroData(),
46 fAltroBunch(NULL),
47 fMapping(NULL),
7c9a4e09 48 // initialization due to the logic in NextSignals
49 fNextCounter(-1),
7dceaa9b 50 fNextSignalMethodUsed(kFALSE)
f8121cb1 51{
52 // see header file for class documentation
53 // or
54 // refer to README to build package
55 // or
56 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
57}
58
59AliHLTTPCDigitReaderDecoder::~AliHLTTPCDigitReaderDecoder()
60{
61 // see header file for class documentation
7dceaa9b 62 if(fAltroDecoder){
63 delete fAltroDecoder;
64 }
65 if(fAltroBunch){
66 delete fAltroBunch;
67 }
68 if(fMapping){
69 delete fMapping;
70 }
f8121cb1 71}
72
a74855c2 73int AliHLTTPCDigitReaderDecoder::InitBlock(void* ptr,unsigned long size, Int_t patch, Int_t /*slice*/)
f8121cb1 74{
75 // see header file for class documentation
7c9a4e09 76 // HLTDebug("Initializing block in decoder");
77 if(!fMapping){
78 fMapping = new AliHLTTPCMapping(patch);
79 }
80 if(!fAltroDecoder){
81 fAltroDecoder = new AliAltroDecoder();
82 }
83 if(!fAltroBunch){
84 fAltroBunch = new AliAltroBunch();
85 }
7dceaa9b 86 fAltroDecoder->SetMemory((UChar_t*)ptr, size);
87 fAltroDecoder->Decode();
f8121cb1 88 return 0;
89}
90
900fdfb2 91void AliHLTTPCDigitReaderDecoder::SetUnsorted(bool unsorted)
92{
93 // see header file for class documentation
94
95 // The DigitReaderDecoder does not support sorted data, forward to
96 // default if sorted data requested
97 if (!unsorted) AliHLTTPCDigitReader::SetUnsorted(unsorted);
98}
99
f8121cb1 100bool AliHLTTPCDigitReaderDecoder::NextChannel()
101{
102 // see header file for class documentation
d2f725e4 103 Bool_t result=fAltroDecoder->NextChannel(&fAltroData);
104 if(result && !fMapping->IsValidHWAddress(fAltroData.GetHadd())){
105 result = fAltroDecoder->NextChannel(&fAltroData);
106 }
107 return result;
f8121cb1 108}
109
110int AliHLTTPCDigitReaderDecoder::NextBunch()
111{
112 // see header file for class documentation
7dceaa9b 113 return fAltroData.NextBunch(fAltroBunch);
f8121cb1 114}
115
116bool AliHLTTPCDigitReaderDecoder::NextSignal()
117{
118 // see header file for class documentation
7c9a4e09 119 fNextSignalMethodUsed=kTRUE;
120 do {
121 if (fNextCounter>0) {
122 // there is data available in the current bunch
123 fNextCounter--;
124 return true;
7dceaa9b 125 }
7c9a4e09 126
127 // there is no data left in the current bunch, search for the next one
128 while (NextBunch()) if (GetBunchSize()>0) {
129 fNextCounter=GetBunchSize()-1;
130 return true;
7dceaa9b 131 }
7c9a4e09 132
133 fNextCounter=-1;
134 // there is no bunch left, go to the next channel
135 } while (NextChannel());
7dceaa9b 136
7c9a4e09 137 return false;
f8121cb1 138}
139
7dceaa9b 140const UInt_t* AliHLTTPCDigitReaderDecoder::GetSignals()
f8121cb1 141{
142 // see header file for class documentation
7dceaa9b 143 return fAltroBunch->GetData();
f8121cb1 144}
145
146int AliHLTTPCDigitReaderDecoder::GetRow()
147{
148 // see header file for class documentation
7dceaa9b 149 return fMapping->GetRow(fAltroData.GetHadd());
f8121cb1 150}
151
152int AliHLTTPCDigitReaderDecoder::GetPad()
153{
154 // see header file for class documentation
7dceaa9b 155 return fMapping->GetPad(fAltroData.GetHadd());
f8121cb1 156}
157
158int AliHLTTPCDigitReaderDecoder::GetSignal()
159{
160 // see header file for class documentation
7c9a4e09 161 if (fNextSignalMethodUsed) {
162 const UInt_t* pData=GetSignals();
163 if (pData && fNextCounter>=0) {
164 assert(fNextCounter<GetBunchSize());
165 return pData[fNextCounter];
166 }
167 }
f8121cb1 168 return 0;
169}
170
171int AliHLTTPCDigitReaderDecoder::GetTime()
172{
173 // see header file for class documentation
092a1374 174 int iResult=0;
7dceaa9b 175 if(!fNextSignalMethodUsed){// this is true if the bunch approach is used
092a1374 176
177 iResult= fAltroBunch->GetStartTimeBin();
7dceaa9b 178 }
179 else{
7c9a4e09 180 assert(fNextCounter>=0);
092a1374 181 iResult = fAltroBunch->GetStartTimeBin()+fNextCounter;
7dceaa9b 182 }
092a1374 183 if(iResult<0 || iResult>AliHLTTPCTransform::GetNTimeBins()){
184 iResult=0;
185 }
186 return iResult;
7dceaa9b 187}
188
189int AliHLTTPCDigitReaderDecoder::GetBunchSize()
190{
7c9a4e09 191 // see header file for class documentation
7dceaa9b 192 return fAltroBunch->GetBunchSize();
f8121cb1 193}
7c9a4e09 194
d2f725e4 195int AliHLTTPCDigitReaderDecoder::GetRowOffset() const
196{
197 return fMapping->GetRowOffset();
198}
7c9a4e09 199AliHLTUInt32_t AliHLTTPCDigitReaderDecoder::GetAltroBlockHWaddr() const
200{
201 // see header file for class documentation
202 return (AliHLTUInt32_t)fAltroData.GetHadd();
203}
092a1374 204AliHLTUInt32_t AliHLTTPCDigitReaderDecoder::GetAltroBlockHWaddr(Int_t row, Int_t pad) const
205{
206 // see header file for class documentation
207 if(fMapping){
208 return fMapping->GetHwAddress(row,pad);
209 }
210 else{
211 return 0;
212 }
213}