First big commit of the mchview program and its accompanying library,
[u/mrichter/AliRoot.git] / EVE / macros / alieve_init.C
CommitLineData
5a5a1232 1// $Header$
2
32e219c2 3#ifndef __CINT_
4#include <list>
5#include <string>
6#endif
7
94986496 8void alieve_init(const Text_t* path = ".", Int_t event=0,
9 const Text_t* cdburi = 0,
0513dc59 10 Bool_t assert_runloader=kFALSE, Bool_t assert_esd=kFALSE)
5a5a1232 11{
32e219c2 12 using namespace std;
5a5a1232 13
14 // Set-up environment, load libraries.
5a5a1232 15 Reve::SetupEnvironment();
5a5a1232 16
5a5a1232 17
32e219c2 18 Info("alieve_init", "Adding standard macros.");
008138bd 19 alieve_init_import_macros();
20
21 // Reve::AssertMacro("region_marker.C");
22
23 gSystem->ProcessEvents();
24
25 // Open event
26 if(path != 0) {
27 Alieve::Event::SetCdbUri(cdburi);
28 Alieve::Event::SetAssertElements(assert_runloader, assert_esd);
29 printf("Opening event %d from '%s' ...", event, path); fflush(stdout);
30 Alieve::gEvent = new Alieve::Event(path, event);
31 printf(" done.\n");
32 gReve->AddEvent(Alieve::gEvent);
33 }
34}
35
36void alieve_init_import_macros()
37{
38 // Put macros in the list of browsables, add a macro browser to
39 // top-level GUI.
32e219c2 40
5a5a1232 41 TString macdir("$(REVESYS)/alice-macros");
42 gSystem->ExpandPathName(macdir);
43
46a5da3d 44 TFolder* f = gReve->GetMacroFolder();
5a5a1232 45 void* dirhandle = gSystem->OpenDirectory(macdir.Data());
46 if(dirhandle != 0) {
47 char* filename;
48 TPRegexp re("\.C$");
32e219c2 49 list<string> names;
5a5a1232 50 while((filename = gSystem->GetDirEntry(dirhandle)) != 0) {
51 if(re.Match(filename)) {
32e219c2 52 names.push_back(filename);
5a5a1232 53 }
54 }
32e219c2 55 names.sort();
56 //PH The line below is replaced waiting for a fix in Root
57 //PH which permits to use variable siza arguments in CINT
58 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
59 // f->Add(new Reve::RMacro(Form("%s/%s", macdir.Data(), filename)));
60 char fullName[1000];
61 for (list<string>::iterator si=names.begin(); si!=names.end(); ++si)
62 {
63 sprintf(fullName,"%s/%s", macdir.Data(), si->c_str());
64 f->Add(new Reve::RMacro(fullName));
65 }
5a5a1232 66 }
67 gSystem->FreeDirectory(dirhandle);
68
5a5a1232 69 gROOT->GetListOfBrowsables()->Add
46a5da3d 70 // (new TSystemDirectory("alice-macros", macdir.Data())); // !!!! this spits blood, but then works
5a5a1232 71 (new TSystemDirectory(macdir.Data(), macdir.Data()));
72
32e219c2 73 {
74 Reve::RGBrowser *br = gReve->GetBrowser();
75 TGFileBrowser *fb = 0;
76 fb = br->GetFileBrowser();
008138bd 77 fb->GotoDir(macdir);
32e219c2 78 {
79 br->StartEmbedding(0);
80 fb = br->MakeFileBrowser();
81 fb->BrowseObj(f);
82 fb->Show();
83 br->StopEmbedding();
84 br->SetTabTitle("Macros", 0);
85 br->SetTab(0, 0);
86 }
008138bd 87 }
5a5a1232 88}