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