Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IORTDetectorMessenger.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 // This is the *BASIC* version of IORT, a Geant4-based application
27 //
28 // Main Authors: G.Russo(a,b), C.Casarino*(c), G.C. Candiano(c), G.A.P. Cirrone(d), F.Romano(d)
29 // Contributor Authors: S.Guatelli(e)
30 // Past Authors: G.Arnetta(c), S.E.Mazzaglia(d)
31 //
32 // (a) Fondazione Istituto San Raffaele G.Giglio, Cefalù, Italy
33 // (b) IBFM-CNR , Segrate (Milano), Italy
34 // (c) LATO (Laboratorio di Tecnologie Oncologiche), Cefalù, Italy
35 // (d) Laboratori Nazionali del Sud of the INFN, Catania, Italy
36 // (e) University of Wallongong, Australia
37 //
38 // *Corresponding author, email to carlo.casarino@polooncologicocefalu.it
40 
41 #include "IORTDetectorMessenger.hh"
43 #include "G4UIdirectory.hh"
46 #include "G4UIcmdWithAString.hh"
47 #include "G4UIcmdWithADoubleAndUnit.hh" // aggiunto
48 
51  :iortDetector(detector)
52 {
53  // Change Phantom size
54  changeThePhantomDir = new G4UIdirectory("/changePhantom/");
55  changeThePhantomDir -> SetGuidance("Command to change the Phantom Size/position");
56  changeThePhantomSizeCmd = new G4UIcmdWith3VectorAndUnit("/changePhantom/size", this);
57  changeThePhantomSizeCmd -> SetGuidance("Insert sizes X Y and Z"
58  "\n 0 or negative values mean <<Don't change it!>>");
59  changeThePhantomSizeCmd -> SetParameterName("PhantomSizeAlongX",
60  "PhantomSizeAlongY",
61  "PhantomSizeAlongZ", false);
62  changeThePhantomSizeCmd -> SetDefaultUnit("mm");
63  changeThePhantomSizeCmd -> SetUnitCandidates("nm um mm cm");
64  changeThePhantomSizeCmd -> AvailableForStates(G4State_Idle);
65 
66 
67  // Change Phantom material
68  changeThePhantomMaterialCmd = new G4UIcmdWithAString("/changePhantom/material", this);
69  changeThePhantomMaterialCmd -> SetGuidance("Change the Phantom and the detector material");
70  changeThePhantomMaterialCmd -> SetParameterName("PhantomMaterial", false);
71  changeThePhantomMaterialCmd -> SetDefaultValue("G4_WATER");
72  changeThePhantomMaterialCmd -> AvailableForStates(G4State_Idle);
73 
74  // Change Phantom position
75  changeThePhantomPositionCmd = new G4UIcmdWith3VectorAndUnit("/changePhantom/position", this);
76  changeThePhantomPositionCmd -> SetGuidance("Insert X Y and Z dimensions for the position of the center of the Phantom"
77  " respect to that of the \"World\"");
78  changeThePhantomPositionCmd -> SetParameterName("PositionAlongX",
79  "PositionAlongY",
80  "PositionAlongZ", false);
81  changeThePhantomPositionCmd -> SetDefaultUnit("mm");
82  changeThePhantomPositionCmd -> SetUnitCandidates("um mm cm m");
83  changeThePhantomPositionCmd -> AvailableForStates(G4State_Idle);
84 
85 
86  updateCmd = new G4UIcmdWithoutParameter("/changePhantom/update",this);
87  updateCmd->SetGuidance("Update Phantom/Detector geometry.");
88  updateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
89  updateCmd->SetGuidance("if you changed geometrical value(s).");
90  updateCmd->AvailableForStates(G4State_Idle);
91 
92  // Change detector size
93  changeTheDetectorDir = new G4UIdirectory("/changeDetector/");
94  changeTheDetectorDir -> SetGuidance("Command to change the Detector's Size/position/Voxels");
95 
96  changeTheDetectorSizeCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/size",this);
97  changeTheDetectorSizeCmd -> SetGuidance("Insert sizes for X Y and Z dimensions of the Detector"
98  "\n 0 or negative values mean <<Don't change it>>");
99  changeTheDetectorSizeCmd -> SetParameterName("DetectorSizeAlongX", "DetectorSizeAlongY", "DetectorSizeAlongZ", false);
100  changeTheDetectorSizeCmd -> SetDefaultUnit("mm");
101  changeTheDetectorSizeCmd -> SetUnitCandidates("nm um mm cm");
102  changeTheDetectorSizeCmd -> AvailableForStates(G4State_Idle);
103 
104  // Change the detector to phantom displacement
105  changeTheDetectorToPhantomPositionCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/displacement",this);
106  changeTheDetectorToPhantomPositionCmd -> SetGuidance("Insert X Y and Z displacements between Detector and Phantom"
107  "\nNegative values mean <<Don't change it!>>");
108  changeTheDetectorToPhantomPositionCmd -> SetParameterName("DisplacementAlongX",
109  "DisplacementAlongY",
110  "DisplacementAlongZ", false);
111  changeTheDetectorToPhantomPositionCmd -> SetDefaultUnit("mm");
112  changeTheDetectorToPhantomPositionCmd -> SetUnitCandidates("nm um mm cm");
113  changeTheDetectorToPhantomPositionCmd -> AvailableForStates(G4State_Idle);
114 
115  // Change voxels by its size
116  changeTheDetectorVoxelCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/voxelSize",this);
117  changeTheDetectorVoxelCmd -> SetGuidance("Insert Voxel sizes for X Y and Z dimensions"
118  "\n 0 or negative values mean <<Don't change it!>>");
119  changeTheDetectorVoxelCmd -> SetParameterName("VoxelSizeAlongX", "VoxelSizeAlongY", "VoxelSizeAlongZ", false);
120  changeTheDetectorVoxelCmd -> SetDefaultUnit("mm");
121  changeTheDetectorVoxelCmd -> SetUnitCandidates("nm um mm cm");
122  changeTheDetectorVoxelCmd -> AvailableForStates(G4State_Idle);
123 
124 
125  // Change disc1
126  changeTheDisc1Dir = new G4UIdirectory("/ProtectionDisc1/");
127  changeTheDisc1Dir -> SetGuidance("Command to change the Disc1");
128 
129  changeOuterRadiusDiscoIORTCmd = new G4UIcmdWithADoubleAndUnit("/ProtectionDisc1/OuterRadiusDisc1",this);
130  changeOuterRadiusDiscoIORTCmd -> SetGuidance("Set size of outer radius");
131  changeOuterRadiusDiscoIORTCmd -> SetParameterName("Size",false);
132  changeOuterRadiusDiscoIORTCmd -> SetDefaultUnit("mm");
133  changeOuterRadiusDiscoIORTCmd -> SetUnitCandidates("mm cm m");
134  changeOuterRadiusDiscoIORTCmd -> AvailableForStates(G4State_Idle);
135 
136  changeinnerRadiusDiscoIORTCmd = new G4UIcmdWithADoubleAndUnit("/ProtectionDisc1/InnerRadiusDisc1",this);
137  changeinnerRadiusDiscoIORTCmd -> SetGuidance("Set size of inner radius");
138  changeinnerRadiusDiscoIORTCmd -> SetParameterName("Size",false);
139  changeinnerRadiusDiscoIORTCmd -> SetDefaultUnit("mm");
140  changeinnerRadiusDiscoIORTCmd -> SetUnitCandidates("mm cm m");
141  changeinnerRadiusDiscoIORTCmd -> AvailableForStates(G4State_Idle);
142 
143 
144  changeheightDiscoIORTCmd = new G4UIcmdWithADoubleAndUnit("/ProtectionDisc1/HeightDisc1",this);
145  changeheightDiscoIORTCmd -> SetGuidance("Set size of higth");
146  changeheightDiscoIORTCmd -> SetParameterName("Size",false);
147  changeheightDiscoIORTCmd -> SetDefaultUnit("mm");
148  changeheightDiscoIORTCmd -> SetUnitCandidates("mm cm m");
149  changeheightDiscoIORTCmd -> AvailableForStates(G4State_Idle);
150 
151  changeDiscoXPositionIORTCmd = new G4UIcmdWithADoubleAndUnit("/ProtectionDisc1/XPositionDisc1",this);
152  changeDiscoXPositionIORTCmd -> SetGuidance("Set the X position");
153  changeDiscoXPositionIORTCmd -> SetParameterName("Size",false);
154  changeDiscoXPositionIORTCmd -> SetDefaultUnit("mm");
155  changeDiscoXPositionIORTCmd -> SetUnitCandidates("mm cm m");
156  changeDiscoXPositionIORTCmd -> AvailableForStates(G4State_Idle);
157 
158  changeDiscoYPositionIORTCmd = new G4UIcmdWithADoubleAndUnit("/ProtectionDisc1/YPositionDisc1",this);
159  changeDiscoYPositionIORTCmd -> SetGuidance("Set the Y position");
160  changeDiscoYPositionIORTCmd -> SetParameterName("Size",false);
161  changeDiscoYPositionIORTCmd -> SetDefaultUnit("mm");
162  changeDiscoYPositionIORTCmd -> SetUnitCandidates("mm cm m");
163  changeDiscoYPositionIORTCmd -> AvailableForStates(G4State_Idle);
164 
165  changeDiscoZPositionIORTCmd = new G4UIcmdWithADoubleAndUnit("/ProtectionDisc1/ZPositionDisc1",this);
166  changeDiscoZPositionIORTCmd -> SetGuidance("Set the Z position");
167  changeDiscoZPositionIORTCmd -> SetParameterName("Size",false);
168  changeDiscoZPositionIORTCmd -> SetDefaultUnit("mm");
169  changeDiscoZPositionIORTCmd -> SetUnitCandidates("mm cm m");
170  changeDiscoZPositionIORTCmd -> AvailableForStates(G4State_Idle);
171 
172  changeTheDisc1MaterialCmd = new G4UIcmdWithAString("/ProtectionDisc1/material", this);
173  changeTheDisc1MaterialCmd -> SetGuidance("Change the Disc1 material");
174  changeTheDisc1MaterialCmd -> SetParameterName("Disc1Material", false);
175  changeTheDisc1MaterialCmd -> SetDefaultValue("G4_WATER");
176  changeTheDisc1MaterialCmd -> AvailableForStates(G4State_Idle);
177 
178 
179 
180  // Change disc2
181  changeTheDisc2Dir = new G4UIdirectory("/ProtectionDisc2/");
182  changeTheDisc2Dir -> SetGuidance("Command to change the Disc2");
183 
184  changeOuterRadiusDisco1IORTCmd = new G4UIcmdWithADoubleAndUnit("/ProtectionDisc2/OuterRadiusDisc2",this);
185  changeOuterRadiusDisco1IORTCmd -> SetGuidance("Set size of outer radius");
186  changeOuterRadiusDisco1IORTCmd -> SetParameterName("Size",false);
187  changeOuterRadiusDisco1IORTCmd -> SetDefaultUnit("mm");
188  changeOuterRadiusDisco1IORTCmd -> SetUnitCandidates("mm cm m");
189  changeOuterRadiusDisco1IORTCmd -> AvailableForStates(G4State_Idle);
190 
191  changeinnerRadiusDisco1IORTCmd = new G4UIcmdWithADoubleAndUnit("/ProtectionDisc2/InnerRadiusDisc2",this);
192  changeinnerRadiusDisco1IORTCmd -> SetGuidance("Set size of inner radius");
193  changeinnerRadiusDisco1IORTCmd -> SetParameterName("Size",false);
194  changeinnerRadiusDisco1IORTCmd -> SetDefaultUnit("mm");
195  changeinnerRadiusDisco1IORTCmd -> SetUnitCandidates("mm cm m");
196  changeinnerRadiusDisco1IORTCmd -> AvailableForStates(G4State_Idle);
197 
198 
199  changeheightDisco1IORTCmd = new G4UIcmdWithADoubleAndUnit("/ProtectionDisc2/HeightDisc2",this);
200  changeheightDisco1IORTCmd -> SetGuidance("Set size of higth");
201  changeheightDisco1IORTCmd -> SetParameterName("Size",false);
202  changeheightDisco1IORTCmd -> SetDefaultUnit("mm");
203  changeheightDisco1IORTCmd -> SetUnitCandidates("mm cm m");
204  changeheightDisco1IORTCmd -> AvailableForStates(G4State_Idle);
205 
206  changeDisco1XPositionIORTCmd = new G4UIcmdWithADoubleAndUnit("/ProtectionDisc2/XPositionDisc2",this);
207  changeDisco1XPositionIORTCmd -> SetGuidance("Set the X position");
208  changeDisco1XPositionIORTCmd -> SetParameterName("Size",false);
209  changeDisco1XPositionIORTCmd -> SetDefaultUnit("mm");
210  changeDisco1XPositionIORTCmd -> SetUnitCandidates("mm cm m");
211  changeDisco1XPositionIORTCmd -> AvailableForStates(G4State_Idle);
212 
213  changeTheDisc2MaterialCmd = new G4UIcmdWithAString("/ProtectionDisc2/material", this);
214  changeTheDisc2MaterialCmd -> SetGuidance("Change the Disc2 material");
215  changeTheDisc2MaterialCmd -> SetParameterName("Disc1Material", false);
216  changeTheDisc2MaterialCmd -> SetDefaultValue("G4_WATER");
217  changeTheDisc2MaterialCmd -> AvailableForStates(G4State_Idle);
218 
219  // Delete disc 1-2
220  deleteTheDiscDir = new G4UIdirectory("/DeleteProtectionDisc/");
221  deleteTheDiscDir -> SetGuidance("Command to delete the 1-2 Discs ");
222 
223  deletediscCmd = new G4UIcmdWithoutParameter("/DeleteProtectionDisc/delete",this);
224  deletediscCmd->SetGuidance("Delete the 1-2 Discs geometry.");
225  deletediscCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
226  deletediscCmd->AvailableForStates(G4State_Idle);
227 
228  // Insert disc 1-2
229  insertTheDiscDir = new G4UIdirectory("/InsertProtectionDisc/");
230  insertTheDiscDir -> SetGuidance("Command to insert the 1-2 Discs ");
231 
232  insertdiscCmd = new G4UIcmdWithoutParameter("/InsertProtectionDisc/insert",this);
233  insertdiscCmd->SetGuidance("Insert the 1-2 Discs geometry.");
234  insertdiscCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
235  insertdiscCmd->SetGuidance("After this command MUST be applied update command \"beamOn\" ");
236  insertdiscCmd->AvailableForStates(G4State_Idle);
237 
238  // Change Tilt angle disc1 + disc2
239  changeTheAnglediscDir = new G4UIdirectory("/ChangeTiltAngleDisc1-2/");
240  changeTheAnglediscDir -> SetGuidance("Set tilt angle of the 1-2 Discs");
241 
242  changeTheAnglediscCmd = new G4UIcmdWithADoubleAndUnit("/ChangeTiltAngleDisc1-2/TiltAngleDisc1-2",this);
243  changeTheAnglediscCmd -> SetParameterName("Angle",false);
244  changeTheAnglediscCmd -> SetDefaultUnit("deg");
245  changeTheAnglediscCmd -> SetUnitCandidates("deg rad");
246  changeTheAnglediscCmd -> AvailableForStates(G4State_Idle);
247  }
248 
251 {
252  delete changeThePhantomDir;
253  delete changeThePhantomSizeCmd;
254  delete changeThePhantomPositionCmd;
255  delete changeThePhantomMaterialCmd;
256  delete updateCmd;
257  delete changeTheDetectorDir;
258  delete changeTheDetectorSizeCmd;
259  delete changeTheDetectorToPhantomPositionCmd;
260  delete changeTheDetectorVoxelCmd;
261 
262  delete changeTheDisc1Dir;
263  delete changeOuterRadiusDiscoIORTCmd;
264  delete changeinnerRadiusDiscoIORTCmd;
265  delete changeheightDiscoIORTCmd;
266  delete changeDiscoXPositionIORTCmd;
267  delete changeDiscoYPositionIORTCmd;
268  delete changeDiscoZPositionIORTCmd;
269  delete changeTheDisc1MaterialCmd;
270 
271  delete changeTheDisc2Dir;
272  delete changeOuterRadiusDisco1IORTCmd;
273  delete changeinnerRadiusDisco1IORTCmd;
274  delete changeheightDisco1IORTCmd;
275  delete changeDisco1XPositionIORTCmd;
276  delete changeTheDisc2MaterialCmd;
277 
278  delete deletediscCmd;
279  delete insertdiscCmd;
280 
281  delete changeTheAnglediscDir;
282  delete changeTheAnglediscCmd;
283 }
284 
287 {
288 
289  if( command == changeThePhantomSizeCmd)
290  {
291  G4ThreeVector size = changeThePhantomSizeCmd -> GetNew3VectorValue(newValue);
292  iortDetector -> SetPhantomSize(size.getX(),size.getY(),size.getZ());
293  }
294  else if (command == changeThePhantomPositionCmd )
295  {
296  G4ThreeVector size = changeThePhantomPositionCmd -> GetNew3VectorValue(newValue);
297  iortDetector -> SetPhantomPosition(size);
298  }
299  else if (command == changeThePhantomMaterialCmd)
300  {
301  iortDetector -> SetPhantomMaterial(newValue);
302  }
303  else if (command == changeTheDetectorSizeCmd)
304  {
305  G4ThreeVector size = changeTheDetectorSizeCmd -> GetNew3VectorValue(newValue);
306  iortDetector -> SetDetectorSize(size.getX(),size.getY(),size.getZ());
307  }
308  else if (command == changeTheDetectorToPhantomPositionCmd)
309  {
310  G4ThreeVector size = changeTheDetectorToPhantomPositionCmd-> GetNew3VectorValue(newValue);
311  iortDetector -> SetDetectorToPhantomPosition(size);
312  }
313  else if (command == changeTheDetectorVoxelCmd)
314  {
315  G4ThreeVector size = changeTheDetectorVoxelCmd -> GetNew3VectorValue(newValue);
316  iortDetector -> SetVoxelSize(size.getX(),size.getY(),size.getZ());
317  }
319 
320  else if( command == changeOuterRadiusDiscoIORTCmd )
321  {
322  iortDetector -> SetOuterRadiusDiscoIORT
323  (changeOuterRadiusDiscoIORTCmd -> GetNewDoubleValue(newValue));
324  }
325  else if( command == changeinnerRadiusDiscoIORTCmd )
326  { iortDetector -> SetinnerRadiusDiscoIORT
327  (changeinnerRadiusDiscoIORTCmd -> GetNewDoubleValue(newValue));
328  }
329  else if( command == changeheightDiscoIORTCmd )
330  { iortDetector -> SetheightDiscoIORT
331  (changeheightDiscoIORTCmd -> GetNewDoubleValue(newValue));
332  }
333  else if( command == changeDiscoXPositionIORTCmd )
334  { iortDetector -> SetDiscoXPositionIORT
335  (changeDiscoXPositionIORTCmd -> GetNewDoubleValue(newValue));
336  }
337  else if( command == changeDiscoYPositionIORTCmd )
338  { iortDetector -> SetDiscoYPositionIORT
339  (changeDiscoYPositionIORTCmd -> GetNewDoubleValue(newValue));
340  }
341  else if( command == changeDiscoZPositionIORTCmd )
342  { iortDetector -> SetDiscoZPositionIORT
343  (changeDiscoZPositionIORTCmd -> GetNewDoubleValue(newValue));
344  }
345  else if (command == changeTheDisc1MaterialCmd)
346  {
347  iortDetector -> SetDiscoMaterialIORT(newValue);
348  }
349 
350  else if( command == changeOuterRadiusDisco1IORTCmd )
351  { iortDetector -> SetOuterRadiusDiscoIORT1
352  (changeOuterRadiusDisco1IORTCmd -> GetNewDoubleValue(newValue));
353  }
354  else if( command == changeinnerRadiusDisco1IORTCmd )
355  { iortDetector -> SetinnerRadiusDiscoIORT1
356  (changeinnerRadiusDisco1IORTCmd -> GetNewDoubleValue(newValue));
357  }
358  else if( command == changeheightDisco1IORTCmd )
359  { iortDetector -> SetheightDiscoIORT1
360  (changeheightDisco1IORTCmd -> GetNewDoubleValue(newValue));
361  }
362  else if( command == changeDisco1XPositionIORTCmd )
363  { iortDetector -> SetDiscoXPositionIORT1
364  (changeDisco1XPositionIORTCmd -> GetNewDoubleValue(newValue));
365  }
366  else if (command == changeTheDisc2MaterialCmd)
367  {
368  iortDetector -> SetDiscoMaterialIORT1(newValue);
369  }
370  else if (command == changeTheAnglediscCmd)
371  {
372  iortDetector -> SetAngleDiscoIORT0
373  (changeTheAnglediscCmd -> GetNewDoubleValue(newValue));
374  }
375 
376 
377 
378  else if (command == updateCmd)
379  {
380  iortDetector -> UpdateGeometry();
381  }
382 
383  else if (command == deletediscCmd)
384  {
385  iortDetector -> DeleteDisc();
386  }
387 
388 else if (command == insertdiscCmd)
389  {
390  iortDetector -> ConstructDisc();
391  }
392 }