]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROQAChecker.cxx
Minor changes
[u/mrichter/AliRoot.git] / VZERO / AliVZEROQAChecker.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16
17 /*
18   Checks the quality assurance. Under construction. 
19   By comparing with reference data
20
21 */
22
23 // --- ROOT system ---
24 #include <TClass.h>
25 #include <TH1F.h> 
26 #include <TH1I.h> 
27 #include <TIterator.h> 
28 #include <TKey.h> 
29 #include <TFile.h> 
30
31 // --- Standard library ---
32
33 // --- AliRoot header files ---
34 #include "AliLog.h"
35 #include "AliQA.h"
36 #include "AliQAChecker.h"
37 #include "AliVZEROQAChecker.h"
38 #include "AliVZEROQADataMakerRec.h"
39 //#include "AliCDBEntry.h"
40 //#include "AliCDBManager.h"
41
42 ClassImp(AliVZEROQAChecker)
43
44 //__________________________________________________________________
45 Double_t AliVZEROQAChecker::Check(AliQA::ALITASK_t index, TObjArray * list) 
46 {
47
48 // Main check function: Depending on the TASK, different checks will be applied
49 // Check for empty histograms 
50
51 //   AliDebug(1,Form("AliVZEROChecker"));
52 //   AliCDBEntry *QARefRec = AliCDBManager::Instance()->Get("VZERO/QARef/RAW");
53 //   if( !QARefRec){
54 //     AliInfo("QA reference data NOT retrieved for QA check...");
55 //     return 1.;
56 //   }
57
58 //   Check that histos are filled - (FATAL) set if empty
59      if(CheckEntries(list) == 0.0){
60         return CheckEntries(list);
61      }
62
63 //   Check for one disk missing (FATAL) or one ring missing (ERROR) in ESDs     
64      if(index == AliQA::kESD) {
65         return CheckEsds(list);
66      } 
67
68       return 1.0; 
69 }
70 //_________________________________________________________________
71 Double_t AliVZEROQAChecker::CheckEntries(TObjArray * list) const
72 {
73
74   //  check on the QA histograms on the input list: list
75 //  list->Print();
76
77   Double_t test = 0.0 ;
78   Int_t   count = 0 ; 
79
80   if (list->GetEntries() == 0){  
81         test = 1.0; 
82         AliInfo(Form("There are NO ENTRIES to be checked..."));
83   } else {
84         TIter next(list) ; 
85         TH1 * hdata ;
86         count = 0 ; 
87         while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
88                 if (hdata) {       
89                         Double_t rv = 0.0;
90                         if(hdata->GetEntries()>0) rv=1.0;
91 //         AliInfo(Form("%s -> %f", hdata->GetName(), rv)); 
92                         count++ ;        // number of histos
93                         test += rv ;     // number of histos filled
94         }else{
95                         AliError(Form("Data type cannot be processed"));
96         }      
97         }
98         if (count != 0) { 
99                 if (test==0.0) {
100                         AliWarning(Form("Histograms are BOOKED for this specific task, but they are all EMPTY"));
101                 } else {
102                         test /= count; 
103                 }
104         }
105   }
106   return test ; 
107 }  
108
109 //_________________________________________________________________
110 Double_t AliVZEROQAChecker::CheckEsds(TObjArray * list) const
111 {
112   
113 //  check the ESDs for missing disk or ring
114
115 //  printf(" Number of entries in ESD list = %d\n", list->GetEntries()); 
116 //  list->Print();
117
118   Double_t test     = 1.0;     // initialisation to OK
119   Int_t    histo_nb =   0; 
120   Double_t Mult_V0A = 0.0;
121   Double_t Mult_V0C = 0.0;
122   Double_t V0A_BB_Ring[4], V0C_BB_Ring[4];
123   Double_t V0A_BG_Ring[4], V0C_BG_Ring[4];
124   for (Int_t i=0; i<4; i++) { 
125        V0A_BB_Ring[i]= V0C_BB_Ring[i]= 0.0;
126        V0A_BG_Ring[i]= V0C_BG_Ring[i]= 0.0;
127   }  
128   TIter next(list) ; 
129   TH1 * hdata ;
130   
131   while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
132           if (hdata) {
133                   switch (histo_nb) {
134                   case AliVZEROQADataMakerRec::kCellMultiV0A:
135                           Mult_V0A  = hdata->GetMean();
136                           break;
137                   case AliVZEROQADataMakerRec::kCellMultiV0C:
138                           Mult_V0C  = hdata->GetMean();
139                           break;
140                   case AliVZEROQADataMakerRec::kBBFlag:
141                   for (Int_t i=0; i<8; i++) {         
142                                   if(i<4) V0C_BB_Ring[i]  = hdata->Integral((i*8)+1, (i*8) +8);
143                                   else V0A_BB_Ring[i-4]  = hdata->Integral((i*8)+1, (i*8) +8);
144                           }           
145                           break;
146                   case AliVZEROQADataMakerRec::kBGFlag:
147                   for (Int_t i=0; i<8; i++) {         
148                                   if(i<4) V0C_BG_Ring[i]  = hdata->Integral((i*8)+1, (i*8) +8);
149                                   else V0A_BG_Ring[i-4]  = hdata->Integral((i*8)+1, (i*8) +8);
150                           }           
151                           break;
152                   }
153           }
154           histo_nb++;
155   }
156   
157   if(Mult_V0A == 0.0 || Mult_V0C == 0.0) {
158      AliWarning(Form("One of the two disks is missing !") );
159      test = 0.0; // bit FATAL set
160   }
161   if( V0A_BB_Ring[0]+V0A_BG_Ring[0] == 0.0 || 
162       V0A_BB_Ring[1]+V0A_BG_Ring[1] == 0.0 || 
163       V0A_BB_Ring[2]+V0A_BG_Ring[2] == 0.0 || 
164       V0A_BB_Ring[3]+V0A_BG_Ring[3] == 0.0 || 
165       V0C_BB_Ring[0]+V0C_BG_Ring[0] == 0.0 || 
166       V0C_BB_Ring[1]+V0C_BG_Ring[1] == 0.0 || 
167       V0C_BB_Ring[2]+V0C_BG_Ring[2] == 0.0 || 
168       V0C_BB_Ring[3]+V0C_BG_Ring[3] == 0.0  ){    
169       AliWarning(Form("One ring is missing !") );
170       test = 0.1;   // bit ERROR set
171   }
172
173   return test ; 
174
175
176 //______________________________________________________________________________
177 void AliVZEROQAChecker::SetQA(AliQA::ALITASK_t index, const Double_t value) const
178 {
179 // sets the QA word according to return value of the Check
180   AliQA * qa = AliQA::Instance(index);
181   
182   qa->UnSet(AliQA::kFATAL);
183   qa->UnSet(AliQA::kWARNING);
184   qa->UnSet(AliQA::kERROR);
185   qa->UnSet(AliQA::kINFO);
186         
187   if ( value <= 0.0 ) qa->Set(AliQA::kFATAL) ; 
188   else if ( value > 0.0 && value <= 0.2 ) qa->Set(AliQA::kERROR) ; 
189   else if ( value > 0.2 && value <= 0.5 ) qa->Set(AliQA::kWARNING) ;
190   else if ( value > 0.5 && value < 1.0 ) qa->Set(AliQA::kINFO) ;                
191 }
192