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
107 gFile = TFile::Open(laserFile);
109 AliError("No input laser data found ");
114 TH1F* hAmp = (TH1F*) gFile->Get("hAmpLaser");
116 for (Int_t ibin=0; ibin<1000; ibin++) {
117 Float_t bincont = hAmp->GetBinContent(ibin);
119 mips[nmips] = hAmp->GetXaxis()->GetBinCenter(ibin);
120 cout<<ibin<<" bincont "<<bincont<<" amp "<< mips[nmips]<<endl;
124 Float_t x1[20], y1[20];
125 Float_t x2[20], xx2[20],y2[20];
126 Float_t xx1[20],yy1[20], xx[20];
131 for (Int_t ii=0; ii<nmips; ii++)
132 x1[ii] = y1[ii] = x2[ii] = y2[ii] = 0;
134 for (Int_t i=0; i<24; i++)
136 for (Int_t im=startim; im<nmips; im++)
139 TString cfd = Form("hCFD%i_%i",i+1,im+1);
140 TString qtc = Form("hQTC%i_%i",i+1,im+1);
141 TString led = Form("hLED%i_%i",i+1,im+1);
143 TH1F *hCFD = (TH1F*) gFile->Get(cfd.Data()) ;
144 TH1F *hLED = (TH1F*) gFile->Get(led.Data());
145 TH1F *hQTC = (TH1F*) gFile->Get(qtc.Data()) ;
146 hCFD->SetDirectory(0);
147 hQTC->SetDirectory(0);
148 hLED->SetDirectory(0);
150 AliWarning(Form(" no CFD data in LASER DA for channel %i for amplitude %f MIPs",i,mips[im]));
152 AliWarning(Form(" no QTC correction data in LASER DA for channel %i for amplitude %f MIPs",i,mips[im]));
154 AliWarning(Form(" no LED correction data in LASER DA for channel %i for amplitude %f MIPs",i,mips[im]));
157 TSpectrum *s = new TSpectrum(2*npeaks,1);
158 Int_t nfound = s->Search(hCFD,sigma," ",0.1);
160 Float_t *xpeak = s->GetPositionX();
161 TMath::Sort(nfound, xpeak, index,down);
162 Float_t xp = xpeak[index[0]];
163 Double_t hmax = xp+3*sigma;
164 Double_t hmin = xp-3*sigma;
165 hCFD->GetXaxis()->SetRangeUser(hmin-10,hmax+10);
170 TSpectrum *s = new TSpectrum(2*npeaks,1);
171 Int_t nfound = s->Search(hCFD,sigma," ",0.1);
173 Float_t *xpeak = s->GetPositionX();
174 TMath::Sort(nfound, xpeak, index,down);
175 Float_t xp = xpeak[index[0]];
176 Double_t hmax = xp+3*sigma;
177 Double_t hmin = xp-3*sigma;
178 hCFD->GetXaxis()->SetRangeUser(hmin-10,hmax+10);
184 if (im == 0) cfd0[i] = hCFD->GetMean();
185 y1[im] = hCFD->GetMean() - cfd0[i];
187 if( hQTC) x1[im] = hQTC->GetMean();
190 TSpectrum *s = new TSpectrum(2*npeaks,1);
191 Int_t nfound = s->Search(hLED,sigma," ",0.1);
193 Float_t *xpeak = s->GetPositionX();
194 TMath::Sort(nfound, xpeak, index,down);
195 Float_t xp = xpeak[index[0]];
196 Double_t hmax = xp+10*sigma;
197 Double_t hmin = xp-10*sigma;
198 hLED->GetXaxis()->SetRangeUser(hmin-10,hmax+10);
202 x2[im] = hLED->GetMean();
203 xx2[im] = x2[nmips-im-1];
207 if (hQTC) delete hQTC;
208 if (hCFD) delete hCFD;
209 if (hLED) delete hLED;
212 for (Int_t imi=0; imi<nmips; imi++)
214 yy1[imi] = Float_t (mips[nmips-imi-1]);
215 xx1[imi] = x2[nmips-imi-1];
216 // cout<<" LED rev "<<i<<" "<<imi<<" "<<xx1[imi]<<" "<< yy1[imi]<<"nmips-imi-1 = "<< nmips-imi-1<<endl;
219 if(i==0) cout<<"Making graphs..."<<endl;
221 TGraph *grwalkqtc = new TGraph (nmips,x1,y1);
222 grwalkqtc->SetTitle(Form("PMT%i",i));
223 TGraph *grwalkled = new TGraph (nmips,x2,y1);
224 grwalkled->SetTitle(Form("PMT%i",i));
225 fWalk.AddAtAndExpand(grwalkqtc,i);
226 fAmpLEDRec.AddAtAndExpand(grwalkled,i);
227 // cout<<" add walk "<<i<<endl;
229 //fit amplitude graphs to make comparison wth new one
230 TGraph *grampled = new TGraph (nmips,xx1,yy1);
231 TGraph *grqtc = new TGraph (nmips,x1,xx);
232 fQTC.AddAtAndExpand(grqtc,i);
233 fAmpLED.AddAtAndExpand(grampled,i);
234 // cout<<" add amp "<<i<<endl;
237 cout<<"Graphs created..."<<endl;