Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
326 | f9daq | 1 | #include <stdio.h> |
2 | #include <stdlib.h> |
||
3 | |||
4 | #include <TROOT.h> |
||
5 | #include <TH1D.h> |
||
6 | #include <TH2D.h> |
||
7 | #include <TH3D.h> |
||
8 | #include <TCanvas.h> |
||
9 | #include <TStyle.h> |
||
10 | #include <TSystem.h> |
||
11 | #include <TFile.h> |
||
12 | #include <TDirectory.h> |
||
13 | #include <TPaveText.h> |
||
14 | |||
15 | #include "base.h" |
||
16 | #include "focus.h" |
||
17 | |||
18 | int focus(int runNumber, int save) { |
||
19 | |||
20 | int HAPDnumber; //Number of HAPD: 0, 1, 2 or 3! |
||
21 | |||
22 | int direction, nx, ny; |
||
23 | char name[128]; |
||
24 | char pdfname[128]; |
||
25 | char buf[256]; |
||
26 | float pNoise; |
||
27 | int color[6] = {1,2,4,6,8,9}; |
||
28 | |||
29 | char hname[0xF]; |
||
30 | |||
31 | int max = 20; |
||
32 | |||
33 | TFile * data[max]; |
||
34 | |||
35 | |||
36 | for (int b=0;b<max;b++){ |
||
37 | sprintf(buf,"./meritve/%04d_4_2DX_zOS_%05d.root",runNumber+b,(runNumber-10+b)*1000); |
||
38 | data[b] = new TFile(buf); |
||
39 | } |
||
40 | |||
41 | const char * serialNumber = getSN(); |
||
42 | char * serialNumberTemp = strdup(serialNumber); |
||
43 | char * HAPDserialNumber; |
||
44 | |||
45 | GRID m = mapping(); |
||
46 | int vrstaPisave = 82; |
||
47 | |||
48 | TCanvas * c; |
||
49 | TPad * pad1, * pad2, * pad3; |
||
50 | TPad * VirtualPad2[12]; |
||
51 | TPaveText * info, * axisName; |
||
52 | TAxis * axis; |
||
53 | TH3D * h; |
||
54 | TH2D * slice[12]; //take the right slice from 3D histogram |
||
55 | TH1D * p[12]; |
||
56 | |||
57 | /********** GLOBALNE **********/ |
||
58 | gStyle->SetOptStat(0); |
||
59 | //gStyle->SetOptTitle(1); |
||
60 | gStyle->SetTitleFontSize(.15); |
||
61 | |||
62 | for(int HAPDnumber=0;HAPDnumber<4;HAPDnumber++){ |
||
63 | HAPDserialNumber = strsep(&serialNumberTemp,","); |
||
64 | if(!strcmp(HAPDserialNumber,"noserial")) continue; |
||
65 | |||
66 | sprintf(hname,"hxy%d_0;1",HAPDnumber); |
||
67 | printf("%s \t %s \n",HAPDserialNumber,hname); |
||
68 | |||
69 | h = (TH3D *) data[0]->Get(hname); |
||
70 | |||
71 | /********** SMER MERITVE **********/ |
||
72 | h->GetZaxis()->SetRange(1,1); |
||
73 | nx = h->GetNbinsX(); |
||
74 | ny = h->GetNbinsY(); |
||
75 | if (nx>=ny) direction = 0; |
||
76 | else direction = 1; |
||
77 | |||
78 | printf("Direction = %d\n", direction); |
||
79 | |||
80 | /********** CANVAS **********/ |
||
81 | if (!direction) { |
||
82 | sprintf(buf,"%04d_%s_px",runNumber,HAPDserialNumber); |
||
83 | c = new TCanvas(buf,buf,0,0,2000,2000); |
||
84 | } else { |
||
85 | sprintf(buf,"%04d_%s_py",runNumber,HAPDserialNumber); |
||
86 | c = new TCanvas(buf,buf,0,0,2000,2000); |
||
87 | } |
||
88 | c->Divide(4,5,0,0); |
||
89 | |||
90 | for(int a=0;a<max;a++){ |
||
91 | c->cd(a+1); |
||
92 | c->cd(a+1)->SetBorderSize(0); |
||
93 | c->cd(a+1)->SetBorderMode(0); |
||
94 | pad1 = new TPad("pad1","Title",0.05,0.94,0.95,1,0,0); |
||
95 | pad1->SetFillStyle(4000); |
||
96 | pad1->Draw(); |
||
97 | |||
98 | pad2 = new TPad("pad2","Graphs",0,0,1,0.95,0,0); |
||
99 | pad2->SetFillStyle(4000); |
||
100 | pad2->Draw(); |
||
101 | |||
102 | pad3 = new TPad("pad3","AxisTitle",0.57,0,0.92,0.05,0,0); |
||
103 | pad3->SetFillStyle(4000); |
||
104 | pad3->Draw(); |
||
105 | |||
106 | /********** PAD 1 **********/ |
||
107 | pad1->cd(); |
||
108 | info = new TPaveText(0.2,0,0.8,1,"ndc"); |
||
109 | info->SetBorderSize(0); |
||
110 | info->SetFillColor(4000); |
||
111 | info->SetTextSize(1); |
||
112 | info->SetTextAlign(22); |
||
113 | |||
114 | sprintf(name,"Z = %d stage steps", (runNumber-10+a)*1000); |
||
115 | info->AddText(name); |
||
116 | info->Draw(); |
||
117 | |||
118 | /********** PAD3 **********/ |
||
119 | pad3->cd(); |
||
120 | axisName = new TPaveText(0.2,0,0.8,1,"ndc"); |
||
121 | axisName->SetBorderSize(0); |
||
122 | axisName->SetFillColor(4000); |
||
123 | axisName->SetTextSize(.7); |
||
124 | axisName->SetTextFont(vrstaPisave); |
||
125 | axisName->SetTextAlign(22); |
||
126 | |||
127 | sprintf(name,"Incident light position (stage step)"); |
||
128 | axisName->AddText(name); |
||
129 | //axisName->Draw(); |
||
130 | |||
131 | /********** PAD2 **********/ |
||
132 | pad2->cd(); |
||
133 | pad2->Divide(1,4,0,0); |
||
134 | |||
135 | if(a) h = (TH3D *) data[a]->Get(hname); |
||
136 | |||
137 | for (int i=4;i<8;i++) { |
||
138 | if (!direction) { |
||
139 | pad2->cd(11 - i+1-4); |
||
140 | VirtualPad2[11 - i-4] = (TPad *)(pad2->cd(11 - i+1-4)); //Tole nastaviš zato, da lahko daš Log skalo |
||
141 | VirtualPad2[11 - i-4]->SetLogy(1); |
||
142 | //VirtualPad2[11 - i]->SetLeftMargin(.05); |
||
143 | //VirtualPad2[11 - i]->SetRightMargin(.05); |
||
144 | //VirtualPad2[11 - i]->SetGrid(); |
||
145 | } else { |
||
146 | pad2->cd(i+1-4); |
||
147 | VirtualPad2[i-4] = (TPad *)(pad2->cd(11 - i+1 - 4)); //Tole nastaviš zato, da lahko daš Log skalo |
||
148 | VirtualPad2[i-4]->SetLogy(1); |
||
149 | //VirtualPad2[i]->SetLeftMargin(.05); |
||
150 | //VirtualPad2[i]->SetRightMargin(.05); |
||
151 | //VirtualPad2[i]->SetGrid(); |
||
152 | } |
||
153 | for (int j=4;j<8;j++) { |
||
154 | if (!direction) h->GetZaxis()->SetRange(m.koordinatniSistem[j][i]+1,m.koordinatniSistem[j][i]+1); |
||
155 | else h->GetZaxis()->SetRange(m.koordinatniSistem[i][j]+1,m.koordinatniSistem[i][j]+1); |
||
156 | |||
157 | slice[j] = (TH2D *)h->Project3D("pyx"); |
||
158 | |||
159 | if (!direction) { |
||
160 | sprintf(name,"PX: (%d,%d)",j,i); |
||
161 | p[j] = slice[j]->ProjectionX(name,i+1-4,i+1-4); |
||
162 | sprintf(name,"Projection X of row %d",i); |
||
163 | } else { |
||
164 | sprintf(name,"PY: (%d,%d)",i,j); |
||
165 | p[j] = slice[j]->ProjectionY(name,i+1-4,i+1-4); |
||
166 | sprintf(name,"Projection Y of column %d",i); |
||
167 | } |
||
168 | axis = p[j]->GetXaxis(); |
||
169 | |||
170 | |||
171 | if(!direction) VirtualPad2[3]->SetBottomMargin(.17); |
||
172 | else VirtualPad2[0]->SetBottomMargin(.17); |
||
173 | |||
174 | p[j]->SetLineWidth(1); |
||
175 | |||
176 | p[j]->SetTitle(name); |
||
177 | p[j]->SetTitleOffset(1.5); |
||
178 | |||
179 | p[j]->GetYaxis()->SetRangeUser(1,10000); |
||
180 | p[j]->GetYaxis()->SetTickLength(0.01); |
||
181 | p[j]->GetYaxis()->SetTitleFont(vrstaPisave); |
||
182 | p[j]->GetYaxis()->SetLabelFont(vrstaPisave); |
||
183 | p[j]->GetYaxis()->SetLabelSize(0.05); |
||
184 | p[j]->GetYaxis()->SetLabelColor(kBlack); |
||
185 | p[j]->GetYaxis()->SetTitle("# events"); |
||
186 | p[j]->GetYaxis()->SetNdivisions(0); |
||
187 | p[j]->GetYaxis()->CenterTitle(); |
||
188 | p[j]->GetYaxis()->SetTitleSize(0.05); |
||
189 | p[j]->GetYaxis()->SetTitleOffset(.5); |
||
190 | p[j]->GetYaxis()->SetTitleColor(kWhite); |
||
191 | |||
192 | p[j]->GetXaxis()->SetTickLength(0.1); |
||
193 | p[j]->GetXaxis()->SetTitleFont(vrstaPisave); |
||
194 | p[j]->GetXaxis()->SetLabelFont(vrstaPisave); |
||
195 | p[j]->GetXaxis()->SetLabelSize(0.15); |
||
196 | p[j]->GetXaxis()->SetLabelColor(kBlack); |
||
197 | p[j]->GetXaxis()->SetLabelOffset(.05); |
||
198 | p[j]->GetXaxis()->SetTitle("Incident light position (stage step)"); |
||
199 | //p[j]->GetXaxis()->SetNdivisions(0); |
||
200 | //p[j]->GetXaxis()->CenterTitle(); |
||
201 | p[j]->GetXaxis()->SetTitleSize(0.01); |
||
202 | p[j]->GetXaxis()->SetTitleColor(kWhite); //zato ker ga ne moreš pozicionirat |
||
203 | p[j]->GetXaxis()->SetTitleOffset(.5); |
||
204 | |||
205 | pNoise = noise(p[j]); |
||
206 | for (int k=1;k<=p[j]->GetSize();k++) p[j]->SetBinContent(k,p[j]->GetBinContent(k)-pNoise); |
||
207 | |||
208 | if (j<6) p[j]->SetLineColor(kWhite+color[j]); |
||
209 | else p[j]->SetLineColor(kWhite+color[j-6]); |
||
210 | if (j==4) p[j]->DrawCopy(); |
||
211 | else p[j]->DrawCopy("SAME"); |
||
212 | } |
||
213 | } |
||
214 | } |
||
215 | c->Modified(); |
||
216 | c->Update(); |
||
217 | if (save==1){ |
||
218 | switch (direction) { |
||
219 | case 0: sprintf(pdfname,"./meritve/%s_4_2DX_focus1_run%04d_to%04d.pdf",HAPDserialNumber,runNumber,runNumber+max-1);break; |
||
220 | case 1: sprintf(pdfname,"./meritve/%s_5_2DY_focus1_run%04d_to%04d.pdf",HAPDserialNumber,runNumber,runNumber+max-1);break; |
||
221 | } |
||
222 | c->SaveAs(pdfname,"pdf"); |
||
223 | } else if (save==2){ |
||
224 | switch (direction) { |
||
225 | case 0: sprintf(pdfname,"./meritve/%s_4_2DX_focus1.pdf(",HAPDserialNumber);break; |
||
226 | case 1: sprintf(pdfname,"./meritve/%s_5_2DY_focus1.pdf(",HAPDserialNumber);break; |
||
227 | } |
||
228 | c->SaveAs(pdfname,"pdf"); |
||
229 | } else if (save==3){ |
||
230 | switch (direction) { |
||
231 | case 0: sprintf(pdfname,"./meritve/%s_4_2DX_focus1.pdf",HAPDserialNumber);break; |
||
232 | case 1: sprintf(pdfname,"./meritve/%s_5_2DY_focus1.pdf",HAPDserialNumber);break; |
||
233 | } |
||
234 | c->SaveAs(pdfname,"pdf"); |
||
235 | } else if (save==4){ |
||
236 | switch (direction) { |
||
237 | case 0: sprintf(pdfname,"./meritve/%s_4_2DX_focus1.pdf)",HAPDserialNumber);break; |
||
238 | case 1: sprintf(pdfname,"./meritve/%s_5_2DY_focus1.pdf)",HAPDserialNumber);break; |
||
239 | } |
||
240 | c->SaveAs(pdfname,"pdf"); |
||
241 | } |
||
242 | } |
||
243 | |||
244 | return 0; |
||
245 | } |
||
246 | |||
247 | int focus2(int runNumber, int save) { |
||
248 | |||
249 | int HAPDnumber; //Number of HAPD: 0, 1, 2 or 3! |
||
250 | |||
251 | int direction, nx, ny; |
||
252 | char name[128]; |
||
253 | char pdfname[128]; |
||
254 | char buf[256]; |
||
255 | float pNoise; |
||
256 | int color[6] = {1,2,4,6,8,9}; |
||
257 | |||
258 | char hname[0xF]; |
||
259 | int max = 20; |
||
260 | |||
261 | TFile * data[max]; |
||
262 | for (int b=0;b<max;b++){ |
||
263 | sprintf(buf,"./meritve/%04d_4_2DX_zOS_%05d.root",runNumber+b,(runNumber-10+b)*1000); |
||
264 | data[b] = new TFile(buf); |
||
265 | } |
||
266 | |||
267 | const char * serialNumber = getSN(); |
||
268 | char * serialNumberTemp = strdup(serialNumber); |
||
269 | char * HAPDserialNumber; |
||
270 | |||
271 | GRID m = mapping(); |
||
272 | int vrstaPisave = 82; |
||
273 | |||
274 | TCanvas * c; |
||
275 | TPad * pad2; |
||
276 | TPad * VirtualPad2[max]; |
||
277 | TH3D * h; |
||
278 | TH2D * slice[max]; //take the right slice from 3D histogram |
||
279 | TH1D * p[max]; |
||
280 | |||
281 | /********** GLOBALNE **********/ |
||
282 | gStyle->SetOptStat(0); |
||
283 | //gStyle->SetOptTitle(1); |
||
284 | gStyle->SetTitleFontSize(.15); |
||
285 | |||
286 | |||
287 | |||
288 | int line = 1; |
||
289 | |||
290 | for(int HAPDnumber=0;HAPDnumber<4;HAPDnumber++){ |
||
291 | HAPDserialNumber = strsep(&serialNumberTemp,","); |
||
292 | if(!strcmp(HAPDserialNumber,"noserial")) continue; |
||
293 | |||
294 | sprintf(hname,"hxy%d_0;1",HAPDnumber); |
||
295 | printf("%s \t %s \n",HAPDserialNumber,hname); |
||
296 | |||
297 | h = (TH3D *) data[0]->Get(hname); |
||
298 | |||
299 | /********** SMER MERITVE **********/ |
||
300 | h->GetZaxis()->SetRange(1,1); |
||
301 | nx = h->GetNbinsX(); |
||
302 | ny = h->GetNbinsY(); |
||
303 | if (nx>=ny) direction = 0; |
||
304 | else direction = 1; |
||
305 | |||
306 | printf("Direction = %d\n", direction); |
||
307 | |||
308 | /********** CANVAS **********/ |
||
309 | if (!direction) { |
||
310 | sprintf(buf,"%04d_%s_px",runNumber,HAPDserialNumber); |
||
311 | c = new TCanvas(buf,buf,0,0,500,2000); |
||
312 | } else { |
||
313 | sprintf(buf,"%04d_%s_py",runNumber,HAPDserialNumber); |
||
314 | c = new TCanvas(buf,buf,0,0,2000,2000); |
||
315 | } |
||
316 | pad2 = new TPad("pad2","Graphs",0,0,1,1,0,0); |
||
317 | pad2->SetFillStyle(4000); |
||
318 | pad2->Draw(); |
||
319 | |||
320 | /********** PAD2 **********/ |
||
321 | pad2->cd(); |
||
322 | pad2->Divide(1,max,0,0); |
||
323 | |||
324 | for (int i=0;i<max;i++) { |
||
325 | if(i) h = (TH3D *) data[i]->Get(hname); |
||
326 | |||
327 | pad2->cd(i+1); |
||
328 | VirtualPad2[i] = (TPad *)(pad2->cd(i+1)); //Tole nastaviš zato, da lahko daš Log skalo |
||
329 | VirtualPad2[i]->SetLogy(1); |
||
330 | //VirtualPad2[i]->SetLeftMargin(.05); |
||
331 | //VirtualPad2[i]->SetRightMargin(.05); |
||
332 | //VirtualPad2[i]->SetGrid(); |
||
333 | |||
334 | for (int j=4;j<8;j++) { |
||
335 | if (!direction) h->GetZaxis()->SetRange(m.koordinatniSistem[j][line+4]+1,m.koordinatniSistem[j][line+4]+1); |
||
336 | else h->GetZaxis()->SetRange(m.koordinatniSistem[line+4][j]+1,m.koordinatniSistem[line+4][j]+1); |
||
337 | |||
338 | slice[j] = (TH2D *)h->Project3D("pyx"); |
||
339 | |||
340 | if (!direction) { |
||
341 | sprintf(name,"PX: (%d,%d)",j,line+4); |
||
342 | p[j] = slice[j]->ProjectionX(name,line+1,line+1); |
||
343 | sprintf(name,"Z = %d Projection X of row %d",(runNumber-10+i)*1000,line+4); |
||
344 | } else { |
||
345 | sprintf(name,"PY: (%d,%d)",line+4,j); |
||
346 | p[j] = slice[j]->ProjectionY(name,line+1,line+1); |
||
347 | sprintf(name,"Z = %d Projection Y of column %d",(runNumber-10+i)*1000,line+4); |
||
348 | } |
||
349 | |||
350 | p[j]->SetLineWidth(1); |
||
351 | |||
352 | p[j]->SetTitle(name); |
||
353 | p[j]->SetTitleOffset(1.5); |
||
354 | |||
355 | p[j]->GetYaxis()->SetRangeUser(1,10000); |
||
356 | p[j]->GetYaxis()->SetTickLength(0.01); |
||
357 | p[j]->GetYaxis()->SetTitleFont(vrstaPisave); |
||
358 | p[j]->GetYaxis()->SetLabelFont(vrstaPisave); |
||
359 | p[j]->GetYaxis()->SetLabelSize(0.05); |
||
360 | p[j]->GetYaxis()->SetLabelColor(kBlack); |
||
361 | p[j]->GetYaxis()->SetTitle("# events"); |
||
362 | p[j]->GetYaxis()->SetNdivisions(0); |
||
363 | p[j]->GetYaxis()->CenterTitle(); |
||
364 | p[j]->GetYaxis()->SetTitleSize(0.05); |
||
365 | p[j]->GetYaxis()->SetTitleOffset(.5); |
||
366 | p[j]->GetYaxis()->SetTitleColor(kWhite); |
||
367 | |||
368 | p[j]->GetXaxis()->SetTickLength(0.1); |
||
369 | p[j]->GetXaxis()->SetTitleFont(vrstaPisave); |
||
370 | p[j]->GetXaxis()->SetLabelFont(vrstaPisave); |
||
371 | p[j]->GetXaxis()->SetLabelSize(0.15); |
||
372 | p[j]->GetXaxis()->SetLabelColor(kBlack); |
||
373 | p[j]->GetXaxis()->SetLabelOffset(.05); |
||
374 | p[j]->GetXaxis()->SetTitle("Incident light position (stage step)"); |
||
375 | //p[j]->GetXaxis()->SetNdivisions(0); |
||
376 | //p[j]->GetXaxis()->CenterTitle(); |
||
377 | p[j]->GetXaxis()->SetTitleSize(0.01); |
||
378 | p[j]->GetXaxis()->SetTitleColor(kWhite); //zato ker ga ne moreš pozicionirat |
||
379 | p[j]->GetXaxis()->SetTitleOffset(.5); |
||
380 | |||
381 | pNoise = noise(p[j]); |
||
382 | for (int k=1;k<=p[j]->GetSize();k++) p[j]->SetBinContent(k,p[j]->GetBinContent(k)-pNoise); |
||
383 | |||
384 | if (j<6) p[j]->SetLineColor(kWhite+color[j]); |
||
385 | else p[j]->SetLineColor(kWhite+color[j-6]); |
||
386 | if (j==4) p[j]->DrawCopy(); |
||
387 | else p[j]->DrawCopy("SAME"); |
||
388 | } |
||
389 | if(i==max-1) VirtualPad2[max-1]->SetBottomMargin(.17); |
||
390 | |||
391 | } |
||
392 | c->Modified(); |
||
393 | c->Update(); |
||
394 | if (save==1){ |
||
395 | switch (direction) { |
||
396 | case 0: sprintf(pdfname,"./meritve/%s_4_2DX_focus2_run%04d_to%04d.pdf",HAPDserialNumber,runNumber,runNumber+max-1);break; |
||
397 | case 1: sprintf(pdfname,"./meritve/%s_5_2DY_focus2_run%04d_to%04d.pdf",HAPDserialNumber,runNumber,runNumber+max-1);break; |
||
398 | } |
||
399 | c->SaveAs(pdfname,"pdf"); |
||
400 | } else if (save==2){ |
||
401 | switch (direction) { |
||
402 | case 0: sprintf(pdfname,"./meritve/%s_4_2DX_focus2.pdf(",HAPDserialNumber);break; |
||
403 | case 1: sprintf(pdfname,"./meritve/%s_5_2DY_focus2.pdf(",HAPDserialNumber);break; |
||
404 | } |
||
405 | c->SaveAs(pdfname,"pdf"); |
||
406 | } else if (save==3){ |
||
407 | switch (direction) { |
||
408 | case 0: sprintf(pdfname,"./meritve/%s_4_2DX_focus2.pdf",HAPDserialNumber);break; |
||
409 | case 1: sprintf(pdfname,"./meritve/%s_5_2DY_focus2.pdf",HAPDserialNumber);break; |
||
410 | } |
||
411 | c->SaveAs(pdfname,"pdf"); |
||
412 | } else if (save==4){ |
||
413 | switch (direction) { |
||
414 | case 0: sprintf(pdfname,"./meritve/%s_4_2DX_focus2.pdf)",HAPDserialNumber);break; |
||
415 | case 1: sprintf(pdfname,"./meritve/%s_5_2DY_focus2.pdf)",HAPDserialNumber);break; |
||
416 | } |
||
417 | c->SaveAs(pdfname,"pdf"); |
||
418 | } |
||
419 | } |
||
420 | |||
421 | return 0; |
||
422 | } |
||
423 | |||
424 | int focus3(int runNumber, int save) { |
||
425 | |||
426 | int HAPDnumber; //Number of HAPD: 0, 1, 2 or 3! |
||
427 | |||
428 | int direction, nx, ny; |
||
429 | char name[128]; |
||
430 | char pdfname[128]; |
||
431 | char buf[256]; |
||
432 | float pNoise; |
||
433 | int color[6] = {1,2,4,6,8,9}; |
||
434 | |||
435 | char hname[0xF]; |
||
436 | |||
437 | const char * serialNumber = getSN(); |
||
438 | char * serialNumberTemp = strdup(serialNumber); |
||
439 | char * HAPDserialNumber; |
||
440 | |||
441 | GRID m = mapping(); |
||
442 | int vrstaPisave = 82; |
||
443 | |||
444 | TCanvas * c; |
||
445 | TPad * pad1, * pad2, * pad3; |
||
446 | TPad * VirtualPad2[12]; |
||
447 | TPaveText * info, * axisName; |
||
448 | TAxis * axis; |
||
449 | TH3D * h; |
||
450 | TH2D * slice[12]; //take the right slice from 3D histogram |
||
451 | TH1D * p[12]; |
||
452 | |||
453 | /********** GLOBALNE **********/ |
||
454 | gStyle->SetOptStat(0); |
||
455 | //gStyle->SetOptTitle(1); |
||
456 | gStyle->SetTitleFontSize(.15); |
||
457 | |||
458 | for(int HAPDnumber=0;HAPDnumber<4;HAPDnumber++){ |
||
459 | HAPDserialNumber = strsep(&serialNumberTemp,","); |
||
460 | if(!strcmp(HAPDserialNumber,"noserial")) continue; |
||
461 | |||
462 | sprintf(hname,"hxy%d_0;1",HAPDnumber); |
||
463 | printf("%s \t %s \n",HAPDserialNumber,hname); |
||
464 | |||
465 | h = (TH3D *) gDirectory->Get(hname); |
||
466 | |||
467 | /********** SMER MERITVE **********/ |
||
468 | h->GetZaxis()->SetRange(1,1); |
||
469 | nx = h->GetNbinsX(); |
||
470 | ny = h->GetNbinsY(); |
||
471 | if (nx>=ny) direction = 0; |
||
472 | else direction = 1; |
||
473 | |||
474 | printf("Direction = %d\n", direction); |
||
475 | |||
476 | /********** CANVAS **********/ |
||
477 | if (!direction) { |
||
478 | sprintf(buf,"%04d_%s_px",runNumber,HAPDserialNumber); |
||
479 | c = new TCanvas(buf,buf,0,0,700,700); |
||
480 | } else { |
||
481 | sprintf(buf,"%04d_%s_py",runNumber,HAPDserialNumber); |
||
482 | c = new TCanvas(buf,buf,0,0,700,700); |
||
483 | } |
||
484 | pad1 = new TPad("pad1","Title",0.05,0.94,0.95,1,0,0); |
||
485 | pad1->SetFillStyle(4000); |
||
486 | pad1->Draw(); |
||
487 | |||
488 | pad2 = new TPad("pad2","Graphs",0,0,1,0.95,0,0); |
||
489 | pad2->SetFillStyle(4000); |
||
490 | pad2->Draw(); |
||
491 | |||
492 | pad3 = new TPad("pad3","AxisTitle",0.57,0,0.92,0.05,0,0); |
||
493 | pad3->SetFillStyle(4000); |
||
494 | pad3->Draw(); |
||
495 | |||
496 | /********** PAD 1 **********/ |
||
497 | pad1->cd(); |
||
498 | info = new TPaveText(0.2,0,0.8,1,"ndc"); |
||
499 | info->SetBorderSize(0); |
||
500 | info->SetFillColor(4000); |
||
501 | info->SetTextSize(1); |
||
502 | info->SetTextAlign(22); |
||
503 | |||
504 | sprintf(name,"HAPD# %s (center)", HAPDserialNumber); |
||
505 | info->AddText(name); |
||
506 | info->Draw(); |
||
507 | |||
508 | /********** PAD3 **********/ |
||
509 | pad3->cd(); |
||
510 | axisName = new TPaveText(0.2,0,0.8,1,"ndc"); |
||
511 | axisName->SetBorderSize(0); |
||
512 | axisName->SetFillColor(4000); |
||
513 | axisName->SetTextSize(.7); |
||
514 | axisName->SetTextFont(vrstaPisave); |
||
515 | axisName->SetTextAlign(22); |
||
516 | |||
517 | sprintf(name,"Incident light position (stage step)"); |
||
518 | axisName->AddText(name); |
||
519 | //axisName->Draw(); |
||
520 | |||
521 | /********** PAD2 **********/ |
||
522 | pad2->cd(); |
||
523 | pad2->Divide(1,4,0,0); |
||
524 | |||
525 | h = (TH3D *) gDirectory->Get(hname); |
||
526 | |||
527 | for (int i=4;i<8;i++) { |
||
528 | if (!direction) { |
||
529 | pad2->cd(11 - i+1-4); |
||
530 | VirtualPad2[11 - i-4] = (TPad *)(pad2->cd(11 - i+1-4)); //Tole nastaviš zato, da lahko daš Log skalo |
||
531 | VirtualPad2[11 - i-4]->SetLogy(1); |
||
532 | //VirtualPad2[11 - i]->SetLeftMargin(.05); |
||
533 | //VirtualPad2[11 - i]->SetRightMargin(.05); |
||
534 | VirtualPad2[11 - i-4]->SetGrid(); |
||
535 | } else { |
||
536 | pad2->cd(i+1-4); |
||
537 | VirtualPad2[i-4] = (TPad *)(pad2->cd(11 - i+1 - 4)); //Tole nastaviš zato, da lahko daš Log skalo |
||
538 | VirtualPad2[i-4]->SetLogy(1); |
||
539 | //VirtualPad2[i]->SetLeftMargin(.05); |
||
540 | //VirtualPad2[i]->SetRightMargin(.05); |
||
541 | VirtualPad2[i-4]->SetGrid(); |
||
542 | } |
||
543 | for (int j=4;j<8;j++) { |
||
544 | if (!direction) h->GetZaxis()->SetRange(m.koordinatniSistem[j][i]+1,m.koordinatniSistem[j][i]+1); |
||
545 | else h->GetZaxis()->SetRange(m.koordinatniSistem[i][j]+1,m.koordinatniSistem[i][j]+1); |
||
546 | |||
547 | slice[j] = (TH2D *)h->Project3D("pyx"); |
||
548 | |||
549 | if (!direction) { |
||
550 | sprintf(name,"PX: (%d,%d)",j,i); |
||
551 | p[j] = slice[j]->ProjectionX(name,i+1-4,i+1-4); |
||
552 | sprintf(name,"Projection X of row %d",i); |
||
553 | } else { |
||
554 | sprintf(name,"PY: (%d,%d)",i,j); |
||
555 | p[j] = slice[j]->ProjectionY(name,i+1-4,i+1-4); |
||
556 | sprintf(name,"Projection Y of column %d",i); |
||
557 | } |
||
558 | axis = p[j]->GetXaxis(); |
||
559 | |||
560 | |||
561 | if(!direction) VirtualPad2[3]->SetBottomMargin(.17); |
||
562 | else VirtualPad2[0]->SetBottomMargin(.17); |
||
563 | |||
564 | p[j]->SetLineWidth(1); |
||
565 | |||
566 | p[j]->SetTitle(name); |
||
567 | p[j]->SetTitleOffset(1.5); |
||
568 | |||
569 | p[j]->GetYaxis()->SetRangeUser(1,10000); |
||
570 | p[j]->GetYaxis()->SetTickLength(0.01); |
||
571 | p[j]->GetYaxis()->SetTitleFont(vrstaPisave); |
||
572 | p[j]->GetYaxis()->SetLabelFont(vrstaPisave); |
||
573 | p[j]->GetYaxis()->SetLabelSize(0.05); |
||
574 | p[j]->GetYaxis()->SetLabelColor(kBlack); |
||
575 | p[j]->GetYaxis()->SetTitle("# events"); |
||
576 | p[j]->GetYaxis()->SetNdivisions(0); |
||
577 | p[j]->GetYaxis()->CenterTitle(); |
||
578 | p[j]->GetYaxis()->SetTitleSize(0.05); |
||
579 | p[j]->GetYaxis()->SetTitleOffset(.5); |
||
580 | p[j]->GetYaxis()->SetTitleColor(kWhite); |
||
581 | |||
582 | p[j]->GetXaxis()->SetTickLength(0.1); |
||
583 | p[j]->GetXaxis()->SetTitleFont(vrstaPisave); |
||
584 | p[j]->GetXaxis()->SetLabelFont(vrstaPisave); |
||
585 | p[j]->GetXaxis()->SetLabelSize(0.15); |
||
586 | p[j]->GetXaxis()->SetLabelColor(kBlack); |
||
587 | p[j]->GetXaxis()->SetLabelOffset(.05); |
||
588 | p[j]->GetXaxis()->SetTitle("Incident light position (stage step)"); |
||
589 | //p[j]->GetXaxis()->SetNdivisions(0); |
||
590 | //p[j]->GetXaxis()->CenterTitle(); |
||
591 | p[j]->GetXaxis()->SetTitleSize(0.01); |
||
592 | p[j]->GetXaxis()->SetTitleColor(kWhite); //zato ker ga ne moreš pozicionirat |
||
593 | p[j]->GetXaxis()->SetTitleOffset(.5); |
||
594 | |||
595 | pNoise = noise(p[j]); |
||
596 | for (int k=1;k<=p[j]->GetSize();k++) p[j]->SetBinContent(k,p[j]->GetBinContent(k)-pNoise); |
||
597 | |||
598 | if (j<6) p[j]->SetLineColor(kWhite+color[j]); |
||
599 | else p[j]->SetLineColor(kWhite+color[j-6]); |
||
600 | if (j==4) p[j]->DrawCopy(); |
||
601 | else p[j]->DrawCopy("SAME"); |
||
602 | } |
||
603 | } |
||
604 | c->Modified(); |
||
605 | c->Update(); |
||
606 | if (save==1){ |
||
607 | switch (direction) { |
||
608 | case 0: sprintf(pdfname,"./meritve/%03d_%s_4_2DX_focus3.pdf",runNumber,HAPDserialNumber);break; |
||
609 | case 1: sprintf(pdfname,"./meritve/%03d_%s_5_2DY_focus3.pdf",runNumber,HAPDserialNumber);break; |
||
610 | } |
||
611 | c->SaveAs(pdfname,"pdf"); |
||
612 | } else if (save==2){ |
||
613 | switch (direction) { |
||
614 | case 0: sprintf(pdfname,"./meritve/%s_4_2DX_focus3.pdf(",HAPDserialNumber);break; |
||
615 | case 1: sprintf(pdfname,"./meritve/%s_5_2DY_focus3.pdf(",HAPDserialNumber);break; |
||
616 | } |
||
617 | c->SaveAs(pdfname,"pdf"); |
||
618 | } else if (save==3){ |
||
619 | switch (direction) { |
||
620 | case 0: sprintf(pdfname,"./meritve/%s_4_2DX_focus3.pdf",HAPDserialNumber);break; |
||
621 | case 1: sprintf(pdfname,"./meritve/%s_5_2DY_focus3.pdf",HAPDserialNumber);break; |
||
622 | } |
||
623 | c->SaveAs(pdfname,"pdf"); |
||
624 | } else if (save==4){ |
||
625 | switch (direction) { |
||
626 | case 0: sprintf(pdfname,"./meritve/%s_4_2DX_focus3.pdf)",HAPDserialNumber);break; |
||
627 | case 1: sprintf(pdfname,"./meritve/%s_5_2DY_focus3.pdf)",HAPDserialNumber);break; |
||
628 | } |
||
629 | c->SaveAs(pdfname,"pdf"); |
||
630 | } |
||
631 | } |
||
632 | |||
633 | return 0; |
||
634 | } |
||
635 | |||
636 | float noise(TH1D * proj) { |
||
637 | float nBin=proj->GetSize(); //ugotovi koliko binov je v histogramu |
||
638 | float wholeAverage=0; //sem da povprečje celotnega kanala |
||
639 | float noise=0; //sem da povprečn šum |
||
640 | int j=0; |
||
641 | for (int i=1;i<=nBin;i++) wholeAverage+=proj->GetBinContent(i)/nBin; |
||
642 | for (int i=1;i<=nBin;i++) { |
||
643 | if (proj->GetBinContent(i)<1.1*wholeAverage) { |
||
644 | noise+=proj->GetBinContent(i); |
||
645 | j++; |
||
646 | } |
||
647 | } |
||
648 | if(j!=0) return noise/j; |
||
649 | else return 0; |
||
650 | } |