]>
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 | ||
78018435 | 30 | void PlotDriftSpeedSDDVsTime(Int_t year=2009, Int_t firstRun=62840, |
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]; | |
42 | Int_t iPt[260]; | |
43 | for(Int_t iMod=0; iMod<260;iMod++){ | |
44 | gvdrvstime[iMod]=new TGraphErrors(0); | |
45 | gvdrvstime[iMod]->SetTitle(Form("Module %d",iMod+240)); | |
46 | gvdrvstime[iMod]->SetName(Form("gspmod%dt",iMod+240)); | |
47 | gvdrvsrun[iMod]=new TGraphErrors(0); | |
48 | gvdrvsrun[iMod]->SetTitle(Form("Module %d",iMod+240)); | |
49 | gvdrvsrun[iMod]->SetName(Form("gspmod%dr",iMod+240)); | |
50 | iPt[iMod]=0; | |
51 | } | |
52 | Float_t Edrift=(1800-45)/291/0.012; | |
9c3758ab | 53 | Int_t nrun,nrun2,nv,ns; |
8d024204 | 54 | while(!feof(listruns)){ |
55 | fscanf(listruns,"%s\n",filnam); | |
78018435 | 56 | Char_t directory[100]; |
57 | sprintf(directory,"/alice/data/%d",year); | |
58 | if(!strstr(filnam,directory)) continue; | |
59 | sscanf(filnam,"/alice/data/%d/OCDB/ITS/Calib/DriftSpeedSDD/Run%d_%d_v%d_s%d.root",&year,&nrun,&nrun2,&nv,&ns); | |
60 | ||
61 | if(year==2009 && (nrun<85639 && nrun2> 85639)) continue;// protection for files with swapped ladders 4-5 of layer 3 | |
2420973e | 62 | if(year==2009 && (nrun>100000 && nv< 325)) continue; // protection for files with swapped ladder 0-1 of layer 4 |
78018435 | 63 | |
8d024204 | 64 | if(nrun<firstRun) continue; |
65 | if(nrun>lastRun) continue; | |
66 | sprintf(filnamalien,"alien://%s",filnam); | |
67 | printf("Open file: %s\n",filnam); | |
68 | TFile *f= TFile::Open(filnamalien); | |
69 | AliCDBEntry *ent=(AliCDBEntry*)f->Get("AliCDBEntry"); | |
70 | TObjArray *drspSDD = (TObjArray *)ent->GetObject(); | |
71 | ||
72 | AliITSDriftSpeedArraySDD *vdriftarr; | |
73 | for(Int_t iMod=0; iMod<260;iMod++){ | |
74 | Int_t index=-1; | |
75 | if(anode<256) index=2*iMod; | |
76 | else index=2*iMod+1; | |
77 | vdriftarr=(AliITSDriftSpeedArraySDD*)drspSDD->At(index); | |
78 | Int_t iAn=anode; | |
79 | if(anode>256) iAn=anode-256; | |
80 | Float_t vdrift=vdriftarr->GetDriftSpeed(0,iAn); | |
81 | UInt_t timest=vdriftarr->GetTimestamp(0); | |
78018435 | 82 | if(timest==0) continue; |
83 | Float_t timeday; | |
84 | if(year==2009){ | |
85 | timeday=float(timest-1247762992)/60./60./24.; | |
86 | } else { | |
87 | timeday=float(timest-1264531801)/60./60./24.; | |
88 | } | |
8d024204 | 89 | Float_t mob=vdrift*1.E5/Edrift; |
90 | Float_t temper=293.15*TMath::Power((mob/1350.),-1/2.4); | |
91 | if(iMod==497-240) printf("Run %s Time %d Day %f Speed=%f Temp=%f\n",filnam,timest,timeday,vdrift,temper); | |
92 | gvdrvstime[iMod]->SetPoint(iPt[iMod],timeday,vdrift); | |
93 | gvdrvstime[iMod]->SetPointError(iPt[iMod],0,errSpeed[iMod]); | |
94 | gvdrvsrun[iMod]->SetPoint(iPt[iMod],(Float_t)nrun,vdrift); | |
95 | gvdrvsrun[iMod]->SetPointError(iPt[iMod],0,errSpeed[iMod]); | |
96 | ++iPt[iMod]; | |
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){ | |
146 | sprintf(title,"Time (days since January 16th 2010)"); | |
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(); | |
189 | } | |
190 | ||
191 | void FillErrors(Float_t errSpeed[260]){ | |
192 | Float_t err[260]={ | |
193 | 0.002308,0.005120,0.004632,0.001000,0.001735, | |
194 | 0.001000,0.001000,0.002667,0.004237,0.005297, | |
195 | 0.001000,0.005460,0.005149,0.003921,0.001000, | |
196 | 0.003906,0.001000,0.004871,0.001000,0.001000, | |
197 | 0.001000,0.001000,0.002261,0.002986,0.002056, | |
198 | 0.002848,0.001000,0.001777,0.002822,0.004651, | |
199 | 0.001000,0.003551,0.006466,0.001000,0.002083, | |
200 | 0.004531,0.001000,0.002213,0.001000,0.001000, | |
201 | 0.001000,0.001000,0.001000,0.003223,0.002800, | |
202 | 0.002147,0.001000,0.003364,0.001000,0.001000, | |
203 | 0.002515,0.003229,0.002552,0.005765,0.002368, | |
204 | 0.003473,0.002363,0.001000,0.003413,0.001000, | |
205 | 0.004906,0.001000,0.004346,0.004887,0.007138, | |
206 | 0.007242,0.004289,0.003970,0.002914,0.002199, | |
207 | 0.001000,0.003483,0.002154,0.002914,0.003097, | |
208 | 0.006034,0.003101,0.001000,0.002425,0.002651, | |
209 | 0.002771,0.002409,0.002260,0.003109,0.001000, | |
210 | 0.003384,0.003374,0.002212,0.004441,0.001000, | |
211 | 0.001000,0.001000,0.003578,0.001000,0.001000, | |
212 | 0.003517,0.003590,0.001787,0.003329,0.001000, | |
213 | 0.002770,0.001000,0.004032,0.003059,0.001000, | |
214 | 0.001000,0.001000,0.001000,0.001000,0.001000, | |
215 | 0.001000,0.004556,0.001000,0.001000,0.001000, | |
216 | 0.001000,0.001000,0.001000,0.004819,0.002100, | |
217 | 0.002624,0.003784,0.003772,0.002483,0.002792, | |
218 | 0.001000,0.004713,0.003214,0.003180,0.002145, | |
219 | 0.002470,0.003078,0.001000,0.007131,0.002770, | |
220 | 0.002533,0.001000,0.004362,0.002819,0.001000, | |
221 | 0.003630,0.004215,0.002975,0.001000,0.003790, | |
222 | 0.002345,0.001000,0.003999,0.004555,0.003989, | |
223 | 0.001000,0.001000,0.001000,0.003136,0.002426, | |
224 | 0.005144,0.002844,0.002310,0.002467,0.002503, | |
225 | 0.003811,0.003440,0.004773,0.003114,0.001000, | |
226 | 0.000583,0.001000,0.001000,0.003385,0.001000, | |
227 | 0.001000,0.001000,0.001000,0.003108,0.002109, | |
228 | 0.005325,0.003750,0.002810,0.003559,0.001000, | |
229 | 0.001000,0.003262,0.003903,0.001000,0.003622, | |
230 | 0.002533,0.002121,0.003733,0.005353,0.002221, | |
231 | 0.004767,0.003267,0.004892,0.002152,0.003398, | |
232 | 0.001000,0.003146,0.001000,0.002952,0.003310, | |
233 | 0.002644,0.002573,0.001000,0.003989,0.001000, | |
234 | 0.005294,0.003095,0.003479,0.002250,0.001000, | |
235 | 0.001000,0.005221,0.001000,0.001653,0.004330, | |
236 | 0.013188,0.007375,0.003226,0.003875,0.001000, | |
237 | 0.003653,0.001000,0.002655,0.001000,0.001000, | |
238 | 0.001000,0.001000,0.004718,0.001000,0.001000, | |
239 | 0.001000,0.002780,0.003680,0.001000,0.002787, | |
240 | 0.001000,0.004617,0.001000,0.001000,0.003231, | |
241 | 0.001887,0.002090,0.003326,0.129970,0.004907, | |
242 | 0.004334,0.001000,0.001000,0.003489,0.002573, | |
243 | 0.002566,0.002982,0.001000,0.001000,0.003436, | |
244 | 0.004016,0.003736,0.001784,0.004775,0.008090}; | |
245 | for(Int_t i=0;i<260;i++) errSpeed[i]=err[i]; | |
246 | ||
247 | ||
248 | } |