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