]> git.uio.no Git - u/mrichter/AliRoot.git/blame - macros/g4menu.C
Updated version of the Geant4 configuration (Andrei)
[u/mrichter/AliRoot.git] / macros / g4menu.C
CommitLineData
1fccbbe0 1// $Id$
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.
15
16
17#include <iostream>
18
19void g4menu()
20{
21
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()");
26
27 // Menu
28 TControlBar* menu = new TControlBar("vertical","Alice Geant4 menu");
29
30 menu->AddButton("Init", "gAlice->Init(\"g4Config.C\")", "Initialize \" AliRun \"");
31 menu->AddButton("Run", "gAlice->Run()", "Process Alice run");
32 menu->AddButton("Geant4", "CreateGeant4()", "Create Geant4 only (without initializing AliRun)");
33 menu->AddButton("Geant4UI", "StartGeant4UI()","Go to Geant4 Interactive session");
67d736ee 34 menu->AddButton("XML", "GenerateXML()","Generate XML (AGDD) file with geometry description");
35 menu->AddButton("Quit", "Quit()", "Quit aliroot");
1fccbbe0 36 gROOT->SaveContext();
37 menu->Show();
38}
39
40void CreateGeant4()
41{
42 if (!gMC) {
43
44 // TG4RunConfiguration for Geant4
45 TG4RunConfiguration* runConfiguration
46 = new TG4RunConfiguration(true);
47
48 // TGeant4
49 TGeant4* geant4
50 = new TGeant4("TGeant4", "The Geant4 Monte Carlo", runConfiguration);
51
52 cout << "Geant4 has been created." << endl;
53 }
54 else {
55 cout << "Monte Carlo has been already created." << endl;
56 }
57}
58
59void StartGeant4UI()
60{
61 if (gMC) {
62 // release Root terminal control
63
64 // go into non-raw term mode
65 Getlinem(kCleanUp, 0);
66
67 // add test if gMC is TGeant4
68 TGeant4* g4 = (TGeant4*)gMC;
69
70 g4->StartGeantUI();
71
72 // new Root prompt
73 Getlinem(kInit, ((TRint*)gROOT->GetApplication())->GetPrompt());
74 }
75 else {
76 cout << "Monte Carlo has not been yet created." << endl;
77 }
67d736ee 78}
79
80void GenerateXML()
81{
82 if (gMC) {
83 // release Root terminal control
84
85 // go into non-raw term mode
86 //Getlinem(kCleanUp, 0);
87
88 // add test if gMC is TGeant4
89 TGeant4* g4 = (TGeant4*)gMC;
90
91 g4->ProcessGeantCommand("/xml/generateAGDD");
92
93 // new Root prompt
94 //Getlinem(kInit, ((TRint*)gROOT->GetApplication())->GetPrompt());
95 }
96 else {
97 cout << "Monte Carlo has not been yet created." << endl;
98 }
99}
100
101void Quit()
102{
103 delete gAlice->GetRunLoader();
104 delete gAlice;
105
106 exit(0);
1fccbbe0 107}