Geant4-11
Public Member Functions | Protected Member Functions | Protected Attributes
G4MoleculeShootMessenger Class Reference

#include <G4MoleculeGunMessenger.hh>

Inheritance diagram for G4MoleculeShootMessenger:
G4UImessenger

Public Member Functions

G4bool CommandsShouldBeInMaster () const
 
 G4MoleculeShootMessenger (const G4String &name, G4MoleculeGunMessenger *, G4shared_ptr< G4MoleculeShoot >)
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
G4shared_ptr< G4MoleculeShoot > & GetShoot ()
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4bool operator== (const G4UImessenger &messenger) const
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
virtual ~G4MoleculeShootMessenger ()
 

Protected Member Functions

void AddUIcommand (G4UIcommand *newCommand)
 
G4String BtoS (G4bool b)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
G4String DtoS (G4double a)
 
G4String ItoS (G4int i)
 
G4bool StoB (G4String s)
 
G4double StoD (G4String s)
 
G4int StoI (G4String s)
 
G4long StoL (G4String s)
 

Protected Attributes

G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 
G4UIcmdWithAnIntegerfpGunN
 
G4UIcmdWith3VectorAndUnitfpGunPosition
 
G4UIcmdWith3VectorAndUnitfpGunRdnmPosition
 
G4UIcmdWithAStringfpGunSpecies
 
G4UIcmdWithADoubleAndUnitfpGunTime
 
G4UIcmdWithAStringfpGunType
 
G4shared_ptr< G4MoleculeShootfpShoot
 

Detailed Description

Definition at line 64 of file G4MoleculeGunMessenger.hh.

Constructor & Destructor Documentation

◆ G4MoleculeShootMessenger()

G4MoleculeShootMessenger::G4MoleculeShootMessenger ( const G4String name,
G4MoleculeGunMessenger ,
G4shared_ptr< G4MoleculeShoot shoot 
)

Definition at line 98 of file G4MoleculeGunMessenger.cc.

