]> git.uio.no Git - u/mrichter/AliRoot.git/blame - macros/g4menu.C
more centrality bins
[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
e14b4d5a 8// --> First select "Geometry" to build geometry.root file
9// --> Then re-run aliroot and select "Run" button
1fccbbe0 10//
e14b4d5a 11// The Init button is kept for debugging purposes,
12// it itializes MonteCarlo but it does not itialize
13// completely ALICE framework. That's why to run simulation,
14// you have to re-run aliroot and select Run button.
15//
16// The menu enables to start Geant4 interactive session:
1fccbbe0 17// --> Select "Geant4UI" button and use Geant4 interactive commands;
1fccbbe0 18// To go back to Root UI, type exit.
e14b4d5a 19//
20// By I. Hrivnacova, IPN Orsay
1fccbbe0 21
22
23#include <iostream>
24
25void g4menu()
26{
27
28 // Load Geant4 libraries
29 if (!gInterpreter->IsLoaded("$ALICE/geant4_vmc/examples/macro/g4libs.C"))
30 gROOT->LoadMacro("$ALICE/geant4_vmc/examples/macro/g4libs.C");
31 gInterpreter->ProcessLine("g4libs()");
32
dde0a601 33 // Load ALICE Geant4 library
34 //cout << "Loading g4alice library ..." << endl;
35 //gSystem->Load("libg4alice");
36
1fccbbe0 37 // Menu
38 TControlBar* menu = new TControlBar("vertical","Alice Geant4 menu");
39
e14b4d5a 40 menu->AddButton("Geometry", "MakeGeometry()", "Generate Root geometry file");
dde0a601 41 menu->AddButton("Run G4", "RunG4Simulation()", "Process Alice run");
42 menu->AddButton("Run G4 batch", "RunG4Simulation(); >& g4.out", "Process Alice run");
43 menu->AddButton("Run G3", "RunG3Simulation()", "Process Alice run");
44 menu->AddButton("Run G3 batch", "RunG3Simulation(); >& g3.out", "Process Alice run");
45 menu->AddButton("Init", "Init();", "Initialize Alice for G4 simulation");
46 menu->AddButton("Init batch","Init(); >& g4init.out", "Initialize Alice for G4 simulation");
1fccbbe0 47 menu->AddButton("Geant4UI", "StartGeant4UI()","Go to Geant4 Interactive session");
e14b4d5a 48 menu->AddButton("AGDD", "GenerateAGDD()","Generate XML (AGDD) file with geometry description");
49 //menu->AddButton("GDML", "GenerateGDML()","Generate XML (GDML) file with geometry description");
67d736ee 50 menu->AddButton("Quit", "Quit()", "Quit aliroot");
1fccbbe0 51 gROOT->SaveContext();
e14b4d5a 52
53 cout << endl
54 << "**************************************************************" << endl
55 << " To run simulation:" << endl
56 << " First select <Geometry> to build geometry.root file." << endl
57 << " Then re-run aliroot and select <Run> button" << endl
58 << endl
59 << " The <Init> button is kept for debugging purposes," << endl
60 << " it itializes MonteCarlo but it does not itialize" << endl
61 << " completely ALICE framework. That's why to run simulation," << endl
62 << " you have to re-run aliroot and select Run button." << endl
63 << endl
64 << " The menu enables to start Geant4 interactive session:" << endl
65 << " Select <Geant4UI> button and use Geant4 interactive commands" << endl
66 << " To go back to Root UI, type exit." << endl
67 << "**************************************************************" << endl
68 << endl;
69
1fccbbe0 70 menu->Show();
71}
72
e14b4d5a 73void MakeGeometry()
1fccbbe0 74{
e14b4d5a 75 AliCDBManager* man = AliCDBManager::Instance();
162637e4 76 man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
e14b4d5a 77 man->SetRun(1);
5e509454 78
79 // MC application initialization
80 TString configFileName = "$ALICE_ROOT/macros/g4ConfigGeometry.C";
81 gROOT->LoadMacro(configFileName.Data());
82 gInterpreter->ProcessLine(gAlice->GetConfigFunction());
83 gAlice->GetMCApp()->Init();
1fccbbe0 84
e14b4d5a 85 // Generate geometry file
86 //
87 gGeoManager->Export("geometry.root");
1fccbbe0 88
e14b4d5a 89 cout << endl
90 << "Geometry file geometry.root has been generated." << endl
91 << "You have to re-run aliroot and choose Run in g4menu." << endl;
92
93 exit(0);
94}
95
96
97void Init()
98{
99 AliCDBManager* man = AliCDBManager::Instance();
162637e4 100 man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
e14b4d5a 101 man->SetRun(0);
5e509454 102
103 // MC application initialization
104 TString configFileName = "$ALICE_ROOT/macros/g4Config.C";
105 gROOT->LoadMacro(configFileName.Data());
106 gInterpreter->ProcessLine(gAlice->GetConfigFunction());
107 gAlice->GetMCApp()->Init();
e14b4d5a 108
dde0a601 109 ((TGeant4*)gMC)->ProcessGeantCommand("/mcDet/printMedia");
110
e14b4d5a 111 cout << endl
112 << "Only MonteCarlo initialization has been performed. " << endl
113 << "To run simulation you have to re-run aliroot and choose Run in g4menu." << endl;
114}
115
116
dde0a601 117void RunG4Simulation()
e14b4d5a 118{
119 AliSimulation sim("$ALICE_ROOT/macros/g4Config.C");
dde0a601 120 sim.SetMakeSDigits("");
e14b4d5a 121 sim.SetMakeDigits("");
dde0a601 122 //sim.SetMakeDigitsFromHits("ITS TPC");
123 //sim.SetMakeDigitsFromHits("ITS");
124 sim.SetMakeDigitsFromHits("");
125 sim.SetRunHLT("");
126 sim.SetNumberOfEvents(1000);
127 TStopwatch timer;
128 timer.Start();
129 sim.Run(1);
130 timer.Stop();
131 timer.Print();
132}
133
134void RunG3Simulation()
135{
136 AliSimulation sim("$ALICE_ROOT/macros/g3Config.C");
e14b4d5a 137 sim.SetMakeSDigits("");
dde0a601 138 sim.SetMakeDigits("");
139 //sim.SetMakeDigitsFromHits("ITS TPC");
140 //sim.SetMakeDigitsFromHits("ITS");
141 sim.SetMakeDigitsFromHits("");
e14b4d5a 142 sim.SetRunHLT("");
dde0a601 143 sim.SetNumberOfEvents(1000);
e14b4d5a 144 TStopwatch timer;
145 timer.Start();
146 sim.Run(1);
147 timer.Stop();
148 timer.Print();
1fccbbe0 149}
150
151void StartGeant4UI()
152{
153 if (gMC) {
154 // release Root terminal control
155
156 // go into non-raw term mode
157 Getlinem(kCleanUp, 0);
158
159 // add test if gMC is TGeant4
160 TGeant4* g4 = (TGeant4*)gMC;
161
162 g4->StartGeantUI();
163
164 // new Root prompt
165 Getlinem(kInit, ((TRint*)gROOT->GetApplication())->GetPrompt());
166 }
167 else {
168 cout << "Monte Carlo has not been yet created." << endl;
169 }
67d736ee 170}
171
e14b4d5a 172void GenerateAGDD()
67d736ee 173{
174 if (gMC) {
175 // release Root terminal control
176
177 // go into non-raw term mode
178 //Getlinem(kCleanUp, 0);
179
180 // add test if gMC is TGeant4
181 TGeant4* g4 = (TGeant4*)gMC;
182
e14b4d5a 183 g4->ProcessGeantCommand("/vgm/generateAGDD");
67d736ee 184
185 // new Root prompt
186 //Getlinem(kInit, ((TRint*)gROOT->GetApplication())->GetPrompt());
187 }
188 else {
189 cout << "Monte Carlo has not been yet created." << endl;
190 }
191}
e14b4d5a 192/*
193void GenerateGDML()
194{
195 if (gMC) {
196 // release Root terminal control
197
198 // go into non-raw term mode
199 //Getlinem(kCleanUp, 0);
200
201 // add test if gMC is TGeant4
202 TGeant4* g4 = (TGeant4*)gMC;
203
204 g4->ProcessGeantCommand("/vgm/generateGDML");
67d736ee 205
e14b4d5a 206 // new Root prompt
207 //Getlinem(kInit, ((TRint*)gROOT->GetApplication())->GetPrompt());
208 }
209 else {
210 cout << "Monte Carlo has not been yet created." << endl;
211 }
212}
213*/
67d736ee 214void Quit()
215{
33c3c91a 216 delete AliRunLoader::Instance();
67d736ee 217 delete gAlice;
218
219 exit(0);
1fccbbe0 220}