]>
Commit | Line | Data |
---|---|---|
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 = "", |
14 | const TString& path = ".", Int_t event=0, | |
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 | ||
c2c4b7a2 | 40 | AliEveEventManager::SetESDFileName(esdfile); |
41 | AliEveEventManager::SetRawFileName(rawfile); | |
c2c4b7a2 | 42 | AliEveEventManager::SetCdbUri(cdburi); |
b3b7b8d3 | 43 | AliEveEventManager::SetAssertElements(assert_runloader, assert_esd, |
44 | assert_aod, assert_raw); | |
c2c4b7a2 | 45 | |
008138bd | 46 | // Open event |
c63f2997 | 47 | if (path.BeginsWith("alien:") || ! cdburi.BeginsWith("local:")) |
c2c4b7a2 | 48 | { |
1d97117d | 49 | if (gGrid != 0) |
50 | { | |
51 | Info("alieve_init", "TGrid already initializied. Skiping checks and initialization."); | |
52 | } | |
53 | else | |
54 | { | |
55 | Info("alieve_init", "AliEn requested - connecting."); | |
4f222c66 | 56 | if (gSystem->Getenv("GSHELL_ROOT") == 0) |
1d97117d | 57 | { |
58 | Error("alieve_init", "AliEn environment not initialized. Aborting."); | |
59 | gSystem->Exit(1); | |
60 | } | |
61 | if (TGrid::Connect("alien") == 0) | |
62 | { | |
63 | Error("alieve_init", "TGrid::Connect() failed. Aborting."); | |
64 | gSystem->Exit(1); | |
65 | } | |
66 | } | |
008138bd | 67 | } |
1d97117d | 68 | |
69 | Info("alieve_init", "Opening event %d from '%s' ...", event, path.Data()); | |
70 | TString name("Event"); // CINT has trouble with direct "Event". | |
be736e6d | 71 | new AliEveEventManager(name, event); |
1d97117d | 72 | gEve->AddEvent(AliEveEventManager::GetMaster()); |
008138bd | 73 | } |
74 | ||
75 | void alieve_init_import_macros() | |
76 | { | |
77 | // Put macros in the list of browsables, add a macro browser to | |
78 | // top-level GUI. | |
32e219c2 | 79 | |
81515106 | 80 | TString macdir("$(ALICE_ROOT)/EVE/alice-macros"); |
5a5a1232 | 81 | gSystem->ExpandPathName(macdir); |
82 | ||
84aff7a4 | 83 | TFolder* f = gEve->GetMacroFolder(); |
5a5a1232 | 84 | void* dirhandle = gSystem->OpenDirectory(macdir.Data()); |
4d62585e | 85 | if (dirhandle != 0) |
86 | { | |
5a5a1232 | 87 | char* filename; |
68ca2fe7 | 88 | TPMERegexp re("\\.C$"); |
c14ec1f6 | 89 | TObjArray names; |
4d62585e | 90 | while ((filename = gSystem->GetDirEntry(dirhandle)) != 0) |
91 | { | |
92 | if (re.Match(filename)) | |
c14ec1f6 | 93 | names.AddLast(new TObjString(filename)); |
5a5a1232 | 94 | } |
c14ec1f6 | 95 | names.Sort(); |
5f842026 | 96 | |
c14ec1f6 | 97 | for (Int_t ii=0; ii<names.GetEntries(); ++ii) |
32e219c2 | 98 | { |
c14ec1f6 | 99 | TObjString * si = (TObjString*) names.At(ii); |
100 | f->Add(new TEveMacro(Form("%s/%s", macdir.Data(), (si->GetString()).Data()))); | |
32e219c2 | 101 | } |
5a5a1232 | 102 | } |
103 | gSystem->FreeDirectory(dirhandle); | |
104 | ||
c14ec1f6 | 105 | gROOT->GetListOfBrowsables()->Add(new TSystemDirectory(macdir.Data(), macdir.Data())); |
5a5a1232 | 106 | |
32e219c2 | 107 | { |
84aff7a4 | 108 | TEveBrowser *br = gEve->GetBrowser(); |
109 | TGFileBrowser *fb = 0; | |
32e219c2 | 110 | fb = br->GetFileBrowser(); |
008138bd | 111 | fb->GotoDir(macdir); |
32e219c2 | 112 | { |
113 | br->StartEmbedding(0); | |
114 | fb = br->MakeFileBrowser(); | |
115 | fb->BrowseObj(f); | |
116 | fb->Show(); | |
117 | br->StopEmbedding(); | |
118 | br->SetTabTitle("Macros", 0); | |
119 | br->SetTab(0, 0); | |
120 | } | |
84aff7a4 | 121 | } |
5a5a1232 | 122 | } |