Using TMath::Abs instead of fabs
[u/mrichter/AliRoot.git] / HLT / exa / make_init.C
1 // $Id$ 
2
3 /**
4    Macro to get the default parameters from AliTPCParam. 
5    Output is written to a file, which can be inserted directly into 
6    AliL3Transform.cxx as the default parameters to be set at top.
7 */
8
9 void make_init(char *tofile="Init.cxx")
10 {
11   AliTPCParamSR *param = new AliTPCParamSR();
12   param->SetDefault();
13   if(!param)
14     {
15       cerr<<"AliL3Transform::MakeInitFile : No TPC parameters found"<<endl;
16       return;
17     }
18   
19   AliTPCPRF2D    * prfinner   = new AliTPCPRF2D;
20   AliTPCPRF2D    * prfouter1   = new AliTPCPRF2D;
21   AliTPCPRF2D    * prfouter2   = new AliTPCPRF2D;  
22   AliTPCRF1D     * rf    = new AliTPCRF1D(kTRUE);
23   rf->SetGauss(param->GetZSigma(),param->GetZWidth(),1.);
24   rf->SetOffset(3*param->GetZSigma());
25   rf->Update();
26   
27   TDirectory *savedir=gDirectory;
28   TFile *f1=TFile::Open("$ALICE_ROOT/TPC/AliTPCprf2d.root");
29   if (!f1->IsOpen()) 
30     { 
31       cerr<<"Can't open $ALICE_ROOT/TPC/AliTPCprf2d.root !\n" ;
32       exit(3);
33     }
34   prfinner->Read("prf_07504_Gati_056068_d02");
35   prfouter1->Read("prf_10006_Gati_047051_d03");
36   prfouter2->Read("prf_15006_Gati_047051_d03");  
37   f1->Close();
38   savedir->cd();
39   
40   param->SetInnerPRF(prfinner);
41   param->SetOuter1PRF(prfouter1); 
42   param->SetOuter2PRF(prfouter2);
43   param->SetTimeRF(rf);
44   
45   Int_t fNTimeBins = param->GetMaxTBin()+1;
46   Int_t fNRowLow = param->GetNRowLow();
47   Int_t fNRowUp  = param->GetNRowUp();
48   Int_t fNRowUp1 = param->GetNRowUp1();
49   Int_t fNRowUp2 = param->GetNRowUp2();
50   Int_t fNRow= fNRowLow + fNRowUp;
51   Int_t fNSectorLow = param->GetNInnerSector();
52   Int_t fNSectorUp = param->GetNOuterSector();
53   Int_t fNSector = fNSectorLow + fNSectorUp;
54   Int_t fNSlice = fNSectorLow;
55   
56   FILE *f = fopen(tofile,"w");
57   if(!f)
58     {
59       cerr<<"Error opening file "<<tofile<<endl;
60       return;
61     }
62   fprintf(f,"const Double_t AliL3Transform::fBFACT = 0.0029980;\n");
63   fprintf(f,"Double_t AliL3Transform::fBField = 0.2;\n");
64   fprintf(f,"Int_t AliL3Transform::fVersion = 0;\n");
65   fprintf(f,"Int_t AliL3Transform::fBFieldFactor = %d ;\n",gAlice->Field()->Factor());
66   fprintf(f,"Int_t AliL3Transform::fNTimeBins = %d ;\n",fNTimeBins);
67   fprintf(f,"Int_t AliL3Transform::fNRowLow = %d ;\n",fNRowLow);
68   fprintf(f,"Int_t AliL3Transform::fNRowUp = %d ;\n",fNRowUp);
69   fprintf(f,"Int_t AliL3Transform::fNRowUp1 = %d ;\n",fNRowUp1);
70   fprintf(f,"Int_t AliL3Transform::fNRowUp2 = %d ;\n",fNRowUp2);
71   fprintf(f,"Int_t AliL3Transform::fNSectorLow = %d ;\n",fNSectorLow);
72   fprintf(f,"Int_t AliL3Transform::fNSectorUp = %d ;\n",fNSectorUp);
73   fprintf(f,"Int_t AliL3Transform::fNSector = %d ;\n",fNSector);
74   fprintf(f,"Double_t AliL3Transform::fPadPitchWidthLow = %f ;\n",param->GetInnerPadPitchWidth());
75   fprintf(f,"Double_t AliL3Transform::fPadPitchWidthUp = %f ;\n",param->GetOuterPadPitchWidth());
76   fprintf(f,"Double_t AliL3Transform::fZWidth = %.20f ;\n",param->GetZWidth());
77   fprintf(f,"Double_t AliL3Transform::fZSigma = %.20f ;\n",param->GetZSigma());
78   fprintf(f,"Double_t AliL3Transform::fZLength = %.20f ;\n",param->GetZLength());
79   fprintf(f,"Double_t AliL3Transform::fZOffset = %.20f ;\n",param->GetZOffset());
80   fprintf(f,"Double_t AliL3Transform::fDiffT = %.20f ;\n",param->GetDiffT());
81   fprintf(f,"Double_t AliL3Transform::fDiffL = %.20f ;\n",param->GetDiffL());
82   fprintf(f,"Double_t AliL3Transform::fInnerPadLength = %f ;\n",param->GetInnerPadLength());
83   fprintf(f,"Double_t AliL3Transform::fOuter1PadLength = %f ;\n",param->GetOuter1PadLength());
84   fprintf(f,"Double_t AliL3Transform::fOuter2PadLength = %f ;\n",param->GetOuter2PadLength());
85   fprintf(f,"Double_t AliL3Transform::fInnerPRFSigma = %.20f ;\n",param->GetInnerPRF()->GetSigmaX());
86   fprintf(f,"Double_t AliL3Transform::fOuter1PRFSigma = %.20f ;\n",param->GetOuter1PRF()->GetSigmaX());
87   fprintf(f,"Double_t AliL3Transform::fOuter2PRFSigma = %.20f ;\n",param->GetOuter2PRF()->GetSigmaX());
88   fprintf(f,"Double_t AliL3Transform::fTimeSigma = %.20f ;\n",param->GetTimeRF()->GetSigma());
89   fprintf(f,"Int_t AliL3Transform::fNSlice = %d ;\n",fNSectorLow);
90   fprintf(f,"Int_t AliL3Transform::fNRow = %d ;\n",fNRow);
91   fprintf(f,"Int_t AliL3Transform::fNRotShift = 0.5 ;\n");
92   fprintf(f,"Double_t AliL3Transform::fPi = %.15f ;\n",TMath::Pi());
93     
94   fprintf(f,"Double_t AliL3Transform::fX[159] = {");
95   for(Int_t i=0;i<fNRow;i++){
96     int sec,row;
97     if( i < fNRowLow){sec =0;row =i;}
98     else{sec = fNSectorLow;row =i-fNRowLow;}
99     
100     fprintf(f,"                                    %3.15f,\n",param->GetPadRowRadii(sec,row));
101   }
102   fprintf(f,"};\n\n");
103   
104   fprintf(f,"Int_t AliL3Transform::fNPads[159] = {");
105   for(Int_t i=0;i<fNRow;i++){
106     int sec,row;
107     if( i < fNRowLow){sec =0;row =i;}
108     else{sec = fNSectorLow;row =i-fNRowLow;}
109   fprintf(f,"                                     %d,\n",param->GetNPads(sec,row));
110   }
111     
112   fprintf(f,"};\n");
113   fclose(f);
114 }