]>
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 | **************************************************************************/ | |
923f55ee | 15 | //////////////////////////////////////////////////////////////////////////// |
16 | // | |
17 | // QA histogram viewer | |
21535372 | 18 | // scans the current directory fro files with QA |
19 | // and plots them. | |
923f55ee | 20 | // |
21 | // origin: Mikolaj Krzewicki, Nikhef, Mikolaj.Krzewicki@cern.ch | |
22 | // | |
23 | /////////////////////////////////////////////////////////////////////////// | |
24 | ||
21535372 | 25 | #include <TApplication.h> |
26 | #include <TGButton.h> | |
27 | #include <TGFrame.h> | |
28 | #include <TFrame.h> | |
29 | #include <TRootEmbeddedCanvas.h> | |
30 | #include <TGStatusBar.h> | |
31 | #include <TCanvas.h> | |
32 | #include <TH1.h> | |
33 | #include <TF1.h> | |
34 | #include <TString.h> | |
35 | #include <TGComboBox.h> | |
36 | #include <TList.h> | |
37 | #include "AliQAHistNavigator.h" | |
923f55ee | 38 | #include "AliQAHistViewer.h" |
39 | ||
40 | ClassImp(AliQAHistViewer) | |
41 | ||
42 | //_________________________________________________________________________ | |
43 | void AliQAHistViewer::DoDrawNext() | |
44 | { | |
21535372 | 45 | //draw next histogram |
923f55ee | 46 | Int_t rows = 2; |
47 | Int_t cols = 2; | |
48 | TString oldDirStr; | |
49 | TString newDirStr; | |
50 | oldDirStr = fQANavigator->GetDirName(); | |
51 | ||
52 | UpdateAllPathComboBoxes(); | |
53 | ||
54 | TCanvas *c1 = fEcan->GetCanvas(); | |
55 | c1->Clear(); | |
56 | c1->Divide(rows,cols); | |
57 | for (Int_t i=1; i<=rows*cols;i++) | |
58 | { | |
59 | newDirStr = fQANavigator->GetDirName(); | |
60 | if (newDirStr!=oldDirStr) | |
61 | { | |
62 | oldDirStr=newDirStr; | |
63 | break; | |
64 | } | |
65 | c1->cd(i); | |
66 | TH1* hist; | |
d3a269ff | 67 | if (fQANavigator->GetHistogram(hist)) |
68 | { | |
69 | if (hist) hist->Draw(); | |
70 | } | |
923f55ee | 71 | if (!fQANavigator->Next()) |
72 | { | |
73 | break; | |
74 | } | |
75 | } | |
f92896b5 | 76 | c1->cd(0); |
923f55ee | 77 | c1->Update(); |
78 | } | |
79 | ||
80 | //_________________________________________________________________________ | |
81 | void AliQAHistViewer::DoDrawPrev() | |
82 | { | |
21535372 | 83 | //draw previous histogram |
923f55ee | 84 | Int_t rows = 2; |
85 | Int_t cols = 2; | |
86 | TString oldDirStr; | |
87 | TString newDirStr; | |
88 | oldDirStr = fQANavigator->GetDirName(); | |
89 | ||
90 | UpdateAllPathComboBoxes(); | |
91 | ||
92 | TCanvas *c1 = fEcan->GetCanvas(); | |
93 | c1->Clear(); | |
94 | c1->Divide(rows,cols); | |
95 | for (Int_t i=1; i<=rows*cols;i++) | |
96 | { | |
97 | newDirStr = fQANavigator->GetDirName(); | |
98 | if (newDirStr!=oldDirStr) | |
99 | { | |
100 | oldDirStr=newDirStr; | |
101 | break; | |
102 | } | |
103 | c1->cd(i); | |
104 | TH1* hist; | |
d3a269ff | 105 | if (fQANavigator->GetHistogram(hist)) |
106 | { | |
107 | if (hist) hist->Draw(); | |
108 | } | |
923f55ee | 109 | if (!fQANavigator->Prev()) |
110 | { | |
111 | break; | |
112 | } | |
113 | } | |
f92896b5 | 114 | c1->cd(0); |
923f55ee | 115 | c1->Update(); |
116 | } | |
117 | ||
118 | //_________________________________________________________________________ | |
119 | void AliQAHistViewer::DoExit() | |
120 | { | |
21535372 | 121 | //exit |
923f55ee | 122 | printf("Exit application..."); |
123 | gApplication->Terminate(0); | |
124 | } | |
125 | ||
126 | //_________________________________________________________________________ | |
127 | AliQAHistViewer::AliQAHistViewer(const TGWindow *p, UInt_t w, UInt_t h, Bool_t embed) : | |
39116cf0 | 128 | TGMainFrame(p, w, h), |
d3a269ff | 129 | fEcan(NULL), |
130 | fQANavigator(new AliQAHistNavigator()), | |
923f55ee | 131 | fFileListBox(NULL), |
132 | fDetectorListBox(NULL), | |
133 | fLevelListBox(NULL), | |
134 | fHistListBox(NULL), | |
d3a269ff | 135 | fExpertMode(NULL), |
923f55ee | 136 | fIsEmbedded(embed) |
137 | { | |
138 | //initialize the QA navigator | |
923f55ee | 139 | // horizontal frame with comboboxes for navigation |
140 | TGHorizontalFrame *hframenav = new TGHorizontalFrame(this, 200,40); | |
141 | fFileListBox = new TGComboBox(hframenav); | |
142 | fFileListBox->Connect("Selected(Int_t)", "AliQAHistViewer", this, "DoSetFile(Int_t)"); | |
143 | fFileListBox->Resize(150,20); | |
144 | hframenav->AddFrame(fFileListBox, new TGLayoutHints(kLHintsExpandY|kLHintsLeft)); | |
145 | fDetectorListBox = new TGComboBox(hframenav); | |
146 | fDetectorListBox->Connect("Selected(Int_t)", "AliQAHistViewer", this, "DoSetDetector(Int_t)"); | |
147 | fDetectorListBox->Resize(100,20); | |
148 | hframenav->AddFrame(fDetectorListBox, new TGLayoutHints(kLHintsLeft)); | |
149 | fLevelListBox = new TGComboBox(hframenav); | |
150 | fLevelListBox->Connect("Selected(Int_t)", "AliQAHistViewer", this, "DoSetLevel(Int_t)"); | |
151 | fLevelListBox->Resize(100,20); | |
152 | hframenav->AddFrame(fLevelListBox, new TGLayoutHints(kLHintsLeft)); | |
153 | fHistListBox = new TGComboBox(hframenav); | |
154 | fHistListBox->Connect("Selected(Int_t)", "AliQAHistViewer", this, "DoSetHistogram(Int_t)"); | |
155 | fHistListBox->Resize(250,20); | |
156 | hframenav->AddFrame(fHistListBox, new TGLayoutHints(kLHintsLeft)); | |
157 | AddFrame(hframenav, new TGLayoutHints((kLHintsLeft|kLHintsExpandX), 5,5,5,5)); | |
158 | UpdateAllPathComboBoxes(); | |
d3a269ff | 159 | fExpertMode = new TGCheckButton(hframenav,"Expert"); |
160 | hframenav->AddFrame(fExpertMode,new TGLayoutHints(kLHintsLeft, 0, 4, 3, 0)); | |
161 | fExpertMode->SetToolTipText("Show expert histograms"); | |
162 | fExpertMode->Connect("Toggled(Bool_t)", "AliQAHistViewer", this, "DoSetExpertMode(Bool_t)"); | |
163 | // Create the embedded canvas | |
164 | fEcan = new TRootEmbeddedCanvas(0,this,800,600); | |
165 | Int_t wid = fEcan->GetCanvasWindowId(); | |
166 | TCanvas *myc = new TCanvas("MyCanvas", 10,10,wid); | |
167 | fEcan->AdoptCanvas(myc); | |
168 | //myc->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)","AliQAHistViewer",this, | |
169 | // "EventInfo(Int_t,Int_t,Int_t,TObject*)"); | |
170 | ||
171 | AddFrame(fEcan, new TGLayoutHints(kLHintsTop | kLHintsLeft | | |
172 | kLHintsExpandX | kLHintsExpandY,0,0,1,1)); | |
173 | ||
174 | // Create a horizontal frame containing the buttons | |
923f55ee | 175 | TGHorizontalFrame *hframebuttons = new TGHorizontalFrame(this, 200, 40); |
176 | TGTextButton *prev = new TGTextButton(hframebuttons, "&Prev"); | |
177 | prev->Connect("Clicked()", "AliQAHistViewer", this, "DoDrawPrev()"); | |
178 | hframebuttons->AddFrame(prev, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4)); | |
179 | TGTextButton *next = new TGTextButton(hframebuttons, "&Next"); | |
180 | next->Connect("Clicked()", "AliQAHistViewer", this, "DoDrawNext()"); | |
181 | hframebuttons->AddFrame(next, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4)); | |
d3a269ff | 182 | AddFrame(hframebuttons, new TGLayoutHints(kLHintsCenterX, 2, 2, 2, 2)); |
183 | ||
923f55ee | 184 | if ((!fIsEmbedded)) |
185 | { | |
186 | TGTextButton *exit = new TGTextButton(hframebuttons, "&Exit "); | |
187 | exit->Connect("Pressed()", "AliQAHistViewer", this, "DoExit()"); | |
188 | hframebuttons->AddFrame(exit, new TGLayoutHints(kLHintsRight, 5, 5, 3, 4)); | |
189 | } | |
923f55ee | 190 | |
191 | // Set a name to the main frame | |
192 | SetWindowName("Quality Assurance Monitoring"); | |
193 | MapSubwindows(); | |
194 | ||
195 | // Initialize the layout algorithm via Resize() | |
196 | Resize(GetDefaultSize()); | |
197 | ||
198 | // Map main frame | |
199 | MapWindow(); | |
200 | DoDrawNext(); | |
201 | } | |
202 | ||
203 | //_________________________________________________________________________ | |
204 | AliQAHistViewer::~AliQAHistViewer() | |
205 | { | |
206 | // Clean up main frame... | |
207 | Cleanup(); | |
461ab3a0 | 208 | // if(fEcan) delete fEcan; fEcan = 0; |
209 | if(fQANavigator) delete fQANavigator; fQANavigator = 0; | |
923f55ee | 210 | } |
211 | ||
212 | //_________________________________________________________________________ | |
213 | void AliQAHistViewer::FillComboBoxWithListEntries( TGComboBox* box, const TList* list ) | |
214 | { | |
21535372 | 215 | //fill the combobox with list entries |
923f55ee | 216 | box->RemoveAll(); |
217 | Int_t i=0; | |
218 | TIter listiter(list); | |
219 | TObject* o = NULL; | |
220 | while ((o = (TObject*)listiter.Next())) | |
221 | { | |
222 | TString name = o->GetName(); | |
223 | box->AddEntry( name.Data(), i++ ); | |
224 | } | |
225 | } | |
226 | ||
227 | //_________________________________________________________________________ | |
228 | void AliQAHistViewer::UpdateAllPathComboBoxes() | |
229 | { | |
21535372 | 230 | //make gui elements up to date |
7b852582 | 231 | if (!fQANavigator->InitOK()) return; |
d3a269ff | 232 | FillComboBoxWithListEntries( fFileListBox, (TList*)fQANavigator->GetFileList()->GetDirs() ); |
233 | FillComboBoxWithListEntries( fDetectorListBox, (TList*)fQANavigator->GetDetectorList()->GetDirs() ); | |
234 | FillComboBoxWithListEntries( fLevelListBox, (TList*)fQANavigator->GetLevelList()->GetDirs() ); | |
235 | FillComboBoxWithListEntries( fHistListBox, (TList*)fQANavigator->GetItemList() ); | |
236 | fFileListBox->Select(fQANavigator->GetCurrListOfFiles()->GetDirs()->IndexOf(fQANavigator->GetCurrFile()),kFALSE); | |
237 | fDetectorListBox->Select(fQANavigator->GetCurrFile()->GetDirs()->IndexOf(fQANavigator->GetCurrDetector()),kFALSE); | |
238 | fLevelListBox->Select(fQANavigator->GetCurrDetector()->GetDirs()->IndexOf(fQANavigator->GetCurrLevel()),kFALSE); | |
239 | fHistListBox->Select(fQANavigator->GetItemList()->IndexOf(fQANavigator->GetCurrItem()),kFALSE); | |
923f55ee | 240 | } |
241 | ||
242 | //_________________________________________________________________________ | |
243 | void AliQAHistViewer::DoSetFile( Int_t s ) | |
244 | { | |
21535372 | 245 | //set file from user choice |
923f55ee | 246 | fQANavigator->SetFile(s); |
247 | DoDrawNext(); | |
248 | } | |
249 | ||
250 | //_________________________________________________________________________ | |
251 | void AliQAHistViewer::DoSetDetector( Int_t s ) | |
252 | { | |
21535372 | 253 | //set detector number from user choice |
923f55ee | 254 | fQANavigator->SetDetector(s); |
255 | DoDrawNext(); | |
256 | } | |
257 | ||
258 | //_________________________________________________________________________ | |
259 | void AliQAHistViewer::DoSetLevel( Int_t s ) | |
260 | { | |
21535372 | 261 | //set QA level |
923f55ee | 262 | fQANavigator->SetLevel(s); |
263 | DoDrawNext(); | |
264 | } | |
265 | ||
266 | //_________________________________________________________________________ | |
267 | void AliQAHistViewer::DoSetHistogram( Int_t s ) | |
268 | { | |
21535372 | 269 | //set histogram |
d3a269ff | 270 | fQANavigator->SetItem(s); |
271 | DoDrawNext(); | |
272 | } | |
273 | ||
274 | //_________________________________________________________________________ | |
275 | void AliQAHistViewer::DoSetExpertMode(Bool_t mode) | |
276 | { | |
21535372 | 277 | //set expert mode |
d3a269ff | 278 | fQANavigator->SetExpertMode(mode); |
923f55ee | 279 | DoDrawNext(); |
280 | } |