Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4DecayTableMessenger.cc
이 파일의 문서화 페이지로 가기
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 105720 2017-08-16 12:38:10Z 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  currentParticle(nullptr),
61  currentDecayTable(nullptr),
62  idxCurrentChannel(-1),
63  currentChannel(nullptr),
64  thisDirectory(nullptr),
65  dumpCmd(nullptr),
66  selectCmd(nullptr),
67  brCmd(nullptr)
68 {
69  if ( theParticleTable == nullptr ) {
71  }
72  currentParticle = nullptr;
73 
74  //Commnad /particle/property/decay/
75  thisDirectory = new G4UIdirectory("/particle/property/decay/");
76  thisDirectory->SetGuidance("Decay Table control commands.");
77 
78  //Commnad /particle/property/decay/select
79  selectCmd = new G4UIcmdWithAnInteger("/particle/property/decay/select",this);
80  selectCmd->SetGuidance("Enter index of decay mode.");
81  selectCmd->SetParameterName("mode", true);
83  selectCmd->SetRange("mode >=0");
84  currentChannel = nullptr;
85 
86  //Commnad /particle/property/decay/dump
87  dumpCmd = new G4UIcmdWithoutParameter("/particle/property/decay/dump",this);
88  dumpCmd->SetGuidance("Dump decay mode information.");
89 
90  //Command /particle/property/decay/br
91  brCmd = new G4UIcmdWithADouble("/particle/property/decay/br",this);
92  brCmd->SetGuidance("Set branching ratio. [0< BR <1.0]");
93  brCmd->SetParameterName("br",false);
94  brCmd->SetRange("(br >=0.0) && (br <=1.0)");
95 
96 }
97 
99 {
100  if (dumpCmd != nullptr) delete dumpCmd;
101  if (selectCmd != nullptr) delete selectCmd;
102  if (brCmd != nullptr) delete brCmd;
103  if (thisDirectory != nullptr) delete thisDirectory;
104 }
105 
107 {
108  if (SetCurrentParticle()== nullptr) {
109  G4cout << "Particle is not selected yet !! Command ignored." << G4endl;
110  return;
111  }
112  if (currentDecayTable== nullptr) {
113  G4cout << "The particle has no decay table !! Command ignored." << G4endl;
114  return;
115  }
116 
117  if( command == dumpCmd ){
118  //Commnad /particle/property/decay/dump
120 
121  } else if ( command == selectCmd ){
122  //Commnad /particle/property/decay/select
123  G4int index = selectCmd->GetNewIntValue(newValue) ;
125  if ( currentChannel == nullptr ) {
126  G4cout << "Invalid index. Command ignored." << G4endl;
127  } else {
128  idxCurrentChannel = index;
129  }
130 
131  } else {
132  if ( currentChannel == nullptr ) {
133  G4cout << "Select a decay channel. Command ignored." << G4endl;
134  return;
135  }
136  if (command == brCmd) {
137  //Commnad /particle/property/decay/br
138  G4double br = brCmd->GetNewDoubleValue(newValue);
139  if( (br<0.0) || (br>1.0) ) {
140  G4cout << "Invalid brancing ratio. Command ignored." << G4endl;
141  } else {
142  currentChannel->SetBR(br);
143  }
144  }
145  }
146 }
147 
148 
150 {
151  // set currentParticle pointer
152  // get particle name by asking G4ParticleMessenger via UImanager
153 
154  G4String particleName = G4UImanager::GetUIpointer()->GetCurrentStringValue("/particle/select");
155 
156  if (currentParticle != nullptr ){
157  // check whether selection is changed
158  if (currentParticle->GetParticleName() != particleName) {
160  idxCurrentChannel = -1;
161  currentDecayTable = nullptr;
162  } else {
163  // no change
164  return currentParticle;
165  }
166 
167  } else {
169  idxCurrentChannel = -1;
170  currentDecayTable = nullptr;
171  if (currentParticle != nullptr ){
173  if ((currentDecayTable != nullptr ) && (idxCurrentChannel >0) ) {
175  } else {
176  idxCurrentChannel = -1;
177  currentChannel = nullptr;
178  }
179  }
180 
181  }
182  return currentParticle;
183 }
184 
186 {
187  G4String returnValue('\0');
188 
189  if (SetCurrentParticle()==nullptr) {
190  // no particle is selected. return null
191  return returnValue;
192  }
193 
194  if( command == selectCmd ){
195  //Commnad /particle/property/decay/select
197 
198  } else if( command == brCmd ){
199  if ( currentChannel != nullptr) {
200  returnValue = brCmd->ConvertToString(currentChannel->GetBR());
201  }
202  }
203  return returnValue;
204 }
205 
206 
207 
208 
209 
210 
211 
212 
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
G4double GetBR() const
G4DecayTable * GetDecayTable() const
static G4ParticleTable * GetParticleTable()
void SetDefaultValue(G4int defVal)
#define G4endl
Definition: G4ios.hh:61
const G4String & GetParticleName() const
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
static G4double GetNewDoubleValue(const char *paramString)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
G4VDecayChannel * currentChannel
void SetBR(G4double value)
double G4double
Definition: G4Types.hh:76
virtual G4String GetCurrentValue(G4UIcommand *command)
G4ParticleTable * theParticleTable
void DumpInfo() const
G4VDecayChannel * GetDecayChannel(G4int index) const
virtual void SetNewValue(G4UIcommand *command, G4String newValues)
G4ParticleDefinition * SetCurrentParticle()
G4ParticleDefinition * currentParticle
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:374
G4UIcmdWithAnInteger * selectCmd
int G4int
Definition: G4Types.hh:78
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4int GetNewIntValue(const char *paramString)
G4GLOB_DLL std::ostream G4cout
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4UIcmdWithoutParameter * dumpCmd
G4UIcmdWithADouble * brCmd
G4DecayTableMessenger(G4ParticleTable *pTable=0)
G4String GetCurrentStringValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:202