1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
20 // Base class for detectors quality assurance checkers
21 // Compares Data made by QADataMakers with reference data
22 // Y. Schutz CERN August 2007
25 // --- ROOT system ---
29 #include <TIterator.h>
35 // --- Standard library ---
37 // --- AliRoot header files ---
40 #include "AliQAChecker.h"
41 #include "AliQACheckerBase.h"
42 #include "AliQADataMaker.h"
44 ClassImp(AliQACheckerBase)
47 //____________________________________________________________________________
48 AliQACheckerBase::AliQACheckerBase(const char * name, const char * title) :
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 ;
68 AliInfo("Default setting is:") ;
69 printf( " INFO -> %1.5f < value < %1.5f \n", fLowTestValue[AliQAv1::kINFO], fUpTestValue[AliQAv1::kINFO]) ;
70 printf( " WARNING -> %1.5f < value <= %1.5f \n", fLowTestValue[AliQAv1::kWARNING], fUpTestValue[AliQAv1::kWARNING]) ;
71 printf( " ERROR -> %1.5f < value <= %1.5f \n", fLowTestValue[AliQAv1::kERROR], fUpTestValue[AliQAv1::kERROR]) ;
72 printf( " FATAL -> %1.5f <= value < %1.5f \n", fLowTestValue[AliQAv1::kFATAL], fUpTestValue[AliQAv1::kFATAL]) ;
76 //____________________________________________________________________________
77 AliQACheckerBase::AliQACheckerBase(const AliQACheckerBase& qac) :
78 TNamed(qac.GetName(), qac.GetTitle()),
79 fDataSubDir(qac.fDataSubDir),
80 fRefSubDir(qac.fRefSubDir),
81 fRefOCDBSubDir(qac.fRefOCDBSubDir),
82 fLowTestValue(qac.fLowTestValue),
83 fUpTestValue(qac.fLowTestValue)
86 for (Int_t index = 0 ; index < AliQAv1::kNBIT ; index++) {
87 fLowTestValue[index] = qac.fLowTestValue[index] ;
88 fUpTestValue[index] = qac.fUpTestValue[index] ;
93 //____________________________________________________________________________
94 AliQACheckerBase& AliQACheckerBase::operator = (const AliQACheckerBase& qadm )
97 this->~AliQACheckerBase();
98 new(this) AliQACheckerBase(qadm);
102 //____________________________________________________________________________
103 AliQACheckerBase::~AliQACheckerBase()
105 delete [] fLowTestValue ;
106 delete [] fUpTestValue ;
109 //____________________________________________________________________________
110 Double_t * AliQACheckerBase::Check(AliQAv1::ALITASK_t /*index*/)
112 // Performs a basic checking
113 // Compares all the histograms stored in the directory
114 // With reference histograms either in a file of in OCDB
116 Double_t * test = new Double_t[AliRecoParam::kNSpecies] ;
117 Int_t count[AliRecoParam::kNSpecies] = { 0 };
119 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
121 if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) )
124 test[specie] = 0. ; // nothing to check
125 } else if (!fRefSubDir && !fRefOCDBSubDir) {
126 test[specie] = -1 ; // no reference data
128 TList * keyList = fDataSubDir->GetListOfKeys() ;
129 TIter next(keyList) ;
132 while ( (key = static_cast<TKey *>(next())) ) {
133 TObject * odata = fRefSubDir->Get(key->GetName()) ;
134 if ( odata->IsA()->InheritsFrom("TH1") ) {
135 TH1 * hdata = static_cast<TH1*>(odata) ;
138 href = static_cast<TH1*>(fRefSubDir->Get(key->GetName())) ;
139 else if (fRefOCDBSubDir[specie]) {
140 href = static_cast<TH1*>(fRefOCDBSubDir[specie]->FindObject(key->GetName())) ;
143 test[specie] = -1 ; // no reference data ;
145 Double_t rv = DiffK(hdata, href) ;
146 AliInfo(Form("%s ->Test = %f", hdata->GetName(), rv)) ;
151 AliError(Form("%s Is a Classname that cannot be processed", key->GetClassName())) ;
153 if (count[specie] != 0)
154 test[specie] /= count[specie] ;
160 //____________________________________________________________________________
161 Double_t * AliQACheckerBase::Check(AliQAv1::ALITASK_t /*index*/, TObjArray ** list)
163 // Performs a basic checking
164 // Compares all the histograms in the list
166 Double_t * test = new Double_t[AliRecoParam::kNSpecies] ;
167 Int_t count[AliRecoParam::kNSpecies] = { 0 };
169 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
171 if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) )
173 if (list[specie]->GetEntries() == 0)
174 test[specie] = 0. ; // nothing to check
176 if (!fRefSubDir && !fRefOCDBSubDir)
177 test[specie] = -1 ; // no reference data
179 TIter next(list[specie]) ;
182 while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
184 if ( hdata->TestBit(AliQAv1::GetExpertBit()) ) // does not perform the test for expert data
188 href = static_cast<TH1*>(fRefSubDir->Get(hdata->GetName())) ;
189 else if (fRefOCDBSubDir[specie])
190 href = static_cast<TH1*>(fRefOCDBSubDir[specie]->FindObject(hdata->GetName())) ;
192 test[specie] = -1 ; // no reference data ;
194 Double_t rv = DiffK(hdata, href) ;
195 AliInfo(Form("%s ->Test = %f", hdata->GetName(), rv)) ;
201 AliError("Data type cannot be processed") ;
203 if (count[specie] != 0)
204 test[specie] /= count[specie] ;
212 //____________________________________________________________________________
213 Double_t AliQACheckerBase::DiffC(const TH1 * href, const TH1 * hin) const
215 // compares two histograms using the Chi2 test
216 if ( hin->Integral() == 0 ) {
217 AliWarning(Form("Spectrum %s is empty", hin->GetName())) ;
221 return hin->Chi2Test(href) ;
224 //____________________________________________________________________________
225 Double_t AliQACheckerBase::DiffK(const TH1 * href, const TH1 * hin) const
227 // compares two histograms using the Kolmogorov test
228 if ( hin->Integral() == 0 ) {
229 AliWarning(Form("Spectrum %s is empty", hin->GetName())) ;
233 return hin->KolmogorovTest(href) ;
236 //____________________________________________________________________________
237 void AliQACheckerBase::Run(AliQAv1::ALITASK_t index, TObjArray ** list)
239 AliDebug(1, Form("Processing %s", AliQAv1::GetAliTaskName(index))) ;
241 Double_t * rv = NULL ;
245 rv = Check(index, list) ;
248 AliDebug(1, Form("Test result of %s", AliQAv1::GetAliTaskName(index))) ;
255 //____________________________________________________________________________
256 void AliQACheckerBase::Finish() const
258 // wrap up and save QA in proper file
259 AliQAv1 * qa = AliQAv1::Instance() ;
261 AliQAv1::GetQAResultFile()->cd() ;
262 qa->Write(qa->GetName(), kWriteDelete) ;
263 AliQAv1::GetQAResultFile()->Close() ;
266 //____________________________________________________________________________
267 void AliQACheckerBase::SetHiLo(Float_t * hiValue, Float_t * lowValue)
269 AliInfo("Previous setting was:") ;
270 printf( " INFO -> %1.5f < value < %1.5f \n", fLowTestValue[AliQAv1::kINFO], fUpTestValue[AliQAv1::kINFO]) ;
271 printf( " WARNING -> %1.5f < value <= %1.5f \n", fLowTestValue[AliQAv1::kWARNING], fUpTestValue[AliQAv1::kWARNING]) ;
272 printf( " ERROR -> %1.5f < value <= %1.5f \n", fLowTestValue[AliQAv1::kERROR], fUpTestValue[AliQAv1::kERROR]) ;
273 printf( " FATAL -> %1.5f <= value < %1.5f \n", fLowTestValue[AliQAv1::kFATAL], fUpTestValue[AliQAv1::kFATAL]) ;
275 for (Int_t index = 0 ; index < AliQAv1::kNBIT ; index++) {
276 fLowTestValue[index] = lowValue[index] ;
277 fUpTestValue[index] = hiValue[index] ;
279 AliInfo("Current setting is:") ;
280 printf( " INFO -> %1.5f < value < %1.5f \n", fLowTestValue[AliQAv1::kINFO], fUpTestValue[AliQAv1::kINFO]) ;
281 printf( " WARNING -> %1.5f < value <= %1.5f \n", fLowTestValue[AliQAv1::kWARNING], fUpTestValue[AliQAv1::kWARNING]) ;
282 printf( " ERROR -> %1.5f < value <= %1.5f \n", fLowTestValue[AliQAv1::kERROR], fUpTestValue[AliQAv1::kERROR]) ;
283 printf( " FATAL -> %1.5f <= value < %1.5f \n", fLowTestValue[AliQAv1::kFATAL], fUpTestValue[AliQAv1::kFATAL]) ;
286 //____________________________________________________________________________
287 void AliQACheckerBase::SetQA(AliQAv1::ALITASK_t index, Double_t * value) const
289 // sets the QA according the return value of the Check
291 AliQAv1 * qa = AliQAv1::Instance(index) ;
292 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
293 if ( value == NULL ) { // No checker is implemented, set all QA to Fatal
294 qa->Set(AliQAv1::kFATAL, specie) ;
296 if ( value[specie] >= fLowTestValue[AliQAv1::kFATAL] && value[specie] < fUpTestValue[AliQAv1::kFATAL] )
297 qa->Set(AliQAv1::kFATAL, specie) ;
298 else if ( value[specie] > fLowTestValue[AliQAv1::kERROR] && value[specie] <= fUpTestValue[AliQAv1::kERROR] )
299 qa->Set(AliQAv1::kERROR, specie) ;
300 else if ( value[specie] > fLowTestValue[AliQAv1::kWARNING] && value[specie] <= fUpTestValue[AliQAv1::kWARNING] )
301 qa->Set(AliQAv1::kWARNING, specie) ;
302 else if ( value[specie] > fLowTestValue[AliQAv1::kINFO] && value[specie] <= fUpTestValue[AliQAv1::kINFO] )
303 qa->Set(AliQAv1::kINFO, specie) ;