Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ParticlePropertyMessenger Class Reference

#include <G4ParticlePropertyMessenger.hh>

+ Inheritance diagram for G4ParticlePropertyMessenger:

Public Member Functions

 G4ParticlePropertyMessenger (G4ParticleTable *pTable=nullptr)
 
virtual ~G4ParticlePropertyMessenger ()
 
 G4ParticlePropertyMessenger (const G4ParticlePropertyMessenger &)=delete
 
G4ParticlePropertyMessengeroperator= (const G4ParticlePropertyMessenger &)=delete
 
virtual void SetNewValue (G4UIcommand *command, G4String newValues)
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()=default
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4bool CommandsShouldBeInMaster () const
 

Additional Inherited Members

- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (const G4String &s)
 
G4long StoL (const G4String &s)
 
G4double StoD (const G4String &s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

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)
51 theParticleTable = G4ParticleTable::GetParticleTable();
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);
74 lifetimeCmd->SetDefaultValue(0.0);
75 lifetimeCmd->SetRange("life >0.0");
76 //lifetimeCmd->SetUnitCategory("Time");
77 //lifetimeCmd->SetUnitCandidates("s ms ns");
78 lifetimeCmd->SetDefaultUnit("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);
88 verboseCmd->SetDefaultValue(0);
89 verboseCmd->SetRange("verbose_level >=0");
90
91 // UI messenger for Decay Table
92 fDecayTableMessenger = new G4DecayTableMessenger(theParticleTable);
93}
@ G4State_Idle
@ G4State_GeomClosed
@ G4State_PreInit
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:157
void SetRange(const char *rs)
Definition: G4UIcommand.hh:121
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:287

◆ ~G4ParticlePropertyMessenger()

G4ParticlePropertyMessenger::~G4ParticlePropertyMessenger ( )
virtual

Definition at line 95 of file G4ParticlePropertyMessenger.cc.

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

◆ G4ParticlePropertyMessenger() [2/2]

G4ParticlePropertyMessenger::G4ParticlePropertyMessenger ( const G4ParticlePropertyMessenger )
delete

Member Function Documentation

◆ 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
159 const G4ParticleDefinition* currentParticle = theParticleTable->GetSelectedParticle();
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:446

◆ operator=()

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

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 107 of file G4ParticlePropertyMessenger.cc.

109{
110 G4ParticleDefinition* currentParticle
111 = const_cast<G4ParticleDefinition*>(theParticleTable->GetSelectedParticle());
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}
#define G4endl
Definition: G4ios.hh:57
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)

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