]>
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 | // | |
6b7d32f7 | 27 | #include "AliT0.h" |
dc7ca31d | 28 | #include "AliLog.h" |
29 | #include "AliT0Parameters.h" | |
30 | #include "AliT0CalibData.h" | |
82ee3b37 | 31 | #include "AliT0CalibWalk.h" |
32 | #include "AliT0CalibTimeEq.h" | |
58bd3a16 | 33 | #include "AliT0CalibLatency.h" |
2d3bfdf7 | 34 | #include "AliT0LookUpKey.h" |
e0bba6cc | 35 | #include "AliT0LookUpValue.h" |
dc7ca31d | 36 | #include <AliCDBManager.h> |
37 | #include <AliCDBEntry.h> | |
0d82bd92 | 38 | #include <AliCDBStorage.h> |
aae44346 | 39 | #include <TMath.h> |
0d82bd92 | 40 | #include <TSystem.h> |
700e6b36 | 41 | //#include <Riostream.h> |
5325480c | 42 | #include <TGeoManager.h> |
43 | #include <TGeoPhysicalNode.h> | |
212239a1 | 44 | #include <TGeoMatrix.h> |
0d82bd92 | 45 | #include <AliGeomManager.h> |
dc7ca31d | 46 | |
82ee3b37 | 47 | AliT0CalibTimeEq* AliT0Parameters::fgCalibData = 0; |
e0bba6cc | 48 | AliT0CalibData* AliT0Parameters::fgLookUp = 0; |
82ee3b37 | 49 | AliT0CalibWalk* AliT0Parameters::fgSlewCorr =0; |
58bd3a16 | 50 | AliT0CalibLatency *AliT0Parameters::fgLatency=0; |
dc7ca31d | 51 | //==================================================================== |
52 | ClassImp(AliT0Parameters) | |
53 | #if 0 | |
54 | ; // This is here to keep Emacs for indenting the next line | |
55 | #endif | |
56 | ||
57 | //____________________________________________________________________ | |
58 | AliT0Parameters* AliT0Parameters::fgInstance = 0; | |
59 | //____________________________________________________________________ | |
3b7f37fd | 60 | AliT0Parameters* AliT0Parameters::Instance() |
dc7ca31d | 61 | { |
62 | // Get static instance | |
76f3b07a | 63 | if (!fgInstance) { |
64 | fgInstance = new AliT0Parameters; | |
76f3b07a | 65 | } |
dc7ca31d | 66 | return fgInstance; |
67 | } | |
68 | ||
69 | //____________________________________________________________________ | |
70 | AliT0Parameters::AliT0Parameters() | |
5325480c | 71 | :fIsInit(kFALSE), |
72 | fPh2Mip(0),fmV2Mip(0), | |
73 | fChannelWidth(0),fmV2Channel(0), | |
74 | fQTmin(0),fQTmax(0), | |
29d3e0eb | 75 | fAmpLEDRec(0), |
5325480c | 76 | fPMTeff(), |
29d3e0eb | 77 | fWalk(0), |
c2337900 | 78 | fQTC(0), |
79 | fAmpLED(0), | |
29d3e0eb | 80 | fTimeDelayCFD(0), |
82ee3b37 | 81 | // fTimeV0(0), |
29d3e0eb | 82 | fTimeDelayTVD(0), |
494f5042 | 83 | fMeanT0(512), |
4c809cd8 | 84 | fMeanVertex(0), |
c05dcae4 | 85 | fLatencyHPTDC(0), |
86 | fLatencyL1(0), | |
87 | fLatencyL1A(0), | |
88 | fLatencyL1C(0), | |
29d3e0eb | 89 | fLookUp(0), |
90 | fNumberOfTRMs(2), | |
91 | fCalibentry(), fLookUpentry(),fSlewCorr() | |
92 | ||
74adb36a | 93 | |
dc7ca31d | 94 | { |
95 | // Default constructor | |
dc7ca31d | 96 | for (Int_t ipmt=0; ipmt<24; ipmt++) |
97 | { | |
dc7ca31d | 98 | SetPh2Mip(); |
99 | SetmV2Mip(); | |
100 | SetChannelWidth(); | |
101 | SetmV2channel(); | |
dc7ca31d | 102 | SetQTmin(); |
103 | SetQTmax(); | |
104 | SetPMTeff(ipmt); | |
74adb36a | 105 | } |
dc7ca31d | 106 | SetTimeDelayTVD(); |
107 | SetZposition(); | |
74adb36a | 108 | |
dc7ca31d | 109 | } |
110 | ||
111 | //__________________________________________________________________ | |
112 | void | |
113 | AliT0Parameters::Init() | |
114 | { | |
115 | // Initialize the parameters manager. We need to get stuff from the | |
116 | // CDB here. | |
94c27e4f | 117 | if (fIsInit) return; |
6ba20b30 | 118 | |
74adb36a | 119 | AliCDBManager *stor =AliCDBManager::Instance(); |
74adb36a | 120 | //time equalizing |
256d4943 | 121 | fCalibentry = stor->Get("T0/Calib/TimeDelay"); |
122 | if (fCalibentry) | |
82ee3b37 | 123 | fgCalibData = (AliT0CalibTimeEq*)fCalibentry->GetObject(); |
256d4943 | 124 | else { |
125 | AliFatal(" ALARM !!!! No time delays in CDB "); | |
126 | fIsInit = kFALSE; | |
127 | return; | |
128 | } | |
c41ceaac | 129 | //slewing correction |
74adb36a | 130 | fSlewCorr = stor->Get("T0/Calib/Slewing_Walk"); |
5325480c | 131 | if (fSlewCorr){ |
82ee3b37 | 132 | fgSlewCorr = (AliT0CalibWalk*)fSlewCorr->GetObject(); |
c41ceaac | 133 | } |
3b7f37fd | 134 | else { |
256d4943 | 135 | AliFatal(" ALARM !!!! No slewing correction in CDB "); |
3b7f37fd | 136 | fIsInit = kFALSE; |
137 | return; | |
138 | } | |
74adb36a | 139 | //lookup table |
6eac39a1 | 140 | fLookUpentry = stor->Get("T0/Calib/LookUp_Table"); |
e0bba6cc | 141 | if (fLookUpentry){ |
142 | fgLookUp = (AliT0CalibData*)fLookUpentry->GetObject(); | |
e0bba6cc | 143 | } |
3b7f37fd | 144 | else { |
256d4943 | 145 | AliFatal(" ALARM !!!! No Lookup table in CDB "); |
3b7f37fd | 146 | fIsInit = kFALSE; |
147 | return; | |
148 | } | |
58bd3a16 | 149 | //latency |
150 | ||
151 | fLatency = stor->Get("T0/Calib/Latency"); | |
152 | if (fLatency){ | |
153 | fgLatency = (AliT0CalibLatency*)fLatency->GetObject(); | |
154 | } | |
155 | else { | |
156 | AliWarning(" !!! no latency in CDB "); | |
157 | return; | |
158 | } | |
159 | ||
160 | fIsInit = kTRUE; | |
dc7ca31d | 161 | } |
162 | ||
163 | ||
dc7ca31d | 164 | //__________________________________________________________________ |
f8bea420 | 165 | |
166 | void AliT0Parameters::InitIfOnline() | |
167 | { | |
168 | // should be used in online | |
169 | // for switching to this one should write | |
170 | // AliT0RawReader myrawreader(rawReader); | |
171 | // myrawreader.SetOnlineMode(kTRUE); | |
700e6b36 | 172 | |
0d82bd92 | 173 | if (fIsInit) return; |
29d3e0eb | 174 | //standart configuration (used for simulation) |
175 | //Int_t trm=0; Int_t tdc=0; Int_t chain=0; Int_t channel=0; | |
176 | // configuration for test Jun07. | |
d9cae8af | 177 | fgLookUp = new AliT0CalibData("T0"); |
dd9fd8d6 | 178 | |
0d72dc5b | 179 | fNumberOfTRMs = 1; |
d9cae8af | 180 | fgLookUp-> SetNumberOfTRMs(fNumberOfTRMs); |
0d72dc5b | 181 | Int_t trm=7; Int_t tdc=0; Int_t chain=0; Int_t channel=0; |
79e04c5f | 182 | for (Int_t ik=0; ik<105; ik++) |
f8bea420 | 183 | { |
184 | AliT0LookUpKey * lookkey= new AliT0LookUpKey(); | |
185 | AliT0LookUpValue * lookvalue= new AliT0LookUpValue(); | |
186 | ||
187 | ||
188 | lookvalue->SetTRM(trm); | |
189 | lookvalue->SetTDC(tdc); | |
190 | lookvalue->SetChain(chain); | |
191 | lookvalue->SetChannel(channel); | |
192 | lookkey->SetKey(ik); | |
0d82bd92 | 193 | fgLookUp->GetMapLookup()->Add((TObject*)lookvalue,(TObject*)lookkey); |
663b10cd | 194 | if (channel<6) channel +=2; |
195 | else {channel = 0; tdc++;} | |
0d82bd92 | 196 | if(ik==56) { tdc=0; channel=0; chain = 1;} |
dd9fd8d6 | 197 | |
f8bea420 | 198 | } |
74adb36a | 199 | |
200 | fIsInit=kTRUE; | |
f8bea420 | 201 | } |
202 | //__________________________________________________________________ | |
dc7ca31d | 203 | Float_t |
204 | AliT0Parameters::GetTimeDelayCFD(Int_t ipmt) | |
82ee3b37 | 205 | { |
dc7ca31d | 206 | // return time delay for CFD channel |
207 | // | |
208 | if (!fCalibentry) | |
209 | { | |
c41ceaac | 210 | fTimeDelayCFD = 1000+ipmt*100; |
211 | return fTimeDelayCFD; | |
dc7ca31d | 212 | } |
213 | ||
82ee3b37 | 214 | return fgCalibData->GetTimeEq(ipmt); |
dc7ca31d | 215 | } |
58bd3a16 | 216 | |
217 | //__________________________________________________________________ | |
218 | Float_t | |
219 | AliT0Parameters::GetLatencyHPTDC() | |
220 | { | |
221 | // return LatencyHPTDC for CFD channel | |
222 | if (!fLatency) | |
223 | { | |
224 | fLatencyHPTDC=9000.; | |
225 | return fLatencyHPTDC; | |
226 | } | |
227 | ||
228 | return fgLatency->GetLatencyHPTDC(); | |
229 | } | |
230 | //__________________________________________________________________ | |
231 | Float_t | |
232 | AliT0Parameters::GetLatencyL1() | |
233 | { | |
234 | // return time delay for CFD channel | |
235 | ||
236 | return fgLatency->GetLatencyL1(); | |
237 | } | |
238 | ||
239 | //__________________________________________________________________ | |
240 | Float_t | |
241 | AliT0Parameters::GetLatencyL1A() | |
242 | { | |
243 | // return time delay for CFD channel | |
244 | ||
245 | return fgLatency->GetLatencyL1A(); | |
246 | } | |
247 | ||
248 | //__________________________________________________________________ | |
249 | Float_t | |
250 | AliT0Parameters::GetLatencyL1C() | |
251 | { | |
252 | // return time delay for CFD channel | |
253 | ||
254 | return fgLatency->GetLatencyL1C(); | |
255 | } | |
dc7ca31d | 256 | //__________________________________________________________________ |
257 | ||
b95e8d87 | 258 | Float_t |
259 | AliT0Parameters:: GetMeanVertex() | |
260 | { | |
261 | if (!fCalibentry) | |
262 | { | |
263 | fMeanVertex=0; | |
264 | return fMeanVertex; | |
265 | } | |
266 | ||
267 | return fgCalibData->GetMeanVertex(); | |
268 | } | |
269 | //__________________________________________________________________ | |
270 | ||
74adb36a | 271 | TGraph *AliT0Parameters::GetAmpLEDRec(Int_t ipmt) const |
dc7ca31d | 272 | { |
74adb36a | 273 | if (!fSlewCorr) { |
29d3e0eb | 274 | AliError("No slewing correction is available!"); |
275 | return (TGraph*)fAmpLEDRec.At(ipmt); | |
dc7ca31d | 276 | } |
74adb36a | 277 | return fgSlewCorr -> GetAmpLEDRec(ipmt) ; |
dc7ca31d | 278 | } |
279 | ||
280 | //__________________________________________________________________ | |
281 | ||
c41ceaac | 282 | TGraph *AliT0Parameters::GetWalk(Int_t ipmt) const |
283 | { | |
74adb36a | 284 | if (!fSlewCorr) { |
29d3e0eb | 285 | AliError("No walk correction is available!"); |
c41ceaac | 286 | return (TGraph*)fWalk.At(ipmt); |
287 | } | |
74adb36a | 288 | return fgSlewCorr -> GetWalk(ipmt) ; |
c41ceaac | 289 | } |
290 | ||
291 | //__________________________________________________________________ | |
292 | ||
c883fdf2 | 293 | TGraph *AliT0Parameters::GetQTC(Int_t ipmt) const |
c41ceaac | 294 | { |
0d82bd92 | 295 | if (!fSlewCorr) { |
c883fdf2 | 296 | AliError("No walk correction is available!"); |
297 | // return (TGraph*)fQTC.At(ipmt); | |
298 | return 0; | |
c41ceaac | 299 | } |
c883fdf2 | 300 | return fgSlewCorr -> GetQTC(ipmt) ; |
c41ceaac | 301 | } |
302 | ||
c883fdf2 | 303 | //__________________________________________________________________ |
304 | TGraph *AliT0Parameters::GetAmpLED(Int_t ipmt) const | |
305 | { | |
306 | if (!fSlewCorr) { | |
307 | AliError("No walk correction is available!"); | |
308 | // return (TGraph*)fQTC.At(ipmt); | |
309 | return 0; | |
310 | } | |
311 | return fgSlewCorr -> GetAmpLED(ipmt) ; | |
312 | } | |
c41ceaac | 313 | |
dc7ca31d | 314 | //__________________________________________________________________ |
315 | void | |
316 | AliT0Parameters::SetPMTeff(Int_t ipmt) | |
317 | { | |
318 | Float_t lambda[50]; | |
319 | Float_t eff[50 ] = {0, 0, 0.23619, 0.202909, 0.177913, | |
320 | 0.175667, 0.17856, 0.190769, 0.206667, 0.230286, | |
321 | 0.252276, 0.256267,0.26, 0.27125, 0.281818, | |
322 | 0.288118, 0.294057,0.296222, 0.301622, 0.290421, | |
323 | 0.276615, 0.2666, 0.248, 0.23619, 0.227814, | |
324 | 0.219818, 0.206667,0.194087, 0.184681, 0.167917, | |
325 | 0.154367, 0.1364, 0.109412, 0.0834615,0.0725283, | |
326 | 0.0642963,0.05861, 0.0465, 0.0413333,0.032069, | |
327 | 0.0252203,0.02066, 0.016262, 0.012, 0.00590476, | |
328 | 0.003875, 0.00190, 0, 0, 0 } ; | |
329 | for (Int_t i=0; i<50; i++) lambda[i]=200+10*i; | |
330 | ||
331 | TGraph* gr = new TGraph(50,lambda,eff); | |
332 | fPMTeff.AddAtAndExpand(gr,ipmt); | |
333 | } | |
e0bba6cc | 334 | //________________________________________________________________ |
335 | ||
336 | Int_t | |
337 | AliT0Parameters::GetChannel(Int_t trm, Int_t tdc, Int_t chain, Int_t channel) | |
338 | { | |
339 | ||
e30bc492 | 340 | if (fgLookUp) { |
341 | AliT0LookUpValue key(trm,tdc,chain,channel); | |
3a06b1d2 | 342 | AliT0LookUpKey *val = (AliT0LookUpKey*) fgLookUp->GetMapLookup()->GetValue((TObject*)&key); |
343 | // AliT0LookUpKey *val = (AliT0LookUpKey*) fLookUp.GetValue((TObject*)&key); | |
e30bc492 | 344 | if (val ) |
345 | return val->GetKey(); | |
346 | else { | |
347 | AliWarning(Form("No such address (%d %d %d %d)!",trm,tdc,chain,channel)); | |
348 | return -1; | |
349 | } | |
350 | } | |
351 | else { | |
352 | AliError("No look up table has been loader!"); | |
29d3e0eb | 353 | return -1; |
e0bba6cc | 354 | } |
e0bba6cc | 355 | |
356 | } | |
5325480c | 357 | //__________________________________________________________________ |
29d3e0eb | 358 | TMap *AliT0Parameters::GetMapLookup() |
359 | { | |
360 | if (!fgLookUp){ | |
361 | cout<<" No look up table in OCDB"; | |
362 | return 0; | |
363 | } | |
364 | return fgLookUp->GetMapLookup(); | |
365 | } | |
366 | //__________________________________________________________________ | |
367 | ||
5325480c | 368 | Int_t |
369 | AliT0Parameters::GetNumberOfTRMs() | |
370 | { | |
371 | // return number of trms | |
372 | // | |
373 | if (!fgLookUp) { | |
29d3e0eb | 374 | // fNumberOfTRMs = 2; |
5325480c | 375 | return fNumberOfTRMs; |
376 | } | |
377 | return fgLookUp ->GetNumberOfTRMs(); | |
378 | } | |
256d4943 | 379 | /* |
5325480c | 380 | //________________________________________________________________________________ |
381 | Double_t AliT0Parameters::GetZPosition(const char* symname){ | |
382 | // Get the global z coordinate of the given T0 alignable volume | |
383 | // | |
29d3e0eb | 384 | Double_t *tr = AliGeomManager::GetMatrix(symname)->GetTranslation(); |
5325480c | 385 | |
5325480c | 386 | return tr[2]; |
29d3e0eb | 387 | } |
256d4943 | 388 | */ |
389 | //________________________________________________________________________________ | |
390 | Double_t AliT0Parameters::GetZPosition(const char* symname){ | |
391 | // Get the global z coordinate of the given T0 alignable volume | |
392 | // | |
393 | Double_t *tr; | |
256d4943 | 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 | } | |
29d3e0eb | 413 | //________________________________________________________________________________ |
414 | ||
415 | Double_t AliT0Parameters::GetZPositionShift(const char* symname) | |
416 | { | |
417 | // Get the global z coordinate of the given T0 alignable volume | |
418 | // | |
419 | Double_t *tr = AliGeomManager::GetMatrix(symname)->GetTranslation(); | |
420 | ||
421 | TGeoHMatrix origmat; | |
422 | AliGeomManager::GetOrigGlobalMatrix(symname,origmat); | |
423 | Double_t *otr = origmat.GetTranslation(); | |
5325480c | 424 | |
29d3e0eb | 425 | return (tr[2]-otr[2]); |
5325480c | 426 | } |
427 |