Geant4 10.7.0
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 ()
 
 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 (G4String s)
 
G4long StoL (G4String s)
 
G4double StoD (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:156
void SetRange(const char *rs)
Definition: G4UIcommand.hh:120
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:273

◆ ~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 176 of file G4ParticlePropertyMessenger.cc.

177{
178 G4String returnValue('\0');
179
180 if ( SetCurrentParticle() == nullptr )
181 {
182 return returnValue; // no particle is selected. return null
183 }
184
185 if( command == stableCmd )
186 {
187 // Command /particle/property/stable
188 returnValue = stableCmd->ConvertToString( currentParticle->GetPDGStable());
189 }
190 else if( command == lifetimeCmd )
191 {
192 // Command /particle/property/lifetime
193 returnValue = lifetimeCmd->ConvertToString( currentParticle->GetPDGLifeTime(), "ns" );
194 }
195 else if( command==verboseCmd )
196 {
197 // Command /particle/property/Verbose
198 returnValue= verboseCmd->ConvertToString(currentParticle->GetVerboseLevel());
199 }
200
201 return returnValue;
202}
G4bool GetPDGStable() const
G4int GetVerboseLevel() const
G4double GetPDGLifeTime() const
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:430

◆ 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 if (SetCurrentParticle() == nullptr)
111 {
112 G4cout << "Particle is not selected yet !! Command ignored." << G4endl;
113 return;
114 }
115
116 if( command == dumpCmd )
117 {
118 // Command /particle/property/dump
119 currentParticle->DumpTable();
120
121 }
122 else if (command == lifetimeCmd )
123 {
124 // Command /particle/property/lifetime
125 currentParticle->SetPDGLifeTime(lifetimeCmd->GetNewDoubleValue(newValue));
126
127 }
128 else if (command == stableCmd )
129 {
130 // Command /particle/property/stable
131 if (currentParticle->GetPDGLifeTime()<0.0)
132 {
133 G4cout << "Life time is negative! Command ignored." << G4endl;
134 }
135 else if (currentParticle->GetPDGMass()<=0.0)
136 {
137 G4cout << "Zero Mass! Command ignored." << G4endl;
138 }
139 else
140 {
141 currentParticle->SetPDGStable(stableCmd->GetNewBoolValue(newValue));
142 }
143
144 }
145 else if( command==verboseCmd )
146 {
147 // Command /particle/property/Verbose
148 currentParticle->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue));
149 }
150}
#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: