3 // Root macro that opens a mini GUI for running aliroot with Geant4.
5 // To run aliroot with Geant4 using the g4menu.C:
7 // root [0] .x g4menu.C
8 // --> First select "Geometry" to build geometry.root file
9 // --> Then re-run aliroot and select "Run" button
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.
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.
20 // By I. Hrivnacova, IPN Orsay
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()");
33 // Load ALICE Geant4 library
34 //cout << "Loading g4alice library ..." << endl;
35 //gSystem->Load("libg4alice");
38 TControlBar* menu = new TControlBar("vertical","Alice Geant4 menu");
40 menu->AddButton("Geometry", "MakeGeometry()", "Generate Root geometry file");
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");
47 menu->AddButton("Geant4UI", "StartGeant4UI()","Go to Geant4 Interactive session");
48 menu->AddButton("AGDD", "GenerateAGDD()","Generate XML (AGDD) file with geometry description");
49 //menu->AddButton("GDML", "GenerateGDML()","Generate XML (GDML) file with geometry description");
50 menu->AddButton("Quit", "Quit()", "Quit aliroot");
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
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
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
75 AliCDBManager* man = AliCDBManager::Instance();
76 man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
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();
85 // Generate geometry file
87 gGeoManager->Export("geometry.root");
90 << "Geometry file geometry.root has been generated." << endl
91 << "You have to re-run aliroot and choose Run in g4menu." << endl;
99 AliCDBManager* man = AliCDBManager::Instance();
100 man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
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();
109 ((TGeant4*)gMC)->ProcessGeantCommand("/mcDet/printMedia");
112 << "Only MonteCarlo initialization has been performed. " << endl
113 << "To run simulation you have to re-run aliroot and choose Run in g4menu." << endl;
117 void RunG4Simulation()
119 AliSimulation sim("$ALICE_ROOT/macros/g4Config.C");
120 sim.SetMakeSDigits("");
121 sim.SetMakeDigits("");
122 //sim.SetMakeDigitsFromHits("ITS TPC");
123 //sim.SetMakeDigitsFromHits("ITS");
124 sim.SetMakeDigitsFromHits("");
126 sim.SetNumberOfEvents(1000);
134 void RunG3Simulation()
136 AliSimulation sim("$ALICE_ROOT/macros/g3Config.C");
137 sim.SetMakeSDigits("");
138 sim.SetMakeDigits("");
139 //sim.SetMakeDigitsFromHits("ITS TPC");
140 //sim.SetMakeDigitsFromHits("ITS");
141 sim.SetMakeDigitsFromHits("");
143 sim.SetNumberOfEvents(1000);
154 // release Root terminal control
156 // go into non-raw term mode
157 Getlinem(kCleanUp, 0);
159 // add test if gMC is TGeant4
160 TGeant4* g4 = (TGeant4*)gMC;
165 Getlinem(kInit, ((TRint*)gROOT->GetApplication())->GetPrompt());
168 cout << "Monte Carlo has not been yet created." << endl;
175 // release Root terminal control
177 // go into non-raw term mode
178 //Getlinem(kCleanUp, 0);
180 // add test if gMC is TGeant4
181 TGeant4* g4 = (TGeant4*)gMC;
183 g4->ProcessGeantCommand("/vgm/generateAGDD");
186 //Getlinem(kInit, ((TRint*)gROOT->GetApplication())->GetPrompt());
189 cout << "Monte Carlo has not been yet created." << endl;
196 // release Root terminal control
198 // go into non-raw term mode
199 //Getlinem(kCleanUp, 0);
201 // add test if gMC is TGeant4
202 TGeant4* g4 = (TGeant4*)gMC;
204 g4->ProcessGeantCommand("/vgm/generateGDML");
207 //Getlinem(kInit, ((TRint*)gROOT->GetApplication())->GetPrompt());
210 cout << "Monte Carlo has not been yet created." << endl;
216 delete AliRunLoader::Instance();