Example for analysis on kine tree.
[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
32e219c2 10#ifndef __CINT_
11#include <list>
12#include <string>
13#endif
14
16718cdc 15// !!!!! Need initialization that will also work for raw.
16// Path and event-id are usually not needed.
17// const Text_t* raw_file = 0,
18
94986496 19void alieve_init(const Text_t* path = ".", Int_t event=0,
20 const Text_t* cdburi = 0,
0513dc59 21 Bool_t assert_runloader=kFALSE, Bool_t assert_esd=kFALSE)
5a5a1232 22{
32e219c2 23 Info("alieve_init", "Adding standard macros.");
84aff7a4 24 TString hack = gSystem->pwd(); // Problem with TGFileBrowser cding
008138bd 25 alieve_init_import_macros();
84aff7a4 26 gSystem->cd(hack);
008138bd 27
d810d0de 28 // TEveUtil::AssertMacro("region_marker.C");
51346b82 29
008138bd 30 gSystem->ProcessEvents();
31
32 // Open event
33 if(path != 0) {
d810d0de 34 AliEveEventManager::SetCdbUri(cdburi);
35 AliEveEventManager::SetAssertElements(assert_runloader, assert_esd);
008138bd 36 printf("Opening event %d from '%s' ...", event, path); fflush(stdout);
a15e6d7d 37 gAliEveEvent = new AliEveEventManager(path, event);
008138bd 38 printf(" done.\n");
a15e6d7d 39 gEve->AddEvent(gAliEveEvent);
008138bd 40 }
41}
42
43void alieve_init_import_macros()
44{
45 // Put macros in the list of browsables, add a macro browser to
46 // top-level GUI.
32e219c2 47
5a5a1232 48 TString macdir("$(REVESYS)/alice-macros");
49 gSystem->ExpandPathName(macdir);
50
84aff7a4 51 TFolder* f = gEve->GetMacroFolder();
5a5a1232 52 void* dirhandle = gSystem->OpenDirectory(macdir.Data());
53 if(dirhandle != 0) {
54 char* filename;
55 TPRegexp re("\.C$");
84aff7a4 56 std::list<string> names;
5a5a1232 57 while((filename = gSystem->GetDirEntry(dirhandle)) != 0) {
58 if(re.Match(filename)) {
32e219c2 59 names.push_back(filename);
5a5a1232 60 }
61 }
32e219c2 62 names.sort();
63 //PH The line below is replaced waiting for a fix in Root
64 //PH which permits to use variable siza arguments in CINT
65 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
84aff7a4 66 // f->Add(new TEveMacro(Form("%s/%s", macdir.Data(), filename)));
32e219c2 67 char fullName[1000];
84aff7a4 68 for (std::list<string>::iterator si=names.begin(); si!=names.end(); ++si)
32e219c2 69 {
70 sprintf(fullName,"%s/%s", macdir.Data(), si->c_str());
84aff7a4 71 f->Add(new TEveMacro(fullName));
32e219c2 72 }
5a5a1232 73 }
74 gSystem->FreeDirectory(dirhandle);
75
5a5a1232 76 gROOT->GetListOfBrowsables()->Add
46a5da3d 77 // (new TSystemDirectory("alice-macros", macdir.Data())); // !!!! this spits blood, but then works
5a5a1232 78 (new TSystemDirectory(macdir.Data(), macdir.Data()));
79
32e219c2 80 {
84aff7a4 81 TEveBrowser *br = gEve->GetBrowser();
82 TGFileBrowser *fb = 0;
32e219c2 83 fb = br->GetFileBrowser();
008138bd 84 fb->GotoDir(macdir);
32e219c2 85 {
86 br->StartEmbedding(0);
87 fb = br->MakeFileBrowser();
88 fb->BrowseObj(f);
89 fb->Show();
90 br->StopEmbedding();
91 br->SetTabTitle("Macros", 0);
92 br->SetTab(0, 0);
93 }
84aff7a4 94 }
5a5a1232 95}