G4ParticleMessenger Class Reference

#include <G4ParticleMessenger.hh>

Inheritance diagram for G4ParticleMessenger:

G4UImessenger

Public Member Functions

 G4ParticleMessenger (G4ParticleTable *pTable=0)
virtual ~G4ParticleMessenger ()
void SetNewValue (G4UIcommand *command, G4String newValues)
G4String GetCurrentValue (G4UIcommand *command)

Detailed Description

Definition at line 92 of file G4ParticleMessenger.hh.


Constructor & Destructor Documentation

G4ParticleMessenger::G4ParticleMessenger ( G4ParticleTable pTable = 0  ) 

Definition at line 60 of file G4ParticleMessenger.cc.

References G4UIcommand::AvailableForStates(), G4State_Idle, G4State_PreInit, G4ParticleTable::GetParticleTable(), G4UIcmdWithAString::SetCandidates(), G4UIcmdWithAnInteger::SetDefaultValue(), G4UIcmdWithAString::SetDefaultValue(), G4UIcommand::SetGuidance(), G4UIcmdWithAnInteger::SetParameterName(), G4UIcmdWithAString::SetParameterName(), and G4UIcommand::SetRange().

00061 {
00062   // get the pointer to ParticleTable
00063   if ( pTable == 0) {
00064     theParticleTable = G4ParticleTable::GetParticleTable();
00065   } else {
00066     theParticleTable = pTable;
00067   }
00068  
00069   //Directory   /particle/
00070   thisDirectory = new G4UIdirectory("/particle/");
00071   thisDirectory->SetGuidance("Particle control commands.");
00072 
00073   //Commnad   /particle/select
00074   selectCmd = new G4UIcmdWithAString("/particle/select",this);
00075   selectCmd->SetGuidance("Select particle ");
00076   selectCmd->SetDefaultValue("none");
00077   selectCmd->SetParameterName("particle name", false);
00078   selectCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00079 
00080   //Commnad   /particle/list
00081   listCmd = new G4UIcmdWithAString("/particle/list",this);
00082   listCmd->SetGuidance("List name of particles.");
00083   listCmd->SetGuidance(" all(default)/lepton/baryon/meson/nucleus/quarks");
00084   listCmd->SetParameterName("particle type", true);
00085   listCmd->SetDefaultValue("all");
00086   listCmd->SetCandidates("all lepton baryon meson nucleus quarks");
00087   listCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00088 
00089   //Commnad   /particle/find 
00090   findCmd = new G4UIcmdWithAnInteger("/particle/find",this);
00091   findCmd->SetGuidance("Find particle by encoding");
00092   findCmd->SetDefaultValue(0);
00093   findCmd->SetParameterName("encoding", false);
00094   findCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00095 
00096   //Commnad   /particle/createAllIon
00097   createAllCmd = new G4UIcmdWithoutParameter("/particle/createAllIon",this);
00098   createAllCmd->SetGuidance("Create All ions");
00099   createAllCmd->AvailableForStates(G4State_Idle);
00100 
00101   // -- particle/property/Verbose ---
00102   verboseCmd = new G4UIcmdWithAnInteger("/particle/verbose",this);
00103   verboseCmd->SetGuidance("Set Verbose level of particle table.");
00104   verboseCmd->SetGuidance(" 0 : Silent (default)");
00105   verboseCmd->SetGuidance(" 1 : Display warning messages");
00106   verboseCmd->SetGuidance(" 2 : Display more");
00107   verboseCmd->SetParameterName("verbose_level",true);
00108   verboseCmd->SetDefaultValue(0);
00109   verboseCmd->SetRange("verbose_level >=0");
00110 
00111   currentParticle = 0;
00112 
00113   //UI messenger for Particle Properties
00114   fParticlePropertyMessenger = new G4ParticlePropertyMessenger(theParticleTable);
00115 
00116 }

G4ParticleMessenger::~G4ParticleMessenger (  )  [virtual]

Definition at line 118 of file G4ParticleMessenger.cc.

00119 {
00120   delete fParticlePropertyMessenger;
00121 
00122   delete listCmd; 
00123   delete selectCmd;
00124   delete findCmd;
00125   delete createAllCmd;
00126   delete verboseCmd;
00127 
00128   delete thisDirectory;
00129 }


Member Function Documentation

G4String G4ParticleMessenger::GetCurrentValue ( G4UIcommand command  )  [virtual]

Reimplemented from G4UImessenger.

