]>
Commit | Line | Data |
---|---|---|
a2ad8166 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
271b5bd3 | 15 | |
a2ad8166 | 16 | /* $Id$ */ |
17 | ||
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // class T0 walk correction Alla Maevskaya alla@inr.ru 20.11.2007 // | |
21 | // // | |
22 | /////////////////////////////////////////////////////////////////////////////// | |
23 | ||
24 | #include "AliT0CalibWalk.h" | |
a2ad8166 | 25 | #include "AliLog.h" |
a2ad8166 | 26 | |
27 | #include <TObjArray.h> | |
28 | #include <TGraph.h> | |
29 | #include <TFile.h> | |
a2ad8166 | 30 | #include <TH2F.h> |
31 | #include <TMath.h> | |
32 | #include <TSystem.h> | |
33 | #include <Riostream.h> | |
34 | #include <TSpectrum.h> | |
a2ad8166 | 35 | #include <TProfile.h> |
8f1790c4 | 36 | #include <TF1.h> |
a2ad8166 | 37 | |
38 | ClassImp(AliT0CalibWalk) | |
39 | ||
40 | //________________________________________________________________ | |
41 | AliT0CalibWalk::AliT0CalibWalk(): TNamed(), | |
42 | fWalk(0), | |
c883fdf2 | 43 | fAmpLEDRec(0), |
44 | fQTC(0), | |
45 | fAmpLED(0) | |
a2ad8166 | 46 | { |
47 | // | |
48 | } | |
49 | ||
50 | //________________________________________________________________ | |
51 | AliT0CalibWalk::AliT0CalibWalk(const char* name):TNamed(), | |
52 | fWalk(0), | |
c883fdf2 | 53 | fAmpLEDRec(0), fQTC(0), |
54 | fAmpLED(0) | |
55 | ||
a2ad8166 | 56 | { |
57 | TString namst = "Calib_"; | |
58 | namst += name; | |
59 | SetName(namst.Data()); | |
60 | SetTitle(namst.Data()); | |
61 | ||
62 | } | |
63 | ||
64 | //________________________________________________________________ | |
65 | AliT0CalibWalk::AliT0CalibWalk(const AliT0CalibWalk& calibda) : | |
66 | TNamed(calibda), | |
67 | fWalk(0), | |
c883fdf2 | 68 | fAmpLEDRec(0), |
69 | fQTC(0), | |
70 | fAmpLED(0) | |
71 | ||
a2ad8166 | 72 | { |
73 | // copy constructor | |
74 | SetName(calibda.GetName()); | |
75 | SetTitle(calibda.GetName()); | |
76 | ||
77 | ||
78 | } | |
79 | ||
80 | //________________________________________________________________ | |
81 | AliT0CalibWalk &AliT0CalibWalk::operator =(const AliT0CalibWalk& calibda) | |
82 | { | |
83 | // assignment operator | |
84 | SetName(calibda.GetName()); | |
85 | SetTitle(calibda.GetName()); | |
86 | ||
87 | return *this; | |
88 | } | |
89 | ||
90 | //________________________________________________________________ | |
91 | AliT0CalibWalk::~AliT0CalibWalk() | |
92 | { | |
93 | // | |
94 | } | |
d95247c3 | 95 | //________________________________________________________________ |
a2ad8166 | 96 | |
d95247c3 | 97 | Bool_t AliT0CalibWalk::MakeWalkCorrGraph(const char *laserFile) |
a2ad8166 | 98 | { |
7576945f | 99 | //make walk corerction for preprocessor |
8704b209 | 100 | Float_t sigma,cfdmean, qtmean, ledmean; |
d95247c3 | 101 | Bool_t ok=true; |
ff49b4c0 | 102 | Float_t mips[50]; |
d95247c3 | 103 | |
c2337900 | 104 | gFile = TFile::Open(laserFile); |
6318dd46 | 105 | if(!gFile) { |
106 | AliError("No input laser data found "); | |
107 | } | |
108 | else | |
109 | { | |
8f1790c4 | 110 | // gFile->ls(); |
d95247c3 | 111 | TH1F* hAmp = (TH1F*) gFile->Get("hAmpLaser"); |
112 | Int_t nmips=0; | |
99584f2a | 113 | for (Int_t ibin=0; ibin<2000; ibin++) { |
d95247c3 | 114 | Float_t bincont = hAmp->GetBinContent(ibin); |
115 | if(bincont>0){ | |
116 | mips[nmips] = hAmp->GetXaxis()->GetBinCenter(ibin); | |
117 | cout<<ibin<<" bincont "<<bincont<<" amp "<< mips[nmips]<<endl; | |
118 | nmips++; | |
119 | } | |
c69fcbc1 | 120 | } |
121 | ||
07342b9d | 122 | if (nmips<17) { |
123 | ok=false; | |
124 | return ok; | |
125 | } | |
c69fcbc1 | 126 | |
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]; | |
95f63b36 | 130 | |
612737bb | 131 | Float_t cfd0 = 0; |
95f63b36 | 132 | |
d95247c3 | 133 | for (Int_t ii=0; ii<nmips; ii++) |
134 | x1[ii] = y1[ii] = x2[ii] = y2[ii] = 0; | |
95f63b36 | 135 | |
136 | for (Int_t i=0; i<24; i++) | |
c883fdf2 | 137 | { |
612737bb | 138 | cfd0 = 0; |
139 | for (Int_t im=0; im<nmips; im++) | |
8f1790c4 | 140 | { |
d95247c3 | 141 | TString cfd = Form("hCFD%i_%i",i+1,im+1); |
142 | TString qtc = Form("hQTC%i_%i",i+1,im+1); | |
3740a735 | 143 | TString led = Form("hLED%i_%i",i+1,im+1); |
95f63b36 | 144 | |
d95247c3 | 145 | TH1F *hCFD = (TH1F*) gFile->Get(cfd.Data()) ; |
146 | TH1F *hLED = (TH1F*) gFile->Get(led.Data()); | |
147 | TH1F *hQTC = (TH1F*) gFile->Get(qtc.Data()) ; | |
ff49b4c0 | 148 | // hCFD->SetDirectory(0); |
149 | // hQTC->SetDirectory(0); | |
150 | // hLED->SetDirectory(0); | |
d95247c3 | 151 | if(!hCFD ) |
152 | AliWarning(Form(" no CFD data in LASER DA for channel %i for amplitude %f MIPs",i,mips[im])); | |
153 | if(!hQTC ) | |
154 | AliWarning(Form(" no QTC correction data in LASER DA for channel %i for amplitude %f MIPs",i,mips[im])); | |
155 | if(!hLED) | |
156 | AliWarning(Form(" no LED correction data in LASER DA for channel %i for amplitude %f MIPs",i,mips[im])); | |
8704b209 | 157 | if( hCFD && hCFD->GetEntries()<500 ) { |
158 | ok=false; | |
159 | printf("no peak in CFD spectrum for PMT %i amplitude %i\n",i,im); | |
160 | return ok; | |
161 | } | |
ff49b4c0 | 162 | |
8704b209 | 163 | if(hCFD && hCFD->GetEntries()>500 ) { |
164 | if( hCFD->GetRMS() >= 1.5) | |
165 | GetMeanAndSigma(hCFD, cfdmean, sigma); | |
166 | else | |
167 | cfdmean = hCFD->GetMean(); | |
168 | ||
612737bb | 169 | if(TMath::Abs(hCFD->GetMean() - cfdmean) >10 ) cfdmean = hCFD->GetMean(); |
170 | if (im == 0) cfd0 = cfdmean; | |
171 | y1[im] = cfdmean - cfd0; | |
8704b209 | 172 | } |
173 | if(hQTC && hQTC->GetEntries()>500) { | |
174 | GetMeanAndSigma(hQTC, qtmean, sigma); | |
175 | ||
176 | x1[im] = qtmean; | |
177 | if( x1[im] == 0) { | |
07342b9d | 178 | ok=false; |
8704b209 | 179 | printf("no peak in QTC signal for PMT %i amplitude %i\n",i,im); |
07342b9d | 180 | return ok; |
ff49b4c0 | 181 | } |
8704b209 | 182 | } |
ff49b4c0 | 183 | |
8704b209 | 184 | if( hLED && hLED->GetEntries()>500) { |
185 | GetMeanAndSigma(hLED, ledmean, sigma); | |
186 | } | |
187 | else | |
188 | { | |
189 | ok=false; | |
190 | printf("no peak in LED spectrum for PMT %i amplitude %i\n",i,im); | |
191 | return ok; | |
95f63b36 | 192 | } |
8704b209 | 193 | x2[im] = ledmean; |
194 | xx2[im] = x2[nmips-im-1]; | |
ff49b4c0 | 195 | |
196 | xx[im]=mips[im]; | |
197 | if (hQTC) delete hQTC; | |
198 | if (hCFD) delete hCFD; | |
199 | if (hLED) delete hLED; | |
200 | ||
e47b556f | 201 | } |
d95247c3 | 202 | |
8f1790c4 | 203 | for (Int_t imi=0; imi<nmips; imi++) |
95f63b36 | 204 | { |
8f1790c4 | 205 | yy1[imi] = Float_t (mips[nmips-imi-1]); |
206 | xx1[imi] = x2[nmips-imi-1]; | |
d95247c3 | 207 | // cout<<" LED rev "<<i<<" "<<imi<<" "<<xx1[imi]<<" "<< yy1[imi]<<"nmips-imi-1 = "<< nmips-imi-1<<endl; |
95f63b36 | 208 | } |
95f63b36 | 209 | |
d95247c3 | 210 | if(i==0) cout<<"Making graphs..."<<endl; |
99584f2a | 211 | |
8704b209 | 212 | TGraph *grwalkqtc = new TGraph (nmips,x1,y1); |
99584f2a | 213 | grwalkqtc->SetTitle(Form("PMT%i",i)); |
1daa10df | 214 | TGraph *grwalkled = new TGraph (nmips,x2,y1); |
99584f2a | 215 | grwalkled->SetTitle(Form("PMT%i",i)); |
216 | fWalk.AddAtAndExpand(grwalkqtc,i); | |
217 | fAmpLEDRec.AddAtAndExpand(grwalkled,i); | |
218 | // cout<<" add walk "<<i<<endl; | |
219 | ||
220 | //fit amplitude graphs to make comparison wth new one | |
1daa10df | 221 | TGraph *grampled = new TGraph (nmips,xx1,yy1); |
222 | TGraph *grqtc = new TGraph (nmips,x1,xx); | |
99584f2a | 223 | fQTC.AddAtAndExpand(grqtc,i); |
224 | fAmpLED.AddAtAndExpand(grampled,i); | |
225 | // cout<<" add amp "<<i<<endl; | |
226 | ||
227 | if(i==23) | |
228 | cout<<"Graphs created..."<<endl; | |
271b5bd3 | 229 | } |
6318dd46 | 230 | } //if gFile exits |
07342b9d | 231 | |
d95247c3 | 232 | return ok; |
a2ad8166 | 233 | } |
234 | ||
ff49b4c0 | 235 | void AliT0CalibWalk::GetMeanAndSigma(TH1F* hist, Float_t &mean, Float_t &sigma) |
236 | { | |
237 | ||
238 | const double window = 5.; //fit window | |
ff49b4c0 | 239 | |
240 | double meanEstimate, sigmaEstimate; | |
241 | int maxBin; | |
242 | maxBin = hist->GetMaximumBin(); //position of maximum | |
243 | meanEstimate = hist->GetBinCenter( maxBin); // mean of gaussian sitting in maximum | |
244 | sigmaEstimate = hist->GetRMS(); | |
245 | TF1* fit= new TF1("fit","gaus", meanEstimate - window*sigmaEstimate, meanEstimate + window*sigmaEstimate); | |
246 | fit->SetParameters(hist->GetBinContent(maxBin), meanEstimate, sigmaEstimate); | |
247 | hist->Fit("fit","RQ","Q"); | |
248 | ||
249 | mean = (Float_t) fit->GetParameter(1); | |
250 | sigma = (Float_t) fit->GetParameter(2); | |
251 | ||
252 | delete fit; | |
253 | } | |
c883fdf2 | 254 | |
255 | ||
256 |