5 #include "TControlBar.h"
13 #include "AliT0CalibData.h"
14 #include "AliT0AlignData.h"
15 #include "AliCDBMetaData.h"
17 #include "AliCDBEntry.h"
18 #include "AliCDBManager.h"
19 #include "AliCDBStorage.h"
23 void AliT0CalibViewer()
25 TControlBar *menu = new TControlBar("vertical","T0 CalibViewer");
26 menu->AddButton("Open file","OpenFile()",
28 menu->AddButton("Draw CFD","DrawCFD()",
30 menu->AddButton("Draw LED","DrawLED()",
32 menu->AddButton("Draw LED-CFD","DrawLEDminCFD()",
34 menu->AddButton("Draw QTC","DrawQTC()",
36 menu->AddButton("Draw CFDvsQTC","DrawCFDvsQTC()",
38 menu->AddButton("Draw CFDvsLED","DrawCFDvsLED()",
39 "Draw CFD vs LED-CFD");
40 menu->AddButton("Draw Walk","DrawWalk()",
41 "Draw CFD vs LED-CFD");
47 const char *ft[]={"T0 raw files","t0tree*.root","All files","*",0,0};
49 TGFileInfo fi; fi.fFileTypes=ft; fi.fIniDir=StrDup(dir);
50 new TGFileDialog(gClient->GetRoot(), 0x0, kFDOpen, &fi);
52 if(!fi.fFilename) return;
53 if(gFile){ gFile->Close(); gFile=0;}
55 gFile=TFile::Open(fi.fFilename);
59 //------------------------------------------------------------------------
67 TCanvas *c1 = new TCanvas("c1", "CFD C side",0,48,1280,951);
69 gStyle->SetOptFit(1111);
72 for (Int_t i=0; i<12; i++)
75 sprintf(buf1,"T0_C_%i_CFD",i+1);
76 TH1F *cfd = (TH1F*) gFile->Get(buf1);
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;;
83 Float_t *xpeak = s->GetPositionX();
84 TMath::Sort(nfound, xpeak, index,down);
85 Float_t xp = xpeak[index[0]];
86 cout<<" index[0] "<<index[0]<<endl;
87 // Float_t xp = xpeak[1];
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;
94 cfd->GetXaxis()->SetRange(hmin-10,hmax+10);
95 cout<<" cfd range "<<hmin-10<<" "<<hmax+10<<endl;
96 cfd->GetXaxis()->SetLabelSize(0.03);
97 TF1 *g1 = new TF1("g1", "gaus", hmin, hmax);
104 TCanvas *c2 = new TCanvas("c2", "CFD A side",0,48,1280,951);
106 gStyle->SetOptFit(1111);
109 for (Int_t i=0; i<12; i++)
112 sprintf(buf1,"T0_A_%i_CFD",i+1);
113 TH1F *cfd = (TH1F*) gFile->Get(buf1);
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;;
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);
143 //------------------------------------------------------------------------
151 TCanvas *c1 = new TCanvas("c1", "LED C side",0,48,1280,951);
155 for (Int_t i=0; i<12; i++)
158 sprintf(buf1,"T0_C_%i_LED",i+1);
159 TH1F *cfd = (TH1F*) gFile->Get(buf1);
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;;
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);
181 TCanvas *c2 = new TCanvas("c2", "LED A side",0,48,1280,951);
185 for (Int_t i=0; i<12; i++)
188 sprintf(buf1,"T0_A_%i_LED",i+1);
189 TH1F *cfd = (TH1F*) gFile->Get(buf1);
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;;
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);
204 cfd->GetXaxis()->SetLabelSize(0.03);
205 TF1 *g1 = new TF1("g1", "gaus", hmin, hmax);
214 //------------------------------------------------------------------------
218 TCanvas *c1 = new TCanvas("c1", "QTC C side",0,48,1280,951);
223 for (Int_t i=0; i<12; i++)
226 sprintf(buf1,"QTC%i",i+1);
228 TH1F *qtc = (TH1F*) gFile->Get(buf1);
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);
239 // TF1 *g2 = new TF1("g2", "gaus", hmin, hmax);
240 // qtc->Fit("g2","RQ");
241 qtc->GetXaxis()->SetLabelSize(0.03);
246 TCanvas *c2 = new TCanvas("c2", "QTC A side",0,48,1280,951);
251 for (Int_t i=12; i<24; i++)
254 sprintf(buf1,"QTC%i",i+1);
256 TH1F *qtc = (TH1F*) gFile->Get(buf1);
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");
268 qtc->GetXaxis()->SetLabelSize(0.03);
276 //------------------------------------------------------------------------
284 TCanvas *c1 = new TCanvas("c1", " LED-CFD C side",0,48,1280,951);
288 for (Int_t i=0; i<12; i++)
291 sprintf(buf1,"LEDminCFD%i",i+1);
292 TH1F *cfd = (TH1F*) gFile->Get(buf1);
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;;
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);
314 TCanvas *c2 = new TCanvas("c2", "LED-CFD A side",0,48,1280,951);
318 for (Int_t i=12; i<24; i++)
321 sprintf(buf1,"LEDminCFD%i",i+1);
322 TH1F *cfd = (TH1F*) gFile->Get(buf1);
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;;
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);
345 TCanvas *c1 = new TCanvas("c1", "c1",0,48,1280,951);
348 for (Int_t i=0; i<4; i++)
351 sprintf(buf1,"LED-CFD%i",i+1);
352 TH1F *cfd = (TH1F*) file->Get(buf1);
353 // cout<<buf1<<" "<<cfd<<endl;
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");
369 //------------------------------------------------------------------------
377 Char_t buf1[10], buf2[10];
379 TCanvas *c1 = new TCanvas("c1", "CFD vs QTC C side",0,48,1280,951);
380 gStyle->SetOptStat(111111);
383 for (Int_t i=0; i<12; i++)
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);
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;;
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);
414 TCanvas *c2 = new TCanvas("c2", "CFD vs QTC A side",0,48,1280,951);
415 gStyle->SetOptStat(111111);
418 for (Int_t i=12; i<24; i++)
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);
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;;
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);
453 //------------------------------------------------------------------------
461 Char_t buf1[10], buf2[10];
463 TCanvas *c1 = new TCanvas("c1", "c1",0,48,1280,951);
464 gStyle->SetOptStat(0);
467 for (Int_t i=0; i<12; i++)
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);
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;;
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;
497 TProfile *pr_y = qtc_cfd->ProfileX();
498 Float_t maxHr=pr_y->GetBinCenter(hmaxbin);
500 pr_y->SetMaximum(hmax);
501 pr_y->SetMinimum(hmin);
503 Double_t *xx = new Double_t[np];
504 Double_t *yy = new Double_t[np];
507 for (Int_t ip=1; ip<nbins; ip++)
510 if (pr_y->GetBinContent(ip) !=0)
511 yg +=pr_y->GetBinContent(ip);
512 // cout<<ng<<" "<<pr_y->GetBinContent(ip)<<" "<<yg<<endl;
515 xx[ip/20] = Float_t (pr_y->GetBinCenter(ip));
519 cout<<ip<<" "<<ip/20<<" "<< xx[ip/20]<<" "<< yy[ip/20]<<endl;
522 TH2F *hr = new TH2F("hr"," ",np,0,maxHr, np, hmin, hmax);
524 TGraph *gr = new TGraph(np,xx,yy);
525 gr->SetMinimum(hmin);
526 gr->SetMaximum(hmax);
527 gr->SetMarkerStyle(20);
541 //------------------------------------------------------------------------
544 Int_t runNumber=1098;
548 Char_t buf1[10], buf2[10];
549 TCanvas *c1 = new TCanvas("c1", "c1",0,48,1280,951);
550 gStyle->SetOptStat(0);
552 for (Int_t i=0; i<12; i++)
555 sprintf(buf1,"T0_C_%i_CFD",i+1);
556 sprintf(buf2,"CFDvsLED%i",i+1);
558 TH2F *qtc_cfd = (TH2F*) gFile->Get(buf2);
560 TH1F *cfd = (TH1F*) gFile->Get(buf1);
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;;
567 Double_t tabmax[2] = {0.0, 0.0};
568 Float_t *xpeak = s->GetPositionX();
569 for(Int_t k=0; k<1 ;k++)
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;
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;
587 /*TProfile *pr_y = qtc_cfd->ProfileX();
589 pr_y->SetMaximum(hmax);
590 pr_y->SetMinimum(hmin);
592 Double_t *xx = new Double_t[np];
593 Double_t *yy = new Double_t[np];
596 for (Int_t ip=1; ip<nbins; ip++)
599 if (pr_y->GetBinContent(ip) !=0)
600 yg +=pr_y->GetBinContent(ip);
601 // cout<<ng<<" "<<pr_y->GetBinContent(ip)<<" "<<yg<<endl;
604 xx[ip/20] = Float_t (ip);
608 cout<<ip<<" "<<ip/20<<" "<< xx[ip/20]<<" "<< yy[ip/20]<<endl;
611 TH2F *hr = new TH2F("hr"," ",np,0,nbins, np, hmin, hmax);
613 TGraph *gr = new TGraph(np,xx,yy);
614 gr->SetMinimum(hmin);
615 gr->SetMaximum(hmax);