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