2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
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 **************************************************************************/
10 /// \ingroup evemacros
11 /// \file alieve_init.C
13 void alieve_init(const TString& cdburi = "",
14 const TString& path = ".", Int_t event=0,
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)
23 if (cdburi.IsNull() && ! AliCDBManager::Instance()->IsDefaultStorageSet())
25 gEnv->SetValue("Root.Stacktrace", "no");
26 Fatal("alieve_init.C", "OCDB path MUST be specified as the first argument.");
29 Info("alieve_init", "Adding standard macros.");
30 TString hack = gSystem->pwd(); // Problem with TGFileBrowser cding
31 alieve_init_import_macros();
34 TEveUtil::AssertMacro("VizDB_scan.C");
36 gSystem->ProcessEvents();
38 AliEveEventManager::SetESDFileName(esdfile);
39 AliEveEventManager::SetRawFileName(rawfile);
40 AliEveEventManager::SetCdbUri(cdburi);
41 AliEveEventManager::SetAssertElements(assert_runloader, assert_esd,
42 assert_aod, assert_raw);
45 if (path.BeginsWith("alien:") || ! cdburi.BeginsWith("local:"))
49 Info("alieve_init", "TGrid already initializied. Skiping checks and initialization.");
53 Info("alieve_init", "AliEn requested - connecting.");
54 if (gSystem->Getenv("GSHELL_ROOT") == 0)
56 Error("alieve_init", "AliEn environment not initialized. Aborting.");
59 if (TGrid::Connect("alien") == 0)
61 Error("alieve_init", "TGrid::Connect() failed. Aborting.");
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());
73 void alieve_init_import_macros()
75 // Put macros in the list of browsables, add a macro browser to
78 TString macdir("$(ALICE_ROOT)/EVE/alice-macros");
79 gSystem->ExpandPathName(macdir);
81 TFolder* f = gEve->GetMacroFolder();
82 void* dirhandle = gSystem->OpenDirectory(macdir.Data());
86 TPMERegexp re("\\.C$");
87 std::list<string> names; // This form understood by cint (fails with std::string).
88 while ((filename = gSystem->GetDirEntry(dirhandle)) != 0)
90 std::string sFilename(filename);
91 if (re.Match(filename))
92 names.push_back(sFilename);
96 for (std::list<string>::iterator si=names.begin(); si!=names.end(); ++si)
98 f->Add(new TEveMacro(Form("%s/%s", macdir.Data(), si->c_str())));
101 gSystem->FreeDirectory(dirhandle);
103 gROOT->GetListOfBrowsables()->Add
104 // (new TSystemDirectory("alice-macros", macdir.Data())); // !!!! this spits blood, but then works
105 (new TSystemDirectory(macdir.Data(), macdir.Data()));
108 TEveBrowser *br = gEve->GetBrowser();
109 TGFileBrowser *fb = 0;
110 fb = br->GetFileBrowser();
113 br->StartEmbedding(0);
114 fb = br->MakeFileBrowser();
118 br->SetTabTitle("Macros", 0);