]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDcalibDB.cxx
Make destructor public
[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
31#include <TRandom.h>
32
2745a409 33#include "AliCDBManager.h"
34#include "AliCDBStorage.h"
35#include "AliCDBEntry.h"
36#include "AliLog.h"
3551db50 37
38#include "AliTRDcalibDB.h"
39#include "AliTRDgeometry.h"
40#include "AliTRDpadPlane.h"
41#include "AliTRDCommonParam.h"
42
7754cd1f 43#include "Cal/AliTRDCalROC.h"
7754cd1f 44#include "Cal/AliTRDCalPad.h"
45#include "Cal/AliTRDCalDet.h"
46#include "Cal/AliTRDCalGlobals.h"
47#include "Cal/AliTRDCalPIDLQ.h"
48#include "Cal/AliTRDCalMonitoring.h"
7754cd1f 49#include "Cal/AliTRDCalSuperModuleStatus.h"
50#include "Cal/AliTRDCalChamberStatus.h"
51#include "Cal/AliTRDCalMCMStatus.h"
52#include "Cal/AliTRDCalPadStatus.h"
53#include "Cal/AliTRDCalSingleChamberStatus.h"
3551db50 54
55ClassImp(AliTRDcalibDB)
56
2745a409 57AliTRDcalibDB *AliTRDcalibDB::fgInstance = 0;
58Bool_t AliTRDcalibDB::fgTerminated = kFALSE;
3551db50 59
60//_ singleton implementation __________________________________________________
61AliTRDcalibDB* AliTRDcalibDB::Instance()
62{
63 //
64 // Singleton implementation
65 // Returns an instance of this class, it is created if neccessary
63a700c6 66 //
3551db50 67
68 if (fgTerminated != kFALSE)
69 return 0;
70
71 if (fgInstance == 0)
72 fgInstance = new AliTRDcalibDB();
e254cad1 73
3551db50 74 return fgInstance;
75}
76
2745a409 77//_____________________________________________________________________________
3551db50 78void AliTRDcalibDB::Terminate()
79{
80 //
81 // Singleton implementation
82 // Deletes the instance of this class and sets the terminated flag, instances cannot be requested anymore
83 // This function can be called several times.
84 //
85
86 fgTerminated = kTRUE;
87
88 if (fgInstance != 0)
89 {
90 delete fgInstance;
91 fgInstance = 0;
92 }
2745a409 93
3551db50 94}
95
96//_____________________________________________________________________________
97AliTRDcalibDB::AliTRDcalibDB()
2745a409 98 :TObject()
99 ,fRun(-1)
3551db50 100{
101 //
2745a409 102 // Default constructor
3551db50 103 //
2745a409 104 // TODO Default runnumber is set to 0, this should be changed later
105 // to an invalid value (e.g. -1) to prevent
3551db50 106 // TODO invalid calibration data to be used.
2745a409 107 //
108
109 fPadResponse.fPRFbin = 0;
110 fPadResponse.fPRFlo = 0.0;
111 fPadResponse.fPRFhi = 0.0;
112 fPadResponse.fPRFwid = 0.0;
113 fPadResponse.fPRFpad = 0;
114 fPadResponse.fPRFsmp = 0;
115
116 for (Int_t i=0; i<kCDBCacheSize; ++i)
117 {
118 fCDBCache[i] = 0;
119 fCDBEntries[i] = 0;
120 }
3551db50 121
2745a409 122 // Create the sampled PRF
123 SamplePRF();
124
125}
126
127//_____________________________________________________________________________
128AliTRDcalibDB::AliTRDcalibDB(const AliTRDcalibDB &c)
129 :TObject(c)
130 ,fRun(0)
131{
132 //
133 // Copy constructor (not that it make any sense for a singleton...)
134 //
135
136 fPadResponse.fPRFbin = 0;
137 fPadResponse.fPRFlo = 0.0;
138 fPadResponse.fPRFhi = 0.0;
139 fPadResponse.fPRFwid = 0.0;
140 fPadResponse.fPRFpad = 0;
141 fPadResponse.fPRFsmp = 0;
e254cad1 142
3551db50 143 for (Int_t i=0; i<kCDBCacheSize; ++i)
144 {
2745a409 145 fCDBCache[i] = 0;
3551db50 146 fCDBEntries[i] = 0;
147 }
6a739e92 148
149 // Create the sampled PRF
150 SamplePRF();
2745a409 151
152}
153
154//_____________________________________________________________________________
155AliTRDcalibDB &AliTRDcalibDB::operator=(const AliTRDcalibDB &c)
156{
157 //
158 // Assignment operator (same as above ...)
159 //
160
161 if (this != &c) {
162 AliFatal("No assignment operator defined");
163 }
164 return *this;
165
acba9bad 166}
3551db50 167
168//_____________________________________________________________________________
169AliTRDcalibDB::~AliTRDcalibDB()
170{
171 //
172 // destructor
173 //
174
6a739e92 175 if (fPadResponse.fPRFsmp) {
176 delete [] fPadResponse.fPRFsmp;
177 fPadResponse.fPRFsmp = 0;
178 }
179
3551db50 180 Invalidate();
2745a409 181
acba9bad 182}
3551db50 183
63a700c6 184//_caching functions____________________________________________________________
185const TObject* AliTRDcalibDB::GetCachedCDBObject(Int_t id)
186{
2745a409 187 //
188 // Retrieves a cdb object with the given id. The objects are cached as
189 // long as the run number is not changed.
190 //
191 // Put together the available objects here by using the lines
192 // a) For usual calibration objects:
193 // case kID<Name> :
194 // return CacheCDBEntry(kID<Name>,"TRD/Calib/<Path>");
195 // break;
196 // See function CacheCDBEntry for details.
197 // and
198 // b) For calibration data which depends on two objects: One containing
199 // a value per detector and one the local fluctuations per pad:
200 // case kID<Name> :
201 // return CacheMergeCDBEntry(kID<Name>,"TRD/Calib/<padPath>","TRD/Calib/<chamberPath>");
202 // break;
203 // See function CacheMergeCDBEntry for details.
204 //
63a700c6 205
2745a409 206 switch (id)
207 {
208
209 // Parameters defined per pad and chamber
210 case kIDVdriftPad :
211 return CacheCDBEntry(kIDVdriftPad, "TRD/Calib/LocalVdrift");
212 break;
213 case kIDVdriftChamber :
214 return CacheCDBEntry(kIDVdriftChamber, "TRD/Calib/ChamberVdrift");
215 break;
216 case kIDT0Pad :
217 return CacheCDBEntry(kIDT0Pad, "TRD/Calib/LocalT0");
218 break;
219 case kIDT0Chamber :
220 return CacheCDBEntry(kIDT0Chamber, "TRD/Calib/ChamberT0");
221 break;
222 case kIDGainFactorPad :
223 return CacheCDBEntry(kIDGainFactorPad, "TRD/Calib/LocalGainFactor");
224 break;
225 case kIDGainFactorChamber :
226 return CacheCDBEntry(kIDGainFactorChamber, "TRD/Calib/ChamberGainFactor");
227 break;
228
229 // Parameters defined per pad
230 case kIDPRFWidth :
231 return CacheCDBEntry(kIDPRFWidth, "TRD/Calib/PRFWidth");
232 break;
233
234 // Status values
235 case kIDSuperModuleStatus :
236 return CacheCDBEntry(kIDSuperModuleStatus, "TRD/Calib/SuperModuleStatus");
237 break;
238 case kIDChamberStatus :
239 return CacheCDBEntry(kIDChamberStatus, "TRD/Calib/ChamberStatus");
240 break;
241 case kIDMCMStatus :
242 return CacheCDBEntry(kIDMCMStatus, "TRD/Calib/MCMStatus");
243 break;
244 case kIDPadStatus :
245 return CacheCDBEntry(kIDPadStatus, "TRD/Calib/PadStatus");
246 break;
247
248 // Global parameters
249 case kIDMonitoringData :
250 return CacheCDBEntry(kIDMonitoringData, "TRD/Calib/MonitoringData");
251 break;
252 case kIDGlobals :
253 return CacheCDBEntry(kIDGlobals, "TRD/Calib/Globals");
254 break;
255 case kIDPIDLQ :
256 return CacheCDBEntry(kIDPIDLQ, "TRD/Calib/PIDLQ");
257 break;
258
259 }
260
261 return 0;
262
63a700c6 263}
264
265//_____________________________________________________________________________
266AliCDBEntry* AliTRDcalibDB::GetCDBEntry(const char* cdbPath)
267{
268 //
269 // Retrieves an entry with path <cdbPath> from the CDB.
270 //
271
e254cad1 272 AliCDBEntry* entry = AliCDBManager::Instance()->Get(cdbPath, fRun);
2745a409 273 if (!entry) {
274 AliError(Form("Failed to get entry: %s",cdbPath));
63a700c6 275 return 0;
276 }
277
2745a409 278 AliInfo(Form("AliTRDcalibDB: Retrieved object: %s",cdbPath));
279
63a700c6 280 return entry;
2745a409 281
63a700c6 282}
283
284//_____________________________________________________________________________
285const TObject* AliTRDcalibDB::CacheCDBEntry(Int_t id, const char* cdbPath)
286{
287 //
288 // Caches the entry <id> with cdb path <cdbPath>
289 //
290
2745a409 291 if (!fCDBCache[id]) {
63a700c6 292 fCDBEntries[id] = GetCDBEntry(cdbPath);
293 if (fCDBEntries[id])
294 fCDBCache[id] = fCDBEntries[id]->GetObject();
295 }
296 return fCDBCache[id];
2745a409 297
63a700c6 298}
299
3551db50 300//_____________________________________________________________________________
301void AliTRDcalibDB::SetRun(Long64_t run)
302{
303 //
7754cd1f 304 // Sets current run number. Calibration data is read from the corresponding file.
3551db50 305 // When the run number changes the caching is invalidated.
306 //
7754cd1f 307
3551db50 308 if (fRun == run)
309 return;
7754cd1f 310
3551db50 311 fRun = run;
312 Invalidate();
2745a409 313
3551db50 314}
7754cd1f 315
3551db50 316//_____________________________________________________________________________
317void AliTRDcalibDB::Invalidate()
318{
319 //
320 // Invalidates cache (when run number is changed).
321 //
322
2745a409 323 for (Int_t i=0; i<kCDBCacheSize; ++i) {
324 if (fCDBEntries[i]) {
325 if (AliCDBManager::Instance()->GetCacheFlag() == kFALSE) {
326 if (fCDBEntries[i]->IsOwner() == kFALSE && fCDBCache[i]) {
e254cad1 327 delete fCDBCache[i];
2745a409 328 }
e254cad1 329 delete fCDBEntries[i];
330 }
3551db50 331 fCDBEntries[i] = 0;
2745a409 332 fCDBCache[i] = 0;
3551db50 333 }
334 }
2745a409 335
3551db50 336}
337
3551db50 338//_____________________________________________________________________________
339Float_t AliTRDcalibDB::GetVdrift(Int_t det, Int_t col, Int_t row)
340{
341 //
342 // Returns the drift velocity for the given pad.
343 //
7754cd1f 344
345 const AliTRDCalPad* calPad = dynamic_cast<const AliTRDCalPad*> (GetCachedCDBObject(kIDVdriftPad));
3551db50 346 if (!calPad)
347 return -1;
348
349 AliTRDCalROC* roc = calPad->GetCalROC(det);
350 if (!roc)
351 return -1;
352
7754cd1f 353 const AliTRDCalDet* calChamber = dynamic_cast<const AliTRDCalDet*> (GetCachedCDBObject(kIDVdriftChamber));
354 if (!calChamber)
355 return -1;
356
357 return calChamber->GetValue(det) * roc->GetValue(col, row);
2745a409 358
7754cd1f 359}
360
361//_____________________________________________________________________________
362Float_t AliTRDcalibDB::GetVdriftAverage(Int_t det)
363{
364 //
365 // Returns the average drift velocity for the given detector
366 //
367
368 const AliTRDCalDet* calDet = dynamic_cast<const AliTRDCalDet*> (GetCachedCDBObject(kIDVdriftChamber));
369 if (!calDet)
370 return -1;
371
372 return calDet->GetValue(det);
2745a409 373
acba9bad 374}
3551db50 375
376//_____________________________________________________________________________
377Float_t AliTRDcalibDB::GetT0(Int_t det, Int_t col, Int_t row)
378{
379 //
380 // Returns t0 for the given pad.
381 //
382
7754cd1f 383 const AliTRDCalPad* calPad = dynamic_cast<const AliTRDCalPad*> (GetCachedCDBObject(kIDT0Pad));
3551db50 384 if (!calPad)
385 return -1;
386
387 AliTRDCalROC* roc = calPad->GetCalROC(det);
388 if (!roc)
389 return -1;
390
7754cd1f 391 const AliTRDCalDet* calChamber = dynamic_cast<const AliTRDCalDet*> (GetCachedCDBObject(kIDT0Chamber));
392 if (!calChamber)
393 return -1;
394
395 return calChamber->GetValue(det) * roc->GetValue(col, row);
2745a409 396
7754cd1f 397}
398
399//_____________________________________________________________________________
400Float_t AliTRDcalibDB::GetT0Average(Int_t det)
401{
402 //
403 // Returns the average t0 for the given detector
404 //
405
406 const AliTRDCalDet* calDet = dynamic_cast<const AliTRDCalDet*> (GetCachedCDBObject(kIDT0Chamber));
407 if (!calDet)
408 return -1;
409
410 return calDet->GetValue(det);
2745a409 411
acba9bad 412}
3551db50 413
414//_____________________________________________________________________________
415Float_t AliTRDcalibDB::GetGainFactor(Int_t det, Int_t col, Int_t row)
416{
417 //
418 // Returns the gain factor for the given pad.
419 //
420
7754cd1f 421 const AliTRDCalPad* calPad = dynamic_cast<const AliTRDCalPad*> (GetCachedCDBObject(kIDGainFactorPad));
3551db50 422 if (!calPad)
423 return -1;
424
425 AliTRDCalROC* roc = calPad->GetCalROC(det);
426 if (!roc)
427 return -1;
428
7754cd1f 429 const AliTRDCalDet* calChamber = dynamic_cast<const AliTRDCalDet*> (GetCachedCDBObject(kIDGainFactorChamber));
430 if (!calChamber)
431 return -1;
432
433 return calChamber->GetValue(det) * roc->GetValue(col, row);
2745a409 434
7754cd1f 435}
436
437//_____________________________________________________________________________
438Float_t AliTRDcalibDB::GetGainFactorAverage(Int_t det)
439{
440 //
441 // Returns the average gain factor for the given detector
442 //
443
444 const AliTRDCalDet* calDet = dynamic_cast<const AliTRDCalDet*> (GetCachedCDBObject(kIDGainFactorChamber));
445 if (!calDet)
446 return -1;
447
448 return calDet->GetValue(det);
2745a409 449
acba9bad 450}
6a739e92 451
452//_____________________________________________________________________________
453Float_t AliTRDcalibDB::GetPRFWidth(Int_t det, Int_t col, Int_t row)
454{
455 //
456 // Returns the PRF width for the given pad.
457 //
458
63a700c6 459 const AliTRDCalPad* calPad = dynamic_cast<const AliTRDCalPad*> (GetCachedCDBObject(kIDPRFWidth));
6a739e92 460 if (!calPad)
461 return -1;
462
463 AliTRDCalROC* roc = calPad->GetCalROC(det);
464 if (!roc)
465 return -1;
466
467 return roc->GetValue(col, row);
2745a409 468
acba9bad 469}
3551db50 470
471//_____________________________________________________________________________
472Float_t AliTRDcalibDB::GetSamplingFrequency()
473{
474 //
475 // Returns the sampling frequency of the TRD read-out.
476 //
477
63a700c6 478 const AliTRDCalGlobals* calGlobal = dynamic_cast<const AliTRDCalGlobals*> (GetCachedCDBObject(kIDGlobals));
3551db50 479 if (!calGlobal)
480 return -1;
481
482 return calGlobal->GetSamplingFrequency();
2745a409 483
3551db50 484}
485
486//_____________________________________________________________________________
487Int_t AliTRDcalibDB::GetNumberOfTimeBins()
488{
489 //
490 // Returns the number of time bins which are read-out.
491 //
7754cd1f 492
63a700c6 493 const AliTRDCalGlobals* calGlobal = dynamic_cast<const AliTRDCalGlobals*> (GetCachedCDBObject(kIDGlobals));
3551db50 494 if (!calGlobal)
7754cd1f 495 return -1;
496
3551db50 497 return calGlobal->GetNumberOfTimeBins();
2745a409 498
3551db50 499}
500
7754cd1f 501//_____________________________________________________________________________
502Char_t AliTRDcalibDB::GetPadStatus(Int_t det, Int_t col, Int_t row)
503{
504 //
505 // Returns the status of the given pad
506 //
507
508 const AliTRDCalPadStatus* cal = dynamic_cast<const AliTRDCalPadStatus*> (GetCachedCDBObject(kIDPadStatus));
509 if (!cal)
510 return -1;
511
512 const AliTRDCalSingleChamberStatus* roc = cal->GetCalROC(det);
513 if (!roc)
514 return -1;
515
516 return roc->GetStatus(col, row);
2745a409 517
7754cd1f 518}
519
520//_____________________________________________________________________________
521Char_t AliTRDcalibDB::GetMCMStatus(Int_t det, Int_t col, Int_t row)
522{
523 //
524 // Returns the status of the given MCM
525 //
526
1395f333 527 Int_t mcm = ((Int_t) col / 18);
528
7754cd1f 529 const AliTRDCalMCMStatus* cal = dynamic_cast<const AliTRDCalMCMStatus*> (GetCachedCDBObject(kIDMCMStatus));
530 if (!cal)
531 return -1;
532
533 const AliTRDCalSingleChamberStatus* roc = cal->GetCalROC(det);
534 if (!roc)
535 return -1;
536
1395f333 537 return roc->GetStatus(mcm, row);
2745a409 538
7754cd1f 539}
540
541//_____________________________________________________________________________
542Char_t AliTRDcalibDB::GetChamberStatus(Int_t det)
543{
544 //
545 // Returns the status of the given chamber
546 //
547
548 const AliTRDCalChamberStatus* cal = dynamic_cast<const AliTRDCalChamberStatus*> (GetCachedCDBObject(kIDChamberStatus));
549 if (!cal)
550 return -1;
551
552 return cal->GetStatus(det);
2745a409 553
7754cd1f 554}
555
556//_____________________________________________________________________________
557Char_t AliTRDcalibDB::GetSuperModuleStatus(Int_t sm)
558{
559 //
560 // Returns the status of the given chamber
561 //
562
563 const AliTRDCalSuperModuleStatus* cal = dynamic_cast<const AliTRDCalSuperModuleStatus*> (GetCachedCDBObject(kIDSuperModuleStatus));
564 if (!cal)
565 return -1;
566
567 return cal->GetStatus(sm);
2745a409 568
7754cd1f 569}
570
571//_____________________________________________________________________________
572Bool_t AliTRDcalibDB::IsPadMasked(Int_t det, Int_t col, Int_t row)
573{
574 //
575 // Returns status, see name of functions for details ;-)
576 //
577
578 const AliTRDCalPadStatus* cal = dynamic_cast<const AliTRDCalPadStatus*> (GetCachedCDBObject(kIDPadStatus));
579 if (!cal)
580 return -1;
581
582 return cal->IsMasked(det, col, row);
2745a409 583
7754cd1f 584}
585
586//_____________________________________________________________________________
587Bool_t AliTRDcalibDB::IsPadBridgedLeft(Int_t det, Int_t col, Int_t row)
588{
589 //
590 // Returns status, see name of functions for details ;-)
591 //
592
593 const AliTRDCalPadStatus* cal = dynamic_cast<const AliTRDCalPadStatus*> (GetCachedCDBObject(kIDPadStatus));
594 if (!cal)
595 return -1;
596
597 return cal->IsBridgedLeft(det, col, row);
2745a409 598
7754cd1f 599}
600
601//_____________________________________________________________________________
602Bool_t AliTRDcalibDB::IsPadBridgedRight(Int_t det, Int_t col, Int_t row)
603{
604 //
605 // Returns status, see name of functions for details ;-)
606 //
607
608 const AliTRDCalPadStatus* cal = dynamic_cast<const AliTRDCalPadStatus*> (GetCachedCDBObject(kIDPadStatus));
609 if (!cal)
610 return -1;
611
612 return cal->IsBridgedRight(det, col, row);
2745a409 613
7754cd1f 614}
615
616//_____________________________________________________________________________
617Bool_t AliTRDcalibDB::IsMCMMasked(Int_t det, Int_t col, Int_t row)
618{
619 //
620 // Returns status, see name of functions for details ;-)
621 //
622
623 const AliTRDCalMCMStatus* cal = dynamic_cast<const AliTRDCalMCMStatus*> (GetCachedCDBObject(kIDMCMStatus));
624 if (!cal)
625 return -1;
626
627 return cal->IsMasked(det, col, row);
2745a409 628
7754cd1f 629}
630
631//_____________________________________________________________________________
632Bool_t AliTRDcalibDB::IsChamberInstalled(Int_t det)
633{
634 //
635 // Returns status, see name of functions for details ;-)
636 //
637
638 const AliTRDCalChamberStatus* cal = dynamic_cast<const AliTRDCalChamberStatus*> (GetCachedCDBObject(kIDChamberStatus));
639 if (!cal)
640 return -1;
641
642 return cal->IsInstalled(det);
2745a409 643
7754cd1f 644}
645
646//_____________________________________________________________________________
647Bool_t AliTRDcalibDB::IsChamberMasked(Int_t det)
648{
649 //
650 // Returns status, see name of functions for details ;-)
651 //
652
653 const AliTRDCalChamberStatus* cal = dynamic_cast<const AliTRDCalChamberStatus*> (GetCachedCDBObject(kIDChamberStatus));
654 if (!cal)
655 return -1;
656
657 return cal->IsMasked(det);
2745a409 658
7754cd1f 659}
660
661//_____________________________________________________________________________
662Bool_t AliTRDcalibDB::IsSuperModuleInstalled(Int_t det)
663{
664 //
665 // Returns status, see name of functions for details ;-)
666 //
667
668 const AliTRDCalSuperModuleStatus* cal = dynamic_cast<const AliTRDCalSuperModuleStatus*> (GetCachedCDBObject(kIDSuperModuleStatus));
669 if (!cal)
670 return -1;
671
672 return cal->IsInstalled(det);
2745a409 673
7754cd1f 674}
675
676//_____________________________________________________________________________
677Bool_t AliTRDcalibDB::IsSuperModuleMasked(Int_t det)
678{
679 //
680 // Returns status, see name of functions for details ;-)
681 //
682
683 const AliTRDCalSuperModuleStatus* cal = dynamic_cast<const AliTRDCalSuperModuleStatus*> (GetCachedCDBObject(kIDSuperModuleStatus));
684 if (!cal)
685 return -1;
686
687 return cal->IsMasked(det);
2745a409 688
7754cd1f 689}
690
cc7cef99 691//_____________________________________________________________________________
63a700c6 692const AliTRDCalPIDLQ* AliTRDcalibDB::GetPIDLQObject()
cc7cef99 693{
694 //
695 // Returns the object storing the distributions for PID with likelihood
696 //
7754cd1f 697
4e864ef1 698 return dynamic_cast<const AliTRDCalPIDLQ*> (GetCachedCDBObject(kIDPIDLQ));
2745a409 699
cc7cef99 700}
701
7754cd1f 702//_____________________________________________________________________________
703const AliTRDCalMonitoring* AliTRDcalibDB::GetMonitoringObject()
704{
705 //
706 // Returns the object storing the monitoring data
707 //
708
709 return dynamic_cast<const AliTRDCalMonitoring*> (GetCachedCDBObject(kIDMonitoringData));
2745a409 710
7754cd1f 711}
712
3551db50 713//_____________________________________________________________________________
714Float_t AliTRDcalibDB::GetOmegaTau(Float_t vdrift)
715{
716 //
717 // Returns omega*tau (tan(Lorentz-angle)) for a given drift velocity <vd>
718 // and a B-field <b> for Xe/CO2 (15%).
719 // The values are according to a GARFIELD simulation.
720 //
721 // This function basically does not belong to the calibration class. It should be moved somewhere else.
722 // However, currently it is in use by simulation and reconstruction.
723 //
724
725 AliTRDCommonParam* commonParam = AliTRDCommonParam::Instance();
726 if (!commonParam)
727 return -1;
d19b1f90 728 Float_t fieldAbs = TMath::Abs(commonParam->GetField());
729 Float_t fieldSgn = 1.0;
730 if (fieldAbs > 0.0) {
731 fieldSgn = commonParam->GetField() / fieldAbs;
732 }
3551db50 733
734 const Int_t kNb = 5;
735 Float_t p0[kNb] = { 0.004810, 0.007412, 0.010252, 0.013409, 0.016888 };
736 Float_t p1[kNb] = { 0.054875, 0.081534, 0.107333, 0.131983, 0.155455 };
737 Float_t p2[kNb] = { -0.008682, -0.012896, -0.016987, -0.020880, -0.024623 };
738 Float_t p3[kNb] = { 0.000155, 0.000238, 0.000330, 0.000428, 0.000541 };
739
d19b1f90 740 Int_t ib = ((Int_t) (10 * (fieldAbs - 0.15)));
3551db50 741 ib = TMath::Max( 0,ib);
742 ib = TMath::Min(kNb,ib);
743
744 Float_t alphaL = p0[ib]
d19b1f90 745 + p1[ib] * vdrift
746 + p2[ib] * vdrift*vdrift
747 + p3[ib] * vdrift*vdrift*vdrift;
748
749 return TMath::Tan(fieldSgn * alphaL);
3551db50 750
6a739e92 751}
752
753//_____________________________________________________________________________
754void AliTRDcalibDB::SamplePRF()
755{
756 //
2745a409 757 // Samples the pad response function (should maybe go somewhere else ...)
6a739e92 758 //
759
760 const Int_t kPRFbin = 61;
761
762 Float_t prf[kNplan][kPRFbin] = { {2.9037e-02, 3.3608e-02, 3.9020e-02, 4.5292e-02,
763 5.2694e-02, 6.1362e-02, 7.1461e-02, 8.3362e-02,
764 9.7063e-02, 1.1307e-01, 1.3140e-01, 1.5235e-01,
765 1.7623e-01, 2.0290e-01, 2.3294e-01, 2.6586e-01,
766 3.0177e-01, 3.4028e-01, 3.8077e-01, 4.2267e-01,
767 4.6493e-01, 5.0657e-01, 5.4655e-01, 5.8397e-01,
768 6.1767e-01, 6.4744e-01, 6.7212e-01, 6.9188e-01,
769 7.0627e-01, 7.1499e-01, 7.1851e-01, 7.1499e-01,
770 7.0627e-01, 6.9188e-01, 6.7212e-01, 6.4744e-01,
771 6.1767e-01, 5.8397e-01, 5.4655e-01, 5.0657e-01,
772 4.6493e-01, 4.2267e-01, 3.8077e-01, 3.4028e-01,
773 3.0177e-01, 2.6586e-01, 2.3294e-01, 2.0290e-01,
774 1.7623e-01, 1.5235e-01, 1.3140e-01, 1.1307e-01,
775 9.7063e-02, 8.3362e-02, 7.1461e-02, 6.1362e-02,
776 5.2694e-02, 4.5292e-02, 3.9020e-02, 3.3608e-02,
777 2.9037e-02},
778 {2.5478e-02, 2.9695e-02, 3.4655e-02, 4.0454e-02,
779 4.7342e-02, 5.5487e-02, 6.5038e-02, 7.6378e-02,
780 8.9696e-02, 1.0516e-01, 1.2327e-01, 1.4415e-01,
781 1.6794e-01, 1.9516e-01, 2.2573e-01, 2.5959e-01,
782 2.9694e-01, 3.3719e-01, 3.7978e-01, 4.2407e-01,
783 4.6889e-01, 5.1322e-01, 5.5569e-01, 5.9535e-01,
784 6.3141e-01, 6.6259e-01, 6.8882e-01, 7.0983e-01,
785 7.2471e-01, 7.3398e-01, 7.3761e-01, 7.3398e-01,
786 7.2471e-01, 7.0983e-01, 6.8882e-01, 6.6259e-01,
787 6.3141e-01, 5.9535e-01, 5.5569e-01, 5.1322e-01,
788 4.6889e-01, 4.2407e-01, 3.7978e-01, 3.3719e-01,
789 2.9694e-01, 2.5959e-01, 2.2573e-01, 1.9516e-01,
790 1.6794e-01, 1.4415e-01, 1.2327e-01, 1.0516e-01,
791 8.9696e-02, 7.6378e-02, 6.5038e-02, 5.5487e-02,
792 4.7342e-02, 4.0454e-02, 3.4655e-02, 2.9695e-02,
793 2.5478e-02},
794 {2.2363e-02, 2.6233e-02, 3.0782e-02, 3.6140e-02,
795 4.2535e-02, 5.0157e-02, 5.9197e-02, 6.9900e-02,
796 8.2707e-02, 9.7811e-02, 1.1548e-01, 1.3601e-01,
797 1.5998e-01, 1.8739e-01, 2.1840e-01, 2.5318e-01,
798 2.9182e-01, 3.3373e-01, 3.7837e-01, 4.2498e-01,
799 4.7235e-01, 5.1918e-01, 5.6426e-01, 6.0621e-01,
800 6.4399e-01, 6.7700e-01, 7.0472e-01, 7.2637e-01,
801 7.4206e-01, 7.5179e-01, 7.5551e-01, 7.5179e-01,
802 7.4206e-01, 7.2637e-01, 7.0472e-01, 6.7700e-01,
803 6.4399e-01, 6.0621e-01, 5.6426e-01, 5.1918e-01,
804 4.7235e-01, 4.2498e-01, 3.7837e-01, 3.3373e-01,
805 2.9182e-01, 2.5318e-01, 2.1840e-01, 1.8739e-01,
806 1.5998e-01, 1.3601e-01, 1.1548e-01, 9.7811e-02,
807 8.2707e-02, 6.9900e-02, 5.9197e-02, 5.0157e-02,
808 4.2535e-02, 3.6140e-02, 3.0782e-02, 2.6233e-02,
809 2.2363e-02},
810 {1.9635e-02, 2.3167e-02, 2.7343e-02, 3.2293e-02,
811 3.8224e-02, 4.5335e-02, 5.3849e-02, 6.4039e-02,
812 7.6210e-02, 9.0739e-02, 1.0805e-01, 1.2841e-01,
813 1.5216e-01, 1.7960e-01, 2.1099e-01, 2.4671e-01,
814 2.8647e-01, 3.2996e-01, 3.7660e-01, 4.2547e-01,
815 4.7536e-01, 5.2473e-01, 5.7215e-01, 6.1632e-01,
816 6.5616e-01, 6.9075e-01, 7.1939e-01, 7.4199e-01,
817 7.5838e-01, 7.6848e-01, 7.7227e-01, 7.6848e-01,
818 7.5838e-01, 7.4199e-01, 7.1939e-01, 6.9075e-01,
819 6.5616e-01, 6.1632e-01, 5.7215e-01, 5.2473e-01,
820 4.7536e-01, 4.2547e-01, 3.7660e-01, 3.2996e-01,
821 2.8647e-01, 2.4671e-01, 2.1099e-01, 1.7960e-01,
822 1.5216e-01, 1.2841e-01, 1.0805e-01, 9.0739e-02,
823 7.6210e-02, 6.4039e-02, 5.3849e-02, 4.5335e-02,
824 3.8224e-02, 3.2293e-02, 2.7343e-02, 2.3167e-02,
825 1.9635e-02},
826 {1.7224e-02, 2.0450e-02, 2.4286e-02, 2.8860e-02,
827 3.4357e-02, 4.0979e-02, 4.8966e-02, 5.8612e-02,
828 7.0253e-02, 8.4257e-02, 1.0102e-01, 1.2094e-01,
829 1.4442e-01, 1.7196e-01, 2.0381e-01, 2.4013e-01,
830 2.8093e-01, 3.2594e-01, 3.7450e-01, 4.2563e-01,
831 4.7796e-01, 5.2991e-01, 5.7974e-01, 6.2599e-01,
832 6.6750e-01, 7.0344e-01, 7.3329e-01, 7.5676e-01,
833 7.7371e-01, 7.8410e-01, 7.8793e-01, 7.8410e-01,
834 7.7371e-01, 7.5676e-01, 7.3329e-01, 7.0344e-01,
835 6.6750e-01, 6.2599e-01, 5.7974e-01, 5.2991e-01,
836 4.7796e-01, 4.2563e-01, 3.7450e-01, 3.2594e-01,
837 2.8093e-01, 2.4013e-01, 2.0381e-01, 1.7196e-01,
838 1.4442e-01, 1.2094e-01, 1.0102e-01, 8.4257e-02,
839 7.0253e-02, 5.8612e-02, 4.8966e-02, 4.0979e-02,
840 3.4357e-02, 2.8860e-02, 2.4286e-02, 2.0450e-02,
841 1.7224e-02},
842 {1.5096e-02, 1.8041e-02, 2.1566e-02, 2.5793e-02,
843 3.0886e-02, 3.7044e-02, 4.4515e-02, 5.3604e-02,
844 6.4668e-02, 7.8109e-02, 9.4364e-02, 1.1389e-01,
845 1.3716e-01, 1.6461e-01, 1.9663e-01, 2.3350e-01,
846 2.7527e-01, 3.2170e-01, 3.7214e-01, 4.2549e-01,
847 4.8024e-01, 5.3460e-01, 5.8677e-01, 6.3512e-01,
848 6.7838e-01, 7.1569e-01, 7.4655e-01, 7.7071e-01,
849 7.8810e-01, 7.9871e-01, 8.0255e-01, 7.9871e-01,
850 7.8810e-01, 7.7071e-01, 7.4655e-01, 7.1569e-01,
851 6.7838e-01, 6.3512e-01, 5.8677e-01, 5.3460e-01,
852 4.8024e-01, 4.2549e-01, 3.7214e-01, 3.2170e-01,
853 2.7527e-01, 2.3350e-01, 1.9663e-01, 1.6461e-01,
854 1.3716e-01, 1.1389e-01, 9.4364e-02, 7.8109e-02,
855 6.4668e-02, 5.3604e-02, 4.4515e-02, 3.7044e-02,
856 3.0886e-02, 2.5793e-02, 2.1566e-02, 1.8041e-02,
857 1.5096e-02}};
858
859 // More sampling precision with linear interpolation
860 fPadResponse.fPRFlo = -1.5;
861 fPadResponse.fPRFhi = 1.5;
862 Float_t pad[kPRFbin];
863 Int_t sPRFbin = kPRFbin;
864 Float_t sPRFwid = (fPadResponse.fPRFhi - fPadResponse.fPRFlo) / ((Float_t) sPRFbin);
865 for (Int_t iPad = 0; iPad < sPRFbin; iPad++) {
866 pad[iPad] = ((Float_t) iPad + 0.5) * sPRFwid + fPadResponse.fPRFlo;
867 }
868 fPadResponse.fPRFbin = 500;
869 fPadResponse.fPRFwid = (fPadResponse.fPRFhi - fPadResponse.fPRFlo) / ((Float_t) fPadResponse.fPRFbin);
870 fPadResponse.fPRFpad = ((Int_t) (1.0 / fPadResponse.fPRFwid));
871
872 if (fPadResponse.fPRFsmp) delete [] fPadResponse.fPRFsmp;
873 fPadResponse.fPRFsmp = new Float_t[kNplan*fPadResponse.fPRFbin];
874
875 Int_t ipos1;
876 Int_t ipos2;
877 Float_t diff;
878
879 for (Int_t iPla = 0; iPla < kNplan; iPla++) {
880
881 for (Int_t iBin = 0; iBin < fPadResponse.fPRFbin; iBin++) {
882
883 Float_t bin = (((Float_t) iBin) + 0.5) * fPadResponse.fPRFwid + fPadResponse.fPRFlo;
884 ipos1 = ipos2 = 0;
885 diff = 0;
886 do {
887 diff = bin - pad[ipos2++];
888 } while ((diff > 0) && (ipos2 < kPRFbin));
889 if (ipos2 == kPRFbin) {
890 fPadResponse.fPRFsmp[iPla*fPadResponse.fPRFbin+iBin] = prf[iPla][ipos2-1];
891 }
892 else if (ipos2 == 1) {
893 fPadResponse.fPRFsmp[iPla*fPadResponse.fPRFbin+iBin] = prf[iPla][ipos2-1];
894 }
895 else {
896 ipos2--;
897 if (ipos2 >= kPRFbin) ipos2 = kPRFbin - 1;
898 ipos1 = ipos2 - 1;
899 fPadResponse.fPRFsmp[iPla*fPadResponse.fPRFbin+iBin] = prf[iPla][ipos2]
900 + diff * (prf[iPla][ipos2] - prf[iPla][ipos1])
901 / sPRFwid;
902 }
903
904 }
905 }
906
907}
908
909//_____________________________________________________________________________
910Int_t AliTRDcalibDB::PadResponse(Double_t signal, Double_t dist
2745a409 911 , Int_t plane, Double_t *pad) const
6a739e92 912{
913 //
914 // Applies the pad response
915 //
916
917 Int_t iBin = ((Int_t) (( - dist - fPadResponse.fPRFlo) / fPadResponse.fPRFwid));
918 Int_t iOff = plane * fPadResponse.fPRFbin;
919
920 Int_t iBin0 = iBin - fPadResponse.fPRFpad + iOff;
921 Int_t iBin1 = iBin + iOff;
922 Int_t iBin2 = iBin + fPadResponse.fPRFpad + iOff;
923
924 pad[0] = 0.0;
925 pad[1] = 0.0;
926 pad[2] = 0.0;
927 if ((iBin1 >= 0) && (iBin1 < (fPadResponse.fPRFbin*kNplan))) {
928
929 if (iBin0 >= 0) {
930 pad[0] = signal * fPadResponse.fPRFsmp[iBin0];
931 }
932 pad[1] = signal * fPadResponse.fPRFsmp[iBin1];
933 if (iBin2 < (fPadResponse.fPRFbin*kNplan)) {
934 pad[2] = signal * fPadResponse.fPRFsmp[iBin2];
935 }
936
937 return 1;
938
939 }
940 else {
941
942 return 0;
943
944 }
ab0a4106 945
3551db50 946}
947