Geant4 Cross Reference |
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 // Hadrontherapy advanced example for Geant4 27 // See more at: https://twiki.cern.ch/twiki/bin/view/Geant4/AdvancedExamplesHadrontherapy 28 29 #include "LaserDrivenBeamLineMessenger.hh" 30 #include "LaserDrivenBeamLine.hh" 31 #include "G4UIdirectory.hh" 32 #include "G4UIcmdWithADoubleAndUnit.hh" 33 #include "G4UIcmdWithoutParameter.hh" 34 #include "G4UIcmdWithAString.hh" 35 #include "G4SystemOfUnits.hh" 36 37 ///////////////////////////////////////////////////////////////////////////// 38 LaserDrivenBeamLineMessenger::LaserDrivenBeamLineMessenger(LaserDrivenBeamLine* laserDriven) 39 :laserDrivenMessengerPointer(laserDriven) 40 { 41 // Messenger directories for the Energy Selector module 42 laserDrivenDir = new G4UIdirectory("/LaserDriven/"); 43 laserDrivenDir -> SetGuidance("The Laser Driven Beam Line module of Hadrontherapy"); 44 45 // Messenger directories for the Energy Selector module 46 energySelectorDir = new G4UIdirectory("/LaserDriven/EnergySelector/"); 47 energySelectorDir -> SetGuidance("The Energy selector (ESS) module of Hadrontherapy"); 48 49 FcollimatorDir = new G4UIdirectory("/LaserDriven/EnergySelector/FirstCollimator/"); 50 FcollimatorDir -> SetGuidance("Define geometrical characteristics of the ESS first collimator"); 51 52 ScollimatorDir = new G4UIdirectory("/LaserDriven/EnergySelector/SecondCollimator/"); 53 ScollimatorDir -> SetGuidance("Define geometrical characteristics of the ESS second collimator"); 54 55 slitDir = new G4UIdirectory("/LaserDriven/EnergySelector/Slit/"); 56 slitDir -> SetGuidance("Define geometrical characteristics of the ESS slit"); 57 58 // Messenger directories for the Quadrupole module 59 quadrupoleDir = new G4UIdirectory("/LaserDriven/Quadrupoles/"); 60 quadrupoleDir -> SetGuidance("The Quadrupoles module of Hadrontherapy"); 61 62 relativePosDir = new G4UIdirectory("/LaserDriven/Quadrupoles/xRelPosition/"); 63 relativePosDir -> SetGuidance("Define the x relative positions of the quadrupoles"); 64 65 // ESS DISABLE 66 DisableESSCmd = new G4UIcmdWithoutParameter("/LaserDriven/EnergySelector/Disable", this); 67 DisableESSCmd -> SetGuidance("Disable the Energy Selector."); 68 DisableESSCmd -> SetGuidance("This command MUST be applied before \"beamOn\" "); 69 DisableESSCmd -> AvailableForStates(G4State_Idle); 70 71 // THE FIRST ESS COLLIMATOR 72 // 73 // Diameter of the first collimator 74 FcollimatorRadiusCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/FirstCollimator/Radius", this); 75 FcollimatorRadiusCmd -> SetGuidance("Set the Radius of the first collimator"); 76 FcollimatorRadiusCmd -> SetParameterName("Size",false); 77 FcollimatorRadiusCmd -> SetDefaultUnit("mm"); 78 FcollimatorRadiusCmd -> SetUnitCandidates("mm cm m"); 79 FcollimatorRadiusCmd -> AvailableForStates(G4State_Idle); 80 81 // Thickness of the first collimator 82 FcollimatorThicknessCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/FirstCollimator/Thickness", this); 83 FcollimatorThicknessCmd -> SetGuidance("Set the thickness of the first collimator"); 84 FcollimatorThicknessCmd -> SetParameterName("Size",false); 85 FcollimatorThicknessCmd -> SetDefaultUnit("mm"); 86 FcollimatorThicknessCmd -> SetUnitCandidates("mm cm m"); 87 FcollimatorThicknessCmd -> AvailableForStates(G4State_Idle); 88 89 // Z Position of the first collimator hole 90 FcollimatorZpositionCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/FirstCollimator/zPosizion", this); 91 FcollimatorZpositionCmd -> SetGuidance("Set the Z position of the first collimator hole as respect the internal vacuum chamber center axis"); 92 FcollimatorZpositionCmd -> SetParameterName("Size",false); 93 FcollimatorZpositionCmd -> SetDefaultUnit("mm"); 94 FcollimatorZpositionCmd -> SetUnitCandidates("mm cm m"); 95 FcollimatorZpositionCmd -> AvailableForStates(G4State_Idle); 96 97 // THE SECOND ESS COLLIMATOR 98 // 99 // Diameter of the second collimator 100 ScollimatorRadiusCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/SecondCollimator/Radius", this); 101 ScollimatorRadiusCmd -> SetGuidance("Set the Radius of the second collimator"); 102 ScollimatorRadiusCmd -> SetParameterName("Size",false); 103 ScollimatorRadiusCmd -> SetDefaultUnit("mm"); 104 ScollimatorRadiusCmd -> SetUnitCandidates("mm cm m"); 105 ScollimatorRadiusCmd -> AvailableForStates(G4State_Idle); 106 107 // Thickness of the second collimator 108 ScollimatorThicknessCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/SecondCollimator/Thickness", this); 109 ScollimatorThicknessCmd -> SetGuidance("Set the thickness of the second collimator"); 110 ScollimatorThicknessCmd -> SetParameterName("Size",false); 111 ScollimatorThicknessCmd -> SetDefaultUnit("mm"); 112 ScollimatorThicknessCmd -> SetUnitCandidates("mm cm m"); 113 ScollimatorThicknessCmd -> AvailableForStates(G4State_Idle); 114 115 // Z Position of the second collimator hole 116 ScollimatorZpositionCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/SecondCollimator/zPosizion", this); 117 ScollimatorZpositionCmd -> SetGuidance("Set the Z position of the second collimator hole as respect the internal vacuum chamber center axis"); 118 ScollimatorZpositionCmd -> SetParameterName("Size",false); 119 ScollimatorZpositionCmd -> SetDefaultUnit("mm"); 120 ScollimatorZpositionCmd -> SetUnitCandidates("mm cm m"); 121 ScollimatorZpositionCmd -> AvailableForStates(G4State_Idle); 122 123 // THE SLIT 124 // 125 // Thickness Slit 126 SlitThicknessCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/Slit/thickness",this); 127 SlitThicknessCmd -> SetGuidance("Set the X dimension of the Slit, the maximum value is 10 mm"); 128 SlitThicknessCmd -> SetParameterName("Size",false); 129 SlitThicknessCmd -> SetDefaultUnit("mm"); 130 SlitThicknessCmd -> SetUnitCandidates("mm cm m"); 131 SlitThicknessCmd -> AvailableForStates(G4State_Idle); 132 133 //Hole dimension of the Slit (in Y direction) 134 holeSlitDimensionYCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/Slit/HoleDimensionY",this); 135 holeSlitDimensionYCmd -> SetGuidance("Set the Y dimension of the Slit Hole"); 136 holeSlitDimensionYCmd -> SetParameterName("Size",false); 137 holeSlitDimensionYCmd -> SetDefaultUnit("mm"); 138 holeSlitDimensionYCmd -> SetUnitCandidates("mm cm m"); 139 holeSlitDimensionYCmd -> AvailableForStates(G4State_Idle); 140 141 // Hole dimension of the Slit (in Z direction) 142 holeSlitDimensionZCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/Slit/HoleDimensionZ",this); 143 holeSlitDimensionZCmd -> SetGuidance("Set the Z dimension of the external part of magnet 4"); 144 holeSlitDimensionZCmd -> SetParameterName("Size",false); 145 holeSlitDimensionZCmd -> SetDefaultUnit("mm"); 146 holeSlitDimensionZCmd -> SetUnitCandidates("mm cm m"); 147 holeSlitDimensionZCmd -> AvailableForStates(G4State_Idle); 148 149 // Hole position of the Slit (in Z direction as respect the Slit body) 150 slitHolePositionZCmd = new G4UIcmdWithADoubleAndUnit("/LaserDriven/EnergySelector/Slit/HolePositionZ", this); 151 slitHolePositionZCmd -> SetGuidance("Set the Slit hole position in the Z direction as respect the Slit body center"); 152 slitHolePositionZCmd -> SetParameterName("Size",false); 153 slitHolePositionZCmd -> SetDefaultUnit("mm"); 154 slitHolePositionZCmd -> SetUnitCandidates("mm cm m"); 155 slitHolePositionZCmd -> AvailableForStates(G4State_Idle); 156 157 // Quadrupole system DISABLE 158 DisableQuadsCmd = new G4UIcmdWithoutParameter("/LaserDriven/Quadrupoles/DisableQuads", this); 159 DisableQuadsCmd -> SetGuidance("Disable the Quadrupole system."); 160 DisableQuadsCmd -> SetGuidance("This command MUST be applied before \"beamOn\" "); 161 DisableQuadsCmd -> AvailableForStates(G4State_Idle); 162 } 163 164 ///////////////////////////////////////////////////////////////////////////// 165 LaserDrivenBeamLineMessenger::~LaserDrivenBeamLineMessenger() 166 { 167 168 delete laserDrivenDir; 169 delete energySelectorDir; 170 delete FcollimatorDir; 171 delete ScollimatorDir; 172 delete slitDir; 173 delete quadrupoleDir; 174 delete relativePosDir; 175 delete DisableESSCmd; 176 delete FcollimatorRadiusCmd; 177 delete FcollimatorThicknessCmd; 178 delete FcollimatorZpositionCmd; 179 delete ScollimatorRadiusCmd; 180 delete ScollimatorThicknessCmd; 181 delete ScollimatorZpositionCmd; 182 183 delete SlitThicknessCmd; 184 delete holeSlitDimensionYCmd; 185 delete holeSlitDimensionZCmd; 186 delete slitHolePositionZCmd; 187 188 delete DisableQuadsCmd; 189 190 } 191 ///////////////////////////////////////////////////////////////////////////// 192 void LaserDrivenBeamLineMessenger::SetNewValue(G4UIcommand* command,G4String newValue) 193 { 194 if (command == DisableESSCmd) 195 { 196 laserDrivenMessengerPointer -> RemoveESS(); 197 } 198 if( command == FcollimatorRadiusCmd ) 199 { 200 laserDrivenMessengerPointer -> SetFirstCollimatorRadius 201 (FcollimatorRadiusCmd -> GetNewDoubleValue(newValue)); 202 } 203 else if( command == FcollimatorThicknessCmd ) 204 { 205 laserDrivenMessengerPointer -> SetFirstCollimatorThickness 206 (FcollimatorThicknessCmd -> GetNewDoubleValue(newValue)); 207 } 208 else if( command == FcollimatorZpositionCmd ) 209 { 210 laserDrivenMessengerPointer -> SetFirstCollimatorPositionZ 211 (FcollimatorZpositionCmd -> GetNewDoubleValue(newValue)); 212 } 213 else if( command == ScollimatorRadiusCmd ) 214 { 215 laserDrivenMessengerPointer -> SetSecondCollimatorRadius 216 (ScollimatorRadiusCmd -> GetNewDoubleValue(newValue)); 217 } 218 else if( command == ScollimatorThicknessCmd ) 219 { 220 laserDrivenMessengerPointer -> SetSecondCollimatorThickness 221 (ScollimatorThicknessCmd -> GetNewDoubleValue(newValue)); 222 } 223 else if( command == ScollimatorZpositionCmd ) 224 { 225 laserDrivenMessengerPointer -> SetSecondCollimatorPositionZ 226 (ScollimatorZpositionCmd -> GetNewDoubleValue(newValue)); 227 } 228 else if( command == SlitThicknessCmd ) 229 { 230 laserDrivenMessengerPointer -> SetThicknessSlit 231 (SlitThicknessCmd -> GetNewDoubleValue(newValue)); 232 } 233 else if( command == holeSlitDimensionYCmd ) 234 { 235 laserDrivenMessengerPointer -> SetSlitHoleDimensionY 236 (holeSlitDimensionYCmd -> GetNewDoubleValue(newValue)); 237 } 238 else if( command == holeSlitDimensionZCmd ) 239 { 240 laserDrivenMessengerPointer -> SetSlitHoleDimensionZ 241 (holeSlitDimensionZCmd -> GetNewDoubleValue(newValue)); 242 } 243 else if( command == slitHolePositionZCmd ) 244 { 245 laserDrivenMessengerPointer -> SetSlitHolePositionZ 246 (slitHolePositionZCmd -> GetNewDoubleValue(newValue)); 247 } 248 else if (command==DisableQuadsCmd) 249 { 250 laserDrivenMessengerPointer -> RemoveQuads(); 251 } 252 253 } 254 255