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 | #define hTestPrimaryGeneratorMessenger_CPP |
---|
27 | |
---|
28 | //--------------------------------------------------------------------------- |
---|
29 | // |
---|
30 | // ClassName: hTestPrimaryGeneratorMessenger |
---|
31 | // |
---|
32 | // Description: Definition of physics list parameters |
---|
33 | // |
---|
34 | // Author: V.Ivanchenko 26/09/00 |
---|
35 | // |
---|
36 | //---------------------------------------------------------------------------- |
---|
37 | // |
---|
38 | |
---|
39 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
40 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
41 | |
---|
42 | #include "hTestPrimaryGeneratorMessenger.hh" |
---|
43 | #include "hTestPrimaryGeneratorAction.hh" |
---|
44 | #include "G4UImanager.hh" |
---|
45 | #include "hTestHisto.hh" |
---|
46 | |
---|
47 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
48 | |
---|
49 | hTestPrimaryGeneratorMessenger::hTestPrimaryGeneratorMessenger( |
---|
50 | hTestPrimaryGeneratorAction* gen): |
---|
51 | theGen(gen) |
---|
52 | { |
---|
53 | G4cout << "hTestPrimaryGeneratorMessenger: Construct " << G4endl; |
---|
54 | |
---|
55 | beamXCmd = new G4UIcmdWithADoubleAndUnit("/hTest/gun/beamX",this); |
---|
56 | beamXCmd->SetGuidance("Set X position of the center of the beam."); |
---|
57 | beamXCmd->SetParameterName("beamX",true); |
---|
58 | beamXCmd->SetUnitCategory("Length"); |
---|
59 | beamXCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
60 | |
---|
61 | beamYCmd = new G4UIcmdWithADoubleAndUnit("/hTest/gun/beamY",this); |
---|
62 | beamYCmd->SetGuidance("Set Y position of the center of the beam."); |
---|
63 | beamYCmd->SetParameterName("beamY",true); |
---|
64 | beamYCmd->SetUnitCategory("Length"); |
---|
65 | beamYCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
66 | |
---|
67 | beamZCmd = new G4UIcmdWithADoubleAndUnit("/hTest/gun/beamZ",this); |
---|
68 | beamZCmd->SetGuidance("Set Z of the entry point of the beam."); |
---|
69 | beamZCmd->SetParameterName("beamZ",true); |
---|
70 | beamZCmd->SetUnitCategory("Length"); |
---|
71 | beamZCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
72 | |
---|
73 | sigmaXCmd = new G4UIcmdWithADoubleAndUnit("/hTest/gun/sigmaX",this); |
---|
74 | sigmaXCmd->SetGuidance("Set the beam Gussian width for X"); |
---|
75 | sigmaXCmd->SetParameterName("sigmaX",false); |
---|
76 | sigmaXCmd->SetUnitCategory("Length"); |
---|
77 | sigmaXCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
78 | |
---|
79 | sigmaYCmd = new G4UIcmdWithADoubleAndUnit("/hTest/gun/sigmaY",this); |
---|
80 | sigmaYCmd->SetGuidance("Set the beam Gussian width for Y"); |
---|
81 | sigmaYCmd->SetParameterName("sigmaY",false); |
---|
82 | sigmaYCmd->SetUnitCategory("Length"); |
---|
83 | sigmaYCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
84 | |
---|
85 | sigmaZCmd = new G4UIcmdWithADoubleAndUnit("/hTest/gun/sigmaZ",this); |
---|
86 | sigmaZCmd->SetGuidance("Set the beam Gussian width for Y"); |
---|
87 | sigmaZCmd->SetParameterName("sigmaZ",false); |
---|
88 | sigmaZCmd->SetUnitCategory("Length"); |
---|
89 | sigmaZCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
90 | |
---|
91 | sigmaECmd = new G4UIcmdWithADoubleAndUnit("/hTest/gun/sigmaE",this); |
---|
92 | sigmaECmd->SetGuidance("Set the beam Gussian width for energy"); |
---|
93 | sigmaECmd->SetParameterName("sigmaE",false); |
---|
94 | sigmaECmd->SetUnitCategory("Energy"); |
---|
95 | sigmaECmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
96 | |
---|
97 | beamECmd = new G4UIcmdWithADoubleAndUnit("/hTest/gun/beamE",this); |
---|
98 | beamECmd->SetGuidance("Set the beam kinetic energy"); |
---|
99 | beamECmd->SetParameterName("beamE",false); |
---|
100 | beamECmd->SetUnitCategory("Energy"); |
---|
101 | beamECmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
102 | |
---|
103 | beamBetaCmd = new G4UIcmdWithADouble("/hTest/gun/beamBeta",this); |
---|
104 | beamBetaCmd->SetGuidance("Set the beam velocity"); |
---|
105 | beamBetaCmd->SetParameterName("beamBeta",false); |
---|
106 | beamBetaCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
107 | |
---|
108 | sigmaBetaCmd = new G4UIcmdWithADouble("/hTest/gun/sigmaBeta",this); |
---|
109 | sigmaBetaCmd->SetGuidance("Set the sigma velocity"); |
---|
110 | sigmaBetaCmd->SetParameterName("sigmaBeta",false); |
---|
111 | sigmaBetaCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
112 | |
---|
113 | randCmd = new G4UIcmdWithAString("/hTest/gun/random",this); |
---|
114 | randCmd->SetGuidance("Set the name of the random distribution (gauss,flatE,flatBeta)"); |
---|
115 | randCmd->SetParameterName("rand",false); |
---|
116 | randCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
117 | |
---|
118 | partCmd = new G4UIcmdWithAString("/hTest/gun/particle",this); |
---|
119 | partCmd->SetGuidance("Set the name of the particle"); |
---|
120 | partCmd->SetParameterName("part",false); |
---|
121 | partCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
122 | |
---|
123 | maxThetaCmd = new G4UIcmdWithADoubleAndUnit("/hTest/gun/maxTheta",this); |
---|
124 | maxThetaCmd->SetGuidance("Set the beam maxTheta in degrees."); |
---|
125 | maxThetaCmd->SetParameterName("maxTheta",false); |
---|
126 | maxThetaCmd->SetUnitCategory("Angle"); |
---|
127 | maxThetaCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
128 | |
---|
129 | } |
---|
130 | |
---|
131 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
132 | |
---|
133 | hTestPrimaryGeneratorMessenger::~hTestPrimaryGeneratorMessenger() |
---|
134 | { |
---|
135 | delete beamXCmd; |
---|
136 | delete beamYCmd; |
---|
137 | delete beamZCmd; |
---|
138 | delete sigmaXCmd; |
---|
139 | delete sigmaYCmd; |
---|
140 | delete sigmaZCmd; |
---|
141 | delete sigmaECmd; |
---|
142 | delete beamECmd; |
---|
143 | delete maxThetaCmd; |
---|
144 | delete partCmd; |
---|
145 | delete beamBetaCmd; |
---|
146 | delete sigmaBetaCmd; |
---|
147 | delete randCmd; |
---|
148 | } |
---|
149 | |
---|
150 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
151 | |
---|
152 | void hTestPrimaryGeneratorMessenger::SetNewValue(G4UIcommand* command, |
---|
153 | G4String newValue) |
---|
154 | { |
---|
155 | |
---|
156 | if(1 < theGen->GetVerbose()) { |
---|
157 | G4cout << "hTestPrimaryGeneratorMessenger: Next command value = " |
---|
158 | << newValue << G4endl; |
---|
159 | } |
---|
160 | |
---|
161 | if(command == beamXCmd) |
---|
162 | {theGen->SetBeamX(beamXCmd->GetNewDoubleValue(newValue));} |
---|
163 | if(command == beamYCmd) |
---|
164 | {theGen->SetBeamY(beamYCmd->GetNewDoubleValue(newValue));} |
---|
165 | if(command == beamZCmd) |
---|
166 | {theGen->SetBeamZ(beamZCmd->GetNewDoubleValue(newValue));} |
---|
167 | if(command == sigmaXCmd) |
---|
168 | {theGen->SetBeamSigmaX(sigmaXCmd->GetNewDoubleValue(newValue));} |
---|
169 | if(command == sigmaYCmd) |
---|
170 | {theGen->SetBeamSigmaY(sigmaYCmd->GetNewDoubleValue(newValue));} |
---|
171 | if(command == sigmaZCmd) |
---|
172 | {theGen->SetBeamSigmaZ(sigmaZCmd->GetNewDoubleValue(newValue));} |
---|
173 | if(command == sigmaECmd) |
---|
174 | {theGen->SetBeamSigmaE(sigmaECmd->GetNewDoubleValue(newValue));} |
---|
175 | if(command == beamECmd) { |
---|
176 | G4double e = beamECmd->GetNewDoubleValue(newValue); |
---|
177 | theGen->SetBeamEnergy(e); |
---|
178 | hTestHisto* theHisto = hTestHisto::GetPointer(); |
---|
179 | if(theHisto->GetMaxEnergy() == 0.0) theHisto->SetMaxEnergy(e); |
---|
180 | } |
---|
181 | if(command == maxThetaCmd) |
---|
182 | {theGen->SetBeamMinCosTheta(std::cos(maxThetaCmd->GetNewDoubleValue(newValue)));} |
---|
183 | if(command == partCmd) |
---|
184 | {(G4UImanager::GetUIpointer())->ApplyCommand("/gun/particle "+newValue);} |
---|
185 | if(command == beamBetaCmd) |
---|
186 | {theGen->SetBeamBeta(beamBetaCmd->GetNewDoubleValue(newValue));} |
---|
187 | if(command == sigmaBetaCmd) |
---|
188 | {theGen->SetSigmaBeta(sigmaBetaCmd->GetNewDoubleValue(newValue));} |
---|
189 | if(command == randCmd) |
---|
190 | {theGen->SetRandom(newValue);} |
---|
191 | |
---|
192 | |
---|
193 | if(0 < theGen->GetVerbose()) |
---|
194 | {G4cout << "hTestPrimaryGeneratorMessenger: O'K " << G4endl;} |
---|
195 | } |
---|
196 | |
---|
197 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
198 | |
---|