Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4ParticlePropertyMessenger.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: G4ParticlePropertyMessenger.cc 67971 2013-03-13 10:13:24Z gcosmo $
28 //
29 //
30 //---------------------------------------------------------------
31 //
32 // G4ParticlePropertyMessenger.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 // 19 June 1998 H. Kurashige : adds UnitCategory
43 //---------------------------------------------------------------
44 
46 #include "G4UImanager.hh"
47 #include "G4UIdirectory.hh"
49 #include "G4UIcmdWithAnInteger.hh"
51 #include "G4UIcmdWithABool.hh"
52 #include "G4ParticleDefinition.hh"
53 #include "G4DecayTableMessenger.hh"
55 #include "G4ParticleTable.hh"
56 #include "G4ios.hh" // Include from 'system'
57 #include <iomanip> // Include from 'system'
58 
60  :theParticleTable(pTable),
61  currentParticle(0),
62  fDecayTableMessenger(0)
63 {
65  //Commnad /particle/property/
66  thisDirectory = new G4UIdirectory("/particle/property/");
67  thisDirectory->SetGuidance("Paricle Table control commands.");
68 
69  //Commnad /particle/property/dump
70  dumpCmd = new G4UIcmdWithoutParameter("/particle/property/dump",this);
71  dumpCmd->SetGuidance("dump particle properties.");
72 
73  //Command /particle/property/stable
74  stableCmd = new G4UIcmdWithABool("/particle/property/stable",this);
75  stableCmd->SetGuidance("Set stable flag.");
76  stableCmd->SetGuidance(" false: Unstable true: Stable");
77  stableCmd->SetParameterName("stable",false);
79 
80  //particle/property/lifetime
81  lifetimeCmd = new G4UIcmdWithADoubleAndUnit("/particle/property/lifetime",this);
82  lifetimeCmd->SetGuidance("Set life time.");
83  lifetimeCmd->SetGuidance("Unit of the time can be :");
84  lifetimeCmd->SetGuidance(" s, ms, ns (default)");
85  lifetimeCmd->SetParameterName("life",false);
87  lifetimeCmd->SetRange("life >0.0");
88  //lifetimeCmd->SetUnitCategory("Time");
89  //lifetimeCmd->SetUnitCandidates("s ms ns");
92 
93  // -- particle/property/Verbose ---
94  verboseCmd = new G4UIcmdWithAnInteger("/particle/property/verbose",this);
95  verboseCmd->SetGuidance("Set Verbose level of particle property.");
96  verboseCmd->SetGuidance(" 0 : Silent (default)");
97  verboseCmd->SetGuidance(" 1 : Display warning messages");
98  verboseCmd->SetGuidance(" 2 : Display more");
99  verboseCmd->SetParameterName("verbose_level",true);
101  verboseCmd->SetRange("verbose_level >=0");
102 
103  //UI messenger for Decay Table
105 
106 }
107 
109 {
112 
113  delete stableCmd;
114  delete verboseCmd;
115  delete lifetimeCmd;
116  delete dumpCmd;
117  delete thisDirectory;
118 }
119 
121 {
122  if (SetCurrentParticle()==0) {
123  G4cout << "Particle is not selected yet !! Command ignored." << G4endl;
124  return;
125  }
126 
127  if( command == dumpCmd ){
128  //Commnad /particle/property/dump
130 
131  } else if (command == lifetimeCmd ) {
132  //Commnad /particle/property/lifetime
134 
135  } else if (command == stableCmd ) {
136  //Commnad /particle/property/stable
137  if (currentParticle->GetPDGLifeTime()<0.0) {
138  G4cout << "Life time is negative! Command ignored." << G4endl;
139  } else if (currentParticle->GetPDGMass()<=0.0) {
140  G4cout << "Zero Mass! Command ignored." << G4endl;
141  } else {
143  }
144 
145  } else if( command==verboseCmd ) {
146  //Commnad /particle/property/Verbose
148  }
149 }
150 
152 {
153  // set currentParticle pointer
154 
155  // get particle name by asking G4ParticleMessenger via UImanager
156 
157  G4String particleName = G4UImanager::GetUIpointer()->GetCurrentStringValue("/particle/select");
158 
159  if (currentParticle != 0 ){
160  // check whether selection is changed
161  if (currentParticle->GetParticleName() != particleName) {
163  }
164  } else {
166  }
167  return currentParticle;
168 }
169 
171 {
172  G4String returnValue('\0');
173 
174  if (SetCurrentParticle()==0) {
175  // no particle is selected. return null
176  return returnValue;
177  }
178 
179  if( command == stableCmd ){
180  //Commnad /particle/property/stable
182 
183  } else if( command == lifetimeCmd ){
184  //Commnad /particle/property/lifetime
185  returnValue = lifetimeCmd->ConvertToString( currentParticle->GetPDGLifeTime() , "ns" );
186 
187  } else if( command==verboseCmd ){
188  //Commnad /particle/property/Verbose
190 
191  }
192 
193  return returnValue;
194 }
195 
196 
197 
198 
199 
200 
201 
202 
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
G4ParticleDefinition * SetCurrentParticle()
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4ParticleTable * GetParticleTable()
G4double GetPDGLifeTime() const
void SetDefaultValue(G4int defVal)
#define G4endl
Definition: G4ios.hh:61
const G4String & GetParticleName() const
G4UIcmdWithADoubleAndUnit * lifetimeCmd
void SetPDGLifeTime(G4double aLifeTime)
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
G4double GetPDGMass() const
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
virtual G4String GetCurrentValue(G4UIcommand *command)
static G4bool GetNewBoolValue(const char *paramString)
static G4double GetNewDoubleValue(const char *paramString)
G4int GetVerboseLevel() const
G4DecayTableMessenger * fDecayTableMessenger
G4bool GetPDGStable() const
G4ParticlePropertyMessenger(G4ParticleTable *pTable=0)
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:374
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetPDGStable(const G4bool aFlag)
static G4int GetNewIntValue(const char *paramString)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
virtual void SetNewValue(G4UIcommand *command, G4String newValues)
G4GLOB_DLL std::ostream G4cout
void SetVerboseLevel(G4int value)
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:242
G4String GetCurrentStringValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:202
void SetDefaultUnit(const char *defUnit)