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