]>
Commit | Line | Data |
---|---|---|
8661738e | 1 | |
421ab0fb | 2 | /************************************************************************** |
3 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
4 | * * | |
5 | * Author: The ALICE Off-line Project. * | |
6 | * Contributors are mentioned in the code where appropriate. * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | /* $Id$ */ | |
17 | ||
18 | ////////////////////////////////////////////////////////////////////////////// | |
19 | // | |
20 | // Quality Assurance Object//_________________________________________________________________________ | |
21 | // Quality Assurance object. The QA status is held in one word per detector, | |
22 | // each bit corresponds to a different status. | |
23 | // bit 0-3 : QA raised during simulation (SIM) | |
24 | // bit 4-7 : QA raised during reconstruction (REC) | |
25 | // bit 8-11 : QA raised during ESD checking (ESD) | |
26 | // bit 12-15: QA raised during analysis (ANA) | |
27 | // Each of the 4 bits corresponds to a severity level of increasing importance | |
28 | // from lower to higher bit (INFO, WARNING, ERROR, FATAL) | |
29 | // | |
30 | //*-- Yves Schutz CERN, July 2007 | |
31 | ////////////////////////////////////////////////////////////////////////////// | |
32 | ||
33 | ||
34 | // --- ROOT system --- | |
35 | #include <TFile.h> | |
36 | #include <TSystem.h> | |
37 | ||
38 | // --- Standard library --- | |
39 | ||
40 | // --- AliRoot header files --- | |
4ecde5fc | 41 | #include "AliCDBManager.h" |
42 | #include "AliCDBMetaData.h" | |
43 | #include "AliCDBEntry.h" | |
421ab0fb | 44 | #include "AliLog.h" |
2e42b4d4 | 45 | #include "AliQA.h" |
9a223722 | 46 | #include "AliQAChecker.h" |
421ab0fb | 47 | |
48 | ||
2e42b4d4 | 49 | ClassImp(AliQA) |
4ecde5fc | 50 | AliQA * AliQA::fgQA = 0x0 ; |
46ca5304 | 51 | TFile * AliQA::fgQADataFile = 0x0 ; |
52 | TString AliQA::fgQADataFileName = "QA" ; // will transform into Det.QA.run.cycle.root | |
53 | TFile * AliQA::fgQARefFile = 0x0 ; | |
4ecde5fc | 54 | TString AliQA::fgQARefDirName = "local://Ref/" ; |
55 | TString AliQA::fgQARefFileName = "QA.root" ; | |
46ca5304 | 56 | TFile * AliQA::fgQAResultFile = 0x0 ; |
4ecde5fc | 57 | TString AliQA::fgQAResultDirName = "local://RUN/" ; |
58 | TString AliQA::fgQAResultFileName = "QA.root" ; | |
59 | TString AliQA::fgDetNames[] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", | |
a5fa6165 | 60 | "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT"} ; |
4ecde5fc | 61 | TString AliQA::fgTaskNames[] = {"Raws", "Hits", "SDigits", "Digits", "RecPoints", "TrackSegments", "RecParticles", "ESDs"} ; |
421ab0fb | 62 | |
63 | //____________________________________________________________________________ | |
2e42b4d4 | 64 | AliQA::AliQA() : |
421ab0fb | 65 | TNamed("", ""), |
9a223722 | 66 | fNdet(kNDET), |
67 | fQA(new ULong_t[fNdet]), | |
421ab0fb | 68 | fDet(kNULLDET), |
69 | fTask(kNULLTASK) | |
70 | { | |
71 | // default constructor | |
72 | // beware singleton: not to be used | |
4ecde5fc | 73 | |
9a223722 | 74 | for (Int_t index = 0 ; index < fNdet ; index++) |
75 | fQA[index] = 0 ; | |
421ab0fb | 76 | } |
77 | ||
78 | //____________________________________________________________________________ | |
2e42b4d4 | 79 | AliQA::AliQA(const AliQA& qa) : |
421ab0fb | 80 | TNamed(qa), |
9a223722 | 81 | fNdet(qa.fNdet), |
421ab0fb | 82 | fQA(qa.fQA), |
83 | fDet(qa.fDet), | |
84 | fTask(qa.fTask) | |
85 | { | |
86 | // cpy ctor | |
87 | } | |
88 | ||
89 | //_____________________________________________________________________________ | |
2e42b4d4 | 90 | AliQA& AliQA::operator = (const AliQA& qa) |
421ab0fb | 91 | { |
92 | // assignment operator | |
93 | ||
2e42b4d4 | 94 | this->~AliQA(); |
95 | new(this) AliQA(qa); | |
421ab0fb | 96 | return *this; |
97 | } | |
98 | ||
99 | //_______________________________________________________________ | |
2e42b4d4 | 100 | AliQA::AliQA(const DETECTORINDEX det) : |
9a223722 | 101 | TNamed("QA", "Quality Assurance status"), |
102 | fNdet(kNDET), | |
103 | fQA(new ULong_t[fNdet]), | |
a5fa6165 | 104 | fDet(det), |
105 | fTask(kNULLTASK) | |
106 | { | |
107 | // constructor to be used | |
108 | if (! CheckRange(det) ) { | |
109 | fDet = kNULLDET ; | |
110 | return ; | |
a4976ef3 | 111 | } |
a5fa6165 | 112 | Int_t index ; |
9a223722 | 113 | for (index = 0; index < fNdet; index++) |
a5fa6165 | 114 | fQA[index] = 0 ; |
115 | } | |
116 | ||
117 | //_______________________________________________________________ | |
2e42b4d4 | 118 | AliQA::AliQA(const ALITASK tsk) : |
421ab0fb | 119 | TNamed("QA", "Quality Assurance status"), |
9a223722 | 120 | fNdet(kNDET), |
121 | fQA(new ULong_t[fNdet]), | |
421ab0fb | 122 | fDet(kNULLDET), |
123 | fTask(tsk) | |
124 | { | |
125 | // constructor to be used in the AliRoot module (SIM, REC, ESD or ANA) | |
126 | if (! CheckRange(tsk) ) { | |
127 | fTask = kNULLTASK ; | |
128 | return ; | |
a4976ef3 | 129 | } |
a5fa6165 | 130 | Int_t index ; |
9a223722 | 131 | for (index = 0; index < fNdet; index++) |
a5fa6165 | 132 | fQA[index] = 0 ; |
421ab0fb | 133 | } |
134 | ||
135 | //____________________________________________________________________________ | |
2e42b4d4 | 136 | AliQA::~AliQA() |
421ab0fb | 137 | { |
138 | // dtor | |
139 | delete[] fQA ; | |
140 | } | |
141 | ||
4ecde5fc | 142 | //_______________________________________________________________ |
143 | const Bool_t AliQA::AddQAData2CDB(const char * defSto) const | |
144 | { | |
145 | // loads the QA data into the OCDB | |
146 | Bool_t rv = kTRUE ; | |
147 | AliCDBManager* man = AliCDBManager::Instance() ; | |
148 | man->SetDefaultStorage(defSto) ; | |
149 | AliCDBMetaData md ; | |
150 | // loop over detectors | |
151 | AliCDBId id("QA/Ref/PHOS",0,999999999) ; | |
152 | ||
153 | ||
154 | return rv ; | |
155 | } | |
156 | ||
46ca5304 | 157 | //_______________________________________________________________ |
158 | void AliQA::Close() | |
159 | { | |
160 | // close the open files | |
161 | if (fgQADataFile) | |
162 | if (fgQADataFile->IsOpen()) | |
163 | fgQADataFile->Close() ; | |
164 | if (fgQAResultFile) | |
165 | if (fgQAResultFile->IsOpen()) | |
166 | fgQAResultFile->Close() ; | |
167 | if (fgQARefFile) | |
168 | if (fgQARefFile->IsOpen()) | |
169 | fgQARefFile->Close() ; | |
170 | } | |
171 | ||
4ecde5fc | 172 | //_______________________________________________________________ |
173 | const Bool_t AliQA::CheckFatal() const | |
174 | { | |
175 | // check if any FATAL status is set | |
176 | Bool_t rv = kFALSE ; | |
177 | Int_t index ; | |
178 | for (index = 0; index < kNDET ; index++) | |
179 | rv = rv || IsSet(DETECTORINDEX(index), fTask, kFATAL) ; | |
180 | return rv ; | |
181 | } | |
182 | ||
421ab0fb | 183 | //_______________________________________________________________ |
2e42b4d4 | 184 | const Bool_t AliQA::CheckRange(DETECTORINDEX det) const |
421ab0fb | 185 | { |
a4976ef3 | 186 | // check if detector is in given detector range: 0-kNDET |
421ab0fb | 187 | |
a5fa6165 | 188 | Bool_t rv = ( det < 0 || det > kNDET ) ? kFALSE : kTRUE ; |
421ab0fb | 189 | if (!rv) |
190 | AliFatal(Form("Detector index %d is out of range: 0 <= index <= %d", det, kNDET)) ; | |
191 | return rv ; | |
192 | } | |
193 | ||
194 | //_______________________________________________________________ | |
2e42b4d4 | 195 | const Bool_t AliQA::CheckRange(ALITASK task) const |
421ab0fb | 196 | { |
197 | // check if task is given taskk range: 0:kNTASK | |
6c18591a | 198 | Bool_t rv = ( task < kRAW || task > kNTASK ) ? kFALSE : kTRUE ; |
421ab0fb | 199 | if (!rv) |
200 | AliFatal(Form("Module index %d is out of range: 0 <= index <= %d", task, kNTASK)) ; | |
201 | return rv ; | |
202 | } | |
203 | ||
204 | //_______________________________________________________________ | |
2e42b4d4 | 205 | const Bool_t AliQA::CheckRange(QABIT bit) const |
421ab0fb | 206 | { |
207 | // check if bit is in given bit range: 0-kNBit | |
208 | ||
209 | Bool_t rv = ( bit < 0 || bit > kNBIT ) ? kFALSE : kTRUE ; | |
210 | if (!rv) | |
211 | AliFatal(Form("Status bit %d is out of range: 0 <= bit <= %d", bit, kNBIT)) ; | |
212 | return rv ; | |
213 | } | |
214 | ||
421ab0fb | 215 | |
4ecde5fc | 216 | |
a5fa6165 | 217 | //_______________________________________________________________ |
2e42b4d4 | 218 | const char * AliQA::GetAliTaskName(ALITASK tsk) |
421ab0fb | 219 | { |
220 | // returns the char name corresponding to module index | |
a5fa6165 | 221 | TString tskName ; |
421ab0fb | 222 | switch (tsk) { |
223 | case kNULLTASK: | |
224 | break ; | |
6c18591a | 225 | case kRAW: |
226 | tskName = "RAW" ; | |
227 | break ; | |
421ab0fb | 228 | case kSIM: |
229 | tskName = "SIM" ; | |
230 | break ; | |
231 | case kREC: | |
232 | tskName = "REC" ; | |
233 | break ; | |
234 | case kESD: | |
235 | tskName = "ESD" ; | |
236 | break ; | |
237 | case kANA: | |
238 | tskName = "ANA" ; | |
239 | break ; | |
240 | default: | |
a5fa6165 | 241 | tsk = kNULLTASK ; |
421ab0fb | 242 | break ; |
243 | } | |
a5fa6165 | 244 | return tskName.Data() ; |
421ab0fb | 245 | } |
246 | ||
46ca5304 | 247 | //_______________________________________________________________ |
248 | const char * AliQA::GetDetName(Int_t det) | |
249 | { | |
250 | // returns the detector name corresponding to a given index (needed in a loop) | |
251 | ||
252 | if ( det >= 0 && det < kNDET) | |
253 | return (fgDetNames[det]).Data() ; | |
254 | else | |
255 | return NULL ; | |
256 | } | |
257 | ||
258 | //_______________________________________________________________ | |
259 | TFile * AliQA::GetQADataFile(const char * name, const Int_t run, const Int_t cycle) | |
260 | { | |
261 | // opens the file to store the detectors Quality Assurance Data Maker results | |
262 | char temp[100] ; | |
263 | sprintf(temp, "%s.%s.%d.%d.root", name, fgQADataFileName.Data(), run, cycle) ; | |
264 | TString opt ; | |
265 | if (! fgQADataFile ) { | |
266 | if (gSystem->AccessPathName(temp)) | |
267 | opt = "NEW" ; | |
268 | else | |
269 | opt = "UPDATE" ; | |
270 | fgQADataFile = TFile::Open(temp, opt.Data()) ; | |
271 | } else { | |
272 | if ( (strcmp(temp, fgQADataFile->GetName()) != 0) ) { | |
273 | if (gSystem->AccessPathName(temp)) | |
274 | opt = "NEW" ; | |
275 | else | |
276 | opt = "UPDATE" ; | |
277 | fgQADataFile = TFile::Open(temp, opt.Data()) ; | |
278 | } | |
279 | } | |
280 | return fgQADataFile ; | |
281 | } | |
282 | ||
283 | //_____________________________________________________________________________ | |
284 | TFile * AliQA::GetQADataFile(const char * fileName) | |
285 | { | |
286 | // Open if necessary the Data file and return its pointer | |
287 | ||
288 | if (!fgQADataFile) | |
289 | if (!fileName) | |
290 | fileName = AliQA::GetQADataFileName() ; | |
291 | if (!gSystem->AccessPathName(fileName)) { | |
292 | fgQADataFile = TFile::Open(fileName) ; | |
293 | } else { | |
294 | printf("File %s not found", fileName) ; | |
295 | exit(1) ; | |
296 | } | |
297 | return fgQADataFile ; | |
298 | } | |
299 | ||
421ab0fb | 300 | //_______________________________________________________________ |
4ecde5fc | 301 | TFile * AliQA::GetQARefFile() |
421ab0fb | 302 | { |
4ecde5fc | 303 | // opens the file whwre Quality Assurance Reference Data are stored |
304 | ||
46ca5304 | 305 | if (!fgQARefFile) { |
306 | TString fileName(fgQARefDirName + fgQARefFileName) ; | |
4ecde5fc | 307 | |
46ca5304 | 308 | if ( fileName.Contains("local://")) |
309 | fileName.ReplaceAll("local://", "") ; | |
4ecde5fc | 310 | |
46ca5304 | 311 | fgQARefFile = TFile::Open(fileName.Data(), "READ") ; |
312 | } | |
313 | return fgQARefFile ; | |
314 | } | |
4ecde5fc | 315 | |
316 | //_______________________________________________________________ | |
317 | TFile * AliQA::GetQAResultFile() | |
318 | { | |
319 | // opens the file to store the Quality Assurance Data Checker results | |
320 | ||
46ca5304 | 321 | if (!fgQAResultFile) { |
1c0190ec | 322 | TString dirName(fgQAResultDirName) ; |
323 | if ( dirName.Contains("local://")) | |
324 | dirName.ReplaceAll("local://", "") ; | |
325 | TString fileName(dirName + fgQAResultFileName) ; | |
46ca5304 | 326 | TString opt("") ; |
327 | if ( !gSystem->AccessPathName(fileName) ) | |
328 | opt = "UPDATE" ; | |
5bd22145 | 329 | else { |
1c0190ec | 330 | if ( gSystem->AccessPathName(dirName) ) |
331 | gSystem->mkdir(dirName) ; | |
46ca5304 | 332 | opt = "NEW" ; |
5bd22145 | 333 | } |
46ca5304 | 334 | fgQAResultFile = TFile::Open(fileName, opt) ; |
335 | } | |
336 | ||
337 | return fgQAResultFile ; | |
421ab0fb | 338 | } |
339 | ||
340 | //_______________________________________________________________ | |
2e42b4d4 | 341 | const Bool_t AliQA::IsSet(DETECTORINDEX det, ALITASK tsk, QABIT bit) const |
421ab0fb | 342 | { |
343 | // Checks is the requested bit is set | |
344 | ||
345 | CheckRange(det) ; | |
346 | CheckRange(tsk) ; | |
347 | CheckRange(bit) ; | |
348 | ||
349 | ULong_t offset = Offset(tsk) ; | |
350 | ULong_t status = GetStatus(det) ; | |
351 | offset+= bit ; | |
352 | status = (status & 1 << offset) != 0 ; | |
353 | return status ; | |
354 | } | |
355 | ||
356 | //_______________________________________________________________ | |
2e42b4d4 | 357 | AliQA * AliQA::Instance() |
421ab0fb | 358 | { |
359 | // Get an instance of the singleton. | |
360 | // Object must have been instantiated with Instance(ALITASK) first | |
361 | ||
362 | return fgQA ; | |
363 | } | |
364 | ||
365 | //_______________________________________________________________ | |
2e42b4d4 | 366 | AliQA * AliQA::Instance(const DETECTORINDEX det) |
421ab0fb | 367 | { |
368 | // Get an instance of the singleton. The only authorized way to call the ctor | |
369 | ||
9a223722 | 370 | if ( ! fgQA) { |
46ca5304 | 371 | TFile * f = GetQAResultFile() ; |
9a223722 | 372 | fgQA = dynamic_cast<AliQA *>(f->Get("QA")) ; |
373 | if ( ! fgQA ) | |
374 | fgQA = new AliQA(det) ; | |
375 | } | |
421ab0fb | 376 | fgQA->Set(det) ; |
377 | return fgQA ; | |
378 | } | |
379 | ||
380 | //_______________________________________________________________ | |
2e42b4d4 | 381 | AliQA * AliQA::Instance(const ALITASK tsk) |
421ab0fb | 382 | { |
383 | // get an instance of the singleton. | |
384 | ||
385 | if ( ! fgQA) | |
386 | switch (tsk) { | |
387 | case kNULLTASK: | |
388 | break ; | |
6c18591a | 389 | case kRAW: |
2e42b4d4 | 390 | fgQA = new AliQA(tsk) ; |
6c18591a | 391 | break ; |
392 | case kSIM: | |
2e42b4d4 | 393 | fgQA = new AliQA(tsk) ; |
421ab0fb | 394 | break ; |
395 | case kREC: | |
396 | printf("fgQA = gAlice->GetQA()") ; | |
397 | break ; | |
398 | case kESD: | |
399 | printf("fgQA = dynamic_cast<AliQA *> (esdFile->Get(\"QA\")") ; | |
400 | break ; | |
401 | case kANA: | |
402 | printf("fgQA = dynamic_cast<AliQA *> (esdFile->Get(\"QA\")") ; | |
403 | break ; | |
404 | case kNTASK: | |
405 | break ; | |
406 | } | |
407 | if (fgQA) | |
408 | fgQA->Set(tsk) ; | |
409 | return fgQA ; | |
410 | } | |
411 | ||
412 | //_______________________________________________________________ | |
2e42b4d4 | 413 | const ULong_t AliQA::Offset(ALITASK tsk) const |
421ab0fb | 414 | { |
415 | // Calculates the bit offset for a given module (SIM, REC, ESD, ANA) | |
416 | ||
417 | CheckRange(tsk) ; | |
418 | ||
419 | ULong_t offset = 0 ; | |
420 | switch (tsk) { | |
421 | case kNULLTASK: | |
422 | break ; | |
6c18591a | 423 | case kRAW: |
421ab0fb | 424 | offset+= 0 ; |
425 | break ; | |
6c18591a | 426 | case kSIM: |
421ab0fb | 427 | offset+= 4 ; |
428 | break ; | |
6c18591a | 429 | case kREC: |
421ab0fb | 430 | offset+= 8 ; |
431 | break ; | |
6c18591a | 432 | case kESD: |
421ab0fb | 433 | offset+= 12 ; |
434 | break ; | |
6c18591a | 435 | case kANA: |
436 | offset+= 16 ; | |
437 | break ; | |
421ab0fb | 438 | case kNTASK: |
439 | break ; | |
440 | } | |
441 | ||
442 | return offset ; | |
443 | } | |
444 | ||
445 | //_______________________________________________________________ | |
2e42b4d4 | 446 | void AliQA::Set(QABIT bit) |
421ab0fb | 447 | { |
448 | // Set the status bit of the current detector in the current module | |
449 | ||
450 | SetStatusBit(fDet, fTask, bit) ; | |
451 | } | |
452 | ||
4ecde5fc | 453 | //_____________________________________________________________________________ |
454 | void AliQA::SetQARefDir(const char * name) | |
455 | { | |
456 | // Set the root directory where the QA reference data are stored | |
457 | ||
458 | fgQARefDirName.Prepend(name) ; | |
459 | printf("AliQA::SetQARefDir: QA references are in %s\n", fgQARefDirName.Data()) ; | |
460 | if ( fgQARefDirName.Contains("local://")) | |
461 | fgQARefDirName.ReplaceAll("local:/", "") ; | |
462 | fgQARefFileName.Prepend(fgQARefDirName) ; | |
463 | } | |
464 | ||
465 | //_____________________________________________________________________________ | |
466 | void AliQA::SetQAResultDirName(const char * name) | |
467 | { | |
468 | // Set the root directory where to store the QA status object | |
469 | ||
470 | fgQAResultDirName.Prepend(name) ; | |
471 | printf("AliQA::SetQAResultDirName: QA results are in %s\n", fgQAResultDirName.Data()) ; | |
472 | if ( fgQAResultDirName.Contains("local://")) | |
473 | fgQAResultDirName.ReplaceAll("local:/", "") ; | |
474 | fgQAResultFileName.Prepend(fgQAResultDirName) ; | |
475 | } | |
476 | ||
421ab0fb | 477 | //_______________________________________________________________ |
2e42b4d4 | 478 | void AliQA::SetStatusBit(DETECTORINDEX det, ALITASK tsk, QABIT bit) |
421ab0fb | 479 | { |
480 | // Set the status bit for a given detector and a given task | |
481 | ||
482 | CheckRange(det) ; | |
483 | CheckRange(tsk) ; | |
484 | CheckRange(bit) ; | |
485 | ||
486 | ULong_t offset = Offset(tsk) ; | |
487 | ULong_t status = GetStatus(det) ; | |
488 | offset+= bit ; | |
489 | status = status | 1 << offset ; | |
490 | SetStatus(det, status) ; | |
491 | } | |
492 | ||
493 | //_______________________________________________________________ | |
2e42b4d4 | 494 | void AliQA::ShowAll() const |
421ab0fb | 495 | { |
496 | // dispplay the QA status word | |
497 | Int_t index ; | |
498 | for (index = 0 ; index < kNDET ; index++) | |
499 | ShowStatus(DETECTORINDEX(index)) ; | |
500 | } | |
501 | ||
502 | //_______________________________________________________________ | |
2e42b4d4 | 503 | void AliQA::ShowStatus(DETECTORINDEX det) const |
421ab0fb | 504 | { |
505 | // Prints the full QA status of a given detector | |
506 | CheckRange(det) ; | |
507 | ULong_t status = GetStatus(det) ; | |
a4976ef3 | 508 | ULong_t rawStatus = status & 0x0000f ; |
509 | ULong_t simStatus = status & 0x000f0 ; | |
510 | ULong_t recStatus = status & 0x00f00 ; | |
511 | ULong_t esdStatus = status & 0x0f000 ; | |
512 | ULong_t anaStatus = status & 0xf0000 ; | |
421ab0fb | 513 | |
a4976ef3 | 514 | AliInfo(Form("QA Status for %s raw =0x%x, sim=0x%x, rec=0x%x, esd=0x%x, ana=0x%x\n", GetDetName(det).Data(), rawStatus, simStatus, recStatus, esdStatus, anaStatus )) ; |
421ab0fb | 515 | } |
516 |