]>
Commit | Line | Data |
---|---|---|
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 | ||
202374b1 | 19 | // |
20 | // Base class for detectors quality assurance checkers | |
21 | // Compares Data made by QADataMakers with reference data | |
22 | // Y. Schutz CERN August 2007 | |
23 | // | |
421ab0fb | 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> | |
a4976ef3 | 32 | #include <TList.h> |
421ab0fb | 33 | |
34 | // --- Standard library --- | |
35 | ||
36 | // --- AliRoot header files --- | |
37 | #include "AliLog.h" | |
2e42b4d4 | 38 | #include "AliQA.h" |
39 | #include "AliQAChecker.h" | |
40 | #include "AliQACheckerBase.h" | |
41 | #include "AliQADataMaker.h" | |
421ab0fb | 42 | |
2e42b4d4 | 43 | ClassImp(AliQACheckerBase) |
421ab0fb | 44 | |
45 | ||
46 | //____________________________________________________________________________ | |
2e42b4d4 | 47 | AliQACheckerBase::AliQACheckerBase(const char * name, const char * title) : |
421ab0fb | 48 | TNamed(name, title), |
a5fa6165 | 49 | fDataSubDir(0x0), |
4edbc5bc | 50 | fRefSubDir(0x0), |
51 | fRefOCDBSubDir(0x0) | |
421ab0fb | 52 | { |
53 | // ctor | |
421ab0fb | 54 | } |
55 | ||
56 | //____________________________________________________________________________ | |
4edbc5bc | 57 | AliQACheckerBase::AliQACheckerBase(const AliQACheckerBase& qac) : |
58 | TNamed(qac.GetName(), qac.GetTitle()), | |
59 | fDataSubDir(qac.fDataSubDir), | |
60 | fRefSubDir(qac.fRefSubDir), | |
61 | fRefOCDBSubDir(qac.fRefOCDBSubDir) | |
421ab0fb | 62 | { |
63 | //copy ctor | |
64 | ||
65 | } | |
66 | ||
67 | //____________________________________________________________________________ | |
2e42b4d4 | 68 | AliQACheckerBase& AliQACheckerBase::operator = (const AliQACheckerBase& qadm ) |
421ab0fb | 69 | { |
70 | // Equal operator. | |
2e42b4d4 | 71 | this->~AliQACheckerBase(); |
72 | new(this) AliQACheckerBase(qadm); | |
421ab0fb | 73 | return *this; |
74 | } | |
75 | ||
a5fa6165 | 76 | //____________________________________________________________________________ |
6b374954 | 77 | const Double_t AliQACheckerBase::Check(AliQA::ALITASK_t /*index*/) |
a5fa6165 | 78 | { |
79 | // Performs a basic checking | |
80 | // Compares all the histograms stored in the directory | |
4edbc5bc | 81 | // With reference histograms either in a file of in OCDB |
a5fa6165 | 82 | |
96d67a8d | 83 | Double_t test = 0.0 ; |
84 | Int_t count = 0 ; | |
85 | ||
86 | if (!fDataSubDir) | |
87 | test = 1. ; // nothing to check | |
88 | else | |
89 | if (!fRefSubDir && !fRefOCDBSubDir) | |
90 | test = -1 ; // no reference data | |
91 | else { | |
92 | TList * keyList = fDataSubDir->GetListOfKeys() ; | |
93 | TIter next(keyList) ; | |
94 | TKey * key ; | |
95 | count = 0 ; | |
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) ; | |
100 | TH1 * href = NULL ; | |
101 | if (fRefSubDir) | |
102 | href = static_cast<TH1*>(fRefSubDir->Get(key->GetName())) ; | |
103 | else if (fRefOCDBSubDir) { | |
104 | href = static_cast<TH1*>(fRefOCDBSubDir->FindObject(key->GetName())) ; | |
105 | } | |
106 | if (!href) | |
107 | test = -1 ; // no reference data ; | |
108 | else { | |
109 | Double_t rv = DiffK(hdata, href) ; | |
110 | AliInfo(Form("%s ->Test = %f", hdata->GetName(), rv)) ; | |
111 | test += rv ; | |
112 | count++ ; | |
113 | } | |
114 | } else | |
115 | AliError(Form("%s Is a Classname that cannot be processed", key->GetClassName())) ; | |
116 | } | |
117 | } | |
4edbc5bc | 118 | |
96d67a8d | 119 | if (count != 0) |
120 | test /= count ; | |
a5fa6165 | 121 | |
96d67a8d | 122 | return test ; |
a5fa6165 | 123 | } |
124 | ||
a4976ef3 | 125 | //____________________________________________________________________________ |
6b374954 | 126 | const Double_t AliQACheckerBase::Check(AliQA::ALITASK_t /*index*/, TObjArray * list) |
a4976ef3 | 127 | { |
128 | // Performs a basic checking | |
129 | // Compares all the histograms in the list | |
130 | ||
96d67a8d | 131 | Double_t test = 0.0 ; |
132 | Int_t count = 0 ; | |
133 | ||
134 | if (list->GetEntries() == 0) | |
135 | test = 1. ; // nothing to check | |
136 | else { | |
137 | if (!fRefSubDir) | |
138 | test = -1 ; // no reference data | |
139 | else { | |
140 | TIter next(list) ; | |
141 | TH1 * hdata ; | |
142 | count = 0 ; | |
143 | while ( (hdata = dynamic_cast<TH1 *>(next())) ) { | |
144 | if ( hdata) { | |
145 | TH1 * href = NULL ; | |
146 | if (fRefSubDir) | |
147 | href = static_cast<TH1*>(fRefSubDir->Get(hdata->GetName())) ; | |
148 | else if (fRefOCDBSubDir) | |
149 | href = static_cast<TH1*>(fRefOCDBSubDir->FindObject(hdata->GetName())) ; | |
150 | if (!href) | |
151 | test = -1 ; // no reference data ; | |
152 | else { | |
153 | Double_t rv = DiffK(hdata, href) ; | |
154 | AliInfo(Form("%s ->Test = %f", hdata->GetName(), rv)) ; | |
155 | test += rv ; | |
156 | count++ ; | |
157 | } | |
158 | } | |
159 | else | |
160 | AliError("Data type cannot be processed") ; | |
161 | } | |
162 | } | |
163 | } | |
4edbc5bc | 164 | if (count != 0) |
165 | test /= count ; | |
166 | return test ; | |
a4976ef3 | 167 | } |
168 | ||
421ab0fb | 169 | //____________________________________________________________________________ |
2e42b4d4 | 170 | const Double_t AliQACheckerBase::DiffC(const TH1 * href, const TH1 * hin) const |
421ab0fb | 171 | { |
172 | // compares two histograms using the Chi2 test | |
173 | if ( hin->Integral() == 0 ) { | |
8bea2de0 | 174 | AliWarning(Form("Spectrum %s is empty", hin->GetName())) ; |
421ab0fb | 175 | return 0. ; |
176 | } | |
177 | ||
178 | return hin->Chi2Test(href) ; | |
179 | } | |
180 | ||
181 | //____________________________________________________________________________ | |
2e42b4d4 | 182 | const Double_t AliQACheckerBase::DiffK(const TH1 * href, const TH1 * hin) const |
421ab0fb | 183 | { |
184 | // compares two histograms using the Kolmogorov test | |
185 | if ( hin->Integral() == 0 ) { | |
8bea2de0 | 186 | AliWarning(Form("Spectrum %s is empty", hin->GetName())) ; |
421ab0fb | 187 | return 0. ; |
188 | } | |
189 | ||
190 | return hin->KolmogorovTest(href) ; | |
191 | } | |
192 | ||
193 | //____________________________________________________________________________ | |
96d67a8d | 194 | void AliQACheckerBase::Init(const AliQA::DETECTORINDEX_t det) |
421ab0fb | 195 | { |
2e42b4d4 | 196 | AliQA::Instance(det) ; |
421ab0fb | 197 | } |
198 | ||
199 | //____________________________________________________________________________ | |
96d67a8d | 200 | void AliQACheckerBase::Run(AliQA::ALITASK_t index, TObjArray * list) |
421ab0fb | 201 | { |
54a7f3ac | 202 | AliDebug(1, Form("Processing %s", AliQA::GetAliTaskName(index))) ; |
a5fa6165 | 203 | |
2e42b4d4 | 204 | AliQA * qa = AliQA::Instance(index) ; |
a5fa6165 | 205 | |
a4976ef3 | 206 | Double_t rv = -1 ; |
207 | if (list) | |
6b374954 | 208 | rv = Check(index, list) ; |
a4976ef3 | 209 | else |
6b374954 | 210 | rv = Check(index) ; |
a4976ef3 | 211 | |
a5fa6165 | 212 | if ( rv <= 0.) |
2e42b4d4 | 213 | qa->Set(AliQA::kFATAL) ; |
ca36a0bf | 214 | else if ( rv > 0 && rv <= 0.0002 ) |
2e42b4d4 | 215 | qa->Set(AliQA::kERROR) ; |
ca36a0bf | 216 | else if ( rv > 0.0002 && rv <= 0.5 ) |
2e42b4d4 | 217 | qa->Set(AliQA::kWARNING) ; |
421ab0fb | 218 | else if ( rv > 0.5 && rv < 1 ) |
2e42b4d4 | 219 | qa->Set(AliQA::kINFO) ; |
54a7f3ac | 220 | AliDebug(1, Form("Test result of %s", AliQA::GetAliTaskName(index))) ; |
421ab0fb | 221 | Finish() ; |
421ab0fb | 222 | } |
223 | ||
224 | //____________________________________________________________________________ | |
2e42b4d4 | 225 | void AliQACheckerBase::Finish() const |
421ab0fb | 226 | { |
54a7f3ac | 227 | // wrap up and save QA in proper file |
228 | AliQA * qa = AliQA::Instance() ; | |
229 | qa->Show() ; | |
230 | AliQA::GetQAResultFile()->cd() ; | |
231 | qa->Write(qa->GetName(), kWriteDelete) ; | |
232 | AliQA::GetQAResultFile()->Close() ; | |
421ab0fb | 233 | } |