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