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