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