cd058d23 |
1 | // $Id$ |
2 | |
3 | // Author: Anders Vestbo <mailto:vestbo@fi.uib.no>, Uli Frankenfeld <mailto:franken@fi.uib.no> |
4 | //*-- Copyright © ASV |
5 | // changes done by Constantin Loizides <mailto:loizides@ikf.physik.uni-frankfurt.de> |
108615fc |
6 | |
118c26c3 |
7 | #include "AliL3StandardIncludes.h" |
8 | |
108615fc |
9 | #include "AliL3Logging.h" |
10 | #include "AliL3Transform.h" |
5923e698 |
11 | #ifdef use_aliroot |
12 | #include "AliRun.h" |
13 | #include "AliMagF.h" |
14 | #include "AliTPCParamSR.h" |
15 | #include "AliTPCPRF2D.h" |
16 | #include "AliTPCRF1D.h" |
17 | #include "TFile.h" |
18 | #endif |
b661165c |
19 | |
4499ed26 |
20 | /** \class AliL3Transform |
21 | //<pre> |
b661165c |
22 | //_____________________________________________________________ |
108615fc |
23 | // AliL3Transform |
24 | // |
25 | // Transformation class for ALICE TPC. |
494fad94 |
26 | // |
27 | // Class which contains all detector specific parameters for the TPC, |
28 | // and different useful functions for coordinate transforms. |
29 | // |
30 | // The class is completely static, which means that no object needs |
5923e698 |
31 | // to be instantiated. Function calls should then be done like, e.g.: |
494fad94 |
32 | // |
5923e698 |
33 | // Double_t eta = AliL3Transform::GetEta(xyz); |
494fad94 |
34 | // |
35 | // IMPORTANT: If used as is, default detector parameters will be used, |
36 | // and you really have to make sure that these correspond to |
37 | // the AliROOT version you are currently working on!! |
38 | // You should therefore always initialize the parameters by |
39 | // |
40 | // AliL3Transform::Init(path); |
41 | // |
42 | // where path is a char*, giving the path to where file containing |
43 | // the detector parameter is located. This file should be called |
5923e698 |
44 | // "l3transform.config", and can be created with the function MakeInitFile. |
45 | // |
46 | // You can also force reading the parameters from a AliTPCParam object |
47 | // by setting the flag; |
48 | // |
49 | // AliL3Transform::Init(filename,kTRUE); |
50 | // |
51 | // where filename is a char* providing the path to the rootfile which |
52 | // should be called digitfile.root. Note that in this case you have to |
53 | // compile with USEPACKAGE=ALIROOT set (see level3code/Makefile.conf). |
4499ed26 |
54 | //</pre> |
55 | */ |
494fad94 |
56 | |
57 | ClassImp(AliL3Transform) |
58 | |
af99f571 |
59 | const Double_t AliL3Transform::fBFACT = 0.0029980; |
ef79795d |
60 | Double_t AliL3Transform::fBField = 0.2; |
494fad94 |
61 | Int_t AliL3Transform::fVersion = 0; |
5923e698 |
62 | Int_t AliL3Transform::fNPatches = 6; |
63 | Int_t AliL3Transform::fBFieldFactor = 1 ; |
494fad94 |
64 | Int_t AliL3Transform::fNTimeBins = 446 ; |
5923e698 |
65 | Int_t AliL3Transform::fNRowLow = 63 ; |
66 | Int_t AliL3Transform::fNRowUp = 96 ; |
67 | Int_t AliL3Transform::fNRowUp1 = 64 ; |
68 | Int_t AliL3Transform::fNRowUp2 = 32 ; |
494fad94 |
69 | Int_t AliL3Transform::fNSectorLow = 36 ; |
70 | Int_t AliL3Transform::fNSectorUp = 36 ; |
71 | Int_t AliL3Transform::fNSector = 72 ; |
5923e698 |
72 | Double_t AliL3Transform::fAnodeWireSpacing = 0.25; //Taken from the TDR |
494fad94 |
73 | Double_t AliL3Transform::fPadPitchWidthLow = 0.400000 ; |
74 | Double_t AliL3Transform::fPadPitchWidthUp = 0.600000 ; |
75 | Double_t AliL3Transform::fZWidth = 0.56599998474121093750 ; |
76 | Double_t AliL3Transform::fZSigma = 0.22880849748219134199 ; |
5923e698 |
77 | Double_t AliL3Transform::fZLength = 250.00000000000000000000 ; |
78 | Double_t AliL3Transform::fZOffset = 0.68642549244657402596 ; |
79 | Double_t AliL3Transform::fDiffT = 0.02199999988079071045 ; |
80 | Double_t AliL3Transform::fDiffL = 0.02199999988079071045 ; |
81 | Double_t AliL3Transform::fInnerPadLength = 0.750000 ; |
82 | Double_t AliL3Transform::fOuter1PadLength = 1.000000 ; |
83 | Double_t AliL3Transform::fOuter2PadLength = 1.500000 ; |
84 | Double_t AliL3Transform::fInnerPRFSigma = 0.20381128787994384766 ; |
85 | Double_t AliL3Transform::fOuter1PRFSigma = 0.29932481050491333008 ; |
86 | Double_t AliL3Transform::fOuter2PRFSigma = 0.29932320117950439453 ; |
87 | Double_t AliL3Transform::fTimeSigma = 0.22880862653255462646 ; |
494fad94 |
88 | Int_t AliL3Transform::fNSlice = 36 ; |
5923e698 |
89 | Int_t AliL3Transform::fNRow = 159 ; |
494fad94 |
90 | Double_t AliL3Transform::fNRotShift = 0.5 ; |
91 | Double_t AliL3Transform::fPi = 3.141592653589793 ; |
5923e698 |
92 | Int_t AliL3Transform::fRows[6][2] = {{0,31},{32,62},{63,86},{87,110},{111,134},{135,158}}; //Defined by us |
93 | Int_t AliL3Transform::fNRows[6] = {32,31,24,24,24,24}; //Defined by us |
94 | Double_t AliL3Transform::fX[159] = {85.194999694824219, |
95 | 85.944999694824219, |
96 | 86.694999694824219, |
97 | 87.444999694824219, |
98 | 88.194999694824219, |
99 | 88.944999694824219, |
100 | 89.694999694824219, |
101 | 90.444999694824219, |
102 | 91.194999694824219, |
103 | 91.944999694824219, |
104 | 92.694999694824219, |
105 | 93.444999694824219, |
106 | 94.194999694824219, |
107 | 94.944999694824219, |
108 | 95.694999694824219, |
109 | 96.444999694824219, |
110 | 97.194999694824219, |
111 | 97.944999694824219, |
112 | 98.694999694824219, |
113 | 99.444999694824219, |
114 | 100.194999694824219, |
115 | 100.944999694824219, |
116 | 101.694999694824219, |
117 | 102.444999694824219, |
118 | 103.194999694824219, |
119 | 103.944999694824219, |
120 | 104.694999694824219, |
121 | 105.444999694824219, |
122 | 106.194999694824219, |
123 | 106.944999694824219, |
124 | 107.694999694824219, |
125 | 108.444999694824219, |
126 | 109.194999694824219, |
127 | 109.944999694824219, |
128 | 110.694999694824219, |
129 | 111.444999694824219, |
130 | 112.194999694824219, |
131 | 112.944999694824219, |
132 | 113.694999694824219, |
133 | 114.444999694824219, |
134 | 115.194999694824219, |
135 | 115.944999694824219, |
136 | 116.694999694824219, |
137 | 117.444999694824219, |
138 | 118.194999694824219, |
139 | 118.944999694824219, |
140 | 119.694999694824219, |
141 | 120.444999694824219, |
142 | 121.194999694824219, |
143 | 121.944999694824219, |
144 | 122.694999694824219, |
145 | 123.444999694824219, |
146 | 124.194999694824219, |
147 | 124.944999694824219, |
148 | 125.694999694824219, |
149 | 126.444999694824219, |
150 | 127.194999694824219, |
151 | 127.944999694824219, |
152 | 128.695007324218750, |
153 | 129.445007324218750, |
154 | 130.195007324218750, |
155 | 130.945007324218750, |
156 | 131.695007324218750, |
157 | 135.180007934570312, |
158 | 136.180007934570312, |
159 | 137.180007934570312, |
160 | 138.180007934570312, |
161 | 139.180007934570312, |
162 | 140.180007934570312, |
163 | 141.180007934570312, |
164 | 142.180007934570312, |
165 | 143.180007934570312, |
166 | 144.180007934570312, |
167 | 145.180007934570312, |
168 | 146.180007934570312, |
169 | 147.180007934570312, |
170 | 148.180007934570312, |
171 | 149.180007934570312, |
172 | 150.180007934570312, |
173 | 151.180007934570312, |
174 | 152.180007934570312, |
175 | 153.180007934570312, |
176 | 154.180007934570312, |
177 | 155.180007934570312, |
178 | 156.180007934570312, |
179 | 157.180007934570312, |
180 | 158.180007934570312, |
181 | 159.180007934570312, |
182 | 160.180007934570312, |
183 | 161.180007934570312, |
184 | 162.180007934570312, |
185 | 163.180007934570312, |
186 | 164.180007934570312, |
187 | 165.180007934570312, |
188 | 166.180007934570312, |
189 | 167.180007934570312, |
190 | 168.180007934570312, |
191 | 169.180007934570312, |
192 | 170.180007934570312, |
193 | 171.180007934570312, |
194 | 172.180007934570312, |
195 | 173.180007934570312, |
196 | 174.180007934570312, |
197 | 175.180007934570312, |
198 | 176.180007934570312, |
199 | 177.180007934570312, |
200 | 178.180007934570312, |
201 | 179.180007934570312, |
202 | 180.180007934570312, |
203 | 181.180007934570312, |
204 | 182.180007934570312, |
205 | 183.180007934570312, |
206 | 184.180007934570312, |
207 | 185.180007934570312, |
208 | 186.180007934570312, |
209 | 187.180007934570312, |
210 | 188.180007934570312, |
211 | 189.180007934570312, |
212 | 190.180007934570312, |
213 | 191.180007934570312, |
214 | 192.180007934570312, |
215 | 193.180007934570312, |
216 | 194.180007934570312, |
217 | 195.180007934570312, |
218 | 196.180007934570312, |
219 | 197.180007934570312, |
220 | 198.180007934570312, |
221 | 199.430007934570312, |
222 | 200.930007934570312, |
223 | 202.430007934570312, |
224 | 203.930007934570312, |
225 | 205.430007934570312, |
226 | 206.930007934570312, |
227 | 208.430007934570312, |
228 | 209.930007934570312, |
229 | 211.430007934570312, |
230 | 212.930007934570312, |
231 | 214.430007934570312, |
232 | 215.930007934570312, |
233 | 217.430007934570312, |
234 | 218.930007934570312, |
235 | 220.430007934570312, |
236 | 221.930007934570312, |
237 | 223.430007934570312, |
238 | 224.930007934570312, |
239 | 226.430007934570312, |
240 | 227.930007934570312, |
241 | 229.430007934570312, |
242 | 230.930007934570312, |
243 | 232.430007934570312, |
244 | 233.930007934570312, |
245 | 235.430007934570312, |
246 | 236.930007934570312, |
247 | 238.430007934570312, |
248 | 239.930007934570312, |
249 | 241.430007934570312, |
250 | 242.930007934570312, |
251 | 244.430007934570312, |
252 | 245.930007934570312 |
494fad94 |
253 | }; |
254 | |
5923e698 |
255 | Int_t AliL3Transform::fNPads[159] = {67, |
494fad94 |
256 | 67, |
257 | 69, |
258 | 69, |
259 | 69, |
260 | 71, |
261 | 71, |
262 | 71, |
263 | 73, |
264 | 73, |
265 | 73, |
266 | 75, |
267 | 75, |
268 | 75, |
269 | 77, |
270 | 77, |
271 | 77, |
272 | 79, |
273 | 79, |
274 | 79, |
275 | 81, |
276 | 81, |
277 | 81, |
278 | 83, |
279 | 83, |
280 | 83, |
281 | 85, |
282 | 85, |
283 | 85, |
284 | 87, |
285 | 87, |
286 | 87, |
287 | 89, |
288 | 89, |
289 | 89, |
290 | 91, |
291 | 91, |
292 | 91, |
293 | 93, |
294 | 93, |
295 | 93, |
296 | 95, |
297 | 95, |
298 | 95, |
299 | 97, |
300 | 97, |
301 | 97, |
302 | 99, |
303 | 99, |
304 | 99, |
5923e698 |
305 | 99, |
494fad94 |
306 | 101, |
307 | 101, |
308 | 101, |
309 | 103, |
310 | 103, |
311 | 103, |
312 | 105, |
313 | 105, |
314 | 105, |
315 | 107, |
316 | 107, |
317 | 107, |
494fad94 |
318 | 73, |
319 | 75, |
320 | 75, |
321 | 75, |
5923e698 |
322 | 75, |
494fad94 |
323 | 77, |
324 | 77, |
325 | 77, |
326 | 79, |
327 | 79, |
328 | 79, |
329 | 81, |
330 | 81, |
331 | 81, |
5923e698 |
332 | 81, |
494fad94 |
333 | 83, |
334 | 83, |
335 | 83, |
336 | 85, |
337 | 85, |
338 | 85, |
5923e698 |
339 | 85, |
494fad94 |
340 | 87, |
341 | 87, |
342 | 87, |
343 | 89, |
344 | 89, |
345 | 89, |
346 | 91, |
347 | 91, |
348 | 91, |
5923e698 |
349 | 91, |
494fad94 |
350 | 93, |
351 | 93, |
352 | 93, |
353 | 95, |
354 | 95, |
355 | 95, |
5923e698 |
356 | 95, |
494fad94 |
357 | 97, |
358 | 97, |
359 | 97, |
360 | 99, |
361 | 99, |
362 | 99, |
363 | 101, |
364 | 101, |
365 | 101, |
5923e698 |
366 | 101, |
494fad94 |
367 | 103, |
368 | 103, |
369 | 103, |
370 | 105, |
371 | 105, |
372 | 105, |
5923e698 |
373 | 105, |
494fad94 |
374 | 107, |
375 | 107, |
376 | 107, |
377 | 109, |
378 | 109, |
379 | 109, |
380 | 111, |
381 | 111, |
382 | 111, |
383 | 113, |
384 | 113, |
385 | 113, |
494fad94 |
386 | 115, |
387 | 115, |
494fad94 |
388 | 117, |
389 | 117, |
494fad94 |
390 | 119, |
391 | 119, |
392 | 121, |
393 | 121, |
394 | 121, |
395 | 123, |
396 | 123, |
494fad94 |
397 | 125, |
398 | 125, |
494fad94 |
399 | 127, |
400 | 127, |
401 | 127, |
402 | 129, |
403 | 129, |
494fad94 |
404 | 131, |
405 | 131, |
406 | 133, |
407 | 133, |
494fad94 |
408 | 135, |
409 | 135, |
410 | 135, |
411 | 137, |
412 | 137, |
118c26c3 |
413 | 139 |
494fad94 |
414 | }; |
415 | |
416 | |
417 | |
5923e698 |
418 | void AliL3Transform::Init(Char_t* path,Bool_t UseAliTPCParam) |
f59eed2d |
419 | { |
494fad94 |
420 | //Overwrite the parameters with values stored in file "l3transform.config" in path. |
421 | //If file does not exist, old default values will be used. |
5923e698 |
422 | //If flag UseAliTPCParam is set, the parameters will be read from the the rootfile |
423 | //which then has to be called path/digitfile.root |
424 | |
425 | if(fVersion != 0) |
426 | LOG(AliL3Log::kWarning,"AliL3Transform::Init","Init values") |
427 | <<"You are initializing the parameters more than once; check your code please! "<<fVersion<<ENDLOG; |
b25c64e5 |
428 | |
5923e698 |
429 | if(UseAliTPCParam) |
430 | { |
431 | ReadInit(path); |
432 | return; |
433 | } |
434 | |
f59eed2d |
435 | Char_t *pathname=new Char_t[1024]; |
a4e75a99 |
436 | strcpy(pathname,path); |
437 | strcat(pathname,"/l3transform.config"); |
494fad94 |
438 | |
a4e75a99 |
439 | FILE *fptr=fopen(pathname,"r"); |
440 | if(!fptr){ |
b25c64e5 |
441 | LOG(AliL3Log::kWarning,"AliL3Transform::Init","File Open") |
442 | <<"Pointer to Config File \""<<pathname<<"\" 0x0!"<<ENDLOG; |
a4e75a99 |
443 | return; |
444 | } |
445 | |
f59eed2d |
446 | Char_t d1[250], d2[100], d3[100]; |
447 | Int_t dummy=0; |
448 | Double_t ddummy=0.0; |
a4e75a99 |
449 | |
450 | while(!feof(fptr)) { |
451 | fscanf(fptr,"%s",d1); |
452 | |
293aee2f |
453 | if(strcmp(d1,"fBFieldFactor")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fBFieldFactor=(Int_t)dummy;fBField=fBFieldFactor*0.2;} |
454 | else if(strcmp(d1,"fNTimeBins")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNTimeBins=(Int_t)dummy;} |
a4e75a99 |
455 | else if(strcmp(d1,"fNRowLow")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNRowLow=(Int_t)dummy;} |
5923e698 |
456 | if(fNRowLow != 63) |
768861a0 |
457 | LOG(AliL3Log::kError,"AliL3Transform::Init","Overflow") |
5923e698 |
458 | <<"Number of inner PadRows should be 63! Check and fgrep the code for 63 to see the consequences of this major change!"<<ENDLOG; |
a4e75a99 |
459 | else if(strcmp(d1,"fNRowUp")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNRowUp=(Int_t)dummy;} |
5923e698 |
460 | else if(strcmp(d1,"fNRowUp1")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNRowUp1=(Int_t)dummy;} |
461 | else if(strcmp(d1,"fNRowUp2")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNRowUp2=(Int_t)dummy;} |
a4e75a99 |
462 | else if(strcmp(d1,"fNSectorLow")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNSectorLow=(Int_t)dummy;} |
463 | else if(strcmp(d1,"fNSectorUp")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNSectorUp=(Int_t)dummy;} |
464 | else if(strcmp(d1,"fNSector")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNSector=(Int_t)dummy;} |
465 | else if(strcmp(d1,"fPadPitchWidthLow")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fPadPitchWidthLow=(Double_t)ddummy;} |
466 | else if(strcmp(d1,"fPadPitchWidthUp")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fPadPitchWidthUp=(Double_t)ddummy;} |
467 | else if(strcmp(d1,"fZWidth")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fZWidth=(Double_t)ddummy;} |
468 | else if(strcmp(d1,"fZSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fZSigma=(Double_t)ddummy;} |
740da2a6 |
469 | else if(strcmp(d1,"fZLength")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fZLength=(Double_t)ddummy;} |
470 | else if(strcmp(d1,"fZOffset")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fZOffset=(Double_t)ddummy;} |
a4e75a99 |
471 | else if(strcmp(d1,"fNSlice")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNSlice=(Int_t)dummy;} |
768861a0 |
472 | else if(strcmp(d1,"fDiffT")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fDiffT=(Double_t)ddummy;} |
473 | else if(strcmp(d1,"fDiffL")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fDiffL=(Double_t)ddummy;} |
474 | else if(strcmp(d1,"fInnerPadLength")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fInnerPadLength=(Double_t)ddummy;} |
5923e698 |
475 | else if(strcmp(d1,"fOuter1PadLength")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fOuter1PadLength=(Double_t)ddummy;} |
476 | else if(strcmp(d1,"fOuter2PadLength")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fOuter2PadLength=(Double_t)ddummy;} |
768861a0 |
477 | else if(strcmp(d1,"fInnerPRFSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fInnerPRFSigma=(Double_t)ddummy;} |
5923e698 |
478 | else if(strcmp(d1,"fOuter1PRFSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fOuter1PRFSigma=(Double_t)ddummy;} |
479 | else if(strcmp(d1,"fOuter2PRFSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fOuter2PRFSigma=(Double_t)ddummy;} |
768861a0 |
480 | else if(strcmp(d1,"fTimeSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fTimeSigma=(Double_t)ddummy;} |
a4e75a99 |
481 | else if(strcmp(d1,"fNRow")==0){ |
482 | fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNRow=(Int_t)dummy; |
5923e698 |
483 | if(fNRow!=159){ |
484 | LOG(AliL3Log::kError,"AliL3Transform::Init","Overflow")<<"Number of PadRows should be 159! Check and fgrep the code for 159 to see the consequences of this major change!"<<ENDLOG; |
a4e75a99 |
485 | } |
486 | } |
487 | else if(strcmp(d1,"fNRotShift")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fNRotShift=(Double_t)ddummy;} |
488 | else if(strcmp(d1,"fPi")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fPi=(Double_t)ddummy;} |
489 | else if(strcmp(d1,"fX[0]")==0){ |
490 | fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fX[0]=(Double_t)ddummy; |
740da2a6 |
491 | for(Int_t i=1;i<fNRow;i++){fscanf(fptr,"%s %s %lf %s",d1,d2,&ddummy,d3);fX[i]=(Double_t)ddummy;} |
a4e75a99 |
492 | } |
493 | else if(strcmp(d1,"fNPads[0]")==0){ |
494 | fscanf(fptr,"%s %d %s",d2,&dummy,d3);fNPads[0]=(Int_t)dummy; |
495 | for(Int_t i=1;i<fNRow;i++){fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fNPads[i]=(Int_t)dummy;} |
496 | } |
497 | } |
498 | |
a4e75a99 |
499 | fclose(fptr); |
500 | delete pathname; |
5923e698 |
501 | fVersion++; //new version |
502 | } |
503 | void AliL3Transform::ReadInit(Char_t *path) |
504 | { |
505 | //Read all the parameters from a aliroot file, and store it in a temporary |
506 | //file which is read by Init. Use this if you want to read the parameters from |
507 | //the rootfile "every" time. |
508 | |
509 | #ifndef use_aliroot |
510 | LOG(AliL3Log::kError,"AliL3Transform::ReadInit","Version") |
511 | <<"You have to compile with use_aliroot flag in order to read from AliROOT file"<<ENDLOG; |
512 | return; |
513 | #else |
514 | Char_t filename[1024]; |
515 | sprintf(filename,"%s/digitfile.root",path); |
516 | MakeInitFile(filename,"/tmp/"); |
517 | Init("/tmp/"); |
518 | #endif |
519 | } |
520 | |
521 | |
522 | |
523 | void AliL3Transform::MakeInitFile(Char_t *filename,Char_t *path) |
524 | { |
525 | //Get the parameters from rootfile, and store it on the file "l3transform.config" |
526 | //which is being read by Init. |
527 | |
528 | #ifndef use_aliroot |
529 | LOG(AliL3Log::kError,"AliL3Transform::MakeInitFile","Version") |
530 | <<"You have to compile with use_aliroot flag in order to use this function"<<ENDLOG; |
531 | return; |
532 | #else |
533 | TFile *rootfile = TFile::Open(filename); |
534 | AliRun *gAlice = (AliRun*)rootfile->Get("gAlice"); |
535 | if(!gAlice) |
536 | { |
537 | LOG(AliL3Log::kError,"AliL3Transform::MakeInitFile","File") |
538 | <<"No gAlice in file: "<<filename<<ENDLOG; |
539 | return; |
540 | } |
541 | AliTPCParamSR *param=(AliTPCParamSR*)rootfile->Get("75x40_100x60_150x60"); |
542 | if(!param) |
543 | { |
544 | LOG(AliL3Log::kError,"AliL3Transform::MakeInitFile","File") |
545 | <<"No TPC parameters found"<<ENDLOG; |
546 | return; |
547 | } |
548 | |
549 | AliTPCPRF2D * prfinner = new AliTPCPRF2D; |
550 | AliTPCPRF2D * prfouter1 = new AliTPCPRF2D; |
551 | AliTPCPRF2D * prfouter2 = new AliTPCPRF2D; |
552 | AliTPCRF1D * rf = new AliTPCRF1D(kTRUE); |
553 | rf->SetGauss(param->GetZSigma(),param->GetZWidth(),1.); |
554 | rf->SetOffset(3*param->GetZSigma()); |
555 | rf->Update(); |
556 | |
557 | TDirectory *savedir=gDirectory; |
558 | TFile *prf_file = TFile::Open("$ALICE_ROOT/TPC/AliTPCprf2d.root"); |
559 | if (!prf_file->IsOpen()) |
560 | { |
561 | LOG(AliL3Log::kError,"AliL3Transform::MakeInitFile","File") |
562 | <<"Can't open $ALICE_ROOT/TPC/AliTPCprf2d.root !"<<ENDLOG; |
563 | return; |
564 | } |
565 | prfinner->Read("prf_07504_Gati_056068_d02"); |
566 | prfouter1->Read("prf_10006_Gati_047051_d03"); |
567 | prfouter2->Read("prf_15006_Gati_047051_d03"); |
568 | prf_file->Close(); |
569 | savedir->cd(); |
570 | |
571 | param->SetInnerPRF(prfinner); |
572 | param->SetOuter1PRF(prfouter1); |
573 | param->SetOuter2PRF(prfouter2); |
574 | param->SetTimeRF(rf); |
575 | |
576 | Int_t nTimeBins = param->GetMaxTBin()+1; |
577 | Int_t nRowLow = param->GetNRowLow(); |
578 | Int_t nRowUp = param->GetNRowUp(); |
579 | Int_t nRowUp1 = param->GetNRowUp1(); |
580 | Int_t nRowUp2 = param->GetNRowUp2(); |
581 | Int_t nRow= fNRowLow + fNRowUp; |
582 | Int_t nSectorLow = param->GetNInnerSector(); |
583 | Int_t nSectorUp = param->GetNOuterSector(); |
584 | Int_t nSector = fNSectorLow + fNSectorUp; |
585 | |
586 | Char_t tofile[100]; |
587 | sprintf(tofile,"%s/l3transform.config",path); |
588 | FILE *f = fopen(tofile,"w"); |
589 | fprintf(f,"void AliL3Transform::Init(){\n"); |
590 | |
591 | fprintf(f," fBFieldFactor = %d ;\n",(Int_t)gAlice->Field()->Factor()); |
592 | fprintf(f," //sector:\n"); |
593 | fprintf(f," fNTimeBins = %d ;\n",nTimeBins); |
594 | fprintf(f," fNRowLow = %d ;\n",nRowLow); |
595 | fprintf(f," fNRowUp = %d ;\n",nRowUp); |
596 | fprintf(f," fNRowUp1 = %d ;\n",nRowUp1); |
597 | fprintf(f," fNRowUp2 = %d ;\n",nRowUp2); |
598 | fprintf(f," fNSectorLow = %d ;\n",nSectorLow); |
599 | fprintf(f," fNSectorUp = %d ;\n",nSectorUp); |
600 | fprintf(f," fNSector = %d ;\n",nSector); |
601 | fprintf(f," fPadPitchWidthLow = %f ;\n",param->GetInnerPadPitchWidth()); |
602 | fprintf(f," fPadPitchWidthUp = %f ;\n",param->GetOuterPadPitchWidth()); |
603 | fprintf(f," fZWidth = %.20f ;\n",param->GetZWidth()); |
604 | fprintf(f," fZSigma = %.20f ;\n",param->GetZSigma()); |
605 | fprintf(f," fZLength = %.20f ;\n",param->GetZLength()); |
606 | fprintf(f," fZOffset = %.20f ;\n",param->GetZOffset()); |
607 | fprintf(f," fDiffT = %.20f ;\n",param->GetDiffT()); |
608 | fprintf(f," fDiffL = %.20f ;\n",param->GetDiffL()); |
609 | fprintf(f," fInnerPadLength = %f ;\n",param->GetInnerPadLength()); |
610 | fprintf(f," fOuter1PadLength = %f ;\n",param->GetOuter1PadLength()); |
611 | fprintf(f," fOuter2PadLength = %f ;\n",param->GetOuter2PadLength()); |
612 | fprintf(f," fInnerPRFSigma = %.20f ;\n",param->GetInnerPRF()->GetSigmaX()); |
613 | fprintf(f," fOuter1PRFSigma = %.20f ;\n",param->GetOuter1PRF()->GetSigmaX()); |
614 | fprintf(f," fOuter2PRFSigma = %.20f ;\n",param->GetOuter2PRF()->GetSigmaX()); |
615 | |
616 | fprintf(f," fTimeSigma = %.20f ;\n",param->GetTimeRF()->GetSigma()); |
617 | |
618 | fprintf(f,"\n //slices:\n"); |
619 | fprintf(f," fNSlice = %d ;\n",nSectorLow); |
620 | fprintf(f," fNRow = %d ;\n",nRow); |
621 | |
622 | //rotation shift put in by hand -> Constantin |
623 | fprintf(f," fNRotShift = 0.5 ;\n"); |
624 | |
625 | fprintf(f," fPi = %.15f ;\n",TMath::Pi()); |
626 | |
627 | for(Int_t i=0;i<nRow;i++){ |
628 | Int_t sec,row; |
629 | if( i < nRowLow){sec =0;row =i;} |
630 | else{sec = nSectorLow;row =i-nRowLow;} |
631 | fprintf(f," fX[%d] = %3.15f ;\n",i,param->GetPadRowRadii(sec,row)); |
632 | } |
633 | for(Int_t i=0;i<nRow;i++){ |
634 | Int_t sec,row; |
635 | if( i < nRowLow){sec =0;row =i;} |
636 | else{sec = nSectorLow;row =i-nRowLow;} |
637 | fprintf(f," fNPads[%d] = %d ;\n",i,param->GetNPads(sec,row)); |
638 | } |
639 | |
640 | fprintf(f,"}\n"); |
641 | fclose(f); |
642 | #endif |
643 | } |
644 | |
645 | inline Double_t AliL3Transform::GetPadLength(Int_t padrow) |
646 | { |
647 | if(padrow >= fNRow) |
648 | return 0; |
649 | if(padrow < fNRowLow) |
650 | return fInnerPadLength; |
651 | if(padrow >= fNRowLow && padrow < fNRowLow + fNRowUp1 - 1) |
652 | return fOuter1PadLength; |
653 | if(padrow >= fNRowLow + fNRowUp1 - 1) |
654 | return fOuter2PadLength; |
655 | } |
656 | |
657 | inline Double_t AliL3Transform::GetPRFSigma(Int_t padrow) |
658 | { |
659 | if(padrow >= fNRow) |
660 | return 0; |
661 | if(padrow < fNRowLow) |
662 | return fInnerPRFSigma; |
663 | if(padrow >= fNRowLow && padrow < fNRowLow + fNRowUp1 - 1) |
664 | return fOuter1PRFSigma; |
665 | if(padrow >= fNRowLow + fNRowUp1 - 1) |
666 | return fOuter2PRFSigma; |
a4e75a99 |
667 | } |
668 | |
108615fc |
669 | Double_t AliL3Transform::GetEta(Float_t *xyz) |
670 | { |
671 | Double_t r3 = sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]+xyz[2]*xyz[2]); |
672 | Double_t eta = 0.5 * log((r3+xyz[2])/(r3-xyz[2])); |
673 | return eta; |
674 | } |
675 | |
740da2a6 |
676 | void AliL3Transform::XYZtoRPhiEta(Float_t *rpe, Float_t *xyz) |
677 | { |
678 | rpe[0] = sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]+xyz[2]*xyz[2]); |
679 | rpe[1] = atan2(xyz[1],xyz[0]); |
680 | rpe[2] = 0.5 * log((rpe[0]+xyz[2])/(rpe[0]-xyz[2])); |
681 | } |
682 | |
3a1c3849 |
683 | Double_t AliL3Transform::GetEta(Int_t padrow,Int_t pad,Int_t time) |
bd7e82e0 |
684 | { |
685 | Float_t xyz[3]; |
3a1c3849 |
686 | Int_t sector,row; |
687 | Slice2Sector(0,padrow,sector,row); |
688 | Raw2Local(xyz,sector,row,pad,time); |
bd7e82e0 |
689 | |
690 | return GetEta(xyz); |
691 | } |
692 | |
108615fc |
693 | Double_t AliL3Transform::GetPhi(Float_t *xyz) |
694 | { |
108615fc |
695 | Double_t phi = atan2(xyz[1],xyz[0]); |
696 | //if(phi<0) phi=phi+2*TMath::Pi(); |
697 | return phi; |
698 | } |
699 | |
494fad94 |
700 | Bool_t AliL3Transform::Slice2Sector(Int_t slice, Int_t slicerow, Int_t & sector, Int_t &row) |
701 | { |
108615fc |
702 | if(slicerow<0&&slicerow>=fNRow) return kFALSE; |
703 | if(slice<0||slice>=fNSlice) return kFALSE; |
704 | |
705 | if(slicerow<fNRowLow){ |
706 | sector = slice; |
707 | row = slicerow; |
708 | } |
709 | else { |
710 | sector = slice+fNSlice; |
711 | row = slicerow-fNRowLow; |
712 | } |
713 | return kTRUE; |
714 | } |
715 | |
494fad94 |
716 | Bool_t AliL3Transform::Sector2Slice(Int_t & slice, Int_t sector) |
717 | { |
108615fc |
718 | if(sector<0||sector>=fNSector) return kFALSE; |
719 | if(sector<fNSectorLow) slice = sector; |
720 | else slice = sector - fNSectorLow; |
721 | return kTRUE; |
722 | } |
723 | |
494fad94 |
724 | Bool_t AliL3Transform::Sector2Slice(Int_t & slice, Int_t & slicerow,Int_t sector, Int_t row) |
725 | { |
108615fc |
726 | if(sector<0||sector>=fNSector||row<0) return kFALSE; |
727 | if(sector<fNSectorLow){ |
728 | if(row>=fNRowLow) return kFALSE; |
729 | slice = sector; |
730 | slicerow = row; |
731 | } |
732 | else{ |
733 | if(row>=fNRowUp) return kFALSE; |
734 | slice = sector - fNSectorLow; |
735 | slicerow = row + fNRowLow; |
736 | } |
737 | return kTRUE; |
738 | } |
739 | |
740 | Double_t AliL3Transform::Row2X(Int_t slicerow){ |
741 | if(slicerow<0||slicerow>=fNRow) return 0; |
742 | return fX[slicerow]; |
743 | } |
744 | |
745 | void AliL3Transform::Local2Global(Float_t *xyz,Int_t slice) |
746 | { |
747 | //Transformation to global coordinate system |
748 | Float_t x0 = xyz[0]; |
749 | Float_t y0 = xyz[1]; |
750 | Float_t cs,sn; |
494fad94 |
751 | cs = cos( (2*fPi/18) * (slice+fNRotShift) ); |
752 | sn = sin( (2*fPi/18) * (slice+fNRotShift) ); |
108615fc |
753 | xyz[0]=x0*cs-y0*sn; |
754 | xyz[1]=x0*sn+y0*cs; |
755 | xyz[2]=xyz[2];//global z=local z |
756 | } |
757 | |
758 | void AliL3Transform::Local2GlobalAngle(Float_t *angle,Int_t slice){ |
740da2a6 |
759 | angle[0] = fmod(angle[0]+(slice+fNRotShift)*(2*fPi/18),2*fPi); |
108615fc |
760 | } |
761 | |
762 | void AliL3Transform::Global2LocalAngle(Float_t *angle,Int_t slice){ |
740da2a6 |
763 | angle[0] = angle[0]-(slice+fNRotShift)*(2*fPi/18); |
108615fc |
764 | if(angle[0]<0) angle[0]+=2*fPi; |
765 | } |
766 | |
767 | void AliL3Transform::Raw2Local(Float_t *xyz,Int_t sector,Int_t row,Float_t pad,Float_t time) |
768 | { |
769 | //Transformation from rawdata to local coordinate system |
770 | |
771 | Int_t slice,slicerow; |
772 | Sector2Slice(slice, slicerow, sector, row); |
773 | |
740da2a6 |
774 | //X-Value |
108615fc |
775 | xyz[0]=Row2X(slicerow); |
740da2a6 |
776 | |
777 | //Y-Value |
108615fc |
778 | Int_t npads= fNPads[slicerow]; |
779 | if(sector<fNSectorLow) |
780 | xyz[1]=(pad-0.5*(npads-1))*fPadPitchWidthLow; |
781 | else |
782 | xyz[1]=(pad-0.5*(npads-1))*fPadPitchWidthUp; |
740da2a6 |
783 | |
784 | //Z-Value (remember PULSA Delay) |
785 | //xyz[2]=fZWidth*time-3.*fZSigma; |
786 | xyz[2]=fZWidth*time-fZOffset; |
0e0b1e59 |
787 | if(slice < 18) |
740da2a6 |
788 | xyz[2]=fZLength-xyz[2]; |
0e0b1e59 |
789 | else |
740da2a6 |
790 | xyz[2]=xyz[2]-fZLength; |
494fad94 |
791 | |
108615fc |
792 | } |
793 | |
794 | void AliL3Transform::Local2Global(Float_t *xyz,Int_t sector,Int_t row) |
795 | { |
796 | //Transformation to global coordinate system |
797 | Int_t slice,slicerow; |
798 | Sector2Slice(slice, slicerow, sector, row); |
799 | Float_t r=Row2X(slicerow); |
494fad94 |
800 | Float_t cs = cos( (2*fPi/18) * (slice+fNRotShift) ); |
801 | Float_t sn = sin( (2*fPi/18) * (slice+fNRotShift) ); |
108615fc |
802 | |
803 | xyz[0]=r*cs-xyz[1]*sn; |
804 | xyz[1]=r*sn+xyz[1]*cs; |
805 | xyz[2]=xyz[2];//global z=local z |
806 | } |
807 | |
808 | Double_t AliL3Transform::GetMaxY(Int_t slicerow) |
809 | { |
494fad94 |
810 | |
108615fc |
811 | if(slicerow < fNRowLow) |
812 | return fPadPitchWidthLow*fNPads[slicerow]/2; |
813 | |
814 | else |
815 | return fPadPitchWidthUp*fNPads[slicerow]/2; |
494fad94 |
816 | |
108615fc |
817 | } |
818 | |
2342214c |
819 | void AliL3Transform::Global2Local(Float_t *xyz,Int_t sector,Bool_t isSlice) |
108615fc |
820 | { |
2342214c |
821 | |
108615fc |
822 | Int_t slice; |
2342214c |
823 | if(!isSlice) |
824 | Sector2Slice(slice, sector); |
825 | else |
826 | slice = sector; |
494fad94 |
827 | Float_t cs = cos( (2*fPi/18) * (slice+fNRotShift) ); |
828 | Float_t sn = sin( (2*fPi/18) * (slice+fNRotShift) ); |
108615fc |
829 | Float_t x1 = xyz[0]*cs + xyz[1]*sn; |
830 | Float_t y1 = -xyz[0]*sn + xyz[1]*cs; |
831 | xyz[0] = x1; |
832 | xyz[1] = y1; |
833 | } |
834 | |
835 | void AliL3Transform::Raw2Global(Float_t *xyz,Int_t sector,Int_t row,Float_t pad,Float_t time) |
836 | { |
837 | //Transformation from raw to global coordinates |
838 | |
839 | Raw2Local(xyz,sector,row,pad,time); |
840 | Local2Global(xyz,sector,row); |
841 | } |
842 | |
843 | void AliL3Transform::Local2Raw(Float_t *xyz,Int_t sector,Int_t row) |
844 | { |
845 | //Transformation from local coordinates to raw |
494fad94 |
846 | |
108615fc |
847 | Int_t slice,slicerow; |
848 | Sector2Slice(slice, slicerow, sector, row); |
849 | |
850 | if(sector<fNSectorLow) |
851 | xyz[1]=xyz[1]/fPadPitchWidthLow+0.5*(fNPads[slicerow]-1); |
852 | else |
853 | xyz[1]=xyz[1]/fPadPitchWidthUp+0.5*(fNPads[slicerow]-1); |
854 | Int_t sign=-1; |
855 | Int_t nis=fNSectorLow; |
856 | Int_t nos=fNSectorUp; |
857 | |
858 | if ((sector<nis/2) || ((sector-nis)<nos/2)) sign=1; |
1727f1c9 |
859 | xyz[2]=fZLength-sign*xyz[2]; |
860 | xyz[2]=(xyz[2]+fZOffset)/fZWidth; |
494fad94 |
861 | |
108615fc |
862 | } |
863 | |
864 | void AliL3Transform::Global2Raw(Float_t *xyz,Int_t sector,Int_t row) |
865 | { |
866 | //Transformation from global coordinates to raw. |
867 | |
868 | Global2Local(xyz,sector); |
869 | Local2Raw(xyz,sector,row); |
870 | |
871 | } |