For Pythia with tune don't switch off MI in ConfigHeavyFlavor
[u/mrichter/AliRoot.git] / ITS / ShowDriftSpeedSDD.C
CommitLineData
40b3a8c7 1#if !defined(__CINT__) || defined(__MAKECINT__)
2420973e 2#include <TF1.h>
40b3a8c7 3#include <TFile.h>
4#include <TH1F.h>
5#include <TGraph.h>
6#include <TStyle.h>
551eb942 7#include <TSystem.h>
8#include <TString.h>
40b3a8c7 9#include <TGrid.h>
10#include <TCanvas.h>
11#include <TLatex.h>
12#include <TObjArray.h>
13#include "AliCDBEntry.h"
14#include "AliITSDriftSpeedArraySDD.h"
2420973e 15#include "AliITSDriftSpeedSDD.h"
40b3a8c7 16#endif
17
18// Macro to plot the calibration parameters from the OCDB file
19// created from an INJECTOR run (OCDB/ITS/Calib/DriftSpeedSDD)
20// Two methods ShowDriftSpeedSDD:
21// - the first takes the name of the file to be displayed
22// - the second builds the alien path+name from run number and file version
23//
24// Origin: F. Prino (prino@to.infn.it)
25
b70dd7af 26Bool_t kNoDraw = kFALSE; // set to kTRUE to eliminate module dependent plots
27
e9b71015 28
b70dd7af 29void ShowDriftSpeedSDD(Char_t filnam[150]="$ALICE_ROOT/ITS/Calib/DriftSpeedSDD/Run0_9999999_v0_s0.root", Int_t firstmod=0, Int_t lastmod=260,Int_t nrun=0){
40b3a8c7 30 TFile *f= TFile::Open(filnam);
31 AliCDBEntry *ent=(AliCDBEntry*)f->Get("AliCDBEntry");
32 TObjArray *drspSDD = (TObjArray *)ent->GetObject();
33 AliITSDriftSpeedArraySDD *vdriftarr0;
34 AliITSDriftSpeedArraySDD *vdriftarr1;
35 TGraph **gvdr0=new TGraph*[260];
36 TGraph **gvdr1=new TGraph*[260];
e9b71015 37 TCanvas *c0=0x0;
38 if(!kNoDraw)c0=new TCanvas("c0","Module Drift Speed",700,1000);
40b3a8c7 39
40 TGraph *vvsmod0=new TGraph(0);
41 TGraph *vvsmod1=new TGraph(0);
915c0469 42 TGraph *poldegvsmod0=new TGraph(0);
43 TGraph *poldegvsmod1=new TGraph(0);
44 TGraph *anmaxvsmod0=new TGraph(0);
45 TGraph *anmaxvsmod1=new TGraph(0);
46 TGraph *dvcevsmod0=new TGraph(0);
47 TGraph *dvcevsmod1=new TGraph(0);
48 TGraph *dveevsmod0=new TGraph(0);
49 TGraph *dveevsmod1=new TGraph(0);
50
b70dd7af 51 char tit0[100];
52 sprintf(tit0,"Drift Speed vs. mod. number");
53 if(nrun!=0)sprintf(tit0,"Drift Speed vs. mod. number - Run %d",nrun);
54 vvsmod0->SetTitle(tit0);
55 vvsmod1->SetTitle(tit0);
915c0469 56
57 sprintf(tit0,"Degree of poly fit vs. mod. number");
58 if(nrun!=0)sprintf(tit0,"Degree of poly fit vs. mod. number - Run %d",nrun);
59 poldegvsmod0->SetTitle(tit0);
60 poldegvsmod1->SetTitle(tit0);
61
62 sprintf(tit0,"Anode with max. vdrift vs. mod. number");
63 if(nrun!=0)sprintf(tit0,"Anode with max. vdrift vs. mod. number - Run %d",nrun);
64 anmaxvsmod0->SetTitle(tit0);
65 anmaxvsmod1->SetTitle(tit0);
66
67 sprintf(tit0,"Delta Vdrift 128-0 vs. mod. number");
68 if(nrun!=0)sprintf(tit0,"Delta Vdrift 128-0 vs. mod. number - Run %d",nrun);
69 dvcevsmod0->SetTitle(tit0);
70 dvcevsmod1->SetTitle(tit0);
71
72 sprintf(tit0,"Delta Vdrift 256-0 vs. mod. number");
73 if(nrun!=0)sprintf(tit0,"Delta Vdrift 256-0 vs. mod. number - Run %d",nrun);
74 dveevsmod0->SetTitle(tit0);
75 dveevsmod1->SetTitle(tit0);
76
49c59b1d 77 TF1* fPoly=new TF1("fPoly","pol3",0.,256.);
40b3a8c7 78 Char_t tit[100];
e9b71015 79 TString psnm0 = "vdriftSDD.ps[";
80 TString psnm1 = "vdriftSDD.ps";
81 TString psnm2 = "vdriftSDD.ps]";
82 if(!kNoDraw) c0->Print(psnm0.Data());
83 Int_t cntpad = 0;
915c0469 84 Int_t iGoodInj=0;
85 Int_t iAverSpeed=0;
e9b71015 86 TLatex* tleft=new TLatex(0.2,0.82,"Side 0");
87 tleft->SetNDC();
88 tleft->SetTextColor(1);
89 TLatex* tright=new TLatex(0.2,0.75,"Side 1");
90 tright->SetNDC();
91 tright->SetTextColor(2);
92
40b3a8c7 93 for(Int_t i=firstmod; i<lastmod; i++){
266a4b47 94 Int_t iMod=i+240;
40b3a8c7 95 Int_t i0=2*i;
96 Int_t i1=1+2*i;
97 vdriftarr0=(AliITSDriftSpeedArraySDD*)drspSDD->At(i0);
98 vdriftarr1=(AliITSDriftSpeedArraySDD*)drspSDD->At(i1);
915c0469 99 AliITSDriftSpeedSDD* vdrift0=0x0;
100 if(vdriftarr0) vdrift0=vdriftarr0->GetDriftSpeedObject(0);
101 AliITSDriftSpeedSDD* vdrift1=0x0;
102 if(vdriftarr1) vdrift1=vdriftarr1->GetDriftSpeedObject(0);
103
40b3a8c7 104 gvdr0[i]=new TGraph(0);
105 gvdr1[i]=new TGraph(0);
106 gvdr0[i]->SetMarkerStyle(7);
107 gvdr1[i]->SetMarkerStyle(7);
e9b71015 108 gvdr0[i]->SetMarkerColor(kBlack);
109 gvdr0[i]->SetLineColor(kBlack);
40b3a8c7 110 gvdr0[i]->SetMinimum(5.);
111 gvdr1[i]->SetMinimum(5.);
e9b71015 112 gvdr0[i]->SetMaximum(7.5);
113 gvdr1[i]->SetMaximum(7.5);
266a4b47 114 sprintf(tit,"Mod %d\n",iMod);
40b3a8c7 115 gvdr0[i]->SetTitle(tit);
116 gvdr1[i]->SetTitle(tit);
e9b71015 117 gvdr1[i]->SetMarkerColor(kRed);
118 gvdr1[i]->SetLineColor(kRed);
40b3a8c7 119
120 for(Int_t iAn=0; iAn<256; iAn++){
121 Float_t vel0=0;
915c0469 122 if(vdrift0) vel0=vdrift0->GetDriftSpeedAtAnode(iAn);
40b3a8c7 123 Float_t vel1=0;
915c0469 124 if(vdrift1) vel1=vdrift1->GetDriftSpeedAtAnode(iAn);
40b3a8c7 125 gvdr0[i]->SetPoint(iAn,(Float_t)iAn,vel0);
126 gvdr1[i]->SetPoint(iAn,(Float_t)iAn,vel1);
127 }
915c0469 128 if(vdriftarr0->GetInjectorStatus()>0) iGoodInj++;
129 else iAverSpeed++;
130 if(vdriftarr1->GetInjectorStatus()>0) iGoodInj++;
131 else iAverSpeed++;
132
50d25e98 133 printf(" Mod. %d \tStatusLR=%X %X \t v(an 128l)= %f",iMod,vdriftarr0->GetInjectorStatus(),vdriftarr1->GetInjectorStatus(),vdriftarr0->GetDriftSpeed(0,128));
915c0469 134 printf(" \t v(an 128r)= %f Degree=%d %d\n",vdriftarr1->GetDriftSpeed(0,128),vdrift0->GetDegreeofPoly(),vdrift1->GetDegreeofPoly());
2420973e 135
136 if(!kNoDraw){
e9b71015 137 if (i%12==0 ) {
138 c0->cd();
139 c0->Modified();
140 c0->Update();
141 if (i) c0->Print(psnm1.Data());
142 c0->Clear();
143 c0->Divide(3,4);
144 cntpad = 0;
145 }
146 c0->cd(++cntpad);
2420973e 147 gvdr0[i]->Draw("AP");
148 gvdr0[i]->GetXaxis()->SetTitle("Anode");
e9b71015 149 gvdr0[i]->GetYaxis()->SetTitle("Vdrift (#mum/ns)");
150 gvdr1[i]->Draw("P same");
2420973e 151 gvdr1[i]->GetXaxis()->SetTitle("Anode");
152 gvdr1[i]->GetYaxis()->SetTitle("Vdrift (#mum/ns)");
e9b71015 153 tleft->Draw();
154 tright->Draw();
2420973e 155 }
156
40b3a8c7 157 Float_t vel0=0;
915c0469 158 Float_t pd0=0;
159 if(vdrift0){
160 vel0=vdrift0->GetDriftSpeedAtAnode(128);
e9b71015 161 pd0=vdrift0->GetDegreeofPoly();
915c0469 162 }
40b3a8c7 163 Float_t vel1=0;
915c0469 164 Float_t pd1=0;
165 if(vdrift1){
166 vel1=vdrift1->GetDriftSpeedAtAnode(128);
167 pd1=vdrift1->GetDegreeofPoly();
168 }
266a4b47 169 vvsmod0->SetPoint(vvsmod0->GetN(),(Float_t)iMod,vel0);
170 vvsmod1->SetPoint(vvsmod1->GetN(),(Float_t)iMod,vel1);
915c0469 171 poldegvsmod0->SetPoint(poldegvsmod0->GetN(),(Float_t)iMod,pd0);
172 poldegvsmod1->SetPoint(poldegvsmod1->GetN(),(Float_t)iMod,pd1);
173
174 for(Int_t ipar=0; ipar<=vdrift0->GetDegreeofPoly(); ipar++){
175 fPoly->SetParameter(ipar,vdrift0->GetDriftSpeedParameter(ipar));
176 }
177 if(vdrift0->GetDegreeofPoly()<3){
178 for(Int_t ipar=vdrift0->GetDegreeofPoly()+1; ipar<=3; ipar++) fPoly->SetParameter(ipar,0.);
179 }
180
181 anmaxvsmod0->SetPoint(anmaxvsmod0->GetN(),(Float_t)iMod,fPoly->GetMaximumX(0.,256.));
182 dvcevsmod0->SetPoint(dvcevsmod0->GetN(),(Float_t)iMod,fPoly->Eval(128)-fPoly->Eval(0));
183 dveevsmod0->SetPoint(dveevsmod0->GetN(),(Float_t)iMod,fPoly->Eval(256)-fPoly->Eval(0));
40b3a8c7 184
915c0469 185 for(Int_t ipar=0; ipar<=vdrift1->GetDegreeofPoly(); ipar++){
186 fPoly->SetParameter(ipar,vdrift1->GetDriftSpeedParameter(ipar));
187 }
188 if(vdrift1->GetDegreeofPoly()<3){
189 for(Int_t ipar=vdrift1->GetDegreeofPoly()+1; ipar<=3; ipar++) fPoly->SetParameter(ipar,0.);
190 }
191 anmaxvsmod1->SetPoint(anmaxvsmod1->GetN(),(Float_t)iMod,fPoly->GetMaximumX(0.,256.));
192 dvcevsmod1->SetPoint(dvcevsmod1->GetN(),(Float_t)iMod,fPoly->Eval(128)-fPoly->Eval(0));
193 dveevsmod1->SetPoint(dveevsmod1->GetN(),(Float_t)iMod,fPoly->Eval(256)-fPoly->Eval(0));
40b3a8c7 194 // getchar();
195 }
915c0469 196
e9b71015 197 if(!kNoDraw){
198 c0->cd();
199 c0->Modified();
200 c0->Update();
201 c0->Print(psnm2.Data());
202 }
915c0469 203 printf("Number of half-modules with drift speed from injectors = %d\n",iGoodInj);
204 printf("Number of half-modules with average drift speed = %d\n",iAverSpeed);
205
40b3a8c7 206 TCanvas* c2;
207 c2=new TCanvas("c2","",1000,700);
208 vvsmod0->SetMarkerStyle(20);
209 vvsmod0->Draw("AP");
210 vvsmod0->GetXaxis()->SetTitle("Module Number");
211 vvsmod0->GetYaxis()->SetTitle("Vdrift (#mum/ns)");
212 vvsmod1->SetMarkerStyle(21);
213 vvsmod1->SetMarkerColor(2);
214 vvsmod1->Draw("SAMEP");
40b3a8c7 215 tleft->Draw();
40b3a8c7 216 tright->Draw();
217
915c0469 218 TCanvas* c3;
219 c3=new TCanvas("c3","",900,900);
220 c3->Divide(2,2);
221
222 c3->cd(1);
223 gPad->SetLeftMargin(0.14);
224 poldegvsmod0->SetMarkerStyle(20);
225 poldegvsmod0->Draw("AP");
226 poldegvsmod0->GetXaxis()->SetTitle("Module Number");
227 poldegvsmod0->GetYaxis()->SetTitle("Degree of Polynomial fit");
228 poldegvsmod0->GetYaxis()->SetTitleOffset(1.4);
229 poldegvsmod1->SetMarkerStyle(21);
230 poldegvsmod1->SetMarkerColor(2);
231 poldegvsmod1->Draw("SAMEP");
232 tleft->Draw();
233 tright->Draw();
234 c3->cd(2);
235 gPad->SetLeftMargin(0.14);
236 anmaxvsmod0->SetMarkerStyle(20);
237 anmaxvsmod0->Draw("AP");
238 anmaxvsmod0->GetXaxis()->SetTitle("Module Number");
239 anmaxvsmod0->GetYaxis()->SetTitle("Anode with max. drift speed");
240 anmaxvsmod0->GetYaxis()->SetTitleOffset(1.4);
241 anmaxvsmod1->SetMarkerStyle(21);
242 anmaxvsmod1->SetMarkerColor(2);
243 anmaxvsmod1->Draw("SAMEP");
244 tleft->Draw();
245 tright->Draw();
246 c3->cd(3);
247 gPad->SetLeftMargin(0.14);
248 dvcevsmod0->SetMarkerStyle(20);
249 dvcevsmod0->Draw("AP");
250 dvcevsmod0->GetXaxis()->SetTitle("Module Number");
251 dvcevsmod0->GetYaxis()->SetTitle("vdrift(anode128)-vdrift(anode0)");
252 dvcevsmod0->GetYaxis()->SetTitleOffset(1.4);
253 dvcevsmod1->SetMarkerStyle(21);
254 dvcevsmod1->SetMarkerColor(2);
255 dvcevsmod1->Draw("SAMEP");
256 tleft->Draw();
257 tright->Draw();
258 c3->cd(4);
259 gPad->SetLeftMargin(0.14);
260 dveevsmod0->SetMarkerStyle(20);
261 dveevsmod0->Draw("AP");
262 dveevsmod0->GetYaxis()->SetTitleOffset(1.4);
263 dveevsmod0->GetXaxis()->SetTitle("Module Number");
264 dveevsmod0->GetYaxis()->SetTitle("vdrift(anode256)-vdrift(anode0)");
265 dveevsmod1->SetMarkerStyle(21);
266 dveevsmod1->SetMarkerColor(2);
267 dveevsmod1->Draw("SAMEP");
268 tleft->Draw();
269 tright->Draw();
270
271
40b3a8c7 272}
273
274
275
e9b71015 276void ShowDriftSpeedSDD(Int_t nrun, Int_t year=2010, Int_t nv=-1){
40b3a8c7 277 TGrid::Connect("alien:",0,0,"t");
551eb942 278 TString cmd=Form("gbbox find \"/alice/data/%d/OCDB/ITS/Calib/DriftSpeedSDD\" \"Run%d*.root\" > run.txt",year,nrun);
e9b71015 279 if(nv>0){
280 cmd.Form("gbbox find \"/alice/data/%d/OCDB/ITS/Calib/DriftSpeedSDD\" \"Run%d_999999999_v%d_s0.root\" > run.txt",year,nrun,nv);
281 }
551eb942 282 gSystem->Exec(cmd.Data());
283
284 Char_t filnam[200],filnamalien[200];
285 FILE* runtxt=fopen("run.txt","r");
286 fscanf(runtxt,"%s\n",filnam);
287 if(!strstr(filnam,"/alice/data/")){
288 printf("Bad run number\n");
289 gSystem->Exec("rm run.txt");
290 return;
291 }
292 sprintf(filnamalien,"alien://%s",filnam);
293
294 printf("Open file: %s\n",filnamalien);
b70dd7af 295 ShowDriftSpeedSDD(filnamalien,0,260,nrun);
551eb942 296 fclose(runtxt);
297 gSystem->Exec("rm run.txt");
298
40b3a8c7 299}