]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliQualAssCheckerBase.cxx
New QA classes (Yves)
[u/mrichter/AliRoot.git] / STEER / AliQualAssCheckerBase.cxx
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
42 ClassImp(AliQualAssCheckerBase)
43
44            
45 //____________________________________________________________________________ 
46 AliQualAssCheckerBase::AliQualAssCheckerBase(const char * name, const char * title) : 
47   TNamed(name, title), 
48   fData(0x0), 
49   fDetectorDir(0x0),
50   fRef(0x0) 
51 {
52   // ctor
53   Init() ; 
54 }
55
56 //____________________________________________________________________________ 
57 AliQualAssCheckerBase::AliQualAssCheckerBase(const AliQualAssCheckerBase& qadm) :
58   TNamed(qadm.GetName(), qadm.GetTitle()),
59   fData(qadm.fData),
60   fDetectorDir(qadm.fDetectorDir), 
61   fRef(qadm.fRef)
62 {
63   //copy ctor
64     
65 }
66
67 //____________________________________________________________________________
68 AliQualAssCheckerBase& AliQualAssCheckerBase::operator = (const AliQualAssCheckerBase& qadm )
69 {
70   // Equal operator.
71   this->~AliQualAssCheckerBase();
72   new(this) AliQualAssCheckerBase(qadm);
73   return *this;
74 }
75
76 //____________________________________________________________________________ 
77 const Double_t AliQualAssCheckerBase::DiffC(const TH1 * href, const TH1 * hin) const
78 {
79   // compares two histograms using the Chi2 test
80   if ( hin->Integral() == 0 ) {
81     AliWarning(Form("Spectrum %s in %s is empty", hin->GetName(), fData->GetName())) ; 
82     return 0. ;
83   }
84     
85   return hin->Chi2Test(href) ;  
86 }
87
88 //____________________________________________________________________________ 
89 const Double_t AliQualAssCheckerBase::DiffK(const TH1 * href, const TH1 * hin) const
90 {
91   // compares two histograms using the Kolmogorov test
92   if ( hin->Integral() == 0 ) {
93     AliWarning(Form("Spectrum %s in %s is empty", hin->GetName(), fData->GetName())) ; 
94     return 0. ;
95   }
96     
97   return hin->KolmogorovTest(href) ;  
98 }
99
100 //____________________________________________________________________________ 
101 void AliQualAssCheckerBase::Init()
102 {
103   //open files and search for the appropriate detector directory
104   
105   fRef = AliQualAssChecker::GetRefFile() ;
106   if (!fRef)
107     AliFatal(Form("Reference file %s not found", AliQualAssChecker::GetRefFileName())) ; 
108         
109   fDetectorDir = fRef->GetDirectory(AliQualAssDataMaker::GetDetectorDirName()) ; 
110   if (!fDetectorDir)
111     AliFatal(Form("Directory %s not found in reference file %s not found", AliQualAssDataMaker::GetDetectorDirName(), AliQualAssChecker::GetRefFileName())) ; 
112
113   fData = AliQualAssChecker::GetDataFile() ;
114   if (!fData)
115     AliFatal(Form("Reference file %s not found", AliQualAss::GetOutputName())) ; 
116
117   if (! fData->GetDirectory(AliQualAssDataMaker::GetDetectorDirName())) ; 
118     AliFatal(Form("Directory %s not found in reference file %s not found", AliQualAssDataMaker::GetDetectorDirName(), AliQualAss::GetOutputName())) ; 
119   
120   AliQualAss::Instance(AliQualAss::kSIM) ; 
121 }
122  
123 //____________________________________________________________________________
124 void AliQualAssCheckerBase::Exec(const Option_t * opt) 
125
126   AliInfo(Form("Processing %s", opt)) ; 
127 // loop over detectors
128   AliQualAss * qa = AliQualAss::Instance(AliQualAss::kPHOS) ; 
129   Double_t rv = Check(opt) ;   
130  if ( rv <= 0.) 
131     qa->Set(AliQualAss::kFATAL) ; 
132   else if ( rv > 0 && rv <= 0.2 )
133     qa->Set(AliQualAss::kERROR) ; 
134   else if ( rv > 0.2 && rv <= 0.5 )
135     qa->Set(AliQualAss::kWARNING) ;
136   else if ( rv > 0.5 && rv < 1 ) 
137     qa->Set(AliQualAss::kINFO) ; 
138   AliInfo(Form("Test result of %s in PHOS", opt)) ;
139   Finish() ; 
140 // endloop     
141 }
142
143 //____________________________________________________________________________
144 void AliQualAssCheckerBase::Finish() const 
145 {
146   // wrap up and save QA in proper file
147     
148   AliQualAss * qa = AliQualAss::Instance() ; 
149   qa->Show() ;
150   AliQualAssChecker::GetOutFile()->cd() ; 
151   qa->Write(qa->GetName(), kWriteDelete) ;   
152   AliQualAssChecker::GetOutFile()->Close() ;  
153 }