]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/macros/alieve_init.C
Coverity bugs
[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$");
87 std::list<string> names; // This form understood by cint (fails with std::string).
4d62585e 88 while ((filename = gSystem->GetDirEntry(dirhandle)) != 0)
89 {
5f842026 90 std::string sFilename(filename);
4d62585e 91 if (re.Match(filename))
5f842026 92 names.push_back(sFilename);
5a5a1232 93 }
32e219c2 94 names.sort();
5f842026 95
84aff7a4 96 for (std::list<string>::iterator si=names.begin(); si!=names.end(); ++si)
32e219c2 97 {
5f842026 98 f->Add(new TEveMacro(Form("%s/%s", macdir.Data(), si->c_str())));
32e219c2 99 }
5a5a1232 100 }
101 gSystem->FreeDirectory(dirhandle);
102
5a5a1232 103 gROOT->GetListOfBrowsables()->Add
46a5da3d 104 // (new TSystemDirectory("alice-macros", macdir.Data())); // !!!! this spits blood, but then works
5a5a1232 105 (new TSystemDirectory(macdir.Data(), macdir.Data()));
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}