4 modified files
slic/include
diff -u -r1.8 -r1.9
--- G4CmdQueue.hh 27 Jun 2005 19:17:36 -0000 1.8
+++ G4CmdQueue.hh 6 Sep 2005 22:54:40 -0000 1.9
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/G4CmdQueue.hh,v 1.8 2005/06/27 19:17:36 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/G4CmdQueue.hh,v 1.9 2005/09/06 22:54:40 jeremy Exp $
#ifndef slic_G4CmdQueue_hh
#define slic_G4CmdQueue_hh
@@ -66,6 +66,15 @@
m_commands.clear();
}
+ void prepare();
+
+ private:
+
+ void reorder();
+ void setInitialize();
+ void reorderBeamOn();
+ void reorderLimits();
+
private:
CmdVecType m_commands;
slic/src
diff -u -r1.15 -r1.16
--- CmdManager.cc 18 May 2005 02:43:33 -0000 1.15
+++ CmdManager.cc 6 Sep 2005 22:54:41 -0000 1.16
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/CmdManager.cc,v 1.15 2005/05/18 02:43:33 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/CmdManager.cc,v 1.16 2005/09/06 22:54:41 jeremy Exp $
#include "CmdManager.hh"
#include "G4Application.hh"
@@ -22,7 +22,7 @@
if ( m_instance == 0 ) {
m_instance = new CmdManager();
}
-
+
return m_instance;
}
@@ -53,14 +53,14 @@
// handle a command
if ( is_opt || is_name) {
-
+
// add current cmd to queue if not first time
if ( first_time == false ) {
// add cmd to queue
m_cmdQueue.addCmd( curr_g4_cmd );
- // reset
+ // reset
n_args = 0;
curr_g4_cmd.clear();
}
@@ -135,20 +135,20 @@
if ( token.length() == 2 ) {
// look for '-' in first pos
- if ( token[0] == '-' ) {
-
+ if ( token[0] == '-' ) {
+
// find pos of valid cmd char from reg
int srch_pos = token.find_first_of( valid_opt, 1 );
// char must be idx 1
- if ( srch_pos == 1 ) {
+ if ( srch_pos == 1 ) {
is_opt = true;
}
else {
std::cerr << "Unknown option <" << token << ">." << std::endl;
G4Exception("Option not found in command registry.");
}
- }
+ }
}
return is_opt;
@@ -182,7 +182,7 @@
CmdArgs* CmdManager::getCmdArgs()
{
return &m_args;
- }
+ }
CmdRegistry* CmdManager::getCmdRegistry()
{
@@ -196,8 +196,16 @@
void CmdManager::execCurrG4CmdQueue(bool clear_it)
{
+ /* Reorder, insert implied commands such as initialize, etc. */
+ m_cmdQueue.prepare();
+
+ /* Print queue before execution. */
+ m_cmdQueue.printOut(std::cout);
+
+ /* Execute the queue. */
m_cmdQueue.execCmds();
-
+
+ /* Clear the queue. */
if ( clear_it ) {
clearG4CmdQueue();
}
slic/src
diff -u -r1.42 -r1.43
--- G4Application.cc 6 Sep 2005 17:25:49 -0000 1.42
+++ G4Application.cc 6 Sep 2005 22:54:41 -0000 1.43
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/G4Application.cc,v 1.42 2005/09/06 17:25:49 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/G4Application.cc,v 1.43 2005/09/06 22:54:41 jeremy Exp $
#include "G4Application.hh"
// SLIC
@@ -259,18 +259,8 @@
{
// exec cmd queue
std::cout << std::endl;
- CmdManager::instance()->getG4CmdQueue()->printOut(std::cout);
CmdManager::instance()->execCurrG4CmdQueue(true);
- /* If geometry is set, then attempt automatic simulator initialization. */
- G4ApplicationState state = getG4ApplicationState();
- if ( state==G4State_PreInit ) {
- LCDDParser* parser = LCDDParser::instance();
- if ( parser->isValidSetup() ) {
- G4RunManager::GetRunManager()->Initialize();
- }
- }
-
// init UI and start session if interactive mode and not G4UI_NONE
#ifndef G4UI_NONE
if ( getMode() == eInteractive ) {
slic/src
diff -u -r1.10 -r1.11
--- G4CmdQueue.cc 3 Aug 2005 23:19:38 -0000 1.10
+++ G4CmdQueue.cc 6 Sep 2005 22:54:41 -0000 1.11
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/G4CmdQueue.cc,v 1.10 2005/08/03 23:19:38 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/G4CmdQueue.cc,v 1.11 2005/09/06 22:54:41 jeremy Exp $
#include "G4CmdQueue.hh"
#include "G4UImanager.hh"
@@ -7,6 +7,7 @@
{
void G4CmdQueue::printOut(std::ostream& os) const
{
+ std::cout << std::endl;
os << "********************" << std::endl;
os << "* G4 Command Queue *" << std::endl;
os << "********************" << std::endl;
@@ -15,6 +16,7 @@
iter++ ) {
os << *iter << std::endl;
}
+ std::cout << std::endl;
}
void G4CmdQueue::execCmds()
@@ -23,7 +25,130 @@
iter != cmdsEnd();
iter++ ) {
std::string cmd = *iter;
+ // std::cout << "exec cmd: " << cmd << std::endl;
G4UImanager::GetUIpointer()->ApplyCommand( cmd );
}
}
+
+ void G4CmdQueue::prepare()
+ {
+ setInitialize();
+ reorder();
+ }
+
+ void G4CmdQueue::reorder()
+ {
+ reorderBeamOn();
+ reorderLimits();
+ }
+
+ void G4CmdQueue::reorderBeamOn()
+ {
+ bool gotBeamOn = false;
+
+ CmdVecType::iterator iter = m_commands.begin();
+ std::string cmd;
+ for ( ;
+ iter != m_commands.end();
+ iter++ ) {
+ cmd = (*iter);
+
+ if ( cmd.find("/run/beamOn") != std::string::npos ) {
+ gotBeamOn = true;
+ break;
+ }
+ }
+
+ if ( gotBeamOn ) {
+
+ /* Erase the old beamOn. */
+ m_commands.erase(iter);
+
+ /* Put the beamOn command at the end of the queue. */
+ addCmd(cmd);
+ }
+ }
+
+ void G4CmdQueue::reorderLimits()
+ {
+ bool gotLimits = false;
+ std::string limitsStr = std::string("/physics/enableLimits");
+
+ CmdVecType::iterator iter = m_commands.begin();
+ for ( ;
+ iter != m_commands.end();
+ iter++ ) {
+ std::string cmd = *iter;
+
+ if ( cmd.find(limitsStr) != std::string::npos ) {
+ gotLimits = true;
+ break;
+ }
+ }
+
+ if ( gotLimits ) {
+ m_commands.erase(iter);
+ }
+ else {
+ return;
+ }
+
+ bool gotInit = false;
+ iter = m_commands.begin();
+ for ( ;
+ iter != m_commands.end();
+ iter++ ) {
+ std::string cmd = *iter;
+
+ if ( cmd.find("/run/initialize") != std::string::npos ) {
+ gotInit = true;
+ break;
+ }
+ }
+
+ if ( gotInit ) {
+ m_commands.insert(iter + 1, limitsStr);
+ }
+ }
+
+ void G4CmdQueue::setInitialize()
+ {
+ bool setupGeom = false;
+ std::string cmd;
+ CmdVecType::iterator lastCmd;
+ for ( CmdVecType::iterator iter = m_commands.begin();
+ iter != m_commands.end();
+ iter++ ) {
+
+ cmd = (*iter);
+
+ /*
+ * Initialization should come after all LCDD commands.
+ */
+ if ( cmd.find("/lcdd/") != std::string::npos ) {
+
+ lastCmd = iter;
+
+ /* Require that the geometry location is set to initialize. */
+ if ( cmd.find("/lcdd/url") != std::string::npos ) {
+ setupGeom = true;
+ }
+ }
+
+ /* Initialize after physics selection. */
+ if ( cmd.find("/physics/select") != std::string::npos ) {
+ lastCmd = iter;
+ }
+
+ /* Use the in-order command if the user provided "-z" arg at CL. */
+ if ( cmd.find("/run/initialize") != std::string::npos ) {
+ return;
+ }
+ }
+
+ lastCmd = lastCmd + 1;
+ if ( setupGeom ) {
+ m_commands.insert(lastCmd, std::string("/run/initialize") );
+ }
+ }
};
CVSspam 0.2.8