Remove obsolete comments about TTree::Refresh() not working.
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveTrackCounterEditor.cxx
CommitLineData
f76c9e9b 1// @(#)root/eve:$Id$
2// Author: Matevz Tadel 2007
3
4/**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
7 * full copyright notice. *
8 **************************************************************************/
9
10#include "AliEveTrackCounterEditor.h"
11#include "AliEveTrackCounter.h"
12365217 12#include "AliEveEventManager.h"
f76c9e9b 13
12365217 14#include "TGedEditor.h"
f76c9e9b 15#include "TVirtualPad.h"
16#include "TColor.h"
17
18// Cleanup these includes:
19#include "TGLabel.h"
20#include "TGNumberEntry.h"
21#include "TGComboBox.h"
22#include "TGMsgBox.h"
23
786d9102 24#include "TTree.h"
f76c9e9b 25#include "TH1F.h"
26
27#include "TCanvas.h"
786d9102 28#include "TLatex.h"
f76c9e9b 29#include "TEveManager.h"
30
31#include "TROOT.h"
32#include "TSystem.h" // File input/output for track-count status.
33
34//______________________________________________________________________________
35// GUI editor for AliEveTrackCounter.
36//
37
38ClassImp(AliEveTrackCounterEditor)
39
40//______________________________________________________________________________
41AliEveTrackCounterEditor::AliEveTrackCounterEditor(const TGWindow *p, Int_t width, Int_t height,
42 UInt_t options, Pixel_t back) :
43 TGedFrame(p, width, height, options | kVerticalFrame, back),
c12be4d4 44 fM(0), fAF(0), fDF(0),
3a20f984 45 fClickAction(0),
46 fInfoLabelTracks (0),
47 fInfoLabelTracklets(0),
48 fEventId(0)
f76c9e9b 49{
50 // Constructor.
51
52 MakeTitle("AliEveTrackCounter");
53
54 Int_t labelW = 42;
55
c12be4d4 56
57 // Active frame
58
59 fAF = new TGVerticalFrame(this);
60
61 { // Deactivate button
62 TGHorizontalFrame* f = new TGHorizontalFrame(fAF, 210, 20, kFixedWidth);
63
64 TGTextButton* b = new TGTextButton(f, "Deactivate");
65 f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 4));
66 b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoDeactivate()");
67
68 fAF->AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
69 }
f76c9e9b 70 { // ClickAction
c12be4d4 71 TGHorizontalFrame* f = new TGHorizontalFrame(fAF);
f76c9e9b 72 TGLabel* lab = new TGLabel(f, "Click:");
73 f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 10, 1, 2));
74 fClickAction = new TGComboBox(f);
75 fClickAction->AddEntry("Print", 0);
76 fClickAction->AddEntry("Toggle", 1);
77 TGListBox* lb = fClickAction->GetListBox();
78 lb->Resize(lb->GetWidth(), 2*16);
79 fClickAction->Resize(70, 20);
80 fClickAction->Connect("Selected(Int_t)", "AliEveTrackCounterEditor", this,
81 "DoClickAction(Int_t)");
82 f->AddFrame(fClickAction, new TGLayoutHints(kLHintsLeft, 1, 2, 1, 1));
83
c12be4d4 84 fAF->AddFrame(f);
f76c9e9b 85 }
3a20f984 86 { // fInfoLabelTracks
c12be4d4 87 TGHorizontalFrame* f = new TGHorizontalFrame(fAF);
3a20f984 88 TGLabel* lab = new TGLabel(f, "Tracks:");
f76c9e9b 89 f->AddFrame(lab, new TGLayoutHints(kLHintsLeft, 1, 5, 1, 2));
90
3a20f984 91 fInfoLabelTracks = new TGLabel(f);
92 f->AddFrame(fInfoLabelTracks, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 9, 1, 2));
93
c12be4d4 94 fAF->AddFrame(f);
3a20f984 95 }
96 { // fInfoLabelTracklets
c12be4d4 97 TGHorizontalFrame* f = new TGHorizontalFrame(fAF);
3a20f984 98 TGLabel* lab = new TGLabel(f, "Tracklets:");
99 f->AddFrame(lab, new TGLayoutHints(kLHintsLeft, 1, 5, 1, 2));
100
101 fInfoLabelTracklets = new TGLabel(f);
102 f->AddFrame(fInfoLabelTracklets, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 9, 1, 2));
f76c9e9b 103
c12be4d4 104 fAF->AddFrame(f);
f76c9e9b 105 }
f76c9e9b 106 {
c12be4d4 107 TGHorizontalFrame* f = new TGHorizontalFrame(fAF, 210, 20, kFixedWidth);
f76c9e9b 108
109 TGHorizontalFrame* g = new TGHorizontalFrame(f, labelW, 0, kFixedWidth);
110 TGLabel* l = new TGLabel(g, "Event:");
111 g->AddFrame(l, new TGLayoutHints(kLHintsLeft, 0,0,4,0));
112 f->AddFrame(g);
113
114 TGTextButton* b;
115
116 b = new TGTextButton(f, "Prev");
117 f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
118 b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoPrev()");
119
120 fEventId = new TGNumberEntry(f, 0, 3, -1,TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
121 TGNumberFormat::kNELLimitMinMax, 0, 10000);
122 f->AddFrame(fEventId, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
123 fEventId->Connect("ValueSet(Long_t)", "AliEveTrackCounterEditor", this, "DoSetEvent()");
124
125 b = new TGTextButton(f, "Next");
126 f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
127 b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoNext()");
128
c12be4d4 129 fAF->AddFrame(f);
f76c9e9b 130 }
f76c9e9b 131 {
c12be4d4 132 TGHorizontalFrame* f = new TGHorizontalFrame(fAF, 210, 20, kFixedWidth);
f76c9e9b 133
134 TGHorizontalFrame* g = new TGHorizontalFrame(f, labelW, 0, kFixedWidth);
135 TGLabel* l = new TGLabel(g, "Report:");
136 g->AddFrame(l, new TGLayoutHints(kLHintsLeft, 0,0,4,0));
137 f->AddFrame(g);
138
139 TGTextButton* b;
140
141 b = new TGTextButton(f, "Print");
142 f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
143 b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoPrintReport()");
144
145 b = new TGTextButton(f, "File");
146 f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
147 b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoFileReport()");
148
c12be4d4 149 fAF->AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 4, 0));
f76c9e9b 150 }
151 {
c12be4d4 152 TGHorizontalFrame* f = new TGHorizontalFrame(fAF, 210, 20, kFixedWidth);
f76c9e9b 153
154 TGHorizontalFrame* g = new TGHorizontalFrame(f, labelW, 0, kFixedWidth);
155 TGLabel* l = new TGLabel(g, "Histos:");
156 g->AddFrame(l, new TGLayoutHints(kLHintsLeft, 0,0,4,0));
157 f->AddFrame(g);
158
159 TGTextButton* b;
160
161 b = new TGTextButton(f, "Show");
162 f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
163 b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoShowHistos()");
164
c12be4d4 165 fAF->AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
f76c9e9b 166 }
167
c12be4d4 168 AddFrame(fAF, new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY));
169
170
171 // Disabled frame
172
173 fDF = new TGVerticalFrame(this);
174
175 { // Activate button
176 TGHorizontalFrame* f = new TGHorizontalFrame(fDF, 210, 20, kFixedWidth);
177
178 TGTextButton* b = new TGTextButton(f, "Activate");
179 f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
180 b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoActivate()");
181
182 fDF->AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
183 }
184
185 AddFrame(fDF, new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY));
186
187 AliEveEventManager::GetMaster()->Connect("NewEventLoaded()", "AliEveTrackCounterEditor", this, "UpdateModel()");
12365217 188}
189
190AliEveTrackCounterEditor::~AliEveTrackCounterEditor()
191{
192 // Destructor.
193
4d62585e 194 AliEveEventManager::GetMaster()->Disconnect("NewEventLoaded()", this);
f76c9e9b 195}
196
197/******************************************************************************/
198
12365217 199void AliEveTrackCounterEditor::UpdateModel()
200{
201 if (fGedEditor && fM && fGedEditor->GetModel() == fM->GetEditorObject())
202 {
203 SetModel(fM->GetEditorObject());
204 }
205}
206
f76c9e9b 207//______________________________________________________________________________
208void AliEveTrackCounterEditor::SetModel(TObject* obj)
209{
210 // Set model object.
211
212 fM = dynamic_cast<AliEveTrackCounter*>(obj);
213
c12be4d4 214 if (fM->GetActive())
215 {
216 ShowFrame(fAF); HideFrame(fDF);
217
218 fClickAction->Select(fM->fClickAction, kFALSE);
219 fInfoLabelTracks ->SetText(Form("All: %3d; Primaries: %3d", fM->fAllTracks, fM->fGoodTracks));
220 fInfoLabelTracklets->SetText(Form("All: %3d; Primaries: %3d", fM->fAllTracklets, fM->fGoodTracklets));
221 fEventId->SetNumber(fM->GetEventId());
222 }
223 else
224 {
225 ShowFrame(fDF); HideFrame(fAF);
226 }
227
228 Layout();
229}
230
231/******************************************************************************/
232
233void AliEveTrackCounterEditor::DoActivate()
234{
235 // Activate track-counter
236
237 fM->SetActive(kTRUE);
238 AliEveEventManager::GetMaster()->GotoEvent(AliEveEventManager::GetMaster()->GetEventId());
239 fGedEditor->Layout();
240}
241
242void AliEveTrackCounterEditor::DoDeactivate()
243{
244 // Deactivate track-counter.
245
246 fM->SetActive(kFALSE);
247 AliEveEventManager::GetMaster()->GotoEvent(AliEveEventManager::GetMaster()->GetEventId());
f76c9e9b 248}
249
250/******************************************************************************/
251
252//______________________________________________________________________________
253void AliEveTrackCounterEditor::DoPrev()
254{
255 // Slot for Prev.
256
4d62585e 257 AliEveEventManager::GetMaster()->PrevEvent();
f76c9e9b 258}
259
260//______________________________________________________________________________
261void AliEveTrackCounterEditor::DoNext()
262{
263 // Slot for Next.
264
4d62585e 265 AliEveEventManager::GetMaster()->NextEvent();
f76c9e9b 266}
267
268//______________________________________________________________________________
269void AliEveTrackCounterEditor::DoSetEvent()
270{
271 // Slot for SetEvent.
c12be4d4 272
4d62585e 273 AliEveEventManager::GetMaster()->GotoEvent((Int_t) fEventId->GetNumber());
f76c9e9b 274}
275
276/******************************************************************************/
277
278//______________________________________________________________________________
279void AliEveTrackCounterEditor::DoPrintReport()
280{
281 // Slot for PrintReport.
282
786d9102 283 fM->PrintEventTracks();
f76c9e9b 284}
285
286//______________________________________________________________________________
287void AliEveTrackCounterEditor::DoFileReport()
288{
289 // Slot for FileReport.
290
786d9102 291 fM->OutputEventTracks();
f76c9e9b 292}
293
294//______________________________________________________________________________
295void AliEveTrackCounterEditor::DoShowHistos()
296{
297 // Slot for ShowHistos.
298
c12be4d4 299 TEveUtil::Macro("make_scan_results.C");
786d9102 300 TEveUtil::Macro("show_scan_results.C");
f76c9e9b 301}
302
303/******************************************************************************/
304
305//______________________________________________________________________________
306void AliEveTrackCounterEditor::DoClickAction(Int_t mode)
307{
308 // Slot for ClickAction.
309
310 fM->SetClickAction(mode);
311}