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())
65 //_________________________________________________________________________
66 void AliQAHistViewer::DoDrawPrev()
72 oldDirStr = fQANavigator->GetDirName();
74 UpdateAllPathComboBoxes();
76 TCanvas *c1 = fEcan->GetCanvas();
78 c1->Divide(rows,cols);
79 for (Int_t i=1; i<=rows*cols;i++)
81 newDirStr = fQANavigator->GetDirName();
82 if (newDirStr!=oldDirStr)
89 if (fQANavigator->GetHistogram(hist))
91 if (hist) hist->Draw();
93 if (!fQANavigator->Prev())
102 //_________________________________________________________________________
103 void AliQAHistViewer::DoExit()
105 printf("Exit application...");
106 gApplication->Terminate(0);
109 //_________________________________________________________________________
110 AliQAHistViewer::AliQAHistViewer(const TGWindow *p, UInt_t w, UInt_t h, Bool_t embed) :
111 TGMainFrame(p, w, h),
113 fQANavigator(new AliQAHistNavigator()),
115 fDetectorListBox(NULL),
121 //initialize the QA navigator
122 // horizontal frame with comboboxes for navigation
123 TGHorizontalFrame *hframenav = new TGHorizontalFrame(this, 200,40);
124 fFileListBox = new TGComboBox(hframenav);
125 fFileListBox->Connect("Selected(Int_t)", "AliQAHistViewer", this, "DoSetFile(Int_t)");
126 fFileListBox->Resize(150,20);
127 hframenav->AddFrame(fFileListBox, new TGLayoutHints(kLHintsExpandY|kLHintsLeft));
128 fDetectorListBox = new TGComboBox(hframenav);
129 fDetectorListBox->Connect("Selected(Int_t)", "AliQAHistViewer", this, "DoSetDetector(Int_t)");
130 fDetectorListBox->Resize(100,20);
131 hframenav->AddFrame(fDetectorListBox, new TGLayoutHints(kLHintsLeft));
132 fLevelListBox = new TGComboBox(hframenav);
133 fLevelListBox->Connect("Selected(Int_t)", "AliQAHistViewer", this, "DoSetLevel(Int_t)");
134 fLevelListBox->Resize(100,20);
135 hframenav->AddFrame(fLevelListBox, new TGLayoutHints(kLHintsLeft));
136 fHistListBox = new TGComboBox(hframenav);
137 fHistListBox->Connect("Selected(Int_t)", "AliQAHistViewer", this, "DoSetHistogram(Int_t)");
138 fHistListBox->Resize(250,20);
139 hframenav->AddFrame(fHistListBox, new TGLayoutHints(kLHintsLeft));
140 AddFrame(hframenav, new TGLayoutHints((kLHintsLeft|kLHintsExpandX), 5,5,5,5));
141 UpdateAllPathComboBoxes();
142 fExpertMode = new TGCheckButton(hframenav,"Expert");
143 hframenav->AddFrame(fExpertMode,new TGLayoutHints(kLHintsLeft, 0, 4, 3, 0));
144 fExpertMode->SetToolTipText("Show expert histograms");
145 fExpertMode->Connect("Toggled(Bool_t)", "AliQAHistViewer", this, "DoSetExpertMode(Bool_t)");
146 // Create the embedded canvas
147 fEcan = new TRootEmbeddedCanvas(0,this,800,600);
148 Int_t wid = fEcan->GetCanvasWindowId();
149 TCanvas *myc = new TCanvas("MyCanvas", 10,10,wid);
150 fEcan->AdoptCanvas(myc);
151 //myc->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)","AliQAHistViewer",this,
152 // "EventInfo(Int_t,Int_t,Int_t,TObject*)");
154 AddFrame(fEcan, new TGLayoutHints(kLHintsTop | kLHintsLeft |
155 kLHintsExpandX | kLHintsExpandY,0,0,1,1));
157 // Create a horizontal frame containing the buttons
158 TGHorizontalFrame *hframebuttons = new TGHorizontalFrame(this, 200, 40);
159 TGTextButton *prev = new TGTextButton(hframebuttons, "&Prev");
160 prev->Connect("Clicked()", "AliQAHistViewer", this, "DoDrawPrev()");
161 hframebuttons->AddFrame(prev, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4));
162 TGTextButton *next = new TGTextButton(hframebuttons, "&Next");
163 next->Connect("Clicked()", "AliQAHistViewer", this, "DoDrawNext()");
164 hframebuttons->AddFrame(next, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4));
165 AddFrame(hframebuttons, new TGLayoutHints(kLHintsCenterX, 2, 2, 2, 2));
169 TGTextButton *exit = new TGTextButton(hframebuttons, "&Exit ");
170 exit->Connect("Pressed()", "AliQAHistViewer", this, "DoExit()");
171 hframebuttons->AddFrame(exit, new TGLayoutHints(kLHintsRight, 5, 5, 3, 4));
174 // Set a name to the main frame
175 SetWindowName("Quality Assurance Monitoring");
178 // Initialize the layout algorithm via Resize()
179 Resize(GetDefaultSize());
186 //_________________________________________________________________________
187 AliQAHistViewer::~AliQAHistViewer()
189 // Clean up main frame...
195 //_________________________________________________________________________
196 void AliQAHistViewer::FillComboBoxWithListEntries( TGComboBox* box, const TList* list )
200 TIter listiter(list);
202 while ((o = (TObject*)listiter.Next()))
204 TString name = o->GetName();
205 box->AddEntry( name.Data(), i++ );
209 //_________________________________________________________________________
210 void AliQAHistViewer::UpdateAllPathComboBoxes()
212 if (!fQANavigator->InitOK()) return;
213 FillComboBoxWithListEntries( fFileListBox, (TList*)fQANavigator->GetFileList()->GetDirs() );
214 FillComboBoxWithListEntries( fDetectorListBox, (TList*)fQANavigator->GetDetectorList()->GetDirs() );
215 FillComboBoxWithListEntries( fLevelListBox, (TList*)fQANavigator->GetLevelList()->GetDirs() );
216 FillComboBoxWithListEntries( fHistListBox, (TList*)fQANavigator->GetItemList() );
217 fFileListBox->Select(fQANavigator->GetCurrListOfFiles()->GetDirs()->IndexOf(fQANavigator->GetCurrFile()),kFALSE);
218 fDetectorListBox->Select(fQANavigator->GetCurrFile()->GetDirs()->IndexOf(fQANavigator->GetCurrDetector()),kFALSE);
219 fLevelListBox->Select(fQANavigator->GetCurrDetector()->GetDirs()->IndexOf(fQANavigator->GetCurrLevel()),kFALSE);
220 fHistListBox->Select(fQANavigator->GetItemList()->IndexOf(fQANavigator->GetCurrItem()),kFALSE);
223 //_________________________________________________________________________
224 void AliQAHistViewer::DoSetFile( Int_t s )
226 fQANavigator->SetFile(s);
230 //_________________________________________________________________________
231 void AliQAHistViewer::DoSetDetector( Int_t s )
233 fQANavigator->SetDetector(s);
237 //_________________________________________________________________________
238 void AliQAHistViewer::DoSetLevel( Int_t s )
240 fQANavigator->SetLevel(s);
244 //_________________________________________________________________________
245 void AliQAHistViewer::DoSetHistogram( Int_t s )
247 fQANavigator->SetItem(s);
251 //_________________________________________________________________________
252 void AliQAHistViewer::DoSetExpertMode(Bool_t mode)
254 fQANavigator->SetExpertMode(mode);