source: trunk/examples/extended/field/field04/src/F04DetectorMessenger.cc@ 1337

Last change on this file since 1337 was 807, checked in by garnier, 17 years ago

update

File size: 11.4 KB
Line 
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//
27//
28
29#include "F04DetectorMessenger.hh"
30
31#include "G4UIdirectory.hh"
32#include "G4UIcmdWithAString.hh"
33#include "G4UIcmdWithAnInteger.hh"
34#include "G4UIcmdWithADoubleAndUnit.hh"
35#include "G4UIcmdWithoutParameter.hh"
36
37F04DetectorMessenger::F04DetectorMessenger(F04DetectorConstruction * Det)
38 : Detector(Det)
39{
40 detDir = new G4UIdirectory("/field04/");
41 detDir->SetGuidance(" field04 Simulation ");
42
43 WorldMaterCmd = new G4UIcmdWithAString("/field04/SetWorldMat",this);
44 WorldMaterCmd->SetGuidance("Select Material of the World");
45 WorldMaterCmd->SetParameterName("wchoice",true);
46 WorldMaterCmd->SetDefaultValue("Air");
47 WorldMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
48
49 WorldRCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetWorldR",this);
50 WorldRCmd->SetGuidance("Set Radius of the World");
51 WorldRCmd->SetParameterName("WSizeR",false,false);
52 WorldRCmd->SetDefaultUnit("cm");
53 WorldRCmd->SetRange("WSizeR>0.");
54 WorldRCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
55
56 WorldZCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetWorldZ",this);
57 WorldZCmd->SetGuidance("Set Length of the World");
58 WorldZCmd->SetParameterName("WSizeZ",false,false);
59 WorldZCmd->SetDefaultUnit("cm");
60 WorldZCmd->SetRange("WSizeZ>0.");
61 WorldZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
62
63 CaptureRCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetCaptureR",this);
64 CaptureRCmd->SetGuidance("Set Radius of the Capture Magnet");
65 CaptureRCmd->SetParameterName("CSizeR",false,false);
66 CaptureRCmd->SetDefaultUnit("cm");
67 CaptureRCmd->SetRange("CSizeR>0.");
68 CaptureRCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
69
70 CaptureZCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetCaptureZ",this);
71 CaptureZCmd->SetGuidance("Set Length of the Capture Magnet");
72 CaptureZCmd->SetParameterName("CSizeZ",false,false);
73 CaptureZCmd->SetDefaultUnit("cm");
74 CaptureZCmd->SetRange("CSizeZ>0.");
75 CaptureZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
76
77 CaptureB1Cmd = new G4UIcmdWithADoubleAndUnit("/field04/SetCaptureB1",this);
78 CaptureB1Cmd->SetGuidance("Set B1 of the Capture Magnet");
79 CaptureB1Cmd->SetParameterName("CSizeB1",false,false);
80 CaptureB1Cmd->SetDefaultUnit("tesla");
81 CaptureB1Cmd->SetRange("CSizeB1>0.");
82 CaptureB1Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
83
84 CaptureB2Cmd = new G4UIcmdWithADoubleAndUnit("/field04/SetCaptureB2",this);
85 CaptureB2Cmd->SetGuidance("Set B2 of the Capture Magnet");
86 CaptureB2Cmd->SetParameterName("CSizeB2",false,false);
87 CaptureB2Cmd->SetDefaultUnit("tesla");
88 CaptureB2Cmd->SetRange("CSizeB2>0.");
89 CaptureB2Cmd->AvailableForStates(G4State_PreInit,G4State_Idle);
90
91 TransferRCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetTransferR",this);
92 TransferRCmd->SetGuidance("Set Radius of the Transfer Magnet");
93 TransferRCmd->SetParameterName("TSizeR",false,false);
94 TransferRCmd->SetDefaultUnit("cm");
95 TransferRCmd->SetRange("TSizeR>0.");
96 TransferRCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
97
98 TransferZCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetTransferZ",this);
99 TransferZCmd->SetGuidance("Set Length of the Transfer Magnet");
100 TransferZCmd->SetParameterName("TSizeZ",false,false);
101 TransferZCmd->SetDefaultUnit("cm");
102 TransferZCmd->SetRange("TSizeZ>0.");
103 TransferZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
104
105 TransferBCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetTransferB",this);
106 TransferBCmd->SetGuidance("Set B of the Transfer Magnet");
107 TransferBCmd->SetParameterName("TSizeB",false,false);
108 TransferBCmd->SetDefaultUnit("tesla");
109 TransferBCmd->SetRange("TSizeB>0.");
110 TransferBCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
111
112 TransferPCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetTransferP",this);
113 TransferPCmd->SetGuidance("Set Z pos of the T-Mgnt from end of C-Mgnt");
114 TransferPCmd->SetParameterName("TSizeP",false,false);
115 TransferPCmd->SetDefaultUnit("cm");
116 TransferPCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
117
118 TgtMaterCmd = new G4UIcmdWithAString("/field04/SetTgtMat",this);
119 TgtMaterCmd->SetGuidance("Select Material of the Target");
120 TgtMaterCmd->SetParameterName("tchoice",true);
121 TgtMaterCmd->SetDefaultValue("Tungsten");
122 TgtMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
123
124 TgtRadCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetTgtRad",this);
125 TgtRadCmd->SetGuidance("Set Radius of the Target");
126 TgtRadCmd->SetParameterName("TgtSizeR",false,false);
127 TgtRadCmd->SetDefaultUnit("cm");
128 TgtRadCmd->SetRange("TgtSizeR>0.");
129 TgtRadCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
130
131 TgtThickCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetTgtThick",this);
132 TgtThickCmd->SetGuidance("Set Thickness of the Target");
133 TgtThickCmd->SetParameterName("TgtSizeZ",false,false);
134 TgtThickCmd->SetDefaultUnit("cm");
135 TgtThickCmd->SetRange("TgtSizeZ>0.");
136 TgtThickCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
137
138 TgtPosCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetTgtPos",this);
139 TgtPosCmd->SetGuidance("Set Z pos of the tgt relative to C-Mgnt centre");
140 TgtPosCmd->SetParameterName("TgtSizeP",false,false);
141 TgtPosCmd->SetDefaultUnit("cm");
142 TgtPosCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
143
144 TgtAngCmd = new G4UIcmdWithAnInteger("/field04/SetTgtAng",this);
145 TgtAngCmd->SetGuidance("Set the angle [in deg] of the Tgt relative to C-Mgnt centre");
146 TgtAngCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
147
148 DgrMaterCmd = new G4UIcmdWithAString("/field04/SetDgrMat",this);
149 DgrMaterCmd->SetGuidance("Select Material of the Degrader");
150 DgrMaterCmd->SetParameterName("dchoice",true);
151 DgrMaterCmd->SetDefaultValue("Lead");
152 DgrMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
153
154 DgrRadCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetDgrRad",this);
155 DgrRadCmd->SetGuidance("Set Radius of the Degrader");
156 DgrRadCmd->SetParameterName("DrgSizeR",false,false);
157 DgrRadCmd->SetDefaultUnit("cm");
158 DgrRadCmd->SetRange("DrgSizeR>0.");
159 DgrRadCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
160
161 DgrThickCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetDgrThick",this);
162 DgrThickCmd->SetGuidance("Set Thickness of the Degrader");
163 DgrThickCmd->SetParameterName("DgrSizeZ",false,false);
164 DgrThickCmd->SetDefaultUnit("cm");
165 DgrThickCmd->SetRange("DgrSizeZ>0.");
166 DgrThickCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
167
168 DgrPosCmd = new G4UIcmdWithADoubleAndUnit("/field04/SetDgrPos",this);
169 DgrPosCmd->SetGuidance("Set Z pos of the Dgr relative to T-Mgnt centre");
170 DgrPosCmd->SetParameterName("DgrSizeP",false,false);
171 DgrPosCmd->SetDefaultUnit("cm");
172 DgrPosCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
173
174 UpdateCmd = new G4UIcmdWithoutParameter("/field04/Update",this);
175 UpdateCmd->SetGuidance("Update field04 geometry");
176 UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
177 UpdateCmd->SetGuidance("if you changed geometrical value(s).");
178 UpdateCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
179
180}
181
182F04DetectorMessenger::~F04DetectorMessenger()
183{
184 delete detDir;
185
186 delete WorldMaterCmd;
187 delete WorldRCmd;
188 delete WorldZCmd;
189
190 delete CaptureRCmd;
191 delete CaptureZCmd;
192 delete CaptureB1Cmd;
193 delete CaptureB2Cmd;
194
195 delete TransferRCmd;
196 delete TransferZCmd;
197 delete TransferBCmd;
198 delete TransferPCmd;
199
200 delete TgtMaterCmd;
201 delete TgtRadCmd;
202 delete TgtThickCmd;
203 delete TgtPosCmd;
204 delete TgtAngCmd;
205
206 delete DgrMaterCmd;
207 delete DgrRadCmd;
208 delete DgrThickCmd;
209 delete DgrPosCmd;
210
211 delete UpdateCmd;
212}
213
214void F04DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
215{
216 if( command == WorldMaterCmd )
217 { Detector->SetWorldMaterial(newValue);}
218
219 if( command == TgtMaterCmd )
220 { Detector->SetTargetMaterial(newValue);}
221
222 if( command == DgrMaterCmd )
223 { Detector->SetDegraderMaterial(newValue);}
224
225 if( command == WorldRCmd )
226 { Detector->SetWorldSizeR(WorldRCmd->GetNewDoubleValue(newValue));}
227
228 if( command == WorldZCmd )
229 { Detector->SetWorldSizeZ(WorldZCmd->GetNewDoubleValue(newValue));}
230
231 if( command == CaptureRCmd )
232 { Detector->SetCaptureMgntRadius(CaptureRCmd->GetNewDoubleValue(newValue));}
233
234 if( command == CaptureZCmd )
235 { Detector->SetCaptureMgntLength(CaptureZCmd->GetNewDoubleValue(newValue));}
236
237 if( command == CaptureB1Cmd )
238 { Detector->SetCaptureMgntB1(CaptureB1Cmd->GetNewDoubleValue(newValue));}
239
240 if( command == CaptureB2Cmd )
241 { Detector->SetCaptureMgntB2(CaptureB2Cmd->GetNewDoubleValue(newValue));}
242
243 if( command == TransferRCmd )
244 { Detector->SetTransferMgntRadius(TransferRCmd->GetNewDoubleValue(newValue));}
245
246 if( command == TransferZCmd )
247 { Detector->SetTransferMgntLength(TransferZCmd->GetNewDoubleValue(newValue));}
248
249 if( command == TransferBCmd )
250 { Detector->SetTransferMgntB(TransferBCmd->GetNewDoubleValue(newValue));}
251
252 if( command == TransferPCmd )
253 { Detector->SetTransferMgntPos(TransferPCmd->GetNewDoubleValue(newValue));}
254
255 if( command == TgtRadCmd )
256 { Detector->SetTargetRadius(TgtRadCmd->GetNewDoubleValue(newValue));}
257
258 if( command == TgtThickCmd )
259 { Detector->SetTargetThickness(TgtThickCmd->GetNewDoubleValue(newValue));}
260
261 if( command == TgtPosCmd )
262 { Detector->SetTargetPos(TgtPosCmd->GetNewDoubleValue(newValue));}
263
264 if( command == TgtAngCmd )
265 { Detector->SetTargetAngle(TgtAngCmd->GetNewIntValue(newValue));}
266
267 if( command == DgrRadCmd )
268 { Detector->SetDegraderRadius(DgrRadCmd->GetNewDoubleValue(newValue));}
269
270 if( command == DgrThickCmd )
271 { Detector->SetDegraderThickness(DgrThickCmd->GetNewDoubleValue(newValue));}
272
273 if( command == DgrPosCmd )
274 { Detector->SetDegraderPos(DgrPosCmd->GetNewDoubleValue(newValue));}
275
276 if( command == WorldZCmd )
277 { Detector->SetWorldSizeZ(WorldZCmd->GetNewDoubleValue(newValue));}
278
279 if( command == WorldRCmd )
280 { Detector->SetWorldSizeR(WorldRCmd->GetNewDoubleValue(newValue));}
281
282 if( command == UpdateCmd )
283 { Detector->UpdateGeometry(); }
284
285}
Note: See TracBrowser for help on using the repository browser.