AliEveEventManager
[u/mrichter/AliRoot.git] / EVE / macros / alieve_init.C
CommitLineData
84aff7a4 1// $Id$
d810d0de 2// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 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 *
51346b82 7 * full copyright notice. *
d810d0de 8 **************************************************************************/
5a5a1232 9
32e219c2 10#ifndef __CINT_
11#include <list>
12#include <string>
13#endif
14
94986496 15void alieve_init(const Text_t* path = ".", Int_t event=0,
c2c4b7a2 16 const Text_t* esdfile = 0,
17 const Text_t* rawfile = 0,
18 const Text_t* cdburi = 0,
19 Bool_t assert_runloader = kFALSE,
20 Bool_t assert_esd = kFALSE,
21 Bool_t assert_raw = kFALSE)
5a5a1232 22{
32e219c2 23 Info("alieve_init", "Adding standard macros.");
84aff7a4 24 TString hack = gSystem->pwd(); // Problem with TGFileBrowser cding
008138bd 25 alieve_init_import_macros();
84aff7a4 26 gSystem->cd(hack);
008138bd 27
bb3715b9 28 // Temporarily assert default vizdb
29 TEveUtil::AssertMacro("VizDB_scan.C");
51346b82 30
008138bd 31 gSystem->ProcessEvents();
32
c2c4b7a2 33 AliEveEventManager::SetESDFileName(esdfile);
34 AliEveEventManager::SetRawFileName(rawfile);
c2c4b7a2 35 AliEveEventManager::SetCdbUri(cdburi);
4d62585e 36 AliEveEventManager::SetAssertElements(assert_runloader, assert_esd, assert_raw);
c2c4b7a2 37
008138bd 38 // Open event
4d62585e 39 if (path != 0)
c2c4b7a2 40 {
73267f50 41 Info("alieve_init", "Opening event %d from '%s' ...", event, path);
ba5d58f2 42 TString name("Event"); // CINT has trouble with direct "Event".
43 new AliEveEventManager(name, path, event);
4d62585e 44 gEve->AddEvent(AliEveEventManager::GetMaster());
008138bd 45 }
46}
47
48void alieve_init_import_macros()
49{
50 // Put macros in the list of browsables, add a macro browser to
51 // top-level GUI.
32e219c2 52
81515106 53 TString macdir("$(ALICE_ROOT)/EVE/alice-macros");
5a5a1232 54 gSystem->ExpandPathName(macdir);
55
84aff7a4 56 TFolder* f = gEve->GetMacroFolder();
5a5a1232 57 void* dirhandle = gSystem->OpenDirectory(macdir.Data());
4d62585e 58 if (dirhandle != 0)
59 {
5a5a1232 60 char* filename;
61 TPRegexp re("\.C$");
84aff7a4 62 std::list<string> names;
4d62585e 63 while ((filename = gSystem->GetDirEntry(dirhandle)) != 0)
64 {
65 if (re.Match(filename))
32e219c2 66 names.push_back(filename);
5a5a1232 67 }
32e219c2 68 names.sort();
69 //PH The line below is replaced waiting for a fix in Root
70 //PH which permits to use variable siza arguments in CINT
71 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
84aff7a4 72 // f->Add(new TEveMacro(Form("%s/%s", macdir.Data(), filename)));
32e219c2 73 char fullName[1000];
84aff7a4 74 for (std::list<string>::iterator si=names.begin(); si!=names.end(); ++si)
32e219c2 75 {
76 sprintf(fullName,"%s/%s", macdir.Data(), si->c_str());
84aff7a4 77 f->Add(new TEveMacro(fullName));
32e219c2 78 }
5a5a1232 79 }
80 gSystem->FreeDirectory(dirhandle);
81
5a5a1232 82 gROOT->GetListOfBrowsables()->Add
46a5da3d 83 // (new TSystemDirectory("alice-macros", macdir.Data())); // !!!! this spits blood, but then works
5a5a1232 84 (new TSystemDirectory(macdir.Data(), macdir.Data()));
85
32e219c2 86 {
84aff7a4 87 TEveBrowser *br = gEve->GetBrowser();
88 TGFileBrowser *fb = 0;
32e219c2 89 fb = br->GetFileBrowser();
008138bd 90 fb->GotoDir(macdir);
32e219c2 91 {
92 br->StartEmbedding(0);
93 fb = br->MakeFileBrowser();
94 fb->BrowseObj(f);
95 fb->Show();
96 br->StopEmbedding();
97 br->SetTabTitle("Macros", 0);
98 br->SetTab(0, 0);
99 }
84aff7a4 100 }
5a5a1232 101}