Definition at line 191 of file G4ParticleMessenger.cc.

References G4UIcommand::ConvertToString(), G4ParticleTable::GetIterator(), G4ParticleDefinition::GetParticleName(), G4ParticleTable::GetVerboseLevel(), G4UIcmdWithAString::SetCandidates(), and G4ParticleTableIterator< K, V >::value().

00192 {
00193   if( command==selectCmd ){
00194     //Command  /particle/select
00195     // set candidate List
00196     G4String candidates("none");
00197     G4ParticleTable::G4PTblDicIterator *piter = theParticleTable->GetIterator();
00198     piter -> reset();
00199     while( (*piter)() ){
00200       G4ParticleDefinition *particle = piter->value();
00201       candidates += " " + particle->GetParticleName();
00202     }
00203     selectCmd->SetCandidates((const char *)(candidates));   
00204 
00205     static G4String noName("none");
00206     // current value
00207     if(currentParticle == 0) {
00208       // no particle is selected. return null 
00209       return noName;
00210     } else {
00211       return currentParticle->GetParticleName();
00212     }
00213   } else if( command==verboseCmd ){
00214     //Commnad   /particle/verbose
00215     return verboseCmd->ConvertToString(theParticleTable->GetVerboseLevel());
00216   }
00217   return "";
00218 }

void G4ParticleMessenger::SetNewValue ( G4UIcommand command,
G4String  newValues 
) [virtual]

Reimplemented from G4UImessenger.

Definition at line 132 of file G4ParticleMessenger.cc.

References G4IonTable::CreateAllIon(), G4ParticleDefinition::DumpTable(), G4ParticleTable::FindParticle(), G4cout, G4endl, G4ParticleTable::GetIonTable(), G4ParticleTable::GetIterator(), G4UIcmdWithAnInteger::GetNewIntValue(), G4ParticleDefinition::GetParticleName(), G4ParticleDefinition::GetParticleType(), G4UIcmdWithAString::SetCandidates(), G4ParticleTable::SetVerboseLevel(), and G4ParticleTableIterator< K, V >::value().

00133 {
00134   if( command==listCmd ){
00135     //Commnad   /particle/List
00136     G4int counter = 0;
00137     G4ParticleTable::G4PTblDicIterator *piter = theParticleTable->GetIterator();
00138     piter -> reset();
00139   
00140     while( (*piter)() ){
00141       G4ParticleDefinition *particle = piter->value();
00142       if ((newValues=="all") || (newValues==particle->GetParticleType())) {
00143         G4cout << std::setw(19) << particle->GetParticleName();
00144         if ((counter++)%4 == 3) {
00145           G4cout << G4endl;
00146         } else {
00147           G4cout << ",";
00148         }
00149       }
00150     }
00151     G4cout << G4endl;
00152     if (counter == 0) G4cout << newValues << " is not found " << G4endl;
00153     
00154    //Command  /particle/select
00155     // set candidate List
00156     G4String candidates("none");
00157     piter -> reset();
00158     while( (*piter)() ){
00159       G4ParticleDefinition *particle = piter->value();
00160       candidates += " " + particle->GetParticleName();
00161     }
00162     selectCmd->SetCandidates((const char *)(candidates));   
00163  
00164   } else if( command==selectCmd ){
00165     //Commnad   /particle/select
00166     currentParticle = theParticleTable->FindParticle(newValues);
00167     if(currentParticle == 0) {
00168       G4cout << "Unknown particle [" << newValues << "]. Command ignored." << G4endl;
00169     }   
00170 
00171   } else if( command==findCmd ){
00172     //Commnad   /particle/find
00173     G4ParticleDefinition* tmp = theParticleTable->FindParticle( findCmd->GetNewIntValue(newValues));
00174     if(tmp == 0) {
00175       G4cout << "Unknown particle [" << newValues << "]. Command ignored." << G4endl;
00176     } else {
00177       G4cout << tmp->GetParticleName() << G4endl;
00178       tmp->DumpTable();
00179     }
00180 
00181   } else if( command==createAllCmd ) {
00182     //Commnad   /particle/createAllIon
00183     theParticleTable->GetIonTable()->CreateAllIon();
00184 
00185   } else if( command==verboseCmd ) {
00186     //Commnad   /particle/verbose
00187     theParticleTable->SetVerboseLevel(verboseCmd->GetNewIntValue(newValues));
00188   }    
00189 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:52:51 2013 for Geant4 by  doxygen 1.4.7