Garfield++ v2r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
exampleGarfield.cc File Reference
#include "GarfieldDetectorConstruction.hh"
#include "GarfieldPhysics.hh"
#include "GarfieldPhysicsList.hh"
#include "GarfieldPrimaryGeneratorAction.hh"
#include "GarfieldRunAction.hh"
#include "GarfieldEventAction.hh"
#include "GarfieldSteppingAction.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4UIcommand.hh"
#include "Randomize.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
#include "Random.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 61 of file exampleGarfield.cc.

61 {
62
63
64 // Evaluate arguments
65 //
66 if (argc > 7) {
67 PrintUsage();
68 return 1;
69 }
70
71 G4String macro;
72 G4String session;
73
74 for (G4int i = 1; i < argc; i = i + 2) {
75 if (G4String(argv[i]) == "-m")
76 macro = argv[i + 1];
77 else if (G4String(argv[i]) == "-u")
78 session = argv[i + 1];
79 else {
80 PrintUsage();
81 return 1;
82 }
83 }
84
85 // Detect interactive mode (if no macro provided) and define UI session
86 //
87 G4UIExecutive* ui = 0;
88 if (!macro.size()) {
89 ui = new G4UIExecutive(argc, argv);
90 }
91
92 // Choose the Random engine
93 //
94 G4Random::setTheEngine(new CLHEP::RanecuEngine);
95 G4Random::setTheSeed(1);
96 //Choose seed for Garfield random engine
98
99
100 // Construct the default run manager
101 //
102 G4RunManager * runManager = new G4RunManager;
103
104 GarfieldDetectorConstruction* detConstruction =
106 runManager->SetUserInitialization(detConstruction);
107
108 runManager->SetUserInitialization(new GarfieldPhysicsList());
109
110
111 runManager->SetUserAction(new GarfieldPrimaryGeneratorAction);
112 runManager-> SetUserAction(new GarfieldRunAction);
113 GarfieldEventAction* eventAction = new GarfieldEventAction;
114 runManager->SetUserAction(eventAction);
115 runManager->SetUserAction(new GarfieldSteppingAction(detConstruction,eventAction));
116
117
118
119 // Initialize visualization
120 //
121 G4VisManager* visManager = new G4VisExecutive;
122 // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
123 // G4VisManager* visManager = new G4VisExecutive("Quiet");
124 visManager->Initialize();
125
126 // Get the pointer to the User Interface manager
127 G4UImanager* UImanager = G4UImanager::GetUIpointer();
128
129 // Process macro or start UI session
130 //
131 if (macro.size()) {
132 // batch mode
133 G4String command = "/control/execute ";
134 UImanager->ApplyCommand(command + macro);
135 } else {
136 // interactive mode : define UI session
137 UImanager->ApplyCommand("/control/execute init_vis.mac");
138 if (ui->IsGUI()) {
139 UImanager->ApplyCommand("/control/execute gui.mac");
140 }
141 ui->SessionStart();
142 delete ui;
143 }
144
145 // Job termination
146 // Free the store: user actions, physics_list and detector_description are
147 // owned and deleted by the run manager, so they should not be deleted
148 // in the main() program !
149
150 delete visManager;
151 delete runManager;
153}
static void Dispose()
void Seed(unsigned int s)
Initialise the random number generator.
RandomEngineRoot randomEngine
Random number generator.