.so cleanup: more gSystem->Load()
[u/mrichter/AliRoot.git] / TPC / macros / gainCalib.C
1 /*
2  Small macro to show perforamance of the gain calibration
3  tHe list of the  files with tpc calib tracks is supposed to be in cosmic.txt file 
4  Supposing the 
5
6
7  gSystem->Load("libSTAT")
8  .x ~/rootlogon.C
9  .L $ALICE_ROOT/TPC/macros/AliXRDPROOFtoolkit.cxx+
10  AliXRDPROOFtoolkit tool;
11  //gSystem->Load("/usr/local/grid/XRootd/GSI/lib/libXrdClient");
12  //TProof * proof = TProof::Open("miranov@lxgrid2.gsi.de");
13
14 */
15
16 TChain * chain = 0;
17 TChain * chaing = 0;
18
19 TStatToolkit toolkit;
20
21 void Init(){
22
23   AliCDBManager::Instance()->SetRun(0);
24   AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
25   AliTPCClusterParam *clparam = AliTPCcalibDB::Instance()->GetClusterParam();
26   AliTPCClusterParam::SetInstance(clparam);  
27   //
28   AliXRDPROOFtoolkit tool;
29   chain = tool.MakeChain("cosmic.txt","dEdxT",0,1000)
30   chain->Lookup();
31   chaing = tool.MakeChain("cosmic.txt","TrackG",0,1000)
32   chaing->Lookup();
33   //
34   chain->SetAlias("dr","(250-abs(meanPos.fElements[4]))/250.");
35   chain->SetAlias("tz","(0+abs(parZ.fElements[1]))");
36   chain->SetAlias("ty","(0+abs(parY.fElements[1]))");
37   chain->SetAlias("corrg","sqrt((1+ty^2)*(1+tz^2))");
38 }
39
40
41
42
43
44 void MakeFits(){
45   TStatToolkit toolkit;
46   Double_t chi2;
47   TVectorD param;
48   TMatrixD covar;
49   Int_t npoints;
50   TString *strq0 = toolkit.FitPlane(chain,"dedxQ.fElements[2]","dr++tz++ty++dr*tz++dr*ty++ty*tz","IPad==0",chi2,npoints,param,covar,0,20000);
51   TString *strq1 = toolkit.FitPlane(chain,"dedxQ.fElements[2]","dr++tz++ty++dr*tz++dr*ty++ty*tz","IPad==1",chi2,npoints,param,covar,0,20000);
52   TString *strq2 = toolkit.FitPlane(chain,"dedxQ.fElements[2]","dr++tz++ty++dr*tz++dr*ty++ty*tz","IPad==2",chi2,npoints,param,covar,0,20000);
53   TString *strm0 = toolkit.FitPlane(chain,"dedxM.fElements[2]","dr++tz++ty++dr*tz++dr*ty++ty*tz","IPad==0",chi2,npoints,param,covar,0,20000);
54   TString *strm1 = toolkit.FitPlane(chain,"dedxM.fElements[2]","dr++tz++ty++dr*tz++dr*ty++ty*tz","IPad==1",chi2,npoints,param,covar,0,20000);
55   TString *strm2 = toolkit.FitPlane(chain,"dedxM.fElements[2]","dr++tz++ty++dr*tz++dr*ty++ty*tz","IPad==2",chi2,npoints,param,covar,0,20000);  
56   chain->SetAlias("normqt0",strq0.Data());
57   chain->SetAlias("normqt1",strq1.Data());
58   chain->SetAlias("normqt2",strq2.Data());
59   chain->SetAlias("normqm0",strm0.Data());
60   chain->SetAlias("normqm1",strm1.Data());
61   chain->SetAlias("normqm2",strm2.Data());
62 }
63
64 TFile fqplot("qplot.root","update");
65
66
67 void MakePlotsQS(){
68   
69   chain->Draw("dedxQ.fElements[2]:sector>>hisQ_sector(36,0,36)","IPad==0&&P>1","prof*",1000000);
70   chain->Draw("dedxQ.fElements[2]/corrg:sector>>hisQ_sector_corrg(36,0,36)","IPad==0&&P>1","prof*",1000000);
71   chain->Draw("dedxQ.fElements[2]/AliTPCClusterParam::SQnorm(0,0,dr,ty,tz):sector>>hisQ_sector_corrcal(36,0,36)","IPad==0&&P>1","prof*",1000000);
72
73   TProfile * profq_sector = (TProfile*) gROOT->FindObject("hisQ_sector");
74   TProfile * profq_sector_corrg = (TProfile*) gROOT->FindObject("hisQ_sector_corrg");
75   TProfile * profq_sector_corrcal = (TProfile*) gROOT->FindObject("hisQ_sector_corrcal");
76   profq_sector->SetMarkerStyle(22);
77   profq_sector_corrg->SetMarkerStyle(24);
78   profq_sector_corrcal->SetMarkerStyle(26);
79   //
80   profq_sector->SetXTitle("Sector number");
81   profq_sector->SetYTitle("Mean amplitude");  
82   profq_sector->SetMinimum(0);
83   profq_sector->Draw();
84   profq_sector_corrg->Draw("same");
85   profq_sector_corrcal->Draw("same");
86   fqplot.cd();
87   profq_sector->Write("qt_sector_0");
88   profq_sector_corrg->Write("qt_sector_1");
89   profq_sector_corrcal->Write("qt_sector_2");
90   gPad->Write("qt_sector");
91 }
92   
93
94 void MakePlotsTY(){
95   //
96   //
97   //
98   chain->Draw("dedxQ.fElements[2]:ty>>hisQ_ty(20,0,1.5)","IPad==0&&P>1","prof*",1000000);
99   chain->Draw("dedxQ.fElements[2]/corrg:ty>>hisQ_ty_corrg(20,0,1.5)","IPad==0&&P>1","prof*",1000000);
100   chain->Draw("dedxQ.fElements[2]/AliTPCClusterParam::SQnorm(0,0,dr,ty,tz):ty>>hisQ_ty_corrcal(20,0,1.5)","IPad==0&&P>1","prof*",1000000);
101
102   TProfile * profq_ty = (TProfile*) gROOT->FindObject("hisQ_ty");
103   TProfile * profq_ty_corrg = (TProfile*) gROOT->FindObject("hisQ_ty_corrg");
104   TProfile * profq_ty_corrcal = (TProfile*) gROOT->FindObject("hisQ_ty_corrcal");
105   profq_ty->SetMarkerStyle(22);
106   profq_ty_corrg->SetMarkerStyle(24);
107   profq_ty_corrcal->SetMarkerStyle(26);
108   //
109   profq_ty->SetXTitle("tan(#phi)");
110   profq_ty->SetYTitle("Mean amplitude");  
111   profq_ty->SetMinimum(0);
112   profq_ty->Draw();
113   profq_ty_corrg->Draw("same");
114   profq_ty_corrcal->Draw("same");
115   fqplot.cd();
116   profq_ty->Write("qt_ty_0");
117   profq_ty_corrg->Write("qt_ty_1");
118   profq_ty_corrcal->Write("qt_ty_2");
119   gPad->Write("qt_ty");
120 }
121
122
123 void MakePlotsTZ(){
124   //
125   //
126   //
127   chain->Draw("dedxQ.fElements[2]:tz>>hisQ_tz(20,0,1.5)","IPad==0&&P>1","prof*",1000000);
128   chain->Draw("dedxQ.fElements[2]/corrg:tz>>hisQ_tz_corrg(20,0,1.5)","IPad==0&&P>1","prof*",1000000);
129   chain->Draw("dedxQ.fElements[2]/AliTPCClusterParam::SQnorm(0,0,dr,ty,tz):tz>>hisQ_tz_corrcal(20,0,1.5)","IPad==0&&P>1","prof*",1000000);
130
131   TProfile * profq_tz = (TProfile*) gROOT->FindObject("hisQ_tz");
132   TProfile * profq_tz_corrg = (TProfile*) gROOT->FindObject("hisQ_tz_corrg");
133   TProfile * profq_tz_corrcal = (TProfile*) gROOT->FindObject("hisQ_tz_corrcal");
134   profq_tz->SetMarkerStyle(22);
135   profq_tz_corrg->SetMarkerStyle(24);
136   profq_tz_corrcal->SetMarkerStyle(26);
137   //
138   profq_tz->SetXTitle("tan(#theta)");
139   profq_tz->SetYTitle("Mean amplitude");  
140   profq_tz->SetMinimum(0);
141   profq_tz->Draw();
142   profq_tz_corrg->Draw("same");
143   profq_tz_corrcal->Draw("same");
144   fqplot.cd();
145   profq_tz->Write("qt_tz_0");
146   profq_tz_corrg->Write("qt_tz_1");
147   profq_tz_corrcal->Write("qt_tz_2");
148   gPad->Write("qt_tz");
149 }
150
151 void MakePlotsDR(){
152   //
153   //
154   //
155   chain->Draw("dedxQ.fElements[2]:dr>>hisQ_dr(20,0,1.)","IPad==0&&P>1","prof*",1000000);
156   chain->Draw("dedxQ.fElements[2]/corrg:dr>>hisQ_dr_corrg(20,0,1.)","IPad==0&&P>1","prof*",1000000);
157   chain->Draw("dedxQ.fElements[2]/AliTPCClusterParam::SQnorm(0,0,dr,ty,dr):dr>>hisQ_dr_corrcal(20,0,1.)","IPad==0&&P>1","prof*",1000000);
158
159   TProfile * profq_dr = (TProfile*) gROOT->FindObject("hisQ_dr");
160   TProfile * profq_dr_corrg = (TProfile*) gROOT->FindObject("hisQ_dr_corrg");
161   TProfile * profq_dr_corrcal = (TProfile*) gROOT->FindObject("hisQ_dr_corrcal");
162   profq_dr->SetMarkerStyle(22);
163   profq_dr_corrg->SetMarkerStyle(24);
164   profq_dr_corrcal->SetMarkerStyle(26);
165   //
166   profq_dr->SetXTitle("drift length(unit)");
167   profq_dr->SetYTitle("Mean amplitude");  
168   profq_dr->SetMinimum(0);
169   profq_dr->Draw();
170   profq_dr_corrg->Draw("same");
171   profq_dr_corrcal->Draw("same");
172   fqplot.cd();
173   profq_dr->Write("qt_dr_0");
174   profq_dr_corrg->Write("qt_dr_1");
175   profq_dr_corrcal->Write("qt_dr_2");
176   gPad->Write("qt_dr");
177 }
178
179
180
181 void MakePlotsQ(){
182   //
183   //
184   //
185   //
186   chaing->Draw("Track.fdEdx>>his0dedx(100,0,200)","Track.fN>100&&abs(Track.P()-15)<3","",20000);
187   chaing->Draw("Track.CookdEdxNorm(0.02,0.6,0,0,160)/3.71>>his0dedxnormQ(100,0,200)","Track.fN>100&&abs(Track.P()-15)<3","",20000);
188   TH1F * his0dedx = gROOT->FindObject("his0dedx");
189   TH1F * his0dedxnormq = gROOT->FindObject("his0dedxnormQ");
190   his0dedxnormq->SetXTitle("dEdx (rel. unit)")
191   his0dedxnormq->Draw();
192   his0dedx->Draw("same");
193  
194
195   chaing->Draw("Track.CookdEdxNorm(0.02,0.6,0,0,160)/3.71:Track.GetP()>>hispdedxnorm(10,5,100)","Track.fN>100","prof",20000);
196
197
198   chaing->Draw("Track.fdEdx:sector0>>hisdedx(36,0,36)","Track.fN>60","prof",10000);
199   chaing->Draw("Track.CookdEdxNorm(0.02,0.6,0,0,160)/3.71:sector0>>hisdedxnormQ(36,0,36)","Track.fN>60","prof",10000);
200
201 }
202
203
204
205
206
207
208
209
210
211
212
213