]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/src/AliL3Transform.cxx
New convention for the solenoid field
[u/mrichter/AliRoot.git] / HLT / src / AliL3Transform.cxx
CommitLineData
3e87ef69 1// @(#) $Id$
2
3// Author: Anders Vestbo <mailto:vestbo@fi.uib.no>, Uli Frankenfeld <mailto:franken@fi.uib.no>, Constantin Loizides <mailto:loizides@ikf.uni-frankfurt.de>
4//*-- Copyright &copy ALICE HLT Group
cd058d23 5
108615fc 6
118c26c3 7#include "AliL3StandardIncludes.h"
3e87ef69 8#include "dirent.h"
118c26c3 9
5923e698 10#ifdef use_aliroot
5e0f9911 11#include <AliRun.h>
12#include <AliMagF.h>
13#include <AliTPCParamSR.h>
14#include <AliTPCPRF2D.h>
15#include <AliTPCRF1D.h>
3e87ef69 16#endif
17#ifdef use_root
5e0f9911 18#include <TFile.h>
2220326f 19#include <TUnixSystem.h>
20#include <TTimeStamp.h>
3e87ef69 21#include <TError.h>
5923e698 22#endif
b661165c 23
5e0f9911 24#include "AliL3Logging.h"
25#include "AliL3Transform.h"
26
5929c18d 27#if defined(__GNUC__) && __GNUC__ >= 3
3e87ef69 28using namespace std;
29#endif
30
4499ed26 31/** \class AliL3Transform
3e87ef69 32<pre>
b661165c 33//_____________________________________________________________
108615fc 34// AliL3Transform
35//
36// Transformation class for ALICE TPC.
494fad94 37//
38// Class which contains all detector specific parameters for the TPC,
39// and different useful functions for coordinate transforms.
40//
41// The class is completely static, which means that no object needs
5923e698 42// to be instantiated. Function calls should then be done like, e.g.:
494fad94 43//
5923e698 44// Double_t eta = AliL3Transform::GetEta(xyz);
494fad94 45//
46// IMPORTANT: If used as is, default detector parameters will be used,
47// and you really have to make sure that these correspond to
48// the AliROOT version you are currently working on!!
49// You should therefore always initialize the parameters by
50//
51// AliL3Transform::Init(path);
52//
53// where path is a char*, giving the path to where file containing
54// the detector parameter is located. This file should be called
5923e698 55// "l3transform.config", and can be created with the function MakeInitFile.
56//
57// You can also force reading the parameters from a AliTPCParam object
58// by setting the flag;
59//
2220326f 60// AliL3Transform::Init(path,kTRUE);
5923e698 61//
2220326f 62// where path is a char*
3e87ef69 63// either providing the rootfile name containing the geometry or
64// the path to the rootfile which should then be called alirunfile.root.
0ceee3a5 65// Note that for both of these cases you have to
5923e698 66// compile with USEPACKAGE=ALIROOT set (see level3code/Makefile.conf).
3e87ef69 67//
68// Currently, there are 4 versions of the Transformer:
b1ed0288 69// fVersion==kValiroot: ALIROOT-head compatible
70// fVersion==kVcosmics: Cosmics data run (2003) compatible
71// fVersion==kVdefault: means no config file has been loaded
72// fVersion==kVdeprecated: dont use old (before July 2003) style of transformer
3e87ef69 73//
74</pre>
4499ed26 75*/
494fad94 76
77ClassImp(AliL3Transform)
78
b1ed0288 79const Double_t AliL3Transform::fgkAnodeWireSpacing = 0.25; //Taken from the TDR
80const Double_t AliL3Transform::fgkBFACT = 0.0029980; //Conversion Factor
81const Double_t AliL3Transform::fgkPi = 3.141592653589793;
82const Double_t AliL3Transform::fgk2Pi = 2*3.141592653589793;
83const Double_t AliL3Transform::fgkPi2 = 0.5*3.141592653589793;
84const Double_t AliL3Transform::fgkToDeg = 180/3.141592653589793;
3e87ef69 85
86//Defined by HLT and GSI
b1ed0288 87Int_t AliL3Transform::fgNPatches = 6;
88Int_t AliL3Transform::fgRows[6][2] = {{0,29},{30,62},{63,90},{91,116},{117,139},{140,158}};
89Int_t AliL3Transform::fgNRows[6] = {30,33,28,26,23,19};
3e87ef69 90
91// The following definition is generated by MakeInitFile function
b1ed0288 92Double_t AliL3Transform::fgBField = 0.2;
93Double_t AliL3Transform::fgSolenoidBField = 2;
94Double_t AliL3Transform::fgBFieldFactor = 1;
95Int_t AliL3Transform::fgVersion = kVdefault;
96Int_t AliL3Transform::fgNTimeBins = 446;
97Int_t AliL3Transform::fgNRowLow = 63;
98Int_t AliL3Transform::fgNRowUp = 96;
99Int_t AliL3Transform::fgNRowUp1 = 64;
100Int_t AliL3Transform::fgNRowUp2 = 32;
101Int_t AliL3Transform::fgNSectorLow = 36;
102Int_t AliL3Transform::fgNSectorUp = 36;
103Int_t AliL3Transform::fgNSector = 72;
104Double_t AliL3Transform::fgPadPitchWidthLow = 0.4;
105Double_t AliL3Transform::fgPadPitchWidthUp = 0.6;
106Double_t AliL3Transform::fgZWidth = 0.5660;
107Double_t AliL3Transform::fgZSigma = 0.2288;
108Double_t AliL3Transform::fgZLength = 250.0000;
109Double_t AliL3Transform::fgZOffset = 0.6864;
110Double_t AliL3Transform::fgDiffT = 0.0220;
111Double_t AliL3Transform::fgDiffL = 0.0220;
112Double_t AliL3Transform::fgOmegaTau = 0.1450;
113Double_t AliL3Transform::fgInnerPadLength = 0.75;
114Double_t AliL3Transform::fgOuter1PadLength = 1.00;
115Double_t AliL3Transform::fgOuter2PadLength = 1.50;
116Double_t AliL3Transform::fgInnerPRFSigma = 0.203811;
117Double_t AliL3Transform::fgOuter1PRFSigma = 0.299325;
118Double_t AliL3Transform::fgOuter2PRFSigma = 0.299323;
119Double_t AliL3Transform::fgTimeSigma = 0.228809;
120Int_t AliL3Transform::fgADCSat = 1024;
121Int_t AliL3Transform::fgZeroSup = 0;
122Int_t AliL3Transform::fgNSlice = 36;
123Int_t AliL3Transform::fgNRow = 159;
124Double_t AliL3Transform::fgNRotShift = 0.5;
125Int_t AliL3Transform::fgSlice2Sector[36][2] = { { 0, 36},
3e87ef69 126 { 1, 37},
127 { 2, 38},
128 { 3, 39},
129 { 4, 40},
130 { 5, 41},
131 { 6, 42},
132 { 7, 43},
133 { 8, 44},
134 { 9, 45},
135 {10, 46},
136 {11, 47},
137 {12, 48},
138 {13, 49},
139 {14, 50},
140 {15, 51},
141 {16, 52},
142 {17, 53},
143 {18, 54},
144 {19, 55},
145 {20, 56},
146 {21, 57},
147 {22, 58},
148 {23, 59},
149 {24, 60},
150 {25, 61},
151 {26, 62},
152 {27, 63},
153 {28, 64},
154 {29, 65},
155 {30, 66},
156 {31, 67},
157 {32, 68},
158 {33, 69},
159 {34, 70},
160 {35, 71}
161};
162
b1ed0288 163Int_t AliL3Transform::fgSector2Slice[72] = { 0,
3e87ef69 164 1,
165 2,
166 3,
167 4,
168 5,
169 6,
170 7,
171 8,
172 9,
173 10,
174 11,
175 12,
176 13,
177 14,
178 15,
179 16,
180 17,
181 18,
182 19,
183 20,
184 21,
185 22,
186 23,
187 24,
188 25,
189 26,
190 27,
191 28,
192 29,
193 30,
194 31,
195 32,
196 33,
197 34,
198 35,
199 0,
200 1,
201 2,
202 3,
203 4,
204 5,
205 6,
206 7,
207 8,
208 9,
209 10,
210 11,
211 12,
212 13,
213 14,
214 15,
215 16,
216 17,
217 18,
218 19,
219 20,
220 21,
221 22,
222 23,
223 24,
224 25,
225 26,
226 27,
227 28,
228 29,
229 30,
230 31,
231 32,
232 33,
233 34,
234 35
235};
236
b1ed0288 237Int_t AliL3Transform::fgSectorLow[72] = { 1,
3e87ef69 238 1,
239 1,
240 1,
241 1,
242 1,
243 1,
244 1,
245 1,
246 1,
247 1,
248 1,
249 1,
250 1,
251 1,
252 1,
253 1,
254 1,
255 1,
256 1,
257 1,
258 1,
259 1,
260 1,
261 1,
262 1,
263 1,
264 1,
265 1,
266 1,
267 1,
268 1,
269 1,
270 1,
271 1,
272 1,
273 0,
274 0,
275 0,
276 0,
277 0,
278 0,
279 0,
280 0,
281 0,
282 0,
283 0,
284 0,
285 0,
286 0,
287 0,
288 0,
289 0,
290 0,
291 0,
292 0,
293 0,
294 0,
295 0,
296 0,
297 0,
298 0,
299 0,
300 0,
301 0,
302 0,
303 0,
304 0,
305 0,
306 0,
307 0,
308 0
309};
310
b1ed0288 311Double_t AliL3Transform::fgX[159] = { 85.195,
3e87ef69 312 85.945,
313 86.695,
314 87.445,
315 88.195,
316 88.945,
317 89.695,
318 90.445,
319 91.195,
320 91.945,
321 92.695,
322 93.445,
323 94.195,
324 94.945,
325 95.695,
326 96.445,
327 97.195,
328 97.945,
329 98.695,
330 99.445,
331 100.195,
332 100.945,
333 101.695,
334 102.445,
335 103.195,
336 103.945,
337 104.695,
338 105.445,
339 106.195,
340 106.945,
341 107.695,
342 108.445,
343 109.195,
344 109.945,
345 110.695,
346 111.445,
347 112.195,
348 112.945,
349 113.695,
350 114.445,
351 115.195,
352 115.945,
353 116.695,
354 117.445,
355 118.195,
356 118.945,
357 119.695,
358 120.445,
359 121.195,
360 121.945,
361 122.695,
362 123.445,
363 124.195,
364 124.945,
365 125.695,
366 126.445,
367 127.195,
368 127.945,
369 128.695,
370 129.445,
371 130.195,
372 130.945,
373 131.695,
374 135.180,
375 136.180,
376 137.180,
377 138.180,
378 139.180,
379 140.180,
380 141.180,
381 142.180,
382 143.180,
383 144.180,
384 145.180,
385 146.180,
386 147.180,
387 148.180,
388 149.180,
389 150.180,
390 151.180,
391 152.180,
392 153.180,
393 154.180,
394 155.180,
395 156.180,
396 157.180,
397 158.180,
398 159.180,
399 160.180,
400 161.180,
401 162.180,
402 163.180,
403 164.180,
404 165.180,
405 166.180,
406 167.180,
407 168.180,
408 169.180,
409 170.180,
410 171.180,
411 172.180,
412 173.180,
413 174.180,
414 175.180,
415 176.180,
416 177.180,
417 178.180,
418 179.180,
419 180.180,
420 181.180,
421 182.180,
422 183.180,
423 184.180,
424 185.180,
425 186.180,
426 187.180,
427 188.180,
428 189.180,
429 190.180,
430 191.180,
431 192.180,
432 193.180,
433 194.180,
434 195.180,
435 196.180,
436 197.180,
437 198.180,
438 199.430,
439 200.930,
440 202.430,
441 203.930,
442 205.430,
443 206.930,
444 208.430,
445 209.930,
446 211.430,
447 212.930,
448 214.430,
449 215.930,
450 217.430,
451 218.930,
452 220.430,
453 221.930,
454 223.430,
455 224.930,
456 226.430,
457 227.930,
458 229.430,
459 230.930,
460 232.430,
461 233.930,
462 235.430,
463 236.930,
464 238.430,
465 239.930,
466 241.430,
467 242.930,
468 244.430,
469 245.930
494fad94 470};
471
b1ed0288 472Int_t AliL3Transform::fgNPads[159] = {67,
494fad94 473 67,
474 69,
475 69,
476 69,
477 71,
478 71,
479 71,
480 73,
481 73,
482 73,
483 75,
484 75,
485 75,
486 77,
487 77,
488 77,
489 79,
490 79,
491 79,
492 81,
493 81,
494 81,
495 83,
496 83,
497 83,
498 85,
499 85,
500 85,
501 87,
502 87,
503 87,
504 89,
505 89,
506 89,
507 91,
508 91,
509 91,
510 93,
511 93,
512 93,
513 95,
514 95,
515 95,
516 97,
517 97,
518 97,
519 99,
520 99,
521 99,
5923e698 522 99,
494fad94 523 101,
524 101,
525 101,
526 103,
527 103,
528 103,
529 105,
530 105,
531 105,
532 107,
533 107,
534 107,
494fad94 535 73,
536 75,
537 75,
538 75,
5923e698 539 75,
494fad94 540 77,
541 77,
542 77,
543 79,
544 79,
545 79,
546 81,
547 81,
548 81,
5923e698 549 81,
494fad94 550 83,
551 83,
552 83,
553 85,
554 85,
555 85,
5923e698 556 85,
494fad94 557 87,
558 87,
559 87,
560 89,
561 89,
562 89,
563 91,
564 91,
565 91,
5923e698 566 91,
494fad94 567 93,
568 93,
569 93,
570 95,
571 95,
572 95,
5923e698 573 95,
494fad94 574 97,
575 97,
576 97,
577 99,
578 99,
579 99,
580 101,
581 101,
582 101,
5923e698 583 101,
494fad94 584 103,
585 103,
586 103,
587 105,
588 105,
589 105,
5923e698 590 105,
494fad94 591 107,
592 107,
593 107,
594 109,
595 109,
596 109,
597 111,
598 111,
599 111,
600 113,
601 113,
602 113,
494fad94 603 115,
604 115,
494fad94 605 117,
606 117,
494fad94 607 119,
608 119,
609 121,
610 121,
611 121,
612 123,
613 123,
494fad94 614 125,
615 125,
494fad94 616 127,
617 127,
618 127,
619 129,
620 129,
494fad94 621 131,
622 131,
623 133,
624 133,
494fad94 625 135,
626 135,
627 135,
628 137,
629 137,
118c26c3 630 139
494fad94 631};
632
b1ed0288 633Double_t AliL3Transform::fgCos[36] = { 0.9848077297,
3e87ef69 634 0.8660253882,
635 0.6427876353,
636 0.3420201540,
637 0.0000000000,
638 -0.3420201540,
639 -0.6427876353,
640 -0.8660253882,
641 -0.9848077297,
642 -0.9848077297,
643 -0.8660253882,
644 -0.6427876353,
645 -0.3420201540,
646 -0.0000000000,
647 0.3420201540,
648 0.6427876353,
649 0.8660253882,
650 0.9848077297,
651 0.9848077297,
652 0.8660253882,
653 0.6427876353,
654 0.3420201540,
655 0.0000000000,
656 -0.3420201540,
657 -0.6427876353,
658 -0.8660253882,
659 -0.9848077297,
660 -0.9848077297,
661 -0.8660253882,
662 -0.6427876353,
663 -0.3420201540,
664 -0.0000000000,
665 0.3420201540,
666 0.6427876353,
667 0.8660253882,
668 0.9848077297
669};
670
b1ed0288 671Double_t AliL3Transform::fgSin[36] = { 0.1736481786,
3e87ef69 672 0.5000000000,
673 0.7660444379,
674 0.9396926165,
675 1.0000000000,
676 0.9396926165,
677 0.7660444379,
678 0.5000000000,
679 0.1736481786,
680 -0.1736481786,
681 -0.5000000000,
682 -0.7660444379,
683 -0.9396926165,
684 -1.0000000000,
685 -0.9396926165,
686 -0.7660444379,
687 -0.5000000000,
688 -0.1736481786,
689 0.1736481786,
690 0.5000000000,
691 0.7660444379,
692 0.9396926165,
693 1.0000000000,
694 0.9396926165,
695 0.7660444379,
696 0.5000000000,
697 0.1736481786,
698 -0.1736481786,
699 -0.5000000000,
700 -0.7660444379,
701 -0.9396926165,
702 -1.0000000000,
703 -0.9396926165,
704 -0.7660444379,
705 -0.5000000000,
706 -0.1736481786
707};
708
cefeb80d 709#ifdef use_aliroot
710Bool_t AliL3Transform::Init(AliRunLoader *runLoader)
b1ed0288 711{
712 //init with runloader
cefeb80d 713 if(!runLoader) {
714 LOG(AliL3Log::kFatal,"AliL3Transform::Init","RunLoader")
715 <<" Missing RunLoader! 0x0"<<ENDLOG;
716 return kFALSE;
717 }
718
b1ed0288 719 if(fgVersion != kVdefault)
cefeb80d 720 LOG(AliL3Log::kWarning,"AliL3Transform::Init","Init values")
b1ed0288 721 <<AliL3Log::kDec<<"You are initializing the parameters more than once; check your code please! "<<fgVersion<<ENDLOG;
cefeb80d 722
723 TDirectory* savedir1 = gDirectory;
724 runLoader->CdGAFile();
725 AliTPCParamSR *param=(AliTPCParamSR*)gDirectory->Get(GetParamName());
726 savedir1->cd();
727 if(!param)
728 {
729 LOG(AliL3Log::kFatal,"AliL3Transform::Init","File")
730 <<"No TPC parameters found!"<<ENDLOG;
731 return kFALSE;
732 }
733
734 AliTPCPRF2D * prfinner = new AliTPCPRF2D;
735 AliTPCPRF2D * prfouter1 = new AliTPCPRF2D;
736 AliTPCPRF2D * prfouter2 = new AliTPCPRF2D;
737 AliTPCRF1D * rf = new AliTPCRF1D(kTRUE);
738 rf->SetGauss(param->GetZSigma(),param->GetZWidth(),1.);
739 rf->SetOffset(3*param->GetZSigma());
740 rf->Update();
741
742 TDirectory *savedir2=gDirectory;
743 TFile *prf_file = TFile::Open("$ALICE_ROOT/TPC/AliTPCprf2d.root");
744 if (!prf_file->IsOpen())
745 {
746 LOG(AliL3Log::kError,"AliL3Transform::Init","File")
747 <<"Can't open $ALICE_ROOT/TPC/AliTPCprf2d.root !"<<ENDLOG;
748 return kFALSE;
749 }
750 prfinner ->Read("prf_07504_Gati_056068_d02");
751 prfouter1->Read("prf_10006_Gati_047051_d03");
752 prfouter2->Read("prf_15006_Gati_047051_d03");
753 prf_file->Close();
754 savedir2->cd();
755
756 param->SetInnerPRF(prfinner);
757 param->SetOuter1PRF(prfouter1);
758 param->SetOuter2PRF(prfouter2);
759 param->SetTimeRF(rf);
760
b1ed0288 761 fgNTimeBins = param->GetMaxTBin()+1;
762 fgNRowLow = param->GetNRowLow();
763 fgNRowUp = param->GetNRowUp();
764 fgNRowUp1 = param->GetNRowUp1();
765 fgNRowUp2 = param->GetNRowUp2();
766 fgNRow= fgNRowLow + fgNRowUp;
767 if(fgNRow!=159){
cefeb80d 768 LOG(AliL3Log::kError,"AliL3Transform::Init","fNRow")
769 <<"Number of rows have changed in ALIROOT"<<ENDLOG;
770 return kFALSE;
771 }
772
b1ed0288 773 fgNSectorLow = param->GetNInnerSector();
774 fgNSectorUp = param->GetNOuterSector();
775 fgNSector = fgNSectorLow + fgNSectorUp;
cefeb80d 776
777 //test whether they were changes to the rotation shift
b1ed0288 778 fgNRotShift=0;
cefeb80d 779 Float_t irotshift = param->GetInnerAngleShift(); //shift angle
780 Float_t orotshift = param->GetOuterAngleShift(); //shift angle
781 const Float_t kDegtoRad = 0.01745329251994;
782 Int_t shift1=TMath::Nint(irotshift/kDegtoRad);
783 Int_t shift2=TMath::Nint(orotshift/kDegtoRad+0.1);
784 if((shift1!=shift2) || (shift1!=10)){
785 LOG(AliL3Log::kError,"AliL3Transform::Init","Rotshiftangle")
786 <<"Rotation shift angle has changed in ALIROOT"<<ENDLOG;
787 return kFALSE;
788 } else {
b1ed0288 789 fgNRotShift=0.5; //our version of the shift angle
cefeb80d 790 }
791
b1ed0288 792 fgVersion=kValiroot;
cefeb80d 793 SetBFieldFactor((Double_t)runLoader->GetAliRun()->Field()->Factor());
cce3eda4 794 SetSolenoidBField(-
795 (Double_t)runLoader->GetAliRun()->Field()->SolenoidField()/
796 (Double_t)runLoader->GetAliRun()->Field()->Factor()
797 );
b1ed0288 798 fgPadPitchWidthLow=param->GetInnerPadPitchWidth();
799 fgPadPitchWidthUp=param->GetOuterPadPitchWidth();
800 fgZWidth=param->GetZWidth();
801 fgZSigma=param->GetZSigma();
802 fgZLength=param->GetZLength();
803 fgZOffset=param->GetZOffset();
804 fgDiffT=param->GetDiffT();
805 fgDiffL=param->GetDiffL();
806 fgOmegaTau=param->GetOmegaTau();
807 fgInnerPadLength=param->GetInnerPadLength();
808 fgOuter1PadLength=param->GetOuter1PadLength();
809 fgOuter2PadLength=param->GetOuter2PadLength();
810 fgInnerPRFSigma=param->GetInnerPRF()->GetSigmaX();
811 fgOuter1PRFSigma=param->GetOuter1PRF()->GetSigmaX();
812 fgOuter2PRFSigma=param->GetOuter2PRF()->GetSigmaX();
813 fgTimeSigma=param->GetTimeRF()->GetSigma();
814 fgADCSat=param->GetADCSat();
815 fgZeroSup=param->GetZeroSup();
816 fgNSlice=fgNSectorLow;
cefeb80d 817
818 //now do the arrays
b1ed0288 819 for(Int_t i=0;i<fgNRow;i++){
cefeb80d 820 Int_t sec,row;
b1ed0288 821 if( i < fgNRowLow){sec =0;row =i;}
822 else{sec = fgNSectorLow;row =i-fgNRowLow;}
823 fgX[i]=param->GetPadRowRadii(sec,row);
cefeb80d 824 }
b1ed0288 825 for(Int_t i=0;i<fgNRow;i++){
cefeb80d 826 Int_t sec,row;
b1ed0288 827 if( i < fgNRowLow){sec =0;row =i;}
828 else{sec = fgNSectorLow;row =i-fgNRowLow;}
829 fgNPads[i]=param->GetNPads(sec,row);
cefeb80d 830 }
b1ed0288 831 for(Int_t i=0;i<fgNSector;i++){
832 if(i<fgNSectorLow) fgSectorLow[i]=1;
833 else fgSectorLow[i]=0;
cefeb80d 834 }
835
b1ed0288 836 return kTRUE;
837
838 /* not needed
cefeb80d 839 TTimeStamp time;
840 Char_t tmpfile[1024];
841 sprintf(tmpfile,"./l3transform.config-%d",(Int_t)time.GetSec());
842
843 return SaveInitFile(tmpfile);
b1ed0288 844 */
cefeb80d 845}
846#endif
847
2220326f 848Bool_t AliL3Transform::Init(Char_t* path,Bool_t UseAliTPCParam)
f59eed2d 849{
494fad94 850 //Overwrite the parameters with values stored in file "l3transform.config" in path.
851 //If file does not exist, old default values will be used.
5923e698 852 //If flag UseAliTPCParam is set, the parameters will be read from the the rootfile
853 //which then has to be called path/digitfile.root
854
b1ed0288 855 if(fgVersion != kVdefault)
5923e698 856 LOG(AliL3Log::kWarning,"AliL3Transform::Init","Init values")
b1ed0288 857 <<AliL3Log::kDec<<"You are initializing the parameters more than once; check your code please! "<<fgVersion<<ENDLOG;
b25c64e5 858
3e87ef69 859 if(UseAliTPCParam) //use rootfile to generate temporary init file
860 return ReadInit(path);
5923e698 861
3e87ef69 862 //create filename
863 Char_t pathname[1024];
a4e75a99 864 strcpy(pathname,path);
3e87ef69 865
866 //test whether provided path is the file itself
02f030e3 867 Int_t isdir = 0;
3e87ef69 868 DIR *testdir=opendir(pathname);
869 if(testdir){
870 isdir=1;
871 closedir(testdir);
872 }
873
874 if(isdir) strcat(pathname,"/l3transform.config");
875
876 return ReadInitFile(pathname);
877}
878
879Bool_t AliL3Transform::ReadInitFile(Char_t* pathname)
880{
881 //read transformer settings from pathname
a4e75a99 882 FILE *fptr=fopen(pathname,"r");
883 if(!fptr){
045549b7 884 LOG(AliL3Log::kWarning,"AliL3Transform::ReadInitFile","File Open")
b25c64e5 885 <<"Pointer to Config File \""<<pathname<<"\" 0x0!"<<ENDLOG;
2220326f 886 return kFALSE;
a4e75a99 887 }
888
f59eed2d 889 Char_t d1[250], d2[100], d3[100];
890 Int_t dummy=0;
891 Double_t ddummy=0.0;
a4e75a99 892
893 while(!feof(fptr)) {
894 fscanf(fptr,"%s",d1);
b1ed0288 895 if(strcmp(d1,"fVersion")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgVersion=dummy;}
896 else if(strcmp(d1,"fBFieldFactor")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgBFieldFactor=(Double_t)ddummy;}
3e87ef69 897 else if(strcmp(d1,"fSolenoidBField")==0)
898 {
899 fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);
b1ed0288 900 fgSolenoidBField=(Double_t)ddummy;
3e87ef69 901 }
b1ed0288 902 else if(strcmp(d1,"fNTimeBins")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgNTimeBins=(Int_t)dummy;}
e1964feb 903 else if(strcmp(d1,"fNRowLow")==0)
904 {
905 fscanf(fptr,"%s %d %s",d2,&dummy,d3);
b1ed0288 906 fgNRowLow=(Int_t)dummy;
907 if(fgNRowLow != 63)
045549b7 908 LOG(AliL3Log::kError,"AliL3Transform::ReadInitFile","Overflow")
e1964feb 909 <<"Number of inner PadRows should be 63! Check and fgrep the code for 63 to see the consequences of this major change!"<<ENDLOG;
910 }
b1ed0288 911 else if(strcmp(d1,"fNRowUp")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgNRowUp=(Int_t)dummy;}
912 else if(strcmp(d1,"fNRowUp1")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgNRowUp1=(Int_t)dummy;}
913 else if(strcmp(d1,"fNRowUp2")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgNRowUp2=(Int_t)dummy;}
914 else if(strcmp(d1,"fNSectorLow")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgNSectorLow=(Int_t)dummy;}
915 else if(strcmp(d1,"fNSectorUp")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgNSectorUp=(Int_t)dummy;}
916 else if(strcmp(d1,"fNSector")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgNSector=(Int_t)dummy;}
917 else if(strcmp(d1,"fPadPitchWidthLow")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgPadPitchWidthLow=(Double_t)ddummy;}
918 else if(strcmp(d1,"fPadPitchWidthUp")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgPadPitchWidthUp=(Double_t)ddummy;}
919 else if(strcmp(d1,"fZWidth")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgZWidth=(Double_t)ddummy;}
920 else if(strcmp(d1,"fZSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgZSigma=(Double_t)ddummy;}
921 else if(strcmp(d1,"fZLength")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgZLength=(Double_t)ddummy;}
922 else if(strcmp(d1,"fZOffset")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgZOffset=(Double_t)ddummy;}
923 else if(strcmp(d1,"fNSlice")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgNSlice=(Int_t)dummy;}
924 else if(strcmp(d1,"fDiffT")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgDiffT=(Double_t)ddummy;}
925 else if(strcmp(d1,"fDiffL")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgDiffL=(Double_t)ddummy;}
926 else if(strcmp(d1,"fOmegaTau")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgOmegaTau=(Double_t)ddummy;}
927 else if(strcmp(d1,"fInnerPadLength")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgInnerPadLength=(Double_t)ddummy;}
928 else if(strcmp(d1,"fOuter1PadLength")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgOuter1PadLength=(Double_t)ddummy;}
929 else if(strcmp(d1,"fOuter2PadLength")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgOuter2PadLength=(Double_t)ddummy;}
930 else if(strcmp(d1,"fInnerPRFSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgInnerPRFSigma=(Double_t)ddummy;}
931 else if(strcmp(d1,"fOuter1PRFSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgOuter1PRFSigma=(Double_t)ddummy;}
932 else if(strcmp(d1,"fOuter2PRFSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgOuter2PRFSigma=(Double_t)ddummy;}
933 else if(strcmp(d1,"fTimeSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgTimeSigma=(Double_t)ddummy;}
934 else if(strcmp(d1,"fADCSat")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgADCSat=(Int_t)dummy;}
935 else if(strcmp(d1,"fZeroSup")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgZeroSup=(Int_t)dummy;}
a4e75a99 936 else if(strcmp(d1,"fNRow")==0){
b1ed0288 937 fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgNRow=(Int_t)dummy;
938 if(fgNRow!=159){
045549b7 939 LOG(AliL3Log::kError,"AliL3Transform::ReadInitFile","Overflow")<<"Number of PadRows should be 159! Check and fgrep the code for 159 to see the consequences of this major change!"<<ENDLOG;
a4e75a99 940 }
941 }
b1ed0288 942 else if(strcmp(d1,"fNRotShift")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgNRotShift=(Double_t)ddummy;}
a4e75a99 943 else if(strcmp(d1,"fX[0]")==0){
b1ed0288 944 fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgX[0]=(Double_t)ddummy;
945 for(Int_t i=1;i<fgNRow;i++){fscanf(fptr,"%s %s %lf %s",d1,d2,&ddummy,d3);fgX[i]=(Double_t)ddummy;}
a4e75a99 946 }
947 else if(strcmp(d1,"fNPads[0]")==0){
b1ed0288 948 fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgNPads[0]=(Int_t)dummy;
949 for(Int_t i=1;i<fgNRow;i++){fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fgNPads[i]=(Int_t)dummy;}
a4e75a99 950 }
3e87ef69 951 else if(strcmp(d1,"fNRows[0]")==0){
b1ed0288 952 fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgNRows[0]=(Int_t)dummy;
953 for(Int_t i=1;i<fgNPatches;i++){fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fgNRows[i]=(Int_t)dummy;}
3e87ef69 954 }
955 else if(strcmp(d1,"fRows[0][0]")==0){
b1ed0288 956 fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgRows[0][0]=(Int_t)dummy;
957 fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fgRows[0][1]=(Int_t)dummy;
958 for(Int_t i=1;i<fgNPatches;i++){
959 fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fgRows[i][0]=(Int_t)dummy;
960 fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fgRows[i][1]=(Int_t)dummy;
3e87ef69 961 }
962 }
963 else if(strcmp(d1,"fSlice2Sector[0][0]")==0){
b1ed0288 964 fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgSlice2Sector[0][0]=(Int_t)dummy;
965 fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fgSlice2Sector[0][1]=(Int_t)dummy;
966 for(Int_t i=1;i<fgNSlice;i++){
967 fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fgSlice2Sector[i][0]=(Int_t)dummy;
968 fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fgSlice2Sector[i][1]=(Int_t)dummy;
3e87ef69 969 }
970 }
971 else if(strcmp(d1,"fSector2Slice[0]")==0){
b1ed0288 972 fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgSector2Slice[0]=(Int_t)dummy;
973 for(Int_t i=1;i<fgNSector;i++){fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fgSector2Slice[i]=(Int_t)dummy;}
3e87ef69 974 }
975 else if(strcmp(d1,"fSectorLow[0]")==0){
b1ed0288 976 fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgSectorLow[0]=(Int_t)dummy;
977 for(Int_t i=1;i<fgNSector;i++){fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fgSectorLow[i]=(Int_t)dummy;}
3e87ef69 978 }
979 else if(strcmp(d1,"fCos[0]")==0){
b1ed0288 980 fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgCos[0]=(Double_t)ddummy;
981 for(Int_t i=1;i<fgNSlice;i++){fscanf(fptr,"%s %s %lf %s",d1,d2,&ddummy,d3);fgCos[i]=(Double_t)ddummy;}
3e87ef69 982 }
983 else if(strcmp(d1,"fSin[0]")==0){
b1ed0288 984 fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgSin[0]=(Double_t)ddummy;
985 for(Int_t i=1;i<fgNSlice;i++){fscanf(fptr,"%s %s %lf %s",d1,d2,&ddummy,d3);fgSin[i]=(Double_t)ddummy;}
3e87ef69 986 }
a4e75a99 987 }
5a31e9df 988 fclose(fptr);
a4e75a99 989
3e87ef69 990 //The first multiplier gives the scale factor used to modify the field map
991 //defined by the second multiplier.
b1ed0288 992 fgBField=fgBFieldFactor*fgSolenoidBField*0.1;
3e87ef69 993
3e87ef69 994 //Test if new config file has been used.
b1ed0288 995 if(fgVersion==kVdeprecated){
045549b7 996 LOG(AliL3Log::kError,"AliL3Transform::ReadInitFile","Version")
3e87ef69 997 <<"Version is deprecated, you have to create a new config file."<<ENDLOG;
998 return kFALSE;
999 }
2220326f 1000
045549b7 1001 LOG(AliL3Log::kInformational,"AliL3Transform::ReadInitFile","Config")
240d63be 1002 <<"Successfully loaded values from config file \""<<pathname<<"\""<<ENDLOG;
1003
2220326f 1004 return kTRUE;
5923e698 1005}
2220326f 1006
1007Bool_t AliL3Transform::ReadInit(Char_t *path)
5923e698 1008{
1009 //Read all the parameters from a aliroot file, and store it in a temporary
1010 //file which is read by Init. Use this if you want to read the parameters from
1011 //the rootfile "every" time.
1012
1013#ifndef use_aliroot
1014 LOG(AliL3Log::kError,"AliL3Transform::ReadInit","Version")
1015 <<"You have to compile with use_aliroot flag in order to read from AliROOT file"<<ENDLOG;
2220326f 1016 return kFALSE;
5923e698 1017#else
1018 Char_t filename[1024];
2220326f 1019 //first test whether provided path is the rootfile itself
3e87ef69 1020 Int_t saveErrIgLevel=gErrorIgnoreLevel;
1021 gErrorIgnoreLevel=kFatal; //dont report errors
2220326f 1022 TFile *rootfile = TFile::Open(path);
a27af97b 1023 if(!rootfile || rootfile->IsZombie())
3e87ef69 1024 { //ok assume its path to alirunfile file
2220326f 1025 sprintf(filename,"%s/alirunfile.root",path); //create rootfile name
3e87ef69 1026 } else { //path contains itself the rootfile name
2220326f 1027 rootfile->Close();
3e87ef69 1028 sprintf(filename,"%s",path);
2220326f 1029 }
3e87ef69 1030 gErrorIgnoreLevel=saveErrIgLevel;
2220326f 1031
02f030e3 1032 //finally make dummy init file /tmp/$USER/l3transform.config-`date`
1033 Char_t tmppath[1024];
1034 sprintf(tmppath,"/tmp/%s",gSystem->Getenv("USER"));
1035 gSystem->mkdir(tmppath);
1036 TTimeStamp time;
1037 Char_t tmpfile[1024];
1038 sprintf(tmpfile,"%s/l3transform.config-%d",tmppath,(Int_t)time.GetSec());
1039 return MakeInitFile(filename,tmpfile);
5923e698 1040#endif
1041}
1042
02f030e3 1043Bool_t AliL3Transform::MakeInitFile(Char_t *rootfilename,Char_t *filename)
5923e698 1044{
1045 //Get the parameters from rootfile, and store it on the file "l3transform.config"
b1ed0288 1046 //which is being read by Init. fVersion will be kV_aliroot!
5923e698 1047
1048#ifndef use_aliroot
1049 LOG(AliL3Log::kError,"AliL3Transform::MakeInitFile","Version")
1050 <<"You have to compile with use_aliroot flag in order to use this function"<<ENDLOG;
2220326f 1051 return kFALSE;
5923e698 1052#else
02f030e3 1053 TFile *rootfile = TFile::Open(rootfilename);
2220326f 1054 if(!rootfile)
1055 {
1056 LOG(AliL3Log::kError,"AliL3Transform::MakeInitFile","File")
02f030e3 1057 <<"Could not open file: "<<rootfilename<<ENDLOG;
2220326f 1058 return kFALSE;
1059 }
5923e698 1060 AliRun *gAlice = (AliRun*)rootfile->Get("gAlice");
1061 if(!gAlice)
1062 {
1063 LOG(AliL3Log::kError,"AliL3Transform::MakeInitFile","File")
02f030e3 1064 <<"No gAlice in file: "<<rootfilename<<ENDLOG;
2220326f 1065 return kFALSE;
5923e698 1066 }
5e0f9911 1067 AliTPCParamSR *param=(AliTPCParamSR*)rootfile->Get(GetParamName());
5923e698 1068 if(!param)
1069 {
02f030e3 1070 LOG(AliL3Log::kWarning,"AliL3Transform::MakeInitFile","File")
1071 <<"No TPC parameters found in \""<<rootfilename
1072 <<"\", creating standard parameters "
1073 <<"which might not be what you want!"<<ENDLOG;
1074 param=new AliTPCParamSR;
5923e698 1075 }
ef2318df 1076
1077 AliTPCPRF2D * prfinner = new AliTPCPRF2D;
5923e698 1078 AliTPCPRF2D * prfouter1 = new AliTPCPRF2D;
1079 AliTPCPRF2D * prfouter2 = new AliTPCPRF2D;
1080 AliTPCRF1D * rf = new AliTPCRF1D(kTRUE);
1081 rf->SetGauss(param->GetZSigma(),param->GetZWidth(),1.);
1082 rf->SetOffset(3*param->GetZSigma());
1083 rf->Update();
1084
1085 TDirectory *savedir=gDirectory;
1086 TFile *prf_file = TFile::Open("$ALICE_ROOT/TPC/AliTPCprf2d.root");
1087 if (!prf_file->IsOpen())
1088 {
1089 LOG(AliL3Log::kError,"AliL3Transform::MakeInitFile","File")
1090 <<"Can't open $ALICE_ROOT/TPC/AliTPCprf2d.root !"<<ENDLOG;
2220326f 1091 return kFALSE;
5923e698 1092 }
ef2318df 1093 prfinner ->Read("prf_07504_Gati_056068_d02");
5923e698 1094 prfouter1->Read("prf_10006_Gati_047051_d03");
1095 prfouter2->Read("prf_15006_Gati_047051_d03");
1096 prf_file->Close();
1097 savedir->cd();
1098
1099 param->SetInnerPRF(prfinner);
1100 param->SetOuter1PRF(prfouter1);
1101 param->SetOuter2PRF(prfouter2);
1102 param->SetTimeRF(rf);
1103
b1ed0288 1104 fgNTimeBins = param->GetMaxTBin()+1;
1105 fgNRowLow = param->GetNRowLow();
1106 fgNRowUp = param->GetNRowUp();
1107 fgNRowUp1 = param->GetNRowUp1();
1108 fgNRowUp2 = param->GetNRowUp2();
1109 fgNRow= fgNRowLow + fgNRowUp;
1110 if(fgNRow!=159){
3e87ef69 1111 LOG(AliL3Log::kError,"AliL3Transform::MakeInitFile","fNRow")
1112 <<"Number of rows have changed in ALIROOT"<<ENDLOG;
1113 return kFALSE;
1114 }
1115
b1ed0288 1116 fgNSectorLow = param->GetNInnerSector();
1117 fgNSectorUp = param->GetNOuterSector();
1118 fgNSector = fgNSectorLow + fgNSectorUp;
3e87ef69 1119
1120 //test whether they were changes to the rotation shift
b1ed0288 1121 fgNRotShift=0;
3e87ef69 1122 Float_t irotshift = param->GetInnerAngleShift(); //shift angle
1123 Float_t orotshift = param->GetOuterAngleShift(); //shift angle
1124 const Float_t kDegtoRad = 0.01745329251994;
1125 Int_t shift1=TMath::Nint(irotshift/kDegtoRad);
1126 Int_t shift2=TMath::Nint(orotshift/kDegtoRad+0.1);
1127 if((shift1!=shift2) || (shift1!=10)){
1128 LOG(AliL3Log::kError,"AliL3Transform::MakeInitFile","Rotshiftangle")
1129 <<"Rotation shift angle has changed in ALIROOT"<<ENDLOG;
1130 return kFALSE;
1131 } else {
b1ed0288 1132 fgNRotShift=0.5; //our version of the shift angle
3e87ef69 1133 }
1134
b1ed0288 1135 fgVersion=kValiroot;
240d63be 1136 SetBFieldFactor((Double_t)gAlice->Field()->Factor());
cce3eda4 1137 SetSolenoidBField(-
1138 (Double_t)gAlice->Field()->SolenoidField()/
1139 (Double_t)gAlice->Field()->Factor()
1140 );
b1ed0288 1141 fgPadPitchWidthLow=param->GetInnerPadPitchWidth();
1142 fgPadPitchWidthUp=param->GetOuterPadPitchWidth();
1143 fgZWidth=param->GetZWidth();
1144 fgZSigma=param->GetZSigma();
1145 fgZLength=param->GetZLength();
1146 fgZOffset=param->GetZOffset();
1147 fgDiffT=param->GetDiffT();
1148 fgDiffL=param->GetDiffL();
1149 fgOmegaTau=param->GetOmegaTau();
1150 fgInnerPadLength=param->GetInnerPadLength();
1151 fgOuter1PadLength=param->GetOuter1PadLength();
1152 fgOuter2PadLength=param->GetOuter2PadLength();
1153 fgInnerPRFSigma=param->GetInnerPRF()->GetSigmaX();
1154 fgOuter1PRFSigma=param->GetOuter1PRF()->GetSigmaX();
1155 fgOuter2PRFSigma=param->GetOuter2PRF()->GetSigmaX();
1156 fgTimeSigma=param->GetTimeRF()->GetSigma();
1157 fgADCSat=param->GetADCSat();
1158 fgZeroSup=param->GetZeroSup();
1159 fgNSlice=fgNSectorLow;
240d63be 1160
3e87ef69 1161 //now do the arrays
b1ed0288 1162 for(Int_t i=0;i<fgNRow;i++){
3e87ef69 1163 Int_t sec,row;
b1ed0288 1164 if( i < fgNRowLow){sec =0;row =i;}
1165 else{sec = fgNSectorLow;row =i-fgNRowLow;}
1166 fgX[i]=param->GetPadRowRadii(sec,row);
3e87ef69 1167 }
b1ed0288 1168 for(Int_t i=0;i<fgNRow;i++){
3e87ef69 1169 Int_t sec,row;
b1ed0288 1170 if( i < fgNRowLow){sec =0;row =i;}
1171 else{sec = fgNSectorLow;row =i-fgNRowLow;}
1172 fgNPads[i]=param->GetNPads(sec,row);
3e87ef69 1173 }
b1ed0288 1174 for(Int_t i=0;i<fgNSector;i++){
1175 if(i<fgNSectorLow) fgSectorLow[i]=1;
1176 else fgSectorLow[i]=0;
3e87ef69 1177 }
a6c89175 1178
1179 delete gAlice;
1180 rootfile->Close();
1181 delete rootfile;
1182
02f030e3 1183 return SaveInitFile(filename);
3e87ef69 1184#endif
1185}
5923e698 1186
3e87ef69 1187Bool_t AliL3Transform::SaveInitFile(Char_t *filenamepath)
1188{
1189 //store the parameters in the file "filenamepath"
5923e698 1190
3e87ef69 1191 FILE *f = fopen(filenamepath,"w");
1192 if(!f){
02f030e3 1193 LOG(AliL3Log::kError,"AliL3Transform::SaveInitFile","File")
1194 <<"Could not open file: "<<filenamepath<<ENDLOG;
3e87ef69 1195 return kFALSE;
1196 }
6f3df1c8 1197
3e87ef69 1198 fprintf(f,"void AliL3Transform::Init(){\n");
b1ed0288 1199 fprintf(f," fVersion = %d;\n", fgVersion);
1200 fprintf(f," fBFieldFactor = %.3f;\n",fgBFieldFactor);
1201 fprintf(f," fSolenoidBField = %.3f;\n",fgSolenoidBField);
1202 fprintf(f," fNTimeBins = %d;\n",fgNTimeBins);
1203 fprintf(f," fNRowLow = %d;\n",fgNRowLow);
1204 fprintf(f," fNRowUp = %d;\n",fgNRowUp);
1205 fprintf(f," fNRowUp1 = %d;\n",fgNRowUp1);
1206 fprintf(f," fNRowUp2 = %d;\n",fgNRowUp2);
1207 fprintf(f," fNSectorLow = %d;\n",fgNSectorLow);
1208 fprintf(f," fNSectorUp = %d;\n",fgNSectorUp);
1209 fprintf(f," fNSector = %d;\n",fgNSector);
1210 fprintf(f," fPadPitchWidthLow = %.3f;\n",fgPadPitchWidthLow);
1211 fprintf(f," fPadPitchWidthUp = %.3f;\n",fgPadPitchWidthUp);
1212 fprintf(f," fZWidth = %.4f;\n",fgZWidth);
1213 fprintf(f," fZSigma = %.4f;\n",fgZSigma);
1214 fprintf(f," fZLength = %.4f;\n",fgZLength);
1215 fprintf(f," fZOffset = %.4f;\n",fgZOffset);
1216 fprintf(f," fDiffT = %.4f;\n",fgDiffT);
1217 fprintf(f," fDiffL = %.4f;\n",fgDiffL);
1218 fprintf(f," fOmegaTau = %.4f;\n",fgOmegaTau);
1219 fprintf(f," fInnerPadLength = %.3f;\n",fgInnerPadLength);
1220 fprintf(f," fOuter1PadLength = %.3f;\n",fgOuter1PadLength);
1221 fprintf(f," fOuter2PadLength = %.3f;\n",fgOuter2PadLength);
1222 fprintf(f," fInnerPRFSigma = %.6f;\n",fgInnerPRFSigma);
1223 fprintf(f," fOuter1PRFSigma = %.6f;\n",fgOuter1PRFSigma);
1224 fprintf(f," fOuter2PRFSigma = %.6f;\n",fgOuter2PRFSigma);
1225 fprintf(f," fTimeSigma = %.6f;\n",fgTimeSigma);
1226 fprintf(f," fADCSat = %d;\n",fgADCSat);
1227 fprintf(f," fZeroSup = %d;\n",fgZeroSup);
1228 fprintf(f," fNSlice = %d;\n",fgNSlice);
1229 fprintf(f," fNRow = %d;\n",fgNRow);
1230 fprintf(f," fNRotShift = %.2f;\n",fgNRotShift);
3e87ef69 1231 //now do the arrays
b1ed0288 1232 for(Int_t i=0;i<fgNRow;i++){
1233 fprintf(f," fX[%d] = %3.2f;\n",i,fgX[i]);
3e87ef69 1234 }
b1ed0288 1235 for(Int_t i=0;i<fgNRow;i++){
1236 fprintf(f," fNPads[%d] = %d;\n",i,fgNPads[i]);
3e87ef69 1237 }
5923e698 1238
3e87ef69 1239 //Slice/Sector dont belong to aliroot, but we want to be flexible
b1ed0288 1240 for(Int_t i=0;i<fgNSlice;i++){
1241 fprintf(f," fSlice2Sector[%d][0] = %d;\n",i,fgSlice2Sector[i][0]);
1242 fprintf(f," fSlice2Sector[%d][1] = %d;\n",i,fgSlice2Sector[i][1]);
3e87ef69 1243 }
b1ed0288 1244 for(Int_t i=0;i<fgNSector;i++){
1245 fprintf(f," fSector2Slice[%d] = %d;\n",i,fgSector2Slice[i]);
3e87ef69 1246 }
b1ed0288 1247 for(Int_t i=0;i<fgNSector;i++){
1248 fprintf(f," fSectorLow[%d] = %d;\n",i,fgSectorLow[i]);
3e87ef69 1249 }
5923e698 1250
3e87ef69 1251 //Patches also dont really belong to the aliroot settings (but nevermind)
b1ed0288 1252 for(Int_t i=0;i<fgNPatches;i++){
1253 fprintf(f," fNRows[%d] = %d;\n",i,fgNRows[i]);
3e87ef69 1254 }
b1ed0288 1255 for(Int_t i=0;i<fgNPatches;i++){
1256 fprintf(f," fRows[%d][0] = %d;\n",i,fgRows[i][0]);
1257 fprintf(f," fRows[%d][1] = %d;\n",i,fgRows[i][1]);
3e87ef69 1258 }
1259
1260 //Rotation shift is an addon, too
b1ed0288 1261 for(Int_t i=0;i<fgNSlice;i++){
1262 Float_t cs = cos( (2*fgkPi/18) * (i+fgNRotShift) );
3e87ef69 1263 fprintf(f," fCos[%d] = %.10f;\n",i,cs);
5923e698 1264 }
b1ed0288 1265 for(Int_t i=0;i<fgNSlice;i++){
1266 Float_t sn = sin( (2*fgkPi/18) * (i+fgNRotShift) );
3e87ef69 1267 fprintf(f," fSin[%d] = %.10f;\n",i,sn);
5923e698 1268 }
3e87ef69 1269
5923e698 1270 fprintf(f,"}\n");
1271 fclose(f);
2220326f 1272
3e87ef69 1273 LOG(AliL3Log::kInformational,"AliL3Transform::SaveInitFile","File created")
1274 <<"Init file \""<<filenamepath<<"\" created"<<ENDLOG;
1275
2220326f 1276 return kTRUE;
3e87ef69 1277}
1278
1279Int_t AliL3Transform::GetNPads(Int_t row)
1280{
b1ed0288 1281 //get number of pads per row
1282 if(row < 0 || row >= fgNRow)
3e87ef69 1283 {
1284 LOG(AliL3Log::kError,"AliL3Transform::GetNPads","Row")
1285 <<AliL3Log::kDec<<"Wrong row "<<row<<ENDLOG;
1286 return 0;
1287 }
1288
b1ed0288 1289 return fgNPads[row];
5923e698 1290}
1291
e376e129 1292Int_t AliL3Transform::GetFirstRow(Int_t patch)
1293{
b1ed0288 1294 //get first row per patch
1295
e376e129 1296 if(patch==-1)
1297 return 0;
1298 else if(patch < -1 || patch >= 6)
1299 {
3e87ef69 1300 LOG(AliL3Log::kError,"AliL3Transform::GetFirstRow","Patch")
1301 <<AliL3Log::kDec<<"Wrong patch "<<patch<<ENDLOG;
e376e129 1302 return 0;
1303 }
1304 else
b1ed0288 1305 return fgRows[patch][0];
e376e129 1306}
1307
1308Int_t AliL3Transform::GetLastRow(Int_t patch)
1309{
b1ed0288 1310 //get last row per patch
e376e129 1311 if(patch==-1)
b1ed0288 1312 return fgRows[5][1];
e376e129 1313 else if(patch < -1 || patch >= 6)
1314 {
3e87ef69 1315 LOG(AliL3Log::kError,"AliL3Transform::GetLastRow","Patch")
1316 <<AliL3Log::kDec<<"Wrong patch "<<patch<<ENDLOG;
e376e129 1317 return 0;
1318 }
1319 else
b1ed0288 1320 return fgRows[patch][1];
e376e129 1321}
1322
a8ffd46b 1323Int_t AliL3Transform::GetFirstRowOnDDL(Int_t patch)
1324{
1325 //get first row per patch
1326
1327 if(patch==-1)
1328 return 0;
1329 else if(patch < -1 || patch >= 6)
1330 {
1331 LOG(AliL3Log::kError,"AliL3Transform::GetFirstRow","Patch")
1332 <<AliL3Log::kDec<<"Wrong patch "<<patch<<ENDLOG;
1333 return 0;
1334 }
1335 else
1336 {
1337 if(patch==1) return fgRows[patch][0]+1;
1338 return fgRows[patch][0];
1339 }
1340}
1341
1342Int_t AliL3Transform::GetLastRowOnDDL(Int_t patch)
1343{
1344 //get last row per patch
1345 if(patch==-1)
1346 return fgRows[5][1];
1347 else if(patch < -1 || patch >= 6)
1348 {
1349 LOG(AliL3Log::kError,"AliL3Transform::GetLastRow","Patch")
1350 <<AliL3Log::kDec<<"Wrong patch "<<patch<<ENDLOG;
1351 return 0;
1352 }
1353 else
1354 {
1355 if(patch==2 || patch==4) return fgRows[patch][1]-1;
1356 return fgRows[patch][1];
1357 }
1358}
1359
e376e129 1360Int_t AliL3Transform::GetNRows(Int_t patch)
1361{
b1ed0288 1362 //get number of rows per patch
e376e129 1363 if(patch==-1)
b1ed0288 1364 return fgNRow;
e376e129 1365 else if(patch < -1 || patch >= 6)
1366 {
3e87ef69 1367 LOG(AliL3Log::kError,"AliL3Transform::GetNRows","Patch")
1368 <<AliL3Log::kDec<<"Wrong patch "<<patch<<ENDLOG;
e376e129 1369 return 0;
1370 }
1371 else
b1ed0288 1372 return fgNRows[patch];
e376e129 1373}
1374
3e87ef69 1375Int_t AliL3Transform::GetPadRow(Float_t xvalue)
5923e698 1376{
3e87ef69 1377 //Find the padrow number corresponding to cartesian _local_ x value
3e87ef69 1378 if(xvalue < 0 || xvalue > 250)
1379 {
1380 LOG(AliL3Log::kError,"AliL3Transform::GetPadRow","X-value")
1381 <<AliL3Log::kDec<<"Suspicious x-value, make sure it is in local coordinate! "
1382 <<xvalue<<ENDLOG;
1383 return -1;
1384 }
1385
1386 Int_t x = (Int_t)rint(xvalue*10);
b1ed0288 1387 if(x < (Int_t)rint(fgX[1]*10))
5923e698 1388 return 0;
b1ed0288 1389 else if(x > (Int_t)rint(fgX[fgNRow-2]*10))
1390 return fgNRow-1;
3e87ef69 1391 else
1392 {
1393 Int_t padrow=1; //Of course, a more clever algorithm could help here
b1ed0288 1394 while(padrow < fgNRow-2)
3e87ef69 1395 {
b1ed0288 1396 if(x > (Int_t)rint(fgX[padrow-1]*10) && x < (Int_t)rint(fgX[padrow+1]*10))
3e87ef69 1397 break;
1398 padrow++;
1399 }
1400 return padrow;
1401 }
1402}
1403
1404Int_t AliL3Transform::GetPatch(Int_t padrow)
1405{
b1ed0288 1406 //get patch for padrow
1407 if(padrow < 0 || padrow >= fgNRow)
3e87ef69 1408 {
1409 LOG(AliL3Log::kError,"AliL3Transform::GetPatch","Padrow")
1410 <<AliL3Log::kDec<<"Wrong padrow "<<padrow<<ENDLOG;
1411 return -2;
1412 }
1413 Int_t patch=0;
b1ed0288 1414 while(patch < fgNPatches)
3e87ef69 1415 {
b1ed0288 1416 if(padrow >= fgRows[patch][0] && padrow <= fgRows[patch][1])
3e87ef69 1417 break;
1418 patch++;
1419 }
1420 return patch;
1421}
1422
1423Double_t AliL3Transform::GetPadLength(Int_t padrow)
1424{
b1ed0288 1425 //get pad length for padrow
1426 if(padrow >= fgNRow){
3e87ef69 1427 LOG(AliL3Log::kError,"AliL3Transform::GetPadLength","Padrow")
1428 <<AliL3Log::kDec<<"Wrong padrow "<<padrow<<ENDLOG;
1429 return 0;
1430 }
1431
b1ed0288 1432 if(padrow < fgNRowLow)
1433 return fgInnerPadLength;
1434 if(padrow >= fgNRowLow && padrow < fgNRowLow + fgNRowUp1 - 1)
1435 return fgOuter1PadLength;
1436 if(padrow >= fgNRowLow + fgNRowUp1 - 1)
1437 return fgOuter2PadLength;
5e0f9911 1438
3e87ef69 1439 //should never happen
1440 LOG(AliL3Log::kError,"AliL3Transform::GetPadLength","Padrow")
1441 <<AliL3Log::kDec<<"Wrong padrow "<<padrow<<ENDLOG;
1442 return -1.0;
1443}
1444
1445Double_t AliL3Transform::GetPadPitchWidth(Int_t patch)
1446{
b1ed0288 1447 //get pad patch width for patch
1448 if(patch < 0 || patch > fgNPatches)
3e87ef69 1449 {
1450 LOG(AliL3Log::kError,"AliL3Transform::GetPadPitchWidth","patct")
1451 <<AliL3Log::kDec<<"Wrong patch "<<patch<<ENDLOG;
1452 return -1;
1453 }
b1ed0288 1454 return patch < 2 ? fgPadPitchWidthLow : fgPadPitchWidthUp;
3e87ef69 1455}
1456
1457Double_t AliL3Transform::GetParSigmaY2(Int_t padrow,Float_t z,Float_t angle)
1458{
1459 //Calculate the expected transverse cluster width as a function of
1460 //drift distance and crossing angle.
1461 //z = local z-coordinate of cluster
1462 //angle = track crossing angle with normal to padrow plane
1463 //return value = sigma^2 (cartesian coordinates)
1464
1465 Double_t drift;
1466 if(z > 0)
b1ed0288 1467 drift = fgZLength - z;
3e87ef69 1468 else
b1ed0288 1469 drift = fgZLength + z;
3e87ef69 1470
1471 Double_t t1 = GetPRFSigma(padrow)*GetPRFSigma(padrow);
b1ed0288 1472 Double_t t2 = fgDiffT*fgDiffT*drift;
3e87ef69 1473 Double_t t3 = GetPadLength(padrow)*GetPadLength(padrow)*tan(angle)*tan(angle)/12;
b1ed0288 1474 Double_t t4 = fgkAnodeWireSpacing*fgkAnodeWireSpacing*(tan(angle) - fgOmegaTau)*(tan(angle) - fgOmegaTau)/12;
3e87ef69 1475
1476 return (t1 + t2 + t3 + t4);
1477}
1478
1479Double_t AliL3Transform::GetParSigmaZ2(Int_t padrow,Float_t z,Float_t tgl)
1480{
1481 //Calculate the expected longitudinal cluster width as a function of
1482 //drift distance and track crossing angle.
1483 //z = local z-coordinate of cluster
1484 //tgl = tan(dipangle)
1485 //return value = sigma^2 (cartesian coordinates)
1486
1487 Double_t drift;
1488 if(z > 0)
1489 drift = AliL3Transform::GetZLength() - z;
1490 else
1491 drift = AliL3Transform::GetZLength() + z;
1492
b1ed0288 1493 Double_t t1 = fgZSigma*fgZSigma;
1494 Double_t t2 = fgDiffL*fgDiffL*drift;
3e87ef69 1495 Double_t t3 = GetPadLength(padrow)*GetPadLength(padrow)*tgl*tgl/12;
1496
1497 return (t1 + t2 + t3);
5923e698 1498}
1499
5e0f9911 1500Double_t AliL3Transform::GetPRFSigma(Int_t padrow)
5923e698 1501{
b1ed0288 1502 //get sigma of pad response function for padrow
1503
1504 if(padrow >= fgNRow){
3e87ef69 1505 LOG(AliL3Log::kError,"AliL3Transform::GetPRFSigma","Padrow")
1506 <<AliL3Log::kDec<<"Wrong padrow "<<padrow<<ENDLOG;
5923e698 1507 return 0;
3e87ef69 1508 }
b1ed0288 1509 if(padrow < fgNRowLow)
1510 return fgInnerPRFSigma;
1511 if(padrow >= fgNRowLow && padrow < fgNRowLow + fgNRowUp1 - 1)
1512 return fgOuter1PRFSigma;
1513 if(padrow >= fgNRowLow + fgNRowUp1 - 1)
1514 return fgOuter2PRFSigma;
5e0f9911 1515
3e87ef69 1516 //should never happen
1517 LOG(AliL3Log::kError,"AliL3Transform::GetPRFSigma","Padrow")
1518 <<AliL3Log::kDec<<"Wrong padrow "<<padrow<<ENDLOG;
1519 return -1.;
a4e75a99 1520}
1521
108615fc 1522Double_t AliL3Transform::GetEta(Float_t *xyz)
1523{
b1ed0288 1524 //get eta
108615fc 1525 Double_t r3 = sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]+xyz[2]*xyz[2]);
1526 Double_t eta = 0.5 * log((r3+xyz[2])/(r3-xyz[2]));
1527 return eta;
1528}
1529
740da2a6 1530void AliL3Transform::XYZtoRPhiEta(Float_t *rpe, Float_t *xyz)
1531{
b1ed0288 1532 //transform xyz into rpe
740da2a6 1533 rpe[0] = sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]+xyz[2]*xyz[2]);
1534 rpe[1] = atan2(xyz[1],xyz[0]);
1535 rpe[2] = 0.5 * log((rpe[0]+xyz[2])/(rpe[0]-xyz[2]));
1536}
1537
3ac82106 1538Double_t AliL3Transform::GetEta(Int_t slice,Int_t padrow,Int_t pad,Int_t time)
bd7e82e0 1539{
b1ed0288 1540 //get eta
bd7e82e0 1541 Float_t xyz[3];
3a1c3849 1542 Int_t sector,row;
3ac82106 1543 Slice2Sector(slice,padrow,sector,row);
3a1c3849 1544 Raw2Local(xyz,sector,row,pad,time);
bd7e82e0 1545
1546 return GetEta(xyz);
1547}
1548
108615fc 1549Double_t AliL3Transform::GetPhi(Float_t *xyz)
1550{
b1ed0288 1551 //get phi
108615fc 1552 Double_t phi = atan2(xyz[1],xyz[0]);
108615fc 1553 return phi;
1554}
1555
494fad94 1556Bool_t AliL3Transform::Slice2Sector(Int_t slice, Int_t slicerow, Int_t & sector, Int_t &row)
1557{
b1ed0288 1558 //slice to sector number
1559 if(slicerow<0&&slicerow>=fgNRow){
3e87ef69 1560 LOG(AliL3Log::kError,"AliL3Transform::Slice2Sector","Slicerow")
1561 <<AliL3Log::kDec<<"Wrong slicerow "<<slicerow<<ENDLOG;
1562 return kFALSE;
1563 }
b1ed0288 1564 if(slice<0||slice>=fgNSlice){
3e87ef69 1565 LOG(AliL3Log::kError,"AliL3Transform::Slice2Sector","Slice")
1566 <<AliL3Log::kDec<<"Wrong slice "<<slice<<ENDLOG;
1567 return kFALSE;
1568 }
108615fc 1569
b1ed0288 1570 if(slicerow<fgNRowLow){
1571 sector = fgSlice2Sector[slice][0];
108615fc 1572 row = slicerow;
1573 }
1574 else {
b1ed0288 1575 sector = fgSlice2Sector[slice][1];
1576 row = slicerow-fgNRowLow;
108615fc 1577 }
3e87ef69 1578
108615fc 1579 return kTRUE;
1580}
1581
494fad94 1582Bool_t AliL3Transform::Sector2Slice(Int_t & slice, Int_t sector)
1583{
b1ed0288 1584 //sector to slice
1585 if(sector<0||sector>=fgNSector){
3e87ef69 1586 LOG(AliL3Log::kError,"AliL3Transform::Sector2Slice","Sector")
1587 <<AliL3Log::kDec<<"Wrong sector "<<sector<<ENDLOG;
1588 return kFALSE;
1589 }
1590
b1ed0288 1591 slice=fgSector2Slice[sector];
3e87ef69 1592
108615fc 1593 return kTRUE;
1594}
1595
3e87ef69 1596Bool_t AliL3Transform::Sector2Slice(Int_t & slice, Int_t & slicerow, Int_t sector, Int_t row)
494fad94 1597{
b1ed0288 1598 //sector to slice
1599 if(sector<0 || sector>=fgNSector){
3e87ef69 1600 LOG(AliL3Log::kError,"AliL3Transform::Sector2Slice","Sector")
1601 <<AliL3Log::kDec<<"Wrong sector "<<sector<<ENDLOG;
1602 return kFALSE;
1603 }
1604 if(row<0){
1605 LOG(AliL3Log::kError,"AliL3Transform::Sector2Slice","Row")
1606 <<AliL3Log::kDec<<"Wrong row "<<row<<ENDLOG;
1607 return kFALSE;
1608 }
1609
b1ed0288 1610 if(fgSectorLow[sector]){
1611 if(row>=fgNRowLow){
3e87ef69 1612 LOG(AliL3Log::kError,"AliL3Transform::Sector2Slice","Row")
1613 <<AliL3Log::kDec<<"Wrong row "<<row<<ENDLOG;
1614 return kFALSE;
1615 }
b1ed0288 1616 slice = fgSector2Slice[sector];
108615fc 1617 slicerow = row;
1618 }
1619 else{
b1ed0288 1620 if(row>=fgNRowUp){
3e87ef69 1621 LOG(AliL3Log::kError,"AliL3Transform::Sector2Slice","Row")
1622 <<AliL3Log::kDec<<"Wrong row "<<row<<ENDLOG;
1623 return kFALSE;
1624 }
b1ed0288 1625 slice = fgSector2Slice[sector];
1626 slicerow = row + fgNRowLow;
108615fc 1627 }
3e87ef69 1628
108615fc 1629 return kTRUE;
1630}
1631
5a31e9df 1632Double_t AliL3Transform::GetMaxY(Int_t slicerow)
1633{
b1ed0288 1634 //get maximum y value (for slice 0)
1635 if(slicerow < fgNRowLow)
1636 return fgPadPitchWidthLow*fgNPads[slicerow]/2;
5a31e9df 1637
1638 else
b1ed0288 1639 return fgPadPitchWidthUp*fgNPads[slicerow]/2;
5a31e9df 1640
1641}
1642
b1ed0288 1643Double_t AliL3Transform::Row2X(Int_t slicerow)
1644{
1645 //slicerow to X value (slice 0)
1646 if(slicerow<0||slicerow>=fgNRow){
3e87ef69 1647 LOG(AliL3Log::kError,"AliL3Transform::Row2X","Slicerow")
1648 <<AliL3Log::kDec<<"Wrong slicerow "<<slicerow<<ENDLOG;
1649 return 0;
1650 }
b1ed0288 1651 return fgX[slicerow];
108615fc 1652}
1653
de3c3890 1654Double_t AliL3Transform::GetZFast(Int_t slice, Int_t time, Float_t vertex)
5a31e9df 1655{
b1ed0288 1656 //get z value
1657 Double_t z=fgZWidth*time-fgZOffset;
5a31e9df 1658 if(slice < 18)
b1ed0288 1659 z=fgZLength-z-vertex;
5a31e9df 1660 else
b1ed0288 1661 z=z-fgZLength-vertex;
de3c3890 1662 return z;
5a31e9df 1663}
1664
108615fc 1665void AliL3Transform::Local2Global(Float_t *xyz,Int_t slice)
1666{
1667 //Transformation to global coordinate system
1668 Float_t x0 = xyz[0];
1669 Float_t y0 = xyz[1];
3e87ef69 1670
b1ed0288 1671 xyz[0]=x0*fgCos[slice]-y0*fgSin[slice];
1672 xyz[1]=x0*fgSin[slice]+y0*fgCos[slice];
108615fc 1673 xyz[2]=xyz[2];//global z=local z
1674}
1675
b1ed0288 1676void AliL3Transform::Local2GlobalAngle(Float_t *angle,Int_t slice)
1677{
1678 //get angle global
1679 angle[0] = fmod(angle[0]+(slice+fgNRotShift)*(2*fgkPi/18),2*fgkPi);
108615fc 1680}
1681
b1ed0288 1682void AliL3Transform::Global2LocalAngle(Float_t *angle,Int_t slice)
1683{
1684 //get angle local
1685 angle[0] = angle[0]-(slice+fgNRotShift)*(2*fgkPi/18);
1686 if(angle[0]<0) angle[0]+=2*fgkPi;
108615fc 1687}
1688
1689void AliL3Transform::Raw2Local(Float_t *xyz,Int_t sector,Int_t row,Float_t pad,Float_t time)
1690{
1691 //Transformation from rawdata to local coordinate system
1692
1693 Int_t slice,slicerow;
1694 Sector2Slice(slice, slicerow, sector, row);
1695
740da2a6 1696 //X-Value
108615fc 1697 xyz[0]=Row2X(slicerow);
740da2a6 1698
1699 //Y-Value
b1ed0288 1700 Int_t npads= fgNPads[slicerow];
3e87ef69 1701
b1ed0288 1702 if(fgSectorLow[sector])
1703 xyz[1]=(pad-0.5*(npads-1))*fgPadPitchWidthLow;
108615fc 1704 else
b1ed0288 1705 xyz[1]=(pad-0.5*(npads-1))*fgPadPitchWidthUp;
740da2a6 1706
1707 //Z-Value (remember PULSA Delay)
0e0b1e59 1708 if(slice < 18)
b1ed0288 1709 xyz[2]=fgZLength-fgZWidth*time+fgZOffset;
5a31e9df 1710 else
b1ed0288 1711 xyz[2]=fgZWidth*time-fgZOffset-fgZLength;
5a31e9df 1712}
1713
1714void AliL3Transform::Raw2Local(Float_t *xyz,Int_t sector,Int_t row,Int_t pad,Int_t time)
1715{
1716 //Transformation from rawdata to local coordinate system
1717
1718 Int_t slice,slicerow;
1719 Sector2Slice(slice, slicerow, sector, row);
1720
1721 //X-Value
1722 xyz[0]=Row2X(slicerow);
1723
1724 //Y-Value
b1ed0288 1725 Int_t npads= fgNPads[slicerow];
5a31e9df 1726
b1ed0288 1727 if(fgSectorLow[sector])
1728 xyz[1]=(pad-0.5*(npads-1))*fgPadPitchWidthLow;
5a31e9df 1729 else
b1ed0288 1730 xyz[1]=(pad-0.5*(npads-1))*fgPadPitchWidthUp;
5a31e9df 1731
1732 //Z-Value (remember PULSA Delay)
1733 if(slice < 18)
b1ed0288 1734 xyz[2]=fgZLength-fgZWidth*time+fgZOffset;
0e0b1e59 1735 else
b1ed0288 1736 xyz[2]=fgZWidth*time-fgZOffset-fgZLength;
5a31e9df 1737}
1738
1739void AliL3Transform::RawHLT2Local(Float_t *xyz,Int_t slice,
1740 Int_t slicerow,Float_t pad,Float_t time)
1741{
1742 //Transformation from HLT rawdata to local coordinate system
1743
1744 //X-Value
1745 xyz[0]=Row2X(slicerow);
1746
1747 //Y-Value
b1ed0288 1748 Int_t npads= fgNPads[slicerow];
1749 if(slicerow<fgNRowLow)
1750 xyz[1]=(pad-0.5*(npads-1))*fgPadPitchWidthLow;
5a31e9df 1751 else
b1ed0288 1752 xyz[1]=(pad-0.5*(npads-1))*fgPadPitchWidthUp;
5a31e9df 1753
1754 //Z-Value
1755 if(slice < 18)
b1ed0288 1756 xyz[2]=fgZLength-fgZWidth*time+fgZOffset;
5a31e9df 1757 else
b1ed0288 1758 xyz[2]=fgZWidth*time-fgZOffset-fgZLength;
5a31e9df 1759}
1760
1761void AliL3Transform::RawHLT2Local(Float_t *xyz,Int_t slice,
1762 Int_t slicerow,Int_t pad,Int_t time)
1763{
1764 //Transformation from HLT rawdata to local coordinate system
1765
1766 //X-Value
1767 xyz[0]=Row2X(slicerow);
1768
1769 //Y-Value
b1ed0288 1770 Int_t npads= fgNPads[slicerow];
1771 if(slicerow<fgNRowLow)
1772 xyz[1]=(pad-0.5*(npads-1))*fgPadPitchWidthLow;
5a31e9df 1773 else
b1ed0288 1774 xyz[1]=(pad-0.5*(npads-1))*fgPadPitchWidthUp;
5a31e9df 1775
1776 //Z-Value
1777 if(slice < 18)
b1ed0288 1778 xyz[2]=fgZLength-fgZWidth*time+fgZOffset;
5a31e9df 1779 else
b1ed0288 1780 xyz[2]=fgZWidth*time-fgZOffset-fgZLength;
108615fc 1781}
1782
1783void AliL3Transform::Local2Global(Float_t *xyz,Int_t sector,Int_t row)
1784{
1785 //Transformation to global coordinate system
1786 Int_t slice,slicerow;
1787 Sector2Slice(slice, slicerow, sector, row);
3e87ef69 1788 Float_t r=Row2X(slicerow); //have to get x value first
1789
b1ed0288 1790 xyz[0]=r*fgCos[slice]-xyz[1]*fgSin[slice];
1791 xyz[1]=r*fgSin[slice]+xyz[1]*fgCos[slice];
108615fc 1792 xyz[2]=xyz[2];//global z=local z
1793}
1794
5a31e9df 1795void AliL3Transform::LocHLT2Global(Float_t *xyz,Int_t slice,Int_t slicerow)
108615fc 1796{
5a31e9df 1797 //Transformation from HLT to global coordinate system
1798 Float_t r=Row2X(slicerow); //have to get x value first
1799
b1ed0288 1800 xyz[0]=r*fgCos[slice]-xyz[1]*fgSin[slice];
1801 xyz[1]=r*fgSin[slice]+xyz[1]*fgCos[slice];
5a31e9df 1802 xyz[2]=xyz[2];//global z=local z
108615fc 1803}
1804
5a31e9df 1805void AliL3Transform::Global2Local(Float_t *xyz,Int_t sector)
1806{ //check code
108615fc 1807 Int_t slice;
b1ed0288 1808 Sector2Slice(slice, sector);
5a31e9df 1809
b1ed0288 1810 Float_t x1 = xyz[0]*fgCos[slice] + xyz[1]*fgSin[slice];
1811 Float_t y1 = -xyz[0]*fgSin[slice] + xyz[1]*fgCos[slice];
5a31e9df 1812 xyz[0] = x1;
1813 xyz[1] = y1;
1814}
3e87ef69 1815
5a31e9df 1816void AliL3Transform::Global2LocHLT(Float_t *xyz,Int_t slice)
1817{
b1ed0288 1818 Float_t x1 = xyz[0]*fgCos[slice] + xyz[1]*fgSin[slice];
1819 Float_t y1 = -xyz[0]*fgSin[slice] + xyz[1]*fgCos[slice];
108615fc 1820 xyz[0] = x1;
1821 xyz[1] = y1;
1822}
1823
1824void AliL3Transform::Raw2Global(Float_t *xyz,Int_t sector,Int_t row,Float_t pad,Float_t time)
1825{
1826 //Transformation from raw to global coordinates
5a31e9df 1827
108615fc 1828 Raw2Local(xyz,sector,row,pad,time);
1829 Local2Global(xyz,sector,row);
1830}
1831
5a31e9df 1832void AliL3Transform::Raw2Global(Float_t *xyz,Int_t sector,Int_t row,Int_t pad,Int_t time)
1833{
1834 //Transformation from raw to global coordinates
1835
1836 Raw2Local(xyz,sector,row,pad,time);
1837 Local2Global(xyz,sector,row);
1838}
1839
1840void AliL3Transform::RawHLT2Global(Float_t *xyz,Int_t slice,
1841 Int_t slicerow,Float_t pad,Float_t time)
1842{
1843 //Transformation from raw to global coordinates
1844
1845 RawHLT2Local(xyz,slice,slicerow,pad,time);
1846 LocHLT2Global(xyz,slice,slicerow);
1847}
1848
1849void AliL3Transform::RawHLT2Global(Float_t *xyz,Int_t slice,
1850 Int_t slicerow,Int_t pad,Int_t time)
1851{
1852 //Transformation from raw to global coordinates
1853
1854 RawHLT2Local(xyz,slice,slicerow,pad,time);
1855 LocHLT2Global(xyz,slice,slicerow);
1856}
1857
108615fc 1858void AliL3Transform::Local2Raw(Float_t *xyz,Int_t sector,Int_t row)
1859{
1860 //Transformation from local coordinates to raw
494fad94 1861
108615fc 1862 Int_t slice,slicerow;
1863 Sector2Slice(slice, slicerow, sector, row);
1864
3e87ef69 1865 xyz[0]=slicerow;
3e87ef69 1866
b1ed0288 1867 if(fgSectorLow[sector])
1868 xyz[1]=xyz[1]/fgPadPitchWidthLow+0.5*(fgNPads[slicerow]-1);
108615fc 1869 else
b1ed0288 1870 xyz[1]=xyz[1]/fgPadPitchWidthUp+0.5*(fgNPads[slicerow]-1);
3e87ef69 1871
5a31e9df 1872 if(slice < 18)
b1ed0288 1873 xyz[2]=(fgZLength-xyz[2]+fgZOffset)/fgZWidth;
5a31e9df 1874 else
b1ed0288 1875 xyz[2]=(fgZLength+xyz[2]+fgZOffset)/fgZWidth;
5a31e9df 1876}
1877
1878void AliL3Transform::LocHLT2Raw(Float_t *xyz,Int_t slice,Int_t slicerow)
1879{
1880 //Transformation from local coordinates to raw
1881
1882 xyz[0]=slicerow;
1883
b1ed0288 1884 if(slicerow<fgNRowLow)
1885 xyz[1]=xyz[1]/fgPadPitchWidthLow+0.5*(fgNPads[slicerow]-1);
5a31e9df 1886 else
b1ed0288 1887 xyz[1]=xyz[1]/fgPadPitchWidthUp+0.5*(fgNPads[slicerow]-1);
5a31e9df 1888
1889 if(slice < 18)
b1ed0288 1890 xyz[2]=(fgZLength-xyz[2]+fgZOffset)/fgZWidth;
5a31e9df 1891 else
b1ed0288 1892 xyz[2]=(fgZLength+xyz[2]+fgZOffset)/fgZWidth;
108615fc 1893}
1894
1895void AliL3Transform::Global2Raw(Float_t *xyz,Int_t sector,Int_t row)
1896{
1897 //Transformation from global coordinates to raw.
1898
1899 Global2Local(xyz,sector);
1900 Local2Raw(xyz,sector,row);
3e87ef69 1901}
1902
5a31e9df 1903void AliL3Transform::Global2HLT(Float_t *xyz,Int_t slice,Int_t slicerow)
1904{
1905 //Transformation from global coordinates to raw.
1906
1907 Global2LocHLT(xyz,slice);
1908 LocHLT2Raw(xyz,slice,slicerow);
1909}
1910
3e87ef69 1911void AliL3Transform::PrintCompileOptions()
1912{
b1ed0288 1913 //print compile options
62bb4b3d 1914#if defined(__GNUC__)
0bd0c1ef 1915 cout << "Compiler (g++) version used: " << __GNUC__ << endl;
62bb4b3d 1916#endif
3e87ef69 1917
1918#ifdef no_root
1919 cout << "STANDALONE version: -Dno_root was given." << endl;
1920#else
1921 const Char_t *roottest="$ROOTSYS/bin/root -n -b -q | grep Version | cut -b 17-25 | cut -d\" \" -f1";
1922#ifdef use_aliroot
1923#ifdef use_cvs
1924 const Char_t *aliroottest="if test -n \"`cd $ALICE_ROOT/STEER/ && cvs stat AliRun.cxx | grep \"Sticky Tag\" | grep none`\"; then echo HEAD; else cd $ALICE_ROOT/STEER/ && cvs stat AliRun.cxx | grep \"Sticky Tag\" | cut -b 18- | cut -d\" \" -f1; fi";
1925#else
1926 const Char_t *aliroottest="Unknown";
1927#endif
1928 cout << "ALIROOT version: -Duse_aliroot and -Duse_root was given." << endl;
1929 cout << "Root Version: " << ROOTVERSION << " found " << flush;
1930 gSystem->Exec(roottest);
1931
1932 cout << "AliRoot Version: " << ALIROOTVERSION << " found " << flush;
1933 gSystem->Exec(aliroottest);
1934#else
1935 cout << "ROOT version: -Duse_root was given." << endl;
1936 cout << "Root Version: " << ROOTVERSION << " found " << flush;
1937 gSystem->Exec(roottest);
1938#endif
1939#endif
1940
1941#ifdef do_mc
1942 cout << "Using Monte Carlo Info: -Ddo_mc was given." << endl;
1943#else
1944 cout << "NOT using Monte Carlo Info: -Ddo_mc was not given." << endl;
1945#endif
108615fc 1946
de3c3890 1947#ifdef ROWHOUGHPARAMS
1948 cout << "Using extended AliL3TrackSegmentData: -DROWHOUGHPARAMS was given." << endl;
0bd0c1ef 1949#else
de3c3890 1950 cout << "NOT using extended AliL3TrackSegmentData: -DROWHOUGHPARAMS was not given." << endl;
0bd0c1ef 1951#endif
1952
1953#ifdef use_newio
1954 cout << "Using NEWIO version: -Duse_newio was given." << endl;
1955#else
1956 cout << "NOT using NEWIO version: -Duse_newio was not given." << endl;
1957#endif
1958
3e87ef69 1959#ifdef use_logging
1960 cout << "Using logging classes (MLUC): -Duse_logging was given." << endl;
1961#else
1962 cout << "NOT using logging classes (MLUC): -Duse_logging not was given." << endl;
1963#endif
0bd0c1ef 1964
108615fc 1965}