Introduce smaller AliTRDCalDCSFEEv2 object (Frederick)
[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// //
2745a409 22// Request an instance with AliTRDcalibDB::Instance() //
3551db50 23// If a new event is processed set the event number with SetRun //
24// Then request the calibration data //
25// //
2745a409 26// Author: //
27// Jan Fiete Grosse-Oetringhaus (Jan.Fiete.Grosse-Oetringhaus@cern.ch) //
28// //
3551db50 29///////////////////////////////////////////////////////////////////////////////
30
a7ac01d2 31#include <TClonesArray.h>
e232d349 32#include <TObjArray.h>
3551db50 33
2745a409 34#include "AliCDBManager.h"
2745a409 35#include "AliCDBEntry.h"
36#include "AliLog.h"
3551db50 37
38#include "AliTRDcalibDB.h"
3551db50 39
7754cd1f 40#include "Cal/AliTRDCalROC.h"
7754cd1f 41#include "Cal/AliTRDCalPad.h"
42#include "Cal/AliTRDCalDet.h"
e232d349 43#include "Cal/AliTRDCalDCS.h"
4a2eec96 44#include "Cal/AliTRDCalDCSv2.h"
720a0a16 45#include "Cal/AliTRDCalPID.h"
7754cd1f 46#include "Cal/AliTRDCalMonitoring.h"
7754cd1f 47#include "Cal/AliTRDCalChamberStatus.h"
7754cd1f 48#include "Cal/AliTRDCalPadStatus.h"
49#include "Cal/AliTRDCalSingleChamberStatus.h"
3551db50 50
51ClassImp(AliTRDcalibDB)
52
2745a409 53AliTRDcalibDB *AliTRDcalibDB::fgInstance = 0;
54Bool_t AliTRDcalibDB::fgTerminated = kFALSE;
3551db50 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
6d50f529 64 if (fgTerminated != kFALSE) {
3551db50 65 return 0;
6d50f529 66 }
3551db50 67
6d50f529 68 if (fgInstance == 0) {
3551db50 69 fgInstance = new AliTRDcalibDB();
6d50f529 70 }
e254cad1 71
3551db50 72 return fgInstance;
4e009ce4 73
3551db50 74}
75
2745a409 76//_____________________________________________________________________________
3551db50 77void AliTRDcalibDB::Terminate()
78{
79 //
80 // Singleton implementation
6bf5f0ce 81 // Deletes the instance of this class and sets the terminated flag,
82 // instances cannot be requested anymore
3551db50 83 // This function can be called several times.
84 //
85
86 fgTerminated = kTRUE;
87
6d50f529 88 if (fgInstance != 0) {
3551db50 89 delete fgInstance;
90 fgInstance = 0;
91 }
2745a409 92
3551db50 93}
94
95//_____________________________________________________________________________
96AliTRDcalibDB::AliTRDcalibDB()
2745a409 97 :TObject()
98 ,fRun(-1)
6d50f529 99 ,fPRFsmp(0)
100 ,fPRFbin(0)
101 ,fPRFlo(0)
102 ,fPRFhi(0)
103 ,fPRFwid(0)
104 ,fPRFpad(0)
3551db50 105{
106 //
2745a409 107 // Default constructor
3551db50 108 //
2745a409 109 // TODO Default runnumber is set to 0, this should be changed later
110 // to an invalid value (e.g. -1) to prevent
3551db50 111 // TODO invalid calibration data to be used.
2745a409 112 //
113
95867fd1 114 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
2745a409 115 fCDBCache[i] = 0;
116 fCDBEntries[i] = 0;
117 }
3551db50 118
2745a409 119 // Create the sampled PRF
120 SamplePRF();
d4c6453d 121
2745a409 122}
123
124//_____________________________________________________________________________
125AliTRDcalibDB::AliTRDcalibDB(const AliTRDcalibDB &c)
126 :TObject(c)
6d50f529 127 ,fRun(-1)
128 ,fPRFsmp(0)
129 ,fPRFbin(0)
130 ,fPRFlo(0)
131 ,fPRFhi(0)
132 ,fPRFwid(0)
133 ,fPRFpad(0)
2745a409 134{
135 //
136 // Copy constructor (not that it make any sense for a singleton...)
137 //
138
95867fd1 139 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
2745a409 140 fCDBCache[i] = 0;
3551db50 141 fCDBEntries[i] = 0;
142 }
6a739e92 143
144 // Create the sampled PRF
145 SamplePRF();
2745a409 146
147}
148
149//_____________________________________________________________________________
150AliTRDcalibDB &AliTRDcalibDB::operator=(const AliTRDcalibDB &c)
151{
152 //
153 // Assignment operator (same as above ...)
154 //
155
156 if (this != &c) {
157 AliFatal("No assignment operator defined");
158 }
4e009ce4 159
2745a409 160 return *this;
161
acba9bad 162}
3551db50 163
164//_____________________________________________________________________________
165AliTRDcalibDB::~AliTRDcalibDB()
166{
167 //
168 // destructor
169 //
170
6d50f529 171 if (fPRFsmp) {
172 delete [] fPRFsmp;
173 fPRFsmp = 0;
6a739e92 174 }
175
3551db50 176 Invalidate();
2745a409 177
acba9bad 178}
3551db50 179
63a700c6 180//_caching functions____________________________________________________________
95867fd1 181const TObject *AliTRDcalibDB::GetCachedCDBObject(Int_t id)
63a700c6 182{
2745a409 183 //
184 // Retrieves a cdb object with the given id. The objects are cached as
185 // long as the run number is not changed.
186 //
187 // Put together the available objects here by using the lines
188 // a) For usual calibration objects:
189 // case kID<Name> :
190 // return CacheCDBEntry(kID<Name>,"TRD/Calib/<Path>");
191 // break;
192 // See function CacheCDBEntry for details.
193 // and
194 // b) For calibration data which depends on two objects: One containing
195 // a value per detector and one the local fluctuations per pad:
196 // case kID<Name> :
197 // return CacheMergeCDBEntry(kID<Name>,"TRD/Calib/<padPath>","TRD/Calib/<chamberPath>");
198 // break;
199 // See function CacheMergeCDBEntry for details.
200 //
63a700c6 201
6d50f529 202 switch (id) {
2745a409 203
204 // Parameters defined per pad and chamber
205 case kIDVdriftPad :
6d50f529 206 return CacheCDBEntry(kIDVdriftPad ,"TRD/Calib/LocalVdrift");
2745a409 207 break;
208 case kIDVdriftChamber :
6d50f529 209 return CacheCDBEntry(kIDVdriftChamber ,"TRD/Calib/ChamberVdrift");
2745a409 210 break;
211 case kIDT0Pad :
6d50f529 212 return CacheCDBEntry(kIDT0Pad ,"TRD/Calib/LocalT0");
2745a409 213 break;
214 case kIDT0Chamber :
6d50f529 215 return CacheCDBEntry(kIDT0Chamber ,"TRD/Calib/ChamberT0");
2745a409 216 break;
217 case kIDGainFactorPad :
6d50f529 218 return CacheCDBEntry(kIDGainFactorPad ,"TRD/Calib/LocalGainFactor");
2745a409 219 break;
220 case kIDGainFactorChamber :
6d50f529 221 return CacheCDBEntry(kIDGainFactorChamber ,"TRD/Calib/ChamberGainFactor");
2745a409 222 break;
df83a620 223 case kIDNoiseChamber :
224 return CacheCDBEntry(kIDNoiseChamber ,"TRD/Calib/DetNoise");
225 break;
226 case kIDNoisePad :
227 return CacheCDBEntry(kIDNoisePad ,"TRD/Calib/PadNoise");
228 break;
229
2745a409 230
231 // Parameters defined per pad
232 case kIDPRFWidth :
6d50f529 233 return CacheCDBEntry(kIDPRFWidth ,"TRD/Calib/PRFWidth");
2745a409 234 break;
235
236 // Status values
2745a409 237 case kIDChamberStatus :
6d50f529 238 return CacheCDBEntry(kIDChamberStatus ,"TRD/Calib/ChamberStatus");
2745a409 239 break;
2745a409 240 case kIDPadStatus :
6d50f529 241 return CacheCDBEntry(kIDPadStatus ,"TRD/Calib/PadStatus");
2745a409 242 break;
243
244 // Global parameters
245 case kIDMonitoringData :
6d50f529 246 return CacheCDBEntry(kIDMonitoringData ,"TRD/Calib/MonitoringData");
2745a409 247 break;
aa617684 248 case kIDFEE :
249 return CacheCDBEntry(kIDFEE ,"TRD/Calib/FEE");
2745a409 250 break;
e232d349 251 case kIDDCS :
4a2eec96 252 if (GetCDBEntry("TRD/Calib/DCSv2"))
253 return CacheCDBEntry(kIDDCS ,"TRD/Calib/DCSv2");
254 else
255 return CacheCDBEntry(kIDDCS ,"TRD/Calib/DCS");
e232d349 256 break;
44dbae42 257 case kIDPIDNN :
258 return CacheCDBEntry(kIDPIDNN ,"TRD/Calib/PIDNN");
2745a409 259 case kIDPIDLQ :
6d50f529 260 return CacheCDBEntry(kIDPIDLQ ,"TRD/Calib/PIDLQ");
2745a409 261 break;
a7ac01d2 262 case kIDRecoParam :
263 return CacheCDBEntry(kIDRecoParam ,"TRD/Calib/RecoParam");
264 break;
2745a409 265
266 }
267
268 return 0;
269
63a700c6 270}
271
272//_____________________________________________________________________________
95867fd1 273AliCDBEntry *AliTRDcalibDB::GetCDBEntry(const char *cdbPath)
63a700c6 274{
275 //
276 // Retrieves an entry with path <cdbPath> from the CDB.
277 //
278
95867fd1 279 AliCDBEntry *entry = AliCDBManager::Instance()->Get(cdbPath,fRun);
2745a409 280 if (!entry) {
a7ac01d2 281 AliError(Form("Failed to get entry: %s",cdbPath));
63a700c6 282 return 0;
283 }
284
63a700c6 285 return entry;
2745a409 286
63a700c6 287}
288
289//_____________________________________________________________________________
95867fd1 290const TObject *AliTRDcalibDB::CacheCDBEntry(Int_t id, const char *cdbPath)
63a700c6 291{
292 //
293 // Caches the entry <id> with cdb path <cdbPath>
294 //
295
2745a409 296 if (!fCDBCache[id]) {
63a700c6 297 fCDBEntries[id] = GetCDBEntry(cdbPath);
95867fd1 298 if (fCDBEntries[id]) {
63a700c6 299 fCDBCache[id] = fCDBEntries[id]->GetObject();
95867fd1 300 }
63a700c6 301 }
95867fd1 302
63a700c6 303 return fCDBCache[id];
2745a409 304
63a700c6 305}
306
3551db50 307//_____________________________________________________________________________
308void AliTRDcalibDB::SetRun(Long64_t run)
309{
310 //
7754cd1f 311 // Sets current run number. Calibration data is read from the corresponding file.
3551db50 312 // When the run number changes the caching is invalidated.
313 //
7754cd1f 314
6d50f529 315 if (fRun == run) {
3551db50 316 return;
6d50f529 317 }
7754cd1f 318
3551db50 319 fRun = run;
95867fd1 320
3551db50 321 Invalidate();
2745a409 322
3551db50 323}
7754cd1f 324
3551db50 325//_____________________________________________________________________________
326void AliTRDcalibDB::Invalidate()
327{
328 //
329 // Invalidates cache (when run number is changed).
330 //
331
95867fd1 332 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
2745a409 333 if (fCDBEntries[i]) {
334 if (AliCDBManager::Instance()->GetCacheFlag() == kFALSE) {
11f5dd43 335 if ((fCDBEntries[i]->IsOwner() == kFALSE) &&
336 (fCDBCache[i])) {
e254cad1 337 delete fCDBCache[i];
2745a409 338 }
e254cad1 339 delete fCDBEntries[i];
340 }
3551db50 341 fCDBEntries[i] = 0;
2745a409 342 fCDBCache[i] = 0;
3551db50 343 }
344 }
2745a409 345
df83a620 346}
347//_____________________________________________________________________________
348Float_t AliTRDcalibDB::GetNoise(Int_t det, Int_t col, Int_t row)
349{
350 //
351 // Returns the noise level in ADC counts for the given pad.
352 //
353
354 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
355 (GetCachedCDBObject(kIDNoisePad));
356 if (!calPad) {
357 return -1;
358 }
359
360 AliTRDCalROC *roc = calPad->GetCalROC(det);
361 if (!roc) {
362 return -1;
363 }
364
365 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
366 (GetCachedCDBObject(kIDNoiseChamber));
367 if (!calChamber) {
368 return -1;
369 }
370
371 return calChamber->GetValue(det) * roc->GetValue(col,row);
372
373}
374
375//_____________________________________________________________________________
376AliTRDCalROC *AliTRDcalibDB::GetNoiseROC(Int_t det)
377{
378 //
379 // Returns the Vdrift calibration object for a given ROC
380 // containing one number per pad
381 //
382
383 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
384 (GetCachedCDBObject(kIDNoisePad));
385 if (!calPad) {
386 return 0;
387 }
388
389 AliTRDCalROC *roc = calPad->GetCalROC(det);
390 if (!roc) {
391 return 0;
392 }
393 else {
394 return roc;
395 }
396
397}
398
399//_____________________________________________________________________________
400const AliTRDCalDet *AliTRDcalibDB::GetNoiseDet()
401{
402 //
403 // Returns the Vdrift calibration object
404 // containing one number per detector
405 //
406
407 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
408 (GetCachedCDBObject(kIDNoiseChamber));
409 if (!calChamber) {
410 return 0;
411 }
412 else {
413 return calChamber;
414 }
415
3551db50 416}
417
3551db50 418//_____________________________________________________________________________
419Float_t AliTRDcalibDB::GetVdrift(Int_t det, Int_t col, Int_t row)
420{
421 //
422 // Returns the drift velocity for the given pad.
423 //
7754cd1f 424
95867fd1 425 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
6d50f529 426 (GetCachedCDBObject(kIDVdriftPad));
427 if (!calPad) {
3551db50 428 return -1;
6d50f529 429 }
3551db50 430
95867fd1 431 AliTRDCalROC *roc = calPad->GetCalROC(det);
6d50f529 432 if (!roc) {
3551db50 433 return -1;
6d50f529 434 }
3551db50 435
95867fd1 436 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
6d50f529 437 (GetCachedCDBObject(kIDVdriftChamber));
438 if (!calChamber) {
7754cd1f 439 return -1;
6d50f529 440 }
7754cd1f 441
95867fd1 442 return calChamber->GetValue(det) * roc->GetValue(col,row);
2745a409 443
7754cd1f 444}
afb9f880 445
446//_____________________________________________________________________________
447AliTRDCalROC *AliTRDcalibDB::GetVdriftROC(Int_t det)
448{
449 //
450 // Returns the Vdrift calibration object for a given ROC
451 // containing one number per pad
452 //
453
454 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
455 (GetCachedCDBObject(kIDVdriftPad));
456 if (!calPad) {
457 return 0;
458 }
459
460 AliTRDCalROC *roc = calPad->GetCalROC(det);
461 if (!roc) {
462 return 0;
463 }
464 else {
465 return roc;
466 }
467
468}
469
470//_____________________________________________________________________________
471const AliTRDCalDet *AliTRDcalibDB::GetVdriftDet()
472{
473 //
474 // Returns the Vdrift calibration object
475 // containing one number per detector
476 //
477
478 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
479 (GetCachedCDBObject(kIDVdriftChamber));
480 if (!calChamber) {
481 return 0;
482 }
483 else {
484 return calChamber;
485 }
486
487}
7754cd1f 488
489//_____________________________________________________________________________
490Float_t AliTRDcalibDB::GetVdriftAverage(Int_t det)
491{
492 //
493 // Returns the average drift velocity for the given detector
494 //
495
95867fd1 496 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
6d50f529 497 (GetCachedCDBObject(kIDVdriftChamber));
498 if (!calDet) {
7754cd1f 499 return -1;
6d50f529 500 }
7754cd1f 501
502 return calDet->GetValue(det);
2745a409 503
acba9bad 504}
3551db50 505
506//_____________________________________________________________________________
507Float_t AliTRDcalibDB::GetT0(Int_t det, Int_t col, Int_t row)
508{
509 //
510 // Returns t0 for the given pad.
511 //
512
d4c6453d 513 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
514 (GetCachedCDBObject(kIDT0Pad));
6d50f529 515 if (!calPad) {
3551db50 516 return -1;
6d50f529 517 }
3551db50 518
d4c6453d 519 AliTRDCalROC *roc = calPad->GetCalROC(det);
6d50f529 520 if (!roc) {
3551db50 521 return -1;
6d50f529 522 }
3551db50 523
d4c6453d 524 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
525 (GetCachedCDBObject(kIDT0Chamber));
6d50f529 526 if (!calChamber) {
7754cd1f 527 return -1;
6d50f529 528 }
7754cd1f 529
8d786fb8 530 return calChamber->GetValue(det) + roc->GetValue(col,row);
2745a409 531
7754cd1f 532}
afb9f880 533
56178ff4 534//_____________________________________________________________________________
535AliTRDCalROC *AliTRDcalibDB::GetT0ROC(Int_t det)
536{
537 //
538 // Returns the t0 calibration object for a given ROC
539 // containing one number per pad
540 //
541
542 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
543 (GetCachedCDBObject(kIDT0Pad));
544 if (!calPad) {
545 return 0;
546 }
547
548 AliTRDCalROC *roc = calPad->GetCalROC(det);
549 if (!roc) {
550 return 0;
551 }
552 else {
553 return roc;
554 }
555
556}
557
558//_____________________________________________________________________________
559const AliTRDCalDet *AliTRDcalibDB::GetT0Det()
560{
561 //
562 // Returns the t0 calibration object
563 // containing one number per detector
564 //
565
566 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
567 (GetCachedCDBObject(kIDT0Chamber));
568 if (!calChamber) {
569 return 0;
570 }
571 else {
572 return calChamber;
573 }
574
575}
576
7754cd1f 577//_____________________________________________________________________________
578Float_t AliTRDcalibDB::GetT0Average(Int_t det)
579{
580 //
581 // Returns the average t0 for the given detector
582 //
583
5aba4f09 584 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
585 (GetCachedCDBObject(kIDT0Pad));
586 if (!calPad) {
587 return -1;
588 }
589
590 AliTRDCalROC *roc = calPad->GetCalROC(det);
591 if (!roc) {
592 return -1;
593 }
594
95867fd1 595 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
6d50f529 596 (GetCachedCDBObject(kIDT0Chamber));
597 if (!calDet) {
7754cd1f 598 return -1;
6d50f529 599 }
7754cd1f 600
4eb02ab1 601 Double_t sum = 0.0;
5aba4f09 602 for (Int_t channel = 0; channel < roc->GetNchannels(); ++channel) {
4eb02ab1 603 sum += roc->GetValue(channel);
5aba4f09 604 }
4eb02ab1 605 sum /= roc->GetNchannels();
606 sum += calDet->GetValue(det);
607 return sum;
2745a409 608
acba9bad 609}
3551db50 610
611//_____________________________________________________________________________
612Float_t AliTRDcalibDB::GetGainFactor(Int_t det, Int_t col, Int_t row)
613{
614 //
615 // Returns the gain factor for the given pad.
616 //
617
95867fd1 618 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
6d50f529 619 (GetCachedCDBObject(kIDGainFactorPad));
620 if (!calPad) {
3551db50 621 return -1;
6d50f529 622 }
3551db50 623
95867fd1 624 AliTRDCalROC *roc = calPad->GetCalROC(det);
56178ff4 625 if (!roc) {
3551db50 626 return -1;
56178ff4 627 }
3551db50 628
95867fd1 629 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
6d50f529 630 (GetCachedCDBObject(kIDGainFactorChamber));
631 if (!calChamber) {
7754cd1f 632 return -1;
6d50f529 633 }
7754cd1f 634
95867fd1 635 return calChamber->GetValue(det) * roc->GetValue(col,row);
2745a409 636
7754cd1f 637}
638
56178ff4 639//_____________________________________________________________________________
640AliTRDCalROC *AliTRDcalibDB::GetGainFactorROC(Int_t det)
641{
642 //
643 // Returns the gain factor calibration object for a given ROC
56178ff4 644 //
645
646 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
647 (GetCachedCDBObject(kIDGainFactorPad));
648 if (!calPad) {
649 return 0;
650 }
651
652 AliTRDCalROC *roc = calPad->GetCalROC(det);
653 if (!roc) {
654 return 0;
655 }
656 else {
657 return roc;
658 }
659
660}
661
662//_____________________________________________________________________________
663const AliTRDCalDet *AliTRDcalibDB::GetGainFactorDet()
664{
665 //
666 // Returns the gain factor calibration object
667 // containing one number per detector
668 //
669
670 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
671 (GetCachedCDBObject(kIDGainFactorChamber));
672 if (!calChamber) {
673 return 0;
674 }
675 else {
676 return calChamber;
677 }
678
679}
680
7754cd1f 681//_____________________________________________________________________________
682Float_t AliTRDcalibDB::GetGainFactorAverage(Int_t det)
683{
684 //
685 // Returns the average gain factor for the given detector
686 //
687
95867fd1 688 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
6d50f529 689 (GetCachedCDBObject(kIDGainFactorChamber));
690 if (!calDet) {
7754cd1f 691 return -1;
6d50f529 692 }
7754cd1f 693
694 return calDet->GetValue(det);
2745a409 695
acba9bad 696}
6a739e92 697
524fc8fa 698//_____________________________________________________________________________
699AliTRDCalROC *AliTRDcalibDB::GetPRFROC(Int_t det)
700{
701 //
702 // Returns the PRF calibration object for a given ROC
703 // containing one number per pad
704 //
705
706 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
707 (GetCachedCDBObject(kIDPRFWidth));
708 if (!calPad) {
709 return 0;
710 }
711
712 AliTRDCalROC *roc = calPad->GetCalROC(det);
713 if (!roc) {
714 return 0;
715 }
716 else {
717 return roc;
718 }
719
720}
721
6a739e92 722//_____________________________________________________________________________
723Float_t AliTRDcalibDB::GetPRFWidth(Int_t det, Int_t col, Int_t row)
724{
725 //
726 // Returns the PRF width for the given pad.
727 //
728
95867fd1 729 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
6d50f529 730 (GetCachedCDBObject(kIDPRFWidth));
731 if (!calPad) {
6a739e92 732 return -1;
6d50f529 733 }
6a739e92 734
95867fd1 735 AliTRDCalROC *roc = calPad->GetCalROC(det);
6d50f529 736 if (!roc) {
6a739e92 737 return -1;
6d50f529 738 }
6a739e92 739
95867fd1 740 return roc->GetValue(col,row);
2745a409 741
acba9bad 742}
3551db50 743
744//_____________________________________________________________________________
f1dcad37 745Int_t AliTRDcalibDB::GetNumberOfTimeBinsDCS()
3551db50 746{
e232d349 747 //
748 // Returns Number of time bins from the DCS
749 //
f1dcad37 750
c6f7c6cb 751 Int_t nMixed = -2; // not the same number for all chambers
752 Int_t nUndef = -1; // default value - has not been set!
753 Int_t nTbSor = nUndef;
754 Int_t nTbEor = nUndef;
755
e232d349 756 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
f1dcad37 757
c6f7c6cb 758 if (!dcsArr) {
759 AliError("No DCS object found!");
760 return nUndef;
e232d349 761 }
c6f7c6cb 762
4a2eec96 763 if (GetCDBEntry("TRD/Calib/DCSv2")) {
764 // if there is a DCSv2 object
765 const AliTRDCalDCSv2 *calDCSsorv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(0));
766 const AliTRDCalDCSv2 *calDCSeorv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(1));
0eaf9c74 767
4a2eec96 768 if (!calDCSsorv2) {
769 // the SOR file is mandatory
770 AliError("NO SOR AliTRDCalDCSv2 object found in CDB file!");
771 return nUndef;
772 }
773
774 if (!calDCSeorv2) {
775 // this can happen if the run is shorter than a couple of seconds.
776 AliWarning("NO EOR AliTRDCalDCSv2 object found in CDB file.");
777 }
778
779 // get the numbers
780 nTbSor = calDCSsorv2->GetGlobalNumberOfTimeBins();
781 if (calDCSeorv2) nTbEor = calDCSeorv2->GetGlobalNumberOfTimeBins();
782 } else {
783 // if there is a DCS object
784 const AliTRDCalDCS *calDCSsor = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(0));
785 const AliTRDCalDCS *calDCSeor = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(1));
786
787 if (!calDCSsor) {
788 // the SOR file is mandatory
789 AliError("NO SOR AliTRDCalDCS object found in CDB file!");
790 return nUndef;
7a6352a6 791 }
c6f7c6cb 792
4a2eec96 793 if (!calDCSeor) {
794 // this can happen if the run is shorter than a couple of seconds.
795 AliWarning("NO EOR AliTRDCalDCS object found in CDB file.");
7a6352a6 796 }
c6f7c6cb 797
4a2eec96 798 // get the numbers
799 nTbSor = calDCSsor->GetGlobalNumberOfTimeBins();
800 if (calDCSeor) nTbEor = calDCSeor->GetGlobalNumberOfTimeBins();
801 }
c6f7c6cb 802
803 // if they're the same return the value
804 // -2 means mixed, -1: no data, >= 0: good number of time bins
805 if (nTbSor == nTbEor) return nTbSor;
806
807 // if they're differing:
808 if (nTbSor == nMixed || nTbEor == nMixed) {
809 AliWarning("Inconsistent number of time bins found!");
810 return nMixed;
e232d349 811 }
c6f7c6cb 812
813 // one is undefined, the other ok -> return that one
814 if (nTbSor == nUndef) return nTbEor;
815 if (nTbEor == nUndef) return nTbSor;
816
817 // only remains: two different numbers >= 0
818 return nMixed;
e232d349 819}
820
821//_____________________________________________________________________________
f1dcad37 822void AliTRDcalibDB::GetFilterType(TString &filterType)
823{
824 //
825 // Returns the filter type
826 //
827
e232d349 828 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
829 if(!dcsArr){
830 filterType = "";
831 return;
832 }
4a2eec96 833 if (GetCDBEntry("TRD/Calib/DCSv2")) {
834 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(0)); // Take SOR
835
836 if(!calDCSv2){
837 filterType = "";
838 return;
839 }
840 filterType = calDCSv2->GetGlobalFilterType();
841 } else {
842 const AliTRDCalDCS *calDCS = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(0)); // Take SOR
843
844 if(!calDCS){
845 filterType = "";
846 return;
847 }
848 filterType = calDCS->GetGlobalFilterType();
849 }
af086c5e 850}
851
852//_____________________________________________________________________________
853void AliTRDcalibDB::GetGlobalConfiguration(TString &config){
854 //
855 // Get Configuration from the DCS
856 //
857 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
858 if(!dcsArr){
859 config = "";
860 return;
861 }
4a2eec96 862
863 if (GetCDBEntry("TRD/Calib/DCSv2")) {
864 const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(0)); // Take SOR
865
866 if(!calDCSv2){
867 config = "";
868 return;
869 }
870 config = calDCSv2->GetGlobalConfigName();
871 } else {
872 const AliTRDCalDCS *calDCS = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(0)); // Take SOR
873
874 if(!calDCS){
875 config = "";
876 return;
877 }
878 config = calDCS->GetGlobalConfigName();
879 }
af086c5e 880}
f1dcad37 881
af086c5e 882//_____________________________________________________________________________
883Bool_t AliTRDcalibDB::HasOnlineFilterPedestal()
884{
885 //
886 // Checks whether pedestal filter was applied online
887 //
888 TString cname;
889 // Temporary: Get the filter config from the configuration name
890 GetGlobalConfiguration(cname);
891 TString filterconfig = cname(cname.First("_") + 1, cname.First("-") - cname.First("_") - 1);
892 // TString filterconfig;
893 //GetFilterType(filterconfig);
894 return filterconfig.Contains("p");
895}
896
897//_____________________________________________________________________________
898Bool_t AliTRDcalibDB::HasOnlineFilterGain(){
899 //
900 // Checks whether online gain filter was applied
901 //
902 TString cname;
903 // Temporary: Get the filter config from the configuration name
904 GetGlobalConfiguration(cname);
905 TString filterconfig = cname(cname.First("_") + 1, cname.First("-") - cname.First("_") - 1);
906 //TString filterconfig;
907 //GetFilterType(filterconfig);
908 return filterconfig.Contains("g");
909}
910
911//_____________________________________________________________________________
912Bool_t AliTRDcalibDB::HasOnlineTailCancellation(){
913 //
914 // Checks whether online tail cancellation was applied
915 //
916 TString cname;
917 // Temporary: Get the filter config from the configuration name
918 GetGlobalConfiguration(cname);
919 TString filterconfig = cname(cname.First("_") + 1, cname.First("-") - cname.First("_") - 1);
920 //TString filterconfig;
921 //GetFilterType(filterconfig);
922 return filterconfig.Contains("t");
e232d349 923}
924
7754cd1f 925//_____________________________________________________________________________
926Char_t AliTRDcalibDB::GetPadStatus(Int_t det, Int_t col, Int_t row)
927{
928 //
929 // Returns the status of the given pad
930 //
931
aa617684 932 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
933 (GetCachedCDBObject(kIDPadStatus));
6d50f529 934 if (!cal) {
7754cd1f 935 return -1;
6d50f529 936 }
7754cd1f 937
95867fd1 938 const AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
6d50f529 939 if (!roc) {
7754cd1f 940 return -1;
6d50f529 941 }
7754cd1f 942
95867fd1 943 return roc->GetStatus(col,row);
2745a409 944
7754cd1f 945}
946
0e09df31 947//_____________________________________________________________________________
948AliTRDCalSingleChamberStatus* AliTRDcalibDB::GetPadStatusROC(Int_t det)
949{
950 //
951 // Returns the pad status calibration object for a given ROC
952 //
953
954 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
955 (GetCachedCDBObject(kIDPadStatus));
956 if (!cal) {
957 return 0;
958 }
959
960 AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
961 if (!roc) {
962 return 0;
963 }
964 else {
965 return roc;
966 }
967
968}
969
7754cd1f 970//_____________________________________________________________________________
971Char_t AliTRDcalibDB::GetChamberStatus(Int_t det)
972{
973 //
974 // Returns the status of the given chamber
975 //
976
95867fd1 977 const AliTRDCalChamberStatus *cal = dynamic_cast<const AliTRDCalChamberStatus *>
6d50f529 978 (GetCachedCDBObject(kIDChamberStatus));
979 if (!cal) {
7754cd1f 980 return -1;
6d50f529 981 }
7754cd1f 982
983 return cal->GetStatus(det);
2745a409 984
7754cd1f 985}
986
a7ac01d2 987//_____________________________________________________________________________
988AliTRDrecoParam* AliTRDcalibDB::GetRecoParam(Int_t */*eventtype*/)
989{
be28462a 990 //
991 // Returns the TRD reconstruction parameters from the OCDB
992 //
993
a7ac01d2 994 const TClonesArray *recos = dynamic_cast<const TClonesArray*>(GetCachedCDBObject(kIDRecoParam));
be28462a 995 if (!recos) return 0x0;
a7ac01d2 996
997 // calculate entry based on event type info
998 Int_t n = 0; //f(eventtype[0], eventtype[1], ....)
be28462a 999
a7ac01d2 1000 return (AliTRDrecoParam*)recos->UncheckedAt(n);
a7ac01d2 1001
be28462a 1002}
a7ac01d2 1003
7754cd1f 1004//_____________________________________________________________________________
1005Bool_t AliTRDcalibDB::IsPadMasked(Int_t det, Int_t col, Int_t row)
1006{
1007 //
1008 // Returns status, see name of functions for details ;-)
1009 //
1010
95867fd1 1011 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1012 (GetCachedCDBObject(kIDPadStatus));
6d50f529 1013 if (!cal) {
7754cd1f 1014 return -1;
6d50f529 1015 }
7754cd1f 1016
95867fd1 1017 return cal->IsMasked(det,col,row);
2745a409 1018
7754cd1f 1019}
1020
1021//_____________________________________________________________________________
1022Bool_t AliTRDcalibDB::IsPadBridgedLeft(Int_t det, Int_t col, Int_t row)
1023{
1024 //
1025 // Returns status, see name of functions for details ;-)
1026 //
1027
95867fd1 1028 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
1029 (GetCachedCDBObject(kIDPadStatus));
6d50f529 1030 if (!cal) {
7754cd1f 1031 return -1;
6d50f529 1032 }
7754cd1f 1033
95867fd1 1034 return cal->IsBridgedLeft(det,col,row);
2745a409 1035
7754cd1f 1036}
1037
1038//_____________________________________________________________________________
1039Bool_t AliTRDcalibDB::IsPadBridgedRight(Int_t det, Int_t col, Int_t row)
1040{
1041 //
1042 // Returns status, see name of functions for details ;-)
1043 //
1044
95867fd1 1045 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
1046 (GetCachedCDBObject(kIDPadStatus));
6d50f529 1047 if (!cal) {
7754cd1f 1048 return -1;
6d50f529 1049 }
7754cd1f 1050
95867fd1 1051 return cal->IsBridgedRight(det,col,row);
2745a409 1052
7754cd1f 1053}
1054
fa7427d0 1055//_____________________________________________________________________________
1056Bool_t AliTRDcalibDB::IsPadNotConnected(Int_t det, Int_t col, Int_t row)
1057{
1058 //
1059 // Returns status, see name of functions for details ;-)
1060 //
f1dcad37 1061
fa7427d0 1062 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
1063 (GetCachedCDBObject(kIDPadStatus));
1064 if (!cal) {
1065 return -1;
1066 }
1067
1068 return cal->IsNotConnected(det,col,row);
1069
1070}
1071
7754cd1f 1072//_____________________________________________________________________________
1073Bool_t AliTRDcalibDB::IsChamberInstalled(Int_t det)
1074{
1075 //
1076 // Returns status, see name of functions for details ;-)
1077 //
1078
95867fd1 1079 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1080 (GetCachedCDBObject(kIDChamberStatus));
6d50f529 1081 if (!cal) {
7754cd1f 1082 return -1;
6d50f529 1083 }
7754cd1f 1084
1085 return cal->IsInstalled(det);
2745a409 1086
7754cd1f 1087}
1088
1089//_____________________________________________________________________________
1090Bool_t AliTRDcalibDB::IsChamberMasked(Int_t det)
1091{
1092 //
1093 // Returns status, see name of functions for details ;-)
1094 //
1095
95867fd1 1096 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1097 (GetCachedCDBObject(kIDChamberStatus));
6d50f529 1098 if (!cal) {
7754cd1f 1099 return -1;
6d50f529 1100 }
7754cd1f 1101
1102 return cal->IsMasked(det);
2745a409 1103
7754cd1f 1104}
7a6352a6 1105//_____________________________________________________________________________
1106Bool_t AliTRDcalibDB::IsHalfChamberMasked(Int_t det, Int_t side){
1107 //
1108 // Returns status, see name of functions for details ;-)
1109 //
7754cd1f 1110
7a6352a6 1111 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
1112 (GetCachedCDBObject(kIDChamberStatus));
1113 if (!cal) {
1114 return -1;
1115 }
1116
1117 return side > 0 ? cal->IsHalfChamberSideBMasked(det) : cal->IsHalfChamberSideAMasked(det);
1118
1119}
cc7cef99 1120//_____________________________________________________________________________
0d83b3a5 1121const AliTRDCalPID *AliTRDcalibDB::GetPIDObject(AliTRDpidUtil::ETRDPIDMethod method)
cc7cef99 1122{
1123 //
1124 // Returns the object storing the distributions for PID with likelihood
1125 //
9a96f175 1126
1127 switch(method) {
0d83b3a5 1128 case AliTRDpidUtil::kLQ:
4ba1d6ae 1129 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDLQ));
0d83b3a5 1130 case AliTRDpidUtil::kNN:
4ba1d6ae 1131 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDNN));
543691ea 1132 case AliTRDpidUtil::kESD:
1133 return 0x0; // To avoid compiler warnings
9a96f175 1134 }
1135
10f75631 1136 return 0x0;
2745a409 1137
cc7cef99 1138}
1139
7754cd1f 1140//_____________________________________________________________________________
d4c6453d 1141const AliTRDCalMonitoring *AliTRDcalibDB::GetMonitoringObject()
7754cd1f 1142{
1143 //
1144 // Returns the object storing the monitoring data
1145 //
1146
d4c6453d 1147 return dynamic_cast<const AliTRDCalMonitoring *>
1148 (GetCachedCDBObject(kIDMonitoringData));
1b95a37b 1149
7754cd1f 1150}
1151
6a739e92 1152//_____________________________________________________________________________
1153void AliTRDcalibDB::SamplePRF()
1154{
1155 //
2745a409 1156 // Samples the pad response function (should maybe go somewhere else ...)
6a739e92 1157 //
1158
1159 const Int_t kPRFbin = 61;
1160
053767a4 1161 Float_t prf[kNlayer][kPRFbin] = {
6d50f529 1162 {2.9037e-02, 3.3608e-02, 3.9020e-02, 4.5292e-02,
6a739e92 1163 5.2694e-02, 6.1362e-02, 7.1461e-02, 8.3362e-02,
1164 9.7063e-02, 1.1307e-01, 1.3140e-01, 1.5235e-01,
1165 1.7623e-01, 2.0290e-01, 2.3294e-01, 2.6586e-01,
1166 3.0177e-01, 3.4028e-01, 3.8077e-01, 4.2267e-01,
1167 4.6493e-01, 5.0657e-01, 5.4655e-01, 5.8397e-01,
1168 6.1767e-01, 6.4744e-01, 6.7212e-01, 6.9188e-01,
1169 7.0627e-01, 7.1499e-01, 7.1851e-01, 7.1499e-01,
1170 7.0627e-01, 6.9188e-01, 6.7212e-01, 6.4744e-01,
1171 6.1767e-01, 5.8397e-01, 5.4655e-01, 5.0657e-01,
1172 4.6493e-01, 4.2267e-01, 3.8077e-01, 3.4028e-01,
1173 3.0177e-01, 2.6586e-01, 2.3294e-01, 2.0290e-01,
1174 1.7623e-01, 1.5235e-01, 1.3140e-01, 1.1307e-01,
1175 9.7063e-02, 8.3362e-02, 7.1461e-02, 6.1362e-02,
1176 5.2694e-02, 4.5292e-02, 3.9020e-02, 3.3608e-02,
1177 2.9037e-02},
1178 {2.5478e-02, 2.9695e-02, 3.4655e-02, 4.0454e-02,
1179 4.7342e-02, 5.5487e-02, 6.5038e-02, 7.6378e-02,
1180 8.9696e-02, 1.0516e-01, 1.2327e-01, 1.4415e-01,
1181 1.6794e-01, 1.9516e-01, 2.2573e-01, 2.5959e-01,
1182 2.9694e-01, 3.3719e-01, 3.7978e-01, 4.2407e-01,
1183 4.6889e-01, 5.1322e-01, 5.5569e-01, 5.9535e-01,
1184 6.3141e-01, 6.6259e-01, 6.8882e-01, 7.0983e-01,
1185 7.2471e-01, 7.3398e-01, 7.3761e-01, 7.3398e-01,
1186 7.2471e-01, 7.0983e-01, 6.8882e-01, 6.6259e-01,
1187 6.3141e-01, 5.9535e-01, 5.5569e-01, 5.1322e-01,
1188 4.6889e-01, 4.2407e-01, 3.7978e-01, 3.3719e-01,
1189 2.9694e-01, 2.5959e-01, 2.2573e-01, 1.9516e-01,
1190 1.6794e-01, 1.4415e-01, 1.2327e-01, 1.0516e-01,
1191 8.9696e-02, 7.6378e-02, 6.5038e-02, 5.5487e-02,
1192 4.7342e-02, 4.0454e-02, 3.4655e-02, 2.9695e-02,
1193 2.5478e-02},
1194 {2.2363e-02, 2.6233e-02, 3.0782e-02, 3.6140e-02,
1195 4.2535e-02, 5.0157e-02, 5.9197e-02, 6.9900e-02,
1196 8.2707e-02, 9.7811e-02, 1.1548e-01, 1.3601e-01,
1197 1.5998e-01, 1.8739e-01, 2.1840e-01, 2.5318e-01,
1198 2.9182e-01, 3.3373e-01, 3.7837e-01, 4.2498e-01,
1199 4.7235e-01, 5.1918e-01, 5.6426e-01, 6.0621e-01,
1200 6.4399e-01, 6.7700e-01, 7.0472e-01, 7.2637e-01,
1201 7.4206e-01, 7.5179e-01, 7.5551e-01, 7.5179e-01,
1202 7.4206e-01, 7.2637e-01, 7.0472e-01, 6.7700e-01,
1203 6.4399e-01, 6.0621e-01, 5.6426e-01, 5.1918e-01,
1204 4.7235e-01, 4.2498e-01, 3.7837e-01, 3.3373e-01,
1205 2.9182e-01, 2.5318e-01, 2.1840e-01, 1.8739e-01,
1206 1.5998e-01, 1.3601e-01, 1.1548e-01, 9.7811e-02,
1207 8.2707e-02, 6.9900e-02, 5.9197e-02, 5.0157e-02,
1208 4.2535e-02, 3.6140e-02, 3.0782e-02, 2.6233e-02,
1209 2.2363e-02},
1210 {1.9635e-02, 2.3167e-02, 2.7343e-02, 3.2293e-02,
1211 3.8224e-02, 4.5335e-02, 5.3849e-02, 6.4039e-02,
1212 7.6210e-02, 9.0739e-02, 1.0805e-01, 1.2841e-01,
1213 1.5216e-01, 1.7960e-01, 2.1099e-01, 2.4671e-01,
1214 2.8647e-01, 3.2996e-01, 3.7660e-01, 4.2547e-01,
1215 4.7536e-01, 5.2473e-01, 5.7215e-01, 6.1632e-01,
1216 6.5616e-01, 6.9075e-01, 7.1939e-01, 7.4199e-01,
1217 7.5838e-01, 7.6848e-01, 7.7227e-01, 7.6848e-01,
1218 7.5838e-01, 7.4199e-01, 7.1939e-01, 6.9075e-01,
1219 6.5616e-01, 6.1632e-01, 5.7215e-01, 5.2473e-01,
1220 4.7536e-01, 4.2547e-01, 3.7660e-01, 3.2996e-01,
1221 2.8647e-01, 2.4671e-01, 2.1099e-01, 1.7960e-01,
1222 1.5216e-01, 1.2841e-01, 1.0805e-01, 9.0739e-02,
1223 7.6210e-02, 6.4039e-02, 5.3849e-02, 4.5335e-02,
1224 3.8224e-02, 3.2293e-02, 2.7343e-02, 2.3167e-02,
1225 1.9635e-02},
1226 {1.7224e-02, 2.0450e-02, 2.4286e-02, 2.8860e-02,
1227 3.4357e-02, 4.0979e-02, 4.8966e-02, 5.8612e-02,
1228 7.0253e-02, 8.4257e-02, 1.0102e-01, 1.2094e-01,
1229 1.4442e-01, 1.7196e-01, 2.0381e-01, 2.4013e-01,
1230 2.8093e-01, 3.2594e-01, 3.7450e-01, 4.2563e-01,
1231 4.7796e-01, 5.2991e-01, 5.7974e-01, 6.2599e-01,
1232 6.6750e-01, 7.0344e-01, 7.3329e-01, 7.5676e-01,
1233 7.7371e-01, 7.8410e-01, 7.8793e-01, 7.8410e-01,
1234 7.7371e-01, 7.5676e-01, 7.3329e-01, 7.0344e-01,
1235 6.6750e-01, 6.2599e-01, 5.7974e-01, 5.2991e-01,
1236 4.7796e-01, 4.2563e-01, 3.7450e-01, 3.2594e-01,
1237 2.8093e-01, 2.4013e-01, 2.0381e-01, 1.7196e-01,
1238 1.4442e-01, 1.2094e-01, 1.0102e-01, 8.4257e-02,
1239 7.0253e-02, 5.8612e-02, 4.8966e-02, 4.0979e-02,
1240 3.4357e-02, 2.8860e-02, 2.4286e-02, 2.0450e-02,
1241 1.7224e-02},
1242 {1.5096e-02, 1.8041e-02, 2.1566e-02, 2.5793e-02,
1243 3.0886e-02, 3.7044e-02, 4.4515e-02, 5.3604e-02,
1244 6.4668e-02, 7.8109e-02, 9.4364e-02, 1.1389e-01,
1245 1.3716e-01, 1.6461e-01, 1.9663e-01, 2.3350e-01,
1246 2.7527e-01, 3.2170e-01, 3.7214e-01, 4.2549e-01,
1247 4.8024e-01, 5.3460e-01, 5.8677e-01, 6.3512e-01,
1248 6.7838e-01, 7.1569e-01, 7.4655e-01, 7.7071e-01,
1249 7.8810e-01, 7.9871e-01, 8.0255e-01, 7.9871e-01,
1250 7.8810e-01, 7.7071e-01, 7.4655e-01, 7.1569e-01,
1251 6.7838e-01, 6.3512e-01, 5.8677e-01, 5.3460e-01,
1252 4.8024e-01, 4.2549e-01, 3.7214e-01, 3.2170e-01,
1253 2.7527e-01, 2.3350e-01, 1.9663e-01, 1.6461e-01,
1254 1.3716e-01, 1.1389e-01, 9.4364e-02, 7.8109e-02,
1255 6.4668e-02, 5.3604e-02, 4.4515e-02, 3.7044e-02,
1256 3.0886e-02, 2.5793e-02, 2.1566e-02, 1.8041e-02,
1257 1.5096e-02}};
1258
1259 // More sampling precision with linear interpolation
6d50f529 1260 fPRFlo = -1.5;
1261 fPRFhi = 1.5;
6a739e92 1262 Float_t pad[kPRFbin];
1263 Int_t sPRFbin = kPRFbin;
6d50f529 1264 Float_t sPRFwid = (fPRFhi - fPRFlo) / ((Float_t) sPRFbin);
6a739e92 1265 for (Int_t iPad = 0; iPad < sPRFbin; iPad++) {
6d50f529 1266 pad[iPad] = ((Float_t) iPad + 0.5) * sPRFwid + fPRFlo;
6a739e92 1267 }
6d50f529 1268 fPRFbin = 500;
1269 fPRFwid = (fPRFhi - fPRFlo) / ((Float_t) fPRFbin);
1270 fPRFpad = ((Int_t) (1.0 / fPRFwid));
6a739e92 1271
6d50f529 1272 if (fPRFsmp) delete [] fPRFsmp;
053767a4 1273 fPRFsmp = new Float_t[kNlayer*fPRFbin];
6a739e92 1274
1275 Int_t ipos1;
1276 Int_t ipos2;
1277 Float_t diff;
1278
053767a4 1279 for (Int_t iLayer = 0; iLayer < kNlayer; iLayer++) {
6a739e92 1280
6d50f529 1281 for (Int_t iBin = 0; iBin < fPRFbin; iBin++) {
6a739e92 1282
6d50f529 1283 Float_t bin = (((Float_t) iBin) + 0.5) * fPRFwid + fPRFlo;
6a739e92 1284 ipos1 = ipos2 = 0;
1285 diff = 0;
1286 do {
1287 diff = bin - pad[ipos2++];
1288 } while ((diff > 0) && (ipos2 < kPRFbin));
1289 if (ipos2 == kPRFbin) {
053767a4 1290 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
6a739e92 1291 }
1292 else if (ipos2 == 1) {
053767a4 1293 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
6a739e92 1294 }
1295 else {
1296 ipos2--;
1297 if (ipos2 >= kPRFbin) ipos2 = kPRFbin - 1;
1298 ipos1 = ipos2 - 1;
053767a4 1299 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2]
1300 + diff * (prf[iLayer][ipos2] - prf[iLayer][ipos1])
1301 / sPRFwid;
6a739e92 1302 }
1303
1304 }
1305 }
1306
1307}
1308
1309//_____________________________________________________________________________
1310Int_t AliTRDcalibDB::PadResponse(Double_t signal, Double_t dist
eb52b657 1311 , Int_t layer, Double_t *pad) const
6a739e92 1312{
1313 //
1314 // Applies the pad response
56178ff4 1315 // So far this is the fixed parametrization and should be replaced by
1316 // something dependent on calibration values
6a739e92 1317 //
1318
eb52b657 1319 Int_t iBin = ((Int_t) ((-dist - fPRFlo) / fPRFwid));
053767a4 1320 Int_t iOff = layer * fPRFbin;
6a739e92 1321
6d50f529 1322 Int_t iBin0 = iBin - fPRFpad + iOff;
6a739e92 1323 Int_t iBin1 = iBin + iOff;
6d50f529 1324 Int_t iBin2 = iBin + fPRFpad + iOff;
6a739e92 1325
1326 pad[0] = 0.0;
1327 pad[1] = 0.0;
1328 pad[2] = 0.0;
053767a4 1329 if ((iBin1 >= 0) && (iBin1 < (fPRFbin*kNlayer))) {
6a739e92 1330
1331 if (iBin0 >= 0) {
6d50f529 1332 pad[0] = signal * fPRFsmp[iBin0];
6a739e92 1333 }
6d50f529 1334 pad[1] = signal * fPRFsmp[iBin1];
053767a4 1335 if (iBin2 < (fPRFbin*kNlayer)) {
6d50f529 1336 pad[2] = signal * fPRFsmp[iBin2];
6a739e92 1337 }
1338
1339 return 1;
1340
1341 }
1342 else {
1343
1344 return 0;
1345
1346 }
ab0a4106 1347
3551db50 1348}
7a6352a6 1349
1350