]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliQAv1.cxx
reorganization of TRD PID reference maker classes. Data management has
[u/mrichter/AliRoot.git] / STEER / AliQAv1.cxx
CommitLineData
4e25ac79 1
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: AliQAv1.cxx 31503 2009-03-16 11:01:16Z schutz $ */
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 (RAW)
24// bit 4-7 : QA raised during simulation (SIM)
25// bit 8-11 : QA raised during reconstruction (REC)
26// bit 12-15 : QA raised during ESD checking (ESD)
27// bit 16-19 : QA raised during analysis (ANA)
28// Each of the 4 bits corresponds to a severity level of increasing importance
29// from lower to higher bit (INFO, WARNING, ERROR, FATAL)
30//
31//*-- Yves Schutz CERN, July 2007
32//////////////////////////////////////////////////////////////////////////////
33
34
35#include <cstdlib>
36// --- ROOT system ---
34709735 37#include <TClass.h>
4e25ac79 38#include <TFile.h>
39#include <TSystem.h>
40#include <TROOT.h>
41
42// --- Standard library ---
43
44// --- AliRoot header files ---
45#include "AliLog.h"
46#include "AliQAv1.h"
47
48
49ClassImp(AliQAv1)
49466ea2 50AliQAv1 * AliQAv1::fgQA = 0x0 ;
51TFile * AliQAv1::fgQADataFile = 0x0 ;
52TString AliQAv1::fgQADataFileName = "QA" ; // will transform into Det.QA.run.root
53TFile * AliQAv1::fgQARefFile = 0x0 ;
54TString AliQAv1::fgQARefDirName = "" ;
55TString AliQAv1::fgQARefFileName = "QA.root" ;
56TFile * AliQAv1::fgQAResultFile = 0x0 ;
57TString AliQAv1::fgQAResultDirName = "" ;
58TString AliQAv1::fgQAResultFileName = "QA.root" ;
59TString AliQAv1::fgDetNames[] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD",
60 "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT", "Global", "CORR"} ;
61TString AliQAv1::fgGRPPath = "GRP/GRP/Data" ;
62TString AliQAv1::fgTaskNames[] = {"Raws", "Hits", "SDigits", "Digits", "DigitsR", "RecPoints", "TrackSegments", "RecParticles", "ESDs"} ;
634696f5 63TString AliQAv1::fgModeNames[] = {"", "Sim", "Rec"} ;
49466ea2 64const TString AliQAv1::fgkLabLocalFile = "file://" ;
65const TString AliQAv1::fgkLabLocalOCDB = "local://" ;
66const TString AliQAv1::fgkLabAliEnOCDB = "alien://" ;
67const TString AliQAv1::fgkRefFileName = "QA.root" ;
68const TString AliQAv1::fgkQAName = "QA" ;
69const TString AliQAv1::fgkQACorrNtName = "CorrQA" ;
70const TString AliQAv1::fgkRefOCDBDirName = "QA" ;
71TString AliQAv1::fgRefDataDirName = "" ;
72const TString AliQAv1::fgkQARefOCDBDefault = "alien://folder=/alice/QA/20" ;
73const TString AliQAv1::fgkExpert = "Expert" ;
74const UInt_t AliQAv1::fgkExpertBit = 0x40000 ;
75const UInt_t AliQAv1::fgkQABit = 0x80000 ;
76const UInt_t AliQAv1::fgkImageBit = 0x100000 ;
77const Int_t AliQAv1::fgkQADebugLevel = 99 ;
78const TString AliQAv1::fImageFileName = "QAImage" ;
99737f39 79const TString AliQAv1::fImageFileFormat = "ps" ;
49466ea2 80const UShort_t AliQAv1::fgkMaxQAObjects = 10000 ;
fec0891b 81
4e25ac79 82//____________________________________________________________________________
83AliQAv1::AliQAv1() :
84 TNamed("", ""),
85 fNdet(kNDET),
86 fNEventSpecies(AliRecoParam::kNSpecies),
87 fLengthQA(fNdet*fNEventSpecies),
88 fQA(new ULong_t[fLengthQA]),
89 fDet(kNULLDET),
90 fTask(kNULLTASK),
91 fEventSpecie(AliRecoParam::kDefault),
92 fEventSpecies(new Bool_t[fNEventSpecies])
93{
94 // default constructor
95 memset(fQA,0,fLengthQA*sizeof(ULong_t));
96 memset(fEventSpecies,kFALSE,fNEventSpecies*sizeof(Bool_t));
97}
98
99//____________________________________________________________________________
100AliQAv1::AliQAv1(const AliQAv1& qa) :
101 TNamed(qa),
102 fNdet(qa.fNdet),
103 fNEventSpecies(qa.fNEventSpecies),
104 fLengthQA(qa.fLengthQA),
105 fQA(new ULong_t[fLengthQA]),
106 fDet(qa.fDet),
107 fTask(qa.fTask),
108 fEventSpecie(qa.fEventSpecie),
109 fEventSpecies(new Bool_t[fNEventSpecies])
110{
111 // cpy ctor
112 memcpy(fQA,qa.fQA,fLengthQA*sizeof(ULong_t));
113 memcpy(fEventSpecies,qa.fEventSpecies,fNEventSpecies*sizeof(Bool_t));
114}
115
116//_____________________________________________________________________________
117AliQAv1& AliQAv1::operator = (const AliQAv1& qa)
118{
119 // assignment operator
120 if(&qa != this) {
121 TNamed::operator=(qa);
122 fNdet = qa.fNdet;
123 fNEventSpecies = qa.fNEventSpecies;
124 fLengthQA = qa.fLengthQA;
125
126 if(fQA) delete [] fQA;
127 fQA = new ULong_t[fLengthQA];
128 memcpy(fQA,qa.fQA,fLengthQA*sizeof(ULong_t));
129
130 fDet = qa.fDet;
131 fTask = qa.fTask;
132 fEventSpecie = qa.fEventSpecie;
133 if(fEventSpecies) delete [] fEventSpecies;
134 fEventSpecies = new Bool_t[fNEventSpecies];
135 memcpy(fEventSpecies,qa.fEventSpecies,fNEventSpecies*sizeof(Bool_t));
136 }
137 return *this;
138}
139
140//_______________________________________________________________
141AliQAv1::AliQAv1(const Int_t qalength, ULong_t * qa, const Int_t eslength, Bool_t * es) :
142TNamed("QA", "Quality Assurance status"),
143fNdet(kNDET),
144fNEventSpecies(eslength),
145fLengthQA(qalength),
146fQA(new ULong_t[fLengthQA]),
147fDet(kNULLDET),
148fTask(kNULLTASK),
149fEventSpecie(AliRecoParam::kDefault),
150fEventSpecies(new Bool_t[fNEventSpecies])
151{
152 // constructor to be used
153 memcpy(fQA, qa, fLengthQA*sizeof(ULong_t));
154 memcpy(fEventSpecies, es, fNEventSpecies*sizeof(Bool_t));
155}
156
157//_______________________________________________________________
158AliQAv1::AliQAv1(const DETECTORINDEX_t det) :
159 TNamed("QA", "Quality Assurance status"),
160 fNdet(kNDET),
161 fNEventSpecies(AliRecoParam::kNSpecies),
162 fLengthQA(fNdet*fNEventSpecies),
163 fQA(new ULong_t[fLengthQA]),
164 fDet(det),
165 fTask(kNULLTASK),
166 fEventSpecie(AliRecoParam::kDefault),
167 fEventSpecies(new Bool_t[fNEventSpecies])
168{
169 // constructor to be used
170 if (! CheckRange(det) ) fDet = kNULLDET ;
171 memset(fQA,0,fLengthQA*sizeof(ULong_t));
172 memset(fEventSpecies,kFALSE,fNEventSpecies*sizeof(Bool_t));
173}
174
175//_______________________________________________________________
176AliQAv1::AliQAv1(const ALITASK_t tsk) :
177 TNamed("QA", "Quality Assurance status"),
178 fNdet(kNDET),
179 fNEventSpecies(AliRecoParam::kNSpecies),
180 fLengthQA(fNdet*fNEventSpecies),
181 fQA(new ULong_t[fLengthQA]),
182 fDet(kNULLDET),
183 fTask(tsk),
184 fEventSpecie(AliRecoParam::kDefault),
185 fEventSpecies(new Bool_t[fNEventSpecies])
186{
187 // constructor to be used in the AliRoot module (SIM, REC, ESD or ANA)
188 if (! CheckRange(tsk) ) fTask = kNULLTASK ;
189 memset(fQA,0,fLengthQA*sizeof(ULong_t));
190 memset(fEventSpecies,kFALSE,fNEventSpecies*sizeof(Bool_t));
191}
192
193//____________________________________________________________________________
194AliQAv1::~AliQAv1()
195{
196 // dtor
197 delete [] fQA;
198 delete [] fEventSpecies;
199}
200
201//_______________________________________________________________
202void AliQAv1::Close()
203{
204 // close the open files
205 if (fgQADataFile)
206 if (fgQADataFile->IsOpen())
207 fgQADataFile->Close() ;
208 if (fgQAResultFile)
209 if (fgQAResultFile->IsOpen())
210 fgQAResultFile->Close() ;
211 if (fgQARefFile)
212 if (fgQARefFile->IsOpen())
213 fgQARefFile->Close() ;
214}
215
216//_______________________________________________________________
217Bool_t AliQAv1::CheckFatal() const
218{
219 // check if any FATAL status is set
220 Bool_t rv = kFALSE ;
221 Int_t index ;
222 for (index = 0; index < kNDET ; index++)
223 rv = rv || IsSet(DETECTORINDEX_t(index), fTask, fEventSpecie, kFATAL) ;
224 return rv ;
225}
226
227//_______________________________________________________________
228Bool_t AliQAv1::CheckRange(DETECTORINDEX_t det) const
229{
230 // check if detector is in given detector range: 0-kNDET
231
232 Bool_t rv = ( det < 0 || det > kNDET ) ? kFALSE : kTRUE ;
233 if (!rv)
234 AliFatal(Form("Detector index %d is out of range: 0 <= index <= %d", det, kNDET)) ;
235 return rv ;
236}
237
238//_______________________________________________________________
239Bool_t AliQAv1::CheckRange(ALITASK_t task) const
240{
241 // check if task is given taskk range: 0:kNTASK
242 Bool_t rv = ( task < kRAW || task > kNTASK ) ? kFALSE : kTRUE ;
243 if (!rv)
244 AliFatal(Form("Module index %d is out of range: 0 <= index <= %d", task, kNTASK)) ;
245 return rv ;
246}
247
248//_______________________________________________________________
249Bool_t AliQAv1::CheckRange(QABIT_t bit) const
250{
251 // check if bit is in given bit range: 0-kNBit
252
253 Bool_t rv = ( bit < 0 || bit > kNBIT ) ? kFALSE : kTRUE ;
254 if (!rv)
255 AliFatal(Form("Status bit %d is out of range: 0 <= bit <= %d", bit, kNBIT)) ;
256 return rv ;
257}
258
259//_______________________________________________________________
260Bool_t AliQAv1::CheckRange(AliRecoParam::EventSpecie_t es) const
261{
262 // check if bit is in given bit range: 0-kNBit
263 Bool_t rv = kFALSE ;
264 switch (es) {
265 case AliRecoParam::kDefault:
266 rv = kTRUE ;
267 break ;
268 case AliRecoParam::kLowMult:
269 rv = kTRUE ;
270 break ;
271 case AliRecoParam::kHighMult:
272 rv = kTRUE ;
273 break ;
274 case AliRecoParam::kCosmic:
275 rv = kTRUE ;
276 break ;
277 case AliRecoParam::kCalib:
278 rv = kTRUE ;
279 break ;
280 }
281 if (!rv)
282 AliFatal(Form("Event Specie %d is not valid", es)) ;
283 return rv ;
284}
285
286//_______________________________________________________________
287const char * AliQAv1::GetAliTaskName(ALITASK_t tsk)
288{
289 // returns the char name corresponding to module index
290 TString tskName ;
291 switch (tsk) {
292 case kNULLTASK:
293 break ;
294 case kRAW:
295 tskName = "RAW" ;
296 break ;
297 case kSIM:
298 tskName = "SIM" ;
299 break ;
300 case kREC:
301 tskName = "REC" ;
302 break ;
303 case kESD:
304 tskName = "ESD" ;
305 break ;
306 case kANA:
307 tskName = "ANA" ;
308 break ;
309 default:
310 tsk = kNULLTASK ;
311 break ;
312 }
313 return tskName.Data() ;
314}
315
316//_______________________________________________________________
317const char * AliQAv1::GetBitName(QABIT_t bit) const
318{
319 // returns the char name corresponding to bit
320 TString bitName ;
321 switch (bit) {
322 case kNULLBit:
323 break ;
324 case kINFO:
325 bitName = "INFO" ;
326 break ;
327 case kWARNING:
328 bitName = "WARNING" ;
329 break ;
330 case kERROR:
331 bitName = "ERROR" ;
332 break ;
333 case kFATAL:
334 bitName = "FATAL" ;
335 break ;
336 default:
337 bit = kNULLBit ;
338 break ;
339 }
340 return bitName.Data() ;
341}
342
343//_______________________________________________________________
344AliQAv1::DETECTORINDEX_t AliQAv1::GetDetIndex(const char * name)
345{
346 // returns the detector index corresponding to a given name
347 TString sname(name) ;
348 DETECTORINDEX_t rv = kNULLDET ;
349 for (Int_t det = 0; det < kNDET ; det++) {
350 if ( GetDetName(det) == sname ) {
351 rv = DETECTORINDEX_t(det) ;
352 break ;
353 }
354 }
355 return rv ;
356}
357
358//_______________________________________________________________
359const char * AliQAv1::GetDetName(Int_t det)
360{
361 // returns the detector name corresponding to a given index (needed in a loop)
362
363 if ( det >= 0 && det < kNDET)
364 return (fgDetNames[det]).Data() ;
365 else
366 return NULL ;
367}
368
369//_______________________________________________________________
370TFile * AliQAv1::GetQADataFile(const char * name, Int_t run)
371{
372 // opens the file to store the detectors Quality Assurance Data Maker results
373 const char * temp = Form("%s.%s.%d.root", name, fgQADataFileName.Data(), run) ;
374 TString opt ;
375 if (! fgQADataFile ) {
376 if (gSystem->AccessPathName(temp))
377 opt = "NEW" ;
378 else
379 opt = "UPDATE" ;
380 fgQADataFile = TFile::Open(temp, opt.Data()) ;
381 } else {
382 if ( strcmp(temp, fgQADataFile->GetName()) != 0 ) {
eca4fa66 383 fgQADataFile = static_cast<TFile *>(gROOT->FindObject(temp)) ;
4e25ac79 384 if ( !fgQADataFile ) {
eca4fa66 385 if (gSystem->AccessPathName(temp))
386 opt = "NEW" ;
387 else
388 opt = "UPDATE" ;
4e25ac79 389 fgQADataFile = TFile::Open(temp, opt.Data()) ;
390 }
391 }
392 }
393 return fgQADataFile ;
394}
395
634696f5 396//_____________________________________________________________________________
397AliQAv1::MODE_t AliQAv1::Mode(TASKINDEX_t task) {
398 // return "rec" or "sim" depending on the task
399
400 switch (task) {
401 case AliQAv1::kRAWS:
402 return kRECMODE ;
403 break;
404 case AliQAv1::kHITS:
405 return kSIMMODE ;
406 break;
407 case AliQAv1::kSDIGITS:
408 return kSIMMODE ;
409 break;
410 case AliQAv1::kDIGITS:
411 return kSIMMODE ;
412 break;
413 case AliQAv1::kDIGITSR:
414 return kRECMODE ;
415 break;
416 case AliQAv1::kRECPOINTS:
417 return kRECMODE ;
418 break ;
419 case AliQAv1::kTRACKSEGMENTS:
420 return kRECMODE ;
421 break;
422 case AliQAv1::kRECPARTICLES:
423 return kRECMODE ;
424 break;
425 case AliQAv1::kESDS:
426 return kRECMODE ;
427 break;
428 default:
429 break;
430 }
431}
432
4e25ac79 433//_____________________________________________________________________________
434TFile * AliQAv1::GetQADataFile(const char * fileName)
435{
436 // Open if necessary the Data file and return its pointer
437
cf5fddb1 438 if (!fgQADataFile) {
439 if (!fileName)
440 fileName = AliQAv1::GetQADataFileName() ;
441 if (!gSystem->AccessPathName(fileName)) {
442 fgQADataFile = TFile::Open(fileName) ;
443 } else {
444 AliFatalClass(Form("File %s not found", fileName)) ;
445 }
446 }
4e25ac79 447 return fgQADataFile ;
448}
449
450//_______________________________________________________________
451TFile * AliQAv1::GetQAResultFile()
452{
453 // opens the file to store the Quality Assurance Data Checker results
454 if (fgQAResultFile)
455 fgQAResultFile->Close() ;
456 fgQAResultFile = 0x0 ;
457// if (!fgQAResultFile) {
458 TString dirName(fgQAResultDirName) ;
459 if ( dirName.Contains(fgkLabLocalFile))
460 dirName.ReplaceAll(fgkLabLocalFile, "") ;
461 TString fileName(dirName + fgQAResultFileName) ;
462 TString opt("") ;
463 if ( !gSystem->AccessPathName(fileName) )
464 opt = "UPDATE" ;
465 else {
466 if ( gSystem->AccessPathName(dirName) )
467 gSystem->mkdir(dirName) ;
468 opt = "NEW" ;
469 }
470 fgQAResultFile = TFile::Open(fileName, opt) ;
471// }
472
473 return fgQAResultFile ;
474}
475
476//_______________________________________________________________
477AliQAv1::TASKINDEX_t AliQAv1::GetTaskIndex(const char * name)
478{
479 // returns the detector index corresponding to a given name
480 TString sname(name) ;
481 TASKINDEX_t rv = kNULLTASKINDEX ;
482 for (Int_t tsk = 0; tsk < kNTASKINDEX ; tsk++) {
483 if ( GetTaskName(tsk) == sname ) {
484 rv = TASKINDEX_t(tsk) ;
485 break ;
486 }
487 }
488 return rv ;
489}
490
491//_______________________________________________________________
492Bool_t AliQAv1::IsSet(DETECTORINDEX_t det, ALITASK_t tsk, Int_t ies, QABIT_t bit) const
493{
494 // Checks is the requested bit is set
495
496 const AliRecoParam::EventSpecie_t es = AliRecoParam::Convert(ies) ;
497 return IsSet(det, tsk, es, bit) ;
498
499}
500
501//_______________________________________________________________
502Bool_t AliQAv1::IsSet(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es, QABIT_t bit) const
503{
504 // Checks is the requested bit is set
505
506 CheckRange(det) ;
507 CheckRange(tsk) ;
508 CheckRange(bit) ;
509 CheckRange(es) ;
510
511 ULong_t offset = Offset(tsk) ;
512 ULong_t status = GetStatus(det, es) ;
513 offset+= bit ;
514 status = (status & 1 << offset) != 0 ;
515 return status ;
516}
517
518//_______________________________________________________________
519Bool_t AliQAv1::IsSetAny(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es) const
520{
521 // Checks is the requested bit is set
522
523 CheckRange(det) ;
524 CheckRange(tsk) ;
525 CheckRange(es) ;
526
527 ULong_t offset = Offset(tsk) ;
528 ULong_t status = GetStatus(det, es) ;
529 ULong_t st = 0 ;
530 for ( Int_t bit = 0 ; bit < kNBIT ; bit++) {
531 offset+= bit ;
532 st += (status & 1 << offset) != 0 ;
533 }
534 if ( st == 0 )
535 return kFALSE ;
536 else
537 return kTRUE ;
538}
539//_______________________________________________________________
540Bool_t AliQAv1::IsSetAny(DETECTORINDEX_t det, AliRecoParam::EventSpecie_t es) const
541{
542 // Checks is the requested bit is set
543
544 CheckRange(det) ;
545 CheckRange(es) ;
546
547 ULong_t status = GetStatus(det, es) ;
548 ULong_t st = 0 ;
549 for ( Int_t tsk = 0 ; tsk < kNTASK ; tsk++) {
550 ULong_t offset = Offset(ALITASK_t(tsk)) ;
551 for ( Int_t bit = 0 ; bit < kNBIT ; bit++) {
552 offset+= bit ;
553 st += (status & 1 << offset) != 0 ;
554 }
555 }
556 if ( st == 0 )
557 return kFALSE ;
558 else
559 return kTRUE ;
560}
561
562//_______________________________________________________________
563AliQAv1 * AliQAv1::Instance()
564{
565 // Get an instance of the singleton. The only authorized way to call the ctor
566
567 if ( ! fgQA) {
568 TFile * f = GetQAResultFile() ;
eca4fa66 569 fgQA = static_cast<AliQAv1 *>(f->Get("QA")) ;
4e25ac79 570 if ( ! fgQA )
571 fgQA = new AliQAv1() ;
eca4fa66 572 }
4e25ac79 573 return fgQA ;
574}
575
576//_______________________________________________________________
577AliQAv1 * AliQAv1::Instance(const Int_t qalength, ULong_t * qa, const Int_t eslength, Bool_t * es)
578{
579 // Get an instance of the singleton. The only authorized way to call the ctor
580
581 if ( ! fgQA)
582 fgQA = new AliQAv1(qalength, qa, eslength, es) ;
583 return fgQA ;
584}
585
586//_______________________________________________________________
587AliQAv1 * AliQAv1::Instance(const DETECTORINDEX_t det)
588{
589 // Get an instance of the singleton. The only authorized way to call the ctor
590
591 if ( ! fgQA) {
592 TFile * f = GetQAResultFile() ;
eca4fa66 593 fgQA = static_cast<AliQAv1 *>(f->Get("QA")) ;
4e25ac79 594 if ( ! fgQA )
eca4fa66 595 fgQA = new AliQAv1(det) ;
4e25ac79 596 }
597 fgQA->Set(det) ;
598 return fgQA ;
599}
600
601//_______________________________________________________________
602AliQAv1 * AliQAv1::Instance(const ALITASK_t tsk)
603{
604 // Get an instance of the singleton. The only authorized way to call the ctor
605
606 if ( ! fgQA)
607 switch (tsk) {
608 case kNULLTASK:
609 break ;
610 case kRAW:
611 fgQA = new AliQAv1(tsk) ;
612 break ;
613 case kSIM:
614 fgQA = new AliQAv1(tsk) ;
615 break ;
616 case kREC:
34709735 617 AliInfoClass("fgQA = gAlice->GetQA()") ;
4e25ac79 618 break ;
619 case kESD:
eca4fa66 620 AliInfoClass("fgQA = static_cast<AliQAv1 *> (esdFile->Get(\"QA\")") ;
4e25ac79 621 break ;
622 case kANA:
eca4fa66 623 AliInfoClass("fgQA = static_cast<AliQAv1 *> (esdFile->Get(\"QA\")") ;
4e25ac79 624 break ;
625 case kNTASK:
626 break ;
627 }
628 if (fgQA)
629 fgQA->Set(tsk) ;
630 return fgQA ;
631}
632
633//_______________________________________________________________
634AliQAv1 * AliQAv1::Instance(const TASKINDEX_t tsk)
635{
636 // get an instance of the singleton.
637
638 ALITASK_t index = kNULLTASK ;
639
640 if ( tsk == kRAWS )
641 index = kRAW ;
642 else if (tsk < kDIGITS)
643 index = kSIM ;
644 else if (tsk < kRECPARTICLES)
645 index = kREC ;
646 else if (tsk == kESDS)
647 index = kESD ;
648
649 return Instance(index) ;
650}
651
652//_______________________________________________________________
653void AliQAv1::Merge(TCollection * list) {
654 // Merge the QA resuls in the list into this single AliQAv1 object
655
656 for (Int_t det = 0 ; det < kNDET ; det++) {
657 Set(DETECTORINDEX_t(det)) ;
658 for (Int_t task = 0 ; task < kNTASK ; task++) {
659 Set(ALITASK_t(task)) ;
660 for (Int_t bit = 0 ; bit < kNBIT ; bit++) {
661 TIter next(list) ;
662 AliQAv1 * qa ;
663 while ( (qa = (AliQAv1*)next() ) ) {
664 for (Int_t es = 0 ; es < fNEventSpecies ; es++) {
665 if (qa->IsSet(DETECTORINDEX_t(det), ALITASK_t(task), es, QABIT_t(bit)))
666 Set(QABIT_t(bit), es) ;
667 }
668 } // qa list
669 } // bit
670 } // task
671 } // detector
672}
673
674//_______________________________________________________________
675ULong_t AliQAv1::Offset(ALITASK_t tsk) const
676{
677 // Calculates the bit offset for a given module (SIM, REC, ESD, ANA)
678
679 CheckRange(tsk) ;
680
681 ULong_t offset = 0 ;
682 switch (tsk) {
683 case kNULLTASK:
684 break ;
685 case kRAW:
686 offset+= 0 ;
687 break ;
688 case kSIM:
689 offset+= 4 ;
690 break ;
691 case kREC:
692 offset+= 8 ;
693 break ;
694 case kESD:
695 offset+= 12 ;
696 break ;
697 case kANA:
698 offset+= 16 ;
699 break ;
700 case kNTASK:
701 break ;
702 }
703
704 return offset ;
705}
706
707//_______________________________________________________________
708void AliQAv1::ResetStatus(DETECTORINDEX_t det)
709{
710 // reset the status of det for all event specie
711 for (Int_t es = 0 ; es < fNEventSpecies ; es++)
712 fQA[det*fNdet+es] = 0 ;
713}
714
715//_______________________________________________________________
716void AliQAv1::Set(QABIT_t bit, Int_t ies)
717{
718 // Set the status bit of the current detector in the current module and for the current event specie
719 Set(bit, AliRecoParam::Convert(ies)) ;
720}
721
722//_______________________________________________________________
723void AliQAv1::Set(QABIT_t bit, AliRecoParam::EventSpecie_t es)
724{
725 // Set the status bit of the current detector in the current module and for the current event specie
726
727 SetStatusBit(fDet, fTask, es, bit) ;
728}
729
730//_____________________________________________________________________________
731void AliQAv1::SetQARefStorage(const char * name)
732{
733 // Set the root directory where the QA reference data are stored
734
735 fgQARefDirName = name ;
736 if ( fgQARefDirName.Contains(fgkLabLocalFile) )
737 fgQARefFileName = fgkRefFileName ;
738 else if ( fgQARefDirName.Contains(fgkLabLocalOCDB) )
739 fgQARefFileName = fgkQAName ;
740 else if ( fgQARefDirName.Contains(fgkLabAliEnOCDB) )
741 fgQARefFileName = fgkQAName ;
742
743 else {
34709735 744 AliErrorClass(Form("ERROR: %s is an invalid storage definition\n", name)) ;
4e25ac79 745 fgQARefDirName = "" ;
746 fgQARefFileName = "" ;
747 }
748 TString tmp(fgQARefDirName) ; // + fgQARefFileName) ;
34709735 749 AliInfoClass(Form("AliQAv1::SetQARefDir: QA references are in %s\n", tmp.Data() )) ;
4e25ac79 750}
751
752//_____________________________________________________________________________
753void AliQAv1::SetQAResultDirName(const char * name)
754{
755 // Set the root directory where to store the QA status object
756
757 fgQAResultDirName.Prepend(name) ;
34709735 758 AliInfoClass(Form("AliQAv1::SetQAResultDirName: QA results are in %s\n", fgQAResultDirName.Data())) ;
4e25ac79 759 if ( fgQAResultDirName.Contains(fgkLabLocalFile))
760 fgQAResultDirName.ReplaceAll(fgkLabLocalFile, "") ;
761 fgQAResultFileName.Prepend(fgQAResultDirName) ;
762}
763
764//_______________________________________________________________
765void AliQAv1::SetStatusBit(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es, QABIT_t bit)
766{
767 // Set the status bit for a given detector and a given task
768
769 CheckRange(det) ;
770 CheckRange(tsk) ;
771 CheckRange(bit) ;
772 CheckRange(es) ;
773
774 ULong_t offset = Offset(tsk) ;
775 ULong_t status = GetStatus(det, es) ;
776 offset+= bit ;
777 status = status | 1 << offset ;
778 SetStatus(det, es, status) ;
779}
780
781//_______________________________________________________________
782void AliQAv1::Show(DETECTORINDEX_t det) const
783{
784 // dispplay the QA status word
785 if ( det == kNULLDET)
786 det = fDet ;
787 for (Int_t ies = 0 ; ies < fNEventSpecies ; ies++) {
eca4fa66 788 if ( IsEventSpecieSet(ies) )
789 ShowStatus(det, kNULLTASK, AliRecoParam::ConvertIndex(ies)) ;
4e25ac79 790 }
791}
792
793//_______________________________________________________________
794void AliQAv1::ShowAll() const
795{
796 // dispplay the QA status word
797 Int_t index ;
798 for (index = 0 ; index < kNDET ; index++) {
799 for (Int_t tsk = kRAW ; tsk < kNTASK ; tsk++) {
800 for (Int_t ies = 0 ; ies < fNEventSpecies ; ies++) {
eca4fa66 801 if ( IsEventSpecieSet(ies) )
802 ShowStatus(DETECTORINDEX_t(index), ALITASK_t(tsk), AliRecoParam::ConvertIndex(ies)) ;
4e25ac79 803 }
804 }
805 }
806}
807
808//_______________________________________________________________
809void AliQAv1::ShowStatus(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es) const
810{
811 // Prints the full QA status of a given detector
812 CheckRange(det) ;
813 CheckRange(es) ;
814 ULong_t status = GetStatus(det, es) ;
815 ULong_t tskStatus[kNTASK] ;
816 tskStatus[kRAW] = status & 0x0000f ;
817 tskStatus[kSIM] = status & 0x000f0 ;
818 tskStatus[kREC] = status & 0x00f00 ;
819 tskStatus[kESD] = status & 0x0f000 ;
820 tskStatus[kANA] = status & 0xf0000 ;
821
822 AliInfo(Form("====> QA Status for %8s %8s raw =0x%x, sim=0x%x, rec=0x%x, esd=0x%x, ana=0x%x", GetDetName(det).Data(), AliRecoParam::GetEventSpecieName(es),
823 tskStatus[kRAW], tskStatus[kSIM], tskStatus[kREC], tskStatus[kESD], tskStatus[kANA] )) ;
824 if (tsk == kNULLTASK) {
825 for (Int_t itsk = kRAW ; itsk < kNTASK ; itsk++) {
826 ShowASCIIStatus(es, det, ALITASK_t(itsk), tskStatus[itsk]) ;
827 }
828 } else {
829 ShowASCIIStatus(es, det, tsk, tskStatus[tsk]) ;
830 }
831}
832
833//_______________________________________________________________
834void AliQAv1::ShowASCIIStatus(AliRecoParam::EventSpecie_t es, DETECTORINDEX_t det, ALITASK_t tsk, const ULong_t status) const
835{
836 // print the QA status in human readable format
837 TString text;
838 for (Int_t bit = kINFO ; bit < kNBIT ; bit++) {
839 if (IsSet(det, tsk, es, QABIT_t(bit))) {
840 text = GetBitName(QABIT_t(bit)) ;
841 text += " " ;
842 }
843 }
844 if (! text.IsNull())
34709735 845 AliInfoClass(Form(" %8s %8s %4s 0x%4lx, Problem signalled: %8s \n", AliRecoParam::GetEventSpecieName(es), GetDetName(det).Data(), GetAliTaskName(tsk), status, text.Data())) ;
4e25ac79 846}
847
848//_______________________________________________________________
849void AliQAv1::UnSet(QABIT_t bit, Int_t ies)
850{
851 // UnSet the status bit of the current detector in the current module
852 UnSet(bit, AliRecoParam::Convert(ies)) ;
853}
854
855//_______________________________________________________________
856void AliQAv1::UnSet(QABIT_t bit, AliRecoParam::EventSpecie_t es)
857{
858 // UnSet the status bit of the current detector in the current module
859
860 UnSetStatusBit(fDet, fTask, es, bit) ;
861}
862
863//_______________________________________________________________
864void AliQAv1::UnSetStatusBit(DETECTORINDEX_t det, ALITASK_t tsk, AliRecoParam::EventSpecie_t es, QABIT_t bit)
865{
866 // UnSet the status bit for a given detector and a given task
867
868 CheckRange(det) ;
869 CheckRange(tsk) ;
870 CheckRange(bit) ;
871 CheckRange(es) ;
872
873 ULong_t offset = Offset(tsk) ;
874 ULong_t status = GetStatus(det, es) ;
875 offset+= bit ;
876 status = status & 0 << offset ;
877 SetStatus(det, es, status) ;
878}