]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCMapping.cxx
changes by Kenneth
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCMapping.cxx
CommitLineData
7e914051 1// $Id$
7dceaa9b 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: Kenneth Aamodt <kenneth@ift.uib.no> *
7 * for The ALICE HLT Project. *
8 * *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
17
18/** @file AliHLTTPCMapping.cxx
19 @author Kenneth Aamodt
20 @date
21 @brief A mapping class for the TPC.
22*/
23
24// see header file for class documentation //
25// or //
26// refer to README to build package //
27// or //
28// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt //
29
30#if __GNUC__>= 3
31using namespace std;
32#endif
33#include <cassert>
34#include "AliHLTTPCMapping.h"
35
36ClassImp(AliHLTTPCMapping)
37
38AliHLTTPCMapping::AliHLTTPCMapping(UInt_t patch)
39 :
7dceaa9b 40 fCurrentRowMapping(NULL),
a74855c2 41 fCurrentPadMapping(NULL),
42 fNHWAdd(0),
43 fMaxHWAdd(0)
7dceaa9b 44{
45 // see header file for class documentation
46 // or
47 // refer to README to build package
48 // or
49 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
50
51 switch(patch){
52 case 0:
a74855c2 53 if(!fgMapping0IsDone){
7dceaa9b 54 memset(fgRowMapping0, 0, fgkMapping0Size*sizeof(UInt_t));
55 memset(fgPadMapping0, 0, fgkMapping0Size*sizeof(UInt_t));
56 InitializeMap(patch);
57 }
58 fCurrentRowMapping=fgRowMapping0;
59 fCurrentPadMapping=fgPadMapping0;
60 break;
61 case 1:
a74855c2 62 if(!fgMapping1IsDone){
7dceaa9b 63 memset(fgRowMapping1, 0, fgkMapping1Size*sizeof(UInt_t));
64 memset(fgPadMapping1, 0, fgkMapping1Size*sizeof(UInt_t));
65 InitializeMap(patch);
66 }
67 fCurrentRowMapping=fgRowMapping1;
68 fCurrentPadMapping=fgPadMapping1;
69 break;
70 case 2:
a74855c2 71 if(!fgMapping2IsDone){
7dceaa9b 72 memset(fgRowMapping2, 0, fgkMapping2Size*sizeof(UInt_t));
73 memset(fgPadMapping2, 0, fgkMapping2Size*sizeof(UInt_t));
74 InitializeMap(patch);
75 }
76 fCurrentRowMapping=fgRowMapping2;
77 fCurrentPadMapping=fgPadMapping2;
78 break;
79 case 3:
a74855c2 80 if(!fgMapping3IsDone){
7dceaa9b 81 memset(fgRowMapping3, 0, fgkMapping3Size*sizeof(UInt_t));
82 memset(fgPadMapping3, 0, fgkMapping3Size*sizeof(UInt_t));
83 InitializeMap(patch);
84 }
85 fCurrentRowMapping=fgRowMapping3;
86 fCurrentPadMapping=fgPadMapping3;
87 break;
88 case 4:
a74855c2 89 if(!fgMapping4IsDone){
7dceaa9b 90 memset(fgRowMapping4, 0, fgkMapping4Size*sizeof(UInt_t));
91 memset(fgPadMapping4, 0, fgkMapping4Size*sizeof(UInt_t));
92 InitializeMap(patch);
93 }
94 fCurrentRowMapping=fgRowMapping4;
95 fCurrentPadMapping=fgPadMapping4;
96 break;
97 case 5:
a74855c2 98 if(!fgMapping5IsDone){
7dceaa9b 99 memset(fgRowMapping5, 0, fgkMapping5Size*sizeof(UInt_t));
100 memset(fgPadMapping5, 0, fgkMapping5Size*sizeof(UInt_t));
101 InitializeMap(patch);
102 }
103 fCurrentRowMapping=fgRowMapping5;
104 fCurrentPadMapping=fgPadMapping5;
105 break;
106 }
107}
108
a74855c2 109Bool_t AliHLTTPCMapping::fgMapping0IsDone=kFALSE;
110Bool_t AliHLTTPCMapping::fgMapping1IsDone=kFALSE;
111Bool_t AliHLTTPCMapping::fgMapping2IsDone=kFALSE;
112Bool_t AliHLTTPCMapping::fgMapping3IsDone=kFALSE;
113Bool_t AliHLTTPCMapping::fgMapping4IsDone=kFALSE;
114Bool_t AliHLTTPCMapping::fgMapping5IsDone=kFALSE;
7dceaa9b 115UInt_t AliHLTTPCMapping::fgRowMapping0[fgkMapping0Size];
116UInt_t AliHLTTPCMapping::fgPadMapping0[fgkMapping0Size];
117UInt_t AliHLTTPCMapping::fgRowMapping1[fgkMapping1Size];
118UInt_t AliHLTTPCMapping::fgPadMapping1[fgkMapping1Size];
119UInt_t AliHLTTPCMapping::fgRowMapping2[fgkMapping2Size];
120UInt_t AliHLTTPCMapping::fgPadMapping2[fgkMapping2Size];
121UInt_t AliHLTTPCMapping::fgRowMapping3[fgkMapping3Size];
122UInt_t AliHLTTPCMapping::fgPadMapping3[fgkMapping3Size];
123UInt_t AliHLTTPCMapping::fgRowMapping4[fgkMapping4Size];
124UInt_t AliHLTTPCMapping::fgPadMapping4[fgkMapping4Size];
125UInt_t AliHLTTPCMapping::fgRowMapping5[fgkMapping5Size];
126UInt_t AliHLTTPCMapping::fgPadMapping5[fgkMapping5Size];
127
128AliHLTTPCMapping::~AliHLTTPCMapping(){
129 // see header file for class documentation
130}
131
132void AliHLTTPCMapping::InitializeMap(UInt_t patch)
133{
134 // see header file for class documentation
135
136 UInt_t fNRowsToSubtract=0;
137 //The row numbers returned by digit readers used are not from zero always
138 switch(patch){
139 case 0:
140 fNRowsToSubtract=0;
141 break;
142 case 1:
143 fNRowsToSubtract=30;
144 break;
145 case 2:
146 fNRowsToSubtract=0;
147 break;
148 case 3:
149 fNRowsToSubtract=27;
150 break;
151 case 4:
152 fNRowsToSubtract=54;
153 break;
154 case 5:
155 fNRowsToSubtract=76;
156 break;
157 }
158
159 //Making mapping arrays for the given patch
160 ifstream inFile;
161 TString filename;
162 const char* basePath=getenv("ALICE_ROOT");
163 if (basePath) {
164 filename.Form("%s/TPC/mapping/Patch%d.data", basePath,patch);
165 }
166 inFile.open(filename.Data());
167 if (!inFile) {
168 HLTFatal("Unable to open file: %s This means no mapping is provided.", filename.Data());
169 }
170 else{
171 fNHWAdd=0;
172 if(inFile >> fNHWAdd){
173 if(inFile >> fMaxHWAdd){
174 UInt_t hwAdd=0;
175 UInt_t row=0;
176 UInt_t pad=0;
177 switch(patch){
178 case 0:
179 if(fgkMapping0Size<fMaxHWAdd){
180 HLTFatal("Max hardware address exceeded for patch %d, max number is %d, number from mapping file is %d.",patch,fgkMapping0Size ,fMaxHWAdd);
181 break;
182 }
183 while(inFile>>hwAdd && inFile>>row && inFile>>pad){
8252a538 184 if (hwAdd>fMaxHWAdd) {
7dceaa9b 185 HLTFatal("hardware address exceeds max hwAddress %d, mapping file %s corrupted?", fMaxHWAdd);
186 break;
187 }
188 fgRowMapping0[hwAdd]=row-fNRowsToSubtract;
189 fgPadMapping0[hwAdd]=pad;
190 }
a74855c2 191 fgMapping0IsDone=kTRUE;
7dceaa9b 192 break;
193 case 1:
194 if(fgkMapping1Size<fMaxHWAdd){
195 HLTFatal("Max hardware address exceeded for patch %d, max number is %d, number from mapping file is %d.",patch,fgkMapping1Size ,fMaxHWAdd);
196 break;
197 }
198 while(inFile>>hwAdd && inFile>>row && inFile>>pad){
8252a538 199 if (hwAdd>fMaxHWAdd) {
7dceaa9b 200 HLTFatal("hardware address exceeds max hwAddress %d, mapping file %s corrupted?", fMaxHWAdd);
201 break;
202 }
203 fgRowMapping1[hwAdd]=row-fNRowsToSubtract;
204 fgPadMapping1[hwAdd]=pad;
205 }
a74855c2 206 fgMapping1IsDone=kTRUE;
7dceaa9b 207 break;
208 case 2:
209 if(fgkMapping2Size<fMaxHWAdd){
210 HLTFatal("Max hardware address exceeded for patch %d, max number is %d number from mapping file is %d.",patch,fgkMapping2Size ,fMaxHWAdd);
211 break;
212 }
213 while(inFile>>hwAdd && inFile>>row && inFile>>pad){
8252a538 214 if (hwAdd>fMaxHWAdd) {
7dceaa9b 215 HLTFatal("hardware address exceeds max hwAddress %d, mapping file %s corrupted?", fMaxHWAdd);
216 break;
217 }
218 fgRowMapping2[hwAdd]=row-fNRowsToSubtract;
219 fgPadMapping2[hwAdd]=pad;
220 }
a74855c2 221 fgMapping2IsDone=kTRUE;
7dceaa9b 222 break;
223 case 3:
224 if(fgkMapping3Size<fMaxHWAdd){
225 HLTFatal("Max hardware address exceeded for patch %d, max number is %d number from mapping file is %d.",patch,fgkMapping3Size ,fMaxHWAdd);
226 break;
227 }
228 while(inFile>>hwAdd && inFile>>row && inFile>>pad){
8252a538 229 if (hwAdd>fMaxHWAdd) {
7dceaa9b 230 HLTFatal("hardware address exceeds max hwAddress %d, mapping file %s corrupted?", fMaxHWAdd);
231 break;
232 }
233 fgRowMapping3[hwAdd]=row-fNRowsToSubtract;
234 fgPadMapping3[hwAdd]=pad;
235 }
a74855c2 236 fgMapping3IsDone=kTRUE;
7dceaa9b 237 break;
238 case 4:
239 if(fgkMapping4Size<fMaxHWAdd){
240 HLTFatal("Max hardware address exceeded for patch %d, max number is %d number from mapping file is %d.",patch,fgkMapping4Size ,fMaxHWAdd);
241 break;
242 }
243 while(inFile>>hwAdd && inFile>>row && inFile>>pad){
8252a538 244 if (hwAdd>fMaxHWAdd) {
7dceaa9b 245 HLTFatal("hardware address exceeds max hwAddress %d, mapping file %s corrupted?", fMaxHWAdd);
246 break;
247 }
248 fgRowMapping4[hwAdd]=row-fNRowsToSubtract;
249 fgPadMapping4[(UInt_t)hwAdd]=(UInt_t)pad;
250 }
a74855c2 251 fgMapping4IsDone=kTRUE;
7dceaa9b 252 break;
253 case 5:
254 if(fgkMapping5Size<fMaxHWAdd){
255 HLTFatal("Max hardware address exceeded for patch %d, max number is %d number from mapping file is %d.",patch,fgkMapping5Size ,fMaxHWAdd);
256 break;
257 }
258 while(inFile>>hwAdd && inFile>>row && inFile>>pad){
8252a538 259 if (hwAdd>fMaxHWAdd) {
7dceaa9b 260 HLTFatal("hardware address exceeds max hwAddress %d, mapping file %s corrupted?", fMaxHWAdd);
261 break;
262 }
263 fgRowMapping5[hwAdd]=row-fNRowsToSubtract;
264 fgPadMapping5[hwAdd]=pad;
265 }
a74855c2 266 fgMapping5IsDone=kTRUE;
7dceaa9b 267 break;
268 }
269 }
270 }
271 }
272 inFile.close();
273}
274
a74855c2 275UInt_t AliHLTTPCMapping::GetRow(UInt_t hwadd) const
7dceaa9b 276{
277 // see header file for class documentation
278 assert(fCurrentRowMapping);
70a4e20c 279 // assert(hwadd<=fMaxHWAdd);
7dceaa9b 280 if (!fCurrentRowMapping) return 0;
70a4e20c 281 if (hwadd>fMaxHWAdd) return 1000;
7dceaa9b 282 return fCurrentRowMapping[hwadd];
283}
284
a74855c2 285UInt_t AliHLTTPCMapping::GetPad(UInt_t hwadd) const
7dceaa9b 286{
287 // see header file for class documentation
288 assert(fCurrentPadMapping);
70a4e20c 289 // assert(hwadd<=fMaxHWAdd);
7dceaa9b 290 if (!fCurrentPadMapping) return 0;
70a4e20c 291 if (hwadd>fMaxHWAdd) return 1000;
7dceaa9b 292 return fCurrentPadMapping[hwadd];
293}