]>
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> |
36 | ||
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 | } | |
95 | //________________________________________________________________ | |
96 | void AliT0CalibWalk::SetWalk(Int_t ipmt) | |
97 | { | |
7576945f | 98 | //read QTC walk graph from external file |
a2ad8166 | 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); | |
c883fdf2 | 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); | |
a2ad8166 | 155 | } |
156 | ||
157 | //________________________________________________________________ | |
158 | ||
159 | void AliT0CalibWalk::SetAmpLEDRec(Int_t ipmt) | |
160 | { | |
7576945f | 161 | // read LED walk from external file |
a2ad8166 | 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); | |
c883fdf2 | 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); | |
a2ad8166 | 189 | |
190 | } | |
191 | ||
192 | //________________________________________________________________ | |
193 | ||
194 | void AliT0CalibWalk::MakeWalkCorrGraph(const char *laserFile) | |
195 | { | |
7576945f | 196 | //make walk corerction for preprocessor |
c883fdf2 | 197 | |
198 | Double_t *grY ; //= new grY[2500] ; | |
199 | Double_t *grX ; | |
a2ad8166 | 200 | TFile *gFile = TFile::Open(laserFile); |
c883fdf2 | 201 | // gFile->ls(); |
c883fdf2 | 202 | Float_t x1[10], y1[10]; |
203 | Float_t x2[10], y2[10]; | |
204 | ||
205 | Float_t xx1[10],yy1[10], xx[10]; | |
206 | ||
700e6b36 | 207 | |
c883fdf2 | 208 | TH2F* hCFDvsQTC[24][10]; TH2F* hCFDvsLED[24][10]; |
209 | ||
700e6b36 | 210 | for (Int_t i=0; i<24; i++) |
a2ad8166 | 211 | { |
c883fdf2 | 212 | for (Int_t im=0; im<10; im++) |
213 | { | |
214 | ||
215 | TString qtc = Form("QTCvsCFD%i_%i",i+1,im+1); | |
216 | TString led = Form("LEDvsCFD%i_%i",i+1,im+1); | |
217 | hCFDvsQTC[i][im] = (TH2F*) gFile->Get(qtc.Data()) ; | |
218 | hCFDvsLED[i][im] = (TH2F*) gFile->Get(led.Data()); | |
2e6a5ee0 | 219 | |
c883fdf2 | 220 | x1[im] = hCFDvsQTC[i][im]->GetMean(1); |
221 | y1[im] = hCFDvsQTC[i][im]->GetMean(2); | |
222 | x2[im] = hCFDvsLED[i][im]->GetMean(1); | |
223 | y2[im] = hCFDvsLED[i][im]->GetMean(2); | |
224 | xx[im]=im+1; | |
225 | //cout<<" qtc "<< x1[im]<<" "<< y1[im]<<endl; | |
226 | } | |
227 | for (Int_t imi=0; imi<10; imi++) | |
228 | { | |
229 | yy1[imi] = Float_t (10-imi); | |
230 | xx1[imi]=x2[10-imi-1]; | |
231 | ||
232 | // cout<<i<<" "<<imi<<" "<<" qtc " <<x1[imi]<<" "<<xx[imi]<< | |
233 | // " led "<<x2[imi]<<" "<<y2[imi]<<" led2d "<<yy1[imi]<<" "<<xx1[imi]<<endl; | |
234 | } | |
271b5bd3 | 235 | if(i==0){ |
236 | cout<<"Making graphs..."<<endl; | |
237 | } | |
c883fdf2 | 238 | TGraph *gr1 = new TGraph (10,x1,y1); |
239 | TGraph *gr2 = new TGraph (10,x2,y2); | |
240 | fWalk.AddAtAndExpand(gr1,i); | |
241 | fAmpLEDRec.AddAtAndExpand(gr2,i); | |
242 | ||
700e6b36 | 243 | |
c883fdf2 | 244 | |
245 | TGraph *gr4 = new TGraph (10,xx1,yy1); | |
246 | TGraph *gr3 = new TGraph (10,x1,xx); | |
247 | /* | |
248 | if(gr4) { | |
249 | Int_t np=gr4->GetN(); | |
250 | if(np>0) { | |
251 | grY = gr4->GetY(); | |
252 | grX = gr4->GetX(); | |
253 | for (Int_t ig=0; ig<np; ig++) | |
254 | cout<<i<<" "<<ig<<" "<<grX[ig]<<" "<<grY[ig]<<" eval "<<gr4->Eval(grX[ig])<<endl; | |
255 | } | |
700e6b36 | 256 | } |
c883fdf2 | 257 | */ |
258 | fQTC.AddAtAndExpand(gr3,i); | |
259 | fAmpLED.AddAtAndExpand(gr4,i); | |
260 | // for (Int_t im=0; im<10; im++) { x2[im]=0; y2[im]=0; xx1[im]=0; xx[im]=0;} | |
271b5bd3 | 261 | if(i==23){ |
262 | cout<<"Graphs created..."<<endl; | |
263 | } | |
a2ad8166 | 264 | } |
a2ad8166 | 265 | } |
266 | ||
c883fdf2 | 267 | |
268 | ||
269 |