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) :
56 //____________________________________________________________________________
57 AliQACheckerBase::AliQACheckerBase(const AliQACheckerBase& qac) :
58 TNamed(qac.GetName(), qac.GetTitle()),
59 fDataSubDir(qac.fDataSubDir),
60 fRefSubDir(qac.fRefSubDir),
61 fRefOCDBSubDir(qac.fRefOCDBSubDir)
67 //____________________________________________________________________________
68 AliQACheckerBase& AliQACheckerBase::operator = (const AliQACheckerBase& qadm )
71 this->~AliQACheckerBase();
72 new(this) AliQACheckerBase(qadm);
76 //____________________________________________________________________________
77 const Double_t AliQACheckerBase::Check(AliQA::ALITASK_t /*index*/)
79 // Performs a basic checking
80 // Compares all the histograms stored in the directory
81 // With reference histograms either in a file of in OCDB
87 test = 1. ; // nothing to check
89 if (!fRefSubDir && !fRefOCDBSubDir)
90 test = -1 ; // no reference data
92 TList * keyList = fDataSubDir->GetListOfKeys() ;
96 while ( (key = static_cast<TKey *>(next())) ) {
97 TObject * odata = fRefSubDir->Get(key->GetName()) ;
98 if ( odata->IsA()->InheritsFrom("TH1") ) {
99 TH1 * hdata = static_cast<TH1*>(odata) ;
102 href = static_cast<TH1*>(fRefSubDir->Get(key->GetName())) ;
103 else if (fRefOCDBSubDir) {
104 href = static_cast<TH1*>(fRefOCDBSubDir->FindObject(key->GetName())) ;
107 test = -1 ; // no reference data ;
109 Double_t rv = DiffK(hdata, href) ;
110 AliInfo(Form("%s ->Test = %f", hdata->GetName(), rv)) ;
115 AliError(Form("%s Is a Classname that cannot be processed", key->GetClassName())) ;
125 //____________________________________________________________________________
126 const Double_t AliQACheckerBase::Check(AliQA::ALITASK_t /*index*/, TObjArray * list)
128 // Performs a basic checking
129 // Compares all the histograms in the list
131 Double_t test = 0.0 ;
134 if (list->GetEntries() == 0)
135 test = 1. ; // nothing to check
138 test = -1 ; // no reference data
143 while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
147 href = static_cast<TH1*>(fRefSubDir->Get(hdata->GetName())) ;
148 else if (fRefOCDBSubDir)
149 href = static_cast<TH1*>(fRefOCDBSubDir->FindObject(hdata->GetName())) ;
151 test = -1 ; // no reference data ;
153 Double_t rv = DiffK(hdata, href) ;
154 AliInfo(Form("%s ->Test = %f", hdata->GetName(), rv)) ;
160 AliError("Data type cannot be processed") ;
169 //____________________________________________________________________________
170 const Double_t AliQACheckerBase::DiffC(const TH1 * href, const TH1 * hin) const
172 // compares two histograms using the Chi2 test
173 if ( hin->Integral() == 0 ) {
174 AliWarning(Form("Spectrum %s is empty", hin->GetName())) ;
178 return hin->Chi2Test(href) ;
181 //____________________________________________________________________________
182 const Double_t AliQACheckerBase::DiffK(const TH1 * href, const TH1 * hin) const
184 // compares two histograms using the Kolmogorov test
185 if ( hin->Integral() == 0 ) {
186 AliWarning(Form("Spectrum %s is empty", hin->GetName())) ;
190 return hin->KolmogorovTest(href) ;
193 //____________________________________________________________________________
194 void AliQACheckerBase::Init(const AliQA::DETECTORINDEX_t det)
196 AliQA::Instance(det) ;
199 //____________________________________________________________________________
200 void AliQACheckerBase::Run(AliQA::ALITASK_t index, TObjArray * list)
202 AliDebug(1, Form("Processing %s", AliQA::GetAliTaskName(index))) ;
204 AliQA * qa = AliQA::Instance(index) ;
208 rv = Check(index, list) ;
213 qa->Set(AliQA::kFATAL) ;
214 else if ( rv > 0 && rv <= 0.0002 )
215 qa->Set(AliQA::kERROR) ;
216 else if ( rv > 0.0002 && rv <= 0.5 )
217 qa->Set(AliQA::kWARNING) ;
218 else if ( rv > 0.5 && rv < 1 )
219 qa->Set(AliQA::kINFO) ;
220 AliDebug(1, Form("Test result of %s", AliQA::GetAliTaskName(index))) ;
224 //____________________________________________________________________________
225 void AliQACheckerBase::Finish() const
227 // wrap up and save QA in proper file
228 AliQA * qa = AliQA::Instance() ;
230 AliQA::GetQAResultFile()->cd() ;
231 qa->Write(qa->GetName(), kWriteDelete) ;
232 AliQA::GetQAResultFile()->Close() ;