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