]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/TPCupgrade/macros/SCdistortionsForPerformanceNote.C
Install macros
[u/mrichter/AliRoot.git] / TPC / TPCupgrade / macros / SCdistortionsForPerformanceNote.C
1 void SCdistortionsForPerformanceNoteAll(){
2
3   SCdistortionsForPerformanceNote(1,1);
4   SCdistortionsForPerformanceNote(2,1);
5   SCdistortionsForPerformanceNote(1.5,1);
6
7 }
8
9 void SCdistortionsForPerformanceNote(Double_t radiusScale=1.5, Int_t epsScale=1,Int_t iOmegaTau = 0){
10   //
11   // do for one file (given by directory) the correction (specify the gas = iOmegaTau)
12   // use the integrate along drift line option
13   //
14   // 1. Initialzation form space charge maps
15   //
16   AliTPCSpaceCharge3D *spaceCharge = new AliTPCSpaceCharge3D;
17   const Double_t fgke0 = 8.854187817e-12; // vacuum permittivity [A·s/(V·m)]
18
19   // omega tau parameters and TF1
20   const Int_t nEps = 2;
21   Int_t eps[nEps] = {20,10};
22   Int_t col[nEps] = {kBlack,kRed};
23   Int_t sty[nEps] = {1,2};
24
25   const Int_t nOmegaTau = 1;
26   Double_t omegaTau[nOmegaTau] = {0.32};
27   TString tGas[nOmegaTau] = {"NeCO2_2"}; 
28   TString sGas[nOmegaTau] = {"Ne-CO_{2}-N_{2} (90-10-5)"};
29   TF1 * fdiffR[nEps];
30   TF1 * fdiffPhiR[nEps];
31   TH1F * hdiffR[nEps];
32   TH1F * hdiffPhiR[nEps];
33   TH2F * hMap[nEps];
34
35   //use always the integrate option here
36   Double_t integrateStep = 1.;
37
38   TCanvas *cMap[nEps];
39
40   TCanvas *cOmegaTau = new TCanvas("cOmegaTau","cOmegaTau",1200,500);
41   cOmegaTau->Divide(2,1);
42
43   TString outfilename = Form("SCdistortions_SC_NeCO2_50kHz_radiusScaling%.0f_epsScaling%d",radiusScale,epsScale);
44   if(radiusScale>1.1 && radiusScale < 1.9) outfilename = Form("SCdistortions_SC_NeCO2_50kHz_radiusScaling%.1f_epsScaling%d",radiusScale,epsScale);
45
46   TLegend *legend = new TLegend(0.35,0.6,0.8,0.85,Form("%s: 50 kHz",sGas[iOmegaTau].Data(),"brNDC"));
47   setupLegend(legend,0.05);
48
49   //loop over epsilons
50   for(Int_t iEps = 0; iEps < nEps; ++iEps){
51
52     cMap[iEps] = new TCanvas(Form("cMap%d",iEps),Form("cMap%d",iEps),600,500);
53     cMap[iEps]->SetPhi(150);
54     
55     // select gas 
56     // 0 = NeCO2N2 
57
58     if(radiusScale>1.1 && radiusScale < 1.9){
59       cout<<"Open file = "<<Form("/Users/physics/ALICE/TPCupgrade/SpaceCharge/Maps/SC_%s_eps%d_50kHz_radiusScaling%.1f_epsScaling%d/SpaceChargeMap.root",tGas[iOmegaTau].Data(),eps[iEps],radiusScale,epsScale)<<endl;
60       spaceCharge->SetSCDataFileName(Form("/Users/physics/ALICE/TPCupgrade/SpaceCharge/Maps/SC_%s_eps%d_50kHz_radiusScaling%.1f_epsScaling%d/SpaceChargeMap.root",tGas[iOmegaTau].Data(),eps[iEps],radiusScale,epsScale));
61     }
62     else{
63       cout<<"Open file = "<<Form("/Users/physics/ALICE/TPCupgrade/SpaceCharge/Maps/SC_%s_eps%d_50kHz_radiusScaling%.0f_epsScaling%d/SpaceChargeMap.root",tGas[iOmegaTau].Data(),eps[iEps],radiusScale,epsScale)<<endl;
64       spaceCharge->SetSCDataFileName(Form("/Users/physics/ALICE/TPCupgrade/SpaceCharge/Maps/SC_%s_eps%d_50kHz_radiusScaling%.0f_epsScaling%d/SpaceChargeMap.root",tGas[iOmegaTau].Data(),eps[iEps],radiusScale,epsScale));
65     }
66
67     // select omegaTau value
68     if(iOmegaTau ==  0){
69       spaceCharge->SetOmegaTauT1T2(omegaTau[iOmegaTau],1,0.99); // Ne CO2 N2
70     }
71   
72     //
73     //
74     // init and add to corrections
75     spaceCharge->InitSpaceCharge3DDistortion();
76     spaceCharge->AddVisualCorrection(spaceCharge,1);
77     
78     // draw the map
79     
80     hMap[iEps] = (TH2F*)spaceCharge->CreateHistoSCinZR(0.);
81     hMap[iEps]->Scale(fgke0/1e6*1e15); // C/m^3/e0 --> fC/cm^3
82     hMap[iEps]->GetXaxis()->SetTitle("z (cm)");
83     hMap[iEps]->GetYaxis()->SetTitle("r (cm)");
84     hMap[iEps]->GetZaxis()->SetTitle("#rho_{SC} (fC/cm^{3})");
85     hMap[iEps]->SetTitleSize(0.05,"XYZ");
86     hMap[iEps]->SetTitleOffset(1.5,"XY");
87     hMap[iEps]->SetTitleOffset(0.9,"Z");
88     hMap[iEps]->SetTitle(Form("%s: 50 kHz, #varepsilon = %d",sGas[iOmegaTau].Data(),eps[iEps]));
89     hMap[iEps]->DrawCopy("surf2fb");
90     
91     
92     //
93     // 2. get TF1 with differences 
94     //
95     // get corrections (at y = 0 and z = 10) for visual correction 1 (last argument)
96     // 0 = dR
97     // 1 = dPhiR
98     // 2 = dZ?    
99     fdiffR[iEps]       = new TF1(Form("fdiffR%d",iEps), Form("AliTPCCorrection::GetDistXYZIntegrateZ(x,0,10,0,1,%f)",integrateStep),85,245);
100     fdiffPhiR[iEps]    = new TF1(Form("fdiffPhiR%d",iEps), Form("AliTPCCorrection::GetDistXYZIntegrateZ(x,0,10,1,1,%f)",integrateStep),85,245);
101     
102     hdiffR[iEps] = (TH1F*)fdiffR[iEps]->GetHistogram();
103     hdiffPhiR[iEps] = (TH1F*)fdiffPhiR[iEps]->GetHistogram();
104     
105     
106     hdiffR[iEps]->SetName(fdiffR[iEps]->GetName());
107     hdiffPhiR[iEps]->SetName(fdiffPhiR[iEps]->GetName());
108     
109     
110     
111     //
112     // 3. Plot and store TH1Fs
113     //
114     
115     hdiffR[iEps]->GetXaxis()->SetTitle("r (cm)");
116     hdiffPhiR[iEps]->GetXaxis()->SetTitle("r (cm)");
117     
118     hdiffR[iEps]->GetYaxis()->SetTitle("dr (cm)");
119     hdiffPhiR[iEps]->GetYaxis()->SetTitle("d(r#varphi) (cm)");
120     
121     hdiffR[iEps]->SetTitle("dr (cm)");
122     hdiffPhiR[iEps]->SetTitle("d(r#varphi) (cm)");
123   
124     hdiffR[iEps]->SetMarkerColor(col[iEps]);
125     hdiffPhiR[iEps]->SetMarkerColor(col[iEps]);
126     
127     hdiffR[iEps]->SetLineColor(col[iEps]);
128     hdiffPhiR[iEps]->SetLineColor(col[iEps]);
129
130     hdiffR[iEps]->SetLineStyle(sty[iEps]);
131     hdiffPhiR[iEps]->SetLineStyle(sty[iEps]);
132     
133     hdiffR[iEps]->SetFillColor(col[iEps]);
134     hdiffPhiR[iEps]->SetFillColor(col[iEps]);
135     
136     hdiffR[iEps]->SetTitleSize(0.05,"XYZ");
137     hdiffPhiR[iEps]->SetTitleSize(0.05,"XYZ");
138     
139     legend->AddEntry(hdiffR[iEps],Form("#varepsilon = %d",eps[iEps]),"lp");
140     
141     cOmegaTau->cd(1);
142     if(iEps==0)
143       hdiffR[iEps]->DrawCopy("lf");
144     else{
145       hdiffR[iEps]->DrawCopy("lf,same");
146       legend->Draw();
147     }
148
149     cOmegaTau->cd(2);
150     if(iEps==0)
151       hdiffPhiR[iEps]->DrawCopy("fl");
152     else{
153       hdiffPhiR[iEps]->DrawCopy("fl,same");
154     }
155   }
156   
157   for(Int_t iEps = 0; iEps < nEps; iEps++){
158     cMap[iEps]->SaveAs(Form("%s_epsilon%d_SC_performanceNote.eps",outfilename.Data(),eps[iEps]));
159     cMap[iEps]->SaveAs(Form("%s_epsilon%d_SC_performanceNote.pdf",outfilename.Data(),eps[iEps]));
160   }
161   cOmegaTau->SaveAs(Form("%s_Distortions_performanceNote.eps",outfilename.Data()));
162   cOmegaTau->SaveAs(Form("%s_Distortions_performanceNote.pdf",outfilename.Data()));
163 }
164
165   
166 //____________________________________________________________//
167 void setupLegend(TLegend *currentLegend=0,float currentTextSize=0.07){
168   currentLegend->SetTextFont(42);
169   currentLegend->SetBorderSize(0);
170   currentLegend->SetFillStyle(0);
171   currentLegend->SetFillColor(0);
172   currentLegend->SetMargin(0.25);
173   currentLegend->SetTextSize(currentTextSize);
174   currentLegend->SetEntrySeparation(0.5);
175   return;
176 }