| 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 | //
|
|---|
| 27 | // $Id: exampleN03Con.cc,v 1.2 2007/05/26 00:24:09 tkoi Exp $
|
|---|
| 28 | // GEANT4 tag $Name: geant4-09-03-cand-01 $
|
|---|
| 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 |
|
|---|
| 39 | #ifdef G4UI_USE_XM
|
|---|
| 40 | #include "G4UIXm.hh"
|
|---|
| 41 | #endif
|
|---|
| 42 |
|
|---|
| 43 | #ifdef G4UI_USE_WIN32
|
|---|
| 44 | #include "G4UIWin32.hh"
|
|---|
| 45 | #endif
|
|---|
| 46 |
|
|---|
| 47 | #include "Randomize.hh"
|
|---|
| 48 |
|
|---|
| 49 | #ifdef G4VIS_USE
|
|---|
| 50 | #include "G4VisExecutive.hh"
|
|---|
| 51 | #endif
|
|---|
| 52 |
|
|---|
| 53 | #include "ExN03DetectorConstruction.hh"
|
|---|
| 54 | #include "ExN03PhysicsList.hh"
|
|---|
| 55 | #include "ExN03PrimaryGeneratorAction.hh"
|
|---|
| 56 | #include "ExN03RunAction.hh"
|
|---|
| 57 | #include "ExN03EventAction.hh"
|
|---|
| 58 | #include "ExN03SteppingAction.hh"
|
|---|
| 59 | #include "ExN03SteppingVerbose.hh"
|
|---|
| 60 |
|
|---|
| 61 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 62 |
|
|---|
| 63 | int main(int argc,char** argv)
|
|---|
| 64 | {
|
|---|
| 65 | // Choose the Random engine
|
|---|
| 66 | //
|
|---|
| 67 | CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
|
|---|
| 68 |
|
|---|
| 69 | // User Verbose output class
|
|---|
| 70 | //
|
|---|
| 71 | G4VSteppingVerbose* verbosity = new ExN03SteppingVerbose;
|
|---|
| 72 | G4VSteppingVerbose::SetInstance(verbosity);
|
|---|
| 73 |
|
|---|
| 74 | // Construct the default run manager
|
|---|
| 75 | //
|
|---|
| 76 | G4RunManager * runManager = new G4RunManager;
|
|---|
| 77 |
|
|---|
| 78 | // Set mandatory initialization classes
|
|---|
| 79 | //
|
|---|
| 80 | ExN03DetectorConstruction* detector = new ExN03DetectorConstruction;
|
|---|
| 81 | runManager->SetUserInitialization(detector);
|
|---|
| 82 | //
|
|---|
| 83 | G4VUserPhysicsList* physics = new ExN03PhysicsList;
|
|---|
| 84 | runManager->SetUserInitialization(physics);
|
|---|
| 85 |
|
|---|
| 86 | G4UIsession* session=0;
|
|---|
| 87 |
|
|---|
| 88 | if (argc==1) // Define UI session for interactive mode.
|
|---|
| 89 | {
|
|---|
| 90 | // G4UIterminal is a (dumb) terminal
|
|---|
| 91 | //
|
|---|
| 92 | #if defined(G4UI_USE_XM)
|
|---|
| 93 | session = new G4UIXm(argc,argv);
|
|---|
| 94 | #elif defined(G4UI_USE_WIN32)
|
|---|
| 95 | session = new G4UIWin32();
|
|---|
| 96 | #elif defined(G4UI_USE_TCSH)
|
|---|
| 97 | session = new G4UIterminal(new G4UItcsh);
|
|---|
| 98 | #else
|
|---|
| 99 | session = new G4UIterminal();
|
|---|
| 100 | #endif
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | #ifdef G4VIS_USE
|
|---|
| 104 | // Visualization manager
|
|---|
| 105 | //
|
|---|
| 106 | G4VisManager* visManager = new G4VisExecutive;
|
|---|
| 107 | visManager->Initialize();
|
|---|
| 108 | #endif
|
|---|
| 109 |
|
|---|
| 110 | // Set user action classes
|
|---|
| 111 | //
|
|---|
| 112 | G4VUserPrimaryGeneratorAction* gen_action = new ExN03PrimaryGeneratorAction(detector);
|
|---|
| 113 | runManager->SetUserAction(gen_action);
|
|---|
| 114 | //
|
|---|
| 115 | ExN03RunAction* run_action = new ExN03RunAction;
|
|---|
| 116 | runManager->SetUserAction(run_action);
|
|---|
| 117 | //
|
|---|
| 118 | ExN03EventAction* event_action = new ExN03EventAction(run_action);
|
|---|
| 119 | runManager->SetUserAction(event_action);
|
|---|
| 120 | //
|
|---|
| 121 | G4UserSteppingAction* stepping_action =
|
|---|
| 122 | new ExN03SteppingAction(detector, event_action);
|
|---|
| 123 | runManager->SetUserAction(stepping_action);
|
|---|
| 124 |
|
|---|
| 125 | // Initialize G4 kernel
|
|---|
| 126 | //
|
|---|
| 127 | runManager->Initialize();
|
|---|
| 128 |
|
|---|
| 129 | // Get the pointer to the User Interface manager
|
|---|
| 130 | //
|
|---|
| 131 | G4UImanager* UI = G4UImanager::GetUIpointer();
|
|---|
| 132 |
|
|---|
| 133 | if (session) // Define UI session for interactive mode
|
|---|
| 134 | {
|
|---|
| 135 | // G4UIterminal is a (dumb) terminal
|
|---|
| 136 | //
|
|---|
| 137 | // UI->ApplyCommand("/control/execute vis.mac");
|
|---|
| 138 | #if defined(G4UI_USE_XM) || defined(G4UI_USE_WIN32)
|
|---|
| 139 | // Customize the G4UIXm,Win32 menubar with a macro file
|
|---|
| 140 | //
|
|---|
| 141 | // UI->ApplyCommand("/control/execute visTutor/gui.mac");
|
|---|
| 142 | #endif
|
|---|
| 143 | session->SessionStart();
|
|---|
| 144 | delete session;
|
|---|
| 145 | }
|
|---|
| 146 | else // Batch mode
|
|---|
| 147 | {
|
|---|
| 148 | #ifdef G4VIS_USE
|
|---|
| 149 | visManager->SetVerboseLevel("quiet");
|
|---|
| 150 | #endif
|
|---|
| 151 | G4String command = "/control/execute ";
|
|---|
| 152 | G4String fileName = argv[1];
|
|---|
| 153 | UI->ApplyCommand(command+fileName);
|
|---|
| 154 | }
|
|---|
| 155 |
|
|---|
| 156 | // Job termination
|
|---|
| 157 | // Free the store: user actions, physics_list and detector_description are
|
|---|
| 158 | // owned and deleted by the run manager, so they should not
|
|---|
| 159 | // be deleted in the main() program !
|
|---|
| 160 |
|
|---|
| 161 | #ifdef G4VIS_USE
|
|---|
| 162 | delete visManager;
|
|---|
| 163 | #endif
|
|---|
| 164 | delete runManager;
|
|---|
| 165 | delete verbosity;
|
|---|
| 166 |
|
|---|
| 167 | return 0;
|
|---|
| 168 | }
|
|---|
| 169 |
|
|---|
| 170 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|