]>
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" | |
e0bba6cc | 33 | #include "AliT0LookUpValue.h" |
94249139 | 34 | #include "AliT0LookUpKey.h" |
dc7ca31d | 35 | #include <AliCDBManager.h> |
36 | #include <AliCDBEntry.h> | |
aae44346 | 37 | #include <TMath.h> |
5325480c | 38 | #include <TGeoManager.h> |
39 | #include <TGeoPhysicalNode.h> | |
29d3e0eb | 40 | #include <AliGeomManager.h> |
dc7ca31d | 41 | |
82ee3b37 | 42 | AliT0CalibTimeEq* AliT0Parameters::fgCalibData = 0; |
e0bba6cc | 43 | AliT0CalibData* AliT0Parameters::fgLookUp = 0; |
82ee3b37 | 44 | AliT0CalibWalk* AliT0Parameters::fgSlewCorr =0; |
dc7ca31d | 45 | //==================================================================== |
46 | ClassImp(AliT0Parameters) | |
47 | #if 0 | |
48 | ; // This is here to keep Emacs for indenting the next line | |
49 | #endif | |
50 | ||
51 | //____________________________________________________________________ | |
52 | AliT0Parameters* AliT0Parameters::fgInstance = 0; | |
53 | //____________________________________________________________________ | |
3b7f37fd | 54 | AliT0Parameters* AliT0Parameters::Instance() |
dc7ca31d | 55 | { |
56 | // Get static instance | |
76f3b07a | 57 | if (!fgInstance) { |
58 | fgInstance = new AliT0Parameters; | |
76f3b07a | 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), | |
29d3e0eb | 69 | fAmpLEDRec(0), |
5325480c | 70 | fPMTeff(), |
29d3e0eb | 71 | fWalk(0), |
29d3e0eb | 72 | fTimeDelayCFD(0), |
82ee3b37 | 73 | // fTimeV0(0), |
29d3e0eb | 74 | fTimeDelayTVD(0), |
494f5042 | 75 | fMeanT0(512), |
29d3e0eb | 76 | fLookUp(0), |
77 | fNumberOfTRMs(2), | |
78 | fCalibentry(), fLookUpentry(),fSlewCorr() | |
79 | ||
74adb36a | 80 | |
dc7ca31d | 81 | { |
82 | // Default constructor | |
dc7ca31d | 83 | for (Int_t ipmt=0; ipmt<24; ipmt++) |
84 | { | |
dc7ca31d | 85 | SetPh2Mip(); |
86 | SetmV2Mip(); | |
87 | SetChannelWidth(); | |
88 | SetmV2channel(); | |
dc7ca31d | 89 | SetQTmin(); |
90 | SetQTmax(); | |
91 | SetPMTeff(ipmt); | |
74adb36a | 92 | } |
dc7ca31d | 93 | SetTimeDelayTVD(); |
94 | SetZposition(); | |
74adb36a | 95 | |
dc7ca31d | 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 | if (fIsInit) return; |
6ba20b30 | 105 | |
74adb36a | 106 | AliCDBManager *stor =AliCDBManager::Instance(); |
74adb36a | 107 | //time equalizing |
256d4943 | 108 | fCalibentry = stor->Get("T0/Calib/TimeDelay"); |
109 | if (fCalibentry) | |
82ee3b37 | 110 | fgCalibData = (AliT0CalibTimeEq*)fCalibentry->GetObject(); |
256d4943 | 111 | else { |
112 | AliFatal(" ALARM !!!! No time delays in CDB "); | |
113 | fIsInit = kFALSE; | |
114 | return; | |
115 | } | |
c41ceaac | 116 | //slewing correction |
74adb36a | 117 | fSlewCorr = stor->Get("T0/Calib/Slewing_Walk"); |
5325480c | 118 | if (fSlewCorr){ |
82ee3b37 | 119 | fgSlewCorr = (AliT0CalibWalk*)fSlewCorr->GetObject(); |
c41ceaac | 120 | } |
3b7f37fd | 121 | else { |
256d4943 | 122 | AliFatal(" ALARM !!!! No slewing correction in CDB "); |
3b7f37fd | 123 | fIsInit = kFALSE; |
124 | return; | |
125 | } | |
74adb36a | 126 | //lookup table |
6eac39a1 | 127 | fLookUpentry = stor->Get("T0/Calib/LookUp_Table"); |
e0bba6cc | 128 | if (fLookUpentry){ |
129 | fgLookUp = (AliT0CalibData*)fLookUpentry->GetObject(); | |
e0bba6cc | 130 | } |
3b7f37fd | 131 | else { |
256d4943 | 132 | AliFatal(" ALARM !!!! No Lookup table in CDB "); |
3b7f37fd | 133 | fIsInit = kFALSE; |
134 | return; | |
135 | } | |
dc7ca31d | 136 | fIsInit = kTRUE; |
137 | } | |
138 | ||
139 | ||
dc7ca31d | 140 | //__________________________________________________________________ |
f8bea420 | 141 | |
142 | void AliT0Parameters::InitIfOnline() | |
143 | { | |
144 | // should be used in online | |
145 | // for switching to this one should write | |
146 | // AliT0RawReader myrawreader(rawReader); | |
147 | // myrawreader.SetOnlineMode(kTRUE); | |
94249139 | 148 | |
149 | if (fIsInit) return; | |
29d3e0eb | 150 | //standart configuration (used for simulation) |
151 | //Int_t trm=0; Int_t tdc=0; Int_t chain=0; Int_t channel=0; | |
152 | // configuration for test Jun07. | |
d9cae8af | 153 | fgLookUp = new AliT0CalibData("T0"); |
dd9fd8d6 | 154 | |
0d72dc5b | 155 | fNumberOfTRMs = 1; |
d9cae8af | 156 | fgLookUp-> SetNumberOfTRMs(fNumberOfTRMs); |
0d72dc5b | 157 | Int_t trm=7; Int_t tdc=0; Int_t chain=0; Int_t channel=0; |
79e04c5f | 158 | for (Int_t ik=0; ik<105; ik++) |
f8bea420 | 159 | { |
160 | AliT0LookUpKey * lookkey= new AliT0LookUpKey(); | |
161 | AliT0LookUpValue * lookvalue= new AliT0LookUpValue(); | |
162 | ||
163 | ||
164 | lookvalue->SetTRM(trm); | |
165 | lookvalue->SetTDC(tdc); | |
166 | lookvalue->SetChain(chain); | |
167 | lookvalue->SetChannel(channel); | |
168 | lookkey->SetKey(ik); | |
663b10cd | 169 | if (channel<6) channel +=2; |
170 | else {channel = 0; tdc++;} | |
dd9fd8d6 | 171 | if(ik==57) { tdc=0; channel=0; chain = 1;} |
172 | ||
173 | fgLookUp->GetMapLookup()->Add((TObject*)lookvalue,(TObject*)lookkey); | |
f8bea420 | 174 | } |
74adb36a | 175 | |
176 | fIsInit=kTRUE; | |
f8bea420 | 177 | } |
178 | //__________________________________________________________________ | |
dc7ca31d | 179 | Float_t |
180 | AliT0Parameters::GetTimeDelayCFD(Int_t ipmt) | |
82ee3b37 | 181 | { |
dc7ca31d | 182 | // return time delay for CFD channel |
183 | // | |
184 | if (!fCalibentry) | |
185 | { | |
c41ceaac | 186 | fTimeDelayCFD = 1000+ipmt*100; |
187 | return fTimeDelayCFD; | |
dc7ca31d | 188 | } |
189 | ||
82ee3b37 | 190 | return fgCalibData->GetTimeEq(ipmt); |
dc7ca31d | 191 | } |
dc7ca31d | 192 | //__________________________________________________________________ |
193 | ||
74adb36a | 194 | TGraph *AliT0Parameters::GetAmpLEDRec(Int_t ipmt) const |
dc7ca31d | 195 | { |
94249139 | 196 | // get walk correction by LED-CFD vs CFD graph |
74adb36a | 197 | if (!fSlewCorr) { |
29d3e0eb | 198 | AliError("No slewing correction is available!"); |
199 | return (TGraph*)fAmpLEDRec.At(ipmt); | |
dc7ca31d | 200 | } |
74adb36a | 201 | return fgSlewCorr -> GetAmpLEDRec(ipmt) ; |
dc7ca31d | 202 | } |
203 | ||
204 | //__________________________________________________________________ | |
205 | ||
c41ceaac | 206 | TGraph *AliT0Parameters::GetWalk(Int_t ipmt) const |
207 | { | |
94249139 | 208 | // get walk correction by QTC vs CFD |
74adb36a | 209 | if (!fSlewCorr) { |
29d3e0eb | 210 | AliError("No walk correction is available!"); |
c41ceaac | 211 | return (TGraph*)fWalk.At(ipmt); |
212 | } | |
74adb36a | 213 | return fgSlewCorr -> GetWalk(ipmt) ; |
c41ceaac | 214 | } |
215 | ||
216 | //__________________________________________________________________ | |
217 | ||
218 | Float_t AliT0Parameters::GetWalkVal(Int_t ipmt, Float_t mv) const | |
219 | { | |
94249139 | 220 | // get walk correction by QTC vs CFD |
221 | if (!fSlewCorr) { | |
c41ceaac | 222 | return ((TGraph*)fWalk.At(ipmt))->Eval(mv); |
223 | } | |
74adb36a | 224 | return fgSlewCorr -> GetWalkVal(ipmt, mv) ; |
c41ceaac | 225 | } |
226 | ||
c41ceaac | 227 | |
dc7ca31d | 228 | //__________________________________________________________________ |
229 | void | |
230 | AliT0Parameters::SetPMTeff(Int_t ipmt) | |
231 | { | |
94249139 | 232 | // PMT quantum efficiency |
dc7ca31d | 233 | Float_t lambda[50]; |
234 | Float_t eff[50 ] = {0, 0, 0.23619, 0.202909, 0.177913, | |
235 | 0.175667, 0.17856, 0.190769, 0.206667, 0.230286, | |
236 | 0.252276, 0.256267,0.26, 0.27125, 0.281818, | |
237 | 0.288118, 0.294057,0.296222, 0.301622, 0.290421, | |
238 | 0.276615, 0.2666, 0.248, 0.23619, 0.227814, | |
239 | 0.219818, 0.206667,0.194087, 0.184681, 0.167917, | |
240 | 0.154367, 0.1364, 0.109412, 0.0834615,0.0725283, | |
241 | 0.0642963,0.05861, 0.0465, 0.0413333,0.032069, | |
242 | 0.0252203,0.02066, 0.016262, 0.012, 0.00590476, | |
243 | 0.003875, 0.00190, 0, 0, 0 } ; | |
244 | for (Int_t i=0; i<50; i++) lambda[i]=200+10*i; | |
245 | ||
246 | TGraph* gr = new TGraph(50,lambda,eff); | |
247 | fPMTeff.AddAtAndExpand(gr,ipmt); | |
248 | } | |
e0bba6cc | 249 | //________________________________________________________________ |
250 | ||
251 | Int_t | |
252 | AliT0Parameters::GetChannel(Int_t trm, Int_t tdc, Int_t chain, Int_t channel) | |
253 | { | |
94249139 | 254 | // get logical number of channel according physical address |
e0bba6cc | 255 | |
e30bc492 | 256 | if (fgLookUp) { |
257 | AliT0LookUpValue key(trm,tdc,chain,channel); | |
3a06b1d2 | 258 | AliT0LookUpKey *val = (AliT0LookUpKey*) fgLookUp->GetMapLookup()->GetValue((TObject*)&key); |
259 | // AliT0LookUpKey *val = (AliT0LookUpKey*) fLookUp.GetValue((TObject*)&key); | |
e30bc492 | 260 | if (val ) |
261 | return val->GetKey(); | |
262 | else { | |
263 | AliWarning(Form("No such address (%d %d %d %d)!",trm,tdc,chain,channel)); | |
264 | return -1; | |
265 | } | |
266 | } | |
267 | else { | |
268 | AliError("No look up table has been loader!"); | |
29d3e0eb | 269 | return -1; |
e0bba6cc | 270 | } |
e0bba6cc | 271 | |
272 | } | |
5325480c | 273 | //__________________________________________________________________ |
29d3e0eb | 274 | TMap *AliT0Parameters::GetMapLookup() |
275 | { | |
94249139 | 276 | // get LookUp Table |
277 | ||
29d3e0eb | 278 | if (!fgLookUp){ |
279 | cout<<" No look up table in OCDB"; | |
280 | return 0; | |
281 | } | |
282 | return fgLookUp->GetMapLookup(); | |
283 | } | |
284 | //__________________________________________________________________ | |
285 | ||
5325480c | 286 | Int_t |
287 | AliT0Parameters::GetNumberOfTRMs() | |
288 | { | |
289 | // return number of trms | |
290 | // | |
291 | if (!fgLookUp) { | |
29d3e0eb | 292 | // fNumberOfTRMs = 2; |
5325480c | 293 | return fNumberOfTRMs; |
294 | } | |
295 | return fgLookUp ->GetNumberOfTRMs(); | |
296 | } | |
256d4943 | 297 | /* |
5325480c | 298 | //________________________________________________________________________________ |
299 | Double_t AliT0Parameters::GetZPosition(const char* symname){ | |
300 | // Get the global z coordinate of the given T0 alignable volume | |
301 | // | |
29d3e0eb | 302 | Double_t *tr = AliGeomManager::GetMatrix(symname)->GetTranslation(); |
5325480c | 303 | |
5325480c | 304 | return tr[2]; |
29d3e0eb | 305 | } |
256d4943 | 306 | */ |
307 | //________________________________________________________________________________ | |
308 | Double_t AliT0Parameters::GetZPosition(const char* symname){ | |
309 | // Get the global z coordinate of the given T0 alignable volume | |
310 | // | |
311 | Double_t *tr; | |
256d4943 | 312 | TGeoPNEntry *pne = gGeoManager->GetAlignableEntry(symname); |
313 | if (!pne) return 0; | |
314 | ||
315 | ||
316 | TGeoPhysicalNode *pnode = pne->GetPhysicalNode(); | |
317 | if(pnode){ | |
318 | TGeoHMatrix* hm = pnode->GetMatrix(); | |
319 | tr = hm->GetTranslation(); | |
320 | }else{ | |
321 | const char* path = pne->GetTitle(); | |
322 | if(!gGeoManager->cd(path)){ | |
323 | AliErrorClass(Form("Volume path %s not valid!",path)); | |
324 | return 0; | |
325 | } | |
326 | tr = gGeoManager->GetCurrentMatrix()->GetTranslation(); | |
327 | } | |
328 | return tr[2]; | |
329 | ||
330 | } | |
29d3e0eb | 331 | //________________________________________________________________________________ |
332 | ||
333 | Double_t AliT0Parameters::GetZPositionShift(const char* symname) | |
334 | { | |
335 | // Get the global z coordinate of the given T0 alignable volume | |
336 | // | |
337 | Double_t *tr = AliGeomManager::GetMatrix(symname)->GetTranslation(); | |
338 | ||
339 | TGeoHMatrix origmat; | |
340 | AliGeomManager::GetOrigGlobalMatrix(symname,origmat); | |
341 | Double_t *otr = origmat.GetTranslation(); | |
5325480c | 342 | |
29d3e0eb | 343 | return (tr[2]-otr[2]); |
5325480c | 344 | } |
345 |