Public Member Functions | |
BLCMDlist () | |
G4String | commandName () |
int | command (BLArgumentVector &argv, BLArgumentMap &namedArgs) |
void | defineNamedArgs () |
void | listParticles () |
void | listParticleDetails () |
Private Attributes | |
G4String | particle |
BLCMDlist::BLCMDlist | ( | ) |
References BLCMDTYPE_CONTROL, BLCommand::registerCommand(), BLCommand::setDescription(), and BLCommand::setSynopsis().
00049 { 00050 registerCommand(BLCMDTYPE_CONTROL); 00051 setSynopsis("provides interactive list of interesting internal tables."); 00052 setDescription("list with no arguments lists all lists except processes.\n" 00053 "'list name' lists that specific one.\n" 00054 "'list -exit name(s)' will exit after listing.\n" 00055 "List names are:\n" 00056 " commands all commands\n" 00057 " materials currently known materials\n" 00058 " physics all physics lists\n" 00059 " particles currently known particles\n" 00060 " processes currently known physics processes ***\n" 00061 "NOTE: the particles and processes lists are " 00062 "not populated until the physics list is selected (via " 00063 "the physics command). Different physics lists use different " 00064 "processes and particles.\n\n" 00065 "***NOTE: listing processes will prevent any simulating, " 00066 "as will a non-empty particle list."); 00067 }
G4String BLCMDlist::commandName | ( | ) | [inline, virtual] |
int BLCMDlist::command | ( | BLArgumentVector & | argv, | |
BLArgumentMap & | namedArgs | |||
) | [virtual] |
Implements BLCommand.
References BLCommand::doCommand(), g4bl_exit(), BLManager::getObject(), BLManager::handleCallbacks(), BLCommand::handleNamedArgs(), BLManager::initialize(), BLManager::isInitialized(), listParticleDetails(), listParticles(), and particle.
00071 { 00072 bool exit = (argv.size() > 0 && argv[0] == "-exit"); 00073 if(exit) argv.erase(argv.begin()); 00074 00075 handleNamedArgs(namedArgs); 00076 00077 if((argv.size() == 0 || argv[0] == "*" || argv[0] == "all") && 00078 particle.size() == 0) { 00079 argv.clear(); 00080 argv.push_back("commands"); 00081 argv.push_back("materials"); 00082 argv.push_back("physics"); 00083 argv.push_back("particles"); 00084 //argv.push_back("processes"); 00085 } 00086 00087 for(unsigned i=0; i<argv.size(); ++i) { 00088 if(argv[i].compareTo("commands",G4String::ignoreCase) == 0) { 00089 printf("\nCommands:\n---------\n"); 00090 G4String s("help"); 00091 doCommand(s); 00092 } else if(argv[i].compareTo("particles",G4String::ignoreCase) == 0) { 00093 printf("\nParticles:\n----------\n"); 00094 listParticles(); 00095 } else if(argv[i].compareTo("physics",G4String::ignoreCase) == 0) { 00096 printf("\nPhysics lists:\n--------------\n"); 00097 G4String s("physics"); 00098 doCommand(s); 00099 } else if(argv[i].compareTo("materials",G4String::ignoreCase) == 0) { 00100 G4String s("material"); 00101 doCommand(s); 00102 } else if(argv[i].compareTo("processes",G4String::ignoreCase) == 0) { 00103 if(BLManager::getObject()->getPhysics() == 0) { 00104 printf("cannot list processes -- no physics registered.\n"); 00105 return 0; 00106 } 00107 if(!BLManager::isInitialized()) { 00108 BLManager::getObject()->initialize(); 00109 BLManager::getObject()->handleCallbacks(0); 00110 } 00111 printf("\nlist: Note that simulation will fail due to multiple initializations.\n"); 00112 printf("Physics processes:\n------------------\n"); 00113 G4String s("/process/list"); 00114 doCommand(s); 00115 } 00116 } 00117 00118 if(particle.size() > 0) { 00119 printf("\nlist: Note that simulation will fail due to multiple initializations.\n"); 00120 printf("Particle details:\n----------------\n"); 00121 if(!BLManager::isInitialized()) { 00122 BLManager::getObject()->initialize(); 00123 BLManager::getObject()->handleCallbacks(0); 00124 } 00125 listParticleDetails(); 00126 } 00127 00128 if(exit) { 00129 fflush(stdout); 00130 g4bl_exit(0); 00131 } 00132 00133 particle = ""; // in case another list command is issued 00134 00135 return 0; 00136 }
void BLCMDlist::defineNamedArgs | ( | ) | [virtual] |
Reimplemented from BLCommand.
References BLCommand::argString(), and particle.
00139 { 00140 argString(particle,"particle","Comma-separated list of particles for " 00141 "which details will be printed"); 00142 }
void BLCMDlist::listParticles | ( | ) |
References BLManager::getObject().
Referenced by command().
00145 { 00146 if(BLManager::getObject()->getPhysics() == 0) { 00147 printf("cannot list particles -- no physics registered.\n"); 00148 return; 00149 } 00150 00151 G4ParticleTable::G4PTblDicIterator *i = 00152 G4ParticleTable::GetParticleTable()->GetIterator(); 00153 i->reset(); 00154 int n=0; 00155 while((*i)()) { 00156 G4ParticleDefinition *pd = i->value(); 00157 printf("%15s PDGid=%d\n", pd->GetParticleName().c_str(), 00158 pd->GetPDGEncoding()); 00159 ++n; 00160 } 00161 if(n == 0) 00162 printf("No particles listed -- select physics list first\n"); 00163 }
void BLCMDlist::listParticleDetails | ( | ) |
References particle, BLCommand::printError(), BLCommand::splitString(), and BLCommand::wrapWords().
Referenced by command().
00166 { 00167 G4ParticleTable *table = G4ParticleTable::GetParticleTable(); 00168 std::vector<G4String> v = splitString(particle,','); 00169 for(unsigned i=0; i<v.size(); ++i) { 00170 G4ParticleDefinition *pd = table->FindParticle(v[i]); 00171 if(!pd) { 00172 printError("list: cannot find particle '%s'\n", 00173 v[i].c_str()); 00174 continue; 00175 } 00176 G4ProcessManager *pmgr = pd->GetProcessManager(); 00177 if(!pmgr) continue; 00178 G4String line(v[i] + " "); 00179 while(line.size() < 10) line += " "; 00180 printf("%sPDGid=%d mass=%.3f MeV/c^2\n",line.c_str(), 00181 pd->GetPDGEncoding(),pd->GetPDGMass()); 00182 G4ProcessVector *pv = pmgr->GetProcessList(); 00183 line = "Processes: "; 00184 for(int i=0; i<pv->size(); ++i) { 00185 if(!pmgr->GetProcessActivation(i)) continue; 00186 line += (*pv)[i]->GetProcessName() + " "; 00187 } 00188 printf("%s",wrapWords(line," "," ").c_str()); 00189 } 00190 00191 00192 /*** 00193 // add "bookends" to simplify the comparison 00194 G4String comma(","); 00195 particle = comma + particle + comma; 00196 00197 G4ParticleTable::G4PTblDicIterator *theParticleIterator 00198 = G4ParticleTable::GetParticleTable()->GetIterator(); 00199 theParticleIterator->reset(); 00200 while((*theParticleIterator)()) { 00201 G4ParticleDefinition *pd = theParticleIterator->value(); 00202 G4ProcessManager *pmgr = pd->GetProcessManager(); 00203 if(!pmgr) continue; 00204 G4String name = pd->GetParticleName(); 00205 if(particle.find(comma+name+comma) == particle.npos) continue; 00206 G4String line(name + " "); 00207 while(line.size() < 10) line += " "; 00208 printf("%sPDGid=%d mass=%.3f MeV/c^2\n",line.c_str(), 00209 pd->GetPDGEncoding(),pd->GetPDGMass()); 00210 G4ProcessVector *pv = pmgr->GetProcessList(); 00211 line = "Processes: "; 00212 for(int i=0; i<pv->size(); ++i) { 00213 if(!pmgr->GetProcessActivation(i)) continue; 00214 line += (*pv)[i]->GetProcessName() + " "; 00215 } 00216 printf("%s",wrapWords(line," "," ").c_str()); 00217 } 00218 ***/ 00219 }
G4String BLCMDlist::particle [private] |
Referenced by command(), defineNamedArgs(), and listParticleDetails().