Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4GeneralParticleSourceMessenger.hh
Go to the documentation of this file.
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// G4GeneralParticleSourceMessenger
27//
28// Class Description:
29//
30// The function of the G4GeneralParticleSourceMessenger is to allow the user to
31// enter commands either in interactive command line mode or through macros to
32// control the G4GeneralParticleSource.
33
34// Author: Fan Lei, QinetiQ ltd.
35// Customer: ESA/ESTEC
36// History:
37// - Version 2.0, 05/02/2004, Fan Lei - Created.
38// Multiple particle source definition
39// - Version 2.1, 20/03/2014, Andrew Green - Modifications for MT
40// Added a check to force only one thread to parse the macro file.
41// This information is fed into the GPS which now has a split mechanism
42// for the large data (hence need to only read in 1 thread)
43// - Version 3.0, Aug-Oct 2014, Andrea Dotti
44// Transformations for thread safety and use in MT application
45// Messenger is now a singleton w/ explicit Destroy() method for deletion
46// Note the following: the class should be instantiated only once
47// by a worker thread. It relies on a new feature of basic messenger class
48// that allows for UI commands to be created by worker threads but being
49// executed by master thread. For this reason the messenger itself should
50// be created once, form here the singleton pattern
51// --------------------------------------------------------------------
52#ifndef G4GeneralParticleSourceMessenger_hh
53#define G4GeneralParticleSourceMessenger_hh 1
54
55#include "G4UImessenger.hh"
56#include "globals.hh"
57
58class G4ParticleTable;
59class G4UIcommand;
60class G4UIdirectory;
70
73
75{
76 public:
77
78 void SetParticleGun(G4SingleParticleSource *fpg) { fParticleGun = fpg; } ;
79 // Select the particle gun to be defined/modified
80
81 void SetNewValue(G4UIcommand* command, G4String newValues) override;
82 // Identifies the command which has been invoked by the user, extracts the
83 // parameters associated with that command (held in newValues), and uses
84 // these values with the appropriate member function of
85 // G4GeneralParticleSource
86
87 G4String GetCurrentValue(G4UIcommand* command) override;
88 // Allows the user to retrieve the current values of parameters.
89 // NOT yet implemented!
90
92 static void Destroy();
93
94 private:
95
97 // Constructor: sets up commands
99 // Destructor: deletes commands
100
101 void IonCommand(G4String newValues);
102 void IonLvlCommand(G4String newValues);
103
104 private:
105
106 G4GeneralParticleSource* fGPS = nullptr;
107 G4SingleParticleSource* fParticleGun = nullptr;
108 G4ParticleTable* particleTable = nullptr;
109 G4String histtype;
110
111 G4UIdirectory* gpsDirectory;
112
113 // Multiple source control commands
114 //
115 G4UIdirectory *sourceDirectory;
116 G4UIcmdWithADouble *addsourceCmd;
117 G4UIcmdWithoutParameter *listsourceCmd;
118 G4UIcmdWithoutParameter *clearsourceCmd;
119 G4UIcmdWithoutParameter *getsourceCmd;
120 G4UIcmdWithAnInteger *setsourceCmd;
121 G4UIcmdWithADouble *setintensityCmd;
122 G4UIcmdWithAnInteger *deletesourceCmd;
123 G4UIcmdWithABool *multiplevertexCmd;
124 G4UIcmdWithABool *flatsamplingCmd;
125
126 // Positional commands
127 //
128 G4UIdirectory *positionDirectory;
129 G4UIcmdWithAString *typeCmd1;
130 G4UIcmdWithAString *shapeCmd1;
131 G4UIcmdWith3VectorAndUnit *centreCmd1;
132 G4UIcmdWith3Vector *posrot1Cmd1;
133 G4UIcmdWith3Vector *posrot2Cmd1;
134 G4UIcmdWithADoubleAndUnit *halfxCmd1;
135 G4UIcmdWithADoubleAndUnit *halfyCmd1;
136 G4UIcmdWithADoubleAndUnit *halfzCmd1;
137 G4UIcmdWithADoubleAndUnit *radiusCmd1;
138 G4UIcmdWithADoubleAndUnit *radius0Cmd1;
139 G4UIcmdWithADoubleAndUnit *possigmarCmd1;
140 G4UIcmdWithADoubleAndUnit *possigmaxCmd1;
141 G4UIcmdWithADoubleAndUnit *possigmayCmd1;
142 G4UIcmdWithADoubleAndUnit *paralpCmd1;
143 G4UIcmdWithADoubleAndUnit *partheCmd1;
144 G4UIcmdWithADoubleAndUnit *parphiCmd1;
145 G4UIcmdWithAString *confineCmd1;
146
147 // Angular commands
148 //
149 G4UIdirectory* angularDirectory;
150 G4UIcmdWithAString *angtypeCmd1;
151 G4UIcmdWith3Vector *angrot1Cmd1;
152 G4UIcmdWith3Vector *angrot2Cmd1;
153 G4UIcmdWithADoubleAndUnit *minthetaCmd1;
154 G4UIcmdWithADoubleAndUnit *maxthetaCmd1;
155 G4UIcmdWithADoubleAndUnit *minphiCmd1;
156 G4UIcmdWithADoubleAndUnit *maxphiCmd1;
157 G4UIcmdWithADoubleAndUnit *angsigmarCmd1;
158 G4UIcmdWithADoubleAndUnit *angsigmaxCmd1;
159 G4UIcmdWithADoubleAndUnit *angsigmayCmd1;
160 G4UIcmdWith3VectorAndUnit *angfocusCmd;
161 G4UIcmdWithABool *useuserangaxisCmd1;
162 G4UIcmdWithABool *surfnormCmd1;
163
164 // Energy commands
165 //
166 G4UIdirectory* energyDirectory;
167 G4UIcmdWithAString *energytypeCmd1;
170 G4UIcmdWithADoubleAndUnit *monoenergyCmd1;
171 G4UIcmdWithADoubleAndUnit *engsigmaCmd1;
172 G4UIcmdWithADouble *alphaCmd1;
173 G4UIcmdWithADouble *tempCmd1;
174 G4UIcmdWithADouble *ezeroCmd1;
175 G4UIcmdWithADouble *gradientCmd1;
176 G4UIcmdWithADouble *interceptCmd1;
177 G4UIcmdWithADouble *arbeintCmd1;
178 G4UIcmdWithoutParameter *calculateCmd1;
179 G4UIcmdWithABool *energyspecCmd1;
180 G4UIcmdWithABool *diffspecCmd1;
181 G4UIcmdWithABool *applyEnergyWeightCmd1;
182
183 // Histogram commands
184 //
185 G4UIdirectory *histDirectory;
186 G4UIcmdWith3Vector *histpointCmd1;
187 G4UIcmdWithAString *histfileCmd1;
188 G4UIcmdWithAString *histnameCmd1;
189 G4UIcmdWithAString *arbintCmd1;
190 G4UIcmdWithAString *resethistCmd1;
191
192 G4UIcmdWithAnInteger* verbosityCmd;
193
194 // Commands from G4ParticleGun
195 //
196 G4UIcommand* ionCmd;
197 G4UIcommand* ionLvlCmd;
198 G4UIcmdWithAString* particleCmd;
200 G4UIcmdWith3Vector* polCmd;
201 G4UIcmdWithAnInteger* numberCmd;
202 G4UIcmdWith3VectorAndUnit* positionCmd;
203 G4UIcmdWith3Vector* directionCmd;
204 G4UIcmdWithADoubleAndUnit* energyCmd;
206
207 // For ion shooting
208 //
209 G4bool fShootIon = false;
210
211 G4int fAtomicNumber = 0;
212 G4int fAtomicMass = 0;
213 G4int fIonCharge = 0;
214 G4double fIonExciteEnergy = 0.0;
215
216 G4int fAtomicNumberL = 0;
217 G4int fAtomicMassL = 0;
218 G4int fIonChargeL = 0;
219 G4int fIonEnergyLevel = 0;
220
221/** Andrea Dotti Feb 2015
222 * GPS messenger design requires some explanation for what distributions
223 * parameters are concerned : Each thread has its own GPS
224 * since primary generation is a user action.
225 * However to save memory the underlying structures that provide the
226 * GPS functionalities ( the G4SPS*Distribution classes and the
227 * G4SPSRandomGenerator class)
228 * are shared among threads. This implies that modifying parameters of sources
229 * requires some attention:
230 * 1- Only one thread should change source parameters.
231 * 2- Changing of parameters can happen only between runs, when is guaranteed
232 * that no thread is accessing them
233 * 2- UI commands require that even if messenger is instantiated in a thread
234 * the commands are executed in the master (this is possible since V10.1)
235 * The simplest solution is to use UI commands to change GPS parameters and
236 * avoid C++ APIs. If this is inevitable a simple solution is to instantiate
237 * an instance of G4GeneralParticleSource explicitly in the master thread
238 * (for example in G4VUserActionInitialization::BuildForMaster() and set the
239 * defaults parameter there).
240 */
241
242};
243
244#endif
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
static G4GeneralParticleSourceMessenger * GetInstance(G4GeneralParticleSource *)
void SetNewValue(G4UIcommand *command, G4String newValues) override
G4String GetCurrentValue(G4UIcommand *command) override
void SetParticleGun(G4SingleParticleSource *fpg)