13 modified files
slic/include
diff -u -r1.12 -r1.13
--- RunManager.hh 27 Apr 2007 01:54:32 -0000 1.12
+++ RunManager.hh 8 Jan 2010 23:18:56 -0000 1.13
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/RunManager.hh,v 1.12 2007/04/27 01:54:32 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/RunManager.hh,v 1.13 2010/01/08 23:18:56 jeremy Exp $
#ifndef SLIC_RUNMANAGER_HH
#define SLIC_RUNMANAGER_HH 1
@@ -9,33 +9,38 @@
namespace slic
{
- /**
- * @class RunManager
- * @brief Extension of G4RunManager.
- * @note Current, primary function is to initialize the default
- * physics list setup using PhysicsListManager.
- */
- class RunManager : public G4RunManager, public Module
- {
- public:
- RunManager();
- virtual ~RunManager();
+ /**
+ * @class RunManager
+ * @brief Extension of G4RunManager.
+ * @note Current, primary function is to initialize the default
+ * physics list setup using PhysicsListManager.
+ */
+ class RunManager : public G4RunManager, public Module
+ {
+ public:
+ RunManager();
+ virtual ~RunManager();
+
+ public:
+
+ void Initialize();
+ int getNumberOfEventsToRun();
+
+ protected:
+
+ void BeamOn(G4int n_event, const char* macroFile=0, G4int n_select=-1);
+ void InitializePhysics();
+ void InitializeGeometry();
+
+ private:
+ void initializeUserActions();
- public:
+ private:
- int getNumberOfEventsToRun();
+ bool m_userActionsInitialized;
+ int m_numberOfEventsToRun;
- protected:
-
- virtual void BeamOn(G4int n_event, const char* macroFile=0, G4int n_select=-1);
- virtual void InitializePhysics();
- virtual void InitializeGeometry();
-
- private:
-
- int m_numberOfEventsToRun;
-
- };
+ };
}
#endif
slic/include
diff -u -r1.35 -r1.36
--- SlicApplication.hh 17 Dec 2007 21:11:59 -0000 1.35
+++ SlicApplication.hh 8 Jan 2010 23:18:56 -0000 1.36
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/SlicApplication.hh,v 1.35 2007/12/17 21:11:59 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/SlicApplication.hh,v 1.36 2010/01/08 23:18:56 jeremy Exp $
#ifndef SLIC_SLICAPPLICATION_HH
#define SLIC_SLICAPPLICATION_HH 1
@@ -172,7 +172,7 @@
/**
* Register the PrimaryGeneratorAction.
*/
- void initializePrimaryGeneratorAction();
+ //void initializePrimaryGeneratorAction();
/**
* Initialize the Geant4 user interface.
slic/src
diff -u -r1.12 -r1.13
--- CommandLineProcessor.cc 15 May 2008 02:03:02 -0000 1.12
+++ CommandLineProcessor.cc 8 Jan 2010 23:18:56 -0000 1.13
@@ -1,4 +1,4 @@
-// $Id: CommandLineProcessor.cc,v 1.12 2008/05/15 02:03:02 jeremy Exp $
+// $Id: CommandLineProcessor.cc,v 1.13 2010/01/08 23:18:56 jeremy Exp $
#include "CommandLineProcessor.hh"
@@ -60,8 +60,8 @@
const char* optstr = m_getoptOptions.c_str();
- while (1) {
-
+ while (1)
+ {
int option_index = 0;
int c;
slic/src
diff -u -r1.2 -r1.3
--- CommandQueue.cc 27 Apr 2007 01:54:34 -0000 1.2
+++ CommandQueue.cc 8 Jan 2010 23:18:56 -0000 1.3
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/CommandQueue.cc,v 1.2 2007/04/27 01:54:34 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/CommandQueue.cc,v 1.3 2010/01/08 23:18:56 jeremy Exp $
#include "CommandQueue.hh"
@@ -9,7 +9,6 @@
{
void CommandQueue::printOut()
{
- log() << LOG::always << LOG::done;
log() << LOG::always << "************************" << LOG::done;
log() << LOG::always << "* Geant4 Command Queue *" << LOG::done;
log() << LOG::always << "************************" << LOG::done;
slic/src
diff -u -r1.20 -r1.21
--- EventSourceManager.cc 8 Dec 2009 01:04:52 -0000 1.20
+++ EventSourceManager.cc 8 Jan 2010 23:18:56 -0000 1.21
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/EventSourceManager.cc,v 1.20 2009/12/08 01:04:52 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/EventSourceManager.cc,v 1.21 2010/01/08 23:18:56 jeremy Exp $
#include "EventSourceManager.hh"
// slic
@@ -249,27 +249,28 @@
void EventSourceManager::setupEventSource(ESourceType st)
{
- // is a known source type?
+ // Is it a known source type?
if ( st != eUnknown )
{
- // is new type of source?
+ // It is a new type of source?
if ( isNewSource(st) )
{
-
- // set new source type
+ // Set new source type.
m_sourceType = st;
- // delete current source
+ // Delete current source.
deleteCurrentEventSource();
- // create new source
+ // Create new source.
m_currentEventSource = createEventSource( m_sourceType );
+#ifdef SLIC_LOG
log().okay("Created event generator <" + getCurrentSourceName() + ">");
+#endif
}
else
{
- log().warning("Type of new event source is same as old -- keeping old source.");
+ log().warning("Type of new event source is same as old; keeping old source.");
}
}
else
@@ -299,12 +300,10 @@
void EventSourceManager::beginEvent(const G4Event* anEvent)
{
- /*
- * Start the event timer, as generation occurs before EventAction::BeginOfEventAction().
- */
+ // Start the event timer, as generation occurs before EventAction::BeginOfEventAction().
EventAction::getEventAction()->startEventTimer();
- // begin event action of current source
+ // Begin event action of current source.
m_currentEventSource->beginEvent(anEvent);
}
slic/src
diff -u -r1.13 -r1.14
--- GeneratorMessenger.cc 10 Sep 2008 00:04:34 -0000 1.13
+++ GeneratorMessenger.cc 8 Jan 2010 23:18:56 -0000 1.14
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/GeneratorMessenger.cc,v 1.13 2008/09/10 00:04:34 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/GeneratorMessenger.cc,v 1.14 2010/01/08 23:18:56 jeremy Exp $
#include "GeneratorMessenger.hh"
// slic
@@ -41,32 +41,38 @@
EventSourceManager* mgr = EventSourceManager::instance();
// select
- if ( cmd == m_selectCmd ) {
+ if ( cmd == m_selectCmd )
+ {
mgr->setupEventSource( s );
}
// reset
- else if ( cmd == m_resetCmd ) {
+ else if ( cmd == m_resetCmd )
+ {
mgr->resetCurrentEventSource();
}
// skipEvents
- else if ( cmd == m_skipEventsCmd ) {
+ else if ( cmd == m_skipEventsCmd )
+ {
mgr->setSkipEvents( StringUtil::toInt( s ) );
}
// filename
- else if ( cmd == m_filenameCmd ) {
+ else if ( cmd == m_filenameCmd )
+ {
mgr->setFilename( s );
}
// dumpCurrentEvent
- else if ( cmd == m_dumpCurrentEventCmd ) {
+ else if ( cmd == m_dumpCurrentEventCmd )
+ {
mgr->dumpCurrentEvent();
}
// printNumEventsGenerated
- else if ( cmd == m_printNumEventsGeneratedCmd ) {
+ else if ( cmd == m_printNumEventsGeneratedCmd )
+ {
mgr->printNumEventsGenerated();
}
// set random seed
- else if ( cmd == m_randomSeedCmd ) {
-
+ else if ( cmd == m_randomSeedCmd )
+ {
G4int seed = 0;
// seed from user arg
@@ -85,8 +91,9 @@
mgr->log() << LOG::okay << "set random seed: " << seed << LOG::done;
}
// Lorentz transformation angle
- else if ( cmd == m_setLorentzTransformationAngleCmd ) {
- EventSourceManager::instance()->setLorentzTransformationAngle( G4UIcmdWithADoubleAndUnit::GetNewDoubleValue(newVals));
+ else if ( cmd == m_setLorentzTransformationAngleCmd )
+ {
+ EventSourceManager::instance()->setLorentzTransformationAngle(G4UIcmdWithADoubleAndUnit::GetNewDoubleValue(newVals));
}
else {
G4Exception("Unknown cmd for this messenger.");
slic/src
diff -u -r1.5 -r1.6
--- LCExtendedParticles.cc 16 Dec 2009 00:11:47 -0000 1.5
+++ LCExtendedParticles.cc 8 Jan 2010 23:18:56 -0000 1.6
@@ -9,8 +9,8 @@
namespace slic
{
- LCExtendedParticles::LCExtendedParticles( const G4String& name )
- : G4VPhysicsConstructor( name )
+ LCExtendedParticles::LCExtendedParticles(const G4String& name)
+ : G4VPhysicsConstructor(name)
{}
LCExtendedParticles::~LCExtendedParticles()
@@ -30,10 +30,10 @@
HepPDT::ParticleData pdata = it->second;
// Check for a built-in definition of this particle.
- G4ParticleDefinition* pdef = G4ParticleTable::GetParticleTable()->FindParticle( pdata.pid() );
+ G4ParticleDefinition* pdef = G4ParticleTable::GetParticleTable()->FindParticle(pdata.pid());
// Add particles that Geant4 does not already know about.
- if ( pdef == 0)
+ if (pdef == 0)
{
G4String name = "extended";
if ( id.isSUSY() )
@@ -67,22 +67,22 @@
void LCExtendedParticles::ConstructProcess()
{
theParticleIterator->reset();
- while( ( *theParticleIterator ) () )
+ while((*theParticleIterator)())
{
G4ParticleDefinition* pdef = theParticleIterator->value();
G4ProcessManager* pmgr = pdef->GetProcessManager();
- if ( pdef->GetParticleType() == "extended" || pdef->GetParticleType() == "susy" )
+ if (pdef->GetParticleType() == "extended" || pdef->GetParticleType() == "susy")
{
if (pdef->GetPDGCharge() != 0)
{
- pmgr->AddProcess( &m_scatter, -1, 1, 1 ); // multiple scattering
- pmgr->AddProcess( &m_ionise, -1, 2, 2 ); // ionisation
- pmgr->AddProcess( &m_decay, -1, -1, 3 ); // decay
+ pmgr->AddProcess(&m_scatter, -1, 1, 1); // multiple scattering
+ pmgr->AddProcess(&m_ionise, -1, 2, 2); // ionisation
+ pmgr->AddProcess(&m_decay, -1, -1, 2); // decay
}
else
{
- pmgr->AddProcess( &m_scatter, -1, 1, 1 ); // multiple scattering
- pmgr->AddProcess( &m_decay, -1, -1, 2 ); // decay
+ pmgr->AddProcess(&m_scatter, -1, 1, 1); // multiple scattering
+ pmgr->AddProcess(&m_decay, -1, -1, 2); // decay
}
}
}
slic/src
diff -u -r1.4 -r1.5
--- ParticleGunEventSource.cc 27 Apr 2007 01:54:35 -0000 1.4
+++ ParticleGunEventSource.cc 8 Jan 2010 23:18:56 -0000 1.5
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/ParticleGunEventSource.cc,v 1.4 2007/04/27 01:54:35 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/ParticleGunEventSource.cc,v 1.5 2010/01/08 23:18:56 jeremy Exp $
#include "ParticleGunEventSource.hh"
// geant4
@@ -7,38 +7,38 @@
namespace slic
{
- ParticleGunEventSource::ParticleGunEventSource()
- : EventSource( "ParticleGunEventSource" )
- {
- m_generator = new G4ParticleGun();
- }
-
- ParticleGunEventSource::~ParticleGunEventSource()
- {
- delete m_generator;
- }
-
- void ParticleGunEventSource::generate(G4Event* evt)
- {
- m_generator->GeneratePrimaryVertex(evt);
- }
-
- void ParticleGunEventSource::dumpCurrentEvent()
- {
- log() << LOG::okay << "Dumping ParticleGun Event info..." << LOG::done;
-
- G4ParticleDefinition* pdef = m_generator->GetParticleDefinition();
-
- log() << LOG::okay << "particle: " << pdef->GetParticleName() << LOG::done;
- log() << LOG::okay << "time: " << m_generator->GetParticleTime () << LOG::done;
- log() << LOG::okay << "pos: " << m_generator->GetParticlePosition () << LOG::done;
- log() << LOG::okay << "mom: " << m_generator->GetParticleMomentumDirection() << LOG::done;
- log() << LOG::okay << "E: " << m_generator->GetParticleEnergy() << LOG::done;
- log() << LOG::okay << LOG::done;
- }
-
- G4ParticleGun* ParticleGunEventSource::getParticleGun()
- {
- return m_generator;
- }
+ ParticleGunEventSource::ParticleGunEventSource()
+ : EventSource( "ParticleGunEventSource" )
+ {
+ m_generator = new G4ParticleGun();
+ }
+
+ ParticleGunEventSource::~ParticleGunEventSource()
+ {
+ delete m_generator;
+ }
+
+ void ParticleGunEventSource::generate(G4Event* evt)
+ {
+ m_generator->GeneratePrimaryVertex(evt);
+ }
+
+ void ParticleGunEventSource::dumpCurrentEvent()
+ {
+ log() << LOG::okay << "Dumping ParticleGun Event info..." << LOG::done;
+
+ G4ParticleDefinition* pdef = m_generator->GetParticleDefinition();
+
+ log() << LOG::okay << "particle: " << pdef->GetParticleName() << LOG::done;
+ log() << LOG::okay << "time: " << m_generator->GetParticleTime () << LOG::done;
+ log() << LOG::okay << "pos: " << m_generator->GetParticlePosition () << LOG::done;
+ log() << LOG::okay << "mom: " << m_generator->GetParticleMomentumDirection() << LOG::done;
+ log() << LOG::okay << "E: " << m_generator->GetParticleEnergy() << LOG::done;
+ log() << LOG::okay << LOG::done;
+ }
+
+ G4ParticleGun* ParticleGunEventSource::getParticleGun()
+ {
+ return m_generator;
+ }
}
slic/src
diff -u -r1.24 -r1.25
--- PhysicsListManager.cc 23 Nov 2009 23:13:34 -0000 1.24
+++ PhysicsListManager.cc 8 Jan 2010 23:18:56 -0000 1.25
@@ -1,8 +1,7 @@
-// $Header: /cvs/lcd/slic/src/PhysicsListManager.cc,v 1.24 2009/11/23 23:13:34 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/PhysicsListManager.cc,v 1.25 2010/01/08 23:18:56 jeremy Exp $
#include "PhysicsListManager.hh"
// geant4
-#include "G4ParticleTable.hh"
#include "G4UserSpecialCuts.hh"
#include "G4StepLimiter.hh"
#include "G4RunManager.hh"
@@ -11,13 +10,11 @@
// slic
#include "LCOpticalPhysics.hh"
#include "HepPDTManager.hh"
-#include "LCSUSYPhysics.hh"
#include "LCExtendedParticles.hh"
namespace slic
{
-
- // QGSP_BERT is the default physics list when none is selected at runtime.
+ // QGSP_BERT is the default physics list.
const std::string PhysicsListManager::m_defaultListName = std::string("QGSP_BERT");
PhysicsListManager::PhysicsListManager()
@@ -34,9 +31,6 @@
// Create the messenger class for the manager.
m_messenger = new PhysicsMessenger();
-
- // Initialize a default (or dummy) physics list, for Geant4 initialization ordering.
- G4RunManager::GetRunManager()->SetUserInitialization( PhysicsListFactory::instance()->create( m_defaultListName ) );
}
PhysicsListManager::~PhysicsListManager()
@@ -44,58 +38,53 @@
void PhysicsListManager::setCurrentListName(const std::string& n)
{
- log().okay("Setting physics list <" + n + ">");
m_currentListName = n;
m_isFromDefault = false;
}
void PhysicsListManager::initializePhysicsList()
{
- if ( !m_isInitialized ) {
-
+ if ( !m_isInitialized )
+ {
#ifdef SLIC_LOG
- if ( m_isFromDefault ) {
+ if ( m_isFromDefault )
+ {
log() << LOG::okay << "Using default physics list <" << m_defaultListName << ">." << LOG::done;
}
#endif
// Create the physics list from the name argument.
- m_currentList = PhysicsListFactory::instance()->create( m_currentListName );
-
- // Support for extended set of particles from PDT.
- setupExtended();
+ m_currentList = PhysicsListFactory::instance()->create(m_currentListName);
// Enable optical processes.
- if ( enableOptical() ) {
+ if ( enableOptical() )
+ {
setupOpticalProcesses();
}
- G4RunManager::GetRunManager()->SetUserInitialization( m_currentList );
+ // Support for extended set of particles from PDT.
+ setupExtended();
+
+ // Register the physics list with the run manager.
+ G4RunManager::GetRunManager()->SetUserInitialization(m_currentList);
-#ifdef SLIC_LOG
- log().okay( "Registered physics list <" + m_currentListName + "> with G4RunManager" );
- log() << LOG::debug << "Dumping Geant4 particle table ..." << LOG::done;
- // Use log level to determine whether particle table should be dumped.
- if ( log().getOutputLevel() >= LOG::verbose )
- G4ParticleTable::GetParticleTable()->DumpTable(); // FIXME: Goes to G4cout.
-#endif
+ // Print out particle table.
+ //G4cout << "Dumping Geant4 particle table ..." << G4endl;
+ //G4ParticleTable::GetParticleTable()->DumpTable();
m_isInitialized = true;
}
#ifdef SLIC_LOG
- // Don't allow this to be called twice.
- else {
- log().error("Ignoring additional call to PhysicsListManager::initializePhysics()");
+ // Don't allow initialization to be called more than once.
+ else
+ {
+ log().error("Ignoring additional call to PhysicsListManager::initializePhysics() !!!");
}
#endif
}
void PhysicsListManager::setupUserLimitsProcesses()
- {
-#ifdef SLIC_LOG
- log() << LOG::okay << "Enabling user physics limits." << LOG::done;
-#endif
-
+ {
G4ParticleTable* ptbl = G4ParticleTable::GetParticleTable();
G4ParticleTable::G4PTblDicIterator* piter = ptbl->GetIterator();
@@ -109,8 +98,9 @@
G4ParticleDefinition* pdef = piter->value();
G4ProcessManager* pmgr = pdef->GetProcessManager();
- // add user limit processes for steps and special cuts
- if ( pmgr ) {
+ // Add user limit processes for steps and special cuts.
+ if ( pmgr )
+ {
pmgr->AddProcess( slim,
-1,
-1,
@@ -121,8 +111,9 @@
-1,
4);
}
- else {
- G4Exception( "ERROR: G4ProcessManager is null!" );
+ else
+ {
+ G4Exception("ERROR: G4ProcessManager is null!");
}
}
}
@@ -132,38 +123,20 @@
#ifdef SLIC_LOG
log() << LOG::always << "Enabling optical physics processes for the current physics list." << LOG::done;
#endif
- G4VModularPhysicsList* l = dynamic_cast<G4VModularPhysicsList*> ( m_currentList );
- l->RegisterPhysics( new LCOpticalPhysics("optical"));
- }
-
- void PhysicsListManager::setupSUSY()
- {
-#ifdef SLIC_LOG
- log() << LOG::always << "Enabling SUSY particles for the current physics list." << LOG::done;
-#endif
- G4VModularPhysicsList* l = dynamic_cast<G4VModularPhysicsList*> ( m_currentList );
- if ( HepPDTManager::instance()->getParticleDataTable() )
- {
- l->RegisterPhysics( new LCSUSYPhysics() );
- }
-#ifdef SLIC_LOG
- else
- {
- log() << LOG::error << "HepPDTManager could not load particle data, so SUSY will not be enabled!" << LOG::done;
- }
-#endif
- }
+ G4VModularPhysicsList* l = dynamic_cast<G4VModularPhysicsList*>(m_currentList);
+ l->RegisterPhysics(new LCOpticalPhysics("optical"));
+ }
void PhysicsListManager::setupExtended()
{
#ifdef SLIC_LOG
- log() << LOG::always << "Enabling extended PDT particles for the current physics list." << LOG::done;
+ log().always("Enabling extended PDT particles for the current physics list.");
#endif
- G4VModularPhysicsList* l = dynamic_cast<G4VModularPhysicsList*> ( m_currentList );
- if ( HepPDTManager::instance()->getParticleDataTable() )
+ G4VModularPhysicsList* l = dynamic_cast<G4VModularPhysicsList*>(m_currentList);
+ if (HepPDTManager::instance()->getParticleDataTable())
{
- l->RegisterPhysics( new LCExtendedParticles() );
+ l->RegisterPhysics(new LCExtendedParticles());
}
#ifdef SLIC_LOG
else
slic/src
diff -u -r1.23 -r1.24
--- PhysicsMessenger.cc 11 Apr 2008 03:20:19 -0000 1.23
+++ PhysicsMessenger.cc 8 Jan 2010 23:18:56 -0000 1.24
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/PhysicsMessenger.cc,v 1.23 2008/04/11 03:20:19 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/PhysicsMessenger.cc,v 1.24 2010/01/08 23:18:56 jeremy Exp $
#include "PhysicsMessenger.hh"
// slic
@@ -36,20 +36,24 @@
PhysicsListManager* mgr = PhysicsListManager::instance();
// set physics list
- if ( cmd == m_selectCmd ) {
+ if ( cmd == m_selectCmd )
+ {
mgr->setCurrentListName( s );
}
// print available lists
- else if ( cmd == m_printListsCmd ) {
+ else if ( cmd == m_printListsCmd )
+ {
PhysicsListFactory::instance()->printAvailableLists();
}
// print current list and whether initialized
- else if ( cmd == m_printCurrentCmd ) {
+ else if ( cmd == m_printCurrentCmd )
+ {
mgr->log() << LOG::okay << "Current physics list <" << mgr->getCurrentListName() << ">." << LOG::done;
mgr->log() << LOG::okay << "Physics has been initialized <" << mgr->isInitialized() << ">." << LOG::done;
}
// Enable optical physics processes.
- else if ( cmd == m_enableOpticalCmd ) {
+ else if ( cmd == m_enableOpticalCmd )
+ {
bool enableOptical=true;
if (newVals != G4String("") )
enableOptical = G4UIcmdWithABool::GetNewBoolValue(newVals);
slic/src
diff -u -r1.16 -r1.17
--- RunManager.cc 27 Apr 2007 01:54:35 -0000 1.16
+++ RunManager.cc 8 Jan 2010 23:18:56 -0000 1.17
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/RunManager.cc,v 1.16 2007/04/27 01:54:35 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/RunManager.cc,v 1.17 2010/01/08 23:18:56 jeremy Exp $
#include "RunManager.hh"
// lcdd
@@ -6,7 +6,14 @@
#include "LCDDProcessor.hh"
// slic
+#include "EventAction.hh"
+#include "EventSourceManager.hh"
+#include "ModuleRegistry.hh"
#include "PhysicsListManager.hh"
+#include "PrimaryGeneratorAction.hh"
+#include "RunAction.hh"
+#include "SteppingAction.hh"
+#include "TrackingAction.hh"
// geant4
#include "G4StateManager.hh"
@@ -15,57 +22,93 @@
namespace slic
{
- RunManager::RunManager() :
- Module("RunManager", false)
- {}
-
- RunManager::~RunManager()
- {}
-
- void RunManager::InitializePhysics()
- {
- /* Initialize the physics list in SLIC. */
- PhysicsListManager::instance()->initializePhysicsList();
-
- /* Call G4RunManager's init function to setup physics. */
- G4RunManager::InitializePhysics();
-
- /* Check if the LCDD subsystem got some limits from the input file. */
- LCDDProcessor* lcdd = LCDDProcessor::instance();
- PhysicsListManager* pmgr = PhysicsListManager::instance();
- if ( lcdd->getLimitSetsBegin() != lcdd->getLimitSetsEnd() ) {
- pmgr->enableLimits(true);
+ RunManager::RunManager() :
+ Module("RunManager", false),
+ m_userActionsInitialized(false)
+ {}
+
+ RunManager::~RunManager()
+ {}
+
+ void RunManager::initializeUserActions()
+ {
+ SetUserAction(new PrimaryGeneratorAction);
+ SetUserAction(new RunAction);
+ SetUserAction(new EventAction);
+ SetUserAction(new TrackingAction);
+ SetUserAction(new SteppingAction);
+ m_userActionsInitialized = true;
}
- /* enable physics limits, if necessary */
- if ( pmgr->enableLimits() ) {
- pmgr->setupUserLimitsProcesses();
+
+ void RunManager::Initialize()
+ {
+ // This makes sure that physics initialization occurs before other user actions.
+ G4RunManager::Initialize();
+
+ // Initialize user actions here to avoid ordering problems.
+ if (!m_userActionsInitialized)
+ initializeUserActions();
+
+ // Initialize the event generation manager.
+ EventSourceManager::instance();
+
+ // Setup the default event source.
+ EventSourceManager::instance()->setupEventSource();
+
+ // Print list of registered modules.
+#ifdef SLIC_LOG
+ ModuleRegistry::instance()->print();
+#endif
}
- }
- // called before InitializePhysics()
- void RunManager::InitializeGeometry()
- {
- if ( !LCDDParser::instance()->isValidSetup() ) {
- G4Exception("FATAL ERROR: Current LCDD geometry setup is not valid.");
+ void RunManager::InitializePhysics()
+ {
+ // Initialize the physics list.
+ PhysicsListManager::instance()->initializePhysicsList();
+
+ // Call the G4RunManager's intitialization method.
+ G4RunManager::InitializePhysics();
+
+ // Check if the LCDD subsystem got some limits.
+ LCDDProcessor* lcdd = LCDDProcessor::instance();
+ PhysicsListManager* pmgr = PhysicsListManager::instance();
+ if ( lcdd->getLimitSetsBegin() != lcdd->getLimitSetsEnd() )
+ {
+ pmgr->enableLimits(true);
+ }
+
+ // Enable physics limits, if necessary.
+ if ( pmgr->enableLimits() )
+ {
+ pmgr->setupUserLimitsProcesses();
+ }
}
- G4RunManager::InitializeGeometry();
- }
+ void RunManager::InitializeGeometry()
+ {
+ if ( !LCDDParser::instance()->isValidSetup() )
+ {
+ G4Exception("FATAL ERROR: Current LCDD geometry setup is not valid.");
+ }
- void RunManager::BeamOn(G4int n_event, const char* macroFile, G4int n_select)
- {
- /* Attempt to initialize Geant4 if not in idle state. */
- if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_Idle ) {
- this->Initialize();
+ G4RunManager::InitializeGeometry();
}
- m_numberOfEventsToRun = n_event;
+ void RunManager::BeamOn(G4int n_event, const char* macroFile, G4int n_select)
+ {
+ // Attempt to initialize Geant4 if not in idle state.
+ if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_Idle )
+ {
+ this->Initialize();
+ }
+
+ m_numberOfEventsToRun = n_event;
- G4RunManager::BeamOn(n_event, macroFile, n_select);
- }
+ G4RunManager::BeamOn(n_event, macroFile, n_select);
+ }
- int RunManager::getNumberOfEventsToRun()
- {
- return m_numberOfEventsToRun;
- }
+ int RunManager::getNumberOfEventsToRun()
+ {
+ return m_numberOfEventsToRun;
+ }
}
slic/src
diff -u -r1.48 -r1.49
--- SlicApplication.cc 7 Jul 2009 21:39:19 -0000 1.48
+++ SlicApplication.cc 8 Jan 2010 23:18:56 -0000 1.49
@@ -1,27 +1,20 @@
-// $Header: /cvs/lcd/slic/src/SlicApplication.cc,v 1.48 2009/07/07 21:39:19 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/SlicApplication.cc,v 1.49 2010/01/08 23:18:56 jeremy Exp $
#include "SlicApplication.hh"
// slic
#include "CommandLineProcessor.hh"
#include "CommandQueue.hh"
-#include "EventAction.hh"
#include "EventDebugger.hh"
-#include "EventSourceManager.hh"
#include "FieldManager.hh"
#include "SlicApplicationMessenger.hh"
#include "LCDD.hh"
#include "LcioManager.hh"
#include "ModuleRegistry.hh"
#include "PackageInfo.hh"
-#include "PhysicsListManager.hh"
-#include "PrimaryGeneratorAction.hh"
-#include "RunAction.hh"
#include "RunManager.hh"
-#include "SteppingAction.hh"
#include "StringUtil.hh"
#include "TimeUtil.hh"
-#include "TrackingAction.hh"
#include "TrajectoryManager.hh"
#include "HepPDTManager.hh"
@@ -58,353 +51,326 @@
#include "G4Version.hh"
#endif
+#include "PhysicsListManager.hh"
+
namespace slic
{
- SlicApplication::SlicApplication()
- : Module("SLIC", false),
- m_session(0),
+ SlicApplication::SlicApplication()
+ : Module("SlicApplication", false),
+ m_session(0),
#ifdef G4VIS_USE
- m_visManager(0),
+ m_visManager(0),
+#endif
+ m_appMessenger(0),
+ m_runManager(0),
+ m_mode(SlicApplication::eBatch),
+ m_returnCode(0),
+ m_setRunAbort(false),
+ m_isInitialized(false),
+ m_geant4VersionString(0)
+ {
+#ifdef SLIC_LOG
+ log() << LOG::okay << LOG::head << "SLIC is starting." << LOG::done;
#endif
- m_appMessenger(0),
- m_runManager(0),
- m_mode(SlicApplication::eBatch),
- m_returnCode(0),
- m_setRunAbort(false),
- m_isInitialized(false),
- m_geant4VersionString(0)
- {
- log() << LOG::okay << LOG::head << "SLIC is starting" << LOG::done;
- }
-
- SlicApplication::~SlicApplication()
- {
- if (m_session != 0) {
- delete m_session;
}
- if (m_appMessenger != 0) {
- delete m_appMessenger;
- }
+ SlicApplication::~SlicApplication()
+ {
+ if (m_session != 0)
+ {
+ delete m_session;
+ }
+
+ if (m_appMessenger != 0)
+ {
+ delete m_appMessenger;
+ }
- // Delete all the modules. Only seems to work without seg fault on Linux.
- // https://jira.slac.stanford.edu/browse/SLIC-185
+ // Delete all the modules. Only seems to work without seg fault on Linux.
+ // https://jira.slac.stanford.edu/browse/SLIC-185
#ifdef linux
#ifdef SLIC_LOG
- log().debug("Deleting registered modules ...");
+ log().debug("Deleting registered modules ...");
#endif
- ModuleRegistry::instance()->deleteModules();
+ ModuleRegistry::instance()->deleteModules();
#endif
- // Delete the G4RunManager, which also deletes
- // all the Geant4-related modules, such as
- // RunAction.
- log().debug("Deleting G4RunManager ...");
- delete G4RunManager::GetRunManager();
-
- log() << LOG::okay << LOG::head << "SLIC is exiting" << LOG::done;
- }
-
- void SlicApplication::initialize(int argc, char** argv)
- {
- // Set the name and basename of slic's binary from the command line arguments.
- m_binaryname = std::string(argv[0]);
- setBinaryBasename();
-
- // Process arguments using the CommandLineProcessor.
- CommandLineProcessor* cmd = CommandLineProcessor::instance();
- cmd->process(argc, argv);
- }
-
- void SlicApplication::initialize()
- {
- if (!m_isInitialized) {
-
- // Initialize the application messenger.
- m_appMessenger = new SlicApplicationMessenger(this);
-
- // Initialize the event generation manager.
- EventSourceManager::instance();
+ // Delete the G4RunManager, which also deletes all the Geant4-related modules.
+#ifdef SLIC_LOG
+ log().debug("Deleting G4RunManager ...");
+#endif
+ delete G4RunManager::GetRunManager();
#ifdef SLIC_LOG
- log().okay("SLIC logging system is enabled.");
-#else
- log().okay("SLIC logging system is disabled.");
+ log() << LOG::okay << LOG::head << "SLIC is exiting." << LOG::done;
#endif
+ }
- // Create a new RunManager.
- m_runManager = new RunManager();
+ void SlicApplication::initialize(int argc, char** argv)
+ {
+ // Set the name and basename of slic's binary from the command line arguments.
+ m_binaryname = std::string(argv[0]);
+ setBinaryBasename();
- // Initialize the physics list manager.
- PhysicsListManager::instance();
+ // Process arguments using the CommandLineProcessor.
+ CommandLineProcessor* cmd = CommandLineProcessor::instance();
+ cmd->process(argc, argv);
+ }
- // Setup the default event source AFTER PHYSICS.
- EventSourceManager::instance()->setupEventSource();
+ void SlicApplication::initialize()
+ {
+ if (!m_isInitialized)
+ {
+ // Print the SLIC splash screen.
+ printSplashScreen();
- // Print the SLIC splash screen.
- printSplashScreen();
+ // Initialize the application messenger.
+ m_appMessenger = new SlicApplicationMessenger(this);
- // Initialize the LcioManager.
- LcioManager::instance();
+ // Create a new RunManager.
+ m_runManager = new RunManager();
- // Initialize the EventDebugger.
- EventDebugger::instance();
+ // Initialize the physics list manager.
+ PhysicsListManager::instance();
- // Initialize the magnetic field messenger.
- FieldManager::instance();
+ // Initialize the LcioManager.
+ LcioManager::instance();
- // Setup the generator.
- initializePrimaryGeneratorAction();
+ // Initialize the magnetic field messenger.
+ FieldManager::instance();
- // Setup the LCDD subsystem.
- initializeLCDD();
+ // Setup the LCDD subsystem.
+ initializeLCDD();
#ifdef USE_G4NIST
- // Setup the NIST Writer.
- initializeNistWriter();
+ // Setup the NIST Writer.
+ initializeNistWriter();
#endif
- // Construct and register the UserAction classes.
- initializeUserActions();
-
- // Initialize visualization.
+ // Initialize visualization.
#ifdef G4VIS_USE
- initializeVis();
+ initializeVis();
#endif
- // Initialize the UI.
+ // Initialize the UI.
#ifndef G4UI_NONE
- initializeUI();
+ initializeUI();
#endif
- HepPDTManager::instance();
+ HepPDTManager::instance();
- // Print list of registered modules.
-#ifdef SLIC_LOG
- log().always("Printing list of registered modules ...");
- ModuleRegistry::instance()->print();
-#endif
-
- // Set state variable.
- m_isInitialized = true;
- }
- else {
- log().warning("Call to SlicApplication::initialize() was ignored. SLIC is already initialized!");
+ // Set state variable.
+ m_isInitialized = true;
+ }
+ else
+ {
+ log().warning("Call to SlicApplication::initialize() was ignored. SLIC is already initialized!");
+ }
}
- }
#ifndef G4UI_NONE
- void SlicApplication::initializeUI()
- {
- // A tcsh terminal.
+ void SlicApplication::initializeUI()
+ {
+ // A tcsh terminal.
#ifdef G4UI_USE_TCSH
- m_session = new G4UIterminal(new G4UItcsh);
+ m_session = new G4UIterminal(new G4UItcsh);
- // A csh terminal.
+ // A csh terminal.
#elif G4UI_USE_CSH
- m_session = new G4UIterminal(new G4UIcsh);
+ m_session = new G4UIterminal(new G4UIcsh);
- // GAG.
+ // GAG.
#elif G4UI_USE_GAG
- session = new G4UIGAG;
+ session = new G4UIGAG;
- // Motif GUI.
+ // Motif GUI.
#elif G4UI_USE_XM
- m_session = new G4UIXm( 0, NULL );
+ m_session = new G4UIXm( 0, NULL );
- // Add file and exit buttons to Motif UI
- if ( m_session ) {
- G4UImanager* ui = G4UImanager::GetUIpointer();
- ui->ApplyCommand("/gui/addMenu file File");
- ui->ApplyCommand("/gui/addButton file Exit \"exit\"");
- }
- // Plain terminal is the fallback.
+ // Add file and exit buttons to Motif UI
+ if ( m_session )
+ {
+ G4UImanager* ui = G4UImanager::GetUIpointer();
+ ui->ApplyCommand("/gui/addMenu file File");
+ ui->ApplyCommand("/gui/addButton file Exit \"exit\"");
+ }
+ // Plain terminal is the fallback.
#else
- m_session = new G4UIterminal();
+ m_session = new G4UIterminal();
#endif
- if ( !m_session ) {
- log().fatal( "Failed to initialize UI session." );
- G4Exception( "Failed to initialize UI session." );
+ if ( !m_session )
+ {
+ log().fatal( "Failed to initialize UI session." );
+ G4Exception( "Failed to initialize UI session." );
+ }
}
- }
#endif
#ifdef G4VIS_USE
- void SlicApplication::initializeVis()
- {
- m_visManager = new VisManager();
- m_visManager->Initialize();
+ void SlicApplication::initializeVis()
+ {
+ m_visManager = new VisManager();
+ m_visManager->Initialize();
- // VRML test
- new VRML2WriterMessenger();
- }
-#endif
-
- void SlicApplication::initializeLCDD()
- {
- // LCDD geometry subsystem.
- m_runManager->SetUserInitialization((new LCDD())->getDetectorConstruction());
- }
-
- void SlicApplication::initializePrimaryGeneratorAction()
- {
- // Primary generator.
- m_runManager->SetUserAction(new PrimaryGeneratorAction);
- }
-
- void SlicApplication::initializeUserActions()
- {
- // SLIC's UserAction handlers.
- m_runManager->SetUserAction(new RunAction);
- m_runManager->SetUserAction(new EventAction);
- m_runManager->SetUserAction(new TrackingAction);
- m_runManager->SetUserAction(new SteppingAction);
- }
-
- void SlicApplication::setMode(SlicApplication::ERunMode rmode)
- {
- m_mode = rmode;
- }
-
- const std::string& SlicApplication::getBinaryName() const
- {
- return m_binaryname;
- }
-
- const std::string& SlicApplication::getBinaryBasename() const
- {
- return m_binarybasename;
- }
-
- int SlicApplication::getReturnCode() const
- {
- return m_returnCode;
- }
-
- void SlicApplication::setReturnCode(int rc)
- {
- m_returnCode = rc;
- }
-
- void SlicApplication::setBinaryBasename()
- {
- std::string::size_type sidx = m_binaryname.find_last_of('/');
- if (sidx != std::string::npos) {
- m_binarybasename = std::string(m_binaryname, sidx + 1);
- }
- }
-
- SlicApplication::ERunMode SlicApplication::getMode() const
- {
- return m_mode;
- }
-
- void SlicApplication::setAborting(bool a)
- {
- if (a) {
- // FIXME: Does this actually do anything to current G4Event?
- G4RunManager::GetRunManager()->AbortRun(a);
- }
-
- m_setRunAbort = a;
- }
-
- bool SlicApplication::isAborting() const
- {
- return m_setRunAbort;
- }
-
- RunManager* SlicApplication::getRunManager()
- {
- return m_runManager;
- }
-
- void SlicApplication::run()
- {
- // Initialize if not already.
- if (!m_isInitialized) {
- initialize();
+ // VRML test
+ new VRML2WriterMessenger();
+ }
+#endif
+
+ void SlicApplication::initializeLCDD()
+ {
+ // LCDD geometry subsystem.
+ m_runManager->SetUserInitialization((new LCDD())->getDetectorConstruction());
+ }
+
+ void SlicApplication::setMode(SlicApplication::ERunMode rmode)
+ {
+ m_mode = rmode;
+ }
+
+ const std::string& SlicApplication::getBinaryName() const
+ {
+ return m_binaryname;
+ }
+
+ const std::string& SlicApplication::getBinaryBasename() const
+ {
+ return m_binarybasename;
+ }
+
+ int SlicApplication::getReturnCode() const
+ {
+ return m_returnCode;
+ }
+
+ void SlicApplication::setReturnCode(int rc)
+ {
+ m_returnCode = rc;
+ }
+
+ void SlicApplication::setBinaryBasename()
+ {
+ std::string::size_type sidx = m_binaryname.find_last_of('/');
+ if (sidx != std::string::npos)
+ {
+ m_binarybasename = std::string(m_binaryname, sidx + 1);
+ }
+ }
+
+ SlicApplication::ERunMode SlicApplication::getMode() const
+ {
+ return m_mode;
+ }
+
+ void SlicApplication::setAborting(bool a)
+ {
+ if (a) {
+ // FIXME: Does this actually do anything to current G4Event?
+ G4RunManager::GetRunManager()->AbortRun(a);
+ }
+
+ m_setRunAbort = a;
}
- // Retrieve the list of Geant4 commands created by CommandLineProcessor.
- CommandQueue* q = CommandLineProcessor::instance()->getCommandQueue();
+ bool SlicApplication::isAborting() const
+ {
+ return m_setRunAbort;
+ }
+
+ RunManager* SlicApplication::getRunManager()
+ {
+ return m_runManager;
+ }
- // Print, execute, and clear the CommandQueue.
+ void SlicApplication::run()
+ {
+ // Initialize if not already.
+ if (!m_isInitialized)
+ {
+ initialize();
+ }
+
+ // Retrieve the list of Geant4 commands created by CommandLineProcessor.
+ CommandQueue* q = CommandLineProcessor::instance()->getCommandQueue();
+
+ // Print, execute, and clear the CommandQueue.
#ifdef SLIC_LOG
- log().verbose("Printing the Geant4 command queue ...");
- q->printOut();
+ log().verbose("Printing the Geant4 command queue ...");
+ q->printOut();
#endif
- q->execute();
- q->clear();
+ q->execute();
+ q->clear();
- // Start the UI session if in interactive mode.
+ // Start the UI session if in interactive mode.
#ifndef G4UI_NONE
- if ( getMode() == eInteractive ) {
- log().verbose("Starting interactive session ...");
- m_session->SessionStart();
- }
+ if ( getMode() == eInteractive )
+ {
+ log().verbose("Starting interactive session ...");
+ m_session->SessionStart();
+ }
#endif
- }
+ }
- void SlicApplication::printVersion()
- {
- CommandLineProcessor::instance()->printVersion();
- }
-
- void SlicApplication::printSplashScreen()
- {
- log() << LOG::always << "*************************************************************" << LOG::done;
- log() << LOG::always << " App : " << PackageInfo::getNameString() << " (" << PackageInfo::getAbbrevString() << ")" << LOG::done;
- log() << LOG::always << " Version : " << PackageInfo::getVersionString() << LOG::done;
- log() << LOG::always << " Date : " << PackageInfo::getChangeDateString() << LOG::done;
- log() << LOG::always << " Authors : " << PackageInfo::getAuthorString() << LOG::done;
- log() << LOG::always << " Inst : " << PackageInfo::getInstitutionString() << LOG::done;
- log() << LOG::always << " WWW : " << PackageInfo::getWWW() << LOG::done;
- log() << LOG::always << " Contact : " << PackageInfo::getEmail() << LOG::done;
- log() << LOG::always << "*************************************************************" << LOG::done;
- log() << LOG::always << LOG::done;
- }
-
- void SlicApplication::printUsage()
- {
- CommandLineProcessor::instance()->printUsage();
- }
+ void SlicApplication::printVersion()
+ {
+ CommandLineProcessor::instance()->printVersion();
+ }
+
+ void SlicApplication::printSplashScreen()
+ {
+ log() << LOG::done;
+ log() << LOG::always << "*************************************************************" << LOG::done;
+ log() << LOG::always << " App : " << PackageInfo::getNameString() << " (" << PackageInfo::getAbbrevString() << ")" << LOG::done;
+ log() << LOG::always << " Version : " << PackageInfo::getVersionString() << LOG::done;
+ log() << LOG::always << " Date : " << PackageInfo::getChangeDateString() << LOG::done;
+ log() << LOG::always << " Authors : " << PackageInfo::getAuthorString() << LOG::done;
+ log() << LOG::always << " Inst : " << PackageInfo::getInstitutionString() << LOG::done;
+ log() << LOG::always << " WWW : " << PackageInfo::getWWW() << LOG::done;
+ log() << LOG::always << " Contact : " << PackageInfo::getEmail() << LOG::done;
+ log() << LOG::always << "*************************************************************" << LOG::done;
+ }
+
+ void SlicApplication::printUsage()
+ {
+ CommandLineProcessor::instance()->printUsage();
+ }
#ifdef USE_G4NIST
- void SlicApplication::initializeNistWriter()
- {
- new NistWriterMessenger();
- }
+ void SlicApplication::initializeNistWriter()
+ {
+ new NistWriterMessenger();
+ }
#endif
- std::string SlicApplication::getGeant4VersionString()
- {
- if (m_geant4VersionString == 0) {
- std::string g4ver;
+ std::string SlicApplication::getGeant4VersionString()
+ {
+ if (m_geant4VersionString == 0)
+ {
+ std::string g4ver;
#ifdef HAVE_G4VERSION
- g4ver = StringUtil::toString(G4VERSION_NUMBER);
+ g4ver = StringUtil::toString(G4VERSION_NUMBER);
#else
- // Massage the string returned by G4RunManager into format
- // returned by G4Version in recent Geant4 versions.
- g4ver = G4RunManager::GetRunManager()->GetVersionString();
- std::string::size_type start = g4ver.find("geant4-",0) + 7;
- std::string::size_type end = g4ver.find(" ",start);
- g4ver = g4ver.substr(start, end - start);
- std::string g4major = g4ver.substr(1,1);
- std::string g4minor = g4ver.substr(4,1);
- std::string g4patch = "0";
- if (g4ver.find("patch") != string::npos) {
- g4patch = g4ver.substr(13,1);
- }
- g4ver = g4major + g4minor + g4patch;
-#endif
- std::stringstream s;
- s << "geant4-" << "v" << g4ver[0] << "r" << g4ver[1] << "p" << g4ver[2];
- m_geant4VersionString = new std::string(s.str());
+ // Massage the string returned by G4RunManager into format
+ // returned by G4Version in recent Geant4 versions.
+ g4ver = G4RunManager::GetRunManager()->GetVersionString();
+ std::string::size_type start = g4ver.find("geant4-",0) + 7;
+ std::string::size_type end = g4ver.find(" ",start);
+ g4ver = g4ver.substr(start, end - start);
+ std::string g4major = g4ver.substr(1,1);
+ std::string g4minor = g4ver.substr(4,1);
+ std::string g4patch = "0";
+ if (g4ver.find("patch") != string::npos) {
+ g4patch = g4ver.substr(13,1);
+ }
+ g4ver = g4major + g4minor + g4patch;
+#endif
+ std::stringstream s;
+ s << "geant4-" << "v" << g4ver[0] << "r" << g4ver[1] << "p" << g4ver[2];
+ m_geant4VersionString = new std::string(s.str());
+ }
+ return *m_geant4VersionString;
}
- return *m_geant4VersionString;
- }
} // namespace slic
slic/src
diff -u -r1.1 -r1.2
--- SlicMain.cc 27 Apr 2007 01:54:35 -0000 1.1
+++ SlicMain.cc 8 Jan 2010 23:18:56 -0000 1.2
@@ -1,4 +1,4 @@
-// $Id: SlicMain.cc,v 1.1 2007/04/27 01:54:35 jeremy Exp $
+// $Id: SlicMain.cc,v 1.2 2010/01/08 23:18:56 jeremy Exp $
#include "SlicMain.hh"
@@ -26,8 +26,8 @@
SlicApplication* slicApp = 0;
// Top-level try block.
- try {
-
+ try
+ {
// Create the SLIC application using singleton function.
slicApp = SlicApplication::instance();
@@ -41,11 +41,13 @@
returnCode = slicApp->getReturnCode();
}
// Catch an std::exception.
- catch(std::exception& stde) {
+ catch(std::exception& stde)
+ {
log() << LOG::error << stde.what() << LOG::done;
}
// Catch an unknown exception.
- catch(...) {
+ catch(...)
+ {
log() << LOG::error << "Top-level flak catcher caught unknown exception!" << LOG::done;
}
CVSspam 0.2.8