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