]>
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 | |
c2337900 | 198 | gFile = TFile::Open(laserFile); |
6318dd46 | 199 | if(!gFile) { |
200 | AliError("No input laser data found "); | |
201 | } | |
202 | else | |
203 | { | |
95f63b36 | 204 | gFile->ls(); |
205 | Float_t x1[10], y1[10]; | |
206 | Float_t x2[10], y2[10]; | |
207 | ||
208 | Float_t xx1[10],yy1[10], xx[10]; | |
209 | for (Int_t ii=0; ii<10; ii++) | |
210 | { x1[ii]=0; y1[ii]=0; x2[ii]=0; y2[ii]=0; } | |
211 | ||
212 | ||
213 | TH2F* hCFDvsQTC[24][10]; TH2F* hCFDvsLED[24][10]; | |
214 | ||
215 | for (Int_t i=0; i<24; i++) | |
c883fdf2 | 216 | { |
95f63b36 | 217 | for (Int_t im=0; im<10; im++) |
218 | { | |
219 | ||
220 | TString qtc = Form("CFDvsQTC%i_%i",i+1,im+1); | |
221 | TString led = Form("CFDvsLED%i_%i",i+1,im+1); | |
222 | cout<<qtc<<" "<<led<<endl; | |
223 | hCFDvsQTC[i][im] = (TH2F*) gFile->Get(qtc.Data()) ; | |
224 | hCFDvsLED[i][im] = (TH2F*) gFile->Get(led.Data()); | |
225 | ||
226 | // if(!hCFDvsQTC[i][im] || !hCFDvsLED[i][im]) | |
227 | // AliWarning(Form(" no walk correction data in LASER DA for channel %i for amplitude %i MIPs",i,im)); | |
228 | ||
229 | if(hCFDvsQTC[i][im] && hCFDvsLED[i][im]) | |
230 | { | |
231 | x1[im] = hCFDvsQTC[i][im]->GetMean(1); | |
232 | y1[im] = hCFDvsQTC[i][im]->GetMean(2); | |
233 | x2[im] = hCFDvsLED[i][im]->GetMean(1); | |
234 | y2[im] = hCFDvsLED[i][im]->GetMean(2); | |
235 | } | |
236 | xx[im]=im+1; | |
e47b556f | 237 | } |
95f63b36 | 238 | for (Int_t imi=0; imi<10; imi++) |
239 | { | |
240 | yy1[imi] = Float_t (10-imi); | |
241 | xx1[imi]=x2[10-imi-1]; | |
242 | } | |
243 | if(i==0){ | |
271b5bd3 | 244 | cout<<"Making graphs..."<<endl; |
95f63b36 | 245 | } |
246 | TGraph *gr1 = new TGraph (10,x1,y1); | |
247 | TGraph *gr2 = new TGraph (10,x2,y2); | |
248 | fWalk.AddAtAndExpand(gr1,i); | |
249 | fAmpLEDRec.AddAtAndExpand(gr2,i); | |
250 | ||
251 | ||
252 | ||
253 | TGraph *gr4 = new TGraph (10,xx1,yy1); | |
254 | TGraph *gr3 = new TGraph (10,x1,xx); | |
255 | fQTC.AddAtAndExpand(gr3,i); | |
256 | fAmpLED.AddAtAndExpand(gr4,i); | |
257 | // for (Int_t im=0; im<10; im++) { x2[im]=0; y2[im]=0; xx1[im]=0; xx[im]=0;} | |
258 | if(i==23){ | |
259 | cout<<"Graphs created..."<<endl; | |
260 | } | |
271b5bd3 | 261 | } |
6318dd46 | 262 | } //if gFile exits |
a2ad8166 | 263 | } |
264 | ||
c883fdf2 | 265 | |
266 | ||
267 |