File indexing completed on 2025-02-23 09:20:26
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 #include "STCyclotronDetectorMessenger.hh"
0032 #include "STCyclotronDetectorConstruction.hh"
0033 #include "G4UIdirectory.hh"
0034 #include "G4UIcmdWithADoubleAndUnit.hh"
0035 #include "G4UIcmdWithoutParameter.hh"
0036 #include "G4UIcmdWithADouble.hh"
0037 #include "G4UIcmdWithAString.hh"
0038 #include "G4UIcmdWithAnInteger.hh"
0039 #include "G4SystemOfUnits.hh"
0040 #include "G4UnitsTable.hh"
0041 #include "G4UIcommand.hh"
0042
0043
0044 STCyclotronDetectorMessenger::STCyclotronDetectorMessenger(STCyclotronDetectorConstruction* detector)
0045 :fDet(detector)
0046 {
0047
0048
0049
0050 fChangeTarget = new G4UIdirectory("/changeTarget/");
0051 fChangeTarget -> SetGuidance("Change the Target diameter/thickness/material");
0052
0053
0054 fChangeTargetDiameterCmd = new G4UIcmdWithADoubleAndUnit("/changeTarget/diameter", this);
0055 fChangeTargetDiameterCmd -> SetGuidance("Change the diameter value of the target. "
0056 "\nDefault value is 7. mm."
0057 "\nThe range is between 0 and 15 mm.");
0058 fChangeTargetDiameterCmd -> SetParameterName("TargetDiameter", true);
0059 fChangeTargetDiameterCmd -> SetRange("TargetDiameter > 0. && TargetDiameter < 15.");
0060 fChangeTargetDiameterCmd -> SetDefaultValue(7.*mm);
0061 fChangeTargetDiameterCmd -> AvailableForStates(G4State_Idle);
0062 fChangeTargetDiameterCmd -> SetDefaultUnit("mm");
0063 fChangeTargetDiameterCmd -> SetUnitCandidates("mm");
0064
0065
0066 fChangeTargetMaterial = new G4UIdirectory("/changeTarget/designedMaterial/");
0067 fChangeTargetMaterial -> SetGuidance("Change the Target material choosing isotopes and elements, and their abundance in the target");
0068
0069
0070 fTargetIsotopeName = new G4UIcmdWithAString("/changeTarget/designedMaterial/isotopeName",this);
0071 fTargetIsotopeName->SetGuidance("name of the isotope - ex : Ni64");
0072 fTargetIsotopeName->SetParameterName("IsotopeName",false);
0073 fTargetIsotopeName->AvailableForStates(G4State_Idle);
0074
0075 fTargetIsotopeZ = new G4UIcmdWithADouble("/changeTarget/designedMaterial/isotopeZ",this);
0076 fTargetIsotopeZ-> SetGuidance("Z of the isotope");
0077 fTargetIsotopeZ->SetParameterName("IsotopeZ",false);
0078 fTargetIsotopeZ->AvailableForStates(G4State_Idle);
0079
0080 fTargetIsotopeN = new G4UIcmdWithAnInteger("/changeTarget/designedMaterial/isotopeN",this);
0081 fTargetIsotopeN->SetGuidance("N (number of nucleons) of the isotope");
0082 fTargetIsotopeN->SetParameterName("IsotopeN",false);
0083 fTargetIsotopeN->AvailableForStates(G4State_Idle);
0084
0085 fTargetIsotopeA = new G4UIcmdWithADouble("/changeTarget/designedMaterial/isotopeA",this);
0086 fTargetIsotopeA->SetGuidance("A of the isotope, in g/cm3");
0087 fTargetIsotopeA->SetParameterName("IsotopeA",false);
0088 fTargetIsotopeA->AvailableForStates(G4State_Idle);
0089
0090
0091 fTargetElementName= new G4UIcmdWithAString("/changeTarget/designedMaterial/ElementName",this);
0092 fTargetElementName->SetGuidance("Name of the material - ex : PureNi64");
0093 fTargetElementName->SetParameterName("ElementName",false);
0094 fTargetElementName->AvailableForStates(G4State_Idle);
0095
0096 fTargetElementSymbole=new G4UIcmdWithAString("/changeTarget/designedMaterial/ElementSymbole",this);
0097 fTargetElementSymbole->SetGuidance("Symbole of the element : ex 64Ni");
0098 fTargetElementSymbole->SetParameterName("ElementSymbole", false);
0099 fTargetElementSymbole->AvailableForStates(G4State_Idle);
0100
0101 fTargetElementNComponents = new G4UIcmdWithAnInteger("/changeTarget/designedMaterial/ElementNComponents",this);
0102 fTargetElementNComponents->SetGuidance("Number of isotopes in the element");
0103 fTargetElementNComponents->SetParameterName("ElementNComponent", false);
0104 fTargetElementNComponents->AvailableForStates(G4State_Idle);
0105
0106 fTargetElementAbundance = new G4UIcmdWithADouble("/changeTarget/designedMaterial/IsotopeAbundanceInElement",this);
0107 fTargetElementAbundance->SetGuidance("Abundance of the isotope in the target");
0108 fTargetElementAbundance->SetParameterName("IsotopeAbundance",false);
0109 fTargetElementAbundance->AvailableForStates(G4State_Idle);
0110
0111
0112 fChangeTargetMaterialDensityCmd = new G4UIcmdWithADouble("/changeTarget/designedMaterial/materialDensity", this);
0113 fChangeTargetMaterialDensityCmd -> SetGuidance("Change the density value of the Target Material."
0114 "\nDefault value : 8.85 g/cm3.");
0115 fChangeTargetMaterialDensityCmd -> SetParameterName("TargetMaterialDensity", true);
0116 fChangeTargetMaterialDensityCmd -> SetDefaultValue(8.85);
0117 fChangeTargetMaterialDensityCmd -> AvailableForStates(G4State_Idle);
0118
0119 fTargetMaterialNComponents = new G4UIcmdWithAnInteger("/changeTarget/designedMaterial/MaterialNComponents",this);
0120 fTargetMaterialNComponents->SetGuidance("Number of elements in the target material");
0121 fTargetMaterialNComponents->SetParameterName("MaterialNComponents",false);
0122 fTargetMaterialNComponents->AvailableForStates(G4State_PreInit,G4State_Idle);
0123
0124 fTargetMaterialFractionMass= new G4UIcmdWithADouble("/changeTarget/designedMaterial/MaterialFractionMass",this);
0125 fTargetMaterialFractionMass->SetGuidance("Fraction mass of the element in the material");
0126 fTargetMaterialFractionMass->SetParameterName("MaterialFractionMass",false);
0127 fTargetMaterialFractionMass->AvailableForStates(G4State_Idle);
0128
0129 fTargetMaterialNaturalElement= new G4UIcmdWithAString("/changeTarget/designedMaterial/naturalElementName",this);
0130 fTargetMaterialNaturalElement->SetGuidance("Add an element using NIST database");
0131 fTargetMaterialNaturalElement->SetParameterName("NaturalElement",false);
0132 fTargetMaterialNaturalElement->AvailableForStates(G4State_Idle);
0133
0134 fTargetMaterialNaturalElementFractionMass= new G4UIcmdWithADouble("/changeTarget/designedMaterial/naturalElementFractionMass",this);
0135 fTargetMaterialNaturalElementFractionMass->SetGuidance("Add the fraction mass of the natural element");
0136 fTargetMaterialNaturalElementFractionMass->SetParameterName("NaturalElementFractionMass",false);
0137 fTargetMaterialNaturalElementFractionMass->AvailableForStates(G4State_Idle);
0138
0139
0140 fUpdateMaterial = new G4UIcmdWithoutParameter("/changeTarget/designedMaterial/update",this);
0141 fUpdateMaterial->SetGuidance("Update the material once its components are defined");
0142 fUpdateMaterial->AvailableForStates(G4State_Idle);
0143
0144
0145 fChangeTargetMaterialCmd = new G4UIcmdWithAString("/changeTarget/materialNist", this);
0146 fChangeTargetMaterialCmd -> SetGuidance("Change the material of your target using the NIST database."
0147 "\nTo get the list of the available NIST materials, please select 'TargetMaterial->NistMaterialList'."
0148 "\nExample of a NIST material : 'G4_Ni'.");
0149 fChangeTargetMaterialCmd -> SetParameterName("TargetMaterial",false);
0150
0151
0152
0153 fChangeTargetThicknessCmd = new G4UIcmdWithADoubleAndUnit("/changeTarget/thickness", this);
0154 fChangeTargetThicknessCmd -> SetGuidance("Change the thickness value of the Target."
0155 "\nDefault value : 0.6 mm.");
0156 fChangeTargetThicknessCmd -> SetParameterName("TargetThickness", true);
0157 fChangeTargetThicknessCmd -> SetDefaultValue(0.6*mm);
0158 fChangeTargetThicknessCmd -> AvailableForStates(G4State_Idle);
0159 fChangeTargetThicknessCmd -> SetDefaultUnit("mm");
0160 fChangeTargetThicknessCmd -> SetUnitCandidates("mm");
0161
0162
0163
0164
0165
0166
0167 fChangeFoil = new G4UIdirectory("/changeFoil/");
0168 fChangeFoil -> SetGuidance("Change the Foil thickness");
0169
0170
0171 fChangeFoilThicknessCmd = new G4UIcmdWithADoubleAndUnit("/changeFoil/thickness", this);
0172 fChangeFoilThicknessCmd -> SetGuidance("Change the thickness value of the foil "
0173 "\nThe default value is 0.32 mm.");
0174 fChangeFoilThicknessCmd -> SetParameterName("FoilThickness", true);
0175 fChangeFoilThicknessCmd -> SetDefaultValue(.32*mm);
0176 fChangeFoilThicknessCmd -> AvailableForStates(G4State_Idle);
0177 fChangeFoilThicknessCmd -> SetDefaultUnit("mm");
0178 fChangeFoilThicknessCmd -> SetUnitCandidates("mm");
0179
0180
0181 fChangeFoilMaterial = new G4UIdirectory("/changeFoil/designedMaterial/");
0182 fChangeFoilMaterial -> SetGuidance("Change the Foil material choosing isotopes and elements, and their abundance in the foil");
0183
0184
0185 fFoilIsotopeName = new G4UIcmdWithAString("/changeFoil/designedMaterial/isotopeName",this);
0186 fFoilIsotopeName->SetGuidance("name of the isotope - ex : Ni64");
0187 fFoilIsotopeName->SetParameterName("foilIsotopeName",false);
0188 fFoilIsotopeName->AvailableForStates(G4State_Idle);
0189
0190 fFoilIsotopeZ = new G4UIcmdWithADouble("/changeFoil/designedMaterial/isotopeZ",this);
0191 fFoilIsotopeZ-> SetGuidance("Z of the isotope");
0192 fFoilIsotopeZ->SetParameterName("foilIsotopeZ",false);
0193 fFoilIsotopeZ->AvailableForStates(G4State_Idle);
0194
0195 fFoilIsotopeN = new G4UIcmdWithAnInteger("/changeFoil/designedMaterial/isotopeN",this);
0196 fFoilIsotopeN->SetGuidance("N (number of nucleons) of the isotope");
0197 fFoilIsotopeN->SetParameterName("foilIsotopeN",false);
0198 fFoilIsotopeN->AvailableForStates(G4State_Idle);
0199
0200 fFoilIsotopeA = new G4UIcmdWithADouble("/changeFoil/designedMaterial/isotopeA",this);
0201 fFoilIsotopeA->SetGuidance("A of the isotope, in g/cm3");
0202 fFoilIsotopeA->SetParameterName("foilIsotopeA",false);
0203 fFoilIsotopeA->AvailableForStates(G4State_Idle);
0204
0205
0206
0207 fFoilElementName= new G4UIcmdWithAString("/changeFoil/designedMaterial/ElementName",this);
0208 fFoilElementName->SetGuidance("Name of the material - ex : PureNi64");
0209 fFoilElementName->SetParameterName("foilElementName",false);
0210 fFoilElementName->AvailableForStates(G4State_Idle);
0211
0212 fFoilElementSymbole=new G4UIcmdWithAString("/changeFoil/designedMaterial/ElementSymbole",this);
0213 fFoilElementSymbole->SetGuidance("Symbole of the element : ex 64Ni");
0214 fFoilElementSymbole->SetParameterName("foilElementSymbole", false);
0215 fFoilElementSymbole->AvailableForStates(G4State_Idle);
0216
0217 fFoilElementNComponents = new G4UIcmdWithAnInteger("/changeFoil/designedMaterial/ElementNComponents",this);
0218 fFoilElementNComponents->SetGuidance("Number of isotopes in the element");
0219 fFoilElementNComponents->SetParameterName("foilElementNComponent", false);
0220 fFoilElementNComponents->AvailableForStates(G4State_Idle);
0221
0222 fFoilElementAbundance = new G4UIcmdWithADouble("/changeFoil/designedMaterial/IsotopeAbundanceInElement",this);
0223 fFoilElementAbundance->SetGuidance("Abundance of the isotope in the foil");
0224 fFoilElementAbundance->SetParameterName("foilIsotopeAbundance",false);
0225 fFoilElementAbundance->AvailableForStates(G4State_Idle);
0226
0227
0228 fChangeFoilMaterialDensityCmd = new G4UIcmdWithADouble("/changeFoil/designedMaterial/materialDensity", this);
0229 fChangeFoilMaterialDensityCmd -> SetGuidance("Change the density value of the Target Material");
0230 fChangeFoilMaterialDensityCmd -> SetParameterName("FoilMaterialDensity", true);
0231 fChangeFoilMaterialDensityCmd -> AvailableForStates(G4State_Idle);
0232
0233 fFoilMaterialNComponents = new G4UIcmdWithAnInteger("/changeFoil/designedMaterial/MaterialNComponents",this);
0234 fFoilMaterialNComponents->SetGuidance("Number of elements in the target material");
0235 fFoilMaterialNComponents->SetParameterName("foilMaterialNComponents",false);
0236 fFoilMaterialNComponents->AvailableForStates(G4State_Idle);
0237
0238 fFoilMaterialFractionMass= new G4UIcmdWithADouble("/changeFoil/designedMaterial/MaterialFractionMass",this);
0239 fFoilMaterialFractionMass->SetGuidance("Fraction mass of the element in the material");
0240 fFoilMaterialFractionMass->SetParameterName("foilMaterialFractionMass",false);
0241 fFoilMaterialFractionMass->AvailableForStates(G4State_Idle);
0242
0243 fFoilMaterialNaturalElement= new G4UIcmdWithAString("/changeFoil/designedMaterial/naturalElementName",this);
0244 fFoilMaterialNaturalElement->SetGuidance("Add an element using NIST database");
0245 fFoilMaterialNaturalElement->SetParameterName("foilNaturalElement",false);
0246 fFoilMaterialNaturalElement->AvailableForStates(G4State_Idle);
0247
0248 fFoilMaterialNaturalElementFractionMass= new G4UIcmdWithADouble("/changeFoil/designedMaterial/naturalElementFractionMass",this);
0249 fFoilMaterialNaturalElementFractionMass->SetGuidance("Add the fraction mass of the natural element");
0250 fFoilMaterialNaturalElementFractionMass->SetParameterName("foilNaturalElementFractionMass",false);
0251 fFoilMaterialNaturalElementFractionMass->AvailableForStates(G4State_Idle);
0252
0253
0254 fUpdateFoilMaterial = new G4UIcmdWithoutParameter("/changeFoil/designedMaterial/update",this);
0255 fUpdateFoilMaterial->SetGuidance("Update the material once its components are defined");
0256 fUpdateFoilMaterial->AvailableForStates(G4State_Idle);
0257
0258
0259
0260 fChangeFoilMaterialCmd = new G4UIcmdWithAString("/changeFoil/materialNist", this);
0261 fChangeFoilMaterialCmd -> SetGuidance("Change the material of your foil using the NIST database."
0262 "\nTo get the list of the available NIST materials, please select 'TargetMaterial->NistMaterialList'."
0263 "\nExample of a NIST material : 'G4_Ni'.");
0264 fChangeFoilMaterialCmd -> SetParameterName("FoilMaterial",false);
0265
0266 }
0267
0268 STCyclotronDetectorMessenger::~STCyclotronDetectorMessenger()
0269 {
0270 delete fChangeTarget;
0271 delete fChangeTargetDiameterCmd;
0272 delete fChangeTargetMaterial;
0273 delete fTargetIsotopeName;
0274 delete fTargetIsotopeZ ;
0275 delete fTargetIsotopeN;
0276 delete fTargetIsotopeA;
0277 delete fTargetElementName;
0278 delete fTargetElementSymbole;
0279 delete fTargetElementNComponents;
0280 delete fTargetElementAbundance ;
0281 delete fChangeTargetMaterialDensityCmd ;
0282 delete fTargetMaterialNComponents;
0283 delete fTargetMaterialFractionMass;
0284 delete fTargetMaterialNaturalElement;
0285 delete fTargetMaterialNaturalElementFractionMass;
0286 delete fUpdateMaterial;
0287 delete fChangeTargetMaterialCmd;
0288 delete fChangeFoilMaterial;
0289 delete fFoilIsotopeName;
0290 delete fFoilIsotopeZ ;
0291 delete fFoilIsotopeN;
0292 delete fFoilIsotopeA;
0293 delete fFoilElementName;
0294 delete fFoilElementSymbole;
0295 delete fFoilElementNComponents;
0296 delete fFoilElementAbundance ;
0297 delete fChangeFoilMaterialDensityCmd ;
0298 delete fFoilMaterialNComponents;
0299 delete fFoilMaterialFractionMass;
0300 delete fFoilMaterialNaturalElement;
0301 delete fFoilMaterialNaturalElementFractionMass;
0302 delete fUpdateFoilMaterial;
0303 delete fChangeFoilMaterialCmd;
0304 delete fChangeTargetThicknessCmd;
0305 delete fChangeFoil;
0306 delete fChangeFoilThicknessCmd;
0307
0308 }
0309
0310 void STCyclotronDetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
0311 {
0312
0313
0314 if( command == fChangeTargetDiameterCmd)
0315 {
0316 G4double updatedValue = fChangeTargetDiameterCmd -> GetNewDoubleValue(newValue);
0317 fDet -> SetTargetDiameter(updatedValue);
0318 }
0319
0320
0321 else if(command == fTargetIsotopeName)
0322 {
0323 fDet -> SetTargetIsotopeName(newValue);
0324 }
0325
0326 else if(command == fTargetIsotopeZ)
0327 {
0328 fDet -> SetTargetIsotopeZ(fTargetIsotopeZ->GetNewDoubleValue(newValue));
0329 }
0330
0331 else if(command == fTargetIsotopeN)
0332 {
0333 fDet -> SetTargetIsotopeN(fTargetIsotopeN->GetNewIntValue(newValue));
0334 }
0335
0336 else if(command == fTargetIsotopeA)
0337 {
0338 fDet -> SetTargetIsotopeA(fTargetIsotopeA->GetNewDoubleValue(newValue));
0339 }
0340
0341 else if(command == fTargetElementName)
0342 {
0343 fDet -> SetTargetElementName(newValue);
0344 }
0345
0346 else if(command == fTargetElementSymbole)
0347 {
0348 fDet -> SetTargetElementSymbole(newValue);
0349 }
0350
0351 else if(command == fTargetElementNComponents)
0352 {
0353 fDet -> SetTargetElementNComponents(fTargetElementNComponents->GetNewIntValue(newValue));
0354 }
0355
0356 else if(command == fTargetElementAbundance)
0357 {
0358 fDet -> SetTargetElementAbundance(fTargetElementAbundance->GetNewDoubleValue(newValue));
0359 }
0360
0361
0362 else if (command == fChangeTargetMaterialDensityCmd )
0363 {
0364 G4double updatedValue = fChangeTargetMaterialDensityCmd -> GetNewDoubleValue(newValue);
0365 fDet -> SetTargetMaterialDensity(updatedValue);
0366 }
0367
0368 else if(command == fTargetMaterialNComponents)
0369 {
0370 fDet -> SetTargetMaterialNComponents(fTargetMaterialNComponents->GetNewIntValue(newValue));
0371 }
0372
0373 else if(command == fTargetMaterialFractionMass)
0374 {
0375 fDet -> SetTargetMaterialFractionMass(fTargetMaterialFractionMass->GetNewDoubleValue(newValue));
0376 }
0377
0378 else if(command == fUpdateMaterial)
0379 {
0380 fDet -> UpdateMaterial();
0381 }
0382
0383
0384 else if(command == fTargetMaterialNaturalElement)
0385 {
0386 fDet ->SetTargetNaturalElement(newValue);
0387 }
0388
0389 else if(command == fTargetMaterialNaturalElementFractionMass)
0390 {
0391 fDet ->SetTargetNaturalMaterialFractionMass(fTargetMaterialNaturalElementFractionMass->GetNewDoubleValue(newValue));
0392 }
0393
0394
0395
0396
0397 else if (command == fChangeTargetMaterialCmd )
0398 {
0399 fDet -> SetTargetMaterial(newValue);
0400 }
0401
0402
0403
0404 else if (command == fChangeTargetThicknessCmd )
0405 {
0406 G4double updatedValue = fChangeTargetThicknessCmd -> GetNewDoubleValue(newValue);
0407 fDet -> SetTargetThickness(updatedValue);
0408 }
0409
0410
0411
0412 else if (command == fChangeFoilThicknessCmd )
0413 {
0414 G4double updatedValue = fChangeFoilThicknessCmd -> GetNewDoubleValue(newValue);
0415 fDet -> SetFoilThickness(updatedValue);
0416 }
0417
0418
0419 else if(command == fFoilIsotopeName)
0420 {
0421 fDet -> SetFoilIsotopeName(newValue);
0422 }
0423
0424 else if(command == fFoilIsotopeZ)
0425 {
0426 fDet -> SetFoilIsotopeZ(fFoilIsotopeZ->GetNewDoubleValue(newValue));
0427 }
0428
0429 else if(command == fFoilIsotopeN)
0430 {
0431 fDet -> SetFoilIsotopeN(fFoilIsotopeN->GetNewIntValue(newValue));
0432 }
0433
0434 else if(command == fFoilIsotopeA)
0435 {
0436 fDet -> SetFoilIsotopeA(fFoilIsotopeA->GetNewDoubleValue(newValue));
0437 }
0438
0439 else if(command == fFoilElementName)
0440 {
0441 fDet -> SetFoilElementName(newValue);
0442 }
0443
0444 else if(command == fFoilElementSymbole)
0445 {
0446 fDet -> SetFoilElementSymbole(newValue);
0447 }
0448
0449 else if(command == fFoilElementNComponents)
0450 {
0451 fDet -> SetFoilElementNComponents(fFoilElementNComponents->GetNewIntValue(newValue));
0452 }
0453
0454 else if(command == fFoilElementAbundance)
0455 {
0456 fDet -> SetFoilElementAbundance(fFoilElementAbundance->GetNewDoubleValue(newValue));
0457 }
0458
0459
0460 else if (command == fChangeFoilMaterialDensityCmd )
0461 {
0462 G4double updatedValue = fChangeFoilMaterialDensityCmd -> GetNewDoubleValue(newValue);
0463 fDet -> SetFoilMaterialDensity(updatedValue);
0464 }
0465
0466 else if(command == fFoilMaterialNComponents)
0467 {
0468 fDet -> SetFoilMaterialNComponents(fFoilMaterialNComponents->GetNewIntValue(newValue));
0469 }
0470
0471 else if(command == fFoilMaterialFractionMass)
0472 {
0473 fDet -> SetFoilMaterialFractionMass(fFoilMaterialFractionMass->GetNewDoubleValue(newValue));
0474 }
0475
0476 else if(command == fUpdateFoilMaterial)
0477 {
0478 fDet -> UpdateFoilMaterial();
0479 }
0480
0481
0482 else if(command == fFoilMaterialNaturalElement)
0483 {
0484 fDet ->SetFoilNaturalElement(newValue);
0485 }
0486
0487 else if(command == fFoilMaterialNaturalElementFractionMass)
0488 {
0489 fDet ->SetFoilNaturalMaterialFractionMass(fFoilMaterialNaturalElementFractionMass->GetNewDoubleValue(newValue));
0490 }
0491
0492
0493 else if (command == fChangeFoilMaterialCmd )
0494 {
0495 fDet -> SetFoilMaterial(newValue);
0496 }
0497 }