101 :
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}
G4UIcmdWithAString * fpGunType
G4UIcmdWithADoubleAndUnit * fpGunTime
G4UIcmdWith3VectorAndUnit * fpGunRdnmPosition
G4UIcmdWith3VectorAndUnit * fpGunPosition
G4shared_ptr< G4MoleculeShoot > fpShoot
G4UIcmdWithAString * fpGunSpecies
G4UIcmdWithAnInteger * fpGunN
void CreateDirectory(const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
ThreeVector shoot(const G4int Ap, const G4int Af)
const char * name(G4int ptype)

References G4UImessenger::CreateDirectory(), fpGunN, fpGunPosition, fpGunRdnmPosition, fpGunSpecies, fpGunTime, fpGunType, and G4InuclParticleNames::name().

◆ ~G4MoleculeShootMessenger()

G4MoleculeShootMessenger::~G4MoleculeShootMessenger ( )
virtual

Definition at line 137 of file G4MoleculeGunMessenger.cc.

138{
139 if (fpGunSpecies) delete fpGunSpecies;
140 if (fpGunPosition) delete fpGunPosition;
141 if (fpGunTime) delete fpGunTime;
142 if (fpGunN) delete fpGunN;
143}

References fpGunN, fpGunPosition, fpGunSpecies, and fpGunTime.

Member Function Documentation

◆ AddUIcommand()

void G4UImessenger::AddUIcommand ( G4UIcommand newCommand)
protectedinherited

Definition at line 149 of file G4UImessenger.cc.

150{
151 G4cerr << "Warning : Old style definition of G4UIcommand <"
152 << newCommand->GetCommandPath() << ">." << G4endl;
153}
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
const G4String & GetCommandPath() const
Definition: G4UIcommand.hh:136

References G4cerr, G4endl, and G4UIcommand::GetCommandPath().

◆ BtoS()

G4String G4UImessenger::BtoS ( G4bool  b)
protectedinherited

Definition at line 98 of file G4UImessenger.cc.

99{
100 G4String vl = "0";
101 if(b)
102 vl = "true";
103 return vl;
104}

◆ CommandsShouldBeInMaster()

G4bool G4UImessenger::CommandsShouldBeInMaster ( ) const
inlineinherited

Definition at line 77 of file G4UImessenger.hh.

78 {
80 }
G4bool commandsShouldBeInMaster

References G4UImessenger::commandsShouldBeInMaster.

Referenced by G4UIcommand::G4UIcommandCommonConstructorCode().

◆ CreateCommand()

template<typename T >
T * G4UImessenger::CreateCommand ( const G4String cname,
const G4String dsc 
)
protectedinherited

Definition at line 110 of file G4UImessenger.hh.

111{
112 G4String path;
113 if(cname[0] != '/')
114 {
115 path = baseDirName + cname;
116 if(path[0] != '/')
117 path = "/" + path;
118 }
119
120 T* command = new T(path.c_str(), this);
121 command->SetGuidance(dsc.c_str());
122
123 return command;
124}
G4String baseDirName

References G4UImessenger::baseDirName.

◆ CreateDirectory()

void G4UImessenger::CreateDirectory ( const G4String path,
const G4String dsc,
G4bool  commandsToBeBroadcasted = true 
)
protectedinherited

Definition at line 156 of file G4UImessenger.cc.

158{
160
161 G4String fullpath = path;
162 if(fullpath.back() != '/')
163 fullpath.append("/");
164
165 G4UIcommandTree* tree = ui->GetTree()->FindCommandTree(fullpath.c_str());
166 if(tree != nullptr)
167 {
168 baseDirName = tree->GetPathName();
169 }
170 else
171 {
172 baseDir = new G4UIdirectory(fullpath.c_str(), commandsToBeBroadcasted);
173 baseDirName = fullpath;
174 baseDir->SetGuidance(dsc.c_str());
175 }
176}
const G4String & GetPathName() const
G4UIcommandTree * FindCommandTree(const char *commandPath)
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:186
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
G4UIdirectory * baseDir

References G4UImessenger::baseDir, G4UImessenger::baseDirName, G4UIcommandTree::FindCommandTree(), G4UIcommandTree::GetPathName(), G4UImanager::GetTree(), G4UImanager::GetUIpointer(), and G4UIcommand::SetGuidance().

Referenced by G4MoleculeShootMessenger(), and G4UImessenger::G4UImessenger().

◆ DtoS()

G4String G4UImessenger::DtoS ( G4double  a)
protectedinherited

Definition at line 90 of file G4UImessenger.cc.

91{
92 std::ostringstream os;
93 os << a;
94 return G4String(os.str());
95}

Referenced by G4ScoreQuantityMessenger::FilterCommands(), and G4UIcontrolMessenger::SetNewValue().

◆ GetCurrentValue()

G4String G4MoleculeShootMessenger::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 183 of file G4MoleculeGunMessenger.cc.

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}
CLHEP::Hep3Vector G4ThreeVector
G4String ConvertToStringWithBestUnit(G4ThreeVector vec)
G4String ConvertToStringWithBestUnit(G4double val)
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:445

References G4UIcommand::ConvertToString(), G4UIcmdWithADoubleAndUnit::ConvertToStringWithBestUnit(), G4UIcmdWith3VectorAndUnit::ConvertToStringWithBestUnit(), fpGunN, fpGunPosition, fpGunRdnmPosition, fpGunSpecies, fpGunTime, and fpShoot.

◆ GetShoot()

G4shared_ptr< G4MoleculeShoot > & G4MoleculeShootMessenger::GetShoot ( )
inline

Definition at line 74 of file G4MoleculeGunMessenger.hh.

74 {
75 return fpShoot;
76 }

References fpShoot.

◆ ItoS()

G4String G4UImessenger::ItoS ( G4int  i)
protectedinherited

Definition at line 82 of file G4UImessenger.cc.

83{
84 std::ostringstream os;
85 os << i;
86 return G4String(os.str());
87}

Referenced by G4GenericMessenger::DeclareMethod(), and G4ParticleGunMessenger::GetCurrentValue().

