2 # include <TGFileDialog.h>
3 # include <TGFileBrowser.h>
4 # include <TControlBar.h>
8 # include <TEveManager.h>
9 # include <TSystemDirectory.h>
10 # include <TEveMacro.h>
11 # include <TEveBrowser.h>
14 # include <TApplication.h>
15 # include "aliroot/EVE/EveBase/AliEveEventManager.h"
22 //____________________________________________________________________
24 @param file File or directory to read data from */
25 Display(const char* file="./")
28 fEnableDigits(kFALSE),
36 AliEveEventManager::SetCdbUri("local://$ALICE_ROOT");
42 //____________________________________________________________________
43 /** Setup the control bar */
46 fCb = new TControlBar("vertical", "EVE Controls");
47 const char* buts[] = { "Load ...",
58 const char* meths[] = { "LoadFile",
69 const char* hints[] = { "Specify input" ,
70 "Select which detectors to show",
73 "Toggle display of hits",
74 "Toggle display of simulated digits",
75 "Toggle display of raw digits",
76 "Toggle display of event summary data",
77 "Toggle display of tracks",
81 char** but = const_cast<char**>(buts);
82 char** meth = const_cast<char**>(meths);
83 char** hint = const_cast<char**>(hints);
85 fCb->AddButton(*but, Form("Display::Instance()->%s()", *meth), *hint);
92 //____________________________________________________________________
93 /** Setup the selection bar */
96 fSelect = new TControlBar("vertical", "Detector selection");
97 char* dets[] = { "emcal",
111 // TString cmd(Form("Display::Instance()->Enable(\"%s\")", *det));
112 // TString help(Form("Enable display of %s data", name.Data()));
113 fSelect->AddButton(*det,
114 Form("Display::Instance()->Enable(\"%s\")", *det),
115 Form("Enable display of %s data", *det));
118 std::cout << "Adding \"Hide\" to select" << std::endl;
119 fSelect->AddButton("Hide", "Display::Instance()->HideSelect()",
120 "Hide the detector selection menu");
122 //____________________________________________________________________
123 /** Load macros used by EVE */
126 std::cout << "Loading macros ... " << std::flush;
127 TString savdir(gSystem->pwd());
128 TString macdir("$(ALICE_ROOT)/EVE/alice-macros");
129 gSystem->ExpandPathName(macdir);
131 TFolder* f = gEve->GetMacroFolder();
132 TSystemDirectory* dir = new TSystemDirectory(macdir.Data(),
134 TList* files = dir->GetListOfFiles();
137 TSystemFile* file = 0;
138 while ((file = static_cast<TSystemFile*>(next()))) {
139 if (file->IsDirectory()) continue;
140 TString name(gSystem->ConcatFileName(macdir.Data(),file->GetName()));
141 if (!name.EndsWith(".C")) continue;
142 f->Add(new TEveMacro(name.Data()));
145 gROOT->GetListOfBrowsables()->Add(dir);
148 TEveBrowser* b = gEve->GetBrowser();
149 TGFileBrowser* fb = b->GetFileBrowser();
152 b->StartEmbedding(0);
153 fb = b->MakeFileBrowser();
157 b->SetTabTitle("Macros", 0);
162 std::cout << "done" << std::endl;
164 //____________________________________________________________________
165 /** Set-up load location, etc.
166 @param file File or directory to read data from
167 @param refresh Force a refresh */
168 void Setup(const char* file, bool refresh)
170 TString fileName(gSystem->BaseName(file));
171 TString dirName(gSystem->DirName(file));
173 if (fileName.Contains("ESD")) {
174 std::cout << "Adding ESD file " << fileName << std::endl;
175 AliEveEventManager::SetESDFileName(fileName.Data());
177 else if (fileName.EndsWith(".root") || fileName.EndsWith(".raw")) {
178 std::cout << "Adding raw file " << fileName << std::endl;
179 AliEveEventManager::SetRawFileName(fileName.Data());
181 else if (fileName.IsNull()) {
182 std::cout << "No file given!" << std::endl;
183 // std::cout << "Adding raw directory " << dirName.Data() << std::endl;
184 // AliEveEventManager::SetRawFileName(dirName.Data());
187 std::cerr << "Don't know how to deal with '" << fileName << "'"
191 std::cout << "Opening " << fileName << " (" << dirName << ")" << std::endl;
193 if (gAliEveEvent) delete gAliEveEvent;
194 gAliEveEvent = new AliEveEventManager(dirName.Data(), 0);
195 gEve->AddEvent(gAliEveEvent);
197 if (refresh) Refresh();
199 //____________________________________________________________________
200 /** Executed in response to hitting the "Load ..." button. */
204 fCb->SetButtonState("Load ...", 1);
206 fi.fIniDir = StrDup(gSystem->pwd());
207 new TGFileDialog(gClient->GetRoot(), gClient->GetRoot(), kFDOpen, &fi);
208 Setup(fi.fFilename, true);
209 fCb->SetButtonState("Load ...", 0);
211 //____________________________________________________________________
212 /** Pop-up or down the selection menu */
217 fCb->SetButtonState("Select ...", 1);
219 //____________________________________________________________________
220 /** Enable a detector or type of display */
222 Enable(const char* what)
224 TObject* o = fEnabled.FindObject(what);
227 std::cout << "Enable " << what << "?" << std::endl;
230 fSelect->SetButtonState(what, 0);
234 fEnabled.Add(new TObjString(what));
235 fSelect->SetButtonState(what, 1);
239 //____________________________________________________________________
240 /** Pop-down the selection menu */
244 fCb->SetButtonState("Select ...", 0);
247 //____________________________________________________________________
248 /** Prepare for a new event */
258 //____________________________________________________________________
259 /** Get the next event */
264 std::cout << "Getting next event, please wait ... " << std::flush;
265 gROOT->Macro("event_next.C");
266 std::cout << "done" << std::endl;
269 //____________________________________________________________________
270 /** Get the previous event */
275 std::cout << "Getting previous event, please wait ... " << std::flush;
276 gROOT->Macro("event_prev.C");
277 std::cout << "done" << std::endl;
280 //____________________________________________________________________
281 /** Reload the current event */
286 Int_t event = gAliEveEvent->GetEventId();
287 std::cout << "Getting event " << event
288 << ", please wait ... " << std::flush;
289 gROOT->Macro(Form("event_goto.C(%d)", event));
290 std::cout << "done" << std::endl;
293 //__________________________________________________________________
294 /** Refresh the display of something
295 @param enabled Whether this something is enabled or not
296 @param has Whether we have already shown this data
297 @param what What data to show */
299 RefreshOne(Bool_t enabled, Bool_t& has, const char* what)
301 if (!enabled || has) return;
302 std::cout << what << "..." << std::flush;
303 TIter next(&fEnabled);
305 while ((o = next())) {
306 TMacro* macro = gEve->GetMacro(Form("%s_%s", o->GetName(), what));
307 if (macro) macro->Exec();
312 //____________________________________________________________________
313 /** Refresh the display of the data */
317 std::cout << "Drawing ... " << std::flush;
318 RefreshOne(fEnableTracks, fHasTracks, "tracks");
319 RefreshOne(fEnableHits, fHasHits, "hits2");
320 RefreshOne(fEnableDigits, fHasDigits, "digits");
321 RefreshOne(fEnableRaw, fHasRaw, "raw");
322 RefreshOne(fEnableESD, fHasESD, "esd");
323 std::cout << "done" << std::endl;
325 //____________________________________________________________________
326 /** Toggle the diplay of some data */
328 Toggle(Bool_t& what, const char* name)
331 fCb->SetButtonState(name, what ? 1 : 0);
335 //____________________________________________________________________
336 /** Toggle the diplay the simulated hits */
337 void ToggleHits() { Toggle(fEnableHits, "Hits"); }
338 //____________________________________________________________________
339 /** Toggle the diplay the simulated digits */
340 void ToggleDigits() { Toggle(fEnableDigits, "Digits"); }
341 //____________________________________________________________________
342 /** Toggle the diplay the raw digits */
343 void ToggleRaw() { Toggle(fEnableRaw, "Raw"); }
344 //____________________________________________________________________
345 /** Toggle the diplay the Event Summary Data */
346 void ToggleESD() { Toggle(fEnableESD, "ESD"); }
347 //____________________________________________________________________
348 /** Toggle the diplay of tracks */
349 void ToggleTracks() { Toggle(fEnableTracks, "Tracks"); }
350 //____________________________________________________________________
351 /** Pop-down both menues */
359 //____________________________________________________________________
360 /** Get the static instance */
361 static Display* Instance() {
362 if (!fgInstance) fgInstance = new Display();
366 TControlBar* fCb; // Control bar
367 TControlBar* fSelect; // Selection bar
368 Bool_t fEnableHits; // Whether simulated hits are enabled
369 Bool_t fEnableDigits; // Whether simulated digits are enabled
370 Bool_t fEnableRaw; // Whehter raw data digits are enabled
371 Bool_t fEnableESD; // Whehter Event Summary Data is enabled
372 Bool_t fEnableTracks; // Whether tracks are shown
373 Bool_t fHasHits; // Whether simulated hits are rendered
374 Bool_t fHasDigits; // Whether simulated digits are rendered
375 Bool_t fHasRaw; // Whether raw data digits are rendered
376 Bool_t fHasESD; // Whether Event Summary Data is rendered
377 Bool_t fHasTracks; // Whether tracks are rendered
379 static Display* fgInstance; // Static singleton instance
381 Display* Display::fgInstance = 0;
384 //____________________________________________________________________
387 TGeoManager::Import("geometry.root");
389 Display* d = Display::Instance();
393 //____________________________________________________________________