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");
45 const char *ft[]={"T0 raw files","t0tree*.root","All files","*",0,0};
47 TGFileInfo fi; fi.fFileTypes=ft; fi.fIniDir=StrDup(dir);
48 new TGFileDialog(gClient->GetRoot(), 0x0, kFDOpen, &fi);
50 if(!fi.fFilename) return;
51 if(gFile){ gFile->Close(); gFile=0;}
53 gFile=TFile::Open(fi.fFilename);
57 //------------------------------------------------------------------------
65 TCanvas *c1 = new TCanvas("c1", "c1",0,48,1280,951);
67 gStyle->SetOptFit(1111);
70 for (Int_t i=0; i<12; i++)
73 sprintf(buf1,"T0_C_%i_CFD",i+1);
74 TH1F *cfd = (TH1F*) gFile->Get(buf1);
76 TSpectrum *s = new TSpectrum(2*npeaks,1);
77 Int_t nfound = s->Search(cfd,sigma," ",0.05);
78 cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;;
80 Float_t *xpeak = s->GetPositionX();
81 TMath::Sort(nfound, xpeak, index,down);
82 Float_t xp = xpeak[index[0]];
83 Int_t xbin = cfd->GetXaxis()->FindBin(xp);
84 Float_t yp = cfd->GetBinContent(xbin);
85 cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[1]<<"\typeak = "<<yp<<endl;
86 Float_t hmax = xp+3*sigma;
87 Float_t hmin = xp-3*sigma;
88 cout<<hmin<< " "<<hmax<<endl;
89 cfd->GetXaxis()->SetRange(hmin-20,hmax+20);
90 // cout<<" cfd range "<<mean<<" rms "<<rms<<" "<<hmin<<" "<<hmax<<endl;
91 TF1 *g1 = new TF1("g1", "gaus", hmin, hmax);
92 // cfd->Fit("g1","R");
98 //------------------------------------------------------------------------
106 TCanvas *c1 = new TCanvas("c1", "c1",0,48,1280,951);
110 for (Int_t i=0; i<12; i++)
113 sprintf(buf1,"T0_C_%i_LED",i+1);
114 TH1F *cfd = (TH1F*) gFile->Get(buf1);
116 TSpectrum *s = new TSpectrum(2*npeaks,1);
117 Int_t nfound = s->Search(cfd,sigma," ",0.2);
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 Int_t xbin = cfd->GetXaxis()->FindBin(xp);
124 Float_t yp = cfd->GetBinContent(xbin);
125 cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[index[0]]<<"\typeak = "<<yp<<endl;
126 Float_t hmin=xp-3*sigma;
127 Float_t hmax =xp+3*sigma;
128 cfd->GetXaxis()->SetRange(hmin,hmax);
129 TF1 *g1 = new TF1("g1", "gaus", hmin, hmax);
138 //------------------------------------------------------------------------
142 TCanvas *c1 = new TCanvas("c1", "QTC",0,48,1280,951);
147 for (Int_t i=0; i<12; i++)
150 sprintf(buf1,"QTC%i",i+1);
151 TH1F *qtc = (TH1F*) gFile->Get(buf1);
152 Float_t mean = qtc->GetMean();
153 Float_t rms = qtc->GetRMS();
154 Float_t hminR=mean - 0.1*mean;
155 Float_t hmaxR =mean + 0.1*mean;
156 qtc->GetXaxis()->SetRange(hminR,hmaxR);
157 Float_t hmin=mean - 3*rms;
158 Float_t hmax =mean + 3*rms;
159 qtc->GetXaxis()->SetRange(hmin,hmax);
160 // TF1 *g2 = new TF1("g2", "gaus", hmin, hmax);
161 // qtc->Fit("g2","RQ");
168 //------------------------------------------------------------------------
176 TCanvas *c1 = new TCanvas("c1", "c1",0,48,1280,951);
180 for (Int_t i=0; i<12; i++)
183 sprintf(buf1,"LED-CFD%i",i+1);
184 TH1F *cfd = (TH1F*) gFile->Get(buf1);
186 TSpectrum *s = new TSpectrum(2*npeaks,1);
187 Int_t nfound = s->Search(cfd,sigma," ",0.2);
188 cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;;
190 Float_t *xpeak = s->GetPositionX();
191 TMath::Sort(nfound, xpeak, index,down);
192 Float_t xp = xpeak[index[0]];
193 Int_t xbin = cfd->GetXaxis()->FindBin(xp);
194 Float_t yp = cfd->GetBinContent(xbin);
195 cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[index[0]]<<"\typeak = "<<yp<<endl;
196 Float_t hmin=xp-3*sigma;
197 Float_t hmax =xp+3*sigma;
198 cfd->GetXaxis()->SetRange(hmin,hmax);
199 TF1 *g1 = new TF1("g1", "gaus", hmin, hmax);
207 TCanvas *c1 = new TCanvas("c1", "c1",0,48,1280,951);
210 for (Int_t i=0; i<4; i++)
213 sprintf(buf1,"LED-CFD%i",i+1);
214 TH1F *cfd = (TH1F*) file->Get(buf1);
215 // cout<<buf1<<" "<<cfd<<endl;
217 // cfd->GetXaxis()->SetRange(0,100);
218 Float_t mean = cfd->GetMean();
219 Float_t rms = cfd->GetRMS();
220 Float_t hmin=mean - 3*rms;
221 Float_t hmax =mean + 3*rms;
222 cfd->GetXaxis()->SetRange(hmin-10,hmax+10);
223 cout<<" cfd range "<<mean<<" rms "<<rms<<" "<<hmin<<" "<<hmax<<endl;
224 // TF1 *g1 = new TF1("g1", "gaus", hmin, hmax);
225 // cfd->Fit("g1","RQ");
231 //------------------------------------------------------------------------
239 Char_t buf1[10], buf2[10];
241 TCanvas *c1 = new TCanvas("c1", "c1",0,48,1280,951);
242 gStyle->SetOptStat(0);
245 for (Int_t i=0; i<5; i++)
248 sprintf(buf1,"T0_C_%i_CFD",i+1);
249 sprintf(buf2,"CFDvsQTC%i",i+1);
250 cout<<buf1<<" "<<buf2<<endl;
251 TH2F *qtc_cfd = (TH2F*) gFile->Get(buf2);
252 TH1F *cfd = (TH1F*) gFile->Get(buf1);
254 TSpectrum *s = new TSpectrum(2*npeaks,1);
255 Int_t nfound = s->Search(cfd,sigma," ",0.05);
256 cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;;
258 Float_t *xpeak = s->GetPositionX();
259 TMath::Sort(nfound, xpeak, index,down);
260 Float_t xp = xpeak[index[0]];
261 Int_t xbin = cfd->GetXaxis()->FindBin(xp);
262 Float_t yp = cfd->GetBinContent(xbin);
263 cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[1]<<"\typeak = "<<yp<<endl;
264 Float_t hmax = xp+10*sigma;
265 Float_t hmin = xp-10*sigma;
266 cout<<hmin<< " "<<hmax<<endl;
267 // cfd->GetXaxis()->SetRange(hmin,hmax);
268 // TF1 *g1 = new TF1("g1", "gaus", hmin, hmax);
269 // cfd->Fit("g1","R");
270 Int_t hminbin= qtc_cfd->GetXaxis()->GetFirst();
271 Int_t hmaxbin= qtc_cfd->GetXaxis()->GetLast();
272 Int_t nbins= qtc_cfd->GetXaxis()->GetNbins();
273 cout<<" qtc_cfd "<<hminbin<<" "<<hmaxbin<<" "<<nbins<<endl;
275 TProfile *pr_y = qtc_cfd->ProfileX();
277 pr_y->SetMaximum(hmax);
278 pr_y->SetMinimum(hmin);
280 Double_t *xx = new Double_t[np];
281 Double_t *yy = new Double_t[np];
284 for (Int_t ip=1; ip<nbins; ip++)
287 if (pr_y->GetBinContent(ip) !=0)
288 yg +=pr_y->GetBinContent(ip);
289 // cout<<ng<<" "<<pr_y->GetBinContent(ip)<<" "<<yg<<endl;
292 xx[ip/20] = Float_t (ip);
296 // cout<<ip<<" "<<ip/20<<" "<< xx[ip/20]<<" "<< yy[ip/20]<<endl;
299 TH2F *hr = new TH2F("hr"," ",np,0,nbins, np, hmin, hmax);
301 TGraph *gr = new TGraph(np,xx,yy);
302 gr->SetMinimum(hmin);
303 gr->SetMaximum(hmax);
304 gr->SetMarkerStyle(20);
318 //------------------------------------------------------------------------
321 Int_t runNumber=1098;
325 Char_t buf1[10], buf2[10];
327 for (Int_t i=0; i<1; i++)
330 sprintf(buf1,"T0_C_%i_CFD",i+1);
331 sprintf(buf2,"CFD_LED%i",i+1);
333 TH2F *qtc_cfd = (TH2F*) gFile->Get(buf2);
334 TH1F *cfd = (TH1F*) gFile->Get(buf1);
336 TSpectrum *s = new TSpectrum(2*npeaks,1);
337 Int_t nfound = s->Search(cfd,sigma," ",0.05);
338 cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;;
341 Double_t tabmax[2] = {0.0, 0.0};
342 Float_t *xpeak = s->GetPositionX();
343 for(Int_t k=0; k<1 ;k++)
345 Float_t xp = xpeak[k];
346 Int_t xbin = cfd->GetXaxis()->FindBin(xp);
347 Float_t yp = cfd->GetBinContent(xbin);
348 cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[k]<<"\typeak = "<<yp<<endl;
350 Float_t hmin=xp-10*sigma;
351 Float_t hmax =xp+10*sigma;
352 cout<<hmin<< " "<<hmax<<endl;
353 // cfd->GetXaxis()->SetRange(hmin,hmax);
354 // TF1 *g1 = new TF1("g1", "gaus", hmin, hmax);
355 // cfd->Fit("g1","R");
356 Int_t hminbin= qtc_cfd->GetXaxis()->GetFirst();
357 Int_t hmaxbin= qtc_cfd->GetXaxis()->GetLast();
358 Int_t nbins= qtc_cfd->GetXaxis()->GetNbins();
359 cout<<" qtc_cfd "<<hminbin<<" "<<hmaxbin<<" "<<nbins<<endl;
361 TProfile *pr_y = qtc_cfd->ProfileX();
363 pr_y->SetMaximum(hmax);
364 pr_y->SetMinimum(hmin);
366 Double_t *xx = new Double_t[np];
367 Double_t *yy = new Double_t[np];
370 for (Int_t ip=1; ip<nbins; ip++)
373 if (pr_y->GetBinContent(ip) !=0)
374 yg +=pr_y->GetBinContent(ip);
375 // cout<<ng<<" "<<pr_y->GetBinContent(ip)<<" "<<yg<<endl;
378 xx[ip/20] = Float_t (ip);
382 cout<<ip<<" "<<ip/20<<" "<< xx[ip/20]<<" "<< yy[ip/20]<<endl;
385 TH2F *hr = new TH2F("hr"," ",np,0,nbins, np, hmin, hmax);
387 TGraph *gr = new TGraph(np,xx,yy);
388 gr->SetMinimum(hmin);
389 gr->SetMaximum(hmax);