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