Geant4 11.4.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)
 ~G4ParticlePropertyMessenger () override
 G4ParticlePropertyMessenger (const G4ParticlePropertyMessenger &)=delete
G4ParticlePropertyMessengeroperator= (const G4ParticlePropertyMessenger &)=delete
void SetNewValue (G4UIcommand *command, G4String newValues) override
G4String GetCurrentValue (G4UIcommand *command) override
Public Member Functions inherited from G4UImessenger
 G4UImessenger ()=default
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
virtual ~G4UImessenger ()
G4bool CommandsShouldBeInMaster () const

Additional Inherited Members

Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
G4String LtoS (G4long l)
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 (const 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.

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

Referenced by G4ParticlePropertyMessenger(), and operator=().

◆ ~G4ParticlePropertyMessenger()

G4ParticlePropertyMessenger::~G4ParticlePropertyMessenger ( )
override

Definition at line 93 of file G4ParticlePropertyMessenger.cc.

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

◆ G4ParticlePropertyMessenger() [2/2]

G4ParticlePropertyMessenger::G4ParticlePropertyMessenger ( const G4ParticlePropertyMessenger & )
delete

Member Function Documentation

◆ GetCurrentValue()

G4String G4ParticlePropertyMessenger::GetCurrentValue ( G4UIcommand * command)
overridevirtual

Reimplemented from G4UImessenger.

Definition at line 140 of file G4ParticlePropertyMessenger.cc.

141{
142 G4String returnValue(1, '\0');
143
144 const G4ParticleDefinition* currentParticle = theParticleTable->GetSelectedParticle();
145 if (currentParticle == nullptr) {
146 return returnValue; // no particle is selected. return null
147 }
148
149 if (command == stableCmd) {
150 // Command /particle/property/stable
151 returnValue = stableCmd->ConvertToString(currentParticle->GetPDGStable());
152 }
153 else if (command == lifetimeCmd) {
154 // Command /particle/property/lifetime
155 returnValue = lifetimeCmd->ConvertToString(currentParticle->GetPDGLifeTime(), "ns");
156 }
157 else if (command == verboseCmd) {
158 // Command /particle/property/Verbose
159 returnValue = verboseCmd->ConvertToString(currentParticle->GetVerboseLevel());
160 }
161
162 return returnValue;
163}
G4bool GetPDGStable() const
G4int GetVerboseLevel() const
G4double GetPDGLifeTime() const

◆ operator=()

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

◆ SetNewValue()

void G4ParticlePropertyMessenger::SetNewValue ( G4UIcommand * command,
G4String newValues )
overridevirtual

Reimplemented from G4UImessenger.

Definition at line 105 of file G4ParticlePropertyMessenger.cc.

106{
107 auto currentParticle = const_cast<G4ParticleDefinition*>(theParticleTable->GetSelectedParticle());
108
109 if (currentParticle == nullptr) {
110 G4cout << "Particle is not selected yet !! Command ignored." << G4endl;
111 return;
112 }
113
114 if (command == dumpCmd) {
115 // Command /particle/property/dump
116 currentParticle->DumpTable();
117 }
118 else if (command == lifetimeCmd) {
119 // Command /particle/property/lifetime
120 currentParticle->SetPDGLifeTime(lifetimeCmd->GetNewDoubleValue(newValue));
121 }
122 else if (command == stableCmd) {
123 // Command /particle/property/stable
124 if (currentParticle->GetPDGLifeTime() < 0.0) {
125 G4cout << "Life time is negative! Command ignored." << G4endl;
126 }
127 else if (currentParticle->GetPDGMass() <= 0.0) {
128 G4cout << "Zero Mass! Command ignored." << G4endl;
129 }
130 else {
131 currentParticle->SetPDGStable(stableCmd->GetNewBoolValue(newValue));
132 }
133 }
134 else if (command == verboseCmd) {
135 // Command /particle/property/Verbose
136 currentParticle->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue));
137 }
138}
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout

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