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 **************************************************************************/
16 ////////////////////////////////////////////////////////////////////////////
18 // QA histogram viewer
20 // origin: Mikolaj Krzewicki, Nikhef, Mikolaj.Krzewicki@cern.ch
22 ///////////////////////////////////////////////////////////////////////////
24 #include "AliQAHistViewer.h"
26 ClassImp(AliQAHistViewer)
28 //_________________________________________________________________________
29 void AliQAHistViewer::DoDrawNext()
35 oldDirStr = fQANavigator->GetDirName();
37 UpdateAllPathComboBoxes();
39 TCanvas *c1 = fEcan->GetCanvas();
41 c1->Divide(rows,cols);
42 for (Int_t i=1; i<=rows*cols;i++)
44 newDirStr = fQANavigator->GetDirName();
45 if (newDirStr!=oldDirStr)
52 if (fQANavigator->GetHistogram(hist))
54 if (hist) hist->Draw();
56 if (!fQANavigator->Next())
64 //_________________________________________________________________________
65 void AliQAHistViewer::DoDrawPrev()
71 oldDirStr = fQANavigator->GetDirName();
73 UpdateAllPathComboBoxes();
75 TCanvas *c1 = fEcan->GetCanvas();
77 c1->Divide(rows,cols);
78 for (Int_t i=1; i<=rows*cols;i++)
80 newDirStr = fQANavigator->GetDirName();
81 if (newDirStr!=oldDirStr)
88 if (fQANavigator->GetHistogram(hist))
90 if (hist) hist->Draw();
92 if (!fQANavigator->Prev())
100 //_________________________________________________________________________
101 void AliQAHistViewer::DoExit()
103 printf("Exit application...");
104 gApplication->Terminate(0);
107 //_________________________________________________________________________
108 AliQAHistViewer::AliQAHistViewer(const TGWindow *p, UInt_t w, UInt_t h, Bool_t embed) :
109 TGMainFrame(p, w, h),
111 fQANavigator(new AliQAHistNavigator()),
113 fDetectorListBox(NULL),
119 //initialize the QA navigator
120 // horizontal frame with comboboxes for navigation
121 TGHorizontalFrame *hframenav = new TGHorizontalFrame(this, 200,40);
122 fFileListBox = new TGComboBox(hframenav);
123 fFileListBox->Connect("Selected(Int_t)", "AliQAHistViewer", this, "DoSetFile(Int_t)");
124 fFileListBox->Resize(150,20);
125 hframenav->AddFrame(fFileListBox, new TGLayoutHints(kLHintsExpandY|kLHintsLeft));
126 fDetectorListBox = new TGComboBox(hframenav);
127 fDetectorListBox->Connect("Selected(Int_t)", "AliQAHistViewer", this, "DoSetDetector(Int_t)");
128 fDetectorListBox->Resize(100,20);
129 hframenav->AddFrame(fDetectorListBox, new TGLayoutHints(kLHintsLeft));
130 fLevelListBox = new TGComboBox(hframenav);
131 fLevelListBox->Connect("Selected(Int_t)", "AliQAHistViewer", this, "DoSetLevel(Int_t)");
132 fLevelListBox->Resize(100,20);
133 hframenav->AddFrame(fLevelListBox, new TGLayoutHints(kLHintsLeft));
134 fHistListBox = new TGComboBox(hframenav);
135 fHistListBox->Connect("Selected(Int_t)", "AliQAHistViewer", this, "DoSetHistogram(Int_t)");
136 fHistListBox->Resize(250,20);
137 hframenav->AddFrame(fHistListBox, new TGLayoutHints(kLHintsLeft));
138 AddFrame(hframenav, new TGLayoutHints((kLHintsLeft|kLHintsExpandX), 5,5,5,5));
139 UpdateAllPathComboBoxes();
140 fExpertMode = new TGCheckButton(hframenav,"Expert");
141 hframenav->AddFrame(fExpertMode,new TGLayoutHints(kLHintsLeft, 0, 4, 3, 0));
142 fExpertMode->SetToolTipText("Show expert histograms");
143 fExpertMode->Connect("Toggled(Bool_t)", "AliQAHistViewer", this, "DoSetExpertMode(Bool_t)");
144 // Create the embedded canvas
145 fEcan = new TRootEmbeddedCanvas(0,this,800,600);
146 Int_t wid = fEcan->GetCanvasWindowId();
147 TCanvas *myc = new TCanvas("MyCanvas", 10,10,wid);
148 fEcan->AdoptCanvas(myc);
149 //myc->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)","AliQAHistViewer",this,
150 // "EventInfo(Int_t,Int_t,Int_t,TObject*)");
152 AddFrame(fEcan, new TGLayoutHints(kLHintsTop | kLHintsLeft |
153 kLHintsExpandX | kLHintsExpandY,0,0,1,1));
155 // Create a horizontal frame containing the buttons
156 TGHorizontalFrame *hframebuttons = new TGHorizontalFrame(this, 200, 40);
157 TGTextButton *prev = new TGTextButton(hframebuttons, "&Prev");
158 prev->Connect("Clicked()", "AliQAHistViewer", this, "DoDrawPrev()");
159 hframebuttons->AddFrame(prev, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4));
160 TGTextButton *next = new TGTextButton(hframebuttons, "&Next");
161 next->Connect("Clicked()", "AliQAHistViewer", this, "DoDrawNext()");
162 hframebuttons->AddFrame(next, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4));
163 AddFrame(hframebuttons, new TGLayoutHints(kLHintsCenterX, 2, 2, 2, 2));
167 TGTextButton *exit = new TGTextButton(hframebuttons, "&Exit ");
168 exit->Connect("Pressed()", "AliQAHistViewer", this, "DoExit()");
169 hframebuttons->AddFrame(exit, new TGLayoutHints(kLHintsRight, 5, 5, 3, 4));
172 // Set a name to the main frame
173 SetWindowName("Quality Assurance Monitoring");
176 // Initialize the layout algorithm via Resize()
177 Resize(GetDefaultSize());
184 //_________________________________________________________________________
185 AliQAHistViewer::~AliQAHistViewer()
187 // Clean up main frame...
193 //_________________________________________________________________________
194 void AliQAHistViewer::FillComboBoxWithListEntries( TGComboBox* box, const TList* list )
198 TIter listiter(list);
200 while ((o = (TObject*)listiter.Next()))
202 TString name = o->GetName();
203 box->AddEntry( name.Data(), i++ );
207 //_________________________________________________________________________
208 void AliQAHistViewer::UpdateAllPathComboBoxes()
210 if (!fQANavigator->InitOK()) return;
211 FillComboBoxWithListEntries( fFileListBox, (TList*)fQANavigator->GetFileList()->GetDirs() );
212 FillComboBoxWithListEntries( fDetectorListBox, (TList*)fQANavigator->GetDetectorList()->GetDirs() );
213 FillComboBoxWithListEntries( fLevelListBox, (TList*)fQANavigator->GetLevelList()->GetDirs() );
214 FillComboBoxWithListEntries( fHistListBox, (TList*)fQANavigator->GetItemList() );
215 fFileListBox->Select(fQANavigator->GetCurrListOfFiles()->GetDirs()->IndexOf(fQANavigator->GetCurrFile()),kFALSE);
216 fDetectorListBox->Select(fQANavigator->GetCurrFile()->GetDirs()->IndexOf(fQANavigator->GetCurrDetector()),kFALSE);
217 fLevelListBox->Select(fQANavigator->GetCurrDetector()->GetDirs()->IndexOf(fQANavigator->GetCurrLevel()),kFALSE);
218 fHistListBox->Select(fQANavigator->GetItemList()->IndexOf(fQANavigator->GetCurrItem()),kFALSE);
221 //_________________________________________________________________________
222 void AliQAHistViewer::DoSetFile( Int_t s )
224 fQANavigator->SetFile(s);
228 //_________________________________________________________________________
229 void AliQAHistViewer::DoSetDetector( Int_t s )
231 fQANavigator->SetDetector(s);
235 //_________________________________________________________________________
236 void AliQAHistViewer::DoSetLevel( Int_t s )
238 fQANavigator->SetLevel(s);
242 //_________________________________________________________________________
243 void AliQAHistViewer::DoSetHistogram( Int_t s )
245 fQANavigator->SetItem(s);
249 //_________________________________________________________________________
250 void AliQAHistViewer::DoSetExpertMode(Bool_t mode)
252 fQANavigator->SetExpertMode(mode);