]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDcalibDB.cxx
add dimuon trigger efficiency
[u/mrichter/AliRoot.git] / TRD / AliTRDcalibDB.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 // Class providing the calibration parameters by accessing the CDB           //
21 //                                                                           //
22 // Request an instance with AliTRDcalibDB::Instance()                 //
23 // If a new event is processed set the event number with SetRun              //
24 // Then request the calibration data                                         // 
25 //                                                                           //
26 ///////////////////////////////////////////////////////////////////////////////
27
28 #include <TRandom.h>
29
30 #include <AliCDBManager.h>
31
32 #include "AliTRDcalibDB.h"
33 #include "AliTRDgeometry.h"
34 #include "AliTRDpadPlane.h"
35 #include "AliTRDCommonParam.h"
36
37 #include "AliTRDCalROC.h"
38 #include "AliTRDCalChamber.h"
39 #include "AliTRDCalStack.h"
40 #include "AliTRDCalPad.h"
41 #include "AliTRDCalDet.h"
42 #include "AliTRDCalGlobals.h"
43
44 ClassImp(AliTRDcalibDB)
45
46 AliTRDcalibDB* AliTRDcalibDB::fgInstance = 0;
47 Bool_t AliTRDcalibDB::fgTerminated = kFALSE;
48
49 //_ singleton implementation __________________________________________________
50 AliTRDcalibDB* AliTRDcalibDB::Instance()
51 {
52   //
53   // Singleton implementation
54   // Returns an instance of this class, it is created if neccessary
55   // 
56   
57   if (fgTerminated != kFALSE)
58     return 0;
59
60   if (fgInstance == 0)
61     fgInstance = new AliTRDcalibDB();
62   
63   return fgInstance;
64 }
65
66 void AliTRDcalibDB::Terminate()
67 {
68   //
69   // Singleton implementation
70   // Deletes the instance of this class and sets the terminated flag, instances cannot be requested anymore
71   // This function can be called several times.
72   //
73   
74   fgTerminated = kTRUE;
75   
76   if (fgInstance != 0)
77   {
78     delete fgInstance;
79     fgInstance = 0;
80   }
81 }
82
83 //_____________________________________________________________________________
84 AliTRDcalibDB::AliTRDcalibDB()
85 {
86   //
87   // constructor
88   //
89   
90   // TODO Default runnumber is set to 0, this should be changed later to an invalid value (e.g. -1) to prevent
91   // TODO invalid calibration data to be used.
92   fRun = 0;
93   
94   fPadResponse.fPRFbin             = 0;
95   fPadResponse.fPRFlo              = 0.0;
96   fPadResponse.fPRFhi              = 0.0;
97   fPadResponse.fPRFwid             = 0.0;
98   fPadResponse.fPRFpad             = 0;
99   fPadResponse.fPRFsmp             = 0;
100     
101   AliCDBManager* manager = AliCDBManager::Instance();
102   if (!manager)
103   {
104     std::cout << "AliTRDcalibDB: CRITICAL: Failed to get instance of AliCDBManager." << std::endl;
105     fLocator = 0;
106   }
107   else
108     fLocator = manager->GetStorage("local://$ALICE_ROOT");
109   
110   for (Int_t i=0; i<kCDBCacheSize; ++i)
111   {
112     fCDBCache[i] = 0;
113     fCDBEntries[i] = 0;
114   }
115   
116   // Create the sampled PRF
117   SamplePRF();
118 }
119
120 //_____________________________________________________________________________
121 AliTRDcalibDB::~AliTRDcalibDB() 
122 {
123   //
124   // destructor
125   //
126   
127   if (fPadResponse.fPRFsmp) {
128     delete [] fPadResponse.fPRFsmp;
129     fPadResponse.fPRFsmp = 0;
130   }
131
132   Invalidate();
133 }
134
135 //_____________________________________________________________________________
136 void AliTRDcalibDB::SetRun(Long64_t run)
137 {
138   //
139   // Sets current run number. Calibration data is read from the corresponding file. 
140   // When the run number changes the caching is invalidated.
141   //
142   
143   if (fRun == run)
144     return;
145   
146   fRun = run;
147   Invalidate();
148 }
149   
150 //_____________________________________________________________________________
151 void AliTRDcalibDB::Invalidate()
152 {
153   //
154   // Invalidates cache (when run number is changed).
155   //
156   
157   for (Int_t i=0; i<kCDBCacheSize; ++i)
158   {
159     if (fCDBEntries[i])
160     {
161       if (fCDBEntries[i]->IsOwner() == kFALSE && fCDBCache[i])
162         delete fCDBCache[i];
163       
164       delete fCDBEntries[i];
165       fCDBEntries[i] = 0;
166       fCDBCache[i] = 0;
167     }
168   }
169 }
170
171 //_____________________________________________________________________________
172 Bool_t AliTRDcalibDB::GetChamberPos(Int_t det, Float_t* xyz)
173 {
174   //
175   // Returns the deviation of the chamber position from the nominal position.
176   //
177   
178   AliTRDCalChamber* chamber = dynamic_cast<AliTRDCalChamber*>(GetCachedCDBObject(kIDChamber));
179   if (!chamber)
180     return kFALSE;
181   
182   const Float_t* kvalues = chamber->GetChamberPos(det);
183   if (!kvalues)
184     return kFALSE;
185   
186   xyz[0] = kvalues[0];
187   xyz[1] = kvalues[1];
188   xyz[2] = kvalues[2];
189   
190   return kTRUE;
191 }
192
193 //_____________________________________________________________________________
194 Bool_t AliTRDcalibDB::GetChamberRot(Int_t det, Float_t* xyz)
195 {
196   //
197   // Returns the rotation of the chamber from the nominal position.
198   //
199   
200   AliTRDCalChamber* chamber = dynamic_cast<AliTRDCalChamber*>(GetCachedCDBObject(kIDChamber));
201   if (!chamber)
202     return kFALSE;
203   
204   const Float_t* kvalues = chamber->GetChamberRot(det);
205   if (!kvalues)
206     return kFALSE;
207   
208   xyz[0] = kvalues[0];
209   xyz[1] = kvalues[1];
210   xyz[2] = kvalues[2];
211   
212   return kTRUE;
213 }
214
215 //_____________________________________________________________________________
216 Bool_t AliTRDcalibDB::GetStackPos(Int_t chamber, Int_t sector, Float_t* xyz)
217 {
218   //
219   // Returns the deviation of the stack position from the nominal position.
220   //
221   
222   AliTRDCalStack* stack = dynamic_cast<AliTRDCalStack*>(GetCachedCDBObject(kIDStack));
223   if (!stack)
224     return kFALSE;
225   
226   const Float_t* kvalues = stack->GetStackPos(chamber, sector);
227   if (!kvalues)
228     return kFALSE;
229   
230   xyz[0] = kvalues[0];
231   xyz[1] = kvalues[1];
232   xyz[2] = kvalues[2];
233   
234   return kTRUE;
235 }
236
237 //_____________________________________________________________________________
238 Bool_t AliTRDcalibDB::GetStackRot(Int_t chamber, Int_t sector, Float_t* xyz)
239 {
240   //
241   // Returns the rotation of the stack from the nominal position.
242   //
243   
244   AliTRDCalStack* stack = dynamic_cast<AliTRDCalStack*>(GetCachedCDBObject(kIDStack));
245   if (!stack)
246     return kFALSE;
247   
248   const Float_t* kvalues = stack->GetStackRot(chamber, sector);
249   if (!kvalues)
250     return kFALSE;
251   
252   xyz[0] = kvalues[0];
253   xyz[1] = kvalues[1];
254   xyz[2] = kvalues[2];
255   
256   return kTRUE;
257 }
258
259 //_____________________________________________________________________________
260 Float_t AliTRDcalibDB::GetVdrift(Int_t det, Int_t col, Int_t row)
261 {
262   //
263   // Returns the drift velocity for the given pad.
264   //
265   
266   AliTRDCalPad* calPad = dynamic_cast<AliTRDCalPad*> (GetCachedCDBObject(kIDVdrift));
267   if (!calPad)
268     return -1;
269
270   AliTRDCalROC* roc = calPad->GetCalROC(det);
271   if (!roc)
272     return -1;
273
274   return roc->GetValue(col, row);
275 }
276
277 //_____________________________________________________________________________
278 Float_t AliTRDcalibDB::GetT0(Int_t det, Int_t col, Int_t row)
279 {
280   //
281   // Returns t0 for the given pad.
282   //
283   
284   AliTRDCalPad* calPad = dynamic_cast<AliTRDCalPad*> (GetCachedCDBObject(kIDT0));
285   if (!calPad)
286     return -1;
287
288   AliTRDCalROC* roc = calPad->GetCalROC(det);
289   if (!roc)
290     return -1;
291
292   return roc->GetValue(col, row);
293 }
294
295 //_____________________________________________________________________________
296 Float_t AliTRDcalibDB::GetGainFactor(Int_t det, Int_t col, Int_t row)
297 {
298   //
299   // Returns the gain factor for the given pad.
300   //
301   
302   AliTRDCalPad* calPad = dynamic_cast<AliTRDCalPad*> (GetCachedCDBObject(kIDGainFactor));
303   if (!calPad)
304     return -1;
305
306   AliTRDCalROC* roc = calPad->GetCalROC(det);
307   if (!roc)
308     return -1;
309
310   return roc->GetValue(col, row);
311 }
312
313 //_____________________________________________________________________________
314 Float_t AliTRDcalibDB::GetPRFWidth(Int_t det, Int_t col, Int_t row)
315 {
316   //
317   // Returns the PRF width for the given pad.
318   //
319   
320   AliTRDCalPad* calPad = dynamic_cast<AliTRDCalPad*> (GetCachedCDBObject(kIDPRFWidth));
321   if (!calPad)
322     return -1;
323
324   AliTRDCalROC* roc = calPad->GetCalROC(det);
325   if (!roc)
326     return -1;
327
328   return roc->GetValue(col, row);
329 }
330
331 //_____________________________________________________________________________
332 Float_t AliTRDcalibDB::GetSamplingFrequency()
333 {
334   //
335   // Returns the sampling frequency of the TRD read-out.
336   //
337   
338   AliTRDCalGlobals* calGlobal = dynamic_cast<AliTRDCalGlobals*> (GetCachedCDBObject(kIDGlobals));
339   if (!calGlobal)
340     return -1;  
341   
342   return calGlobal->GetSamplingFrequency();
343 }
344   
345 //_____________________________________________________________________________
346 Int_t AliTRDcalibDB::GetNumberOfTimeBins()
347 {
348   //
349   // Returns the number of time bins which are read-out.
350   //
351   
352   AliTRDCalGlobals* calGlobal = dynamic_cast<AliTRDCalGlobals*> (GetCachedCDBObject(kIDGlobals));
353   if (!calGlobal)
354     return -1;  
355   
356   return calGlobal->GetNumberOfTimeBins();
357 }
358
359 //_____________________________________________________________________________
360 Float_t AliTRDcalibDB::GetOmegaTau(Float_t vdrift)
361 {
362   //
363   // Returns omega*tau (tan(Lorentz-angle)) for a given drift velocity <vd> 
364   // and a B-field <b> for Xe/CO2 (15%).
365   // The values are according to a GARFIELD simulation.
366   //
367   // This function basically does not belong to the calibration class. It should be moved somewhere else. 
368   // However, currently it is in use by simulation and reconstruction.
369   //
370   
371   AliTRDCommonParam* commonParam = AliTRDCommonParam::Instance();
372   if (!commonParam)
373     return -1;
374   Float_t field = commonParam->GetField();
375
376   const Int_t kNb = 5;
377   Float_t p0[kNb] = {  0.004810,  0.007412,  0.010252,  0.013409,  0.016888 };
378   Float_t p1[kNb] = {  0.054875,  0.081534,  0.107333,  0.131983,  0.155455 };
379   Float_t p2[kNb] = { -0.008682, -0.012896, -0.016987, -0.020880, -0.024623 };
380   Float_t p3[kNb] = {  0.000155,  0.000238,  0.000330,  0.000428,  0.000541 };
381
382   Int_t ib = ((Int_t) (10 * (field - 0.15)));
383   ib       = TMath::Max(  0,ib);
384   ib       = TMath::Min(kNb,ib);
385
386   Float_t alphaL = p0[ib] 
387       + p1[ib] * vdrift
388       + p2[ib] * vdrift*vdrift
389       + p3[ib] * vdrift*vdrift*vdrift;
390
391   return TMath::Tan(alphaL);
392 }
393
394 //_____________________________________________________________________________
395 void AliTRDcalibDB::SamplePRF()
396 {
397   //
398   // Samples the pad response function
399   //
400
401   const Int_t kPRFbin = 61;
402
403   Float_t prf[kNplan][kPRFbin] = { {2.9037e-02, 3.3608e-02, 3.9020e-02, 4.5292e-02,
404                     5.2694e-02, 6.1362e-02, 7.1461e-02, 8.3362e-02,
405                     9.7063e-02, 1.1307e-01, 1.3140e-01, 1.5235e-01,
406                     1.7623e-01, 2.0290e-01, 2.3294e-01, 2.6586e-01,
407                     3.0177e-01, 3.4028e-01, 3.8077e-01, 4.2267e-01,
408                     4.6493e-01, 5.0657e-01, 5.4655e-01, 5.8397e-01,
409                     6.1767e-01, 6.4744e-01, 6.7212e-01, 6.9188e-01,
410                     7.0627e-01, 7.1499e-01, 7.1851e-01, 7.1499e-01,
411                     7.0627e-01, 6.9188e-01, 6.7212e-01, 6.4744e-01,
412                     6.1767e-01, 5.8397e-01, 5.4655e-01, 5.0657e-01,
413                     4.6493e-01, 4.2267e-01, 3.8077e-01, 3.4028e-01,
414                     3.0177e-01, 2.6586e-01, 2.3294e-01, 2.0290e-01,
415                     1.7623e-01, 1.5235e-01, 1.3140e-01, 1.1307e-01,
416                     9.7063e-02, 8.3362e-02, 7.1461e-02, 6.1362e-02,
417                     5.2694e-02, 4.5292e-02, 3.9020e-02, 3.3608e-02,
418                     2.9037e-02},
419                    {2.5478e-02, 2.9695e-02, 3.4655e-02, 4.0454e-02,
420                     4.7342e-02, 5.5487e-02, 6.5038e-02, 7.6378e-02,
421                     8.9696e-02, 1.0516e-01, 1.2327e-01, 1.4415e-01,
422                     1.6794e-01, 1.9516e-01, 2.2573e-01, 2.5959e-01,
423                     2.9694e-01, 3.3719e-01, 3.7978e-01, 4.2407e-01,
424                     4.6889e-01, 5.1322e-01, 5.5569e-01, 5.9535e-01,
425                     6.3141e-01, 6.6259e-01, 6.8882e-01, 7.0983e-01,
426                     7.2471e-01, 7.3398e-01, 7.3761e-01, 7.3398e-01,
427                     7.2471e-01, 7.0983e-01, 6.8882e-01, 6.6259e-01,
428                     6.3141e-01, 5.9535e-01, 5.5569e-01, 5.1322e-01,
429                     4.6889e-01, 4.2407e-01, 3.7978e-01, 3.3719e-01,
430                     2.9694e-01, 2.5959e-01, 2.2573e-01, 1.9516e-01,
431                     1.6794e-01, 1.4415e-01, 1.2327e-01, 1.0516e-01,
432                     8.9696e-02, 7.6378e-02, 6.5038e-02, 5.5487e-02,
433                     4.7342e-02, 4.0454e-02, 3.4655e-02, 2.9695e-02,
434                     2.5478e-02},
435                    {2.2363e-02, 2.6233e-02, 3.0782e-02, 3.6140e-02,
436                     4.2535e-02, 5.0157e-02, 5.9197e-02, 6.9900e-02,
437                     8.2707e-02, 9.7811e-02, 1.1548e-01, 1.3601e-01,
438                     1.5998e-01, 1.8739e-01, 2.1840e-01, 2.5318e-01,
439                     2.9182e-01, 3.3373e-01, 3.7837e-01, 4.2498e-01,
440                     4.7235e-01, 5.1918e-01, 5.6426e-01, 6.0621e-01,
441                     6.4399e-01, 6.7700e-01, 7.0472e-01, 7.2637e-01,
442                     7.4206e-01, 7.5179e-01, 7.5551e-01, 7.5179e-01,
443                     7.4206e-01, 7.2637e-01, 7.0472e-01, 6.7700e-01,
444                     6.4399e-01, 6.0621e-01, 5.6426e-01, 5.1918e-01,
445                     4.7235e-01, 4.2498e-01, 3.7837e-01, 3.3373e-01,
446                     2.9182e-01, 2.5318e-01, 2.1840e-01, 1.8739e-01,
447                     1.5998e-01, 1.3601e-01, 1.1548e-01, 9.7811e-02,
448                     8.2707e-02, 6.9900e-02, 5.9197e-02, 5.0157e-02,
449                     4.2535e-02, 3.6140e-02, 3.0782e-02, 2.6233e-02,
450                     2.2363e-02},
451                    {1.9635e-02, 2.3167e-02, 2.7343e-02, 3.2293e-02,
452                     3.8224e-02, 4.5335e-02, 5.3849e-02, 6.4039e-02,
453                     7.6210e-02, 9.0739e-02, 1.0805e-01, 1.2841e-01,
454                     1.5216e-01, 1.7960e-01, 2.1099e-01, 2.4671e-01,
455                     2.8647e-01, 3.2996e-01, 3.7660e-01, 4.2547e-01,
456                     4.7536e-01, 5.2473e-01, 5.7215e-01, 6.1632e-01,
457                     6.5616e-01, 6.9075e-01, 7.1939e-01, 7.4199e-01,
458                     7.5838e-01, 7.6848e-01, 7.7227e-01, 7.6848e-01,
459                     7.5838e-01, 7.4199e-01, 7.1939e-01, 6.9075e-01,
460                     6.5616e-01, 6.1632e-01, 5.7215e-01, 5.2473e-01,
461                     4.7536e-01, 4.2547e-01, 3.7660e-01, 3.2996e-01,
462                     2.8647e-01, 2.4671e-01, 2.1099e-01, 1.7960e-01,
463                     1.5216e-01, 1.2841e-01, 1.0805e-01, 9.0739e-02,
464                     7.6210e-02, 6.4039e-02, 5.3849e-02, 4.5335e-02,
465                     3.8224e-02, 3.2293e-02, 2.7343e-02, 2.3167e-02,
466                     1.9635e-02},
467                    {1.7224e-02, 2.0450e-02, 2.4286e-02, 2.8860e-02,
468                     3.4357e-02, 4.0979e-02, 4.8966e-02, 5.8612e-02,
469                     7.0253e-02, 8.4257e-02, 1.0102e-01, 1.2094e-01,
470                     1.4442e-01, 1.7196e-01, 2.0381e-01, 2.4013e-01,
471                     2.8093e-01, 3.2594e-01, 3.7450e-01, 4.2563e-01,
472                     4.7796e-01, 5.2991e-01, 5.7974e-01, 6.2599e-01,
473                     6.6750e-01, 7.0344e-01, 7.3329e-01, 7.5676e-01,
474                     7.7371e-01, 7.8410e-01, 7.8793e-01, 7.8410e-01,
475                     7.7371e-01, 7.5676e-01, 7.3329e-01, 7.0344e-01,
476                     6.6750e-01, 6.2599e-01, 5.7974e-01, 5.2991e-01,
477                     4.7796e-01, 4.2563e-01, 3.7450e-01, 3.2594e-01,
478                     2.8093e-01, 2.4013e-01, 2.0381e-01, 1.7196e-01,
479                     1.4442e-01, 1.2094e-01, 1.0102e-01, 8.4257e-02,
480                     7.0253e-02, 5.8612e-02, 4.8966e-02, 4.0979e-02,
481                     3.4357e-02, 2.8860e-02, 2.4286e-02, 2.0450e-02,
482                     1.7224e-02},
483                    {1.5096e-02, 1.8041e-02, 2.1566e-02, 2.5793e-02,
484                     3.0886e-02, 3.7044e-02, 4.4515e-02, 5.3604e-02,
485                     6.4668e-02, 7.8109e-02, 9.4364e-02, 1.1389e-01,
486                     1.3716e-01, 1.6461e-01, 1.9663e-01, 2.3350e-01,
487                     2.7527e-01, 3.2170e-01, 3.7214e-01, 4.2549e-01,
488                     4.8024e-01, 5.3460e-01, 5.8677e-01, 6.3512e-01,
489                     6.7838e-01, 7.1569e-01, 7.4655e-01, 7.7071e-01,
490                     7.8810e-01, 7.9871e-01, 8.0255e-01, 7.9871e-01,
491                     7.8810e-01, 7.7071e-01, 7.4655e-01, 7.1569e-01,
492                     6.7838e-01, 6.3512e-01, 5.8677e-01, 5.3460e-01,
493                     4.8024e-01, 4.2549e-01, 3.7214e-01, 3.2170e-01,
494                     2.7527e-01, 2.3350e-01, 1.9663e-01, 1.6461e-01,
495                     1.3716e-01, 1.1389e-01, 9.4364e-02, 7.8109e-02,
496                     6.4668e-02, 5.3604e-02, 4.4515e-02, 3.7044e-02,
497                     3.0886e-02, 2.5793e-02, 2.1566e-02, 1.8041e-02,
498                     1.5096e-02}};
499
500   // More sampling precision with linear interpolation
501   fPadResponse.fPRFlo  = -1.5;
502   fPadResponse.fPRFhi  =  1.5;
503   Float_t pad[kPRFbin];
504   Int_t   sPRFbin = kPRFbin;  
505   Float_t sPRFwid = (fPadResponse.fPRFhi - fPadResponse.fPRFlo) / ((Float_t) sPRFbin);
506   for (Int_t iPad = 0; iPad < sPRFbin; iPad++) {
507     pad[iPad] = ((Float_t) iPad + 0.5) * sPRFwid + fPadResponse.fPRFlo;
508   }
509   fPadResponse.fPRFbin = 500;  
510   fPadResponse.fPRFwid = (fPadResponse.fPRFhi - fPadResponse.fPRFlo) / ((Float_t) fPadResponse.fPRFbin);
511   fPadResponse.fPRFpad = ((Int_t) (1.0 / fPadResponse.fPRFwid));
512
513   if (fPadResponse.fPRFsmp) delete [] fPadResponse.fPRFsmp;
514   fPadResponse.fPRFsmp = new Float_t[kNplan*fPadResponse.fPRFbin];
515
516   Int_t   ipos1;
517   Int_t   ipos2;
518   Float_t diff;
519
520   for (Int_t iPla = 0; iPla < kNplan; iPla++) {
521
522     for (Int_t iBin = 0; iBin < fPadResponse.fPRFbin; iBin++) {
523
524       Float_t bin = (((Float_t) iBin) + 0.5) * fPadResponse.fPRFwid + fPadResponse.fPRFlo;
525       ipos1 = ipos2 = 0;
526       diff  = 0;
527       do {
528         diff = bin - pad[ipos2++];
529       } while ((diff > 0) && (ipos2 < kPRFbin));
530       if      (ipos2 == kPRFbin) {
531         fPadResponse.fPRFsmp[iPla*fPadResponse.fPRFbin+iBin] = prf[iPla][ipos2-1];
532       }
533       else if (ipos2 == 1) {
534         fPadResponse.fPRFsmp[iPla*fPadResponse.fPRFbin+iBin] = prf[iPla][ipos2-1];
535       }
536       else {
537         ipos2--;
538         if (ipos2 >= kPRFbin) ipos2 = kPRFbin - 1;
539         ipos1 = ipos2 - 1;
540         fPadResponse.fPRFsmp[iPla*fPadResponse.fPRFbin+iBin] = prf[iPla][ipos2] 
541                                    + diff * (prf[iPla][ipos2] - prf[iPla][ipos1]) 
542                                           / sPRFwid;
543       }
544
545     }
546   } 
547
548 }
549
550 //_____________________________________________________________________________
551 Int_t AliTRDcalibDB::PadResponse(Double_t signal, Double_t dist
552     , Int_t plane, Double_t *pad) const
553 {
554   //
555   // Applies the pad response
556   //
557
558   Int_t iBin  = ((Int_t) (( - dist - fPadResponse.fPRFlo) / fPadResponse.fPRFwid));
559   Int_t iOff  = plane * fPadResponse.fPRFbin;
560
561   Int_t iBin0 = iBin - fPadResponse.fPRFpad + iOff;
562   Int_t iBin1 = iBin           + iOff;
563   Int_t iBin2 = iBin + fPadResponse.fPRFpad + iOff;
564
565   pad[0] = 0.0;
566   pad[1] = 0.0;
567   pad[2] = 0.0;
568   if ((iBin1 >= 0) && (iBin1 < (fPadResponse.fPRFbin*kNplan))) {
569
570     if (iBin0 >= 0) {
571       pad[0] = signal * fPadResponse.fPRFsmp[iBin0];
572     }
573     pad[1] = signal * fPadResponse.fPRFsmp[iBin1];
574     if (iBin2 < (fPadResponse.fPRFbin*kNplan)) {
575       pad[2] = signal * fPadResponse.fPRFsmp[iBin2];
576     }
577
578     return 1;
579
580   }
581   else {
582
583     return 0;
584
585   }
586
587 }
588