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