1 // $Id: AliHLTTPCDigitReaderRaw.cxx 22518 2007-11-26 23:19:47Z richterm $
2 /**************************************************************************
3 * This file is property of and copyright by the ALICE HLT Project *
4 * ALICE Experiment at CERN, All rights reserved. *
6 * Primary Authors: Kenneth Aamodt <kenneth@ift.uib.no> *
7 * for The ALICE HLT Project. *
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 **************************************************************************/
18 /** @file AliHLTTPCMapping.cxx
19 @author Kenneth Aamodt
21 @brief A mapping class for the TPC.
24 // see header file for class documentation //
26 // refer to README to build package //
28 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt //
34 #include "AliHLTTPCMapping.h"
36 ClassImp(AliHLTTPCMapping)
38 AliHLTTPCMapping::AliHLTTPCMapping(UInt_t patch)
42 fCurrentRowMapping(NULL),
43 fCurrentPadMapping(NULL)
45 // see header file for class documentation
47 // refer to README to build package
49 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
54 memset(fgRowMapping0, 0, fgkMapping0Size*sizeof(UInt_t));
55 memset(fgPadMapping0, 0, fgkMapping0Size*sizeof(UInt_t));
58 fCurrentRowMapping=fgRowMapping0;
59 fCurrentPadMapping=fgPadMapping0;
63 memset(fgRowMapping1, 0, fgkMapping1Size*sizeof(UInt_t));
64 memset(fgPadMapping1, 0, fgkMapping1Size*sizeof(UInt_t));
67 fCurrentRowMapping=fgRowMapping1;
68 fCurrentPadMapping=fgPadMapping1;
72 memset(fgRowMapping2, 0, fgkMapping2Size*sizeof(UInt_t));
73 memset(fgPadMapping2, 0, fgkMapping2Size*sizeof(UInt_t));
76 fCurrentRowMapping=fgRowMapping2;
77 fCurrentPadMapping=fgPadMapping2;
81 memset(fgRowMapping3, 0, fgkMapping3Size*sizeof(UInt_t));
82 memset(fgPadMapping3, 0, fgkMapping3Size*sizeof(UInt_t));
85 fCurrentRowMapping=fgRowMapping3;
86 fCurrentPadMapping=fgPadMapping3;
90 memset(fgRowMapping4, 0, fgkMapping4Size*sizeof(UInt_t));
91 memset(fgPadMapping4, 0, fgkMapping4Size*sizeof(UInt_t));
94 fCurrentRowMapping=fgRowMapping4;
95 fCurrentPadMapping=fgPadMapping4;
99 memset(fgRowMapping5, 0, fgkMapping5Size*sizeof(UInt_t));
100 memset(fgPadMapping5, 0, fgkMapping5Size*sizeof(UInt_t));
101 InitializeMap(patch);
103 fCurrentRowMapping=fgRowMapping5;
104 fCurrentPadMapping=fgPadMapping5;
109 Bool_t AliHLTTPCMapping::fMapping0IsDone=kFALSE;
110 Bool_t AliHLTTPCMapping::fMapping1IsDone=kFALSE;
111 Bool_t AliHLTTPCMapping::fMapping2IsDone=kFALSE;
112 Bool_t AliHLTTPCMapping::fMapping3IsDone=kFALSE;
113 Bool_t AliHLTTPCMapping::fMapping4IsDone=kFALSE;
114 Bool_t AliHLTTPCMapping::fMapping5IsDone=kFALSE;
115 UInt_t AliHLTTPCMapping::fgRowMapping0[fgkMapping0Size];
116 UInt_t AliHLTTPCMapping::fgPadMapping0[fgkMapping0Size];
117 UInt_t AliHLTTPCMapping::fgRowMapping1[fgkMapping1Size];
118 UInt_t AliHLTTPCMapping::fgPadMapping1[fgkMapping1Size];
119 UInt_t AliHLTTPCMapping::fgRowMapping2[fgkMapping2Size];
120 UInt_t AliHLTTPCMapping::fgPadMapping2[fgkMapping2Size];
121 UInt_t AliHLTTPCMapping::fgRowMapping3[fgkMapping3Size];
122 UInt_t AliHLTTPCMapping::fgPadMapping3[fgkMapping3Size];
123 UInt_t AliHLTTPCMapping::fgRowMapping4[fgkMapping4Size];
124 UInt_t AliHLTTPCMapping::fgPadMapping4[fgkMapping4Size];
125 UInt_t AliHLTTPCMapping::fgRowMapping5[fgkMapping5Size];
126 UInt_t AliHLTTPCMapping::fgPadMapping5[fgkMapping5Size];
128 AliHLTTPCMapping::~AliHLTTPCMapping(){
129 // see header file for class documentation
132 void AliHLTTPCMapping::InitializeMap(UInt_t patch)
134 // see header file for class documentation
136 UInt_t fNRowsToSubtract=0;
137 //The row numbers returned by digit readers used are not from zero always
159 //Making mapping arrays for the given patch
162 const char* basePath=getenv("ALICE_ROOT");
164 filename.Form("%s/TPC/mapping/Patch%d.data", basePath,patch);
166 inFile.open(filename.Data());
168 HLTFatal("Unable to open file: %s This means no mapping is provided.", filename.Data());
172 if(inFile >> fNHWAdd){
173 if(inFile >> fMaxHWAdd){
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);
183 while(inFile>>hwAdd && inFile>>row && inFile>>pad){
184 if (hwAdd>=fMaxHWAdd) {
185 HLTFatal("hardware address exceeds max hwAddress %d, mapping file %s corrupted?", fMaxHWAdd);
188 fgRowMapping0[hwAdd]=row-fNRowsToSubtract;
189 fgPadMapping0[hwAdd]=pad;
191 fMapping0IsDone=kTRUE;
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);
198 while(inFile>>hwAdd && inFile>>row && inFile>>pad){
199 if (hwAdd>=fMaxHWAdd) {
200 HLTFatal("hardware address exceeds max hwAddress %d, mapping file %s corrupted?", fMaxHWAdd);
203 fgRowMapping1[hwAdd]=row-fNRowsToSubtract;
204 fgPadMapping1[hwAdd]=pad;
206 fMapping1IsDone=kTRUE;
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);
213 while(inFile>>hwAdd && inFile>>row && inFile>>pad){
214 if (hwAdd>=fMaxHWAdd) {
215 HLTFatal("hardware address exceeds max hwAddress %d, mapping file %s corrupted?", fMaxHWAdd);
218 fgRowMapping2[hwAdd]=row-fNRowsToSubtract;
219 fgPadMapping2[hwAdd]=pad;
221 fMapping2IsDone=kTRUE;
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);
228 while(inFile>>hwAdd && inFile>>row && inFile>>pad){
229 if (hwAdd>=fMaxHWAdd) {
230 HLTFatal("hardware address exceeds max hwAddress %d, mapping file %s corrupted?", fMaxHWAdd);
233 fgRowMapping3[hwAdd]=row-fNRowsToSubtract;
234 fgPadMapping3[hwAdd]=pad;
236 fMapping3IsDone=kTRUE;
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);
243 while(inFile>>hwAdd && inFile>>row && inFile>>pad){
244 if (hwAdd>=fMaxHWAdd) {
245 HLTFatal("hardware address exceeds max hwAddress %d, mapping file %s corrupted?", fMaxHWAdd);
248 fgRowMapping4[hwAdd]=row-fNRowsToSubtract;
249 fgPadMapping4[(UInt_t)hwAdd]=(UInt_t)pad;
251 fMapping4IsDone=kTRUE;
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);
258 while(inFile>>hwAdd && inFile>>row && inFile>>pad){
259 if (hwAdd>=fMaxHWAdd) {
260 HLTFatal("hardware address exceeds max hwAddress %d, mapping file %s corrupted?", fMaxHWAdd);
263 fgRowMapping5[hwAdd]=row-fNRowsToSubtract;
264 fgPadMapping5[hwAdd]=pad;
266 fMapping5IsDone=kTRUE;
275 UInt_t AliHLTTPCMapping::GetRow(UInt_t hwadd)
277 // see header file for class documentation
278 assert(fCurrentRowMapping);
279 assert(hwadd<fMaxHWAdd);
280 if (!fCurrentRowMapping) return 0;
281 if (hwadd>=fMaxHWAdd) return 0;
282 return fCurrentRowMapping[hwadd];
285 UInt_t AliHLTTPCMapping::GetPad(UInt_t hwadd)
287 // see header file for class documentation
288 assert(fCurrentPadMapping);
289 assert(hwadd<fMaxHWAdd);
290 if (!fCurrentPadMapping) return 0;
291 if (hwadd>=fMaxHWAdd) return 0;
292 return fCurrentPadMapping[hwadd];