]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCDigitReaderDecoder.cxx
correcting minor compilation and runtime warnings
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCDigitReaderDecoder.cxx
1 // $Id$
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
31 #include <cassert>
32 #include "AliHLTTPCDigitReaderDecoder.h"
33 #include "AliHLTTPCMapping.h"
34 #include "AliAltroDecoder.h"
35 #include "AliAltroData.h"
36 #include "AliAltroBunch.h"
37 #include "AliHLTTPCTransform.h"
38
39 ClassImp(AliHLTTPCDigitReaderDecoder)
40
41 AliHLTTPCDigitReaderDecoder::AliHLTTPCDigitReaderDecoder()
42   :
43   AliHLTTPCDigitReader(),
44   fAltroDecoder(NULL),
45   fAltroData(),
46   fAltroBunch(NULL),
47   fMapping(NULL),
48   // initialization due to the logic in NextSignals
49   fNextCounter(-1),
50   fNextSignalMethodUsed(kFALSE)
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
62   if(fAltroDecoder){
63     delete fAltroDecoder;
64   }
65   if(fAltroBunch){
66     delete fAltroBunch;
67   }
68   if(fMapping){
69     delete fMapping;
70   }
71 }
72
73 int AliHLTTPCDigitReaderDecoder::InitBlock(void* ptr,unsigned long size, Int_t patch, Int_t /*slice*/)
74 {
75   // see header file for class documentation
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   }
86   fAltroDecoder->SetMemory((UChar_t*)ptr, size);
87   fAltroDecoder->Decode();
88   return 0;
89 }
90
91 void 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
100 bool AliHLTTPCDigitReaderDecoder::NextChannel()
101 {
102   // see header file for class documentation
103   Bool_t result=fAltroDecoder->NextChannel(&fAltroData);
104   if(result && !fMapping->IsValidHWAddress(fAltroData.GetHadd())){
105     result = fAltroDecoder->NextChannel(&fAltroData);
106   }
107   return result;
108 }
109
110 int AliHLTTPCDigitReaderDecoder::NextBunch()
111 {
112   // see header file for class documentation
113   return fAltroData.NextBunch(fAltroBunch);
114 }
115
116 bool AliHLTTPCDigitReaderDecoder::NextSignal()
117 {
118   // see header file for class documentation
119   fNextSignalMethodUsed=kTRUE;
120   do {
121     if (fNextCounter>0) {
122       // there is data available in the current bunch
123       fNextCounter--;
124       return true;
125     }
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;
131     }
132
133     fNextCounter=-1;
134     // there is no bunch left, go to the next channel
135   } while (NextChannel());
136   
137   return false;
138 }
139
140 const UInt_t* AliHLTTPCDigitReaderDecoder::GetSignals()
141 {
142   // see header file for class documentation
143   return fAltroBunch->GetData();
144 }
145
146 int AliHLTTPCDigitReaderDecoder::GetRow()
147 {
148   // see header file for class documentation
149   return fMapping->GetRow(fAltroData.GetHadd());
150 }
151
152 int AliHLTTPCDigitReaderDecoder::GetPad()
153 {
154   // see header file for class documentation
155   return fMapping->GetPad(fAltroData.GetHadd());
156 }
157
158 int AliHLTTPCDigitReaderDecoder::GetSignal()
159 {
160   // see header file for class documentation
161   if (fNextSignalMethodUsed) {
162     const  UInt_t* pData=GetSignals();
163     if (pData && fNextCounter>=0) {
164       assert(fNextCounter<GetBunchSize());
165       return pData[fNextCounter];
166     }
167   }
168   return 0;
169 }
170
171 int AliHLTTPCDigitReaderDecoder::GetTime()
172 {
173   // see header file for class documentation
174   int iResult=0;
175   if(!fNextSignalMethodUsed){// this is true if the bunch approach is used
176     
177     iResult= fAltroBunch->GetStartTimeBin();
178   }
179   else{
180     assert(fNextCounter>=0);
181     iResult = fAltroBunch->GetStartTimeBin()+fNextCounter;
182   }
183   if(iResult<0 || iResult>AliHLTTPCTransform::GetNTimeBins()){
184     iResult=0;
185   }
186   return iResult;
187 }
188
189 int AliHLTTPCDigitReaderDecoder::GetBunchSize()
190 {
191   // see header file for class documentation
192   return fAltroBunch->GetBunchSize();
193 }
194
195 int AliHLTTPCDigitReaderDecoder::GetRowOffset() const
196 {
197   return fMapping->GetRowOffset();
198 }
199 AliHLTUInt32_t AliHLTTPCDigitReaderDecoder::GetAltroBlockHWaddr() const
200 {
201   // see header file for class documentation
202   return (AliHLTUInt32_t)fAltroData.GetHadd();
203 }
204 AliHLTUInt32_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 }