]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROQAChecker.cxx
Technical fix for bug #58138: VZERO breaks in AliVZEROTrending::~AliVZEROTrending()
[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 "AliQAv1.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(AliQAv1::ALITASK_t index, TObjArray ** list, AliDetectorRecoParam * /*recoParam*/) 
46 {
47
48 // Main check function: Depending on the TASK, different checks will be applied
49 // Check for empty histograms 
50
51 //   AliDebug(AliQAv1::GetQADebugLevel(),Form("AliVZEROChecker"));
52 //   AliCDBEntry *QARefRec = AliCDBManager::Instance()->Get("VZERO/QARef/RAW");
53 //   if( !QARefRec){
54 //     AliDebug(AliQAv1::GetQADebugLevel(), "QA reference data NOT retrieved for QA check...");
55 //     return 1.;
56 //   }
57
58 //   Check that histos are filled - (FATAL) set if empty
59   Double_t * check = new Double_t[AliRecoParam::kNSpecies] ; 
60   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
61     check[specie]    = 1.0 ; 
62     if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) ) 
63       continue ; 
64     if(CheckEntries(list[specie]) == 0.0){
65         check[specie] =  CheckEntries(list[specie]);
66     } else {
67       //   Check for one disk missing (FATAL) or one ring missing (ERROR) in ESDs     
68       if(index == AliQAv1::kESD) 
69           check[specie] =  CheckEsds(list[specie]);
70     } 
71   }
72   return check; 
73 }
74
75 //_________________________________________________________________
76 Double_t AliVZEROQAChecker::CheckEntries(TObjArray * list) const
77 {
78
79   //  check on the QA histograms on the input list: list
80 //  list->Print();
81
82   Double_t test = 0.0 ;
83   Int_t   count = 0 ; 
84
85   if (list->GetEntries() == 0){  
86         test = 1.0; 
87     AliDebug(AliQAv1::GetQADebugLevel(), Form("There are NO ENTRIES to be checked..."));
88   } else {
89         TIter next(list) ; 
90         TH1 * hdata ;
91         count = 0 ; 
92         while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
93                 if (hdata) {       
94                         Double_t rv = 0.0;
95                         if(hdata->GetEntries()>0) rv=1.0;
96 //         AliDebug(AliQAv1::GetQADebugLevel(), Form("%s -> %f", hdata->GetName(), rv)); 
97                         count++ ;        // number of histos
98                         test += rv ;     // number of histos filled
99         }else{
100                         AliError(Form("Data type cannot be processed"));
101         }      
102         }
103         if (count != 0) { 
104                 if (test==0.0) {
105                         AliWarning(Form("Histograms are BOOKED for this specific task, but they are all EMPTY"));
106                 } else {
107                         test /= count; 
108                 }
109         }
110   }
111   return test ; 
112 }  
113
114 //_________________________________________________________________
115 Double_t AliVZEROQAChecker::CheckEsds(TObjArray * list) const
116 {
117   
118 //  check the ESDs for missing disk or ring
119
120 //  printf(" Number of entries in ESD list = %d\n", list->GetEntries()); 
121 //  list->Print();
122
123   Double_t test     = 1.0;     // initialisation to OK
124   Int_t    histo_nb =   0; 
125   Double_t Mult_V0A = 0.0;
126   Double_t Mult_V0C = 0.0;
127   Double_t V0A_BB_Ring[4], V0C_BB_Ring[4];
128   Double_t V0A_BG_Ring[4], V0C_BG_Ring[4];
129   for (Int_t i=0; i<4; i++) { 
130        V0A_BB_Ring[i]= V0C_BB_Ring[i]= 0.0;
131        V0A_BG_Ring[i]= V0C_BG_Ring[i]= 0.0;
132   }  
133   TIter next(list) ; 
134   TH1 * hdata ;
135   
136   while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
137           if (hdata) {
138                   switch (histo_nb) {
139                   case AliVZEROQADataMakerRec::kCellMultiV0A:
140                           Mult_V0A  = hdata->GetMean();
141                           break;
142                   case AliVZEROQADataMakerRec::kCellMultiV0C:
143                           Mult_V0C  = hdata->GetMean();
144                           break;
145                   case AliVZEROQADataMakerRec::kBBFlag:
146                   for (Int_t i=0; i<8; i++) {         
147                                   if(i<4) V0C_BB_Ring[i]  = hdata->Integral((i*8)+1, (i*8) +8);
148                                   else V0A_BB_Ring[i-4]  = hdata->Integral((i*8)+1, (i*8) +8);
149                           }           
150                           break;
151                   case AliVZEROQADataMakerRec::kBGFlag:
152                   for (Int_t i=0; i<8; i++) {         
153                                   if(i<4) V0C_BG_Ring[i]  = hdata->Integral((i*8)+1, (i*8) +8);
154                                   else V0A_BG_Ring[i-4]  = hdata->Integral((i*8)+1, (i*8) +8);
155                           }           
156                           break;
157                   }
158           }
159           histo_nb++;
160   }
161   
162   if(Mult_V0A == 0.0 || Mult_V0C == 0.0) {
163      AliWarning(Form("One of the two disks is missing !") );
164      test = 0.0; // bit FATAL set
165   }
166   if( V0A_BB_Ring[0]+V0A_BG_Ring[0] == 0.0 || 
167       V0A_BB_Ring[1]+V0A_BG_Ring[1] == 0.0 || 
168       V0A_BB_Ring[2]+V0A_BG_Ring[2] == 0.0 || 
169       V0A_BB_Ring[3]+V0A_BG_Ring[3] == 0.0 || 
170       V0C_BB_Ring[0]+V0C_BG_Ring[0] == 0.0 || 
171       V0C_BB_Ring[1]+V0C_BG_Ring[1] == 0.0 || 
172       V0C_BB_Ring[2]+V0C_BG_Ring[2] == 0.0 || 
173       V0C_BB_Ring[3]+V0C_BG_Ring[3] == 0.0  ){    
174       AliWarning(Form("One ring is missing !") );
175       test = 0.1;   // bit ERROR set
176   }
177
178   return test ; 
179
180
181 //______________________________________________________________________________
182 void AliVZEROQAChecker::Init(const AliQAv1::DETECTORINDEX_t det) 
183 {
184   // intialises QA and QA checker settings
185   AliQAv1::Instance(det) ; 
186   Float_t * hiValue = new Float_t[AliQAv1::kNBIT] ; 
187   Float_t * lowValue = new Float_t[AliQAv1::kNBIT] ;
188   lowValue[AliQAv1::kINFO]      = 0.5   ; 
189   hiValue[AliQAv1::kINFO]       = 1.0 ; 
190   lowValue[AliQAv1::kWARNING]   = 0.2 ; 
191   hiValue[AliQAv1::kWARNING]    = 0.5 ; 
192   lowValue[AliQAv1::kERROR]     = 0.0   ; 
193   hiValue[AliQAv1::kERROR]      = 0.2 ; 
194   lowValue[AliQAv1::kFATAL]     = -1.0   ; 
195   hiValue[AliQAv1::kFATAL]      = 0.0 ; 
196   SetHiLo(hiValue, lowValue) ; 
197 }
198
199 //______________________________________________________________________________
200 void AliVZEROQAChecker::SetQA(AliQAv1::ALITASK_t index, Double_t * value) const
201 {
202 // sets the QA word according to return value of the Check
203   AliQAv1 * qa = AliQAv1::Instance(index);
204   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
205     qa->UnSet(AliQAv1::kFATAL, specie);
206     qa->UnSet(AliQAv1::kWARNING, specie);
207     qa->UnSet(AliQAv1::kERROR, specie);
208     qa->UnSet(AliQAv1::kINFO, specie);
209     if ( ! value ) { // No checker is implemented, set all QA to Fatal
210       qa->Set(AliQAv1::kFATAL, specie) ; 
211     } else {
212       if ( value[specie] >= fLowTestValue[AliQAv1::kFATAL] && value[specie] < fUpTestValue[AliQAv1::kFATAL] ) 
213         qa->Set(AliQAv1::kFATAL, specie) ; 
214       else if ( value[specie] > fLowTestValue[AliQAv1::kERROR] && value[specie] <= fUpTestValue[AliQAv1::kERROR]  )
215         qa->Set(AliQAv1::kERROR, specie) ; 
216       else if ( value[specie] > fLowTestValue[AliQAv1::kWARNING] && value[specie] <= fUpTestValue[AliQAv1::kWARNING]  )
217         qa->Set(AliQAv1::kWARNING, specie) ;
218       else if ( value[specie] > fLowTestValue[AliQAv1::kINFO] && value[specie] <= fUpTestValue[AliQAv1::kINFO] ) 
219         qa->Set(AliQAv1::kINFO, specie) ;       
220     }
221   }
222 }
223