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