Geant4 11.2.2
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
35#include "G4MoleculeGun.hh"
36#include "G4Tokenizer.hh"
39#include "G4UIcmdWithAString.hh"
41#include "G4UIdirectory.hh"
42
43//------------------------------------------------------------------------------
44
46 G4UImessenger("/chem/gun/", "")
47{
48 fpGunNewGunType = new G4UIcmdWithAString("/chem/gun/newShoot",
49 this);
50 fpMoleculeGun = gun;
51}
52
53//------------------------------------------------------------------------------
54
59
60//------------------------------------------------------------------------------
61
66
67//------------------------------------------------------------------------------
68
70 G4String newValue)
71{
72 if (command == fpGunNewGunType)
73 {
74 std::istringstream iss (newValue);
75
76 G4String shootName;
77 iss >> shootName;
78
79 G4String shootType;
80 iss >> shootType;
81
82 if(shootType.empty() || shootType.empty())
83 {
84 CreateNewType<G4Track>(shootName);
85 }
86 else
87 {
89 }
90 }
91}
92
93//------------------------------------------------------------------------------
94
98 shoot) :
99 fpShoot(shoot)
100{
101 G4String dir("/chem/gun/");
102 dir += name;
103 CreateDirectory(dir, "");
104
105 G4String tmp = dir;
106 tmp += "/species";
107 fpGunSpecies = new G4UIcmdWithAString(tmp, this);
108
109 tmp = dir;
110 tmp += "/position";
112
113 tmp = dir;
114 tmp += "/time";
115 fpGunTime = new G4UIcmdWithADoubleAndUnit(tmp, this);
116
117 tmp = dir;
118 tmp += "/number";
119 fpGunN = new G4UIcmdWithAnInteger(tmp, this);
120
121 tmp = dir;
122 tmp += "/rndmPosition";
124
125 tmp = dir;
126 tmp += "/type";
127 fpGunType = new G4UIcmdWithAString(tmp, this);
128
129// fpShoot.reset(new TG4MoleculeShoot<G4Track>());
130}
131
132//------------------------------------------------------------------------------
133
135{
136 delete fpGunSpecies;
137 delete fpGunPosition;
138 delete fpGunTime;
139 delete fpGunN;
140}
141
142//------------------------------------------------------------------------------
143
145{
146 if (command == fpGunSpecies)
147 {
148 fpShoot->fMoleculeName = newValue;
149 }
150 else if (command == fpGunPosition)
151 {
152 fpShoot->fPosition = fpGunPosition->GetNew3VectorValue(newValue);
153 }
154 else if(command == fpGunRdnmPosition)
155 {
156 fpShoot->fBoxSize = new G4ThreeVector(fpGunRdnmPosition->GetNew3VectorValue(newValue));
157 }
158 else if (command == fpGunTime)
159 {
160 fpShoot->fTime = fpGunTime->GetNewDoubleValue(newValue);
161 }
162 else if (command == fpGunN)
163 {
164 fpShoot->fNumber = fpGunN->GetNewIntValue(newValue);
165 }
166 else if (command == fpGunType)
167 {
168 if(newValue == "CM")
169 {
170// G4cout << "**** Change type" << G4endl;
171// TG4MoleculeShoot<G4ContinuousMedium>* casted = static_cast<TG4MoleculeShoot<G4ContinuousMedium>*>(fpShoot.get());
172// fpShoot.reset(casted);
173 fpShoot = fpShoot.get()->ChangeType<G4ContinuousMedium>();
174 }
175 }
176}
177
178//------------------------------------------------------------------------------
179
181{
182 if (command == fpGunSpecies)
183 {
184 return fpShoot->fMoleculeName;
185 }
186 if (command == fpGunPosition)
187 {
189 }
190 if (command == fpGunRdnmPosition)
191 {
192 if(fpShoot->fBoxSize != nullptr)
193 {
195 }
197 }
198 if (command == fpGunTime)
199 {
201 }
202 if (command == fpGunN)
203 {
204 return fpGunN->ConvertToString(fpShoot->fNumber);
205 }
206 return "";
207}
208
209//------------------------------------------------------------------------------
210
G4int G4ContinuousMedium
CLHEP::Hep3Vector G4ThreeVector
#define G4shared_ptr
Definition G4memory.hh:32
G4UIcmdWithAString * fpGunNewGunType
void SetNewValue(G4UIcommand *command, G4String newValue) override
G4String GetCurrentValue(G4UIcommand *command) override
G4MoleculeGunMessenger(G4MoleculeGun *)
G4MoleculeShootMessenger * CreateNewType(const G4String &name)
G4UIcmdWithADoubleAndUnit * fpGunTime
G4MoleculeShootMessenger(const G4String &name, G4MoleculeGunMessenger *, G4shared_ptr< G4MoleculeShoot >)
G4UIcmdWith3VectorAndUnit * fpGunRdnmPosition
G4UIcmdWith3VectorAndUnit * fpGunPosition
G4shared_ptr< G4MoleculeShoot > fpShoot
void SetNewValue(G4UIcommand *command, G4String newValue) override
G4UIcmdWithAString * fpGunSpecies
G4String GetCurrentValue(G4UIcommand *command) override
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)
void CreateDirectory(const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)