]>
Commit | Line | Data |
---|---|---|
79de2f45 | 1 | /* $Id$ */ |
2 | ||
3 | ||
4 | #if !defined(__CINT__) | |
5 | #include "TControlBar.h" | |
6 | #include "TString.h" | |
7 | #include "TRandom.h" | |
8 | #include "TH1F.h" | |
9 | #include "TF1.h" | |
10 | #include "TCanvas.h" | |
11 | ||
12 | #include "AliRun.h" | |
13 | #include "AliT0CalibData.h" | |
14 | #include "AliT0AlignData.h" | |
15 | #include "AliCDBMetaData.h" | |
16 | #include "AliCDBId.h" | |
17 | #include "AliCDBEntry.h" | |
18 | #include "AliCDBManager.h" | |
19 | #include "AliCDBStorage.h" | |
20 | #endif | |
21 | TFile *gFile=0; | |
22 | ||
23 | void AliT0CalibViewer() | |
24 | { | |
25 | TControlBar *menu = new TControlBar("vertical","T0 CalibViewer"); | |
26 | menu->AddButton("Open file","OpenFile()", | |
27 | "Open file"); | |
28 | menu->AddButton("Draw CFD","DrawCFD()", | |
29 | "Draw all CFD"); | |
30 | menu->AddButton("Draw LED","DrawLED()", | |
31 | "Draw all LED"); | |
32 | menu->AddButton("Draw LED-CFD","DrawLEDminCFD()", | |
33 | "Draw LED-CFD"); | |
34 | menu->AddButton("Draw QTC","DrawQTC()", | |
35 | "Draw all QTC"); | |
36 | menu->AddButton("Draw CFDvsQTC","DrawCFDvsQTC()", | |
37 | "Draw CFD vs QTC"); | |
38 | menu->AddButton("Draw CFDvsLED","DrawCFDvsLED()", | |
39 | "Draw CFD vs LED-CFD"); | |
dd08026e | 40 | menu->AddButton("Draw Walk","DrawWalk()", |
41 | "Draw CFD vs LED-CFD"); | |
79de2f45 | 42 | menu->Show(); |
43 | } | |
44 | void OpenFile() | |
45 | { | |
46 | ||
47 | const char *ft[]={"T0 raw files","t0tree*.root","All files","*",0,0}; | |
48 | TString dir("."); | |
49 | TGFileInfo fi; fi.fFileTypes=ft; fi.fIniDir=StrDup(dir); | |
50 | new TGFileDialog(gClient->GetRoot(), 0x0, kFDOpen, &fi); | |
51 | ||
52 | if(!fi.fFilename) return; | |
53 | if(gFile){ gFile->Close(); gFile=0;} | |
54 | ||
55 | gFile=TFile::Open(fi.fFilename); | |
56 | ||
57 | } | |
58 | ||
59 | //------------------------------------------------------------------------ | |
60 | void DrawCFD() | |
61 | { | |
62 | Int_t npeaks = 20; | |
63 | Int_t sigma=3.; | |
64 | Bool_t down=false; | |
65 | Int_t index[20]; | |
66 | ||
dd08026e | 67 | TCanvas *c1 = new TCanvas("c1", "CFD C side",0,48,1280,951); |
79de2f45 | 68 | c1->Divide(4,3); |
69 | gStyle->SetOptFit(1111); | |
70 | //c1->Divide(2,2); | |
71 | Char_t buf1[10]; | |
72 | for (Int_t i=0; i<12; i++) | |
73 | { | |
74 | c1->cd(i+1); | |
75 | sprintf(buf1,"T0_C_%i_CFD",i+1); | |
76 | TH1F *cfd = (TH1F*) gFile->Get(buf1); | |
dd08026e | 77 | // cfd->Draw(); |
78 | ||
79de2f45 | 79 | TSpectrum *s = new TSpectrum(2*npeaks,1); |
80 | Int_t nfound = s->Search(cfd,sigma," ",0.05); | |
81 | cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;; | |
82 | if(nfound!=0){ | |
83 | Float_t *xpeak = s->GetPositionX(); | |
84 | TMath::Sort(nfound, xpeak, index,down); | |
dd08026e | 85 | Float_t xp = xpeak[index[0]]; |
86 | cout<<" index[0] "<<index[0]<<endl; | |
87 | // Float_t xp = xpeak[1]; | |
79de2f45 | 88 | Int_t xbin = cfd->GetXaxis()->FindBin(xp); |
89 | Float_t yp = cfd->GetBinContent(xbin); | |
90 | cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[1]<<"\typeak = "<<yp<<endl; | |
91 | Float_t hmax = xp+3*sigma; | |
92 | Float_t hmin = xp-3*sigma; | |
93 | cout<<hmin<< " "<<hmax<<endl; | |
dd08026e | 94 | cfd->GetXaxis()->SetRange(hmin-10,hmax+10); |
95 | cout<<" cfd range "<<hmin-10<<" "<<hmax+10<<endl; | |
96 | cfd->GetXaxis()->SetLabelSize(0.03); | |
79de2f45 | 97 | TF1 *g1 = new TF1("g1", "gaus", hmin, hmax); |
dd08026e | 98 | cfd->Fit("g1","R"); |
99 | // cfd->Draw(); | |
100 | ||
79de2f45 | 101 | } |
dd08026e | 102 | |
79de2f45 | 103 | } |
dd08026e | 104 | TCanvas *c2 = new TCanvas("c2", "CFD A side",0,48,1280,951); |
105 | c2->Divide(4,3); | |
106 | gStyle->SetOptFit(1111); | |
107 | //c1->Divide(2,2); | |
108 | Char_t buf1[10]; | |
109 | for (Int_t i=0; i<12; i++) | |
110 | { | |
111 | c2->cd(i+1); | |
112 | sprintf(buf1,"T0_A_%i_CFD",i+1); | |
113 | TH1F *cfd = (TH1F*) gFile->Get(buf1); | |
114 | // cfd->Draw(); | |
115 | ||
116 | TSpectrum *s = new TSpectrum(2*npeaks,1); | |
117 | Int_t nfound = s->Search(cfd,sigma," ",0.05); | |
118 | cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;; | |
119 | if(nfound!=0){ | |
120 | Float_t *xpeak = s->GetPositionX(); | |
121 | TMath::Sort(nfound, xpeak, index,down); | |
122 | Float_t xp = xpeak[index[0]]; | |
123 | cout<<" index[0] "<<index[0]<<endl; | |
124 | // Float_t xp = xpeak[1]; | |
125 | Int_t xbin = cfd->GetXaxis()->FindBin(xp); | |
126 | Float_t yp = cfd->GetBinContent(xbin); | |
127 | cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[1]<<"\typeak = "<<yp<<endl; | |
128 | Float_t hmax = xp+3*sigma; | |
129 | Float_t hmin = xp-3*sigma; | |
130 | cout<<hmin<< " "<<hmax<<endl; | |
131 | cfd->GetXaxis()->SetRange(hmin-10,hmax+10); | |
132 | cout<<" cfd range "<<hmin-10<<" "<<hmax+10<<endl; | |
133 | cfd->GetXaxis()->SetLabelSize(0.03); | |
134 | TF1 *g1 = new TF1("g1", "gaus", hmin, hmax); | |
135 | cfd->Fit("g1","R"); | |
136 | // cfd->Draw(); | |
137 | ||
138 | } | |
139 | ||
140 | } | |
141 | ||
79de2f45 | 142 | } |
143 | //------------------------------------------------------------------------ | |
144 | void DrawLED() | |
145 | { | |
146 | Int_t npeaks = 10; | |
147 | Int_t sigma=10.; | |
148 | Bool_t down=false; | |
149 | Int_t index[20]; | |
150 | ||
dd08026e | 151 | TCanvas *c1 = new TCanvas("c1", "LED C side",0,48,1280,951); |
79de2f45 | 152 | c1->Divide(4,3); |
153 | ||
154 | Char_t buf1[20]; | |
155 | for (Int_t i=0; i<12; i++) | |
156 | { | |
157 | c1->cd(i+1); | |
158 | sprintf(buf1,"T0_C_%i_LED",i+1); | |
159 | TH1F *cfd = (TH1F*) gFile->Get(buf1); | |
dd08026e | 160 | TSpectrum *s = new TSpectrum(2*npeaks,1); |
161 | Int_t nfound = s->Search(cfd,sigma," ",0.2); | |
162 | cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;; | |
163 | if(nfound!=0) { | |
164 | Float_t *xpeak = s->GetPositionX(); | |
165 | TMath::Sort(nfound, xpeak, index,down); | |
166 | Float_t xp = xpeak[index[0]]; | |
167 | Int_t xbin = cfd->GetXaxis()->FindBin(xp); | |
168 | Float_t yp = cfd->GetBinContent(xbin); | |
169 | cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[index[0]]<<"\typeak = "<<yp<<endl; | |
170 | Float_t hmin=xp-3*sigma; | |
171 | Float_t hmax =xp+3*sigma; | |
172 | cfd->GetXaxis()->SetRange(hmin,hmax); | |
173 | cfd->GetXaxis()->SetLabelSize(0.03); | |
174 | TF1 *g1 = new TF1("g1", "gaus", hmin, hmax); | |
175 | cfd->Fit("g1","R"); | |
176 | // cfd->Draw(); | |
177 | ||
178 | } | |
179 | ||
180 | } | |
181 | TCanvas *c2 = new TCanvas("c2", "LED A side",0,48,1280,951); | |
182 | c2->Divide(4,3); | |
183 | ||
184 | Char_t buf1[20]; | |
185 | for (Int_t i=0; i<12; i++) | |
186 | { | |
187 | c2->cd(i+1); | |
188 | sprintf(buf1,"T0_A_%i_LED",i+1); | |
189 | TH1F *cfd = (TH1F*) gFile->Get(buf1); | |
190 | ||
79de2f45 | 191 | TSpectrum *s = new TSpectrum(2*npeaks,1); |
192 | Int_t nfound = s->Search(cfd,sigma," ",0.2); | |
193 | cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;; | |
194 | if(nfound!=0) { | |
195 | Float_t *xpeak = s->GetPositionX(); | |
196 | TMath::Sort(nfound, xpeak, index,down); | |
197 | Float_t xp = xpeak[index[0]]; | |
198 | Int_t xbin = cfd->GetXaxis()->FindBin(xp); | |
199 | Float_t yp = cfd->GetBinContent(xbin); | |
200 | cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[index[0]]<<"\typeak = "<<yp<<endl; | |
201 | Float_t hmin=xp-3*sigma; | |
202 | Float_t hmax =xp+3*sigma; | |
203 | cfd->GetXaxis()->SetRange(hmin,hmax); | |
dd08026e | 204 | cfd->GetXaxis()->SetLabelSize(0.03); |
79de2f45 | 205 | TF1 *g1 = new TF1("g1", "gaus", hmin, hmax); |
206 | cfd->Fit("g1","R"); | |
207 | // cfd->Draw(); | |
208 | ||
209 | } | |
210 | ||
211 | } | |
212 | } | |
213 | ||
214 | //------------------------------------------------------------------------ | |
215 | void DrawQTC() | |
216 | { | |
217 | ||
dd08026e | 218 | TCanvas *c1 = new TCanvas("c1", "QTC C side",0,48,1280,951); |
219 | c1->Divide(4,3); | |
220 | // c1->Divide(2,3); | |
79de2f45 | 221 | |
222 | Char_t buf1[10]; | |
223 | for (Int_t i=0; i<12; i++) | |
224 | { | |
225 | c1->cd(i+1); | |
226 | sprintf(buf1,"QTC%i",i+1); | |
dd08026e | 227 | |
79de2f45 | 228 | TH1F *qtc = (TH1F*) gFile->Get(buf1); |
dd08026e | 229 | |
230 | Float_t mean = qtc->GetMean(); | |
231 | Float_t rms = qtc->GetRMS(); | |
232 | Float_t hminR=mean - 0.1*mean; | |
233 | Float_t hmaxR =mean + 0.1*mean; | |
234 | qtc->GetXaxis()->SetRange(hminR,hmaxR); | |
235 | Float_t hmin=mean - 3*rms; | |
236 | Float_t hmax =mean + 3*rms; | |
237 | qtc->GetXaxis()->SetRange(hmin,hmax); | |
238 | ||
239 | // TF1 *g2 = new TF1("g2", "gaus", hmin, hmax); | |
240 | // qtc->Fit("g2","RQ"); | |
241 | qtc->GetXaxis()->SetLabelSize(0.03); | |
242 | ||
243 | qtc->Draw(); | |
244 | } | |
245 | ||
246 | TCanvas *c2 = new TCanvas("c2", "QTC A side",0,48,1280,951); | |
247 | c2->Divide(4,3); | |
248 | // c1->Divide(2,3); | |
249 | ||
250 | Char_t buf1[10]; | |
251 | for (Int_t i=12; i<24; i++) | |
252 | { | |
253 | c2->cd(i+1-12); | |
254 | sprintf(buf1,"QTC%i",i+1); | |
255 | ||
256 | TH1F *qtc = (TH1F*) gFile->Get(buf1); | |
257 | ||
79de2f45 | 258 | Float_t mean = qtc->GetMean(); |
259 | Float_t rms = qtc->GetRMS(); | |
260 | Float_t hminR=mean - 0.1*mean; | |
261 | Float_t hmaxR =mean + 0.1*mean; | |
262 | qtc->GetXaxis()->SetRange(hminR,hmaxR); | |
263 | Float_t hmin=mean - 3*rms; | |
264 | Float_t hmax =mean + 3*rms; | |
265 | qtc->GetXaxis()->SetRange(hmin,hmax); | |
266 | // TF1 *g2 = new TF1("g2", "gaus", hmin, hmax); | |
267 | // qtc->Fit("g2","RQ"); | |
dd08026e | 268 | qtc->GetXaxis()->SetLabelSize(0.03); |
269 | ||
79de2f45 | 270 | qtc->Draw(); |
271 | } | |
272 | ||
273 | ||
274 | } | |
275 | ||
276 | //------------------------------------------------------------------------ | |
277 | void DrawLEDminCFD() | |
278 | { | |
279 | Int_t npeaks = 10; | |
280 | Int_t sigma=10.; | |
281 | Bool_t down=false; | |
282 | Int_t index[20]; | |
283 | ||
dd08026e | 284 | TCanvas *c1 = new TCanvas("c1", " LED-CFD C side",0,48,1280,951); |
79de2f45 | 285 | c1->Divide(4,3); |
286 | ||
287 | Char_t buf1[20]; | |
288 | for (Int_t i=0; i<12; i++) | |
289 | { | |
290 | c1->cd(i+1); | |
dd08026e | 291 | sprintf(buf1,"LEDminCFD%i",i+1); |
292 | TH1F *cfd = (TH1F*) gFile->Get(buf1); | |
293 | cfd->Draw(); | |
294 | TSpectrum *s = new TSpectrum(2*npeaks,1); | |
295 | Int_t nfound = s->Search(cfd,sigma," ",0.2); | |
296 | cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;; | |
297 | if(nfound!=0) { | |
298 | Float_t *xpeak = s->GetPositionX(); | |
299 | TMath::Sort(nfound, xpeak, index,down); | |
300 | Float_t xp = xpeak[index[0]]; | |
301 | Int_t xbin = cfd->GetXaxis()->FindBin(xp); | |
302 | Float_t yp = cfd->GetBinContent(xbin); | |
303 | cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[index[0]]<<"\typeak = "<<yp<<endl; | |
304 | Float_t hmin=xp-3*sigma; | |
305 | Float_t hmax =xp+3*sigma; | |
306 | cfd->GetXaxis()->SetRange(hmin,hmax); | |
307 | TF1 *g1 = new TF1("g1", "gaus", hmin, hmax); | |
308 | cfd->Fit("g1","RQ"); | |
309 | ||
310 | ||
311 | } | |
312 | ||
313 | } | |
314 | TCanvas *c2 = new TCanvas("c2", "LED-CFD A side",0,48,1280,951); | |
315 | c2->Divide(4,3); | |
316 | ||
317 | Char_t buf1[20]; | |
318 | for (Int_t i=12; i<24; i++) | |
319 | { | |
320 | c2->cd(i+1-12); | |
321 | sprintf(buf1,"LEDminCFD%i",i+1); | |
79de2f45 | 322 | TH1F *cfd = (TH1F*) gFile->Get(buf1); |
323 | cfd->Draw(); | |
324 | TSpectrum *s = new TSpectrum(2*npeaks,1); | |
325 | Int_t nfound = s->Search(cfd,sigma," ",0.2); | |
326 | cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;; | |
327 | if(nfound!=0) { | |
328 | Float_t *xpeak = s->GetPositionX(); | |
329 | TMath::Sort(nfound, xpeak, index,down); | |
330 | Float_t xp = xpeak[index[0]]; | |
331 | Int_t xbin = cfd->GetXaxis()->FindBin(xp); | |
332 | Float_t yp = cfd->GetBinContent(xbin); | |
333 | cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[index[0]]<<"\typeak = "<<yp<<endl; | |
334 | Float_t hmin=xp-3*sigma; | |
335 | Float_t hmax =xp+3*sigma; | |
336 | cfd->GetXaxis()->SetRange(hmin,hmax); | |
337 | TF1 *g1 = new TF1("g1", "gaus", hmin, hmax); | |
338 | cfd->Fit("g1","RQ"); | |
339 | ||
340 | ||
341 | } | |
342 | ||
343 | } | |
344 | /* | |
345 | TCanvas *c1 = new TCanvas("c1", "c1",0,48,1280,951); | |
346 | c1->Divide(2,2); | |
347 | Char_t buf1[10]; | |
348 | for (Int_t i=0; i<4; i++) | |
349 | { | |
350 | c1->cd(i+1); | |
351 | sprintf(buf1,"LED-CFD%i",i+1); | |
352 | TH1F *cfd = (TH1F*) file->Get(buf1); | |
353 | // cout<<buf1<<" "<<cfd<<endl; | |
354 | // cfd->Draw(); | |
355 | // cfd->GetXaxis()->SetRange(0,100); | |
356 | Float_t mean = cfd->GetMean(); | |
357 | Float_t rms = cfd->GetRMS(); | |
358 | Float_t hmin=mean - 3*rms; | |
359 | Float_t hmax =mean + 3*rms; | |
360 | cfd->GetXaxis()->SetRange(hmin-10,hmax+10); | |
361 | cout<<" cfd range "<<mean<<" rms "<<rms<<" "<<hmin<<" "<<hmax<<endl; | |
362 | // TF1 *g1 = new TF1("g1", "gaus", hmin, hmax); | |
363 | // cfd->Fit("g1","RQ"); | |
364 | cfd->Draw(); | |
365 | } | |
366 | */ | |
367 | ||
368 | } | |
369 | //------------------------------------------------------------------------ | |
370 | void DrawCFDvsQTC() | |
371 | { | |
372 | Int_t npeaks = 20; | |
373 | Int_t sigma=3.; | |
374 | Bool_t down=false; | |
375 | ||
376 | Int_t index[20]; | |
377 | Char_t buf1[10], buf2[10]; | |
378 | ||
dd08026e | 379 | TCanvas *c1 = new TCanvas("c1", "CFD vs QTC C side",0,48,1280,951); |
380 | gStyle->SetOptStat(111111); | |
381 | c1->Divide(4,3); | |
382 | ||
383 | for (Int_t i=0; i<12; i++) | |
384 | { | |
385 | c1->cd(i+1); | |
386 | sprintf(buf1,"T0_C_%i_CFD",i+1); | |
387 | sprintf(buf2,"CFDvsQTC%i",i+1); | |
388 | cout<<buf1<<" "<<buf2<<endl; | |
389 | TH2F *qtc_cfd = (TH2F*) gFile->Get(buf2); | |
390 | TH1F *cfd = (TH1F*) gFile->Get(buf1); | |
391 | // cfd->Draw(); | |
392 | TSpectrum *s = new TSpectrum(2*npeaks,1); | |
393 | Int_t nfound = s->Search(cfd,sigma," ",0.05); | |
394 | cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;; | |
395 | if(nfound!=0){ | |
396 | Float_t *xpeak = s->GetPositionX(); | |
397 | TMath::Sort(nfound, xpeak, index,down); | |
398 | Float_t xp = xpeak[index[0]]; | |
399 | Int_t xbin = cfd->GetXaxis()->FindBin(xp); | |
400 | Float_t yp = cfd->GetBinContent(xbin); | |
401 | cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[1]<<"\typeak = "<<yp<<endl; | |
402 | Float_t hmax = xp+10*sigma; | |
403 | Float_t hmin = xp-10*sigma; | |
404 | cout<<hmin<< " "<<hmax<<endl; | |
405 | // cfd->GetXaxis()->SetRange(hmin,hmax); | |
406 | // TF1 *g1 = new TF1("g1", "gaus", hmin, hmax); | |
407 | // cfd->Fit("g1","R"); | |
408 | qtc_cfd->GetYaxis()->SetRange(hmin,hmax); | |
409 | qtc_cfd->Draw(); | |
410 | ||
411 | } | |
412 | ||
413 | } | |
414 | TCanvas *c2 = new TCanvas("c2", "CFD vs QTC A side",0,48,1280,951); | |
415 | gStyle->SetOptStat(111111); | |
416 | c2->Divide(4,3); | |
417 | ||
418 | for (Int_t i=12; i<24; i++) | |
419 | { | |
420 | c2->cd(i+1-12); | |
421 | sprintf(buf1,"T0_A_%i_CFD",i+1-12); | |
422 | sprintf(buf2,"CFDvsQTC%i",i+1); | |
423 | cout<<buf1<<" "<<buf2<<endl; | |
424 | TH2F *qtc_cfd = (TH2F*) gFile->Get(buf2); | |
425 | TH1F *cfd = (TH1F*) gFile->Get(buf1); | |
426 | // cfd->Draw(); | |
427 | TSpectrum *s = new TSpectrum(2*npeaks,1); | |
428 | Int_t nfound = s->Search(cfd,sigma," ",0.05); | |
429 | cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;; | |
430 | if(nfound!=0){ | |
431 | Float_t *xpeak = s->GetPositionX(); | |
432 | TMath::Sort(nfound, xpeak, index,down); | |
433 | Float_t xp = xpeak[index[0]]; | |
434 | Int_t xbin = cfd->GetXaxis()->FindBin(xp); | |
435 | Float_t yp = cfd->GetBinContent(xbin); | |
436 | cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[1]<<"\typeak = "<<yp<<endl; | |
437 | Float_t hmax = xp+10*sigma; | |
438 | Float_t hmin = xp-10*sigma; | |
439 | cout<<hmin<< " "<<hmax<<endl; | |
440 | // cfd->GetXaxis()->SetRange(hmin,hmax); | |
441 | // TF1 *g1 = new TF1("g1", "gaus", hmin, hmax); | |
442 | // cfd->Fit("g1","R"); | |
443 | qtc_cfd->GetYaxis()->SetRange(hmin,hmax); | |
444 | qtc_cfd->Draw(); | |
445 | ||
446 | } | |
447 | ||
448 | } | |
449 | ||
450 | ||
451 | ||
452 | } | |
453 | //------------------------------------------------------------------------ | |
454 | void DrawWalk() | |
455 | { | |
456 | Int_t npeaks = 20; | |
457 | Int_t sigma=3.; | |
458 | Bool_t down = false; | |
459 | ||
460 | Int_t index[20]; | |
461 | Char_t buf1[10], buf2[10]; | |
462 | ||
79de2f45 | 463 | TCanvas *c1 = new TCanvas("c1", "c1",0,48,1280,951); |
464 | gStyle->SetOptStat(0); | |
dd08026e | 465 | c1->Divide(4,3); |
79de2f45 | 466 | |
dd08026e | 467 | for (Int_t i=0; i<12; i++) |
79de2f45 | 468 | { |
469 | c1->cd(i+1); | |
470 | sprintf(buf1,"T0_C_%i_CFD",i+1); | |
471 | sprintf(buf2,"CFDvsQTC%i",i+1); | |
472 | cout<<buf1<<" "<<buf2<<endl; | |
473 | TH2F *qtc_cfd = (TH2F*) gFile->Get(buf2); | |
474 | TH1F *cfd = (TH1F*) gFile->Get(buf1); | |
475 | // cfd->Draw(); | |
476 | TSpectrum *s = new TSpectrum(2*npeaks,1); | |
477 | Int_t nfound = s->Search(cfd,sigma," ",0.05); | |
478 | cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;; | |
479 | if(nfound!=0){ | |
480 | Float_t *xpeak = s->GetPositionX(); | |
481 | TMath::Sort(nfound, xpeak, index,down); | |
482 | Float_t xp = xpeak[index[0]]; | |
483 | Int_t xbin = cfd->GetXaxis()->FindBin(xp); | |
484 | Float_t yp = cfd->GetBinContent(xbin); | |
485 | cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[1]<<"\typeak = "<<yp<<endl; | |
486 | Float_t hmax = xp+10*sigma; | |
487 | Float_t hmin = xp-10*sigma; | |
488 | cout<<hmin<< " "<<hmax<<endl; | |
489 | // cfd->GetXaxis()->SetRange(hmin,hmax); | |
490 | // TF1 *g1 = new TF1("g1", "gaus", hmin, hmax); | |
491 | // cfd->Fit("g1","R"); | |
492 | Int_t hminbin= qtc_cfd->GetXaxis()->GetFirst(); | |
493 | Int_t hmaxbin= qtc_cfd->GetXaxis()->GetLast(); | |
494 | Int_t nbins= qtc_cfd->GetXaxis()->GetNbins(); | |
495 | cout<<" qtc_cfd "<<hminbin<<" "<<hmaxbin<<" "<<nbins<<endl; | |
496 | // qtc_cfd->Draw(); | |
497 | TProfile *pr_y = qtc_cfd->ProfileX(); | |
dd08026e | 498 | Float_t maxHr=pr_y->GetBinCenter(hmaxbin); |
79de2f45 | 499 | |
500 | pr_y->SetMaximum(hmax); | |
501 | pr_y->SetMinimum(hmin); | |
502 | Int_t np=nbins/20; | |
503 | Double_t *xx = new Double_t[np]; | |
504 | Double_t *yy = new Double_t[np]; | |
505 | Int_t ng=0; | |
506 | Double_t yg=0; | |
507 | for (Int_t ip=1; ip<nbins; ip++) | |
508 | { | |
509 | if(ip%20 != 0 ) { | |
510 | if (pr_y->GetBinContent(ip) !=0) | |
511 | yg +=pr_y->GetBinContent(ip); | |
512 | // cout<<ng<<" "<<pr_y->GetBinContent(ip)<<" "<<yg<<endl; | |
513 | ng++;} | |
514 | else { | |
dd08026e | 515 | xx[ip/20] = Float_t (pr_y->GetBinCenter(ip)); |
79de2f45 | 516 | yy[ip/20] = yg/ng; |
517 | yg=0; | |
518 | ng=0; | |
dd08026e | 519 | cout<<ip<<" "<<ip/20<<" "<< xx[ip/20]<<" "<< yy[ip/20]<<endl; |
79de2f45 | 520 | } |
521 | } | |
dd08026e | 522 | TH2F *hr = new TH2F("hr"," ",np,0,maxHr, np, hmin, hmax); |
79de2f45 | 523 | hr->Draw(); |
524 | TGraph *gr = new TGraph(np,xx,yy); | |
525 | gr->SetMinimum(hmin); | |
526 | gr->SetMaximum(hmax); | |
527 | gr->SetMarkerStyle(20); | |
528 | gr->Draw("P"); | |
529 | // delete [] xx; | |
530 | // delete [] yy; | |
531 | ||
532 | // pr_y->Rebin(10); | |
533 | // pr_y->Draw(); | |
534 | ||
535 | } | |
536 | ||
537 | } | |
538 | ||
539 | ||
540 | } | |
541 | //------------------------------------------------------------------------ | |
542 | void DrawCFDvsLED() | |
543 | { | |
544 | Int_t runNumber=1098; | |
545 | ||
546 | Int_t npeaks = 20; | |
547 | Int_t sigma=2.; | |
548 | Char_t buf1[10], buf2[10]; | |
dd08026e | 549 | TCanvas *c1 = new TCanvas("c1", "c1",0,48,1280,951); |
550 | gStyle->SetOptStat(0); | |
551 | c1->Divide(4,3); | |
552 | for (Int_t i=0; i<12; i++) | |
79de2f45 | 553 | { |
dd08026e | 554 | c1->cd(i+1); |
79de2f45 | 555 | sprintf(buf1,"T0_C_%i_CFD",i+1); |
dd08026e | 556 | sprintf(buf2,"CFDvsLED%i",i+1); |
79de2f45 | 557 | |
558 | TH2F *qtc_cfd = (TH2F*) gFile->Get(buf2); | |
dd08026e | 559 | //qtc_cfd->Draw(); |
79de2f45 | 560 | TH1F *cfd = (TH1F*) gFile->Get(buf1); |
561 | // cfd->Draw(); | |
562 | TSpectrum *s = new TSpectrum(2*npeaks,1); | |
563 | Int_t nfound = s->Search(cfd,sigma," ",0.05); | |
564 | cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;; | |
565 | if(nfound!=0){ | |
566 | Double_t max=0.0; | |
567 | Double_t tabmax[2] = {0.0, 0.0}; | |
568 | Float_t *xpeak = s->GetPositionX(); | |
569 | for(Int_t k=0; k<1 ;k++) | |
570 | { | |
571 | Float_t xp = xpeak[k]; | |
572 | Int_t xbin = cfd->GetXaxis()->FindBin(xp); | |
573 | Float_t yp = cfd->GetBinContent(xbin); | |
574 | cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[k]<<"\typeak = "<<yp<<endl; | |
575 | } | |
576 | Float_t hmin=xp-10*sigma; | |
577 | Float_t hmax =xp+10*sigma; | |
578 | cout<<hmin<< " "<<hmax<<endl; | |
579 | // cfd->GetXaxis()->SetRange(hmin,hmax); | |
580 | // TF1 *g1 = new TF1("g1", "gaus", hmin, hmax); | |
581 | // cfd->Fit("g1","R"); | |
582 | Int_t hminbin= qtc_cfd->GetXaxis()->GetFirst(); | |
583 | Int_t hmaxbin= qtc_cfd->GetXaxis()->GetLast(); | |
584 | Int_t nbins= qtc_cfd->GetXaxis()->GetNbins(); | |
585 | cout<<" qtc_cfd "<<hminbin<<" "<<hmaxbin<<" "<<nbins<<endl; | |
dd08026e | 586 | qtc_cfd->Draw(); |
587 | /*TProfile *pr_y = qtc_cfd->ProfileX(); | |
79de2f45 | 588 | |
589 | pr_y->SetMaximum(hmax); | |
590 | pr_y->SetMinimum(hmin); | |
591 | Int_t np=nbins/20; | |
592 | Double_t *xx = new Double_t[np]; | |
593 | Double_t *yy = new Double_t[np]; | |
594 | Int_t ng=0; | |
595 | Double_t yg=0; | |
596 | for (Int_t ip=1; ip<nbins; ip++) | |
597 | { | |
598 | if(ip%20 != 0 ) { | |
599 | if (pr_y->GetBinContent(ip) !=0) | |
600 | yg +=pr_y->GetBinContent(ip); | |
601 | // cout<<ng<<" "<<pr_y->GetBinContent(ip)<<" "<<yg<<endl; | |
602 | ng++;} | |
603 | else { | |
604 | xx[ip/20] = Float_t (ip); | |
605 | yy[ip/20] = yg/ng; | |
606 | yg=0; | |
607 | ng=0; | |
608 | cout<<ip<<" "<<ip/20<<" "<< xx[ip/20]<<" "<< yy[ip/20]<<endl; | |
609 | } | |
610 | } | |
611 | TH2F *hr = new TH2F("hr"," ",np,0,nbins, np, hmin, hmax); | |
612 | hr->Draw(); | |
613 | TGraph *gr = new TGraph(np,xx,yy); | |
614 | gr->SetMinimum(hmin); | |
615 | gr->SetMaximum(hmax); | |
616 | gr->Draw("P"); | |
617 | delete [] xx; | |
618 | delete [] yy; | |
619 | ||
620 | // pr_y->Rebin(10); | |
621 | // pr_y->Draw(); | |
dd08026e | 622 | */ |
79de2f45 | 623 | } |
dd08026e | 624 | |
79de2f45 | 625 | } |
626 | ||
627 | ||
628 | } |