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