Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // << 27 /// \file medical/GammaTherapy/src/PrimaryGene << 28 /// \brief Implementation of the PrimaryGenera << 29 // << 30 23 31 //-------------------------------------------- 24 //--------------------------------------------------------------------------- 32 // 25 // 33 // ClassName: PrimaryGeneratorMessenger 26 // ClassName: PrimaryGeneratorMessenger 34 // 27 // 35 // Description: Definition of physics list par 28 // Description: Definition of physics list parameters 36 // 29 // 37 // Author: V.Ivanchenko 26/09/00 30 // Author: V.Ivanchenko 26/09/00 38 // 31 // 39 //-------------------------------------------- 32 //---------------------------------------------------------------------------- 40 // 33 // 41 34 42 //....oooOO0OOooo........oooOO0OOooo........oo 35 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 43 //....oooOO0OOooo........oooOO0OOooo........oo 36 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 44 37 45 #include "PrimaryGeneratorMessenger.hh" 38 #include "PrimaryGeneratorMessenger.hh" 46 << 47 #include "PrimaryGeneratorAction.hh" 39 #include "PrimaryGeneratorAction.hh" 48 #include "Run.hh" << 40 #include "Histo.hh" 49 << 50 #include "G4RunManager.hh" << 51 #include "G4UImanager.hh" 41 #include "G4UImanager.hh" 52 42 53 //....oooOO0OOooo........oooOO0OOooo........oo 43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 54 44 55 PrimaryGeneratorMessenger::PrimaryGeneratorMes << 45 PrimaryGeneratorMessenger::PrimaryGeneratorMessenger( >> 46 PrimaryGeneratorAction* gen): >> 47 theGen(gen) 56 { 48 { 57 fVerbose = gen->GetVerbose(); << 49 G4cout << "PrimaryGeneratorMessenger: Construct " << G4endl; 58 if (fVerbose) G4cout << "PrimaryGeneratorMes << 50 >> 51 beamXCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/beamX",this); >> 52 beamXCmd->SetGuidance("Set X position of the center of the beam."); >> 53 beamXCmd->SetParameterName("beamX",true); >> 54 beamXCmd->SetUnitCategory("Length"); >> 55 beamXCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 56 >> 57 beamYCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/beamY",this); >> 58 beamYCmd->SetGuidance("Set Y position of the center of the beam."); >> 59 beamYCmd->SetParameterName("beamY",true); >> 60 beamYCmd->SetUnitCategory("Length"); >> 61 beamYCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 62 >> 63 beamZCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/beamZ",this); >> 64 beamZCmd->SetGuidance("Set Z of the entry point of the beam."); >> 65 beamZCmd->SetParameterName("beamZ",true); >> 66 beamZCmd->SetUnitCategory("Length"); >> 67 beamZCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 68 >> 69 sigmaXCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaX",this); >> 70 sigmaXCmd->SetGuidance("Set the beam Gussian width for X"); >> 71 sigmaXCmd->SetParameterName("sigmaX",false); >> 72 sigmaXCmd->SetUnitCategory("Length"); >> 73 sigmaXCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 74 >> 75 sigmaYCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaY",this); >> 76 sigmaYCmd->SetGuidance("Set the beam Gussian width for Y"); >> 77 sigmaYCmd->SetParameterName("sigmaY",false); >> 78 sigmaYCmd->SetUnitCategory("Length"); >> 79 sigmaYCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 80 >> 81 sigmaZCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaZ",this); >> 82 sigmaZCmd->SetGuidance("Set the beam Gussian width for Y"); >> 83 sigmaZCmd->SetParameterName("sigmaZ",false); >> 84 sigmaZCmd->SetUnitCategory("Length"); >> 85 sigmaZCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 86 >> 87 sigmaECmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaE",this); >> 88 sigmaECmd->SetGuidance("Set the beam Gussian width for energy"); >> 89 sigmaECmd->SetParameterName("sigmaE",false); >> 90 sigmaECmd->SetUnitCategory("Energy"); >> 91 sigmaECmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 92 >> 93 beamECmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/beamE",this); >> 94 beamECmd->SetGuidance("Set the beam kinetic energy"); >> 95 beamECmd->SetParameterName("beamE",false); >> 96 beamECmd->SetUnitCategory("Energy"); >> 97 beamECmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 98 >> 99 randCmd = new G4UIcmdWithAString("/testem/gun",this); >> 100 randCmd->SetGuidance("Set the name of the random distribution (gauss,flat)"); >> 101 randCmd->SetParameterName("rand",false); >> 102 randCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 103 >> 104 maxThetaCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/maxTheta",this); >> 105 maxThetaCmd->SetGuidance("Set the beam maxTheta in degrees."); >> 106 maxThetaCmd->SetParameterName("maxTheta",false); >> 107 maxThetaCmd->SetUnitCategory("Angle"); >> 108 maxThetaCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 109 >> 110 sThetaCmd = new G4UIcmdWithADoubleAndUnit("/testem/gun/sigmaTheta",this); >> 111 sThetaCmd->SetGuidance("Set the beam sigmaTheta in degrees."); >> 112 sThetaCmd->SetParameterName("sigmaTheta",false); >> 113 sThetaCmd->SetUnitCategory("Angle"); >> 114 sThetaCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 59 115 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 } 116 } 125 117 126 //....oooOO0OOooo........oooOO0OOooo........oo 118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 127 119 128 PrimaryGeneratorMessenger::~PrimaryGeneratorMe 120 PrimaryGeneratorMessenger::~PrimaryGeneratorMessenger() 129 { 121 { 130 delete fBeamXCmd; << 122 delete beamXCmd; 131 delete fBeamYCmd; << 123 delete beamYCmd; 132 delete fBeamZCmd; << 124 delete beamZCmd; 133 << 125 delete sigmaXCmd; 134 delete fSigmaXCmd; << 126 delete sigmaYCmd; 135 delete fSigmaYCmd; << 127 delete sigmaZCmd; 136 delete fSigmaZCmd; << 128 delete sigmaECmd; 137 delete fSigmaECmd; << 129 delete beamECmd; 138 << 130 delete maxThetaCmd; 139 delete fBeamECmd; << 131 delete sThetaCmd; 140 delete fRandCmd; << 132 delete randCmd; 141 delete fMaxThetaCmd; << 142 delete fThetaCmd; << 143 } 133 } 144 134 145 //....oooOO0OOooo........oooOO0OOooo........oo 135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 146 136 147 void PrimaryGeneratorMessenger::SetNewValue(G4 << 137 void PrimaryGeneratorMessenger::SetNewValue(G4UIcommand* command, >> 138 G4String newValue) 148 { 139 { 149 if (fVerbose) G4cout << "PrimaryGeneratorMes << 150 140 151 if (command == fBeamXCmd) { << 141 if(1 < (Histo::GetPointer())->GetVerbose()) { 152 fGen->SetBeamX(fBeamXCmd->GetNewDoubleValu << 142 G4cout << "PrimaryGeneratorMessenger: Next command value = " 153 } << 143 << newValue << G4endl; 154 if (command == fBeamYCmd) { << 144 } 155 fGen->SetBeamY(fBeamYCmd->GetNewDoubleValu << 145 156 } << 146 if(command == beamXCmd) 157 if (command == fBeamZCmd) { << 147 {theGen->SetBeamX(beamXCmd->GetNewDoubleValue(newValue));} 158 fGen->SetBeamZ(fBeamZCmd->GetNewDoubleValu << 148 if(command == beamYCmd) 159 } << 149 {theGen->SetBeamY(beamYCmd->GetNewDoubleValue(newValue));} 160 if (command == fSigmaXCmd) { << 150 if(command == beamZCmd) 161 fGen->SetBeamSigmaX(fSigmaXCmd->GetNewDoub << 151 {theGen->SetBeamZ(beamZCmd->GetNewDoubleValue(newValue));} 162 } << 152 if(command == sigmaXCmd) 163 if (command == fSigmaYCmd) { << 153 {theGen->SetBeamSigmaX(sigmaXCmd->GetNewDoubleValue(newValue));} 164 fGen->SetBeamSigmaY(fSigmaYCmd->GetNewDoub << 154 if(command == sigmaYCmd) 165 } << 155 {theGen->SetBeamSigmaY(sigmaYCmd->GetNewDoubleValue(newValue));} 166 if (command == fSigmaZCmd) { << 156 if(command == sigmaZCmd) 167 fGen->SetBeamSigmaZ(fSigmaZCmd->GetNewDoub << 157 {theGen->SetBeamSigmaZ(sigmaZCmd->GetNewDoubleValue(newValue));} 168 } << 158 if(command == sigmaECmd) 169 if (command == fSigmaECmd) { << 159 {theGen->SetBeamSigmaE(sigmaECmd->GetNewDoubleValue(newValue));} 170 fGen->SetBeamSigmaE(fSigmaECmd->GetNewDoub << 160 if(command == beamECmd) { 171 } << 161 G4double e = beamECmd->GetNewDoubleValue(newValue); 172 if (command == fBeamECmd) { << 162 theGen->SetBeamEnergy(e); 173 G4double e = fBeamECmd->GetNewDoubleValue( << 163 Histo* theHisto = Histo::GetPointer(); 174 fGen->SetBeamEnergy(e); << 164 if(theHisto->GetMaxEnergy() == 0.0) theHisto->SetMaxEnergy(e); 175 } << 165 } 176 if (command == fMaxThetaCmd) { << 166 if(command == maxThetaCmd) 177 fGen->SetBeamMinCosTheta(std::cos(fMaxThet << 167 {theGen->SetBeamMinCosTheta(std::cos(maxThetaCmd->GetNewDoubleValue(newValue)));} 178 } << 168 if(command == sThetaCmd) 179 if (command == fThetaCmd) { << 169 {theGen->SetSigmaTheta(sThetaCmd->GetNewDoubleValue(newValue));} 180 fGen->SetSigmaTheta(fThetaCmd->GetNewDoubl << 170 if(command == randCmd) 181 } << 171 {theGen->SetRandom(newValue);} 182 if (command == fRandCmd) { << 183 fGen->SetRandom(newValue); << 184 } << 185 172 186 if (fVerbose) G4cout << "PrimaryGeneratorMes << 173 187 } << 174 if(1 < (Histo::GetPointer())->GetVerbose()) >> 175 {G4cout << "PrimaryGeneratorMessenger: O'K " << G4endl;} >> 176 } 188 177 189 //....oooOO0OOooo........oooOO0OOooo........oo 178 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 179 190 180