]>
Commit | Line | Data |
---|---|---|
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 | ||
19 | void 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"); | |
34 | gROOT->SaveContext(); | |
35 | menu->Show(); | |
36 | } | |
37 | ||
38 | void CreateGeant4() | |
39 | { | |
40 | if (!gMC) { | |
41 | ||
42 | // TG4RunConfiguration for Geant4 | |
43 | TG4RunConfiguration* runConfiguration | |
44 | = new TG4RunConfiguration(true); | |
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 | ||
57 | void 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 | } |