00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #include "G4ParticlePropertyMessenger.hh"
00046 #include "G4UImanager.hh"
00047 #include "G4UIdirectory.hh"
00048 #include "G4UIcmdWithoutParameter.hh"
00049 #include "G4UIcmdWithAnInteger.hh"
00050 #include "G4UIcmdWithADoubleAndUnit.hh"
00051 #include "G4UIcmdWithABool.hh"
00052 #include "G4ParticleDefinition.hh"
00053 #include "G4DecayTableMessenger.hh"
00054 #include "G4ParticlePropertyMessenger.hh"
00055 #include "G4ParticleTable.hh"
00056 #include "G4ios.hh"
00057 #include <iomanip>
00058
00059 G4ParticlePropertyMessenger::G4ParticlePropertyMessenger(G4ParticleTable* pTable)
00060 :theParticleTable(pTable),
00061 currentParticle(0),
00062 fDecayTableMessenger(0)
00063 {
00064 if ( theParticleTable == 0) theParticleTable = G4ParticleTable::GetParticleTable();
00065
00066 thisDirectory = new G4UIdirectory("/particle/property/");
00067 thisDirectory->SetGuidance("Paricle Table control commands.");
00068
00069
00070 dumpCmd = new G4UIcmdWithoutParameter("/particle/property/dump",this);
00071 dumpCmd->SetGuidance("dump particle properties.");
00072
00073
00074 stableCmd = new G4UIcmdWithABool("/particle/property/stable",this);
00075 stableCmd->SetGuidance("Set stable flag.");
00076 stableCmd->SetGuidance(" false: Unstable true: Stable");
00077 stableCmd->SetParameterName("stable",false);
00078 stableCmd->AvailableForStates(G4State_PreInit,G4State_Idle,G4State_GeomClosed);
00079
00080
00081 lifetimeCmd = new G4UIcmdWithADoubleAndUnit("/particle/property/lifetime",this);
00082 lifetimeCmd->SetGuidance("Set life time.");
00083 lifetimeCmd->SetGuidance("Unit of the time can be :");
00084 lifetimeCmd->SetGuidance(" s, ms, ns (default)");
00085 lifetimeCmd->SetParameterName("life",false);
00086 lifetimeCmd->SetDefaultValue(0.0);
00087 lifetimeCmd->SetRange("life >0.0");
00088
00089
00090 lifetimeCmd->SetDefaultUnit("ns");
00091 lifetimeCmd->AvailableForStates(G4State_PreInit,G4State_Idle,G4State_GeomClosed);
00092
00093
00094 verboseCmd = new G4UIcmdWithAnInteger("/particle/property/verbose",this);
00095 verboseCmd->SetGuidance("Set Verbose level of particle property.");
00096 verboseCmd->SetGuidance(" 0 : Silent (default)");
00097 verboseCmd->SetGuidance(" 1 : Display warning messages");
00098 verboseCmd->SetGuidance(" 2 : Display more");
00099 verboseCmd->SetParameterName("verbose_level",true);
00100 verboseCmd->SetDefaultValue(0);
00101 verboseCmd->SetRange("verbose_level >=0");
00102
00103
00104 fDecayTableMessenger = new G4DecayTableMessenger(theParticleTable);
00105
00106 }
00107
00108 G4ParticlePropertyMessenger::~G4ParticlePropertyMessenger()
00109 {
00110 if (fDecayTableMessenger !=0) delete fDecayTableMessenger;
00111 fDecayTableMessenger = 0;
00112
00113 delete stableCmd;
00114 delete verboseCmd;
00115 delete lifetimeCmd;
00116 delete dumpCmd;
00117 delete thisDirectory;
00118 }
00119
00120 void G4ParticlePropertyMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
00121 {
00122 if (SetCurrentParticle()==0) {
00123 G4cout << "Particle is not selected yet !! Command ignored." << G4endl;
00124 return;
00125 }
00126
00127 if( command == dumpCmd ){
00128
00129 currentParticle->DumpTable();
00130
00131 } else if (command == lifetimeCmd ) {
00132
00133 currentParticle->SetPDGLifeTime(lifetimeCmd->GetNewDoubleValue(newValue));
00134
00135 } else if (command == stableCmd ) {
00136
00137 if (currentParticle->GetPDGLifeTime()<0.0) {
00138 G4cout << "Life time is negative! Command ignored." << G4endl;
00139 } else if (currentParticle->GetPDGMass()<=0.0) {
00140 G4cout << "Zero Mass! Command ignored." << G4endl;
00141 } else {
00142 currentParticle->SetPDGStable(stableCmd->GetNewBoolValue(newValue));
00143 }
00144
00145 } else if( command==verboseCmd ) {
00146
00147 currentParticle->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue));
00148 }
00149 }
00150
00151 G4ParticleDefinition* G4ParticlePropertyMessenger::SetCurrentParticle()
00152 {
00153
00154
00155
00156
00157 G4String particleName = G4UImanager::GetUIpointer()->GetCurrentStringValue("/particle/select");
00158
00159 if (currentParticle != 0 ){
00160
00161 if (currentParticle->GetParticleName() != particleName) {
00162 currentParticle = theParticleTable->FindParticle(particleName);
00163 }
00164 } else {
00165 currentParticle = theParticleTable->FindParticle(particleName);
00166 }
00167 return currentParticle;
00168 }
00169
00170 G4String G4ParticlePropertyMessenger::GetCurrentValue(G4UIcommand * command)
00171 {
00172 G4String returnValue('\0');
00173
00174 if (SetCurrentParticle()==0) {
00175
00176 return returnValue;
00177 }
00178
00179 if( command == stableCmd ){
00180
00181 returnValue = stableCmd->ConvertToString( currentParticle->GetPDGStable());
00182
00183 } else if( command == lifetimeCmd ){
00184
00185 returnValue = lifetimeCmd->ConvertToString( currentParticle->GetPDGLifeTime() , "ns" );
00186
00187 } else if( command==verboseCmd ){
00188
00189 returnValue= verboseCmd->ConvertToString(currentParticle ->GetVerboseLevel());
00190
00191 }
00192
00193 return returnValue;
00194 }
00195
00196
00197
00198
00199
00200
00201
00202