]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDcalibDB.cxx
Modified usage of fAllowProlongationWithEmptyRoad in ITS standalone tracker, conseque...
[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"
aa617684 44#include "Cal/AliTRDCalFEE.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 :
252 return CacheCDBEntry(kIDDCS ,"TRD/Calib/DCS");
253 break;
44dbae42 254 case kIDPIDNN :
255 return CacheCDBEntry(kIDPIDNN ,"TRD/Calib/PIDNN");
2745a409 256 case kIDPIDLQ :
6d50f529 257 return CacheCDBEntry(kIDPIDLQ ,"TRD/Calib/PIDLQ");
2745a409 258 break;
a7ac01d2 259 case kIDRecoParam :
260 return CacheCDBEntry(kIDRecoParam ,"TRD/Calib/RecoParam");
261 break;
2745a409 262
263 }
264
265 return 0;
266
63a700c6 267}
268
269//_____________________________________________________________________________
95867fd1 270AliCDBEntry *AliTRDcalibDB::GetCDBEntry(const char *cdbPath)
63a700c6 271{
272 //
273 // Retrieves an entry with path <cdbPath> from the CDB.
274 //
275
95867fd1 276 AliCDBEntry *entry = AliCDBManager::Instance()->Get(cdbPath,fRun);
2745a409 277 if (!entry) {
a7ac01d2 278 AliError(Form("Failed to get entry: %s",cdbPath));
63a700c6 279 return 0;
280 }
281
63a700c6 282 return entry;
2745a409 283
63a700c6 284}
285
286//_____________________________________________________________________________
95867fd1 287const TObject *AliTRDcalibDB::CacheCDBEntry(Int_t id, const char *cdbPath)
63a700c6 288{
289 //
290 // Caches the entry <id> with cdb path <cdbPath>
291 //
292
2745a409 293 if (!fCDBCache[id]) {
63a700c6 294 fCDBEntries[id] = GetCDBEntry(cdbPath);
95867fd1 295 if (fCDBEntries[id]) {
63a700c6 296 fCDBCache[id] = fCDBEntries[id]->GetObject();
95867fd1 297 }
63a700c6 298 }
95867fd1 299
63a700c6 300 return fCDBCache[id];
2745a409 301
63a700c6 302}
303
3551db50 304//_____________________________________________________________________________
305void AliTRDcalibDB::SetRun(Long64_t run)
306{
307 //
7754cd1f 308 // Sets current run number. Calibration data is read from the corresponding file.
3551db50 309 // When the run number changes the caching is invalidated.
310 //
7754cd1f 311
6d50f529 312 if (fRun == run) {
3551db50 313 return;
6d50f529 314 }
7754cd1f 315
3551db50 316 fRun = run;
95867fd1 317
3551db50 318 Invalidate();
2745a409 319
3551db50 320}
7754cd1f 321
3551db50 322//_____________________________________________________________________________
323void AliTRDcalibDB::Invalidate()
324{
325 //
326 // Invalidates cache (when run number is changed).
327 //
328
95867fd1 329 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
2745a409 330 if (fCDBEntries[i]) {
331 if (AliCDBManager::Instance()->GetCacheFlag() == kFALSE) {
11f5dd43 332 if ((fCDBEntries[i]->IsOwner() == kFALSE) &&
333 (fCDBCache[i])) {
e254cad1 334 delete fCDBCache[i];
2745a409 335 }
e254cad1 336 delete fCDBEntries[i];
337 }
3551db50 338 fCDBEntries[i] = 0;
2745a409 339 fCDBCache[i] = 0;
3551db50 340 }
341 }
2745a409 342
df83a620 343}
344//_____________________________________________________________________________
345Float_t AliTRDcalibDB::GetNoise(Int_t det, Int_t col, Int_t row)
346{
347 //
348 // Returns the noise level in ADC counts for the given pad.
349 //
350
351 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
352 (GetCachedCDBObject(kIDNoisePad));
353 if (!calPad) {
354 return -1;
355 }
356
357 AliTRDCalROC *roc = calPad->GetCalROC(det);
358 if (!roc) {
359 return -1;
360 }
361
362 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
363 (GetCachedCDBObject(kIDNoiseChamber));
364 if (!calChamber) {
365 return -1;
366 }
367
368 return calChamber->GetValue(det) * roc->GetValue(col,row);
369
370}
371
372//_____________________________________________________________________________
373AliTRDCalROC *AliTRDcalibDB::GetNoiseROC(Int_t det)
374{
375 //
376 // Returns the Vdrift calibration object for a given ROC
377 // containing one number per pad
378 //
379
380 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
381 (GetCachedCDBObject(kIDNoisePad));
382 if (!calPad) {
383 return 0;
384 }
385
386 AliTRDCalROC *roc = calPad->GetCalROC(det);
387 if (!roc) {
388 return 0;
389 }
390 else {
391 return roc;
392 }
393
394}
395
396//_____________________________________________________________________________
397const AliTRDCalDet *AliTRDcalibDB::GetNoiseDet()
398{
399 //
400 // Returns the Vdrift calibration object
401 // containing one number per detector
402 //
403
404 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
405 (GetCachedCDBObject(kIDNoiseChamber));
406 if (!calChamber) {
407 return 0;
408 }
409 else {
410 return calChamber;
411 }
412
3551db50 413}
414
3551db50 415//_____________________________________________________________________________
416Float_t AliTRDcalibDB::GetVdrift(Int_t det, Int_t col, Int_t row)
417{
418 //
419 // Returns the drift velocity for the given pad.
420 //
7754cd1f 421
95867fd1 422 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
6d50f529 423 (GetCachedCDBObject(kIDVdriftPad));
424 if (!calPad) {
3551db50 425 return -1;
6d50f529 426 }
3551db50 427
95867fd1 428 AliTRDCalROC *roc = calPad->GetCalROC(det);
6d50f529 429 if (!roc) {
3551db50 430 return -1;
6d50f529 431 }
3551db50 432
95867fd1 433 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
6d50f529 434 (GetCachedCDBObject(kIDVdriftChamber));
435 if (!calChamber) {
7754cd1f 436 return -1;
6d50f529 437 }
7754cd1f 438
95867fd1 439 return calChamber->GetValue(det) * roc->GetValue(col,row);
2745a409 440
7754cd1f 441}
afb9f880 442
443//_____________________________________________________________________________
444AliTRDCalROC *AliTRDcalibDB::GetVdriftROC(Int_t det)
445{
446 //
447 // Returns the Vdrift calibration object for a given ROC
448 // containing one number per pad
449 //
450
451 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
452 (GetCachedCDBObject(kIDVdriftPad));
453 if (!calPad) {
454 return 0;
455 }
456
457 AliTRDCalROC *roc = calPad->GetCalROC(det);
458 if (!roc) {
459 return 0;
460 }
461 else {
462 return roc;
463 }
464
465}
466
467//_____________________________________________________________________________
468const AliTRDCalDet *AliTRDcalibDB::GetVdriftDet()
469{
470 //
471 // Returns the Vdrift calibration object
472 // containing one number per detector
473 //
474
475 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
476 (GetCachedCDBObject(kIDVdriftChamber));
477 if (!calChamber) {
478 return 0;
479 }
480 else {
481 return calChamber;
482 }
483
484}
7754cd1f 485
486//_____________________________________________________________________________
487Float_t AliTRDcalibDB::GetVdriftAverage(Int_t det)
488{
489 //
490 // Returns the average drift velocity for the given detector
491 //
492
95867fd1 493 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
6d50f529 494 (GetCachedCDBObject(kIDVdriftChamber));
495 if (!calDet) {
7754cd1f 496 return -1;
6d50f529 497 }
7754cd1f 498
499 return calDet->GetValue(det);
2745a409 500
acba9bad 501}
3551db50 502
503//_____________________________________________________________________________
504Float_t AliTRDcalibDB::GetT0(Int_t det, Int_t col, Int_t row)
505{
506 //
507 // Returns t0 for the given pad.
508 //
509
d4c6453d 510 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
511 (GetCachedCDBObject(kIDT0Pad));
6d50f529 512 if (!calPad) {
3551db50 513 return -1;
6d50f529 514 }
3551db50 515
d4c6453d 516 AliTRDCalROC *roc = calPad->GetCalROC(det);
6d50f529 517 if (!roc) {
3551db50 518 return -1;
6d50f529 519 }
3551db50 520
d4c6453d 521 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
522 (GetCachedCDBObject(kIDT0Chamber));
6d50f529 523 if (!calChamber) {
7754cd1f 524 return -1;
6d50f529 525 }
7754cd1f 526
8d786fb8 527 return calChamber->GetValue(det) + roc->GetValue(col,row);
2745a409 528
7754cd1f 529}
afb9f880 530
56178ff4 531//_____________________________________________________________________________
532AliTRDCalROC *AliTRDcalibDB::GetT0ROC(Int_t det)
533{
534 //
535 // Returns the t0 calibration object for a given ROC
536 // containing one number per pad
537 //
538
539 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
540 (GetCachedCDBObject(kIDT0Pad));
541 if (!calPad) {
542 return 0;
543 }
544
545 AliTRDCalROC *roc = calPad->GetCalROC(det);
546 if (!roc) {
547 return 0;
548 }
549 else {
550 return roc;
551 }
552
553}
554
555//_____________________________________________________________________________
556const AliTRDCalDet *AliTRDcalibDB::GetT0Det()
557{
558 //
559 // Returns the t0 calibration object
560 // containing one number per detector
561 //
562
563 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
564 (GetCachedCDBObject(kIDT0Chamber));
565 if (!calChamber) {
566 return 0;
567 }
568 else {
569 return calChamber;
570 }
571
572}
573
7754cd1f 574//_____________________________________________________________________________
575Float_t AliTRDcalibDB::GetT0Average(Int_t det)
576{
577 //
578 // Returns the average t0 for the given detector
579 //
580
5aba4f09 581 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
582 (GetCachedCDBObject(kIDT0Pad));
583 if (!calPad) {
584 return -1;
585 }
586
587 AliTRDCalROC *roc = calPad->GetCalROC(det);
588 if (!roc) {
589 return -1;
590 }
591
95867fd1 592 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
6d50f529 593 (GetCachedCDBObject(kIDT0Chamber));
594 if (!calDet) {
7754cd1f 595 return -1;
6d50f529 596 }
7754cd1f 597
5aba4f09 598 Double_t mean = 0.0;
599 for (Int_t channel = 0; channel < roc->GetNchannels(); ++channel) {
600 mean += (calDet->GetValue(det) + roc->GetValue(channel)) / roc->GetNchannels();
601 }
602
603 return mean;
2745a409 604
acba9bad 605}
3551db50 606
607//_____________________________________________________________________________
608Float_t AliTRDcalibDB::GetGainFactor(Int_t det, Int_t col, Int_t row)
609{
610 //
611 // Returns the gain factor for the given pad.
612 //
613
95867fd1 614 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
6d50f529 615 (GetCachedCDBObject(kIDGainFactorPad));
616 if (!calPad) {
3551db50 617 return -1;
6d50f529 618 }
3551db50 619
95867fd1 620 AliTRDCalROC *roc = calPad->GetCalROC(det);
56178ff4 621 if (!roc) {
3551db50 622 return -1;
56178ff4 623 }
3551db50 624
95867fd1 625 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
6d50f529 626 (GetCachedCDBObject(kIDGainFactorChamber));
627 if (!calChamber) {
7754cd1f 628 return -1;
6d50f529 629 }
7754cd1f 630
95867fd1 631 return calChamber->GetValue(det) * roc->GetValue(col,row);
2745a409 632
7754cd1f 633}
634
56178ff4 635//_____________________________________________________________________________
636AliTRDCalROC *AliTRDcalibDB::GetGainFactorROC(Int_t det)
637{
638 //
639 // Returns the gain factor calibration object for a given ROC
56178ff4 640 //
641
642 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
643 (GetCachedCDBObject(kIDGainFactorPad));
644 if (!calPad) {
645 return 0;
646 }
647
648 AliTRDCalROC *roc = calPad->GetCalROC(det);
649 if (!roc) {
650 return 0;
651 }
652 else {
653 return roc;
654 }
655
656}
657
658//_____________________________________________________________________________
659const AliTRDCalDet *AliTRDcalibDB::GetGainFactorDet()
660{
661 //
662 // Returns the gain factor calibration object
663 // containing one number per detector
664 //
665
666 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
667 (GetCachedCDBObject(kIDGainFactorChamber));
668 if (!calChamber) {
669 return 0;
670 }
671 else {
672 return calChamber;
673 }
674
675}
676
7754cd1f 677//_____________________________________________________________________________
678Float_t AliTRDcalibDB::GetGainFactorAverage(Int_t det)
679{
680 //
681 // Returns the average gain factor for the given detector
682 //
683
95867fd1 684 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
6d50f529 685 (GetCachedCDBObject(kIDGainFactorChamber));
686 if (!calDet) {
7754cd1f 687 return -1;
6d50f529 688 }
7754cd1f 689
690 return calDet->GetValue(det);
2745a409 691
acba9bad 692}
6a739e92 693
524fc8fa 694//_____________________________________________________________________________
695AliTRDCalROC *AliTRDcalibDB::GetPRFROC(Int_t det)
696{
697 //
698 // Returns the PRF calibration object for a given ROC
699 // containing one number per pad
700 //
701
702 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
703 (GetCachedCDBObject(kIDPRFWidth));
704 if (!calPad) {
705 return 0;
706 }
707
708 AliTRDCalROC *roc = calPad->GetCalROC(det);
709 if (!roc) {
710 return 0;
711 }
712 else {
713 return roc;
714 }
715
716}
717
6a739e92 718//_____________________________________________________________________________
719Float_t AliTRDcalibDB::GetPRFWidth(Int_t det, Int_t col, Int_t row)
720{
721 //
722 // Returns the PRF width for the given pad.
723 //
724
95867fd1 725 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
6d50f529 726 (GetCachedCDBObject(kIDPRFWidth));
727 if (!calPad) {
6a739e92 728 return -1;
6d50f529 729 }
6a739e92 730
95867fd1 731 AliTRDCalROC *roc = calPad->GetCalROC(det);
6d50f529 732 if (!roc) {
6a739e92 733 return -1;
6d50f529 734 }
6a739e92 735
95867fd1 736 return roc->GetValue(col,row);
2745a409 737
acba9bad 738}
3551db50 739
740//_____________________________________________________________________________
741Int_t AliTRDcalibDB::GetNumberOfTimeBins()
742{
743 //
744 // Returns the number of time bins which are read-out.
745 //
7754cd1f 746
aa617684 747 const AliTRDCalFEE *calFEE = dynamic_cast<const AliTRDCalFEE *>
748 (GetCachedCDBObject(kIDFEE));
749 if (!calFEE) {
7754cd1f 750 return -1;
6d50f529 751 }
7754cd1f 752
aa617684 753 return calFEE->GetNumberOfTimeBins();
2745a409 754
3551db50 755}
756
e232d349 757//_____________________________________________________________________________
758Int_t AliTRDcalibDB::GetNumberOfTimeBinsDCS(){
759 //
760 // Returns Number of time bins from the DCS
761 //
762 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
763 if(!dcsArr){
764 return -1;
765 }
766 const AliTRDCalDCS *calDCS = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(1)); // Take EOR
767
768 if(!calDCS){
769 return -1;
770 }
771 return calDCS->GetGlobalNumberOfTimeBins();
772}
773
774//_____________________________________________________________________________
775void AliTRDcalibDB::GetFilterType(TString &filterType){
776 const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS));
777 if(!dcsArr){
778 filterType = "";
779 return;
780 }
781 const AliTRDCalDCS *calDCS = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(1)); // Take EOR
782
783 if(!calDCS){
784 filterType = "";
785 return;
786 }
787 filterType = calDCS->GetGlobalFilterType();
788}
789
7754cd1f 790//_____________________________________________________________________________
791Char_t AliTRDcalibDB::GetPadStatus(Int_t det, Int_t col, Int_t row)
792{
793 //
794 // Returns the status of the given pad
795 //
796
aa617684 797 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
798 (GetCachedCDBObject(kIDPadStatus));
6d50f529 799 if (!cal) {
7754cd1f 800 return -1;
6d50f529 801 }
7754cd1f 802
95867fd1 803 const AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
6d50f529 804 if (!roc) {
7754cd1f 805 return -1;
6d50f529 806 }
7754cd1f 807
95867fd1 808 return roc->GetStatus(col,row);
2745a409 809
7754cd1f 810}
811
0e09df31 812//_____________________________________________________________________________
813AliTRDCalSingleChamberStatus* AliTRDcalibDB::GetPadStatusROC(Int_t det)
814{
815 //
816 // Returns the pad status calibration object for a given ROC
817 //
818
819 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
820 (GetCachedCDBObject(kIDPadStatus));
821 if (!cal) {
822 return 0;
823 }
824
825 AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
826 if (!roc) {
827 return 0;
828 }
829 else {
830 return roc;
831 }
832
833}
834
7754cd1f 835//_____________________________________________________________________________
836Char_t AliTRDcalibDB::GetChamberStatus(Int_t det)
837{
838 //
839 // Returns the status of the given chamber
840 //
841
95867fd1 842 const AliTRDCalChamberStatus *cal = dynamic_cast<const AliTRDCalChamberStatus *>
6d50f529 843 (GetCachedCDBObject(kIDChamberStatus));
844 if (!cal) {
7754cd1f 845 return -1;
6d50f529 846 }
7754cd1f 847
848 return cal->GetStatus(det);
2745a409 849
7754cd1f 850}
851
a7ac01d2 852//_____________________________________________________________________________
853AliTRDrecoParam* AliTRDcalibDB::GetRecoParam(Int_t */*eventtype*/)
854{
be28462a 855 //
856 // Returns the TRD reconstruction parameters from the OCDB
857 //
858
a7ac01d2 859 const TClonesArray *recos = dynamic_cast<const TClonesArray*>(GetCachedCDBObject(kIDRecoParam));
be28462a 860 if (!recos) return 0x0;
a7ac01d2 861
862 // calculate entry based on event type info
863 Int_t n = 0; //f(eventtype[0], eventtype[1], ....)
be28462a 864
a7ac01d2 865 return (AliTRDrecoParam*)recos->UncheckedAt(n);
a7ac01d2 866
be28462a 867}
a7ac01d2 868
7754cd1f 869//_____________________________________________________________________________
870Bool_t AliTRDcalibDB::IsPadMasked(Int_t det, Int_t col, Int_t row)
871{
872 //
873 // Returns status, see name of functions for details ;-)
874 //
875
95867fd1 876 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
877 (GetCachedCDBObject(kIDPadStatus));
6d50f529 878 if (!cal) {
7754cd1f 879 return -1;
6d50f529 880 }
7754cd1f 881
95867fd1 882 return cal->IsMasked(det,col,row);
2745a409 883
7754cd1f 884}
885
886//_____________________________________________________________________________
887Bool_t AliTRDcalibDB::IsPadBridgedLeft(Int_t det, Int_t col, Int_t row)
888{
889 //
890 // Returns status, see name of functions for details ;-)
891 //
892
95867fd1 893 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
894 (GetCachedCDBObject(kIDPadStatus));
6d50f529 895 if (!cal) {
7754cd1f 896 return -1;
6d50f529 897 }
7754cd1f 898
95867fd1 899 return cal->IsBridgedLeft(det,col,row);
2745a409 900
7754cd1f 901}
902
903//_____________________________________________________________________________
904Bool_t AliTRDcalibDB::IsPadBridgedRight(Int_t det, Int_t col, Int_t row)
905{
906 //
907 // Returns status, see name of functions for details ;-)
908 //
909
95867fd1 910 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
911 (GetCachedCDBObject(kIDPadStatus));
6d50f529 912 if (!cal) {
7754cd1f 913 return -1;
6d50f529 914 }
7754cd1f 915
95867fd1 916 return cal->IsBridgedRight(det,col,row);
2745a409 917
7754cd1f 918}
919
fa7427d0 920//_____________________________________________________________________________
921Bool_t AliTRDcalibDB::IsPadNotConnected(Int_t det, Int_t col, Int_t row)
922{
923 //
924 // Returns status, see name of functions for details ;-)
925 //
926 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
927 (GetCachedCDBObject(kIDPadStatus));
928 if (!cal) {
929 return -1;
930 }
931
932 return cal->IsNotConnected(det,col,row);
933
934}
935
7754cd1f 936//_____________________________________________________________________________
937Bool_t AliTRDcalibDB::IsChamberInstalled(Int_t det)
938{
939 //
940 // Returns status, see name of functions for details ;-)
941 //
942
95867fd1 943 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
944 (GetCachedCDBObject(kIDChamberStatus));
6d50f529 945 if (!cal) {
7754cd1f 946 return -1;
6d50f529 947 }
7754cd1f 948
949 return cal->IsInstalled(det);
2745a409 950
7754cd1f 951}
952
953//_____________________________________________________________________________
954Bool_t AliTRDcalibDB::IsChamberMasked(Int_t det)
955{
956 //
957 // Returns status, see name of functions for details ;-)
958 //
959
95867fd1 960 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
961 (GetCachedCDBObject(kIDChamberStatus));
6d50f529 962 if (!cal) {
7754cd1f 963 return -1;
6d50f529 964 }
7754cd1f 965
966 return cal->IsMasked(det);
2745a409 967
7754cd1f 968}
969
cc7cef99 970//_____________________________________________________________________________
0d83b3a5 971const AliTRDCalPID *AliTRDcalibDB::GetPIDObject(AliTRDpidUtil::ETRDPIDMethod method)
cc7cef99 972{
973 //
974 // Returns the object storing the distributions for PID with likelihood
975 //
9a96f175 976
977 switch(method) {
0d83b3a5 978 case AliTRDpidUtil::kLQ:
4ba1d6ae 979 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDLQ));
0d83b3a5 980 case AliTRDpidUtil::kNN:
4ba1d6ae 981 return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDNN));
543691ea 982 case AliTRDpidUtil::kESD:
983 return 0x0; // To avoid compiler warnings
9a96f175 984 }
985
10f75631 986 return 0x0;
2745a409 987
cc7cef99 988}
989
7754cd1f 990//_____________________________________________________________________________
d4c6453d 991const AliTRDCalMonitoring *AliTRDcalibDB::GetMonitoringObject()
7754cd1f 992{
993 //
994 // Returns the object storing the monitoring data
995 //
996
d4c6453d 997 return dynamic_cast<const AliTRDCalMonitoring *>
998 (GetCachedCDBObject(kIDMonitoringData));
1b95a37b 999
7754cd1f 1000}
1001
6a739e92 1002//_____________________________________________________________________________
1003void AliTRDcalibDB::SamplePRF()
1004{
1005 //
2745a409 1006 // Samples the pad response function (should maybe go somewhere else ...)
6a739e92 1007 //
1008
1009 const Int_t kPRFbin = 61;
1010
053767a4 1011 Float_t prf[kNlayer][kPRFbin] = {
6d50f529 1012 {2.9037e-02, 3.3608e-02, 3.9020e-02, 4.5292e-02,
6a739e92 1013 5.2694e-02, 6.1362e-02, 7.1461e-02, 8.3362e-02,
1014 9.7063e-02, 1.1307e-01, 1.3140e-01, 1.5235e-01,
1015 1.7623e-01, 2.0290e-01, 2.3294e-01, 2.6586e-01,
1016 3.0177e-01, 3.4028e-01, 3.8077e-01, 4.2267e-01,
1017 4.6493e-01, 5.0657e-01, 5.4655e-01, 5.8397e-01,
1018 6.1767e-01, 6.4744e-01, 6.7212e-01, 6.9188e-01,
1019 7.0627e-01, 7.1499e-01, 7.1851e-01, 7.1499e-01,
1020 7.0627e-01, 6.9188e-01, 6.7212e-01, 6.4744e-01,
1021 6.1767e-01, 5.8397e-01, 5.4655e-01, 5.0657e-01,
1022 4.6493e-01, 4.2267e-01, 3.8077e-01, 3.4028e-01,
1023 3.0177e-01, 2.6586e-01, 2.3294e-01, 2.0290e-01,
1024 1.7623e-01, 1.5235e-01, 1.3140e-01, 1.1307e-01,
1025 9.7063e-02, 8.3362e-02, 7.1461e-02, 6.1362e-02,
1026 5.2694e-02, 4.5292e-02, 3.9020e-02, 3.3608e-02,
1027 2.9037e-02},
1028 {2.5478e-02, 2.9695e-02, 3.4655e-02, 4.0454e-02,
1029 4.7342e-02, 5.5487e-02, 6.5038e-02, 7.6378e-02,
1030 8.9696e-02, 1.0516e-01, 1.2327e-01, 1.4415e-01,
1031 1.6794e-01, 1.9516e-01, 2.2573e-01, 2.5959e-01,
1032 2.9694e-01, 3.3719e-01, 3.7978e-01, 4.2407e-01,
1033 4.6889e-01, 5.1322e-01, 5.5569e-01, 5.9535e-01,
1034 6.3141e-01, 6.6259e-01, 6.8882e-01, 7.0983e-01,
1035 7.2471e-01, 7.3398e-01, 7.3761e-01, 7.3398e-01,
1036 7.2471e-01, 7.0983e-01, 6.8882e-01, 6.6259e-01,
1037 6.3141e-01, 5.9535e-01, 5.5569e-01, 5.1322e-01,
1038 4.6889e-01, 4.2407e-01, 3.7978e-01, 3.3719e-01,
1039 2.9694e-01, 2.5959e-01, 2.2573e-01, 1.9516e-01,
1040 1.6794e-01, 1.4415e-01, 1.2327e-01, 1.0516e-01,
1041 8.9696e-02, 7.6378e-02, 6.5038e-02, 5.5487e-02,
1042 4.7342e-02, 4.0454e-02, 3.4655e-02, 2.9695e-02,
1043 2.5478e-02},
1044 {2.2363e-02, 2.6233e-02, 3.0782e-02, 3.6140e-02,
1045 4.2535e-02, 5.0157e-02, 5.9197e-02, 6.9900e-02,
1046 8.2707e-02, 9.7811e-02, 1.1548e-01, 1.3601e-01,
1047 1.5998e-01, 1.8739e-01, 2.1840e-01, 2.5318e-01,
1048 2.9182e-01, 3.3373e-01, 3.7837e-01, 4.2498e-01,
1049 4.7235e-01, 5.1918e-01, 5.6426e-01, 6.0621e-01,
1050 6.4399e-01, 6.7700e-01, 7.0472e-01, 7.2637e-01,
1051 7.4206e-01, 7.5179e-01, 7.5551e-01, 7.5179e-01,
1052 7.4206e-01, 7.2637e-01, 7.0472e-01, 6.7700e-01,
1053 6.4399e-01, 6.0621e-01, 5.6426e-01, 5.1918e-01,
1054 4.7235e-01, 4.2498e-01, 3.7837e-01, 3.3373e-01,
1055 2.9182e-01, 2.5318e-01, 2.1840e-01, 1.8739e-01,
1056 1.5998e-01, 1.3601e-01, 1.1548e-01, 9.7811e-02,
1057 8.2707e-02, 6.9900e-02, 5.9197e-02, 5.0157e-02,
1058 4.2535e-02, 3.6140e-02, 3.0782e-02, 2.6233e-02,
1059 2.2363e-02},
1060 {1.9635e-02, 2.3167e-02, 2.7343e-02, 3.2293e-02,
1061 3.8224e-02, 4.5335e-02, 5.3849e-02, 6.4039e-02,
1062 7.6210e-02, 9.0739e-02, 1.0805e-01, 1.2841e-01,
1063 1.5216e-01, 1.7960e-01, 2.1099e-01, 2.4671e-01,
1064 2.8647e-01, 3.2996e-01, 3.7660e-01, 4.2547e-01,
1065 4.7536e-01, 5.2473e-01, 5.7215e-01, 6.1632e-01,
1066 6.5616e-01, 6.9075e-01, 7.1939e-01, 7.4199e-01,
1067 7.5838e-01, 7.6848e-01, 7.7227e-01, 7.6848e-01,
1068 7.5838e-01, 7.4199e-01, 7.1939e-01, 6.9075e-01,
1069 6.5616e-01, 6.1632e-01, 5.7215e-01, 5.2473e-01,
1070 4.7536e-01, 4.2547e-01, 3.7660e-01, 3.2996e-01,
1071 2.8647e-01, 2.4671e-01, 2.1099e-01, 1.7960e-01,
1072 1.5216e-01, 1.2841e-01, 1.0805e-01, 9.0739e-02,
1073 7.6210e-02, 6.4039e-02, 5.3849e-02, 4.5335e-02,
1074 3.8224e-02, 3.2293e-02, 2.7343e-02, 2.3167e-02,
1075 1.9635e-02},
1076 {1.7224e-02, 2.0450e-02, 2.4286e-02, 2.8860e-02,
1077 3.4357e-02, 4.0979e-02, 4.8966e-02, 5.8612e-02,
1078 7.0253e-02, 8.4257e-02, 1.0102e-01, 1.2094e-01,
1079 1.4442e-01, 1.7196e-01, 2.0381e-01, 2.4013e-01,
1080 2.8093e-01, 3.2594e-01, 3.7450e-01, 4.2563e-01,
1081 4.7796e-01, 5.2991e-01, 5.7974e-01, 6.2599e-01,
1082 6.6750e-01, 7.0344e-01, 7.3329e-01, 7.5676e-01,
1083 7.7371e-01, 7.8410e-01, 7.8793e-01, 7.8410e-01,
1084 7.7371e-01, 7.5676e-01, 7.3329e-01, 7.0344e-01,
1085 6.6750e-01, 6.2599e-01, 5.7974e-01, 5.2991e-01,
1086 4.7796e-01, 4.2563e-01, 3.7450e-01, 3.2594e-01,
1087 2.8093e-01, 2.4013e-01, 2.0381e-01, 1.7196e-01,
1088 1.4442e-01, 1.2094e-01, 1.0102e-01, 8.4257e-02,
1089 7.0253e-02, 5.8612e-02, 4.8966e-02, 4.0979e-02,
1090 3.4357e-02, 2.8860e-02, 2.4286e-02, 2.0450e-02,
1091 1.7224e-02},
1092 {1.5096e-02, 1.8041e-02, 2.1566e-02, 2.5793e-02,
1093 3.0886e-02, 3.7044e-02, 4.4515e-02, 5.3604e-02,
1094 6.4668e-02, 7.8109e-02, 9.4364e-02, 1.1389e-01,
1095 1.3716e-01, 1.6461e-01, 1.9663e-01, 2.3350e-01,
1096 2.7527e-01, 3.2170e-01, 3.7214e-01, 4.2549e-01,
1097 4.8024e-01, 5.3460e-01, 5.8677e-01, 6.3512e-01,
1098 6.7838e-01, 7.1569e-01, 7.4655e-01, 7.7071e-01,
1099 7.8810e-01, 7.9871e-01, 8.0255e-01, 7.9871e-01,
1100 7.8810e-01, 7.7071e-01, 7.4655e-01, 7.1569e-01,
1101 6.7838e-01, 6.3512e-01, 5.8677e-01, 5.3460e-01,
1102 4.8024e-01, 4.2549e-01, 3.7214e-01, 3.2170e-01,
1103 2.7527e-01, 2.3350e-01, 1.9663e-01, 1.6461e-01,
1104 1.3716e-01, 1.1389e-01, 9.4364e-02, 7.8109e-02,
1105 6.4668e-02, 5.3604e-02, 4.4515e-02, 3.7044e-02,
1106 3.0886e-02, 2.5793e-02, 2.1566e-02, 1.8041e-02,
1107 1.5096e-02}};
1108
1109 // More sampling precision with linear interpolation
6d50f529 1110 fPRFlo = -1.5;
1111 fPRFhi = 1.5;
6a739e92 1112 Float_t pad[kPRFbin];
1113 Int_t sPRFbin = kPRFbin;
6d50f529 1114 Float_t sPRFwid = (fPRFhi - fPRFlo) / ((Float_t) sPRFbin);
6a739e92 1115 for (Int_t iPad = 0; iPad < sPRFbin; iPad++) {
6d50f529 1116 pad[iPad] = ((Float_t) iPad + 0.5) * sPRFwid + fPRFlo;
6a739e92 1117 }
6d50f529 1118 fPRFbin = 500;
1119 fPRFwid = (fPRFhi - fPRFlo) / ((Float_t) fPRFbin);
1120 fPRFpad = ((Int_t) (1.0 / fPRFwid));
6a739e92 1121
6d50f529 1122 if (fPRFsmp) delete [] fPRFsmp;
053767a4 1123 fPRFsmp = new Float_t[kNlayer*fPRFbin];
6a739e92 1124
1125 Int_t ipos1;
1126 Int_t ipos2;
1127 Float_t diff;
1128
053767a4 1129 for (Int_t iLayer = 0; iLayer < kNlayer; iLayer++) {
6a739e92 1130
6d50f529 1131 for (Int_t iBin = 0; iBin < fPRFbin; iBin++) {
6a739e92 1132
6d50f529 1133 Float_t bin = (((Float_t) iBin) + 0.5) * fPRFwid + fPRFlo;
6a739e92 1134 ipos1 = ipos2 = 0;
1135 diff = 0;
1136 do {
1137 diff = bin - pad[ipos2++];
1138 } while ((diff > 0) && (ipos2 < kPRFbin));
1139 if (ipos2 == kPRFbin) {
053767a4 1140 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
6a739e92 1141 }
1142 else if (ipos2 == 1) {
053767a4 1143 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1];
6a739e92 1144 }
1145 else {
1146 ipos2--;
1147 if (ipos2 >= kPRFbin) ipos2 = kPRFbin - 1;
1148 ipos1 = ipos2 - 1;
053767a4 1149 fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2]
1150 + diff * (prf[iLayer][ipos2] - prf[iLayer][ipos1])
1151 / sPRFwid;
6a739e92 1152 }
1153
1154 }
1155 }
1156
1157}
1158
1159//_____________________________________________________________________________
1160Int_t AliTRDcalibDB::PadResponse(Double_t signal, Double_t dist
eb52b657 1161 , Int_t layer, Double_t *pad) const
6a739e92 1162{
1163 //
1164 // Applies the pad response
56178ff4 1165 // So far this is the fixed parametrization and should be replaced by
1166 // something dependent on calibration values
6a739e92 1167 //
1168
eb52b657 1169 Int_t iBin = ((Int_t) ((-dist - fPRFlo) / fPRFwid));
053767a4 1170 Int_t iOff = layer * fPRFbin;
6a739e92 1171
6d50f529 1172 Int_t iBin0 = iBin - fPRFpad + iOff;
6a739e92 1173 Int_t iBin1 = iBin + iOff;
6d50f529 1174 Int_t iBin2 = iBin + fPRFpad + iOff;
6a739e92 1175
1176 pad[0] = 0.0;
1177 pad[1] = 0.0;
1178 pad[2] = 0.0;
053767a4 1179 if ((iBin1 >= 0) && (iBin1 < (fPRFbin*kNlayer))) {
6a739e92 1180
1181 if (iBin0 >= 0) {
6d50f529 1182 pad[0] = signal * fPRFsmp[iBin0];
6a739e92 1183 }
6d50f529 1184 pad[1] = signal * fPRFsmp[iBin1];
053767a4 1185 if (iBin2 < (fPRFbin*kNlayer)) {
6d50f529 1186 pad[2] = signal * fPRFsmp[iBin2];
6a739e92 1187 }
1188
1189 return 1;
1190
1191 }
1192 else {
1193
1194 return 0;
1195
1196 }
ab0a4106 1197
3551db50 1198}
543691ea 1199