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