Geant4  10.00.p03
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 //
27 // $Id: G4DecayTableMessenger.cc 67971 2013-03-13 10:13:24Z gcosmo $
28 //
29 //
30 //---------------------------------------------------------------
31 //
32 // G4DecayTableMessenger.cc
33 //
34 // Description:
35 // This is a messenger class to interface to exchange information
36 // between ParticleDefinition and UI.
37 //
38 // History:
39 // 13 June 1997, H. Kurashige : The 1st version created.
40 // 10 Nov. 1997 H. Kurashige : fixed bugs
41 // 08 jan. 1998 H. Kurashige : new UIcommnds
42 //
43 //---------------------------------------------------------------
44 
45 #include "G4DecayTableMessenger.hh"
46 #include "G4UImanager.hh"
47 #include "G4UIdirectory.hh"
49 #include "G4UIcmdWithAnInteger.hh"
50 #include "G4UIcmdWithADouble.hh"
51 #include "G4VDecayChannel.hh"
52 #include "G4DecayTable.hh"
53 #include "G4ParticleDefinition.hh"
54 #include "G4ParticleTable.hh"
55 #include "G4ios.hh" // Include from 'system'
56 #include <iomanip> // Include from 'system'
57 
59  :theParticleTable(pTable)
60 {
62 
63  currentParticle = 0;
64 
65  //Commnad /particle/property/decay/
66  thisDirectory = new G4UIdirectory("/particle/property/decay/");
67  thisDirectory->SetGuidance("Decay Table control commands.");
68 
69  //Commnad /particle/property/decay/select
70  selectCmd = new G4UIcmdWithAnInteger("/particle/property/decay/select",this);
71  selectCmd->SetGuidance("Enter index of decay mode.");
72  selectCmd->SetParameterName("mode", true);
74  selectCmd->SetRange("mode >=0");
75  currentChannel = 0;
76 
77  //Commnad /particle/property/decay/dump
78  dumpCmd = new G4UIcmdWithoutParameter("/particle/property/decay/dump",this);
79  dumpCmd->SetGuidance("Dump decay mode information.");
80 
81  //Command /particle/property/decay/br
82  brCmd = new G4UIcmdWithADouble("/particle/property/decay/br",this);
83  brCmd->SetGuidance("Set branching ratio. [0< BR <1.0]");
84  brCmd->SetParameterName("br",false);
85  brCmd->SetRange("(br >=0.0) && (br <=1.0)");
86 
87 }
88 
90 {
91  delete dumpCmd;
92  delete selectCmd;
93  delete brCmd;
94  delete thisDirectory;
95 }
96 
98 {
99  if (SetCurrentParticle()==0) {
100  G4cout << "Particle is not selected yet !! Command ignored." << G4endl;
101  return;
102  }
103  if (currentDecayTable==0) {
104  G4cout << "The particle has no decay table !! Command ignored." << G4endl;
105  return;
106  }
107 
108  if( command == dumpCmd ){
109  //Commnad /particle/property/decay/dump
111 
112  } else if ( command == selectCmd ){
113  //Commnad /particle/property/decay/select
114  G4int index = selectCmd->GetNewIntValue(newValue) ;
116  if ( currentChannel == 0 ) {
117  G4cout << "Invalid index. Command ignored." << G4endl;
118  } else {
119  idxCurrentChannel = index;
120  }
121 
122  } else {
123  if ( currentChannel == 0 ) {
124  G4cout << "Select a decay channel. Command ignored." << G4endl;
125  return;
126  }
127  if (command == brCmd) {
128  //Commnad /particle/property/decay/br
129  G4double br = brCmd->GetNewDoubleValue(newValue);
130  if( (br<0.0) || (br>1.0) ) {
131  G4cout << "Invalid brancing ratio. Command ignored." << G4endl;
132  } else {
133  currentChannel->SetBR(br);
134  }
135  }
136  }
137 }
138 
139 
141 {
142  // set currentParticle pointer
143 
144  // get particle name by asking G4ParticleMessenger via UImanager
145 
146  G4String particleName = G4UImanager::GetUIpointer()->GetCurrentStringValue("/particle/select");
147 
148  if (currentParticle != 0 ){
149  // check whether selection is changed
150  if (currentParticle->GetParticleName() != particleName) {
152  idxCurrentChannel = -1;
153  currentDecayTable = 0;
154  } else {
155  // no change
156  return currentParticle;
157  }
158  } else {
160  idxCurrentChannel = -1;
161  currentDecayTable = 0;
162  }
163 
164  if (currentParticle != 0 ){
166  if ((currentDecayTable != 0 ) && (idxCurrentChannel >0) ) {
168  } else {
169  idxCurrentChannel = -1;
170  currentChannel = 0;
171  }
172  }
173  return currentParticle;
174 }
175 
177 {
178  G4String returnValue('\0');
179 
180  if (SetCurrentParticle()==0) {
181  // no particle is selected. return null
182  return returnValue;
183  }
184 
185  if( command == selectCmd ){
186  //Commnad /particle/property/decay/select
188 
189  } else if( command == brCmd ){
190  if ( currentChannel != 0) {
191  returnValue = brCmd->ConvertToString(currentChannel->GetBR());
192  }
193  }
194  return returnValue;
195 }
196 
197 
198 
199 
200 
201 
202 
203 
G4double GetBR() const
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
void SetBR(G4double value)
G4ParticleDefinition * currentParticle
G4String GetCurrentStringValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:168
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4int GetNewIntValue(const char *paramString)
virtual G4String GetCurrentValue(G4UIcommand *command)
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:357
G4VDecayChannel * GetDecayChannel(G4int index) const
G4ParticleDefinition * SetCurrentParticle()
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
G4UIcmdWithoutParameter * dumpCmd
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4DecayTable * GetDecayTable() const
G4GLOB_DLL std::ostream G4cout
void DumpInfo() const
G4UIcmdWithADouble * brCmd
static G4double GetNewDoubleValue(const char *paramString)
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
virtual void SetNewValue(G4UIcommand *command, G4String newValues)
static G4ParticleTable * GetParticleTable()
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4UIcmdWithAnInteger * selectCmd
#define G4endl
Definition: G4ios.hh:61
G4VDecayChannel * currentChannel
void SetDefaultValue(G4int defVal)
double G4double
Definition: G4Types.hh:76
G4ParticleTable * theParticleTable
G4DecayTableMessenger(G4ParticleTable *pTable=0)