]>
Commit | Line | Data |
---|---|---|
1 | // @(#) $Id$ | |
2 | ||
3 | // Author: Constantin Loizides <mailto:loizides@ikf.uni-frankfurt.de> | |
4 | //*-- Copyright © ALICE HLT Group | |
5 | ||
6 | #include "AliL3StandardIncludes.h" | |
7 | #include "AliL3Logging.h" | |
8 | #include "AliL3Transform.h" | |
9 | #include "AliL3TPCMapping.h" | |
10 | ||
11 | #if __GNUC__ >= 3 | |
12 | using namespace std; | |
13 | #endif | |
14 | ||
15 | //generated from Ulis txt file with read-roc.sh | |
16 | #include "AliL3TPCMapping-iroc.generated" | |
17 | #include "AliL3TPCMapping-oroc.generated" | |
18 | ||
19 | ||
20 | Int_t AliL3TPCMapping::GetRealNPads(Int_t slicerow) | |
21 | { | |
22 | //see tpc numbering doc | |
23 | ||
24 | if(slicerow<0 || slicerow >= AliL3Transform::GetNRows()){ | |
25 | LOG(AliL3Log::kError,"AliL3TPCMapping::GetRealNPads","Slicerow") | |
26 | <<"Wrong slicerow "<<slicerow<<ENDLOG; | |
27 | return -1; | |
28 | } | |
29 | ||
30 | const Float_t k1=0.293878;// == 10/6*tan(10) | |
31 | const Float_t k2=0.440817;// == 15/6*tan(10) | |
32 | const Int_t knRowLow=AliL3Transform::GetNRowLow(); | |
33 | const Int_t knRowUp1=AliL3Transform::GetNRowUp1(); | |
34 | ||
35 | if(slicerow==0) return 68; | |
36 | else if(slicerow<knRowLow){ | |
37 | Double_t dummy=slicerow/3+33.67; | |
38 | return (2*Int_t(dummy)); | |
39 | } | |
40 | ||
41 | Int_t rowup=slicerow-knRowLow; | |
42 | if(rowup<knRowUp1){ | |
43 | Double_t dummy=k1*rowup+37.75; | |
44 | return (2*Int_t(dummy)); | |
45 | } | |
46 | else | |
47 | { | |
48 | Double_t dummy=k2*(rowup-knRowUp1+56.66); | |
49 | return (2*Int_t(dummy)); | |
50 | } | |
51 | } | |
52 | ||
53 | Double_t AliL3TPCMapping::GetRealX(Int_t slicerow) | |
54 | { | |
55 | //see tpc numbering doc | |
56 | if(slicerow<0 || slicerow >= AliL3Transform::GetNRows()){ | |
57 | LOG(AliL3Log::kError,"AliL3TPCMapping::GetRealX","Slicerow") | |
58 | <<"Wrong slicerow "<<slicerow<<ENDLOG; | |
59 | return -1; | |
60 | } | |
61 | ||
62 | const Int_t knRowLow=AliL3Transform::GetNRowLow(); | |
63 | const Int_t knRowUp1=AliL3Transform::GetNRowUp1(); | |
64 | ||
65 | if(slicerow<knRowLow){ | |
66 | return (85.225+0.75*slicerow); | |
67 | } | |
68 | ||
69 | Int_t rowup=slicerow-knRowLow; | |
70 | if(rowup<knRowUp1){ | |
71 | return (rowup+135.1); | |
72 | } | |
73 | else | |
74 | { | |
75 | return (1.5*(rowup-knRowUp1)+199.35); | |
76 | } | |
77 | } | |
78 | ||
79 | Double_t AliL3TPCMapping::GetRealY(Int_t slicerow, Int_t pad) | |
80 | { | |
81 | //see tpc numbering doc | |
82 | if(slicerow<0 || slicerow >= AliL3Transform::GetNRows()){ | |
83 | LOG(AliL3Log::kError,"AliL3Transform::GetRealY","Slicerow") | |
84 | <<"Wrong slicerow "<<slicerow<<ENDLOG; | |
85 | return -1; | |
86 | } | |
87 | ||
88 | Int_t npads=GetRealNPads(slicerow); | |
89 | if(pad<0 || pad >= npads){ | |
90 | LOG(AliL3Log::kError,"AliL3Transform::GetRealY","pad") | |
91 | <<"Wrong pad "<<pad<<" npads " <<npads<<ENDLOG; | |
92 | return 0.; | |
93 | } | |
94 | ||
95 | const Int_t knRowLow=AliL3Transform::GetNRowLow(); | |
96 | ||
97 | if(slicerow<knRowLow){ | |
98 | return (0.4*pad+0.2-0.2*npads); | |
99 | //== (pad-0.5*(npads-1))*fPadPitchWidthLow; | |
100 | } | |
101 | else | |
102 | { | |
103 | return (0.6*pad+0.3-0.3*npads); | |
104 | // == (pad-0.5*(npads-1))*fPadPitchWidthUp; | |
105 | } | |
106 | } | |
107 | ||
108 | ||
109 | #if __old__ | |
110 | #include "TPCMapping.h" | |
111 | ||
112 | TPCMapping::TPCMapping(char* file){ | |
113 | // constructor | |
114 | fin = new ifstream(); | |
115 | ffile = file; | |
116 | kreadfile = 0; | |
117 | } | |
118 | ||
119 | TPCMapping::~TPCMapping(){ | |
120 | // destructor | |
121 | fin->close(); | |
122 | delete fin; | |
123 | } | |
124 | void TPCMapping::open(){ | |
125 | // opens file | |
126 | fin->open(ffile); | |
127 | } | |
128 | void TPCMapping::isOpen(){ | |
129 | // dummy | |
130 | } | |
131 | void TPCMapping::read(){ | |
132 | // reads the RORC | |
133 | for(int i = 0; i < 5504 ; i++){ | |
134 | for(int j = 0 ; j < 8 ; j++){ | |
135 | *fin >> fIRORC[i][j]; | |
136 | } | |
137 | } | |
138 | fsizeoffIRORC = 5504; | |
139 | kreadfile = 1; | |
140 | } | |
141 | void TPCMapping::read(int* listofRCUs, int numofRCU){ | |
142 | // reads (?) | |
143 | int pos = 0; | |
144 | for(int i = 0; i < 5504 ; i++){ | |
145 | for(int j = 0 ; j < 8 ; j++){ | |
146 | *fin >> fIRORC[pos][j]; | |
147 | } | |
148 | for(int j = 0 ; j < numofRCU ; j++){ | |
149 | if( fIRORC[pos][5] == listofRCUs[j]){ | |
150 | pos++; | |
151 | } | |
152 | } | |
153 | } | |
154 | fsizeoffIRORC = pos; | |
155 | kreadfile = 1; | |
156 | } | |
157 | ||
158 | void TPCMapping::print(){ | |
159 | // debug printout | |
160 | cout << " Index | Row | Pad |Connect| Pin | FEC |channel| FECcon|AltroCH| Altro |" << endl; | |
161 | for(int i = 0; i < fsizeoffIRORC ; i++){ | |
162 | print(i); | |
163 | } | |
164 | } | |
165 | void TPCMapping::print(int start, int end){ | |
166 | // debug printout | |
167 | cout << " Index | Row | Pad |Connect| Pin | FEC |channel| FECcon|AltroCH| Altro |" << endl; | |
168 | for(int i = start; i <= end ; i++){ | |
169 | print(i); | |
170 | } | |
171 | } | |
172 | void TPCMapping::print(int index){ | |
173 | // debug printout | |
174 | cout << | |
175 | getIndex(index) << "\t|" << | |
176 | getPadrow(index) << "\t|" << | |
177 | getPad(index) << "\t|" << | |
178 | getConnector(index) << "\t|" << | |
179 | getPin(index) << "\t|" << | |
180 | getFEC(index) << "\t|" << | |
181 | getFECchannel(index) << "\t|" << | |
182 | getFECconnector(index) << "\t|" << | |
183 | getAltroChannel(index) << "\t|" << | |
184 | getAltro(index) << "\t|" << endl; | |
185 | } | |
186 | int TPCMapping::getIndex(int index){ | |
187 | //COLUMN 0 -> INDEX (0 - 9983) | |
188 | int retval; | |
189 | if(kreadfile == 1) | |
190 | retval = fIRORC[index][0]; | |
191 | else{ | |
192 | retval = 0; | |
193 | cout << "ERROR: Array Empty!" << endl; | |
194 | } | |
195 | return retval; | |
196 | } | |
197 | int TPCMapping::getPadrow(int index){ | |
198 | //COLUMN 1 -> PADROW (0 - 95) | |
199 | int retval; | |
200 | if(kreadfile == 1) | |
201 | retval = fIRORC[index][1]; | |
202 | else{ | |
203 | retval = 0; | |
204 | cout << "ERROR: Array Empty!" << endl; | |
205 | } | |
206 | return retval; | |
207 | } | |
208 | int TPCMapping::getPad(int index){ | |
209 | //COLUMN 2 -> PAD (0 - (Np-1)) | |
210 | int retval; | |
211 | if(kreadfile == 1) | |
212 | retval = fIRORC[index][2]; | |
213 | else{ | |
214 | retval = 0; | |
215 | cout << "ERROR: Array Empty!" << endl; | |
216 | } | |
217 | return retval; | |
218 | } | |
219 | int TPCMapping::getConnector(int index){ | |
220 | //COLUMN 3 -> Connector (1 - 468) | |
221 | int retval; | |
222 | if(kreadfile == 1) | |
223 | retval = fIRORC[index][3]; | |
224 | else{ | |
225 | retval = 0; | |
226 | cout << "ERROR: Array Empty!" << endl; | |
227 | } | |
228 | return retval; | |
229 | } | |
230 | int TPCMapping::getPin(int index){ | |
231 | //COLUMN 4 -> Pin (0 - 22) | |
232 | int retval; | |
233 | if(kreadfile == 1) | |
234 | retval = fIRORC[index][4]; | |
235 | else{ | |
236 | retval = 0; | |
237 | cout << "ERROR: Array Empty!" << endl; | |
238 | } | |
239 | return retval; | |
240 | } | |
241 | int TPCMapping::getFEC(int index){ | |
242 | //COLUMN 5 -> FEC (0 - 77) | |
243 | int retval; | |
244 | if(kreadfile == 1) | |
245 | retval = fIRORC[index][5]; | |
246 | else{ | |
247 | retval = 0; | |
248 | cout << "ERROR: Array Empty!" << endl; | |
249 | } | |
250 | return retval; | |
251 | } | |
252 | int TPCMapping::getFECchannel(int index){ | |
253 | //COLUMN 6 -> FEC Channel (0 - 127) | |
254 | int retval; | |
255 | if(kreadfile == 1) | |
256 | retval = fIRORC[index][6]; | |
257 | else{ | |
258 | retval = 0; | |
259 | cout << "ERROR: Array Empty!" << endl; | |
260 | } | |
261 | return retval; | |
262 | } | |
263 | int TPCMapping::getFECconnector(int index){ | |
264 | //COLUMN 7 -> FEC Connector (0 - 5) | |
265 | int retval; | |
266 | if(kreadfile == 1) | |
267 | retval = fIRORC[index][7]; | |
268 | else{ | |
269 | retval = 0; | |
270 | cout << "ERROR: Array Empty!" << endl; | |
271 | } | |
272 | return retval; | |
273 | } | |
274 | ||
275 | int TPCMapping::getAltroChannel(int index){ | |
276 | // every the channel to Altro ordering is 0,1,2,3,4,5,6,7,16,15,14,13,12,11,10,9,8 | |
277 | int retval; | |
278 | int channel = getFECchannel(index); | |
279 | if(kreadfile == 1){ | |
280 | if( (channel/8)%2 == 0 ){ //every even block hast to be changed | |
281 | retval = channel; | |
282 | }else{ | |
283 | retval = (channel/8)*8 + 7-channel%8; //Blocknumber + reversed internel Number | |
284 | } | |
285 | if( (channel/16)%2 != 0){ | |
286 | // retval = 999; | |
287 | if( (channel/8)%2 == 0 ) | |
288 | retval += 8; | |
289 | else | |
290 | retval -= 8; | |
291 | } | |
292 | }else{ | |
293 | retval = 0; | |
294 | cout << "ERROR: Array Empty!" << endl; | |
295 | } | |
296 | return retval; | |
297 | } | |
298 | int TPCMapping::getAltro(int index){ | |
299 | // gets Altro | |
300 | int retval; | |
301 | int channel = getFECchannel(index); | |
302 | if(kreadfile == 1) | |
303 | retval = channel/16; | |
304 | else{ | |
305 | retval = 0; | |
306 | cout << "ERROR: Array Empty!" << endl; | |
307 | } | |
308 | return retval; | |
309 | } | |
310 | ||
311 | int TPCMapping::getPadsperRow(int row){ | |
312 | //IRORC Formula !!!!!!!!!!!!!!!!!!!!!!!!! | |
313 | int retval; | |
314 | if(row == 0){ | |
315 | retval = 68; | |
316 | }else{ | |
317 | retval = 2*((int)(row/3.0+33.67)); | |
318 | } | |
319 | return retval; | |
320 | } | |
321 | void TPCMapping::myprint(){ | |
322 | // debug printout | |
323 | int FEC = 0; | |
324 | int channel = 0; | |
325 | cout << "channel Index | Row | Pad |Connect| Pin | FEC |channel| FECcon|AltroCH| Altro |" << endl; | |
326 | ||
327 | for(int j = 0; j < 512 ; j++){ | |
328 | // cout << "j: " << j << " fec " << (j/128+29) << " channel: " << j%128 << endl; | |
329 | FEC = (32-j/128); | |
330 | channel = (j%128); | |
331 | for(int i = 0; i < fsizeoffIRORC ; i++){ | |
332 | if((getFEC(i) == FEC) && (getAltroChannel(i) == channel)) { | |
333 | cout << j << "\t" << getIndex(i) << "\t" << getPadrow(i) << "\t" << | |
334 | getPad(i) << "\t" << getConnector(i) << "\t" << getPin(i) << "\t" << | |
335 | getFEC(i) << "\t" << getFECchannel(i) << "\t" << getFECconnector(i) << "\t" << | |
336 | getAltroChannel(i) << "\t" << getAltro(i) << "\t" << endl; | |
337 | } | |
338 | } | |
339 | } | |
340 | } | |
341 | void TPCMapping::myprint1(){ | |
342 | // debug printout | |
343 | int FEC = 0; | |
344 | int channel = 0; | |
345 | cout << "channel Index | Row | Pad |Connect| Pin | FEC |channel| FECcon|AltroCH| Altro |" << endl; | |
346 | ||
347 | for(int j = 0; j < 95 ; j++){ | |
348 | for(int k = 0; k < getPadsperRow(j) ; k++){ | |
349 | for(int i = 0; i < fsizeoffIRORC ; i++){ | |
350 | if(((getFEC(i) >= 29) && (getFEC(i) <= 32)) && (getPadrow(i) == j) && (getPad(i) == k)) { | |
351 | cout << j << "\t" << k << "\t" << getIndex(i) << "\t" << getPadrow(i) << "\t" << | |
352 | getPad(i) << "\t" << getConnector(i) << "\t" << getPin(i) << "\t" << | |
353 | getFEC(i) << "\t" << getFECchannel(i) << "\t" << getFECconnector(i) << "\t" << | |
354 | getAltroChannel(i) << "\t" << getAltro(i) << "\t" << endl; | |
355 | } | |
356 | } | |
357 | } | |
358 | } | |
359 | } | |
360 | void TPCMapping::myprint2(){ | |
361 | // debug printout | |
362 | int FEC = 0; | |
363 | int channel = 0; | |
364 | int rownum = 0; | |
365 | ||
366 | for(int j = 0; j < 95 ; j++){ | |
367 | for(int i = 0; i < fsizeoffIRORC ; i++){ | |
368 | if(((getFEC(i) >= 29) && (getFEC(i) <= 32)) && (getPadrow(i) == j) ){ | |
369 | rownum++; | |
370 | } | |
371 | } | |
372 | if(rownum != 0){ | |
373 | cout << rownum << "\t" << j << "\t"; | |
374 | for(int k = 0; k < getPadsperRow(j) ; k++){ | |
375 | for(int i = 0; i < fsizeoffIRORC ; i++){ | |
376 | if(((getFEC(i) >= 29) && (getFEC(i) <= 32)) && (getPadrow(i) == j) && (getPad(i) == k)) { | |
377 | cout << getAltroChannel(i)+(32-getFEC(i))*128 << "\t"; | |
378 | // cout << getAltroChannel(i) << "\t"; | |
379 | } | |
380 | } | |
381 | } | |
382 | cout << endl; | |
383 | } | |
384 | rownum = 0; | |
385 | } | |
386 | } | |
387 | ||
388 | #endif |