1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // class for T0 calibration TM-AC-AM_6-02-2006
21 // equalize time shift for each time CFD channel
23 ///////////////////////////////////////////////////////////////////////////////
25 #include "AliT0CalibTimeEq.h"
30 #include <TSpectrum.h>
34 ClassImp(AliT0CalibTimeEq)
36 //________________________________________________________________
37 AliT0CalibTimeEq::AliT0CalibTimeEq():TNamed(),
45 //________________________________________________________________
46 AliT0CalibTimeEq::AliT0CalibTimeEq(const char* name):TNamed(),
52 TString namst = "Calib_";
54 SetName(namst.Data());
55 SetTitle(namst.Data());
58 //________________________________________________________________
59 AliT0CalibTimeEq::AliT0CalibTimeEq(const AliT0CalibTimeEq& calibda):TNamed(calibda),
64 SetName(calibda.GetName());
65 SetTitle(calibda.GetName());
70 //________________________________________________________________
71 AliT0CalibTimeEq &AliT0CalibTimeEq::operator =(const AliT0CalibTimeEq& calibda)
73 // assignment operator
74 SetName(calibda.GetName());
75 SetTitle(calibda.GetName());
80 //________________________________________________________________
81 AliT0CalibTimeEq::~AliT0CalibTimeEq()
86 //________________________________________________________________
87 void AliT0CalibTimeEq::Reset()
91 memset(fCFDvalue,0,120*sizeof(Float_t));
92 memset(fTimeEq,1,24*sizeof(Float_t));
96 //________________________________________________________________
97 void AliT0CalibTimeEq::Print(Option_t*) const
101 printf("\n ---- PM Arrays ----\n\n");
102 printf(" Time delay CFD \n");
103 for (Int_t i=0; i<24; i++) printf(" CFD %f ",fTimeEq[i]);
104 printf("\n Mean Vertex %f \n", fMeanVertex);
108 //________________________________________________________________
109 Bool_t AliT0CalibTimeEq::ComputeOnlineParams(const char* filePhys)
111 // compute online equalized time
112 Float_t meandiff, sigmadiff, meanver, meancfdtime, sigmacfdtime;
113 meandiff = sigmadiff = meanver = meancfdtime = sigmacfdtime =0;
114 // Double_t rms=0, rmscfd=0;
118 gFile = TFile::Open(filePhys);
120 AliError("No input PHYS data found ");
126 for (Int_t i=0; i<24; i++)
128 TH1F *cfd = (TH1F*) gFile->Get(Form("CFD1minCFD%d",i+1));
129 TH1F *cfdtime = (TH1F*) gFile->Get(Form("CFD%d",i+1));
130 if(!cfd) AliWarning(Form("no histograms collected by PHYS DA for channel %i", i));
131 // printf(" i = %d buf1 = %s\n", i, buf1);
133 GetMeanAndSigma(cfd, meandiff, sigmadiff);
134 nent = Int_t(cfd->GetEntries());
135 if(nent<500 || cfd->GetRMS()>20. ) {
137 AliWarning(Form("Data is not good enouph in PMT %i - mean %f rsm %f nentries %i", i,meandiff,sigmadiff , nent));
143 AliWarning(Form("Data is not good enouph in PMT %i , no clean peak", i));
145 if(!cfd) AliWarning(Form("no histograms collected by PHYS DA for channel %i", i));
147 // printf(" i = %d buf1 = %s\n", i, buf1);
149 GetMeanAndSigma(cfdtime,meancfdtime, sigmacfdtime);
150 nent = Int_t(cfdtime->GetEntries());
151 if(nent<500 || sigmacfdtime>30. ) {
153 AliWarning(Form("Data is not good enouph in PMT %i CFD data - meancfdtime %f rsm %f nentries %i", i,meancfdtime, sigmacfdtime, nent));
160 AliWarning(Form("Data is not good enouph in PMT %i , no clean peak", i));
165 SetTimeEq(i,meandiff);
166 SetTimeEqRms(i,sigmadiff);
167 SetCFDvalue(i,0,meancfdtime);
168 SetCFDvalue(i,0,sigmacfdtime);
170 if (cfdtime) delete cfdtime;
173 TH1F *ver = (TH1F*) gFile->Get("hVertex");
174 if(!ver) AliWarning("no T0 histogram collected by PHYS DA ");
176 meanver = ver->GetMean();
177 rmsver = ver->GetRMS();
179 SetMeanVertex(meanver);
180 SetRmsVertex(rmsver);
189 //________________________________________________________________
190 Bool_t AliT0CalibTimeEq::ComputeOfflineParams(const char* filePhys)
192 // compute online equalized time
193 Float_t meandiff, sigmadiff, meanver, meancfdtime, sigmacfdtime;
194 meandiff = sigmadiff = meanver = meancfdtime = sigmacfdtime =0;
195 // Double_t rms=0, rmscfd=0;
199 gFile = TFile::Open(filePhys);
201 AliError("No input PHYS data found ");
207 TObjArray * TzeroObj = (TObjArray*) gFile->Get("fTzeroObject");
208 for (Int_t i=0; i<24; i++)
210 TH1F *cfddiff = (TH1F*)TzeroObj->At(i);
211 TH1F *cfdtime = (TH1F*)TzeroObj->At(i+24);
212 if(!cfddiff) AliWarning(Form("no histograms collected by PHYS DA for channel %i", i));
213 // printf(" i = %d buf1 = %s\n", i, buf1);
215 GetMeanAndSigma(cfddiff,meandiff, sigmadiff);
216 nent = Int_t(cfddiff->GetEntries());
217 if(nent<500 || cfddiff->GetRMS()>20. ) {
219 AliWarning(Form("Data is not good enouph in PMT %i - mean %f rsm %f nentries %i", i,meandiff,sigmadiff, nent));
225 AliWarning(Form("Data is not good enouph in PMT %i , no clean peak", i));
227 if(!cfdtime) AliWarning(Form("no histograms collected by PHYS DA for channel %i", i));
228 // printf(" i = %d buf1 = %s\n", i, buf1);
230 GetMeanAndSigma(cfdtime,meancfdtime, sigmacfdtime);
231 nent = Int_t(cfdtime->GetEntries());
232 if(nent<500 || cfdtime->GetRMS()>30. ) {
234 AliWarning(Form("Data is not good enouph in PMT %i CFD data - mean %f rsm %f nentries %i", i,meancfdtime, sigmacfdtime, nent));
241 AliWarning(Form("Data is not good enouph in PMT %i , no clean peak", i));
246 SetTimeEq(i,meandiff);
247 SetTimeEqRms(i,sigmadiff);
248 SetCFDvalue(i,0,meancfdtime);
249 SetCFDvalue(i,0,sigmacfdtime);
250 if (cfddiff) delete cfddiff;
251 if (cfdtime) delete cfdtime;
254 TH1F *ver = (TH1F*) gFile->Get("hVertex");
255 if(!ver) AliWarning("no T0 histogram collected by PHYS DA ");
257 meanver = ver->GetMean();
258 rmsver = ver->GetRMS();
260 SetMeanVertex(meanver);
261 SetRmsVertex(rmsver);
270 //________________________________________________________________________
271 void AliT0CalibTimeEq::GetMeanAndSigma(TH1F* hist, Float_t &mean, Float_t &sigma) {
273 const double window = 5.; //fit window
274 double norm = hist->Integral(); // normalize to one count
275 hist->Scale(1./norm);
277 double meanEstimate, sigmaEstimate;
279 maxBin = hist->GetMaximumBin(); //position of maximum
280 meanEstimate = hist->GetBinCenter( maxBin); // mean of gaussian sitting in maximum
281 sigmaEstimate = hist->GetRMS();
282 TF1* fit= new TF1("fit","gaus", meanEstimate - window*sigmaEstimate, meanEstimate + window*sigmaEstimate);
283 fit->SetParameters(hist->GetBinContent(maxBin), meanEstimate, sigmaEstimate);
284 hist->Fit("fit","R");
286 mean = (Float_t) fit->GetParameter(1);
287 sigma = (Float_t) fit->GetParameter(2);