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