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 //____________________________________________________________________________
58 AliQACheckerBase::AliQACheckerBase(const AliQACheckerBase& qac) :
59 TNamed(qac.GetName(), qac.GetTitle()),
60 fDataSubDir(qac.fDataSubDir),
61 fRefSubDir(qac.fRefSubDir),
62 fRefOCDBSubDir(qac.fRefOCDBSubDir)
68 //____________________________________________________________________________
69 AliQACheckerBase& AliQACheckerBase::operator = (const AliQACheckerBase& qadm )
72 this->~AliQACheckerBase();
73 new(this) AliQACheckerBase(qadm);
77 //____________________________________________________________________________
78 const Double_t AliQACheckerBase::Check(AliQA::ALITASK_t /*index*/)
80 // Performs a basic checking
81 // Compares all the histograms stored in the directory
82 // With reference histograms either in a file of in OCDB
88 test = 1. ; // nothing to check
90 if (!fRefSubDir && !fRefOCDBSubDir)
91 test = -1 ; // no reference data
93 TList * keyList = fDataSubDir->GetListOfKeys() ;
97 while ( (key = static_cast<TKey *>(next())) ) {
98 TObject * odata = fRefSubDir->Get(key->GetName()) ;
99 if ( odata->IsA()->InheritsFrom("TH1") ) {
100 TH1 * hdata = static_cast<TH1*>(odata) ;
103 href = static_cast<TH1*>(fRefSubDir->Get(key->GetName())) ;
104 else if (fRefOCDBSubDir) {
105 href = static_cast<TH1*>(fRefOCDBSubDir->FindObject(key->GetName())) ;
108 test = -1 ; // no reference data ;
110 Double_t rv = DiffK(hdata, href) ;
111 AliInfo(Form("%s ->Test = %f", hdata->GetName(), rv)) ;
116 AliError(Form("%s Is a Classname that cannot be processed", key->GetClassName())) ;
126 //____________________________________________________________________________
127 const Double_t AliQACheckerBase::Check(AliQA::ALITASK_t /*index*/, TObjArray * list)
129 // Performs a basic checking
130 // Compares all the histograms in the list
132 Double_t test = 0.0 ;
135 if (list->GetEntries() == 0)
136 test = 1. ; // nothing to check
139 test = -1 ; // no reference data
144 while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
148 href = static_cast<TH1*>(fRefSubDir->Get(hdata->GetName())) ;
149 else if (fRefOCDBSubDir)
150 href = static_cast<TH1*>(fRefOCDBSubDir->FindObject(hdata->GetName())) ;
152 test = -1 ; // no reference data ;
154 Double_t rv = DiffK(hdata, href) ;
155 AliInfo(Form("%s ->Test = %f", hdata->GetName(), rv)) ;
161 AliError("Data type cannot be processed") ;
170 //____________________________________________________________________________
171 const Double_t AliQACheckerBase::DiffC(const TH1 * href, const TH1 * hin) const
173 // compares two histograms using the Chi2 test
174 if ( hin->Integral() == 0 ) {
175 AliWarning(Form("Spectrum %s is empty", hin->GetName())) ;
179 return hin->Chi2Test(href) ;
182 //____________________________________________________________________________
183 const Double_t AliQACheckerBase::DiffK(const TH1 * href, const TH1 * hin) const
185 // compares two histograms using the Kolmogorov test
186 if ( hin->Integral() == 0 ) {
187 AliWarning(Form("Spectrum %s is empty", hin->GetName())) ;
191 return hin->KolmogorovTest(href) ;
194 //____________________________________________________________________________
195 void AliQACheckerBase::Init(const AliQA::DETECTORINDEX_t det)
197 AliQA::Instance(det) ;
201 //____________________________________________________________________________
202 void AliQACheckerBase::Run(AliQA::ALITASK_t index, TObject * obj)
204 AliDebug(1, Form("Processing %s", AliQA::GetAliTaskName(index))) ;
210 TString className(obj->IsA()->GetName()) ;
211 if (className.Contains("TObjArray")) {
212 rv = Check(index, static_cast<TObjArray *>(obj)) ;
213 } else if (className.Contains("TNtupleD")) {
214 rv = Check(index, static_cast<TNtupleD *>(obj)) ;
216 AliError(Form("%s class not implemented", className.Data())) ;
222 AliDebug(1, Form("Test result of %s", AliQA::GetAliTaskName(index))) ;
227 //____________________________________________________________________________
228 void AliQACheckerBase::Finish() const
230 // wrap up and save QA in proper file
231 AliQA * qa = AliQA::Instance() ;
233 AliQA::GetQAResultFile()->cd() ;
234 qa->Write(qa->GetName(), kWriteDelete) ;
235 AliQA::GetQAResultFile()->Close() ;
238 //____________________________________________________________________________
239 void AliQACheckerBase::SetQA(AliQA::ALITASK_t index, const Double_t value) const
241 // sets the QA according the return value of the Check
243 AliQA * qa = AliQA::Instance(index) ;
246 qa->Set(AliQA::kFATAL) ;
247 else if ( value > 0 && value <= 0.0002 )
248 qa->Set(AliQA::kERROR) ;
249 else if ( value > 0.0002 && value <= 0.5 )
250 qa->Set(AliQA::kWARNING) ;
251 else if ( value > 0.5 && value < 1 )
252 qa->Set(AliQA::kINFO) ;