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4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

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