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