]>
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 | ||
f2391aef | 31 | #include <TROOT.h> |
a7ac01d2 | 32 | #include <TClonesArray.h> |
e232d349 | 33 | #include <TObjArray.h> |
3551db50 | 34 | |
2745a409 | 35 | #include "AliCDBManager.h" |
2745a409 | 36 | #include "AliCDBEntry.h" |
37 | #include "AliLog.h" | |
3551db50 | 38 | |
51a0ce25 | 39 | #include "AliTRDPIDReference.h" |
121fadea | 40 | #include "AliTRDPIDResponseObject.h" |
3551db50 | 41 | #include "AliTRDcalibDB.h" |
a9e22145 | 42 | #include "AliTRDtrapConfig.h" |
43 | #include "AliTRDtrapConfigHandler.h" | |
eda91732 | 44 | #include "AliTRDCommonParam.h" |
56a188ab | 45 | #include "AliTRDgeometry.h" |
3551db50 | 46 | |
7754cd1f | 47 | #include "Cal/AliTRDCalROC.h" |
7754cd1f | 48 | #include "Cal/AliTRDCalPad.h" |
49 | #include "Cal/AliTRDCalDet.h" | |
e232d349 | 50 | #include "Cal/AliTRDCalDCS.h" |
d6a1ec13 | 51 | #include "Cal/AliTRDCalDCSv2.h" |
ea3eaa08 | 52 | #include "Cal/AliTRDCalDCSFEEv2.h" |
720a0a16 | 53 | #include "Cal/AliTRDCalPID.h" |
7754cd1f | 54 | #include "Cal/AliTRDCalMonitoring.h" |
7754cd1f | 55 | #include "Cal/AliTRDCalChamberStatus.h" |
7754cd1f | 56 | #include "Cal/AliTRDCalPadStatus.h" |
57 | #include "Cal/AliTRDCalSingleChamberStatus.h" | |
9dcc64cc | 58 | #include "Cal/AliTRDCalTrkAttach.h" |
ea3eaa08 | 59 | #include "Cal/AliTRDCalOnlineGainTable.h" |
3551db50 | 60 | |
61 | ClassImp(AliTRDcalibDB) | |
62 | ||
2745a409 | 63 | AliTRDcalibDB *AliTRDcalibDB::fgInstance = 0; |
64 | Bool_t AliTRDcalibDB::fgTerminated = kFALSE; | |
3551db50 | 65 | |
66 | //_ singleton implementation __________________________________________________ | |
67 | AliTRDcalibDB* AliTRDcalibDB::Instance() | |
68 | { | |
69 | // | |
70 | // Singleton implementation | |
71 | // Returns an instance of this class, it is created if neccessary | |
63a700c6 | 72 | // |
3551db50 | 73 | |
6d50f529 | 74 | if (fgTerminated != kFALSE) { |
3551db50 | 75 | return 0; |
6d50f529 | 76 | } |
3551db50 | 77 | |
6d50f529 | 78 | if (fgInstance == 0) { |
3551db50 | 79 | fgInstance = new AliTRDcalibDB(); |
6d50f529 | 80 | } |
e254cad1 | 81 | |
3551db50 | 82 | return fgInstance; |
4e009ce4 | 83 | |
3551db50 | 84 | } |
85 | ||
2745a409 | 86 | //_____________________________________________________________________________ |
3551db50 | 87 | void AliTRDcalibDB::Terminate() |
88 | { | |
89 | // | |
90 | // Singleton implementation | |
6bf5f0ce | 91 | // Deletes the instance of this class and sets the terminated flag, |
92 | // instances cannot be requested anymore | |
3551db50 | 93 | // This function can be called several times. |
94 | // | |
95 | ||
96 | fgTerminated = kTRUE; | |
97 | ||
6d50f529 | 98 | if (fgInstance != 0) { |
3551db50 | 99 | delete fgInstance; |
100 | fgInstance = 0; | |
101 | } | |
2745a409 | 102 | |
3551db50 | 103 | } |
104 | ||
105 | //_____________________________________________________________________________ | |
106 | AliTRDcalibDB::AliTRDcalibDB() | |
2745a409 | 107 | :TObject() |
108 | ,fRun(-1) | |
6d50f529 | 109 | ,fPRFsmp(0) |
110 | ,fPRFbin(0) | |
111 | ,fPRFlo(0) | |
112 | ,fPRFhi(0) | |
113 | ,fPRFwid(0) | |
114 | ,fPRFpad(0) | |
9dcc64cc | 115 | ,fPIDResponse(NULL) |
ea3eaa08 | 116 | ,fOnlineGainTableID(0) |
a9e22145 | 117 | ,fTrapConfig(0x0) |
f16844ef | 118 | ,fTrapConfigName("") |
119 | ,fTrapConfigVersion("") | |
3551db50 | 120 | { |
121 | // | |
2745a409 | 122 | // Default constructor |
3551db50 | 123 | // |
2745a409 | 124 | // TODO Default runnumber is set to 0, this should be changed later |
125 | // to an invalid value (e.g. -1) to prevent | |
3551db50 | 126 | // TODO invalid calibration data to be used. |
2745a409 | 127 | // |
128 | ||
95867fd1 | 129 | for (Int_t i = 0; i < kCDBCacheSize; ++i) { |
2745a409 | 130 | fCDBCache[i] = 0; |
131 | fCDBEntries[i] = 0; | |
132 | } | |
3551db50 | 133 | |
2745a409 | 134 | // Create the sampled PRF |
135 | SamplePRF(); | |
d4c6453d | 136 | |
2745a409 | 137 | } |
138 | ||
139 | //_____________________________________________________________________________ | |
140 | AliTRDcalibDB::AliTRDcalibDB(const AliTRDcalibDB &c) | |
141 | :TObject(c) | |
6d50f529 | 142 | ,fRun(-1) |
143 | ,fPRFsmp(0) | |
144 | ,fPRFbin(0) | |
145 | ,fPRFlo(0) | |
146 | ,fPRFhi(0) | |
147 | ,fPRFwid(0) | |
148 | ,fPRFpad(0) | |
9dcc64cc | 149 | ,fPIDResponse(NULL) |
ea3eaa08 | 150 | ,fOnlineGainTableID(0) |
a9e22145 | 151 | ,fTrapConfig(0x0) |
f16844ef | 152 | ,fTrapConfigName("") |
153 | ,fTrapConfigVersion("") | |
2745a409 | 154 | { |
155 | // | |
156 | // Copy constructor (not that it make any sense for a singleton...) | |
157 | // | |
158 | ||
95867fd1 | 159 | for (Int_t i = 0; i < kCDBCacheSize; ++i) { |
2745a409 | 160 | fCDBCache[i] = 0; |
3551db50 | 161 | fCDBEntries[i] = 0; |
162 | } | |
6a739e92 | 163 | |
164 | // Create the sampled PRF | |
165 | SamplePRF(); | |
2745a409 | 166 | |
167 | } | |
168 | ||
169 | //_____________________________________________________________________________ | |
170 | AliTRDcalibDB &AliTRDcalibDB::operator=(const AliTRDcalibDB &c) | |
171 | { | |
172 | // | |
173 | // Assignment operator (same as above ...) | |
174 | // | |
175 | ||
176 | if (this != &c) { | |
177 | AliFatal("No assignment operator defined"); | |
178 | } | |
4e009ce4 | 179 | |
2745a409 | 180 | return *this; |
181 | ||
acba9bad | 182 | } |
3551db50 | 183 | |
184 | //_____________________________________________________________________________ | |
185 | AliTRDcalibDB::~AliTRDcalibDB() | |
186 | { | |
187 | // | |
188 | // destructor | |
189 | // | |
190 | ||
6d50f529 | 191 | if (fPRFsmp) { |
192 | delete [] fPRFsmp; | |
193 | fPRFsmp = 0; | |
6a739e92 | 194 | } |
ea3eaa08 | 195 | |
196 | if (fPIDResponse) { | |
197 | delete fPIDResponse; | |
198 | fPIDResponse = 0x0; | |
199 | } | |
6a739e92 | 200 | |
3551db50 | 201 | Invalidate(); |
2745a409 | 202 | |
acba9bad | 203 | } |
3551db50 | 204 | |
63a700c6 | 205 | //_caching functions____________________________________________________________ |
95867fd1 | 206 | const TObject *AliTRDcalibDB::GetCachedCDBObject(Int_t id) |
63a700c6 | 207 | { |
2745a409 | 208 | // |
209 | // Retrieves a cdb object with the given id. The objects are cached as | |
210 | // long as the run number is not changed. | |
211 | // | |
212 | // Put together the available objects here by using the lines | |
213 | // a) For usual calibration objects: | |
214 | // case kID<Name> : | |
215 | // return CacheCDBEntry(kID<Name>,"TRD/Calib/<Path>"); | |
216 | // break; | |
217 | // See function CacheCDBEntry for details. | |
218 | // and | |
219 | // b) For calibration data which depends on two objects: One containing | |
220 | // a value per detector and one the local fluctuations per pad: | |
221 | // case kID<Name> : | |
222 | // return CacheMergeCDBEntry(kID<Name>,"TRD/Calib/<padPath>","TRD/Calib/<chamberPath>"); | |
223 | // break; | |
224 | // See function CacheMergeCDBEntry for details. | |
225 | // | |
63a700c6 | 226 | |
6d50f529 | 227 | switch (id) { |
2745a409 | 228 | |
229 | // Parameters defined per pad and chamber | |
230 | case kIDVdriftPad : | |
6d50f529 | 231 | return CacheCDBEntry(kIDVdriftPad ,"TRD/Calib/LocalVdrift"); |
2745a409 | 232 | break; |
233 | case kIDVdriftChamber : | |
6d50f529 | 234 | return CacheCDBEntry(kIDVdriftChamber ,"TRD/Calib/ChamberVdrift"); |
2745a409 | 235 | break; |
eda91732 | 236 | case kIDExBChamber : |
237 | return CacheCDBEntry(kIDExBChamber ,"TRD/Calib/ChamberExB"); | |
238 | break; | |
2745a409 | 239 | case kIDT0Pad : |
6d50f529 | 240 | return CacheCDBEntry(kIDT0Pad ,"TRD/Calib/LocalT0"); |
2745a409 | 241 | break; |
242 | case kIDT0Chamber : | |
6d50f529 | 243 | return CacheCDBEntry(kIDT0Chamber ,"TRD/Calib/ChamberT0"); |
2745a409 | 244 | break; |
245 | case kIDGainFactorPad : | |
6d50f529 | 246 | return CacheCDBEntry(kIDGainFactorPad ,"TRD/Calib/LocalGainFactor"); |
2745a409 | 247 | break; |
248 | case kIDGainFactorChamber : | |
6d50f529 | 249 | return CacheCDBEntry(kIDGainFactorChamber ,"TRD/Calib/ChamberGainFactor"); |
2745a409 | 250 | break; |
ea3eaa08 | 251 | |
252 | case kIDOnlineGainFactor : | |
253 | switch(GetOnlineGainTableID()) { | |
254 | case 0: | |
255 | // For testing purposes only !!! | |
256 | AliInfo("No gain table name from OCDB. Use default table!"); | |
257 | return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2011-01"); | |
258 | break; | |
259 | case 1: | |
260 | // Online gain table ID 1 | |
261 | return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2011-01"); | |
262 | break; | |
412d07b9 | 263 | case 2: |
264 | // Online gain table ID 2 | |
265 | return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Gaintbl_Uniform_FGAN0_2011-01"); | |
266 | break; | |
267 | case 3: | |
268 | // Online gain table ID 3 | |
269 | return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Gaintbl_Uniform_FGAN8_2011-01"); | |
270 | break; | |
3abf1c06 | 271 | case 4: |
272 | // Online gain table ID 4 | |
273 | return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2011-02"); | |
274 | break; | |
4a05be5f | 275 | case 5: |
276 | // Online gain table ID 5 | |
277 | return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2011-03"); | |
278 | break; | |
279 | case 6: | |
280 | // Online gain table ID 6 | |
281 | return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Gaintbl_Uniform_FGAN0_2012-01"); | |
282 | break; | |
283 | case 7: | |
284 | // Online gain table ID 7 | |
d9e5ae00 | 285 | return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Gaintbl_Uniform_FGAN8_2012-01"); |
286 | break; | |
287 | case 8: | |
288 | // Online gain table ID 8 | |
289 | return CacheCDBEntry(kIDOnlineGainFactor ,"TRD/Calib/Krypton_2012-01"); | |
4a05be5f | 290 | break; |
56a188ab | 291 | default: |
292 | AliError(Form("unknown gaintable requested with ID")); | |
ea3eaa08 | 293 | } |
294 | break; | |
295 | ||
df83a620 | 296 | case kIDNoiseChamber : |
ea3eaa08 | 297 | return CacheCDBEntry(kIDNoiseChamber ,"TRD/Calib/DetNoise"); |
df83a620 | 298 | break; |
299 | case kIDNoisePad : | |
ea3eaa08 | 300 | return CacheCDBEntry(kIDNoisePad ,"TRD/Calib/PadNoise"); |
df83a620 | 301 | break; |
302 | ||
2745a409 | 303 | // Parameters defined per pad |
304 | case kIDPRFWidth : | |
6d50f529 | 305 | return CacheCDBEntry(kIDPRFWidth ,"TRD/Calib/PRFWidth"); |
2745a409 | 306 | break; |
307 | ||
308 | // Status values | |
2745a409 | 309 | case kIDChamberStatus : |
6d50f529 | 310 | return CacheCDBEntry(kIDChamberStatus ,"TRD/Calib/ChamberStatus"); |
2745a409 | 311 | break; |
2745a409 | 312 | case kIDPadStatus : |
6d50f529 | 313 | return CacheCDBEntry(kIDPadStatus ,"TRD/Calib/PadStatus"); |
2745a409 | 314 | break; |
315 | ||
316 | // Global parameters | |
317 | case kIDMonitoringData : | |
6d50f529 | 318 | return CacheCDBEntry(kIDMonitoringData ,"TRD/Calib/MonitoringData"); |
2745a409 | 319 | break; |
aa617684 | 320 | case kIDFEE : |
321 | return CacheCDBEntry(kIDFEE ,"TRD/Calib/FEE"); | |
2745a409 | 322 | break; |
a9e22145 | 323 | case kIDTrapConfig : |
56a188ab | 324 | return CacheCDBEntry(kIDTrapConfig ,"TRD/Calib/TrapConfig"); |
a9e22145 | 325 | break; |
e232d349 | 326 | case kIDDCS : |
5f481838 | 327 | return CacheCDBEntry(kIDDCS ,"TRD/Calib/DCS"); |
e232d349 | 328 | break; |
44dbae42 | 329 | case kIDPIDNN : |
330 | return CacheCDBEntry(kIDPIDNN ,"TRD/Calib/PIDNN"); | |
ea3eaa08 | 331 | break; |
2745a409 | 332 | case kIDPIDLQ : |
6d50f529 | 333 | return CacheCDBEntry(kIDPIDLQ ,"TRD/Calib/PIDLQ"); |
2745a409 | 334 | break; |
9dcc64cc | 335 | case kIDPIDLQ1D: |
336 | return CacheCDBEntry(kIDPIDLQ1D ,"TRD/Calib/PIDLQ1D"); | |
337 | break; | |
a7ac01d2 | 338 | case kIDRecoParam : |
9dcc64cc | 339 | return CacheCDBEntry(kIDRecoParam ,"TRD/Calib/RecoParam"); |
340 | break; | |
341 | case kIDAttach : | |
342 | return CacheCDBEntry(kIDAttach ,"TRD/Calib/TrkAttach"); | |
a7ac01d2 | 343 | break; |
e2a1c98b | 344 | case kIDPHQ : |
345 | return CacheCDBEntry(kIDPHQ ,"TRD/Calib/PHQ"); | |
346 | break; | |
2745a409 | 347 | } |
348 | ||
349 | return 0; | |
350 | ||
63a700c6 | 351 | } |
352 | ||
353 | //_____________________________________________________________________________ | |
95867fd1 | 354 | AliCDBEntry *AliTRDcalibDB::GetCDBEntry(const char *cdbPath) |
63a700c6 | 355 | { |
356 | // | |
357 | // Retrieves an entry with path <cdbPath> from the CDB. | |
358 | // | |
359 | ||
95867fd1 | 360 | AliCDBEntry *entry = AliCDBManager::Instance()->Get(cdbPath,fRun); |
2745a409 | 361 | if (!entry) { |
a7ac01d2 | 362 | AliError(Form("Failed to get entry: %s",cdbPath)); |
63a700c6 | 363 | return 0; |
364 | } | |
365 | ||
63a700c6 | 366 | return entry; |
2745a409 | 367 | |
63a700c6 | 368 | } |
369 | ||
370 | //_____________________________________________________________________________ | |
95867fd1 | 371 | const TObject *AliTRDcalibDB::CacheCDBEntry(Int_t id, const char *cdbPath) |
63a700c6 | 372 | { |
373 | // | |
374 | // Caches the entry <id> with cdb path <cdbPath> | |
375 | // | |
d6a1ec13 | 376 | |
2745a409 | 377 | if (!fCDBCache[id]) { |
63a700c6 | 378 | fCDBEntries[id] = GetCDBEntry(cdbPath); |
95867fd1 | 379 | if (fCDBEntries[id]) { |
63a700c6 | 380 | fCDBCache[id] = fCDBEntries[id]->GetObject(); |
56a188ab | 381 | if (id == kIDOnlineGainFactor) |
382 | AliInfo(Form("loaded gain table: %s", fCDBEntries[id]->GetId().GetAliCDBPath().GetPath().Data())); | |
95867fd1 | 383 | } |
d6a1ec13 | 384 | } |
385 | ||
63a700c6 | 386 | return fCDBCache[id]; |
ea3eaa08 | 387 | |
63a700c6 | 388 | } |
389 | ||
3551db50 | 390 | //_____________________________________________________________________________ |
391 | void AliTRDcalibDB::SetRun(Long64_t run) | |
392 | { | |
393 | // | |
7754cd1f | 394 | // Sets current run number. Calibration data is read from the corresponding file. |
3551db50 | 395 | // When the run number changes the caching is invalidated. |
396 | // | |
7754cd1f | 397 | |
6d50f529 | 398 | if (fRun == run) { |
3551db50 | 399 | return; |
6d50f529 | 400 | } |
7754cd1f | 401 | |
3551db50 | 402 | fRun = run; |
95867fd1 | 403 | |
3551db50 | 404 | Invalidate(); |
2745a409 | 405 | |
3551db50 | 406 | } |
7754cd1f | 407 | |
3551db50 | 408 | //_____________________________________________________________________________ |
409 | void AliTRDcalibDB::Invalidate() | |
410 | { | |
411 | // | |
412 | // Invalidates cache (when run number is changed). | |
413 | // | |
414 | ||
95867fd1 | 415 | for (Int_t i = 0; i < kCDBCacheSize; ++i) { |
2745a409 | 416 | if (fCDBEntries[i]) { |
417 | if (AliCDBManager::Instance()->GetCacheFlag() == kFALSE) { | |
11f5dd43 | 418 | if ((fCDBEntries[i]->IsOwner() == kFALSE) && |
419 | (fCDBCache[i])) { | |
e254cad1 | 420 | delete fCDBCache[i]; |
2745a409 | 421 | } |
e254cad1 | 422 | delete fCDBEntries[i]; |
423 | } | |
3551db50 | 424 | fCDBEntries[i] = 0; |
2745a409 | 425 | fCDBCache[i] = 0; |
3551db50 | 426 | } |
427 | } | |
2745a409 | 428 | |
ea3eaa08 | 429 | fOnlineGainTableID = 0; |
430 | ||
df83a620 | 431 | } |
ea3eaa08 | 432 | |
df83a620 | 433 | //_____________________________________________________________________________ |
434 | Float_t AliTRDcalibDB::GetNoise(Int_t det, Int_t col, Int_t row) | |
435 | { | |
436 | // | |
437 | // Returns the noise level in ADC counts for the given pad. | |
438 | // | |
439 | ||
440 | const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *> | |
441 | (GetCachedCDBObject(kIDNoisePad)); | |
442 | if (!calPad) { | |
443 | return -1; | |
444 | } | |
445 | ||
446 | AliTRDCalROC *roc = calPad->GetCalROC(det); | |
447 | if (!roc) { | |
448 | return -1; | |
449 | } | |
450 | ||
451 | const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *> | |
452 | (GetCachedCDBObject(kIDNoiseChamber)); | |
453 | if (!calChamber) { | |
454 | return -1; | |
455 | } | |
456 | ||
457 | return calChamber->GetValue(det) * roc->GetValue(col,row); | |
458 | ||
459 | } | |
460 | ||
461 | //_____________________________________________________________________________ | |
462 | AliTRDCalROC *AliTRDcalibDB::GetNoiseROC(Int_t det) | |
463 | { | |
464 | // | |
465 | // Returns the Vdrift calibration object for a given ROC | |
466 | // containing one number per pad | |
467 | // | |
468 | ||
469 | const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *> | |
470 | (GetCachedCDBObject(kIDNoisePad)); | |
471 | if (!calPad) { | |
472 | return 0; | |
473 | } | |
474 | ||
475 | AliTRDCalROC *roc = calPad->GetCalROC(det); | |
476 | if (!roc) { | |
477 | return 0; | |
478 | } | |
479 | else { | |
480 | return roc; | |
481 | } | |
482 | ||
483 | } | |
484 | ||
485 | //_____________________________________________________________________________ | |
486 | const AliTRDCalDet *AliTRDcalibDB::GetNoiseDet() | |
487 | { | |
488 | // | |
489 | // Returns the Vdrift calibration object | |
490 | // containing one number per detector | |
491 | // | |
492 | ||
493 | const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *> | |
494 | (GetCachedCDBObject(kIDNoiseChamber)); | |
495 | if (!calChamber) { | |
496 | return 0; | |
497 | } | |
498 | else { | |
499 | return calChamber; | |
500 | } | |
501 | ||
3551db50 | 502 | } |
503 | ||
3551db50 | 504 | //_____________________________________________________________________________ |
505 | Float_t AliTRDcalibDB::GetVdrift(Int_t det, Int_t col, Int_t row) | |
506 | { | |
507 | // | |
508 | // Returns the drift velocity for the given pad. | |
509 | // | |
7754cd1f | 510 | |
95867fd1 | 511 | const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *> |
6d50f529 | 512 | (GetCachedCDBObject(kIDVdriftPad)); |
513 | if (!calPad) { | |
3551db50 | 514 | return -1; |
6d50f529 | 515 | } |
3551db50 | 516 | |
95867fd1 | 517 | AliTRDCalROC *roc = calPad->GetCalROC(det); |
6d50f529 | 518 | if (!roc) { |
3551db50 | 519 | return -1; |
6d50f529 | 520 | } |
3551db50 | 521 | |
95867fd1 | 522 | const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *> |
6d50f529 | 523 | (GetCachedCDBObject(kIDVdriftChamber)); |
524 | if (!calChamber) { | |
7754cd1f | 525 | return -1; |
6d50f529 | 526 | } |
7754cd1f | 527 | |
95867fd1 | 528 | return calChamber->GetValue(det) * roc->GetValue(col,row); |
2745a409 | 529 | |
7754cd1f | 530 | } |
afb9f880 | 531 | |
532 | //_____________________________________________________________________________ | |
533 | AliTRDCalROC *AliTRDcalibDB::GetVdriftROC(Int_t det) | |
534 | { | |
535 | // | |
536 | // Returns the Vdrift calibration object for a given ROC | |
537 | // containing one number per pad | |
538 | // | |
539 | ||
540 | const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *> | |
541 | (GetCachedCDBObject(kIDVdriftPad)); | |
542 | if (!calPad) { | |
543 | return 0; | |
544 | } | |
545 | ||
546 | AliTRDCalROC *roc = calPad->GetCalROC(det); | |
547 | if (!roc) { | |
548 | return 0; | |
549 | } | |
550 | else { | |
551 | return roc; | |
552 | } | |
553 | ||
554 | } | |
555 | ||
556 | //_____________________________________________________________________________ | |
557 | const AliTRDCalDet *AliTRDcalibDB::GetVdriftDet() | |
558 | { | |
559 | // | |
560 | // Returns the Vdrift calibration object | |
561 | // containing one number per detector | |
562 | // | |
563 | ||
564 | const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *> | |
565 | (GetCachedCDBObject(kIDVdriftChamber)); | |
566 | if (!calChamber) { | |
567 | return 0; | |
568 | } | |
569 | else { | |
570 | return calChamber; | |
571 | } | |
572 | ||
573 | } | |
7754cd1f | 574 | |
e2a1c98b | 575 | //_____________________________________________________________________________ |
576 | TObjArray * AliTRDcalibDB::GetPHQ() | |
577 | { | |
578 | // | |
579 | //return PHQ calibration object | |
580 | // | |
581 | TObjArray *arr = (TObjArray *) (GetCachedCDBObject(kIDPHQ)); | |
582 | return arr; | |
583 | } | |
584 | ||
7754cd1f | 585 | //_____________________________________________________________________________ |
586 | Float_t AliTRDcalibDB::GetVdriftAverage(Int_t det) | |
587 | { | |
588 | // | |
589 | // Returns the average drift velocity for the given detector | |
590 | // | |
591 | ||
95867fd1 | 592 | const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *> |
6d50f529 | 593 | (GetCachedCDBObject(kIDVdriftChamber)); |
594 | if (!calDet) { | |
7754cd1f | 595 | return -1; |
6d50f529 | 596 | } |
7754cd1f | 597 | |
598 | return calDet->GetValue(det); | |
2745a409 | 599 | |
acba9bad | 600 | } |
eda91732 | 601 | //_____________________________________________________________________________ |
602 | const AliTRDCalDet *AliTRDcalibDB::GetExBDet() | |
603 | { | |
604 | // | |
605 | // Returns the exB calibration object | |
606 | // containing one number per detector | |
607 | // | |
608 | ||
609 | const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *> (GetCachedCDBObject(kIDExBChamber)); | |
610 | ||
611 | Double_t meanexb = 100.0; | |
612 | if (calChamber) meanexb = calChamber->GetMean(); | |
613 | //printf("mean %f\n",meanexb); | |
3551db50 | 614 | |
eda91732 | 615 | if ((!calChamber) || (meanexb > 70.0)) { |
616 | ||
617 | const AliTRDCalDet *calChambervdrift = dynamic_cast<const AliTRDCalDet *> | |
618 | (GetCachedCDBObject(kIDVdriftChamber)); | |
619 | if (!calChambervdrift) { | |
620 | return 0; | |
621 | } | |
622 | else { | |
623 | AliTRDCalDet *calDetExB = new AliTRDCalDet("lorentz angle tan","lorentz angle tan (detector value)"); | |
624 | for(Int_t k = 0; k < 540; k++){ | |
625 | calDetExB->SetValue(k,AliTRDCommonParam::Instance()->GetOmegaTau(calChambervdrift->GetValue(k))); | |
eda91732 | 626 | } |
627 | return calDetExB; | |
628 | } | |
629 | } | |
630 | else return calChamber; | |
631 | ||
632 | } | |
3551db50 | 633 | //_____________________________________________________________________________ |
634 | Float_t AliTRDcalibDB::GetT0(Int_t det, Int_t col, Int_t row) | |
635 | { | |
636 | // | |
637 | // Returns t0 for the given pad. | |
638 | // | |
639 | ||
d4c6453d | 640 | const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *> |
641 | (GetCachedCDBObject(kIDT0Pad)); | |
6d50f529 | 642 | if (!calPad) { |
3551db50 | 643 | return -1; |
6d50f529 | 644 | } |
3551db50 | 645 | |
d4c6453d | 646 | AliTRDCalROC *roc = calPad->GetCalROC(det); |
6d50f529 | 647 | if (!roc) { |
3551db50 | 648 | return -1; |
6d50f529 | 649 | } |
3551db50 | 650 | |
d4c6453d | 651 | const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *> |
652 | (GetCachedCDBObject(kIDT0Chamber)); | |
6d50f529 | 653 | if (!calChamber) { |
7754cd1f | 654 | return -1; |
6d50f529 | 655 | } |
7754cd1f | 656 | |
8d786fb8 | 657 | return calChamber->GetValue(det) + roc->GetValue(col,row); |
2745a409 | 658 | |
7754cd1f | 659 | } |
afb9f880 | 660 | |
56178ff4 | 661 | //_____________________________________________________________________________ |
662 | AliTRDCalROC *AliTRDcalibDB::GetT0ROC(Int_t det) | |
663 | { | |
664 | // | |
665 | // Returns the t0 calibration object for a given ROC | |
666 | // containing one number per pad | |
667 | // | |
668 | ||
669 | const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *> | |
670 | (GetCachedCDBObject(kIDT0Pad)); | |
671 | if (!calPad) { | |
672 | return 0; | |
673 | } | |
674 | ||
675 | AliTRDCalROC *roc = calPad->GetCalROC(det); | |
676 | if (!roc) { | |
677 | return 0; | |
678 | } | |
679 | else { | |
680 | return roc; | |
681 | } | |
682 | ||
683 | } | |
684 | ||
685 | //_____________________________________________________________________________ | |
686 | const AliTRDCalDet *AliTRDcalibDB::GetT0Det() | |
687 | { | |
688 | // | |
689 | // Returns the t0 calibration object | |
690 | // containing one number per detector | |
691 | // | |
692 | ||
693 | const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *> | |
694 | (GetCachedCDBObject(kIDT0Chamber)); | |
695 | if (!calChamber) { | |
696 | return 0; | |
697 | } | |
698 | else { | |
699 | return calChamber; | |
700 | } | |
701 | ||
702 | } | |
703 | ||
7754cd1f | 704 | //_____________________________________________________________________________ |
705 | Float_t AliTRDcalibDB::GetT0Average(Int_t det) | |
706 | { | |
707 | // | |
708 | // Returns the average t0 for the given detector | |
709 | // | |
710 | ||
5aba4f09 | 711 | const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *> |
712 | (GetCachedCDBObject(kIDT0Pad)); | |
713 | if (!calPad) { | |
714 | return -1; | |
715 | } | |
716 | ||
717 | AliTRDCalROC *roc = calPad->GetCalROC(det); | |
718 | if (!roc) { | |
719 | return -1; | |
720 | } | |
721 | ||
95867fd1 | 722 | const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *> |
6d50f529 | 723 | (GetCachedCDBObject(kIDT0Chamber)); |
724 | if (!calDet) { | |
7754cd1f | 725 | return -1; |
6d50f529 | 726 | } |
7754cd1f | 727 | |
4eb02ab1 | 728 | Double_t sum = 0.0; |
5aba4f09 | 729 | for (Int_t channel = 0; channel < roc->GetNchannels(); ++channel) { |
4eb02ab1 | 730 | sum += roc->GetValue(channel); |
5aba4f09 | 731 | } |
4eb02ab1 | 732 | sum /= roc->GetNchannels(); |
733 | sum += calDet->GetValue(det); | |
734 | return sum; | |
2745a409 | 735 | |
acba9bad | 736 | } |
3551db50 | 737 | |
ea3eaa08 | 738 | //_____________________________________________________________________________ |
739 | AliTRDCalOnlineGainTableROC* AliTRDcalibDB::GetOnlineGainTableROC(Int_t det) | |
740 | { | |
741 | // | |
742 | // Returns the online gain factor table for a given ROC. | |
743 | // | |
c36ddf52 | 744 | |
745 | if (!HasOnlineFilterGain()) { | |
746 | return 0x0; | |
747 | } | |
ea3eaa08 | 748 | |
749 | const AliTRDCalOnlineGainTable *calOnline | |
750 | = dynamic_cast<const AliTRDCalOnlineGainTable *> | |
751 | (GetCachedCDBObject(kIDOnlineGainFactor)); | |
752 | if (!calOnline) { | |
753 | return 0x0; | |
754 | } | |
755 | ||
756 | return calOnline->GetGainTableROC(det); | |
757 | ||
758 | } | |
759 | ||
760 | //_____________________________________________________________________________ | |
761 | Float_t AliTRDcalibDB::GetOnlineGainFactor(Int_t det, Int_t col, Int_t row) | |
762 | { | |
763 | // | |
764 | // Returns the online gain factor for the given pad. | |
765 | // | |
c36ddf52 | 766 | |
767 | if (!HasOnlineFilterGain()) { | |
6c3e7ad0 | 768 | return -1; |
c36ddf52 | 769 | } |
ea3eaa08 | 770 | |
771 | const AliTRDCalOnlineGainTable *calOnline | |
772 | = dynamic_cast<const AliTRDCalOnlineGainTable *> | |
773 | (GetCachedCDBObject(kIDOnlineGainFactor)); | |
774 | if (!calOnline) { | |
775 | return -1; | |
776 | } | |
777 | ||
778 | return calOnline->GetGainCorrectionFactor(det,row,col); | |
779 | ||
780 | } | |
781 | ||
56178ff4 | 782 | //_____________________________________________________________________________ |
783 | AliTRDCalROC *AliTRDcalibDB::GetGainFactorROC(Int_t det) | |
784 | { | |
785 | // | |
786 | // Returns the gain factor calibration object for a given ROC | |
56178ff4 | 787 | // |
788 | ||
789 | const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *> | |
790 | (GetCachedCDBObject(kIDGainFactorPad)); | |
791 | if (!calPad) { | |
792 | return 0; | |
793 | } | |
794 | ||
795 | AliTRDCalROC *roc = calPad->GetCalROC(det); | |
796 | if (!roc) { | |
797 | return 0; | |
798 | } | |
799 | else { | |
800 | return roc; | |
801 | } | |
802 | ||
803 | } | |
804 | ||
c36ddf52 | 805 | //_____________________________________________________________________________ |
806 | Float_t AliTRDcalibDB::GetGainFactor(Int_t det, Int_t col, Int_t row) | |
807 | { | |
808 | // | |
809 | // Returns the gain factor for the given pad. | |
810 | // | |
811 | ||
812 | const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *> | |
813 | (GetCachedCDBObject(kIDGainFactorPad)); | |
814 | if (!calPad) { | |
815 | return -1; | |
816 | } | |
817 | ||
818 | AliTRDCalROC *roc = calPad->GetCalROC(det); | |
819 | if (!roc) { | |
820 | return -1; | |
821 | } | |
822 | ||
823 | const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *> | |
824 | (GetCachedCDBObject(kIDGainFactorChamber)); | |
825 | if (!calChamber) { | |
826 | return -1; | |
827 | } | |
828 | ||
829 | return calChamber->GetValue(det) * roc->GetValue(col,row); | |
830 | ||
831 | } | |
832 | ||
56178ff4 | 833 | //_____________________________________________________________________________ |
834 | const AliTRDCalDet *AliTRDcalibDB::GetGainFactorDet() | |
835 | { | |
836 | // | |
837 | // Returns the gain factor calibration object | |
838 | // containing one number per detector | |
839 | // | |
840 | ||
841 | const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *> | |
842 | (GetCachedCDBObject(kIDGainFactorChamber)); | |
843 | if (!calChamber) { | |
844 | return 0; | |
845 | } | |
846 | else { | |
847 | return calChamber; | |
848 | } | |
849 | ||
850 | } | |
851 | ||
7754cd1f | 852 | //_____________________________________________________________________________ |
853 | Float_t AliTRDcalibDB::GetGainFactorAverage(Int_t det) | |
854 | { | |
855 | // | |
856 | // Returns the average gain factor for the given detector | |
857 | // | |
858 | ||
95867fd1 | 859 | const AliTRDCalDet *calDet = dynamic_cast<const AliTRDCalDet *> |
6d50f529 | 860 | (GetCachedCDBObject(kIDGainFactorChamber)); |
861 | if (!calDet) { | |
7754cd1f | 862 | return -1; |
6d50f529 | 863 | } |
7754cd1f | 864 | |
865 | return calDet->GetValue(det); | |
2745a409 | 866 | |
acba9bad | 867 | } |
6a739e92 | 868 | |
524fc8fa | 869 | //_____________________________________________________________________________ |
870 | AliTRDCalROC *AliTRDcalibDB::GetPRFROC(Int_t det) | |
871 | { | |
872 | // | |
873 | // Returns the PRF calibration object for a given ROC | |
874 | // containing one number per pad | |
875 | // | |
876 | ||
877 | const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *> | |
878 | (GetCachedCDBObject(kIDPRFWidth)); | |
879 | if (!calPad) { | |
880 | return 0; | |
881 | } | |
882 | ||
883 | AliTRDCalROC *roc = calPad->GetCalROC(det); | |
884 | if (!roc) { | |
885 | return 0; | |
886 | } | |
887 | else { | |
888 | return roc; | |
889 | } | |
890 | ||
891 | } | |
892 | ||
6a739e92 | 893 | //_____________________________________________________________________________ |
894 | Float_t AliTRDcalibDB::GetPRFWidth(Int_t det, Int_t col, Int_t row) | |
895 | { | |
896 | // | |
897 | // Returns the PRF width for the given pad. | |
898 | // | |
899 | ||
95867fd1 | 900 | const AliTRDCalPad *calPad = dynamic_cast<const AliTRDCalPad *> |
6d50f529 | 901 | (GetCachedCDBObject(kIDPRFWidth)); |
902 | if (!calPad) { | |
6a739e92 | 903 | return -1; |
6d50f529 | 904 | } |
6a739e92 | 905 | |
95867fd1 | 906 | AliTRDCalROC *roc = calPad->GetCalROC(det); |
6d50f529 | 907 | if (!roc) { |
6a739e92 | 908 | return -1; |
6d50f529 | 909 | } |
6a739e92 | 910 | |
95867fd1 | 911 | return roc->GetValue(col,row); |
2745a409 | 912 | |
acba9bad | 913 | } |
3551db50 | 914 | |
915 | //_____________________________________________________________________________ | |
5b7ccf04 | 916 | Int_t AliTRDcalibDB::ExtractTimeBinsFromString(TString tbstr) |
3551db50 | 917 | { |
a835b5d7 | 918 | // Check if there is any content in the string first |
919 | if (tbstr.Length() == 0) { | |
920 | AliError("Parameter for number of timebins is empty!"); | |
6c3e7ad0 | 921 | return -1; |
e232d349 | 922 | } |
c6f7c6cb | 923 | |
a835b5d7 | 924 | // Check if we have the correct config parameter |
925 | TString tbident = "tb"; | |
926 | TString tbsubstr = tbstr(0,2); | |
927 | if (!tbsubstr.EqualTo(tbident)) { | |
928 | AliError(Form("Parameter for number of timebins is corrupted (%s)!", tbstr.Data())); | |
6c3e7ad0 | 929 | return -1; |
a835b5d7 | 930 | } |
c6f7c6cb | 931 | |
a835b5d7 | 932 | tbstr.Remove(0,2); |
933 | // check if there is more than a number | |
934 | if (!tbstr.IsDigit()) { | |
935 | AliError(Form("Parameter for number of timebins is corrupted (%s)!", tbstr.Data())); | |
6c3e7ad0 | 936 | return -1; |
e232d349 | 937 | } |
d6a1ec13 | 938 | |
5b7ccf04 | 939 | return tbstr.Atoi(); |
c6f7c6cb | 940 | |
5b7ccf04 | 941 | } |
942 | ||
943 | //_____________________________________________________________________________ | |
944 | Int_t AliTRDcalibDB::GetNumberOfTimeBinsDCS() | |
945 | { | |
946 | // | |
947 | // Returns number of time bins from the DCS | |
948 | // | |
949 | ||
950 | // Get the corresponding parameter | |
951 | TString cfgstr = "", cfgname = ""; | |
952 | GetGlobalConfiguration(cfgname); | |
6c3e7ad0 | 953 | if(cfgname.Length()==0) |
954 | return -1; | |
5b7ccf04 | 955 | GetDCSConfigParOption(cfgname, kTimebin, 0, cfgstr); |
6c3e7ad0 | 956 | if(cfgstr.Length()==0) |
957 | return -1; | |
5b7ccf04 | 958 | return ExtractTimeBinsFromString(cfgstr); |
ea3eaa08 | 959 | |
e232d349 | 960 | } |
961 | ||
962 | //_____________________________________________________________________________ | |
f1dcad37 | 963 | void AliTRDcalibDB::GetFilterType(TString &filterType) |
964 | { | |
965 | // | |
966 | // Returns the filter type | |
967 | // | |
968 | ||
5b7ccf04 | 969 | TString cfgname = ""; |
970 | GetGlobalConfiguration(cfgname); | |
971 | GetDCSConfigParOption(cfgname, kFltrSet, 0, filterType); | |
d6a1ec13 | 972 | |
af086c5e | 973 | } |
974 | ||
975 | //_____________________________________________________________________________ | |
ea3eaa08 | 976 | Int_t AliTRDcalibDB::GetOnlineGainTableID() |
977 | { | |
978 | // | |
979 | // Get the gain table ID from the DCS | |
980 | // | |
981 | ||
982 | if (fOnlineGainTableID > 0) { | |
983 | return fOnlineGainTableID; | |
984 | } | |
985 | ||
986 | const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS)); | |
987 | if (!dcsArr){ | |
988 | return -1; | |
989 | } | |
990 | ||
991 | Int_t esor = 0; // Take SOR | |
992 | Int_t calver = 0; // Check CalDCS version | |
993 | if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1; | |
994 | if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2; | |
995 | ||
996 | if (calver == 1) { | |
997 | ||
998 | // No data for old DCS object available, anyway | |
999 | return -1; | |
1000 | ||
1001 | } | |
1002 | else if (calver == 2) { | |
1003 | ||
1004 | // DCSv2 object | |
1005 | const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(esor)); | |
1006 | if(!calDCSv2){ | |
1007 | return -1; | |
1008 | } | |
1009 | ||
1010 | TString tableName = ""; | |
1011 | for (Int_t i = 0; i < 540; i++) { | |
1012 | const AliTRDCalDCSFEEv2 *calDCSFEEv2 = calDCSv2->GetCalDCSFEEObj(0); | |
1013 | tableName = calDCSFEEv2->GetGainTableName(); | |
1014 | if (tableName.Length() > 0) { | |
1015 | break; | |
1016 | } | |
1017 | } | |
56a188ab | 1018 | if (tableName.CompareTo("Krypton_2011-01") == 0) |
ea3eaa08 | 1019 | fOnlineGainTableID = 1; |
56a188ab | 1020 | else if (tableName.CompareTo("Gaintbl_Uniform_FGAN0_2011-01") == 0) |
412d07b9 | 1021 | fOnlineGainTableID = 2; |
56a188ab | 1022 | else if (tableName.CompareTo("Gaintbl_Uniform_FGAN8_2011-01") == 0) |
412d07b9 | 1023 | fOnlineGainTableID = 3; |
56a188ab | 1024 | else if (tableName.CompareTo("Krypton_2011-02") == 0) |
3abf1c06 | 1025 | fOnlineGainTableID = 4; |
56a188ab | 1026 | else if (tableName.CompareTo("Krypton_2011-03") == 0) |
4a05be5f | 1027 | fOnlineGainTableID = 5; |
56a188ab | 1028 | else if (tableName.CompareTo("Gaintbl_Uniform_FGAN0_2012-01") == 0) |
4a05be5f | 1029 | fOnlineGainTableID = 6; |
56a188ab | 1030 | else if (tableName.CompareTo("Gaintbl_Uniform_FGAN8_2012-01") == 0) |
4a05be5f | 1031 | fOnlineGainTableID = 7; |
56a188ab | 1032 | else if (tableName.CompareTo("Krypton_2012-01") == 0) |
d9e5ae00 | 1033 | fOnlineGainTableID = 8; |
56a188ab | 1034 | else |
1035 | AliFatal(Form("unknown gaintable <%s> requested", tableName.Data())); | |
1036 | ||
1037 | AliInfo(Form("looking for gaintable: %s (id %i)", | |
1038 | tableName.Data(), fOnlineGainTableID)); | |
ea3eaa08 | 1039 | |
56a188ab | 1040 | if (fOnlineGainTableID > 0) |
1041 | return fOnlineGainTableID; | |
ea3eaa08 | 1042 | } |
1043 | else { | |
1044 | ||
1045 | AliError("NO DCS/DCSv2 OCDB entry found!"); | |
1046 | return -1; | |
1047 | ||
1048 | } | |
1049 | ||
45b38fb0 | 1050 | return -1; |
1051 | ||
ea3eaa08 | 1052 | } |
1053 | ||
1054 | //_____________________________________________________________________________ | |
1055 | void AliTRDcalibDB::GetGlobalConfiguration(TString &config) | |
1056 | { | |
af086c5e | 1057 | // |
1058 | // Get Configuration from the DCS | |
1059 | // | |
d6a1ec13 | 1060 | |
af086c5e | 1061 | const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS)); |
1062 | if(!dcsArr){ | |
a835b5d7 | 1063 | AliError("No DCS CDB Object available!"); |
af086c5e | 1064 | config = ""; |
1065 | return; | |
1066 | } | |
d6a1ec13 | 1067 | |
a835b5d7 | 1068 | Int_t idSOR = 0, idEOR=1; // The index of SOR and EOR |
1069 | Bool_t hasSOR = (dcsArr->At(idSOR)); | |
1070 | Bool_t hasEOR = (dcsArr->At(idEOR)); | |
1071 | TString cfgSOR = "", cfgEOR = ""; // The configuration at SOR/EOR | |
d6a1ec13 | 1072 | |
a835b5d7 | 1073 | // The SOR object is mandatory |
1074 | if (!hasSOR) { | |
1075 | AliError("NO SOR object found in CDB file!"); | |
1076 | config = ""; | |
1077 | return; | |
1078 | } | |
1079 | if (!hasEOR) AliWarning("NO EOR object found in CDB file!"); | |
ea3eaa08 | 1080 | |
a835b5d7 | 1081 | // Check CalDCS version |
1082 | Int_t calver = 0; | |
1083 | if (!strcmp(dcsArr->At(idSOR)->ClassName(),"AliTRDCalDCS")) calver = 1; | |
1084 | else if (!strcmp(dcsArr->At(idSOR)->ClassName(),"AliTRDCalDCSv2")) calver = 2; | |
ea3eaa08 | 1085 | |
a835b5d7 | 1086 | // Get the configuration strings |
1087 | if (calver == 1) { | |
1088 | // DCS object | |
1089 | const AliTRDCalDCS *calSOR = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(idSOR)); | |
1090 | cfgSOR = calSOR->GetGlobalConfigName(); | |
1091 | if (hasEOR) { | |
1092 | const AliTRDCalDCS *calEOR = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(idEOR)); | |
1093 | cfgEOR = calEOR->GetGlobalConfigName(); | |
1094 | } | |
ea3eaa08 | 1095 | } |
1096 | else if (calver == 2) { | |
d6a1ec13 | 1097 | // DCSv2 object |
a835b5d7 | 1098 | const AliTRDCalDCSv2 *calv2SOR = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(idSOR)); |
1099 | cfgSOR = calv2SOR->GetGlobalConfigName(); | |
1100 | if (hasEOR) { | |
1101 | const AliTRDCalDCSv2 *calv2EOR = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(idEOR)); | |
1102 | cfgEOR = calv2EOR->GetGlobalConfigName(); | |
1103 | } | |
ea3eaa08 | 1104 | } |
1105 | else { | |
ea3eaa08 | 1106 | AliError("NO DCS/DCSv2 OCDB entry found!"); |
a835b5d7 | 1107 | config = ""; |
1108 | return; | |
1109 | } | |
ea3eaa08 | 1110 | |
a835b5d7 | 1111 | // If there is no EOR entry, return the SOR value |
1112 | if (!hasEOR || cfgEOR.Length()==0) { | |
1113 | config = cfgSOR; | |
1114 | return; | |
ea3eaa08 | 1115 | } |
d6a1ec13 | 1116 | |
a835b5d7 | 1117 | // Check if the configuration is the same for both |
1118 | if (cfgSOR.EqualTo(cfgEOR)) { | |
1119 | config = cfgSOR; | |
1120 | return; | |
1121 | } | |
1122 | ||
1123 | // When both SOR and EOR have an entry but are different, the config is not defined | |
1124 | AliError("Inconsistent configuration at start and end of run found!"); | |
1125 | config = ""; | |
1126 | return; | |
1127 | ||
af086c5e | 1128 | } |
f1dcad37 | 1129 | |
f8059b39 | 1130 | //_____________________________________________________________________________ |
1131 | void AliTRDcalibDB::GetGlobalConfigurationVersion(TString &version) | |
1132 | { | |
1133 | // | |
1134 | // Get Version of Configuration from the DCS | |
1135 | // | |
1136 | ||
1137 | const TObjArray *dcsArr = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDDCS)); | |
1138 | if(!dcsArr){ | |
1139 | version = ""; | |
1140 | return; | |
1141 | } | |
1142 | ||
1143 | Int_t esor = 0; // Take SOR | |
1144 | Int_t calver = 0; // Check CalDCS version | |
1145 | if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCS")) calver = 1; | |
1146 | if (!strcmp(dcsArr->At(0)->ClassName(),"AliTRDCalDCSv2")) calver = 2; | |
1147 | ||
1148 | if (calver == 1) { | |
1149 | ||
1150 | // DCS object | |
1151 | const AliTRDCalDCS *calDCS = dynamic_cast<const AliTRDCalDCS *>(dcsArr->At(esor)); | |
1152 | if(!calDCS){ | |
1153 | version = ""; | |
1154 | return; | |
1155 | } | |
1156 | version = calDCS->GetGlobalConfigVersion(); | |
1157 | ||
1158 | } | |
1159 | else if (calver == 2) { | |
1160 | ||
1161 | // DCSv2 object | |
1162 | const AliTRDCalDCSv2 *calDCSv2 = dynamic_cast<const AliTRDCalDCSv2 *>(dcsArr->At(esor)); | |
1163 | if(!calDCSv2){ | |
1164 | version = ""; | |
1165 | return; | |
1166 | } | |
1167 | version = calDCSv2->GetGlobalConfigVersion(); | |
1168 | ||
1169 | } | |
1170 | else { | |
1171 | ||
1172 | AliError("NO DCS/DCSv2 OCDB entry found!"); | |
1173 | ||
1174 | } | |
1175 | ||
1176 | } | |
1177 | ||
af086c5e | 1178 | //_____________________________________________________________________________ |
1567d9a4 | 1179 | Int_t AliTRDcalibDB::GetNumberOfParsDCS(TString cname, Char_t delimiter) |
5b7ccf04 | 1180 | { |
1181 | // Get the number of configuration parameters from the DCS config | |
1182 | ||
1567d9a4 | 1183 | //AliInfo(Form("\"%s\" tokenized by \"%c\"", cname.Data(), delimiter)); |
1184 | if(!cname.Length()) return -1; // -1 for the "cf" | |
1185 | Int_t nconf(0); | |
1186 | for(Int_t ich(1); ich<cname.Length()-1; ich++){ if(cname[ich]==delimiter) nconf++;} | |
1187 | return nconf; | |
5b7ccf04 | 1188 | } |
1189 | ||
1190 | //_____________________________________________________________________________ | |
1191 | Int_t AliTRDcalibDB::GetNumberOfOptsDCS(TString cname, Int_t cfgType) | |
1192 | { | |
1193 | // Get the number of options of a given configuration parameter from DCS | |
1194 | ||
1567d9a4 | 1195 | Char_t cdelim = '_', // define the delimiters |
1196 | odelim = '-'; | |
1197 | Int_t nconfig = GetNumberOfParsDCS(cname, cdelim); | |
5b7ccf04 | 1198 | |
1199 | // protect | |
1567d9a4 | 1200 | if ((nconfig == -1) || (nconfig < cfgType)) { |
5b7ccf04 | 1201 | AliError("Not enough parameters in DCS configuration name!"); |
1202 | return 0; | |
1203 | } | |
1204 | ||
1567d9a4 | 1205 | TObjArray *carr = cname.Tokenize(cdelim); |
1206 | Int_t nopt = GetNumberOfParsDCS(((TObjString*)carr->At(cfgType))->GetString(), odelim); | |
1207 | carr->Delete(); delete carr; | |
1208 | return nopt; | |
5b7ccf04 | 1209 | } |
1210 | ||
1211 | //_____________________________________________________________________________ | |
1212 | void AliTRDcalibDB::GetDCSConfigParOption(TString cname, Int_t cfgType, Int_t option, TString &cfgo) | |
af086c5e | 1213 | { |
1214 | // | |
fc358d0f | 1215 | // Get a configuration (see enum in header file) or the options of a configuration |
1216 | // option == 0 returns the configuration itself | |
1217 | // option > 0 returns the optional parameter Nr. (option) of the configuration (cfgType) | |
af086c5e | 1218 | // |
ea3eaa08 | 1219 | |
1567d9a4 | 1220 | Char_t cdelim = '_', // define the delimiters |
1221 | odelim = '-'; | |
fc358d0f | 1222 | |
1567d9a4 | 1223 | Int_t nconfig = GetNumberOfParsDCS(cname, cdelim); |
fc358d0f | 1224 | // protect |
1567d9a4 | 1225 | if (nconfig == -1) { |
5b7ccf04 | 1226 | AliError("DCS configuration name empty!"); |
fc358d0f | 1227 | cfgo = ""; |
1228 | return; | |
1567d9a4 | 1229 | } else if (nconfig < cfgType) { |
5b7ccf04 | 1230 | AliError("Not enough parameters in DCS configuration name!"); |
fc358d0f | 1231 | cfgo = ""; |
1232 | return; | |
1233 | } | |
1234 | ||
1567d9a4 | 1235 | TObjArray *carr = cname.Tokenize(cdelim); |
1236 | TString cfgString(((TObjString*)carr->At(cfgType))->GetString()); | |
1237 | Int_t noptions = GetNumberOfParsDCS(cfgString, odelim); | |
5b7ccf04 | 1238 | // protect |
1567d9a4 | 1239 | if (noptions < option) { |
5b7ccf04 | 1240 | AliError("Not enough options in DCS configuration name!"); |
1241 | cfgo = ""; | |
1567d9a4 | 1242 | carr->Delete(); delete carr; |
fc358d0f | 1243 | return; |
fc358d0f | 1244 | } |
1567d9a4 | 1245 | TObjArray *oarr = cfgString.Tokenize(odelim); |
5b7ccf04 | 1246 | cfgo = ((TObjString*)oarr->At(option))->GetString(); |
1567d9a4 | 1247 | carr->Delete(); delete carr; |
1248 | oarr->Delete(); delete oarr; | |
5b7ccf04 | 1249 | return; |
fc358d0f | 1250 | |
1251 | } | |
1252 | ||
1253 | //_____________________________________________________________________________ | |
1254 | Bool_t AliTRDcalibDB::HasOnlineFilterPedestal() | |
1255 | { | |
1256 | // | |
1257 | // Checks whether pedestal filter was applied online | |
1258 | // | |
1259 | ||
1260 | TString filterconfig; | |
1261 | GetFilterType(filterconfig); | |
ea3eaa08 | 1262 | |
af086c5e | 1263 | return filterconfig.Contains("p"); |
ea3eaa08 | 1264 | |
af086c5e | 1265 | } |
1266 | ||
1267 | //_____________________________________________________________________________ | |
ea3eaa08 | 1268 | Bool_t AliTRDcalibDB::HasOnlineFilterGain() |
1269 | { | |
af086c5e | 1270 | // |
1271 | // Checks whether online gain filter was applied | |
1272 | // | |
ea3eaa08 | 1273 | |
fc358d0f | 1274 | TString filterconfig; |
1275 | GetFilterType(filterconfig); | |
ea3eaa08 | 1276 | |
af086c5e | 1277 | return filterconfig.Contains("g"); |
ea3eaa08 | 1278 | |
af086c5e | 1279 | } |
1280 | ||
1281 | //_____________________________________________________________________________ | |
ea3eaa08 | 1282 | Bool_t AliTRDcalibDB::HasOnlineTailCancellation() |
1283 | { | |
af086c5e | 1284 | // |
1285 | // Checks whether online tail cancellation was applied | |
1286 | // | |
ea3eaa08 | 1287 | |
fc358d0f | 1288 | TString filterconfig; |
1289 | GetFilterType(filterconfig); | |
ea3eaa08 | 1290 | |
af086c5e | 1291 | return filterconfig.Contains("t"); |
ea3eaa08 | 1292 | |
e232d349 | 1293 | } |
1294 | ||
7754cd1f | 1295 | //_____________________________________________________________________________ |
1296 | Char_t AliTRDcalibDB::GetPadStatus(Int_t det, Int_t col, Int_t row) | |
1297 | { | |
1298 | // | |
1299 | // Returns the status of the given pad | |
1300 | // | |
1301 | ||
aa617684 | 1302 | const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *> |
1303 | (GetCachedCDBObject(kIDPadStatus)); | |
6d50f529 | 1304 | if (!cal) { |
7754cd1f | 1305 | return -1; |
6d50f529 | 1306 | } |
7754cd1f | 1307 | |
95867fd1 | 1308 | const AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det); |
6d50f529 | 1309 | if (!roc) { |
7754cd1f | 1310 | return -1; |
6d50f529 | 1311 | } |
7754cd1f | 1312 | |
95867fd1 | 1313 | return roc->GetStatus(col,row); |
2745a409 | 1314 | |
7754cd1f | 1315 | } |
1316 | ||
0e09df31 | 1317 | //_____________________________________________________________________________ |
1318 | AliTRDCalSingleChamberStatus* AliTRDcalibDB::GetPadStatusROC(Int_t det) | |
1319 | { | |
1320 | // | |
1321 | // Returns the pad status calibration object for a given ROC | |
1322 | // | |
1323 | ||
1324 | const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *> | |
1325 | (GetCachedCDBObject(kIDPadStatus)); | |
1326 | if (!cal) { | |
1327 | return 0; | |
1328 | } | |
1329 | ||
1330 | AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det); | |
1331 | if (!roc) { | |
1332 | return 0; | |
1333 | } | |
1334 | else { | |
1335 | return roc; | |
1336 | } | |
1337 | ||
1338 | } | |
1339 | ||
7754cd1f | 1340 | //_____________________________________________________________________________ |
1341 | Char_t AliTRDcalibDB::GetChamberStatus(Int_t det) | |
1342 | { | |
1343 | // | |
1344 | // Returns the status of the given chamber | |
1345 | // | |
1346 | ||
95867fd1 | 1347 | const AliTRDCalChamberStatus *cal = dynamic_cast<const AliTRDCalChamberStatus *> |
6d50f529 | 1348 | (GetCachedCDBObject(kIDChamberStatus)); |
1349 | if (!cal) { | |
7754cd1f | 1350 | return -1; |
6d50f529 | 1351 | } |
7754cd1f | 1352 | |
1353 | return cal->GetStatus(det); | |
2745a409 | 1354 | |
7754cd1f | 1355 | } |
1356 | ||
a7ac01d2 | 1357 | //_____________________________________________________________________________ |
1358 | AliTRDrecoParam* AliTRDcalibDB::GetRecoParam(Int_t */*eventtype*/) | |
1359 | { | |
be28462a | 1360 | // |
1361 | // Returns the TRD reconstruction parameters from the OCDB | |
1362 | // | |
1363 | ||
a7ac01d2 | 1364 | const TClonesArray *recos = dynamic_cast<const TClonesArray*>(GetCachedCDBObject(kIDRecoParam)); |
be28462a | 1365 | if (!recos) return 0x0; |
a7ac01d2 | 1366 | |
1367 | // calculate entry based on event type info | |
1368 | Int_t n = 0; //f(eventtype[0], eventtype[1], ....) | |
be28462a | 1369 | |
ea3eaa08 | 1370 | return (AliTRDrecoParam *) recos->UncheckedAt(n); |
a7ac01d2 | 1371 | |
be28462a | 1372 | } |
a7ac01d2 | 1373 | |
7754cd1f | 1374 | //_____________________________________________________________________________ |
1375 | Bool_t AliTRDcalibDB::IsPadMasked(Int_t det, Int_t col, Int_t row) | |
1376 | { | |
1377 | // | |
1378 | // Returns status, see name of functions for details ;-) | |
1379 | // | |
1380 | ||
95867fd1 | 1381 | const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *> |
1382 | (GetCachedCDBObject(kIDPadStatus)); | |
6d50f529 | 1383 | if (!cal) { |
7754cd1f | 1384 | return -1; |
6d50f529 | 1385 | } |
7754cd1f | 1386 | |
95867fd1 | 1387 | return cal->IsMasked(det,col,row); |
2745a409 | 1388 | |
7754cd1f | 1389 | } |
1390 | ||
1391 | //_____________________________________________________________________________ | |
1392 | Bool_t AliTRDcalibDB::IsPadBridgedLeft(Int_t det, Int_t col, Int_t row) | |
1393 | { | |
1394 | // | |
1395 | // Returns status, see name of functions for details ;-) | |
1396 | // | |
1397 | ||
95867fd1 | 1398 | const AliTRDCalPadStatus *cal = dynamic_cast<const AliTRDCalPadStatus *> |
1399 | (GetCachedCDBObject(kIDPadStatus)); | |
6d50f529 | 1400 | if (!cal) { |
7754cd1f | 1401 | return -1; |
6d50f529 | 1402 | } |
7754cd1f | 1403 | |
95867fd1 | 1404 | return cal->IsBridgedLeft(det,col,row); |
2745a409 | 1405 | |
7754cd1f | 1406 | } |
1407 | ||
1408 | //_____________________________________________________________________________ | |
1409 | Bool_t AliTRDcalibDB::IsPadBridgedRight(Int_t det, Int_t col, Int_t row) | |
1410 | { | |
1411 | // | |
1412 | // Returns status, see name of functions for details ;-) | |
1413 | // | |
1414 | ||
95867fd1 | 1415 | const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *> |
1416 | (GetCachedCDBObject(kIDPadStatus)); | |
6d50f529 | 1417 | if (!cal) { |
7754cd1f | 1418 | return -1; |
6d50f529 | 1419 | } |
7754cd1f | 1420 | |
95867fd1 | 1421 | return cal->IsBridgedRight(det,col,row); |
2745a409 | 1422 | |
7754cd1f | 1423 | } |
1424 | ||
fa7427d0 | 1425 | //_____________________________________________________________________________ |
1426 | Bool_t AliTRDcalibDB::IsPadNotConnected(Int_t det, Int_t col, Int_t row) | |
1427 | { | |
1428 | // | |
1429 | // Returns status, see name of functions for details ;-) | |
1430 | // | |
f1dcad37 | 1431 | |
fa7427d0 | 1432 | const AliTRDCalPadStatus * cal = dynamic_cast<const AliTRDCalPadStatus *> |
1433 | (GetCachedCDBObject(kIDPadStatus)); | |
1434 | if (!cal) { | |
1435 | return -1; | |
1436 | } | |
1437 | ||
1438 | return cal->IsNotConnected(det,col,row); | |
1439 | ||
1440 | } | |
1441 | ||
7754cd1f | 1442 | //_____________________________________________________________________________ |
eda91732 | 1443 | Bool_t AliTRDcalibDB::IsChamberGood(Int_t det) |
1444 | { | |
1445 | // | |
1446 | // Returns status, see name of functions for details ;-) | |
1447 | // | |
1448 | ||
1449 | const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *> | |
1450 | (GetCachedCDBObject(kIDChamberStatus)); | |
1451 | if (!cal) { | |
1452 | return -1; | |
1453 | } | |
1454 | ||
1455 | return cal->IsGood(det); | |
1456 | ||
1457 | } | |
1458 | ||
1459 | //_____________________________________________________________________________ | |
1460 | Bool_t AliTRDcalibDB::IsChamberNoData(Int_t det) | |
7754cd1f | 1461 | { |
1462 | // | |
1463 | // Returns status, see name of functions for details ;-) | |
1464 | // | |
1465 | ||
95867fd1 | 1466 | const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *> |
1467 | (GetCachedCDBObject(kIDChamberStatus)); | |
6d50f529 | 1468 | if (!cal) { |
7754cd1f | 1469 | return -1; |
6d50f529 | 1470 | } |
7754cd1f | 1471 | |
eda91732 | 1472 | return cal->IsNoData(det); |
2745a409 | 1473 | |
7754cd1f | 1474 | } |
1475 | ||
1476 | //_____________________________________________________________________________ | |
eda91732 | 1477 | Bool_t AliTRDcalibDB::IsHalfChamberNoData(Int_t det, Int_t side) |
7754cd1f | 1478 | { |
1479 | // | |
1480 | // Returns status, see name of functions for details ;-) | |
1481 | // | |
1482 | ||
95867fd1 | 1483 | const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *> |
1484 | (GetCachedCDBObject(kIDChamberStatus)); | |
6d50f529 | 1485 | if (!cal) { |
7754cd1f | 1486 | return -1; |
6d50f529 | 1487 | } |
7754cd1f | 1488 | |
eda91732 | 1489 | return side > 0 ? cal->IsNoDataSideB(det) : cal->IsNoDataSideA(det); |
2745a409 | 1490 | |
7754cd1f | 1491 | } |
ea3eaa08 | 1492 | |
7a6352a6 | 1493 | //_____________________________________________________________________________ |
eda91732 | 1494 | Bool_t AliTRDcalibDB::IsChamberBadCalibrated(Int_t det) |
ea3eaa08 | 1495 | { |
7a6352a6 | 1496 | // |
1497 | // Returns status, see name of functions for details ;-) | |
1498 | // | |
7754cd1f | 1499 | |
7a6352a6 | 1500 | const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *> |
1501 | (GetCachedCDBObject(kIDChamberStatus)); | |
1502 | if (!cal) { | |
1503 | return -1; | |
1504 | } | |
1505 | ||
eda91732 | 1506 | return cal->IsBadCalibrated(det); |
7a6352a6 | 1507 | |
1508 | } | |
ea3eaa08 | 1509 | |
67abca5c | 1510 | //_____________________________________________________________________________ |
1511 | Bool_t AliTRDcalibDB::IsChamberNotCalibrated(Int_t det) | |
1512 | { | |
1513 | // | |
1514 | // Returns status, see name of functions for details ;-) | |
1515 | // | |
1516 | ||
1517 | const AliTRDCalChamberStatus * cal = dynamic_cast<const AliTRDCalChamberStatus *> | |
1518 | (GetCachedCDBObject(kIDChamberStatus)); | |
1519 | if (!cal) { | |
1520 | return -1; | |
1521 | } | |
1522 | ||
1523 | return cal->IsNotCalibrated(det); | |
1524 | ||
1525 | } | |
1526 | ||
cc7cef99 | 1527 | //_____________________________________________________________________________ |
0d83b3a5 | 1528 | const AliTRDCalPID *AliTRDcalibDB::GetPIDObject(AliTRDpidUtil::ETRDPIDMethod method) |
cc7cef99 | 1529 | { |
1530 | // | |
1531 | // Returns the object storing the distributions for PID with likelihood | |
1532 | // | |
9a96f175 | 1533 | |
1534 | switch(method) { | |
0d83b3a5 | 1535 | case AliTRDpidUtil::kLQ: |
4ba1d6ae | 1536 | return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDLQ)); |
0d83b3a5 | 1537 | case AliTRDpidUtil::kNN: |
4ba1d6ae | 1538 | return dynamic_cast<const AliTRDCalPID *>(GetCachedCDBObject(kIDPIDNN)); |
543691ea | 1539 | case AliTRDpidUtil::kESD: |
1540 | return 0x0; // To avoid compiler warnings | |
9a96f175 | 1541 | } |
1542 | ||
10f75631 | 1543 | return 0x0; |
2745a409 | 1544 | |
cc7cef99 | 1545 | } |
1546 | ||
9dcc64cc | 1547 | //_____________________________________________________________________________ |
f2391aef | 1548 | AliTRDPIDResponse *AliTRDcalibDB::GetPIDResponse(AliTRDPIDResponse::ETRDPIDMethod /*method*/) |
ea3eaa08 | 1549 | { |
1550 | // | |
1551 | // Returns the PID response object for 1D-LQ | |
1552 | // | |
1553 | ||
1554 | if (!fPIDResponse) { | |
f2391aef | 1555 | AliDebug(2, "Setting new PID response."); |
ea3eaa08 | 1556 | |
9dcc64cc | 1557 | fPIDResponse = new AliTRDPIDResponse; |
ea3eaa08 | 1558 | |
9dcc64cc | 1559 | // Load Reference Histos from OCDB |
f2391aef | 1560 | // if(method == AliTRDPIDResponse::kLQ1D){ |
bd58d4b9 | 1561 | //fPIDResponse->SetPIDmethod(AliTRDPIDResponse::kLQ1D); |
f2391aef | 1562 | const TObjArray *references = dynamic_cast<const TObjArray *>(GetCachedCDBObject(kIDPIDLQ1D)); |
1563 | ||
1564 | TIter refs(references); | |
1565 | TObject *obj = NULL; | |
1566 | AliTRDPIDReference *ref = NULL; | |
1567 | Bool_t hasReference = kFALSE; | |
1568 | while ((obj = refs())){ | |
1569 | if ((ref = dynamic_cast<AliTRDPIDReference *>(obj))){ | |
1570 | AliDebug(2, "Setting new PID response object."); | |
1571 | TDirectory *bkpdir = gDirectory; | |
1572 | gROOT->cd(); | |
1573 | AliTRDPIDResponseObject *ro = new AliTRDPIDResponseObject; | |
1574 | ro->SetPIDReference(ref); | |
1575 | fPIDResponse->SetPIDResponseObject(ro); | |
1576 | hasReference = kTRUE; | |
1577 | gDirectory = bkpdir; | |
1578 | break; | |
121fadea | 1579 | } |
ea3eaa08 | 1580 | } |
1581 | ||
f2391aef | 1582 | if (!hasReference) { |
1583 | AliError("Reference histograms not found in the OCDB"); | |
1584 | } | |
9dcc64cc | 1585 | } |
ea3eaa08 | 1586 | |
f2391aef | 1587 | // } |
1588 | ||
9dcc64cc | 1589 | return fPIDResponse; |
ea3eaa08 | 1590 | |
9dcc64cc | 1591 | } |
1592 | ||
1593 | //_____________________________________________________________________________ | |
1594 | const AliTRDCalTrkAttach* AliTRDcalibDB::GetAttachObject() | |
1595 | { | |
1596 | // | |
1597 | // Returns the object storing likelihood distributions for cluster to track attachment | |
1598 | // | |
ea3eaa08 | 1599 | |
9dcc64cc | 1600 | return dynamic_cast<const AliTRDCalTrkAttach*>(GetCachedCDBObject(kIDAttach)); |
9dcc64cc | 1601 | |
ea3eaa08 | 1602 | } |
9dcc64cc | 1603 | |
7754cd1f | 1604 | //_____________________________________________________________________________ |
d4c6453d | 1605 | const AliTRDCalMonitoring *AliTRDcalibDB::GetMonitoringObject() |
7754cd1f | 1606 | { |
1607 | // | |
1608 | // Returns the object storing the monitoring data | |
1609 | // | |
1610 | ||
d4c6453d | 1611 | return dynamic_cast<const AliTRDCalMonitoring *> |
1612 | (GetCachedCDBObject(kIDMonitoringData)); | |
1b95a37b | 1613 | |
7754cd1f | 1614 | } |
1615 | ||
6a739e92 | 1616 | //_____________________________________________________________________________ |
1617 | void AliTRDcalibDB::SamplePRF() | |
1618 | { | |
1619 | // | |
2745a409 | 1620 | // Samples the pad response function (should maybe go somewhere else ...) |
6a739e92 | 1621 | // |
1622 | ||
1623 | const Int_t kPRFbin = 61; | |
1624 | ||
053767a4 | 1625 | Float_t prf[kNlayer][kPRFbin] = { |
6d50f529 | 1626 | {2.9037e-02, 3.3608e-02, 3.9020e-02, 4.5292e-02, |
6a739e92 | 1627 | 5.2694e-02, 6.1362e-02, 7.1461e-02, 8.3362e-02, |
1628 | 9.7063e-02, 1.1307e-01, 1.3140e-01, 1.5235e-01, | |
1629 | 1.7623e-01, 2.0290e-01, 2.3294e-01, 2.6586e-01, | |
1630 | 3.0177e-01, 3.4028e-01, 3.8077e-01, 4.2267e-01, | |
1631 | 4.6493e-01, 5.0657e-01, 5.4655e-01, 5.8397e-01, | |
1632 | 6.1767e-01, 6.4744e-01, 6.7212e-01, 6.9188e-01, | |
1633 | 7.0627e-01, 7.1499e-01, 7.1851e-01, 7.1499e-01, | |
1634 | 7.0627e-01, 6.9188e-01, 6.7212e-01, 6.4744e-01, | |
1635 | 6.1767e-01, 5.8397e-01, 5.4655e-01, 5.0657e-01, | |
1636 | 4.6493e-01, 4.2267e-01, 3.8077e-01, 3.4028e-01, | |
1637 | 3.0177e-01, 2.6586e-01, 2.3294e-01, 2.0290e-01, | |
1638 | 1.7623e-01, 1.5235e-01, 1.3140e-01, 1.1307e-01, | |
1639 | 9.7063e-02, 8.3362e-02, 7.1461e-02, 6.1362e-02, | |
1640 | 5.2694e-02, 4.5292e-02, 3.9020e-02, 3.3608e-02, | |
1641 | 2.9037e-02}, | |
1642 | {2.5478e-02, 2.9695e-02, 3.4655e-02, 4.0454e-02, | |
1643 | 4.7342e-02, 5.5487e-02, 6.5038e-02, 7.6378e-02, | |
1644 | 8.9696e-02, 1.0516e-01, 1.2327e-01, 1.4415e-01, | |
1645 | 1.6794e-01, 1.9516e-01, 2.2573e-01, 2.5959e-01, | |
1646 | 2.9694e-01, 3.3719e-01, 3.7978e-01, 4.2407e-01, | |
1647 | 4.6889e-01, 5.1322e-01, 5.5569e-01, 5.9535e-01, | |
1648 | 6.3141e-01, 6.6259e-01, 6.8882e-01, 7.0983e-01, | |
1649 | 7.2471e-01, 7.3398e-01, 7.3761e-01, 7.3398e-01, | |
1650 | 7.2471e-01, 7.0983e-01, 6.8882e-01, 6.6259e-01, | |
1651 | 6.3141e-01, 5.9535e-01, 5.5569e-01, 5.1322e-01, | |
1652 | 4.6889e-01, 4.2407e-01, 3.7978e-01, 3.3719e-01, | |
1653 | 2.9694e-01, 2.5959e-01, 2.2573e-01, 1.9516e-01, | |
1654 | 1.6794e-01, 1.4415e-01, 1.2327e-01, 1.0516e-01, | |
1655 | 8.9696e-02, 7.6378e-02, 6.5038e-02, 5.5487e-02, | |
1656 | 4.7342e-02, 4.0454e-02, 3.4655e-02, 2.9695e-02, | |
1657 | 2.5478e-02}, | |
1658 | {2.2363e-02, 2.6233e-02, 3.0782e-02, 3.6140e-02, | |
1659 | 4.2535e-02, 5.0157e-02, 5.9197e-02, 6.9900e-02, | |
1660 | 8.2707e-02, 9.7811e-02, 1.1548e-01, 1.3601e-01, | |
1661 | 1.5998e-01, 1.8739e-01, 2.1840e-01, 2.5318e-01, | |
1662 | 2.9182e-01, 3.3373e-01, 3.7837e-01, 4.2498e-01, | |
1663 | 4.7235e-01, 5.1918e-01, 5.6426e-01, 6.0621e-01, | |
1664 | 6.4399e-01, 6.7700e-01, 7.0472e-01, 7.2637e-01, | |
1665 | 7.4206e-01, 7.5179e-01, 7.5551e-01, 7.5179e-01, | |
1666 | 7.4206e-01, 7.2637e-01, 7.0472e-01, 6.7700e-01, | |
1667 | 6.4399e-01, 6.0621e-01, 5.6426e-01, 5.1918e-01, | |
1668 | 4.7235e-01, 4.2498e-01, 3.7837e-01, 3.3373e-01, | |
1669 | 2.9182e-01, 2.5318e-01, 2.1840e-01, 1.8739e-01, | |
1670 | 1.5998e-01, 1.3601e-01, 1.1548e-01, 9.7811e-02, | |
1671 | 8.2707e-02, 6.9900e-02, 5.9197e-02, 5.0157e-02, | |
1672 | 4.2535e-02, 3.6140e-02, 3.0782e-02, 2.6233e-02, | |
1673 | 2.2363e-02}, | |
1674 | {1.9635e-02, 2.3167e-02, 2.7343e-02, 3.2293e-02, | |
1675 | 3.8224e-02, 4.5335e-02, 5.3849e-02, 6.4039e-02, | |
1676 | 7.6210e-02, 9.0739e-02, 1.0805e-01, 1.2841e-01, | |
1677 | 1.5216e-01, 1.7960e-01, 2.1099e-01, 2.4671e-01, | |
1678 | 2.8647e-01, 3.2996e-01, 3.7660e-01, 4.2547e-01, | |
1679 | 4.7536e-01, 5.2473e-01, 5.7215e-01, 6.1632e-01, | |
1680 | 6.5616e-01, 6.9075e-01, 7.1939e-01, 7.4199e-01, | |
1681 | 7.5838e-01, 7.6848e-01, 7.7227e-01, 7.6848e-01, | |
1682 | 7.5838e-01, 7.4199e-01, 7.1939e-01, 6.9075e-01, | |
1683 | 6.5616e-01, 6.1632e-01, 5.7215e-01, 5.2473e-01, | |
1684 | 4.7536e-01, 4.2547e-01, 3.7660e-01, 3.2996e-01, | |
1685 | 2.8647e-01, 2.4671e-01, 2.1099e-01, 1.7960e-01, | |
1686 | 1.5216e-01, 1.2841e-01, 1.0805e-01, 9.0739e-02, | |
1687 | 7.6210e-02, 6.4039e-02, 5.3849e-02, 4.5335e-02, | |
1688 | 3.8224e-02, 3.2293e-02, 2.7343e-02, 2.3167e-02, | |
1689 | 1.9635e-02}, | |
1690 | {1.7224e-02, 2.0450e-02, 2.4286e-02, 2.8860e-02, | |
1691 | 3.4357e-02, 4.0979e-02, 4.8966e-02, 5.8612e-02, | |
1692 | 7.0253e-02, 8.4257e-02, 1.0102e-01, 1.2094e-01, | |
1693 | 1.4442e-01, 1.7196e-01, 2.0381e-01, 2.4013e-01, | |
1694 | 2.8093e-01, 3.2594e-01, 3.7450e-01, 4.2563e-01, | |
1695 | 4.7796e-01, 5.2991e-01, 5.7974e-01, 6.2599e-01, | |
1696 | 6.6750e-01, 7.0344e-01, 7.3329e-01, 7.5676e-01, | |
1697 | 7.7371e-01, 7.8410e-01, 7.8793e-01, 7.8410e-01, | |
1698 | 7.7371e-01, 7.5676e-01, 7.3329e-01, 7.0344e-01, | |
1699 | 6.6750e-01, 6.2599e-01, 5.7974e-01, 5.2991e-01, | |
1700 | 4.7796e-01, 4.2563e-01, 3.7450e-01, 3.2594e-01, | |
1701 | 2.8093e-01, 2.4013e-01, 2.0381e-01, 1.7196e-01, | |
1702 | 1.4442e-01, 1.2094e-01, 1.0102e-01, 8.4257e-02, | |
1703 | 7.0253e-02, 5.8612e-02, 4.8966e-02, 4.0979e-02, | |
1704 | 3.4357e-02, 2.8860e-02, 2.4286e-02, 2.0450e-02, | |
1705 | 1.7224e-02}, | |
1706 | {1.5096e-02, 1.8041e-02, 2.1566e-02, 2.5793e-02, | |
1707 | 3.0886e-02, 3.7044e-02, 4.4515e-02, 5.3604e-02, | |
1708 | 6.4668e-02, 7.8109e-02, 9.4364e-02, 1.1389e-01, | |
1709 | 1.3716e-01, 1.6461e-01, 1.9663e-01, 2.3350e-01, | |
1710 | 2.7527e-01, 3.2170e-01, 3.7214e-01, 4.2549e-01, | |
1711 | 4.8024e-01, 5.3460e-01, 5.8677e-01, 6.3512e-01, | |
1712 | 6.7838e-01, 7.1569e-01, 7.4655e-01, 7.7071e-01, | |
1713 | 7.8810e-01, 7.9871e-01, 8.0255e-01, 7.9871e-01, | |
1714 | 7.8810e-01, 7.7071e-01, 7.4655e-01, 7.1569e-01, | |
1715 | 6.7838e-01, 6.3512e-01, 5.8677e-01, 5.3460e-01, | |
1716 | 4.8024e-01, 4.2549e-01, 3.7214e-01, 3.2170e-01, | |
1717 | 2.7527e-01, 2.3350e-01, 1.9663e-01, 1.6461e-01, | |
1718 | 1.3716e-01, 1.1389e-01, 9.4364e-02, 7.8109e-02, | |
1719 | 6.4668e-02, 5.3604e-02, 4.4515e-02, 3.7044e-02, | |
1720 | 3.0886e-02, 2.5793e-02, 2.1566e-02, 1.8041e-02, | |
1721 | 1.5096e-02}}; | |
1722 | ||
1723 | // More sampling precision with linear interpolation | |
6d50f529 | 1724 | fPRFlo = -1.5; |
1725 | fPRFhi = 1.5; | |
6a739e92 | 1726 | Float_t pad[kPRFbin]; |
1727 | Int_t sPRFbin = kPRFbin; | |
6d50f529 | 1728 | Float_t sPRFwid = (fPRFhi - fPRFlo) / ((Float_t) sPRFbin); |
6a739e92 | 1729 | for (Int_t iPad = 0; iPad < sPRFbin; iPad++) { |
6d50f529 | 1730 | pad[iPad] = ((Float_t) iPad + 0.5) * sPRFwid + fPRFlo; |
6a739e92 | 1731 | } |
6d50f529 | 1732 | fPRFbin = 500; |
1733 | fPRFwid = (fPRFhi - fPRFlo) / ((Float_t) fPRFbin); | |
1734 | fPRFpad = ((Int_t) (1.0 / fPRFwid)); | |
6a739e92 | 1735 | |
6d50f529 | 1736 | if (fPRFsmp) delete [] fPRFsmp; |
053767a4 | 1737 | fPRFsmp = new Float_t[kNlayer*fPRFbin]; |
6a739e92 | 1738 | |
1739 | Int_t ipos1; | |
1740 | Int_t ipos2; | |
1741 | Float_t diff; | |
1742 | ||
053767a4 | 1743 | for (Int_t iLayer = 0; iLayer < kNlayer; iLayer++) { |
6a739e92 | 1744 | |
6d50f529 | 1745 | for (Int_t iBin = 0; iBin < fPRFbin; iBin++) { |
6a739e92 | 1746 | |
6d50f529 | 1747 | Float_t bin = (((Float_t) iBin) + 0.5) * fPRFwid + fPRFlo; |
6a739e92 | 1748 | ipos1 = ipos2 = 0; |
1749 | diff = 0; | |
1750 | do { | |
1751 | diff = bin - pad[ipos2++]; | |
1752 | } while ((diff > 0) && (ipos2 < kPRFbin)); | |
1753 | if (ipos2 == kPRFbin) { | |
053767a4 | 1754 | fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1]; |
6a739e92 | 1755 | } |
1756 | else if (ipos2 == 1) { | |
053767a4 | 1757 | fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2-1]; |
6a739e92 | 1758 | } |
1759 | else { | |
1760 | ipos2--; | |
1761 | if (ipos2 >= kPRFbin) ipos2 = kPRFbin - 1; | |
1762 | ipos1 = ipos2 - 1; | |
053767a4 | 1763 | fPRFsmp[iLayer*fPRFbin+iBin] = prf[iLayer][ipos2] |
1764 | + diff * (prf[iLayer][ipos2] - prf[iLayer][ipos1]) | |
1765 | / sPRFwid; | |
6a739e92 | 1766 | } |
1767 | ||
1768 | } | |
1769 | } | |
1770 | ||
1771 | } | |
1772 | ||
1773 | //_____________________________________________________________________________ | |
1774 | Int_t AliTRDcalibDB::PadResponse(Double_t signal, Double_t dist | |
eb52b657 | 1775 | , Int_t layer, Double_t *pad) const |
6a739e92 | 1776 | { |
1777 | // | |
1778 | // Applies the pad response | |
56178ff4 | 1779 | // So far this is the fixed parametrization and should be replaced by |
1780 | // something dependent on calibration values | |
6a739e92 | 1781 | // |
1782 | ||
eb52b657 | 1783 | Int_t iBin = ((Int_t) ((-dist - fPRFlo) / fPRFwid)); |
053767a4 | 1784 | Int_t iOff = layer * fPRFbin; |
6a739e92 | 1785 | |
6d50f529 | 1786 | Int_t iBin0 = iBin - fPRFpad + iOff; |
6a739e92 | 1787 | Int_t iBin1 = iBin + iOff; |
6d50f529 | 1788 | Int_t iBin2 = iBin + fPRFpad + iOff; |
6a739e92 | 1789 | |
1790 | pad[0] = 0.0; | |
1791 | pad[1] = 0.0; | |
1792 | pad[2] = 0.0; | |
053767a4 | 1793 | if ((iBin1 >= 0) && (iBin1 < (fPRFbin*kNlayer))) { |
6a739e92 | 1794 | |
1795 | if (iBin0 >= 0) { | |
6d50f529 | 1796 | pad[0] = signal * fPRFsmp[iBin0]; |
6a739e92 | 1797 | } |
6d50f529 | 1798 | pad[1] = signal * fPRFsmp[iBin1]; |
053767a4 | 1799 | if (iBin2 < (fPRFbin*kNlayer)) { |
6d50f529 | 1800 | pad[2] = signal * fPRFsmp[iBin2]; |
6a739e92 | 1801 | } |
1802 | ||
1803 | return 1; | |
1804 | ||
1805 | } | |
1806 | else { | |
1807 | ||
1808 | return 0; | |
1809 | ||
1810 | } | |
ab0a4106 | 1811 | |
3551db50 | 1812 | } |
7a6352a6 | 1813 | |
1814 | ||
a9e22145 | 1815 | AliTRDtrapConfig* AliTRDcalibDB::GetTrapConfig() |
1816 | { | |
1817 | // return an existing TRAPconfig or load it from the OCDB | |
1818 | // in case of failure, a default TRAPconfig is created | |
1819 | ||
1820 | if (fTrapConfig) | |
1821 | return fTrapConfig; | |
1822 | else { | |
1b1afdd3 | 1823 | if ((fTrapConfigName.Length() <= 0) || (fTrapConfigVersion.Length() <= 0)) { |
1824 | // query the configuration to be used | |
15224417 | 1825 | this->GetGlobalConfiguration(fTrapConfigName); |
1826 | this->GetGlobalConfigurationVersion(fTrapConfigVersion); | |
1b1afdd3 | 1827 | } |
a9e22145 | 1828 | |
1b1afdd3 | 1829 | // try to load the requested configuration |
1830 | this->LoadTrapConfig(fTrapConfigName, fTrapConfigVersion); | |
a9e22145 | 1831 | |
1832 | // if we still don't have a valid TRAPconfig, create a default one | |
1833 | if (!fTrapConfig) { | |
1834 | AliWarning("Falling back to default configuration"); | |
b3b30cf6 | 1835 | static AliTRDtrapConfig trapConfigDefault("default", "default TRAP configuration"); |
1836 | fTrapConfig = &trapConfigDefault; | |
a9e22145 | 1837 | AliTRDtrapConfigHandler cfgHandler(fTrapConfig); |
1838 | cfgHandler.Init(); | |
1839 | cfgHandler.LoadConfig(); | |
1840 | } | |
1841 | ||
1842 | AliInfo(Form("using TRAPconfig \"%s\"", fTrapConfig->GetTitle())); | |
1843 | ||
56a188ab | 1844 | // we still have to load the gain tables |
1845 | // if the gain filter is active | |
1846 | if (HasOnlineFilterGain()) { | |
1847 | const Int_t nDets = AliTRDgeometry::Ndet(); | |
1848 | const Int_t nMcms = AliTRDgeometry::MCMmax(); | |
1849 | const Int_t nChs = AliTRDgeometry::ADCmax(); | |
1850 | ||
1851 | // gain factors are per MCM | |
1852 | // allocate the registers accordingly | |
1853 | for (Int_t ch = 0; ch < nChs; ++ch) { | |
1854 | AliTRDtrapConfig::TrapReg_t regFGAN = (AliTRDtrapConfig::TrapReg_t) (AliTRDtrapConfig::kFGA0 + ch); | |
1855 | AliTRDtrapConfig::TrapReg_t regFGFN = (AliTRDtrapConfig::TrapReg_t) (AliTRDtrapConfig::kFGF0 + ch); | |
1856 | fTrapConfig->SetTrapRegAlloc(regFGAN, AliTRDtrapConfig::kAllocByMCM); | |
1857 | fTrapConfig->SetTrapRegAlloc(regFGFN, AliTRDtrapConfig::kAllocByMCM); | |
1858 | } | |
1859 | ||
1860 | for (Int_t iDet = 0; iDet < nDets; ++iDet) { | |
1861 | AliTRDCalOnlineGainTableROC *gainTbl = GetOnlineGainTableROC(iDet); | |
1862 | if (gainTbl) { | |
1863 | const Int_t nRobs = AliTRDgeometry::GetStack(iDet) == 2 ? | |
1864 | AliTRDgeometry::ROBmaxC0() : AliTRDgeometry::ROBmaxC1(); | |
1865 | for (Int_t rob = 0; rob < nRobs; ++rob) { | |
1866 | for (Int_t mcm = 0; mcm < nMcms; ++mcm) { | |
1867 | AliTRDCalOnlineGainTableMCM *gainTblMCM = gainTbl->GetGainTableMCM(rob, mcm); | |
1868 | ||
1869 | // set ADC reference voltage | |
1870 | fTrapConfig->SetTrapReg(AliTRDtrapConfig::kADCDAC, gainTblMCM->GetAdcdac(), iDet, rob, mcm); | |
1871 | ||
1872 | // set constants channel-wise | |
1873 | for (Int_t ch = 0; ch < nChs; ++ch) { | |
1874 | AliTRDtrapConfig::TrapReg_t regFGAN = (AliTRDtrapConfig::TrapReg_t) (AliTRDtrapConfig::kFGA0 + ch); | |
1875 | AliTRDtrapConfig::TrapReg_t regFGFN = (AliTRDtrapConfig::TrapReg_t) (AliTRDtrapConfig::kFGF0 + ch); | |
1876 | fTrapConfig->SetTrapReg(regFGAN, gainTblMCM->GetFGAN(ch), iDet, rob, mcm); | |
1877 | fTrapConfig->SetTrapReg(regFGFN, gainTblMCM->GetFGFN(ch), iDet, rob, mcm); | |
1878 | } | |
1879 | } | |
1880 | } | |
1881 | } | |
1882 | } | |
1883 | } | |
1884 | ||
a9e22145 | 1885 | return fTrapConfig; |
1886 | } | |
1887 | } | |
1888 | ||
1889 | ||
1890 | AliTRDtrapConfig* AliTRDcalibDB::LoadTrapConfig(const TString &name, const TString &version) | |
1891 | { | |
1892 | // try to load the specified configuration from the OCDB | |
1893 | // if it fails, or it does not exist, return null | |
1894 | ||
1895 | AliInfo(Form("looking for TRAPconfig \"%s.%s\"", name.Data(), version.Data())); | |
1896 | ||
1897 | const AliTRDCalTrapConfig *caltrap = dynamic_cast<const AliTRDCalTrapConfig*> (GetCachedCDBObject(kIDTrapConfig)); | |
1898 | ||
1899 | if (caltrap) { | |
1900 | TString configName(name); | |
1901 | configName.Append("."); | |
1902 | configName.Append(version); | |
1903 | fTrapConfig = caltrap->Get(configName); | |
1904 | } | |
1905 | else { | |
1906 | fTrapConfig = 0x0; | |
1907 | AliError("No TRAPconfig entry found!"); | |
1908 | } | |
1909 | ||
1910 | return fTrapConfig; | |
1911 | } |