]> git.uio.no Git - u/mrichter/AliRoot.git/blame - T0/AliT0Parameters.cxx
Remove printout in the event-mixing method
[u/mrichter/AliRoot.git] / T0 / AliT0Parameters.cxx
CommitLineData
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 47AliT0CalibTimeEq* AliT0Parameters::fgCalibData = 0;
e0bba6cc 48AliT0CalibData* AliT0Parameters::fgLookUp = 0;
82ee3b37 49AliT0CalibWalk* AliT0Parameters::fgSlewCorr =0;
58bd3a16 50AliT0CalibLatency *AliT0Parameters::fgLatency=0;
dc7ca31d 51//====================================================================
cdf48647 52using std::cout;
dc7ca31d 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//____________________________________________________________________
3b7f37fd 61AliT0Parameters* AliT0Parameters::Instance()
dc7ca31d 62{
63 // Get static instance
76f3b07a 64 if (!fgInstance) {
65 fgInstance = new AliT0Parameters;
76f3b07a 66 }
dc7ca31d 67 return fgInstance;
68}
69
70//____________________________________________________________________
71AliT0Parameters::AliT0Parameters()
5325480c 72 :fIsInit(kFALSE),
73 fPh2Mip(0),fmV2Mip(0),
74 fChannelWidth(0),fmV2Channel(0),
75 fQTmin(0),fQTmax(0),
29d3e0eb 76 fAmpLEDRec(0),
5325480c 77 fPMTeff(),
29d3e0eb 78 fWalk(0),
c2337900 79 fQTC(0),
80 fAmpLED(0),
29d3e0eb 81 fTimeDelayCFD(0),
82ee3b37 82 // fTimeV0(0),
29d3e0eb 83 fTimeDelayTVD(0),
494f5042 84 fMeanT0(512),
4c809cd8 85 fMeanVertex(0),
c05dcae4 86 fLatencyHPTDC(0),
87 fLatencyL1(0),
88 fLatencyL1A(0),
89 fLatencyL1C(0),
29d3e0eb 90 fLookUp(0),
91 fNumberOfTRMs(2),
92a84efb 92 fCalibentry(),
93 fLookUpentry(),
94 fSlewCorr(),
95 fLatency()
74adb36a 96
dc7ca31d 97{
98 // Default constructor
dc7ca31d 99 for (Int_t ipmt=0; ipmt<24; ipmt++)
100 {
dc7ca31d 101 SetPh2Mip();
102 SetmV2Mip();
103 SetChannelWidth();
104 SetmV2channel();
dc7ca31d 105 SetQTmin();
106 SetQTmax();
107 SetPMTeff(ipmt);
74adb36a 108 }
dc7ca31d 109 SetTimeDelayTVD();
110 SetZposition();
74adb36a 111
dc7ca31d 112}
113
114//__________________________________________________________________
115void
116AliT0Parameters::Init()
117{
118 // Initialize the parameters manager. We need to get stuff from the
119 // CDB here.
94c27e4f 120 if (fIsInit) return;
6ba20b30 121
74adb36a 122 AliCDBManager *stor =AliCDBManager::Instance();
74adb36a 123 //time equalizing
256d4943 124 fCalibentry = stor->Get("T0/Calib/TimeDelay");
125 if (fCalibentry)
82ee3b37 126 fgCalibData = (AliT0CalibTimeEq*)fCalibentry->GetObject();
256d4943 127 else {
128 AliFatal(" ALARM !!!! No time delays in CDB ");
129 fIsInit = kFALSE;
130 return;
131 }
c41ceaac 132 //slewing correction
74adb36a 133 fSlewCorr = stor->Get("T0/Calib/Slewing_Walk");
5325480c 134 if (fSlewCorr){
82ee3b37 135 fgSlewCorr = (AliT0CalibWalk*)fSlewCorr->GetObject();
c41ceaac 136 }
3b7f37fd 137 else {
256d4943 138 AliFatal(" ALARM !!!! No slewing correction in CDB ");
3b7f37fd 139 fIsInit = kFALSE;
140 return;
141 }
74adb36a 142 //lookup table
6eac39a1 143 fLookUpentry = stor->Get("T0/Calib/LookUp_Table");
e0bba6cc 144 if (fLookUpentry){
145 fgLookUp = (AliT0CalibData*)fLookUpentry->GetObject();
e0bba6cc 146 }
3b7f37fd 147 else {
256d4943 148 AliFatal(" ALARM !!!! No Lookup table in CDB ");
3b7f37fd 149 fIsInit = kFALSE;
150 return;
151 }
58bd3a16 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;
dc7ca31d 164}
165
166
dc7ca31d 167//__________________________________________________________________
f8bea420 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);
0277ddeb 175
0d82bd92 176 if (fIsInit) return;
0277ddeb 177 //standart configuration (used for simulation)
178 //Int_t trm=0; Int_t tdc=0; Int_t chain=0; Int_t channel=0;
29d3e0eb 179 // configuration for test Jun07.
0277ddeb 180 fgLookUp = new AliT0CalibData("T0");
181
0d72dc5b 182 fNumberOfTRMs = 1;
0277ddeb 183 fgLookUp-> SetNumberOfTRMs(fNumberOfTRMs);
0d72dc5b 184 Int_t trm=7; Int_t tdc=0; Int_t chain=0; Int_t channel=0;
79e04c5f 185 for (Int_t ik=0; ik<105; ik++)
0277ddeb 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 }
74adb36a 215
216 fIsInit=kTRUE;
f8bea420 217}
218//__________________________________________________________________
dc7ca31d 219Float_t
220AliT0Parameters::GetTimeDelayCFD(Int_t ipmt)
82ee3b37 221 {
dc7ca31d 222 // return time delay for CFD channel
223 //
224 if (!fCalibentry)
225 {
c41ceaac 226 fTimeDelayCFD = 1000+ipmt*100;
227 return fTimeDelayCFD;
dc7ca31d 228 }
229
82ee3b37 230 return fgCalibData->GetTimeEq(ipmt);
dc7ca31d 231}
112274a2 232//__________________________________________________________________
233Float_t
234AliT0Parameters::GetCFD(Int_t ipmt)
235 {
236 // return CFD channel
237
238 return fgCalibData->GetCFDvalue(ipmt,0);
239}
58bd3a16 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}
dc7ca31d 280//__________________________________________________________________
281
b95e8d87 282Float_t
283AliT0Parameters:: GetMeanVertex()
284{
285 if (!fCalibentry)
286 {
287 fMeanVertex=0;
288 return fMeanVertex;
289 }
290
291 return fgCalibData->GetMeanVertex();
292}
293//__________________________________________________________________
294
74adb36a 295TGraph *AliT0Parameters::GetAmpLEDRec(Int_t ipmt) const
dc7ca31d 296{
74adb36a 297 if (!fSlewCorr) {
29d3e0eb 298 AliError("No slewing correction is available!");
299 return (TGraph*)fAmpLEDRec.At(ipmt);
dc7ca31d 300 }
74adb36a 301 return fgSlewCorr -> GetAmpLEDRec(ipmt) ;
dc7ca31d 302}
303
304//__________________________________________________________________
305
c41ceaac 306TGraph *AliT0Parameters::GetWalk(Int_t ipmt) const
307{
74adb36a 308 if (!fSlewCorr) {
29d3e0eb 309 AliError("No walk correction is available!");
c41ceaac 310 return (TGraph*)fWalk.At(ipmt);
311 }
74adb36a 312 return fgSlewCorr -> GetWalk(ipmt) ;
c41ceaac 313}
314
315//__________________________________________________________________
316
c883fdf2 317TGraph *AliT0Parameters::GetQTC(Int_t ipmt) const
c41ceaac 318{
0d82bd92 319 if (!fSlewCorr) {
c883fdf2 320 AliError("No walk correction is available!");
321 // return (TGraph*)fQTC.At(ipmt);
322 return 0;
c41ceaac 323 }
c883fdf2 324 return fgSlewCorr -> GetQTC(ipmt) ;
c41ceaac 325}
326
c883fdf2 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}
c41ceaac 337
dc7ca31d 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}
e0bba6cc 358//________________________________________________________________
359
360Int_t
361AliT0Parameters::GetChannel(Int_t trm, Int_t tdc, Int_t chain, Int_t channel)
362{
363
e30bc492 364 if (fgLookUp) {
365 AliT0LookUpValue key(trm,tdc,chain,channel);
3a06b1d2 366 AliT0LookUpKey *val = (AliT0LookUpKey*) fgLookUp->GetMapLookup()->GetValue((TObject*)&key);
367 // AliT0LookUpKey *val = (AliT0LookUpKey*) fLookUp.GetValue((TObject*)&key);
e30bc492 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!");
29d3e0eb 377 return -1;
e0bba6cc 378 }
e0bba6cc 379
380}
5325480c 381//__________________________________________________________________
29d3e0eb 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
5325480c 392Int_t
393AliT0Parameters::GetNumberOfTRMs()
394{
395 // return number of trms
396 //
397 if (!fgLookUp) {
29d3e0eb 398 // fNumberOfTRMs = 2;
5325480c 399 return fNumberOfTRMs;
400 }
401 return fgLookUp ->GetNumberOfTRMs();
402}
256d4943 403/*
5325480c 404//________________________________________________________________________________
405Double_t AliT0Parameters::GetZPosition(const char* symname){
406// Get the global z coordinate of the given T0 alignable volume
407//
29d3e0eb 408 Double_t *tr = AliGeomManager::GetMatrix(symname)->GetTranslation();
5325480c 409
5325480c 410 return tr[2];
29d3e0eb 411}
256d4943 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;
256d4943 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}
29d3e0eb 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();
5325480c 448
29d3e0eb 449 return (tr[2]-otr[2]);
5325480c 450}
451