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