]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCDigitReader32Bit.cxx
including cmath to be consistent with macosx
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCDigitReader32Bit.cxx
1
2 //**************************************************************************
3 //* This file is property of and copyright by the ALICE HLT Project        * 
4 //* ALICE Experiment at CERN, All rights reserved.                         *
5 //*                                                                        *
6 //* Primary 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 HLT 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 /** @file   AliHLTTPCDigitReader32Bit.cxx
21     @author Kenneth Aamodt
22     @date   
23     @brief  DigitReader implementation for the 32 bit offline decoder
24 */
25
26 #if __GNUC__>= 3
27 using namespace std;
28 #endif
29
30 #include <cassert>
31 #include "AliHLTTPCDigitReader32Bit.h"
32 #include "AliHLTTPCMapping.h"
33 #include "AliRawReader.h"
34 #include "AliRawReaderMemory.h"
35 #ifndef HAVE_NOT_ALTRORAWSTREAMV3
36 #include "AliAltroRawStreamV3.h"
37 #endif //HAVE_NOT_ALTRORAWSTREAMV3
38 #include "AliHLTTPCTransform.h"
39
40 ClassImp(AliHLTTPCDigitReader32Bit)
41
42 AliHLTTPCDigitReader32Bit::AliHLTTPCDigitReader32Bit()
43   :
44   AliHLTTPCDigitReader(),
45   fRawReaderMemory(NULL),
46   fAltroRawStreamV3(NULL),
47   fMapping(NULL),
48   fSkipDataReadingFlag(kFALSE)
49 {
50   // see header file for class documentation
51   // or
52   // refer to README to build package
53   // or
54   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
55   
56   // initlialized here to get more accurate comparison with the 
57   // digitReaderDecoder when using SimpleComponentWrapper
58   if(fRawReaderMemory ==NULL){
59     fRawReaderMemory = new AliRawReaderMemory();
60   }
61 }
62
63 AliHLTTPCDigitReader32Bit::~AliHLTTPCDigitReader32Bit()
64 {
65   // see header file for class documentation
66   if (fRawReaderMemory){
67     delete fRawReaderMemory;
68     fRawReaderMemory=NULL;
69   }
70
71 #ifndef HAVE_NOT_ALTRORAWSTREAMV3
72   if (fAltroRawStreamV3){
73     delete fAltroRawStreamV3;
74     fAltroRawStreamV3 = NULL;
75   }
76 #endif //HAVE_NOT_ALTRORAWSTREAMV3
77
78   if(fMapping){
79     delete fMapping;
80   }
81 }
82
83 int AliHLTTPCDigitReader32Bit::InitBlock(void* ptr,unsigned long size, Int_t patch, Int_t slice)
84 {
85   // see header file for class documentation
86   
87   Int_t ddlno=768;
88   if (patch>1) ddlno+=72+4*slice+(patch-2);
89   else ddlno+=2*slice+patch;
90
91   if(fRawReaderMemory == NULL){
92     fRawReaderMemory = new AliRawReaderMemory();
93   }
94   if(!fRawReaderMemory){
95     return -ENODEV;
96   }
97   fRawReaderMemory->SetMemory(reinterpret_cast<UChar_t*>(ptr), ULong_t(size));
98   fRawReaderMemory->SetEquipmentID(ddlno);
99   fRawReaderMemory->Reset();
100   fSkipDataReadingFlag = fRawReaderMemory->NextEvent();
101
102 #ifndef HAVE_NOT_ALTRORAWSTREAMV3
103   if(fAltroRawStreamV3 != NULL){
104     delete fAltroRawStreamV3;
105     fAltroRawStreamV3=NULL;
106   }
107   fAltroRawStreamV3= new AliAltroRawStreamV3(fRawReaderMemory);
108
109   if (!fAltroRawStreamV3){
110     return -ENODEV;
111   }
112
113   fSkipDataReadingFlag = fAltroRawStreamV3->NextDDL();
114
115 #else
116   HLTError("AltroRawStreamV3 is not available in this AliRoot version");
117 #endif //HAVE_NOT_ALTRORAWSTREAMV3
118
119   if(!fMapping){
120     fMapping = new AliHLTTPCMapping(patch);
121     if(!fMapping){
122       return -ENODEV;
123     }
124   }
125   return 0;
126 }
127
128 int AliHLTTPCDigitReader32Bit::Reset()
129 {
130   // see header file for class documentation
131   fRawReaderMemory->ClearBuffers();
132   return 0;
133 }
134
135 void AliHLTTPCDigitReader32Bit::SetUnsorted(bool unsorted)
136 {
137   // see header file for class documentation
138
139   // The DigitReaderDecoder does not support sorted data, forward to
140   // default if sorted data requested
141   if (!unsorted) AliHLTTPCDigitReader::SetUnsorted(unsorted);
142 }
143
144 bool AliHLTTPCDigitReader32Bit::NextChannel()
145 {
146   // see header file for class documentation
147   if(fSkipDataReadingFlag == kFALSE){
148     return kFALSE;
149   }
150
151 #ifndef HAVE_NOT_ALTRORAWSTREAMV3
152   return fAltroRawStreamV3->NextChannel(); 
153 #else
154   return false;
155 #endif //HAVE_NOT_ALTRORAWSTREAMV3
156
157 }
158
159 int AliHLTTPCDigitReader32Bit::NextBunch()
160 {
161   // see header file for class documentation
162 #ifndef HAVE_NOT_ALTRORAWSTREAMV3
163   return fAltroRawStreamV3->NextBunch();
164 #else
165   return -1;
166 #endif //HAVE_NOT_ALTRORAWSTREAMV3
167 }
168
169 bool AliHLTTPCDigitReader32Bit::NextSignal()
170 {
171   // see header file for class documentation
172   return false;
173 }
174
175 const UInt_t* AliHLTTPCDigitReader32Bit::GetSignals()
176 {
177   // see header file for class documentation
178   HLTError("AliHLTTPCDigitReader32Bit does not support the UInt_t* format, use GetSignalsShort instead");
179   return 0;
180 }
181
182 const UShort_t* AliHLTTPCDigitReader32Bit::GetSignalsShort()
183 {
184   // see header file for class documentation
185 #ifndef HAVE_NOT_ALTRORAWSTREAMV3
186   return fAltroRawStreamV3->GetSignals();
187 #else
188   return NULL;
189 #endif //HAVE_NOT_ALTRORAWSTREAMV3
190 }
191
192 int AliHLTTPCDigitReader32Bit::GetRow()
193 {
194   // see header file for class documentation
195 #ifndef HAVE_NOT_ALTRORAWSTREAMV3
196   return fMapping->GetRow(fAltroRawStreamV3->GetHWAddress());
197 #else
198   return -1;
199 #endif //HAVE_NOT_ALTRORAWSTREAMV3
200 }
201
202 int AliHLTTPCDigitReader32Bit::GetPad()
203 {
204   // see header file for class documentation
205 #ifndef HAVE_NOT_ALTRORAWSTREAMV3
206   return fMapping->GetPad(fAltroRawStreamV3->GetHWAddress());
207 #else
208   return -1;
209 #endif //HAVE_NOT_ALTRORAWSTREAMV3
210 }
211
212 int AliHLTTPCDigitReader32Bit::GetSignal()
213 {
214   // see header file for class documentation
215   return 0;
216 }
217
218 int AliHLTTPCDigitReader32Bit::GetTime()
219 {
220   // see header file for class documentation
221   int iResult=-1;
222 #ifndef HAVE_NOT_ALTRORAWSTREAMV3
223   iResult=fAltroRawStreamV3->GetStartTimeBin()-fAltroRawStreamV3->GetBunchLength()+1;
224 #endif //HAVE_NOT_ALTRORAWSTREAMV3
225   return iResult;
226 }
227
228 int AliHLTTPCDigitReader32Bit::GetBunchSize()
229 {
230   // see header file for class documentation
231 #ifndef HAVE_NOT_ALTRORAWSTREAMV3
232   return fAltroRawStreamV3->GetBunchLength();
233 #else
234   return -1;
235 #endif //HAVE_NOT_ALTRORAWSTREAMV3
236 }
237
238 int AliHLTTPCDigitReader32Bit::GetRowOffset() const
239 {
240   return fMapping->GetRowOffset();
241 }
242
243 AliHLTUInt32_t AliHLTTPCDigitReader32Bit::GetAltroBlockHWaddr() const
244 {
245   // see header file for class documentation
246 #ifndef HAVE_NOT_ALTRORAWSTREAMV3
247   return (AliHLTUInt32_t)fAltroRawStreamV3->GetHWAddress();
248 #else
249   return 0;
250 #endif //HAVE_NOT_ALTRORAWSTREAMV3
251 }
252
253 AliHLTUInt32_t AliHLTTPCDigitReader32Bit::GetAltroBlockHWaddr(Int_t row, Int_t pad) const
254 {
255   // see header file for class documentation
256   if(fMapping){
257     return fMapping->GetHwAddress(row,pad);
258   }
259   else{
260     return 0;
261   }
262 }
263
264 int AliHLTTPCDigitReader32Bit::GetRCUTrailerSize()
265 {
266   // see header file for class documentation
267   return 0;
268 }
269
270 bool AliHLTTPCDigitReader32Bit::GetRCUTrailerData(UChar_t*& /*trData*/)
271 {
272   // see header file for class documentation
273   return false;
274 }