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