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