bugfix: calculate correct time bin width after setting of time bin range
[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();
d71fd696 981 // Matthias 24.04.2007 a default parameter has been added to GetZLength
982 // reverting some of Mareks changes
983 // TODO: we have to use the method correctly and put the slice no into it
984 //fgZLength=param->GetZLength(0)+0.275;
985 fgZLength=param->GetZLength()+0.275;
a6c02c85 986 fgZOffset=param->GetZOffset();
987 fgDiffT=param->GetDiffT();
988 fgDiffL=param->GetDiffL();
989 fgOmegaTau=param->GetOmegaTau();
990 fgInnerPadLength=param->GetInnerPadLength();
991 fgOuter1PadLength=param->GetOuter1PadLength();
992 fgOuter2PadLength=param->GetOuter2PadLength();
993 fgInnerPRFSigma=param->GetInnerPRF()->GetSigmaX();
994 fgOuter1PRFSigma=param->GetOuter1PRF()->GetSigmaX();
995 fgOuter2PRFSigma=param->GetOuter2PRF()->GetSigmaX();
996 fgTimeSigma=param->GetTimeRF()->GetSigma();
997 fgADCSat=param->GetADCSat();
998 fgZeroSup=param->GetZeroSup();
999 fgNSlice=fgNSectorLow;
1000
1001 //now do the arrays
1002 for(Int_t i=0;i<fgNRow;i++){
1003 Int_t sec,row;
1004 if( i < fgNRowLow){sec =0;row =i;}
1005 else{sec = fgNSectorLow;row =i-fgNRowLow;}
1006 fgX[i]=param->GetPadRowRadii(sec,row);
1007 }
1008 for(Int_t i=0;i<fgNRow;i++){
1009 Int_t sec,row;
1010 if( i < fgNRowLow){sec =0;row =i;}
1011 else{sec = fgNSectorLow;row =i-fgNRowLow;}
1012 fgNPads[i]=param->GetNPads(sec,row);
1013 }
1014 for(Int_t i=0;i<fgNSector;i++){
1015 if(i<fgNSectorLow) fgSectorLow[i]=1;
1016 else fgSectorLow[i]=0;
1017 }
1018
1019 return kTRUE;
1020
1021 /* not needed
1022 TTimeStamp time;
1023 Char_t tmpfile[1024];
1024 sprintf(tmpfile,"./l3transform.config-%d",(Int_t)time.GetSec());
1025
1026 return SaveInitFile(tmpfile);
1027 */
1028}
1029#endif
1030
1031Bool_t AliHLTTPCTransform::Init(Char_t* path,Bool_t UseAliTPCParam)
1032{
1033 //Overwrite the parameters with values stored in file "l3transform.config" in path.
1034 //If file does not exist, old default values will be used.
1035 //If flag UseAliTPCParam is set, the parameters will be read from the the rootfile
1036 //which then has to be called path/digitfile.root
1037
1038 if(fgVersion != kVdefault)
1039 LOG(AliHLTTPCLog::kWarning,"AliHLTTPCTransform::Init","Init values")
1040 <<AliHLTTPCLog::kDec<<"You are initializing the parameters more than once; check your code please! "<<fgVersion<<ENDLOG;
1041
1042 if(UseAliTPCParam) //use rootfile to generate temporary init file
1043 return ReadInit(path);
1044
1045 //create filename
1046 Char_t pathname[1024];
1047 strcpy(pathname,path);
1048
1049 //test whether provided path is the file itself
1050 Int_t isdir = 0;
1051 DIR *testdir=opendir(pathname);
1052 if(testdir){
1053 isdir=1;
1054 closedir(testdir);
1055 }
1056
1057 if(isdir) strcat(pathname,"/l3transform.config");
1058
1059 return ReadInitFile(pathname);
1060}
1061
1062Bool_t AliHLTTPCTransform::ReadInitFile(Char_t* pathname)
1063{
1064 //read transformer settings from pathname
1065 FILE *fptr=fopen(pathname,"r");
1066 if(!fptr){
1067 LOG(AliHLTTPCLog::kWarning,"AliHLTTPCTransform::ReadInitFile","File Open")
1068 <<"Pointer to Config File \""<<pathname<<"\" 0x0!"<<ENDLOG;
1069 return kFALSE;
1070 }
1071
1072 Char_t d1[250], d2[100], d3[100];
1073 Int_t dummy=0;
1074 Double_t ddummy=0.0;
1075
1076 while(!feof(fptr)) {
1077 fscanf(fptr,"%s",d1);
1078 if(strcmp(d1,"fVersion")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgVersion=dummy;}
1079 else if(strcmp(d1,"fBFieldFactor")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgBFieldFactor=(Double_t)ddummy;}
1080 else if(strcmp(d1,"fSolenoidBField")==0)
1081 {
1082 fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);
1083 fgSolenoidBField=(Double_t)ddummy;
1084 }
1085 else if(strcmp(d1,"fNTimeBins")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgNTimeBins=(Int_t)dummy;}
1086 else if(strcmp(d1,"fNRowLow")==0)
1087 {
1088 fscanf(fptr,"%s %d %s",d2,&dummy,d3);
1089 fgNRowLow=(Int_t)dummy;
1090 if(fgNRowLow != 63)
1091 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::ReadInitFile","Overflow")
1092 <<"Number of inner PadRows should be 63! Check and fgrep the code for 63 to see the consequences of this major change!"<<ENDLOG;
1093 }
1094 else if(strcmp(d1,"fNRowUp")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgNRowUp=(Int_t)dummy;}
1095 else if(strcmp(d1,"fNRowUp1")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgNRowUp1=(Int_t)dummy;}
1096 else if(strcmp(d1,"fNRowUp2")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgNRowUp2=(Int_t)dummy;}
1097 else if(strcmp(d1,"fNSectorLow")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgNSectorLow=(Int_t)dummy;}
1098 else if(strcmp(d1,"fNSectorUp")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgNSectorUp=(Int_t)dummy;}
1099 else if(strcmp(d1,"fNSector")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgNSector=(Int_t)dummy;}
1100 else if(strcmp(d1,"fPadPitchWidthLow")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgPadPitchWidthLow=(Double_t)ddummy;}
1101 else if(strcmp(d1,"fPadPitchWidthUp")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgPadPitchWidthUp=(Double_t)ddummy;}
1102 else if(strcmp(d1,"fZWidth")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgZWidth=(Double_t)ddummy;}
1103 else if(strcmp(d1,"fZSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgZSigma=(Double_t)ddummy;}
1104 else if(strcmp(d1,"fZLength")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgZLength=(Double_t)ddummy;}
1105 else if(strcmp(d1,"fZOffset")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgZOffset=(Double_t)ddummy;}
1106 else if(strcmp(d1,"fNSlice")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgNSlice=(Int_t)dummy;}
1107 else if(strcmp(d1,"fDiffT")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgDiffT=(Double_t)ddummy;}
1108 else if(strcmp(d1,"fDiffL")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgDiffL=(Double_t)ddummy;}
1109 else if(strcmp(d1,"fOmegaTau")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgOmegaTau=(Double_t)ddummy;}
1110 else if(strcmp(d1,"fInnerPadLength")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgInnerPadLength=(Double_t)ddummy;}
1111 else if(strcmp(d1,"fOuter1PadLength")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgOuter1PadLength=(Double_t)ddummy;}
1112 else if(strcmp(d1,"fOuter2PadLength")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgOuter2PadLength=(Double_t)ddummy;}
1113 else if(strcmp(d1,"fInnerPRFSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgInnerPRFSigma=(Double_t)ddummy;}
1114 else if(strcmp(d1,"fOuter1PRFSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgOuter1PRFSigma=(Double_t)ddummy;}
1115 else if(strcmp(d1,"fOuter2PRFSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgOuter2PRFSigma=(Double_t)ddummy;}
1116 else if(strcmp(d1,"fTimeSigma")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgTimeSigma=(Double_t)ddummy;}
1117 else if(strcmp(d1,"fADCSat")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgADCSat=(Int_t)dummy;}
1118 else if(strcmp(d1,"fZeroSup")==0){fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgZeroSup=(Int_t)dummy;}
1119 else if(strcmp(d1,"fNRow")==0){
1120 fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgNRow=(Int_t)dummy;
1121 if(fgNRow!=159){
1122 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;
1123 }
1124 }
1125 else if(strcmp(d1,"fNRotShift")==0){fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgNRotShift=(Double_t)ddummy;}
1126 else if(strcmp(d1,"fX[0]")==0){
1127 fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgX[0]=(Double_t)ddummy;
1128 for(Int_t i=1;i<fgNRow;i++){fscanf(fptr,"%s %s %lf %s",d1,d2,&ddummy,d3);fgX[i]=(Double_t)ddummy;}
1129 }
1130 else if(strcmp(d1,"fNPads[0]")==0){
1131 fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgNPads[0]=(Int_t)dummy;
1132 for(Int_t i=1;i<fgNRow;i++){fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fgNPads[i]=(Int_t)dummy;}
1133 }
1134 else if(strcmp(d1,"fNRows[0]")==0){
1135 fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgNRows[0]=(Int_t)dummy;
1136 for(Int_t i=1;i<fgNPatches;i++){fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fgNRows[i]=(Int_t)dummy;}
1137 }
1138 else if(strcmp(d1,"fRows[0][0]")==0){
1139 fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgRows[0][0]=(Int_t)dummy;
1140 fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fgRows[0][1]=(Int_t)dummy;
1141 for(Int_t i=1;i<fgNPatches;i++){
1142 fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fgRows[i][0]=(Int_t)dummy;
1143 fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fgRows[i][1]=(Int_t)dummy;
1144 }
1145 }
1146 else if(strcmp(d1,"fSlice2Sector[0][0]")==0){
1147 fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgSlice2Sector[0][0]=(Int_t)dummy;
1148 fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fgSlice2Sector[0][1]=(Int_t)dummy;
1149 for(Int_t i=1;i<fgNSlice;i++){
1150 fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fgSlice2Sector[i][0]=(Int_t)dummy;
1151 fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fgSlice2Sector[i][1]=(Int_t)dummy;
1152 }
1153 }
1154 else if(strcmp(d1,"fSector2Slice[0]")==0){
1155 fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgSector2Slice[0]=(Int_t)dummy;
1156 for(Int_t i=1;i<fgNSector;i++){fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fgSector2Slice[i]=(Int_t)dummy;}
1157 }
1158 else if(strcmp(d1,"fSectorLow[0]")==0){
1159 fscanf(fptr,"%s %d %s",d2,&dummy,d3);fgSectorLow[0]=(Int_t)dummy;
1160 for(Int_t i=1;i<fgNSector;i++){fscanf(fptr,"%s %s %d %s",d1,d2,&dummy,d3);fgSectorLow[i]=(Int_t)dummy;}
1161 }
1162 else if(strcmp(d1,"fCos[0]")==0){
1163 fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgCos[0]=(Double_t)ddummy;
1164 for(Int_t i=1;i<fgNSlice;i++){fscanf(fptr,"%s %s %lf %s",d1,d2,&ddummy,d3);fgCos[i]=(Double_t)ddummy;}
1165 }
1166 else if(strcmp(d1,"fSin[0]")==0){
1167 fscanf(fptr,"%s %lf %s",d2,&ddummy,d3);fgSin[0]=(Double_t)ddummy;
1168 for(Int_t i=1;i<fgNSlice;i++){fscanf(fptr,"%s %s %lf %s",d1,d2,&ddummy,d3);fgSin[i]=(Double_t)ddummy;}
1169 }
1170 }
1171 fclose(fptr);
1172
1173 //The first multiplier gives the scale factor used to modify the field map
1174 //defined by the second multiplier.
1175 fgBField=fgBFieldFactor*fgSolenoidBField*0.1;
1176
1177 //Test if new config file has been used.
1178 if(fgVersion==kVdeprecated){
1179 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::ReadInitFile","Version")
1180 <<"Version is deprecated, you have to create a new config file."<<ENDLOG;
1181 return kFALSE;
1182 }
1183
1184 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCTransform::ReadInitFile","Config")
1185 <<"Successfully loaded values from config file \""<<pathname<<"\""<<ENDLOG;
1186
1187 return kTRUE;
1188}
1189
1190Bool_t AliHLTTPCTransform::ReadInit(Char_t *path)
1191{
1192 //Read all the parameters from a aliroot file, and store it in a temporary
1193 //file which is read by Init. Use this if you want to read the parameters from
1194 //the rootfile "every" time.
1195
1196#ifndef use_aliroot
1197 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::ReadInit","Version")
1198 <<"You have to compile with use_aliroot flag in order to read from AliROOT file"<<ENDLOG;
1199 return kFALSE;
1200#else
1201 Char_t filename[1024];
1202 //first test whether provided path is the rootfile itself
1203 Int_t saveErrIgLevel=gErrorIgnoreLevel;
1204 gErrorIgnoreLevel=kFatal; //dont report errors
1205 TFile *rootfile = TFile::Open(path);
1206 if(!rootfile || rootfile->IsZombie())
1207 { //ok assume its path to alirunfile file
1208 sprintf(filename,"%s/alirunfile.root",path); //create rootfile name
1209 } else { //path contains itself the rootfile name
1210 rootfile->Close();
1211 sprintf(filename,"%s",path);
1212 }
1213 gErrorIgnoreLevel=saveErrIgLevel;
1214
1215 //finally make dummy init file /tmp/$USER/l3transform.config-`date`
1216 Char_t tmppath[1024];
1217 sprintf(tmppath,"/tmp/%s",gSystem->Getenv("USER"));
1218 gSystem->mkdir(tmppath);
1219 TTimeStamp time;
1220 Char_t tmpfile[1024];
1221 sprintf(tmpfile,"%s/l3transform.config-%d",tmppath,(Int_t)time.GetSec());
1222 return MakeInitFile(filename,tmpfile);
1223#endif
1224}
1225
1226Bool_t AliHLTTPCTransform::MakeInitFile(Char_t *rootfilename,Char_t *filename)
1227{
1228 //Get the parameters from rootfile, and store it on the file "l3transform.config"
1229 //which is being read by Init. fVersion will be kV_aliroot!
1230
1231#ifndef use_aliroot
1232 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::MakeInitFile","Version")
1233 <<"You have to compile with use_aliroot flag in order to use this function"<<ENDLOG;
1234 return kFALSE;
1235#else
1236 TFile *rootfile = TFile::Open(rootfilename);
1237 if(!rootfile)
1238 {
1239 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::MakeInitFile","File")
1240 <<"Could not open file: "<<rootfilename<<ENDLOG;
1241 return kFALSE;
1242 }
1243 AliRun *gAlice = (AliRun*)rootfile->Get("gAlice");
1244 if(!gAlice)
1245 {
1246 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::MakeInitFile","File")
1247 <<"No gAlice in file: "<<rootfilename<<ENDLOG;
1248 return kFALSE;
1249 }
1250 AliTPCParamSR *param=(AliTPCParamSR*)rootfile->Get(GetParamName());
1251 if(!param)
1252 {
1253 LOG(AliHLTTPCLog::kWarning,"AliHLTTPCTransform::MakeInitFile","File")
1254 <<"No TPC parameters found in \""<<rootfilename
1255 <<"\", creating standard parameters "
1256 <<"which might not be what you want!"<<ENDLOG;
1257 param=new AliTPCParamSR;
1258 }
1259
1260 AliTPCPRF2D * prfinner = new AliTPCPRF2D;
1261 AliTPCPRF2D * prfouter1 = new AliTPCPRF2D;
1262 AliTPCPRF2D * prfouter2 = new AliTPCPRF2D;
1263 AliTPCRF1D * rf = new AliTPCRF1D(kTRUE);
1264 rf->SetGauss(param->GetZSigma(),param->GetZWidth(),1.);
1265 rf->SetOffset(3*param->GetZSigma());
1266 rf->Update();
1267
1268 TDirectory *savedir=gDirectory;
1269 TFile *prf_file = TFile::Open("$ALICE_ROOT/TPC/AliTPCprf2d.root");
1270 if (!prf_file->IsOpen())
1271 {
1272 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::MakeInitFile","File")
1273 <<"Can't open $ALICE_ROOT/TPC/AliTPCprf2d.root !"<<ENDLOG;
1274 return kFALSE;
1275 }
1276 prfinner ->Read("prf_07504_Gati_056068_d02");
1277 prfouter1->Read("prf_10006_Gati_047051_d03");
1278 prfouter2->Read("prf_15006_Gati_047051_d03");
1279 prf_file->Close();
1280 savedir->cd();
1281
1282 param->SetInnerPRF(prfinner);
1283 param->SetOuter1PRF(prfouter1);
1284 param->SetOuter2PRF(prfouter2);
1285 param->SetTimeRF(rf);
1286
1287 fgNTimeBins = param->GetMaxTBin()+1;
1288 fgNRowLow = param->GetNRowLow();
1289 fgNRowUp = param->GetNRowUp();
1290 fgNRowUp1 = param->GetNRowUp1();
1291 fgNRowUp2 = param->GetNRowUp2();
1292 fgNRow= fgNRowLow + fgNRowUp;
1293 if(fgNRow!=159){
1294 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::MakeInitFile","fNRow")
1295 <<"Number of rows have changed in ALIROOT"<<ENDLOG;
1296 return kFALSE;
1297 }
1298
1299 fgNSectorLow = param->GetNInnerSector();
1300 fgNSectorUp = param->GetNOuterSector();
1301 fgNSector = fgNSectorLow + fgNSectorUp;
1302
1303 //test whether they were changes to the rotation shift
1304 fgNRotShift=0;
1305 Float_t irotshift = param->GetInnerAngleShift(); //shift angle
1306 Float_t orotshift = param->GetOuterAngleShift(); //shift angle
1307 const Float_t kDegtoRad = 0.01745329251994;
1308 Int_t shift1=TMath::Nint(irotshift/kDegtoRad);
1309 Int_t shift2=TMath::Nint(orotshift/kDegtoRad+0.1);
1310 if((shift1!=shift2) || (shift1!=10)){
1311 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::MakeInitFile","Rotshiftangle")
1312 <<"Rotation shift angle has changed in ALIROOT"<<ENDLOG;
1313 return kFALSE;
1314 } else {
1315 fgNRotShift=0.5; //our version of the shift angle
1316 }
1317
1318 fgVersion=kValiroot;
1319 SetBFieldFactor((Double_t)gAlice->Field()->Factor());
cce3eda4 1320 SetSolenoidBField(-
1321 (Double_t)gAlice->Field()->SolenoidField()/
1322 (Double_t)gAlice->Field()->Factor()
1323 );
a6c02c85 1324 fgPadPitchWidthLow=param->GetInnerPadPitchWidth();
1325 fgPadPitchWidthUp=param->GetOuterPadPitchWidth();
1326 fgZWidth=param->GetZWidth();
1327 fgZSigma=param->GetZSigma();
d71fd696 1328 // Matthias 24.04.2007 a default parameter has been added to GetZLength
1329 // reverting some of Mareks changes
1330 // TODO: we have to use the method correctly and put the slice no into it
1331 //fgZLength=param->GetZLength(0)+0.275;
1332 fgZLength=param->GetZLength()+0.275;
a6c02c85 1333 fgZOffset=param->GetZOffset();
1334 fgDiffT=param->GetDiffT();
1335 fgDiffL=param->GetDiffL();
1336 fgOmegaTau=param->GetOmegaTau();
1337 fgInnerPadLength=param->GetInnerPadLength();
1338 fgOuter1PadLength=param->GetOuter1PadLength();
1339 fgOuter2PadLength=param->GetOuter2PadLength();
1340 fgInnerPRFSigma=param->GetInnerPRF()->GetSigmaX();
1341 fgOuter1PRFSigma=param->GetOuter1PRF()->GetSigmaX();
1342 fgOuter2PRFSigma=param->GetOuter2PRF()->GetSigmaX();
1343 fgTimeSigma=param->GetTimeRF()->GetSigma();
1344 fgADCSat=param->GetADCSat();
1345 fgZeroSup=param->GetZeroSup();
1346 fgNSlice=fgNSectorLow;
1347
1348 //now do the arrays
1349 for(Int_t i=0;i<fgNRow;i++){
1350 Int_t sec,row;
1351 if( i < fgNRowLow){sec =0;row =i;}
1352 else{sec = fgNSectorLow;row =i-fgNRowLow;}
1353 fgX[i]=param->GetPadRowRadii(sec,row);
1354 }
1355 for(Int_t i=0;i<fgNRow;i++){
1356 Int_t sec,row;
1357 if( i < fgNRowLow){sec =0;row =i;}
1358 else{sec = fgNSectorLow;row =i-fgNRowLow;}
1359 fgNPads[i]=param->GetNPads(sec,row);
1360 }
1361 for(Int_t i=0;i<fgNSector;i++){
1362 if(i<fgNSectorLow) fgSectorLow[i]=1;
1363 else fgSectorLow[i]=0;
1364 }
1365
1366 delete gAlice;
1367 rootfile->Close();
1368 delete rootfile;
1369
1370 return SaveInitFile(filename);
1371#endif
1372}
1373
1374Bool_t AliHLTTPCTransform::SaveInitFile(Char_t *filenamepath)
1375{
1376 //store the parameters in the file "filenamepath"
1377
1378 FILE *f = fopen(filenamepath,"w");
1379 if(!f){
1380 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::SaveInitFile","File")
1381 <<"Could not open file: "<<filenamepath<<ENDLOG;
1382 return kFALSE;
1383 }
1384
1385 fprintf(f,"void AliHLTTPCTransform::Init(){\n");
1386 fprintf(f," fVersion = %d;\n", fgVersion);
1387 fprintf(f," fBFieldFactor = %.3f;\n",fgBFieldFactor);
1388 fprintf(f," fSolenoidBField = %.3f;\n",fgSolenoidBField);
1389 fprintf(f," fNTimeBins = %d;\n",fgNTimeBins);
1390 fprintf(f," fNRowLow = %d;\n",fgNRowLow);
1391 fprintf(f," fNRowUp = %d;\n",fgNRowUp);
1392 fprintf(f," fNRowUp1 = %d;\n",fgNRowUp1);
1393 fprintf(f," fNRowUp2 = %d;\n",fgNRowUp2);
1394 fprintf(f," fNSectorLow = %d;\n",fgNSectorLow);
1395 fprintf(f," fNSectorUp = %d;\n",fgNSectorUp);
1396 fprintf(f," fNSector = %d;\n",fgNSector);
1397 fprintf(f," fPadPitchWidthLow = %.3f;\n",fgPadPitchWidthLow);
1398 fprintf(f," fPadPitchWidthUp = %.3f;\n",fgPadPitchWidthUp);
1399 fprintf(f," fZWidth = %.4f;\n",fgZWidth);
1400 fprintf(f," fZSigma = %.4f;\n",fgZSigma);
1401 fprintf(f," fZLength = %.4f;\n",fgZLength);
1402 fprintf(f," fZOffset = %.4f;\n",fgZOffset);
1403 fprintf(f," fDiffT = %.4f;\n",fgDiffT);
1404 fprintf(f," fDiffL = %.4f;\n",fgDiffL);
1405 fprintf(f," fOmegaTau = %.4f;\n",fgOmegaTau);
1406 fprintf(f," fInnerPadLength = %.3f;\n",fgInnerPadLength);
1407 fprintf(f," fOuter1PadLength = %.3f;\n",fgOuter1PadLength);
1408 fprintf(f," fOuter2PadLength = %.3f;\n",fgOuter2PadLength);
1409 fprintf(f," fInnerPRFSigma = %.6f;\n",fgInnerPRFSigma);
1410 fprintf(f," fOuter1PRFSigma = %.6f;\n",fgOuter1PRFSigma);
1411 fprintf(f," fOuter2PRFSigma = %.6f;\n",fgOuter2PRFSigma);
1412 fprintf(f," fTimeSigma = %.6f;\n",fgTimeSigma);
1413 fprintf(f," fADCSat = %d;\n",fgADCSat);
1414 fprintf(f," fZeroSup = %d;\n",fgZeroSup);
1415 fprintf(f," fNSlice = %d;\n",fgNSlice);
1416 fprintf(f," fNRow = %d;\n",fgNRow);
1417 fprintf(f," fNRotShift = %.2f;\n",fgNRotShift);
1418 //now do the arrays
1419 for(Int_t i=0;i<fgNRow;i++){
1420 fprintf(f," fX[%d] = %3.2f;\n",i,fgX[i]);
1421 }
1422 for(Int_t i=0;i<fgNRow;i++){
1423 fprintf(f," fNPads[%d] = %d;\n",i,fgNPads[i]);
1424 }
1425
1426 //Slice/Sector dont belong to aliroot, but we want to be flexible
1427 for(Int_t i=0;i<fgNSlice;i++){
1428 fprintf(f," fSlice2Sector[%d][0] = %d;\n",i,fgSlice2Sector[i][0]);
1429 fprintf(f," fSlice2Sector[%d][1] = %d;\n",i,fgSlice2Sector[i][1]);
1430 }
1431 for(Int_t i=0;i<fgNSector;i++){
1432 fprintf(f," fSector2Slice[%d] = %d;\n",i,fgSector2Slice[i]);
1433 }
1434 for(Int_t i=0;i<fgNSector;i++){
1435 fprintf(f," fSectorLow[%d] = %d;\n",i,fgSectorLow[i]);
1436 }
1437
1438 //Patches also dont really belong to the aliroot settings (but nevermind)
1439 for(Int_t i=0;i<fgNPatches;i++){
1440 fprintf(f," fNRows[%d] = %d;\n",i,fgNRows[i]);
1441 }
1442 for(Int_t i=0;i<fgNPatches;i++){
1443 fprintf(f," fRows[%d][0] = %d;\n",i,fgRows[i][0]);
1444 fprintf(f," fRows[%d][1] = %d;\n",i,fgRows[i][1]);
1445 }
1446
1447 //Rotation shift is an addon, too
1448 for(Int_t i=0;i<fgNSlice;i++){
1449 Float_t cs = cos( (2*fgkPi/18) * (i+fgNRotShift) );
1450 fprintf(f," fCos[%d] = %.10f;\n",i,cs);
1451 }
1452 for(Int_t i=0;i<fgNSlice;i++){
1453 Float_t sn = sin( (2*fgkPi/18) * (i+fgNRotShift) );
1454 fprintf(f," fSin[%d] = %.10f;\n",i,sn);
1455 }
1456
1457 fprintf(f,"}\n");
1458 fclose(f);
1459
1460 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCTransform::SaveInitFile","File created")
1461 <<"Init file \""<<filenamepath<<"\" created"<<ENDLOG;
1462
1463 return kTRUE;
1464}
1465
1466Int_t AliHLTTPCTransform::GetNPads(Int_t row)
1467{
1468 //get number of pads per row
1469 if(row < 0 || row >= fgNRow)
1470 {
1471 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::GetNPads","Row")
1472 <<AliHLTTPCLog::kDec<<"Wrong row "<<row<<ENDLOG;
1473 return 0;
1474 }
1475
1476 return fgNPads[row];
1477}
1478
84645eb0 1479Int_t AliHLTTPCTransform::GetNumberOfPatches() {
1480 return fgNPatches;
1481}
1482
a6c02c85 1483Int_t AliHLTTPCTransform::GetFirstRow(Int_t patch)
1484{
1485 //get first row per patch
1486
1487 if(patch==-1)
1488 return 0;
1489 else if(patch < -1 || patch >= 6)
1490 {
1491 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::GetFirstRow","Patch")
1492 <<AliHLTTPCLog::kDec<<"Wrong patch "<<patch<<ENDLOG;
1493 return 0;
1494 }
1495 else
1496 return fgRows[patch][0];
1497}
1498
1499Int_t AliHLTTPCTransform::GetLastRow(Int_t patch)
1500{
1501 //get last row per patch
1502 if(patch==-1)
1503 return fgRows[5][1];
1504 else if(patch < -1 || patch >= 6)
1505 {
1506 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::GetLastRow","Patch")
1507 <<AliHLTTPCLog::kDec<<"Wrong patch "<<patch<<ENDLOG;
1508 return 0;
1509 }
1510 else
1511 return fgRows[patch][1];
1512}
1513
1514Int_t AliHLTTPCTransform::GetFirstRowOnDDL(Int_t patch)
1515{
1516 //get first row per patch
1517
1518 if(patch==-1)
1519 return 0;
1520 else if(patch < -1 || patch >= 6)
1521 {
1522 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::GetFirstRow","Patch")
1523 <<AliHLTTPCLog::kDec<<"Wrong patch "<<patch<<ENDLOG;
1524 return 0;
1525 }
1526 else
1527 {
1528 if(patch==1) return fgRows[patch][0]+1;
1529 return fgRows[patch][0];
1530 }
1531}
1532
1533Int_t AliHLTTPCTransform::GetLastRowOnDDL(Int_t patch)
1534{
1535 //get last row per patch
1536 if(patch==-1)
1537 return fgRows[5][1];
1538 else if(patch < -1 || patch >= 6)
1539 {
1540 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::GetLastRow","Patch")
1541 <<AliHLTTPCLog::kDec<<"Wrong patch "<<patch<<ENDLOG;
1542 return 0;
1543 }
1544 else
1545 {
1546 if(patch==2 || patch==4) return fgRows[patch][1]-1;
1547 return fgRows[patch][1];
1548 }
1549}
1550
1551Int_t AliHLTTPCTransform::GetNRows(Int_t patch)
1552{
1553 //get number of rows per patch
1554 if(patch==-1)
1555 return fgNRow;
1556 else if(patch < -1 || patch >= 6)
1557 {
1558 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::GetNRows","Patch")
1559 <<AliHLTTPCLog::kDec<<"Wrong patch "<<patch<<ENDLOG;
1560 return 0;
1561 }
1562 else
1563 return fgNRows[patch];
1564}
1565
1566Int_t AliHLTTPCTransform::GetPadRow(Float_t xvalue)
1567{
1568 //Find the padrow number corresponding to cartesian _local_ x value
1569 if(xvalue < 0 || xvalue > 250)
1570 {
1571 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::GetPadRow","X-value")
1572 <<AliHLTTPCLog::kDec<<"Suspicious x-value, make sure it is in local coordinate! "
1573 <<xvalue<<ENDLOG;
1574 return -1;
1575 }
1576
1577 Int_t x = (Int_t)rint(xvalue*10);
1578 if(x < (Int_t)rint(fgX[1]*10))
1579 return 0;
1580 else if(x > (Int_t)rint(fgX[fgNRow-2]*10))
1581 return fgNRow-1;
1582 else
1583 {
1584 Int_t padrow=1; //Of course, a more clever algorithm could help here
1585 while(padrow < fgNRow-2)
1586 {
1587 if(x > (Int_t)rint(fgX[padrow-1]*10) && x < (Int_t)rint(fgX[padrow+1]*10))
1588 break;
1589 padrow++;
1590 }
1591 return padrow;
1592 }
1593}
1594
1595Int_t AliHLTTPCTransform::GetPatch(Int_t padrow)
1596{
1597 //get patch for padrow
1598 if(padrow < 0 || padrow >= fgNRow)
1599 {
1600 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::GetPatch","Padrow")
1601 <<AliHLTTPCLog::kDec<<"Wrong padrow "<<padrow<<ENDLOG;
1602 return -2;
1603 }
1604 Int_t patch=0;
1605 while(patch < fgNPatches)
1606 {
1607 if(padrow >= fgRows[patch][0] && padrow <= fgRows[patch][1])
1608 break;
1609 patch++;
1610 }
1611 return patch;
1612}
1613
1614Double_t AliHLTTPCTransform::GetPadLength(Int_t padrow)
1615{
1616 //get pad length for padrow
1617 if(padrow >= fgNRow){
1618 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::GetPadLength","Padrow")
1619 <<AliHLTTPCLog::kDec<<"Wrong padrow "<<padrow<<ENDLOG;
1620 return 0;
1621 }
1622
1623 if(padrow < fgNRowLow)
1624 return fgInnerPadLength;
1625 if(padrow >= fgNRowLow && padrow < fgNRowLow + fgNRowUp1 - 1)
1626 return fgOuter1PadLength;
1627 if(padrow >= fgNRowLow + fgNRowUp1 - 1)
1628 return fgOuter2PadLength;
1629
1630 //should never happen
1631 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::GetPadLength","Padrow")
1632 <<AliHLTTPCLog::kDec<<"Wrong padrow "<<padrow<<ENDLOG;
1633 return -1.0;
1634}
1635
1636Double_t AliHLTTPCTransform::GetPadPitchWidth(Int_t patch)
1637{
1638 //get pad patch width for patch
1639 if(patch < 0 || patch > fgNPatches)
1640 {
1641 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::GetPadPitchWidth","patct")
1642 <<AliHLTTPCLog::kDec<<"Wrong patch "<<patch<<ENDLOG;
1643 return -1;
1644 }
1645 return patch < 2 ? fgPadPitchWidthLow : fgPadPitchWidthUp;
1646}
1647
1648Double_t AliHLTTPCTransform::GetParSigmaY2(Int_t padrow,Float_t z,Float_t angle)
1649{
1650 //Calculate the expected transverse cluster width as a function of
1651 //drift distance and crossing angle.
1652 //z = local z-coordinate of cluster
1653 //angle = track crossing angle with normal to padrow plane
1654 //return value = sigma^2 (cartesian coordinates)
1655
1656 Double_t drift;
1657 if(z > 0)
1658 drift = fgZLength - z;
1659 else
1660 drift = fgZLength + z;
1661
1662 Double_t t1 = GetPRFSigma(padrow)*GetPRFSigma(padrow);
1663 Double_t t2 = fgDiffT*fgDiffT*drift;
1664 Double_t t3 = GetPadLength(padrow)*GetPadLength(padrow)*tan(angle)*tan(angle)/12;
1665 Double_t t4 = fgkAnodeWireSpacing*fgkAnodeWireSpacing*(tan(angle) - fgOmegaTau)*(tan(angle) - fgOmegaTau)/12;
1666
1667 return (t1 + t2 + t3 + t4);
1668}
1669
1670Double_t AliHLTTPCTransform::GetParSigmaZ2(Int_t padrow,Float_t z,Float_t tgl)
1671{
1672 //Calculate the expected longitudinal cluster width as a function of
1673 //drift distance and track crossing angle.
1674 //z = local z-coordinate of cluster
1675 //tgl = tan(dipangle)
1676 //return value = sigma^2 (cartesian coordinates)
1677
1678 Double_t drift;
1679 if(z > 0)
a1ec4d07 1680 drift = AliHLTTPCTransform::GetZLength()-0.275 - z;
a6c02c85 1681 else
a1ec4d07 1682 drift = AliHLTTPCTransform::GetZLength()-0.302 + z;
a6c02c85 1683
1684 Double_t t1 = fgZSigma*fgZSigma;
1685 Double_t t2 = fgDiffL*fgDiffL*drift;
1686 Double_t t3 = GetPadLength(padrow)*GetPadLength(padrow)*tgl*tgl/12;
1687
1688 return (t1 + t2 + t3);
1689}
1690
1691Double_t AliHLTTPCTransform::GetPRFSigma(Int_t padrow)
1692{
1693 //get sigma of pad response function for padrow
1694
1695 if(padrow >= fgNRow){
1696 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::GetPRFSigma","Padrow")
1697 <<AliHLTTPCLog::kDec<<"Wrong padrow "<<padrow<<ENDLOG;
1698 return 0;
1699 }
1700 if(padrow < fgNRowLow)
1701 return fgInnerPRFSigma;
1702 if(padrow >= fgNRowLow && padrow < fgNRowLow + fgNRowUp1 - 1)
1703 return fgOuter1PRFSigma;
1704 if(padrow >= fgNRowLow + fgNRowUp1 - 1)
1705 return fgOuter2PRFSigma;
1706
1707 //should never happen
1708 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::GetPRFSigma","Padrow")
1709 <<AliHLTTPCLog::kDec<<"Wrong padrow "<<padrow<<ENDLOG;
1710 return -1.;
1711}
1712
1713Double_t AliHLTTPCTransform::GetEta(Float_t *xyz)
1714{
1715 //get eta
1716 Double_t r3 = sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]+xyz[2]*xyz[2]);
1717 Double_t eta = 0.5 * log((r3+xyz[2])/(r3-xyz[2]));
1718 return eta;
1719}
1720
1721void AliHLTTPCTransform::XYZtoRPhiEta(Float_t *rpe, Float_t *xyz)
1722{
1723 //transform xyz into rpe
1724 rpe[0] = sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]+xyz[2]*xyz[2]);
1725 rpe[1] = atan2(xyz[1],xyz[0]);
1726 rpe[2] = 0.5 * log((rpe[0]+xyz[2])/(rpe[0]-xyz[2]));
1727}
1728
1729Double_t AliHLTTPCTransform::GetEta(Int_t slice,Int_t padrow,Int_t pad,Int_t time)
1730{
1731 //get eta
1732 Float_t xyz[3];
1733 Int_t sector,row;
1734 Slice2Sector(slice,padrow,sector,row);
1735 Raw2Local(xyz,sector,row,pad,time);
1736
1737 return GetEta(xyz);
1738}
1739
1740Double_t AliHLTTPCTransform::GetPhi(Float_t *xyz)
1741{
1742 //get phi
1743 Double_t phi = atan2(xyz[1],xyz[0]);
1744 return phi;
1745}
1746
1747Bool_t AliHLTTPCTransform::Slice2Sector(Int_t slice, Int_t slicerow, Int_t & sector, Int_t &row)
1748{
1749 //slice to sector number
1750 if(slicerow<0&&slicerow>=fgNRow){
1751 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::Slice2Sector","Slicerow")
1752 <<AliHLTTPCLog::kDec<<"Wrong slicerow "<<slicerow<<ENDLOG;
1753 return kFALSE;
1754 }
1755 if(slice<0||slice>=fgNSlice){
1756 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::Slice2Sector","Slice")
1757 <<AliHLTTPCLog::kDec<<"Wrong slice "<<slice<<ENDLOG;
1758 return kFALSE;
1759 }
1760
1761 if(slicerow<fgNRowLow){
1762 sector = fgSlice2Sector[slice][0];
1763 row = slicerow;
1764 }
1765 else {
1766 sector = fgSlice2Sector[slice][1];
1767 row = slicerow-fgNRowLow;
1768 }
1769
1770 return kTRUE;
1771}
1772
1773Bool_t AliHLTTPCTransform::Sector2Slice(Int_t & slice, Int_t sector)
1774{
1775 //sector to slice
1776 if(sector<0||sector>=fgNSector){
1777 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::Sector2Slice","Sector")
1778 <<AliHLTTPCLog::kDec<<"Wrong sector "<<sector<<ENDLOG;
1779 return kFALSE;
1780 }
1781
1782 slice=fgSector2Slice[sector];
1783
1784 return kTRUE;
1785}
1786
1787Bool_t AliHLTTPCTransform::Sector2Slice(Int_t & slice, Int_t & slicerow, Int_t sector, Int_t row)
1788{
1789 //sector to slice
1790 if(sector<0 || sector>=fgNSector){
1791 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::Sector2Slice","Sector")
1792 <<AliHLTTPCLog::kDec<<"Wrong sector "<<sector<<ENDLOG;
1793 return kFALSE;
1794 }
1795 if(row<0){
1796 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::Sector2Slice","Row")
1797 <<AliHLTTPCLog::kDec<<"Wrong row "<<row<<ENDLOG;
1798 return kFALSE;
1799 }
1800
1801 if(fgSectorLow[sector]){
1802 if(row>=fgNRowLow){
1803 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::Sector2Slice","Row")
1804 <<AliHLTTPCLog::kDec<<"Wrong row "<<row<<ENDLOG;
1805 return kFALSE;
1806 }
1807 slice = fgSector2Slice[sector];
1808 slicerow = row;
1809 }
1810 else{
1811 if(row>=fgNRowUp){
1812 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::Sector2Slice","Row")
1813 <<AliHLTTPCLog::kDec<<"Wrong row "<<row<<ENDLOG;
1814 return kFALSE;
1815 }
1816 slice = fgSector2Slice[sector];
1817 slicerow = row + fgNRowLow;
1818 }
1819
1820 return kTRUE;
1821}
1822
1823Double_t AliHLTTPCTransform::GetMaxY(Int_t slicerow)
1824{
1825 //get maximum y value (for slice 0)
42a3bb88 1826 if (slicerow>=fgNRow) {
1827 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::GetMaxY","Slicerow")
1828 <<AliHLTTPCLog::kDec<<"slicerow out of range"<<slicerow<<ENDLOG;
1829 }
a6c02c85 1830 if(slicerow < fgNRowLow)
1831 return fgPadPitchWidthLow*fgNPads[slicerow]/2;
1832
1833 else
1834 return fgPadPitchWidthUp*fgNPads[slicerow]/2;
1835
1836}
1837
1838Double_t AliHLTTPCTransform::Row2X(Int_t slicerow)
1839{
1840 //slicerow to X value (slice 0)
1841 if(slicerow<0||slicerow>=fgNRow){
1842 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::Row2X","Slicerow")
1843 <<AliHLTTPCLog::kDec<<"Wrong slicerow "<<slicerow<<ENDLOG;
1844 return 0;
1845 }
1846 return fgX[slicerow];
1847}
1848
1849Double_t AliHLTTPCTransform::GetZFast(Int_t slice, Int_t time, Float_t vertex)
1850{
1851 //get z value
1852 Double_t z=fgZWidth*time-fgZOffset;
1853 if(slice < 18)
1854 z=fgZLength-z-vertex;
1855 else
1856 z=z-fgZLength-vertex;
1857 return z;
1858}
1859
1860void AliHLTTPCTransform::Local2Global(Float_t *xyz,Int_t slice)
1861{
1862 //Transformation to global coordinate system
1863 Float_t x0 = xyz[0];
1864 Float_t y0 = xyz[1];
1865
1866 xyz[0]=x0*fgCos[slice]-y0*fgSin[slice];
1867 xyz[1]=x0*fgSin[slice]+y0*fgCos[slice];
1868 xyz[2]=xyz[2];//global z=local z
1869}
1870
1871void AliHLTTPCTransform::Local2GlobalAngle(Float_t *angle,Int_t slice)
1872{
1873 //get angle global
1874 angle[0] = fmod(angle[0]+(slice+fgNRotShift)*(2*fgkPi/18),2*fgkPi);
1875}
1876
1877void AliHLTTPCTransform::Global2LocalAngle(Float_t *angle,Int_t slice)
1878{
1879 //get angle local
1880 angle[0] = angle[0]-(slice+fgNRotShift)*(2*fgkPi/18);
1881 if(angle[0]<0) angle[0]+=2*fgkPi;
1882}
1883
1884void AliHLTTPCTransform::Raw2Local(Float_t *xyz,Int_t sector,Int_t row,Float_t pad,Float_t time)
1885{
1886 //Transformation from rawdata to local coordinate system
1887
1888 Int_t slice,slicerow;
42a3bb88 1889 if (Sector2Slice(slice, slicerow, sector, row)==kFALSE) return;
a6c02c85 1890
1891 //X-Value
1892 xyz[0]=Row2X(slicerow);
1893
1894 //Y-Value
42a3bb88 1895 if (slicerow>=fgNRow) {
1896 LOG(AliHLTTPCLog::kError,"AliHLTTPCTransform::GetMaxY","Slicerow")
1897 <<AliHLTTPCLog::kDec<<"slicerow out of range"<<slicerow<<ENDLOG;
1898 return;
1899 }
a6c02c85 1900 Int_t npads= fgNPads[slicerow];
1901
1902 if(fgSectorLow[sector])
1903 xyz[1]=(pad-0.5*(npads-1))*fgPadPitchWidthLow;
1904 else
1905 xyz[1]=(pad-0.5*(npads-1))*fgPadPitchWidthUp;
1906
1907 //Z-Value (remember PULSA Delay)
1908 if(slice < 18)
42a3bb88 1909 xyz[2]=GetZLength()-GetZWidth()*time+GetZOffset();
a6c02c85 1910 else
42a3bb88 1911 xyz[2]=GetZWidth()*time-GetZOffset()-GetZLength();
a6c02c85 1912}
1913
1914void AliHLTTPCTransform::Raw2Local(Float_t *xyz,Int_t sector,Int_t row,Int_t pad,Int_t time)
1915{
1916 //Transformation from rawdata to local coordinate system
1917
1918 Int_t slice,slicerow;
1919 Sector2Slice(slice, slicerow, sector, row);
1920
1921 //X-Value
1922 xyz[0]=Row2X(slicerow);
1923
1924 //Y-Value
1925 Int_t npads= fgNPads[slicerow];
1926
1927 if(fgSectorLow[sector])
1928 xyz[1]=(pad-0.5*(npads-1))*fgPadPitchWidthLow;
1929 else
1930 xyz[1]=(pad-0.5*(npads-1))*fgPadPitchWidthUp;
1931
1932 //Z-Value (remember PULSA Delay)
1933 if(slice < 18)
42a3bb88 1934 xyz[2]=GetZLength()-GetZWidth()*time+GetZOffset();
a6c02c85 1935 else
42a3bb88 1936 xyz[2]=GetZWidth()*time-GetZOffset()-GetZLength();
a6c02c85 1937}
1938
1939void AliHLTTPCTransform::RawHLT2Local(Float_t *xyz,Int_t slice,
1940 Int_t slicerow,Float_t pad,Float_t time)
1941{
1942 //Transformation from HLT rawdata to local coordinate system
1943
1944 //X-Value
1945 xyz[0]=Row2X(slicerow);
1946
1947 //Y-Value
1948 Int_t npads= fgNPads[slicerow];
1949 if(slicerow<fgNRowLow)
1950 xyz[1]=(pad-0.5*(npads-1))*fgPadPitchWidthLow;
1951 else
1952 xyz[1]=(pad-0.5*(npads-1))*fgPadPitchWidthUp;
1953
1954 //Z-Value
1955 if(slice < 18)
42a3bb88 1956 xyz[2]=GetZLength()-GetZWidth()*time+GetZOffset();
a6c02c85 1957 else
42a3bb88 1958 xyz[2]=GetZWidth()*time-GetZOffset()-GetZLength();
a6c02c85 1959}
1960
1961void AliHLTTPCTransform::RawHLT2Local(Float_t *xyz,Int_t slice,
1962 Int_t slicerow,Int_t pad,Int_t time)
1963{
1964 //Transformation from HLT rawdata to local coordinate system
1965
1966 //X-Value
1967 xyz[0]=Row2X(slicerow);
1968
1969 //Y-Value
1970 Int_t npads= fgNPads[slicerow];
1971 if(slicerow<fgNRowLow)
1972 xyz[1]=(pad-0.5*(npads-1))*fgPadPitchWidthLow;
1973 else
1974 xyz[1]=(pad-0.5*(npads-1))*fgPadPitchWidthUp;
1975
1976 //Z-Value
1977 if(slice < 18)
42a3bb88 1978 xyz[2]=GetZLength()-GetZWidth()*time+GetZOffset();
a6c02c85 1979 else
42a3bb88 1980 xyz[2]=GetZWidth()*time-GetZOffset()-GetZLength();
a6c02c85 1981}
1982
1983void AliHLTTPCTransform::Local2Global(Float_t *xyz,Int_t sector,Int_t row)
1984{
1985 //Transformation to global coordinate system
1986 Int_t slice,slicerow;
1987 Sector2Slice(slice, slicerow, sector, row);
1988 Float_t r=Row2X(slicerow); //have to get x value first
1989
1990 xyz[0]=r*fgCos[slice]-xyz[1]*fgSin[slice];
1991 xyz[1]=r*fgSin[slice]+xyz[1]*fgCos[slice];
1992 xyz[2]=xyz[2];//global z=local z
1993}
1994
1995void AliHLTTPCTransform::LocHLT2Global(Float_t *xyz,Int_t slice,Int_t slicerow)
1996{
1997 //Transformation from HLT to global coordinate system
1998 Float_t r=Row2X(slicerow); //have to get x value first
1999
2000 xyz[0]=r*fgCos[slice]-xyz[1]*fgSin[slice];
2001 xyz[1]=r*fgSin[slice]+xyz[1]*fgCos[slice];
2002 xyz[2]=xyz[2];//global z=local z
2003}
2004
2005void AliHLTTPCTransform::Global2Local(Float_t *xyz,Int_t sector)
2006{ //check code
2007 Int_t slice;
2008 Sector2Slice(slice, sector);
2009
2010 Float_t x1 = xyz[0]*fgCos[slice] + xyz[1]*fgSin[slice];
2011 Float_t y1 = -xyz[0]*fgSin[slice] + xyz[1]*fgCos[slice];
2012 xyz[0] = x1;
2013 xyz[1] = y1;
2014}
2015
2016void AliHLTTPCTransform::Global2LocHLT(Float_t *xyz,Int_t slice)
2017{
2018 Float_t x1 = xyz[0]*fgCos[slice] + xyz[1]*fgSin[slice];
2019 Float_t y1 = -xyz[0]*fgSin[slice] + xyz[1]*fgCos[slice];
2020 xyz[0] = x1;
2021 xyz[1] = y1;
2022}
2023
2024void AliHLTTPCTransform::Raw2Global(Float_t *xyz,Int_t sector,Int_t row,Float_t pad,Float_t time)
2025{
2026 //Transformation from raw to global coordinates
2027
2028 Raw2Local(xyz,sector,row,pad,time);
2029 Local2Global(xyz,sector,row);
2030}
2031
2032void AliHLTTPCTransform::Raw2Global(Float_t *xyz,Int_t sector,Int_t row,Int_t pad,Int_t time)
2033{
2034 //Transformation from raw to global coordinates
2035
2036 Raw2Local(xyz,sector,row,pad,time);
2037 Local2Global(xyz,sector,row);
2038}
2039
2040void AliHLTTPCTransform::RawHLT2Global(Float_t *xyz,Int_t slice,
2041 Int_t slicerow,Float_t pad,Float_t time)
2042{
2043 //Transformation from raw to global coordinates
2044
2045 RawHLT2Local(xyz,slice,slicerow,pad,time);
2046 LocHLT2Global(xyz,slice,slicerow);
2047}
2048
2049void AliHLTTPCTransform::RawHLT2Global(Float_t *xyz,Int_t slice,
2050 Int_t slicerow,Int_t pad,Int_t time)
2051{
2052 //Transformation from raw to global coordinates
2053
2054 RawHLT2Local(xyz,slice,slicerow,pad,time);
2055 LocHLT2Global(xyz,slice,slicerow);
2056}
2057
2058void AliHLTTPCTransform::Local2Raw(Float_t *xyz,Int_t sector,Int_t row)
2059{
2060 //Transformation from local coordinates to raw
2061
2062 Int_t slice,slicerow;
2063 Sector2Slice(slice, slicerow, sector, row);
2064
2065 xyz[0]=slicerow;
2066
2067 if(fgSectorLow[sector])
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)
42a3bb88 2073 xyz[2]=(GetZLength()-xyz[2]+GetZOffset())/GetZWidth();
a6c02c85 2074 else
42a3bb88 2075 xyz[2]=(GetZLength()+xyz[2]+GetZOffset())/GetZWidth();
a6c02c85 2076}
2077
2078void AliHLTTPCTransform::LocHLT2Raw(Float_t *xyz,Int_t slice,Int_t slicerow)
2079{
2080 //Transformation from local coordinates to raw
2081
2082 xyz[0]=slicerow;
2083
2084 if(slicerow<fgNRowLow)
2085 xyz[1]=xyz[1]/fgPadPitchWidthLow+0.5*(fgNPads[slicerow]-1);
2086 else
2087 xyz[1]=xyz[1]/fgPadPitchWidthUp+0.5*(fgNPads[slicerow]-1);
2088
2089 if(slice < 18)
42a3bb88 2090 xyz[2]=(GetZLength()-xyz[2]+GetZOffset())/GetZWidth();
a6c02c85 2091 else
42a3bb88 2092 xyz[2]=(GetZLength()+xyz[2]+GetZOffset())/GetZWidth();
a6c02c85 2093}
2094
2095void AliHLTTPCTransform::Global2Raw(Float_t *xyz,Int_t sector,Int_t row)
2096{
2097 //Transformation from global coordinates to raw.
2098
2099 Global2Local(xyz,sector);
2100 Local2Raw(xyz,sector,row);
2101}
2102
2103void AliHLTTPCTransform::Global2HLT(Float_t *xyz,Int_t slice,Int_t slicerow)
2104{
2105 //Transformation from global coordinates to raw.
2106
2107 Global2LocHLT(xyz,slice);
2108 LocHLT2Raw(xyz,slice,slicerow);
2109}
2110
2111void AliHLTTPCTransform::PrintCompileOptions()
2112{
2113 //print compile options
2114#if defined(__GNUC__)
2115 cout << "Compiler (g++) version used: " << __GNUC__ << endl;
2116#endif
2117
2118#ifdef no_root
2119 cout << "STANDALONE version: -Dno_root was given." << endl;
2120#else
2121 const Char_t *roottest="$ROOTSYS/bin/root -n -b -q | grep Version | cut -b 17-25 | cut -d\" \" -f1";
2122#ifdef use_aliroot
2123#ifdef use_cvs
2124 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";
2125#else
2126 const Char_t *aliroottest="Unknown";
2127#endif
2128 cout << "ALIROOT version: -Duse_aliroot and -Duse_root was given." << endl;
2129 cout << "Root Version: " << ROOTVERSION << " found " << flush;
2130 gSystem->Exec(roottest);
2131
2132 cout << "AliRoot Version: " << ALIROOTVERSION << " found " << flush;
2133 gSystem->Exec(aliroottest);
2134#else
2135 cout << "ROOT version: -Duse_root was given." << endl;
2136 cout << "Root Version: " << ROOTVERSION << " found " << flush;
2137 gSystem->Exec(roottest);
2138#endif
2139#endif
2140
2141#ifdef do_mc
2142 cout << "Using Monte Carlo Info: -Ddo_mc was given." << endl;
2143#else
2144 cout << "NOT using Monte Carlo Info: -Ddo_mc was not given." << endl;
2145#endif
2146
2147#ifdef INCLUDE_TPC_HOUGH
2148 cout << "Including support for TPC Hough transformations." << endl;
2149#ifdef ROWHOUGHPARAMS
2150 cout << "Using extended AliHLTTPCTrackSegmentData: -DROWHOUGHPARAMS was given." << endl;
2151#else
2152 cout << "NOT using extended AliHLTTPCTrackSegmentData: -DROWHOUGHPARAMS was not given." << endl;
2153#endif
2154#else
2155 cout << "NOT including any support for TPC Hough transformations." << endl;
2156#endif // INCLUDE_TPC_HOUGH
2157
a6c02c85 2158}