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 // $Id: HadrontherapyPrimaryGeneratorMessenger.cc; May 2005 27 // See more at: https://twiki.cern.ch/twiki/bi << 27 // ---------------------------------------------------------------------------- >> 28 // GEANT 4 - Hadrontherapy example >> 29 // ---------------------------------------------------------------------------- >> 30 // Code developed by: >> 31 // >> 32 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) >> 33 // >> 34 // (a) Laboratori Nazionali del Sud >> 35 // of the National Institute for Nuclear Physics, Catania, Italy >> 36 // (b) National Institute for Nuclear Physics Section of Genova, genova, Italy >> 37 // >> 38 // * cirrone@lns.infn.it >> 39 // ---------------------------------------------------------------------------- 28 40 29 #include "HadrontherapyPrimaryGeneratorMesseng 41 #include "HadrontherapyPrimaryGeneratorMessenger.hh" 30 #include "HadrontherapyPrimaryGeneratorAction. 42 #include "HadrontherapyPrimaryGeneratorAction.hh" 31 #include "G4UIdirectory.hh" 43 #include "G4UIdirectory.hh" 32 #include "G4UIcmdWithADoubleAndUnit.hh" 44 #include "G4UIcmdWithADoubleAndUnit.hh" 33 #include "G4UIcmdWithADouble.hh" 45 #include "G4UIcmdWithADouble.hh" 34 #include "G4SystemOfUnits.hh" << 35 #include "G4UIcmdWithAString.hh" << 36 #include "G4UIcmdWithAnInteger.hh" << 37 #include "G4UIcmdWithABool.hh" << 38 46 39 HadrontherapyPrimaryGeneratorMessenger::Hadron 47 HadrontherapyPrimaryGeneratorMessenger::HadrontherapyPrimaryGeneratorMessenger( 40 << 48 HadrontherapyPrimaryGeneratorAction* HadrontherapyGun) 41 :HadrontherapyAction(HadrontherapyGun) 49 :HadrontherapyAction(HadrontherapyGun) 42 { << 50 { 43 << 51 // 44 changeTheSource = new G4UIdirectory("/prim << 52 // Definition of the interactive commands to modify the parameters of the 45 changeTheSource -> SetGuidance("Command to << 53 // generation of primary particles 46 << 54 // 47 NewSource = new G4UIcmdWithABool("/primary << 55 beamParametersDir = new G4UIdirectory("/beam/"); 48 NewSource -> SetParameterName("NewSource " << 56 beamParametersDir -> SetGuidance("set parameters of beam"); 49 NewSource -> SetDefaultValue("false"); << 57 50 NewSource -> SetGuidance("Set if you want << 58 EnergyDir = new G4UIdirectory("/beam/energy/"); 51 "\n[usage]: /prim << 59 EnergyDir -> SetGuidance ("set energy of beam"); 52 NewSource -> AvailableForStates(G4State_Id << 60 53 << 61 particlePositionDir = new G4UIdirectory("/beam/position/"); 54 << 62 particlePositionDir -> SetGuidance ("set position of particle"); 55 calculatedPhaseSpaceFileIN=new G4UIcmdWith << 63 56 calculatedPhaseSpaceFileIN->SetDefaultValu << 64 MomentumDir = new G4UIdirectory("/beam/momentum/"); 57 calculatedPhaseSpaceFileIN->SetGuidance("f << 65 MomentumDir -> SetGuidance ("set momentum of particle "); 58 << 66 59 << 67 sigmaMomentumYCmd = new G4UIcmdWithADouble("/beam/momentum/sigmaY",this); 60 << 68 sigmaMomentumYCmd -> SetGuidance("set sigma momentum y"); >> 69 sigmaMomentumYCmd -> SetParameterName("momentum",false); >> 70 sigmaMomentumYCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); >> 71 >> 72 sigmaMomentumZCmd = new G4UIcmdWithADouble("/beam/momentum/sigmaZ",this); >> 73 sigmaMomentumZCmd -> SetGuidance("set sigma momentum z"); >> 74 sigmaMomentumZCmd -> SetParameterName("momentum",false); >> 75 sigmaMomentumZCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); >> 76 >> 77 meanKineticEnergyCmd = new G4UIcmdWithADoubleAndUnit("/beam/energy/meanEnergy",this); >> 78 meanKineticEnergyCmd -> SetGuidance("set mean Kinetic energy"); >> 79 meanKineticEnergyCmd -> SetParameterName("Energy",false); >> 80 meanKineticEnergyCmd -> SetDefaultUnit("MeV"); >> 81 meanKineticEnergyCmd -> SetUnitCandidates("eV keV MeV GeV TeV"); >> 82 meanKineticEnergyCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); >> 83 >> 84 sigmaEnergyCmd = new G4UIcmdWithADoubleAndUnit("/beam/energy/sigmaEnergy",this); >> 85 sigmaEnergyCmd -> SetGuidance("set sigma energy"); >> 86 sigmaEnergyCmd -> SetParameterName("Energy",false); >> 87 sigmaEnergyCmd -> SetDefaultUnit("keV"); >> 88 sigmaEnergyCmd -> SetUnitCandidates("eV keV MeV GeV TeV"); >> 89 sigmaEnergyCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); >> 90 >> 91 XpositionCmd = new G4UIcmdWithADoubleAndUnit("/beam/position/Xposition",this); >> 92 XpositionCmd -> SetGuidance("set x coordinate of particle"); >> 93 XpositionCmd -> SetParameterName("position",false); >> 94 XpositionCmd -> SetDefaultUnit("mm"); >> 95 XpositionCmd -> SetUnitCandidates("mm cm m"); >> 96 XpositionCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); >> 97 >> 98 YpositionCmd = new G4UIcmdWithADoubleAndUnit("/beam/position/Yposition",this); >> 99 YpositionCmd -> SetGuidance("set y coordinate of particle"); >> 100 YpositionCmd -> SetParameterName("position",false); >> 101 YpositionCmd -> SetDefaultUnit("mm"); >> 102 YpositionCmd -> SetUnitCandidates("mm cm m"); >> 103 YpositionCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); >> 104 >> 105 sigmaYCmd = new G4UIcmdWithADoubleAndUnit("/beam/position/Yposition/sigmaY",this); >> 106 sigmaYCmd -> SetGuidance("set sigma y"); >> 107 sigmaYCmd -> SetParameterName("position",false); >> 108 sigmaYCmd -> SetDefaultUnit("mm"); >> 109 sigmaYCmd -> SetUnitCandidates("mm cm m"); >> 110 sigmaYCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); >> 111 >> 112 ZpositionCmd = new G4UIcmdWithADoubleAndUnit("/beam/position/Zposition",this); >> 113 ZpositionCmd -> SetGuidance("set z coordinate of particle"); >> 114 ZpositionCmd -> SetParameterName("position",false); >> 115 ZpositionCmd -> SetDefaultUnit("mm"); >> 116 ZpositionCmd -> SetUnitCandidates("mm cm m"); >> 117 ZpositionCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); >> 118 >> 119 sigmaZCmd = new G4UIcmdWithADoubleAndUnit("/beam/position/Zposition/sigmaZ",this); >> 120 sigmaZCmd -> SetGuidance("set sigma z"); >> 121 sigmaZCmd -> SetParameterName("position",false); >> 122 sigmaZCmd -> SetDefaultUnit("mm"); >> 123 sigmaZCmd -> SetUnitCandidates("mm cm m"); >> 124 sigmaZCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); 61 } 125 } 62 126 63 HadrontherapyPrimaryGeneratorMessenger::~Hadro 127 HadrontherapyPrimaryGeneratorMessenger::~HadrontherapyPrimaryGeneratorMessenger() 64 { 128 { 65 << 129 delete beamParametersDir; 66 delete NewSource; << 130 delete EnergyDir; 67 delete changeTheSource; << 131 delete meanKineticEnergyCmd; 68 delete calculatedPhaseSpaceFileIN; << 132 delete sigmaEnergyCmd; 69 << 133 delete particlePositionDir; 70 << 134 delete MomentumDir; 71 } << 135 delete XpositionCmd; 72 << 136 delete YpositionCmd; 73 << 137 delete ZpositionCmd; 74 void HadrontherapyPrimaryGeneratorMessenger::S << 138 delete sigmaYCmd; >> 139 delete sigmaZCmd; >> 140 delete sigmaMomentumYCmd; >> 141 delete sigmaMomentumZCmd; >> 142 } 75 143 >> 144 void HadrontherapyPrimaryGeneratorMessenger::SetNewValue(G4UIcommand* command,G4String newValue) 76 { 145 { 77 if (command == calculatedPhaseSpaceFileIN) << 146 if ( command == meanKineticEnergyCmd ) 78 { << 147 { HadrontherapyAction -> SetmeanKineticEnergy(meanKineticEnergyCmd 79 HadrontherapyAction->setCalculatedPhas << 148 -> GetNewDoubleValue(newValue));} 80 } << 149 if ( command == sigmaEnergyCmd ) 81 << 150 { HadrontherapyAction -> SetsigmaEnergy(sigmaEnergyCmd 82 if (command == NewSource) << 151 -> GetNewDoubleValue(newValue));} 83 { << 152 if ( command == XpositionCmd ) 84 HadrontherapyAction->setNewSource(NewS << 153 { HadrontherapyAction -> SetXposition(XpositionCmd 85 << 154 -> GetNewDoubleValue(newValue));} 86 } << 155 87 << 156 if ( command == YpositionCmd ) 88 } << 157 { HadrontherapyAction -> SetYposition(YpositionCmd 89 << 158 -> GetNewDoubleValue(newValue));} 90 << 159 91 << 160 if ( command == ZpositionCmd ) >> 161 { HadrontherapyAction -> SetZposition(ZpositionCmd >> 162 -> GetNewDoubleValue(newValue));} >> 163 >> 164 if ( command == sigmaYCmd ) >> 165 { HadrontherapyAction -> SetsigmaY(sigmaYCmd >> 166 -> GetNewDoubleValue(newValue));} >> 167 >> 168 if ( command == sigmaZCmd ) >> 169 { HadrontherapyAction -> SetsigmaZ(sigmaZCmd >> 170 -> GetNewDoubleValue(newValue));} >> 171 >> 172 if ( command == sigmaMomentumYCmd ) >> 173 { HadrontherapyAction -> SetsigmaMomentumY(sigmaMomentumYCmd >> 174 -> GetNewDoubleValue(newValue));} >> 175 >> 176 if ( command == sigmaMomentumZCmd ) >> 177 { HadrontherapyAction -> SetsigmaMomentumZ(sigmaMomentumZCmd >> 178 -> GetNewDoubleValue(newValue));} >> 179 } 92 180