]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/macros/alieve_init.C
Changes in order to modify also ITSonly tracks
[u/mrichter/AliRoot.git] / EVE / macros / alieve_init.C
1 // $Id$
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          *
7  * full copyright notice.                                                 *
8  **************************************************************************/
9
10 /// \ingroup evemacros
11 /// \file alieve_init.C
12
13 void alieve_init(const TString& cdburi = "",
14                  const TString& path   = ".", Int_t event=0,
15                  const Text_t* esdfile = 0,
16                  const Text_t* aodfile = 0,
17                  const Text_t* rawfile = 0,
18                  Bool_t assert_runloader = kFALSE,
19                  Bool_t assert_esd       = kFALSE,
20                  Bool_t assert_aod       = kFALSE,
21                  Bool_t assert_raw       = kFALSE)
22 {
23   if (cdburi.IsNull() && ! AliCDBManager::Instance()->IsDefaultStorageSet())
24   {
25     gEnv->SetValue("Root.Stacktrace", "no");
26     Fatal("alieve_init.C", "OCDB path MUST be specified as the first argument.");
27   }
28
29   Info("alieve_init", "Adding standard macros.");
30   TString  hack = gSystem->pwd(); // Problem with TGFileBrowser cding
31   alieve_init_import_macros();
32   gSystem->cd(hack);
33
34   TEveUtil::AssertMacro("VizDB_scan.C");
35
36   gSystem->ProcessEvents();
37
38   AliEveEventManager::SetESDFileName(esdfile);
39   AliEveEventManager::SetRawFileName(rawfile);
40   AliEveEventManager::SetCdbUri(cdburi);
41   AliEveEventManager::SetAssertElements(assert_runloader, assert_esd,
42                                         assert_aod, assert_raw);
43
44   // Open event
45   if (path.BeginsWith("alien:") || ! cdburi.BeginsWith("local:"))
46   {
47     if (gGrid != 0)
48     {
49       Info("alieve_init", "TGrid already initializied. Skiping checks and initialization.");
50     }
51     else
52     {
53       Info("alieve_init", "AliEn requested - connecting.");
54       if (gSystem->Getenv("GSHELL_ROOT") == 0)
55       {
56         Error("alieve_init", "AliEn environment not initialized. Aborting.");
57         gSystem->Exit(1);
58       }
59       if (TGrid::Connect("alien") == 0)
60       {
61         Error("alieve_init", "TGrid::Connect() failed. Aborting.");
62         gSystem->Exit(1);
63       }
64     }
65   }
66
67   Info("alieve_init", "Opening event %d from '%s' ...", event, path.Data());
68   TString name("Event"); // CINT has trouble with direct "Event".
69   new AliEveEventManager(name, path, event);
70   gEve->AddEvent(AliEveEventManager::GetMaster());
71 }
72
73 void alieve_init_import_macros()
74 {
75   // Put macros in the list of browsables, add a macro browser to
76   // top-level GUI.
77
78   TString macdir("$(ALICE_ROOT)/EVE/alice-macros");
79   gSystem->ExpandPathName(macdir);
80
81   TFolder* f = gEve->GetMacroFolder();
82   void* dirhandle = gSystem->OpenDirectory(macdir.Data());
83   if (dirhandle != 0)
84   {
85     char* filename;
86     TPMERegexp re("\\.C$");
87     std::list<string> names; // This form understood by cint (fails with std::string).
88     while ((filename = gSystem->GetDirEntry(dirhandle)) != 0)
89     {
90       std::string sFilename(filename);
91       if (re.Match(filename))
92         names.push_back(sFilename);
93     }
94     names.sort();
95
96     for (std::list<string>::iterator si=names.begin(); si!=names.end(); ++si)
97     {
98       f->Add(new TEveMacro(Form("%s/%s", macdir.Data(), si->c_str())));
99     }
100   }
101   gSystem->FreeDirectory(dirhandle);
102
103   gROOT->GetListOfBrowsables()->Add
104     // (new TSystemDirectory("alice-macros", macdir.Data())); // !!!! this spits blood, but then works
105     (new TSystemDirectory(macdir.Data(), macdir.Data()));
106
107   {
108     TEveBrowser   *br = gEve->GetBrowser();
109     TGFileBrowser *fb = 0;
110     fb = br->GetFileBrowser();
111     fb->GotoDir(macdir);
112     {
113       br->StartEmbedding(0);
114       fb = br->MakeFileBrowser();
115       fb->BrowseObj(f);
116       fb->Show();
117       br->StopEmbedding();
118       br->SetTabTitle("Macros", 0);
119       br->SetTab(0, 0);
120     }
121   }
122 }