]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - EVE/macros/alieve_init.C
saveViews macro fixed. Some macros are now being compiled before using to fix issues...
[u/mrichter/AliRoot.git] / EVE / macros / alieve_init.C
... / ...
CommitLineData
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/// \ingroup evemacros
11/// \file alieve_init.C
12
13void alieve_init(const TString& cdburi = "",
14 const TString& path = ".", Int_t event=0,Bool_t showHLTESDTree=kFALSE,
15 const Text_t* esdfile = 0,
16 const Text_t* aodfile = 0,
17 const Text_t* rawfile = 0,
18 Bool_t assert_runloader = kFALSE,
19 Bool_t assert_esd = kFALSE,
20 Bool_t assert_aod = kFALSE,
21 Bool_t assert_raw = kFALSE)
22{
23 if (cdburi.IsNull() && ! AliCDBManager::Instance()->IsDefaultStorageSet())
24 {
25 gEnv->SetValue("Root.Stacktrace", "no");
26 Fatal("alieve_init.C", "OCDB path MUST be specified as the first argument.");
27 }
28
29 Info("alieve_init", "Adding standard macros.");
30 TString hack = gSystem->pwd(); // Problem with TGFileBrowser cding
31 alieve_init_import_macros();
32 gSystem->cd(hack);
33
34 TEveUtil::AssertMacro("VizDB_scan.C");
35
36 gSystem->ProcessEvents();
37
38 AliEveEventManager::SetFilesPath(path);
39
40 if(showHLTESDTree){
41 AliEveEventManager::SetESDFileName(esdfile, AliEveEventManager::kHLTTree);
42 }
43 else
44 {
45 AliEveEventManager::SetESDFileName(esdfile, AliEveEventManager::kOfflineTree);
46 }
47
48 AliEveEventManager::SetRawFileName(rawfile);
49 AliEveEventManager::SetCdbUri(cdburi);
50 AliEveEventManager::SetAssertElements(assert_runloader, assert_esd,
51 assert_aod, assert_raw);
52
53 // Open event
54 if (path.BeginsWith("alien:") || ! cdburi.BeginsWith("local:"))
55 {
56 if (gGrid != 0)
57 {
58 Info("alieve_init", "TGrid already initializied. Skiping checks and initialization.");
59 }
60 else
61 {
62 Info("alieve_init", "AliEn requested - connecting.");
63 if (gSystem->Getenv("GSHELL_ROOT") == 0)
64 {
65 Error("alieve_init", "AliEn environment not initialized. Aborting.");
66 gSystem->Exit(1);
67 }
68 if (TGrid::Connect("alien") == 0)
69 {
70 Error("alieve_init", "TGrid::Connect() failed. Aborting.");
71 gSystem->Exit(1);
72 }
73 }
74 }
75
76 Info("alieve_init", "Opening event %d from '%s' ...", event, path.Data());
77 TString name("Event"); // CINT has trouble with direct "Event".
78 new AliEveEventManager(name, event);
79 gEve->AddEvent(AliEveEventManager::GetMaster());
80}
81
82void alieve_init_import_macros()
83{
84 // Put macros in the list of browsables, add a macro browser to
85 // top-level GUI.
86
87 TString macdir("$(ALICE_ROOT)/EVE/alice-macros");
88 gSystem->ExpandPathName(macdir);
89
90 TFolder* f = gEve->GetMacroFolder();
91 void* dirhandle = gSystem->OpenDirectory(macdir.Data());
92 if (dirhandle != 0)
93 {
94 char* filename;
95 TPMERegexp re("\\.C$");
96 TObjArray names;
97 while ((filename = gSystem->GetDirEntry(dirhandle)) != 0)
98 {
99 if (re.Match(filename))
100 names.AddLast(new TObjString(filename));
101 }
102 names.Sort();
103
104 for (Int_t ii=0; ii<names.GetEntries(); ++ii)
105 {
106 TObjString * si = (TObjString*) names.At(ii);
107 f->Add(new TEveMacro(Form("%s/%s", macdir.Data(), (si->GetString()).Data())));
108 }
109 }
110 gSystem->FreeDirectory(dirhandle);
111
112 gROOT->GetListOfBrowsables()->Add(new TSystemDirectory(macdir.Data(), macdir.Data()));
113
114 {
115 TEveBrowser *br = gEve->GetBrowser();
116 TGFileBrowser *fb = 0;
117 fb = br->GetFileBrowser();
118 fb->GotoDir(macdir);
119 {
120 br->StartEmbedding(0);
121 fb = br->MakeFileBrowser();
122 fb->BrowseObj(f);
123 fb->Show();
124 br->StopEmbedding();
125 br->SetTabTitle("Macros", 0);
126 br->SetTab(0, 0);
127 }
128 }
129}