]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliQACheckerBase.cxx
The track number and track pid associated with the cluster are included
[u/mrichter/AliRoot.git] / STEER / AliQACheckerBase.cxx
CommitLineData
421ab0fb 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/* $Id$ */
18
202374b1 19//
20// Base class for detectors quality assurance checkers
21// Compares Data made by QADataMakers with reference data
22// Y. Schutz CERN August 2007
23//
421ab0fb 24
25// --- ROOT system ---
26#include <TClass.h>
27#include <TH1F.h>
28#include <TH1I.h>
29#include <TIterator.h>
30#include <TKey.h>
31#include <TFile.h>
a4976ef3 32#include <TList.h>
a2b64fbd 33#include <TNtupleD.h>
421ab0fb 34
35// --- Standard library ---
36
37// --- AliRoot header files ---
38#include "AliLog.h"
4e25ac79 39#include "AliQAv1.h"
2e42b4d4 40#include "AliQAChecker.h"
41#include "AliQACheckerBase.h"
42#include "AliQADataMaker.h"
421ab0fb 43
2e42b4d4 44ClassImp(AliQACheckerBase)
421ab0fb 45
46
47//____________________________________________________________________________
2e42b4d4 48AliQACheckerBase::AliQACheckerBase(const char * name, const char * title) :
421ab0fb 49 TNamed(name, title),
a5fa6165 50 fDataSubDir(0x0),
4edbc5bc 51 fRefSubDir(0x0),
57acd2d2 52 fRefOCDBSubDir(0x0),
53 fLowTestValue(0x0),
54 fUpTestValue(0x0)
421ab0fb 55{
56 // ctor
4e25ac79 57 fLowTestValue = new Float_t[AliQAv1::kNBIT] ;
58 fUpTestValue = new Float_t[AliQAv1::kNBIT] ;
59 fLowTestValue[AliQAv1::kINFO] = 0.5 ;
60 fUpTestValue[AliQAv1::kINFO] = 1.0 ;
61 fLowTestValue[AliQAv1::kWARNING] = 0.002 ;
62 fUpTestValue[AliQAv1::kWARNING] = 0.5 ;
63 fLowTestValue[AliQAv1::kERROR] = 0.0 ;
64 fUpTestValue[AliQAv1::kERROR] = 0.002 ;
65 fLowTestValue[AliQAv1::kFATAL] = -1.0 ;
66 fUpTestValue[AliQAv1::kFATAL] = 0.0 ;
57acd2d2 67
5379c4a3 68 AliDebug(AliQAv1::GetQADebugLevel(), "Default setting is:") ;
69 if ( AliDebugLevel() == AliQAv1::GetQADebugLevel() ) {
70 printf( " INFO -> %1.5f < value < %1.5f \n", fLowTestValue[AliQAv1::kINFO], fUpTestValue[AliQAv1::kINFO]) ;
71 printf( " WARNING -> %1.5f < value <= %1.5f \n", fLowTestValue[AliQAv1::kWARNING], fUpTestValue[AliQAv1::kWARNING]) ;
72 printf( " ERROR -> %1.5f < value <= %1.5f \n", fLowTestValue[AliQAv1::kERROR], fUpTestValue[AliQAv1::kERROR]) ;
73 printf( " FATAL -> %1.5f <= value < %1.5f \n", fLowTestValue[AliQAv1::kFATAL], fUpTestValue[AliQAv1::kFATAL]) ;
74 }
421ab0fb 75}
76
77//____________________________________________________________________________
4edbc5bc 78AliQACheckerBase::AliQACheckerBase(const AliQACheckerBase& qac) :
79 TNamed(qac.GetName(), qac.GetTitle()),
80 fDataSubDir(qac.fDataSubDir),
81 fRefSubDir(qac.fRefSubDir),
57acd2d2 82 fRefOCDBSubDir(qac.fRefOCDBSubDir),
83 fLowTestValue(qac.fLowTestValue),
84 fUpTestValue(qac.fLowTestValue)
421ab0fb 85{
86 //copy ctor
4e25ac79 87 for (Int_t index = 0 ; index < AliQAv1::kNBIT ; index++) {
57acd2d2 88 fLowTestValue[index] = qac.fLowTestValue[index] ;
89 fUpTestValue[index] = qac.fUpTestValue[index] ;
90 }
421ab0fb 91
92}
93
94//____________________________________________________________________________
2e42b4d4 95AliQACheckerBase& AliQACheckerBase::operator = (const AliQACheckerBase& qadm )
421ab0fb 96{
97 // Equal operator.
2e42b4d4 98 this->~AliQACheckerBase();
99 new(this) AliQACheckerBase(qadm);
421ab0fb 100 return *this;
101}
102
57acd2d2 103//____________________________________________________________________________
104AliQACheckerBase::~AliQACheckerBase()
105{
106 delete [] fLowTestValue ;
107 delete [] fUpTestValue ;
108}
109
a5fa6165 110//____________________________________________________________________________
4e25ac79 111Double_t * AliQACheckerBase::Check(AliQAv1::ALITASK_t /*index*/)
a5fa6165 112{
113 // Performs a basic checking
114 // Compares all the histograms stored in the directory
4edbc5bc 115 // With reference histograms either in a file of in OCDB
a5fa6165 116
57acd2d2 117 Double_t * test = new Double_t[AliRecoParam::kNSpecies] ;
118 Int_t count[AliRecoParam::kNSpecies] = { 0 };
119
120 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
121 test[specie] = 1.0 ;
4e25ac79 122 if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) )
57acd2d2 123 continue ;
124 if (!fDataSubDir) {
125 test[specie] = 0. ; // nothing to check
126 } else if (!fRefSubDir && !fRefOCDBSubDir) {
127 test[specie] = -1 ; // no reference data
128 } else {
129 TList * keyList = fDataSubDir->GetListOfKeys() ;
130 TIter next(keyList) ;
131 TKey * key ;
132 count[specie] = 0 ;
133 while ( (key = static_cast<TKey *>(next())) ) {
134 TObject * odata = fRefSubDir->Get(key->GetName()) ;
135 if ( odata->IsA()->InheritsFrom("TH1") ) {
136 TH1 * hdata = static_cast<TH1*>(odata) ;
137 TH1 * href = NULL ;
138 if (fRefSubDir)
139 href = static_cast<TH1*>(fRefSubDir->Get(key->GetName())) ;
140 else if (fRefOCDBSubDir[specie]) {
141 href = static_cast<TH1*>(fRefOCDBSubDir[specie]->FindObject(key->GetName())) ;
142 }
143 if (!href)
144 test[specie] = -1 ; // no reference data ;
145 else {
146 Double_t rv = DiffK(hdata, href) ;
5379c4a3 147 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s ->Test = %f", hdata->GetName(), rv)) ;
57acd2d2 148 test[specie] += rv ;
149 count[specie]++ ;
150 }
151 } else
152 AliError(Form("%s Is a Classname that cannot be processed", key->GetClassName())) ;
153 }
154 if (count[specie] != 0)
155 test[specie] /= count[specie] ;
156 }
157 }
158 return test ;
a5fa6165 159}
160
a4976ef3 161//____________________________________________________________________________
4e25ac79 162Double_t * AliQACheckerBase::Check(AliQAv1::ALITASK_t /*index*/, TObjArray ** list)
a4976ef3 163{
164 // Performs a basic checking
165 // Compares all the histograms in the list
166
57acd2d2 167 Double_t * test = new Double_t[AliRecoParam::kNSpecies] ;
168 Int_t count[AliRecoParam::kNSpecies] = { 0 };
169
170 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
171 test[specie] = 1.0 ;
4e25ac79 172 if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) )
57acd2d2 173 continue ;
174 if (list[specie]->GetEntries() == 0)
175 test[specie] = 0. ; // nothing to check
176 else {
177 if (!fRefSubDir && !fRefOCDBSubDir)
178 test[specie] = -1 ; // no reference data
179 else {
180 TIter next(list[specie]) ;
181 TH1 * hdata ;
182 count[specie] = 0 ;
183 while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
184 if ( hdata) {
4e25ac79 185 if ( hdata->TestBit(AliQAv1::GetExpertBit()) ) // does not perform the test for expert data
57acd2d2 186 continue ;
187 TH1 * href = NULL ;
188 if (fRefSubDir)
189 href = static_cast<TH1*>(fRefSubDir->Get(hdata->GetName())) ;
190 else if (fRefOCDBSubDir[specie])
191 href = static_cast<TH1*>(fRefOCDBSubDir[specie]->FindObject(hdata->GetName())) ;
192 if (!href)
193 test[specie] = -1 ; // no reference data ;
194 else {
195 Double_t rv = DiffK(hdata, href) ;
5379c4a3 196 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s ->Test = %f", hdata->GetName(), rv)) ;
57acd2d2 197 test[specie] += rv ;
198 count[specie]++ ;
199 }
200 }
201 else
202 AliError("Data type cannot be processed") ;
203 }
204 if (count[specie] != 0)
205 test[specie] /= count[specie] ;
206 }
207 }
208 }
4edbc5bc 209 return test ;
a4976ef3 210}
211
57acd2d2 212
421ab0fb 213//____________________________________________________________________________
f12d42ce 214Double_t AliQACheckerBase::DiffC(const TH1 * href, const TH1 * hin) const
421ab0fb 215{
216 // compares two histograms using the Chi2 test
217 if ( hin->Integral() == 0 ) {
5379c4a3 218 AliDebug(AliQAv1::GetQADebugLevel(), Form("Spectrum %s is empty", hin->GetName())) ;
421ab0fb 219 return 0. ;
220 }
221
222 return hin->Chi2Test(href) ;
223}
224
225//____________________________________________________________________________
f12d42ce 226Double_t AliQACheckerBase::DiffK(const TH1 * href, const TH1 * hin) const
421ab0fb 227{
228 // compares two histograms using the Kolmogorov test
229 if ( hin->Integral() == 0 ) {
5379c4a3 230 AliDebug(AliQAv1::GetQADebugLevel(), Form("Spectrum %s is empty", hin->GetName())) ;
421ab0fb 231 return 0. ;
232 }
233
234 return hin->KolmogorovTest(href) ;
235}
236
421ab0fb 237//____________________________________________________________________________
4e25ac79 238void AliQACheckerBase::Run(AliQAv1::ALITASK_t index, TObjArray ** list)
421ab0fb 239{
5379c4a3 240 AliDebug(AliQAv1::GetQADebugLevel(), Form("Processing %s", AliQAv1::GetAliTaskName(index))) ;
a2b64fbd 241
57acd2d2 242 Double_t * rv = NULL ;
243 if ( !list)
a2b64fbd 244 rv = Check(index) ;
57acd2d2 245 else
246 rv = Check(index, list) ;
a2b64fbd 247 SetQA(index, rv) ;
46b8a84d 248
5379c4a3 249 AliDebug(AliQAv1::GetQADebugLevel(), Form("Test result of %s", AliQAv1::GetAliTaskName(index))) ;
46b8a84d 250
57acd2d2 251 if (rv)
252 delete [] rv ;
a2b64fbd 253 Finish() ;
421ab0fb 254}
255
256//____________________________________________________________________________
2e42b4d4 257void AliQACheckerBase::Finish() const
421ab0fb 258{
54a7f3ac 259 // wrap up and save QA in proper file
4e25ac79 260 AliQAv1 * qa = AliQAv1::Instance() ;
54a7f3ac 261 qa->Show() ;
4e25ac79 262 AliQAv1::GetQAResultFile()->cd() ;
54a7f3ac 263 qa->Write(qa->GetName(), kWriteDelete) ;
4e25ac79 264 AliQAv1::GetQAResultFile()->Close() ;
421ab0fb 265}
46b8a84d 266
267//____________________________________________________________________________
57acd2d2 268void AliQACheckerBase::SetHiLo(Float_t * hiValue, Float_t * lowValue)
46b8a84d 269{
5379c4a3 270 AliDebug(AliQAv1::GetQADebugLevel(), "Previous setting was:") ;
271 if ( AliDebugLevel() == AliQAv1::GetQADebugLevel() ) {
272 printf( " INFO -> %1.5f < value < %1.5f \n", fLowTestValue[AliQAv1::kINFO], fUpTestValue[AliQAv1::kINFO]) ;
273 printf( " WARNING -> %1.5f < value <= %1.5f \n", fLowTestValue[AliQAv1::kWARNING], fUpTestValue[AliQAv1::kWARNING]) ;
274 printf( " ERROR -> %1.5f < value <= %1.5f \n", fLowTestValue[AliQAv1::kERROR], fUpTestValue[AliQAv1::kERROR]) ;
275 printf( " FATAL -> %1.5f <= value < %1.5f \n", fLowTestValue[AliQAv1::kFATAL], fUpTestValue[AliQAv1::kFATAL]) ;
276 }
57acd2d2 277
4e25ac79 278 for (Int_t index = 0 ; index < AliQAv1::kNBIT ; index++) {
57acd2d2 279 fLowTestValue[index] = lowValue[index] ;
280 fUpTestValue[index] = hiValue[index] ;
281 }
5379c4a3 282 AliDebug(AliQAv1::GetQADebugLevel(), "Current setting is:") ;
283 if ( AliDebugLevel() == AliQAv1::GetQADebugLevel() ) {
284 printf( " INFO -> %1.5f < value < %1.5f \n", fLowTestValue[AliQAv1::kINFO], fUpTestValue[AliQAv1::kINFO]) ;
285 printf( " WARNING -> %1.5f < value <= %1.5f \n", fLowTestValue[AliQAv1::kWARNING], fUpTestValue[AliQAv1::kWARNING]) ;
286 printf( " ERROR -> %1.5f < value <= %1.5f \n", fLowTestValue[AliQAv1::kERROR], fUpTestValue[AliQAv1::kERROR]) ;
287 printf( " FATAL -> %1.5f <= value < %1.5f \n", fLowTestValue[AliQAv1::kFATAL], fUpTestValue[AliQAv1::kFATAL]) ;
288 }
57acd2d2 289}
46b8a84d 290
57acd2d2 291//____________________________________________________________________________
4e25ac79 292void AliQACheckerBase::SetQA(AliQAv1::ALITASK_t index, Double_t * value) const
57acd2d2 293{
294 // sets the QA according the return value of the Check
46b8a84d 295
4e25ac79 296 AliQAv1 * qa = AliQAv1::Instance(index) ;
57acd2d2 297 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
298 if ( value == NULL ) { // No checker is implemented, set all QA to Fatal
4e25ac79 299 qa->Set(AliQAv1::kFATAL, specie) ;
57acd2d2 300 } else {
4e25ac79 301 if ( value[specie] >= fLowTestValue[AliQAv1::kFATAL] && value[specie] < fUpTestValue[AliQAv1::kFATAL] )
302 qa->Set(AliQAv1::kFATAL, specie) ;
303 else if ( value[specie] > fLowTestValue[AliQAv1::kERROR] && value[specie] <= fUpTestValue[AliQAv1::kERROR] )
304 qa->Set(AliQAv1::kERROR, specie) ;
305 else if ( value[specie] > fLowTestValue[AliQAv1::kWARNING] && value[specie] <= fUpTestValue[AliQAv1::kWARNING] )
306 qa->Set(AliQAv1::kWARNING, specie) ;
307 else if ( value[specie] > fLowTestValue[AliQAv1::kINFO] && value[specie] <= fUpTestValue[AliQAv1::kINFO] )
308 qa->Set(AliQAv1::kINFO, specie) ;
57acd2d2 309 }
310 }
46b8a84d 311}