[474] | 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 | // |
---|
[1143] | 27 | // $Id: exampleN03.cc,v 1.37 2009/10/30 15:06:01 allison Exp $ |
---|
[1209] | 28 | // GEANT4 tag $Name: geant4-09-03-cand-01 $ |
---|
[474] | 29 | // |
---|
| 30 | // |
---|
| 31 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 32 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 33 | |
---|
| 34 | #include "G4RunManager.hh" |
---|
| 35 | #include "G4UImanager.hh" |
---|
| 36 | |
---|
[609] | 37 | #include "Randomize.hh" |
---|
| 38 | |
---|
| 39 | #include "ExN03DetectorConstruction.hh" |
---|
| 40 | #include "ExN03PhysicsList.hh" |
---|
| 41 | #include "ExN03PrimaryGeneratorAction.hh" |
---|
| 42 | #include "ExN03RunAction.hh" |
---|
| 43 | #include "ExN03EventAction.hh" |
---|
| 44 | #include "ExN03SteppingAction.hh" |
---|
| 45 | #include "ExN03SteppingVerbose.hh" |
---|
| 46 | |
---|
| 47 | #ifdef G4VIS_USE |
---|
| 48 | #include "G4VisExecutive.hh" |
---|
| 49 | #endif |
---|
| 50 | |
---|
[1143] | 51 | #ifdef G4UI_USE |
---|
| 52 | #include "G4UIExecutive.hh" |
---|
[474] | 53 | #endif |
---|
| 54 | |
---|
| 55 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 56 | |
---|
| 57 | int main(int argc,char** argv) |
---|
| 58 | { |
---|
| 59 | // Choose the Random engine |
---|
| 60 | // |
---|
| 61 | CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); |
---|
[609] | 62 | |
---|
[474] | 63 | // User Verbose output class |
---|
| 64 | // |
---|
[609] | 65 | G4VSteppingVerbose::SetInstance(new ExN03SteppingVerbose); |
---|
[474] | 66 | |
---|
| 67 | // Construct the default run manager |
---|
| 68 | // |
---|
| 69 | G4RunManager * runManager = new G4RunManager; |
---|
| 70 | |
---|
| 71 | // Set mandatory initialization classes |
---|
| 72 | // |
---|
| 73 | ExN03DetectorConstruction* detector = new ExN03DetectorConstruction; |
---|
| 74 | runManager->SetUserInitialization(detector); |
---|
| 75 | // |
---|
| 76 | G4VUserPhysicsList* physics = new ExN03PhysicsList; |
---|
| 77 | runManager->SetUserInitialization(physics); |
---|
[609] | 78 | |
---|
[474] | 79 | // Set user action classes |
---|
| 80 | // |
---|
[609] | 81 | G4VUserPrimaryGeneratorAction* gen_action = |
---|
| 82 | new ExN03PrimaryGeneratorAction(detector); |
---|
[474] | 83 | runManager->SetUserAction(gen_action); |
---|
| 84 | // |
---|
| 85 | ExN03RunAction* run_action = new ExN03RunAction; |
---|
| 86 | runManager->SetUserAction(run_action); |
---|
| 87 | // |
---|
| 88 | ExN03EventAction* event_action = new ExN03EventAction(run_action); |
---|
| 89 | runManager->SetUserAction(event_action); |
---|
| 90 | // |
---|
| 91 | G4UserSteppingAction* stepping_action = |
---|
[609] | 92 | new ExN03SteppingAction(detector, event_action); |
---|
[474] | 93 | runManager->SetUserAction(stepping_action); |
---|
| 94 | |
---|
| 95 | // Initialize G4 kernel |
---|
| 96 | // |
---|
| 97 | runManager->Initialize(); |
---|
[609] | 98 | |
---|
[887] | 99 | #ifdef G4VIS_USE |
---|
| 100 | // Initialize visualization |
---|
| 101 | // |
---|
| 102 | G4VisManager* visManager = new G4VisExecutive; |
---|
| 103 | visManager->Initialize(); |
---|
| 104 | #endif |
---|
| 105 | |
---|
[474] | 106 | // Get the pointer to the User Interface manager |
---|
| 107 | // |
---|
[1143] | 108 | G4UImanager* UImanager = G4UImanager::GetUIpointer(); |
---|
[609] | 109 | |
---|
| 110 | if (argc!=1) // batch mode |
---|
[474] | 111 | { |
---|
[609] | 112 | G4String command = "/control/execute "; |
---|
| 113 | G4String fileName = argv[1]; |
---|
[1143] | 114 | UImanager->ApplyCommand(command+fileName); |
---|
[609] | 115 | } |
---|
[1143] | 116 | else |
---|
| 117 | { // interactive mode : define UI session |
---|
| 118 | #ifdef G4UI_USE |
---|
[1209] | 119 | G4UIExecutive* ui = new G4UIExecutive(argc,argv); |
---|
[887] | 120 | #ifdef G4VIS_USE |
---|
[1143] | 121 | UImanager->ApplyCommand("/control/execute vis.mac"); |
---|
[659] | 122 | #endif |
---|
[1143] | 123 | if (ui->IsGUI()) |
---|
| 124 | UImanager->ApplyCommand("/control/execute visTutor/gui.mac"); |
---|
| 125 | ui->SessionStart(); |
---|
| 126 | delete ui; |
---|
| 127 | #endif |
---|
[474] | 128 | } |
---|
[1143] | 129 | |
---|
[474] | 130 | // Job termination |
---|
| 131 | // Free the store: user actions, physics_list and detector_description are |
---|
| 132 | // owned and deleted by the run manager, so they should not |
---|
| 133 | // be deleted in the main() program ! |
---|
[887] | 134 | #ifdef G4VIS_USE |
---|
| 135 | delete visManager; |
---|
| 136 | #endif |
---|
[474] | 137 | delete runManager; |
---|
| 138 | |
---|
| 139 | return 0; |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|