]> git.uio.no Git - u/mrichter/AliRoot.git/blame - T0/AliT0Parameters.cxx
Corrected size of a string (icc)
[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//
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>
e0bba6cc 33#include <AliCDBStorage.h>
dc7ca31d 34#include <Riostream.h>
35
36AliT0CalibData* AliT0Parameters::fgCalibData = 0;
e0bba6cc 37AliT0CalibData* AliT0Parameters::fgLookUp = 0;
dc7ca31d 38//====================================================================
39ClassImp(AliT0Parameters)
40#if 0
41 ; // This is here to keep Emacs for indenting the next line
42#endif
43
44//____________________________________________________________________
45AliT0Parameters* AliT0Parameters::fgInstance = 0;
46//____________________________________________________________________
47AliT0Parameters*
48AliT0Parameters::Instance()
49{
50 // Get static instance
51 if (!fgInstance) fgInstance = new AliT0Parameters;
52 return fgInstance;
53}
54
55//____________________________________________________________________
56AliT0Parameters::AliT0Parameters()
57 :fIsInit(kFALSE),fPh2Mip(0),fmV2Mip(0),fChannelWidth(0),fmV2Channel(0),fQTmin(0),fQTmax(0),fFixedGain(0),fSlewingLED(),fSlewingRec(),fPMTeff(),fTimeDelayLED(0),fTimeDelayCFD(0),fTimeDelayTVD(0),fCalibentry()
58{
59 // Default constructor
60
61 for (Int_t ipmt=0; ipmt<24; ipmt++)
62 {
63 SetTimeDelayCablesCFD(ipmt);
64 SetTimeDelayCablesLED(ipmt);
65 SetTimeDelayElectronicCFD(ipmt);
66 SetTimeDelayElectronicLED(ipmt);
67 SetTimeDelayPMT(ipmt);
68 SetVariableDelayLine(ipmt);
69 SetSlewingLED(ipmt);
70 SetSlewingRec(ipmt);
71 SetPh2Mip();
72 SetmV2Mip();
73 SetChannelWidth();
74 SetmV2channel();
75 SetGain();
76 SetQTmin();
77 SetQTmax();
78 SetPMTeff(ipmt);
79 }
80 SetTimeDelayTVD();
81 SetZposition();
82
83}
84
85//__________________________________________________________________
86void
87AliT0Parameters::Init()
88{
89 // Initialize the parameters manager. We need to get stuff from the
90 // CDB here.
91 // if (fIsInit) return;
92
6ba20b30 93 // AliCDBManager* cdb = AliCDBManager::Instance();
94 // fCalibentry = cdb->Get("T0/Calib/Gain_TimeDelay_Slewing_Walk");
95
96
97 AliCDBStorage *stor =AliCDBManager::Instance()->GetStorage("local://$ALICE_ROOT");
98 AliCDBEntry* fCalibentry = stor->Get("T0/Calib/Gain_TimeDelay_Slewing_Walk",0);
99 if (fCalibentry){
dc7ca31d 100 fgCalibData = (AliT0CalibData*)fCalibentry->GetObject();
101 }
6ba20b30 102 // fLookUpentry = cdb->Get("T0/Calib/LookUp_Table");
103 fLookUpentry = stor->Get("T0/Calib/LookUp_Table",0);
e0bba6cc 104 if (fLookUpentry){
105 fgLookUp = (AliT0CalibData*)fLookUpentry->GetObject();
106 // fgLookUp->Dump();
107 }
108 else {
109 fgLookUp->ReadAsciiLookup("$ALICE_ROOT/T0/lookUpTable.txt");
110 }
dc7ca31d 111
112 fIsInit = kTRUE;
113}
114
115
116//__________________________________________________________________
117Float_t
118AliT0Parameters::GetGain(Int_t ipmt) const
119{
120 // Returns the calibrated gain for each PMT
121 //
122
123 if (!fCalibentry)
124 return fFixedGain;
125
126 return fgCalibData->GetGain(ipmt);
127}
128
129//__________________________________________________________________
130Float_t
131AliT0Parameters::GetTimeDelayLED(Int_t ipmt)
132{
133 // return time delay for LED channel
134 //
135 if (!fCalibentry) {
136 fTimeDelayLED = fTimeDelayCablesLED[ipmt] + fTimeDelayElectronicLED[ipmt] + fTimeDelayPMT[ipmt];
137 return fTimeDelayLED;
138 }
139 return fgCalibData ->GetTimeDelayLED(ipmt);
140}
141//__________________________________________________________________
142Float_t
143AliT0Parameters::GetTimeDelayCFD(Int_t ipmt)
144{
145 // return time delay for CFD channel
146 //
147 if (!fCalibentry)
148 {
149 fTimeDelayCFD = fTimeDelayCablesCFD[ipmt] + fTimeDelayElectronicCFD[ipmt] + fTimeDelayPMT[ipmt] + fVariableDelayLine[ipmt];
150 return fTimeDelayCFD+37;
151 }
152
153 return fgCalibData->GetTimeDelayCFD(ipmt);
154}
155
156//__________________________________________________________________
157
158void
159AliT0Parameters::SetSlewingLED(Int_t ipmt)
160{
161 // Set Slweing Correction for LED channel
162 Float_t mv[23] = {25, 30,40,60, 80,100,150,200,250,300,
163 400,500,600,800,1000,1500, 2000, 3000, 4000, 5500,
164 6000, 7000,8000};
165 Float_t y[23] = {5044, 4719, 3835, 3224, 2847, 2691,2327, 2067, 1937, 1781,
166 1560, 1456 ,1339, 1163.5, 1027, 819, 650, 520, 370.5, 234,
167 156, 78, 0};
168
169 TGraph* gr = new TGraph(23,mv,y);
170 fSlewingLED.AddAtAndExpand(gr,ipmt);
171 }
172//__________________________________________________________________
173
174Float_t AliT0Parameters::GetSlewingLED(Int_t ipmt, Float_t mv) const
175{
176 if (!fCalibentry) {
177 return ((TGraph*)fSlewingLED.At(ipmt))->Eval(mv);
178 }
179 return fgCalibData->GetSlewingLED(ipmt, mv) ;
180}
181
182
183//__________________________________________________________________
184
185TGraph *AliT0Parameters::GetSlew(Int_t ipmt) const
186{
187 if (!fCalibentry) {
188 return (TGraph*)fSlewingLED.At(ipmt);
189 }
190 return fgCalibData -> GetSlew(ipmt) ;
191}
192
193//__________________________________________________________________
194
195
196void
197AliT0Parameters::SetSlewingRec(Int_t ipmt)
198{
199 // Set Slweing Correction for LED channel
200 Float_t mv[23] = {25, 30, 40,60, 80,100,150,200,250,300,
201 400,500,600,800,1000,1500, 2000, 3000, 4000, 5500,
202 6000, 7000,8000};
203 Float_t y[23] = {5044, 4719, 3835, 3224, 2847, 2691,2327, 2067, 1937, 1781,
204 1560, 1456 ,1339, 1163.5, 1027, 819, 650, 520, 370.5, 234,
205 156, 78, 0};
206 Float_t y1[23], mv1[23];
207 for (Int_t i=0; i<23; i++){
208 y1[i] = y[22-i]; mv1[i] = mv[22-i];}
209
210 TGraph* gr = new TGraph(23,y1,mv1);
211 fSlewingRec.AddAtAndExpand(gr,ipmt);
212
213}
214//__________________________________________________________________
215
216Float_t AliT0Parameters::GetSlewingRec(Int_t ipmt, Float_t mv) const
217{
218 if (!fCalibentry) {
219 return ((TGraph*)fSlewingRec.At(ipmt))->Eval(mv);
220 }
221 return fgCalibData -> GetSlewingRec(ipmt, mv) ;
222}
223
224//__________________________________________________________________
225
226TGraph *AliT0Parameters::GetSlewRec(Int_t ipmt) const
227{
228 if (!fCalibentry) {
229 return (TGraph*)fSlewingRec.At(ipmt);
230 }
231 return fgCalibData -> GetSlewRec(ipmt) ;
232}
233
234//__________________________________________________________________
235void
236AliT0Parameters::SetPMTeff(Int_t ipmt)
237{
238 Float_t lambda[50];
239 Float_t eff[50 ] = {0, 0, 0.23619, 0.202909, 0.177913,
240 0.175667, 0.17856, 0.190769, 0.206667, 0.230286,
241 0.252276, 0.256267,0.26, 0.27125, 0.281818,
242 0.288118, 0.294057,0.296222, 0.301622, 0.290421,
243 0.276615, 0.2666, 0.248, 0.23619, 0.227814,
244 0.219818, 0.206667,0.194087, 0.184681, 0.167917,
245 0.154367, 0.1364, 0.109412, 0.0834615,0.0725283,
246 0.0642963,0.05861, 0.0465, 0.0413333,0.032069,
247 0.0252203,0.02066, 0.016262, 0.012, 0.00590476,
248 0.003875, 0.00190, 0, 0, 0 } ;
249 for (Int_t i=0; i<50; i++) lambda[i]=200+10*i;
250
251 TGraph* gr = new TGraph(50,lambda,eff);
252 fPMTeff.AddAtAndExpand(gr,ipmt);
253}
e0bba6cc 254//________________________________________________________________
255
256Int_t
257AliT0Parameters::GetChannel(Int_t trm, Int_t tdc, Int_t chain, Int_t channel)
258{
259
260
261 AliT0LookUpKey * lookkey; //= new AliT0LookUpKey();
262 AliT0LookUpValue * lookvalue= new AliT0LookUpValue(trm,tdc,chain,channel);
263
264 lookkey = (AliT0LookUpKey*) fgLookUp->GetMapLookup()->GetValue((TObject*)lookvalue);
265 if (!lookkey ) {
266 cout<<" no such address "<<endl; return -1;
267 }
268
269
270 //cout<<"AliT0Parameters:: key "<<lookkey->GetKey()<<endl;
271 return lookkey->GetKey();
272
273
274}