]>
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 | |
107 | AliCDBStorage *stor =AliCDBManager::Instance()->GetStorage("local://$ALICE_ROOT"); | |
c41ceaac | 108 | //time equalizing |
109 | AliCDBEntry* fCalibentry = stor->Get("T0/Calib/TimeDelay",0); | |
5325480c | 110 | if (fCalibentry) |
dc7ca31d | 111 | fgCalibData = (AliT0CalibData*)fCalibentry->GetObject(); |
5325480c | 112 | else |
113 | AliError(" ALARM !!!! No time delays in CDB "); | |
c41ceaac | 114 | //slewing correction |
115 | AliCDBEntry* fSlewCorr = stor->Get("T0/Calib/Slewing_Walk",0); | |
5325480c | 116 | if (fSlewCorr){ |
117 | fgSlewCorr = (AliT0CalibData*)fSlewCorr->GetObject(); | |
c41ceaac | 118 | } |
6ba20b30 | 119 | fLookUpentry = stor->Get("T0/Calib/LookUp_Table",0); |
e0bba6cc | 120 | if (fLookUpentry){ |
121 | fgLookUp = (AliT0CalibData*)fLookUpentry->GetObject(); | |
e0bba6cc | 122 | } |
123 | else { | |
ca7c0417 | 124 | const char * filename = gSystem->ExpandPathName("$ALICE_ROOT/T0/lookUpTable.txt"); |
125 | ifstream inFile(filename); | |
126 | fgLookUp->ReadAsciiLookup(filename); | |
e0bba6cc | 127 | } |
dc7ca31d | 128 | |
129 | fIsInit = kTRUE; | |
130 | } | |
131 | ||
132 | ||
dc7ca31d | 133 | //__________________________________________________________________ |
134 | Float_t | |
94c27e4f | 135 | AliT0Parameters::GetTimeDelayDA(Int_t ipmt) |
dc7ca31d | 136 | { |
137 | // return time delay for LED channel | |
138 | // | |
139 | if (!fCalibentry) { | |
d530f23a | 140 | fTimeDelayDA = 500; |
94c27e4f | 141 | return fTimeDelayDA; |
dc7ca31d | 142 | } |
94c27e4f | 143 | return fgCalibData ->GetTimeDelayDA(ipmt); |
dc7ca31d | 144 | } |
145 | //__________________________________________________________________ | |
146 | Float_t | |
147 | AliT0Parameters::GetTimeDelayCFD(Int_t ipmt) | |
148 | { | |
149 | // return time delay for CFD channel | |
150 | // | |
151 | if (!fCalibentry) | |
152 | { | |
c41ceaac | 153 | fTimeDelayCFD = 1000+ipmt*100; |
154 | return fTimeDelayCFD; | |
dc7ca31d | 155 | } |
156 | ||
157 | return fgCalibData->GetTimeDelayCFD(ipmt); | |
158 | } | |
159 | ||
94c27e4f | 160 | //__________________________________________________________________ |
161 | Int_t | |
162 | AliT0Parameters::GetMeanT0() | |
163 | { | |
164 | // return mean of T0 distrubution with vertex=0 | |
165 | // | |
166 | if (!fCalibentry) | |
167 | { | |
168 | return fMeanT0; | |
169 | } | |
170 | ||
171 | return fgCalibData->GetMeanT0(); | |
172 | } | |
dc7ca31d | 173 | //__________________________________________________________________ |
174 | ||
175 | void | |
176 | AliT0Parameters::SetSlewingLED(Int_t ipmt) | |
177 | { | |
178 | // Set Slweing Correction for LED channel | |
179 | Float_t mv[23] = {25, 30,40,60, 80,100,150,200,250,300, | |
180 | 400,500,600,800,1000,1500, 2000, 3000, 4000, 5500, | |
181 | 6000, 7000,8000}; | |
182 | Float_t y[23] = {5044, 4719, 3835, 3224, 2847, 2691,2327, 2067, 1937, 1781, | |
183 | 1560, 1456 ,1339, 1163.5, 1027, 819, 650, 520, 370.5, 234, | |
184 | 156, 78, 0}; | |
185 | ||
186 | TGraph* gr = new TGraph(23,mv,y); | |
187 | fSlewingLED.AddAtAndExpand(gr,ipmt); | |
188 | } | |
189 | //__________________________________________________________________ | |
190 | ||
191 | Float_t AliT0Parameters::GetSlewingLED(Int_t ipmt, Float_t mv) const | |
192 | { | |
193 | if (!fCalibentry) { | |
194 | return ((TGraph*)fSlewingLED.At(ipmt))->Eval(mv); | |
195 | } | |
196 | return fgCalibData->GetSlewingLED(ipmt, mv) ; | |
197 | } | |
198 | ||
199 | ||
200 | //__________________________________________________________________ | |
201 | ||
202 | TGraph *AliT0Parameters::GetSlew(Int_t ipmt) const | |
203 | { | |
204 | if (!fCalibentry) { | |
205 | return (TGraph*)fSlewingLED.At(ipmt); | |
206 | } | |
207 | return fgCalibData -> GetSlew(ipmt) ; | |
208 | } | |
209 | ||
210 | //__________________________________________________________________ | |
211 | ||
212 | ||
213 | void | |
214 | AliT0Parameters::SetSlewingRec(Int_t ipmt) | |
215 | { | |
216 | // Set Slweing Correction for LED channel | |
217 | Float_t mv[23] = {25, 30, 40,60, 80,100,150,200,250,300, | |
218 | 400,500,600,800,1000,1500, 2000, 3000, 4000, 5500, | |
219 | 6000, 7000,8000}; | |
220 | Float_t y[23] = {5044, 4719, 3835, 3224, 2847, 2691,2327, 2067, 1937, 1781, | |
221 | 1560, 1456 ,1339, 1163.5, 1027, 819, 650, 520, 370.5, 234, | |
222 | 156, 78, 0}; | |
223 | Float_t y1[23], mv1[23]; | |
224 | for (Int_t i=0; i<23; i++){ | |
225 | y1[i] = y[22-i]; mv1[i] = mv[22-i];} | |
226 | ||
227 | TGraph* gr = new TGraph(23,y1,mv1); | |
228 | fSlewingRec.AddAtAndExpand(gr,ipmt); | |
229 | ||
230 | } | |
231 | //__________________________________________________________________ | |
232 | ||
233 | Float_t AliT0Parameters::GetSlewingRec(Int_t ipmt, Float_t mv) const | |
234 | { | |
235 | if (!fCalibentry) { | |
236 | return ((TGraph*)fSlewingRec.At(ipmt))->Eval(mv); | |
237 | } | |
238 | return fgCalibData -> GetSlewingRec(ipmt, mv) ; | |
239 | } | |
240 | ||
241 | //__________________________________________________________________ | |
242 | ||
243 | TGraph *AliT0Parameters::GetSlewRec(Int_t ipmt) const | |
244 | { | |
245 | if (!fCalibentry) { | |
246 | return (TGraph*)fSlewingRec.At(ipmt); | |
247 | } | |
248 | return fgCalibData -> GetSlewRec(ipmt) ; | |
249 | } | |
250 | ||
c41ceaac | 251 | |
252 | //________________________________________________________________ | |
253 | void AliT0Parameters::SetWalk(Int_t ipmt) | |
254 | { | |
255 | ||
256 | Int_t mv, ps; | |
257 | Int_t x[70000], y[70000], index[70000]; | |
258 | Float_t time[10000],amplitude[10000]; | |
259 | string buffer; | |
260 | Bool_t down=false; | |
261 | ||
aae44346 | 262 | const char * filename = gSystem->ExpandPathName("$ALICE_ROOT/T0/data/CFD-Amp.txt"); |
263 | ifstream inFile(filename); | |
c41ceaac | 264 | // if(!inFile) AliError(Form("Cannot open file %s !",filename)); |
265 | ||
ca7c0417 | 266 | Int_t i=0; |
c41ceaac | 267 | while(getline(inFile,buffer)){ |
268 | inFile >> ps >> mv; | |
269 | ||
270 | x[i]=ps; y[i]=mv; | |
271 | i++; | |
272 | } | |
273 | inFile.close(); | |
274 | ||
275 | TMath::Sort(i, y, index,down); | |
276 | Int_t amp=0, iin=0, isum=0, sum=0; | |
277 | Int_t ind=0; | |
aae44346 | 278 | for (Int_t ii=0; ii<i; ii++) |
c41ceaac | 279 | { |
280 | ind=index[ii]; | |
281 | if(y[ind] == amp) | |
282 | { | |
283 | sum +=x[ind]; | |
284 | iin++; | |
285 | } | |
286 | else | |
287 | { | |
288 | if(iin>0) | |
289 | time[isum] = Float_t (sum/(iin)); | |
290 | else | |
291 | time[isum] =Float_t (x[ind]); | |
292 | amplitude[isum] = Float_t (amp); | |
293 | amp=y[ind]; | |
294 | // cout<<ii<<" "<<ind<<" "<<y[ind]<<" "<<x[ind]<<" iin "<<iin<<" mean "<<time[isum]<<" amp "<< amplitude[isum]<<" "<<isum<<endl; | |
295 | iin=0; | |
296 | isum++; | |
297 | sum=0; | |
298 | } | |
299 | ||
300 | ||
301 | } | |
302 | ||
303 | inFile.close(); | |
304 | ||
305 | TGraph* gr = new TGraph(isum, amplitude, time); | |
306 | fWalk.AddAtAndExpand(gr,ipmt); | |
307 | ||
308 | ||
309 | } | |
310 | //__________________________________________________________________ | |
311 | ||
312 | TGraph *AliT0Parameters::GetWalk(Int_t ipmt) const | |
313 | { | |
314 | if (!fCalibentry) { | |
315 | return (TGraph*)fWalk.At(ipmt); | |
316 | } | |
317 | return fgCalibData -> GetWalk(ipmt) ; | |
318 | } | |
319 | ||
320 | //__________________________________________________________________ | |
321 | ||
322 | Float_t AliT0Parameters::GetWalkVal(Int_t ipmt, Float_t mv) const | |
323 | { | |
324 | if (!fCalibentry) { | |
325 | return ((TGraph*)fWalk.At(ipmt))->Eval(mv); | |
326 | } | |
327 | return fgCalibData -> GetWalkVal(ipmt, mv) ; | |
328 | } | |
329 | ||
c41ceaac | 330 | |
dc7ca31d | 331 | //__________________________________________________________________ |
332 | void | |
333 | AliT0Parameters::SetPMTeff(Int_t ipmt) | |
334 | { | |
335 | Float_t lambda[50]; | |
336 | Float_t eff[50 ] = {0, 0, 0.23619, 0.202909, 0.177913, | |
337 | 0.175667, 0.17856, 0.190769, 0.206667, 0.230286, | |
338 | 0.252276, 0.256267,0.26, 0.27125, 0.281818, | |
339 | 0.288118, 0.294057,0.296222, 0.301622, 0.290421, | |
340 | 0.276615, 0.2666, 0.248, 0.23619, 0.227814, | |
341 | 0.219818, 0.206667,0.194087, 0.184681, 0.167917, | |
342 | 0.154367, 0.1364, 0.109412, 0.0834615,0.0725283, | |
343 | 0.0642963,0.05861, 0.0465, 0.0413333,0.032069, | |
344 | 0.0252203,0.02066, 0.016262, 0.012, 0.00590476, | |
345 | 0.003875, 0.00190, 0, 0, 0 } ; | |
346 | for (Int_t i=0; i<50; i++) lambda[i]=200+10*i; | |
347 | ||
348 | TGraph* gr = new TGraph(50,lambda,eff); | |
349 | fPMTeff.AddAtAndExpand(gr,ipmt); | |
350 | } | |
e0bba6cc | 351 | //________________________________________________________________ |
352 | ||
353 | Int_t | |
354 | AliT0Parameters::GetChannel(Int_t trm, Int_t tdc, Int_t chain, Int_t channel) | |
355 | { | |
356 | ||
357 | ||
358 | AliT0LookUpKey * lookkey; //= new AliT0LookUpKey(); | |
359 | AliT0LookUpValue * lookvalue= new AliT0LookUpValue(trm,tdc,chain,channel); | |
360 | ||
361 | lookkey = (AliT0LookUpKey*) fgLookUp->GetMapLookup()->GetValue((TObject*)lookvalue); | |
362 | if (!lookkey ) { | |
363 | cout<<" no such address "<<endl; return -1; | |
364 | } | |
365 | ||
366 | ||
367 | //cout<<"AliT0Parameters:: key "<<lookkey->GetKey()<<endl; | |
368 | return lookkey->GetKey(); | |
369 | ||
370 | ||
371 | } | |
5325480c | 372 | //__________________________________________________________________ |
373 | Int_t | |
374 | AliT0Parameters::GetNumberOfTRMs() | |
375 | { | |
376 | // return number of trms | |
377 | // | |
378 | if (!fgLookUp) { | |
379 | fNumberOfTRMs = 2; | |
380 | return fNumberOfTRMs; | |
381 | } | |
382 | return fgLookUp ->GetNumberOfTRMs(); | |
383 | } | |
384 | //________________________________________________________________________________ | |
385 | Double_t AliT0Parameters::GetZPosition(const char* symname){ | |
386 | // Get the global z coordinate of the given T0 alignable volume | |
387 | // | |
388 | Double_t *tr; | |
389 | ||
390 | cout<<symname<<endl; | |
391 | TGeoPNEntry *pne = gGeoManager->GetAlignableEntry(symname); | |
392 | if (!pne) return 0; | |
393 | ||
394 | ||
395 | TGeoPhysicalNode *pnode = pne->GetPhysicalNode(); | |
396 | if(pnode){ | |
397 | TGeoHMatrix* hm = pnode->GetMatrix(); | |
398 | tr = hm->GetTranslation(); | |
399 | }else{ | |
400 | const char* path = pne->GetTitle(); | |
401 | if(!gGeoManager->cd(path)){ | |
402 | AliErrorClass(Form("Volume path %s not valid!",path)); | |
403 | return 0; | |
404 | } | |
405 | tr = gGeoManager->GetCurrentMatrix()->GetTranslation(); | |
406 | } | |
407 | return tr[2]; | |
408 | ||
409 | } | |
410 |