]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROQAChecker.cxx
restore threshold getters after parameter dynamics update (fw v. >= A012)
[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 void AliVZEROQAChecker::Check(Double_t * check, AliQAv1::ALITASK_t index, TObjArray ** list, const 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   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
60     check[specie]    = 1.0 ; 
61     if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) ) 
62       continue ; 
63     if(CheckEntries(list[specie]) == 0.0){
64         check[specie] =  CheckEntries(list[specie]);
65     } else {
66       //   Check for one disk missing (FATAL) or one ring missing (ERROR) in ESDs     
67       if(index == AliQAv1::kESD) 
68           check[specie] =  CheckEsds(list[specie]);
69     } 
70   }
71 }
72
73 //_________________________________________________________________
74 Double_t AliVZEROQAChecker::CheckEntries(TObjArray * list) const
75 {
76
77   //  check on the QA histograms on the input list: list
78 //  list->Print();
79
80   Double_t test = 0.0 ;
81   Int_t   count = 0 ; 
82
83   if (list->GetEntries() == 0){  
84         test = 1.0; 
85     AliDebug(AliQAv1::GetQADebugLevel(), Form("There are NO ENTRIES to be checked..."));
86   } else {
87         TIter next(list) ; 
88         TH1 * hdata ;
89         count = 0 ; 
90         while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
91                 if (hdata) {       
92                         Double_t rv = 0.0;
93                         if(hdata->GetEntries()>0) rv=1.0;
94 //         AliDebug(AliQAv1::GetQADebugLevel(), Form("%s -> %f", hdata->GetName(), rv)); 
95                         count++ ;        // number of histos
96                         test += rv ;     // number of histos filled
97         }else{
98                         AliError(Form("Data type cannot be processed"));
99         }      
100         }
101         if (count != 0) { 
102                 if (test==0.0) {
103                         AliWarning(Form("Histograms are BOOKED for this specific task, but they are all EMPTY"));
104                 } else {
105                         test /= count; 
106                 }
107         }
108   }
109   return test ; 
110 }  
111
112 //_________________________________________________________________
113 Double_t AliVZEROQAChecker::CheckEsds(TObjArray * list) const
114 {
115   
116 //  check the ESDs for missing disk or ring
117
118 //  printf(" Number of entries in ESD list = %d\n", list->GetEntries()); 
119 //  list->Print();
120
121   Double_t test     = 1.0;     // initialisation to OK
122   Int_t    histonb =   0; 
123   Double_t multV0A = 0.0;
124   Double_t multV0C = 0.0;
125   Double_t v0ABBRing[4], v0CBBRing[4];
126   Double_t v0ABGRing[4], v0CBGRing[4];
127   for (Int_t i=0; i<4; i++) { 
128        v0ABBRing[i]= v0CBBRing[i]= 0.0;
129        v0ABGRing[i]= v0CBGRing[i]= 0.0;
130   }  
131   TIter next(list) ; 
132   TH1 * hdata ;
133   
134   while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
135           if (hdata) {
136                   switch (histonb) {
137                   case AliVZEROQADataMakerRec::kCellMultiV0A:
138                           multV0A  = hdata->GetMean();
139                           break;
140                   case AliVZEROQADataMakerRec::kCellMultiV0C:
141                           multV0C  = hdata->GetMean();
142                           break;
143                   case AliVZEROQADataMakerRec::kBBFlag:
144                   for (Int_t i=0; i<8; i++) {         
145                                   if(i<4) v0CBBRing[i]  = hdata->Integral((i*8)+1, (i*8) +8);
146                                   else v0ABBRing[i-4]  = hdata->Integral((i*8)+1, (i*8) +8);
147                           }           
148                           break;
149                   case AliVZEROQADataMakerRec::kBGFlag:
150                   for (Int_t i=0; i<8; i++) {         
151                                   if(i<4) v0CBGRing[i]  = hdata->Integral((i*8)+1, (i*8) +8);
152                                   else v0ABGRing[i-4]  = hdata->Integral((i*8)+1, (i*8) +8);
153                           }           
154                           break;
155                   }
156           }
157           histonb++;
158   }
159   
160   if(multV0A == 0.0 || multV0C == 0.0) {
161      AliWarning(Form("One of the two disks is missing !") );
162      test = 0.0; // bit FATAL set
163   }
164   if( v0ABBRing[0]+v0ABGRing[0] == 0.0 || 
165       v0ABBRing[1]+v0ABGRing[1] == 0.0 || 
166       v0ABBRing[2]+v0ABGRing[2] == 0.0 || 
167       v0ABBRing[3]+v0ABGRing[3] == 0.0 || 
168       v0CBBRing[0]+v0CBGRing[0] == 0.0 || 
169       v0CBBRing[1]+v0CBGRing[1] == 0.0 || 
170       v0CBBRing[2]+v0CBGRing[2] == 0.0 || 
171       v0CBBRing[3]+v0CBGRing[3] == 0.0  ){    
172       AliWarning(Form("One ring is missing !") );
173       test = 0.1;   // bit ERROR set
174   }
175
176   return test ; 
177
178
179 //______________________________________________________________________________
180 void AliVZEROQAChecker::Init(const AliQAv1::DETECTORINDEX_t det) 
181 {
182   // intialises QA and QA checker settings
183   AliQAv1::Instance(det) ; 
184   Float_t * hiValue = new Float_t[AliQAv1::kNBIT] ; 
185   Float_t * lowValue = new Float_t[AliQAv1::kNBIT] ;
186   lowValue[AliQAv1::kINFO]      = 0.5   ; 
187   hiValue[AliQAv1::kINFO]       = 1.0 ; 
188   lowValue[AliQAv1::kWARNING]   = 0.2 ; 
189   hiValue[AliQAv1::kWARNING]    = 0.5 ; 
190   lowValue[AliQAv1::kERROR]     = 0.0   ; 
191   hiValue[AliQAv1::kERROR]      = 0.2 ; 
192   lowValue[AliQAv1::kFATAL]     = -1.0   ; 
193   hiValue[AliQAv1::kFATAL]      = 0.0 ; 
194   SetHiLo(hiValue, lowValue) ; 
195   delete [] hiValue;
196   delete [] 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