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