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