///////////////////////////////////////////////////////////////////////////////
// //
-// class for T0 calibration TM-AC-AM_6-02-2006 //
+// class for T0 calibration TM-AC-AM_6-02-2006
+// equalize time shift for each time CFD channel
// //
///////////////////////////////////////////////////////////////////////////////
#include "AliT0CalibTimeEq.h"
-#include "AliT0LookUpValue.h"
#include "AliLog.h"
-#include "AliRun.h"
-
-#include <TCanvas.h>
#include <TFile.h>
#include <TMath.h>
#include <TF1.h>
-#include <TSystem.h>
-#include <Riostream.h>
#include <TSpectrum.h>
-#include <TVirtualFitter.h>
#include <TProfile.h>
-
-#include <Riostream.h>
-#include <string>
+#include <iostream>
ClassImp(AliT0CalibTimeEq)
//________________________________________________________________
- AliT0CalibTimeEq::AliT0CalibTimeEq(): TNamed(),
- fTimeDelayTVD(0),
- fMeanT0(0)
+ AliT0CalibTimeEq::AliT0CalibTimeEq():TNamed(),
+ fMeanVertex(0),
+ fRmsVertex(0)
{
//
+
}
//________________________________________________________________
AliT0CalibTimeEq::AliT0CalibTimeEq(const char* name):TNamed(),
- fTimeDelayTVD(0),
- fMeanT0(0)
+ fMeanVertex(0),
+ fRmsVertex(0)
{
+ //constructor
+
TString namst = "Calib_";
namst += name;
SetName(namst.Data());
}
//________________________________________________________________
-AliT0CalibTimeEq::AliT0CalibTimeEq(const AliT0CalibTimeEq& calibda) :
- TNamed(calibda),
- fTimeDelayTVD(0),
- fMeanT0(0)
+AliT0CalibTimeEq::AliT0CalibTimeEq(const AliT0CalibTimeEq& calibda):TNamed(calibda),
+ fMeanVertex(0),
+ fRmsVertex(0)
{
// copy constructor
SetName(calibda.GetName());
AliT0CalibTimeEq::~AliT0CalibTimeEq()
{
//
+ // destrictor
}
//________________________________________________________________
void AliT0CalibTimeEq::Reset()
{
+ //reset values
+
memset(fCFDvalue,0,120*sizeof(Float_t));
memset(fTimeEq,1,24*sizeof(Float_t));
}
//________________________________________________________________
void AliT0CalibTimeEq::Print(Option_t*) const
{
+ // print time values
printf("\n ---- PM Arrays ----\n\n");
printf(" Time delay CFD \n");
for (Int_t i=0; i<24; i++) printf(" CFD %f ",fTimeEq[i]);
+ printf("\n Mean Vertex %f \n", fMeanVertex);
}
//________________________________________________________________
-void AliT0CalibTimeEq::ComputeOnlineParams(char* name1, char* name2, char* canv, Int_t npeaks, Double_t sigma, const char* filePhys)
+Bool_t AliT0CalibTimeEq::ComputeOnlineParams(const char* filePhys)
{
- TFile *gFile = TFile::Open(filePhys);
- gSystem->Load("libSpectrum");
- npeaks = 20;
- sigma=3.;
+ // compute online equalized time
+ Double_t mean=0, meanver=0;
+ Double_t rms=0, rmsver=0;
+ Int_t nent=0;
+ Bool_t ok=false;
+ Int_t npeaks = 20;
+ Int_t sigma=3;
Bool_t down=false;
Int_t index[20];
- TCanvas *c1 = new TCanvas(canv, canv,0,48,1280,951);
- c1->Divide(4,3);
- Char_t buf1[15];
- Char_t temp[10];
- Float_t p[12][3]={0.,0.,0.};
- for (Int_t i=12; i<24; i++)
+ Int_t nfound=0;
+ gFile = TFile::Open(filePhys);
+ if(!gFile) {
+ AliError("No input PHYS data found ");
+ }
+ else
{
- c1->cd(i+1);
- sprintf(buf1,name1);
- sprintf(temp,"%i",i+1);
- strcat (buf1,temp);
- strcat (buf1,name2);
- TH1F *cfd = (TH1F*) gFile->Get(buf1);
- TSpectrum *s = new TSpectrum(2*npeaks,1.);
- Int_t nfound = s->Search(cfd,sigma," ",0.2);
- if(nfound!=0){
- Float_t *xpeak = s->GetPositionX();
- TMath::Sort(nfound, xpeak, index,down);
- Float_t xp = xpeak[index[0]];
- Float_t hmax = xp+3*sigma;
- Float_t hmin = xp-3*sigma;
- cfd->GetXaxis()->SetRange((Int_t)hmin-20,(Int_t)hmax+20);
- TF1 *g1 = new TF1("g1", "gaus", hmin, hmax);
- cfd->Fit("g1","IR");
-
- for(Int_t j =0; j<3; j++){
- p[i][j] = g1->GetParameter(j);
- SetCFDvalue(i, j, p[i][j]);
- }
- SetCFDvalue(i, 3, hmin);
- SetCFDvalue(i, 4, hmax);
- SetTimeEq(i,p[i][2]);
- // if(p[i][0]==0)
- // cfd->Draw();
-
- // cfd->Draw();
- } // else
- // cfd->Draw();
+ // gFile->ls();
+ ok=true;
+ Char_t buf1[30];
+ for (Int_t i=0; i<24; i++)
+ {
+ sprintf(buf1,"CFD1minCFD%d",i+1);
+ TH1F *cfd = (TH1F*) gFile->Get(buf1);
+ if(!cfd) AliWarning(Form("no histograms collected by PHYS DA for channel %i", i));
+ // printf(" i = %d buf1 = %s\n", i, buf1);
+ if(cfd) {
+ TSpectrum *s = new TSpectrum(2*npeaks,1);
+ nfound = s->Search(cfd,sigma," ",0.1);
+ if(nfound!=0){
+ Float_t *xpeak = s->GetPositionX();
+ TMath::Sort(nfound, xpeak, index,down);
+ Float_t xp = xpeak[index[0]];
+ Double_t hmax = xp+3*sigma;
+ Double_t hmin = xp-3*sigma;
+ cfd->GetXaxis()->SetRangeUser(hmin-20,hmax+20);
+ mean=cfd->GetMean();
+ rms=cfd->GetRMS();
+ nent=cfd->GetEntries();
+ if(nent<500 || rms>10. ) {
+ ok=false;
+ AliWarning(Form("Data is not good enouph in PMT %i - mean %f rsm %f nentries %i", i,mean, rms, nent));
+
+ }
+ }
+ else
+ {
+ ok=false;
+ AliWarning(Form("Data is not good enouph in PMT %i , no clean peak", i));
+ }
+ }
+
+
+ SetTimeEq(i,mean);
+ SetTimeEqRms(i,rms);
+ if (cfd) delete cfd;
+ }
+ TH1F *ver = (TH1F*) gFile->Get("hVertex");
+ if(!ver) AliWarning("no T0 histogram collected by PHYS DA ");
+ if(ver) {
+ meanver = ver->GetMean();
+ rmsver = ver->GetRMS();
+ }
+ SetMeanVertex(meanver);
+ SetRmsVertex(rmsver);
+
+ gFile->Close();
+ delete gFile;
+
}
- // TFile *onl = new TFile("onl.root","RECREATE");
- // this->Write("Values");
- // onl->Close();
- // delete onl;
- gFile->Close();
- delete gFile;
+ return ok;
}