]>
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 | ||
24 | #include <iostream> | |
25 | #include <fstream> | |
26 | #include <iomanip> | |
27 | #include <string> | |
28 | #include <TCanvas.h> | |
29 | ||
30 | #include "AliT0CalibData.h" | |
e0bba6cc | 31 | #include "AliT0LookUpValue.h" |
dc7ca31d | 32 | #include "TObjArray.h" |
33 | #include "TGraph.h" | |
34 | #include "TFile.h" | |
35 | #include "AliLog.h" | |
36 | #include "TObjString.h" | |
37 | ||
38 | #include "TAxis.h" | |
39 | #include "TH2F.h" | |
40 | ||
41 | ||
42 | ||
43 | ClassImp(AliT0CalibData) | |
44 | ||
45 | //________________________________________________________________ | |
46 | AliT0CalibData::AliT0CalibData(): TNamed() | |
47 | ||
48 | { | |
49 | // | |
50 | } | |
51 | ||
52 | //________________________________________________________________ | |
53 | AliT0CalibData::AliT0CalibData(const char* name):TNamed(),fTimeDelayTVD(0),fWalk(),fSlewingLED(),fSlewingRec() | |
54 | { | |
55 | TString namst = "Calib_"; | |
56 | namst += name; | |
57 | SetName(namst.Data()); | |
58 | SetTitle(namst.Data()); | |
59 | ||
60 | } | |
61 | ||
62 | //________________________________________________________________ | |
63 | AliT0CalibData::AliT0CalibData(const AliT0CalibData& calibda) : | |
64 | TNamed(calibda),fTimeDelayTVD(0),fWalk(),fSlewingLED(),fSlewingRec() | |
65 | { | |
66 | // copy constructor | |
67 | SetName(calibda.GetName()); | |
68 | SetTitle(calibda.GetName()); | |
69 | ||
70 | ||
71 | } | |
72 | ||
73 | //________________________________________________________________ | |
74 | AliT0CalibData &AliT0CalibData::operator =(const AliT0CalibData& calibda) | |
75 | { | |
76 | // assignment operator | |
77 | SetName(calibda.GetName()); | |
78 | SetTitle(calibda.GetName()); | |
79 | ||
80 | return *this; | |
81 | } | |
82 | ||
83 | //________________________________________________________________ | |
84 | AliT0CalibData::~AliT0CalibData() | |
85 | { | |
e0bba6cc | 86 | // |
dc7ca31d | 87 | } |
88 | //________________________________________________________________ | |
89 | void AliT0CalibData::Reset() | |
90 | { | |
91 | memset(fTimeDelayCFD,1,24*sizeof(Float_t)); | |
92 | memset(fTimeDelayLED,1,24*sizeof(Float_t)); | |
93 | memset(fGain,1,24*sizeof(Float_t)); | |
94 | } | |
95 | ||
96 | ||
97 | //________________________________________________________________ | |
98 | void AliT0CalibData::Print(Option_t*) const | |
99 | { | |
100 | ||
101 | printf("\n ---- PM Arrays ----\n\n"); | |
102 | printf(" Time delay CFD \n"); | |
103 | for (Int_t i=0; i<24; i++) printf(" %f",fTimeDelayCFD[i]); | |
104 | printf(" \n LED \n"); | |
105 | for (Int_t i=0; i<24; i++) printf(" %f",fTimeDelayLED[i]); | |
106 | printf(" \n Gain \n"); | |
107 | for (Int_t i=0; i<24; i++) printf(" %f",fGain[i]); | |
108 | printf(" \n"); | |
109 | } | |
110 | ||
e0bba6cc | 111 | //________________________________________________________________ |
112 | void AliT0CalibData::PrintLookup(Option_t*, Int_t iTRM, Int_t iTDC, Int_t iChannel) const | |
113 | { | |
114 | ||
115 | AliT0LookUpKey* lookkey= new AliT0LookUpKey(); | |
116 | AliT0LookUpValue* lookvalue= new AliT0LookUpValue(); | |
117 | ||
118 | lookvalue->SetTRM(iTRM); | |
119 | lookvalue->SetTDC(iTDC); | |
120 | lookvalue->SetChain(0); | |
121 | lookvalue->SetChannel(iChannel); | |
122 | ||
123 | printf(" AliT0CalibData::PrintLookup ::start GetValue %i %i %i \n",iTRM, iTDC, iChannel); | |
124 | lookkey = (AliT0LookUpKey*) fLookup.GetValue((TObject*)lookvalue); | |
125 | ||
126 | cout<<" AliT0CalibData::PrintLookup :: lookkey "<< lookkey<<endl; | |
127 | if (lookkey) | |
128 | { | |
129 | cout<<" lookup KEY!!! "<<lookkey->GetKey()<<" VALUE "<<lookvalue->GetTRM()<<" " | |
130 | <<lookvalue->GetTDC()<<" " | |
131 | << lookvalue->GetChain()<<" " | |
132 | <<lookvalue->GetChannel()<<endl; | |
133 | } | |
134 | ||
dc7ca31d | 135 | |
e0bba6cc | 136 | } |
dc7ca31d | 137 | |
138 | //________________________________________________________________ | |
139 | void AliT0CalibData::SetTimeDelayCFD(Float_t* TimeDelay) | |
140 | { | |
141 | if(TimeDelay) for(int t=0; t<24; t++) fTimeDelayCFD[t] = TimeDelay[t]; | |
142 | // else for(int t=0; t<24; t++) fTimeDelay[t] = 0.; | |
143 | } | |
144 | //________________________________________________________________ | |
145 | void AliT0CalibData::SetTimeDelayLED(Float_t* TimeDelay) | |
146 | { | |
147 | if(TimeDelay) for(int t=0; t<24; t++) fTimeDelayLED[t] = TimeDelay[t]; | |
148 | // else for(int t=0; t<24; t++) fTimeDelay[t] = 0.; | |
149 | } | |
150 | ||
151 | //________________________________________________________________ | |
152 | void AliT0CalibData::SetGain(Float_t* Gain) | |
153 | { | |
154 | if(Gain) for(int t=0; t<24; t++) fGain[t] = Gain[t]; | |
155 | // else for(int t=0; t<24; t++) fGain[t] = 0.; | |
156 | } | |
157 | ||
158 | ||
159 | //________________________________________________________________ | |
160 | void AliT0CalibData::SetWalk(Int_t ipmt, const Char_t *filename) | |
161 | { | |
162 | ||
163 | TFile *file = new TFile(filename); | |
164 | char funcname[256]; | |
165 | sprintf(funcname,"CFD%i",ipmt+1); | |
166 | TF1* gr = (TF1*)file->Get(funcname); | |
167 | fWalk.AddAtAndExpand(gr,ipmt); | |
168 | file->Close(); | |
169 | } | |
170 | ||
171 | ||
172 | //________________________________________________________________ | |
173 | ||
174 | void AliT0CalibData::SetSlewingLED(Int_t ipmt,const Char_t *filename) | |
175 | { | |
176 | Float_t mv, ps; | |
177 | Float_t x[100], y[100]; | |
178 | string buffer; | |
179 | ||
180 | ifstream inFile(filename); | |
181 | if(!inFile) {AliError(Form("Cannot open file %s !",filename));} | |
182 | ||
183 | inFile >> mv>>ps; | |
184 | Int_t i=0; | |
185 | ||
186 | while(getline(inFile,buffer)){ | |
187 | x[i]=mv; y[i]=ps; | |
188 | inFile >> mv >> ps; | |
189 | i++; | |
190 | } | |
191 | inFile.close(); | |
192 | TGraph* gr = new TGraph(i,x,y); | |
193 | fSlewingLED.AddAtAndExpand(gr,ipmt); | |
194 | ||
195 | } | |
196 | ||
197 | //________________________________________________________________ | |
198 | ||
199 | void AliT0CalibData::SetSlewingRec(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 | Float_t y1[100], x1[100]; | |
218 | for (Int_t ir=0; ir<i; ir++){ | |
219 | y1[ir]=y[i-ir]; x1[ir]=x[i-ir];} | |
220 | TGraph* gr = new TGraph(i,y1,x1); | |
221 | fSlewingRec.AddAtAndExpand(gr,ipmt); | |
222 | ||
223 | } | |
224 | ||
225 | ||
e0bba6cc | 226 | void AliT0CalibData::ReadAsciiLookup(const Char_t *filename) |
227 | { | |
228 | ||
229 | if(filename == 0){ | |
230 | AliError(Form("Please, specify file with database")) ; | |
231 | return ; | |
232 | } | |
233 | ||
234 | // AliT0LookUpKey * lookkey= new AliT0LookUpKey(); | |
235 | //AliT0LookUpValue * lookvalue= new AliT0LookUpValue(); | |
236 | ||
237 | ifstream lookup; | |
238 | lookup.open(filename); | |
239 | if(!lookup) {AliError(Form("Cannot open file %s !",filename));} | |
240 | Char_t varname[11]; | |
241 | Int_t key, trm, tdc, chain, channel; | |
242 | // while(lookup.eof()) | |
243 | ||
244 | for (Int_t i=0; i<108; i++) | |
245 | // for (Int_t i=0;i<3;i++) | |
246 | { | |
247 | AliT0LookUpKey * lookkey= new AliT0LookUpKey(); | |
248 | AliT0LookUpValue * lookvalue= new AliT0LookUpValue(); | |
249 | ||
250 | lookup>>varname>>key>>trm>>chain>>tdc>>channel; | |
251 | lookvalue->SetTRM(trm); | |
252 | lookvalue->SetTDC(tdc); | |
253 | lookvalue->SetChain(chain); | |
254 | lookvalue->SetChannel(channel); | |
255 | lookkey->SetKey(key); | |
256 | ||
257 | // cout<<"TRM="<<trm<<" TDC="<<tdc<<" chain="<<chain<<" channel="<<channel<<" key="<<key<<endl; | |
258 | ||
259 | cout<<"AliT0CalibData:: "<<varname<<" "<<key<<" "<<trm<<" "<<chain<<" "<<tdc<<" "<<channel<<endl; | |
260 | ||
261 | // fLookup.Add((TObject*)lookkey,(TObject*)lookvalue); | |
262 | // ar_key.AddAt(lookkey,i); | |
263 | // ar_val.AddAt(lookvalue,i); | |
264 | ||
265 | fLookup.Add((TObject*)lookvalue,(TObject*)lookkey); | |
266 | ||
267 | } | |
268 | ||
269 | lookup.close(); | |
270 | ||
271 | } | |
272 | ||
273 | //________________________________________________________________ | |
274 | ||
275 | Int_t AliT0CalibData::GetChannel(Int_t trm, Int_t tdc, Int_t chain, Int_t channel) | |
276 | { | |
277 | ||
278 | AliT0LookUpKey * lookkey;//= new AliT0LookUpKey(); | |
279 | AliT0LookUpValue * lookvalue= new AliT0LookUpValue(trm,tdc,chain,channel); | |
280 | ||
281 | lookkey = (AliT0LookUpKey*) fLookup.GetValue((TObject*)lookvalue); | |
282 | cout<<"AliT0CalibData:: key "<<lookkey->GetKey()<<endl; | |
283 | return lookkey->GetKey(); | |
284 | ||
285 | } | |
286 |