Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // Hadrontherapy advanced example for Geant4 << 26 // This is the *BASIC* version of Hadrontherapy, a Geant4-based application 27 // See more at: https://twiki.cern.ch/twiki/bi << 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy >> 28 // >> 29 // Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request >> 30 // the *COMPLETE* version of this program, together with its documentation; >> 31 // Hadrontherapy (both basic and full version) are supported by the Italian INFN >> 32 // Institute in the framework of the MC-INFN Group >> 33 // 28 34 29 #include "PassiveProtonBeamLineMessenger.hh" 35 #include "PassiveProtonBeamLineMessenger.hh" 30 #include "PassiveProtonBeamLine.hh" 36 #include "PassiveProtonBeamLine.hh" 31 #include "G4UIdirectory.hh" 37 #include "G4UIdirectory.hh" 32 #include "G4UIcmdWithADoubleAndUnit.hh" 38 #include "G4UIcmdWithADoubleAndUnit.hh" 33 #include "G4UIcmdWithAString.hh" 39 #include "G4UIcmdWithAString.hh" 34 #include "G4SystemOfUnits.hh" 40 #include "G4SystemOfUnits.hh" 35 41 36 PassiveProtonBeamLineMessenger::PassivePro 42 PassiveProtonBeamLineMessenger::PassiveProtonBeamLineMessenger(PassiveProtonBeamLine* beamLine) 37 :passiveProton(beamLine) 43 :passiveProton(beamLine) 38 44 39 { 45 { 40 changeTheBeamLineDir = new G4UIdirectory(" 46 changeTheBeamLineDir = new G4UIdirectory("/ChangeBeamLine/"); 41 changeTheBeamLineDir -> SetGuidance("Comma 47 changeTheBeamLineDir -> SetGuidance("Command to change the transport beam line"); 42 48 43 changeTheBeamLineNameCmd = new G4UIcmdWith 49 changeTheBeamLineNameCmd = new G4UIcmdWithAString("/ChangeBeamLine/beamLineName",this); 44 changeTheBeamLineNameCmd -> SetGuidance("I 50 changeTheBeamLineNameCmd -> SetGuidance("Insert the name of the beam line you want simulate"); 45 changeTheBeamLineNameCmd -> SetParameterNa 51 changeTheBeamLineNameCmd -> SetParameterName("List",false); 46 changeTheBeamLineNameCmd -> AvailableForSt 52 changeTheBeamLineNameCmd -> AvailableForStates(G4State_PreInit); 47 53 48 modulatorDir = new G4UIdirectory("/modulat 54 modulatorDir = new G4UIdirectory("/modulator/"); 49 modulatorDir -> SetGuidance("Command to ro 55 modulatorDir -> SetGuidance("Command to rotate the modulator wheel"); 50 56 51 beamLineDir = new G4UIdirectory("/beamLine 57 beamLineDir = new G4UIdirectory("/beamLine/"); 52 beamLineDir -> SetGuidance("set specificat 58 beamLineDir -> SetGuidance("set specification of range shifter"); 53 59 54 rangeShifterDir = new G4UIdirectory("/beam 60 rangeShifterDir = new G4UIdirectory("/beamLine/RangeShifter/"); 55 rangeShifterDir -> SetGuidance("set specif 61 rangeShifterDir -> SetGuidance("set specification of range shifter"); 56 62 57 firstScatteringFoilDir = new G4UIdirectory 63 firstScatteringFoilDir = new G4UIdirectory("/beamLine/ScatteringFoil1/"); 58 firstScatteringFoilDir -> SetGuidance("set 64 firstScatteringFoilDir -> SetGuidance("set specification of first scattering foil"); 59 65 60 secondScatteringFoilDir = new G4UIdirector 66 secondScatteringFoilDir = new G4UIdirectory("/beamLine/ScatteringFoil2/"); 61 secondScatteringFoilDir -> SetGuidance("se 67 secondScatteringFoilDir -> SetGuidance("set specification of second scattering foil"); 62 68 63 rangeStopperDir = new G4UIdirectory("/beam 69 rangeStopperDir = new G4UIdirectory("/beamLine/Stopper/"); 64 rangeStopperDir -> SetGuidance("set specif 70 rangeStopperDir -> SetGuidance("set specification of stopper"); 65 71 66 finalCollimatorDir = new G4UIdirectory("/b 72 finalCollimatorDir = new G4UIdirectory("/beamLine/FinalCollimator/"); 67 finalCollimatorDir -> SetGuidance("set spe 73 finalCollimatorDir -> SetGuidance("set specification of final collimator"); 68 74 69 modulatorAngleCmd = new G4UIcmdWithADouble 75 modulatorAngleCmd = new G4UIcmdWithADoubleAndUnit("/modulator/angle",this); 70 modulatorAngleCmd -> SetGuidance("Set Modu 76 modulatorAngleCmd -> SetGuidance("Set Modulator Angle"); 71 modulatorAngleCmd -> SetParameterName("Siz 77 modulatorAngleCmd -> SetParameterName("Size",false); 72 modulatorAngleCmd -> SetRange("Size>=0."); 78 modulatorAngleCmd -> SetRange("Size>=0."); 73 modulatorAngleCmd -> SetUnitCategory("Angl 79 modulatorAngleCmd -> SetUnitCategory("Angle"); 74 modulatorAngleCmd -> AvailableForStates(G4 80 modulatorAngleCmd -> AvailableForStates(G4State_Idle); 75 81 76 rangeShifterMatCmd = new G4UIcmdWithAStrin 82 rangeShifterMatCmd = new G4UIcmdWithAString("/beamLine/RangeShifter/RSMat",this); 77 rangeShifterMatCmd -> SetGuidance("Set mat 83 rangeShifterMatCmd -> SetGuidance("Set material of range shifter"); 78 rangeShifterMatCmd -> SetParameterName("ch 84 rangeShifterMatCmd -> SetParameterName("choice",false); 79 rangeShifterMatCmd -> AvailableForStates(G 85 rangeShifterMatCmd -> AvailableForStates(G4State_Idle); 80 86 81 rangeShifterXSizeCmd = new G4UIcmdWithADou 87 rangeShifterXSizeCmd = new G4UIcmdWithADoubleAndUnit("/beamLine/RangeShifter/thickness",this); 82 rangeShifterXSizeCmd -> SetGuidance("Set h 88 rangeShifterXSizeCmd -> SetGuidance("Set half of the thickness of range shifter along X axis"); 83 rangeShifterXSizeCmd -> SetParameterName(" 89 rangeShifterXSizeCmd -> SetParameterName("Size",false); 84 rangeShifterXSizeCmd -> SetDefaultUnit("mm 90 rangeShifterXSizeCmd -> SetDefaultUnit("mm"); 85 rangeShifterXSizeCmd -> SetUnitCandidates( 91 rangeShifterXSizeCmd -> SetUnitCandidates("mm cm m"); 86 rangeShifterXSizeCmd -> AvailableForStates 92 rangeShifterXSizeCmd -> AvailableForStates(G4State_Idle); 87 93 88 rangeShifterXPositionCmd = new G4UIcmdWith 94 rangeShifterXPositionCmd = new G4UIcmdWithADoubleAndUnit("/beamLine/RangeShifter/position",this); 89 rangeShifterXPositionCmd -> SetGuidance("S 95 rangeShifterXPositionCmd -> SetGuidance("Set position of range shifter"); 90 rangeShifterXPositionCmd -> SetParameterNa 96 rangeShifterXPositionCmd -> SetParameterName("Size",false); 91 rangeShifterXPositionCmd -> SetDefaultUnit 97 rangeShifterXPositionCmd -> SetDefaultUnit("mm"); 92 rangeShifterXPositionCmd -> SetUnitCandida 98 rangeShifterXPositionCmd -> SetUnitCandidates("mm cm m"); 93 rangeShifterXPositionCmd -> AvailableForSt 99 rangeShifterXPositionCmd -> AvailableForStates(G4State_Idle); 94 100 95 firstScatteringFoilXSizeCmd = new G4UIcmdW 101 firstScatteringFoilXSizeCmd = new G4UIcmdWithADoubleAndUnit("/beamLine/ScatteringFoil1/thickness",this); 96 firstScatteringFoilXSizeCmd -> SetGuidance 102 firstScatteringFoilXSizeCmd -> SetGuidance("Set half thickness of first scattering foil"); 97 firstScatteringFoilXSizeCmd -> SetParamete 103 firstScatteringFoilXSizeCmd -> SetParameterName("Size",false); 98 firstScatteringFoilXSizeCmd -> SetDefaultU 104 firstScatteringFoilXSizeCmd -> SetDefaultUnit("mm"); 99 firstScatteringFoilXSizeCmd -> SetUnitCand 105 firstScatteringFoilXSizeCmd -> SetUnitCandidates("mm cm m"); 100 firstScatteringFoilXSizeCmd -> AvailableFo 106 firstScatteringFoilXSizeCmd -> AvailableForStates(G4State_Idle); 101 107 102 secondScatteringFoilXSizeCmd = new G4UIcmd 108 secondScatteringFoilXSizeCmd = new G4UIcmdWithADoubleAndUnit("/beamLine/ScatteringFoil2/thickness",this); 103 secondScatteringFoilXSizeCmd -> SetGuidanc 109 secondScatteringFoilXSizeCmd -> SetGuidance("Set half thickness of second scattering foil"); 104 secondScatteringFoilXSizeCmd -> SetParamet 110 secondScatteringFoilXSizeCmd -> SetParameterName("Size",false); 105 secondScatteringFoilXSizeCmd -> SetDefault 111 secondScatteringFoilXSizeCmd -> SetDefaultUnit("mm"); 106 secondScatteringFoilXSizeCmd -> SetUnitCan 112 secondScatteringFoilXSizeCmd -> SetUnitCandidates("mm cm m"); 107 secondScatteringFoilXSizeCmd -> AvailableF 113 secondScatteringFoilXSizeCmd -> AvailableForStates(G4State_Idle); 108 114 109 outerRadiusStopperCmd = new G4UIcmdWithADo 115 outerRadiusStopperCmd = new G4UIcmdWithADoubleAndUnit("/beamLine/Stopper/outRadius",this); 110 outerRadiusStopperCmd -> SetGuidance("Set 116 outerRadiusStopperCmd -> SetGuidance("Set size of outer radius"); 111 outerRadiusStopperCmd -> SetParameterName( 117 outerRadiusStopperCmd -> SetParameterName("Size",false); 112 outerRadiusStopperCmd -> SetDefaultUnit("m 118 outerRadiusStopperCmd -> SetDefaultUnit("mm"); 113 outerRadiusStopperCmd -> SetUnitCandidates 119 outerRadiusStopperCmd -> SetUnitCandidates("mm cm m"); 114 outerRadiusStopperCmd -> AvailableForState 120 outerRadiusStopperCmd -> AvailableForStates(G4State_Idle); 115 121 116 innerRadiusFinalCollimatorCmd = new G4UIcm 122 innerRadiusFinalCollimatorCmd = new G4UIcmdWithADoubleAndUnit("/beamLine/FinalCollimator/halfInnerRad",this); 117 innerRadiusFinalCollimatorCmd -> SetGuidan 123 innerRadiusFinalCollimatorCmd -> SetGuidance("Set size of inner radius ( max 21.5 mm)"); 118 innerRadiusFinalCollimatorCmd -> SetParame 124 innerRadiusFinalCollimatorCmd -> SetParameterName("Size",false); 119 innerRadiusFinalCollimatorCmd -> SetDefaul 125 innerRadiusFinalCollimatorCmd -> SetDefaultUnit("mm"); 120 innerRadiusFinalCollimatorCmd -> SetUnitCa 126 innerRadiusFinalCollimatorCmd -> SetUnitCandidates("mm cm m"); 121 innerRadiusFinalCollimatorCmd -> Available 127 innerRadiusFinalCollimatorCmd -> AvailableForStates(G4State_Idle); 122 } 128 } 123 129 124 PassiveProtonBeamLineMessenger::~PassiveProton 130 PassiveProtonBeamLineMessenger::~PassiveProtonBeamLineMessenger() 125 { 131 { 126 delete innerRadiusFinalCollimatorCmd; 132 delete innerRadiusFinalCollimatorCmd; 127 delete outerRadiusStopperCmd; 133 delete outerRadiusStopperCmd; 128 delete secondScatteringFoilXSizeCmd; 134 delete secondScatteringFoilXSizeCmd; 129 delete firstScatteringFoilXSizeCmd; 135 delete firstScatteringFoilXSizeCmd; 130 delete rangeShifterXPositionCmd; 136 delete rangeShifterXPositionCmd; 131 delete rangeShifterXSizeCmd; 137 delete rangeShifterXSizeCmd; 132 delete rangeShifterMatCmd; 138 delete rangeShifterMatCmd; 133 delete modulatorAngleCmd; 139 delete modulatorAngleCmd; 134 delete finalCollimatorDir; 140 delete finalCollimatorDir; 135 delete rangeStopperDir; 141 delete rangeStopperDir; 136 delete secondScatteringFoilDir; 142 delete secondScatteringFoilDir; 137 delete firstScatteringFoilDir; 143 delete firstScatteringFoilDir; 138 delete rangeShifterDir; 144 delete rangeShifterDir; 139 delete beamLineDir; 145 delete beamLineDir; 140 delete modulatorDir; 146 delete modulatorDir; 141 } 147 } 142 148 143 149 144 150 145 151 146 void PassiveProtonBeamLineMessenger::SetNewVal 152 void PassiveProtonBeamLineMessenger::SetNewValue(G4UIcommand* command,G4String newValue) 147 { 153 { 148 if( command == modulatorAngleCmd ) 154 if( command == modulatorAngleCmd ) 149 { passiveProton -> SetModulatorAngle 155 { passiveProton -> SetModulatorAngle 150 (modulatorAngleCmd -> GetNewDoubleValue(newV 156 (modulatorAngleCmd -> GetNewDoubleValue(newValue));} 151 157 152 else if( command == rangeShifterMatCmd ) 158 else if( command == rangeShifterMatCmd ) 153 { passiveProton -> SetRSMaterial(newValue) 159 { passiveProton -> SetRSMaterial(newValue);} 154 160 155 else if( command == rangeShifterXSizeCmd ) 161 else if( command == rangeShifterXSizeCmd ) 156 { passiveProton -> SetRangeShifterXSize 162 { passiveProton -> SetRangeShifterXSize 157 (rangeShifterXSizeCmd -> GetNewDoubleValue(n 163 (rangeShifterXSizeCmd -> GetNewDoubleValue(newValue));} 158 164 159 else if( command == rangeShifterXPositionC 165 else if( command == rangeShifterXPositionCmd ) 160 { passiveProton -> SetRangeShifterXPositio 166 { passiveProton -> SetRangeShifterXPosition 161 (rangeShifterXPositionCmd -> GetNewDoubleVal 167 (rangeShifterXPositionCmd -> GetNewDoubleValue(newValue));} 162 168 163 else if( command == firstScatteringFoilXSi 169 else if( command == firstScatteringFoilXSizeCmd ) 164 { passiveProton -> SetFirstScatteringFoilX 170 { passiveProton -> SetFirstScatteringFoilXSize 165 (firstScatteringFoilXSizeCmd -> GetNewDouble 171 (firstScatteringFoilXSizeCmd -> GetNewDoubleValue(newValue));} 166 172 167 else if( command == secondScatteringFoilXS 173 else if( command == secondScatteringFoilXSizeCmd ) 168 { passiveProton -> SetSecondScatteringFoil 174 { passiveProton -> SetSecondScatteringFoilXSize 169 (secondScatteringFoilXSizeCmd -> GetNewDoubl 175 (secondScatteringFoilXSizeCmd -> GetNewDoubleValue(newValue));} 170 176 171 else if( command == outerRadiusStopperCmd 177 else if( command == outerRadiusStopperCmd ) 172 { passiveProton -> SetOuterRadiusStopper( 178 { passiveProton -> SetOuterRadiusStopper( 173 outerRadiusStopperCmd -> GetNewDoubleVal 179 outerRadiusStopperCmd -> GetNewDoubleValue(newValue));} 174 180 175 else if( command == innerRadiusFinalCollim 181 else if( command == innerRadiusFinalCollimatorCmd ) 176 { passiveProton -> SetInnerRadiusFinalColl 182 { passiveProton -> SetInnerRadiusFinalCollimator 177 (innerRadiusFinalCollimatorCmd -> GetNewDoub 183 (innerRadiusFinalCollimatorCmd -> GetNewDoubleValue(newValue));} 178 } 184 } 179 185 180 186