]>
Commit | Line | Data |
---|---|---|
8d024204 | 1 | #if !defined(__CINT__) || defined(__MAKECINT__) |
2 | #include <TFile.h> | |
3 | #include <TH1F.h> | |
4 | #include <TGraph.h> | |
5 | #include <TStyle.h> | |
6 | #include <TLegend.h> | |
7 | #include <TLegendEntry.h> | |
8 | #include <TSystem.h> | |
9 | #include <TGrid.h> | |
10 | #include <TMath.h> | |
11 | #include <TGraphErrors.h> | |
12 | #include <TCanvas.h> | |
13 | #include <TLatex.h> | |
14 | #include <TObjArray.h> | |
15 | #include "AliCDBEntry.h" | |
16 | #include "AliITSDriftSpeedArraySDD.h" | |
17 | #include "AliITSgeomTGeo.h" | |
18 | #endif | |
19 | ||
20 | /* $Id$ */ | |
21 | ||
22 | ||
23 | // Macro to plot the drift speed vs. time from the OCDB files | |
24 | // created from INJECTOR runs (OCDB/ITS/Calib/DriftSpeedSDD) | |
25 | // Origin: F. Prino (prino@to.infn.it) | |
26 | ||
27 | void FillErrors(Float_t errSpeed[260]); | |
28 | ||
29 | void PlotDriftSpeedSDDVsTime(Int_t firstRun=76172, | |
30 | Int_t lastRun=999999999, | |
31 | Int_t anode=128){ | |
32 | ||
33 | TGrid::Connect("alien:",0,0,"t"); | |
34 | ||
35 | Float_t errSpeed[260]; | |
36 | FillErrors(errSpeed); | |
37 | ||
38 | gSystem->Exec("gbbox find \"/alice/data/2009/OCDB/ITS/Calib/DriftSpeedSDD\" \"Run*.root\" > runSpeedAlien.txt"); | |
39 | FILE* listruns=fopen("runSpeedAlien.txt","r"); | |
40 | Char_t filnam[200],filnamalien[200]; | |
41 | TGraphErrors** gvdrvstime=new TGraphErrors*[520]; | |
42 | TGraphErrors** gvdrvsrun=new TGraphErrors*[520]; | |
43 | Int_t iPt[260]; | |
44 | for(Int_t iMod=0; iMod<260;iMod++){ | |
45 | gvdrvstime[iMod]=new TGraphErrors(0); | |
46 | gvdrvstime[iMod]->SetTitle(Form("Module %d",iMod+240)); | |
47 | gvdrvstime[iMod]->SetName(Form("gspmod%dt",iMod+240)); | |
48 | gvdrvsrun[iMod]=new TGraphErrors(0); | |
49 | gvdrvsrun[iMod]->SetTitle(Form("Module %d",iMod+240)); | |
50 | gvdrvsrun[iMod]->SetName(Form("gspmod%dr",iMod+240)); | |
51 | iPt[iMod]=0; | |
52 | } | |
53 | Float_t Edrift=(1800-45)/291/0.012; | |
54 | Int_t nrun,nrun2,dum; | |
55 | ||
56 | while(!feof(listruns)){ | |
57 | fscanf(listruns,"%s\n",filnam); | |
58 | if(!strstr(filnam,"/alice/data/2009")) continue; | |
59 | sscanf(filnam,"/alice/data/2009/OCDB/ITS/Calib/DriftSpeedSDD/Run%d_%d_v%d_s%d.root",&nrun,&nrun2,&dum,&dum); | |
60 | if(nrun<85639 && nrun2> 85639) continue; | |
61 | if(nrun<firstRun) continue; | |
62 | if(nrun>lastRun) continue; | |
63 | sprintf(filnamalien,"alien://%s",filnam); | |
64 | printf("Open file: %s\n",filnam); | |
65 | TFile *f= TFile::Open(filnamalien); | |
66 | AliCDBEntry *ent=(AliCDBEntry*)f->Get("AliCDBEntry"); | |
67 | TObjArray *drspSDD = (TObjArray *)ent->GetObject(); | |
68 | ||
69 | AliITSDriftSpeedArraySDD *vdriftarr; | |
70 | for(Int_t iMod=0; iMod<260;iMod++){ | |
71 | Int_t index=-1; | |
72 | if(anode<256) index=2*iMod; | |
73 | else index=2*iMod+1; | |
74 | vdriftarr=(AliITSDriftSpeedArraySDD*)drspSDD->At(index); | |
75 | Int_t iAn=anode; | |
76 | if(anode>256) iAn=anode-256; | |
77 | Float_t vdrift=vdriftarr->GetDriftSpeed(0,iAn); | |
78 | UInt_t timest=vdriftarr->GetTimestamp(0); | |
79 | if(timest==0) continue; | |
80 | Float_t timeday=float(timest-1247762992)/60./60./24.; | |
81 | Float_t mob=vdrift*1.E5/Edrift; | |
82 | Float_t temper=293.15*TMath::Power((mob/1350.),-1/2.4); | |
83 | if(iMod==497-240) printf("Run %s Time %d Day %f Speed=%f Temp=%f\n",filnam,timest,timeday,vdrift,temper); | |
84 | gvdrvstime[iMod]->SetPoint(iPt[iMod],timeday,vdrift); | |
85 | gvdrvstime[iMod]->SetPointError(iPt[iMod],0,errSpeed[iMod]); | |
86 | gvdrvsrun[iMod]->SetPoint(iPt[iMod],(Float_t)nrun,vdrift); | |
87 | gvdrvsrun[iMod]->SetPointError(iPt[iMod],0,errSpeed[iMod]); | |
88 | ++iPt[iMod]; | |
89 | } | |
90 | f->Close(); | |
91 | } | |
92 | ||
93 | Int_t mod1=244-240; | |
94 | Int_t mod2=277-240; | |
95 | //Int_t mod1=268-240; | |
96 | //Int_t mod2=274-240; | |
97 | Int_t mod3=327-240; | |
98 | Int_t mod4=453-240; | |
99 | // Int_t mod4=497-240; | |
100 | Int_t lay1,lad1,det1; | |
101 | Int_t lay2,lad2,det2; | |
102 | Int_t lay3,lad3,det3; | |
103 | Int_t lay4,lad4,det4; | |
104 | AliITSgeomTGeo::GetModuleId(mod1+240,lay1,lad1,det1); | |
105 | AliITSgeomTGeo::GetModuleId(mod2+240,lay2,lad2,det2); | |
106 | AliITSgeomTGeo::GetModuleId(mod3+240,lay3,lad3,det3); | |
107 | AliITSgeomTGeo::GetModuleId(mod4+240,lay4,lad4,det4); | |
108 | ||
109 | TFile *ofil=new TFile("DriftSp2009VsTime.root","recreate"); | |
110 | for(Int_t iMod=0; iMod<260;iMod++){ | |
111 | gvdrvstime[iMod]->Write(); | |
112 | gvdrvsrun[iMod]->Write(); | |
113 | } | |
114 | ofil->Close(); | |
115 | ||
116 | gStyle->SetOptTitle(0); | |
117 | TCanvas* c0=new TCanvas(); | |
118 | c0->SetGridx(); | |
119 | c0->SetGridy(); | |
120 | gvdrvstime[mod1]->SetMarkerStyle(20); | |
121 | gvdrvstime[mod2]->SetMarkerStyle(22); | |
122 | gvdrvstime[mod2]->SetMarkerColor(2); | |
123 | gvdrvstime[mod2]->SetLineColor(2); | |
124 | gvdrvstime[mod3]->SetMarkerStyle(29); | |
125 | gvdrvstime[mod3]->SetMarkerColor(3); | |
126 | gvdrvstime[mod3]->SetLineColor(3); | |
127 | gvdrvstime[mod4]->SetMarkerStyle(27); | |
128 | gvdrvstime[mod4]->SetMarkerColor(4); | |
129 | gvdrvstime[mod4]->SetLineColor(4); | |
130 | gvdrvstime[mod1]->Draw("AP"); | |
131 | gvdrvstime[mod1]->SetMinimum(6.3); | |
132 | gvdrvstime[mod1]->SetMaximum(6.75); | |
133 | ||
134 | gvdrvstime[mod1]->GetXaxis()->SetTitle("Time (days since July 16th 2009)"); | |
135 | gvdrvstime[mod1]->GetYaxis()->SetTitle("Drift speed (#mum/ns)"); | |
136 | gvdrvstime[mod2]->Draw("PSAME"); | |
137 | gvdrvstime[mod3]->Draw("PSAME"); | |
138 | gvdrvstime[mod4]->Draw("PSAME"); | |
139 | TLegend* leg=new TLegend(0.6,0.7,0.89,0.89); | |
140 | leg->SetBorderSize(0); | |
141 | leg->SetFillColor(0); | |
142 | leg->SetFillStyle(0); | |
143 | TLegendEntry* lent=leg->AddEntry(gvdrvstime[mod1],Form("Lay %d Lad %d Det %d",lay1,lad1,det1),"P"); | |
144 | lent=leg->AddEntry(gvdrvstime[mod2],Form("Lay %d Lad %d Det %d",lay2,lad2,det2),"P"); | |
145 | lent->SetTextColor(2); | |
146 | lent=leg->AddEntry(gvdrvstime[mod3],Form("Lay %d Lad %d Det %d",lay3,lad3,det3),"P"); | |
147 | lent->SetTextColor(3); | |
148 | lent=leg->AddEntry(gvdrvstime[mod4],Form("Lay %d Lad %d Det %d",lay4,lad4,det4),"P"); | |
149 | lent->SetTextColor(4); | |
150 | leg->Draw(); | |
151 | ||
152 | TCanvas* c1=new TCanvas(); | |
153 | c1->SetGridx(); | |
154 | c1->SetGridy(); | |
155 | gvdrvsrun[mod1]->SetMarkerStyle(20); | |
156 | gvdrvsrun[mod2]->SetMarkerStyle(22); | |
157 | gvdrvsrun[mod2]->SetMarkerColor(2); | |
158 | gvdrvsrun[mod2]->SetLineColor(2); | |
159 | gvdrvsrun[mod3]->SetMarkerStyle(29); | |
160 | gvdrvsrun[mod3]->SetMarkerColor(3); | |
161 | gvdrvsrun[mod3]->SetLineColor(3); | |
162 | gvdrvsrun[mod4]->SetMarkerStyle(27); | |
163 | gvdrvsrun[mod4]->SetMarkerColor(4); | |
164 | gvdrvsrun[mod4]->SetLineColor(4); | |
165 | gvdrvsrun[mod1]->Draw("AP"); | |
166 | gvdrvsrun[mod1]->SetMinimum(6.3); | |
167 | gvdrvsrun[mod1]->SetMaximum(6.75); | |
168 | ||
169 | gvdrvsrun[mod1]->GetXaxis()->SetTitle("Run number"); | |
170 | gvdrvsrun[mod1]->GetYaxis()->SetTitle("Drift speed (#mum/ns)"); | |
171 | gvdrvsrun[mod2]->Draw("PSAME"); | |
172 | gvdrvsrun[mod3]->Draw("PSAME"); | |
173 | gvdrvsrun[mod4]->Draw("PSAME"); | |
174 | leg->Draw(); | |
175 | } | |
176 | ||
177 | void FillErrors(Float_t errSpeed[260]){ | |
178 | Float_t err[260]={ | |
179 | 0.002308,0.005120,0.004632,0.001000,0.001735, | |
180 | 0.001000,0.001000,0.002667,0.004237,0.005297, | |
181 | 0.001000,0.005460,0.005149,0.003921,0.001000, | |
182 | 0.003906,0.001000,0.004871,0.001000,0.001000, | |
183 | 0.001000,0.001000,0.002261,0.002986,0.002056, | |
184 | 0.002848,0.001000,0.001777,0.002822,0.004651, | |
185 | 0.001000,0.003551,0.006466,0.001000,0.002083, | |
186 | 0.004531,0.001000,0.002213,0.001000,0.001000, | |
187 | 0.001000,0.001000,0.001000,0.003223,0.002800, | |
188 | 0.002147,0.001000,0.003364,0.001000,0.001000, | |
189 | 0.002515,0.003229,0.002552,0.005765,0.002368, | |
190 | 0.003473,0.002363,0.001000,0.003413,0.001000, | |
191 | 0.004906,0.001000,0.004346,0.004887,0.007138, | |
192 | 0.007242,0.004289,0.003970,0.002914,0.002199, | |
193 | 0.001000,0.003483,0.002154,0.002914,0.003097, | |
194 | 0.006034,0.003101,0.001000,0.002425,0.002651, | |
195 | 0.002771,0.002409,0.002260,0.003109,0.001000, | |
196 | 0.003384,0.003374,0.002212,0.004441,0.001000, | |
197 | 0.001000,0.001000,0.003578,0.001000,0.001000, | |
198 | 0.003517,0.003590,0.001787,0.003329,0.001000, | |
199 | 0.002770,0.001000,0.004032,0.003059,0.001000, | |
200 | 0.001000,0.001000,0.001000,0.001000,0.001000, | |
201 | 0.001000,0.004556,0.001000,0.001000,0.001000, | |
202 | 0.001000,0.001000,0.001000,0.004819,0.002100, | |
203 | 0.002624,0.003784,0.003772,0.002483,0.002792, | |
204 | 0.001000,0.004713,0.003214,0.003180,0.002145, | |
205 | 0.002470,0.003078,0.001000,0.007131,0.002770, | |
206 | 0.002533,0.001000,0.004362,0.002819,0.001000, | |
207 | 0.003630,0.004215,0.002975,0.001000,0.003790, | |
208 | 0.002345,0.001000,0.003999,0.004555,0.003989, | |
209 | 0.001000,0.001000,0.001000,0.003136,0.002426, | |
210 | 0.005144,0.002844,0.002310,0.002467,0.002503, | |
211 | 0.003811,0.003440,0.004773,0.003114,0.001000, | |
212 | 0.000583,0.001000,0.001000,0.003385,0.001000, | |
213 | 0.001000,0.001000,0.001000,0.003108,0.002109, | |
214 | 0.005325,0.003750,0.002810,0.003559,0.001000, | |
215 | 0.001000,0.003262,0.003903,0.001000,0.003622, | |
216 | 0.002533,0.002121,0.003733,0.005353,0.002221, | |
217 | 0.004767,0.003267,0.004892,0.002152,0.003398, | |
218 | 0.001000,0.003146,0.001000,0.002952,0.003310, | |
219 | 0.002644,0.002573,0.001000,0.003989,0.001000, | |
220 | 0.005294,0.003095,0.003479,0.002250,0.001000, | |
221 | 0.001000,0.005221,0.001000,0.001653,0.004330, | |
222 | 0.013188,0.007375,0.003226,0.003875,0.001000, | |
223 | 0.003653,0.001000,0.002655,0.001000,0.001000, | |
224 | 0.001000,0.001000,0.004718,0.001000,0.001000, | |
225 | 0.001000,0.002780,0.003680,0.001000,0.002787, | |
226 | 0.001000,0.004617,0.001000,0.001000,0.003231, | |
227 | 0.001887,0.002090,0.003326,0.129970,0.004907, | |
228 | 0.004334,0.001000,0.001000,0.003489,0.002573, | |
229 | 0.002566,0.002982,0.001000,0.001000,0.003436, | |
230 | 0.004016,0.003736,0.001784,0.004775,0.008090}; | |
231 | for(Int_t i=0;i<260;i++) errSpeed[i]=err[i]; | |
232 | ||
233 | ||
234 | } |