]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDcalibDB.cxx
Updated ideal geometry, including ACORDE
[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
090026bf 31#include <TMath.h>
3551db50 32#include <TRandom.h>
33
2745a409 34#include "AliCDBManager.h"
35#include "AliCDBStorage.h"
36#include "AliCDBEntry.h"
37#include "AliLog.h"
3551db50 38
39#include "AliTRDcalibDB.h"
40#include "AliTRDgeometry.h"
41#include "AliTRDpadPlane.h"
42#include "AliTRDCommonParam.h"
43
7754cd1f 44#include "Cal/AliTRDCalROC.h"
7754cd1f 45#include "Cal/AliTRDCalPad.h"
46#include "Cal/AliTRDCalDet.h"
aa617684 47#include "Cal/AliTRDCalFEE.h"
720a0a16 48#include "Cal/AliTRDCalPID.h"
7754cd1f 49#include "Cal/AliTRDCalMonitoring.h"
7754cd1f 50#include "Cal/AliTRDCalChamberStatus.h"
7754cd1f 51#include "Cal/AliTRDCalPadStatus.h"
52#include "Cal/AliTRDCalSingleChamberStatus.h"
3551db50 53
54ClassImp(AliTRDcalibDB)
55
2745a409 56AliTRDcalibDB *AliTRDcalibDB::fgInstance = 0;
57Bool_t AliTRDcalibDB::fgTerminated = kFALSE;
3551db50 58
59//_ singleton implementation __________________________________________________
60AliTRDcalibDB* AliTRDcalibDB::Instance()
61{
62 //
63 // Singleton implementation
64 // Returns an instance of this class, it is created if neccessary
63a700c6 65 //
3551db50 66
6d50f529 67 if (fgTerminated != kFALSE) {
3551db50 68 return 0;
6d50f529 69 }
3551db50 70
6d50f529 71 if (fgInstance == 0) {
3551db50 72 fgInstance = new AliTRDcalibDB();
6d50f529 73 }
e254cad1 74
3551db50 75 return fgInstance;
4e009ce4 76
3551db50 77}
78
2745a409 79//_____________________________________________________________________________
3551db50 80void AliTRDcalibDB::Terminate()
81{
82 //
83 // Singleton implementation
6bf5f0ce 84 // Deletes the instance of this class and sets the terminated flag,
85 // instances cannot be requested anymore
3551db50 86 // This function can be called several times.
87 //
88
89 fgTerminated = kTRUE;
90
6d50f529 91 if (fgInstance != 0) {
3551db50 92 delete fgInstance;
93 fgInstance = 0;
94 }
2745a409 95
3551db50 96}
97
98//_____________________________________________________________________________
99AliTRDcalibDB::AliTRDcalibDB()
2745a409 100 :TObject()
101 ,fRun(-1)
6d50f529 102 ,fPRFsmp(0)
103 ,fPRFbin(0)
104 ,fPRFlo(0)
105 ,fPRFhi(0)
106 ,fPRFwid(0)
107 ,fPRFpad(0)
3551db50 108{
109 //
2745a409 110 // Default constructor
3551db50 111 //
2745a409 112 // TODO Default runnumber is set to 0, this should be changed later
113 // to an invalid value (e.g. -1) to prevent
3551db50 114 // TODO invalid calibration data to be used.
2745a409 115 //
116
95867fd1 117 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
2745a409 118 fCDBCache[i] = 0;
119 fCDBEntries[i] = 0;
120 }
3551db50 121
2745a409 122 // Create the sampled PRF
123 SamplePRF();
d4c6453d 124
2745a409 125}
126
127//_____________________________________________________________________________
128AliTRDcalibDB::AliTRDcalibDB(const AliTRDcalibDB &c)
129 :TObject(c)
6d50f529 130 ,fRun(-1)
131 ,fPRFsmp(0)
132 ,fPRFbin(0)
133 ,fPRFlo(0)
134 ,fPRFhi(0)
135 ,fPRFwid(0)
136 ,fPRFpad(0)
2745a409 137{
138 //
139 // Copy constructor (not that it make any sense for a singleton...)
140 //
141
95867fd1 142 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
2745a409 143 fCDBCache[i] = 0;
3551db50 144 fCDBEntries[i] = 0;
145 }
6a739e92 146
147 // Create the sampled PRF
148 SamplePRF();
2745a409 149
150}
151
152//_____________________________________________________________________________
153AliTRDcalibDB &AliTRDcalibDB::operator=(const AliTRDcalibDB &c)
154{
155 //
156 // Assignment operator (same as above ...)
157 //
158
159 if (this != &c) {
160 AliFatal("No assignment operator defined");
161 }
4e009ce4 162
2745a409 163 return *this;
164
acba9bad 165}
3551db50 166
167//_____________________________________________________________________________
168AliTRDcalibDB::~AliTRDcalibDB()
169{
170 //
171 // destructor
172 //
173
6d50f529 174 if (fPRFsmp) {
175 delete [] fPRFsmp;
176 fPRFsmp = 0;
6a739e92 177 }
178
3551db50 179 Invalidate();
2745a409 180
acba9bad 181}
3551db50 182
63a700c6 183//_caching functions____________________________________________________________
95867fd1 184const TObject *AliTRDcalibDB::GetCachedCDBObject(Int_t id)
63a700c6 185{
2745a409 186 //
187 // Retrieves a cdb object with the given id. The objects are cached as
188 // long as the run number is not changed.
189 //
190 // Put together the available objects here by using the lines
191 // a) For usual calibration objects:
192 // case kID<Name> :
193 // return CacheCDBEntry(kID<Name>,"TRD/Calib/<Path>");
194 // break;
195 // See function CacheCDBEntry for details.
196 // and
197 // b) For calibration data which depends on two objects: One containing
198 // a value per detector and one the local fluctuations per pad:
199 // case kID<Name> :
200 // return CacheMergeCDBEntry(kID<Name>,"TRD/Calib/<padPath>","TRD/Calib/<chamberPath>");
201 // break;
202 // See function CacheMergeCDBEntry for details.
203 //
63a700c6 204
6d50f529 205 switch (id) {
2745a409 206
207 // Parameters defined per pad and chamber
208 case kIDVdriftPad :
6d50f529 209 return CacheCDBEntry(kIDVdriftPad ,"TRD/Calib/LocalVdrift");
2745a409 210 break;
211 case kIDVdriftChamber :
6d50f529 212 return CacheCDBEntry(kIDVdriftChamber ,"TRD/Calib/ChamberVdrift");
2745a409 213 break;
214 case kIDT0Pad :
6d50f529 215 return CacheCDBEntry(kIDT0Pad ,"TRD/Calib/LocalT0");
2745a409 216 break;
217 case kIDT0Chamber :
6d50f529 218 return CacheCDBEntry(kIDT0Chamber ,"TRD/Calib/ChamberT0");
2745a409 219 break;
220 case kIDGainFactorPad :
6d50f529 221 return CacheCDBEntry(kIDGainFactorPad ,"TRD/Calib/LocalGainFactor");
2745a409 222 break;
223 case kIDGainFactorChamber :
6d50f529 224 return CacheCDBEntry(kIDGainFactorChamber ,"TRD/Calib/ChamberGainFactor");
2745a409 225 break;
226
227 // Parameters defined per pad
228 case kIDPRFWidth :
6d50f529 229 return CacheCDBEntry(kIDPRFWidth ,"TRD/Calib/PRFWidth");
2745a409 230 break;
231
232 // Status values
2745a409 233 case kIDChamberStatus :
6d50f529 234 return CacheCDBEntry(kIDChamberStatus ,"TRD/Calib/ChamberStatus");
2745a409 235 break;
2745a409 236 case kIDPadStatus :
6d50f529 237 return CacheCDBEntry(kIDPadStatus ,"TRD/Calib/PadStatus");
2745a409 238 break;
239
240 // Global parameters
241 case kIDMonitoringData :
6d50f529 242 return CacheCDBEntry(kIDMonitoringData ,"TRD/Calib/MonitoringData");
2745a409 243 break;
aa617684 244 case kIDFEE :
245 return CacheCDBEntry(kIDFEE ,"TRD/Calib/FEE");
2745a409 246 break;
44dbae42 247 case kIDPIDNN :
248 return CacheCDBEntry(kIDPIDNN ,"TRD/Calib/PIDNN");
2745a409 249 case kIDPIDLQ :
6d50f529 250 return CacheCDBEntry(kIDPIDLQ ,"TRD/Calib/PIDLQ");
2745a409 251 break;
252
253 }
254
255 return 0;
256
63a700c6 257}
258
259//_____________________________________________________________________________
95867fd1 260AliCDBEntry *AliTRDcalibDB::GetCDBEntry(const char *cdbPath)
63a700c6 261{
262 //
263 // Retrieves an entry with path <cdbPath> from the CDB.
264 //
265
95867fd1 266 AliCDBEntry *entry = AliCDBManager::Instance()->Get(cdbPath,fRun);
2745a409 267 if (!entry) {
4fad09c9 268 AliFatal(Form("Failed to get entry: %s",cdbPath));
63a700c6 269 return 0;
270 }
271
63a700c6 272 return entry;
2745a409 273
63a700c6 274}
275
276//_____________________________________________________________________________
95867fd1 277const TObject *AliTRDcalibDB::CacheCDBEntry(Int_t id, const char *cdbPath)
63a700c6 278{
279 //
280 // Caches the entry <id> with cdb path <cdbPath>
281 //
282
2745a409 283 if (!fCDBCache[id]) {
63a700c6 284 fCDBEntries[id] = GetCDBEntry(cdbPath);
95867fd1 285 if (fCDBEntries[id]) {
63a700c6 286 fCDBCache[id] = fCDBEntries[id]->GetObject();
95867fd1 287 }
63a700c6 288 }
95867fd1 289
63a700c6 290 return fCDBCache[id];
2745a409 291
63a700c6 292}
293
3551db50 294//_____________________________________________________________________________
295void AliTRDcalibDB::SetRun(Long64_t run)
296{
297 //
7754cd1f 298 // Sets current run number. Calibration data is read from the corresponding file.
3551db50 299 // When the run number changes the caching is invalidated.
300 //
7754cd1f 301
6d50f529 302 if (fRun == run) {
3551db50 303 return;
6d50f529 304 }
7754cd1f 305
3551db50 306 fRun = run;
95867fd1 307
3551db50 308 Invalidate();
2745a409 309
3551db50 310}
7754cd1f 311
3551db50 312//_____________________________________________________________________________
313void AliTRDcalibDB::Invalidate()
314{
315 //
316 // Invalidates cache (when run number is changed).
317 //
318
95867fd1 319 for (Int_t i = 0; i < kCDBCacheSize; ++i) {
2745a409 320 if (fCDBEntries[i]) {
321 if (AliCDBManager::Instance()->GetCacheFlag() == kFALSE) {
11f5dd43 322 if ((fCDBEntries[i]->IsOwner() == kFALSE) &&
323 (fCDBCache[i])) {
e254cad1 324 delete fCDBCache[i];
2745a409 325 }
e254cad1 326 delete fCDBEntries[i];
327 }
3551db50 328 fCDBEntries[i] = 0;
2745a409 329 fCDBCache[i] = 0;
3551db50 330 }
331 }
2745a409 332
3551db50 333}
334
3551db50 335//_____________________________________________________________________________
336Float_t AliTRDcalibDB::GetVdrift(Int_t det, Int_t col, Int_t row)
337{
338 //
339 // Returns the drift velocity for the given pad.
340 //
7754cd1f 341
95867fd1 342 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
6d50f529 343 (GetCachedCDBObject(kIDVdriftPad));
344 if (!calPad) {
3551db50 345 return -1;
6d50f529 346 }
3551db50 347
95867fd1 348 AliTRDCalROC *roc = calPad->GetCalROC(det);
6d50f529 349 if (!roc) {
3551db50 350 return -1;
6d50f529 351 }
3551db50 352
95867fd1 353 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
6d50f529 354 (GetCachedCDBObject(kIDVdriftChamber));
355 if (!calChamber) {
7754cd1f 356 return -1;
6d50f529 357 }
7754cd1f 358
95867fd1 359 return calChamber->GetValue(det) * roc->GetValue(col,row);
2745a409 360
7754cd1f 361}
afb9f880 362
363//_____________________________________________________________________________
364AliTRDCalROC *AliTRDcalibDB::GetVdriftROC(Int_t det)
365{
366 //
367 // Returns the Vdrift calibration object for a given ROC
368 // containing one number per pad
369 //
370
371 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
372 (GetCachedCDBObject(kIDVdriftPad));
373 if (!calPad) {
374 return 0;
375 }
376
377 AliTRDCalROC *roc = calPad->GetCalROC(det);
378 if (!roc) {
379 return 0;
380 }
381 else {
382 return roc;
383 }
384
385}
386
387//_____________________________________________________________________________
388const AliTRDCalDet *AliTRDcalibDB::GetVdriftDet()
389{
390 //
391 // Returns the Vdrift calibration object
392 // containing one number per detector
393 //
394
395 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
396 (GetCachedCDBObject(kIDVdriftChamber));
397 if (!calChamber) {
398 return 0;
399 }
400 else {
401 return calChamber;
402 }
403
404}
7754cd1f 405
406//_____________________________________________________________________________
407Float_t AliTRDcalibDB::GetVdriftAverage(Int_t det)
408{
409 //
410 // Returns the average drift velocity for the given detector
411 //
412
95867fd1 413 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
6d50f529 414 (GetCachedCDBObject(kIDVdriftChamber));
415 if (!calDet) {
7754cd1f 416 return -1;
6d50f529 417 }
7754cd1f 418
419 return calDet->GetValue(det);
2745a409 420
acba9bad 421}
3551db50 422
423//_____________________________________________________________________________
424Float_t AliTRDcalibDB::GetT0(Int_t det, Int_t col, Int_t row)
425{
426 //
427 // Returns t0 for the given pad.
428 //
429
d4c6453d 430 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
431 (GetCachedCDBObject(kIDT0Pad));
6d50f529 432 if (!calPad) {
3551db50 433 return -1;
6d50f529 434 }
3551db50 435
d4c6453d 436 AliTRDCalROC *roc = calPad->GetCalROC(det);
6d50f529 437 if (!roc) {
3551db50 438 return -1;
6d50f529 439 }
3551db50 440
d4c6453d 441 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
442 (GetCachedCDBObject(kIDT0Chamber));
6d50f529 443 if (!calChamber) {
7754cd1f 444 return -1;
6d50f529 445 }
7754cd1f 446
8d786fb8 447 return calChamber->GetValue(det) + roc->GetValue(col,row);
2745a409 448
7754cd1f 449}
afb9f880 450
56178ff4 451//_____________________________________________________________________________
452AliTRDCalROC *AliTRDcalibDB::GetT0ROC(Int_t det)
453{
454 //
455 // Returns the t0 calibration object for a given ROC
456 // containing one number per pad
457 //
458
459 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
460 (GetCachedCDBObject(kIDT0Pad));
461 if (!calPad) {
462 return 0;
463 }
464
465 AliTRDCalROC *roc = calPad->GetCalROC(det);
466 if (!roc) {
467 return 0;
468 }
469 else {
470 return roc;
471 }
472
473}
474
475//_____________________________________________________________________________
476const AliTRDCalDet *AliTRDcalibDB::GetT0Det()
477{
478 //
479 // Returns the t0 calibration object
480 // containing one number per detector
481 //
482
483 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
484 (GetCachedCDBObject(kIDT0Chamber));
485 if (!calChamber) {
486 return 0;
487 }
488 else {
489 return calChamber;
490 }
491
492}
493
7754cd1f 494//_____________________________________________________________________________
495Float_t AliTRDcalibDB::GetT0Average(Int_t det)
496{
497 //
498 // Returns the average t0 for the given detector
499 //
500
5aba4f09 501 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
502 (GetCachedCDBObject(kIDT0Pad));
503 if (!calPad) {
504 return -1;
505 }
506
507 AliTRDCalROC *roc = calPad->GetCalROC(det);
508 if (!roc) {
509 return -1;
510 }
511
95867fd1 512 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
6d50f529 513 (GetCachedCDBObject(kIDT0Chamber));
514 if (!calDet) {
7754cd1f 515 return -1;
6d50f529 516 }
7754cd1f 517
5aba4f09 518 Double_t mean = 0.0;
519 for (Int_t channel = 0; channel < roc->GetNchannels(); ++channel) {
520 mean += (calDet->GetValue(det) + roc->GetValue(channel)) / roc->GetNchannels();
521 }
522
523 return mean;
2745a409 524
acba9bad 525}
3551db50 526
527//_____________________________________________________________________________
528Float_t AliTRDcalibDB::GetGainFactor(Int_t det, Int_t col, Int_t row)
529{
530 //
531 // Returns the gain factor for the given pad.
532 //
533
95867fd1 534 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
6d50f529 535 (GetCachedCDBObject(kIDGainFactorPad));
536 if (!calPad) {
3551db50 537 return -1;
6d50f529 538 }
3551db50 539
95867fd1 540 AliTRDCalROC *roc = calPad->GetCalROC(det);
56178ff4 541 if (!roc) {
3551db50 542 return -1;
56178ff4 543 }
3551db50 544
95867fd1 545 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
6d50f529 546 (GetCachedCDBObject(kIDGainFactorChamber));
547 if (!calChamber) {
7754cd1f 548 return -1;
6d50f529 549 }
7754cd1f 550
95867fd1 551 return calChamber->GetValue(det) * roc->GetValue(col,row);
2745a409 552
7754cd1f 553}
554
56178ff4 555//_____________________________________________________________________________
556AliTRDCalROC *AliTRDcalibDB::GetGainFactorROC(Int_t det)
557{
558 //
559 // Returns the gain factor calibration object for a given ROC
56178ff4 560 //
561
562 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
563 (GetCachedCDBObject(kIDGainFactorPad));
564 if (!calPad) {
565 return 0;
566 }
567
568 AliTRDCalROC *roc = calPad->GetCalROC(det);
569 if (!roc) {
570 return 0;
571 }
572 else {
573 return roc;
574 }
575
576}
577
578//_____________________________________________________________________________
579const AliTRDCalDet *AliTRDcalibDB::GetGainFactorDet()
580{
581 //
582 // Returns the gain factor calibration object
583 // containing one number per detector
584 //
585
586 const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *>
587 (GetCachedCDBObject(kIDGainFactorChamber));
588 if (!calChamber) {
589 return 0;
590 }
591 else {
592 return calChamber;
593 }
594
595}
596
7754cd1f 597//_____________________________________________________________________________
598Float_t AliTRDcalibDB::GetGainFactorAverage(Int_t det)
599{
600 //
601 // Returns the average gain factor for the given detector
602 //
603
95867fd1 604 const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *>
6d50f529 605 (GetCachedCDBObject(kIDGainFactorChamber));
606 if (!calDet) {
7754cd1f 607 return -1;
6d50f529 608 }
7754cd1f 609
610 return calDet->GetValue(det);
2745a409 611
acba9bad 612}
6a739e92 613
524fc8fa 614//_____________________________________________________________________________
615AliTRDCalROC *AliTRDcalibDB::GetPRFROC(Int_t det)
616{
617 //
618 // Returns the PRF calibration object for a given ROC
619 // containing one number per pad
620 //
621
622 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
623 (GetCachedCDBObject(kIDPRFWidth));
624 if (!calPad) {
625 return 0;
626 }
627
628 AliTRDCalROC *roc = calPad->GetCalROC(det);
629 if (!roc) {
630 return 0;
631 }
632 else {
633 return roc;
634 }
635
636}
637
6a739e92 638//_____________________________________________________________________________
639Float_t AliTRDcalibDB::GetPRFWidth(Int_t det, Int_t col, Int_t row)
640{
641 //
642 // Returns the PRF width for the given pad.
643 //
644
95867fd1 645 const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *>
6d50f529 646 (GetCachedCDBObject(kIDPRFWidth));
647 if (!calPad) {
6a739e92 648 return -1;
6d50f529 649 }
6a739e92 650
95867fd1 651 AliTRDCalROC *roc = calPad->GetCalROC(det);
6d50f529 652 if (!roc) {
6a739e92 653 return -1;
6d50f529 654 }
6a739e92 655
95867fd1 656 return roc->GetValue(col,row);
2745a409 657
acba9bad 658}
3551db50 659
660//_____________________________________________________________________________
661Int_t AliTRDcalibDB::GetNumberOfTimeBins()
662{
663 //
664 // Returns the number of time bins which are read-out.
665 //
7754cd1f 666
aa617684 667 const AliTRDCalFEE *calFEE = dynamic_cast<const AliTRDCalFEE *>
668 (GetCachedCDBObject(kIDFEE));
669 if (!calFEE) {
7754cd1f 670 return -1;
6d50f529 671 }
7754cd1f 672
aa617684 673 return calFEE->GetNumberOfTimeBins();
2745a409 674
3551db50 675}
676
7754cd1f 677//_____________________________________________________________________________
678Char_t AliTRDcalibDB::GetPadStatus(Int_t det, Int_t col, Int_t row)
679{
680 //
681 // Returns the status of the given pad
682 //
683
aa617684 684 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
685 (GetCachedCDBObject(kIDPadStatus));
6d50f529 686 if (!cal) {
7754cd1f 687 return -1;
6d50f529 688 }
7754cd1f 689
95867fd1 690 const AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
6d50f529 691 if (!roc) {
7754cd1f 692 return -1;
6d50f529 693 }
7754cd1f 694
95867fd1 695 return roc->GetStatus(col,row);
2745a409 696
7754cd1f 697}
698
0e09df31 699//_____________________________________________________________________________
700AliTRDCalSingleChamberStatus* AliTRDcalibDB::GetPadStatusROC(Int_t det)
701{
702 //
703 // Returns the pad status calibration object for a given ROC
704 //
705
706 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
707 (GetCachedCDBObject(kIDPadStatus));
708 if (!cal) {
709 return 0;
710 }
711
712 AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
713 if (!roc) {
714 return 0;
715 }
716 else {
717 return roc;
718 }
719
720}
721
7754cd1f 722//_____________________________________________________________________________
723Char_t AliTRDcalibDB::GetChamberStatus(Int_t det)
724{
725 //
726 // Returns the status of the given chamber
727 //
728
95867fd1 729 const AliTRDCalChamberStatus *cal = dynamic_cast<const AliTRDCalChamberStatus *>
6d50f529 730 (GetCachedCDBObject(kIDChamberStatus));
731 if (!cal) {
7754cd1f 732 return -1;
6d50f529 733 }
7754cd1f 734
735 return cal->GetStatus(det);
2745a409 736
7754cd1f 737}
738
7754cd1f 739//_____________________________________________________________________________
740Bool_t AliTRDcalibDB::IsPadMasked(Int_t det, Int_t col, Int_t row)
741{
742 //
743 // Returns status, see name of functions for details ;-)
744 //
745
95867fd1 746 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
747 (GetCachedCDBObject(kIDPadStatus));
6d50f529 748 if (!cal) {
7754cd1f 749 return -1;
6d50f529 750 }
7754cd1f 751
95867fd1 752 return cal->IsMasked(det,col,row);
2745a409 753
7754cd1f 754}
755
756//_____________________________________________________________________________
757Bool_t AliTRDcalibDB::IsPadBridgedLeft(Int_t det, Int_t col, Int_t row)
758{
759 //
760 // Returns status, see name of functions for details ;-)
761 //
762
95867fd1 763 const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *>
764 (GetCachedCDBObject(kIDPadStatus));
6d50f529 765 if (!cal) {
7754cd1f 766 return -1;
6d50f529 767 }
7754cd1f 768
95867fd1 769 return cal->IsBridgedLeft(det,col,row);
2745a409 770
7754cd1f 771}
772
773//_____________________________________________________________________________
774Bool_t AliTRDcalibDB::IsPadBridgedRight(Int_t det, Int_t col, Int_t row)
775{
776 //
777 // Returns status, see name of functions for details ;-)
778 //
779
95867fd1 780 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
781 (GetCachedCDBObject(kIDPadStatus));
6d50f529 782 if (!cal) {
7754cd1f 783 return -1;
6d50f529 784 }
7754cd1f 785
95867fd1 786 return cal->IsBridgedRight(det,col,row);
2745a409 787
7754cd1f 788}
789
fa7427d0 790//_____________________________________________________________________________
791Bool_t AliTRDcalibDB::IsPadNotConnected(Int_t det, Int_t col, Int_t row)
792{
793 //
794 // Returns status, see name of functions for details ;-)
795 //
796 const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *>
797 (GetCachedCDBObject(kIDPadStatus));
798 if (!cal) {
799 return -1;
800 }
801
802 return cal->IsNotConnected(det,col,row);
803
804}
805
7754cd1f 806//_____________________________________________________________________________
807Bool_t AliTRDcalibDB::IsChamberInstalled(Int_t det)
808{
809 //
810 // Returns status, see name of functions for details ;-)
811 //
812
95867fd1 813 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
814 (GetCachedCDBObject(kIDChamberStatus));
6d50f529 815 if (!cal) {
7754cd1f 816 return -1;
6d50f529 817 }
7754cd1f 818
819 return cal->IsInstalled(det);
2745a409 820
7754cd1f 821}
822
823//_____________________________________________________________________________
824Bool_t AliTRDcalibDB::IsChamberMasked(Int_t det)
825{
826 //
827 // Returns status, see name of functions for details ;-)
828 //
829
95867fd1 830 const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *>
831 (GetCachedCDBObject(kIDChamberStatus));
6d50f529 832 if (!cal) {
7754cd1f 833 return -1;
6d50f529 834 }
7754cd1f 835
836 return cal->IsMasked(det);
2745a409 837
7754cd1f 838}
839
cc7cef99 840//_____________________________________________________________________________
44dbae42 841const AliTRDCalPID *AliTRDcalibDB::GetPIDObject(const Int_t method)
cc7cef99 842{
843 //
844 // Returns the object storing the distributions for PID with likelihood
845 //
9a96f175 846
847 switch(method) {
848 case 0: return dynamic_cast<const AliTRDCalPID *>
9a96f175 849 (GetCachedCDBObject(kIDPIDLQ));
10f75631 850 case 1: return dynamic_cast<const AliTRDCalPID *>
851 (GetCachedCDBObject(kIDPIDNN));
9a96f175 852 }
853
10f75631 854 return 0x0;
2745a409 855
cc7cef99 856}
857
7754cd1f 858//_____________________________________________________________________________
d4c6453d 859const AliTRDCalMonitoring *AliTRDcalibDB::GetMonitoringObject()
7754cd1f 860{
861 //
862 // Returns the object storing the monitoring data
863 //
864
d4c6453d 865 return dynamic_cast<const AliTRDCalMonitoring *>
866 (GetCachedCDBObject(kIDMonitoringData));
1b95a37b 867
7754cd1f 868}
869
3551db50 870//_____________________________________________________________________________
1b95a37b 871Float_t AliTRDcalibDB::GetOmegaTau(Float_t vdrift, Float_t bz)
3551db50 872{
873 //
4e009ce4 874 // Returns omega*tau (tan(Lorentz-angle)) for a given drift velocity <vdrift>
875 // and a B-field <bz> for Xe/CO2 (15%).
3551db50 876 // The values are according to a GARFIELD simulation.
877 //
4e009ce4 878 // This function basically does not belong to the calibration class.
879 // It should be moved somewhere else.
3551db50 880 // However, currently it is in use by simulation and reconstruction.
881 //
882
1b95a37b 883 Float_t fieldAbs = TMath::Abs(bz);
4e009ce4 884 Float_t fieldSgn = (bz > 0.0) ? 1.0 : -1.0;
3551db50 885
886 const Int_t kNb = 5;
887 Float_t p0[kNb] = { 0.004810, 0.007412, 0.010252, 0.013409, 0.016888 };
888 Float_t p1[kNb] = { 0.054875, 0.081534, 0.107333, 0.131983, 0.155455 };
889 Float_t p2[kNb] = { -0.008682, -0.012896, -0.016987, -0.020880, -0.024623 };
890 Float_t p3[kNb] = { 0.000155, 0.000238, 0.000330, 0.000428, 0.000541 };
891
4806f526 892 // No ExB if field is too small (or zero)
893 if (fieldAbs < 0.01) {
3551db50 894
4806f526 895 return 0.0;
d19b1f90 896
4806f526 897 }
898 // Calculate ExB from parametrization
899 else {
900
901 Int_t ib = ((Int_t) (10 * (fieldAbs - 0.15)));
902 ib = TMath::Max( 0,ib);
903 ib = TMath::Min(kNb,ib);
904
905 Float_t alphaL = p0[ib]
906 + p1[ib] * vdrift
907 + p2[ib] * vdrift*vdrift
908 + p3[ib] * vdrift*vdrift*vdrift;
909
910 return TMath::Tan(fieldSgn * alphaL);
911
912 }
3551db50 913
6a739e92 914}
915
916//_____________________________________________________________________________
917void AliTRDcalibDB::SamplePRF()
918{
919 //
2745a409 920 // Samples the pad response function (should maybe go somewhere else ...)
6a739e92 921 //
922
923 const Int_t kPRFbin = 61;
924
6d50f529 925 Float_t prf[kNplan][kPRFbin] = {
926 {2.9037e-02, 3.3608e-02, 3.9020e-02, 4.5292e-02,
6a739e92 927 5.2694e-02, 6.1362e-02, 7.1461e-02, 8.3362e-02,
928 9.7063e-02, 1.1307e-01, 1.3140e-01, 1.5235e-01,
929 1.7623e-01, 2.0290e-01, 2.3294e-01, 2.6586e-01,
930 3.0177e-01, 3.4028e-01, 3.8077e-01, 4.2267e-01,
931 4.6493e-01, 5.0657e-01, 5.4655e-01, 5.8397e-01,
932 6.1767e-01, 6.4744e-01, 6.7212e-01, 6.9188e-01,
933 7.0627e-01, 7.1499e-01, 7.1851e-01, 7.1499e-01,
934 7.0627e-01, 6.9188e-01, 6.7212e-01, 6.4744e-01,
935 6.1767e-01, 5.8397e-01, 5.4655e-01, 5.0657e-01,
936 4.6493e-01, 4.2267e-01, 3.8077e-01, 3.4028e-01,
937 3.0177e-01, 2.6586e-01, 2.3294e-01, 2.0290e-01,
938 1.7623e-01, 1.5235e-01, 1.3140e-01, 1.1307e-01,
939 9.7063e-02, 8.3362e-02, 7.1461e-02, 6.1362e-02,
940 5.2694e-02, 4.5292e-02, 3.9020e-02, 3.3608e-02,
941 2.9037e-02},
942 {2.5478e-02, 2.9695e-02, 3.4655e-02, 4.0454e-02,
943 4.7342e-02, 5.5487e-02, 6.5038e-02, 7.6378e-02,
944 8.9696e-02, 1.0516e-01, 1.2327e-01, 1.4415e-01,
945 1.6794e-01, 1.9516e-01, 2.2573e-01, 2.5959e-01,
946 2.9694e-01, 3.3719e-01, 3.7978e-01, 4.2407e-01,
947 4.6889e-01, 5.1322e-01, 5.5569e-01, 5.9535e-01,
948 6.3141e-01, 6.6259e-01, 6.8882e-01, 7.0983e-01,
949 7.2471e-01, 7.3398e-01, 7.3761e-01, 7.3398e-01,
950 7.2471e-01, 7.0983e-01, 6.8882e-01, 6.6259e-01,
951 6.3141e-01, 5.9535e-01, 5.5569e-01, 5.1322e-01,
952 4.6889e-01, 4.2407e-01, 3.7978e-01, 3.3719e-01,
953 2.9694e-01, 2.5959e-01, 2.2573e-01, 1.9516e-01,
954 1.6794e-01, 1.4415e-01, 1.2327e-01, 1.0516e-01,
955 8.9696e-02, 7.6378e-02, 6.5038e-02, 5.5487e-02,
956 4.7342e-02, 4.0454e-02, 3.4655e-02, 2.9695e-02,
957 2.5478e-02},
958 {2.2363e-02, 2.6233e-02, 3.0782e-02, 3.6140e-02,
959 4.2535e-02, 5.0157e-02, 5.9197e-02, 6.9900e-02,
960 8.2707e-02, 9.7811e-02, 1.1548e-01, 1.3601e-01,
961 1.5998e-01, 1.8739e-01, 2.1840e-01, 2.5318e-01,
962 2.9182e-01, 3.3373e-01, 3.7837e-01, 4.2498e-01,
963 4.7235e-01, 5.1918e-01, 5.6426e-01, 6.0621e-01,
964 6.4399e-01, 6.7700e-01, 7.0472e-01, 7.2637e-01,
965 7.4206e-01, 7.5179e-01, 7.5551e-01, 7.5179e-01,
966 7.4206e-01, 7.2637e-01, 7.0472e-01, 6.7700e-01,
967 6.4399e-01, 6.0621e-01, 5.6426e-01, 5.1918e-01,
968 4.7235e-01, 4.2498e-01, 3.7837e-01, 3.3373e-01,
969 2.9182e-01, 2.5318e-01, 2.1840e-01, 1.8739e-01,
970 1.5998e-01, 1.3601e-01, 1.1548e-01, 9.7811e-02,
971 8.2707e-02, 6.9900e-02, 5.9197e-02, 5.0157e-02,
972 4.2535e-02, 3.6140e-02, 3.0782e-02, 2.6233e-02,
973 2.2363e-02},
974 {1.9635e-02, 2.3167e-02, 2.7343e-02, 3.2293e-02,
975 3.8224e-02, 4.5335e-02, 5.3849e-02, 6.4039e-02,
976 7.6210e-02, 9.0739e-02, 1.0805e-01, 1.2841e-01,
977 1.5216e-01, 1.7960e-01, 2.1099e-01, 2.4671e-01,
978 2.8647e-01, 3.2996e-01, 3.7660e-01, 4.2547e-01,
979 4.7536e-01, 5.2473e-01, 5.7215e-01, 6.1632e-01,
980 6.5616e-01, 6.9075e-01, 7.1939e-01, 7.4199e-01,
981 7.5838e-01, 7.6848e-01, 7.7227e-01, 7.6848e-01,
982 7.5838e-01, 7.4199e-01, 7.1939e-01, 6.9075e-01,
983 6.5616e-01, 6.1632e-01, 5.7215e-01, 5.2473e-01,
984 4.7536e-01, 4.2547e-01, 3.7660e-01, 3.2996e-01,
985 2.8647e-01, 2.4671e-01, 2.1099e-01, 1.7960e-01,
986 1.5216e-01, 1.2841e-01, 1.0805e-01, 9.0739e-02,
987 7.6210e-02, 6.4039e-02, 5.3849e-02, 4.5335e-02,
988 3.8224e-02, 3.2293e-02, 2.7343e-02, 2.3167e-02,
989 1.9635e-02},
990 {1.7224e-02, 2.0450e-02, 2.4286e-02, 2.8860e-02,
991 3.4357e-02, 4.0979e-02, 4.8966e-02, 5.8612e-02,
992 7.0253e-02, 8.4257e-02, 1.0102e-01, 1.2094e-01,
993 1.4442e-01, 1.7196e-01, 2.0381e-01, 2.4013e-01,
994 2.8093e-01, 3.2594e-01, 3.7450e-01, 4.2563e-01,
995 4.7796e-01, 5.2991e-01, 5.7974e-01, 6.2599e-01,
996 6.6750e-01, 7.0344e-01, 7.3329e-01, 7.5676e-01,
997 7.7371e-01, 7.8410e-01, 7.8793e-01, 7.8410e-01,
998 7.7371e-01, 7.5676e-01, 7.3329e-01, 7.0344e-01,
999 6.6750e-01, 6.2599e-01, 5.7974e-01, 5.2991e-01,
1000 4.7796e-01, 4.2563e-01, 3.7450e-01, 3.2594e-01,
1001 2.8093e-01, 2.4013e-01, 2.0381e-01, 1.7196e-01,
1002 1.4442e-01, 1.2094e-01, 1.0102e-01, 8.4257e-02,
1003 7.0253e-02, 5.8612e-02, 4.8966e-02, 4.0979e-02,
1004 3.4357e-02, 2.8860e-02, 2.4286e-02, 2.0450e-02,
1005 1.7224e-02},
1006 {1.5096e-02, 1.8041e-02, 2.1566e-02, 2.5793e-02,
1007 3.0886e-02, 3.7044e-02, 4.4515e-02, 5.3604e-02,
1008 6.4668e-02, 7.8109e-02, 9.4364e-02, 1.1389e-01,
1009 1.3716e-01, 1.6461e-01, 1.9663e-01, 2.3350e-01,
1010 2.7527e-01, 3.2170e-01, 3.7214e-01, 4.2549e-01,
1011 4.8024e-01, 5.3460e-01, 5.8677e-01, 6.3512e-01,
1012 6.7838e-01, 7.1569e-01, 7.4655e-01, 7.7071e-01,
1013 7.8810e-01, 7.9871e-01, 8.0255e-01, 7.9871e-01,
1014 7.8810e-01, 7.7071e-01, 7.4655e-01, 7.1569e-01,
1015 6.7838e-01, 6.3512e-01, 5.8677e-01, 5.3460e-01,
1016 4.8024e-01, 4.2549e-01, 3.7214e-01, 3.2170e-01,
1017 2.7527e-01, 2.3350e-01, 1.9663e-01, 1.6461e-01,
1018 1.3716e-01, 1.1389e-01, 9.4364e-02, 7.8109e-02,
1019 6.4668e-02, 5.3604e-02, 4.4515e-02, 3.7044e-02,
1020 3.0886e-02, 2.5793e-02, 2.1566e-02, 1.8041e-02,
1021 1.5096e-02}};
1022
1023 // More sampling precision with linear interpolation
6d50f529 1024 fPRFlo = -1.5;
1025 fPRFhi = 1.5;
6a739e92 1026 Float_t pad[kPRFbin];
1027 Int_t sPRFbin = kPRFbin;
6d50f529 1028 Float_t sPRFwid = (fPRFhi - fPRFlo) / ((Float_t) sPRFbin);
6a739e92 1029 for (Int_t iPad = 0; iPad < sPRFbin; iPad++) {
6d50f529 1030 pad[iPad] = ((Float_t) iPad + 0.5) * sPRFwid + fPRFlo;
6a739e92 1031 }
6d50f529 1032 fPRFbin = 500;
1033 fPRFwid = (fPRFhi - fPRFlo) / ((Float_t) fPRFbin);
1034 fPRFpad = ((Int_t) (1.0 / fPRFwid));
6a739e92 1035
6d50f529 1036 if (fPRFsmp) delete [] fPRFsmp;
1037 fPRFsmp = new Float_t[kNplan*fPRFbin];
6a739e92 1038
1039 Int_t ipos1;
1040 Int_t ipos2;
1041 Float_t diff;
1042
1043 for (Int_t iPla = 0; iPla < kNplan; iPla++) {
1044
6d50f529 1045 for (Int_t iBin = 0; iBin < fPRFbin; iBin++) {
6a739e92 1046
6d50f529 1047 Float_t bin = (((Float_t) iBin) + 0.5) * fPRFwid + fPRFlo;
6a739e92 1048 ipos1 = ipos2 = 0;
1049 diff = 0;
1050 do {
1051 diff = bin - pad[ipos2++];
1052 } while ((diff > 0) && (ipos2 < kPRFbin));
1053 if (ipos2 == kPRFbin) {
6d50f529 1054 fPRFsmp[iPla*fPRFbin+iBin] = prf[iPla][ipos2-1];
6a739e92 1055 }
1056 else if (ipos2 == 1) {
6d50f529 1057 fPRFsmp[iPla*fPRFbin+iBin] = prf[iPla][ipos2-1];
6a739e92 1058 }
1059 else {
1060 ipos2--;
1061 if (ipos2 >= kPRFbin) ipos2 = kPRFbin - 1;
1062 ipos1 = ipos2 - 1;
6d50f529 1063 fPRFsmp[iPla*fPRFbin+iBin] = prf[iPla][ipos2]
6a739e92 1064 + diff * (prf[iPla][ipos2] - prf[iPla][ipos1])
1065 / sPRFwid;
1066 }
1067
1068 }
1069 }
1070
1071}
1072
1073//_____________________________________________________________________________
1074Int_t AliTRDcalibDB::PadResponse(Double_t signal, Double_t dist
2745a409 1075 , Int_t plane, Double_t *pad) const
6a739e92 1076{
1077 //
1078 // Applies the pad response
56178ff4 1079 // So far this is the fixed parametrization and should be replaced by
1080 // something dependent on calibration values
6a739e92 1081 //
1082
6d50f529 1083 Int_t iBin = ((Int_t) (( - dist - fPRFlo) / fPRFwid));
1084 Int_t iOff = plane * fPRFbin;
6a739e92 1085
6d50f529 1086 Int_t iBin0 = iBin - fPRFpad + iOff;
6a739e92 1087 Int_t iBin1 = iBin + iOff;
6d50f529 1088 Int_t iBin2 = iBin + fPRFpad + iOff;
6a739e92 1089
1090 pad[0] = 0.0;
1091 pad[1] = 0.0;
1092 pad[2] = 0.0;
6d50f529 1093 if ((iBin1 >= 0) && (iBin1 < (fPRFbin*kNplan))) {
6a739e92 1094
1095 if (iBin0 >= 0) {
6d50f529 1096 pad[0] = signal * fPRFsmp[iBin0];
6a739e92 1097 }
6d50f529 1098 pad[1] = signal * fPRFsmp[iBin1];
1099 if (iBin2 < (fPRFbin*kNplan)) {
1100 pad[2] = signal * fPRFsmp[iBin2];
6a739e92 1101 }
1102
1103 return 1;
1104
1105 }
1106 else {
1107
1108 return 0;
1109
1110 }
ab0a4106 1111
3551db50 1112}