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(TString("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);
177 else if (fileName.EndsWith(".root") || fileName.EndsWith(".raw")) {
178 std::cout << "Adding raw file " << fileName << std::endl;
179 AliEveEventManager::SetRawFileName(fileName);
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 (AliEveEventManager::GetMaster()) delete AliEveEventManager::GetMaster();
194 TString eventName("Event"); // CINT has trouble with direct "Event".
195 /* AliEveEventManager::GetMaster() =*/
196 new AliEveEventManager(eventName, dirName, 0);
197 gEve->AddEvent(AliEveEventManager::GetMaster());
199 if (refresh) Refresh();
201 //____________________________________________________________________
202 /** Executed in response to hitting the "Load ..." button. */
206 fCb->SetButtonState("Load ...", 1);
208 fi.fIniDir = StrDup(gSystem->pwd());
209 new TGFileDialog(gClient->GetRoot(), gClient->GetRoot(), kFDOpen, &fi);
210 Setup(fi.fFilename, true);
211 fCb->SetButtonState("Load ...", 0);
213 //____________________________________________________________________
214 /** Pop-up or down the selection menu */
219 fCb->SetButtonState("Select ...", 1);
221 //____________________________________________________________________
222 /** Enable a detector or type of display */
224 Enable(const char* what)
226 TObject* o = fEnabled.FindObject(what);
229 std::cout << "Enable " << what << "?" << std::endl;
232 fSelect->SetButtonState(what, 0);
236 fEnabled.Add(new TObjString(what));
237 fSelect->SetButtonState(what, 1);
241 //____________________________________________________________________
242 /** Pop-down the selection menu */
246 fCb->SetButtonState("Select ...", 0);
249 //____________________________________________________________________
250 /** Prepare for a new event */
260 //____________________________________________________________________
261 /** Get the next event */
266 std::cout << "Getting next event, please wait ... " << std::flush;
267 gROOT->Macro("event_next.C");
268 std::cout << "done" << std::endl;
271 //____________________________________________________________________
272 /** Get the previous event */
277 std::cout << "Getting previous event, please wait ... " << std::flush;
278 gROOT->Macro("event_prev.C");
279 std::cout << "done" << std::endl;
282 //____________________________________________________________________
283 /** Reload the current event */
288 Int_t event = AliEveEventManager::GetMaster()->GetEventId();
289 std::cout << "Getting event " << event
290 << ", please wait ... " << std::flush;
291 gROOT->Macro(Form("event_goto.C(%d)", event));
292 std::cout << "done" << std::endl;
295 //__________________________________________________________________
296 /** Refresh the display of something
297 @param enabled Whether this something is enabled or not
298 @param has Whether we have already shown this data
299 @param what What data to show */
301 RefreshOne(Bool_t enabled, Bool_t& has, const char* what)
303 if (!enabled || has) return;
304 std::cout << what << "..." << std::flush;
305 TIter next(&fEnabled);
307 while ((o = next())) {
308 TMacro* macro = gEve->GetMacro(Form("%s_%s", o->GetName(), what));
309 if (macro) macro->Exec();
314 //____________________________________________________________________
315 /** Refresh the display of the data */
319 std::cout << "Drawing ... " << std::flush;
320 RefreshOne(fEnableTracks, fHasTracks, "tracks");
321 RefreshOne(fEnableHits, fHasHits, "hits");
322 RefreshOne(fEnableDigits, fHasDigits, "digits");
323 RefreshOne(fEnableRaw, fHasRaw, "raw");
324 RefreshOne(fEnableESD, fHasESD, "esd");
325 std::cout << "done" << std::endl;
327 //____________________________________________________________________
328 /** Toggle the diplay of some data */
330 Toggle(Bool_t& what, const char* name)
333 fCb->SetButtonState(name, what ? 1 : 0);
337 //____________________________________________________________________
338 /** Toggle the diplay the simulated hits */
339 void ToggleHits() { Toggle(fEnableHits, "Hits"); }
340 //____________________________________________________________________
341 /** Toggle the diplay the simulated digits */
342 void ToggleDigits() { Toggle(fEnableDigits, "Digits"); }
343 //____________________________________________________________________
344 /** Toggle the diplay the raw digits */
345 void ToggleRaw() { Toggle(fEnableRaw, "Raw"); }
346 //____________________________________________________________________
347 /** Toggle the diplay the Event Summary Data */
348 void ToggleESD() { Toggle(fEnableESD, "ESD"); }
349 //____________________________________________________________________
350 /** Toggle the diplay of tracks */
351 void ToggleTracks() { Toggle(fEnableTracks, "Tracks"); }
352 //____________________________________________________________________
353 /** Pop-down both menues */
361 //____________________________________________________________________
362 /** Get the static instance */
363 static Display* Instance(const char* file=0) {
364 if (!fgInstance) fgInstance = new Display(file);
368 TControlBar* fCb; // Control bar
369 TControlBar* fSelect; // Selection bar
370 Bool_t fEnableHits; // Whether simulated hits are enabled
371 Bool_t fEnableDigits; // Whether simulated digits are enabled
372 Bool_t fEnableRaw; // Whehter raw data digits are enabled
373 Bool_t fEnableESD; // Whehter Event Summary Data is enabled
374 Bool_t fEnableTracks; // Whether tracks are shown
375 Bool_t fHasHits; // Whether simulated hits are rendered
376 Bool_t fHasDigits; // Whether simulated digits are rendered
377 Bool_t fHasRaw; // Whether raw data digits are rendered
378 Bool_t fHasESD; // Whether Event Summary Data is rendered
379 Bool_t fHasTracks; // Whether tracks are rendered
381 static Display* fgInstance; // Static singleton instance
383 Display* Display::fgInstance = 0;
386 //____________________________________________________________________
387 Display* display(const char* file="")
389 // TGeoManager::Import(geom);
390 // AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
391 // AliCDBManager::Instance()->SetRun(0);
392 // AliGeomManager::LoadGeometry("geometry.root");
394 Display* d = Display::Instance(file);
398 //____________________________________________________________________