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

#include <G4ParticlePropertyMessenger.hh>

Inheritance diagram for G4ParticlePropertyMessenger:
G4UImessenger

Public Member Functions

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

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 Attributes

G4UIcmdWithoutParameterdumpCmd = nullptr
 
G4DecayTableMessengerfDecayTableMessenger = nullptr
 
G4UIcmdWithADoubleAndUnitlifetimeCmd = nullptr
 
G4UIcmdWithABoolstableCmd = nullptr
 
G4ParticleTabletheParticleTable = nullptr
 
G4UIdirectorythisDirectory = nullptr
 
G4UIcmdWithAnIntegerverboseCmd = nullptr
 

Detailed Description

Definition at line 58 of file G4ParticlePropertyMessenger.hh.

Constructor & Destructor Documentation

◆ G4ParticlePropertyMessenger() [1/2]

G4ParticlePropertyMessenger::G4ParticlePropertyMessenger ( G4ParticleTable pTable = nullptr)

Definition at line 46 of file G4ParticlePropertyMessenger.cc.

48 : theParticleTable(pTable)
49{
50 if ( theParticleTable == nullptr)
52
53 // Command /particle/property/
54 thisDirectory = new G4UIdirectory("/particle/property/");
55 thisDirectory->SetGuidance("Particle Table control commands.");
56
57 // Command /particle/property/dump
58 dumpCmd = new G4UIcmdWithoutParameter("/particle/property/dump",this);
59 dumpCmd->SetGuidance("Dump particle properties.");
60
61 // Command /particle/property/stable
62 stableCmd = new G4UIcmdWithABool("/particle/property/stable",this);
63 stableCmd->SetGuidance("Set stable flag.");
64 stableCmd->SetGuidance(" false: Unstable true: Stable");
65 stableCmd->SetParameterName("stable",false);
67
68 // Command /particle/property/lifetime
69 lifetimeCmd = new G4UIcmdWithADoubleAndUnit("/particle/property/lifetime",this);
70 lifetimeCmd->SetGuidance("Set life time.");
71 lifetimeCmd->SetGuidance("Unit of the time can be :");
72 lifetimeCmd->SetGuidance(" s, ms, ns (default)");
73 lifetimeCmd->SetParameterName("life",false);
75 lifetimeCmd->SetRange("life >0.0");
76 //lifetimeCmd->SetUnitCategory("Time");
77 //lifetimeCmd->SetUnitCandidates("s ms ns");
80
81 // -- particle/property/Verbose ---
82 verboseCmd = new G4UIcmdWithAnInteger("/particle/property/verbose",this);
83 verboseCmd->SetGuidance("Set Verbose level of particle property.");
84 verboseCmd->SetGuidance(" 0 : Silent (default)");
85 verboseCmd->SetGuidance(" 1 : Display warning messages");
86 verboseCmd->SetGuidance(" 2 : Display more");
87 verboseCmd->SetParameterName("verbose_level",true);
89 verboseCmd->SetRange("verbose_level >=0");
90
91 // UI messenger for Decay Table
93}
@ G4State_Idle
@ G4State_GeomClosed
@ G4State_PreInit
G4UIcmdWithADoubleAndUnit * lifetimeCmd
G4DecayTableMessenger * fDecayTableMessenger
static G4ParticleTable * GetParticleTable()
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultUnit(const char *defUnit)
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
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:288

References G4UIcommand::AvailableForStates(), dumpCmd, fDecayTableMessenger, G4State_GeomClosed, G4State_Idle, G4State_PreInit, G4ParticleTable::GetParticleTable(), lifetimeCmd, G4UIcmdWithADoubleAndUnit::SetDefaultUnit(), G4UIcmdWithADoubleAndUnit::SetDefaultValue(), G4UIcmdWithAnInteger::SetDefaultValue(), G4UIcommand::SetGuidance(), G4UIcmdWithABool::SetParameterName(), G4UIcmdWithADoubleAndUnit::SetParameterName(), G4UIcmdWithAnInteger::SetParameterName(), G4UIcommand::SetRange(), stableCmd, theParticleTable, thisDirectory, and verboseCmd.

◆ ~G4ParticlePropertyMessenger()

G4ParticlePropertyMessenger::~G4ParticlePropertyMessenger ( )
virtual

Definition at line 95 of file G4ParticlePropertyMessenger.cc.

96{
98 fDecayTableMessenger = nullptr;
99
100 delete stableCmd;
101 delete verboseCmd;
102 delete lifetimeCmd;
103 delete dumpCmd;
104 delete thisDirectory;
105}

References dumpCmd, fDecayTableMessenger, lifetimeCmd, stableCmd, thisDirectory, and verboseCmd.

◆ G4ParticlePropertyMessenger() [2/2]

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

Reimplemented from G4UImessenger.

