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>
33 // --- Standard library ---
35 // --- AliRoot header files ---
37 #include "AliQualAss.h"
38 #include "AliQualAssChecker.h"
39 #include "AliQualAssCheckerBase.h"
40 #include "AliQualAssDataMaker.h"
42 ClassImp(AliQualAssCheckerBase)
45 //____________________________________________________________________________
46 AliQualAssCheckerBase::AliQualAssCheckerBase(const char * name, const char * title) :
54 //____________________________________________________________________________
55 AliQualAssCheckerBase::AliQualAssCheckerBase(const AliQualAssCheckerBase& qadm) :
56 TNamed(qadm.GetName(), qadm.GetTitle()),
57 fDataSubDir(qadm.fDataSubDir),
58 fRefSubDir(qadm.fRefSubDir)
64 //____________________________________________________________________________
65 AliQualAssCheckerBase& AliQualAssCheckerBase::operator = (const AliQualAssCheckerBase& qadm )
68 this->~AliQualAssCheckerBase();
69 new(this) AliQualAssCheckerBase(qadm);
73 //____________________________________________________________________________
74 const Double_t AliQualAssCheckerBase::Check()
76 // Performs a basic checking
77 // Compares all the histograms stored in the directory
83 test = 1. ; // nothing to check
86 test = -1 ; // no reference data
88 TList * keyList = fDataSubDir->GetListOfKeys() ;
92 while ( (key = static_cast<TKey *>(next())) ) {
93 TObject * odata = fRefSubDir->Get(key->GetName()) ;
94 if ( odata->IsA()->InheritsFrom("TH1") ) {
95 TH1 * hdata = static_cast<TH1*>(odata) ;
96 TH1 * href = static_cast<TH1*>(fRefSubDir->Get(key->GetName())) ;
98 test = -1 ; // no reference data ;
100 Double_t rv = DiffK(hdata, href) ;
101 AliInfo(Form("%s ->Test = %f", hdata->GetName(), rv)) ;
107 AliError(Form("%s Is a Classname that cannot be processed", key->GetClassName())) ;
117 //____________________________________________________________________________
118 const Double_t AliQualAssCheckerBase::DiffC(const TH1 * href, const TH1 * hin) const
120 // compares two histograms using the Chi2 test
121 if ( hin->Integral() == 0 ) {
122 AliWarning(Form("Spectrum %s in %s is empty", hin->GetName(), AliQualAss::GetDataName())) ;
126 return hin->Chi2Test(href) ;
129 //____________________________________________________________________________
130 const Double_t AliQualAssCheckerBase::DiffK(const TH1 * href, const TH1 * hin) const
132 // compares two histograms using the Kolmogorov test
133 if ( hin->Integral() == 0 ) {
134 AliWarning(Form("Spectrum %s in %s is empty", hin->GetName(), AliQualAss::GetDataName())) ;
138 return hin->KolmogorovTest(href) ;
141 //____________________________________________________________________________
142 void AliQualAssCheckerBase::Init(const AliQualAss::DETECTORINDEX det)
144 AliQualAss::Instance(det) ;
147 //____________________________________________________________________________
148 void AliQualAssCheckerBase::Run(AliQualAss::ALITASK index)
150 AliInfo(Form("Processing %s", AliQualAss::GetAliTaskName(index))) ;
152 AliQualAss * qa = AliQualAss::Instance(index) ;
154 Double_t rv = Check() ;
156 qa->Set(AliQualAss::kFATAL) ;
157 else if ( rv > 0 && rv <= 0.2 )
158 qa->Set(AliQualAss::kERROR) ;
159 else if ( rv > 0.2 && rv <= 0.5 )
160 qa->Set(AliQualAss::kWARNING) ;
161 else if ( rv > 0.5 && rv < 1 )
162 qa->Set(AliQualAss::kINFO) ;
163 AliInfo(Form("Test result of %s", AliQualAss::GetAliTaskName(index))) ;
167 //____________________________________________________________________________
168 void AliQualAssCheckerBase::Finish() const
170 // wrap up and save QA in proper file
172 AliQualAss * qa = AliQualAss::Instance() ;
174 AliQualAssChecker::GetQAResultFile()->cd() ;
175 qa->Write(qa->GetName(), kWriteDelete) ;
176 AliQualAssChecker::GetQAResultFile()->Close() ;