]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCDigitReader.cxx
code cleanup: check for valid channel address and row offset handled by TPC mapping...
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCDigitReader.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   AliHLTTPCDigitReader.cxx
22     @author Timm Steinbeck, Jochen Thaeder, Matthias Richter, Kenneth Aamodt
23     @date   
24     @brief  An abstract reader class for TPC data.
25 */
26
27 // see header file for class documentation
28 // or
29 // refer to README to build package
30 // or
31 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
32
33 #if __GNUC__>= 3
34 using namespace std;
35 #endif
36
37 #include "AliHLTTPCDigitReader.h"
38 #include "AliHLTTPCTransform.h"
39 #include "AliHLTStdIncludes.h"
40
41 ClassImp(AliHLTTPCDigitReader)
42
43 AliHLTTPCDigitReader::AliHLTTPCDigitReader()
44   :
45   fFlags(0),
46   fLckRow(-1),
47   fLckPad(-1)
48 {
49   // see header file for class documentation
50   // or
51   // refer to README to build package
52   // or
53   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
54 }
55
56 AliHLTTPCDigitReader::~AliHLTTPCDigitReader()
57 {
58   // see header file for class documentation
59 }
60
61 int AliHLTTPCDigitReader::InitBlock(void* ptr,unsigned long size,Int_t firstrow,Int_t lastrow, Int_t patch, Int_t slice)
62 {
63   // see header file for class documentation
64   if (patch<0 || patch>=AliHLTTPCTransform::GetNumberOfPatches()) {
65     HLTError("invalid readout partition number %d", patch);
66     return -EINVAL;
67   }
68   if (firstrow!=AliHLTTPCTransform::GetFirstRow(patch)) {
69     HLTWarning("The firstrow parameter does not match the layout of the readout partition %d "
70                "(firstrow=%d). Parameter is ignored", patch, AliHLTTPCTransform::GetFirstRow(patch));
71   }
72   if (lastrow!=AliHLTTPCTransform::GetLastRow(patch)) {
73     HLTWarning("The lastrow parameter does not match the layout of the readout partition %d "
74                "(lastrow=%d). Parameter is ignored", patch, AliHLTTPCTransform::GetLastRow(patch));
75   }
76   return InitBlock(ptr, size, patch, slice);
77 }
78
79 void AliHLTTPCDigitReader::SetOldRCUFormat(Bool_t /*oldrcuformat*/)
80 {
81   // default method of the base class
82 }
83
84 void AliHLTTPCDigitReader::SetUnsorted(Bool_t /*unsorted*/)
85 {
86   // default method of the base class
87   HLTWarning("common sorting functionality has not yet been implemented");
88 }
89
90 bool AliHLTTPCDigitReader::Next(int /*type*/)
91 {
92   // see header file for class documentation
93   if (!CheckFlag(kLocked)) return NextSignal();
94
95   bool haveData=false;
96   if (!CheckFlag(kChannelOverwrap))
97     haveData=NextSignal();
98
99   if (haveData && (fLckRow!=GetRow() || fLckPad!=GetPad())) {
100     SetFlag(kChannelOverwrap);
101     haveData=false;
102   }
103
104   return haveData;
105 }
106
107 bool AliHLTTPCDigitReader::NextChannel()
108 {
109   // see header file for class documentation
110   PrintMissingFastAccessWarning();
111   return false;
112 }
113
114 int AliHLTTPCDigitReader::NextBunch()
115 {
116   // see header file for class documentation
117   PrintMissingFastAccessWarning();
118   return false;
119 }
120
121 const UInt_t* AliHLTTPCDigitReader::GetSignals()
122 {
123   // see header file for class documentation
124   PrintMissingFastAccessWarning();
125   return 0;
126 }
127
128 void AliHLTTPCDigitReader::EnableCaching(bool bCache)
129 {
130   // see header file for class documentation
131   if (bCache) SetFlag(kChannelCaching);
132   else ClearFlag(kChannelCaching);
133 }
134
135 int AliHLTTPCDigitReader::RewindChannel()
136 {
137   // see header file for class documentation
138   int iResult=0;
139   
140   return iResult;
141 }
142
143 unsigned int AliHLTTPCDigitReader::SetFlag(unsigned int flag)
144 {
145   // see header file for class documentation
146   return fFlags|=flag;
147 }
148         
149 unsigned int AliHLTTPCDigitReader::ClearFlag(unsigned int flag)
150 {
151   // see header file for class documentation
152   return fFlags&=~flag;
153 }
154
155 // int operator[](int timebin)
156 // {
157 //   return -1;
158 // }
159
160 int AliHLTTPCDigitReader::RewindCurrentChannel()
161 {
162   // see header file for class documentation
163   SetFlag(kNoRewind);
164   if (!CheckFlag(kChannelCaching)) return -ENODATA;
165   return -ENOSYS;
166 }
167
168 int AliHLTTPCDigitReader::RewindToPrevChannel()
169 {
170   // see header file for class documentation
171   SetFlag(kNoRewind);
172   if (!CheckFlag(kChannelCaching)) return -ENODATA;
173   return -ENOSYS;
174 }
175
176 int AliHLTTPCDigitReader::GetBunchSize()
177 {
178   // see header file for class documentation
179   PrintMissingFastAccessWarning();
180   return 0;
181 }
182
183 int AliHLTTPCDigitReader::GetRowOffset() const
184 {
185   // see header file for class documentation
186   return 0;
187 }
188
189 AliHLTUInt32_t AliHLTTPCDigitReader::GetAltroBlockHWaddr() const
190 {
191   return 0;
192 }
193
194 void AliHLTTPCDigitReader::PrintMissingFastAccessWarning()
195 {
196   // see header file for class documentation
197   if (CheckFlag(kWarnMissFastAccess)) return;
198   SetFlag(kWarnMissFastAccess);
199   HLTWarning("\n"
200              "      !!! This digit reader does not implement the methods for       !!!\n"
201              "      !!! fast data access on channel/bunch basis. Data is discarded !!!");
202 }