| [807] | 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: Microbeam.cc,v 1.9 2007/08/28 09:48:40 gcosmo Exp $
|
|---|
| 28 | // -------------------------------------------------------------------
|
|---|
| 29 | // GEANT4 - Microbeam example
|
|---|
| 30 | // Developed by S. Incerti et al.
|
|---|
| 31 | // Centre d'Etudes Nucleaires de Bordeaux-Gradignan
|
|---|
| 32 | // CNRS / IN2P3 / Bordeaux 1 University
|
|---|
| 33 | // 33175 Gradignan, France
|
|---|
| 34 | // incerti@cenbg.in2p3.fr
|
|---|
| 35 | // -------------------------------------------------------------------
|
|---|
| 36 |
|
|---|
| 37 | #include "G4RunManager.hh"
|
|---|
| 38 | #include "G4UImanager.hh"
|
|---|
| 39 | #include "G4UIterminal.hh"
|
|---|
| 40 | #include "G4UItcsh.hh"
|
|---|
| 41 | #include "Randomize.hh"
|
|---|
| 42 |
|
|---|
| 43 | #ifdef G4VIS_USE
|
|---|
| 44 | #include "G4VisExecutive.hh"
|
|---|
| 45 | #endif
|
|---|
| 46 |
|
|---|
| 47 | #include "MicrobeamDetectorConstruction.hh"
|
|---|
| 48 | #include "MicrobeamPhysicsList.hh"
|
|---|
| 49 | #include "MicrobeamPrimaryGeneratorAction.hh"
|
|---|
| 50 | #include "MicrobeamRunAction.hh"
|
|---|
| 51 | #include "MicrobeamEventAction.hh"
|
|---|
| 52 | #include "MicrobeamTrackingAction.hh"
|
|---|
| 53 | #include "MicrobeamSteppingAction.hh"
|
|---|
| 54 | #include "MicrobeamSteppingVerbose.hh"
|
|---|
| 55 |
|
|---|
| 56 | int main(int argc,char** argv) {
|
|---|
| 57 |
|
|---|
| 58 | // choose the Random engine
|
|---|
| 59 | CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
|
|---|
| 60 |
|
|---|
| 61 | // verbose output class
|
|---|
| 62 | G4VSteppingVerbose::SetInstance(new MicrobeamSteppingVerbose);
|
|---|
| 63 |
|
|---|
| 64 | // construct the default run manager
|
|---|
| 65 | G4RunManager * runManager = new G4RunManager;
|
|---|
| 66 |
|
|---|
| 67 | // set mandatory initialization classes
|
|---|
| 68 | MicrobeamDetectorConstruction* detector = new MicrobeamDetectorConstruction;
|
|---|
| 69 |
|
|---|
| 70 | runManager->SetUserInitialization(detector);
|
|---|
| 71 |
|
|---|
| 72 | runManager->SetUserInitialization(new MicrobeamPhysicsList);
|
|---|
| 73 |
|
|---|
| 74 | #ifdef G4VIS_USE
|
|---|
| 75 | // visualization manager
|
|---|
| 76 | G4VisManager* visManager = new G4VisExecutive;
|
|---|
| 77 | visManager->Initialize();
|
|---|
| 78 | #endif
|
|---|
| 79 |
|
|---|
| 80 | // set user action classes
|
|---|
| 81 | MicrobeamPrimaryGeneratorAction* KinAct = new MicrobeamPrimaryGeneratorAction(detector);
|
|---|
| 82 | runManager->SetUserAction(KinAct);
|
|---|
| 83 |
|
|---|
| 84 | MicrobeamRunAction* RunAct = new MicrobeamRunAction(detector);
|
|---|
| 85 |
|
|---|
| 86 | runManager->SetUserAction(RunAct);
|
|---|
| 87 | runManager->SetUserAction(new MicrobeamEventAction(RunAct));
|
|---|
| 88 | runManager->SetUserAction(new MicrobeamTrackingAction(RunAct));
|
|---|
| 89 | runManager->SetUserAction(new MicrobeamSteppingAction(RunAct,detector));
|
|---|
| 90 |
|
|---|
| 91 | // initialize G4 kernel
|
|---|
| 92 | runManager->Initialize();
|
|---|
| 93 |
|
|---|
| 94 | // get the pointer to the User Interface manager
|
|---|
| 95 | G4UImanager* UI = G4UImanager::GetUIpointer();
|
|---|
| 96 |
|
|---|
| 97 | // local user files created by the simulation
|
|---|
| 98 | system ("rm -rf dose.txt");
|
|---|
| 99 | system ("rm -rf 3DDose.txt");
|
|---|
| 100 | system ("rm -rf stoppingPower.txt");
|
|---|
| 101 | system ("rm -rf range.txt");
|
|---|
| 102 | system ("rm -rf beamPosition.txt");
|
|---|
| 103 |
|
|---|
| 104 | if (argc==1) // define UI session for interactive mode.
|
|---|
| 105 | {
|
|---|
| 106 | // G4UIterminal is a (dumb) terminal.
|
|---|
| 107 | G4UIsession * session = 0;
|
|---|
| 108 | #ifdef G4UI_USE_TCSH
|
|---|
| 109 | session = new G4UIterminal(new G4UItcsh);
|
|---|
| 110 | #else
|
|---|
| 111 | session = new G4UIterminal();
|
|---|
| 112 | #endif
|
|---|
| 113 | UI->ApplyCommand("/control/execute microbeam.mac");
|
|---|
| 114 | session->SessionStart();
|
|---|
| 115 | delete session;
|
|---|
| 116 | }
|
|---|
| 117 | else // batch mode
|
|---|
| 118 | {
|
|---|
| 119 | G4String command = "/control/execute ";
|
|---|
| 120 | G4String fileName = argv[1];
|
|---|
| 121 | UI->ApplyCommand(command+fileName);
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | // job termination
|
|---|
| 125 | #ifdef G4VIS_USE
|
|---|
| 126 | delete visManager;
|
|---|
| 127 | #endif
|
|---|
| 128 | delete runManager;
|
|---|
| 129 |
|
|---|
| 130 | return 0;
|
|---|
| 131 |
|
|---|
| 132 | }
|
|---|
| 133 |
|
|---|