ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
STCyclotronDetectorMessenger.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file STCyclotronDetectorMessenger.cc
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 // Author: F. Poignant, floriane.poignant@gmail.com
27 //
28 // file STCyclotronDetectorMesseger.cc
29 //
30 
33 #include "G4UIdirectory.hh"
36 #include "G4UIcmdWithADouble.hh"
37 #include "G4UIcmdWithAString.hh"
38 #include "G4UIcmdWithAnInteger.hh"
39 #include "G4SystemOfUnits.hh"
40 #include "G4UnitsTable.hh"
41 #include "G4UIcommand.hh"
42 
45  :fDet(detector)
46 {
48  // Change Target parameters//
50  fChangeTarget = new G4UIdirectory("/changeTarget/");
51  fChangeTarget -> SetGuidance("Change the Target diameter/thickness/material");
52 
53  // change Target diameter
54  fChangeTargetDiameterCmd = new G4UIcmdWithADoubleAndUnit("/changeTarget/diameter", this);
55  fChangeTargetDiameterCmd -> SetGuidance("Change the diameter value of the target. "
56  "\nDefault value is 7. mm."
57  "\nThe range is between 0 and 15 mm.");
58  fChangeTargetDiameterCmd -> SetParameterName("TargetDiameter", true);
59  fChangeTargetDiameterCmd -> SetRange("TargetDiameter > 0. && TargetDiameter < 15.");
60  fChangeTargetDiameterCmd -> SetDefaultValue(7.*mm);
61  fChangeTargetDiameterCmd -> AvailableForStates(G4State_Idle);
62  fChangeTargetDiameterCmd -> SetDefaultUnit("mm");
63  fChangeTargetDiameterCmd -> SetUnitCandidates("mm");
64 
65  // Change Target parameters
66  fChangeTargetMaterial = new G4UIdirectory("/changeTarget/designedMaterial/");
67  fChangeTargetMaterial -> SetGuidance("Change the Target material choosing isotopes and elements, and their abundance in the target");
68 
69  //Change target material defining isotopes
70  fTargetIsotopeName = new G4UIcmdWithAString("/changeTarget/designedMaterial/isotopeName",this);
71  fTargetIsotopeName->SetGuidance("name of the isotope - ex : Ni64");
72  fTargetIsotopeName->SetParameterName("IsotopeName",false);
74 
75  fTargetIsotopeZ = new G4UIcmdWithADouble("/changeTarget/designedMaterial/isotopeZ",this);
76  fTargetIsotopeZ-> SetGuidance("Z of the isotope");
77  fTargetIsotopeZ->SetParameterName("IsotopeZ",false);
79 
80  fTargetIsotopeN = new G4UIcmdWithAnInteger("/changeTarget/designedMaterial/isotopeN",this);
81  fTargetIsotopeN->SetGuidance("N (number of nucleons) of the isotope");
82  fTargetIsotopeN->SetParameterName("IsotopeN",false);
84 
85  fTargetIsotopeA = new G4UIcmdWithADouble("/changeTarget/designedMaterial/isotopeA",this);
86  fTargetIsotopeA->SetGuidance("A of the isotope, in g/cm3");
87  fTargetIsotopeA->SetParameterName("IsotopeA",false);
89 
90  //Define elements
91  fTargetElementName= new G4UIcmdWithAString("/changeTarget/designedMaterial/ElementName",this);
92  fTargetElementName->SetGuidance("Name of the material - ex : PureNi64");
93  fTargetElementName->SetParameterName("ElementName",false);
95 
96  fTargetElementSymbole=new G4UIcmdWithAString("/changeTarget/designedMaterial/ElementSymbole",this);
97  fTargetElementSymbole->SetGuidance("Symbole of the element : ex 64Ni");
98  fTargetElementSymbole->SetParameterName("ElementSymbole", false);
100 
101  fTargetElementNComponents = new G4UIcmdWithAnInteger("/changeTarget/designedMaterial/ElementNComponents",this);
102  fTargetElementNComponents->SetGuidance("Number of isotopes in the element");
103  fTargetElementNComponents->SetParameterName("ElementNComponent", false);
105 
106  fTargetElementAbundance = new G4UIcmdWithADouble("/changeTarget/designedMaterial/IsotopeAbundanceInElement",this);
107  fTargetElementAbundance->SetGuidance("Abundance of the isotope in the target");
108  fTargetElementAbundance->SetParameterName("IsotopeAbundance",false);
110 
111  //Change material properties
112  fChangeTargetMaterialDensityCmd = new G4UIcmdWithADouble("/changeTarget/designedMaterial/materialDensity", this);
113  fChangeTargetMaterialDensityCmd -> SetGuidance("Change the density value of the Target Material."
114  "\nDefault value : 8.85 g/cm3.");
115  fChangeTargetMaterialDensityCmd -> SetParameterName("TargetMaterialDensity", true);
116  fChangeTargetMaterialDensityCmd -> SetDefaultValue(8.85);
117  fChangeTargetMaterialDensityCmd -> AvailableForStates(G4State_Idle);
118 
119  fTargetMaterialNComponents = new G4UIcmdWithAnInteger("/changeTarget/designedMaterial/MaterialNComponents",this);
120  fTargetMaterialNComponents->SetGuidance("Number of elements in the target material");
121  fTargetMaterialNComponents->SetParameterName("MaterialNComponents",false);
123 
124  fTargetMaterialFractionMass= new G4UIcmdWithADouble("/changeTarget/designedMaterial/MaterialFractionMass",this);
125  fTargetMaterialFractionMass->SetGuidance("Fraction mass of the element in the material");
126  fTargetMaterialFractionMass->SetParameterName("MaterialFractionMass",false);
128 
129  fTargetMaterialNaturalElement= new G4UIcmdWithAString("/changeTarget/designedMaterial/naturalElementName",this);
130  fTargetMaterialNaturalElement->SetGuidance("Add an element using NIST database");
131  fTargetMaterialNaturalElement->SetParameterName("NaturalElement",false);
133 
134  fTargetMaterialNaturalElementFractionMass= new G4UIcmdWithADouble("/changeTarget/designedMaterial/naturalElementFractionMass",this);
135  fTargetMaterialNaturalElementFractionMass->SetGuidance("Add the fraction mass of the natural element");
136  fTargetMaterialNaturalElementFractionMass->SetParameterName("NaturalElementFractionMass",false);
138 
139 
140  fUpdateMaterial = new G4UIcmdWithoutParameter("/changeTarget/designedMaterial/update",this);
141  fUpdateMaterial->SetGuidance("Update the material once its components are defined");
143 
144  //Change material using physics NIST
145  fChangeTargetMaterialCmd = new G4UIcmdWithAString("/changeTarget/materialNist", this);
146  fChangeTargetMaterialCmd -> SetGuidance("Change the material of your target using the NIST database."
147  "\nTo get the list of the available NIST materials, please select 'TargetMaterial->NistMaterialList'."
148  "\nExample of a NIST material : 'G4_Ni'.");
149  fChangeTargetMaterialCmd -> SetParameterName("TargetMaterial",false);
150 
151 
152  //Change Target thickness
153  fChangeTargetThicknessCmd = new G4UIcmdWithADoubleAndUnit("/changeTarget/thickness", this);
154  fChangeTargetThicknessCmd -> SetGuidance("Change the thickness value of the Target."
155  "\nDefault value : 0.6 mm.");
156  fChangeTargetThicknessCmd -> SetParameterName("TargetThickness", true);
157  fChangeTargetThicknessCmd -> SetDefaultValue(0.6*mm);
158  fChangeTargetThicknessCmd -> AvailableForStates(G4State_Idle);
159  fChangeTargetThicknessCmd -> SetDefaultUnit("mm");
160  fChangeTargetThicknessCmd -> SetUnitCandidates("mm");
161 
162 
164  //Change foil parameters//
166 
167  fChangeFoil = new G4UIdirectory("/changeFoil/");
168  fChangeFoil -> SetGuidance("Change the Foil thickness");
169 
170  // Change Foil Thickness
171  fChangeFoilThicknessCmd = new G4UIcmdWithADoubleAndUnit("/changeFoil/thickness", this);
172  fChangeFoilThicknessCmd -> SetGuidance("Change the thickness value of the foil "
173  "\nThe default value is 0.32 mm.");
174  fChangeFoilThicknessCmd -> SetParameterName("FoilThickness", true);
175  fChangeFoilThicknessCmd -> SetDefaultValue(.32*mm);
176  fChangeFoilThicknessCmd -> AvailableForStates(G4State_Idle);
177  fChangeFoilThicknessCmd -> SetDefaultUnit("mm");
178  fChangeFoilThicknessCmd -> SetUnitCandidates("mm");
179 
180  // Change Target material
181  fChangeFoilMaterial = new G4UIdirectory("/changeFoil/designedMaterial/");
182  fChangeFoilMaterial -> SetGuidance("Change the Foil material choosing isotopes and elements, and their abundance in the foil");
183 
184  //Change target material defining isotopes
185  fFoilIsotopeName = new G4UIcmdWithAString("/changeFoil/designedMaterial/isotopeName",this);
186  fFoilIsotopeName->SetGuidance("name of the isotope - ex : Ni64");
187  fFoilIsotopeName->SetParameterName("foilIsotopeName",false);
189 
190  fFoilIsotopeZ = new G4UIcmdWithADouble("/changeFoil/designedMaterial/isotopeZ",this);
191  fFoilIsotopeZ-> SetGuidance("Z of the isotope");
192  fFoilIsotopeZ->SetParameterName("foilIsotopeZ",false);
194 
195  fFoilIsotopeN = new G4UIcmdWithAnInteger("/changeFoil/designedMaterial/isotopeN",this);
196  fFoilIsotopeN->SetGuidance("N (number of nucleons) of the isotope");
197  fFoilIsotopeN->SetParameterName("foilIsotopeN",false);
199 
200  fFoilIsotopeA = new G4UIcmdWithADouble("/changeFoil/designedMaterial/isotopeA",this);
201  fFoilIsotopeA->SetGuidance("A of the isotope, in g/cm3");
202  fFoilIsotopeA->SetParameterName("foilIsotopeA",false);
204 
205  //Define elements
206 
207  fFoilElementName= new G4UIcmdWithAString("/changeFoil/designedMaterial/ElementName",this);
208  fFoilElementName->SetGuidance("Name of the material - ex : PureNi64");
209  fFoilElementName->SetParameterName("foilElementName",false);
211 
212  fFoilElementSymbole=new G4UIcmdWithAString("/changeFoil/designedMaterial/ElementSymbole",this);
213  fFoilElementSymbole->SetGuidance("Symbole of the element : ex 64Ni");
214  fFoilElementSymbole->SetParameterName("foilElementSymbole", false);
216 
217  fFoilElementNComponents = new G4UIcmdWithAnInteger("/changeFoil/designedMaterial/ElementNComponents",this);
218  fFoilElementNComponents->SetGuidance("Number of isotopes in the element");
219  fFoilElementNComponents->SetParameterName("foilElementNComponent", false);
221 
222  fFoilElementAbundance = new G4UIcmdWithADouble("/changeFoil/designedMaterial/IsotopeAbundanceInElement",this);
223  fFoilElementAbundance->SetGuidance("Abundance of the isotope in the foil");
224  fFoilElementAbundance->SetParameterName("foilIsotopeAbundance",false);
226 
227  //Change material properties
228  fChangeFoilMaterialDensityCmd = new G4UIcmdWithADouble("/changeFoil/designedMaterial/materialDensity", this);
229  fChangeFoilMaterialDensityCmd -> SetGuidance("Change the density value of the Target Material");
230  fChangeFoilMaterialDensityCmd -> SetParameterName("FoilMaterialDensity", true);
231  fChangeFoilMaterialDensityCmd -> AvailableForStates(G4State_Idle);
232 
233  fFoilMaterialNComponents = new G4UIcmdWithAnInteger("/changeFoil/designedMaterial/MaterialNComponents",this);
234  fFoilMaterialNComponents->SetGuidance("Number of elements in the target material");
235  fFoilMaterialNComponents->SetParameterName("foilMaterialNComponents",false);
237 
238  fFoilMaterialFractionMass= new G4UIcmdWithADouble("/changeFoil/designedMaterial/MaterialFractionMass",this);
239  fFoilMaterialFractionMass->SetGuidance("Fraction mass of the element in the material");
240  fFoilMaterialFractionMass->SetParameterName("foilMaterialFractionMass",false);
242 
243  fFoilMaterialNaturalElement= new G4UIcmdWithAString("/changeFoil/designedMaterial/naturalElementName",this);
244  fFoilMaterialNaturalElement->SetGuidance("Add an element using NIST database");
245  fFoilMaterialNaturalElement->SetParameterName("foilNaturalElement",false);
247 
248  fFoilMaterialNaturalElementFractionMass= new G4UIcmdWithADouble("/changeFoil/designedMaterial/naturalElementFractionMass",this);
249  fFoilMaterialNaturalElementFractionMass->SetGuidance("Add the fraction mass of the natural element");
250  fFoilMaterialNaturalElementFractionMass->SetParameterName("foilNaturalElementFractionMass",false);
252 
253 
254  fUpdateFoilMaterial = new G4UIcmdWithoutParameter("/changeFoil/designedMaterial/update",this);
255  fUpdateFoilMaterial->SetGuidance("Update the material once its components are defined");
257 
258  //Change foil material using physics NIST
259 
260  fChangeFoilMaterialCmd = new G4UIcmdWithAString("/changeFoil/materialNist", this);
261  fChangeFoilMaterialCmd -> SetGuidance("Change the material of your foil using the NIST database."
262  "\nTo get the list of the available NIST materials, please select 'TargetMaterial->NistMaterialList'."
263  "\nExample of a NIST material : 'G4_Ni'.");
264  fChangeFoilMaterialCmd -> SetParameterName("FoilMaterial",false);
265 
266  }
267 
269 {
270  delete fChangeTarget;
271  delete fChangeTargetDiameterCmd;
272  delete fChangeTargetMaterial;
273  delete fTargetIsotopeName;
274  delete fTargetIsotopeZ ;
275  delete fTargetIsotopeN;
276  delete fTargetIsotopeA;
277  delete fTargetElementName;
278  delete fTargetElementSymbole;
280  delete fTargetElementAbundance ;
286  delete fUpdateMaterial;
288  delete fChangeFoilMaterial;
289  delete fFoilIsotopeName;
290  delete fFoilIsotopeZ ;
291  delete fFoilIsotopeN;
292  delete fFoilIsotopeA;
293  delete fFoilElementName;
294  delete fFoilElementSymbole;
296  delete fFoilElementAbundance ;
302  delete fUpdateFoilMaterial;
303  delete fChangeFoilMaterialCmd;
305  delete fChangeFoil;
307 
308 }
309 
311 {
312  //TARGET
313  //DIAMETER
314  if( command == fChangeTargetDiameterCmd)
315  {
316  G4double updatedValue = fChangeTargetDiameterCmd -> GetNewDoubleValue(newValue);
317  fDet -> SetTargetDiameter(updatedValue);
318  }
319 
320  //MATERIAL
321  else if(command == fTargetIsotopeName)
322  {
323  fDet -> SetTargetIsotopeName(newValue);
324  }
325 
326  else if(command == fTargetIsotopeZ)
327  {
328  fDet -> SetTargetIsotopeZ(fTargetIsotopeZ->GetNewDoubleValue(newValue));
329  }
330 
331  else if(command == fTargetIsotopeN)
332  {
333  fDet -> SetTargetIsotopeN(fTargetIsotopeN->GetNewIntValue(newValue));
334  }
335 
336  else if(command == fTargetIsotopeA)
337  {
338  fDet -> SetTargetIsotopeA(fTargetIsotopeA->GetNewDoubleValue(newValue));
339  }
340 
341  else if(command == fTargetElementName)
342  {
343  fDet -> SetTargetElementName(newValue);
344  }
345 
346  else if(command == fTargetElementSymbole)
347  {
348  fDet -> SetTargetElementSymbole(newValue);
349  }
350 
351  else if(command == fTargetElementNComponents)
352  {
353  fDet -> SetTargetElementNComponents(fTargetElementNComponents->GetNewIntValue(newValue));
354  }
355 
356  else if(command == fTargetElementAbundance)
357  {
358  fDet -> SetTargetElementAbundance(fTargetElementAbundance->GetNewDoubleValue(newValue));
359  }
360 
361 
362  else if (command == fChangeTargetMaterialDensityCmd )
363  {
364  G4double updatedValue = fChangeTargetMaterialDensityCmd -> GetNewDoubleValue(newValue);
365  fDet -> SetTargetMaterialDensity(updatedValue);
366  }
367 
368  else if(command == fTargetMaterialNComponents)
369  {
370  fDet -> SetTargetMaterialNComponents(fTargetMaterialNComponents->GetNewIntValue(newValue));
371  }
372 
373  else if(command == fTargetMaterialFractionMass)
374  {
375  fDet -> SetTargetMaterialFractionMass(fTargetMaterialFractionMass->GetNewDoubleValue(newValue));
376  }
377 
378  else if(command == fUpdateMaterial)
379  {
380  fDet -> UpdateMaterial();
381  }
382 
383  //NATURAL ELEMENT
384  else if(command == fTargetMaterialNaturalElement)
385  {
386  fDet ->SetTargetNaturalElement(newValue);
387  }
388 
390  {
392  }
393 
394 
395  //NATURAL MATERIAL
396 
397  else if (command == fChangeTargetMaterialCmd )
398  {
399  fDet -> SetTargetMaterial(newValue);
400  }
401 
402  //THICKNESS
403 
404  else if (command == fChangeTargetThicknessCmd )
405  {
406  G4double updatedValue = fChangeTargetThicknessCmd -> GetNewDoubleValue(newValue);
407  fDet -> SetTargetThickness(updatedValue);
408  }
409 
410  //FOIL
411 
412  else if (command == fChangeFoilThicknessCmd )
413  {
414  G4double updatedValue = fChangeFoilThicknessCmd -> GetNewDoubleValue(newValue);
415  fDet -> SetFoilThickness(updatedValue);
416  }
417 
418  //MATERIAL FOIL
419  else if(command == fFoilIsotopeName)
420  {
421  fDet -> SetFoilIsotopeName(newValue);
422  }
423 
424  else if(command == fFoilIsotopeZ)
425  {
426  fDet -> SetFoilIsotopeZ(fFoilIsotopeZ->GetNewDoubleValue(newValue));
427  }
428 
429  else if(command == fFoilIsotopeN)
430  {
431  fDet -> SetFoilIsotopeN(fFoilIsotopeN->GetNewIntValue(newValue));
432  }
433 
434  else if(command == fFoilIsotopeA)
435  {
436  fDet -> SetFoilIsotopeA(fFoilIsotopeA->GetNewDoubleValue(newValue));
437  }
438 
439  else if(command == fFoilElementName)
440  {
441  fDet -> SetFoilElementName(newValue);
442  }
443 
444  else if(command == fFoilElementSymbole)
445  {
446  fDet -> SetFoilElementSymbole(newValue);
447  }
448 
449  else if(command == fFoilElementNComponents)
450  {
451  fDet -> SetFoilElementNComponents(fFoilElementNComponents->GetNewIntValue(newValue));
452  }
453 
454  else if(command == fFoilElementAbundance)
455  {
456  fDet -> SetFoilElementAbundance(fFoilElementAbundance->GetNewDoubleValue(newValue));
457  }
458 
459 
460  else if (command == fChangeFoilMaterialDensityCmd )
461  {
462  G4double updatedValue = fChangeFoilMaterialDensityCmd -> GetNewDoubleValue(newValue);
463  fDet -> SetFoilMaterialDensity(updatedValue);
464  }
465 
466  else if(command == fFoilMaterialNComponents)
467  {
468  fDet -> SetFoilMaterialNComponents(fFoilMaterialNComponents->GetNewIntValue(newValue));
469  }
470 
471  else if(command == fFoilMaterialFractionMass)
472  {
473  fDet -> SetFoilMaterialFractionMass(fFoilMaterialFractionMass->GetNewDoubleValue(newValue));
474  }
475 
476  else if(command == fUpdateFoilMaterial)
477  {
478  fDet -> UpdateFoilMaterial();
479  }
480 
481  //NATURAL ELEMENT
482  else if(command == fFoilMaterialNaturalElement)
483  {
484  fDet ->SetFoilNaturalElement(newValue);
485  }
486 
487  else if(command == fFoilMaterialNaturalElementFractionMass)
488  {
490  }
491 
492  //NATURAL MATERIAL
493  else if (command == fChangeFoilMaterialCmd )
494  {
495  fDet -> SetFoilMaterial(newValue);
496  }
497 }