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