Geant4-11
G4DecayTableMessenger.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4DecayTableMessenger class implementation
27//
28// Author: H.Kurashige, 13 June 1997
29//---------------------------------------------------------------------
30
32#include "G4UImanager.hh"
33#include "G4UIdirectory.hh"
36#include "G4UIcmdWithADouble.hh"
37#include "G4VDecayChannel.hh"
38#include "G4DecayTable.hh"
40#include "G4ParticleTable.hh"
41#include "G4ios.hh" // Include from 'system'
42#include <iomanip> // Include from 'system'
43
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}
75
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}
83
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}
140
141
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}
189
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}
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4VDecayChannel * currentChannel
G4ParticleTable * theParticleTable
virtual void SetNewValue(G4UIcommand *command, G4String newValues)
G4UIcmdWithADouble * brCmd
G4ParticleDefinition * SetCurrentParticle()
G4DecayTableMessenger(G4ParticleTable *pTable=nullptr)
virtual G4String GetCurrentValue(G4UIcommand *command)
G4UIcmdWithoutParameter * dumpCmd
G4UIcmdWithAnInteger * selectCmd
G4ParticleDefinition * currentParticle
G4VDecayChannel * GetDecayChannel(G4int index) const
void DumpInfo() const
G4DecayTable * GetDecayTable() const
const G4String & GetParticleName() const
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
static G4ParticleTable * GetParticleTable()
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4double GetNewDoubleValue(const char *paramString)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4int GetNewIntValue(const char *paramString)
void SetDefaultValue(G4int defVal)
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:445
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
void SetRange(const char *rs)
Definition: G4UIcommand.hh:120
G4String GetCurrentStringValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:177
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
G4double GetBR() const
void SetBR(G4double value)