1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //____________________________________________________________________
22 // This class is a singleton that handles various parameters of
24 // Eventually, this class will use the Conditions DB to get the
25 // various parameters, which code can then request from here.
28 #include "AliT0Parameters.h"
29 #include "AliT0CalibData.h"
30 #include "AliT0LookUpValue.h"
31 #include <AliCDBManager.h>
32 #include <AliCDBEntry.h>
33 #include <AliCDBStorage.h>
34 #include <Riostream.h>
36 AliT0CalibData* AliT0Parameters::fgCalibData = 0;
37 AliT0CalibData* AliT0Parameters::fgLookUp = 0;
38 //====================================================================
39 ClassImp(AliT0Parameters)
41 ; // This is here to keep Emacs for indenting the next line
44 //____________________________________________________________________
45 AliT0Parameters* AliT0Parameters::fgInstance = 0;
46 //____________________________________________________________________
48 AliT0Parameters::Instance()
50 // Get static instance
51 if (!fgInstance) fgInstance = new AliT0Parameters;
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()
59 // Default constructor
61 for (Int_t ipmt=0; ipmt<24; ipmt++)
63 SetTimeDelayCablesCFD(ipmt);
64 SetTimeDelayCablesLED(ipmt);
65 SetTimeDelayElectronicCFD(ipmt);
66 SetTimeDelayElectronicLED(ipmt);
67 SetTimeDelayPMT(ipmt);
68 SetVariableDelayLine(ipmt);
85 //__________________________________________________________________
87 AliT0Parameters::Init()
89 // Initialize the parameters manager. We need to get stuff from the
91 // if (fIsInit) return;
93 // AliCDBManager* cdb = AliCDBManager::Instance();
94 // fCalibentry = cdb->Get("T0/Calib/Gain_TimeDelay_Slewing_Walk");
97 AliCDBStorage *stor =AliCDBManager::Instance()->GetStorage("local://$ALICE_ROOT");
98 AliCDBEntry* fCalibentry = stor->Get("T0/Calib/Gain_TimeDelay_Slewing_Walk",0);
100 fgCalibData = (AliT0CalibData*)fCalibentry->GetObject();
102 // fLookUpentry = cdb->Get("T0/Calib/LookUp_Table");
103 fLookUpentry = stor->Get("T0/Calib/LookUp_Table",0);
105 fgLookUp = (AliT0CalibData*)fLookUpentry->GetObject();
109 fgLookUp->ReadAsciiLookup("$ALICE_ROOT/T0/lookUpTable.txt");
116 //__________________________________________________________________
118 AliT0Parameters::GetGain(Int_t ipmt) const
120 // Returns the calibrated gain for each PMT
126 return fgCalibData->GetGain(ipmt);
129 //__________________________________________________________________
131 AliT0Parameters::GetTimeDelayLED(Int_t ipmt)
133 // return time delay for LED channel
136 fTimeDelayLED = fTimeDelayCablesLED[ipmt] + fTimeDelayElectronicLED[ipmt] + fTimeDelayPMT[ipmt];
137 return fTimeDelayLED;
139 return fgCalibData ->GetTimeDelayLED(ipmt);
141 //__________________________________________________________________
143 AliT0Parameters::GetTimeDelayCFD(Int_t ipmt)
145 // return time delay for CFD channel
149 fTimeDelayCFD = fTimeDelayCablesCFD[ipmt] + fTimeDelayElectronicCFD[ipmt] + fTimeDelayPMT[ipmt] + fVariableDelayLine[ipmt];
150 return fTimeDelayCFD+37;
153 return fgCalibData->GetTimeDelayCFD(ipmt);
156 //__________________________________________________________________
159 AliT0Parameters::SetSlewingLED(Int_t ipmt)
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,
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,
169 TGraph* gr = new TGraph(23,mv,y);
170 fSlewingLED.AddAtAndExpand(gr,ipmt);
172 //__________________________________________________________________
174 Float_t AliT0Parameters::GetSlewingLED(Int_t ipmt, Float_t mv) const
177 return ((TGraph*)fSlewingLED.At(ipmt))->Eval(mv);
179 return fgCalibData->GetSlewingLED(ipmt, mv) ;
183 //__________________________________________________________________
185 TGraph *AliT0Parameters::GetSlew(Int_t ipmt) const
188 return (TGraph*)fSlewingLED.At(ipmt);
190 return fgCalibData -> GetSlew(ipmt) ;
193 //__________________________________________________________________
197 AliT0Parameters::SetSlewingRec(Int_t ipmt)
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,
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,
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];}
210 TGraph* gr = new TGraph(23,y1,mv1);
211 fSlewingRec.AddAtAndExpand(gr,ipmt);
214 //__________________________________________________________________
216 Float_t AliT0Parameters::GetSlewingRec(Int_t ipmt, Float_t mv) const
219 return ((TGraph*)fSlewingRec.At(ipmt))->Eval(mv);
221 return fgCalibData -> GetSlewingRec(ipmt, mv) ;
224 //__________________________________________________________________
226 TGraph *AliT0Parameters::GetSlewRec(Int_t ipmt) const
229 return (TGraph*)fSlewingRec.At(ipmt);
231 return fgCalibData -> GetSlewRec(ipmt) ;
234 //__________________________________________________________________
236 AliT0Parameters::SetPMTeff(Int_t ipmt)
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;
251 TGraph* gr = new TGraph(50,lambda,eff);
252 fPMTeff.AddAtAndExpand(gr,ipmt);
254 //________________________________________________________________
257 AliT0Parameters::GetChannel(Int_t trm, Int_t tdc, Int_t chain, Int_t channel)
261 AliT0LookUpKey * lookkey; //= new AliT0LookUpKey();
262 AliT0LookUpValue * lookvalue= new AliT0LookUpValue(trm,tdc,chain,channel);
264 lookkey = (AliT0LookUpKey*) fgLookUp->GetMapLookup()->GetValue((TObject*)lookvalue);
266 cout<<" no such address "<<endl; return -1;
270 //cout<<"AliT0Parameters:: key "<<lookkey->GetKey()<<endl;
271 return lookkey->GetKey();