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 | //--------------------------------------------------------------------------- |
---|
28 | // |
---|
29 | // ClassName: PrimaryGeneratorMessenger |
---|
30 | // |
---|
31 | // Description: Definition of physics list parameters |
---|
32 | // |
---|
33 | // Author: V.Ivanchenko 26/09/00 |
---|
34 | // |
---|
35 | //---------------------------------------------------------------------------- |
---|
36 | // |
---|
37 | |
---|
38 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
39 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
40 | |
---|
41 | #include "PrimaryGeneratorMessenger.hh" |
---|
42 | #include "PrimaryGeneratorAction.hh" |
---|
43 | #include "Histo.hh" |
---|
44 | #include "G4UImanager.hh" |
---|
45 | |
---|
46 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
47 | |
---|
48 | PrimaryGeneratorMessenger::PrimaryGeneratorMessenger( |
---|
49 | PrimaryGeneratorAction* gen): |
---|
50 | theGen(gen) |
---|
51 | { |
---|
52 | G4cout << "PrimaryGeneratorMessenger: Construct " << G4endl; |
---|
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); |
---|
118 | |
---|
119 | } |
---|
120 | |
---|
121 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
122 | |
---|
123 | PrimaryGeneratorMessenger::~PrimaryGeneratorMessenger() |
---|
124 | { |
---|
125 | delete beamXCmd; |
---|
126 | delete beamYCmd; |
---|
127 | delete beamZCmd; |
---|
128 | delete sigmaXCmd; |
---|
129 | delete sigmaYCmd; |
---|
130 | delete sigmaZCmd; |
---|
131 | delete sigmaECmd; |
---|
132 | delete beamECmd; |
---|
133 | delete maxThetaCmd; |
---|
134 | delete sThetaCmd; |
---|
135 | delete randCmd; |
---|
136 | } |
---|
137 | |
---|
138 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
139 | |
---|
140 | void PrimaryGeneratorMessenger::SetNewValue(G4UIcommand* command, |
---|
141 | G4String newValue) |
---|
142 | { |
---|
143 | |
---|
144 | if(1 < (Histo::GetPointer())->GetVerbose()) { |
---|
145 | G4cout << "PrimaryGeneratorMessenger: Next command value = " |
---|
146 | << newValue << G4endl; |
---|
147 | } |
---|
148 | |
---|
149 | if(command == beamXCmd) |
---|
150 | {theGen->SetBeamX(beamXCmd->GetNewDoubleValue(newValue));} |
---|
151 | if(command == beamYCmd) |
---|
152 | {theGen->SetBeamY(beamYCmd->GetNewDoubleValue(newValue));} |
---|
153 | if(command == beamZCmd) |
---|
154 | {theGen->SetBeamZ(beamZCmd->GetNewDoubleValue(newValue));} |
---|
155 | if(command == sigmaXCmd) |
---|
156 | {theGen->SetBeamSigmaX(sigmaXCmd->GetNewDoubleValue(newValue));} |
---|
157 | if(command == sigmaYCmd) |
---|
158 | {theGen->SetBeamSigmaY(sigmaYCmd->GetNewDoubleValue(newValue));} |
---|
159 | if(command == sigmaZCmd) |
---|
160 | {theGen->SetBeamSigmaZ(sigmaZCmd->GetNewDoubleValue(newValue));} |
---|
161 | if(command == sigmaECmd) |
---|
162 | {theGen->SetBeamSigmaE(sigmaECmd->GetNewDoubleValue(newValue));} |
---|
163 | if(command == beamECmd) { |
---|
164 | G4double e = beamECmd->GetNewDoubleValue(newValue); |
---|
165 | theGen->SetBeamEnergy(e); |
---|
166 | Histo* theHisto = Histo::GetPointer(); |
---|
167 | if(theHisto->GetMaxEnergy() == 0.0) theHisto->SetMaxEnergy(e); |
---|
168 | } |
---|
169 | if(command == maxThetaCmd) |
---|
170 | {theGen->SetBeamMinCosTheta(std::cos(maxThetaCmd->GetNewDoubleValue(newValue)));} |
---|
171 | if(command == sThetaCmd) |
---|
172 | {theGen->SetSigmaTheta(sThetaCmd->GetNewDoubleValue(newValue));} |
---|
173 | if(command == randCmd) |
---|
174 | {theGen->SetRandom(newValue);} |
---|
175 | |
---|
176 | |
---|
177 | if(1 < (Histo::GetPointer())->GetVerbose()) |
---|
178 | {G4cout << "PrimaryGeneratorMessenger: O'K " << G4endl;} |
---|
179 | } |
---|
180 | |
---|
181 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
182 | |
---|