From Pawel Debski:
[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
68ca2fe7 31 alieve_init_basic_vizdb();
32 // Temporarily assert also default vizdb.
bb3715b9 33 TEveUtil::AssertMacro("VizDB_scan.C");
51346b82 34
008138bd 35 gSystem->ProcessEvents();
36
c2c4b7a2 37 AliEveEventManager::SetESDFileName(esdfile);
38 AliEveEventManager::SetRawFileName(rawfile);
c2c4b7a2 39 AliEveEventManager::SetCdbUri(cdburi);
b3b7b8d3 40 AliEveEventManager::SetAssertElements(assert_runloader, assert_esd,
41 assert_aod, assert_raw);
c2c4b7a2 42
008138bd 43 // Open event
c63f2997 44 if (path.BeginsWith("alien:") || ! cdburi.BeginsWith("local:"))
c2c4b7a2 45 {
1d97117d 46 if (gGrid != 0)
47 {
48 Info("alieve_init", "TGrid already initializied. Skiping checks and initialization.");
49 }
50 else
51 {
52 Info("alieve_init", "AliEn requested - connecting.");
53 if (gSystem->Getenv("alien_API_VO") == 0)
54 {
55 Error("alieve_init", "AliEn environment not initialized. Aborting.");
56 gSystem->Exit(1);
57 }
58 if (TGrid::Connect("alien") == 0)
59 {
60 Error("alieve_init", "TGrid::Connect() failed. Aborting.");
61 gSystem->Exit(1);
62 }
63 }
008138bd 64 }
1d97117d 65
66 Info("alieve_init", "Opening event %d from '%s' ...", event, path.Data());
67 TString name("Event"); // CINT has trouble with direct "Event".
68 new AliEveEventManager(name, path, event);
69 gEve->AddEvent(AliEveEventManager::GetMaster());
008138bd 70}
71
72void alieve_init_import_macros()
73{
74 // Put macros in the list of browsables, add a macro browser to
75 // top-level GUI.
32e219c2 76
81515106 77 TString macdir("$(ALICE_ROOT)/EVE/alice-macros");
5a5a1232 78 gSystem->ExpandPathName(macdir);
79
84aff7a4 80 TFolder* f = gEve->GetMacroFolder();
5a5a1232 81 void* dirhandle = gSystem->OpenDirectory(macdir.Data());
4d62585e 82 if (dirhandle != 0)
83 {
5a5a1232 84 char* filename;
68ca2fe7 85 TPMERegexp re("\\.C$");
86 std::list<string> names; // This form understood by cint (fails with std::string).
4d62585e 87 while ((filename = gSystem->GetDirEntry(dirhandle)) != 0)
88 {
89 if (re.Match(filename))
32e219c2 90 names.push_back(filename);
5a5a1232 91 }
32e219c2 92 names.sort();
93 //PH The line below is replaced waiting for a fix in Root
94 //PH which permits to use variable siza arguments in CINT
95 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
84aff7a4 96 // f->Add(new TEveMacro(Form("%s/%s", macdir.Data(), filename)));
32e219c2 97 char fullName[1000];
84aff7a4 98 for (std::list<string>::iterator si=names.begin(); si!=names.end(); ++si)
32e219c2 99 {
100 sprintf(fullName,"%s/%s", macdir.Data(), si->c_str());
84aff7a4 101 f->Add(new TEveMacro(fullName));
32e219c2 102 }
5a5a1232 103 }
104 gSystem->FreeDirectory(dirhandle);
105
5a5a1232 106 gROOT->GetListOfBrowsables()->Add
46a5da3d 107 // (new TSystemDirectory("alice-macros", macdir.Data())); // !!!! this spits blood, but then works
5a5a1232 108 (new TSystemDirectory(macdir.Data(), macdir.Data()));
109
32e219c2 110 {
84aff7a4 111 TEveBrowser *br = gEve->GetBrowser();
112 TGFileBrowser *fb = 0;
32e219c2 113 fb = br->GetFileBrowser();
008138bd 114 fb->GotoDir(macdir);
32e219c2 115 {
116 br->StartEmbedding(0);
117 fb = br->MakeFileBrowser();
118 fb->BrowseObj(f);
119 fb->Show();
120 br->StopEmbedding();
121 br->SetTabTitle("Macros", 0);
122 br->SetTab(0, 0);
123 }
84aff7a4 124 }
5a5a1232 125}
68ca2fe7 126
127void alieve_init_basic_vizdb()
128{
129 TEvePointSet* ps;
130
131 ps = new TEvePointSet();
132 ps->SetMarkerColor(4);
133 ps->SetMarkerSize(0.2);
134 ps->SetMarkerStyle(2);
135 gEve->InsertVizDBEntry("Clusters", ps);
136}