]>
Commit | Line | Data |
---|---|---|
dc7ca31d | 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 for T0 calibration TM-AC-AM_6-02-2006 // | |
21 | // // | |
22 | /////////////////////////////////////////////////////////////////////////////// | |
23 | ||
dc7ca31d | 24 | #include "AliT0CalibData.h" |
e0bba6cc | 25 | #include "AliT0LookUpValue.h" |
dc7ca31d | 26 | #include "AliLog.h" |
dc7ca31d | 27 | |
7d95281b | 28 | #include <TCanvas.h> |
29 | #include <TObjString.h> | |
30 | #include <TObjArray.h> | |
31 | #include <TGraph.h> | |
32 | #include <TFile.h> | |
33 | #include <TAxis.h> | |
34 | #include <TH2F.h> | |
35 | #include <TMath.h> | |
ca7c0417 | 36 | #include <TSystem.h> |
7d95281b | 37 | #include <Riostream.h> |
dc7ca31d | 38 | |
7d95281b | 39 | #include <string> |
dc7ca31d | 40 | |
41 | ClassImp(AliT0CalibData) | |
42 | ||
43 | //________________________________________________________________ | |
29d3e0eb | 44 | AliT0CalibData::AliT0CalibData(): TNamed(), |
45 | fTimeDelayTVD(0), | |
46 | fMeanT0(0), | |
47 | fWalk(0), | |
48 | fAmpLEDRec(0), | |
49 | fLookup(0), | |
50 | fNumberOfTRMs(0) | |
dc7ca31d | 51 | |
52 | { | |
53 | // | |
54 | } | |
55 | ||
56 | //________________________________________________________________ | |
94c27e4f | 57 | AliT0CalibData::AliT0CalibData(const char* name):TNamed(), |
58 | fTimeDelayTVD(0), | |
59 | fMeanT0(0), | |
60 | fWalk(0), | |
74adb36a | 61 | fAmpLEDRec(0), |
94c27e4f | 62 | fLookup(0), |
63 | fNumberOfTRMs(0) | |
dc7ca31d | 64 | { |
65 | TString namst = "Calib_"; | |
66 | namst += name; | |
67 | SetName(namst.Data()); | |
68 | SetTitle(namst.Data()); | |
69 | ||
70 | } | |
71 | ||
72 | //________________________________________________________________ | |
73 | AliT0CalibData::AliT0CalibData(const AliT0CalibData& calibda) : | |
94c27e4f | 74 | TNamed(calibda), |
75 | fTimeDelayTVD(0), | |
76 | fMeanT0(0), | |
77 | fWalk(0), | |
29d3e0eb | 78 | // fAmpLED(0), |
74adb36a | 79 | fAmpLEDRec(0), |
94c27e4f | 80 | fLookup(0), |
81 | fNumberOfTRMs(0) | |
82 | ||
dc7ca31d | 83 | { |
84 | // copy constructor | |
85 | SetName(calibda.GetName()); | |
86 | SetTitle(calibda.GetName()); | |
87 | ||
88 | ||
89 | } | |
90 | ||
91 | //________________________________________________________________ | |
92 | AliT0CalibData &AliT0CalibData::operator =(const AliT0CalibData& calibda) | |
93 | { | |
94 | // assignment operator | |
95 | SetName(calibda.GetName()); | |
96 | SetTitle(calibda.GetName()); | |
97 | ||
98 | return *this; | |
99 | } | |
100 | ||
101 | //________________________________________________________________ | |
102 | AliT0CalibData::~AliT0CalibData() | |
103 | { | |
e0bba6cc | 104 | // |
dc7ca31d | 105 | } |
106 | //________________________________________________________________ | |
107 | void AliT0CalibData::Reset() | |
108 | { | |
109 | memset(fTimeDelayCFD,1,24*sizeof(Float_t)); | |
94c27e4f | 110 | memset(fTimeDelayDA,1,24*sizeof(Float_t)); |
dc7ca31d | 111 | } |
112 | ||
113 | ||
114 | //________________________________________________________________ | |
115 | void AliT0CalibData::Print(Option_t*) const | |
116 | { | |
117 | ||
118 | printf("\n ---- PM Arrays ----\n\n"); | |
94c27e4f | 119 | printf(" Time delay CFD & DA\n"); |
120 | for (Int_t i=0; i<24; i++) printf(" CFD %f DA %f ",fTimeDelayCFD[i], fTimeDelayDA[i]); | |
dc7ca31d | 121 | } |
122 | ||
e0bba6cc | 123 | //________________________________________________________________ |
124 | void AliT0CalibData::PrintLookup(Option_t*, Int_t iTRM, Int_t iTDC, Int_t iChannel) const | |
125 | { | |
c41ceaac | 126 | |
127 | AliT0LookUpKey* lookkey= new AliT0LookUpKey(); | |
128 | AliT0LookUpValue* lookvalue= new AliT0LookUpValue(); | |
5325480c | 129 | |
130 | cout<<" Number Of TRMs in setup "<<GetNumberOfTRMs()<<endl; | |
c41ceaac | 131 | lookvalue->SetTRM(iTRM); |
132 | lookvalue->SetTDC(iTDC); | |
133 | lookvalue->SetChain(0); | |
134 | lookvalue->SetChannel(iChannel); | |
5325480c | 135 | |
c41ceaac | 136 | |
137 | printf(" AliT0CalibData::PrintLookup ::start GetValue %i %i %i \n",iTRM, iTDC, iChannel); | |
138 | lookkey = (AliT0LookUpKey*) fLookup.GetValue((TObject*)lookvalue); | |
139 | ||
94c27e4f | 140 | |
c41ceaac | 141 | if (lookkey) |
142 | { | |
143 | cout<<" lookup KEY!!! "<<lookkey->GetKey()<<" VALUE "<<lookvalue->GetTRM()<<" " | |
144 | <<lookvalue->GetTDC()<<" " | |
145 | << lookvalue->GetChain()<<" " | |
146 | <<lookvalue->GetChannel()<<endl; | |
147 | } | |
148 | ||
149 | ||
e0bba6cc | 150 | } |
dc7ca31d | 151 | |
152 | //________________________________________________________________ | |
153 | void AliT0CalibData::SetTimeDelayCFD(Float_t* TimeDelay) | |
154 | { | |
155 | if(TimeDelay) for(int t=0; t<24; t++) fTimeDelayCFD[t] = TimeDelay[t]; | |
c41ceaac | 156 | } |
157 | //________________________________________________________________ | |
94c27e4f | 158 | void AliT0CalibData::SetTimeDelayDA(Float_t* TimeDelay) |
dc7ca31d | 159 | { |
94c27e4f | 160 | if(TimeDelay) for(int t=0; t<24; t++) fTimeDelayDA[t] = TimeDelay[t]; |
dc7ca31d | 161 | } |
162 | ||
163 | ||
164 | //________________________________________________________________ | |
ca7c0417 | 165 | void AliT0CalibData::SetWalk(Int_t ipmt) |
dc7ca31d | 166 | { |
167 | ||
c41ceaac | 168 | Int_t mv, ps; |
169 | Int_t x[70000], y[70000], index[70000]; | |
170 | Float_t time[10000],amplitude[10000]; | |
171 | string buffer; | |
172 | Bool_t down=false; | |
173 | ||
ca7c0417 | 174 | const char * filename = gSystem->ExpandPathName("$ALICE_ROOT/T0/data/CFD-Amp.txt"); |
175 | ifstream inFile(filename); | |
c41ceaac | 176 | if(!inFile) AliError(Form("Cannot open file %s !",filename)); |
177 | ||
5325480c | 178 | Int_t i=0; |
c41ceaac | 179 | while(getline(inFile,buffer)){ |
180 | inFile >> ps >> mv; | |
181 | ||
182 | x[i]=ps; y[i]=mv; | |
183 | i++; | |
184 | } | |
185 | inFile.close(); | |
5325480c | 186 | cout<<" number of data "<<i<<endl; |
c41ceaac | 187 | |
188 | TMath::Sort(i, y, index,down); | |
189 | Int_t amp=0, iin=0, isum=0, sum=0; | |
190 | Int_t ind=0; | |
5325480c | 191 | for (Int_t ii=0; ii<i; ii++) |
c41ceaac | 192 | { |
193 | ind=index[ii]; | |
194 | if(y[ind] == amp) | |
195 | { | |
196 | sum +=x[ind]; | |
197 | iin++; | |
c41ceaac | 198 | } |
199 | else | |
200 | { | |
201 | if(iin>0) | |
202 | time[isum] = Float_t (sum/(iin)); | |
203 | else | |
204 | time[isum] =Float_t (x[ind]); | |
205 | amplitude[isum] = Float_t (amp); | |
206 | amp=y[ind]; | |
c41ceaac | 207 | iin=0; |
208 | isum++; | |
209 | sum=0; | |
210 | } | |
211 | } | |
212 | ||
213 | inFile.close(); | |
214 | ||
215 | TGraph* gr = new TGraph(isum, amplitude, time); | |
dc7ca31d | 216 | fWalk.AddAtAndExpand(gr,ipmt); |
dc7ca31d | 217 | } |
218 | ||
219 | ||
220 | //________________________________________________________________ | |
29d3e0eb | 221 | /* |
74adb36a | 222 | void AliT0CalibData::SetAmpLED(Int_t ipmt) |
dc7ca31d | 223 | { |
224 | Float_t mv, ps; | |
225 | Float_t x[100], y[100]; | |
226 | string buffer; | |
227 | ||
ca7c0417 | 228 | const char * filename = gSystem->ExpandPathName("$ALICE_ROOT/T0/data/CFD-LED.txt"); |
dc7ca31d | 229 | ifstream inFile(filename); |
230 | if(!inFile) {AliError(Form("Cannot open file %s !",filename));} | |
231 | ||
232 | inFile >> mv>>ps; | |
233 | Int_t i=0; | |
234 | ||
235 | while(getline(inFile,buffer)){ | |
236 | x[i]=mv; y[i]=ps; | |
237 | inFile >> mv >> ps; | |
238 | i++; | |
239 | } | |
240 | inFile.close(); | |
241 | TGraph* gr = new TGraph(i,x,y); | |
74adb36a | 242 | fAmpLED.AddAtAndExpand(gr,ipmt); |
dc7ca31d | 243 | |
244 | } | |
29d3e0eb | 245 | */ |
dc7ca31d | 246 | //________________________________________________________________ |
247 | ||
74adb36a | 248 | void AliT0CalibData::SetAmpLEDRec(Int_t ipmt) |
dc7ca31d | 249 | { |
250 | Float_t mv, ps; | |
251 | Float_t x[100], y[100]; | |
252 | string buffer; | |
253 | ||
74adb36a | 254 | const char * filename = gSystem->ExpandPathName("$ALICE_ROOT/T0/data/CFD-LED.txt"); |
ca7c0417 | 255 | ifstream inFile(filename); |
dc7ca31d | 256 | if(!inFile) {AliError(Form("Cannot open file %s !",filename));} |
257 | ||
258 | inFile >> mv>>ps; | |
259 | Int_t i=0; | |
260 | ||
261 | while(getline(inFile,buffer)){ | |
262 | x[i]=mv; y[i]=ps; | |
263 | inFile >> mv >> ps; | |
264 | i++; | |
265 | } | |
266 | inFile.close(); | |
267 | Float_t y1[100], x1[100]; | |
268 | for (Int_t ir=0; ir<i; ir++){ | |
269 | y1[ir]=y[i-ir]; x1[ir]=x[i-ir];} | |
270 | TGraph* gr = new TGraph(i,y1,x1); | |
74adb36a | 271 | fAmpLEDRec.AddAtAndExpand(gr,ipmt); |
dc7ca31d | 272 | |
273 | } | |
274 | ||
5325480c | 275 | //________________________________________________________________ |
dc7ca31d | 276 | |
e0bba6cc | 277 | void AliT0CalibData::ReadAsciiLookup(const Char_t *filename) |
278 | { | |
c41ceaac | 279 | Int_t key, trm, tdc, chain, channel; |
e0bba6cc | 280 | |
281 | if(filename == 0){ | |
282 | AliError(Form("Please, specify file with database")) ; | |
283 | return ; | |
284 | } | |
285 | ||
e0bba6cc | 286 | |
287 | ifstream lookup; | |
288 | lookup.open(filename); | |
c41ceaac | 289 | if(!lookup) |
290 | { | |
29d3e0eb | 291 | AliError(Form("!!!!!!!!!!!!!!No look up table in CDB!" )); |
292 | ||
c41ceaac | 293 | } |
e0bba6cc | 294 | Char_t varname[11]; |
5325480c | 295 | Int_t ntrms; |
296 | if(lookup) | |
e0bba6cc | 297 | { |
5325480c | 298 | lookup>>ntrms; |
299 | cout<<" !!!!!!! ntrms "<<ntrms<<endl; | |
300 | // fNumberOfTRMs=ntrms; | |
301 | SetNumberOfTRMs(ntrms); | |
302 | while(!lookup.eof()) | |
303 | { | |
304 | AliT0LookUpKey * lookkey= new AliT0LookUpKey(); | |
305 | AliT0LookUpValue * lookvalue= new AliT0LookUpValue(); | |
306 | ||
307 | lookup>>varname>>key>>trm>>chain>>tdc>>channel; | |
308 | lookvalue->SetTRM(trm); | |
309 | lookvalue->SetTDC(tdc); | |
310 | lookvalue->SetChain(chain); | |
311 | lookvalue->SetChannel(channel); | |
312 | lookkey->SetKey(key); | |
313 | cout<<"lookup "<<varname<<" "<<key<<" "<<trm<<" "<<chain<<" "<<tdc<<" "<<channel<<endl; | |
314 | ||
315 | fLookup.Add((TObject*)lookvalue,(TObject*)lookkey); | |
316 | ||
317 | } | |
318 | ||
319 | lookup.close(); | |
ca7c0417 | 320 | |
e0bba6cc | 321 | } |
e0bba6cc | 322 | } |
e0bba6cc | 323 | //________________________________________________________________ |
324 | ||
325 | Int_t AliT0CalibData::GetChannel(Int_t trm, Int_t tdc, Int_t chain, Int_t channel) | |
326 | { | |
327 | ||
328 | AliT0LookUpKey * lookkey;//= new AliT0LookUpKey(); | |
329 | AliT0LookUpValue * lookvalue= new AliT0LookUpValue(trm,tdc,chain,channel); | |
330 | ||
ca7c0417 | 331 | lookkey = (AliT0LookUpKey*) fLookup.GetValue((TObject*)lookvalue); |
332 | ||
e0bba6cc | 333 | return lookkey->GetKey(); |
334 | ||
335 | } | |
336 |