Adding two missing getters
[u/mrichter/AliRoot.git] / TRD / AliTRDcalibDB.cxx
CommitLineData
3551db50 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"
cc7cef99 38#include "AliTRDCalChamberPos.h"
39#include "AliTRDCalStackPos.h"
3551db50 40#include "AliTRDCalPad.h"
41#include "AliTRDCalDet.h"
42#include "AliTRDCalGlobals.h"
cc7cef99 43#include "AliTRDCalPIDLQ.h"
3551db50 44
45ClassImp(AliTRDcalibDB)
46
47AliTRDcalibDB* AliTRDcalibDB::fgInstance = 0;
48Bool_t AliTRDcalibDB::fgTerminated = kFALSE;
49
50//_ singleton implementation __________________________________________________
51AliTRDcalibDB* AliTRDcalibDB::Instance()
52{
53 //
54 // Singleton implementation
55 // Returns an instance of this class, it is created if neccessary
63a700c6 56 //
3551db50 57
58 if (fgTerminated != kFALSE)
59 return 0;
60
61 if (fgInstance == 0)
62 fgInstance = new AliTRDcalibDB();
63
64 return fgInstance;
65}
66
67void AliTRDcalibDB::Terminate()
68{
69 //
70 // Singleton implementation
71 // Deletes the instance of this class and sets the terminated flag, instances cannot be requested anymore
72 // This function can be called several times.
73 //
74
75 fgTerminated = kTRUE;
76
77 if (fgInstance != 0)
78 {
79 delete fgInstance;
80 fgInstance = 0;
81 }
82}
83
84//_____________________________________________________________________________
85AliTRDcalibDB::AliTRDcalibDB()
86{
87 //
88 // constructor
89 //
90
3551db50 91 // TODO Default runnumber is set to 0, this should be changed later to an invalid value (e.g. -1) to prevent
92 // TODO invalid calibration data to be used.
93 fRun = 0;
94
6a739e92 95 fPadResponse.fPRFbin = 0;
96 fPadResponse.fPRFlo = 0.0;
97 fPadResponse.fPRFhi = 0.0;
98 fPadResponse.fPRFwid = 0.0;
99 fPadResponse.fPRFpad = 0;
100 fPadResponse.fPRFsmp = 0;
101
3551db50 102 AliCDBManager* manager = AliCDBManager::Instance();
103 if (!manager)
104 {
6a739e92 105 std::cout << "AliTRDcalibDB: CRITICAL: Failed to get instance of AliCDBManager." << std::endl;
106 fLocator = 0;
3551db50 107 }
6a739e92 108 else
109 fLocator = manager->GetStorage("local://$ALICE_ROOT");
3551db50 110
111 for (Int_t i=0; i<kCDBCacheSize; ++i)
112 {
113 fCDBCache[i] = 0;
114 fCDBEntries[i] = 0;
115 }
6a739e92 116
117 // Create the sampled PRF
118 SamplePRF();
acba9bad 119}
3551db50 120
121//_____________________________________________________________________________
122AliTRDcalibDB::~AliTRDcalibDB()
123{
124 //
125 // destructor
126 //
127
6a739e92 128 if (fPadResponse.fPRFsmp) {
129 delete [] fPadResponse.fPRFsmp;
130 fPadResponse.fPRFsmp = 0;
131 }
132
3551db50 133 Invalidate();
acba9bad 134}
3551db50 135
63a700c6 136//_caching functions____________________________________________________________
137const TObject* AliTRDcalibDB::GetCachedCDBObject(Int_t id)
138{
139 //
140 // Retrieves a cdb object with the given id. The objects are cached as long as the run number is not changed.
141 //
142 // Put together the available objects here by using the lines
143 // a) For usual calibration objects:
144 // ase kID<Name> : return CacheCDBEntry(kID<Name>, "TRD/Calib/<Path>"); break;
145 // See function CacheCDBEntry for details.
146 // and
147 // b) For calibration data which depends on two objects: One containing a value per detector and one the local fluctuations per pad:
148 // case kID<Name> : return CacheMergeCDBEntry(kID<Name>, "TRD/Calib/<padPath>", "TRD/Calib/<chamberPath>"); break;
149 // See function CacheMergeCDBEntry for details.
150 //
151
152 switch (id)
153 {
154 // parameters defined per pad and chamber
155 case kIDVdrift : return CacheMergeCDBEntry(kIDVdrift, "TRD/Calib/LocalVdrift", "TRD/Calib/ChamberVdrift"); break;
156 case kIDT0 : return CacheMergeCDBEntry(kIDT0, "TRD/Calib/LocalT0", "TRD/Calib/ChamberT0"); break;
157
158 // parameters defined per pad
159 case kIDGainFactor : return CacheCDBEntry(kIDGainFactor, "TRD/Calib/GainFactor"); break;
160 case kIDPRFWidth : return CacheCDBEntry(kIDPRFWidth, "TRD/Calib/PRFWidth"); break;
161
162 // global parameters
163 case kIDGlobals : return CacheCDBEntry(kIDGlobals, "TRD/Calib/Globals"); break;
164 case kIDChamber : return CacheCDBEntry(kIDChamber, "TRD/Calib/Chamber"); break;
165 case kIDStack : return CacheCDBEntry(kIDStack, "TRD/Calib/Stack"); break;
166 case kIDPIDLQ : return CacheCDBEntry(kIDPIDLQ, "TRD/Calib/PIDLQ"); break;
167 }
168 return 0;
169}
170
171//_____________________________________________________________________________
172AliCDBEntry* AliTRDcalibDB::GetCDBEntry(const char* cdbPath)
173{
174 //
175 // Retrieves an entry with path <cdbPath> from the CDB.
176 //
177
178 if (fRun < 0)
179 {
180 AliFatal("AliTRDcalibDB: Run number not set! Use AliTRDcalibDB::SetRun.");
181 //std::cerr << "AliTRDcalibDB: Run number not set! Use AliTRDcalibDB::SetRun." << std::endl;
182 return 0;
183 }
184 if (!fLocator)
185 {
186 std::cerr << "AliTRDcalibDB: Storage Locator not available." << std::endl;
187 return 0;
188 }
189 AliCDBEntry* entry = fLocator->Get(cdbPath, fRun);
190 if (!entry)
191 {
192 std::cerr << "AliTRDcalibDB: Failed to get entry: " << cdbPath << std::endl;
193 return 0;
194 }
195
196 std::cout << "AliTRDcalibDB: Retrieved object: " << cdbPath << std::endl;
197 return entry;
198}
199
200//_____________________________________________________________________________
201const TObject* AliTRDcalibDB::CacheCDBEntry(Int_t id, const char* cdbPath)
202{
203 //
204 // Caches the entry <id> with cdb path <cdbPath>
205 //
206
207 if (!fCDBCache[id])
208 {
209 fCDBEntries[id] = GetCDBEntry(cdbPath);
210 if (fCDBEntries[id])
211 fCDBCache[id] = fCDBEntries[id]->GetObject();
212 }
213 return fCDBCache[id];
214}
215
216//_____________________________________________________________________________
217const TObject* AliTRDcalibDB::CacheMergeCDBEntry(Int_t id, const char* cdbPadPath, const char* cdbChamberPath)
218{
219 //
220 // Retrieves and caches an object (id <id>) from the CDB. This function is specialized for parameters which are stored
221 // as local variation at pad level of a global variable defined per detector chamber. It uses the classes AliTRDCalPad and AliTRDCalDet.
222 // Before storing the object it retrieves the local variations (cdbPadPath) and the global variable (cdbChamberPath) and merges them using
223 // the AliTRDCalPad::ScaleROCs.
224 //
225
226 if (!fCDBCache[id])
227 {
228 AliTRDCalPad* padObject = 0;
229 AliTRDCalDet* detObject = 0;
230
231 fCDBEntries[id] = GetCDBEntry(cdbPadPath);
232 if (fCDBEntries[id])
233 padObject = dynamic_cast<AliTRDCalPad*>(fCDBEntries[id]->GetObject());
234
235 AliCDBEntry* mergeEntry = GetCDBEntry(cdbChamberPath);
236 if (mergeEntry)
237 detObject = dynamic_cast<AliTRDCalDet*>(mergeEntry->GetObject());
238
239 if (!padObject || !detObject)
240 {
241 if (fCDBEntries[id]) {
242 if (fCDBEntries[id]->IsOwner() == kFALSE && padObject)
243 delete padObject;
244 delete fCDBEntries[id];
245 fCDBEntries[id] = 0;
246 }
247 if (mergeEntry)
248 {
249 if (mergeEntry->IsOwner() == kFALSE && detObject)
250 delete detObject;
251 delete mergeEntry;
252 }
253 return 0;
254 }
255
256 padObject->ScaleROCs(detObject);
257 if (mergeEntry->IsOwner() == kFALSE)
258 delete detObject;
259 delete mergeEntry;
260
261 fCDBCache[id] = padObject;
262 }
263
264 return fCDBCache[id];
265}
266
3551db50 267//_____________________________________________________________________________
268void AliTRDcalibDB::SetRun(Long64_t run)
269{
270 //
271 // Sets current run number. Calibration data is read from the corresponding file.
272 // When the run number changes the caching is invalidated.
273 //
274
275 if (fRun == run)
276 return;
277
278 fRun = run;
279 Invalidate();
280}
281
282//_____________________________________________________________________________
283void AliTRDcalibDB::Invalidate()
284{
285 //
286 // Invalidates cache (when run number is changed).
287 //
288
289 for (Int_t i=0; i<kCDBCacheSize; ++i)
290 {
291 if (fCDBEntries[i])
292 {
dde59437 293 if (fCDBEntries[i]->IsOwner() == kFALSE && fCDBCache[i])
3551db50 294 delete fCDBCache[i];
dde59437 295
3551db50 296 delete fCDBEntries[i];
297 fCDBEntries[i] = 0;
298 fCDBCache[i] = 0;
299 }
300 }
301}
302
303//_____________________________________________________________________________
304Bool_t AliTRDcalibDB::GetChamberPos(Int_t det, Float_t* xyz)
305{
306 //
307 // Returns the deviation of the chamber position from the nominal position.
308 //
309
63a700c6 310 const AliTRDCalChamberPos* chamber = dynamic_cast<const AliTRDCalChamberPos*>(GetCachedCDBObject(kIDChamber));
3551db50 311 if (!chamber)
312 return kFALSE;
313
314 const Float_t* kvalues = chamber->GetChamberPos(det);
315 if (!kvalues)
316 return kFALSE;
317
318 xyz[0] = kvalues[0];
319 xyz[1] = kvalues[1];
320 xyz[2] = kvalues[2];
321
322 return kTRUE;
323}
324
325//_____________________________________________________________________________
326Bool_t AliTRDcalibDB::GetChamberRot(Int_t det, Float_t* xyz)
327{
328 //
329 // Returns the rotation of the chamber from the nominal position.
330 //
331
63a700c6 332 const AliTRDCalChamberPos* chamber = dynamic_cast<const AliTRDCalChamberPos*>(GetCachedCDBObject(kIDChamber));
3551db50 333 if (!chamber)
334 return kFALSE;
335
336 const Float_t* kvalues = chamber->GetChamberRot(det);
337 if (!kvalues)
338 return kFALSE;
339
340 xyz[0] = kvalues[0];
341 xyz[1] = kvalues[1];
342 xyz[2] = kvalues[2];
343
344 return kTRUE;
345}
346
347//_____________________________________________________________________________
348Bool_t AliTRDcalibDB::GetStackPos(Int_t chamber, Int_t sector, Float_t* xyz)
349{
350 //
351 // Returns the deviation of the stack position from the nominal position.
352 //
353
63a700c6 354 const AliTRDCalStackPos* stack = dynamic_cast<const AliTRDCalStackPos*>(GetCachedCDBObject(kIDStack));
3551db50 355 if (!stack)
356 return kFALSE;
357
358 const Float_t* kvalues = stack->GetStackPos(chamber, sector);
359 if (!kvalues)
360 return kFALSE;
361
362 xyz[0] = kvalues[0];
363 xyz[1] = kvalues[1];
364 xyz[2] = kvalues[2];
365
366 return kTRUE;
367}
368
369//_____________________________________________________________________________
370Bool_t AliTRDcalibDB::GetStackRot(Int_t chamber, Int_t sector, Float_t* xyz)
371{
372 //
373 // Returns the rotation of the stack from the nominal position.
374 //
375
63a700c6 376 const AliTRDCalStackPos* stack = dynamic_cast<const AliTRDCalStackPos*>(GetCachedCDBObject(kIDStack));
3551db50 377 if (!stack)
378 return kFALSE;
379
380 const Float_t* kvalues = stack->GetStackRot(chamber, sector);
381 if (!kvalues)
382 return kFALSE;
383
384 xyz[0] = kvalues[0];
385 xyz[1] = kvalues[1];
386 xyz[2] = kvalues[2];
387
388 return kTRUE;
389}
390
391//_____________________________________________________________________________
392Float_t AliTRDcalibDB::GetVdrift(Int_t det, Int_t col, Int_t row)
393{
394 //
395 // Returns the drift velocity for the given pad.
396 //
397
63a700c6 398 const AliTRDCalPad* calPad = dynamic_cast<const AliTRDCalPad*> (GetCachedCDBObject(kIDVdrift));
3551db50 399 if (!calPad)
400 return -1;
401
402 AliTRDCalROC* roc = calPad->GetCalROC(det);
403 if (!roc)
404 return -1;
405
406 return roc->GetValue(col, row);
acba9bad 407}
3551db50 408
409//_____________________________________________________________________________
410Float_t AliTRDcalibDB::GetT0(Int_t det, Int_t col, Int_t row)
411{
412 //
413 // Returns t0 for the given pad.
414 //
415
63a700c6 416 const AliTRDCalPad* calPad = dynamic_cast<const AliTRDCalPad*> (GetCachedCDBObject(kIDT0));
3551db50 417 if (!calPad)
418 return -1;
419
420 AliTRDCalROC* roc = calPad->GetCalROC(det);
421 if (!roc)
422 return -1;
423
424 return roc->GetValue(col, row);
acba9bad 425}
3551db50 426
427//_____________________________________________________________________________
428Float_t AliTRDcalibDB::GetGainFactor(Int_t det, Int_t col, Int_t row)
429{
430 //
431 // Returns the gain factor for the given pad.
432 //
433
63a700c6 434 const AliTRDCalPad* calPad = dynamic_cast<const AliTRDCalPad*> (GetCachedCDBObject(kIDGainFactor));
3551db50 435 if (!calPad)
436 return -1;
437
438 AliTRDCalROC* roc = calPad->GetCalROC(det);
439 if (!roc)
440 return -1;
441
442 return roc->GetValue(col, row);
acba9bad 443}
6a739e92 444
445//_____________________________________________________________________________
446Float_t AliTRDcalibDB::GetPRFWidth(Int_t det, Int_t col, Int_t row)
447{
448 //
449 // Returns the PRF width for the given pad.
450 //
451
63a700c6 452 const AliTRDCalPad* calPad = dynamic_cast<const AliTRDCalPad*> (GetCachedCDBObject(kIDPRFWidth));
6a739e92 453 if (!calPad)
454 return -1;
455
456 AliTRDCalROC* roc = calPad->GetCalROC(det);
457 if (!roc)
458 return -1;
459
460 return roc->GetValue(col, row);
acba9bad 461}
3551db50 462
463//_____________________________________________________________________________
464Float_t AliTRDcalibDB::GetSamplingFrequency()
465{
466 //
467 // Returns the sampling frequency of the TRD read-out.
468 //
469
63a700c6 470 const AliTRDCalGlobals* calGlobal = dynamic_cast<const AliTRDCalGlobals*> (GetCachedCDBObject(kIDGlobals));
3551db50 471 if (!calGlobal)
472 return -1;
473
474 return calGlobal->GetSamplingFrequency();
475}
476
477//_____________________________________________________________________________
478Int_t AliTRDcalibDB::GetNumberOfTimeBins()
479{
480 //
481 // Returns the number of time bins which are read-out.
482 //
483
63a700c6 484 const AliTRDCalGlobals* calGlobal = dynamic_cast<const AliTRDCalGlobals*> (GetCachedCDBObject(kIDGlobals));
3551db50 485 if (!calGlobal)
486 return -1;
487
488 return calGlobal->GetNumberOfTimeBins();
489}
490
cc7cef99 491//_____________________________________________________________________________
63a700c6 492const AliTRDCalPIDLQ* AliTRDcalibDB::GetPIDLQObject()
cc7cef99 493{
494 //
495 // Returns the object storing the distributions for PID with likelihood
496 //
497
4e864ef1 498 return dynamic_cast<const AliTRDCalPIDLQ*> (GetCachedCDBObject(kIDPIDLQ));
cc7cef99 499}
500
3551db50 501//_____________________________________________________________________________
502Float_t AliTRDcalibDB::GetOmegaTau(Float_t vdrift)
503{
504 //
505 // Returns omega*tau (tan(Lorentz-angle)) for a given drift velocity <vd>
506 // and a B-field <b> for Xe/CO2 (15%).
507 // The values are according to a GARFIELD simulation.
508 //
509 // This function basically does not belong to the calibration class. It should be moved somewhere else.
510 // However, currently it is in use by simulation and reconstruction.
511 //
512
513 AliTRDCommonParam* commonParam = AliTRDCommonParam::Instance();
514 if (!commonParam)
515 return -1;
516 Float_t field = commonParam->GetField();
517
518 const Int_t kNb = 5;
519 Float_t p0[kNb] = { 0.004810, 0.007412, 0.010252, 0.013409, 0.016888 };
520 Float_t p1[kNb] = { 0.054875, 0.081534, 0.107333, 0.131983, 0.155455 };
521 Float_t p2[kNb] = { -0.008682, -0.012896, -0.016987, -0.020880, -0.024623 };
522 Float_t p3[kNb] = { 0.000155, 0.000238, 0.000330, 0.000428, 0.000541 };
523
524 Int_t ib = ((Int_t) (10 * (field - 0.15)));
525 ib = TMath::Max( 0,ib);
526 ib = TMath::Min(kNb,ib);
527
528 Float_t alphaL = p0[ib]
529 + p1[ib] * vdrift
530 + p2[ib] * vdrift*vdrift
531 + p3[ib] * vdrift*vdrift*vdrift;
532
533 return TMath::Tan(alphaL);
6a739e92 534}
535
536//_____________________________________________________________________________
537void AliTRDcalibDB::SamplePRF()
538{
539 //
540 // Samples the pad response function
541 //
542
543 const Int_t kPRFbin = 61;
544
545 Float_t prf[kNplan][kPRFbin] = { {2.9037e-02, 3.3608e-02, 3.9020e-02, 4.5292e-02,
546 5.2694e-02, 6.1362e-02, 7.1461e-02, 8.3362e-02,
547 9.7063e-02, 1.1307e-01, 1.3140e-01, 1.5235e-01,
548 1.7623e-01, 2.0290e-01, 2.3294e-01, 2.6586e-01,
549 3.0177e-01, 3.4028e-01, 3.8077e-01, 4.2267e-01,
550 4.6493e-01, 5.0657e-01, 5.4655e-01, 5.8397e-01,
551 6.1767e-01, 6.4744e-01, 6.7212e-01, 6.9188e-01,
552 7.0627e-01, 7.1499e-01, 7.1851e-01, 7.1499e-01,
553 7.0627e-01, 6.9188e-01, 6.7212e-01, 6.4744e-01,
554 6.1767e-01, 5.8397e-01, 5.4655e-01, 5.0657e-01,
555 4.6493e-01, 4.2267e-01, 3.8077e-01, 3.4028e-01,
556 3.0177e-01, 2.6586e-01, 2.3294e-01, 2.0290e-01,
557 1.7623e-01, 1.5235e-01, 1.3140e-01, 1.1307e-01,
558 9.7063e-02, 8.3362e-02, 7.1461e-02, 6.1362e-02,
559 5.2694e-02, 4.5292e-02, 3.9020e-02, 3.3608e-02,
560 2.9037e-02},
561 {2.5478e-02, 2.9695e-02, 3.4655e-02, 4.0454e-02,
562 4.7342e-02, 5.5487e-02, 6.5038e-02, 7.6378e-02,
563 8.9696e-02, 1.0516e-01, 1.2327e-01, 1.4415e-01,
564 1.6794e-01, 1.9516e-01, 2.2573e-01, 2.5959e-01,
565 2.9694e-01, 3.3719e-01, 3.7978e-01, 4.2407e-01,
566 4.6889e-01, 5.1322e-01, 5.5569e-01, 5.9535e-01,
567 6.3141e-01, 6.6259e-01, 6.8882e-01, 7.0983e-01,
568 7.2471e-01, 7.3398e-01, 7.3761e-01, 7.3398e-01,
569 7.2471e-01, 7.0983e-01, 6.8882e-01, 6.6259e-01,
570 6.3141e-01, 5.9535e-01, 5.5569e-01, 5.1322e-01,
571 4.6889e-01, 4.2407e-01, 3.7978e-01, 3.3719e-01,
572 2.9694e-01, 2.5959e-01, 2.2573e-01, 1.9516e-01,
573 1.6794e-01, 1.4415e-01, 1.2327e-01, 1.0516e-01,
574 8.9696e-02, 7.6378e-02, 6.5038e-02, 5.5487e-02,
575 4.7342e-02, 4.0454e-02, 3.4655e-02, 2.9695e-02,
576 2.5478e-02},
577 {2.2363e-02, 2.6233e-02, 3.0782e-02, 3.6140e-02,
578 4.2535e-02, 5.0157e-02, 5.9197e-02, 6.9900e-02,
579 8.2707e-02, 9.7811e-02, 1.1548e-01, 1.3601e-01,
580 1.5998e-01, 1.8739e-01, 2.1840e-01, 2.5318e-01,
581 2.9182e-01, 3.3373e-01, 3.7837e-01, 4.2498e-01,
582 4.7235e-01, 5.1918e-01, 5.6426e-01, 6.0621e-01,
583 6.4399e-01, 6.7700e-01, 7.0472e-01, 7.2637e-01,
584 7.4206e-01, 7.5179e-01, 7.5551e-01, 7.5179e-01,
585 7.4206e-01, 7.2637e-01, 7.0472e-01, 6.7700e-01,
586 6.4399e-01, 6.0621e-01, 5.6426e-01, 5.1918e-01,
587 4.7235e-01, 4.2498e-01, 3.7837e-01, 3.3373e-01,
588 2.9182e-01, 2.5318e-01, 2.1840e-01, 1.8739e-01,
589 1.5998e-01, 1.3601e-01, 1.1548e-01, 9.7811e-02,
590 8.2707e-02, 6.9900e-02, 5.9197e-02, 5.0157e-02,
591 4.2535e-02, 3.6140e-02, 3.0782e-02, 2.6233e-02,
592 2.2363e-02},
593 {1.9635e-02, 2.3167e-02, 2.7343e-02, 3.2293e-02,
594 3.8224e-02, 4.5335e-02, 5.3849e-02, 6.4039e-02,
595 7.6210e-02, 9.0739e-02, 1.0805e-01, 1.2841e-01,
596 1.5216e-01, 1.7960e-01, 2.1099e-01, 2.4671e-01,
597 2.8647e-01, 3.2996e-01, 3.7660e-01, 4.2547e-01,
598 4.7536e-01, 5.2473e-01, 5.7215e-01, 6.1632e-01,
599 6.5616e-01, 6.9075e-01, 7.1939e-01, 7.4199e-01,
600 7.5838e-01, 7.6848e-01, 7.7227e-01, 7.6848e-01,
601 7.5838e-01, 7.4199e-01, 7.1939e-01, 6.9075e-01,
602 6.5616e-01, 6.1632e-01, 5.7215e-01, 5.2473e-01,
603 4.7536e-01, 4.2547e-01, 3.7660e-01, 3.2996e-01,
604 2.8647e-01, 2.4671e-01, 2.1099e-01, 1.7960e-01,
605 1.5216e-01, 1.2841e-01, 1.0805e-01, 9.0739e-02,
606 7.6210e-02, 6.4039e-02, 5.3849e-02, 4.5335e-02,
607 3.8224e-02, 3.2293e-02, 2.7343e-02, 2.3167e-02,
608 1.9635e-02},
609 {1.7224e-02, 2.0450e-02, 2.4286e-02, 2.8860e-02,
610 3.4357e-02, 4.0979e-02, 4.8966e-02, 5.8612e-02,
611 7.0253e-02, 8.4257e-02, 1.0102e-01, 1.2094e-01,
612 1.4442e-01, 1.7196e-01, 2.0381e-01, 2.4013e-01,
613 2.8093e-01, 3.2594e-01, 3.7450e-01, 4.2563e-01,
614 4.7796e-01, 5.2991e-01, 5.7974e-01, 6.2599e-01,
615 6.6750e-01, 7.0344e-01, 7.3329e-01, 7.5676e-01,
616 7.7371e-01, 7.8410e-01, 7.8793e-01, 7.8410e-01,
617 7.7371e-01, 7.5676e-01, 7.3329e-01, 7.0344e-01,
618 6.6750e-01, 6.2599e-01, 5.7974e-01, 5.2991e-01,
619 4.7796e-01, 4.2563e-01, 3.7450e-01, 3.2594e-01,
620 2.8093e-01, 2.4013e-01, 2.0381e-01, 1.7196e-01,
621 1.4442e-01, 1.2094e-01, 1.0102e-01, 8.4257e-02,
622 7.0253e-02, 5.8612e-02, 4.8966e-02, 4.0979e-02,
623 3.4357e-02, 2.8860e-02, 2.4286e-02, 2.0450e-02,
624 1.7224e-02},
625 {1.5096e-02, 1.8041e-02, 2.1566e-02, 2.5793e-02,
626 3.0886e-02, 3.7044e-02, 4.4515e-02, 5.3604e-02,
627 6.4668e-02, 7.8109e-02, 9.4364e-02, 1.1389e-01,
628 1.3716e-01, 1.6461e-01, 1.9663e-01, 2.3350e-01,
629 2.7527e-01, 3.2170e-01, 3.7214e-01, 4.2549e-01,
630 4.8024e-01, 5.3460e-01, 5.8677e-01, 6.3512e-01,
631 6.7838e-01, 7.1569e-01, 7.4655e-01, 7.7071e-01,
632 7.8810e-01, 7.9871e-01, 8.0255e-01, 7.9871e-01,
633 7.8810e-01, 7.7071e-01, 7.4655e-01, 7.1569e-01,
634 6.7838e-01, 6.3512e-01, 5.8677e-01, 5.3460e-01,
635 4.8024e-01, 4.2549e-01, 3.7214e-01, 3.2170e-01,
636 2.7527e-01, 2.3350e-01, 1.9663e-01, 1.6461e-01,
637 1.3716e-01, 1.1389e-01, 9.4364e-02, 7.8109e-02,
638 6.4668e-02, 5.3604e-02, 4.4515e-02, 3.7044e-02,
639 3.0886e-02, 2.5793e-02, 2.1566e-02, 1.8041e-02,
640 1.5096e-02}};
641
642 // More sampling precision with linear interpolation
643 fPadResponse.fPRFlo = -1.5;
644 fPadResponse.fPRFhi = 1.5;
645 Float_t pad[kPRFbin];
646 Int_t sPRFbin = kPRFbin;
647 Float_t sPRFwid = (fPadResponse.fPRFhi - fPadResponse.fPRFlo) / ((Float_t) sPRFbin);
648 for (Int_t iPad = 0; iPad < sPRFbin; iPad++) {
649 pad[iPad] = ((Float_t) iPad + 0.5) * sPRFwid + fPadResponse.fPRFlo;
650 }
651 fPadResponse.fPRFbin = 500;
652 fPadResponse.fPRFwid = (fPadResponse.fPRFhi - fPadResponse.fPRFlo) / ((Float_t) fPadResponse.fPRFbin);
653 fPadResponse.fPRFpad = ((Int_t) (1.0 / fPadResponse.fPRFwid));
654
655 if (fPadResponse.fPRFsmp) delete [] fPadResponse.fPRFsmp;
656 fPadResponse.fPRFsmp = new Float_t[kNplan*fPadResponse.fPRFbin];
657
658 Int_t ipos1;
659 Int_t ipos2;
660 Float_t diff;
661
662 for (Int_t iPla = 0; iPla < kNplan; iPla++) {
663
664 for (Int_t iBin = 0; iBin < fPadResponse.fPRFbin; iBin++) {
665
666 Float_t bin = (((Float_t) iBin) + 0.5) * fPadResponse.fPRFwid + fPadResponse.fPRFlo;
667 ipos1 = ipos2 = 0;
668 diff = 0;
669 do {
670 diff = bin - pad[ipos2++];
671 } while ((diff > 0) && (ipos2 < kPRFbin));
672 if (ipos2 == kPRFbin) {
673 fPadResponse.fPRFsmp[iPla*fPadResponse.fPRFbin+iBin] = prf[iPla][ipos2-1];
674 }
675 else if (ipos2 == 1) {
676 fPadResponse.fPRFsmp[iPla*fPadResponse.fPRFbin+iBin] = prf[iPla][ipos2-1];
677 }
678 else {
679 ipos2--;
680 if (ipos2 >= kPRFbin) ipos2 = kPRFbin - 1;
681 ipos1 = ipos2 - 1;
682 fPadResponse.fPRFsmp[iPla*fPadResponse.fPRFbin+iBin] = prf[iPla][ipos2]
683 + diff * (prf[iPla][ipos2] - prf[iPla][ipos1])
684 / sPRFwid;
685 }
686
687 }
688 }
689
690}
691
692//_____________________________________________________________________________
693Int_t AliTRDcalibDB::PadResponse(Double_t signal, Double_t dist
694 , Int_t plane, Double_t *pad) const
695{
696 //
697 // Applies the pad response
698 //
699
700 Int_t iBin = ((Int_t) (( - dist - fPadResponse.fPRFlo) / fPadResponse.fPRFwid));
701 Int_t iOff = plane * fPadResponse.fPRFbin;
702
703 Int_t iBin0 = iBin - fPadResponse.fPRFpad + iOff;
704 Int_t iBin1 = iBin + iOff;
705 Int_t iBin2 = iBin + fPadResponse.fPRFpad + iOff;
706
707 pad[0] = 0.0;
708 pad[1] = 0.0;
709 pad[2] = 0.0;
710 if ((iBin1 >= 0) && (iBin1 < (fPadResponse.fPRFbin*kNplan))) {
711
712 if (iBin0 >= 0) {
713 pad[0] = signal * fPadResponse.fPRFsmp[iBin0];
714 }
715 pad[1] = signal * fPadResponse.fPRFsmp[iBin1];
716 if (iBin2 < (fPadResponse.fPRFbin*kNplan)) {
717 pad[2] = signal * fPadResponse.fPRFsmp[iBin2];
718 }
719
720 return 1;
721
722 }
723 else {
724
725 return 0;
726
727 }
ab0a4106 728
3551db50 729}
730