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