correct compilation break
[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"
4e25ac79 35#include "AliQAv1.h"
508b9fc0 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
44//__________________________________________________________________
a42ceb0e 45void AliVZEROQAChecker::Check(Double_t * check, AliQAv1::ALITASK_t index, TObjArray ** list, const AliDetectorRecoParam * /*recoParam*/)
427ef3a5 46{
47
48// Main check function: Depending on the TASK, different checks will be applied
49// Check for empty histograms
50
5379c4a3 51// AliDebug(AliQAv1::GetQADebugLevel(),Form("AliVZEROChecker"));
427ef3a5 52// AliCDBEntry *QARefRec = AliCDBManager::Instance()->Get("VZERO/QARef/RAW");
53// if( !QARefRec){
5379c4a3 54// AliDebug(AliQAv1::GetQADebugLevel(), "QA reference data NOT retrieved for QA check...");
427ef3a5 55// return 1.;
56// }
427ef3a5 57
148dbed9 58// Check that histos are filled - (FATAL) set if empty
57acd2d2 59 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
60 check[specie] = 1.0 ;
4e25ac79 61 if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) )
57acd2d2 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
4e25ac79 67 if(index == AliQAv1::kESD)
57acd2d2 68 check[specie] = CheckEsds(list[specie]);
69 }
70 }
427ef3a5 71}
57acd2d2 72
427ef3a5 73//_________________________________________________________________
74Double_t AliVZEROQAChecker::CheckEntries(TObjArray * list) const
75{
5feb4a9e 76
148dbed9 77 // check on the QA histograms on the input list: list
78// list->Print();
427ef3a5 79
148dbed9 80 Double_t test = 0.0 ;
427ef3a5 81 Int_t count = 0 ;
7cde7f18 82
427ef3a5 83 if (list->GetEntries() == 0){
5feb4a9e 84 test = 1.0;
5379c4a3 85 AliDebug(AliQAv1::GetQADebugLevel(), Form("There are NO ENTRIES to be checked..."));
5feb4a9e 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;
5379c4a3 94// AliDebug(AliQAv1::GetQADebugLevel(), Form("%s -> %f", hdata->GetName(), rv));
5feb4a9e 95 count++ ; // number of histos
96 test += rv ; // number of histos filled
97 }else{
98 AliError(Form("Data type cannot be processed"));
427ef3a5 99 }
5feb4a9e 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 }
427ef3a5 108 }
427ef3a5 109 return test ;
110}
148dbed9 111
112//_________________________________________________________________
113Double_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 histo_nb = 0;
123 Double_t Mult_V0A = 0.0;
124 Double_t Mult_V0C = 0.0;
125 Double_t V0A_BB_Ring[4], V0C_BB_Ring[4];
126 Double_t V0A_BG_Ring[4], V0C_BG_Ring[4];
127 for (Int_t i=0; i<4; i++) {
128 V0A_BB_Ring[i]= V0C_BB_Ring[i]= 0.0;
129 V0A_BG_Ring[i]= V0C_BG_Ring[i]= 0.0;
130 }
131 TIter next(list) ;
132 TH1 * hdata ;
133
134 while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
5feb4a9e 135 if (hdata) {
136 switch (histo_nb) {
137 case AliVZEROQADataMakerRec::kCellMultiV0A:
138 Mult_V0A = hdata->GetMean();
139 break;
140 case AliVZEROQADataMakerRec::kCellMultiV0C:
141 Mult_V0C = hdata->GetMean();
142 break;
143 case AliVZEROQADataMakerRec::kBBFlag:
144 for (Int_t i=0; i<8; i++) {
145 if(i<4) V0C_BB_Ring[i] = hdata->Integral((i*8)+1, (i*8) +8);
146 else V0A_BB_Ring[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) V0C_BG_Ring[i] = hdata->Integral((i*8)+1, (i*8) +8);
152 else V0A_BG_Ring[i-4] = hdata->Integral((i*8)+1, (i*8) +8);
153 }
154 break;
155 }
156 }
157 histo_nb++;
148dbed9 158 }
159
160 if(Mult_V0A == 0.0 || Mult_V0C == 0.0) {
161 AliWarning(Form("One of the two disks is missing !") );
162 test = 0.0; // bit FATAL set
163 }
164 if( V0A_BB_Ring[0]+V0A_BG_Ring[0] == 0.0 ||
165 V0A_BB_Ring[1]+V0A_BG_Ring[1] == 0.0 ||
166 V0A_BB_Ring[2]+V0A_BG_Ring[2] == 0.0 ||
167 V0A_BB_Ring[3]+V0A_BG_Ring[3] == 0.0 ||
168 V0C_BB_Ring[0]+V0C_BG_Ring[0] == 0.0 ||
169 V0C_BB_Ring[1]+V0C_BG_Ring[1] == 0.0 ||
170 V0C_BB_Ring[2]+V0C_BG_Ring[2] == 0.0 ||
171 V0C_BB_Ring[3]+V0C_BG_Ring[3] == 0.0 ){
172 AliWarning(Form("One ring is missing !") );
173 test = 0.1; // bit ERROR set
174 }
175
176 return test ;
177}
5feb4a9e 178
427ef3a5 179//______________________________________________________________________________
4e25ac79 180void AliVZEROQAChecker::Init(const AliQAv1::DETECTORINDEX_t det)
57acd2d2 181{
182 // intialises QA and QA checker settings
4e25ac79 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 ;
57acd2d2 194 SetHiLo(hiValue, lowValue) ;
195}
196
197//______________________________________________________________________________
4e25ac79 198void AliVZEROQAChecker::SetQA(AliQAv1::ALITASK_t index, Double_t * value) const
427ef3a5 199{
7cde7f18 200// sets the QA word according to return value of the Check
4e25ac79 201 AliQAv1 * qa = AliQAv1::Instance(index);
57acd2d2 202 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
4e25ac79 203 qa->UnSet(AliQAv1::kFATAL, specie);
204 qa->UnSet(AliQAv1::kWARNING, specie);
205 qa->UnSet(AliQAv1::kERROR, specie);
206 qa->UnSet(AliQAv1::kINFO, specie);
57acd2d2 207 if ( ! value ) { // No checker is implemented, set all QA to Fatal
4e25ac79 208 qa->Set(AliQAv1::kFATAL, specie) ;
57acd2d2 209 } else {
4e25ac79 210 if ( value[specie] >= fLowTestValue[AliQAv1::kFATAL] && value[specie] < fUpTestValue[AliQAv1::kFATAL] )
211 qa->Set(AliQAv1::kFATAL, specie) ;
212 else if ( value[specie] > fLowTestValue[AliQAv1::kERROR] && value[specie] <= fUpTestValue[AliQAv1::kERROR] )
213 qa->Set(AliQAv1::kERROR, specie) ;
214 else if ( value[specie] > fLowTestValue[AliQAv1::kWARNING] && value[specie] <= fUpTestValue[AliQAv1::kWARNING] )
215 qa->Set(AliQAv1::kWARNING, specie) ;
216 else if ( value[specie] > fLowTestValue[AliQAv1::kINFO] && value[specie] <= fUpTestValue[AliQAv1::kINFO] )
217 qa->Set(AliQAv1::kINFO, specie) ;
57acd2d2 218 }
219 }
427ef3a5 220}
148dbed9 221