]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliQualAssCheckerBase.cxx
Updated QA classes (Yves)
[u/mrichter/AliRoot.git] / STEER / AliQualAssCheckerBase.cxx
CommitLineData
421ab0fb 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16
17/* $Id$ */
18
19/*
20 Base class for detectors quality assurance checkers
21 Compares Data made by QualAssDataMakers with reference data
22 Y. Schutz CERN August 2007
23*/
24
25// --- ROOT system ---
26#include <TClass.h>
27#include <TH1F.h>
28#include <TH1I.h>
29#include <TIterator.h>
30#include <TKey.h>
31#include <TFile.h>
32
33// --- Standard library ---
34
35// --- AliRoot header files ---
36#include "AliLog.h"
37#include "AliQualAss.h"
38#include "AliQualAssChecker.h"
39#include "AliQualAssCheckerBase.h"
40#include "AliQualAssDataMaker.h"
41
42ClassImp(AliQualAssCheckerBase)
43
44
45//____________________________________________________________________________
46AliQualAssCheckerBase::AliQualAssCheckerBase(const char * name, const char * title) :
47 TNamed(name, title),
a5fa6165 48 fDataSubDir(0x0),
49 fRefSubDir(0x0)
421ab0fb 50{
51 // ctor
421ab0fb 52}
53
54//____________________________________________________________________________
55AliQualAssCheckerBase::AliQualAssCheckerBase(const AliQualAssCheckerBase& qadm) :
56 TNamed(qadm.GetName(), qadm.GetTitle()),
a5fa6165 57 fDataSubDir(qadm.fDataSubDir),
58 fRefSubDir(qadm.fRefSubDir)
421ab0fb 59{
60 //copy ctor
61
62}
63
64//____________________________________________________________________________
65AliQualAssCheckerBase& AliQualAssCheckerBase::operator = (const AliQualAssCheckerBase& qadm )
66{
67 // Equal operator.
68 this->~AliQualAssCheckerBase();
69 new(this) AliQualAssCheckerBase(qadm);
70 return *this;
71}
72
a5fa6165 73//____________________________________________________________________________
74const Double_t AliQualAssCheckerBase::Check()
75{
76 // Performs a basic checking
77 // Compares all the histograms stored in the directory
78
79 Double_t test = 0.0 ;
80 Int_t count = 0 ;
81
82 if (!fDataSubDir)
83 test = 1. ; // nothing to check
84 else
85 if (!fRefSubDir)
86 test = -1 ; // no reference data
87 else {
88 TList * keyList = fDataSubDir->GetListOfKeys() ;
89 TIter next(keyList) ;
90 TKey * key ;
91 count = 0 ;
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())) ;
97 if (!href)
98 test = -1 ; // no reference data ;
99 else {
100 Double_t rv = DiffK(hdata, href) ;
101 AliInfo(Form("%s ->Test = %f", hdata->GetName(), rv)) ;
102 test += rv ;
103 count++ ;
104 }
105 }
106 else
107 AliError(Form("%s Is a Classname that cannot be processed", key->GetClassName())) ;
108 }
109
110 }
111 if (count != 0)
112 test /= count ;
113
114 return test ;
115}
116
421ab0fb 117//____________________________________________________________________________
118const Double_t AliQualAssCheckerBase::DiffC(const TH1 * href, const TH1 * hin) const
119{
120 // compares two histograms using the Chi2 test
121 if ( hin->Integral() == 0 ) {
a5fa6165 122 AliWarning(Form("Spectrum %s in %s is empty", hin->GetName(), AliQualAss::GetDataName())) ;
421ab0fb 123 return 0. ;
124 }
125
126 return hin->Chi2Test(href) ;
127}
128
129//____________________________________________________________________________
130const Double_t AliQualAssCheckerBase::DiffK(const TH1 * href, const TH1 * hin) const
131{
132 // compares two histograms using the Kolmogorov test
133 if ( hin->Integral() == 0 ) {
a5fa6165 134 AliWarning(Form("Spectrum %s in %s is empty", hin->GetName(), AliQualAss::GetDataName())) ;
421ab0fb 135 return 0. ;
136 }
137
138 return hin->KolmogorovTest(href) ;
139}
140
141//____________________________________________________________________________
a5fa6165 142void AliQualAssCheckerBase::Init(const AliQualAss::DETECTORINDEX det)
421ab0fb 143{
a5fa6165 144 AliQualAss::Instance(det) ;
421ab0fb 145}
146
147//____________________________________________________________________________
a5fa6165 148void AliQualAssCheckerBase::Run(AliQualAss::ALITASK index)
421ab0fb 149{
a5fa6165 150 AliInfo(Form("Processing %s", AliQualAss::GetAliTaskName(index))) ;
151
152 AliQualAss * qa = AliQualAss::Instance(index) ;
153
154 Double_t rv = Check() ;
155 if ( rv <= 0.)
421ab0fb 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) ;
a5fa6165 163 AliInfo(Form("Test result of %s", AliQualAss::GetAliTaskName(index))) ;
421ab0fb 164 Finish() ;
421ab0fb 165}
166
167//____________________________________________________________________________
168void AliQualAssCheckerBase::Finish() const
169{
170 // wrap up and save QA in proper file
171
172 AliQualAss * qa = AliQualAss::Instance() ;
173 qa->Show() ;
a5fa6165 174 AliQualAssChecker::GetQAResultFile()->cd() ;
421ab0fb 175 qa->Write(qa->GetName(), kWriteDelete) ;
a5fa6165 176 AliQualAssChecker::GetQAResultFile()->Close() ;
421ab0fb 177}