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>
34 // --- Standard library ---
36 // --- AliRoot header files ---
39 #include "AliQAChecker.h"
40 #include "AliQACheckerBase.h"
41 #include "AliQADataMaker.h"
43 ClassImp(AliQACheckerBase)
46 //____________________________________________________________________________
47 AliQACheckerBase::AliQACheckerBase(const char * name, const char * title) :
55 //____________________________________________________________________________
56 AliQACheckerBase::AliQACheckerBase(const AliQACheckerBase& qadm) :
57 TNamed(qadm.GetName(), qadm.GetTitle()),
58 fDataSubDir(qadm.fDataSubDir),
59 fRefSubDir(qadm.fRefSubDir)
65 //____________________________________________________________________________
66 AliQACheckerBase& AliQACheckerBase::operator = (const AliQACheckerBase& qadm )
69 this->~AliQACheckerBase();
70 new(this) AliQACheckerBase(qadm);
74 //____________________________________________________________________________
75 const Double_t AliQACheckerBase::Check()
77 // Performs a basic checking
78 // Compares all the histograms stored in the directory
84 test = 1. ; // nothing to check
87 test = -1 ; // no reference data
89 TList * keyList = fDataSubDir->GetListOfKeys() ;
93 while ( (key = static_cast<TKey *>(next())) ) {
94 TObject * odata = fRefSubDir->Get(key->GetName()) ;
95 if ( odata->IsA()->InheritsFrom("TH1") ) {
96 TH1 * hdata = static_cast<TH1*>(odata) ;
97 TH1 * href = static_cast<TH1*>(fRefSubDir->Get(key->GetName())) ;
99 test = -1 ; // no reference data ;
101 Double_t rv = DiffK(hdata, href) ;
102 AliInfo(Form("%s ->Test = %f", hdata->GetName(), rv)) ;
108 AliError(Form("%s Is a Classname that cannot be processed", key->GetClassName())) ;
118 //____________________________________________________________________________
119 const Double_t AliQACheckerBase::Check(TList * list)
121 // Performs a basic checking
122 // Compares all the histograms in the list
124 Double_t test = 0.0 ;
127 if (list->GetEntries() == 0)
128 test = 1. ; // nothing to check
131 test = -1 ; // no reference data
136 while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
138 TH1 * href = static_cast<TH1*>(fRefSubDir->Get(hdata->GetName())) ;
140 test = -1 ; // no reference data ;
142 Double_t rv = DiffK(hdata, href) ;
143 AliInfo(Form("%s ->Test = %f", hdata->GetName(), rv)) ;
149 AliError("Data type cannot be processed") ;
158 //____________________________________________________________________________
159 const Double_t AliQACheckerBase::DiffC(const TH1 * href, const TH1 * hin) const
161 // compares two histograms using the Chi2 test
162 if ( hin->Integral() == 0 ) {
163 AliWarning(Form("Spectrum %s in %s is empty", hin->GetName(), AliQA::GetDataName())) ;
167 return hin->Chi2Test(href) ;
170 //____________________________________________________________________________
171 const Double_t AliQACheckerBase::DiffK(const TH1 * href, const TH1 * hin) const
173 // compares two histograms using the Kolmogorov test
174 if ( hin->Integral() == 0 ) {
175 AliWarning(Form("Spectrum %s in %s is empty", hin->GetName(), AliQA::GetDataName())) ;
179 return hin->KolmogorovTest(href) ;
182 //____________________________________________________________________________
183 void AliQACheckerBase::Init(const AliQA::DETECTORINDEX det)
185 AliQA::Instance(det) ;
188 //____________________________________________________________________________
189 void AliQACheckerBase::Run(AliQA::ALITASK index, TList * list)
191 AliInfo(Form("Processing %s", AliQA::GetAliTaskName(index))) ;
193 AliQA * qa = AliQA::Instance(index) ;
202 qa->Set(AliQA::kFATAL) ;
203 else if ( rv > 0 && rv <= 0.2 )
204 qa->Set(AliQA::kERROR) ;
205 else if ( rv > 0.2 && rv <= 0.5 )
206 qa->Set(AliQA::kWARNING) ;
207 else if ( rv > 0.5 && rv < 1 )
208 qa->Set(AliQA::kINFO) ;
209 AliInfo(Form("Test result of %s", AliQA::GetAliTaskName(index))) ;
213 //____________________________________________________________________________
214 void AliQACheckerBase::Finish() const
216 // wrap up and save QA in proper file
218 AliQA * qa = AliQA::Instance() ;
220 AliQAChecker::GetQAResultFile()->cd() ;
221 qa->Write(qa->GetName(), kWriteDelete) ;
222 AliQAChecker::GetQAResultFile()->Close() ;