]>
Commit | Line | Data |
---|---|---|
923f55ee | 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 | // | |
18 | // QA histogram viewer | |
19 | // | |
20 | // origin: Mikolaj Krzewicki, Nikhef, Mikolaj.Krzewicki@cern.ch | |
21 | // | |
22 | /////////////////////////////////////////////////////////////////////////// | |
23 | ||
24 | #include "AliQAHistViewer.h" | |
25 | ||
26 | ClassImp(AliQAHistViewer) | |
27 | ||
28 | //_________________________________________________________________________ | |
29 | void AliQAHistViewer::DoDrawNext() | |
30 | { | |
31 | Int_t rows = 2; | |
32 | Int_t cols = 2; | |
33 | TString oldDirStr; | |
34 | TString newDirStr; | |
35 | oldDirStr = fQANavigator->GetDirName(); | |
36 | ||
37 | UpdateAllPathComboBoxes(); | |
38 | ||
39 | TCanvas *c1 = fEcan->GetCanvas(); | |
40 | c1->Clear(); | |
41 | c1->Divide(rows,cols); | |
42 | for (Int_t i=1; i<=rows*cols;i++) | |
43 | { | |
44 | newDirStr = fQANavigator->GetDirName(); | |
45 | if (newDirStr!=oldDirStr) | |
46 | { | |
47 | oldDirStr=newDirStr; | |
48 | break; | |
49 | } | |
50 | c1->cd(i); | |
51 | TH1* hist; | |
52 | if (!fQANavigator->GetHistogram(hist)) break; | |
53 | if (hist) hist->Draw(); | |
54 | else continue; | |
55 | if (!fQANavigator->Next()) | |
56 | { | |
57 | break; | |
58 | } | |
59 | } | |
60 | c1->Update(); | |
61 | } | |
62 | ||
63 | //_________________________________________________________________________ | |
64 | void AliQAHistViewer::DoDrawPrev() | |
65 | { | |
66 | Int_t rows = 2; | |
67 | Int_t cols = 2; | |
68 | TString oldDirStr; | |
69 | TString newDirStr; | |
70 | oldDirStr = fQANavigator->GetDirName(); | |
71 | ||
72 | UpdateAllPathComboBoxes(); | |
73 | ||
74 | TCanvas *c1 = fEcan->GetCanvas(); | |
75 | c1->Clear(); | |
76 | c1->Divide(rows,cols); | |
77 | for (Int_t i=1; i<=rows*cols;i++) | |
78 | { | |
79 | newDirStr = fQANavigator->GetDirName(); | |
80 | if (newDirStr!=oldDirStr) | |
81 | { | |
82 | oldDirStr=newDirStr; | |
83 | break; | |
84 | } | |
85 | c1->cd(i); | |
86 | TH1* hist; | |
87 | if (!fQANavigator->GetHistogram(hist)) break; | |
88 | if (hist) hist->Draw(); | |
89 | else continue; | |
90 | if (!fQANavigator->Prev()) | |
91 | { | |
92 | break; | |
93 | } | |
94 | } | |
95 | c1->Update(); | |
96 | } | |
97 | ||
98 | //_________________________________________________________________________ | |
99 | void AliQAHistViewer::DoExit() | |
100 | { | |
101 | printf("Exit application..."); | |
102 | gApplication->Terminate(0); | |
103 | } | |
104 | ||
105 | //_________________________________________________________________________ | |
106 | AliQAHistViewer::AliQAHistViewer(const TGWindow *p, UInt_t w, UInt_t h, Bool_t embed) : | |
107 | TGMainFrame(p, w, h), | |
108 | fFileListBox(NULL), | |
109 | fDetectorListBox(NULL), | |
110 | fLevelListBox(NULL), | |
111 | fHistListBox(NULL), | |
112 | fIsEmbedded(embed) | |
113 | { | |
114 | //initialize the QA navigator | |
115 | fQANavigator = new AliQAHistNavigator(); | |
116 | // Create the embedded canvas | |
117 | fEcan = new TRootEmbeddedCanvas(0,this,800,600); | |
118 | Int_t wid = fEcan->GetCanvasWindowId(); | |
119 | TCanvas *myc = new TCanvas("MyCanvas", 10,10,wid); | |
120 | fEcan->AdoptCanvas(myc); | |
121 | //myc->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)","AliQAHistViewer",this, | |
122 | // "EventInfo(Int_t,Int_t,Int_t,TObject*)"); | |
123 | ||
124 | AddFrame(fEcan, new TGLayoutHints(kLHintsTop | kLHintsLeft | | |
125 | kLHintsExpandX | kLHintsExpandY,0,0,1,1)); | |
126 | ||
127 | // horizontal frame with comboboxes for navigation | |
128 | TGHorizontalFrame *hframenav = new TGHorizontalFrame(this, 200,40); | |
129 | fFileListBox = new TGComboBox(hframenav); | |
130 | fFileListBox->Connect("Selected(Int_t)", "AliQAHistViewer", this, "DoSetFile(Int_t)"); | |
131 | fFileListBox->Resize(150,20); | |
132 | hframenav->AddFrame(fFileListBox, new TGLayoutHints(kLHintsExpandY|kLHintsLeft)); | |
133 | fDetectorListBox = new TGComboBox(hframenav); | |
134 | fDetectorListBox->Connect("Selected(Int_t)", "AliQAHistViewer", this, "DoSetDetector(Int_t)"); | |
135 | fDetectorListBox->Resize(100,20); | |
136 | hframenav->AddFrame(fDetectorListBox, new TGLayoutHints(kLHintsLeft)); | |
137 | fLevelListBox = new TGComboBox(hframenav); | |
138 | fLevelListBox->Connect("Selected(Int_t)", "AliQAHistViewer", this, "DoSetLevel(Int_t)"); | |
139 | fLevelListBox->Resize(100,20); | |
140 | hframenav->AddFrame(fLevelListBox, new TGLayoutHints(kLHintsLeft)); | |
141 | fHistListBox = new TGComboBox(hframenav); | |
142 | fHistListBox->Connect("Selected(Int_t)", "AliQAHistViewer", this, "DoSetHistogram(Int_t)"); | |
143 | fHistListBox->Resize(250,20); | |
144 | hframenav->AddFrame(fHistListBox, new TGLayoutHints(kLHintsLeft)); | |
145 | AddFrame(hframenav, new TGLayoutHints((kLHintsLeft|kLHintsExpandX), 5,5,5,5)); | |
146 | UpdateAllPathComboBoxes(); | |
147 | // Create a horizontal frame containing two buttons | |
148 | TGHorizontalFrame *hframebuttons = new TGHorizontalFrame(this, 200, 40); | |
149 | TGTextButton *prev = new TGTextButton(hframebuttons, "&Prev"); | |
150 | prev->Connect("Clicked()", "AliQAHistViewer", this, "DoDrawPrev()"); | |
151 | hframebuttons->AddFrame(prev, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4)); | |
152 | TGTextButton *next = new TGTextButton(hframebuttons, "&Next"); | |
153 | next->Connect("Clicked()", "AliQAHistViewer", this, "DoDrawNext()"); | |
154 | hframebuttons->AddFrame(next, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4)); | |
155 | if ((!fIsEmbedded)) | |
156 | { | |
157 | TGTextButton *exit = new TGTextButton(hframebuttons, "&Exit "); | |
158 | exit->Connect("Pressed()", "AliQAHistViewer", this, "DoExit()"); | |
159 | hframebuttons->AddFrame(exit, new TGLayoutHints(kLHintsRight, 5, 5, 3, 4)); | |
160 | } | |
161 | AddFrame(hframebuttons, new TGLayoutHints(kLHintsCenterX, 2, 2, 2, 2)); | |
162 | ||
163 | // Set a name to the main frame | |
164 | SetWindowName("Quality Assurance Monitoring"); | |
165 | MapSubwindows(); | |
166 | ||
167 | // Initialize the layout algorithm via Resize() | |
168 | Resize(GetDefaultSize()); | |
169 | ||
170 | // Map main frame | |
171 | MapWindow(); | |
172 | DoDrawNext(); | |
173 | } | |
174 | ||
175 | //_________________________________________________________________________ | |
176 | AliQAHistViewer::~AliQAHistViewer() | |
177 | { | |
178 | // Clean up main frame... | |
179 | Cleanup(); | |
180 | delete fEcan; | |
181 | delete fQANavigator; | |
182 | } | |
183 | ||
184 | //_________________________________________________________________________ | |
185 | void AliQAHistViewer::FillComboBoxWithListEntries( TGComboBox* box, const TList* list ) | |
186 | { | |
187 | box->RemoveAll(); | |
188 | Int_t i=0; | |
189 | TIter listiter(list); | |
190 | TObject* o = NULL; | |
191 | while ((o = (TObject*)listiter.Next())) | |
192 | { | |
193 | TString name = o->GetName(); | |
194 | box->AddEntry( name.Data(), i++ ); | |
195 | } | |
196 | } | |
197 | ||
198 | //_________________________________________________________________________ | |
199 | void AliQAHistViewer::UpdateAllPathComboBoxes() | |
200 | { | |
201 | FillComboBoxWithListEntries( fFileListBox, fQANavigator->GetFileList() ); | |
202 | FillComboBoxWithListEntries( fDetectorListBox, fQANavigator->GetDetectorList() ); | |
203 | FillComboBoxWithListEntries( fLevelListBox, fQANavigator->GetLevelList() ); | |
204 | FillComboBoxWithListEntries( fHistListBox, fQANavigator->GetHistList() ); | |
205 | fFileListBox->Select(fQANavigator->GetCurrListOfFiles()->IndexOf(fQANavigator->GetCurrFile()),kFALSE); | |
206 | fDetectorListBox->Select(fQANavigator->GetCurrFile()->IndexOf(fQANavigator->GetCurrDetector()),kFALSE); | |
207 | fLevelListBox->Select(fQANavigator->GetCurrDetector()->IndexOf(fQANavigator->GetCurrLevel()),kFALSE); | |
208 | fHistListBox->Select(fQANavigator->GetCurrLevel()->IndexOf(fQANavigator->GetCurrHistName()),kFALSE); | |
209 | } | |
210 | ||
211 | //_________________________________________________________________________ | |
212 | void AliQAHistViewer::DoSetFile( Int_t s ) | |
213 | { | |
214 | fQANavigator->SetFile(s); | |
215 | DoDrawNext(); | |
216 | } | |
217 | ||
218 | //_________________________________________________________________________ | |
219 | void AliQAHistViewer::DoSetDetector( Int_t s ) | |
220 | { | |
221 | fQANavigator->SetDetector(s); | |
222 | DoDrawNext(); | |
223 | } | |
224 | ||
225 | //_________________________________________________________________________ | |
226 | void AliQAHistViewer::DoSetLevel( Int_t s ) | |
227 | { | |
228 | fQANavigator->SetLevel(s); | |
229 | DoDrawNext(); | |
230 | } | |
231 | ||
232 | //_________________________________________________________________________ | |
233 | void AliQAHistViewer::DoSetHistogram( Int_t s ) | |
234 | { | |
235 | fQANavigator->SetHist(s); | |
236 | DoDrawNext(); | |
237 | } |