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"
13 #include "AliESDEvent.h"
15 #include "TGedEditor.h"
16 #include "TVirtualPad.h"
19 // Cleanup these includes:
21 #include "TGNumberEntry.h"
22 #include "TGComboBox.h"
25 #include "TGButtonGroup.h"
32 #include "TEveManager.h"
35 #include "TSystem.h" // File input/output for track-count status.
38 //______________________________________________________________________________
39 // GUI editor for AliEveTrackCounter.
42 ClassImp(AliEveTrackCounterEditor)
44 //______________________________________________________________________________
45 AliEveTrackCounterEditor::AliEveTrackCounterEditor(const TGWindow *p, Int_t width, Int_t height,
46 UInt_t options, Pixel_t back) :
47 TGedFrame(p, width, height, options | kVerticalFrame, back),
48 fM(0), fAF(0), fDF(0),
51 fInfoLabelTracklets(0),
58 MakeTitle("AliEveTrackCounter");
65 fAF = new TGVerticalFrame(this);
67 { // Deactivate button
68 TGHorizontalFrame* f = new TGHorizontalFrame(fAF, 210, 20, kFixedWidth);
70 TGTextButton* b = new TGTextButton(f, "Deactivate");
71 f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 4));
72 b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoDeactivate()");
74 fAF->AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
77 TGHorizontalFrame* f = new TGHorizontalFrame(fAF);
78 TGLabel* lab = new TGLabel(f, "Click:");
79 f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 10, 1, 2));
80 fClickAction = new TGComboBox(f);
81 fClickAction->AddEntry("Print", 0);
82 fClickAction->AddEntry("Toggle", 1);
83 TGListBox* lb = fClickAction->GetListBox();
84 lb->Resize(lb->GetWidth(), 2*16);
85 fClickAction->Resize(70, 20);
86 fClickAction->Connect("Selected(Int_t)", "AliEveTrackCounterEditor", this,
87 "DoClickAction(Int_t)");
88 f->AddFrame(fClickAction, new TGLayoutHints(kLHintsLeft, 1, 2, 1, 1));
93 TGHorizontalFrame* f = new TGHorizontalFrame(fAF);
94 TGLabel* lab = new TGLabel(f, "Tracks:");
95 f->AddFrame(lab, new TGLayoutHints(kLHintsLeft, 1, 5, 1, 2));
97 fInfoLabelTracks = new TGLabel(f);
98 f->AddFrame(fInfoLabelTracks, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 9, 1, 2));
102 { // fInfoLabelTracklets
103 TGHorizontalFrame* f = new TGHorizontalFrame(fAF);
104 TGLabel* lab = new TGLabel(f, "Tracklets:");
105 f->AddFrame(lab, new TGLayoutHints(kLHintsLeft, 1, 5, 1, 2));
107 fInfoLabelTracklets = new TGLabel(f);
108 f->AddFrame(fInfoLabelTracklets, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 9, 1, 2));
113 TGHorizontalFrame* f = new TGHorizontalFrame(fAF, 210, 20, kFixedWidth);
115 TGHorizontalFrame* g = new TGHorizontalFrame(f, labelW, 0, kFixedWidth);
116 TGLabel* l = new TGLabel(g, "Event:");
117 g->AddFrame(l, new TGLayoutHints(kLHintsLeft, 0,0,4,0));
122 b = new TGTextButton(f, "Prev");
123 f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
124 b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoPrev()");
126 fEventId = new TGNumberEntry(f, 0, 3, -1,TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
127 TGNumberFormat::kNELLimitMinMax, 0, 10000);
128 f->AddFrame(fEventId, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
129 fEventId->Connect("ValueSet(Long_t)", "AliEveTrackCounterEditor", this, "DoSetEvent()");
131 b = new TGTextButton(f, "Next");
132 f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
133 b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoNext()");
138 TGHorizontalFrame* f = new TGHorizontalFrame(fAF, 210, 20, kFixedWidth);
140 TGHorizontalFrame* g = new TGHorizontalFrame(f, labelW, 0, kFixedWidth);
141 TGLabel* l = new TGLabel(g, "Report:");
142 g->AddFrame(l, new TGLayoutHints(kLHintsLeft, 0,0,4,0));
147 b = new TGTextButton(f, "Print");
148 f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
149 b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoPrintReport()");
151 b = new TGTextButton(f, "File");
152 f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
153 b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoFileReport()");
155 fAF->AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 4, 0));
158 TGHorizontalFrame* f = new TGHorizontalFrame(fAF, 210, 20, kFixedWidth);
160 TGHorizontalFrame* g = new TGHorizontalFrame(f, labelW, 0, kFixedWidth);
161 TGLabel* l = new TGLabel(g, "Histos:");
162 g->AddFrame(l, new TGLayoutHints(kLHintsLeft, 0,0,4,0));
167 b = new TGTextButton(f, "Show");
168 f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
169 b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoShowHistos()");
171 fAF->AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
174 TGHorizontalFrame* f = new TGHorizontalFrame(fAF, 210, 20, kFixedWidth);
176 TGButtonGroup *fTypeSelector = new TGButtonGroup(f, "Event Categorization");
177 new TGRadioButton(fTypeSelector, "Good");
178 new TGRadioButton(fTypeSelector, "Splash");
179 new TGRadioButton(fTypeSelector, "Empty");
180 new TGRadioButton(fTypeSelector, "Background");
181 new TGRadioButton(fTypeSelector, "Unclear/Other");
182 fTypeSelector->Connect("Clicked(Int_t)", "AliEveTrackCounterEditor", this, "DoEventCategorization(Int_t)");
184 f->AddFrame(fTypeSelector, new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 2, 3, 2, 2));
186 fAF->AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
189 AddFrame(fAF, new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY));
194 fDF = new TGVerticalFrame(this);
197 TGHorizontalFrame* f = new TGHorizontalFrame(fDF, 210, 20, kFixedWidth);
199 TGTextButton* b = new TGTextButton(f, "Activate");
200 f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
201 b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoActivate()");
203 fDF->AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
206 AddFrame(fDF, new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY));
208 AliEveEventManager::GetMaster()->Connect("NewEventLoaded()", "AliEveTrackCounterEditor", this, "UpdateModel()");
211 AliEveTrackCounterEditor::~AliEveTrackCounterEditor()
215 AliEveEventManager::GetMaster()->Disconnect("NewEventLoaded()", this);
217 if (fScanSummaryFile) {
218 fScanSummaryFile->close();
219 delete fScanSummaryFile;
220 fScanSummaryFile = 0;
224 /******************************************************************************/
226 void AliEveTrackCounterEditor::UpdateModel()
228 if (fGedEditor && fM && fGedEditor->GetModel() == fM->GetEditorObject("TEveElement::GetEditorObject"))
230 SetModel(fM->GetEditorObject("TEveElement::GetEditorObject"));
234 //______________________________________________________________________________
235 void AliEveTrackCounterEditor::SetModel(TObject* obj)
239 fM = dynamic_cast<AliEveTrackCounter*>(obj);
243 ShowFrame(fAF); HideFrame(fDF);
245 fClickAction->Select(fM->fClickAction, kFALSE);
246 fInfoLabelTracks ->SetText(Form("All: %3d; Primaries: %3d", fM->fAllTracks, fM->fGoodTracks));
247 fInfoLabelTracklets->SetText(Form("All: %3d; Primaries: %3d", fM->fAllTracklets, fM->fGoodTracklets));
248 fEventId->SetNumber(fM->GetEventId());
252 ShowFrame(fDF); HideFrame(fAF);
258 /******************************************************************************/
260 void AliEveTrackCounterEditor::DoActivate()
262 // Activate track-counter
264 fM->SetActive(kTRUE);
265 AliEveEventManager::GetMaster()->GotoEvent(AliEveEventManager::GetMaster()->GetEventId());
266 fGedEditor->Layout();
268 if (fScanSummaryFile) {
269 fScanSummaryFile->close();
270 delete fScanSummaryFile;
275 sprintf(fname, "ScanSummary.%i.%i.txt", dat.GetDate(), dat.GetTime());
276 fScanSummaryFile = new ofstream(fname);
277 (*fScanSummaryFile) << "Scan summary" << std::endl;
278 (*fScanSummaryFile) << "Scan started at " << dat.GetDate() << " " << dat.GetTime() << std::endl;
279 AliESDEvent *esd = AliEveEventManager::AssertESD();
280 (*fScanSummaryFile) << "Run number " << esd->GetRunNumber() << std::endl;
283 void AliEveTrackCounterEditor::DoDeactivate()
285 // Deactivate track-counter.
287 fM->SetActive(kFALSE);
288 AliEveEventManager::GetMaster()->GotoEvent(AliEveEventManager::GetMaster()->GetEventId());
290 if (fScanSummaryFile) {
291 fScanSummaryFile->close();
292 delete fScanSummaryFile;
293 fScanSummaryFile = 0;
297 /******************************************************************************/
299 //______________________________________________________________________________
300 void AliEveTrackCounterEditor::DoPrev()
304 AliEveEventManager::GetMaster()->PrevEvent();
307 //______________________________________________________________________________
308 void AliEveTrackCounterEditor::DoNext()
312 if (fScanSummaryFile) {
313 AliESDEvent *esd = AliEveEventManager::AssertESD();
314 (*fScanSummaryFile) << std::hex << std::right ;
315 fScanSummaryFile->width(5); (*fScanSummaryFile) << esd->GetPeriodNumber() << " " ;
316 fScanSummaryFile->width(6); (*fScanSummaryFile) << esd->GetOrbitNumber() << " ";
317 fScanSummaryFile->width(4); (*fScanSummaryFile) << esd->GetBunchCrossNumber() << " ";
319 case 1: (*fScanSummaryFile) << "GOOD "; break;
320 case 2: (*fScanSummaryFile) << "SPLASH "; break;
321 case 3: (*fScanSummaryFile) << "EMPTY "; break;
322 case 4: (*fScanSummaryFile) << "BACKGROUND "; break;
323 case 5: (*fScanSummaryFile) << "OTHER "; break;
328 (*fScanSummaryFile) << std::dec;
329 fScanSummaryFile->width(5); (*fScanSummaryFile) << fM->fAllTracks << " ";
330 fScanSummaryFile->width(5); (*fScanSummaryFile) << fM->fGoodTracks << " ";
331 fScanSummaryFile->width(5); (*fScanSummaryFile) << fM->fAllTracklets << " ";
332 fScanSummaryFile->width(5); (*fScanSummaryFile) << fM->fGoodTracklets << " ";
334 if ((esd->GetPrimaryVertex()) && (esd->GetPrimaryVertex()->GetStatus()))
335 { fScanSummaryFile->width(9); (*fScanSummaryFile) << esd->GetPrimaryVertex()->GetZ(); }
336 else { (*fScanSummaryFile) << "NOVTX "; }
338 (*fScanSummaryFile) << std::endl;
341 AliEveEventManager::GetMaster()->NextEvent();
344 //______________________________________________________________________________
345 void AliEveTrackCounterEditor::DoSetEvent()
347 // Slot for SetEvent.
349 AliEveEventManager::GetMaster()->GotoEvent((Int_t) fEventId->GetNumber());
352 /******************************************************************************/
354 //______________________________________________________________________________
355 void AliEveTrackCounterEditor::DoPrintReport()
357 // Slot for PrintReport.
359 fM->PrintEventTracks();
362 //______________________________________________________________________________
363 void AliEveTrackCounterEditor::DoFileReport()
365 // Slot for FileReport.
367 fM->OutputEventTracks();
370 //______________________________________________________________________________
371 void AliEveTrackCounterEditor::DoShowHistos()
373 // Slot for ShowHistos.
375 TEveUtil::Macro("make_scan_results.C");
376 TEveUtil::Macro("show_scan_results.C");
379 /******************************************************************************/
381 //______________________________________________________________________________
382 void AliEveTrackCounterEditor::DoClickAction(Int_t mode)
384 // Slot for ClickAction.
386 fM->SetClickAction(mode);
389 //______________________________________________________________________________
390 void AliEveTrackCounterEditor::DoEventCategorization(Int_t mode)
392 // Slot for ClickAction.
394 printf("Mode is %i\n", mode);