added fake OCDB object needed for QA
[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
5fc205b9 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];
148dbed9 127 for (Int_t i=0; i<4; i++) {
5fc205b9 128 v0ABBRing[i]= v0CBBRing[i]= 0.0;
129 v0ABGRing[i]= v0CBGRing[i]= 0.0;
148dbed9 130 }
131 TIter next(list) ;
132 TH1 * hdata ;
133
134 while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
5feb4a9e 135 if (hdata) {
5fc205b9 136 switch (histonb) {
5feb4a9e 137 case AliVZEROQADataMakerRec::kCellMultiV0A:
5fc205b9 138 multV0A = hdata->GetMean();
5feb4a9e 139 break;
140 case AliVZEROQADataMakerRec::kCellMultiV0C:
5fc205b9 141 multV0C = hdata->GetMean();
5feb4a9e 142 break;
143 case AliVZEROQADataMakerRec::kBBFlag:
144 for (Int_t i=0; i<8; i++) {
5fc205b9 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);
5feb4a9e 147 }
148 break;
149 case AliVZEROQADataMakerRec::kBGFlag:
150 for (Int_t i=0; i<8; i++) {
5fc205b9 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);
5feb4a9e 153 }
154 break;
155 }
156 }
5fc205b9 157 histonb++;
148dbed9 158 }
159
5fc205b9 160 if(multV0A == 0.0 || multV0C == 0.0) {
148dbed9 161 AliWarning(Form("One of the two disks is missing !") );
162 test = 0.0; // bit FATAL set
163 }
5fc205b9 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 ){
148dbed9 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