From 79de2f450f1bfbdb328d3c2d2fcf65e4df2b6a87 Mon Sep 17 00:00:00 2001 From: alla Date: Fri, 21 Sep 2007 11:47:33 +0000 Subject: [PATCH] tools for reading Calibration Laser Data --- T0/AliT0CalibViewer.C | 402 ++++++++++++++++++++++++++++++++++++++++++ T0/readLaserDataGui.C | 7 + 2 files changed, 409 insertions(+) create mode 100644 T0/AliT0CalibViewer.C create mode 100755 T0/readLaserDataGui.C diff --git a/T0/AliT0CalibViewer.C b/T0/AliT0CalibViewer.C new file mode 100644 index 00000000000..75b5926fca8 --- /dev/null +++ b/T0/AliT0CalibViewer.C @@ -0,0 +1,402 @@ +/* $Id$ */ + + +#if !defined(__CINT__) +#include "TControlBar.h" +#include "TString.h" +#include "TRandom.h" +#include "TH1F.h" +#include "TF1.h" +#include "TCanvas.h" + +#include "AliRun.h" +#include "AliT0CalibData.h" +#include "AliT0AlignData.h" +#include "AliCDBMetaData.h" +#include "AliCDBId.h" +#include "AliCDBEntry.h" +#include "AliCDBManager.h" +#include "AliCDBStorage.h" +#endif +TFile *gFile=0; + +void AliT0CalibViewer() +{ + TControlBar *menu = new TControlBar("vertical","T0 CalibViewer"); + menu->AddButton("Open file","OpenFile()", + "Open file"); + menu->AddButton("Draw CFD","DrawCFD()", + "Draw all CFD"); + menu->AddButton("Draw LED","DrawLED()", + "Draw all LED"); + menu->AddButton("Draw LED-CFD","DrawLEDminCFD()", + "Draw LED-CFD"); + menu->AddButton("Draw QTC","DrawQTC()", + "Draw all QTC"); + menu->AddButton("Draw CFDvsQTC","DrawCFDvsQTC()", + "Draw CFD vs QTC"); + menu->AddButton("Draw CFDvsLED","DrawCFDvsLED()", + "Draw CFD vs LED-CFD"); + menu->Show(); +} +void OpenFile() +{ + +const char *ft[]={"T0 raw files","t0tree*.root","All files","*",0,0}; + TString dir("."); + TGFileInfo fi; fi.fFileTypes=ft; fi.fIniDir=StrDup(dir); + new TGFileDialog(gClient->GetRoot(), 0x0, kFDOpen, &fi); + + if(!fi.fFilename) return; + if(gFile){ gFile->Close(); gFile=0;} + + gFile=TFile::Open(fi.fFilename); + +} + +//------------------------------------------------------------------------ +void DrawCFD() +{ + Int_t npeaks = 20; + Int_t sigma=3.; + Bool_t down=false; + Int_t index[20]; + + TCanvas *c1 = new TCanvas("c1", "c1",0,48,1280,951); + c1->Divide(4,3); + gStyle->SetOptFit(1111); + //c1->Divide(2,2); + Char_t buf1[10]; + for (Int_t i=0; i<12; i++) + { + c1->cd(i+1); + sprintf(buf1,"T0_C_%i_CFD",i+1); + TH1F *cfd = (TH1F*) gFile->Get(buf1); + // cfd->Draw(); + TSpectrum *s = new TSpectrum(2*npeaks,1); + Int_t nfound = s->Search(cfd,sigma," ",0.05); + cout<<"Found "<GetPositionX(); + TMath::Sort(nfound, xpeak, index,down); + Float_t xp = xpeak[index[0]]; + Int_t xbin = cfd->GetXaxis()->FindBin(xp); + Float_t yp = cfd->GetBinContent(xbin); + cout<<"xbin = "<GetXaxis()->SetRange(hmin-20,hmax+20); + // cout<<" cfd range "<Fit("g1","R"); + cfd->Draw(); + } + } + +} +//------------------------------------------------------------------------ +void DrawLED() +{ + Int_t npeaks = 10; + Int_t sigma=10.; + Bool_t down=false; + Int_t index[20]; + + TCanvas *c1 = new TCanvas("c1", "c1",0,48,1280,951); + c1->Divide(4,3); + + Char_t buf1[20]; + for (Int_t i=0; i<12; i++) + { + c1->cd(i+1); + sprintf(buf1,"T0_C_%i_LED",i+1); + TH1F *cfd = (TH1F*) gFile->Get(buf1); + cfd->Draw(); + TSpectrum *s = new TSpectrum(2*npeaks,1); + Int_t nfound = s->Search(cfd,sigma," ",0.2); + cout<<"Found "<GetPositionX(); + TMath::Sort(nfound, xpeak, index,down); + Float_t xp = xpeak[index[0]]; + Int_t xbin = cfd->GetXaxis()->FindBin(xp); + Float_t yp = cfd->GetBinContent(xbin); + cout<<"xbin = "<Fit("g1","R"); + // cfd->Draw(); + + } + + } +} + +//------------------------------------------------------------------------ +void DrawQTC() +{ + + TCanvas *c1 = new TCanvas("c1", "QTC",0,48,1280,951); + // c1->Divide(4,3); + c1->Divide(2,3); + + Char_t buf1[10]; + for (Int_t i=0; i<12; i++) + { + c1->cd(i+1); + sprintf(buf1,"QTC%i",i+1); + TH1F *qtc = (TH1F*) gFile->Get(buf1); + Float_t mean = qtc->GetMean(); + Float_t rms = qtc->GetRMS(); + Float_t hminR=mean - 0.1*mean; + Float_t hmaxR =mean + 0.1*mean; + qtc->GetXaxis()->SetRange(hminR,hmaxR); + Float_t hmin=mean - 3*rms; + Float_t hmax =mean + 3*rms; + qtc->GetXaxis()->SetRange(hmin,hmax); + // TF1 *g2 = new TF1("g2", "gaus", hmin, hmax); + // qtc->Fit("g2","RQ"); + qtc->Draw(); + } + + +} + +//------------------------------------------------------------------------ +void DrawLEDminCFD() +{ + Int_t npeaks = 10; + Int_t sigma=10.; + Bool_t down=false; + Int_t index[20]; + + TCanvas *c1 = new TCanvas("c1", "c1",0,48,1280,951); + c1->Divide(4,3); + + Char_t buf1[20]; + for (Int_t i=0; i<12; i++) + { + c1->cd(i+1); + sprintf(buf1,"LED-CFD%i",i+1); + TH1F *cfd = (TH1F*) gFile->Get(buf1); + cfd->Draw(); + TSpectrum *s = new TSpectrum(2*npeaks,1); + Int_t nfound = s->Search(cfd,sigma," ",0.2); + cout<<"Found "<GetPositionX(); + TMath::Sort(nfound, xpeak, index,down); + Float_t xp = xpeak[index[0]]; + Int_t xbin = cfd->GetXaxis()->FindBin(xp); + Float_t yp = cfd->GetBinContent(xbin); + cout<<"xbin = "<Fit("g1","RQ"); + + + } + + } + /* + TCanvas *c1 = new TCanvas("c1", "c1",0,48,1280,951); + c1->Divide(2,2); + Char_t buf1[10]; + for (Int_t i=0; i<4; i++) + { + c1->cd(i+1); + sprintf(buf1,"LED-CFD%i",i+1); + TH1F *cfd = (TH1F*) file->Get(buf1); + // cout<Draw(); + // cfd->GetXaxis()->SetRange(0,100); + Float_t mean = cfd->GetMean(); + Float_t rms = cfd->GetRMS(); + Float_t hmin=mean - 3*rms; + Float_t hmax =mean + 3*rms; + cfd->GetXaxis()->SetRange(hmin-10,hmax+10); + cout<<" cfd range "<Fit("g1","RQ"); + cfd->Draw(); + } + */ + +} +//------------------------------------------------------------------------ +void DrawCFDvsQTC() +{ + Int_t npeaks = 20; + Int_t sigma=3.; + Bool_t down=false; + + Int_t index[20]; + Char_t buf1[10], buf2[10]; + + TCanvas *c1 = new TCanvas("c1", "c1",0,48,1280,951); + gStyle->SetOptStat(0); + c1->Divide(3,2); + + for (Int_t i=0; i<5; i++) + { + c1->cd(i+1); + sprintf(buf1,"T0_C_%i_CFD",i+1); + sprintf(buf2,"CFDvsQTC%i",i+1); + cout<Get(buf2); + TH1F *cfd = (TH1F*) gFile->Get(buf1); + // cfd->Draw(); + TSpectrum *s = new TSpectrum(2*npeaks,1); + Int_t nfound = s->Search(cfd,sigma," ",0.05); + cout<<"Found "<GetPositionX(); + TMath::Sort(nfound, xpeak, index,down); + Float_t xp = xpeak[index[0]]; + Int_t xbin = cfd->GetXaxis()->FindBin(xp); + Float_t yp = cfd->GetBinContent(xbin); + cout<<"xbin = "<GetXaxis()->SetRange(hmin,hmax); + // TF1 *g1 = new TF1("g1", "gaus", hmin, hmax); + // cfd->Fit("g1","R"); + Int_t hminbin= qtc_cfd->GetXaxis()->GetFirst(); + Int_t hmaxbin= qtc_cfd->GetXaxis()->GetLast(); + Int_t nbins= qtc_cfd->GetXaxis()->GetNbins(); + cout<<" qtc_cfd "<Draw(); + TProfile *pr_y = qtc_cfd->ProfileX(); + + pr_y->SetMaximum(hmax); + pr_y->SetMinimum(hmin); + Int_t np=nbins/20; + Double_t *xx = new Double_t[np]; + Double_t *yy = new Double_t[np]; + Int_t ng=0; + Double_t yg=0; + for (Int_t ip=1; ipGetBinContent(ip) !=0) + yg +=pr_y->GetBinContent(ip); + // cout<GetBinContent(ip)<<" "<Draw(); + TGraph *gr = new TGraph(np,xx,yy); + gr->SetMinimum(hmin); + gr->SetMaximum(hmax); + gr->SetMarkerStyle(20); + gr->Draw("P"); + // delete [] xx; + // delete [] yy; + + // pr_y->Rebin(10); + // pr_y->Draw(); + + } + + } + + +} +//------------------------------------------------------------------------ +void DrawCFDvsLED() +{ + Int_t runNumber=1098; + + Int_t npeaks = 20; + Int_t sigma=2.; + Char_t buf1[10], buf2[10]; + + for (Int_t i=0; i<1; i++) + { + // c1->cd(i+1); + sprintf(buf1,"T0_C_%i_CFD",i+1); + sprintf(buf2,"CFD_LED%i",i+1); + + TH2F *qtc_cfd = (TH2F*) gFile->Get(buf2); + TH1F *cfd = (TH1F*) gFile->Get(buf1); + // cfd->Draw(); + TSpectrum *s = new TSpectrum(2*npeaks,1); + Int_t nfound = s->Search(cfd,sigma," ",0.05); + cout<<"Found "<GetPositionX(); + for(Int_t k=0; k<1 ;k++) + { + Float_t xp = xpeak[k]; + Int_t xbin = cfd->GetXaxis()->FindBin(xp); + Float_t yp = cfd->GetBinContent(xbin); + cout<<"xbin = "<GetXaxis()->SetRange(hmin,hmax); + // TF1 *g1 = new TF1("g1", "gaus", hmin, hmax); + // cfd->Fit("g1","R"); + Int_t hminbin= qtc_cfd->GetXaxis()->GetFirst(); + Int_t hmaxbin= qtc_cfd->GetXaxis()->GetLast(); + Int_t nbins= qtc_cfd->GetXaxis()->GetNbins(); + cout<<" qtc_cfd "<Draw(); + TProfile *pr_y = qtc_cfd->ProfileX(); + + pr_y->SetMaximum(hmax); + pr_y->SetMinimum(hmin); + Int_t np=nbins/20; + Double_t *xx = new Double_t[np]; + Double_t *yy = new Double_t[np]; + Int_t ng=0; + Double_t yg=0; + for (Int_t ip=1; ipGetBinContent(ip) !=0) + yg +=pr_y->GetBinContent(ip); + // cout<GetBinContent(ip)<<" "<Draw(); + TGraph *gr = new TGraph(np,xx,yy); + gr->SetMinimum(hmin); + gr->SetMaximum(hmax); + gr->Draw("P"); + delete [] xx; + delete [] yy; + + // pr_y->Rebin(10); + // pr_y->Draw(); + + } + + } + + +} diff --git a/T0/readLaserDataGui.C b/T0/readLaserDataGui.C new file mode 100755 index 00000000000..96e72daef9a --- /dev/null +++ b/T0/readLaserDataGui.C @@ -0,0 +1,7 @@ + void readLaserDataGui(Int_t rNumber=905) + { + + AliT0CalibLaserData *calibda = new AliT0CalibLaserData(); + calibda->ReadHistSize(rNumber); +} + -- 2.39.3