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