Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4MoleculeGunMessenger.cc
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/*
27 * MoleculeGunMessenger.cc
28 *
29 * Created on: 30 janv. 2014
30 * Author: kara
31 */
32
34#include "G4MoleculeGun.hh"
35
36#include "G4Tokenizer.hh"
37
38#include "G4UIdirectory.hh"
39#include "G4UIcmdWithAString.hh"
40#include "G4UIcmdWithAString.hh"
44#include "G4UIdirectory.hh"
45
46//------------------------------------------------------------------------------
47
49 G4UImessenger("/chem/gun/", "")
50{
51 fpGunNewGunType = new G4UIcmdWithAString("/chem/gun/newShoot",
52 this);
53 fpMoleculeGun = gun;
54}
55
56//------------------------------------------------------------------------------
57
59{
61}
62
63//------------------------------------------------------------------------------
64
66{
67 return "";
68}
69
70//------------------------------------------------------------------------------
71
73 G4String newValue)
74{
75 if (command == fpGunNewGunType)
76 {
77 std::istringstream iss (newValue);
78
79 G4String shootName;
80 iss >> shootName;
81
82 G4String shootType;
83 iss >> shootType;
84
85 if(shootType == "" || shootType.empty())
86 {
87 CreateNewType<G4Track>(shootName);
88 }
89 else
90 {
91 CreateNewType<G4ContinuousMedium>(shootName);
92 }
93 }
94}
95
96//------------------------------------------------------------------------------
97
100 G4shared_ptr<G4MoleculeShoot>
101 shoot) :
102 G4UImessenger(), fpShoot(shoot)
103{
104 G4String dir("/chem/gun/");
105 dir += name;
106 CreateDirectory(dir, "");
107
108 G4String tmp = dir;
109 tmp += "/species";
110 fpGunSpecies = new G4UIcmdWithAString(tmp, this);
111
112 tmp = dir;
113 tmp += "/position";
115
116 tmp = dir;
117 tmp += "/time";
118 fpGunTime = new G4UIcmdWithADoubleAndUnit(tmp, this);
119
120 tmp = dir;
121 tmp += "/number";
122 fpGunN = new G4UIcmdWithAnInteger(tmp, this);
123
124 tmp = dir;
125 tmp += "/rndmPosition";
127
128 tmp = dir;
129 tmp += "/type";
130 fpGunType = new G4UIcmdWithAString(tmp, this);
131
132// fpShoot.reset(new TG4MoleculeShoot<G4Track>());
133}
134
135//------------------------------------------------------------------------------
136
138{
139 if (fpGunSpecies) delete fpGunSpecies;
140 if (fpGunPosition) delete fpGunPosition;
141 if (fpGunTime) delete fpGunTime;
142 if (fpGunN) delete fpGunN;
143}
144
145//------------------------------------------------------------------------------
146
148{
149 if (command == fpGunSpecies)
150 {
151 fpShoot->fMoleculeName = newValue;
152 }
153 else if (command == fpGunPosition)
154 {
155 fpShoot->fPosition = fpGunPosition->GetNew3VectorValue(newValue);
156 }
157 else if(command == fpGunRdnmPosition)
158 {
159 fpShoot->fBoxSize = new G4ThreeVector(fpGunRdnmPosition->GetNew3VectorValue(newValue));
160 }
161 else if (command == fpGunTime)
162 {
163 fpShoot->fTime = fpGunTime->GetNewDoubleValue(newValue);
164 }
165 else if (command == fpGunN)
166 {
167 fpShoot->fNumber = fpGunN->GetNewIntValue(newValue);
168 }
169 else if (command == fpGunType)
170 {
171 if(newValue == "CM")
172 {
173// G4cout << "**** Change type" << G4endl;
174// TG4MoleculeShoot<G4ContinuousMedium>* casted = static_cast<TG4MoleculeShoot<G4ContinuousMedium>*>(fpShoot.get());
175// fpShoot.reset(casted);
176 fpShoot = fpShoot.get()->ChangeType<G4ContinuousMedium>();
177 }
178 }
179}
180
181//------------------------------------------------------------------------------
182
184{
185 if (command == fpGunSpecies)
186 {
187 return fpShoot->fMoleculeName;
188 }
189 else if (command == fpGunPosition)
190 {
192 }
193 else if (command == fpGunRdnmPosition)
194 {
195 if(fpShoot->fBoxSize)
196 {
198 }
200 }
201 else if (command == fpGunTime)
202 {
204 }
205 else if (command == fpGunN)
206 {
207 return fpGunN->ConvertToString(fpShoot->fNumber);
208 }
209 return "";
210}
211
212//------------------------------------------------------------------------------
213
G4int G4ContinuousMedium
CLHEP::Hep3Vector G4ThreeVector
G4UIcmdWithAString * fpGunNewGunType
virtual G4String GetCurrentValue(G4UIcommand *command)
G4MoleculeGunMessenger(G4MoleculeGun *)
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
G4UIcmdWithAString * fpGunType
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
virtual G4String GetCurrentValue(G4UIcommand *command)
G4UIcmdWithADoubleAndUnit * fpGunTime
G4MoleculeShootMessenger(const G4String &name, G4MoleculeGunMessenger *, G4shared_ptr< G4MoleculeShoot >)
G4UIcmdWith3VectorAndUnit * fpGunRdnmPosition
G4UIcmdWith3VectorAndUnit * fpGunPosition
G4shared_ptr< G4MoleculeShoot > fpShoot
G4UIcmdWithAString * fpGunSpecies
G4UIcmdWithAnInteger * fpGunN
G4String ConvertToStringWithBestUnit(const G4ThreeVector &vec)
static G4ThreeVector GetNew3VectorValue(const char *paramString)
static G4double GetNewDoubleValue(const char *paramString)
G4String ConvertToStringWithBestUnit(G4double val)
static G4int GetNewIntValue(const char *paramString)
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:446
void CreateDirectory(const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)