[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 | // |
---|
[609] | 27 | // $Id: exampleN03.cc,v 1.33 2007/11/16 10:50:41 lgarnier Exp $ |
---|
| 28 | // GEANT4 tag $Name: $ |
---|
[474] | 29 | // |
---|
| 30 | // |
---|
| 31 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 32 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 33 | |
---|
| 34 | #include "G4RunManager.hh" |
---|
| 35 | #include "G4UImanager.hh" |
---|
| 36 | #include "G4UIterminal.hh" |
---|
| 37 | #include "G4UItcsh.hh" |
---|
| 38 | |
---|
[609] | 39 | #include "Randomize.hh" |
---|
| 40 | |
---|
| 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 | |
---|
[659] | 49 | /** Environnement definition for app launch for mac |
---|
| 50 | */ |
---|
| 51 | |
---|
| 52 | #define MOSX_APP |
---|
| 53 | |
---|
| 54 | #ifdef MOSX_APP |
---|
| 55 | #define G4UI_BUILD_QT_SESSION |
---|
| 56 | #define G4VIS_BUILD_OPENGLQT_DRIVER |
---|
| 57 | #include <qfiledialog.h> |
---|
| 58 | #endif |
---|
| 59 | |
---|
| 60 | /** End of Environnement definition for app launch for mac |
---|
| 61 | */ |
---|
| 62 | |
---|
[609] | 63 | #ifdef G4VIS_USE |
---|
| 64 | #include "G4VisExecutive.hh" |
---|
| 65 | #endif |
---|
| 66 | |
---|
[474] | 67 | #ifdef G4UI_USE_XM |
---|
| 68 | #include "G4UIXm.hh" |
---|
| 69 | #endif |
---|
| 70 | |
---|
| 71 | #ifdef G4UI_USE_WIN32 |
---|
| 72 | #include "G4UIWin32.hh" |
---|
| 73 | #endif |
---|
| 74 | |
---|
[609] | 75 | #ifdef G4UI_USE_QT |
---|
| 76 | #include "G4UIQt.hh" |
---|
| 77 | #include "G4Qt.hh" |
---|
| 78 | #include <qapplication.h> |
---|
[474] | 79 | #endif |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 83 | |
---|
| 84 | int main(int argc,char** argv) |
---|
| 85 | { |
---|
| 86 | // Choose the Random engine |
---|
| 87 | // |
---|
| 88 | CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); |
---|
[609] | 89 | |
---|
[474] | 90 | // User Verbose output class |
---|
| 91 | // |
---|
[609] | 92 | G4VSteppingVerbose::SetInstance(new ExN03SteppingVerbose); |
---|
[474] | 93 | |
---|
| 94 | // Construct the default run manager |
---|
| 95 | // |
---|
| 96 | G4RunManager * runManager = new G4RunManager; |
---|
| 97 | |
---|
| 98 | // Set mandatory initialization classes |
---|
| 99 | // |
---|
| 100 | ExN03DetectorConstruction* detector = new ExN03DetectorConstruction; |
---|
| 101 | runManager->SetUserInitialization(detector); |
---|
| 102 | // |
---|
| 103 | G4VUserPhysicsList* physics = new ExN03PhysicsList; |
---|
| 104 | runManager->SetUserInitialization(physics); |
---|
[609] | 105 | |
---|
[474] | 106 | // Set user action classes |
---|
| 107 | // |
---|
[609] | 108 | G4VUserPrimaryGeneratorAction* gen_action = |
---|
| 109 | new ExN03PrimaryGeneratorAction(detector); |
---|
[474] | 110 | runManager->SetUserAction(gen_action); |
---|
| 111 | // |
---|
| 112 | ExN03RunAction* run_action = new ExN03RunAction; |
---|
| 113 | runManager->SetUserAction(run_action); |
---|
| 114 | // |
---|
| 115 | ExN03EventAction* event_action = new ExN03EventAction(run_action); |
---|
| 116 | runManager->SetUserAction(event_action); |
---|
| 117 | // |
---|
| 118 | G4UserSteppingAction* stepping_action = |
---|
[609] | 119 | new ExN03SteppingAction(detector, event_action); |
---|
[474] | 120 | runManager->SetUserAction(stepping_action); |
---|
| 121 | |
---|
| 122 | // Initialize G4 kernel |
---|
| 123 | // |
---|
| 124 | runManager->Initialize(); |
---|
[609] | 125 | |
---|
[474] | 126 | // Get the pointer to the User Interface manager |
---|
| 127 | // |
---|
[609] | 128 | G4UImanager* UI = G4UImanager::GetUIpointer(); |
---|
| 129 | |
---|
[659] | 130 | #ifndef MOSX_APP |
---|
[609] | 131 | if (argc!=1) // batch mode |
---|
[474] | 132 | { |
---|
[609] | 133 | G4String command = "/control/execute "; |
---|
| 134 | G4String fileName = argv[1]; |
---|
| 135 | UI->ApplyCommand(command+fileName); |
---|
| 136 | } |
---|
| 137 | else // interactive mode : define visualization UI terminal |
---|
| 138 | { |
---|
[659] | 139 | #endif |
---|
| 140 | |
---|
[609] | 141 | #ifdef G4VIS_USE |
---|
| 142 | G4VisManager* visManager = new G4VisExecutive; |
---|
| 143 | visManager->Initialize(); |
---|
[567] | 144 | #endif |
---|
[609] | 145 | |
---|
| 146 | G4UIsession* session = 0; |
---|
| 147 | #if defined(G4UI_USE_TCSH) |
---|
| 148 | session = new G4UIterminal(new G4UItcsh); |
---|
| 149 | #elif defined(G4UI_USE_XM) |
---|
| 150 | session = new G4UIXm(argc,argv); |
---|
| 151 | UI->ApplyCommand("/control/execute visTutor/gui.mac"); |
---|
| 152 | #elif defined(G4UI_USE_WIN32) |
---|
| 153 | session = new G4UIWin32(); |
---|
| 154 | UI->ApplyCommand("/control/execute visTutor/gui.mac"); |
---|
| 155 | #elif defined(G4UI_USE_QT) |
---|
| 156 | session = new G4UIQt(argc,argv); |
---|
[659] | 157 | #ifdef MOSX_APP |
---|
| 158 | G4String gui = (QString("/control/execute ") + |
---|
| 159 | QFileDialog::getOpenFileName(NULL,"Open gui.mac File", |
---|
| 160 | "../Resources", |
---|
| 161 | "gui.mac")).toStdString().c_str(); |
---|
| 162 | |
---|
[567] | 163 | #else |
---|
[659] | 164 | G4String gui = "/control/execute visTutor/gui.mac"; |
---|
| 165 | #endif |
---|
| 166 | UI->ApplyCommand(gui); |
---|
| 167 | #else |
---|
[609] | 168 | session = new G4UIterminal(); |
---|
[474] | 169 | #endif |
---|
[609] | 170 | |
---|
[659] | 171 | #ifdef MOSX_APP |
---|
| 172 | G4String vis = (QString("/control/execute ") + |
---|
| 173 | QFileDialog::getOpenFileName(NULL,"Open vis.mac File", |
---|
| 174 | "../Resources", |
---|
| 175 | "vis.mac")).toStdString().c_str(); |
---|
| 176 | #else |
---|
| 177 | G4String vis = "/control/execute vis.mac"; |
---|
| 178 | #endif |
---|
| 179 | UI->ApplyCommand(vis); |
---|
[474] | 180 | session->SessionStart(); |
---|
| 181 | delete session; |
---|
[609] | 182 | |
---|
[474] | 183 | #ifdef G4VIS_USE |
---|
[609] | 184 | delete visManager; |
---|
| 185 | #endif |
---|
[659] | 186 | |
---|
| 187 | #ifndef MOSX_APP |
---|
[474] | 188 | } |
---|
[659] | 189 | #endif |
---|
[474] | 190 | |
---|
| 191 | // Job termination |
---|
| 192 | // Free the store: user actions, physics_list and detector_description are |
---|
| 193 | // owned and deleted by the run manager, so they should not |
---|
| 194 | // be deleted in the main() program ! |
---|
| 195 | delete runManager; |
---|
| 196 | |
---|
| 197 | return 0; |
---|
| 198 | } |
---|
| 199 | |
---|
| 200 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|