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 T0 walk correction Alla Maevskaya alla@inr.ru 20.11.2007 //
22 ///////////////////////////////////////////////////////////////////////////////
24 #include "AliT0CalibWalk.h"
27 #include <TObjArray.h>
33 #include <Riostream.h>
34 #include <TSpectrum.h>
38 ClassImp(AliT0CalibWalk)
40 //________________________________________________________________
41 AliT0CalibWalk::AliT0CalibWalk(): TNamed(),
50 //________________________________________________________________
51 AliT0CalibWalk::AliT0CalibWalk(const char* name):TNamed(),
53 fAmpLEDRec(0), fQTC(0),
57 TString namst = "Calib_";
59 SetName(namst.Data());
60 SetTitle(namst.Data());
64 //________________________________________________________________
65 AliT0CalibWalk::AliT0CalibWalk(const AliT0CalibWalk& calibda) :
74 SetName(calibda.GetName());
75 SetTitle(calibda.GetName());
80 //________________________________________________________________
81 AliT0CalibWalk &AliT0CalibWalk::operator =(const AliT0CalibWalk& calibda)
83 // assignment operator
84 SetName(calibda.GetName());
85 SetTitle(calibda.GetName());
90 //________________________________________________________________
91 AliT0CalibWalk::~AliT0CalibWalk()
95 //________________________________________________________________
97 Bool_t AliT0CalibWalk::MakeWalkCorrGraph(const char *laserFile)
99 //make walk corerction for preprocessor
100 Float_t sigma,cfdmean, qtmean, ledmean;
104 gFile = TFile::Open(laserFile);
106 AliError("No input laser data found ");
111 TH1F* hAmp = (TH1F*) gFile->Get("hAmpLaser");
113 for (Int_t ibin=0; ibin<2000; ibin++) {
114 Float_t bincont = hAmp->GetBinContent(ibin);
116 mips[nmips] = hAmp->GetXaxis()->GetBinCenter(ibin);
117 cout<<ibin<<" bincont "<<bincont<<" amp "<< mips[nmips]<<endl;
127 Float_t x1[50], y1[50];
128 Float_t x2[50], xx2[50],y2[50];
129 Float_t xx1[50],yy1[50], xx[50];
133 for (Int_t ii=0; ii<nmips; ii++)
134 x1[ii] = y1[ii] = x2[ii] = y2[ii] = 0;
136 for (Int_t i=0; i<24; i++)
139 for (Int_t im=0; im<nmips; im++)
141 TString cfd = Form("hCFD%i_%i",i+1,im+1);
142 TString qtc = Form("hQTC%i_%i",i+1,im+1);
143 TString led = Form("hLED%i_%i",i+1,im+1);
145 TH1F *hCFD = (TH1F*) gFile->Get(cfd.Data()) ;
146 TH1F *hLED = (TH1F*) gFile->Get(led.Data());
147 TH1F *hQTC = (TH1F*) gFile->Get(qtc.Data()) ;
148 // hCFD->SetDirectory(0);
149 // hQTC->SetDirectory(0);
150 // hLED->SetDirectory(0);
152 AliWarning(Form(" no CFD data in LASER DA for channel %i for amplitude %f MIPs",i,mips[im]));
154 AliWarning(Form(" no QTC correction data in LASER DA for channel %i for amplitude %f MIPs",i,mips[im]));
156 AliWarning(Form(" no LED correction data in LASER DA for channel %i for amplitude %f MIPs",i,mips[im]));
157 if( hCFD && hCFD->GetEntries()<500 ) {
159 printf("no peak in CFD spectrum for PMT %i amplitude %i\n",i,im);
162 if(hCFD && hCFD->GetEntries()>500 ) {
163 if( hCFD->GetRMS() >= 1.5)
164 GetMeanAndSigma(hCFD, cfdmean, sigma);
166 cfdmean = hCFD->GetMean();
168 Int_t maxBin = hCFD->GetMaximumBin();
169 Double_t meanEstimate = hCFD->GetBinCenter( maxBin);
170 if(TMath::Abs(meanEstimate - cfdmean) > 20 ) cfdmean = meanEstimate;
171 if (im == 0) cfd0 = cfdmean;
172 y1[im] = cfdmean - cfd0;
174 if(hQTC && hQTC->GetEntries()>500) {
175 GetMeanAndSigma(hQTC, qtmean, sigma);
180 printf("no peak in QTC signal for PMT %i amplitude %i\n",i,im);
185 if( hLED && hLED->GetEntries()>500) {
186 GetMeanAndSigma(hLED, ledmean, sigma);
191 printf("no peak in LED spectrum for PMT %i amplitude %i\n",i,im);
195 xx2[im] = x2[nmips-im-1];
198 if (hQTC) delete hQTC;
199 if (hCFD) delete hCFD;
200 if (hLED) delete hLED;
204 for (Int_t imi=0; imi<nmips; imi++)
206 yy1[imi] = Float_t (mips[nmips-imi-1]);
207 xx1[imi] = x2[nmips-imi-1];
208 // cout<<" LED rev "<<i<<" "<<imi<<" "<<xx1[imi]<<" "<< yy1[imi]<<"nmips-imi-1 = "<< nmips-imi-1<<endl;
211 if(i==0) cout<<"Making graphs..."<<endl;
213 TGraph *grwalkqtc = new TGraph (nmips,x1,y1);
214 grwalkqtc->SetTitle(Form("PMT%i",i));
215 TGraph *grwalkled = new TGraph (nmips,x2,y1);
216 grwalkled->SetTitle(Form("PMT%i",i));
217 fWalk.AddAtAndExpand(grwalkqtc,i);
218 fAmpLEDRec.AddAtAndExpand(grwalkled,i);
219 // cout<<" add walk "<<i<<endl;
221 //fit amplitude graphs to make comparison wth new one
222 TGraph *grampled = new TGraph (nmips,xx1,yy1);
223 TGraph *grqtc = new TGraph (nmips,x1,xx);
224 fQTC.AddAtAndExpand(grqtc,i);
225 fAmpLED.AddAtAndExpand(grampled,i);
226 // cout<<" add amp "<<i<<endl;
229 cout<<"Graphs created..."<<endl;
236 void AliT0CalibWalk::GetMeanAndSigma(TH1F* hist, Float_t &mean, Float_t &sigma)
239 const double window = 2.; //fit window
241 double meanEstimate, sigmaEstimate;
243 maxBin = hist->GetMaximumBin(); //position of maximum
244 meanEstimate = hist->GetBinCenter( maxBin); // mean of gaussian sitting in maximum
245 sigmaEstimate = hist->GetRMS();
246 TF1* fit= new TF1("fit","gaus", meanEstimate - window*sigmaEstimate, meanEstimate + window*sigmaEstimate);
247 fit->SetParameters(hist->GetBinContent(maxBin), meanEstimate, sigmaEstimate);
248 hist->Fit("fit","RQ","Q");
250 mean = (Float_t) fit->GetParameter(1);
251 sigma = (Float_t) fit->GetParameter(2);
252 printf(" mean %f max %f sigma %f \n",mean, meanEstimate , sigma);