Geant4-11
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
G4DecayTableMessenger Class Reference

#include <G4DecayTableMessenger.hh>

Inheritance diagram for G4DecayTableMessenger:
G4UImessenger

Public Member Functions

G4bool CommandsShouldBeInMaster () const
 
 G4DecayTableMessenger (const G4DecayTableMessenger &)=delete
 
 G4DecayTableMessenger (G4ParticleTable *pTable=nullptr)
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4DecayTableMessengeroperator= (const G4DecayTableMessenger &)=delete
 
G4bool operator== (const G4UImessenger &messenger) const
 
virtual void SetNewValue (G4UIcommand *command, G4String newValues)
 
virtual ~G4DecayTableMessenger ()
 

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
 

Private Member Functions

G4ParticleDefinitionSetCurrentParticle ()
 

Private Attributes

G4UIcmdWithADoublebrCmd = nullptr
 
G4VDecayChannelcurrentChannel = nullptr
 
G4DecayTablecurrentDecayTable = nullptr
 
G4ParticleDefinitioncurrentParticle = nullptr
 
G4UIcmdWithoutParameterdumpCmd = nullptr
 
G4int idxCurrentChannel = -1
 
G4UIcmdWithAnIntegerselectCmd = nullptr
 
G4ParticleTabletheParticleTable = nullptr
 
G4UIdirectorythisDirectory = nullptr
 

Detailed Description

Definition at line 57 of file G4DecayTableMessenger.hh.

Constructor & Destructor Documentation

◆ G4DecayTableMessenger() [1/2]

G4DecayTableMessenger::G4DecayTableMessenger ( G4ParticleTable pTable = nullptr)

Definition at line 44 of file G4DecayTableMessenger.cc.

45 : theParticleTable(pTable)
46{
47 if ( theParticleTable == nullptr )
48 {
50 }
51 currentParticle = nullptr;
52
53 // Command /particle/property/decay/
54 thisDirectory = new G4UIdirectory("/particle/property/decay/");
55 thisDirectory->SetGuidance("Decay Table control commands.");
56
57 // Command /particle/property/decay/select
58 selectCmd = new G4UIcmdWithAnInteger("/particle/property/decay/select",this);
59 selectCmd->SetGuidance("Enter index of decay mode.");
60 selectCmd->SetParameterName("mode", true);
62 selectCmd->SetRange("mode >=0");
63 currentChannel = nullptr;
64
65 // Command /particle/property/decay/dump
66 dumpCmd = new G4UIcmdWithoutParameter("/particle/property/decay/dump",this);
67 dumpCmd->SetGuidance("Dump decay mode information.");
68
69 // Command /particle/property/decay/br
70 brCmd = new G4UIcmdWithADouble("/particle/property/decay/br",this);
71 brCmd->SetGuidance("Set branching ratio. [0< BR <1.0]");
72 brCmd->SetParameterName("br",false);
73 brCmd->SetRange("(br >=0.0) && (br <=1.0)");
74}
G4VDecayChannel * currentChannel
G4ParticleTable * theParticleTable
G4UIcmdWithADouble * brCmd
G4UIcmdWithoutParameter * dumpCmd
G4UIcmdWithAnInteger * selectCmd
G4ParticleDefinition * currentParticle
static G4ParticleTable * GetParticleTable()
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4int defVal)
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
void SetRange(const char *rs)
Definition: G4UIcommand.hh:120

References brCmd, currentChannel, currentParticle, dumpCmd, G4ParticleTable::GetParticleTable(), selectCmd, G4UIcmdWithAnInteger::SetDefaultValue(), G4UIcommand::SetGuidance(), G4UIcmdWithADouble::SetParameterName(), G4UIcmdWithAnInteger::SetParameterName(), G4UIcommand::SetRange(), theParticleTable, and thisDirectory.

◆ ~G4DecayTableMessenger()

G4DecayTableMessenger::~G4DecayTableMessenger ( )
virtual

Definition at line 76 of file G4DecayTableMessenger.cc.

77{
78 if (dumpCmd != nullptr) delete dumpCmd;
79 if (selectCmd != nullptr) delete selectCmd;
80 if (brCmd != nullptr) delete brCmd;
81 if (thisDirectory != nullptr) delete thisDirectory;
82}

References brCmd, dumpCmd, selectCmd, and thisDirectory.

◆ G4DecayTableMessenger() [2/2]

G4DecayTableMessenger::G4DecayTableMessenger ( const G4DecayTableMessenger )
delete

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)
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::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 G4DecayTableMessenger::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 190 of file G4DecayTableMessenger.cc.

191{
192 G4String returnValue(1,'\0');
193
194 if (SetCurrentParticle() == nullptr)
195 {
196 // no particle is selected. return null
197 return returnValue;
198 }
199
200 if( command == selectCmd )
201 {
202 // Command /particle/property/decay/select
204
205 }
206 else if( command == brCmd )
207 {
208 if ( currentChannel != nullptr)
209 {
210 returnValue = brCmd->ConvertToString(currentChannel->GetBR());
211 }
212 }
213 return returnValue;
214}
G4ParticleDefinition * SetCurrentParticle()
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:445
G4double GetBR() const

References brCmd, G4UIcommand::ConvertToString(), currentChannel, G4VDecayChannel::GetBR(), idxCurrentChannel, selectCmd, and SetCurrentParticle().

◆ 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=()

G4DecayTableMessenger & G4DecayTableMessenger::operator= ( const G4DecayTableMessenger )
delete

◆ operator==()

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

Definition at line 70 of file G4UImessenger.cc.

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

