1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 ////////////////////////////////////////////////////////////////////////////
17 // QA histogram viewer
18 // scans the current directory fro files with QA
21 // origin: Mikolaj Krzewicki, Nikhef, Mikolaj.Krzewicki@cern.ch
23 ///////////////////////////////////////////////////////////////////////////
25 #include <TApplication.h>
29 #include <TRootEmbeddedCanvas.h>
30 #include <TGStatusBar.h>
35 #include <TGComboBox.h>
37 #include "AliQAHistNavigator.h"
38 #include "AliQAHistViewer.h"
40 ClassImp(AliQAHistViewer)
42 //_________________________________________________________________________
43 void AliQAHistViewer::DoDrawNext()
50 oldDirStr = fQANavigator->GetDirName();
52 UpdateAllPathComboBoxes();
54 TCanvas *c1 = fEcan->GetCanvas();
56 c1->Divide(rows,cols);
57 for (Int_t i=1; i<=rows*cols;i++)
59 newDirStr = fQANavigator->GetDirName();
60 if (newDirStr!=oldDirStr)
67 if (fQANavigator->GetHistogram(hist))
69 if (hist) hist->Draw();
71 if (!fQANavigator->Next())
80 //_________________________________________________________________________
81 void AliQAHistViewer::DoDrawPrev()
83 //draw previous histogram
88 oldDirStr = fQANavigator->GetDirName();
90 UpdateAllPathComboBoxes();
92 TCanvas *c1 = fEcan->GetCanvas();
94 c1->Divide(rows,cols);
95 for (Int_t i=1; i<=rows*cols;i++)
97 newDirStr = fQANavigator->GetDirName();
98 if (newDirStr!=oldDirStr)
105 if (fQANavigator->GetHistogram(hist))
107 if (hist) hist->Draw();
109 if (!fQANavigator->Prev())
118 //_________________________________________________________________________
119 void AliQAHistViewer::DoExit()
122 printf("Exit application...");
123 gApplication->Terminate(0);
126 //_________________________________________________________________________
127 AliQAHistViewer::AliQAHistViewer(const TGWindow *p, UInt_t w, UInt_t h, Bool_t embed) :
128 TGMainFrame(p, w, h),
130 fQANavigator(new AliQAHistNavigator()),
132 fDetectorListBox(NULL),
138 //initialize the QA navigator
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();
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*)");
171 AddFrame(fEcan, new TGLayoutHints(kLHintsTop | kLHintsLeft |
172 kLHintsExpandX | kLHintsExpandY,0,0,1,1));
174 // Create a horizontal frame containing the buttons
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));
182 AddFrame(hframebuttons, new TGLayoutHints(kLHintsCenterX, 2, 2, 2, 2));
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));
191 // Set a name to the main frame
192 SetWindowName("Quality Assurance Monitoring");
195 // Initialize the layout algorithm via Resize()
196 Resize(GetDefaultSize());
203 //_________________________________________________________________________
204 AliQAHistViewer::~AliQAHistViewer()
206 // Clean up main frame...
212 //_________________________________________________________________________
213 void AliQAHistViewer::FillComboBoxWithListEntries( TGComboBox* box, const TList* list )
215 //fill the combobox with list entries
218 TIter listiter(list);
220 while ((o = (TObject*)listiter.Next()))
222 TString name = o->GetName();
223 box->AddEntry( name.Data(), i++ );
227 //_________________________________________________________________________
228 void AliQAHistViewer::UpdateAllPathComboBoxes()
230 //make gui elements up to date
231 if (!fQANavigator->InitOK()) return;
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);
242 //_________________________________________________________________________
243 void AliQAHistViewer::DoSetFile( Int_t s )
245 //set file from user choice
246 fQANavigator->SetFile(s);
250 //_________________________________________________________________________
251 void AliQAHistViewer::DoSetDetector( Int_t s )
253 //set detector number from user choice
254 fQANavigator->SetDetector(s);
258 //_________________________________________________________________________
259 void AliQAHistViewer::DoSetLevel( Int_t s )
262 fQANavigator->SetLevel(s);
266 //_________________________________________________________________________
267 void AliQAHistViewer::DoSetHistogram( Int_t s )
270 fQANavigator->SetItem(s);
274 //_________________________________________________________________________
275 void AliQAHistViewer::DoSetExpertMode(Bool_t mode)
278 fQANavigator->SetExpertMode(mode);