[807] | 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 | // |
---|
[1337] | 27 | // $Id: exampleN03Con.cc,v 1.4 2010/05/12 12:45:06 allison Exp $ |
---|
| 28 | // GEANT4 tag $Name: geant4-09-04-beta-01 $ |
---|
[807] | 29 | // |
---|
| 30 | // |
---|
| 31 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 32 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 33 | |
---|
| 34 | #include "G4RunManager.hh" |
---|
| 35 | #include "G4UImanager.hh" |
---|
| 36 | |
---|
| 37 | #include "Randomize.hh" |
---|
| 38 | |
---|
| 39 | #ifdef G4VIS_USE |
---|
| 40 | #include "G4VisExecutive.hh" |
---|
| 41 | #endif |
---|
| 42 | |
---|
[1337] | 43 | #ifdef G4UI_USE |
---|
| 44 | #include "G4UIExecutive.hh" |
---|
| 45 | #endif |
---|
| 46 | |
---|
[807] | 47 | #include "ExN03DetectorConstruction.hh" |
---|
| 48 | #include "ExN03PhysicsList.hh" |
---|
| 49 | #include "ExN03PrimaryGeneratorAction.hh" |
---|
| 50 | #include "ExN03RunAction.hh" |
---|
| 51 | #include "ExN03EventAction.hh" |
---|
| 52 | #include "ExN03SteppingAction.hh" |
---|
| 53 | #include "ExN03SteppingVerbose.hh" |
---|
| 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); |
---|
| 62 | |
---|
| 63 | // User Verbose output class |
---|
| 64 | // |
---|
| 65 | G4VSteppingVerbose* verbosity = new ExN03SteppingVerbose; |
---|
| 66 | G4VSteppingVerbose::SetInstance(verbosity); |
---|
| 67 | |
---|
| 68 | // Construct the default run manager |
---|
| 69 | // |
---|
| 70 | G4RunManager * runManager = new G4RunManager; |
---|
| 71 | |
---|
| 72 | // Set mandatory initialization classes |
---|
| 73 | // |
---|
| 74 | ExN03DetectorConstruction* detector = new ExN03DetectorConstruction; |
---|
| 75 | runManager->SetUserInitialization(detector); |
---|
| 76 | // |
---|
| 77 | G4VUserPhysicsList* physics = new ExN03PhysicsList; |
---|
| 78 | runManager->SetUserInitialization(physics); |
---|
| 79 | |
---|
| 80 | // Set user action classes |
---|
| 81 | // |
---|
| 82 | G4VUserPrimaryGeneratorAction* gen_action = new ExN03PrimaryGeneratorAction(detector); |
---|
| 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 = |
---|
| 92 | new ExN03SteppingAction(detector, event_action); |
---|
| 93 | runManager->SetUserAction(stepping_action); |
---|
| 94 | |
---|
| 95 | // Initialize G4 kernel |
---|
| 96 | // |
---|
| 97 | runManager->Initialize(); |
---|
| 98 | |
---|
[1337] | 99 | #ifdef G4VIS_USE |
---|
| 100 | // Visualization manager |
---|
| 101 | // |
---|
| 102 | G4VisManager* visManager = new G4VisExecutive; |
---|
| 103 | visManager->Initialize(); |
---|
| 104 | #endif |
---|
| 105 | |
---|
[807] | 106 | // Get the pointer to the User Interface manager |
---|
| 107 | // |
---|
[1337] | 108 | G4UImanager* UImanager = G4UImanager::GetUIpointer(); |
---|
[807] | 109 | |
---|
[1337] | 110 | if (argc!=1) // batch mode |
---|
[807] | 111 | { |
---|
| 112 | #ifdef G4VIS_USE |
---|
| 113 | visManager->SetVerboseLevel("quiet"); |
---|
| 114 | #endif |
---|
| 115 | G4String command = "/control/execute "; |
---|
| 116 | G4String fileName = argv[1]; |
---|
[1337] | 117 | UImanager->ApplyCommand(command+fileName); |
---|
[807] | 118 | } |
---|
[1337] | 119 | else |
---|
| 120 | { // interactive mode : define UI session |
---|
| 121 | #ifdef G4UI_USE |
---|
| 122 | G4UIExecutive* ui = new G4UIExecutive(argc, argv); |
---|
| 123 | ui->SessionStart(); |
---|
| 124 | delete ui; |
---|
| 125 | #endif |
---|
| 126 | } |
---|
[807] | 127 | |
---|
| 128 | // Job termination |
---|
| 129 | // Free the store: user actions, physics_list and detector_description are |
---|
| 130 | // owned and deleted by the run manager, so they should not |
---|
| 131 | // be deleted in the main() program ! |
---|
| 132 | |
---|
| 133 | #ifdef G4VIS_USE |
---|
| 134 | delete visManager; |
---|
| 135 | #endif |
---|
| 136 | delete runManager; |
---|
| 137 | delete verbosity; |
---|
| 138 | |
---|
| 139 | return 0; |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|