2 // Author: Matevz Tadel 2007
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 **************************************************************************/
10 #include "AliEveTrackCounterEditor.h"
11 #include "AliEveTrackCounter.h"
12 #include "AliEveEventManager.h"
14 #include "TGedEditor.h"
15 #include "TVirtualPad.h"
18 // Cleanup these includes:
20 #include "TGNumberEntry.h"
21 #include "TGComboBox.h"
29 #include "TEveManager.h"
32 #include "TSystem.h" // File input/output for track-count status.
34 //______________________________________________________________________________
35 // GUI editor for AliEveTrackCounter.
38 ClassImp(AliEveTrackCounterEditor)
40 //______________________________________________________________________________
41 AliEveTrackCounterEditor::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),
44 fM(0), fAF(0), fDF(0),
47 fInfoLabelTracklets(0),
52 MakeTitle("AliEveTrackCounter");
59 fAF = new TGVerticalFrame(this);
61 { // Deactivate button
62 TGHorizontalFrame* f = new TGHorizontalFrame(fAF, 210, 20, kFixedWidth);
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()");
68 fAF->AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
71 TGHorizontalFrame* f = new TGHorizontalFrame(fAF);
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));
87 TGHorizontalFrame* f = new TGHorizontalFrame(fAF);
88 TGLabel* lab = new TGLabel(f, "Tracks:");
89 f->AddFrame(lab, new TGLayoutHints(kLHintsLeft, 1, 5, 1, 2));
91 fInfoLabelTracks = new TGLabel(f);
92 f->AddFrame(fInfoLabelTracks, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 9, 1, 2));
96 { // fInfoLabelTracklets
97 TGHorizontalFrame* f = new TGHorizontalFrame(fAF);
98 TGLabel* lab = new TGLabel(f, "Tracklets:");
99 f->AddFrame(lab, new TGLayoutHints(kLHintsLeft, 1, 5, 1, 2));
101 fInfoLabelTracklets = new TGLabel(f);
102 f->AddFrame(fInfoLabelTracklets, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 9, 1, 2));
107 TGHorizontalFrame* f = new TGHorizontalFrame(fAF, 210, 20, kFixedWidth);
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));
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()");
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()");
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()");
132 TGHorizontalFrame* f = new TGHorizontalFrame(fAF, 210, 20, kFixedWidth);
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));
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()");
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()");
149 fAF->AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 4, 0));
152 TGHorizontalFrame* f = new TGHorizontalFrame(fAF, 210, 20, kFixedWidth);
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));
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()");
165 fAF->AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
168 AddFrame(fAF, new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY));
173 fDF = new TGVerticalFrame(this);
176 TGHorizontalFrame* f = new TGHorizontalFrame(fDF, 210, 20, kFixedWidth);
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()");
182 fDF->AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
185 AddFrame(fDF, new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY));
187 AliEveEventManager::GetMaster()->Connect("NewEventLoaded()", "AliEveTrackCounterEditor", this, "UpdateModel()");
190 AliEveTrackCounterEditor::~AliEveTrackCounterEditor()
194 AliEveEventManager::GetMaster()->Disconnect("NewEventLoaded()", this);
197 /******************************************************************************/
199 void AliEveTrackCounterEditor::UpdateModel()
201 if (fGedEditor && fM && fGedEditor->GetModel() == fM->GetEditorObject())
203 SetModel(fM->GetEditorObject());
207 //______________________________________________________________________________
208 void AliEveTrackCounterEditor::SetModel(TObject* obj)
212 fM = dynamic_cast<AliEveTrackCounter*>(obj);
216 ShowFrame(fAF); HideFrame(fDF);
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());
225 ShowFrame(fDF); HideFrame(fAF);
231 /******************************************************************************/
233 void AliEveTrackCounterEditor::DoActivate()
235 // Activate track-counter
237 fM->SetActive(kTRUE);
238 AliEveEventManager::GetMaster()->GotoEvent(AliEveEventManager::GetMaster()->GetEventId());
239 fGedEditor->Layout();
242 void AliEveTrackCounterEditor::DoDeactivate()
244 // Deactivate track-counter.
246 fM->SetActive(kFALSE);
247 AliEveEventManager::GetMaster()->GotoEvent(AliEveEventManager::GetMaster()->GetEventId());
250 /******************************************************************************/
252 //______________________________________________________________________________
253 void AliEveTrackCounterEditor::DoPrev()
257 AliEveEventManager::GetMaster()->PrevEvent();
260 //______________________________________________________________________________
261 void AliEveTrackCounterEditor::DoNext()
265 AliEveEventManager::GetMaster()->NextEvent();
268 //______________________________________________________________________________
269 void AliEveTrackCounterEditor::DoSetEvent()
271 // Slot for SetEvent.
273 AliEveEventManager::GetMaster()->GotoEvent((Int_t) fEventId->GetNumber());
276 /******************************************************************************/
278 //______________________________________________________________________________
279 void AliEveTrackCounterEditor::DoPrintReport()
281 // Slot for PrintReport.
283 fM->PrintEventTracks();
286 //______________________________________________________________________________
287 void AliEveTrackCounterEditor::DoFileReport()
289 // Slot for FileReport.
291 fM->OutputEventTracks();
294 //______________________________________________________________________________
295 void AliEveTrackCounterEditor::DoShowHistos()
297 // Slot for ShowHistos.
299 TEveUtil::Macro("make_scan_results.C");
300 TEveUtil::Macro("show_scan_results.C");
303 /******************************************************************************/
305 //______________________________________________________________________________
306 void AliEveTrackCounterEditor::DoClickAction(Int_t mode)
308 // Slot for ClickAction.
310 fM->SetClickAction(mode);