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