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 fLowTestValue = new Float_t[AliQAv1::kNBIT] ;
58 fUpTestValue = new Float_t[AliQAv1::kNBIT] ;
59 fLowTestValue[AliQAv1::kINFO] = 0.5 ;
60 fUpTestValue[AliQAv1::kINFO] = 1.0 ;
61 fLowTestValue[AliQAv1::kWARNING] = 0.002 ;
62 fUpTestValue[AliQAv1::kWARNING] = 0.5 ;
63 fLowTestValue[AliQAv1::kERROR] = 0.0 ;
64 fUpTestValue[AliQAv1::kERROR] = 0.002 ;
65 fLowTestValue[AliQAv1::kFATAL] = -1.0 ;
66 fUpTestValue[AliQAv1::kFATAL] = 0.0 ;
68 AliDebug(AliQAv1::GetQADebugLevel(), "Default setting is:") ;
69 if ( AliDebugLevel() == AliQAv1::GetQADebugLevel() ) {
70 const Char_t * text= Form(" INFO -> %1.5f < value < %1.5f WARNING -> %1.5f < value <= %1.5f \n ERROR -> %1.5f < value <= %1.5f \n FATAL -> %1.5f <= value < %1.5f \n",
71 fLowTestValue[AliQAv1::kINFO], fUpTestValue[AliQAv1::kINFO],
72 fLowTestValue[AliQAv1::kWARNING], fUpTestValue[AliQAv1::kWARNING],
73 fLowTestValue[AliQAv1::kERROR], fUpTestValue[AliQAv1::kERROR],
74 fLowTestValue[AliQAv1::kFATAL], fUpTestValue[AliQAv1::kFATAL]) ;
75 AliInfo(Form("%s", text)) ;
79 //____________________________________________________________________________
80 AliQACheckerBase::AliQACheckerBase(const AliQACheckerBase& qac) :
81 TNamed(qac.GetName(), qac.GetTitle()),
82 fDataSubDir(qac.fDataSubDir),
83 fRefSubDir(qac.fRefSubDir),
84 fRefOCDBSubDir(qac.fRefOCDBSubDir),
85 fLowTestValue(qac.fLowTestValue),
86 fUpTestValue(qac.fLowTestValue)
89 for (Int_t index = 0 ; index < AliQAv1::kNBIT ; index++) {
90 fLowTestValue[index] = qac.fLowTestValue[index] ;
91 fUpTestValue[index] = qac.fUpTestValue[index] ;
96 //____________________________________________________________________________
97 AliQACheckerBase& AliQACheckerBase::operator = (const AliQACheckerBase& qadm )
100 this->~AliQACheckerBase();
101 new(this) AliQACheckerBase(qadm);
105 //____________________________________________________________________________
106 AliQACheckerBase::~AliQACheckerBase()
108 delete [] fLowTestValue ;
109 delete [] fUpTestValue ;
112 //____________________________________________________________________________
113 Double_t * AliQACheckerBase::Check(AliQAv1::ALITASK_t /*index*/)
115 // Performs a basic checking
116 // Compares all the histograms stored in the directory
117 // With reference histograms either in a file of in OCDB
119 Double_t * test = new Double_t[AliRecoParam::kNSpecies] ;
120 Int_t count[AliRecoParam::kNSpecies] = { 0 };
122 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
124 if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) )
127 test[specie] = 0. ; // nothing to check
128 } else if (!fRefSubDir && !fRefOCDBSubDir) {
129 test[specie] = -1 ; // no reference data
131 TList * keyList = fDataSubDir->GetListOfKeys() ;
132 TIter next(keyList) ;
135 while ( (key = static_cast<TKey *>(next())) ) {
136 TObject * odata = fRefSubDir->Get(key->GetName()) ;
137 if ( odata->IsA()->InheritsFrom("TH1") ) {
138 TH1 * hdata = static_cast<TH1*>(odata) ;
141 href = static_cast<TH1*>(fRefSubDir->Get(key->GetName())) ;
142 else if (fRefOCDBSubDir[specie]) {
143 href = static_cast<TH1*>(fRefOCDBSubDir[specie]->FindObject(key->GetName())) ;
146 test[specie] = -1 ; // no reference data ;
148 Double_t rv = DiffK(hdata, href) ;
149 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s ->Test = %f", hdata->GetName(), rv)) ;
154 AliError(Form("%s Is a Classname that cannot be processed", key->GetClassName())) ;
156 if (count[specie] != 0)
157 test[specie] /= count[specie] ;
163 //____________________________________________________________________________
164 Double_t * AliQACheckerBase::Check(AliQAv1::ALITASK_t /*index*/, TObjArray ** list)
166 // Performs a basic checking
167 // Compares all the histograms in the list
169 Double_t * test = new Double_t[AliRecoParam::kNSpecies] ;
170 Int_t count[AliRecoParam::kNSpecies] = { 0 };
172 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
174 if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) )
176 if (list[specie]->GetEntries() == 0)
177 test[specie] = 0. ; // nothing to check
179 if (!fRefSubDir && !fRefOCDBSubDir)
180 test[specie] = -1 ; // no reference data
182 TIter next(list[specie]) ;
185 while ( (hdata = static_cast<TH1 *>(next())) ) {
186 TString cln(hdata->ClassName()) ;
187 if ( ! cln.Contains("TH1") )
190 if ( hdata->TestBit(AliQAv1::GetExpertBit()) ) // does not perform the test for expert data
194 href = static_cast<TH1*>(fRefSubDir->Get(hdata->GetName())) ;
195 else if (fRefOCDBSubDir[specie])
196 href = static_cast<TH1*>(fRefOCDBSubDir[specie]->FindObject(hdata->GetName())) ;
198 test[specie] = -1 ; // no reference data ;
200 Double_t rv = DiffK(hdata, href) ;
201 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s ->Test = %f", hdata->GetName(), rv)) ;
207 AliError("Data type cannot be processed") ;
209 if (count[specie] != 0)
210 test[specie] /= count[specie] ;
218 //____________________________________________________________________________
219 Double_t AliQACheckerBase::DiffC(const TH1 * href, const TH1 * hin) const
221 // compares two histograms using the Chi2 test
222 if ( hin->Integral() == 0 ) {
223 AliDebug(AliQAv1::GetQADebugLevel(), Form("Spectrum %s is empty", hin->GetName())) ;
227 return hin->Chi2Test(href) ;
230 //____________________________________________________________________________
231 Double_t AliQACheckerBase::DiffK(const TH1 * href, const TH1 * hin) const
233 // compares two histograms using the Kolmogorov test
234 if ( hin->Integral() == 0 ) {
235 AliDebug(AliQAv1::GetQADebugLevel(), Form("Spectrum %s is empty", hin->GetName())) ;
239 return hin->KolmogorovTest(href) ;
242 //____________________________________________________________________________
243 void AliQACheckerBase::Run(AliQAv1::ALITASK_t index, TObjArray ** list)
245 AliDebug(AliQAv1::GetQADebugLevel(), Form("Processing %s", AliQAv1::GetAliTaskName(index))) ;
247 Double_t * rv = NULL ;
251 rv = Check(index, list) ;
254 AliDebug(AliQAv1::GetQADebugLevel(), Form("Test result of %s", AliQAv1::GetAliTaskName(index))) ;
261 //____________________________________________________________________________
262 void AliQACheckerBase::Finish() const
264 // wrap up and save QA in proper file
265 AliQAv1 * qa = AliQAv1::Instance() ;
267 AliQAv1::GetQAResultFile()->cd() ;
268 qa->Write(qa->GetName(), kWriteDelete) ;
269 AliQAv1::GetQAResultFile()->Close() ;
272 //____________________________________________________________________________
273 void AliQACheckerBase::SetHiLo(Float_t * hiValue, Float_t * lowValue)
275 AliDebug(AliQAv1::GetQADebugLevel(), "Previous setting was:") ;
276 if ( AliDebugLevel() == AliQAv1::GetQADebugLevel() ) {
277 const Char_t * text= Form(" INFO -> %1.5f < value < %1.5f WARNING -> %1.5f < value <= %1.5f \n ERROR -> %1.5f < value <= %1.5f \n FATAL -> %1.5f <= value < %1.5f \n",
278 fLowTestValue[AliQAv1::kINFO], fUpTestValue[AliQAv1::kINFO],
279 fLowTestValue[AliQAv1::kWARNING], fUpTestValue[AliQAv1::kWARNING],
280 fLowTestValue[AliQAv1::kERROR], fUpTestValue[AliQAv1::kERROR],
281 fLowTestValue[AliQAv1::kFATAL], fUpTestValue[AliQAv1::kFATAL]) ;
282 AliInfo(Form("%s", text)) ;
285 for (Int_t index = 0 ; index < AliQAv1::kNBIT ; index++) {
286 fLowTestValue[index] = lowValue[index] ;
287 fUpTestValue[index] = hiValue[index] ;
289 AliDebug(AliQAv1::GetQADebugLevel(), "Current setting is:") ;
290 if ( AliDebugLevel() == AliQAv1::GetQADebugLevel() ) {
291 const Char_t * text= Form(" INFO -> %1.5f < value < %1.5f WARNING -> %1.5f < value <= %1.5f \n ERROR -> %1.5f < value <= %1.5f \n FATAL -> %1.5f <= value < %1.5f \n",
292 fLowTestValue[AliQAv1::kINFO], fUpTestValue[AliQAv1::kINFO],
293 fLowTestValue[AliQAv1::kWARNING], fUpTestValue[AliQAv1::kWARNING],
294 fLowTestValue[AliQAv1::kERROR], fUpTestValue[AliQAv1::kERROR],
295 fLowTestValue[AliQAv1::kFATAL], fUpTestValue[AliQAv1::kFATAL]) ; AliInfo(Form("%s", text)) ;
299 //____________________________________________________________________________
300 void AliQACheckerBase::SetQA(AliQAv1::ALITASK_t index, Double_t * value) const
302 // sets the QA according the return value of the Check
304 AliQAv1 * qa = AliQAv1::Instance(index) ;
305 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
306 if ( value == NULL ) { // No checker is implemented, set all QA to Fatal
307 qa->Set(AliQAv1::kFATAL, specie) ;
309 if ( value[specie] >= fLowTestValue[AliQAv1::kFATAL] && value[specie] < fUpTestValue[AliQAv1::kFATAL] )
310 qa->Set(AliQAv1::kFATAL, specie) ;
311 else if ( value[specie] > fLowTestValue[AliQAv1::kERROR] && value[specie] <= fUpTestValue[AliQAv1::kERROR] )
312 qa->Set(AliQAv1::kERROR, specie) ;
313 else if ( value[specie] > fLowTestValue[AliQAv1::kWARNING] && value[specie] <= fUpTestValue[AliQAv1::kWARNING] )
314 qa->Set(AliQAv1::kWARNING, specie) ;
315 else if ( value[specie] > fLowTestValue[AliQAv1::kINFO] && value[specie] <= fUpTestValue[AliQAv1::kINFO] )
316 qa->Set(AliQAv1::kINFO, specie) ;