]>
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 | // T0 - T0. | |
21 | // | |
22 | // This class is a singleton that handles various parameters of | |
23 | // the T0 detectors. | |
24 | // Eventually, this class will use the Conditions DB to get the | |
25 | // various parameters, which code can then request from here. | |
26 | // | |
27 | #include "AliLog.h" | |
28 | #include "AliT0Parameters.h" | |
29 | #include "AliT0CalibData.h" | |
e0bba6cc | 30 | #include "AliT0LookUpValue.h" |
dc7ca31d | 31 | #include <AliCDBManager.h> |
32 | #include <AliCDBEntry.h> | |
7d95281b | 33 | #include <AliCDBStorage.h> |
aae44346 | 34 | #include <TMath.h> |
35 | #include <TSystem.h> | |
dc7ca31d | 36 | #include <Riostream.h> |
5325480c | 37 | #include <TGeoManager.h> |
38 | #include <TGeoPhysicalNode.h> | |
dc7ca31d | 39 | |
40 | AliT0CalibData* AliT0Parameters::fgCalibData = 0; | |
e0bba6cc | 41 | AliT0CalibData* AliT0Parameters::fgLookUp = 0; |
c41ceaac | 42 | AliT0CalibData* AliT0Parameters::fgSlewCorr =0; |
dc7ca31d | 43 | //==================================================================== |
44 | ClassImp(AliT0Parameters) | |
45 | #if 0 | |
46 | ; // This is here to keep Emacs for indenting the next line | |
47 | #endif | |
48 | ||
49 | //____________________________________________________________________ | |
50 | AliT0Parameters* AliT0Parameters::fgInstance = 0; | |
51 | //____________________________________________________________________ | |
52 | AliT0Parameters* | |
53 | AliT0Parameters::Instance() | |
54 | { | |
55 | // Get static instance | |
76f3b07a | 56 | if (!fgInstance) { |
57 | fgInstance = new AliT0Parameters; | |
58 | fgInstance->Init(); | |
59 | } | |
dc7ca31d | 60 | return fgInstance; |
61 | } | |
62 | ||
63 | //____________________________________________________________________ | |
64 | AliT0Parameters::AliT0Parameters() | |
5325480c | 65 | :fIsInit(kFALSE), |
66 | fPh2Mip(0),fmV2Mip(0), | |
67 | fChannelWidth(0),fmV2Channel(0), | |
68 | fQTmin(0),fQTmax(0), | |
69 | fSlewingLED(),fSlewingRec(), | |
70 | fPMTeff(), | |
d530f23a | 71 | fTimeDelayDA(0),fTimeDelayCFD(0),fTimeDelayTVD(0),fMeanT0(499), |
94c27e4f | 72 | fCalibentry(), fLookUpentry(),fSlewCorr(), |
73 | fLookUp(0), fNumberOfTRMs(0) | |
74 | ||
dc7ca31d | 75 | { |
76 | // Default constructor | |
77 | ||
78 | for (Int_t ipmt=0; ipmt<24; ipmt++) | |
79 | { | |
dc7ca31d | 80 | SetSlewingLED(ipmt); |
81 | SetSlewingRec(ipmt); | |
c41ceaac | 82 | SetWalk(ipmt); |
dc7ca31d | 83 | SetPh2Mip(); |
84 | SetmV2Mip(); | |
85 | SetChannelWidth(); | |
86 | SetmV2channel(); | |
dc7ca31d | 87 | SetQTmin(); |
88 | SetQTmax(); | |
89 | SetPMTeff(ipmt); | |
c41ceaac | 90 | |
dc7ca31d | 91 | } |
92 | SetTimeDelayTVD(); | |
93 | SetZposition(); | |
5325480c | 94 | SetNumberOfTRMs(2); |
dc7ca31d | 95 | |
96 | } | |
97 | ||
98 | //__________________________________________________________________ | |
99 | void | |
100 | AliT0Parameters::Init() | |
101 | { | |
102 | // Initialize the parameters manager. We need to get stuff from the | |
103 | // CDB here. | |
94c27e4f | 104 | |
105 | if (fIsInit) return; | |
6ba20b30 | 106 | |
6eac39a1 | 107 | AliCDBManager *stor =AliCDBManager::Instance(); |
c41ceaac | 108 | //time equalizing |
6eac39a1 | 109 | AliCDBEntry* fCalibentry = stor->Get("T0/Calib/TimeDelay"); |
5325480c | 110 | if (fCalibentry) |
dc7ca31d | 111 | fgCalibData = (AliT0CalibData*)fCalibentry->GetObject(); |
6eac39a1 | 112 | else { |
5325480c | 113 | AliError(" ALARM !!!! No time delays in CDB "); |
6eac39a1 | 114 | fIsInit = kFALSE; |
115 | return; | |
116 | } | |
c41ceaac | 117 | //slewing correction |
6eac39a1 | 118 | AliCDBEntry* fSlewCorr = stor->Get("T0/Calib/Slewing_Walk"); |
5325480c | 119 | if (fSlewCorr){ |
120 | fgSlewCorr = (AliT0CalibData*)fSlewCorr->GetObject(); | |
c41ceaac | 121 | } |
6eac39a1 | 122 | fLookUpentry = stor->Get("T0/Calib/LookUp_Table"); |
e0bba6cc | 123 | if (fLookUpentry){ |
124 | fgLookUp = (AliT0CalibData*)fLookUpentry->GetObject(); | |
e0bba6cc | 125 | } |
126 | else { | |
ca7c0417 | 127 | const char * filename = gSystem->ExpandPathName("$ALICE_ROOT/T0/lookUpTable.txt"); |
128 | ifstream inFile(filename); | |
129 | fgLookUp->ReadAsciiLookup(filename); | |
e0bba6cc | 130 | } |
dc7ca31d | 131 | |
132 | fIsInit = kTRUE; | |
133 | } | |
134 | ||
135 | ||
dc7ca31d | 136 | //__________________________________________________________________ |
137 | Float_t | |
94c27e4f | 138 | AliT0Parameters::GetTimeDelayDA(Int_t ipmt) |
dc7ca31d | 139 | { |
140 | // return time delay for LED channel | |
141 | // | |
142 | if (!fCalibentry) { | |
d530f23a | 143 | fTimeDelayDA = 500; |
94c27e4f | 144 | return fTimeDelayDA; |
dc7ca31d | 145 | } |
94c27e4f | 146 | return fgCalibData ->GetTimeDelayDA(ipmt); |
dc7ca31d | 147 | } |
148 | //__________________________________________________________________ | |
149 | Float_t | |
150 | AliT0Parameters::GetTimeDelayCFD(Int_t ipmt) | |
151 | { | |
152 | // return time delay for CFD channel | |
153 | // | |
154 | if (!fCalibentry) | |
155 | { | |
c41ceaac | 156 | fTimeDelayCFD = 1000+ipmt*100; |
157 | return fTimeDelayCFD; | |
dc7ca31d | 158 | } |
159 | ||
160 | return fgCalibData->GetTimeDelayCFD(ipmt); | |
161 | } | |
162 | ||
94c27e4f | 163 | //__________________________________________________________________ |
164 | Int_t | |
165 | AliT0Parameters::GetMeanT0() | |
166 | { | |
167 | // return mean of T0 distrubution with vertex=0 | |
168 | // | |
169 | if (!fCalibentry) | |
170 | { | |
171 | return fMeanT0; | |
172 | } | |
173 | ||
174 | return fgCalibData->GetMeanT0(); | |
175 | } | |
dc7ca31d | 176 | //__________________________________________________________________ |
177 | ||
178 | void | |
179 | AliT0Parameters::SetSlewingLED(Int_t ipmt) | |
180 | { | |
181 | // Set Slweing Correction for LED channel | |
182 | Float_t mv[23] = {25, 30,40,60, 80,100,150,200,250,300, | |
183 | 400,500,600,800,1000,1500, 2000, 3000, 4000, 5500, | |
184 | 6000, 7000,8000}; | |
185 | Float_t y[23] = {5044, 4719, 3835, 3224, 2847, 2691,2327, 2067, 1937, 1781, | |
186 | 1560, 1456 ,1339, 1163.5, 1027, 819, 650, 520, 370.5, 234, | |
187 | 156, 78, 0}; | |
188 | ||
189 | TGraph* gr = new TGraph(23,mv,y); | |
190 | fSlewingLED.AddAtAndExpand(gr,ipmt); | |
191 | } | |
192 | //__________________________________________________________________ | |
193 | ||
194 | Float_t AliT0Parameters::GetSlewingLED(Int_t ipmt, Float_t mv) const | |
195 | { | |
196 | if (!fCalibentry) { | |
197 | return ((TGraph*)fSlewingLED.At(ipmt))->Eval(mv); | |
198 | } | |
199 | return fgCalibData->GetSlewingLED(ipmt, mv) ; | |
200 | } | |
201 | ||
202 | ||
203 | //__________________________________________________________________ | |
204 | ||
205 | TGraph *AliT0Parameters::GetSlew(Int_t ipmt) const | |
206 | { | |
207 | if (!fCalibentry) { | |
208 | return (TGraph*)fSlewingLED.At(ipmt); | |
209 | } | |
210 | return fgCalibData -> GetSlew(ipmt) ; | |
211 | } | |
212 | ||
213 | //__________________________________________________________________ | |
214 | ||
215 | ||
216 | void | |
217 | AliT0Parameters::SetSlewingRec(Int_t ipmt) | |
218 | { | |
219 | // Set Slweing Correction for LED channel | |
220 | Float_t mv[23] = {25, 30, 40,60, 80,100,150,200,250,300, | |
221 | 400,500,600,800,1000,1500, 2000, 3000, 4000, 5500, | |
222 | 6000, 7000,8000}; | |
223 | Float_t y[23] = {5044, 4719, 3835, 3224, 2847, 2691,2327, 2067, 1937, 1781, | |
224 | 1560, 1456 ,1339, 1163.5, 1027, 819, 650, 520, 370.5, 234, | |
225 | 156, 78, 0}; | |
226 | Float_t y1[23], mv1[23]; | |
227 | for (Int_t i=0; i<23; i++){ | |
228 | y1[i] = y[22-i]; mv1[i] = mv[22-i];} | |
229 | ||
230 | TGraph* gr = new TGraph(23,y1,mv1); | |
231 | fSlewingRec.AddAtAndExpand(gr,ipmt); | |
232 | ||
233 | } | |
234 | //__________________________________________________________________ | |
235 | ||
236 | Float_t AliT0Parameters::GetSlewingRec(Int_t ipmt, Float_t mv) const | |
237 | { | |
238 | if (!fCalibentry) { | |
239 | return ((TGraph*)fSlewingRec.At(ipmt))->Eval(mv); | |
240 | } | |
241 | return fgCalibData -> GetSlewingRec(ipmt, mv) ; | |
242 | } | |
243 | ||
244 | //__________________________________________________________________ | |
245 | ||
246 | TGraph *AliT0Parameters::GetSlewRec(Int_t ipmt) const | |
247 | { | |
248 | if (!fCalibentry) { | |
249 | return (TGraph*)fSlewingRec.At(ipmt); | |
250 | } | |
251 | return fgCalibData -> GetSlewRec(ipmt) ; | |
252 | } | |
253 | ||
c41ceaac | 254 | |
255 | //________________________________________________________________ | |
256 | void AliT0Parameters::SetWalk(Int_t ipmt) | |
257 | { | |
258 | ||
259 | Int_t mv, ps; | |
260 | Int_t x[70000], y[70000], index[70000]; | |
261 | Float_t time[10000],amplitude[10000]; | |
262 | string buffer; | |
263 | Bool_t down=false; | |
264 | ||
aae44346 | 265 | const char * filename = gSystem->ExpandPathName("$ALICE_ROOT/T0/data/CFD-Amp.txt"); |
266 | ifstream inFile(filename); | |
c41ceaac | 267 | // if(!inFile) AliError(Form("Cannot open file %s !",filename)); |
268 | ||
ca7c0417 | 269 | Int_t i=0; |
c41ceaac | 270 | while(getline(inFile,buffer)){ |
271 | inFile >> ps >> mv; | |
272 | ||
273 | x[i]=ps; y[i]=mv; | |
274 | i++; | |
275 | } | |
276 | inFile.close(); | |
277 | ||
278 | TMath::Sort(i, y, index,down); | |
279 | Int_t amp=0, iin=0, isum=0, sum=0; | |
280 | Int_t ind=0; | |
aae44346 | 281 | for (Int_t ii=0; ii<i; ii++) |
c41ceaac | 282 | { |
283 | ind=index[ii]; | |
284 | if(y[ind] == amp) | |
285 | { | |
286 | sum +=x[ind]; | |
287 | iin++; | |
288 | } | |
289 | else | |
290 | { | |
291 | if(iin>0) | |
292 | time[isum] = Float_t (sum/(iin)); | |
293 | else | |
294 | time[isum] =Float_t (x[ind]); | |
295 | amplitude[isum] = Float_t (amp); | |
296 | amp=y[ind]; | |
297 | // cout<<ii<<" "<<ind<<" "<<y[ind]<<" "<<x[ind]<<" iin "<<iin<<" mean "<<time[isum]<<" amp "<< amplitude[isum]<<" "<<isum<<endl; | |
298 | iin=0; | |
299 | isum++; | |
300 | sum=0; | |
301 | } | |
302 | ||
303 | ||
304 | } | |
305 | ||
306 | inFile.close(); | |
307 | ||
308 | TGraph* gr = new TGraph(isum, amplitude, time); | |
309 | fWalk.AddAtAndExpand(gr,ipmt); | |
310 | ||
311 | ||
312 | } | |
313 | //__________________________________________________________________ | |
314 | ||
315 | TGraph *AliT0Parameters::GetWalk(Int_t ipmt) const | |
316 | { | |
317 | if (!fCalibentry) { | |
318 | return (TGraph*)fWalk.At(ipmt); | |
319 | } | |
320 | return fgCalibData -> GetWalk(ipmt) ; | |
321 | } | |
322 | ||
323 | //__________________________________________________________________ | |
324 | ||
325 | Float_t AliT0Parameters::GetWalkVal(Int_t ipmt, Float_t mv) const | |
326 | { | |
327 | if (!fCalibentry) { | |
328 | return ((TGraph*)fWalk.At(ipmt))->Eval(mv); | |
329 | } | |
330 | return fgCalibData -> GetWalkVal(ipmt, mv) ; | |
331 | } | |
332 | ||
c41ceaac | 333 | |
dc7ca31d | 334 | //__________________________________________________________________ |
335 | void | |
336 | AliT0Parameters::SetPMTeff(Int_t ipmt) | |
337 | { | |
338 | Float_t lambda[50]; | |
339 | Float_t eff[50 ] = {0, 0, 0.23619, 0.202909, 0.177913, | |
340 | 0.175667, 0.17856, 0.190769, 0.206667, 0.230286, | |
341 | 0.252276, 0.256267,0.26, 0.27125, 0.281818, | |
342 | 0.288118, 0.294057,0.296222, 0.301622, 0.290421, | |
343 | 0.276615, 0.2666, 0.248, 0.23619, 0.227814, | |
344 | 0.219818, 0.206667,0.194087, 0.184681, 0.167917, | |
345 | 0.154367, 0.1364, 0.109412, 0.0834615,0.0725283, | |
346 | 0.0642963,0.05861, 0.0465, 0.0413333,0.032069, | |
347 | 0.0252203,0.02066, 0.016262, 0.012, 0.00590476, | |
348 | 0.003875, 0.00190, 0, 0, 0 } ; | |
349 | for (Int_t i=0; i<50; i++) lambda[i]=200+10*i; | |
350 | ||
351 | TGraph* gr = new TGraph(50,lambda,eff); | |
352 | fPMTeff.AddAtAndExpand(gr,ipmt); | |
353 | } | |
e0bba6cc | 354 | //________________________________________________________________ |
355 | ||
356 | Int_t | |
357 | AliT0Parameters::GetChannel(Int_t trm, Int_t tdc, Int_t chain, Int_t channel) | |
358 | { | |
359 | ||
360 | ||
361 | AliT0LookUpKey * lookkey; //= new AliT0LookUpKey(); | |
362 | AliT0LookUpValue * lookvalue= new AliT0LookUpValue(trm,tdc,chain,channel); | |
363 | ||
364 | lookkey = (AliT0LookUpKey*) fgLookUp->GetMapLookup()->GetValue((TObject*)lookvalue); | |
365 | if (!lookkey ) { | |
366 | cout<<" no such address "<<endl; return -1; | |
367 | } | |
368 | ||
369 | ||
370 | //cout<<"AliT0Parameters:: key "<<lookkey->GetKey()<<endl; | |
371 | return lookkey->GetKey(); | |
372 | ||
373 | ||
374 | } | |
5325480c | 375 | //__________________________________________________________________ |
376 | Int_t | |
377 | AliT0Parameters::GetNumberOfTRMs() | |
378 | { | |
379 | // return number of trms | |
380 | // | |
381 | if (!fgLookUp) { | |
382 | fNumberOfTRMs = 2; | |
383 | return fNumberOfTRMs; | |
384 | } | |
385 | return fgLookUp ->GetNumberOfTRMs(); | |
386 | } | |
387 | //________________________________________________________________________________ | |
388 | Double_t AliT0Parameters::GetZPosition(const char* symname){ | |
389 | // Get the global z coordinate of the given T0 alignable volume | |
390 | // | |
391 | Double_t *tr; | |
392 | ||
393 | cout<<symname<<endl; | |
394 | TGeoPNEntry *pne = gGeoManager->GetAlignableEntry(symname); | |
395 | if (!pne) return 0; | |
396 | ||
397 | ||
398 | TGeoPhysicalNode *pnode = pne->GetPhysicalNode(); | |
399 | if(pnode){ | |
400 | TGeoHMatrix* hm = pnode->GetMatrix(); | |
401 | tr = hm->GetTranslation(); | |
402 | }else{ | |
403 | const char* path = pne->GetTitle(); | |
404 | if(!gGeoManager->cd(path)){ | |
405 | AliErrorClass(Form("Volume path %s not valid!",path)); | |
406 | return 0; | |
407 | } | |
408 | tr = gGeoManager->GetCurrentMatrix()->GetTranslation(); | |
409 | } | |
410 | return tr[2]; | |
411 | ||
412 | } | |
413 |