]>
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 | |
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 | ||
25 | void 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 | ||
33 | // Menu | |
34 | TControlBar* menu = new TControlBar("vertical","Alice Geant4 menu"); | |
35 | ||
e14b4d5a | 36 | menu->AddButton("Geometry", "MakeGeometry()", "Generate Root geometry file"); |
37 | menu->AddButton("Run", "RunSimulation()", "Process Alice run"); | |
38 | menu->AddButton("Init", "Init()", "Initialize Alice for simulation"); | |
1fccbbe0 | 39 | menu->AddButton("Geant4UI", "StartGeant4UI()","Go to Geant4 Interactive session"); |
e14b4d5a | 40 | menu->AddButton("AGDD", "GenerateAGDD()","Generate XML (AGDD) file with geometry description"); |
41 | //menu->AddButton("GDML", "GenerateGDML()","Generate XML (GDML) file with geometry description"); | |
67d736ee | 42 | menu->AddButton("Quit", "Quit()", "Quit aliroot"); |
1fccbbe0 | 43 | gROOT->SaveContext(); |
e14b4d5a | 44 | |
45 | cout << endl | |
46 | << "**************************************************************" << endl | |
47 | << " To run simulation:" << endl | |
48 | << " First select <Geometry> to build geometry.root file." << endl | |
49 | << " Then re-run aliroot and select <Run> button" << endl | |
50 | << endl | |
51 | << " The <Init> button is kept for debugging purposes," << endl | |
52 | << " it itializes MonteCarlo but it does not itialize" << endl | |
53 | << " completely ALICE framework. That's why to run simulation," << endl | |
54 | << " you have to re-run aliroot and select Run button." << endl | |
55 | << endl | |
56 | << " The menu enables to start Geant4 interactive session:" << endl | |
57 | << " Select <Geant4UI> button and use Geant4 interactive commands" << endl | |
58 | << " To go back to Root UI, type exit." << endl | |
59 | << "**************************************************************" << endl | |
60 | << endl; | |
61 | ||
1fccbbe0 | 62 | menu->Show(); |
63 | } | |
64 | ||
e14b4d5a | 65 | void MakeGeometry() |
1fccbbe0 | 66 | { |
e14b4d5a | 67 | AliCDBManager* man = AliCDBManager::Instance(); |
162637e4 | 68 | man->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); |
e14b4d5a | 69 | man->SetRun(1); |
5e509454 | 70 | |
71 | // MC application initialization | |
72 | TString configFileName = "$ALICE_ROOT/macros/g4ConfigGeometry.C"; | |
73 | gROOT->LoadMacro(configFileName.Data()); | |
74 | gInterpreter->ProcessLine(gAlice->GetConfigFunction()); | |
75 | gAlice->GetMCApp()->Init(); | |
1fccbbe0 | 76 | |
e14b4d5a | 77 | // Generate geometry file |
78 | // | |
79 | gGeoManager->Export("geometry.root"); | |
1fccbbe0 | 80 | |
e14b4d5a | 81 | cout << endl |
82 | << "Geometry file geometry.root has been generated." << endl | |
83 | << "You have to re-run aliroot and choose Run in g4menu." << endl; | |
84 | ||
85 | exit(0); | |
86 | } | |
87 | ||
88 | ||
89 | void Init() | |
90 | { | |
91 | AliCDBManager* man = AliCDBManager::Instance(); | |
162637e4 | 92 | man->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); |
e14b4d5a | 93 | man->SetRun(0); |
5e509454 | 94 | |
95 | // MC application initialization | |
96 | TString configFileName = "$ALICE_ROOT/macros/g4Config.C"; | |
97 | gROOT->LoadMacro(configFileName.Data()); | |
98 | gInterpreter->ProcessLine(gAlice->GetConfigFunction()); | |
99 | gAlice->GetMCApp()->Init(); | |
e14b4d5a | 100 | |
101 | cout << endl | |
102 | << "Only MonteCarlo initialization has been performed. " << endl | |
103 | << "To run simulation you have to re-run aliroot and choose Run in g4menu." << endl; | |
104 | } | |
105 | ||
106 | ||
107 | void RunSimulation() | |
108 | { | |
109 | AliSimulation sim("$ALICE_ROOT/macros/g4Config.C"); | |
110 | sim.SetMakeDigits(""); | |
111 | sim.SetMakeSDigits(""); | |
112 | sim.SetRunHLT(""); | |
113 | sim.SetNumberOfEvents(1); | |
114 | TStopwatch timer; | |
115 | timer.Start(); | |
116 | sim.Run(1); | |
117 | timer.Stop(); | |
118 | timer.Print(); | |
1fccbbe0 | 119 | } |
120 | ||
121 | void StartGeant4UI() | |
122 | { | |
123 | if (gMC) { | |
124 | // release Root terminal control | |
125 | ||
126 | // go into non-raw term mode | |
127 | Getlinem(kCleanUp, 0); | |
128 | ||
129 | // add test if gMC is TGeant4 | |
130 | TGeant4* g4 = (TGeant4*)gMC; | |
131 | ||
132 | g4->StartGeantUI(); | |
133 | ||
134 | // new Root prompt | |
135 | Getlinem(kInit, ((TRint*)gROOT->GetApplication())->GetPrompt()); | |
136 | } | |
137 | else { | |
138 | cout << "Monte Carlo has not been yet created." << endl; | |
139 | } | |
67d736ee | 140 | } |
141 | ||
e14b4d5a | 142 | void GenerateAGDD() |
67d736ee | 143 | { |
144 | if (gMC) { | |
145 | // release Root terminal control | |
146 | ||
147 | // go into non-raw term mode | |
148 | //Getlinem(kCleanUp, 0); | |
149 | ||
150 | // add test if gMC is TGeant4 | |
151 | TGeant4* g4 = (TGeant4*)gMC; | |
152 | ||
e14b4d5a | 153 | g4->ProcessGeantCommand("/vgm/generateAGDD"); |
67d736ee | 154 | |
155 | // new Root prompt | |
156 | //Getlinem(kInit, ((TRint*)gROOT->GetApplication())->GetPrompt()); | |
157 | } | |
158 | else { | |
159 | cout << "Monte Carlo has not been yet created." << endl; | |
160 | } | |
161 | } | |
e14b4d5a | 162 | /* |
163 | void GenerateGDML() | |
164 | { | |
165 | if (gMC) { | |
166 | // release Root terminal control | |
167 | ||
168 | // go into non-raw term mode | |
169 | //Getlinem(kCleanUp, 0); | |
170 | ||
171 | // add test if gMC is TGeant4 | |
172 | TGeant4* g4 = (TGeant4*)gMC; | |
173 | ||
174 | g4->ProcessGeantCommand("/vgm/generateGDML"); | |
67d736ee | 175 | |
e14b4d5a | 176 | // new Root prompt |
177 | //Getlinem(kInit, ((TRint*)gROOT->GetApplication())->GetPrompt()); | |
178 | } | |
179 | else { | |
180 | cout << "Monte Carlo has not been yet created." << endl; | |
181 | } | |
182 | } | |
183 | */ | |
67d736ee | 184 | void Quit() |
185 | { | |
33c3c91a | 186 | delete AliRunLoader::Instance(); |
67d736ee | 187 | delete gAlice; |
188 | ||
189 | exit(0); | |
1fccbbe0 | 190 | } |