]>
Commit | Line | Data |
---|---|---|
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 | **************************************************************************/ | |
15 | ||
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" | |
25 | #include "AliLog.h" | |
26 | ||
27 | #include <TObjArray.h> | |
28 | #include <TGraph.h> | |
29 | #include <TFile.h> | |
30 | #include <TH2F.h> | |
31 | #include <TMath.h> | |
32 | #include <TSystem.h> | |
33 | #include <Riostream.h> | |
34 | #include <TSpectrum.h> | |
35 | #include <TProfile.h> | |
36 | #include <TF1.h> | |
37 | ||
38 | ClassImp(AliT0CalibWalk) | |
39 | ||
40 | //________________________________________________________________ | |
41 | AliT0CalibWalk::AliT0CalibWalk(): TNamed(), | |
42 | fWalk(0), | |
43 | fAmpLEDRec(0), | |
44 | fQTC(0), | |
45 | fAmpLED(0) | |
46 | { | |
47 | // | |
48 | } | |
49 | ||
50 | //________________________________________________________________ | |
51 | AliT0CalibWalk::AliT0CalibWalk(const char* name):TNamed(), | |
52 | fWalk(0), | |
53 | fAmpLEDRec(0), fQTC(0), | |
54 | fAmpLED(0) | |
55 | ||
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), | |
68 | fAmpLEDRec(0), | |
69 | fQTC(0), | |
70 | fAmpLED(0) | |
71 | ||
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 | } | |
95 | //________________________________________________________________ | |
96 | void AliT0CalibWalk::SetWalk(Int_t ipmt) | |
97 | { | |
98 | //read QTC walk graph from external file | |
99 | ||
100 | Int_t mv, ps; | |
101 | Int_t x[70000], y[70000], index[70000]; | |
102 | Float_t time[10000],amplitude[10000]; | |
103 | string buffer; | |
104 | Bool_t down=false; | |
105 | ||
106 | const char * filename = gSystem->ExpandPathName("$ALICE_ROOT/T0/data/CFD-Amp.txt"); | |
107 | ifstream inFile(filename); | |
108 | if(!inFile) AliError(Form("Cannot open file %s !",filename)); | |
109 | ||
110 | Int_t i=0; | |
111 | while(getline(inFile,buffer)){ | |
112 | inFile >> ps >> mv; | |
113 | ||
114 | x[i]=ps; y[i]=mv; | |
115 | i++; | |
116 | } | |
117 | inFile.close(); | |
118 | // cout<<" number of data "<<i<<endl; | |
119 | ||
120 | TMath::Sort(i, y, index,down); | |
121 | Int_t amp=0, iin=0, isum=0, sum=0; | |
122 | Int_t ind=0; | |
123 | for (Int_t ii=0; ii<i; ii++) | |
124 | { | |
125 | ind=index[ii]; | |
126 | if(y[ind] == amp) | |
127 | { | |
128 | sum +=x[ind]; | |
129 | iin++; | |
130 | } | |
131 | else | |
132 | { | |
133 | if(iin>0) | |
134 | time[isum] = Float_t (sum/(iin)); | |
135 | else | |
136 | time[isum] =Float_t (x[ind]); | |
137 | amplitude[isum] = Float_t (amp); | |
138 | amp=y[ind]; | |
139 | iin=0; | |
140 | isum++; | |
141 | sum=0; | |
142 | } | |
143 | } | |
144 | ||
145 | inFile.close(); | |
146 | ||
147 | TGraph* gr = new TGraph(isum, amplitude, time); | |
148 | fWalk.AddAtAndExpand(gr,ipmt); | |
149 | ||
150 | //should be change to real | |
151 | Double_t xq[10] = { 1220, 1370, 1542, 1697, 1860, 2023,2171,2331,2495,2684}; | |
152 | Double_t yq[10] = {1,2,3,4,5,6,7,8,9,10}; | |
153 | TGraph* gr1 = new TGraph(10, xq, yq); | |
154 | fQTC.AddAtAndExpand(gr1,ipmt); | |
155 | } | |
156 | ||
157 | //________________________________________________________________ | |
158 | ||
159 | void AliT0CalibWalk::SetAmpLEDRec(Int_t ipmt) | |
160 | { | |
161 | // read LED walk from external file | |
162 | Float_t mv, ps; | |
163 | Float_t x[100], y[100]; | |
164 | string buffer; | |
165 | ||
166 | const char * filename = gSystem->ExpandPathName("$ALICE_ROOT/T0/data/CFD-LED.txt"); | |
167 | ifstream inFile(filename); | |
168 | if(!inFile) {AliError(Form("Cannot open file %s !",filename));} | |
169 | ||
170 | inFile >> mv>>ps; | |
171 | Int_t i=0; | |
172 | ||
173 | while(getline(inFile,buffer)){ | |
174 | x[i]=mv; y[i]=ps; | |
175 | inFile >> mv >> ps; | |
176 | i++; | |
177 | } | |
178 | inFile.close(); | |
179 | Float_t y1[100], x1[100]; | |
180 | for (Int_t ir=0; ir<i; ir++){ | |
181 | y1[ir]=y[i-ir]; x1[ir]=x[i-ir];} | |
182 | TGraph* gr = new TGraph(i,y1,x1); | |
183 | fAmpLEDRec.AddAtAndExpand(gr,ipmt); | |
184 | //should be change to real | |
185 | Double_t xq[10] = { 411, 412,413,415,417,419,422,428,437,452}; | |
186 | Double_t yq[10] = {1,2,3,4,5,6,7,8,9,10}; | |
187 | TGraph* gr1 = new TGraph(10, xq, yq); | |
188 | fAmpLED.AddAtAndExpand(gr1,ipmt); | |
189 | ||
190 | } | |
191 | ||
192 | //________________________________________________________________ | |
193 | ||
194 | void AliT0CalibWalk::MakeWalkCorrGraph(const char *laserFile) | |
195 | { | |
196 | //make walk corerction for preprocessor | |
197 | Int_t nmips=14; | |
198 | gFile = TFile::Open(laserFile); | |
199 | if(!gFile) { | |
200 | AliError("No input laser data found "); | |
201 | } | |
202 | else | |
203 | { | |
204 | // gFile->ls(); | |
205 | ||
206 | Float_t x1[14], y1[14]; | |
207 | Float_t x2[14], y2[14]; | |
208 | ||
209 | Float_t mips[14] = {1.,2,3,4,5,6,7,8,9,10,20,30,40,50}; | |
210 | ||
211 | Float_t xx1[14],yy1[14], xx[14]; | |
212 | for (Int_t ii=0; ii<14; ii++) | |
213 | { x1[ii]=0; y1[ii]=0; x2[ii]=0; y2[ii]=0; } | |
214 | ||
215 | ||
216 | TH2F* hCFDvsQTC[24][14]; TH2F* hCFDvsLED[24][14]; | |
217 | ||
218 | for (Int_t i=0; i<24; i++) | |
219 | { | |
220 | for (Int_t im=0; im<nmips; im++) | |
221 | { | |
222 | TString qtc = Form("CFDvsQTC%i_%i",i+1,im+1); | |
223 | TString led = Form("CFDvsLED%i_%i",i+1,im+1); | |
224 | hCFDvsQTC[i][im] = (TH2F*) gFile->Get(qtc.Data()) ; | |
225 | hCFDvsLED[i][im] = (TH2F*) gFile->Get(led.Data()); | |
226 | ||
227 | if(!hCFDvsQTC[i][im] || !hCFDvsLED[i][im]) | |
228 | AliWarning(Form(" no walk correction data in LASER DA for channel %i for amplitude %f MIPs",i,mips[im])); | |
229 | ||
230 | Float_t qtc0 = hCFDvsQTC[i][0]->GetMean(2); | |
231 | if(hCFDvsQTC[i][im]) | |
232 | { | |
233 | x1[im] = hCFDvsQTC[i][im]->GetMean(1); | |
234 | y1[im] = hCFDvsQTC[i][im]->GetMean(2) - qtc0; | |
235 | } | |
236 | Float_t led0 = hCFDvsLED[i][0]->GetMean(2); | |
237 | if( hCFDvsLED[i][im]){ | |
238 | x2[im] = hCFDvsLED[i][im]->GetMean(1); | |
239 | y2[im] = hCFDvsLED[i][im]->GetMean(2) - led0; | |
240 | } | |
241 | xx[im]=mips[im]; | |
242 | } | |
243 | for (Int_t imi=0; imi<nmips; imi++) | |
244 | { | |
245 | yy1[imi] = Float_t (mips[nmips-imi-1]); | |
246 | xx1[imi] = x2[nmips-imi-1]; | |
247 | } | |
248 | if(i==0) cout<<"Making graphs..."<<endl; | |
249 | ||
250 | TGraph *grwalkqtc = new TGraph (nmips,x1,y1); | |
251 | TGraph *grwalkled = new TGraph (nmips,x2,y2); | |
252 | fWalk.AddAtAndExpand(grwalkqtc,i); | |
253 | fAmpLEDRec.AddAtAndExpand(grwalkled,i); | |
254 | ||
255 | //fit amplitude graphs to make comparison wth new one | |
256 | TGraph *grampled = new TGraph (nmips,xx1,yy1); | |
257 | TGraph *grqtc = new TGraph (nmips,x1,xx); | |
258 | fQTC.AddAtAndExpand(grqtc,i); | |
259 | fAmpLED.AddAtAndExpand(grampled,i); | |
260 | ||
261 | //fit amplitude graphs | |
262 | Double_t parled [2], parqtc[2]; | |
263 | ||
264 | TF1 *fuled = new TF1("fuled","expo",x1[0],x1[nmips]); | |
265 | TF1 *fuqtc = new TF1 ("fuqtc","pol1",x1[0],x1[nmips]); | |
266 | grqtc->Fit("fuqtc","Q"," ",x1[0],x1[nmips]); | |
267 | grampled->Fit("fuled","Q"," ",xx1[0],xx1[nmips]); | |
268 | fuled->GetParameters(&parled[0]); | |
269 | fuqtc->GetParameters(&parqtc[0]); | |
270 | ||
271 | for(Int_t ipar=0; ipar<2; ipar++) { | |
272 | SetQTCpar(i,ipar,parqtc[ipar]); | |
273 | SetAmpLEDpar(i,ipar,parled[ipar]); | |
274 | // cout<<" pars :::: "<<i<<" "<<ipar<<" qtc "<<parqtc[ipar]<<" led "<<parled[ipar]<<endl; | |
275 | } | |
276 | ||
277 | if(i==23){ | |
278 | cout<<"Graphs created..."<<endl; | |
279 | } | |
280 | } | |
281 | } //if gFile exits | |
282 | } | |
283 | ||
284 | ||
285 | ||
286 |