* about the suitability of this software for any purpose. It is *
* provided "as is" without express or implied warranty. *
**************************************************************************/
-
+
/* $Id$ */
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#include "AliT0CalibWalk.h"
-#include "AliT0LookUpValue.h"
#include "AliLog.h"
-#include "AliRun.h"
#include <TObjArray.h>
#include <TGraph.h>
#include <TFile.h>
-#include <TAxis.h>
#include <TH2F.h>
#include <TMath.h>
#include <TSystem.h>
#include <Riostream.h>
#include <TSpectrum.h>
-#include <TVirtualFitter.h>
#include <TProfile.h>
-#include <string>
ClassImp(AliT0CalibWalk)
//________________________________________________________________
AliT0CalibWalk::AliT0CalibWalk(): TNamed(),
fWalk(0),
- fAmpLEDRec(0)
+ fAmpLEDRec(0),
+ fQTC(0),
+ fAmpLED(0)
{
//
}
//________________________________________________________________
AliT0CalibWalk::AliT0CalibWalk(const char* name):TNamed(),
fWalk(0),
- fAmpLEDRec(0)
+ fAmpLEDRec(0), fQTC(0),
+ fAmpLED(0)
+
{
TString namst = "Calib_";
namst += name;
AliT0CalibWalk::AliT0CalibWalk(const AliT0CalibWalk& calibda) :
TNamed(calibda),
fWalk(0),
- fAmpLEDRec(0)
-
+ fAmpLEDRec(0),
+ fQTC(0),
+ fAmpLED(0)
+
{
// copy constructor
SetName(calibda.GetName());
//________________________________________________________________
void AliT0CalibWalk::SetWalk(Int_t ipmt)
{
+ //read QTC walk graph from external file
Int_t mv, ps;
Int_t x[70000], y[70000], index[70000];
TGraph* gr = new TGraph(isum, amplitude, time);
fWalk.AddAtAndExpand(gr,ipmt);
+
+ //should be change to real
+ Double_t xq[10] = { 1220, 1370, 1542, 1697, 1860, 2023,2171,2331,2495,2684};
+ Double_t yq[10] = {1,2,3,4,5,6,7,8,9,10};
+ TGraph* gr1 = new TGraph(10, xq, yq);
+ fQTC.AddAtAndExpand(gr1,ipmt);
}
//________________________________________________________________
void AliT0CalibWalk::SetAmpLEDRec(Int_t ipmt)
{
+ // read LED walk from external file
Float_t mv, ps;
Float_t x[100], y[100];
string buffer;
y1[ir]=y[i-ir]; x1[ir]=x[i-ir];}
TGraph* gr = new TGraph(i,y1,x1);
fAmpLEDRec.AddAtAndExpand(gr,ipmt);
+ //should be change to real
+ Double_t xq[10] = { 411, 412,413,415,417,419,422,428,437,452};
+ Double_t yq[10] = {1,2,3,4,5,6,7,8,9,10};
+ TGraph* gr1 = new TGraph(10, xq, yq);
+ fAmpLED.AddAtAndExpand(gr1,ipmt);
}
void AliT0CalibWalk::MakeWalkCorrGraph(const char *laserFile)
{
- TFile *gFile = TFile::Open(laserFile);
- //gSystem->Load("libSpectrum");
- TGraph *gr[24];
- TGraph *grLED[24];
- Int_t npeaks = 20;
- Int_t sigma=3;
- Bool_t down=false;
-
- Int_t index[20];
- Char_t buf1[10], buf2[10], buf3[10], title[10], title2[10], titleLED[10], title2LED[10];
- TSpectrum *s = new TSpectrum(2*npeaks,1.);
+ //make walk corerction for preprocessor
+
+ gFile = TFile::Open(laserFile);
+ if(!gFile) {
+ AliError("No input laser data found ");
+ }
+ else
+ {
+ // gFile->ls();
+ Float_t x1[10], y1[10];
+ Float_t x2[10], y2[10];
+
+ Float_t xx1[10],yy1[10], xx[10];
+ for (Int_t ii=0; ii<10; ii++)
+ { x1[ii]=0; y1[ii]=0; x2[ii]=0; y2[ii]=0; }
+
+
+ TH2F* hCFDvsQTC[24][10]; TH2F* hCFDvsLED[24][10];
- for (Int_t d=0; d<2; d++)
- {
- for (Int_t i=0; i<12; i++)
+ for (Int_t i=0; i<24; i++)
{
- sprintf(buf1,"T0_C_%i_CFD",i+1);
- if (d==0)
- {
- sprintf(buf2,"CFD_QTC%i",i+1);
- }
- else
- {
- sprintf(buf3,"CFD_LED%i",i+1);
- }
- TH2F *qtc_cfd = (TH2F*) gFile->Get(buf2);
- TH2F *led_cfd = (TH2F*) gFile->Get(buf3);
- // cout<<buf1<<" "<<buf2<<endl;
- TH1F *cfd = (TH1F*) gFile->Get(buf1);
- Int_t nfound = s->Search(cfd,sigma,"goff",0.05);
- // cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;
- if(nfound!=0)
- {
- Float_t *xpeak = s->GetPositionX();
- TMath::Sort(nfound, xpeak, index,down);
- Float_t xp = xpeak[index[0]];
- Float_t hmax = xp+10*sigma;
- Float_t hmin = xp-10*sigma;
- if (d==0)
+ for (Int_t im=0; im<10; im++)
{
- Int_t nbins= qtc_cfd->GetXaxis()->GetNbins();
- 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; ip<nbins; ip++)
- {
- if(ip%20 != 0 )
- {
- if (pr_y->GetBinContent(ip) !=0)
- {
- yg +=pr_y->GetBinContent(ip);
- }
- ng++;
- }
- else
- {
- xx[ip/20] = Float_t (pr_y->GetBinCenter(ip));
- yy[ip/20] = yg/ng;
- yg=0;
- ng=0;
- }
- }
- sprintf(title,"Walk %i",i+1);
- gr[i] = new TGraph(np,xx,yy);
- gr[i]->SetTitle(title);
- gr[i]->SetMinimum(hmin);
- gr[i]->SetMaximum(hmax);
- gr[i]->SetMarkerStyle(7);
- sprintf(title2,"Walk %i",i+13);
- gr[i+12] = new TGraph(np,xx,yy);
- gr[i+12]->SetTitle(title2);
- gr[i+12]->SetMinimum(hmin);
- gr[i+12]->SetMaximum(hmax);
- gr[i+12]->SetMarkerStyle(7);
+
+ TString qtc = Form("QTCvsCFD%i_%i",i+1,im+1);
+ TString led = Form("LEDvsCFD%i_%i",i+1,im+1);
+
+ hCFDvsQTC[i][im] = (TH2F*) gFile->Get(qtc.Data()) ;
+ hCFDvsLED[i][im] = (TH2F*) gFile->Get(led.Data());
- fWalk.AddAtAndExpand(gr[i],i);
- fWalk.AddAtAndExpand(gr[i+12],i+12);
- delete [] xx;
- delete [] yy;
- delete pr_y;
+ if(!hCFDvsQTC[i][im] || !hCFDvsLED[i][im])
+ AliWarning(Form(" no walk correction data in LASER DA for channel %i for amplitude %i MIPs",i,im));
+
+ if(hCFDvsQTC[i][im] && hCFDvsLED[i][im])
+ {
+ x1[im] = hCFDvsQTC[i][im]->GetMean(1);
+ y1[im] = hCFDvsQTC[i][im]->GetMean(2);
+ x2[im] = hCFDvsLED[i][im]->GetMean(1);
+ y2[im] = hCFDvsLED[i][im]->GetMean(2);
+ }
+ xx[im]=im+1;
}
- else
+ for (Int_t imi=0; imi<10; imi++)
{
- Int_t nbinsLED= led_cfd->GetXaxis()->GetNbins();
- TProfile *pr_yLED = led_cfd->ProfileX();
- pr_yLED->SetMaximum(hmax);
- pr_yLED->SetMinimum(hmin);
- Int_t npLED=nbinsLED/20;
- Double_t *xxLED = new Double_t[npLED];
- Double_t *yyLED = new Double_t[npLED];
- Int_t ngLED=0;
- Double_t ygLED=0;
- for (Int_t ip=1; ip<nbinsLED; ip++)
- {
- if(ip%20 != 0 )
- {
- if (pr_yLED->GetBinContent(ip) !=0)
- {
- ygLED +=pr_yLED->GetBinContent(ip);
- }
- ngLED++;
- }
- else
- {
- xxLED[ip/20] = Float_t (pr_yLED->GetBinCenter(ip));
- yyLED[ip/20] = ygLED/ngLED;
- ygLED=0;
- ngLED=0;
- }
- }
- sprintf(titleLED,"Walk LED %i",i+1);
- grLED[i] = new TGraph(npLED,xxLED,yyLED);
- grLED[i]->SetTitle(titleLED);
- grLED[i]->SetMinimum(hmin);
- grLED[i]->SetMaximum(hmax);
- grLED[i]->SetMarkerStyle(7);
- sprintf(title2LED,"Walk LED%i",i+13);
- grLED[i+12] = new TGraph(npLED,xxLED,yyLED);
- grLED[i+12]->SetTitle(title2LED);
- grLED[i+12]->SetMinimum(hmin);
- grLED[i+12]->SetMaximum(hmax);
- grLED[i+12]->SetMarkerStyle(7);
+ yy1[imi] = Float_t (10-imi);
+ xx1[imi]=x2[10-imi-1];
+ }
+ if(i==0){
+ cout<<"Making graphs..."<<endl;
+ }
+ TGraph *gr1 = new TGraph (10,x1,y1);
+ TGraph *gr2 = new TGraph (10,x2,y2);
+ fWalk.AddAtAndExpand(gr1,i);
+ fAmpLEDRec.AddAtAndExpand(gr2,i);
+
- fAmpLEDRec.AddAtAndExpand(grLED[i],i);
- fAmpLEDRec.AddAtAndExpand(grLED[i+12],i+12);
- delete [] xxLED;
- delete [] yyLED;
- delete pr_yLED;
+
+ TGraph *gr4 = new TGraph (10,xx1,yy1);
+ TGraph *gr3 = new TGraph (10,x1,xx);
+ fQTC.AddAtAndExpand(gr3,i);
+ fAmpLED.AddAtAndExpand(gr4,i);
+ // for (Int_t im=0; im<10; im++) { x2[im]=0; y2[im]=0; xx1[im]=0; xx[im]=0;}
+ if(i==23){
+ cout<<"Graphs created..."<<endl;
}
- }
- delete cfd;
- delete qtc_cfd;
- delete led_cfd;
}
- }
-
+ } //if gFile exits
}
+
+
+