Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // Hadrontherapy advanced example for Geant4 26 // Hadrontherapy advanced example for Geant4 27 // See more at: https://twiki.cern.ch/twiki/bi 27 // See more at: https://twiki.cern.ch/twiki/bin/view/Geant4/AdvancedExamplesHadrontherapy 28 28 29 #include "HadrontherapyPrimaryGeneratorMesseng 29 #include "HadrontherapyPrimaryGeneratorMessenger.hh" 30 #include "HadrontherapyPrimaryGeneratorAction. 30 #include "HadrontherapyPrimaryGeneratorAction.hh" 31 #include "G4UIdirectory.hh" 31 #include "G4UIdirectory.hh" 32 #include "G4UIcmdWithADoubleAndUnit.hh" 32 #include "G4UIcmdWithADoubleAndUnit.hh" 33 #include "G4UIcmdWithADouble.hh" 33 #include "G4UIcmdWithADouble.hh" 34 #include "G4SystemOfUnits.hh" 34 #include "G4SystemOfUnits.hh" 35 #include "G4UIcmdWithAString.hh" << 36 #include "G4UIcmdWithAnInteger.hh" << 37 #include "G4UIcmdWithABool.hh" << 38 35 39 HadrontherapyPrimaryGeneratorMessenger::Hadron 36 HadrontherapyPrimaryGeneratorMessenger::HadrontherapyPrimaryGeneratorMessenger( 40 << 37 HadrontherapyPrimaryGeneratorAction* HadrontherapyGun) 41 :HadrontherapyAction(HadrontherapyGun) 38 :HadrontherapyAction(HadrontherapyGun) 42 { << 39 { 43 << 40 // 44 changeTheSource = new G4UIdirectory("/prim << 41 // Definition of the interactive commands to modify the parameters of the 45 changeTheSource -> SetGuidance("Command to << 42 // generation of primary particles 46 << 43 // 47 NewSource = new G4UIcmdWithABool("/primary << 44 beamParametersDir = new G4UIdirectory("/beam/"); 48 NewSource -> SetParameterName("NewSource " << 45 beamParametersDir -> SetGuidance("set parameters of beam"); 49 NewSource -> SetDefaultValue("false"); << 46 50 NewSource -> SetGuidance("Set if you want << 47 EnergyDir = new G4UIdirectory("/beam/energy/"); 51 "\n[usage]: /prim << 48 EnergyDir -> SetGuidance ("set energy of beam"); 52 NewSource -> AvailableForStates(G4State_Id << 49 53 << 50 particlePositionDir = new G4UIdirectory("/beam/position/"); 54 << 51 particlePositionDir -> SetGuidance ("set position of particle"); 55 calculatedPhaseSpaceFileIN=new G4UIcmdWith << 52 56 calculatedPhaseSpaceFileIN->SetDefaultValu << 53 MomentumDir = new G4UIdirectory("/beam/momentum/"); 57 calculatedPhaseSpaceFileIN->SetGuidance("f << 54 MomentumDir -> SetGuidance ("set momentum of particle "); 58 << 55 /* 59 << 56 sigmaMomentumYCmd = new G4UIcmdWithADouble("/beam/momentum/sigmaY",this); 60 << 57 sigmaMomentumYCmd -> SetGuidance("set sigma momentum y"); >> 58 sigmaMomentumYCmd -> SetParameterName("momentum",false); >> 59 sigmaMomentumYCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); >> 60 >> 61 sigmaMomentumZCmd = new G4UIcmdWithADouble("/beam/momentum/sigmaZ",this); >> 62 sigmaMomentumZCmd -> SetGuidance("set sigma momentum z"); >> 63 sigmaMomentumZCmd -> SetParameterName("momentum",false); >> 64 sigmaMomentumZCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); >> 65 >> 66 meanKineticEnergyCmd = new G4UIcmdWithADoubleAndUnit("/beam/energy/meanEnergy",this); >> 67 meanKineticEnergyCmd -> SetGuidance("set mean Kinetic energy"); >> 68 meanKineticEnergyCmd -> SetParameterName("Energy",false); >> 69 meanKineticEnergyCmd -> SetDefaultUnit("MeV"); >> 70 meanKineticEnergyCmd -> SetUnitCandidates("eV keV MeV GeV TeV"); >> 71 meanKineticEnergyCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); >> 72 >> 73 sigmaEnergyCmd = new G4UIcmdWithADoubleAndUnit("/beam/energy/sigmaEnergy",this); >> 74 sigmaEnergyCmd -> SetGuidance("set sigma energy"); >> 75 sigmaEnergyCmd -> SetParameterName("Energy",false); >> 76 sigmaEnergyCmd -> SetDefaultUnit("keV"); >> 77 sigmaEnergyCmd -> SetUnitCandidates("eV keV MeV GeV TeV"); >> 78 sigmaEnergyCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); >> 79 >> 80 XpositionCmd = new G4UIcmdWithADoubleAndUnit("/beam/position/Xposition",this); >> 81 XpositionCmd -> SetGuidance("set x coordinate of particle"); >> 82 XpositionCmd -> SetParameterName("position",false); >> 83 XpositionCmd -> SetDefaultUnit("mm"); >> 84 XpositionCmd -> SetUnitCandidates("mm cm m"); >> 85 XpositionCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); >> 86 >> 87 YpositionCmd = new G4UIcmdWithADoubleAndUnit("/beam/position/Yposition",this); >> 88 YpositionCmd -> SetGuidance("set y coordinate of particle"); >> 89 YpositionCmd -> SetParameterName("position",false); >> 90 YpositionCmd -> SetDefaultUnit("mm"); >> 91 YpositionCmd -> SetUnitCandidates("mm cm m"); >> 92 YpositionCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); >> 93 >> 94 sigmaYCmd = new G4UIcmdWithADoubleAndUnit("/beam/position/Yposition/sigmaY",this); >> 95 sigmaYCmd -> SetGuidance("set sigma y"); >> 96 sigmaYCmd -> SetParameterName("position",false); >> 97 sigmaYCmd -> SetDefaultUnit("mm"); >> 98 sigmaYCmd -> SetUnitCandidates("mm cm m"); >> 99 sigmaYCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); >> 100 >> 101 ZpositionCmd = new G4UIcmdWithADoubleAndUnit("/beam/position/Zposition",this); >> 102 ZpositionCmd -> SetGuidance("set z coordinate of particle"); >> 103 ZpositionCmd -> SetParameterName("position",false); >> 104 ZpositionCmd -> SetDefaultUnit("mm"); >> 105 ZpositionCmd -> SetUnitCandidates("mm cm m"); >> 106 ZpositionCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); >> 107 >> 108 sigmaZCmd = new G4UIcmdWithADoubleAndUnit("/beam/position/Zposition/sigmaZ",this); >> 109 sigmaZCmd -> SetGuidance("set sigma z"); >> 110 sigmaZCmd -> SetParameterName("position",false); >> 111 sigmaZCmd -> SetDefaultUnit("mm"); >> 112 sigmaZCmd -> SetUnitCandidates("mm cm m"); >> 113 sigmaZCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); >> 114 */ 61 } 115 } 62 116 63 HadrontherapyPrimaryGeneratorMessenger::~Hadro 117 HadrontherapyPrimaryGeneratorMessenger::~HadrontherapyPrimaryGeneratorMessenger() 64 { 118 { 65 << 119 delete beamParametersDir; 66 delete NewSource; << 120 delete EnergyDir; 67 delete changeTheSource; << 121 // delete meanKineticEnergyCmd; 68 delete calculatedPhaseSpaceFileIN; << 122 // delete sigmaEnergyCmd; 69 << 123 delete particlePositionDir; 70 << 124 delete MomentumDir; 71 } << 125 /* delete XpositionCmd; 72 << 126 delete YpositionCmd; 73 << 127 delete ZpositionCmd; 74 void HadrontherapyPrimaryGeneratorMessenger::S << 128 delete sigmaYCmd; 75 << 129 delete sigmaZCmd; >> 130 delete sigmaMomentumYCmd; >> 131 delete sigmaMomentumZCmd; */ >> 132 } >> 133 /* >> 134 void HadrontherapyPrimaryGeneratorMessenger::SetNewValue(G4UIcommand* command,G4String newValue) 76 { 135 { 77 if (command == calculatedPhaseSpaceFileIN) << 136 if ( command == meanKineticEnergyCmd ) 78 { << 137 { HadrontherapyAction -> SetmeanKineticEnergy(meanKineticEnergyCmd 79 HadrontherapyAction->setCalculatedPhas << 138 -> GetNewDoubleValue(newValue));} 80 } << 139 if ( command == sigmaEnergyCmd ) 81 << 140 { HadrontherapyAction -> SetsigmaEnergy(sigmaEnergyCmd 82 if (command == NewSource) << 141 -> GetNewDoubleValue(newValue));} 83 { << 142 if ( command == XpositionCmd ) 84 HadrontherapyAction->setNewSource(NewS << 143 { HadrontherapyAction -> SetXposition(XpositionCmd 85 << 144 -> GetNewDoubleValue(newValue));} 86 } << 145 87 << 146 if ( command == YpositionCmd ) 88 } << 147 { HadrontherapyAction -> SetYposition(YpositionCmd 89 << 148 -> GetNewDoubleValue(newValue));} 90 << 149 91 << 150 if ( command == ZpositionCmd ) >> 151 { HadrontherapyAction -> SetZposition(ZpositionCmd >> 152 -> GetNewDoubleValue(newValue));} >> 153 >> 154 if ( command == sigmaYCmd ) >> 155 { HadrontherapyAction -> SetsigmaY(sigmaYCmd >> 156 -> GetNewDoubleValue(newValue));} >> 157 >> 158 if ( command == sigmaZCmd ) >> 159 { HadrontherapyAction -> SetsigmaZ(sigmaZCmd >> 160 -> GetNewDoubleValue(newValue));} >> 161 >> 162 if ( command == sigmaMomentumYCmd ) >> 163 { HadrontherapyAction -> SetsigmaMomentumY(sigmaMomentumYCmd >> 164 -> GetNewDoubleValue(newValue));} >> 165 >> 166 if ( command == sigmaMomentumZCmd ) >> 167 { HadrontherapyAction -> SetsigmaMomentumZ(sigmaMomentumZCmd >> 168 -> GetNewDoubleValue(newValue));} >> 169 } */ 92 170