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