// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // // IThembaBeamlineMessenger.cc; // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy #include "IThembaBeamlineMessenger.hh" #include "IThembaBeamline.hh" #include "G4UIdirectory.hh" #include "G4UIcmdWithADoubleAndUnit.hh" #include "G4UIcmdWithAString.hh" #include "G4UIcmdWithoutParameter.hh" //******************************************************************************************* IThembaBeamlineMessenger::IThembaBeamlineMessenger(IThembaBeamline* beamLine) :passiveProton(beamLine) //------------------------------------------------------------------------------------------- { beamLineDir = new G4UIdirectory("/Beamline/"); beamLineDir -> SetGuidance("set specification of range shifter"); modulatorAngleCmd = new G4UIcmdWithADoubleAndUnit("/Beamline/iThemba/modulator/angle",this); modulatorAngleCmd -> SetGuidance("Set Modulator Angle"); modulatorAngleCmd -> SetParameterName("Size",false); modulatorAngleCmd -> SetRange("Size>=0."); modulatorAngleCmd -> SetUnitCategory("Angle"); modulatorAngleCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); rangeMonitorZPositionCmd = new G4UIcmdWithADoubleAndUnit("/Beamline/iThemba/RangeMonitor/move",this); rangeMonitorZPositionCmd -> SetGuidance("Set position of range Range Monitor"); rangeMonitorZPositionCmd -> SetParameterName("Size",false); rangeMonitorZPositionCmd -> SetDefaultUnit("mm"); rangeMonitorZPositionCmd -> SetUnitCandidates("mm cm m"); rangeMonitorZPositionCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); wedgeYPositionCmd = new G4UIcmdWithADoubleAndUnit("/Beamline/iThemba/SetRange",this); wedgeYPositionCmd -> SetGuidance("Set position of wedge"); wedgeYPositionCmd -> SetParameterName("Size",false); wedgeYPositionCmd -> SetDefaultUnit("cm"); wedgeYPositionCmd -> SetUnitCandidates("mm cm m"); wedgeYPositionCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); innerRadiusFinalCollimatorCmd = new G4UIcmdWithADoubleAndUnit("/Beamline/iThemba/TreatmentCollimator/Diameter",this); innerRadiusFinalCollimatorCmd -> SetGuidance("Set size of inner radius ( max 100 mm)"); innerRadiusFinalCollimatorCmd -> SetParameterName("Size",false); innerRadiusFinalCollimatorCmd -> SetDefaultUnit("mm"); innerRadiusFinalCollimatorCmd -> SetUnitCandidates("mm cm m"); innerRadiusFinalCollimatorCmd -> AvailableForStates(G4State_PreInit,G4State_Idle); //---------------- // Copied over from NozzleMessenger as they just affect the iThemba Beamline anyway! //---------------- XFieldCmd = new G4UIcmdWithADoubleAndUnit("/Beamline/iThemba/SetXField",this); XFieldCmd->SetGuidance("Define magnetic field."); XFieldCmd->SetGuidance("Magnetic field will be in X direction."); XFieldCmd->SetParameterName("Bx",false); XFieldCmd->SetUnitCategory("Magnetic flux density"); XFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle); YFieldCmd = new G4UIcmdWithADoubleAndUnit("/Beamline/iThemba/SetYField",this); YFieldCmd->SetGuidance("Define magnetic field."); YFieldCmd->SetGuidance("Magnetic field will be in Y direction."); YFieldCmd->SetParameterName("By",false); YFieldCmd->SetUnitCategory("Magnetic flux density"); YFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle); XSpotCmd = new G4UIcmdWithADoubleAndUnit("/Beamline/iThemba/SetXSpotPosition",this); XSpotCmd->SetGuidance("Define spot position in mm (x-direction)."); XSpotCmd->SetParameterName("xSpot",false); XSpotCmd->SetUnitCategory("Length"); XSpotCmd->SetDefaultUnit("mm"); XSpotCmd->AvailableForStates(G4State_PreInit,G4State_Idle); YSpotCmd = new G4UIcmdWithADoubleAndUnit("/Beamline/iThemba/SetYSpotPosition",this); YSpotCmd->SetGuidance("Define spot position in mm (y-direction)."); YSpotCmd->SetParameterName("ySpot",false); YSpotCmd->SetUnitCategory("Length"); YSpotCmd->SetDefaultUnit("mm"); YSpotCmd->AvailableForStates(G4State_PreInit,G4State_Idle); ZSpotCmd = new G4UIcmdWithADoubleAndUnit("/Beamline/iThemba/SetZSpotPosition",this); ZSpotCmd->SetGuidance("Define spot position in mm (z-direction)."); ZSpotCmd->SetParameterName("zSpot",false); ZSpotCmd->SetUnitCategory("Length"); ZSpotCmd->SetDefaultUnit("mm"); ZSpotCmd->AvailableForStates(G4State_PreInit,G4State_Idle); RemTubCmd = new G4UIcmdWithAString("/Beamline/iThemba/RemoveVacuumTube", this); RemTubCmd->SetGuidance("Choose whether to remove VacuumTube from simulation."); RemTubCmd->SetParameterName("RemoveVacuumTube", false); RemTubCmd->AvailableForStates(G4State_PreInit, G4State_Idle); RemRIonCmd = new G4UIcmdWithAString("/Beamline/iThemba/RemoveReferenceIonizationChamber", this); RemRIonCmd->SetGuidance("Choose whether to remove ReferenceIonizationChamber from simulation."); RemRIonCmd->SetGuidance("either 'Yes' or 'No'"); RemRIonCmd->SetParameterName("RemoveReferenceIonizationChamber", false); RemRIonCmd->AvailableForStates(G4State_PreInit, G4State_Idle); RemYStMagCmd = new G4UIcmdWithAString("/Beamline/iThemba/RemoveYSteeringMagnets", this); RemYStMagCmd->SetGuidance("Choose whether to remove YSteeringMagnets from simulation."); RemYStMagCmd->SetGuidance("either 'Yes' or 'No'"); RemYStMagCmd->SetParameterName("RemoveYSteeringMagnets", false); RemYStMagCmd->AvailableForStates(G4State_PreInit, G4State_Idle); RemMulWirCmd = new G4UIcmdWithAString("/Beamline/iThemba/RemoveMultiWireIonizationChamber", this); RemMulWirCmd->SetGuidance("Choose whether to remove MultiWireIonizationChamber from simulation."); RemMulWirCmd->SetGuidance("either 'Yes' or 'No'"); RemMulWirCmd->SetParameterName("RemoveMultiWireIonizationChamber", false); RemMulWirCmd->AvailableForStates(G4State_PreInit, G4State_Idle); RemXStMagCmd = new G4UIcmdWithAString("/Beamline/iThemba/RemoveXSteeringMagnets", this); RemXStMagCmd->SetGuidance("Choose whether to remove XSteeringMagnets from simulation."); RemXStMagCmd->SetGuidance("either 'Yes' or 'No'"); RemXStMagCmd->SetParameterName("RemoveXSteeringMagnets", false); RemXStMagCmd->AvailableForStates(G4State_PreInit, G4State_Idle); RemRanTriCmd = new G4UIcmdWithAString("/Beamline/iThemba/RemoveRangeTrimmerPlate", this); RemRanTriCmd->SetGuidance("Choose whether to remove RangeTrimmerPlate from simulation."); RemRanTriCmd->SetGuidance("either 'Yes' or 'No'"); RemRanTriCmd->SetParameterName("RemoveRangeTrimmerPlate", false); RemRanTriCmd->AvailableForStates(G4State_PreInit, G4State_Idle); RemLEPlaCmd = new G4UIcmdWithAString("/Beamline/iThemba/RemoveLeadPlate", this); RemLEPlaCmd->SetGuidance("Choose whether to remove LeadPlate from simulation."); RemLEPlaCmd->SetParameterName("RemoveLeadPlate", false); RemLEPlaCmd->AvailableForStates(G4State_PreInit, G4State_Idle); RemWedgeCmd = new G4UIcmdWithAString("/Beamline/iThemba/RemoveWedge", this); RemWedgeCmd->SetGuidance("Choose whether to remove Wedge from simulation."); RemWedgeCmd->SetGuidance("either 'Yes' or 'No'"); RemWedgeCmd->SetParameterName("RemoveWedge", false); RemWedgeCmd->AvailableForStates(G4State_PreInit, G4State_Idle); RemMutLaFraCmd = new G4UIcmdWithAString("/Beamline/iThemba/RemoveMultiLayerFaradayCup", this); RemMutLaFraCmd->SetGuidance("Choose whether to remove MultiLayerFaradayCup from simulation."); RemMutLaFraCmd->SetGuidance("either 'Yes' or 'No'"); RemMutLaFraCmd->SetParameterName("RemoveMultiLayerFaradayCup", false); RemMutLaFraCmd->AvailableForStates(G4State_PreInit, G4State_Idle); RemRanModCmd = new G4UIcmdWithAString("/Beamline/iThemba/RemoveRangeModulator", this); RemRanModCmd->SetGuidance("Choose whether to remove RangeModulator from simulation."); RemRanModCmd->SetGuidance("either 'Yes' or 'No'"); RemRanModCmd->SetParameterName("RemoveRangeModulator", false); RemRanModCmd->AvailableForStates(G4State_PreInit, G4State_Idle); RemRanModiThCmd = new G4UIcmdWithAString("/Beamline/iThemba/RemoveNewRangeMonitoriThemba", this); RemRanModiThCmd->SetGuidance("Choose whether to remove RangeModulator from simulation."); RemRanModiThCmd->SetGuidance("either 'Yes' or 'No'"); RemRanModiThCmd->SetParameterName("RemoveNewRangeMonitoriThemba", false); RemRanModiThCmd->AvailableForStates(G4State_PreInit, G4State_Idle); RemRanMonCmd = new G4UIcmdWithAString("/Beamline/iThemba/RemoveRangeMonitor", this); RemRanMonCmd->SetGuidance("Choose whether to remove RangeMonitor from simulation."); RemRanMonCmd->SetGuidance("either 'Yes' or 'No'"); RemRanMonCmd->SetParameterName("RemoveRangeMonitor", false); RemRanMonCmd->AvailableForStates(G4State_PreInit, G4State_Idle); RemOccRinCmd = new G4UIcmdWithAString("/Beamline/iThemba/RemoveOccludingRingAndCentralStopper", this); RemOccRinCmd->SetGuidance("Choose whether to remove OccludingRingAndCentralStopper from simulation."); RemOccRinCmd->SetGuidance("either 'Yes' or 'No'"); RemOccRinCmd->SetParameterName("RemoveOccludingRingAndCentralStopper", false); RemOccRinCmd->AvailableForStates(G4State_PreInit, G4State_Idle); RemShiColCmd = new G4UIcmdWithAString("/Beamline/iThemba/RemoveShieldingCollimators", this); RemShiColCmd->SetGuidance("Choose whether to remove ShieldingCollimators from simulation."); RemShiColCmd->SetGuidance("either 'Yes' or 'No'"); RemShiColCmd->SetParameterName("RemoveShieldingCollimators", false); RemShiColCmd->AvailableForStates(G4State_PreInit, G4State_Idle); RemQuMonIonCmd = new G4UIcmdWithAString("/Beamline/iThemba/RemoveQuadrantAndMonitorIonizationChamber", this); RemQuMonIonCmd->SetGuidance("Choose whether to remove QuadrantAndMonitorIonizationChamber from simulation."); RemQuMonIonCmd->SetGuidance("either 'Yes' or 'No'"); RemQuMonIonCmd->SetParameterName("RemoveQuadrantAndMonitorIonizationChamber", false); RemQuMonIonCmd->AvailableForStates(G4State_PreInit, G4State_Idle); RemFinColCmd = new G4UIcmdWithAString("/Beamline/iThemba/RemoveBeamFinalCollimator", this); RemFinColCmd->SetGuidance("Choose whether to remove BeamFinalCollimator from simulation."); RemFinColCmd->SetGuidance("either 'Yes' or 'No'"); RemFinColCmd->SetParameterName("RemoveBeamFinalCollimator", false); RemFinColCmd->AvailableForStates(G4State_PreInit, G4State_Idle); /* wedgeYPositionCmd = new G4UIcmdWithADoubleAndUnit("/Beamline/iThemba/Wedge/move",this); wedgeYPositionCmd -> SetGuidance("Set position of wedge"); wedgeYPositionCmd -> SetParameterName("Size",false); wedgeYPositionCmd -> SetDefaultUnit("mm"); wedgeYPositionCmd -> SetUnitCandidates("mm cm m"); wedgeYPositionCmd -> AvailableForStates(G4State_Idle); */ // constructCmd = new G4UIcmdWithoutParameter("/Beamline/iThemba/construct",this); //constructCmd->SetGuidance("This command constructs the iThemba Beamline Model"); //constructCmd->AvailableForStates(G4State_PreInit,G4State_Idle); } //******************************************************************************************* IThembaBeamlineMessenger::~IThembaBeamlineMessenger() //------------------------------------------------------------------------------------------- { delete beamLineDir; delete modulatorDir; delete modulatorAngleCmd; delete rangeMonitorZPositionCmd; delete wedgeYPositionCmd; delete innerRadiusFinalCollimatorCmd; // from NozzleMessenger delete XFieldCmd; delete YFieldCmd; delete XSpotCmd; delete YSpotCmd; delete ZSpotCmd; delete RemTubCmd; delete RemRIonCmd; delete RemYStMagCmd; delete RemMulWirCmd; delete RemXStMagCmd; delete RemRanTriCmd; delete RemLEPlaCmd; delete RemWedgeCmd; delete RemMutLaFraCmd; delete RemRanModCmd; delete RemRanMonCmd; delete RemOccRinCmd; delete RemShiColCmd; delete RemQuMonIonCmd; delete RemFinColCmd; // delete nozzleDir; delete RemRanModiThCmd; // delete wedgeYPositionCmd; } //******************************************************************************************* void IThembaBeamlineMessenger::SetNewValue(G4UIcommand* command,G4String newValue) //------------------------------------------------------------------------------------------- { if( command == modulatorAngleCmd ) { passiveProton -> SetModulatorAngle (modulatorAngleCmd -> GetNewDoubleValue(newValue));} else if( command == rangeMonitorZPositionCmd ) { passiveProton -> BeamRangeMonitor(rangeMonitorZPositionCmd -> GetNewDoubleValue(newValue));} else if( command == wedgeYPositionCmd ) { passiveProton -> SetRange (wedgeYPositionCmd -> GetNewDoubleValue(newValue));} else if( command == innerRadiusFinalCollimatorCmd ) { passiveProton -> SetFinalCollimatorDiameter(innerRadiusFinalCollimatorCmd -> GetNewDoubleValue(newValue));} // else if( command == constructCmd ) // { passiveProton -> ConstructIThembaBeamline(); } //--------------------- // from NozzleMessenger //--------------------- if( command == XFieldCmd ) { passiveProton->SetXMagField(XFieldCmd->GetNewDoubleValue(newValue));} if( command == YFieldCmd ) { passiveProton->SetYMagField(YFieldCmd->GetNewDoubleValue(newValue));} if( command == XSpotCmd ) { passiveProton->SetXSpotPosition(XSpotCmd->GetNewDoubleValue(newValue));} if( command == YSpotCmd ) { passiveProton->SetYSpotPosition(YSpotCmd->GetNewDoubleValue(newValue));} if( command == ZSpotCmd ) { passiveProton->SetZSpotPosition(ZSpotCmd->GetNewDoubleValue(newValue));} if( command == RemTubCmd ) { passiveProton->SetRemoveVacuumTube(newValue);} if( command == RemRIonCmd ) { passiveProton->SetRemoveReferenceIonizationChamber(newValue);} if( command == RemYStMagCmd ) { passiveProton->SetRemoveYSteeringMagnets(newValue);} if( command == RemMulWirCmd ) { passiveProton->SetRemoveMultiWireIonizationChamber(newValue);} if( command == RemXStMagCmd ) { passiveProton->SetRemoveXSteeringMagnets(newValue);} if( command == RemRanTriCmd ) { passiveProton->SetRemoveRangeTrimmerPlate(newValue);} if( command == RemLEPlaCmd ) { passiveProton->SetRemoveLeadPlate(newValue);} if( command == RemWedgeCmd ) { passiveProton->SetRemoveWedge(newValue);} if( command == RemMutLaFraCmd ) { passiveProton->SetRemoveMultiLayerFaradayCup(newValue);} if( command == RemRanModCmd ) { passiveProton->SetRemoveRangeModulator(newValue);} if( command == RemRanModiThCmd ) { passiveProton->RemoveNewRangeMonitoriThemba(newValue);} if( command == RemRanMonCmd ) { passiveProton->SetRemoveRangeMonitor(newValue);} if( command == RemOccRinCmd ) { passiveProton->SetRemoveOccludingRingAndCentralStopper(newValue);} if( command == RemShiColCmd ) { passiveProton->SetRemoveShieldingCollimators(newValue);} if( command == RemQuMonIonCmd ) { passiveProton->SetRemoveQuadrantAndMonitorIonizationChamber(newValue);} if( command == RemFinColCmd ) { passiveProton->SetRemoveBeamFinalCollimator(newValue);} // if( command == wedgeYPositionCmd ) // { passiveProton -> SetWedgepostion (wedgeYPositionCmd -> GetNewDoubleValue(newValue));} } //*******************************************************************************************