File indexing completed on 2025-01-31 09:22:30
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
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041 #include "IORTDetectorMessenger.hh"
0042 #include "IORTDetectorConstruction.hh"
0043 #include "G4UIdirectory.hh"
0044 #include "G4UIcmdWith3VectorAndUnit.hh"
0045 #include "G4UIcmdWithoutParameter.hh"
0046 #include "G4UIcmdWithAString.hh"
0047 #include "G4UIcmdWithADoubleAndUnit.hh" // aggiunto
0048
0049
0050 IORTDetectorMessenger::IORTDetectorMessenger(IORTDetectorConstruction* detector)
0051 :iortDetector(detector)
0052 {
0053
0054 changeThePhantomDir = new G4UIdirectory("/changePhantom/");
0055 changeThePhantomDir -> SetGuidance("Command to change the Phantom Size/position");
0056 changeThePhantomSizeCmd = new G4UIcmdWith3VectorAndUnit("/changePhantom/size", this);
0057 changeThePhantomSizeCmd -> SetGuidance("Insert sizes X Y and Z"
0058 "\n 0 or negative values mean <<Don't change it!>>");
0059 changeThePhantomSizeCmd -> SetParameterName("PhantomSizeAlongX",
0060 "PhantomSizeAlongY",
0061 "PhantomSizeAlongZ", false);
0062 changeThePhantomSizeCmd -> SetDefaultUnit("mm");
0063 changeThePhantomSizeCmd -> SetUnitCandidates("nm um mm cm");
0064 changeThePhantomSizeCmd -> AvailableForStates(G4State_Idle);
0065
0066
0067
0068 changeThePhantomMaterialCmd = new G4UIcmdWithAString("/changePhantom/material", this);
0069 changeThePhantomMaterialCmd -> SetGuidance("Change the Phantom and the detector material");
0070 changeThePhantomMaterialCmd -> SetParameterName("PhantomMaterial", false);
0071 changeThePhantomMaterialCmd -> SetDefaultValue("G4_WATER");
0072 changeThePhantomMaterialCmd -> AvailableForStates(G4State_Idle);
0073
0074
0075 changeThePhantomPositionCmd = new G4UIcmdWith3VectorAndUnit("/changePhantom/position", this);
0076 changeThePhantomPositionCmd -> SetGuidance("Insert X Y and Z dimensions for the position of the center of the Phantom"
0077 " respect to that of the \"World\"");
0078 changeThePhantomPositionCmd -> SetParameterName("PositionAlongX",
0079 "PositionAlongY",
0080 "PositionAlongZ", false);
0081 changeThePhantomPositionCmd -> SetDefaultUnit("mm");
0082 changeThePhantomPositionCmd -> SetUnitCandidates("um mm cm m");
0083 changeThePhantomPositionCmd -> AvailableForStates(G4State_Idle);
0084
0085
0086 updateCmd = new G4UIcmdWithoutParameter("/changePhantom/update",this);
0087 updateCmd->SetGuidance("Update Phantom/Detector geometry.");
0088 updateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
0089 updateCmd->SetGuidance("if you changed geometrical value(s).");
0090 updateCmd->AvailableForStates(G4State_Idle);
0091
0092
0093 changeTheDetectorDir = new G4UIdirectory("/changeDetector/");
0094 changeTheDetectorDir -> SetGuidance("Command to change the Detector's Size/position/Voxels");
0095
0096 changeTheDetectorSizeCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/size",this);
0097 changeTheDetectorSizeCmd -> SetGuidance("Insert sizes for X Y and Z dimensions of the Detector"
0098 "\n 0 or negative values mean <<Don't change it>>");
0099 changeTheDetectorSizeCmd -> SetParameterName("DetectorSizeAlongX", "DetectorSizeAlongY", "DetectorSizeAlongZ", false);
0100 changeTheDetectorSizeCmd -> SetDefaultUnit("mm");
0101 changeTheDetectorSizeCmd -> SetUnitCandidates("nm um mm cm");
0102 changeTheDetectorSizeCmd -> AvailableForStates(G4State_Idle);
0103
0104
0105 changeTheDetectorToPhantomPositionCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/displacement",this);
0106 changeTheDetectorToPhantomPositionCmd -> SetGuidance("Insert X Y and Z displacements between Detector and Phantom"
0107 "\nNegative values mean <<Don't change it!>>");
0108 changeTheDetectorToPhantomPositionCmd -> SetParameterName("DisplacementAlongX",
0109 "DisplacementAlongY",
0110 "DisplacementAlongZ", false);
0111 changeTheDetectorToPhantomPositionCmd -> SetDefaultUnit("mm");
0112 changeTheDetectorToPhantomPositionCmd -> SetUnitCandidates("nm um mm cm");
0113 changeTheDetectorToPhantomPositionCmd -> AvailableForStates(G4State_Idle);
0114
0115
0116 changeTheDetectorVoxelCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/voxelSize",this);
0117 changeTheDetectorVoxelCmd -> SetGuidance("Insert Voxel sizes for X Y and Z dimensions"
0118 "\n 0 or negative values mean <<Don't change it!>>");
0119 changeTheDetectorVoxelCmd -> SetParameterName("VoxelSizeAlongX", "VoxelSizeAlongY", "VoxelSizeAlongZ", false);
0120 changeTheDetectorVoxelCmd -> SetDefaultUnit("mm");
0121 changeTheDetectorVoxelCmd -> SetUnitCandidates("nm um mm cm");
0122 changeTheDetectorVoxelCmd -> AvailableForStates(G4State_Idle);
0123
0124
0125
0126 changeTheDisc1Dir = new G4UIdirectory("/ProtectionDisc1/");
0127 changeTheDisc1Dir -> SetGuidance("Command to change the Disc1");
0128
0129 changeOuterRadiusDiscoIORTCmd = new G4UIcmdWithADoubleAndUnit("/ProtectionDisc1/OuterRadiusDisc1",this);
0130 changeOuterRadiusDiscoIORTCmd -> SetGuidance("Set size of outer radius");
0131 changeOuterRadiusDiscoIORTCmd -> SetParameterName("Size",false);
0132 changeOuterRadiusDiscoIORTCmd -> SetDefaultUnit("mm");
0133 changeOuterRadiusDiscoIORTCmd -> SetUnitCandidates("mm cm m");
0134 changeOuterRadiusDiscoIORTCmd -> AvailableForStates(G4State_Idle);
0135
0136 changeinnerRadiusDiscoIORTCmd = new G4UIcmdWithADoubleAndUnit("/ProtectionDisc1/InnerRadiusDisc1",this);
0137 changeinnerRadiusDiscoIORTCmd -> SetGuidance("Set size of inner radius");
0138 changeinnerRadiusDiscoIORTCmd -> SetParameterName("Size",false);
0139 changeinnerRadiusDiscoIORTCmd -> SetDefaultUnit("mm");
0140 changeinnerRadiusDiscoIORTCmd -> SetUnitCandidates("mm cm m");
0141 changeinnerRadiusDiscoIORTCmd -> AvailableForStates(G4State_Idle);
0142
0143
0144 changeheightDiscoIORTCmd = new G4UIcmdWithADoubleAndUnit("/ProtectionDisc1/HeightDisc1",this);
0145 changeheightDiscoIORTCmd -> SetGuidance("Set size of higth");
0146 changeheightDiscoIORTCmd -> SetParameterName("Size",false);
0147 changeheightDiscoIORTCmd -> SetDefaultUnit("mm");
0148 changeheightDiscoIORTCmd -> SetUnitCandidates("mm cm m");
0149 changeheightDiscoIORTCmd -> AvailableForStates(G4State_Idle);
0150
0151 changeDiscoXPositionIORTCmd = new G4UIcmdWithADoubleAndUnit("/ProtectionDisc1/XPositionDisc1",this);
0152 changeDiscoXPositionIORTCmd -> SetGuidance("Set the X position");
0153 changeDiscoXPositionIORTCmd -> SetParameterName("Size",false);
0154 changeDiscoXPositionIORTCmd -> SetDefaultUnit("mm");
0155 changeDiscoXPositionIORTCmd -> SetUnitCandidates("mm cm m");
0156 changeDiscoXPositionIORTCmd -> AvailableForStates(G4State_Idle);
0157
0158 changeDiscoYPositionIORTCmd = new G4UIcmdWithADoubleAndUnit("/ProtectionDisc1/YPositionDisc1",this);
0159 changeDiscoYPositionIORTCmd -> SetGuidance("Set the Y position");
0160 changeDiscoYPositionIORTCmd -> SetParameterName("Size",false);
0161 changeDiscoYPositionIORTCmd -> SetDefaultUnit("mm");
0162 changeDiscoYPositionIORTCmd -> SetUnitCandidates("mm cm m");
0163 changeDiscoYPositionIORTCmd -> AvailableForStates(G4State_Idle);
0164
0165 changeDiscoZPositionIORTCmd = new G4UIcmdWithADoubleAndUnit("/ProtectionDisc1/ZPositionDisc1",this);
0166 changeDiscoZPositionIORTCmd -> SetGuidance("Set the Z position");
0167 changeDiscoZPositionIORTCmd -> SetParameterName("Size",false);
0168 changeDiscoZPositionIORTCmd -> SetDefaultUnit("mm");
0169 changeDiscoZPositionIORTCmd -> SetUnitCandidates("mm cm m");
0170 changeDiscoZPositionIORTCmd -> AvailableForStates(G4State_Idle);
0171
0172 changeTheDisc1MaterialCmd = new G4UIcmdWithAString("/ProtectionDisc1/material", this);
0173 changeTheDisc1MaterialCmd -> SetGuidance("Change the Disc1 material");
0174 changeTheDisc1MaterialCmd -> SetParameterName("Disc1Material", false);
0175 changeTheDisc1MaterialCmd -> SetDefaultValue("G4_WATER");
0176 changeTheDisc1MaterialCmd -> AvailableForStates(G4State_Idle);
0177
0178
0179
0180
0181 changeTheDisc2Dir = new G4UIdirectory("/ProtectionDisc2/");
0182 changeTheDisc2Dir -> SetGuidance("Command to change the Disc2");
0183
0184 changeOuterRadiusDisco1IORTCmd = new G4UIcmdWithADoubleAndUnit("/ProtectionDisc2/OuterRadiusDisc2",this);
0185 changeOuterRadiusDisco1IORTCmd -> SetGuidance("Set size of outer radius");
0186 changeOuterRadiusDisco1IORTCmd -> SetParameterName("Size",false);
0187 changeOuterRadiusDisco1IORTCmd -> SetDefaultUnit("mm");
0188 changeOuterRadiusDisco1IORTCmd -> SetUnitCandidates("mm cm m");
0189 changeOuterRadiusDisco1IORTCmd -> AvailableForStates(G4State_Idle);
0190
0191 changeinnerRadiusDisco1IORTCmd = new G4UIcmdWithADoubleAndUnit("/ProtectionDisc2/InnerRadiusDisc2",this);
0192 changeinnerRadiusDisco1IORTCmd -> SetGuidance("Set size of inner radius");
0193 changeinnerRadiusDisco1IORTCmd -> SetParameterName("Size",false);
0194 changeinnerRadiusDisco1IORTCmd -> SetDefaultUnit("mm");
0195 changeinnerRadiusDisco1IORTCmd -> SetUnitCandidates("mm cm m");
0196 changeinnerRadiusDisco1IORTCmd -> AvailableForStates(G4State_Idle);
0197
0198
0199 changeheightDisco1IORTCmd = new G4UIcmdWithADoubleAndUnit("/ProtectionDisc2/HeightDisc2",this);
0200 changeheightDisco1IORTCmd -> SetGuidance("Set size of higth");
0201 changeheightDisco1IORTCmd -> SetParameterName("Size",false);
0202 changeheightDisco1IORTCmd -> SetDefaultUnit("mm");
0203 changeheightDisco1IORTCmd -> SetUnitCandidates("mm cm m");
0204 changeheightDisco1IORTCmd -> AvailableForStates(G4State_Idle);
0205
0206 changeDisco1XPositionIORTCmd = new G4UIcmdWithADoubleAndUnit("/ProtectionDisc2/XPositionDisc2",this);
0207 changeDisco1XPositionIORTCmd -> SetGuidance("Set the X position");
0208 changeDisco1XPositionIORTCmd -> SetParameterName("Size",false);
0209 changeDisco1XPositionIORTCmd -> SetDefaultUnit("mm");
0210 changeDisco1XPositionIORTCmd -> SetUnitCandidates("mm cm m");
0211 changeDisco1XPositionIORTCmd -> AvailableForStates(G4State_Idle);
0212
0213 changeTheDisc2MaterialCmd = new G4UIcmdWithAString("/ProtectionDisc2/material", this);
0214 changeTheDisc2MaterialCmd -> SetGuidance("Change the Disc2 material");
0215 changeTheDisc2MaterialCmd -> SetParameterName("Disc1Material", false);
0216 changeTheDisc2MaterialCmd -> SetDefaultValue("G4_WATER");
0217 changeTheDisc2MaterialCmd -> AvailableForStates(G4State_Idle);
0218
0219
0220 deleteTheDiscDir = new G4UIdirectory("/DeleteProtectionDisc/");
0221 deleteTheDiscDir -> SetGuidance("Command to delete the 1-2 Discs ");
0222
0223 deletediscCmd = new G4UIcmdWithoutParameter("/DeleteProtectionDisc/delete",this);
0224 deletediscCmd->SetGuidance("Delete the 1-2 Discs geometry.");
0225 deletediscCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
0226 deletediscCmd->AvailableForStates(G4State_Idle);
0227
0228
0229 insertTheDiscDir = new G4UIdirectory("/InsertProtectionDisc/");
0230 insertTheDiscDir -> SetGuidance("Command to insert the 1-2 Discs ");
0231
0232 insertdiscCmd = new G4UIcmdWithoutParameter("/InsertProtectionDisc/insert",this);
0233 insertdiscCmd->SetGuidance("Insert the 1-2 Discs geometry.");
0234 insertdiscCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
0235 insertdiscCmd->SetGuidance("After this command MUST be applied update command \"beamOn\" ");
0236 insertdiscCmd->AvailableForStates(G4State_Idle);
0237
0238
0239 changeTheAnglediscDir = new G4UIdirectory("/ChangeTiltAngleDisc1-2/");
0240 changeTheAnglediscDir -> SetGuidance("Set tilt angle of the 1-2 Discs");
0241
0242 changeTheAnglediscCmd = new G4UIcmdWithADoubleAndUnit("/ChangeTiltAngleDisc1-2/TiltAngleDisc1-2",this);
0243 changeTheAnglediscCmd -> SetParameterName("Angle",false);
0244 changeTheAnglediscCmd -> SetDefaultUnit("deg");
0245 changeTheAnglediscCmd -> SetUnitCandidates("deg rad");
0246 changeTheAnglediscCmd -> AvailableForStates(G4State_Idle);
0247 }
0248
0249
0250 IORTDetectorMessenger::~IORTDetectorMessenger()
0251 {
0252 delete changeThePhantomDir;
0253 delete changeThePhantomSizeCmd;
0254 delete changeThePhantomPositionCmd;
0255 delete changeThePhantomMaterialCmd;
0256 delete updateCmd;
0257 delete changeTheDetectorDir;
0258 delete changeTheDetectorSizeCmd;
0259 delete changeTheDetectorToPhantomPositionCmd;
0260 delete changeTheDetectorVoxelCmd;
0261
0262 delete changeTheDisc1Dir;
0263 delete changeOuterRadiusDiscoIORTCmd;
0264 delete changeinnerRadiusDiscoIORTCmd;
0265 delete changeheightDiscoIORTCmd;
0266 delete changeDiscoXPositionIORTCmd;
0267 delete changeDiscoYPositionIORTCmd;
0268 delete changeDiscoZPositionIORTCmd;
0269 delete changeTheDisc1MaterialCmd;
0270
0271 delete changeTheDisc2Dir;
0272 delete changeOuterRadiusDisco1IORTCmd;
0273 delete changeinnerRadiusDisco1IORTCmd;
0274 delete changeheightDisco1IORTCmd;
0275 delete changeDisco1XPositionIORTCmd;
0276 delete changeTheDisc2MaterialCmd;
0277
0278 delete deletediscCmd;
0279 delete insertdiscCmd;
0280
0281 delete changeTheAnglediscDir;
0282 delete changeTheAnglediscCmd;
0283 }
0284
0285
0286 void IORTDetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
0287 {
0288
0289 if( command == changeThePhantomSizeCmd)
0290 {
0291 G4ThreeVector size = changeThePhantomSizeCmd -> GetNew3VectorValue(newValue);
0292 iortDetector -> SetPhantomSize(size.getX(),size.getY(),size.getZ());
0293 }
0294 else if (command == changeThePhantomPositionCmd )
0295 {
0296 G4ThreeVector size = changeThePhantomPositionCmd -> GetNew3VectorValue(newValue);
0297 iortDetector -> SetPhantomPosition(size);
0298 }
0299 else if (command == changeThePhantomMaterialCmd)
0300 {
0301 iortDetector -> SetPhantomMaterial(newValue);
0302 }
0303 else if (command == changeTheDetectorSizeCmd)
0304 {
0305 G4ThreeVector size = changeTheDetectorSizeCmd -> GetNew3VectorValue(newValue);
0306 iortDetector -> SetDetectorSize(size.getX(),size.getY(),size.getZ());
0307 }
0308 else if (command == changeTheDetectorToPhantomPositionCmd)
0309 {
0310 G4ThreeVector size = changeTheDetectorToPhantomPositionCmd-> GetNew3VectorValue(newValue);
0311 iortDetector -> SetDetectorToPhantomPosition(size);
0312 }
0313 else if (command == changeTheDetectorVoxelCmd)
0314 {
0315 G4ThreeVector size = changeTheDetectorVoxelCmd -> GetNew3VectorValue(newValue);
0316 iortDetector -> SetVoxelSize(size.getX(),size.getY(),size.getZ());
0317 }
0318
0319
0320 else if( command == changeOuterRadiusDiscoIORTCmd )
0321 {
0322 iortDetector -> SetOuterRadiusDiscoIORT
0323 (changeOuterRadiusDiscoIORTCmd -> GetNewDoubleValue(newValue));
0324 }
0325 else if( command == changeinnerRadiusDiscoIORTCmd )
0326 { iortDetector -> SetinnerRadiusDiscoIORT
0327 (changeinnerRadiusDiscoIORTCmd -> GetNewDoubleValue(newValue));
0328 }
0329 else if( command == changeheightDiscoIORTCmd )
0330 { iortDetector -> SetheightDiscoIORT
0331 (changeheightDiscoIORTCmd -> GetNewDoubleValue(newValue));
0332 }
0333 else if( command == changeDiscoXPositionIORTCmd )
0334 { iortDetector -> SetDiscoXPositionIORT
0335 (changeDiscoXPositionIORTCmd -> GetNewDoubleValue(newValue));
0336 }
0337 else if( command == changeDiscoYPositionIORTCmd )
0338 { iortDetector -> SetDiscoYPositionIORT
0339 (changeDiscoYPositionIORTCmd -> GetNewDoubleValue(newValue));
0340 }
0341 else if( command == changeDiscoZPositionIORTCmd )
0342 { iortDetector -> SetDiscoZPositionIORT
0343 (changeDiscoZPositionIORTCmd -> GetNewDoubleValue(newValue));
0344 }
0345 else if (command == changeTheDisc1MaterialCmd)
0346 {
0347 iortDetector -> SetDiscoMaterialIORT(newValue);
0348 }
0349
0350 else if( command == changeOuterRadiusDisco1IORTCmd )
0351 { iortDetector -> SetOuterRadiusDiscoIORT1
0352 (changeOuterRadiusDisco1IORTCmd -> GetNewDoubleValue(newValue));
0353 }
0354 else if( command == changeinnerRadiusDisco1IORTCmd )
0355 { iortDetector -> SetinnerRadiusDiscoIORT1
0356 (changeinnerRadiusDisco1IORTCmd -> GetNewDoubleValue(newValue));
0357 }
0358 else if( command == changeheightDisco1IORTCmd )
0359 { iortDetector -> SetheightDiscoIORT1
0360 (changeheightDisco1IORTCmd -> GetNewDoubleValue(newValue));
0361 }
0362 else if( command == changeDisco1XPositionIORTCmd )
0363 { iortDetector -> SetDiscoXPositionIORT1
0364 (changeDisco1XPositionIORTCmd -> GetNewDoubleValue(newValue));
0365 }
0366 else if (command == changeTheDisc2MaterialCmd)
0367 {
0368 iortDetector -> SetDiscoMaterialIORT1(newValue);
0369 }
0370 else if (command == changeTheAnglediscCmd)
0371 {
0372 iortDetector -> SetAngleDiscoIORT0
0373 (changeTheAnglediscCmd -> GetNewDoubleValue(newValue));
0374 }
0375
0376
0377
0378 else if (command == updateCmd)
0379 {
0380 iortDetector -> UpdateGeometry();
0381 }
0382
0383 else if (command == deletediscCmd)
0384 {
0385 iortDetector -> DeleteDisc();
0386 }
0387
0388 else if (command == insertdiscCmd)
0389 {
0390 iortDetector -> ConstructDisc();
0391 }
0392 }