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