X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=EVE%2Fmacros%2Falieve_init.C;h=deb3122358d8857e5982f4ce60115f601861fae9;hb=e516f1570b4693fb495dcae48c011c0a410910f5;hp=b8dba950f4ca0fcc6d6acc05fbbf916b54e91456;hpb=46a5da3d012e8e4aa02a4bbc3a63fe054ecdb2a6;p=u%2Fmrichter%2FAliRoot.git diff --git a/EVE/macros/alieve_init.C b/EVE/macros/alieve_init.C index b8dba950f4c..deb3122358d 100644 --- a/EVE/macros/alieve_init.C +++ b/EVE/macros/alieve_init.C @@ -1,31 +1,105 @@ -// $Header$ +// $Id$ +// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007 -void alieve_init(const Text_t* path=".", Int_t event=0, - Bool_t use_runloader=true, Bool_t use_esd=true) +/************************************************************************** + * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. * + * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for * + * full copyright notice. * + **************************************************************************/ + +/// \ingroup evemacros +/// \file alieve_init.C + +void alieve_init(const TString& cdburi = "", + const TString& path = ".", Int_t event=0, + const Text_t* esdfile = 0, + const Text_t* aodfile = 0, + const Text_t* rawfile = 0, + Bool_t assert_runloader = kFALSE, + Bool_t assert_esd = kFALSE, + Bool_t assert_aod = kFALSE, + Bool_t assert_raw = kFALSE) { + if (cdburi.IsNull() && ! AliCDBManager::Instance()->IsDefaultStorageSet()) + { + gEnv->SetValue("Root.Stacktrace", "no"); + Fatal("alieve_init.C", "OCDB path MUST be specified as the first argument."); + } - // Set-up environment, load libraries. + Info("alieve_init", "Adding standard macros."); + TString hack = gSystem->pwd(); // Problem with TGFileBrowser cding + alieve_init_import_macros(); + gSystem->cd(hack); - Reve::SetupEnvironment(); - // alieve executable linked against ALICE nad EVE shared libraries. - // Reve::AssertMacro("alieve_loadlibs.C"); + TEveUtil::AssertMacro("VizDB_scan.C"); + gSystem->ProcessEvents(); - // Put macros in the list of browsables, spawn a browser. + AliEveEventManager::SetESDFileName(esdfile); + AliEveEventManager::SetRawFileName(rawfile); + AliEveEventManager::SetCdbUri(cdburi); + AliEveEventManager::SetAssertElements(assert_runloader, assert_esd, + assert_aod, assert_raw); - TString macdir("$(REVESYS)/alice-macros"); + // Open event + if (path.BeginsWith("alien:") || ! cdburi.BeginsWith("local:")) + { + if (gGrid != 0) + { + Info("alieve_init", "TGrid already initializied. Skiping checks and initialization."); + } + else + { + Info("alieve_init", "AliEn requested - connecting."); + if (gSystem->Getenv("GSHELL_ROOT") == 0) + { + Error("alieve_init", "AliEn environment not initialized. Aborting."); + gSystem->Exit(1); + } + if (TGrid::Connect("alien") == 0) + { + Error("alieve_init", "TGrid::Connect() failed. Aborting."); + gSystem->Exit(1); + } + } + } + + Info("alieve_init", "Opening event %d from '%s' ...", event, path.Data()); + TString name("Event"); // CINT has trouble with direct "Event". + new AliEveEventManager(name, path, event); + gEve->AddEvent(AliEveEventManager::GetMaster()); +} + +void alieve_init_import_macros() +{ + // Put macros in the list of browsables, add a macro browser to + // top-level GUI. + + TString macdir("$(ALICE_ROOT)/EVE/alice-macros"); gSystem->ExpandPathName(macdir); - TFolder* f = gReve->GetMacroFolder(); + TFolder* f = gEve->GetMacroFolder(); void* dirhandle = gSystem->OpenDirectory(macdir.Data()); - if(dirhandle != 0) { + if (dirhandle != 0) + { char* filename; - TPRegexp re("\.C$"); - while((filename = gSystem->GetDirEntry(dirhandle)) != 0) { - if(re.Match(filename)) { - printf("Adding macro '%s'\n", filename); - f->Add(new Reve::RMacro(Form("%s/%s", macdir.Data(), filename))); - } + TPMERegexp re("\\.C$"); + std::list names; // This form understood by cint (fails with std::string). + while ((filename = gSystem->GetDirEntry(dirhandle)) != 0) + { + if (re.Match(filename)) + names.push_back(filename); + } + names.sort(); + //PH The line below is replaced waiting for a fix in Root + //PH which permits to use variable siza arguments in CINT + //PH on some platforms (alphalinuxgcc, solariscc5, etc.) + // f->Add(new TEveMacro(Form("%s/%s", macdir.Data(), filename))); + char fullName[1000]; + for (std::list::iterator si=names.begin(); si!=names.end(); ++si) + { + sprintf(fullName,"%s/%s", macdir.Data(), si->c_str()); + f->Add(new TEveMacro(fullName)); } } gSystem->FreeDirectory(dirhandle); @@ -34,17 +108,19 @@ void alieve_init(const Text_t* path=".", Int_t event=0, // (new TSystemDirectory("alice-macros", macdir.Data())); // !!!! this spits blood, but then works (new TSystemDirectory(macdir.Data(), macdir.Data())); - new TBrowser; - - Reve::AssertMacro("region_marker.C"); - - // Open event - if(path != 0) { - Alieve::Event::Initialize(use_runloader, use_esd); - - printf("Opening event %d from '%s' ...", event, path); fflush(stdout); - Alieve::gEvent = new Alieve::Event(path, event); - printf(" done.\n"); - gReve->AddEvent(Alieve::gEvent); + { + TEveBrowser *br = gEve->GetBrowser(); + TGFileBrowser *fb = 0; + fb = br->GetFileBrowser(); + fb->GotoDir(macdir); + { + br->StartEmbedding(0); + fb = br->MakeFileBrowser(); + fb->BrowseObj(f); + fb->Show(); + br->StopEmbedding(); + br->SetTabTitle("Macros", 0); + br->SetTab(0, 0); + } } }