]>
Commit | Line | Data |
---|---|---|
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 | |
28 | using 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 | |
39 | ClassImp(AliHLTTPCDigitReaderDecoder) | |
40 | ||
41 | AliHLTTPCDigitReaderDecoder::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 | ||
59 | AliHLTTPCDigitReaderDecoder::~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 | 73 | int 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 | ||
91 | bool AliHLTTPCDigitReaderDecoder::NextChannel() | |
92 | { | |
93 | // see header file for class documentation | |
d2f725e4 | 94 | Bool_t result=fAltroDecoder->NextChannel(&fAltroData); |
95 | if(result && !fMapping->IsValidHWAddress(fAltroData.GetHadd())){ | |
96 | result = fAltroDecoder->NextChannel(&fAltroData); | |
97 | } | |
98 | return result; | |
f8121cb1 | 99 | } |
100 | ||
101 | int AliHLTTPCDigitReaderDecoder::NextBunch() | |
102 | { | |
103 | // see header file for class documentation | |
7dceaa9b | 104 | return fAltroData.NextBunch(fAltroBunch); |
f8121cb1 | 105 | } |
106 | ||
107 | bool AliHLTTPCDigitReaderDecoder::NextSignal() | |
108 | { | |
109 | // see header file for class documentation | |
7c9a4e09 | 110 | fNextSignalMethodUsed=kTRUE; |
111 | do { | |
112 | if (fNextCounter>0) { | |
113 | // there is data available in the current bunch | |
114 | fNextCounter--; | |
115 | return true; | |
7dceaa9b | 116 | } |
7c9a4e09 | 117 | |
118 | // there is no data left in the current bunch, search for the next one | |
119 | while (NextBunch()) if (GetBunchSize()>0) { | |
120 | fNextCounter=GetBunchSize()-1; | |
121 | return true; | |
7dceaa9b | 122 | } |
7c9a4e09 | 123 | |
124 | fNextCounter=-1; | |
125 | // there is no bunch left, go to the next channel | |
126 | } while (NextChannel()); | |
7dceaa9b | 127 | |
7c9a4e09 | 128 | return false; |
f8121cb1 | 129 | } |
130 | ||
7dceaa9b | 131 | const UInt_t* AliHLTTPCDigitReaderDecoder::GetSignals() |
f8121cb1 | 132 | { |
133 | // see header file for class documentation | |
7dceaa9b | 134 | return fAltroBunch->GetData(); |
f8121cb1 | 135 | } |
136 | ||
137 | int AliHLTTPCDigitReaderDecoder::GetRow() | |
138 | { | |
139 | // see header file for class documentation | |
7dceaa9b | 140 | return fMapping->GetRow(fAltroData.GetHadd()); |
f8121cb1 | 141 | } |
142 | ||
143 | int AliHLTTPCDigitReaderDecoder::GetPad() | |
144 | { | |
145 | // see header file for class documentation | |
7dceaa9b | 146 | return fMapping->GetPad(fAltroData.GetHadd()); |
f8121cb1 | 147 | } |
148 | ||
149 | int AliHLTTPCDigitReaderDecoder::GetSignal() | |
150 | { | |
151 | // see header file for class documentation | |
7c9a4e09 | 152 | if (fNextSignalMethodUsed) { |
153 | const UInt_t* pData=GetSignals(); | |
154 | if (pData && fNextCounter>=0) { | |
155 | assert(fNextCounter<GetBunchSize()); | |
156 | return pData[fNextCounter]; | |
157 | } | |
158 | } | |
f8121cb1 | 159 | return 0; |
160 | } | |
161 | ||
162 | int AliHLTTPCDigitReaderDecoder::GetTime() | |
163 | { | |
164 | // see header file for class documentation | |
092a1374 | 165 | int iResult=0; |
7dceaa9b | 166 | if(!fNextSignalMethodUsed){// this is true if the bunch approach is used |
092a1374 | 167 | |
168 | iResult= fAltroBunch->GetStartTimeBin(); | |
7dceaa9b | 169 | } |
170 | else{ | |
7c9a4e09 | 171 | assert(fNextCounter>=0); |
092a1374 | 172 | iResult = fAltroBunch->GetStartTimeBin()+fNextCounter; |
7dceaa9b | 173 | } |
092a1374 | 174 | if(iResult<0 || iResult>AliHLTTPCTransform::GetNTimeBins()){ |
175 | iResult=0; | |
176 | } | |
177 | return iResult; | |
7dceaa9b | 178 | } |
179 | ||
180 | int AliHLTTPCDigitReaderDecoder::GetBunchSize() | |
181 | { | |
7c9a4e09 | 182 | // see header file for class documentation |
7dceaa9b | 183 | return fAltroBunch->GetBunchSize(); |
f8121cb1 | 184 | } |
7c9a4e09 | 185 | |
d2f725e4 | 186 | int AliHLTTPCDigitReaderDecoder::GetRowOffset() const |
187 | { | |
188 | return fMapping->GetRowOffset(); | |
189 | } | |
7c9a4e09 | 190 | AliHLTUInt32_t AliHLTTPCDigitReaderDecoder::GetAltroBlockHWaddr() const |
191 | { | |
192 | // see header file for class documentation | |
193 | return (AliHLTUInt32_t)fAltroData.GetHadd(); | |
194 | } | |
092a1374 | 195 | AliHLTUInt32_t AliHLTTPCDigitReaderDecoder::GetAltroBlockHWaddr(Int_t row, Int_t pad) const |
196 | { | |
197 | // see header file for class documentation | |
198 | if(fMapping){ | |
199 | return fMapping->GetHwAddress(row,pad); | |
200 | } | |
201 | else{ | |
202 | return 0; | |
203 | } | |
204 | } |