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