Allow override of CDB storage.
[u/mrichter/AliRoot.git] / EVE / macros / alieve_init.C
1 // $Header$
2
3 void alieve_init(const Text_t* path   = ".", Int_t event=0,
4                  const Text_t* cdburi = 0,
5                  Bool_t use_runloader=kTRUE, Bool_t use_esd=kTRUE,
6                  Bool_t avoid_exceptions_on_open=kTRUE)
7 {
8
9   // Set-up environment, load libraries.
10
11   Reve::SetupEnvironment();
12   // alieve executable linked against ALICE nad EVE shared libraries.
13   // Reve::AssertMacro("alieve_loadlibs.C");
14
15
16   // Put macros in the list of browsables, spawn a browser.
17
18   TString macdir("$(REVESYS)/alice-macros");
19   gSystem->ExpandPathName(macdir);
20
21   TFolder* f = gReve->GetMacroFolder();
22   void* dirhandle = gSystem->OpenDirectory(macdir.Data());
23   if(dirhandle != 0) {
24     char* filename;
25     TPRegexp re("\.C$");
26     while((filename = gSystem->GetDirEntry(dirhandle)) != 0) {
27       if(re.Match(filename)) {
28         printf("Adding macro '%s'\n", filename);
29         //PH The line below is replaced waiting for a fix in Root
30         //PH which permits to use variable siza arguments in CINT
31         //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
32         // f->Add(new Reve::RMacro(Form("%s/%s", macdir.Data(), filename)));
33         char fullName[1000];
34         sprintf(fullName,"%s/%s", macdir.Data(), filename);
35         f->Add(new Reve::RMacro(fullName));
36       }
37     }
38   }
39   gSystem->FreeDirectory(dirhandle);
40
41   gROOT->GetListOfBrowsables()->Add
42     // (new TSystemDirectory("alice-macros", macdir.Data())); // !!!! this spits blood, but then works
43     (new TSystemDirectory(macdir.Data(), macdir.Data()));
44
45   new TBrowser;
46
47   Reve::AssertMacro("region_marker.C");
48
49   // Open event
50   if(path != 0) {
51     Alieve::Event::Initialize(use_runloader, use_esd, avoid_exceptions_on_open);
52     Alieve::Event::SetCdbUri(cdburi);
53     printf("Opening event %d from '%s' ...", event, path); fflush(stdout);
54     Alieve::gEvent = new Alieve::Event(path, event);
55     printf(" done.\n");
56     gReve->AddEvent(Alieve::gEvent);
57   }
58 }