]> git.uio.no Git - u/mrichter/AliRoot.git/blob - macros/g4menu.C
Removed macros not compatible with current package
[u/mrichter/AliRoot.git] / macros / g4menu.C
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 //  --> First select "Geometry" to build geometry.root file
9 //  --> Then re-run aliroot and select "Run" button
10 //          
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:
17 //  --> Select "Geant4UI" button and use Geant4 interactive commands;
18 // To go back to Root UI, type exit.
19 //
20 // By I. Hrivnacova, IPN Orsay
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   
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");
39   menu->AddButton("Geant4UI", "StartGeant4UI()","Go to Geant4 Interactive session");
40   menu->AddButton("AGDD",     "GenerateAGDD()","Generate XML (AGDD) file with geometry description");
41   //menu->AddButton("GDML",     "GenerateGDML()","Generate XML (GDML) file with geometry description");
42   menu->AddButton("Quit",     "Quit()", "Quit aliroot");
43   gROOT->SaveContext();
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   
62   menu->Show();
63 }
64
65 void MakeGeometry()
66 {  
67   AliCDBManager* man = AliCDBManager::Instance();
68   man->SetDefaultStorage("local://$ALICE_ROOT");
69   man->SetRun(1);
70   gAlice->Init("$ALICE_ROOT/macros/g4ConfigGeometry.C");
71   
72   // Generate geometry file
73   //
74   gGeoManager->Export("geometry.root");
75   
76   cout << endl
77        << "Geometry file geometry.root has been generated." << endl
78        << "You have to re-run aliroot and choose Run in g4menu." << endl;
79        
80   exit(0);     
81 }    
82
83
84 void Init()
85 {  
86   AliCDBManager* man = AliCDBManager::Instance();
87   man->SetDefaultStorage("local://$ALICE_ROOT");
88   man->SetRun(0);
89   gAlice->Init("$ALICE_ROOT/macros/g4Config.C");
90
91   cout << endl
92        << "Only MonteCarlo initialization has been performed. " << endl
93        << "To run simulation you have to re-run aliroot and choose Run in g4menu." << endl;
94 }    
95
96
97 void RunSimulation()
98 {  
99   AliSimulation sim("$ALICE_ROOT/macros/g4Config.C");
100   sim.SetMakeDigits("");
101   sim.SetMakeSDigits("");
102   sim.SetRunHLT("");
103   sim.SetNumberOfEvents(1);
104   TStopwatch timer;
105   timer.Start();
106   sim.Run(1);
107   timer.Stop();
108   timer.Print();
109 }    
110
111 void StartGeant4UI()
112 {
113   if (gMC) {
114     // release Root terminal control
115
116     // go into non-raw term mode
117     Getlinem(kCleanUp, 0);
118     
119     // add test if gMC is TGeant4
120     TGeant4* g4 = (TGeant4*)gMC;
121   
122     g4->StartGeantUI();
123
124     // new Root prompt
125     Getlinem(kInit, ((TRint*)gROOT->GetApplication())->GetPrompt());  
126   }
127   else {  
128     cout << "Monte Carlo has not been yet created." << endl;
129   }       
130
131
132 void GenerateAGDD()
133 {
134   if (gMC) {
135     // release Root terminal control
136
137     // go into non-raw term mode
138     //Getlinem(kCleanUp, 0);
139     
140     // add test if gMC is TGeant4
141     TGeant4* g4 = (TGeant4*)gMC;
142     
143     g4->ProcessGeantCommand("/vgm/generateAGDD");
144
145     // new Root prompt
146     //Getlinem(kInit, ((TRint*)gROOT->GetApplication())->GetPrompt());  
147   }
148   else {  
149     cout << "Monte Carlo has not been yet created." << endl;
150   } 
151 }        
152 /*
153 void GenerateGDML()
154 {
155   if (gMC) {
156     // release Root terminal control
157
158     // go into non-raw term mode
159     //Getlinem(kCleanUp, 0);
160     
161     // add test if gMC is TGeant4
162     TGeant4* g4 = (TGeant4*)gMC;
163     
164     g4->ProcessGeantCommand("/vgm/generateGDML");
165
166     // new Root prompt
167     //Getlinem(kInit, ((TRint*)gROOT->GetApplication())->GetPrompt());  
168   }
169   else {  
170     cout << "Monte Carlo has not been yet created." << endl;
171   } 
172 }        
173 */
174 void Quit()
175 {
176   delete gAlice->GetRunLoader();
177   delete gAlice;
178   
179   exit(0);
180 }