Geant4  10.02
HadrontherapyPrimaryGeneratorMessenger.cc
Go to the documentation of this file.
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 // Hadrontherapy advanced example for Geant4
27 // See more at: https://twiki.cern.ch/twiki/bin/view/Geant4/AdvancedExamplesHadrontherapy
28 
31 #include "G4UIdirectory.hh"
33 #include "G4UIcmdWithADouble.hh"
34 #include "G4SystemOfUnits.hh"
35 
37  HadrontherapyPrimaryGeneratorAction* HadrontherapyGun)
38 :HadrontherapyAction(HadrontherapyGun)
39 {
40  //
41  // Definition of the interactive commands to modify the parameters of the
42  // generation of primary particles
43  //
44  beamParametersDir = new G4UIdirectory("/beam/");
45  beamParametersDir -> SetGuidance("set parameters of beam");
46 
47  EnergyDir = new G4UIdirectory("/beam/energy/");
48  EnergyDir -> SetGuidance ("set energy of beam");
49 
50  particlePositionDir = new G4UIdirectory("/beam/position/");
51  particlePositionDir -> SetGuidance ("set position of particle");
52 
53  MomentumDir = new G4UIdirectory("/beam/momentum/");
54  MomentumDir -> SetGuidance ("set momentum of particle ");
55 /*
56  sigmaMomentumYCmd = new G4UIcmdWithADouble("/beam/momentum/sigmaY",this);
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 */
115 }
116 
118 {
119  delete beamParametersDir;
120  delete EnergyDir;
121  // delete meanKineticEnergyCmd;
122  // delete sigmaEnergyCmd;
123  delete particlePositionDir;
124  delete MomentumDir;
125 /* delete XpositionCmd;
126  delete YpositionCmd;
127  delete ZpositionCmd;
128  delete sigmaYCmd;
129  delete sigmaZCmd;
130  delete sigmaMomentumYCmd;
131  delete sigmaMomentumZCmd; */
132 }
133 /*
134 void HadrontherapyPrimaryGeneratorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
135 {
136  if ( command == meanKineticEnergyCmd )
137  { HadrontherapyAction -> SetmeanKineticEnergy(meanKineticEnergyCmd
138  -> GetNewDoubleValue(newValue));}
139  if ( command == sigmaEnergyCmd )
140  { HadrontherapyAction -> SetsigmaEnergy(sigmaEnergyCmd
141  -> GetNewDoubleValue(newValue));}
142  if ( command == XpositionCmd )
143  { HadrontherapyAction -> SetXposition(XpositionCmd
144  -> GetNewDoubleValue(newValue));}
145 
146  if ( command == YpositionCmd )
147  { HadrontherapyAction -> SetYposition(YpositionCmd
148  -> GetNewDoubleValue(newValue));}
149 
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 } */
HadrontherapyPrimaryGeneratorMessenger(HadrontherapyPrimaryGeneratorAction *)