2 gSystem->SetIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/ -I$ALICE_ROOT/include -I$ALICE_ROOT/STEER -I$ALICE_ROOT/TPC -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TRD -I$ALICE_ROOT/TOF -I$ALICE_ROOT/RAW -I$ALICE_ROOT/STAT");
5 #if !defined(__CINT__) || defined(__MAKECINT__)
16 #include "TProfile3D.h"
20 #include "TStatToolkit.h"
21 #include "TTreeStream.h"
22 #include "AliExternalTrackParam.h"
23 #include "AliESDfriend.h"
24 #include "AliTPCcalibTime.h"
26 #include "AliXRDPROOFtoolkit.h"
27 #include "AliTPCCorrection.h"
28 #include "AliTPCExBTwist.h"
29 #include "AliTPCGGVoltError.h"
30 #include "AliTPCComposedCorrection.h"
31 #include "AliTPCExBConical.h"
32 #include "TPostScript.h"
34 #include "AliTrackerBase.h"
36 #include "AliCDBManager.h"
37 #include "AliTPCExBBShape.h"
39 #include "AliGeomManager.h"
40 #include "AliESDVertex.h"
41 #include "AliTPCcalibDB.h"
45 void AliTPCCorrectionDemo() {
48 // This is a Demo function of the general class AliTPCCorrection, which is used for
49 // general space point correction due to different effects.
50 // The effects used in this Demo are:
51 // 1. ExB twist - general offset of the TPC axis in comparison to the B field axis
52 // 2. GG error (Gating Grid volt. error) - not perfectly aligned GG voltage (in terms of voltage)
53 // 3. ExBBShape - B field shape correction of the secound order
55 // See class descriptions for further details
57 // Authors: Magnus Mager, Stefan Rossegger, Jim Thomas
60 // omegaTau (wt) of the langevin equation
61 // This is a function of the drift vel., the magnetic and electric field
62 // e.g. vd=2.6 cm/usc; Ez=400 V/cm; Bz=0.5 T
63 // wt = -10.0*(Bz*10)*vd/Ez = -0.325
65 Double_t vdrift = 2.6; // [cm/us] // to be updated: per second (ideally)
66 Double_t bzField = -0.5; // [Tesla] // to be updated: per run
67 Double_t ezField = 400; // [V/cm] // to be updated: never (hopefully)
68 Double_t wt = -10.0 * (bzField*10) * vdrift / ezField ;
70 // Correction Terms for effective omegaTau; obtained by a laser calibration run
74 AliMagF mag("mag","mag");
77 twist.SetXTwist(0.001);
79 AliTPCGGVoltError GGerror;
80 GGerror.SetDeltaVGGA(50.);
81 GGerror.SetDeltaVGGC(50.);
82 GGerror.InitGGVoltErrorDistortion();
92 AliTPCComposedCorrection cc;
93 cc.SetCorrections(&cs);
94 cc.SetOmegaTauT1T2(wt,T1,T2);
97 cc.Print("DA"); // Print used correction classes
99 TCanvas *c=new TCanvas; // Plots
101 c->cd(1);twist.CreateHistoDRPhiinZR(1.,100,100)->Draw("surf2");
102 c->cd(2);GGerror.CreateHistoDRPhiinZR(1.,100,100)->Draw("surf2");
103 c->cd(3);exb.CreateHistoDRPhiinZR(1.)->Draw("surf2");
104 c->cd(4);cc.CreateHistoDRPhiinZR(1.)->Draw("surf2");
109 void MakeDistortionMap(){
111 // make distortiona map example for specific transformation
114 TTreeSRedirector *pcstream = new TTreeSRedirector("distort.root");
115 Double_t vdrift = 2.6; // [cm/us] // to be updated: per second (ideally)
116 Double_t bzField = -0.5; // [Tesla] // to be updated: per run
117 Double_t ezField = 400; // [V/cm] // to be updated: never (hopefully)
118 Double_t wt = -10.0 * (bzField*10) * vdrift / ezField ;
120 // Correction Terms for effective omegaTau; obtained by a laser calibration run
123 AliMagF* magF= new AliMagF("Maps","Maps", bzField/0.5, 1.);
124 TGeoGlobalMagField::Instance()->SetField(magF);
126 AliCDBManager::Instance()->SetDefaultStorage("local:////$ALICE_ROOT/OCDB");
127 AliCDBManager::Instance()->SetRun(run);
128 AliGeomManager::LoadGeometry();
129 AliGeomManager::ApplyAlignObjsFromCDB("GRP ITS TPC");
132 AliTPCExBTwist twist;
133 twist.SetName("twistX001");
134 twist.SetXTwist(0.001);
136 AliTPCGGVoltError GGerror;
137 GGerror.SetDeltaVGGA(50.);
138 GGerror.SetDeltaVGGC(50.);
139 GGerror.InitGGVoltErrorDistortion();
140 GGerror.SetName("ggoffsetA50C50");
149 AliTPCComposedCorrection *cc = new AliTPCComposedCorrection;
150 cc->SetCorrections(&cs);
151 cc->SetOmegaTauT1T2(wt,T1,T2);
153 cc->SetName("composed");
154 Double_t par[5]={0,0,0,0,0};
155 Double_t cov[15]={0,0,0,0,0,0,0,0,0,0,0,0,0,0};
156 for (Double_t theta=-1.; theta<1; theta+=0.1){
157 for (Double_t alpha=-3.14; alpha<3.14; alpha+=0.2){
162 par[4]=(gRandom->Rndm()-0.5);
163 AliExternalTrackParam trackIn(85,alpha,par,cov);
164 //FitDistortedTrack(&trackIn, cc, 85, -1,pcstream);
165 twist.FitDistortedTrack(trackIn, 85, -1,pcstream);
166 GGerror.FitDistortedTrack(trackIn, 85, -1,pcstream);
167 exb.FitDistortedTrack(trackIn, 85, -1,pcstream);
168 cc->FitDistortedTrack(trackIn, 85, -1,pcstream);
174 void DrawDistortionMap(){
176 // Example -drawing of distortion maps
178 TFile f("distort.root");
179 TTree * fitDistorttwistX001= (TTree*)f.Get("fitDistorttwistX001");
180 TTree * fitDistortggoffsetA50C50=(TTree*)f.Get("fitDistortggoffsetA50C50");
181 TTree * fitDistortExB=(TTree*)f.Get("fitDistortExB");
182 TTree * fitDistortcomposed=(TTree*)f.Get("fitDistortcomposed");
183 fitDistortExB->SetMarkerColor(1);
184 fitDistorttwistX001->SetMarkerColor(2);
185 fitDistortggoffsetA50C50->SetMarkerColor(4);
186 fitDistortExB->SetMarkerStyle(20);
187 fitDistorttwistX001->SetMarkerStyle(21);
188 fitDistortggoffsetA50C50->SetMarkerStyle(22);
190 // example draw delta local y/r-phi as function of fi
193 entries = fitDistortExB->Draw("track1.fP[0]-track0.fP[0]:track0.fAlpha","","");
194 TGraph * grY0= new TGraph(entries, fitDistortExB->GetV2(),fitDistortExB->GetV1());
195 entries = fitDistortggoffsetA50C50->Draw("track1.fP[0]-track0.fP[0]:track0.fAlpha","","");
196 TGraph * grY1= new TGraph(entries, fitDistortggoffsetA50C50->GetV2(),fitDistortggoffsetA50C50->GetV1());
197 entries = fitDistorttwistX001->Draw("track1.fP[0]-track0.fP[0]:track0.fAlpha","","");
198 TGraph * grY2= new TGraph(entries, fitDistorttwistX001->GetV2(),fitDistorttwistX001->GetV1());
199 entries = fitDistortcomposed->Draw("track1.fP[0]-track0.fP[0]:track0.fAlpha","","");
200 TGraph * grY3= new TGraph(entries, fitDistortcomposed->GetV2(),fitDistortcomposed->GetV1());
201 grY0->SetMinimum(-0.4);
202 grY0->SetMaximum(0.4);
203 grY0->SetMarkerStyle(20), grY0->SetMarkerColor(1);
204 grY1->SetMarkerStyle(21), grY1->SetMarkerColor(2);
205 grY2->SetMarkerStyle(22), grY2->SetMarkerColor(4);
206 grY3->SetMarkerStyle(24), grY3->SetMarkerColor(5);
217 // .x ConfigCalibTrain.C(120829)
219 AliTPCComposedCorrection * corrC = ( AliTPCComposedCorrection *)AliTPCcalibDB::Instance()->GetTPCComposedCorrection(0.5);
220 AliTPCCorrection * corrT = (AliTPCCorrection *)corrC->GetCorrections()->FindObject("exb_twist");
221 AliTPCCorrection * corrS = (AliTPCCorrection *)corrC->GetCorrections()->FindObject("ExB");
223 TTreeSRedirector *pcstream = new TTreeSRedirector("vertexDistort.root");
224 TTreeSRedirector *pcstreamS = new TTreeSRedirector("vertexDistortS.root");
225 TTreeSRedirector *pcstreamT = new TTreeSRedirector("vertexDistortT.root");
226 Double_t orgVertex[3] ;
227 AliESDVertex aV,cV,aVO,cVO;
228 for (Int_t iv=0; iv<100; iv++){
230 orgVertex[0]=gRandom->Gaus()*0.01;
231 orgVertex[1]=gRandom->Gaus()*0.01;
232 orgVertex[2]=gRandom->Gaus()*3;
233 corrC->FastSimDistortedVertex(orgVertex,100, aV,aVO,cV,cVO,pcstream);
234 corrS->FastSimDistortedVertex(orgVertex,100, aV,aVO,cV,cVO,pcstreamS);
235 corrT->FastSimDistortedVertex(orgVertex,100, aV,aVO,cV,cVO,pcstreamT);
240 TFile fC("vertexDistortC.root");
241 TFile fT("vertexDistortT.root");
242 TFile fS("vertexDistortS.root");
243 TTree * treeT=(TTree*)fT.Get("vertex"); // twist distrotions
244 TTree * treeS=(TTree*)fS.Get("vertex"); // shape distortions
245 TCanvas *canvasD=new TCanvas("canvasD","canvasD");
246 canvasD->Divide(2,2);
248 treeT->SetLineColor(2);
249 treeT->Draw("av.fPosition[0]-x>>hisATX(100,-0.2,0.2)","","");
250 treeT->SetLineColor(4);
251 treeT->Draw("cv.fPosition[0]-x>>hisCTX(100,-0.2,0.2)","","same");
253 treeT->SetLineColor(2);
254 treeT->Draw("av.fPosition[1]-y>>hisATY(100,-0.2,0.2)","","");
255 treeT->SetLineColor(4);
256 treeT->Draw("cv.fPosition[1]-y>>hisCTY(100,-0.2,0.2)","","same");
259 treeS->SetLineColor(2);
260 treeS->Draw("av.fPosition[0]-x>>hisASX(100,-0.2,0.2)","","");
261 treeS->SetLineColor(4);
262 treeS->Draw("cv.fPosition[0]-x>>hisCSX(100,-0.2,0.2)","","same");
264 treeS->SetLineColor(2);
265 treeS->Draw("av.fPosition[1]-y>>hisASY(100,-0.2,0.2)","","");
266 treeS->SetLineColor(4);
267 treeS->Draw("cv.fPosition[1]-y>>hisCSY(100,-0.2,0.2)","","same");
268 canvasD->SaveAs("vertexShift.ps");