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 QualAssDataMakers with reference data
22 Y. Schutz CERN August 2007
25 // --- ROOT system ---
29 #include <TIterator.h>
34 // --- Standard library ---
36 // --- AliRoot header files ---
38 #include "AliQualAss.h"
39 #include "AliQualAssChecker.h"
40 #include "AliQualAssCheckerBase.h"
41 #include "AliQualAssDataMaker.h"
43 ClassImp(AliQualAssCheckerBase)
46 //____________________________________________________________________________
47 AliQualAssCheckerBase::AliQualAssCheckerBase(const char * name, const char * title) :
55 //____________________________________________________________________________
56 AliQualAssCheckerBase::AliQualAssCheckerBase(const AliQualAssCheckerBase& qadm) :
57 TNamed(qadm.GetName(), qadm.GetTitle()),
58 fDataSubDir(qadm.fDataSubDir),
59 fRefSubDir(qadm.fRefSubDir)
65 //____________________________________________________________________________
66 AliQualAssCheckerBase& AliQualAssCheckerBase::operator = (const AliQualAssCheckerBase& qadm )
69 this->~AliQualAssCheckerBase();
70 new(this) AliQualAssCheckerBase(qadm);
74 //____________________________________________________________________________
75 const Double_t AliQualAssCheckerBase::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 AliQualAssCheckerBase::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 AliQualAssCheckerBase::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(), AliQualAss::GetDataName())) ;
167 return hin->Chi2Test(href) ;
170 //____________________________________________________________________________
171 const Double_t AliQualAssCheckerBase::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(), AliQualAss::GetDataName())) ;
179 return hin->KolmogorovTest(href) ;
182 //____________________________________________________________________________
183 void AliQualAssCheckerBase::Init(const AliQualAss::DETECTORINDEX det)
185 AliQualAss::Instance(det) ;
188 //____________________________________________________________________________
189 void AliQualAssCheckerBase::Run(AliQualAss::ALITASK index, TList * list)
191 AliInfo(Form("Processing %s", AliQualAss::GetAliTaskName(index))) ;
193 AliQualAss * qa = AliQualAss::Instance(index) ;
202 qa->Set(AliQualAss::kFATAL) ;
203 else if ( rv > 0 && rv <= 0.2 )
204 qa->Set(AliQualAss::kERROR) ;
205 else if ( rv > 0.2 && rv <= 0.5 )
206 qa->Set(AliQualAss::kWARNING) ;
207 else if ( rv > 0.5 && rv < 1 )
208 qa->Set(AliQualAss::kINFO) ;
209 AliInfo(Form("Test result of %s", AliQualAss::GetAliTaskName(index))) ;
213 //____________________________________________________________________________
214 void AliQualAssCheckerBase::Finish() const
216 // wrap up and save QA in proper file
218 AliQualAss * qa = AliQualAss::Instance() ;
220 AliQualAssChecker::GetQAResultFile()->cd() ;
221 qa->Write(qa->GetName(), kWriteDelete) ;
222 AliQualAssChecker::GetQAResultFile()->Close() ;