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