]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveBase/AliEveTrackCounterEditor.cxx
Move MultiView.C into EveBase class AliEveMultiView.
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveTrackCounterEditor.cxx
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"
12 #include "AliEveEventManager.h"
13
14 #include "TGedEditor.h"
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
24 #include "TTree.h"
25 #include "TH1F.h"
26
27 #include "TCanvas.h"
28 #include "TLatex.h"
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
38 ClassImp(AliEveTrackCounterEditor)
39
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),
45    fClickAction(0),
46    fInfoLabelTracks   (0),
47    fInfoLabelTracklets(0),
48    fEventId(0)
49 {
50    // Constructor.
51
52    MakeTitle("AliEveTrackCounter");
53
54    Int_t labelW = 42;
55
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    }
70    { // ClickAction
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));
83
84       fAF->AddFrame(f);
85    }
86    { // fInfoLabelTracks
87       TGHorizontalFrame* f = new TGHorizontalFrame(fAF);
88       TGLabel* lab = new TGLabel(f, "Tracks:");
89       f->AddFrame(lab, new TGLayoutHints(kLHintsLeft, 1, 5, 1, 2));
90
91       fInfoLabelTracks = new TGLabel(f);
92       f->AddFrame(fInfoLabelTracks, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 9, 1, 2));
93
94       fAF->AddFrame(f);
95    }
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));
100
101       fInfoLabelTracklets = new TGLabel(f);
102       f->AddFrame(fInfoLabelTracklets, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 9, 1, 2));
103
104       fAF->AddFrame(f);
105    }
106    {
107       TGHorizontalFrame* f = new TGHorizontalFrame(fAF, 210, 20, kFixedWidth);
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
129       fAF->AddFrame(f);
130    }
131    {
132       TGHorizontalFrame* f = new TGHorizontalFrame(fAF, 210, 20, kFixedWidth);
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
149       fAF->AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 4, 0));
150    }
151    {
152       TGHorizontalFrame* f = new TGHorizontalFrame(fAF, 210, 20, kFixedWidth);
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
165       fAF->AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
166    }
167
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()");
188 }
189
190 AliEveTrackCounterEditor::~AliEveTrackCounterEditor()
191 {
192   // Destructor.
193
194   AliEveEventManager::GetMaster()->Disconnect("NewEventLoaded()", this);
195 }
196
197 /******************************************************************************/
198
199 void AliEveTrackCounterEditor::UpdateModel()
200 {
201   if (fGedEditor && fM && fGedEditor->GetModel() == fM->GetEditorObject())
202   {
203     SetModel(fM->GetEditorObject());
204   }
205 }
206
207 //______________________________________________________________________________
208 void AliEveTrackCounterEditor::SetModel(TObject* obj)
209 {
210    // Set model object.
211
212    fM = dynamic_cast<AliEveTrackCounter*>(obj);
213
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
233 void AliEveTrackCounterEditor::DoActivate()
234 {
235    // Activate track-counter
236
237    fM->SetActive(kTRUE);
238    AliEveEventManager::GetMaster()->GotoEvent(AliEveEventManager::GetMaster()->GetEventId());
239    fGedEditor->Layout();
240 }
241
242 void AliEveTrackCounterEditor::DoDeactivate()
243 {
244    // Deactivate track-counter.
245
246    fM->SetActive(kFALSE);
247    AliEveEventManager::GetMaster()->GotoEvent(AliEveEventManager::GetMaster()->GetEventId());
248 }
249
250 /******************************************************************************/
251
252 //______________________________________________________________________________
253 void AliEveTrackCounterEditor::DoPrev()
254 {
255    // Slot for Prev.
256
257    AliEveEventManager::GetMaster()->PrevEvent();
258 }
259
260 //______________________________________________________________________________
261 void AliEveTrackCounterEditor::DoNext()
262 {
263    // Slot for Next.
264
265    AliEveEventManager::GetMaster()->NextEvent();
266 }
267
268 //______________________________________________________________________________
269 void AliEveTrackCounterEditor::DoSetEvent()
270 {
271    // Slot for SetEvent.
272
273    AliEveEventManager::GetMaster()->GotoEvent((Int_t) fEventId->GetNumber());
274 }
275
276 /******************************************************************************/
277
278 //______________________________________________________________________________
279 void AliEveTrackCounterEditor::DoPrintReport()
280 {
281    // Slot for PrintReport.
282
283    fM->PrintEventTracks();
284 }
285
286 //______________________________________________________________________________
287 void AliEveTrackCounterEditor::DoFileReport()
288 {
289    // Slot for FileReport.
290
291    fM->OutputEventTracks();
292 }
293
294 //______________________________________________________________________________
295 void AliEveTrackCounterEditor::DoShowHistos()
296 {
297   // Slot for ShowHistos.
298
299   TEveUtil::Macro("make_scan_results.C");
300   TEveUtil::Macro("show_scan_results.C");
301 }
302
303 /******************************************************************************/
304
305 //______________________________________________________________________________
306 void AliEveTrackCounterEditor::DoClickAction(Int_t mode)
307 {
308    // Slot for ClickAction.
309
310    fM->SetClickAction(mode);
311 }