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