| 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: exampleN03.cc,v 1.37 2009/10/30 15:06:01 allison 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 |
|
|---|
| 37 | #include "Randomize.hh"
|
|---|
| 38 |
|
|---|
| 39 | #include "ExN03DetectorConstruction.hh"
|
|---|
| 40 | #include "ExN03PhysicsList.hh"
|
|---|
| 41 | #include "ExN03PrimaryGeneratorAction.hh"
|
|---|
| 42 | #include "ExN03RunAction.hh"
|
|---|
| 43 | #include "ExN03EventAction.hh"
|
|---|
| 44 | #include "ExN03SteppingAction.hh"
|
|---|
| 45 | #include "ExN03SteppingVerbose.hh"
|
|---|
| 46 |
|
|---|
| 47 | #ifdef G4VIS_USE
|
|---|
| 48 | #include "G4VisExecutive.hh"
|
|---|
| 49 | #endif
|
|---|
| 50 |
|
|---|
| 51 | #ifdef G4UI_USE
|
|---|
| 52 | #include "G4UIExecutive.hh"
|
|---|
| 53 | #endif
|
|---|
| 54 |
|
|---|
| 55 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 56 |
|
|---|
| 57 | int main(int argc,char** argv)
|
|---|
| 58 | {
|
|---|
| 59 | // Choose the Random engine
|
|---|
| 60 | //
|
|---|
| 61 | CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
|
|---|
| 62 |
|
|---|
| 63 | // User Verbose output class
|
|---|
| 64 | //
|
|---|
| 65 | G4VSteppingVerbose::SetInstance(new ExN03SteppingVerbose);
|
|---|
| 66 |
|
|---|
| 67 | // Construct the default run manager
|
|---|
| 68 | //
|
|---|
| 69 | G4RunManager * runManager = new G4RunManager;
|
|---|
| 70 |
|
|---|
| 71 | // Set mandatory initialization classes
|
|---|
| 72 | //
|
|---|
| 73 | ExN03DetectorConstruction* detector = new ExN03DetectorConstruction;
|
|---|
| 74 | runManager->SetUserInitialization(detector);
|
|---|
| 75 | //
|
|---|
| 76 | G4VUserPhysicsList* physics = new ExN03PhysicsList;
|
|---|
| 77 | runManager->SetUserInitialization(physics);
|
|---|
| 78 |
|
|---|
| 79 | // Set user action classes
|
|---|
| 80 | //
|
|---|
| 81 | G4VUserPrimaryGeneratorAction* gen_action =
|
|---|
| 82 | new ExN03PrimaryGeneratorAction(detector);
|
|---|
| 83 | runManager->SetUserAction(gen_action);
|
|---|
| 84 | //
|
|---|
| 85 | ExN03RunAction* run_action = new ExN03RunAction;
|
|---|
| 86 | runManager->SetUserAction(run_action);
|
|---|
| 87 | //
|
|---|
| 88 | ExN03EventAction* event_action = new ExN03EventAction(run_action);
|
|---|
| 89 | runManager->SetUserAction(event_action);
|
|---|
| 90 | //
|
|---|
| 91 | G4UserSteppingAction* stepping_action =
|
|---|
| 92 | new ExN03SteppingAction(detector, event_action);
|
|---|
| 93 | runManager->SetUserAction(stepping_action);
|
|---|
| 94 |
|
|---|
| 95 | // Initialize G4 kernel
|
|---|
| 96 | //
|
|---|
| 97 | runManager->Initialize();
|
|---|
| 98 |
|
|---|
| 99 | #ifdef G4VIS_USE
|
|---|
| 100 | // Initialize visualization
|
|---|
| 101 | //
|
|---|
| 102 | G4VisManager* visManager = new G4VisExecutive;
|
|---|
| 103 | visManager->Initialize();
|
|---|
| 104 | #endif
|
|---|
| 105 |
|
|---|
| 106 | // Get the pointer to the User Interface manager
|
|---|
| 107 | //
|
|---|
| 108 | G4UImanager* UImanager = G4UImanager::GetUIpointer();
|
|---|
| 109 |
|
|---|
| 110 | if (argc!=1) // batch mode
|
|---|
| 111 | {
|
|---|
| 112 | G4String command = "/control/execute ";
|
|---|
| 113 | G4String fileName = argv[1];
|
|---|
| 114 | UImanager->ApplyCommand(command+fileName);
|
|---|
| 115 | }
|
|---|
| 116 | else
|
|---|
| 117 | { // interactive mode : define UI session
|
|---|
| 118 | #ifdef G4UI_USE
|
|---|
| 119 | G4UIExecutive* ui = new G4UIExecutive(argc,argv);
|
|---|
| 120 | #ifdef G4VIS_USE
|
|---|
| 121 | UImanager->ApplyCommand("/control/execute vis.mac");
|
|---|
| 122 | #endif
|
|---|
| 123 | if (ui->IsGUI())
|
|---|
| 124 | UImanager->ApplyCommand("/control/execute visTutor/gui.mac");
|
|---|
| 125 | ui->SessionStart();
|
|---|
| 126 | delete ui;
|
|---|
| 127 | #endif
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | // Job termination
|
|---|
| 131 | // Free the store: user actions, physics_list and detector_description are
|
|---|
| 132 | // owned and deleted by the run manager, so they should not
|
|---|
| 133 | // be deleted in the main() program !
|
|---|
| 134 | #ifdef G4VIS_USE
|
|---|
| 135 | delete visManager;
|
|---|
| 136 | #endif
|
|---|
| 137 | delete runManager;
|
|---|
| 138 |
|
|---|
| 139 | return 0;
|
|---|
| 140 | }
|
|---|
| 141 |
|
|---|
| 142 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|