Geant4  10.02.p01
PassiveProtonBeamLineMessenger.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 
30 #include "PassiveProtonBeamLine.hh"
31 #include "G4UIdirectory.hh"
33 #include "G4UIcmdWithAString.hh"
34 #include "G4SystemOfUnits.hh"
35 
37 :passiveProton(beamLine)
38 
39 {
40  changeTheBeamLineDir = new G4UIdirectory("/ChangeBeamLine/");
41  changeTheBeamLineDir -> SetGuidance("Command to change the transport beam line");
42 
43  changeTheBeamLineNameCmd = new G4UIcmdWithAString("/ChangeBeamLine/beamLineName",this);
44  changeTheBeamLineNameCmd -> SetGuidance("Insert the name of the beam line you want simulate");
45  changeTheBeamLineNameCmd -> SetParameterName("List",false);
46  changeTheBeamLineNameCmd -> AvailableForStates(G4State_PreInit);
47 
48  modulatorDir = new G4UIdirectory("/modulator/");
49  modulatorDir -> SetGuidance("Command to rotate the modulator wheel");
50 
51  beamLineDir = new G4UIdirectory("/beamLine/");
52  beamLineDir -> SetGuidance("set specification of range shifter");
53 
54  rangeShifterDir = new G4UIdirectory("/beamLine/RangeShifter/");
55  rangeShifterDir -> SetGuidance("set specification of range shifter");
56 
57  firstScatteringFoilDir = new G4UIdirectory("/beamLine/ScatteringFoil1/");
58  firstScatteringFoilDir -> SetGuidance("set specification of first scattering foil");
59 
60  secondScatteringFoilDir = new G4UIdirectory("/beamLine/ScatteringFoil2/");
61  secondScatteringFoilDir -> SetGuidance("set specification of second scattering foil");
62 
63  rangeStopperDir = new G4UIdirectory("/beamLine/Stopper/");
64  rangeStopperDir -> SetGuidance("set specification of stopper");
65 
66  finalCollimatorDir = new G4UIdirectory("/beamLine/FinalCollimator/");
67  finalCollimatorDir -> SetGuidance("set specification of final collimator");
68 
69  modulatorAngleCmd = new G4UIcmdWithADoubleAndUnit("/modulator/angle",this);
70  modulatorAngleCmd -> SetGuidance("Set Modulator Angle");
71  modulatorAngleCmd -> SetParameterName("Size",false);
72  modulatorAngleCmd -> SetRange("Size>=0.");
73  modulatorAngleCmd -> SetUnitCategory("Angle");
74  modulatorAngleCmd -> AvailableForStates(G4State_Idle);
75 
76  rangeShifterMatCmd = new G4UIcmdWithAString("/beamLine/RangeShifter/RSMat",this);
77  rangeShifterMatCmd -> SetGuidance("Set material of range shifter");
78  rangeShifterMatCmd -> SetParameterName("choice",false);
79  rangeShifterMatCmd -> AvailableForStates(G4State_Idle);
80 
81  rangeShifterXSizeCmd = new G4UIcmdWithADoubleAndUnit("/beamLine/RangeShifter/thickness",this);
82  rangeShifterXSizeCmd -> SetGuidance("Set half of the thickness of range shifter along X axis");
83  rangeShifterXSizeCmd -> SetParameterName("Size",false);
84  rangeShifterXSizeCmd -> SetDefaultUnit("mm");
85  rangeShifterXSizeCmd -> SetUnitCandidates("mm cm m");
86  rangeShifterXSizeCmd -> AvailableForStates(G4State_Idle);
87 
88  rangeShifterXPositionCmd = new G4UIcmdWithADoubleAndUnit("/beamLine/RangeShifter/position",this);
89  rangeShifterXPositionCmd -> SetGuidance("Set position of range shifter");
90  rangeShifterXPositionCmd -> SetParameterName("Size",false);
91  rangeShifterXPositionCmd -> SetDefaultUnit("mm");
92  rangeShifterXPositionCmd -> SetUnitCandidates("mm cm m");
93  rangeShifterXPositionCmd -> AvailableForStates(G4State_Idle);
94 
95  firstScatteringFoilXSizeCmd = new G4UIcmdWithADoubleAndUnit("/beamLine/ScatteringFoil1/thickness",this);
96  firstScatteringFoilXSizeCmd -> SetGuidance("Set half thickness of first scattering foil");
97  firstScatteringFoilXSizeCmd -> SetParameterName("Size",false);
98  firstScatteringFoilXSizeCmd -> SetDefaultUnit("mm");
99  firstScatteringFoilXSizeCmd -> SetUnitCandidates("mm cm m");
100  firstScatteringFoilXSizeCmd -> AvailableForStates(G4State_Idle);
101 
102  secondScatteringFoilXSizeCmd = new G4UIcmdWithADoubleAndUnit("/beamLine/ScatteringFoil2/thickness",this);
103  secondScatteringFoilXSizeCmd -> SetGuidance("Set half thickness of second scattering foil");
104  secondScatteringFoilXSizeCmd -> SetParameterName("Size",false);
105  secondScatteringFoilXSizeCmd -> SetDefaultUnit("mm");
106  secondScatteringFoilXSizeCmd -> SetUnitCandidates("mm cm m");
107  secondScatteringFoilXSizeCmd -> AvailableForStates(G4State_Idle);
108 
109  outerRadiusStopperCmd = new G4UIcmdWithADoubleAndUnit("/beamLine/Stopper/outRadius",this);
110  outerRadiusStopperCmd -> SetGuidance("Set size of outer radius");
111  outerRadiusStopperCmd -> SetParameterName("Size",false);
112  outerRadiusStopperCmd -> SetDefaultUnit("mm");
113  outerRadiusStopperCmd -> SetUnitCandidates("mm cm m");
114  outerRadiusStopperCmd -> AvailableForStates(G4State_Idle);
115 
116  innerRadiusFinalCollimatorCmd = new G4UIcmdWithADoubleAndUnit("/beamLine/FinalCollimator/halfInnerRad",this);
117  innerRadiusFinalCollimatorCmd -> SetGuidance("Set size of inner radius ( max 21.5 mm)");
118  innerRadiusFinalCollimatorCmd -> SetParameterName("Size",false);
119  innerRadiusFinalCollimatorCmd -> SetDefaultUnit("mm");
120  innerRadiusFinalCollimatorCmd -> SetUnitCandidates("mm cm m");
121  innerRadiusFinalCollimatorCmd -> AvailableForStates(G4State_Idle);
122 }
123 
125 {
127  delete outerRadiusStopperCmd;
131  delete rangeShifterXSizeCmd;
132  delete rangeShifterMatCmd;
133  delete modulatorAngleCmd;
134  delete finalCollimatorDir;
135  delete rangeStopperDir;
137  delete firstScatteringFoilDir;
138  delete rangeShifterDir;
139  delete beamLineDir;
140  delete modulatorDir;
141 }
142 
143 
144 
145 
147 {
148  if( command == modulatorAngleCmd )
149  { passiveProton -> SetModulatorAngle
150  (modulatorAngleCmd -> GetNewDoubleValue(newValue));}
151 
152  else if( command == rangeShifterMatCmd )
153  { passiveProton -> SetRSMaterial(newValue);}
154 
155  else if( command == rangeShifterXSizeCmd )
156  { passiveProton -> SetRangeShifterXSize
157  (rangeShifterXSizeCmd -> GetNewDoubleValue(newValue));}
158 
159  else if( command == rangeShifterXPositionCmd )
160  { passiveProton -> SetRangeShifterXPosition
161  (rangeShifterXPositionCmd -> GetNewDoubleValue(newValue));}
162 
163  else if( command == firstScatteringFoilXSizeCmd )
164  { passiveProton -> SetFirstScatteringFoilXSize
165  (firstScatteringFoilXSizeCmd -> GetNewDoubleValue(newValue));}
166 
167  else if( command == secondScatteringFoilXSizeCmd )
168  { passiveProton -> SetSecondScatteringFoilXSize
169  (secondScatteringFoilXSizeCmd -> GetNewDoubleValue(newValue));}
170 
171  else if( command == outerRadiusStopperCmd )
172  { passiveProton -> SetOuterRadiusStopper(
173  outerRadiusStopperCmd -> GetNewDoubleValue(newValue));}
174 
175  else if( command == innerRadiusFinalCollimatorCmd )
176  { passiveProton -> SetInnerRadiusFinalCollimator
177  (innerRadiusFinalCollimatorCmd -> GetNewDoubleValue(newValue));}
178 }
179 
PassiveProtonBeamLineMessenger(PassiveProtonBeamLine *)
G4UIcmdWithADoubleAndUnit * rangeShifterXSizeCmd
G4UIcmdWithADoubleAndUnit * firstScatteringFoilXSizeCmd
G4UIcmdWithADoubleAndUnit * rangeShifterXPositionCmd
G4UIcmdWithADoubleAndUnit * modulatorAngleCmd
G4UIcmdWithADoubleAndUnit * innerRadiusFinalCollimatorCmd
G4UIcmdWithADoubleAndUnit * outerRadiusStopperCmd
G4UIcmdWithADoubleAndUnit * secondScatteringFoilXSizeCmd