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 printf( " INFO -> %1.5f < value < %1.5f \n", fLowTestValue[AliQAv1::kINFO], fUpTestValue[AliQAv1::kINFO]) ;
71 printf( " WARNING -> %1.5f < value <= %1.5f \n", fLowTestValue[AliQAv1::kWARNING], fUpTestValue[AliQAv1::kWARNING]) ;
72 printf( " ERROR -> %1.5f < value <= %1.5f \n", fLowTestValue[AliQAv1::kERROR], fUpTestValue[AliQAv1::kERROR]) ;
73 printf( " FATAL -> %1.5f <= value < %1.5f \n", fLowTestValue[AliQAv1::kFATAL], fUpTestValue[AliQAv1::kFATAL]) ;
77 //____________________________________________________________________________
78 AliQACheckerBase::AliQACheckerBase(const AliQACheckerBase& qac) :
79 TNamed(qac.GetName(), qac.GetTitle()),
80 fDataSubDir(qac.fDataSubDir),
81 fRefSubDir(qac.fRefSubDir),
82 fRefOCDBSubDir(qac.fRefOCDBSubDir),
83 fLowTestValue(qac.fLowTestValue),
84 fUpTestValue(qac.fLowTestValue)
87 for (Int_t index = 0 ; index < AliQAv1::kNBIT ; index++) {
88 fLowTestValue[index] = qac.fLowTestValue[index] ;
89 fUpTestValue[index] = qac.fUpTestValue[index] ;
94 //____________________________________________________________________________
95 AliQACheckerBase& AliQACheckerBase::operator = (const AliQACheckerBase& qadm )
98 this->~AliQACheckerBase();
99 new(this) AliQACheckerBase(qadm);
103 //____________________________________________________________________________
104 AliQACheckerBase::~AliQACheckerBase()
106 delete [] fLowTestValue ;
107 delete [] fUpTestValue ;
110 //____________________________________________________________________________
111 Double_t * AliQACheckerBase::Check(AliQAv1::ALITASK_t /*index*/)
113 // Performs a basic checking
114 // Compares all the histograms stored in the directory
115 // With reference histograms either in a file of in OCDB
117 Double_t * test = new Double_t[AliRecoParam::kNSpecies] ;
118 Int_t count[AliRecoParam::kNSpecies] = { 0 };
120 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
122 if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) )
125 test[specie] = 0. ; // nothing to check
126 } else if (!fRefSubDir && !fRefOCDBSubDir) {
127 test[specie] = -1 ; // no reference data
129 TList * keyList = fDataSubDir->GetListOfKeys() ;
130 TIter next(keyList) ;
133 while ( (key = static_cast<TKey *>(next())) ) {
134 TObject * odata = fRefSubDir->Get(key->GetName()) ;
135 if ( odata->IsA()->InheritsFrom("TH1") ) {
136 TH1 * hdata = static_cast<TH1*>(odata) ;
139 href = static_cast<TH1*>(fRefSubDir->Get(key->GetName())) ;
140 else if (fRefOCDBSubDir[specie]) {
141 href = static_cast<TH1*>(fRefOCDBSubDir[specie]->FindObject(key->GetName())) ;
144 test[specie] = -1 ; // no reference data ;
146 Double_t rv = DiffK(hdata, href) ;
147 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s ->Test = %f", hdata->GetName(), rv)) ;
152 AliError(Form("%s Is a Classname that cannot be processed", key->GetClassName())) ;
154 if (count[specie] != 0)
155 test[specie] /= count[specie] ;
161 //____________________________________________________________________________
162 Double_t * AliQACheckerBase::Check(AliQAv1::ALITASK_t /*index*/, TObjArray ** list)
164 // Performs a basic checking
165 // Compares all the histograms in the list
167 Double_t * test = new Double_t[AliRecoParam::kNSpecies] ;
168 Int_t count[AliRecoParam::kNSpecies] = { 0 };
170 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
172 if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) )
174 if (list[specie]->GetEntries() == 0)
175 test[specie] = 0. ; // nothing to check
177 if (!fRefSubDir && !fRefOCDBSubDir)
178 test[specie] = -1 ; // no reference data
180 TIter next(list[specie]) ;
183 while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
185 if ( hdata->TestBit(AliQAv1::GetExpertBit()) ) // does not perform the test for expert data
189 href = static_cast<TH1*>(fRefSubDir->Get(hdata->GetName())) ;
190 else if (fRefOCDBSubDir[specie])
191 href = static_cast<TH1*>(fRefOCDBSubDir[specie]->FindObject(hdata->GetName())) ;
193 test[specie] = -1 ; // no reference data ;
195 Double_t rv = DiffK(hdata, href) ;
196 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s ->Test = %f", hdata->GetName(), rv)) ;
202 AliError("Data type cannot be processed") ;
204 if (count[specie] != 0)
205 test[specie] /= count[specie] ;
213 //____________________________________________________________________________
214 Double_t AliQACheckerBase::DiffC(const TH1 * href, const TH1 * hin) const
216 // compares two histograms using the Chi2 test
217 if ( hin->Integral() == 0 ) {
218 AliDebug(AliQAv1::GetQADebugLevel(), Form("Spectrum %s is empty", hin->GetName())) ;
222 return hin->Chi2Test(href) ;
225 //____________________________________________________________________________
226 Double_t AliQACheckerBase::DiffK(const TH1 * href, const TH1 * hin) const
228 // compares two histograms using the Kolmogorov test
229 if ( hin->Integral() == 0 ) {
230 AliDebug(AliQAv1::GetQADebugLevel(), Form("Spectrum %s is empty", hin->GetName())) ;
234 return hin->KolmogorovTest(href) ;
237 //____________________________________________________________________________
238 void AliQACheckerBase::Run(AliQAv1::ALITASK_t index, TObjArray ** list)
240 AliDebug(AliQAv1::GetQADebugLevel(), Form("Processing %s", AliQAv1::GetAliTaskName(index))) ;
242 Double_t * rv = NULL ;
246 rv = Check(index, list) ;
249 AliDebug(AliQAv1::GetQADebugLevel(), Form("Test result of %s", AliQAv1::GetAliTaskName(index))) ;
256 //____________________________________________________________________________
257 void AliQACheckerBase::Finish() const
259 // wrap up and save QA in proper file
260 AliQAv1 * qa = AliQAv1::Instance() ;
262 AliQAv1::GetQAResultFile()->cd() ;
263 qa->Write(qa->GetName(), kWriteDelete) ;
264 AliQAv1::GetQAResultFile()->Close() ;
267 //____________________________________________________________________________
268 void AliQACheckerBase::SetHiLo(Float_t * hiValue, Float_t * lowValue)
270 AliDebug(AliQAv1::GetQADebugLevel(), "Previous setting was:") ;
271 if ( AliDebugLevel() == AliQAv1::GetQADebugLevel() ) {
272 printf( " INFO -> %1.5f < value < %1.5f \n", fLowTestValue[AliQAv1::kINFO], fUpTestValue[AliQAv1::kINFO]) ;
273 printf( " WARNING -> %1.5f < value <= %1.5f \n", fLowTestValue[AliQAv1::kWARNING], fUpTestValue[AliQAv1::kWARNING]) ;
274 printf( " ERROR -> %1.5f < value <= %1.5f \n", fLowTestValue[AliQAv1::kERROR], fUpTestValue[AliQAv1::kERROR]) ;
275 printf( " FATAL -> %1.5f <= value < %1.5f \n", fLowTestValue[AliQAv1::kFATAL], fUpTestValue[AliQAv1::kFATAL]) ;
278 for (Int_t index = 0 ; index < AliQAv1::kNBIT ; index++) {
279 fLowTestValue[index] = lowValue[index] ;
280 fUpTestValue[index] = hiValue[index] ;
282 AliDebug(AliQAv1::GetQADebugLevel(), "Current setting is:") ;
283 if ( AliDebugLevel() == AliQAv1::GetQADebugLevel() ) {
284 printf( " INFO -> %1.5f < value < %1.5f \n", fLowTestValue[AliQAv1::kINFO], fUpTestValue[AliQAv1::kINFO]) ;
285 printf( " WARNING -> %1.5f < value <= %1.5f \n", fLowTestValue[AliQAv1::kWARNING], fUpTestValue[AliQAv1::kWARNING]) ;
286 printf( " ERROR -> %1.5f < value <= %1.5f \n", fLowTestValue[AliQAv1::kERROR], fUpTestValue[AliQAv1::kERROR]) ;
287 printf( " FATAL -> %1.5f <= value < %1.5f \n", fLowTestValue[AliQAv1::kFATAL], fUpTestValue[AliQAv1::kFATAL]) ;
291 //____________________________________________________________________________
292 void AliQACheckerBase::SetQA(AliQAv1::ALITASK_t index, Double_t * value) const
294 // sets the QA according the return value of the Check
296 AliQAv1 * qa = AliQAv1::Instance(index) ;
297 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
298 if ( value == NULL ) { // No checker is implemented, set all QA to Fatal
299 qa->Set(AliQAv1::kFATAL, specie) ;
301 if ( value[specie] >= fLowTestValue[AliQAv1::kFATAL] && value[specie] < fUpTestValue[AliQAv1::kFATAL] )
302 qa->Set(AliQAv1::kFATAL, specie) ;
303 else if ( value[specie] > fLowTestValue[AliQAv1::kERROR] && value[specie] <= fUpTestValue[AliQAv1::kERROR] )
304 qa->Set(AliQAv1::kERROR, specie) ;
305 else if ( value[specie] > fLowTestValue[AliQAv1::kWARNING] && value[specie] <= fUpTestValue[AliQAv1::kWARNING] )
306 qa->Set(AliQAv1::kWARNING, specie) ;
307 else if ( value[specie] > fLowTestValue[AliQAv1::kINFO] && value[specie] <= fUpTestValue[AliQAv1::kINFO] )
308 qa->Set(AliQAv1::kINFO, specie) ;