◆ operator!=()

G4bool G4UImessenger::operator!= ( const G4UImessenger messenger) const
inherited

Definition at line 76 of file G4UImessenger.cc.

77{
78 return this != &messenger;
79}

◆ operator==()

G4bool G4UImessenger::operator== ( const G4UImessenger messenger) const
inherited

Definition at line 70 of file G4UImessenger.cc.

71{
72 return this == &messenger;
73}

◆ SetNewValue()

void G4MoleculeShootMessenger::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 147 of file G4MoleculeGunMessenger.cc.

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}
int G4ContinuousMedium
static G4ThreeVector GetNew3VectorValue(const char *paramString)
static G4double GetNewDoubleValue(const char *paramString)
static G4int GetNewIntValue(const char *paramString)

References fpGunN, fpGunPosition, fpGunRdnmPosition, fpGunSpecies, fpGunTime, fpGunType, fpShoot, G4UIcmdWith3VectorAndUnit::GetNew3VectorValue(), G4UIcmdWithADoubleAndUnit::GetNewDoubleValue(), and G4UIcmdWithAnInteger::GetNewIntValue().

◆ StoB()

G4bool G4UImessenger::StoB ( G4String  s)
protectedinherited

Definition at line 137 of file G4UImessenger.cc.

138{
140 G4bool vl = false;
141 if(v == "Y" || v == "YES" || v == "1" || v == "T" || v == "TRUE")
142 {
143 vl = true;
144 }
145 return vl;
146}
bool G4bool
Definition: G4Types.hh:86
G4String to_upper_copy(G4String str)
Return uppercase copy of string.

References G4StrUtil::to_upper_copy().

Referenced by G4LocalThreadCoutMessenger::SetNewValue(), G4CascadeParamMessenger::SetNewValue(), G4ScoreQuantityMessenger::SetNewValue(), and G4ScoringMessenger::SetNewValue().

◆ StoD()

G4double G4UImessenger::StoD ( G4String  s)
protectedinherited

◆ StoI()

G4int G4UImessenger::StoI ( G4String  s)
protectedinherited

◆ StoL()

G4long G4UImessenger::StoL ( G4String  s)
protectedinherited

Definition at line 117 of file G4UImessenger.cc.

118{
119 G4long vl;
120 const char* t = str;
121 std::istringstream is(t);
122 is >> vl;
123 return vl;
124}
long G4long
Definition: G4Types.hh:87

Referenced by G4RunMessenger::SetNewValue().

Field Documentation

◆ baseDir

G4UIdirectory* G4UImessenger::baseDir = nullptr
protectedinherited

◆ baseDirName

G4String G4UImessenger::baseDirName = ""
protectedinherited

◆ commandsShouldBeInMaster

G4bool G4UImessenger::commandsShouldBeInMaster = false
protectedinherited

◆ fpGunN

G4UIcmdWithAnInteger* G4MoleculeShootMessenger::fpGunN
protected

◆ fpGunPosition

G4UIcmdWith3VectorAndUnit* G4MoleculeShootMessenger::fpGunPosition
protected

◆ fpGunRdnmPosition

G4UIcmdWith3VectorAndUnit* G4MoleculeShootMessenger::fpGunRdnmPosition
protected

◆ fpGunSpecies

G4UIcmdWithAString* G4MoleculeShootMessenger::fpGunSpecies
protected

◆ fpGunTime

G4UIcmdWithADoubleAndUnit* G4MoleculeShootMessenger::fpGunTime
protected

◆ fpGunType

G4UIcmdWithAString* G4MoleculeShootMessenger::fpGunType
protected

Definition at line 84 of file G4MoleculeGunMessenger.hh.

Referenced by G4MoleculeShootMessenger(), and SetNewValue().

◆ fpShoot

G4shared_ptr<G4MoleculeShoot> G4MoleculeShootMessenger::fpShoot
protected

Definition at line 85 of file G4MoleculeGunMessenger.hh.

Referenced by GetCurrentValue(), GetShoot(), and SetNewValue().


The documentation for this class was generated from the following files: