]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MONITOR/AliQAHistViewer.cxx
Adding brand new 4 physics partition type - PHYSICS_X. Cross-checked and confirmed...
[u/mrichter/AliRoot.git] / MONITOR / AliQAHistViewer.cxx
CommitLineData
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
26ClassImp(AliQAHistViewer)
27
28//_________________________________________________________________________
29void 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;
d3a269ff 52 if (fQANavigator->GetHistogram(hist))
53 {
54 if (hist) hist->Draw();
55 }
923f55ee 56 if (!fQANavigator->Next())
57 {
58 break;
59 }
60 }
f92896b5 61 c1->cd(0);
923f55ee 62 c1->Update();
63}
64
65//_________________________________________________________________________
66void AliQAHistViewer::DoDrawPrev()
67{
68 Int_t rows = 2;
69 Int_t cols = 2;
70 TString oldDirStr;
71 TString newDirStr;
72 oldDirStr = fQANavigator->GetDirName();
73
74 UpdateAllPathComboBoxes();
75
76 TCanvas *c1 = fEcan->GetCanvas();
77 c1->Clear();
78 c1->Divide(rows,cols);
79 for (Int_t i=1; i<=rows*cols;i++)
80 {
81 newDirStr = fQANavigator->GetDirName();
82 if (newDirStr!=oldDirStr)
83 {
84 oldDirStr=newDirStr;
85 break;
86 }
87 c1->cd(i);
88 TH1* hist;
d3a269ff 89 if (fQANavigator->GetHistogram(hist))
90 {
91 if (hist) hist->Draw();
92 }
923f55ee 93 if (!fQANavigator->Prev())
94 {
95 break;
96 }
97 }
f92896b5 98 c1->cd(0);
923f55ee 99 c1->Update();
100}
101
102//_________________________________________________________________________
103void AliQAHistViewer::DoExit()
104{
105 printf("Exit application...");
106 gApplication->Terminate(0);
107}
108
109//_________________________________________________________________________
110AliQAHistViewer::AliQAHistViewer(const TGWindow *p, UInt_t w, UInt_t h, Bool_t embed) :
39116cf0 111 TGMainFrame(p, w, h),
d3a269ff 112 fEcan(NULL),
113 fQANavigator(new AliQAHistNavigator()),
923f55ee 114 fFileListBox(NULL),
115 fDetectorListBox(NULL),
116 fLevelListBox(NULL),
117 fHistListBox(NULL),
d3a269ff 118 fExpertMode(NULL),
923f55ee 119 fIsEmbedded(embed)
120{
121 //initialize the QA navigator
923f55ee 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();
d3a269ff 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*)");
153
154 AddFrame(fEcan, new TGLayoutHints(kLHintsTop | kLHintsLeft |
155 kLHintsExpandX | kLHintsExpandY,0,0,1,1));
156
157 // Create a horizontal frame containing the buttons
923f55ee 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));
d3a269ff 165 AddFrame(hframebuttons, new TGLayoutHints(kLHintsCenterX, 2, 2, 2, 2));
166
923f55ee 167 if ((!fIsEmbedded))
168 {
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));
172 }
923f55ee 173
174 // Set a name to the main frame
175 SetWindowName("Quality Assurance Monitoring");
176 MapSubwindows();
177
178 // Initialize the layout algorithm via Resize()
179 Resize(GetDefaultSize());
180
181 // Map main frame
182 MapWindow();
183 DoDrawNext();
184}
185
186//_________________________________________________________________________
187AliQAHistViewer::~AliQAHistViewer()
188{
189 // Clean up main frame...
190 Cleanup();
191 delete fEcan;
192 delete fQANavigator;
193}
194
195//_________________________________________________________________________
196void AliQAHistViewer::FillComboBoxWithListEntries( TGComboBox* box, const TList* list )
197{
198 box->RemoveAll();
199 Int_t i=0;
200 TIter listiter(list);
201 TObject* o = NULL;
202 while ((o = (TObject*)listiter.Next()))
203 {
204 TString name = o->GetName();
205 box->AddEntry( name.Data(), i++ );
206 }
207}
208
209//_________________________________________________________________________
210void AliQAHistViewer::UpdateAllPathComboBoxes()
211{
7b852582 212 if (!fQANavigator->InitOK()) return;
d3a269ff 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);
923f55ee 221}
222
223//_________________________________________________________________________
224void AliQAHistViewer::DoSetFile( Int_t s )
225{
226 fQANavigator->SetFile(s);
227 DoDrawNext();
228}
229
230//_________________________________________________________________________
231void AliQAHistViewer::DoSetDetector( Int_t s )
232{
233 fQANavigator->SetDetector(s);
234 DoDrawNext();
235}
236
237//_________________________________________________________________________
238void AliQAHistViewer::DoSetLevel( Int_t s )
239{
240 fQANavigator->SetLevel(s);
241 DoDrawNext();
242}
243
244//_________________________________________________________________________
245void AliQAHistViewer::DoSetHistogram( Int_t s )
246{
d3a269ff 247 fQANavigator->SetItem(s);
248 DoDrawNext();
249}
250
251//_________________________________________________________________________
252void AliQAHistViewer::DoSetExpertMode(Bool_t mode)
253{
254 fQANavigator->SetExpertMode(mode);
923f55ee 255 DoDrawNext();
256}