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 // << 27 /// \file medical/GammaTherapy/src/PrimaryGene << 28 /// \brief Implementation of the PrimaryGenera << 29 // << 30 26 31 //-------------------------------------------- 27 //--------------------------------------------------------------------------- 32 // 28 // 33 // ClassName: PrimaryGeneratorMessenger 29 // ClassName: PrimaryGeneratorMessenger 34 // 30 // 35 // Description: Definition of physics list par 31 // Description: Definition of physics list parameters 36 // 32 // 37 // Author: V.Ivanchenko 26/09/00 33 // Author: V.Ivanchenko 26/09/00 38 // 34 // 39 //-------------------------------------------- 35 //---------------------------------------------------------------------------- 40 // 36 // 41 37 42 //....oooOO0OOooo........oooOO0OOooo........oo 38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 43 //....oooOO0OOooo........oooOO0OOooo........oo 39 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 44 40 45 #include "PrimaryGeneratorMessenger.hh" 41 #include "PrimaryGeneratorMessenger.hh" 46 << 47 #include "PrimaryGeneratorAction.hh" 42 #include "PrimaryGeneratorAction.hh" 48 #include "Run.hh" << 43 #include "Histo.hh" 49 << 50 #include "G4RunManager.hh" << 51 #include "G4UImanager.hh" 44 #include "G4UImanager.hh" 52 45 53 //....oooOO0OOooo........oooOO0OOooo........oo 46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 54 47 55 PrimaryGeneratorMessenger::PrimaryGeneratorMes << 48 PrimaryGeneratorMessenger::PrimaryGeneratorMessenger( >> 49 PrimaryGeneratorAction* gen): >> 50 theGen(gen) 56 { 51 { 57 fVerbose = gen->GetVerbose(); << 52 G4cout << "PrimaryGeneratorMessenger: Construct " << G4endl; 58 if (fVerbose) G4cout << "PrimaryGeneratorMes << 53 >> 54 beamXCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/beamX",this); >> 55 beamXCmd->SetGuidance("Set X position of the center of the beam."); >> 56 beamXCmd->SetParameterName("beamX",true); >> 57 beamXCmd->SetUnitCategory("Length"); >> 58 beamXCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 59 >> 60 beamYCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/beamY",this); >> 61 beamYCmd->SetGuidance("Set Y position of the center of the beam."); >> 62 beamYCmd->SetParameterName("beamY",true); >> 63 beamYCmd->SetUnitCategory("Length"); >> 64 beamYCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 65 >> 66 beamZCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/beamZ",this); >> 67 beamZCmd->SetGuidance("Set Z of the entry point of the beam."); >> 68 beamZCmd->SetParameterName("beamZ",true); >> 69 beamZCmd->SetUnitCategory("Length"); >> 70 beamZCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 71 >> 72 sigmaXCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaX",this); >> 73 sigmaXCmd->SetGuidance("Set the beam Gussian width for X"); >> 74 sigmaXCmd->SetParameterName("sigmaX",false); >> 75 sigmaXCmd->SetUnitCategory("Length"); >> 76 sigmaXCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 77 >> 78 sigmaYCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaY",this); >> 79 sigmaYCmd->SetGuidance("Set the beam Gussian width for Y"); >> 80 sigmaYCmd->SetParameterName("sigmaY",false); >> 81 sigmaYCmd->SetUnitCategory("Length"); >> 82 sigmaYCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 83 >> 84 sigmaZCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaZ",this); >> 85 sigmaZCmd->SetGuidance("Set the beam Gussian width for Y"); >> 86 sigmaZCmd->SetParameterName("sigmaZ",false); >> 87 sigmaZCmd->SetUnitCategory("Length"); >> 88 sigmaZCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 89 >> 90 sigmaECmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaE",this); >> 91 sigmaECmd->SetGuidance("Set the beam Gussian width for energy"); >> 92 sigmaECmd->SetParameterName("sigmaE",false); >> 93 sigmaECmd->SetUnitCategory("Energy"); >> 94 sigmaECmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 95 >> 96 beamECmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/beamE",this); >> 97 beamECmd->SetGuidance("Set the beam kinetic energy"); >> 98 beamECmd->SetParameterName("beamE",false); >> 99 beamECmd->SetUnitCategory("Energy"); >> 100 beamECmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 101 >> 102 randCmd = new G4UIcmdWithAString("/testem/gun",this); >> 103 randCmd->SetGuidance("Set the name of the random distribution (gauss,flat)"); >> 104 randCmd->SetParameterName("rand",false); >> 105 randCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 106 >> 107 maxThetaCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/maxTheta",this); >> 108 maxThetaCmd->SetGuidance("Set the beam maxTheta in degrees."); >> 109 maxThetaCmd->SetParameterName("maxTheta",false); >> 110 maxThetaCmd->SetUnitCategory("Angle"); >> 111 maxThetaCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 112 >> 113 sThetaCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaTheta",this); >> 114 sThetaCmd->SetGuidance("Set the beam sigmaTheta in degrees."); >> 115 sThetaCmd->SetParameterName("sigmaTheta",false); >> 116 sThetaCmd->SetUnitCategory("Angle"); >> 117 sThetaCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 59 118 60 fBeamXCmd = new G4UIcmdWithADoubleAndUnit("/ << 61 fBeamXCmd->SetGuidance("Set X position of th << 62 fBeamXCmd->SetParameterName("beamX", true); << 63 fBeamXCmd->SetUnitCategory("Length"); << 64 fBeamXCmd->AvailableForStates(G4State_PreIni << 65 << 66 fBeamYCmd = new G4UIcmdWithADoubleAndUnit("/ << 67 fBeamYCmd->SetGuidance("Set Y position of th << 68 fBeamYCmd->SetParameterName("beamY", true); << 69 fBeamYCmd->SetUnitCategory("Length"); << 70 fBeamYCmd->AvailableForStates(G4State_PreIni << 71 << 72 fBeamZCmd = new G4UIcmdWithADoubleAndUnit("/ << 73 fBeamZCmd->SetGuidance("Set Z of the entry p << 74 fBeamZCmd->SetParameterName("beamZ", true); << 75 fBeamZCmd->SetUnitCategory("Length"); << 76 fBeamZCmd->AvailableForStates(G4State_PreIni << 77 << 78 fBeamECmd = new G4UIcmdWithADoubleAndUnit("/ << 79 fBeamECmd->SetGuidance("Set the beam kinetic << 80 fBeamECmd->SetParameterName("beamE", false); << 81 fBeamECmd->SetUnitCategory("Energy"); << 82 fBeamECmd->AvailableForStates(G4State_PreIni << 83 << 84 fSigmaXCmd = new G4UIcmdWithADoubleAndUnit(" << 85 fSigmaXCmd->SetGuidance("Set the beam Gussia << 86 fSigmaXCmd->SetParameterName("sigmaX", false << 87 fSigmaXCmd->SetUnitCategory("Length"); << 88 fSigmaXCmd->AvailableForStates(G4State_PreIn << 89 << 90 fSigmaYCmd = new G4UIcmdWithADoubleAndUnit(" << 91 fSigmaYCmd->SetGuidance("Set the beam Gussia << 92 fSigmaYCmd->SetParameterName("sigmaY", false << 93 fSigmaYCmd->SetUnitCategory("Length"); << 94 fSigmaYCmd->AvailableForStates(G4State_PreIn << 95 << 96 fSigmaZCmd = new G4UIcmdWithADoubleAndUnit(" << 97 fSigmaZCmd->SetGuidance("Set the beam Gussia << 98 fSigmaZCmd->SetParameterName("sigmaZ", false << 99 fSigmaZCmd->SetUnitCategory("Length"); << 100 fSigmaZCmd->AvailableForStates(G4State_PreIn << 101 << 102 fSigmaECmd = new G4UIcmdWithADoubleAndUnit(" << 103 fSigmaECmd->SetGuidance("Set the beam Gussia << 104 fSigmaECmd->SetParameterName("sigmaE", false << 105 fSigmaECmd->SetUnitCategory("Energy"); << 106 fSigmaECmd->AvailableForStates(G4State_PreIn << 107 << 108 fRandCmd = new G4UIcmdWithAString("/testem/g << 109 fRandCmd->SetGuidance("Set the name of the r << 110 fRandCmd->SetParameterName("rand", false); << 111 fRandCmd->AvailableForStates(G4State_PreInit << 112 << 113 fMaxThetaCmd = new G4UIcmdWithADoubleAndUnit << 114 fMaxThetaCmd->SetGuidance("Set the beam maxT << 115 fMaxThetaCmd->SetParameterName("maxTheta", f << 116 fMaxThetaCmd->SetUnitCategory("Angle"); << 117 fMaxThetaCmd->AvailableForStates(G4State_Pre << 118 << 119 fThetaCmd = new G4UIcmdWithADoubleAndUnit("/ << 120 fThetaCmd->SetGuidance("Set the beam sigmaTh << 121 fThetaCmd->SetParameterName("sigmaTheta", fa << 122 fThetaCmd->SetUnitCategory("Angle"); << 123 fThetaCmd->AvailableForStates(G4State_PreIni << 124 } 119 } 125 120 126 //....oooOO0OOooo........oooOO0OOooo........oo 121 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 127 122 128 PrimaryGeneratorMessenger::~PrimaryGeneratorMe 123 PrimaryGeneratorMessenger::~PrimaryGeneratorMessenger() 129 { 124 { 130 delete fBeamXCmd; << 125 delete beamXCmd; 131 delete fBeamYCmd; << 126 delete beamYCmd; 132 delete fBeamZCmd; << 127 delete beamZCmd; 133 << 128 delete sigmaXCmd; 134 delete fSigmaXCmd; << 129 delete sigmaYCmd; 135 delete fSigmaYCmd; << 130 delete sigmaZCmd; 136 delete fSigmaZCmd; << 131 delete sigmaECmd; 137 delete fSigmaECmd; << 132 delete beamECmd; 138 << 133 delete maxThetaCmd; 139 delete fBeamECmd; << 134 delete sThetaCmd; 140 delete fRandCmd; << 135 delete randCmd; 141 delete fMaxThetaCmd; << 142 delete fThetaCmd; << 143 } 136 } 144 137 145 //....oooOO0OOooo........oooOO0OOooo........oo 138 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 146 139 147 void PrimaryGeneratorMessenger::SetNewValue(G4 << 140 void PrimaryGeneratorMessenger::SetNewValue(G4UIcommand* command, >> 141 G4String newValue) 148 { 142 { 149 if (fVerbose) G4cout << "PrimaryGeneratorMes << 150 143 151 if (command == fBeamXCmd) { << 144 if(1 < (Histo::GetPointer())->GetVerbose()) { 152 fGen->SetBeamX(fBeamXCmd->GetNewDoubleValu << 145 G4cout << "PrimaryGeneratorMessenger: Next command value = " 153 } << 146 << newValue << G4endl; 154 if (command == fBeamYCmd) { << 147 } 155 fGen->SetBeamY(fBeamYCmd->GetNewDoubleValu << 148 156 } << 149 if(command == beamXCmd) 157 if (command == fBeamZCmd) { << 150 {theGen->SetBeamX(beamXCmd->GetNewDoubleValue(newValue));} 158 fGen->SetBeamZ(fBeamZCmd->GetNewDoubleValu << 151 if(command == beamYCmd) 159 } << 152 {theGen->SetBeamY(beamYCmd->GetNewDoubleValue(newValue));} 160 if (command == fSigmaXCmd) { << 153 if(command == beamZCmd) 161 fGen->SetBeamSigmaX(fSigmaXCmd->GetNewDoub << 154 {theGen->SetBeamZ(beamZCmd->GetNewDoubleValue(newValue));} 162 } << 155 if(command == sigmaXCmd) 163 if (command == fSigmaYCmd) { << 156 {theGen->SetBeamSigmaX(sigmaXCmd->GetNewDoubleValue(newValue));} 164 fGen->SetBeamSigmaY(fSigmaYCmd->GetNewDoub << 157 if(command == sigmaYCmd) 165 } << 158 {theGen->SetBeamSigmaY(sigmaYCmd->GetNewDoubleValue(newValue));} 166 if (command == fSigmaZCmd) { << 159 if(command == sigmaZCmd) 167 fGen->SetBeamSigmaZ(fSigmaZCmd->GetNewDoub << 160 {theGen->SetBeamSigmaZ(sigmaZCmd->GetNewDoubleValue(newValue));} 168 } << 161 if(command == sigmaECmd) 169 if (command == fSigmaECmd) { << 162 {theGen->SetBeamSigmaE(sigmaECmd->GetNewDoubleValue(newValue));} 170 fGen->SetBeamSigmaE(fSigmaECmd->GetNewDoub << 163 if(command == beamECmd) { 171 } << 164 G4double e = beamECmd->GetNewDoubleValue(newValue); 172 if (command == fBeamECmd) { << 165 theGen->SetBeamEnergy(e); 173 G4double e = fBeamECmd->GetNewDoubleValue( << 166 Histo* theHisto = Histo::GetPointer(); 174 fGen->SetBeamEnergy(e); << 167 if(theHisto->GetMaxEnergy() == 0.0) theHisto->SetMaxEnergy(e); 175 } << 168 } 176 if (command == fMaxThetaCmd) { << 169 if(command == maxThetaCmd) 177 fGen->SetBeamMinCosTheta(std::cos(fMaxThet << 170 {theGen->SetBeamMinCosTheta(std::cos(maxThetaCmd->GetNewDoubleValue(newValue)));} 178 } << 171 if(command == sThetaCmd) 179 if (command == fThetaCmd) { << 172 {theGen->SetSigmaTheta(sThetaCmd->GetNewDoubleValue(newValue));} 180 fGen->SetSigmaTheta(fThetaCmd->GetNewDoubl << 173 if(command == randCmd) 181 } << 174 {theGen->SetRandom(newValue);} 182 if (command == fRandCmd) { << 183 fGen->SetRandom(newValue); << 184 } << 185 175 186 if (fVerbose) G4cout << "PrimaryGeneratorMes << 176 187 } << 177 if(1 < (Histo::GetPointer())->GetVerbose()) >> 178 {G4cout << "PrimaryGeneratorMessenger: O'K " << G4endl;} >> 179 } 188 180 189 //....oooOO0OOooo........oooOO0OOooo........oo 181 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 182 190 183