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