Garfield++ v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
exampleGarfield.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// $Id: exampleB4a.cc 86065 2014-11-07 08:51:15Z gcosmo $
27//
28/// \file exampleB4a.cc
29/// \brief Main program of the B4a example
30
32#include "GarfieldPhysics.hh"
35#include "GarfieldRunAction.hh"
38#include "G4RunManager.hh"
39#include "G4UImanager.hh"
40#include "G4UIcommand.hh"
41
42#include "Randomize.hh"
43
44#include "G4VisExecutive.hh"
45#include "G4UIExecutive.hh"
46
47//Header for Garfield random engine
48#include "Random.hh"
49//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
50
51namespace {
52void PrintUsage() {
53 G4cerr << " Usage: " << G4endl;
54 G4cerr << " Garfield++ [-m macro ] [-u UIsession]" << G4endl;
55
56}
57}
58
59//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60
61int main(int argc, char** argv) {
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}
154
155//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
Definition of the GarfieldDetectorConstruction class.
Definition of the GarfieldEventAction class.
Definition of the GarfieldPhysicsList class.
Definition of the GarfieldPhysics class.
Definition of the GarfieldPrimaryGeneratorAction class.
Definition of the GarfieldRunAction class.
Definition of the GarfieldSteppingAction class.
static void Dispose()
void Seed(unsigned int s)
int main(int argc, char **argv)
RandomEngineRoot randomEngine