Definition at line 155 of file G4ParticlePropertyMessenger.cc.

156{
157 G4String returnValue(1,'\0');
158
160 if ( currentParticle == nullptr )
161 {
162 return returnValue; // no particle is selected. return null
163 }
164
165 if( command == stableCmd )
166 {
167 // Command /particle/property/stable
168 returnValue = stableCmd->ConvertToString( currentParticle->GetPDGStable());
169 }
170 else if( command == lifetimeCmd )
171 {
172 // Command /particle/property/lifetime
173 returnValue = lifetimeCmd->ConvertToString( currentParticle->GetPDGLifeTime(), "ns" );
174 }
175 else if( command==verboseCmd )
176 {
177 // Command /particle/property/Verbose
178 returnValue= verboseCmd->ConvertToString(currentParticle->GetVerboseLevel());
179 }
180
181 return returnValue;
182}
G4bool GetPDGStable() const
G4int GetVerboseLevel() const
G4double GetPDGLifeTime() const
const G4ParticleDefinition * GetSelectedParticle() const
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:445

References G4UIcommand::ConvertToString(), G4ParticleDefinition::GetPDGLifeTime(), G4ParticleDefinition::GetPDGStable(), G4ParticleTable::GetSelectedParticle(), G4ParticleDefinition::GetVerboseLevel(), lifetimeCmd, stableCmd, theParticleTable, and verboseCmd.

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

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

◆ 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 G4ParticlePropertyMessenger::SetNewValue ( G4UIcommand command,
G4String  newValues 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 107 of file G4ParticlePropertyMessenger.cc.

109{
110 G4ParticleDefinition* currentParticle
112
113 if (currentParticle == nullptr)
114 {
115 G4cout << "Particle is not selected yet !! Command ignored." << G4endl;
116 return;
117 }
118
119 if( command == dumpCmd )
120 {
121 // Command /particle/property/dump
122 currentParticle->DumpTable();
123
124 }
125 else if (command == lifetimeCmd )
126 {
127 // Command /particle/property/lifetime
128 currentParticle->SetPDGLifeTime(lifetimeCmd->GetNewDoubleValue(newValue));
129
130 }
131 else if (command == stableCmd )
132 {
133 // Command /particle/property/stable
134 if (currentParticle->GetPDGLifeTime()<0.0)
135 {
136 G4cout << "Life time is negative! Command ignored." << G4endl;
137 }
138 else if (currentParticle->GetPDGMass()<=0.0)
139 {
140 G4cout << "Zero Mass! Command ignored." << G4endl;
141 }
142 else
143 {
144 currentParticle->SetPDGStable(stableCmd->GetNewBoolValue(newValue));
145 }
146
147 }
148 else if( command==verboseCmd )
149 {
150 // Command /particle/property/Verbose
151 currentParticle->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue));
152 }
153}
G4GLOB_DLL std::ostream G4cout
void SetPDGStable(const G4bool aFlag)
void SetVerboseLevel(G4int value)
void SetPDGLifeTime(G4double aLifeTime)
static G4bool GetNewBoolValue(const char *paramString)
static G4double GetNewDoubleValue(const char *paramString)
static G4int GetNewIntValue(const char *paramString)

References dumpCmd, G4ParticleDefinition::DumpTable(), G4cout, G4endl, G4UIcmdWithABool::GetNewBoolValue(), G4UIcmdWithADoubleAndUnit::GetNewDoubleValue(), G4UIcmdWithAnInteger::GetNewIntValue(), G4ParticleDefinition::GetPDGLifeTime(), G4ParticleDefinition::GetPDGMass(), G4ParticleTable::GetSelectedParticle(), lifetimeCmd, G4ParticleDefinition::SetPDGLifeTime(), G4ParticleDefinition::SetPDGStable(), G4ParticleDefinition::SetVerboseLevel(), stableCmd, theParticleTable, and verboseCmd.

◆ 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

◆ dumpCmd

G4UIcmdWithoutParameter* G4ParticlePropertyMessenger::dumpCmd = nullptr
private

◆ fDecayTableMessenger

G4DecayTableMessenger* G4ParticlePropertyMessenger::fDecayTableMessenger = nullptr
private

◆ lifetimeCmd

G4UIcmdWithADoubleAndUnit* G4ParticlePropertyMessenger::lifetimeCmd = nullptr
private

◆ stableCmd

G4UIcmdWithABool* G4ParticlePropertyMessenger::stableCmd = nullptr
private

◆ theParticleTable

G4ParticleTable* G4ParticlePropertyMessenger::theParticleTable = nullptr
private

◆ thisDirectory

G4UIdirectory* G4ParticlePropertyMessenger::thisDirectory = nullptr
private

◆ verboseCmd

G4UIcmdWithAnInteger* G4ParticlePropertyMessenger::verboseCmd = nullptr
private

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