]> git.uio.no Git - u/mrichter/AliRoot.git/blame - AliGeant4/macro/g4menu.C
Merging the VirtualMC branch to the main development branch (HEAD)
[u/mrichter/AliRoot.git] / AliGeant4 / macro / g4menu.C
CommitLineData
a776d963 1// $Id$
b9d0a01d 2//
3// Root macro that opens a mini GUI for running aliroot with Geant4.
4//
5// To run aliroot with Geant4 using the g4menu.C:
6// aliroot
7// root [0] .x g4menu.C
8// --> Select "Init" and then "Run" button
9//
10// The the bar enables to start Geant4 interactive session:
11// --> Select "Geant4UI" button and use Geant4 interactive commands;
12// In case TGeant4 has not yet been created you need first
13// select "Geant4" button before selecting "Geant4UI".
14// To go back to Root UI, type exit.
a776d963 15
b9d0a01d 16
17#include <iostream>
0f507a31 18
19void g4menu()
20{
0f507a31 21
b9d0a01d 22 // Load Geant4 libraries
23 if (!gInterpreter->IsLoaded("$ALICE/geant4_vmc/examples/macro/g4libs.C"))
24 gROOT->LoadMacro("$ALICE/geant4_vmc/examples/macro/g4libs.C");
25 gInterpreter->ProcessLine("g4libs()");
0f507a31 26
b9d0a01d 27 // Menu
0f507a31 28 TControlBar* menu = new TControlBar("vertical","Alice Geant4 menu");
29
b9d0a01d 30 menu->AddButton("Init", "gAlice->Init(\"g4Config.C\")", "Initialize \" AliRun \"");
0f507a31 31 menu->AddButton("Run", "gAlice->Run()", "Process Alice run");
b9d0a01d 32 menu->AddButton("Geant4", "CreateGeant4()", "Create Geant4 only (without initializing AliRun)");
33 menu->AddButton("Geant4UI", "StartGeant4UI()","Go to Geant4 Interactive session");
0f507a31 34 gROOT->SaveContext();
35 menu->Show();
36}
37
38void CreateGeant4()
b9d0a01d 39{
0f507a31 40 if (!gMC) {
b9d0a01d 41
42 // TG4RunConfiguration for Geant4
43 TG4RunConfiguration* runConfiguration
44 = new TG4RunConfiguration(true);
0f507a31 45
46 // TGeant4
47 TGeant4* geant4
48 = new TGeant4("TGeant4", "The Geant4 Monte Carlo", runConfiguration);
49
50 cout << "Geant4 has been created." << endl;
51 }
52 else {
53 cout << "Monte Carlo has been already created." << endl;
54 }
55}
56
57void StartGeant4UI()
58{
59 if (gMC) {
60 // release Root terminal control
61
62 // go into non-raw term mode
63 Getlinem(kCleanUp, 0);
64
65 // add test if gMC is TGeant4
66 TGeant4* g4 = (TGeant4*)gMC;
67
68 g4->StartGeantUI();
69
70 // new Root prompt
71 Getlinem(kInit, ((TRint*)gROOT->GetApplication())->GetPrompt());
72 }
73 else {
74 cout << "Monte Carlo has not been yet created." << endl;
75 }
76}