ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
G4MoleculeGunMessenger.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4MoleculeGunMessenger.cc
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
33
#include "
G4MoleculeGunMessenger.hh
"
34
#include "
G4MoleculeGun.hh
"
35
36
#include "
G4Tokenizer.hh
"
37
38
#include "
G4UIdirectory.hh
"
39
#include "
G4UIcmdWithAString.hh
"
40
#include "
G4UIcmdWithAString.hh
"
41
#include "
G4UIcmdWith3VectorAndUnit.hh
"
42
#include "
G4UIcmdWithADoubleAndUnit.hh
"
43
#include "
G4UIcmdWithAnInteger.hh
"
44
#include "
G4UIdirectory.hh
"
45
46
//------------------------------------------------------------------------------
47
48
G4MoleculeGunMessenger::G4MoleculeGunMessenger
(
G4MoleculeGun
* gun) :
49
G4UImessenger
(
"/chem/gun/"
,
""
)
50
{
51
fpGunNewGunType
=
new
G4UIcmdWithAString
(
"/chem/gun/newShoot"
,
52
this
);
53
fpMoleculeGun
= gun;
54
}
55
56
//------------------------------------------------------------------------------
57
58
G4MoleculeGunMessenger::~G4MoleculeGunMessenger
()
59
{
60
if
(
fpGunNewGunType
)
delete
fpGunNewGunType
;
61
}
62
63
//------------------------------------------------------------------------------
64
65
G4String
G4MoleculeGunMessenger::GetCurrentValue
(
G4UIcommand
*
/*command*/
)
66
{
67
return
""
;
68
}
69
70
//------------------------------------------------------------------------------
71
72
void
G4MoleculeGunMessenger::SetNewValue
(
G4UIcommand
* command,
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
98
G4MoleculeShootMessenger::G4MoleculeShootMessenger
(
const
G4String
&
name
,
99
G4MoleculeGunMessenger
*,
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"
;
114
fpGunPosition
=
new
G4UIcmdWith3VectorAndUnit
(tmp,
this
);
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"
;
126
fpGunRdnmPosition
=
new
G4UIcmdWith3VectorAndUnit
(tmp,
this
);
127
128
tmp =
dir
;
129
tmp +=
"/type"
;
130
fpGunType
=
new
G4UIcmdWithAString
(tmp,
this
);
131
132
// fpShoot.reset(new TG4MoleculeShoot<G4Track>());
133
}
134
135
//------------------------------------------------------------------------------
136
137
G4MoleculeShootMessenger::~G4MoleculeShootMessenger
()
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
147
void
G4MoleculeShootMessenger::SetNewValue
(
G4UIcommand
* command,
G4String
newValue)
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 = reinterpret_cast<TG4MoleculeShoot<G4ContinuousMedium>*>(fpShoot.get());
175
// fpShoot.reset(casted);
176
fpShoot
=
fpShoot
.get()->ChangeType<
G4ContinuousMedium
>();
177
}
178
}
179
}
180
181
//------------------------------------------------------------------------------
182
183
G4String
G4MoleculeShootMessenger::GetCurrentValue
(
G4UIcommand
* command)
184
{
185
if
(command ==
fpGunSpecies
)
186
{
187
return
fpShoot
->fMoleculeName;
188
}
189
else
if
(command ==
fpGunPosition
)
190
{
191
return
fpGunPosition
->
ConvertToStringWithBestUnit
(
fpShoot
->fPosition);
192
}
193
else
if
(command ==
fpGunRdnmPosition
)
194
{
195
if
(
fpShoot
->fBoxSize)
196
{
197
return
fpGunRdnmPosition
->
ConvertToStringWithBestUnit
(*
fpShoot
->fBoxSize);
198
}
199
return
fpGunRdnmPosition
->
ConvertToStringWithBestUnit
(
G4ThreeVector
());
200
}
201
else
if
(command ==
fpGunTime
)
202
{
203
return
fpGunTime
->
ConvertToStringWithBestUnit
(
fpShoot
->fTime);
204
}
205
else
if
(command ==
fpGunN
)
206
{
207
return
fpGunN
->
ConvertToString
(
fpShoot
->fNumber);
208
}
209
return
""
;
210
}
211
212
//------------------------------------------------------------------------------
213
geant4
tree
geant4-10.6-release
source
processes
electromagnetic
dna
utils
src
G4MoleculeGunMessenger.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:30
using
1.8.2 with
ECCE GitHub integration