During simulation: fill STU region w/ non null time sums
[u/mrichter/AliRoot.git] / TPC / AliTPCCalibQAChecker.h
... / ...
CommitLineData
1#ifndef ALITPCCALIBQACHECKER_H
2#define ALITPCCALIBQACHECKER_H
3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
6/////////////////////////////////////////////////////////////////////////////////////////
7// //
8// QA checking class //
9// //
10/////////////////////////////////////////////////////////////////////////////////////////
11
12#include <TNamed.h>
13#include <TString.h>
14#include <TH1.h>
15
16class TTree;
17class TIterator;
18class TGraph;
19class TObjArray;
20class TVirtualPad;
21
22class AliTPCCalibQAChecker : public TNamed {
23public:
24 enum { kNQualityFlags=5 };
25 enum QualityFlag_t { kNULLFLAG=-1, kINFO, kWARNING, kERROR, kFATAL, kNFLAG };
26 enum AlarmType_t { kMean=0, kBinAny, kBinAll, kNentries};
27
28 AliTPCCalibQAChecker();
29 AliTPCCalibQAChecker(const char* name, const char *title);
30
31 virtual ~AliTPCCalibQAChecker();
32
33 void Process();
34
35 void SetTreeChecker(TTree* &tree) {fTreePtr=&tree;}
36 void SetHistChecker(TH1* &hist) {fHistPtr=&hist;}
37 void SetGraphChecker(TGraph* &graph) {fGraphPtr=&graph;}
38 void SetNumberChecker(Double_t & number) {fNumberPtr=&number;}
39
40 const AliTPCCalibQAChecker* GetSubChecker(const char* name, Bool_t recursive=kTRUE) const;
41 AliTPCCalibQAChecker* NextSubChecker();
42 Int_t GetNumberOfSubCheckers(Bool_t recursive=kTRUE) const;
43 Bool_t HasSubCheckers() const {return GetNumberOfSubCheckers(kFALSE)>0;}
44
45 void AddSubChecker(AliTPCCalibQAChecker *alarm);
46
47 //getters
48 void GetAlarmThreshold(Double_t &min, Double_t &max, QualityFlag_t quality=kERROR) const {min=fThresMin[quality]; max=fThresMax[quality];}
49 //
50 const char* GetDrawString() { return fStrDraw.Data(); }
51 const char* GetCutsString() { return fStrCuts.Data(); }
52 const char* GetDrawOptString() {return fStrDrawOpt.Data(); }
53
54 //tree related
55 void SetDrawRepresentation(const char *draw, const char* drawOpt="") {fStrDrawRep=draw; fStrDrawRepOpt=drawOpt;}
56 void SetDrawAlarm(const char *draw, const char* drawOpt="") {fStrDraw=draw; fStrDrawOpt=drawOpt;}
57 void SetCutString(const char *cutString ) {fStrCuts=cutString;}
58
59 //general thresholds for the different qualities
60 void SetAlarmThreshold(const Double_t min, const Double_t max, const QualityFlag_t quality=kERROR);
61 void ResetAlarmThreshold(const QualityFlag_t quality);
62 void ResetAlarmThresholds();
63
64 //descriptions
65 void SetQualityDescription(const char* text, const QualityFlag_t quality=kERROR);
66
67 //alarm type
68 void SetAlarmType(AlarmType_t type) {fAlarmType=type;}
69
70
71 QualityFlag_t GetQuality() const {return fQualityLevel;}
72 Color_t GetQualityColor() const {return AliTPCCalibQAChecker::QualityColor(fQualityLevel);}
73 const char* GetQualityName() const {return AliTPCCalibQAChecker::QualityName(fQualityLevel);}
74 const char* GetQualityDescription() const { return QualityDescription(fQualityLevel);}
75
76 static const char* QualityName(const AliTPCCalibQAChecker::QualityFlag_t quality);
77 static Color_t QualityColor(const AliTPCCalibQAChecker::QualityFlag_t quality);
78 const char* QualityDescription(const QualityFlag_t quality) const;
79
80 virtual void Draw(Option_t *option="");
81 virtual void Print(Option_t *option="") const;
82
83 private:
84 //alarm decision variables
85 TTree **fTreePtr; //! Pointer to the Tree pointer
86 TH1 **fHistPtr; //! Pointer to the hist pointer
87 TGraph **fGraphPtr; //! Pointer to the graph pointer
88 Double_t *fNumberPtr; //! Pointer to number
89 TH1 *fHist; //! Hist pointer for tree processing
90
91 TIterator *fIterSubCheckers; //! iterator over sub checkers
92
93 TObjArray *fArrSubCheckers; //array with checkers to process
94 TObjArray *fArrAlarmDescriptions; //array with alarm descriptions
95
96 TString fStrDrawRep; //draw string for representation histogram to visualise
97 TString fStrDrawRepOpt; //draw option for representation histogram
98
99 TString fStrDraw; //draw string for alarm histogram
100 TString fStrDrawOpt; //draw option for alarm histogram
101
102 TString fStrCuts; //cut string
103
104 AlarmType_t fAlarmType; //type of the alarm
105 QualityFlag_t fQualityLevel; //quality level
106
107 TObject* fHistRep; //visualised histogram
108
109 Double_t fThresMin[kNQualityFlags];//minimum thresholds
110 Double_t fThresMax[kNQualityFlags];//maximum thresholds
111
112 void CreateRepresentationHist();
113 void ResetRepresentationHist() {if (fHistRep) {delete fHistRep; fHistRep=0x0;}}
114 //general processing
115 void ProcessTree();
116 void ProcessHist();
117 void ProcessGraph();
118 void ProcessNumber();
119 void ProcessSub();
120 //special processing
121 void ProcessEntries();
122 void ProcessMean();
123 void ProcessBin();
124 //
125 void CreateAlarmHist();
126 void ResetAlarmHist();
127 //
128 Int_t DrawInPad(TVirtualPad *pad, Int_t sub=1);
129 void DrawSubNodes(Option_t *option);
130 void DrawRepresentationHist(const Option_t *option);
131 void AddQualityLines(TH1 *hist);
132 //
133 AliTPCCalibQAChecker(const AliTPCCalibQAChecker &cfg);
134 AliTPCCalibQAChecker& operator = (const AliTPCCalibQAChecker &cfg);
135
136 QualityFlag_t GetQuality(Double_t value) const;
137 QualityFlag_t GetQuality(Int_t n, const Double_t *arr) const;
138
139 ClassDef(AliTPCCalibQAChecker,1);
140};
141
142//
143//inline functions
144//
145
146//_________________________________________________________________________
147inline AliTPCCalibQAChecker::QualityFlag_t AliTPCCalibQAChecker::GetQuality(Double_t value) const
148{
149 //
150 // check quality of a value
151 //
152
153 QualityFlag_t quality=kINFO;
154 //loop over Quality levels
155 for (Int_t i=(Int_t)kINFO; i<kNQualityFlags; ++i){
156 if (fThresMin[i]>=fThresMax[i]) continue;
157 if (value<fThresMin[i]||value>fThresMax[i]) quality=(QualityFlag_t)i;
158 }
159 return quality;
160}
161//_________________________________________________________________________
162inline AliTPCCalibQAChecker::QualityFlag_t AliTPCCalibQAChecker::GetQuality(Int_t n, const Double_t *arr) const
163{
164 //
165 // check quality of an array
166 //
167
168 QualityFlag_t quality=kINFO;
169 //loop over Quality levels
170 for (Int_t i=(Int_t)kINFO; i<kNQualityFlags; ++i){
171 if (fThresMin[i]>=fThresMax[i]) continue;
172 for (Int_t ientry=0; ientry<n; ++ientry){
173 Double_t value=arr[ientry];
174 if (value<fThresMin[i]||value>fThresMax[i]) quality=(QualityFlag_t)i;
175 }
176 }
177 return quality;
178}
179
180#endif