84aff7a4 |
1 | // $Id$ |
d810d0de |
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 * |
51346b82 |
7 | * full copyright notice. * |
d810d0de |
8 | **************************************************************************/ |
5a5a1232 |
9 | |
38c0afa3 |
10 | /// \ingroup evemacros |
11 | /// \file alieve_init.C |
12 | |
c63f2997 |
13 | void alieve_init(const TString& cdburi = "", |
51104899 |
14 | const TString& path = ".", Int_t event=0,Bool_t showHLTESDTree=kFALSE, |
c2c4b7a2 |
15 | const Text_t* esdfile = 0, |
b3b7b8d3 |
16 | const Text_t* aodfile = 0, |
c2c4b7a2 |
17 | const Text_t* rawfile = 0, |
c2c4b7a2 |
18 | Bool_t assert_runloader = kFALSE, |
19 | Bool_t assert_esd = kFALSE, |
b3b7b8d3 |
20 | Bool_t assert_aod = kFALSE, |
c2c4b7a2 |
21 | Bool_t assert_raw = kFALSE) |
5a5a1232 |
22 | { |
c63f2997 |
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 | |
32e219c2 |
29 | Info("alieve_init", "Adding standard macros."); |
84aff7a4 |
30 | TString hack = gSystem->pwd(); // Problem with TGFileBrowser cding |
008138bd |
31 | alieve_init_import_macros(); |
84aff7a4 |
32 | gSystem->cd(hack); |
008138bd |
33 | |
bb3715b9 |
34 | TEveUtil::AssertMacro("VizDB_scan.C"); |
51346b82 |
35 | |
008138bd |
36 | gSystem->ProcessEvents(); |
37 | |
be736e6d |
38 | AliEveEventManager::SetFilesPath(path); |
39 | |
51104899 |
40 | if(showHLTESDTree){ |
41 | AliEveEventManager::SetESDFileName(esdfile, AliEveEventManager::kHLTTree); |
42 | } |
43 | else |
44 | { |
45 | AliEveEventManager::SetESDFileName(esdfile, AliEveEventManager::kOfflineTree); |
46 | } |
47 | |
c2c4b7a2 |
48 | AliEveEventManager::SetRawFileName(rawfile); |
c2c4b7a2 |
49 | AliEveEventManager::SetCdbUri(cdburi); |
b3b7b8d3 |
50 | AliEveEventManager::SetAssertElements(assert_runloader, assert_esd, |
51 | assert_aod, assert_raw); |
c2c4b7a2 |
52 | |
008138bd |
53 | // Open event |
c63f2997 |
54 | if (path.BeginsWith("alien:") || ! cdburi.BeginsWith("local:")) |
c2c4b7a2 |
55 | { |
1d97117d |
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."); |
4f222c66 |
63 | if (gSystem->Getenv("GSHELL_ROOT") == 0) |
1d97117d |
64 | { |
51104899 |
65 | Error("alieve_init", "AliEn environment not initialized. Aborting."); |
66 | gSystem->Exit(1); |
1d97117d |
67 | } |
68 | if (TGrid::Connect("alien") == 0) |
69 | { |
51104899 |
70 | Error("alieve_init", "TGrid::Connect() failed. Aborting."); |
71 | gSystem->Exit(1); |
1d97117d |
72 | } |
73 | } |
008138bd |
74 | } |
1d97117d |
75 | |
76 | Info("alieve_init", "Opening event %d from '%s' ...", event, path.Data()); |
77 | TString name("Event"); // CINT has trouble with direct "Event". |
be736e6d |
78 | new AliEveEventManager(name, event); |
1d97117d |
79 | gEve->AddEvent(AliEveEventManager::GetMaster()); |
008138bd |
80 | } |
81 | |
82 | void alieve_init_import_macros() |
83 | { |
84 | // Put macros in the list of browsables, add a macro browser to |
85 | // top-level GUI. |
32e219c2 |
86 | |
81515106 |
87 | TString macdir("$(ALICE_ROOT)/EVE/alice-macros"); |
5a5a1232 |
88 | gSystem->ExpandPathName(macdir); |
89 | |
84aff7a4 |
90 | TFolder* f = gEve->GetMacroFolder(); |
5a5a1232 |
91 | void* dirhandle = gSystem->OpenDirectory(macdir.Data()); |
4d62585e |
92 | if (dirhandle != 0) |
93 | { |
5a5a1232 |
94 | char* filename; |
68ca2fe7 |
95 | TPMERegexp re("\\.C$"); |
c14ec1f6 |
96 | TObjArray names; |
4d62585e |
97 | while ((filename = gSystem->GetDirEntry(dirhandle)) != 0) |
98 | { |
99 | if (re.Match(filename)) |
c14ec1f6 |
100 | names.AddLast(new TObjString(filename)); |
5a5a1232 |
101 | } |
c14ec1f6 |
102 | names.Sort(); |
5f842026 |
103 | |
c14ec1f6 |
104 | for (Int_t ii=0; ii<names.GetEntries(); ++ii) |
32e219c2 |
105 | { |
c14ec1f6 |
106 | TObjString * si = (TObjString*) names.At(ii); |
107 | f->Add(new TEveMacro(Form("%s/%s", macdir.Data(), (si->GetString()).Data()))); |
32e219c2 |
108 | } |
5a5a1232 |
109 | } |
110 | gSystem->FreeDirectory(dirhandle); |
111 | |
c14ec1f6 |
112 | gROOT->GetListOfBrowsables()->Add(new TSystemDirectory(macdir.Data(), macdir.Data())); |
5a5a1232 |
113 | |
32e219c2 |
114 | { |
84aff7a4 |
115 | TEveBrowser *br = gEve->GetBrowser(); |
116 | TGFileBrowser *fb = 0; |
32e219c2 |
117 | fb = br->GetFileBrowser(); |
008138bd |
118 | fb->GotoDir(macdir); |
32e219c2 |
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 | } |
84aff7a4 |
128 | } |
5a5a1232 |
129 | } |