◆ SetCurrentParticle()

G4ParticleDefinition * G4DecayTableMessenger::SetCurrentParticle ( )
private

Definition at line 142 of file G4DecayTableMessenger.cc.

143{
144 // set currentParticle pointer
145 // get particle name by asking G4ParticleMessenger via UImanager
146
147 G4String particleName
148 = G4UImanager::GetUIpointer()->GetCurrentStringValue("/particle/select");
149
150 if (currentParticle != nullptr )
151 {
152 // check whether selection is changed
153 if (currentParticle->GetParticleName() != particleName)
154 {
157 currentDecayTable = nullptr;
158 }
159 else
160 {
161 // no change
162 return currentParticle;
163 }
164
165 }
166 else
167 {
170 currentDecayTable = nullptr;
171 }
172
173 if (currentParticle != nullptr )
174 {
176 if ( (currentDecayTable != nullptr ) && (idxCurrentChannel >0) )
177 {
179 }
180 else
181 {
183 currentChannel = nullptr;
184 }
185 }
186
187 return currentParticle;
188}
G4VDecayChannel * GetDecayChannel(G4int index) const
G4DecayTable * GetDecayTable() const
const G4String & GetParticleName() const
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
G4String GetCurrentStringValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:177

References currentChannel, currentDecayTable, currentParticle, G4ParticleTable::FindParticle(), G4UImanager::GetCurrentStringValue(), G4DecayTable::GetDecayChannel(), G4ParticleDefinition::GetDecayTable(), G4ParticleDefinition::GetParticleName(), G4UImanager::GetUIpointer(), idxCurrentChannel, and theParticleTable.

Referenced by GetCurrentValue(), and SetNewValue().

◆ SetNewValue()

void G4DecayTableMessenger::SetNewValue ( G4UIcommand command,
G4String  newValues 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 84 of file G4DecayTableMessenger.cc.

85{
86 if (SetCurrentParticle()== nullptr)
87 {
88 G4cout << "Particle is not selected yet !! Command ignored." << G4endl;
89 return;
90 }
91 if (currentDecayTable== nullptr)
92 {
93 G4cout << "The particle has no decay table !! Command ignored." << G4endl;
94 return;
95 }
96
97 if( command == dumpCmd )
98 {
99 // Command /particle/property/decay/dump
101
102 }
103 else if ( command == selectCmd )
104 {
105 // Command /particle/property/decay/select
106 G4int index = selectCmd->GetNewIntValue(newValue) ;
108 if ( currentChannel == nullptr )
109 {
110 G4cout << "Invalid index. Command ignored." << G4endl;
111 }
112 else
113 {
114 idxCurrentChannel = index;
115 }
116
117 }
118 else
119 {
120 if ( currentChannel == nullptr )
121 {
122 G4cout << "Select a decay channel. Command ignored." << G4endl;
123 return;
124 }
125 if (command == brCmd)
126 {
127 // Command /particle/property/decay/br
128 G4double br = brCmd->GetNewDoubleValue(newValue);
129 if( (br<0.0) || (br>1.0) )
130 {
131 G4cout << "Invalid brancing ratio. Command ignored." << G4endl;
132 }
133 else
134 {
136 }
137 }
138 }
139}
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cout
void DumpInfo() const
static G4double GetNewDoubleValue(const char *paramString)
static G4int GetNewIntValue(const char *paramString)
void SetBR(G4double value)

References brCmd, currentChannel, currentDecayTable, dumpCmd, G4DecayTable::DumpInfo(), G4cout, G4endl, G4DecayTable::GetDecayChannel(), G4UIcmdWithADouble::GetNewDoubleValue(), G4UIcmdWithAnInteger::GetNewIntValue(), idxCurrentChannel, selectCmd, G4VDecayChannel::SetBR(), and SetCurrentParticle().

◆ 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

◆ brCmd

G4UIcmdWithADouble* G4DecayTableMessenger::brCmd = nullptr
private

◆ commandsShouldBeInMaster

G4bool G4UImessenger::commandsShouldBeInMaster = false
protectedinherited

◆ currentChannel

G4VDecayChannel* G4DecayTableMessenger::currentChannel = nullptr
private

◆ currentDecayTable

G4DecayTable* G4DecayTableMessenger::currentDecayTable = nullptr
private

Definition at line 76 of file G4DecayTableMessenger.hh.

Referenced by SetCurrentParticle(), and SetNewValue().

◆ currentParticle

G4ParticleDefinition* G4DecayTableMessenger::currentParticle = nullptr
private

Definition at line 75 of file G4DecayTableMessenger.hh.

Referenced by G4DecayTableMessenger(), and SetCurrentParticle().

◆ dumpCmd

G4UIcmdWithoutParameter* G4DecayTableMessenger::dumpCmd = nullptr
private

◆ idxCurrentChannel

G4int G4DecayTableMessenger::idxCurrentChannel = -1
private

Definition at line 84 of file G4DecayTableMessenger.hh.

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

◆ selectCmd

G4UIcmdWithAnInteger* G4DecayTableMessenger::selectCmd = nullptr
private

◆ theParticleTable

G4ParticleTable* G4DecayTableMessenger::theParticleTable = nullptr
private

Definition at line 74 of file G4DecayTableMessenger.hh.

Referenced by G4DecayTableMessenger(), and SetCurrentParticle().

◆ thisDirectory

G4UIdirectory* G4DecayTableMessenger::thisDirectory = nullptr
private

Definition at line 79 of file G4DecayTableMessenger.hh.

Referenced by G4DecayTableMessenger(), and ~G4DecayTableMessenger().


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