]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/alieve_main/alieve_main.cxx
Event Server can now run without GUI.
[u/mrichter/AliRoot.git] / EVE / alieve_main / alieve_main.cxx
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 #include <EveBase/AliEveConfigManager.h>
10
11 #include <TInterpreter.h>
12 #include <TRint.h>
13 #include <TROOT.h>
14 #include <TPRegexp.h>
15 #include <TSystem.h>
16 #include <TError.h>
17 #include <RVersion.h>
18
19 #include <AliLog.h>
20
21 #include <TEveUtil.h>
22 #include <TEveManager.h>
23 #include <TEveSelection.h>
24 #include <TEveBrowser.h>
25 #include <TEveViewer.h>
26
27 #include <Getline.h>
28
29 // DEV Version includes
30 #include <EveBase/AliEveApplication.h>
31 #include <EveBase/AliEveMainWindow.h>
32
33 int main(int argc, char **argv)
34 {
35     static const TEveException kEH("alieve::main");
36         
37     if(argc>1)
38     {
39         if(strcmp(argv[1],"-dev")==0 ){
40
41             AliEveApplication app("AliEve", &argc, argv);
42             AliEveMainWindow alieve("ALICE Event Display");
43
44             app.Connect(&alieve, "CloseWindow()", "TApplication", &app, "Terminate(=0)" );
45             app.Run();
46
47             return 0;
48         }
49     }
50     else
51     {
52             Info(kEH.Data(),"No parameters");
53     }
54     
55     if (gSystem->Getenv("ALICE_ROOT") == 0)
56     {
57         Error(kEH.Data(), "ALICE_ROOT is not defined, aborting.");
58         gSystem->Exit(1);
59     }
60
61     TString evedir(Form("%s/EVE", gSystem->Getenv("ALICE_ROOT")));
62
63     if (gSystem->AccessPathName(evedir) == kTRUE)
64     {
65         Error(kEH.Data(), "Directory $ALICE_ROOT/EVE does not exist.");
66         gSystem->Exit(1);
67     }
68
69     TString macPath(gROOT->GetMacroPath());
70     macPath += Form(":%s/macros", evedir.Data());
71     gInterpreter->AddIncludePath(evedir);
72     if (gSystem->Getenv("ALICE_ROOT") != 0)
73     {
74         macPath += Form(":%s/alice-macros", evedir.Data());
75         gInterpreter->AddIncludePath(Form("%s/EVE", gSystem->Getenv("ALICE_ROOT")));
76         gInterpreter->AddIncludePath(Form("%s/PWG0", gSystem->Getenv("ALICE_ROOT")));
77         gInterpreter->AddIncludePath(Form("%s/include", gSystem->Getenv("ALICE_ROOT")));
78         gInterpreter->AddIncludePath(gSystem->Getenv("ALICE_ROOT"));
79     }
80     {
81         // TabCom fails on double-colon in macro-path.
82         // I fixed this in ROOT sometime ago ... could be removed
83         // when we go to 5.26.
84         TPMERegexp doubleColon(":{2,}", "og");
85         doubleColon.Substitute(macPath, ":");
86     }
87     gROOT->SetMacroPath(macPath);
88
89     // make sure logger is instantiated
90     AliLog::GetRootLogger();
91     TApplication  *app = new TRint("App", &argc, argv);
92
93 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,25,4) || defined XXX_LATEST_ROOT
94     // Waiting for update by Pawel. Now GED in ROOT is better again :)
95     // Uncomment when fixed in AliEveGedXXX.
96     // TEveGListTreeEditorFrame::SetEditorClass("AliEveGedEditor");
97 #endif
98
99     TEveManager::Create();
100     gEve->GetDefaultViewer()->SetElementName("3D View");
101     gEve->GetSelection()->SetPickToSelect(TEveSelection::kPS_PableCompound);
102     gEve->GetHighlight()->SetPickToSelect(TEveSelection::kPS_PableCompound);
103
104     gEve->RegisterGeometryAlias("Default", Form("%s/alice-data/default_geo.root", evedir.Data()));
105
106     try {AliEveConfigManager::InitializeMaster();}
107     catch (TEveException exc) {
108         AliErrorGeneral("alieve_main",exc.Data());
109     }
110
111     app->Connect( "TEveBrowser", "CloseWindow()", "TRint", app, "Terminate(=0)");
112
113     app->Run(kTRUE);
114
115     if (gEve && gEve->GetBrowser())     gEve->GetBrowser()->UnmapWindow();
116
117     TEveManager::Terminate();
118     app->Terminate(0);
119
120     if(gEve) {delete gEve; gEve = 0;}
121
122
123     return 0;
124 }