[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 | // |
---|
[1342] | 27 | <<<<<<< exampleN03.cc |
---|
[1143] | 28 | // $Id: exampleN03.cc,v 1.37 2009/10/30 15:06:01 allison Exp $ |
---|
[1337] | 29 | // GEANT4 tag $Name: geant4-09-04-beta-01 $ |
---|
[1342] | 30 | ======= |
---|
| 31 | // $Id: exampleN03.cc,v 1.38 2010/10/18 15:56:17 maire Exp $ |
---|
| 32 | // GEANT4 tag $Name: $ |
---|
| 33 | >>>>>>> 1.38 |
---|
[474] | 34 | // |
---|
| 35 | // |
---|
| 36 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 37 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 38 | |
---|
| 39 | #include "G4RunManager.hh" |
---|
| 40 | #include "G4UImanager.hh" |
---|
| 41 | |
---|
[609] | 42 | #include "Randomize.hh" |
---|
| 43 | |
---|
[1342] | 44 | #include "DetectorConstruction.hh" |
---|
| 45 | #include "PhysicsList.hh" |
---|
| 46 | #include "PrimaryGeneratorAction.hh" |
---|
| 47 | #include "RunAction.hh" |
---|
| 48 | #include "EventAction.hh" |
---|
| 49 | #include "SteppingAction.hh" |
---|
| 50 | #include "SteppingVerbose.hh" |
---|
[609] | 51 | |
---|
| 52 | #ifdef G4VIS_USE |
---|
| 53 | #include "G4VisExecutive.hh" |
---|
| 54 | #endif |
---|
| 55 | |
---|
[1143] | 56 | #ifdef G4UI_USE |
---|
| 57 | #include "G4UIExecutive.hh" |
---|
[474] | 58 | #endif |
---|
| 59 | |
---|
[1341] | 60 | #include "qcoreapplication.h" |
---|
| 61 | |
---|
| 62 | #define MAC_OSX_APP 1 |
---|
| 63 | |
---|
[474] | 64 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 65 | |
---|
| 66 | int main(int argc,char** argv) |
---|
| 67 | { |
---|
| 68 | // Choose the Random engine |
---|
| 69 | // |
---|
| 70 | CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); |
---|
[609] | 71 | |
---|
[474] | 72 | // User Verbose output class |
---|
| 73 | // |
---|
[1342] | 74 | G4VSteppingVerbose::SetInstance(new SteppingVerbose); |
---|
[474] | 75 | |
---|
| 76 | // Construct the default run manager |
---|
| 77 | // |
---|
| 78 | G4RunManager * runManager = new G4RunManager; |
---|
| 79 | |
---|
| 80 | // Set mandatory initialization classes |
---|
| 81 | // |
---|
[1342] | 82 | DetectorConstruction* detector = new DetectorConstruction; |
---|
[474] | 83 | runManager->SetUserInitialization(detector); |
---|
| 84 | // |
---|
[1342] | 85 | PhysicsList* physics = new PhysicsList; |
---|
[474] | 86 | runManager->SetUserInitialization(physics); |
---|
[609] | 87 | |
---|
[474] | 88 | // Set user action classes |
---|
| 89 | // |
---|
[1342] | 90 | PrimaryGeneratorAction* gen_action = |
---|
| 91 | new PrimaryGeneratorAction(detector); |
---|
[474] | 92 | runManager->SetUserAction(gen_action); |
---|
| 93 | // |
---|
[1342] | 94 | RunAction* run_action = new RunAction; |
---|
[474] | 95 | runManager->SetUserAction(run_action); |
---|
| 96 | // |
---|
[1342] | 97 | EventAction* event_action = new EventAction(run_action); |
---|
[474] | 98 | runManager->SetUserAction(event_action); |
---|
| 99 | // |
---|
[1342] | 100 | SteppingAction* stepping_action = |
---|
| 101 | new SteppingAction(detector, event_action); |
---|
[474] | 102 | runManager->SetUserAction(stepping_action); |
---|
| 103 | |
---|
| 104 | // Initialize G4 kernel |
---|
| 105 | // |
---|
| 106 | runManager->Initialize(); |
---|
[609] | 107 | |
---|
[887] | 108 | #ifdef G4VIS_USE |
---|
| 109 | // Initialize visualization |
---|
| 110 | // |
---|
| 111 | G4VisManager* visManager = new G4VisExecutive; |
---|
| 112 | visManager->Initialize(); |
---|
| 113 | #endif |
---|
| 114 | |
---|
[474] | 115 | // Get the pointer to the User Interface manager |
---|
| 116 | // |
---|
[1143] | 117 | G4UImanager* UImanager = G4UImanager::GetUIpointer(); |
---|
[1341] | 118 | |
---|
| 119 | #ifdef MAC_OSX_APP |
---|
| 120 | std::string progName = argv[0]; |
---|
| 121 | std::string::size_type pos = progName.find(".app/Contents/MacOS/",0); |
---|
| 122 | if (pos != std::string::npos) { |
---|
| 123 | std::string progDir = progName.substr(0,pos+4); |
---|
| 124 | chdir((progDir+"/Contents/macros").c_str()); |
---|
| 125 | argc = 1; |
---|
| 126 | } |
---|
| 127 | #endif |
---|
| 128 | |
---|
[609] | 129 | if (argc!=1) // batch mode |
---|
[474] | 130 | { |
---|
[1341] | 131 | G4String command = "/control/execute "; |
---|
[609] | 132 | G4String fileName = argv[1]; |
---|
[1143] | 133 | UImanager->ApplyCommand(command+fileName); |
---|
[609] | 134 | } |
---|
[1143] | 135 | else |
---|
| 136 | { // interactive mode : define UI session |
---|
| 137 | #ifdef G4UI_USE |
---|
[1337] | 138 | G4UIExecutive* ui = new G4UIExecutive(argc, argv); |
---|
[887] | 139 | #ifdef G4VIS_USE |
---|
[1143] | 140 | UImanager->ApplyCommand("/control/execute vis.mac"); |
---|
[659] | 141 | #endif |
---|
[1143] | 142 | if (ui->IsGUI()) |
---|
| 143 | UImanager->ApplyCommand("/control/execute visTutor/gui.mac"); |
---|
| 144 | ui->SessionStart(); |
---|
| 145 | delete ui; |
---|
| 146 | #endif |
---|
[474] | 147 | } |
---|
[1143] | 148 | |
---|
[474] | 149 | // Job termination |
---|
| 150 | // Free the store: user actions, physics_list and detector_description are |
---|
| 151 | // owned and deleted by the run manager, so they should not |
---|
| 152 | // be deleted in the main() program ! |
---|
[887] | 153 | #ifdef G4VIS_USE |
---|
| 154 | delete visManager; |
---|
| 155 | #endif |
---|
[474] | 156 | delete runManager; |
---|
| 157 | |
---|
| 158 | return 0; |
---|
| 159 | } |
---|
| 160 | |
---|
| 161 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|