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