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