]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/macros/alieve_init.C
Separate import of standard macros into a special function so that
[u/mrichter/AliRoot.git] / EVE / macros / alieve_init.C
1 // $Header$
2
3 #ifndef __CINT_
4 #include <list>
5 #include <string>
6 #endif
7
8 void alieve_init(const Text_t* path   = ".", Int_t event=0,
9                  const Text_t* cdburi = 0,
10                  Bool_t assert_runloader=kFALSE, Bool_t assert_esd=kFALSE)
11 {
12   using namespace std;
13
14   // Set-up environment, load libraries.
15   Reve::SetupEnvironment();
16
17
18   Info("alieve_init", "Adding standard macros.");
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
36 void alieve_init_import_macros()
37 {
38   // Put macros in the list of browsables, add a macro browser to
39   // top-level GUI.
40
41   TString macdir("$(REVESYS)/alice-macros");
42   gSystem->ExpandPathName(macdir);
43
44   TFolder* f = gReve->GetMacroFolder();
45   void* dirhandle = gSystem->OpenDirectory(macdir.Data());
46   if(dirhandle != 0) {
47     char* filename;
48     TPRegexp re("\.C$");
49     list<string> names;
50     while((filename = gSystem->GetDirEntry(dirhandle)) != 0) {
51       if(re.Match(filename)) {
52         names.push_back(filename);
53       }
54     }
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     }
66   }
67   gSystem->FreeDirectory(dirhandle);
68
69   gROOT->GetListOfBrowsables()->Add
70     // (new TSystemDirectory("alice-macros", macdir.Data())); // !!!! this spits blood, but then works
71     (new TSystemDirectory(macdir.Data(), macdir.Data()));
72
73   {
74     Reve::RGBrowser *br = gReve->GetBrowser();
75     TGFileBrowser   *fb = 0;
76     fb = br->GetFileBrowser();
77     fb->GotoDir(macdir);
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     }
87   }  
88 }