[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 | // $Id: MedLinac.cc,v 1.12 2007/07/01 15:19:18 mpiergen Exp $ |
---|
| 27 | // |
---|
| 28 | // -------------------------------------------------------------- |
---|
| 29 | // GEANT 4 - medical_linac |
---|
| 30 | // |
---|
| 31 | // Code developed by: M. Piergentili |
---|
| 32 | |
---|
| 33 | #include "G4RunManager.hh" |
---|
| 34 | #include "G4UImanager.hh" |
---|
| 35 | #include "G4UIterminal.hh" |
---|
| 36 | #include "G4UItcsh.hh" |
---|
| 37 | #include "globals.hh" |
---|
| 38 | #include "G4SDManager.hh" |
---|
| 39 | #include "G4UImessenger.hh" |
---|
| 40 | #include "Randomize.hh" |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | #include "MedLinacDetectorMessenger.hh" |
---|
| 44 | #include "MedLinacDetectorConstruction.hh" |
---|
| 45 | #include "MedLinacPhysicsList.hh" |
---|
| 46 | #include "MedLinacPhantomSD.hh" |
---|
| 47 | #include "MedLinacPhantomHit.hh" |
---|
| 48 | #include "MedLinacPrimaryGeneratorAction.hh" |
---|
| 49 | #include "MedLinacEventAction.hh" |
---|
| 50 | #include "MedLinacRunAction.hh" |
---|
| 51 | #include "MedLinacTrackingAction.hh" |
---|
| 52 | #include "G4SDManager.hh" |
---|
| 53 | |
---|
| 54 | |
---|
| 55 | #ifdef G4UI_USE_XM |
---|
| 56 | #include "G4UIXm.hh" |
---|
| 57 | #endif |
---|
| 58 | |
---|
| 59 | #ifdef G4VIS_USE |
---|
| 60 | #include "G4VisExecutive.hh" |
---|
| 61 | #endif |
---|
| 62 | |
---|
| 63 | int main(int argc ,char ** argv) |
---|
| 64 | { |
---|
| 65 | |
---|
| 66 | //choose the Random engine |
---|
| 67 | CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); |
---|
| 68 | G4int seed = 0; |
---|
| 69 | CLHEP::HepRandom :: setTheSeed(seed); |
---|
| 70 | |
---|
| 71 | // Construct the default run manager |
---|
| 72 | G4RunManager* runManager = new G4RunManager; |
---|
| 73 | G4String sensitiveDetectorName = "Phantom"; |
---|
| 74 | MedLinacDetectorConstruction* pDetectorConstruction = |
---|
| 75 | MedLinacDetectorConstruction::GetInstance(sensitiveDetectorName); |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | // set mandatory initialization classes |
---|
| 79 | runManager->SetUserInitialization(pDetectorConstruction); |
---|
| 80 | runManager->SetUserInitialization(new MedLinacPhysicsList); |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | #ifdef G4VIS_USE |
---|
| 84 | // Visualization manager |
---|
| 85 | G4VisManager* visManager = new G4VisExecutive; |
---|
| 86 | visManager->Initialize(); |
---|
| 87 | #endif |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | // output environment variables: |
---|
| 91 | #ifdef G4ANALYSIS_USE |
---|
| 92 | G4cout << G4endl << G4endl << G4endl |
---|
| 93 | << " User Environment " << G4endl |
---|
| 94 | << " Using AIDA 3.0 analysis " << G4endl; |
---|
| 95 | # else |
---|
| 96 | G4cout << G4endl << G4endl << G4endl |
---|
| 97 | << " User Environment " << G4endl |
---|
| 98 | << " G4ANALYSIS_USE environment variable not set, NO ANALYSIS " |
---|
| 99 | << G4endl; |
---|
| 100 | #endif |
---|
| 101 | |
---|
| 102 | |
---|
| 103 | |
---|
| 104 | |
---|
| 105 | G4UIsession* session = 0; |
---|
| 106 | if (argc == 1) // Define UI session for interactive mode. |
---|
| 107 | { |
---|
| 108 | session = new G4UIterminal(); |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | // set mandatory user action class |
---|
| 112 | |
---|
| 113 | runManager->SetUserAction(new MedLinacPrimaryGeneratorAction); |
---|
| 114 | MedLinacEventAction *pMedLinacEventAction = new MedLinacEventAction(); |
---|
| 115 | runManager->SetUserAction(pMedLinacEventAction); |
---|
| 116 | |
---|
| 117 | MedLinacRunAction *pRunAction = new MedLinacRunAction(); |
---|
| 118 | |
---|
| 119 | runManager->SetUserAction(pRunAction); |
---|
| 120 | runManager->SetUserAction(new MedLinacTrackingAction); |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | // Initialize G4 kernel |
---|
| 124 | //runManager->Initialize(); |
---|
| 125 | |
---|
| 126 | // get the pointer to the UI manager |
---|
| 127 | G4UImanager* UI = G4UImanager::GetUIpointer(); |
---|
| 128 | |
---|
| 129 | if (session) // Define UI session for interactive mode. |
---|
| 130 | { |
---|
| 131 | G4cout<<" UI session starts ..."<< G4endl; |
---|
| 132 | UI -> ApplyCommand("/control/execute macro.mac"); |
---|
| 133 | session->SessionStart(); |
---|
| 134 | delete session; |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | else // Batch mode |
---|
| 138 | { |
---|
| 139 | G4String command = "/control/execute "; |
---|
| 140 | G4String fileName = argv[1]; |
---|
| 141 | UI->ApplyCommand(command+fileName); |
---|
| 142 | } |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | //job termination |
---|
| 146 | |
---|
| 147 | #ifdef G4VIS_USE |
---|
| 148 | delete visManager; |
---|
| 149 | #endif |
---|
| 150 | |
---|
| 151 | delete runManager; |
---|
| 152 | |
---|
| 153 | return 0; |
---|
| 154 | } |
---|
| 155 | |
---|
| 156 | |
---|
| 157 | |
---|