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