]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/macros/alieve_init.C
From Philippe & Laurent: new variant of MUON visualization.
[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
c63f2997 10void alieve_init(const TString& cdburi = "",
11 const TString& path = ".", Int_t event=0,
c2c4b7a2 12 const Text_t* esdfile = 0,
b3b7b8d3 13 const Text_t* aodfile = 0,
c2c4b7a2 14 const Text_t* rawfile = 0,
c2c4b7a2 15 Bool_t assert_runloader = kFALSE,
16 Bool_t assert_esd = kFALSE,
b3b7b8d3 17 Bool_t assert_aod = kFALSE,
c2c4b7a2 18 Bool_t assert_raw = kFALSE)
5a5a1232 19{
c63f2997 20 if (cdburi.IsNull() && ! AliCDBManager::Instance()->IsDefaultStorageSet())
21 {
22 gEnv->SetValue("Root.Stacktrace", "no");
23 Fatal("alieve_init.C", "OCDB path MUST be specified as the first argument.");
24 }
25
32e219c2 26 Info("alieve_init", "Adding standard macros.");
84aff7a4 27 TString hack = gSystem->pwd(); // Problem with TGFileBrowser cding
008138bd 28 alieve_init_import_macros();
84aff7a4 29 gSystem->cd(hack);
008138bd 30
bb3715b9 31 TEveUtil::AssertMacro("VizDB_scan.C");
51346b82 32
008138bd 33 gSystem->ProcessEvents();
34
c2c4b7a2 35 AliEveEventManager::SetESDFileName(esdfile);
36 AliEveEventManager::SetRawFileName(rawfile);
c2c4b7a2 37 AliEveEventManager::SetCdbUri(cdburi);
b3b7b8d3 38 AliEveEventManager::SetAssertElements(assert_runloader, assert_esd,
39 assert_aod, assert_raw);
c2c4b7a2 40
008138bd 41 // Open event
c63f2997 42 if (path.BeginsWith("alien:") || ! cdburi.BeginsWith("local:"))
c2c4b7a2 43 {
1d97117d 44 if (gGrid != 0)
45 {
46 Info("alieve_init", "TGrid already initializied. Skiping checks and initialization.");
47 }
48 else
49 {
50 Info("alieve_init", "AliEn requested - connecting.");
51 if (gSystem->Getenv("alien_API_VO") == 0)
52 {
53 Error("alieve_init", "AliEn environment not initialized. Aborting.");
54 gSystem->Exit(1);
55 }
56 if (TGrid::Connect("alien") == 0)
57 {
58 Error("alieve_init", "TGrid::Connect() failed. Aborting.");
59 gSystem->Exit(1);
60 }
61 }
008138bd 62 }
1d97117d 63
64 Info("alieve_init", "Opening event %d from '%s' ...", event, path.Data());
65 TString name("Event"); // CINT has trouble with direct "Event".
66 new AliEveEventManager(name, path, event);
67 gEve->AddEvent(AliEveEventManager::GetMaster());
008138bd 68}
69
70void alieve_init_import_macros()
71{
72 // Put macros in the list of browsables, add a macro browser to
73 // top-level GUI.
32e219c2 74
81515106 75 TString macdir("$(ALICE_ROOT)/EVE/alice-macros");
5a5a1232 76 gSystem->ExpandPathName(macdir);
77
84aff7a4 78 TFolder* f = gEve->GetMacroFolder();
5a5a1232 79 void* dirhandle = gSystem->OpenDirectory(macdir.Data());
4d62585e 80 if (dirhandle != 0)
81 {
5a5a1232 82 char* filename;
68ca2fe7 83 TPMERegexp re("\\.C$");
84 std::list<string> names; // This form understood by cint (fails with std::string).
4d62585e 85 while ((filename = gSystem->GetDirEntry(dirhandle)) != 0)
86 {
87 if (re.Match(filename))
32e219c2 88 names.push_back(filename);
5a5a1232 89 }
32e219c2 90 names.sort();
91 //PH The line below is replaced waiting for a fix in Root
92 //PH which permits to use variable siza arguments in CINT
93 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
84aff7a4 94 // f->Add(new TEveMacro(Form("%s/%s", macdir.Data(), filename)));
32e219c2 95 char fullName[1000];
84aff7a4 96 for (std::list<string>::iterator si=names.begin(); si!=names.end(); ++si)
32e219c2 97 {
98 sprintf(fullName,"%s/%s", macdir.Data(), si->c_str());
84aff7a4 99 f->Add(new TEveMacro(fullName));
32e219c2 100 }
5a5a1232 101 }
102 gSystem->FreeDirectory(dirhandle);
103
5a5a1232 104 gROOT->GetListOfBrowsables()->Add
46a5da3d 105 // (new TSystemDirectory("alice-macros", macdir.Data())); // !!!! this spits blood, but then works
5a5a1232 106 (new TSystemDirectory(macdir.Data(), macdir.Data()));
107
32e219c2 108 {
84aff7a4 109 TEveBrowser *br = gEve->GetBrowser();
110 TGFileBrowser *fb = 0;
32e219c2 111 fb = br->GetFileBrowser();
008138bd 112 fb->GotoDir(macdir);
32e219c2 113 {
114 br->StartEmbedding(0);
115 fb = br->MakeFileBrowser();
116 fb->BrowseObj(f);
117 fb->Show();
118 br->StopEmbedding();
119 br->SetTabTitle("Macros", 0);
120 br->SetTab(0, 0);
121 }
84aff7a4 122 }
5a5a1232 123}