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 | // HadrontherapyPrimaryGeneratorMessenger.cc; |
---|
27 | // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy |
---|
28 | |
---|
29 | #include "HadrontherapyPrimaryGeneratorMessenger.hh" |
---|
30 | #include "HadrontherapyPrimaryGeneratorAction.hh" |
---|
31 | #include "G4UIdirectory.hh" |
---|
32 | #include "G4UIcmdWithADoubleAndUnit.hh" |
---|
33 | #include "G4UIcmdWithADouble.hh" |
---|
34 | |
---|
35 | HadrontherapyPrimaryGeneratorMessenger::HadrontherapyPrimaryGeneratorMessenger( |
---|
36 | HadrontherapyPrimaryGeneratorAction* HadrontherapyGun) |
---|
37 | :HadrontherapyAction(HadrontherapyGun) |
---|
38 | { |
---|
39 | // |
---|
40 | // Definition of the interactive commands to modify the parameters of the |
---|
41 | // generation of primary particles |
---|
42 | // |
---|
43 | beamParametersDir = new G4UIdirectory("/beam/"); |
---|
44 | beamParametersDir -> SetGuidance("set parameters of beam"); |
---|
45 | |
---|
46 | EnergyDir = new G4UIdirectory("/beam/energy/"); |
---|
47 | EnergyDir -> SetGuidance ("set energy of beam"); |
---|
48 | |
---|
49 | particlePositionDir = new G4UIdirectory("/beam/position/"); |
---|
50 | particlePositionDir -> SetGuidance ("set position of particle"); |
---|
51 | |
---|
52 | MomentumDir = new G4UIdirectory("/beam/momentum/"); |
---|
53 | MomentumDir -> SetGuidance ("set momentum of particle "); |
---|
54 | |
---|
55 | sigmaMomentumYCmd = new G4UIcmdWithADouble("/beam/momentum/sigmaY",this); |
---|
56 | sigmaMomentumYCmd -> SetGuidance("set sigma momentum y"); |
---|
57 | sigmaMomentumYCmd -> SetParameterName("momentum",false); |
---|
58 | sigmaMomentumYCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
59 | |
---|
60 | sigmaMomentumZCmd = new G4UIcmdWithADouble("/beam/momentum/sigmaZ",this); |
---|
61 | sigmaMomentumZCmd -> SetGuidance("set sigma momentum z"); |
---|
62 | sigmaMomentumZCmd -> SetParameterName("momentum",false); |
---|
63 | sigmaMomentumZCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
64 | |
---|
65 | meanKineticEnergyCmd = new G4UIcmdWithADoubleAndUnit("/beam/energy/meanEnergy",this); |
---|
66 | meanKineticEnergyCmd -> SetGuidance("set mean Kinetic energy"); |
---|
67 | meanKineticEnergyCmd -> SetParameterName("Energy",false); |
---|
68 | meanKineticEnergyCmd -> SetDefaultUnit("MeV"); |
---|
69 | meanKineticEnergyCmd -> SetUnitCandidates("eV keV MeV GeV TeV"); |
---|
70 | meanKineticEnergyCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
71 | |
---|
72 | sigmaEnergyCmd = new G4UIcmdWithADoubleAndUnit("/beam/energy/sigmaEnergy",this); |
---|
73 | sigmaEnergyCmd -> SetGuidance("set sigma energy"); |
---|
74 | sigmaEnergyCmd -> SetParameterName("Energy",false); |
---|
75 | sigmaEnergyCmd -> SetDefaultUnit("keV"); |
---|
76 | sigmaEnergyCmd -> SetUnitCandidates("eV keV MeV GeV TeV"); |
---|
77 | sigmaEnergyCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
78 | |
---|
79 | XpositionCmd = new G4UIcmdWithADoubleAndUnit("/beam/position/Xposition",this); |
---|
80 | XpositionCmd -> SetGuidance("set x coordinate of particle"); |
---|
81 | XpositionCmd -> SetParameterName("position",false); |
---|
82 | XpositionCmd -> SetDefaultUnit("mm"); |
---|
83 | XpositionCmd -> SetUnitCandidates("mm cm m"); |
---|
84 | XpositionCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
85 | |
---|
86 | YpositionCmd = new G4UIcmdWithADoubleAndUnit("/beam/position/Yposition",this); |
---|
87 | YpositionCmd -> SetGuidance("set y coordinate of particle"); |
---|
88 | YpositionCmd -> SetParameterName("position",false); |
---|
89 | YpositionCmd -> SetDefaultUnit("mm"); |
---|
90 | YpositionCmd -> SetUnitCandidates("mm cm m"); |
---|
91 | YpositionCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
92 | |
---|
93 | sigmaYCmd = new G4UIcmdWithADoubleAndUnit("/beam/position/Yposition/sigmaY",this); |
---|
94 | sigmaYCmd -> SetGuidance("set sigma y"); |
---|
95 | sigmaYCmd -> SetParameterName("position",false); |
---|
96 | sigmaYCmd -> SetDefaultUnit("mm"); |
---|
97 | sigmaYCmd -> SetUnitCandidates("mm cm m"); |
---|
98 | sigmaYCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
99 | |
---|
100 | ZpositionCmd = new G4UIcmdWithADoubleAndUnit("/beam/position/Zposition",this); |
---|
101 | ZpositionCmd -> SetGuidance("set z coordinate of particle"); |
---|
102 | ZpositionCmd -> SetParameterName("position",false); |
---|
103 | ZpositionCmd -> SetDefaultUnit("mm"); |
---|
104 | ZpositionCmd -> SetUnitCandidates("mm cm m"); |
---|
105 | ZpositionCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
106 | |
---|
107 | sigmaZCmd = new G4UIcmdWithADoubleAndUnit("/beam/position/Zposition/sigmaZ",this); |
---|
108 | sigmaZCmd -> SetGuidance("set sigma z"); |
---|
109 | sigmaZCmd -> SetParameterName("position",false); |
---|
110 | sigmaZCmd -> SetDefaultUnit("mm"); |
---|
111 | sigmaZCmd -> SetUnitCandidates("mm cm m"); |
---|
112 | sigmaZCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
113 | } |
---|
114 | |
---|
115 | HadrontherapyPrimaryGeneratorMessenger::~HadrontherapyPrimaryGeneratorMessenger() |
---|
116 | { |
---|
117 | delete beamParametersDir; |
---|
118 | delete EnergyDir; |
---|
119 | delete meanKineticEnergyCmd; |
---|
120 | delete sigmaEnergyCmd; |
---|
121 | delete particlePositionDir; |
---|
122 | delete MomentumDir; |
---|
123 | delete XpositionCmd; |
---|
124 | delete YpositionCmd; |
---|
125 | delete ZpositionCmd; |
---|
126 | delete sigmaYCmd; |
---|
127 | delete sigmaZCmd; |
---|
128 | delete sigmaMomentumYCmd; |
---|
129 | delete sigmaMomentumZCmd; |
---|
130 | } |
---|
131 | |
---|
132 | void HadrontherapyPrimaryGeneratorMessenger::SetNewValue(G4UIcommand* command,G4String newValue) |
---|
133 | { |
---|
134 | if ( command == meanKineticEnergyCmd ) |
---|
135 | { HadrontherapyAction -> SetmeanKineticEnergy(meanKineticEnergyCmd |
---|
136 | -> GetNewDoubleValue(newValue));} |
---|
137 | if ( command == sigmaEnergyCmd ) |
---|
138 | { HadrontherapyAction -> SetsigmaEnergy(sigmaEnergyCmd |
---|
139 | -> GetNewDoubleValue(newValue));} |
---|
140 | if ( command == XpositionCmd ) |
---|
141 | { HadrontherapyAction -> SetXposition(XpositionCmd |
---|
142 | -> GetNewDoubleValue(newValue));} |
---|
143 | |
---|
144 | if ( command == YpositionCmd ) |
---|
145 | { HadrontherapyAction -> SetYposition(YpositionCmd |
---|
146 | -> GetNewDoubleValue(newValue));} |
---|
147 | |
---|
148 | if ( command == ZpositionCmd ) |
---|
149 | { HadrontherapyAction -> SetZposition(ZpositionCmd |
---|
150 | -> GetNewDoubleValue(newValue));} |
---|
151 | |
---|
152 | if ( command == sigmaYCmd ) |
---|
153 | { HadrontherapyAction -> SetsigmaY(sigmaYCmd |
---|
154 | -> GetNewDoubleValue(newValue));} |
---|
155 | |
---|
156 | if ( command == sigmaZCmd ) |
---|
157 | { HadrontherapyAction -> SetsigmaZ(sigmaZCmd |
---|
158 | -> GetNewDoubleValue(newValue));} |
---|
159 | |
---|
160 | if ( command == sigmaMomentumYCmd ) |
---|
161 | { HadrontherapyAction -> SetsigmaMomentumY(sigmaMomentumYCmd |
---|
162 | -> GetNewDoubleValue(newValue));} |
---|
163 | |
---|
164 | if ( command == sigmaMomentumZCmd ) |
---|
165 | { HadrontherapyAction -> SetsigmaMomentumZ(sigmaMomentumZCmd |
---|
166 | -> GetNewDoubleValue(newValue));} |
---|
167 | } |
---|