[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 | |
---|
[1234] | 39 | #include "qcoreapplication.h" |
---|
| 40 | |
---|
[609] | 41 | #include "ExN03DetectorConstruction.hh" |
---|
| 42 | #include "ExN03PhysicsList.hh" |
---|
| 43 | #include "ExN03PrimaryGeneratorAction.hh" |
---|
| 44 | #include "ExN03RunAction.hh" |
---|
| 45 | #include "ExN03EventAction.hh" |
---|
| 46 | #include "ExN03SteppingAction.hh" |
---|
| 47 | #include "ExN03SteppingVerbose.hh" |
---|
| 48 | |
---|
| 49 | #ifdef G4VIS_USE |
---|
| 50 | #include "G4VisExecutive.hh" |
---|
| 51 | #endif |
---|
| 52 | |
---|
[1143] | 53 | #ifdef G4UI_USE |
---|
| 54 | #include "G4UIExecutive.hh" |
---|
[474] | 55 | #endif |
---|
| 56 | |
---|
[1234] | 57 | //#define MAC_OSX_APP 1 |
---|
| 58 | |
---|
[474] | 59 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 60 | |
---|
| 61 | int main(int argc,char** argv) |
---|
| 62 | { |
---|
| 63 | // Choose the Random engine |
---|
| 64 | // |
---|
| 65 | CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); |
---|
[609] | 66 | |
---|
[474] | 67 | // User Verbose output class |
---|
| 68 | // |
---|
[609] | 69 | G4VSteppingVerbose::SetInstance(new ExN03SteppingVerbose); |
---|
[474] | 70 | |
---|
| 71 | // Construct the default run manager |
---|
| 72 | // |
---|
| 73 | G4RunManager * runManager = new G4RunManager; |
---|
| 74 | |
---|
| 75 | // Set mandatory initialization classes |
---|
| 76 | // |
---|
| 77 | ExN03DetectorConstruction* detector = new ExN03DetectorConstruction; |
---|
| 78 | runManager->SetUserInitialization(detector); |
---|
| 79 | // |
---|
| 80 | G4VUserPhysicsList* physics = new ExN03PhysicsList; |
---|
| 81 | runManager->SetUserInitialization(physics); |
---|
[609] | 82 | |
---|
[474] | 83 | // Set user action classes |
---|
| 84 | // |
---|
[609] | 85 | G4VUserPrimaryGeneratorAction* gen_action = |
---|
| 86 | new ExN03PrimaryGeneratorAction(detector); |
---|
[474] | 87 | runManager->SetUserAction(gen_action); |
---|
| 88 | // |
---|
| 89 | ExN03RunAction* run_action = new ExN03RunAction; |
---|
| 90 | runManager->SetUserAction(run_action); |
---|
| 91 | // |
---|
| 92 | ExN03EventAction* event_action = new ExN03EventAction(run_action); |
---|
| 93 | runManager->SetUserAction(event_action); |
---|
| 94 | // |
---|
| 95 | G4UserSteppingAction* stepping_action = |
---|
[609] | 96 | new ExN03SteppingAction(detector, event_action); |
---|
[474] | 97 | runManager->SetUserAction(stepping_action); |
---|
| 98 | |
---|
| 99 | // Initialize G4 kernel |
---|
| 100 | // |
---|
| 101 | runManager->Initialize(); |
---|
[609] | 102 | |
---|
[887] | 103 | #ifdef G4VIS_USE |
---|
| 104 | // Initialize visualization |
---|
| 105 | // |
---|
| 106 | G4VisManager* visManager = new G4VisExecutive; |
---|
| 107 | visManager->Initialize(); |
---|
| 108 | #endif |
---|
| 109 | |
---|
[474] | 110 | // Get the pointer to the User Interface manager |
---|
| 111 | // |
---|
[1143] | 112 | G4UImanager* UImanager = G4UImanager::GetUIpointer(); |
---|
[609] | 113 | |
---|
[1234] | 114 | |
---|
| 115 | #ifdef MAC_OSX_APP |
---|
| 116 | std::string progName = argv[0]; |
---|
| 117 | std::string::size_type pos = progName.find(".app/Contents/MacOS/",0); |
---|
| 118 | if (pos != std::string::npos) { |
---|
| 119 | std::string progDir = progName.substr(0,pos+4); |
---|
| 120 | chdir((progDir+"/Contents/macros").c_str()); |
---|
| 121 | argc = 1; |
---|
| 122 | } |
---|
| 123 | #endif |
---|
| 124 | |
---|
[609] | 125 | if (argc!=1) // batch mode |
---|
[474] | 126 | { |
---|
[609] | 127 | G4String command = "/control/execute "; |
---|
| 128 | G4String fileName = argv[1]; |
---|
[1143] | 129 | UImanager->ApplyCommand(command+fileName); |
---|
[609] | 130 | } |
---|
[1143] | 131 | else |
---|
| 132 | { // interactive mode : define UI session |
---|
| 133 | #ifdef G4UI_USE |
---|
[1209] | 134 | G4UIExecutive* ui = new G4UIExecutive(argc,argv); |
---|
[887] | 135 | #ifdef G4VIS_USE |
---|
[1143] | 136 | UImanager->ApplyCommand("/control/execute vis.mac"); |
---|
[659] | 137 | #endif |
---|
[1143] | 138 | if (ui->IsGUI()) |
---|
| 139 | UImanager->ApplyCommand("/control/execute visTutor/gui.mac"); |
---|
| 140 | ui->SessionStart(); |
---|
| 141 | delete ui; |
---|
| 142 | #endif |
---|
[474] | 143 | } |
---|
[1143] | 144 | |
---|
[474] | 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 |
---|
| 148 | // be deleted in the main() program ! |
---|
[887] | 149 | #ifdef G4VIS_USE |
---|
| 150 | delete visManager; |
---|
| 151 | #endif |
---|
[474] | 152 | delete runManager; |
---|
| 153 | |
---|
| 154 | return 0; |
---|
| 155 | } |
---|
| 156 | |
---|
| 157 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|