slic/src
diff -u -r1.10 -r1.11
--- LcioMcpFactory.cc 26 Aug 2008 23:15:31 -0000 1.10
+++ LcioMcpFactory.cc 10 Sep 2008 00:04:58 -0000 1.11
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/LcioMcpFactory.cc,v 1.10 2008/08/26 23:15:31 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/LcioMcpFactory.cc,v 1.11 2008/09/10 00:04:58 jeremy Exp $
#include "LcioMcpFactory.hh"
// slic
@@ -32,8 +32,8 @@
LcioMcpFactory::LcioMcpFactory(LcioMcpManager* manager)
: Module( "LcioMcpFactory" ),
m_finalColl(0),
- m_currentTrajectoryContainer(0),
- m_manager(manager)
+ m_manager(manager),
+ m_currentTrajectoryContainer(0)
{}
LcioMcpFactory::~LcioMcpFactory()
@@ -497,7 +497,9 @@
void LcioMcpFactory::addMcpDaughtersFromInitial(IMPL::MCParticleImpl* mcpNew,
EVENT::MCParticle* mcpInit)
{
+#ifdef SLIC_LOG
log() << LOG::debug << "addMcpDaughtersFromInitial: " << m_manager->getMCParticleIndex(m_manager->getInitialMcpCollection(), mcpInit) << LOG::done;
+#endif
int numDau = mcpInit->getDaughters().size();
slic/src
diff -u -r1.4 -r1.5
--- LcioMcpStatusSetter.cc 27 Apr 2007 01:54:35 -0000 1.4
+++ LcioMcpStatusSetter.cc 10 Sep 2008 00:04:58 -0000 1.5
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/LcioMcpStatusSetter.cc,v 1.4 2007/04/27 01:54:35 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/LcioMcpStatusSetter.cc,v 1.5 2008/09/10 00:04:58 jeremy Exp $
#include "LcioMcpStatusSetter.hh"
// slic
@@ -10,103 +10,103 @@
namespace slic
{
- IMPL::MCParticleImpl* LcioMcpStatusSetter::setMcpStatusCodesFromTrajectory(Trajectory* trj,
- MCParticleImpl* mcp)
- {
- // set vertexIsNotEndOfParent flag
- LcioMcpStatusSetter::setVertexIsNotEndpointOfParentFlag( trj, mcp );
-
- // set final status flags
- LcioMcpStatusSetter::setFinalStatusFlags( trj, mcp );
-
- // set backscatter flag
- LcioMcpStatusSetter::setBackscatterFlag( trj, mcp );
-
- // For GPS source, set generator status to FS for trajectories without parents,
- // i.e. the parent track ID is 0.
- if (EventSourceManager::instance()->getCurrentSourceType() ==
- EventSourceManager::eGPS) {
- if (trj->GetParentID() == 0) {
- mcp->setGeneratorStatus(1);
- }
- }
-
- // return the MCP
- return mcp;
- }
-
- void LcioMcpStatusSetter::setBackscatterFlag(Trajectory* trj,
- IMPL::MCParticleImpl* mcp)
- {
- if ( trj->getBackscatter() ) {
- mcp->setBackscatter( true );
- }
- }
-
- void LcioMcpStatusSetter::setVertexIsNotEndpointOfParentFlag(Trajectory* trj,
- MCParticleImpl* mcp)
- {
- mcp->setVertexIsNotEndpointOfParent( trj->getVertexIsNotEndpointOfParent() );
- }
-
- void LcioMcpStatusSetter::setCreatedInSimulationFlag(Trajectory* trj,
- IMPL::MCParticleImpl* mcp)
- {
- if ( trj->getCreatedInSimulation() ) {
- mcp->setGeneratorStatus( 0 );
- mcp->setCreatedInSimulation( true );
- }
- else {
- mcp->setCreatedInSimulation( false );
- }
- }
-
- void LcioMcpStatusSetter::setFinalStatusFlags(Trajectory* trj,
- IMPL::MCParticleImpl* mcp)
- {
- // set final status flags
- Trajectory::EFinalStatus trjFinalStatus = trj->getFinalStatus();
- switch ( trjFinalStatus ) {
-
- case Trajectory::eDecayedInTracker:
- mcp->setDecayedInTracker( true );
- break;
-
- case Trajectory::eLeftDetector:
- mcp->setHasLeftDetector( true );
- break;
-
- case Trajectory::eStopped:
- mcp->setStopped( true );
- break;
-
- case Trajectory::eDecayedInCalorimeter:
- mcp->setDecayedInCalorimeter( true );
- break;
-
- case Trajectory::eUnset:
- break;
-
- default:
- break;
- }
- }
-
- void LcioMcpStatusSetter::setGeneratorStatus(MCParticle* mcpInit, MCParticleImpl* mcp)
- {
- // set generator status if initial exists
- if ( mcpInit ) {
-
- // if init particle, this was not created in sim
- mcp->setCreatedInSimulation( false );
-
- // copy gen status from initial
- mcp->setGeneratorStatus( mcpInit->getGeneratorStatus() );
- }
- // no initial -> created in sim
- else {
- mcp->setCreatedInSimulation( true );
- mcp->setGeneratorStatus( 0 );
+ IMPL::MCParticleImpl* LcioMcpStatusSetter::setMcpStatusCodesFromTrajectory(Trajectory* trj,
+ MCParticleImpl* mcp)
+ {
+ // set vertexIsNotEndOfParent flag
+ LcioMcpStatusSetter::setVertexIsNotEndpointOfParentFlag( trj, mcp );
+
+ // set final status flags
+ LcioMcpStatusSetter::setFinalStatusFlags( trj, mcp );
+
+ // set backscatter flag
+ LcioMcpStatusSetter::setBackscatterFlag( trj, mcp );
+
+ // For GPS source, set generator status to FS for trajectories without parents,
+ // i.e. the parent track ID is 0.
+ if (EventSourceManager::instance()->getCurrentSourceType() ==
+ EventSourceManager::eGPS) {
+ if (trj->GetParentID() == 0) {
+ mcp->setGeneratorStatus(1);
+ }
+ }
+
+ // return the MCP
+ return mcp;
+ }
+
+ void LcioMcpStatusSetter::setBackscatterFlag(Trajectory* trj,
+ IMPL::MCParticleImpl* mcp)
+ {
+ if ( trj->getBackscatter() ) {
+ mcp->setBackscatter( true );
+ }
+ }
+
+ void LcioMcpStatusSetter::setVertexIsNotEndpointOfParentFlag(Trajectory* trj,
+ MCParticleImpl* mcp)
+ {
+ mcp->setVertexIsNotEndpointOfParent( trj->getVertexIsNotEndpointOfParent() );
+ }
+
+ void LcioMcpStatusSetter::setCreatedInSimulationFlag(Trajectory* trj,
+ IMPL::MCParticleImpl* mcp)
+ {
+ if ( trj->getCreatedInSimulation() ) {
+ mcp->setGeneratorStatus( 0 );
+ mcp->setCreatedInSimulation( true );
+ }
+ else {
+ mcp->setCreatedInSimulation( false );
+ }
+ }
+
+ void LcioMcpStatusSetter::setFinalStatusFlags(Trajectory* trj,
+ IMPL::MCParticleImpl* mcp)
+ {
+ // set final status flags
+ Trajectory::EFinalStatus trjFinalStatus = trj->getFinalStatus();
+ switch ( trjFinalStatus ) {
+
+ case Trajectory::eDecayedInTracker:
+ mcp->setDecayedInTracker( true );
+ break;
+
+ case Trajectory::eLeftDetector:
+ mcp->setHasLeftDetector( true );
+ break;
+
+ case Trajectory::eStopped:
+ mcp->setStopped( true );
+ break;
+
+ case Trajectory::eDecayedInCalorimeter:
+ mcp->setDecayedInCalorimeter( true );
+ break;
+
+ case Trajectory::eUnset:
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ void LcioMcpStatusSetter::setGeneratorStatus(MCParticle* mcpInit, MCParticleImpl* mcp)
+ {
+ // set generator status if initial exists
+ if ( mcpInit ) {
+
+ // if init particle, this was not created in sim
+ mcp->setCreatedInSimulation( false );
+
+ // copy gen status from initial
+ mcp->setGeneratorStatus( mcpInit->getGeneratorStatus() );
+ }
+ // no initial -> created in sim
+ else {
+ mcp->setCreatedInSimulation( true );
+ mcp->setGeneratorStatus( 0 );
+ }
}
- }
}
slic/src
diff -u -r1.18 -r1.19
--- EventSourceManager.cc 14 May 2008 03:24:11 -0000 1.18
+++ EventSourceManager.cc 10 Sep 2008 00:04:58 -0000 1.19
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/EventSourceManager.cc,v 1.18 2008/05/14 03:24:11 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/EventSourceManager.cc,v 1.19 2008/09/10 00:04:58 jeremy Exp $
#include "EventSourceManager.hh"
// slic
@@ -14,380 +14,394 @@
namespace slic
{
- EventSourceManager::EventSourceManager()
- : Module("EventSourceManager"),
- m_currentEventSource(0),
- m_filename(""),
- m_fileIsSet(false),
- m_newFilename(false),
- m_ngen(0),
- m_nskip(0),
- m_newSource(true),
- m_sourceType(eGPS),
- m_lorentzTransformationAngle(0.)
- {
- // messenger
- m_messenger = new GeneratorMessenger();
-
- // generator name strings
- m_stdhepStr = std::string("stdhep");
- m_lcioStr = std::string("lcio");
- m_gpsStr = std::string("gps");
- m_gunStr = std::string("gun");
- m_unknownStr = std::string("unknown");
- }
-
- EventSourceManager::~EventSourceManager()
- {}
-
- const std::string& EventSourceManager::getFilename()
- {
- return m_filename;
- }
-
- void EventSourceManager::setFilename(const std::string& f)
- {
- m_filename = f;
- m_fileIsSet = true;
- m_newFilename = true;
-
- /* Get a file extension from the input file. */
- std::string fext = FileUtil::extension(m_filename);
-
- /* For known file extensions, get a source type. */
- ESourceType est = getSourceTypeFromFileExtension(fext);
-
- /* Setup a (possibly) new source. */
- setupEventSource( est );
- }
-
- EventSourceManager::ESourceType EventSourceManager::getSourceTypeFromFileExtension(const std::string& fext)
- {
- ESourceType est = eUnknown;
-
- /* LCIO file extension */
- if ( fext == "slcio" ) {
- est = eLCIO;
- }
- /* StdHep files, which may have .xdr file ext */
- else if ( fext == "stdhep" || fext == "xdr" ) {
- est = eStdHep;
- }
- else {
- log() << LOG::error << "WARNING: File <" << m_filename << "> does not have a known file extension." << LOG::done;
- }
- return est;
- }
-
- void EventSourceManager::resetCurrentEventSource()
- {
- m_currentEventSource->reset();
- m_ngen = 0;
- }
-
- void EventSourceManager::setSkipEvents(unsigned int s)
- {
- m_nskip = s;
- }
-
- unsigned int EventSourceManager::getSkipEvents()
- {
- return m_nskip;
- }
-
- void EventSourceManager::setSourceType(const std::string& s)
- {
- setSourceType( getSourceTypeFromName( s ) );
- }
-
- void EventSourceManager::setSourceType(ESourceType egt)
- {
- m_sourceType = egt;
- m_newSource = true;
- }
-
- const std::string& EventSourceManager::getSourceNameFromType( ESourceType egt ) const
- {
- if ( egt == eStdHep ) {
- return m_stdhepStr;
- }
- else if ( egt == eLCIO ) {
- return m_lcioStr;
- }
- else if ( egt == eGPS ) {
- return m_gpsStr;
- }
- else if ( egt == eParticleGun ) {
- return m_gunStr;
- }
-
- return m_unknownStr;
- }
-
- EventSourceManager::ESourceType EventSourceManager::getSourceTypeFromName( const std::string& s ) const
- {
- std::string sl = StringUtil::toLower(s);
-
- ESourceType egt = eUnknown;
-
- if ( sl == m_stdhepStr ) {
- egt = eStdHep;
- }
- else if ( sl == m_gpsStr ) {
- egt = eGPS;
- }
- else if ( sl == m_gunStr ) {
- egt = eParticleGun;
- }
- else if ( sl == m_lcioStr ) {
- egt = eLCIO;
- }
-
- return egt;
- }
-
- EventSourceManager::ESourceType EventSourceManager::getCurrentSourceType()
- {
- return m_sourceType;
- }
-
- const std::string& EventSourceManager::getCurrentSourceName()
- {
- return getSourceNameFromType( m_sourceType );
- }
-
- void EventSourceManager::dumpCurrentEvent()
- {
- m_currentEventSource->dumpCurrentEvent();
- }
-
- void EventSourceManager::printNumEventsGenerated()
- {
- log() << LOG::okay << "Num events generated <" << m_ngen << ">." << LOG::done;
- }
-
- int EventSourceManager::getNumEventsGenerated()
- {
- return m_ngen;
- }
-
- void EventSourceManager::incrNumEventsGenerated()
- {
- m_ngen += 1;
- }
-
- void EventSourceManager::generate(G4Event* evt)
- {
- if ( !isEOF() ) {
- m_currentEventSource->generate(evt);
- }
- else {
- log() << LOG::error << "No more input events from file <" << m_filename << ">." << LOG::done;
- }
- }
-
- void EventSourceManager::setEventSource(EventSource* es)
- {
- deleteCurrentEventSource();
- m_currentEventSource = es;
- }
-
- void EventSourceManager::deleteCurrentEventSource()
- {
- if ( m_currentEventSource ) {
- delete m_currentEventSource;
- m_currentEventSource = 0;
- }
- }
-
- EventSource* EventSourceManager::createEventSource(ESourceType st)
- {
- EventSource* src = 0;
- if ( st == eLCIO ) {
- src = new LcioEventSource( getFilename() );
- }
- else if ( st == eStdHep ) {
- src = new StdHepEventSource( getFilename() );
- }
- else if ( st == eGPS ) {
- src = new GPSEventSource();
- }
- else if ( st == eParticleGun ) {
- src = new ParticleGunEventSource();
- }
- else if ( st == eUnknown ) {
- log() << LOG::error << "ESourceType <" << getSourceNameFromType(st) << " is flagged as unknown." << LOG::done;
- }
- else {
- log() << LOG::error << "Invalid ESourceType." << LOG::done;
- }
-
- return src;
- }
-
- void EventSourceManager::setupEventSource(ESourceType st)
- {
- // is a known source type?
- if ( st != eUnknown ) {
-
- // is new type of source?
- if ( isNewSource(st) ) {
-
- // set new source type
- m_sourceType = st;
-
- // delete current source
- deleteCurrentEventSource();
-
- // create new source
- m_currentEventSource = createEventSource( m_sourceType );
-
- log().okay("Created event generator <" + getCurrentSourceName() + ">");
- }
- else {
- log().warning("Type of new event source is same as old -- keeping old source.");
- }
- }
- else {
- G4Exception("Event Source type is unknown.");
- }
- }
-
- void EventSourceManager::setupEventSource(const std::string& s)
- {
- ESourceType st = getSourceTypeFromName( s );
- if ( st != eUnknown ) {
- setupEventSource( st );
- }
- else {
- log().error("The name <" + s + "> is not a valid event source. New source was NOT created.");
- }
- }
-
-
- EventSource* EventSourceManager::getCurrentSource()
- {
- return m_currentEventSource;
- }
-
- void EventSourceManager::beginEvent(const G4Event* anEvent)
- {
- /*
- * Start the event timer, as generation occurs before EventAction::BeginOfEventAction().
- *
- * Event generation is the real start of processing for the event.
- */
- EventAction::getEventAction()->startEventTimer();
-
- // begin event action of current source
- m_currentEventSource->beginEvent(anEvent);
- }
-
- void EventSourceManager::endEvent(const G4Event* anEvent)
- {
- m_currentEventSource->endEvent(anEvent);
- }
-
- void EventSourceManager::beginRun(const G4Run* aRun)
- {
- /*
- * Setup a new event source if neccessary.
- */
- setupEventSource();
-
- /*
- * Call the beginRun() function of the current event source.
- */
- m_currentEventSource->beginRun(aRun);
-
- /* Filename is now old so source won't reset. */
- m_newFilename = false;
- }
-
- void EventSourceManager::setupEventSource()
- {
- if ( m_newSource ) {
- m_currentEventSource = createEventSource( m_sourceType );
- m_newSource = false;
- }
- }
-
- void EventSourceManager::endRun(const G4Run* aRun)
- {
- m_currentEventSource->endRun(aRun);
- }
-
- bool EventSourceManager::isFileSource()
- {
- return ( m_sourceType == eStdHep || m_sourceType == eLCIO );
- }
-
- bool EventSourceManager::isEOF()
- {
- bool eof = false;
- if ( isFileSource() ) {
- EventSourceWithInputFile* src = dynamic_cast<EventSourceWithInputFile*> ( m_currentEventSource );
-
- if ( src ) {
- eof = src->isEOF();
- }
- else {
- G4Exception("Cast to EventSourceWithInputFile failed!");
- }
- }
- return eof;
- }
-
- bool EventSourceManager::isNewSource()
- {
- return m_newSource;
- }
-
- bool EventSourceManager::isNewSource(ESourceType est)
- {
- return ( est != eUnknown && est != m_sourceType );
- }
-
- bool EventSourceManager::isNewFilename()
- {
- return m_newFilename;
- }
-
- EventSourceWithInputFile* EventSourceManager::getFileSource()
- {
- EventSourceWithInputFile* esif = 0;
- if ( isFileSource() ) {
- esif = dynamic_cast<EventSourceWithInputFile*> ( m_currentEventSource ) ;
- }
- return esif;
- }
-
- G4GeneralParticleSource* EventSourceManager::getGPS()
- {
- GPSEventSource* src = dynamic_cast<GPSEventSource*> ( m_currentEventSource );
-
- G4GeneralParticleSource* gps = 0;
- if ( src ) {
- gps = src->getGPS();
- }
-
- return gps;
- }
-
- G4ParticleGun* EventSourceManager::getParticleGun()
- {
- ParticleGunEventSource* src = dynamic_cast<ParticleGunEventSource*> ( m_currentEventSource );
-
- G4ParticleGun* gun = 0;
- if ( src ) {
- gun = src->getParticleGun();
- }
-
- return gun;
- }
-
- void EventSourceManager::GeneratePrimaryVertex(G4Event* evt)
- {
- generate(evt);
- }
+ EventSourceManager::EventSourceManager()
+ : Module("EventSourceManager"),
+ m_currentEventSource(0),
+ m_filename(""),
+ m_fileIsSet(false),
+ m_newFilename(false),
+ m_ngen(0),
+ m_nskip(0),
+ m_newSource(true),
+ m_sourceType(eGPS),
+ m_lorentzTransformationAngle(0.)
+ {
+ // messenger
+ m_messenger = new GeneratorMessenger();
+
+ // generator name strings
+ m_stdhepStr = std::string("stdhep");
+ m_lcioStr = std::string("lcio");
+ m_gpsStr = std::string("gps");
+ m_gunStr = std::string("gun");
+ m_unknownStr = std::string("unknown");
+ }
+
+ EventSourceManager::~EventSourceManager()
+ {}
+
+ const std::string& EventSourceManager::getFilename()
+ {
+ return m_filename;
+ }
+
+ void EventSourceManager::setFilename(const std::string& f)
+ {
+ m_filename = f;
+ m_fileIsSet = true;
+ m_newFilename = true;
+
+ /* Get a file extension from the input file. */
+ std::string fext = FileUtil::extension(m_filename);
+
+ /* For known file extensions, get a source type. */
+ ESourceType est = getSourceTypeFromFileExtension(fext);
+
+ /* Setup a (possibly) new source. */
+ setupEventSource( est );
+ }
+
+ EventSourceManager::ESourceType EventSourceManager::getSourceTypeFromFileExtension(const std::string& fext)
+ {
+ ESourceType est = eUnknown;
+
+ /* LCIO file extension */
+ if ( fext == "slcio" ) {
+ est = eLCIO;
+ }
+ /* StdHep files, which may have .xdr file ext */
+ else if ( fext == "stdhep" || fext == "xdr" ) {
+ est = eStdHep;
+ }
+ else {
+ log() << LOG::error << "WARNING: File <" << m_filename << "> does not have a known file extension." << LOG::done;
+ }
+ return est;
+ }
+
+ void EventSourceManager::resetCurrentEventSource()
+ {
+ m_currentEventSource->reset();
+ m_ngen = 0;
+ }
+
+ void EventSourceManager::setSkipEvents(unsigned int s)
+ {
+ m_nskip = s;
+ }
+
+ unsigned int EventSourceManager::getSkipEvents()
+ {
+ return m_nskip;
+ }
+
+ void EventSourceManager::setSourceType(const std::string& s)
+ {
+ setSourceType( getSourceTypeFromName( s ) );
+ }
+
+ void EventSourceManager::setSourceType(ESourceType egt)
+ {
+ m_sourceType = egt;
+ m_newSource = true;
+ }
+
+ const std::string& EventSourceManager::getSourceNameFromType( ESourceType egt ) const
+ {
+ if ( egt == eStdHep ) {
+ return m_stdhepStr;
+ }
+ else if ( egt == eLCIO ) {
+ return m_lcioStr;
+ }
+ else if ( egt == eGPS ) {
+ return m_gpsStr;
+ }
+ else if ( egt == eParticleGun ) {
+ return m_gunStr;
+ }
+
+ return m_unknownStr;
+ }
+
+ EventSourceManager::ESourceType EventSourceManager::getSourceTypeFromName( const std::string& s ) const
+ {
+ std::string sl = StringUtil::toLower(s);
+
+ ESourceType egt = eUnknown;
+
+ if ( sl == m_stdhepStr ) {
+ egt = eStdHep;
+ }
+ else if ( sl == m_gpsStr ) {
+ egt = eGPS;
+ }
+ else if ( sl == m_gunStr ) {
+ egt = eParticleGun;
+ }
+ else if ( sl == m_lcioStr ) {
+ egt = eLCIO;
+ }
+
+ return egt;
+ }
+
+ EventSourceManager::ESourceType EventSourceManager::getCurrentSourceType()
+ {
+ return m_sourceType;
+ }
+
+ const std::string& EventSourceManager::getCurrentSourceName()
+ {
+ return getSourceNameFromType( m_sourceType );
+ }
+
+ void EventSourceManager::dumpCurrentEvent()
+ {
+ m_currentEventSource->dumpCurrentEvent();
+ }
+
+ void EventSourceManager::printNumEventsGenerated()
+ {
+ log() << LOG::okay << "Num events generated <" << m_ngen << ">." << LOG::done;
+ }
+
+ int EventSourceManager::getNumEventsGenerated()
+ {
+ return m_ngen;
+ }
+
+ void EventSourceManager::incrNumEventsGenerated()
+ {
+ m_ngen += 1;
+ }
+
+ void EventSourceManager::generate(G4Event* evt)
+ {
+ if ( !isEOF() ) {
+ m_currentEventSource->generate(evt);
+ }
+ else {
+ log() << LOG::error << "No more input events from file <" << m_filename << ">." << LOG::done;
+ }
+ }
+
+ void EventSourceManager::setEventSource(EventSource* es)
+ {
+ deleteCurrentEventSource();
+ m_currentEventSource = es;
+ }
+
+ void EventSourceManager::deleteCurrentEventSource()
+ {
+ if ( m_currentEventSource ) {
+ delete m_currentEventSource;
+ m_currentEventSource = 0;
+ }
+ }
+
+ EventSource* EventSourceManager::createEventSource(ESourceType st)
+ {
+ EventSource* src = 0;
+ if ( st == eLCIO ) {
+ src = new LcioEventSource( getFilename() );
+ }
+ else if ( st == eStdHep ) {
+ src = new StdHepEventSource( getFilename() );
+ }
+ else if ( st == eGPS ) {
+ src = new GPSEventSource();
+ }
+ else if ( st == eParticleGun ) {
+ src = new ParticleGunEventSource();
+ }
+ else if ( st == eUnknown ) {
+ log() << LOG::error << "ESourceType <" << getSourceNameFromType(st) << " is flagged as unknown." << LOG::done;
+ }
+ else {
+ log() << LOG::error << "Invalid ESourceType." << LOG::done;
+ }
+
+ return src;
+ }
+
+ void EventSourceManager::setupEventSource(ESourceType st)
+ {
+ // is a known source type?
+ if ( st != eUnknown ) {
+
+ // is new type of source?
+ if ( isNewSource(st) ) {
+
+ // set new source type
+ m_sourceType = st;
+
+ // delete current source
+ deleteCurrentEventSource();
+
+ // create new source
+ m_currentEventSource = createEventSource( m_sourceType );
+
+ log().okay("Created event generator <" + getCurrentSourceName() + ">");
+ }
+ else {
+ log().warning("Type of new event source is same as old -- keeping old source.");
+ }
+ }
+ else {
+ G4Exception("Event Source type is unknown.");
+ }
+ }
+
+ void EventSourceManager::setupEventSource(const std::string& s)
+ {
+ ESourceType st = getSourceTypeFromName( s );
+ if ( st != eUnknown ) {
+ setupEventSource( st );
+ }
+ else {
+ log().error("The name <" + s + "> is not a valid event source. New source was NOT created.");
+ }
+ }
+
+
+ EventSource* EventSourceManager::getCurrentSource()
+ {
+ return m_currentEventSource;
+ }
+
+ void EventSourceManager::beginEvent(const G4Event* anEvent)
+ {
+ /*
+ * Start the event timer, as generation occurs before EventAction::BeginOfEventAction().
+ *
+ * Event generation is the real start of processing for the event.
+ */
+ EventAction::getEventAction()->startEventTimer();
+
+ // begin event action of current source
+ m_currentEventSource->beginEvent(anEvent);
+ }
+
+ void EventSourceManager::endEvent(const G4Event* anEvent)
+ {
+ m_currentEventSource->endEvent(anEvent);
+ }
+
+ void EventSourceManager::beginRun(const G4Run* aRun)
+ {
+ /*
+ * Setup a new event source if neccessary.
+ */
+ setupEventSource();
+
+ /*
+ * Call the beginRun() function of the current event source.
+ */
+ m_currentEventSource->beginRun(aRun);
+
+ /* Filename is now old so source won't reset. */
+ m_newFilename = false;
+ }
+
+ void EventSourceManager::setupEventSource()
+ {
+ if ( m_newSource ) {
+ m_currentEventSource = createEventSource( m_sourceType );
+ m_newSource = false;
+ }
+ }
+
+ void EventSourceManager::endRun(const G4Run* aRun)
+ {
+ m_currentEventSource->endRun(aRun);
+ }
+
+ bool EventSourceManager::isFileSource()
+ {
+ return ( m_sourceType == eStdHep || m_sourceType == eLCIO );
+ }
+
+ bool EventSourceManager::isEOF()
+ {
+ bool eof = false;
+ if ( isFileSource() ) {
+ EventSourceWithInputFile* src = dynamic_cast<EventSourceWithInputFile*> ( m_currentEventSource );
+
+ if ( src ) {
+ eof = src->isEOF();
+ }
+ else {
+ G4Exception("Cast to EventSourceWithInputFile failed!");
+ }
+ }
+ return eof;
+ }
+
+ bool EventSourceManager::isNewSource()
+ {
+ return m_newSource;
+ }
+
+ bool EventSourceManager::isNewSource(ESourceType est)
+ {
+ return ( est != eUnknown && est != m_sourceType );
+ }
+
+ bool EventSourceManager::isNewFilename()
+ {
+ return m_newFilename;
+ }
+
+ EventSourceWithInputFile* EventSourceManager::getFileSource()
+ {
+ EventSourceWithInputFile* esif = 0;
+ if ( isFileSource() ) {
+ esif = dynamic_cast<EventSourceWithInputFile*> ( m_currentEventSource ) ;
+ }
+ return esif;
+ }
+
+ G4GeneralParticleSource* EventSourceManager::getGPS()
+ {
+ GPSEventSource* src = dynamic_cast<GPSEventSource*> ( m_currentEventSource );
+
+ G4GeneralParticleSource* gps = 0;
+ if ( src ) {
+ gps = src->getGPS();
+ }
+
+ return gps;
+ }
+
+ G4ParticleGun* EventSourceManager::getParticleGun()
+ {
+ ParticleGunEventSource* src = dynamic_cast<ParticleGunEventSource*> ( m_currentEventSource );
+
+ G4ParticleGun* gun = 0;
+ if ( src ) {
+ gun = src->getParticleGun();
+ }
+
+ return gun;
+ }
+
+ void EventSourceManager::GeneratePrimaryVertex(G4Event* evt)
+ {
+ generate(evt);
+ }
+
+ void EventSourceManager::setLorentzTransformationAngle( const G4double lorentzTransformationAngle )
+ {
+
+ m_lorentzTransformationAngle = lorentzTransformationAngle;
+#ifdef SLIC_LOG
+ log() << LOG::always
+ << "Set Lorentz transformation angle to "
+ << G4BestUnit(m_lorentzTransformationAngle, "Angle")
+ << LOG::done;
+#endif
+
+ }
+
}
slic/include
diff -u -r1.4 -r1.5
--- LcioMcpStatusSetter.hh 5 Sep 2006 23:21:46 -0000 1.4
+++ LcioMcpStatusSetter.hh 10 Sep 2008 00:04:58 -0000 1.5
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/LcioMcpStatusSetter.hh,v 1.4 2006/09/05 23:21:46 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/LcioMcpStatusSetter.hh,v 1.5 2008/09/10 00:04:58 jeremy Exp $
#ifndef SLIC_LCIOMCPSTATUSSETTER_HH
#define SLIC_LCIOMCPSTATUSSETTER_HH 1
@@ -9,30 +9,30 @@
namespace slic
{
- class Trajectory;
+ class Trajectory;
- /**
- * @class LcioMcpStatusSetter
- * @brief Static utility functions for setting the status of MCParticles
- * from associated Trajectory, initial MCParticle, and TrackInformation
- * objects.
- */
- class LcioMcpStatusSetter
- {
- private:
- LcioMcpStatusSetter() {}
-
- public:
- // set Mcp status codes from trajectory
- static IMPL::MCParticleImpl* setMcpStatusCodesFromTrajectory( Trajectory*, IMPL::MCParticleImpl* );
- static void setGeneratorStatus(EVENT::MCParticle* mcpInit, IMPL::MCParticleImpl* mcp);
-
- private:
- // check and set MCP flags
- static void setVertexIsNotEndpointOfParentFlag( Trajectory*, IMPL::MCParticleImpl* );
- static void setFinalStatusFlags( Trajectory*, IMPL::MCParticleImpl* );
- static void setCreatedInSimulationFlag( Trajectory*, IMPL::MCParticleImpl* );
- static void setBackscatterFlag( Trajectory*, IMPL::MCParticleImpl* );
+ /**
+ * @class LcioMcpStatusSetter
+ * @brief Static utility functions for setting the status of MCParticles
+ * from associated Trajectory, initial MCParticle, and TrackInformation
+ * objects.
+ */
+ class LcioMcpStatusSetter
+ {
+ private:
+ LcioMcpStatusSetter() {}
+
+ public:
+ // set Mcp status codes from trajectory
+ static IMPL::MCParticleImpl* setMcpStatusCodesFromTrajectory( Trajectory*, IMPL::MCParticleImpl* );
+ static void setGeneratorStatus(EVENT::MCParticle* mcpInit, IMPL::MCParticleImpl* mcp);
+
+ private:
+ // check and set MCP flags
+ static void setVertexIsNotEndpointOfParentFlag( Trajectory*, IMPL::MCParticleImpl* );
+ static void setFinalStatusFlags( Trajectory*, IMPL::MCParticleImpl* );
+ static void setCreatedInSimulationFlag( Trajectory*, IMPL::MCParticleImpl* );
+ static void setBackscatterFlag( Trajectory*, IMPL::MCParticleImpl* );
};
}
slic/include
diff -u -r1.10 -r1.11
--- EventSourceManager.hh 14 May 2008 03:24:11 -0000 1.10
+++ EventSourceManager.hh 10 Sep 2008 00:04:58 -0000 1.11
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/EventSourceManager.hh,v 1.10 2008/05/14 03:24:11 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/EventSourceManager.hh,v 1.11 2008/09/10 00:04:58 jeremy Exp $
#ifndef SLIC_EVENTSOURCEMANAGER_HH
#define SLIC_EVENTSOURCEMANAGER_HH 1
@@ -16,130 +16,132 @@
#include "G4VPrimaryGenerator.hh"
#include "G4GeneralParticleSource.hh"
#include "G4ParticleGun.hh"
+#include "G4UnitsTable.hh"
namespace slic
{
- /**
- * @class EventSourceManager
- * @brief This singleton is responsible for managing physics event sources.
- */
- class EventSourceManager : public Module, public Singleton<EventSourceManager>
- {
-
- public:
-
- enum ESourceType {
- eUnknown = 0,
- eStdHep = 1,
- eLCIO,
- eGPS,
- eParticleGun
- };
+ /**
+ * @class EventSourceManager
+ * @brief This singleton is responsible for managing physics event sources.
+ */
+ class EventSourceManager : public Module, public Singleton<EventSourceManager>
+ {
+
+ public:
+
+ enum ESourceType {
+ eUnknown = 0,
+ eStdHep = 1,
+ eLCIO,
+ eGPS,
+ eParticleGun
+ };
- public:
+ public:
- virtual ~EventSourceManager();
+ virtual ~EventSourceManager();
- EventSourceManager();
+ EventSourceManager();
- public:
+ public:
- void setSourceType(ESourceType est);
- void setSourceType(const std::string& s);
- ESourceType getCurrentSourceType();
- ESourceType getSourceTypeFromFileExtension(const std::string& s);
+ void setSourceType(ESourceType est);
+ void setSourceType(const std::string& s);
+ ESourceType getCurrentSourceType();
+ ESourceType getSourceTypeFromFileExtension(const std::string& s);
- const std::string& getCurrentSourceName();
- const std::string& getSourceNameFromType( ESourceType egt ) const;
- ESourceType getSourceTypeFromName( const std::string& s ) const;
+ const std::string& getCurrentSourceName();
+ const std::string& getSourceNameFromType( ESourceType egt ) const;
+ ESourceType getSourceTypeFromName( const std::string& s ) const;
- const std::string& getFilename();
- void setFilename(const std::string& f);
+ const std::string& getFilename();
+ void setFilename(const std::string& f);
- void setupEventSource();
+ void setupEventSource();
- void resetCurrentEventSource();
+ void resetCurrentEventSource();
- void setSkipEvents(unsigned int s);
+ void setSkipEvents(unsigned int s);
- unsigned int getSkipEvents();
+ unsigned int getSkipEvents();
- void dumpCurrentEvent();
+ void dumpCurrentEvent();
- void printNumEventsGenerated();
+ void printNumEventsGenerated();
- int getNumEventsGenerated();
+ int getNumEventsGenerated();
- void incrNumEventsGenerated();
+ void incrNumEventsGenerated();
- void generate(G4Event* evt);
+ void generate(G4Event* evt);
- void setEventSource(EventSource* es);
+ void setEventSource(EventSource* es);
- void deleteCurrentEventSource();
+ void deleteCurrentEventSource();
- EventSource* createEventSource(ESourceType st);
- EventSource* getCurrentSource();
+ EventSource* createEventSource(ESourceType st);
+ EventSource* getCurrentSource();
- void setupEventSource(ESourceType st);
- void setupEventSource(const std::string& s);
+ void setupEventSource(ESourceType st);
+ void setupEventSource(const std::string& s);
- void beginEvent(const G4Event*);
- void endEvent(const G4Event*);
+ void beginEvent(const G4Event*);
+ void endEvent(const G4Event*);
- void beginRun(const G4Run*);
- void endRun(const G4Run*);
+ void beginRun(const G4Run*);
+ void endRun(const G4Run*);
- bool isEOF();
- bool isNewSource();
- bool isNewSource(ESourceType est);
- bool isNewFilename();
- bool isFileSource();
+ bool isEOF();
+ bool isNewSource();
+ bool isNewSource(ESourceType est);
+ bool isNewFilename();
+ bool isFileSource();
- EventSourceWithInputFile* getFileSource();
- G4GeneralParticleSource* getGPS();
- G4ParticleGun* getParticleGun();
+ EventSourceWithInputFile* getFileSource();
+ G4GeneralParticleSource* getGPS();
+ G4ParticleGun* getParticleGun();
- double getLorentzTransformationAngle() { return m_lorentzTransformationAngle; }
- void setLorentzTransformationAngle( const G4double lorentzTransformationAngle ) { m_lorentzTransformationAngle = lorentzTransformationAngle; }
+ double getLorentzTransformationAngle() { return m_lorentzTransformationAngle; }
- public:
- virtual void GeneratePrimaryVertex(G4Event* evt);
+ void setLorentzTransformationAngle( const G4double lorentzTransformationAngle );
- private:
+ public:
+ virtual void GeneratePrimaryVertex(G4Event* evt);
- // generator messenger
- GeneratorMessenger* m_messenger;
+ private:
- // current event source
- EventSource* m_currentEventSource;
+ // generator messenger
+ GeneratorMessenger* m_messenger;
- // filename
- std::string m_filename;
- bool m_fileIsSet;
- bool m_newFilename;
+ // current event source
+ EventSource* m_currentEventSource;
- // num events generated on current generator
- int m_ngen;
+ // filename
+ std::string m_filename;
+ bool m_fileIsSet;
+ bool m_newFilename;
- // num events to skip
- unsigned int m_nskip;
+ // num events generated on current generator
+ int m_ngen;
- // need to setup a new source new run?
- bool m_newSource;
+ // num events to skip
+ unsigned int m_nskip;
- // gen strings
- std::string m_stdhepStr;
- std::string m_lcioStr;
- std::string m_gpsStr;
- std::string m_gunStr;
- std::string m_unknownStr;
+ // need to setup a new source new run?
+ bool m_newSource;
- // source type
- ESourceType m_sourceType;
+ // gen strings
+ std::string m_stdhepStr;
+ std::string m_lcioStr;
+ std::string m_gpsStr;
+ std::string m_gunStr;
+ std::string m_unknownStr;
+
+ // source type
+ ESourceType m_sourceType;
- G4double m_lorentzTransformationAngle;
- };
+ G4double m_lorentzTransformationAngle;
+ };
}
#endif