Commit in slic on MAIN
include/EventSourceManager.hh+9-61.11 -> 1.12
src/EventSourceManager.cc+81-531.19 -> 1.20
+90-59
2 modified files
make ParticleGun always available in slic (requested by Norman)

slic/include
EventSourceManager.hh 1.11 -> 1.12
diff -u -r1.11 -r1.12
--- EventSourceManager.hh	10 Sep 2008 00:04:58 -0000	1.11
+++ EventSourceManager.hh	8 Dec 2009 01:04:52 -0000	1.12
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/EventSourceManager.hh,v 1.11 2008/09/10 00:04:58 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/EventSourceManager.hh,v 1.12 2009/12/08 01:04:52 jeremy Exp $
 
 #ifndef SLIC_EVENTSOURCEMANAGER_HH
 #define SLIC_EVENTSOURCEMANAGER_HH 1
@@ -115,6 +115,9 @@
 
             // current event source
             EventSource* m_currentEventSource;
+            
+            // ParticleGun source.  Always enabled.
+            EventSource* m_particleGunSource;
 
             // filename
             std::string m_filename;
@@ -131,11 +134,11 @@
             bool m_newSource;
 
             // gen strings
-            std::string m_stdhepStr;
-            std::string m_lcioStr;
-            std::string m_gpsStr;
-            std::string m_gunStr;
-            std::string m_unknownStr;
+            static std::string m_stdhepStr;
+            static std::string m_lcioStr;
+            static std::string m_gpsStr;
+            static std::string m_gunStr;
+            static std::string m_unknownStr;
 
             // source type
             ESourceType m_sourceType;

slic/src
EventSourceManager.cc 1.19 -> 1.20
diff -u -r1.19 -r1.20
--- EventSourceManager.cc	10 Sep 2008 00:04:58 -0000	1.19
+++ EventSourceManager.cc	8 Dec 2009 01:04:52 -0000	1.20
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/EventSourceManager.cc,v 1.19 2008/09/10 00:04:58 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/EventSourceManager.cc,v 1.20 2009/12/08 01:04:52 jeremy Exp $
 #include "EventSourceManager.hh"
 
 // slic
@@ -14,6 +14,12 @@
 
 namespace slic
 {
+    std::string EventSourceManager::m_stdhepStr = std::string("stdhep");
+    std::string EventSourceManager::m_lcioStr = std::string("lcio");
+    std::string EventSourceManager::m_gpsStr = std::string("gps");
+    std::string EventSourceManager::m_gunStr = std::string("gun");
+    std::string EventSourceManager::m_unknownStr = std::string("unknown");
+
     EventSourceManager::EventSourceManager()
         : Module("EventSourceManager"),
           m_currentEventSource(0),
@@ -29,12 +35,8 @@
         // 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");
+        // Always create a ParticleGun generator.
+        m_particleGunSource = new ParticleGunEventSource();
     }
 
     EventSourceManager::~EventSourceManager()
@@ -66,14 +68,17 @@
         ESourceType est = eUnknown;
 
         /* LCIO file extension */
-        if ( fext == "slcio" ) {
+        if ( fext == "slcio" ) 
+        {
             est = eLCIO;
         }
         /* StdHep files, which may have .xdr file ext */
-        else if ( fext == "stdhep" || fext == "xdr" ) {
+        else if ( fext == "stdhep" || fext == "xdr" ) 
+        {
             est = eStdHep;
         }
-        else {
+        else 
+        {
             log() << LOG::error << "WARNING: File <" << m_filename << "> does not have a known file extension." << LOG::done;
         }
         return est;
@@ -108,16 +113,20 @@
 
     const std::string& EventSourceManager::getSourceNameFromType( ESourceType egt ) const
     {
-        if ( egt == eStdHep ) {
+        if ( egt == eStdHep ) 
+        {
             return m_stdhepStr;
         }
-        else if ( egt == eLCIO ) {
+        else if ( egt == eLCIO ) 
+        {
             return m_lcioStr;
         }
-        else if ( egt == eGPS ) {
+        else if ( egt == eGPS ) 
+        {
             return m_gpsStr;
         }
-        else if ( egt == eParticleGun ) {
+        else if ( egt == eParticleGun ) 
+        {
             return m_gunStr;
         }
 
@@ -130,16 +139,20 @@
 
         ESourceType egt = eUnknown;
 
-        if ( sl == m_stdhepStr ) {
+        if ( sl == m_stdhepStr ) 
+        {
             egt = eStdHep;
         }
-        else if ( sl == m_gpsStr ) {
+        else if ( sl == m_gpsStr ) 
+        {
             egt = eGPS;
         }
-        else if ( sl == m_gunStr ) {
+        else if ( sl == m_gunStr ) 
+        {
             egt = eParticleGun;
         }
-        else if ( sl == m_lcioStr ) {
+        else if ( sl == m_lcioStr ) 
+        {
             egt = eLCIO;
         }
 
@@ -178,10 +191,12 @@
 
     void EventSourceManager::generate(G4Event* evt)
     {
-        if ( !isEOF() ) {
+        if ( !isEOF() ) 
+        {
             m_currentEventSource->generate(evt);
         }
-        else {
+        else 
+        {
             log() << LOG::error << "No more input events from file <" << m_filename << ">." << LOG::done;
         }
     }
@@ -194,7 +209,8 @@
 
     void EventSourceManager::deleteCurrentEventSource()
     {
-        if ( m_currentEventSource ) {
+        if ( m_currentEventSource ) 
+        {
             delete m_currentEventSource;
             m_currentEventSource = 0;
         }
@@ -203,22 +219,28 @@
     EventSource* EventSourceManager::createEventSource(ESourceType st)
     {
         EventSource* src = 0;
-        if ( st == eLCIO ) {
+        if ( st == eLCIO ) 
+        {
             src = new LcioEventSource( getFilename() );
         }
-        else if ( st == eStdHep ) {
+        else if ( st == eStdHep ) 
+        {
             src = new StdHepEventSource( getFilename() );
         }
-        else if ( st == eGPS ) {
+        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 if ( st == eParticleGun ) 
+        {
+            return m_particleGunSource;
+        }
+        else if ( st == eUnknown ) 
+        {
+            log() << LOG::error << "The event source type <" << getSourceNameFromType(st) << " is flagged as unknown!" << LOG::done;
         }
-        else {
+        else 
+        {
             log() << LOG::error << "Invalid ESourceType." << LOG::done;
         }
 
@@ -228,10 +250,11 @@
     void EventSourceManager::setupEventSource(ESourceType st)
     {
         // is a known source type?
-        if ( st != eUnknown ) {
-
+        if ( st != eUnknown ) 
+        {
             // is new type of source?
-            if ( isNewSource(st) ) {
+            if ( isNewSource(st) ) 
+            {
 
                 // set new source type
                 m_sourceType = st;
@@ -244,11 +267,13 @@
 
                 log().okay("Created event generator <" + getCurrentSourceName() + ">");
             }
-            else {
+            else 
+            {
                 log().warning("Type of new event source is same as old -- keeping old source.");
             }
         }
-        else {
+        else 
+        {
             G4Exception("Event Source type is unknown.");
         }
     }
@@ -256,10 +281,12 @@
     void EventSourceManager::setupEventSource(const std::string& s)
     {
         ESourceType st = getSourceTypeFromName( s );
-        if ( st != eUnknown ) {
+        if ( st != eUnknown ) 
+        {
             setupEventSource( st );
         }
-        else {
+        else 
+        {
             log().error("The name <" + s + "> is not a valid event source.  New source was NOT created.");
         }
     }
@@ -274,8 +301,6 @@
     {
         /*
          * Start the event timer, as generation occurs before EventAction::BeginOfEventAction().
-         *
-         * Event generation is the real start of processing for the event.
          */
         EventAction::getEventAction()->startEventTimer();
 
@@ -290,23 +315,20 @@
 
     void EventSourceManager::beginRun(const G4Run* aRun)
     {
-        /*
-         * Setup a new event source if neccessary.
-         */
+        // Setup a new event source if neccessary.
         setupEventSource();
 
-        /*
-         * Call the beginRun() function of the current event source.
-         */
+        // Call the beginRun() function of the current event source.
         m_currentEventSource->beginRun(aRun);
 
-        /* Filename is now old so source won't reset. */
+        // Filename is now old so source won't reset.
         m_newFilename = false;
     }
 
     void EventSourceManager::setupEventSource()
     {
-        if ( m_newSource ) {
+        if ( m_newSource ) 
+        {
             m_currentEventSource = createEventSource( m_sourceType );
             m_newSource = false;
         }
@@ -325,13 +347,16 @@
     bool EventSourceManager::isEOF()
     {
         bool eof = false;
-        if ( isFileSource() ) {
+        if ( isFileSource() ) 
+        {
             EventSourceWithInputFile* src = dynamic_cast<EventSourceWithInputFile*> ( m_currentEventSource );
 
-            if ( src ) {
+            if ( src ) 
+            {
                 eof = src->isEOF();
             }
-            else {
+            else 
+            {
                 G4Exception("Cast to EventSourceWithInputFile failed!");
             }
         }
@@ -356,7 +381,8 @@
     EventSourceWithInputFile* EventSourceManager::getFileSource()
     {
         EventSourceWithInputFile* esif = 0;
-        if ( isFileSource() ) {
+        if ( isFileSource() ) 
+        {
             esif = dynamic_cast<EventSourceWithInputFile*> ( m_currentEventSource ) ;
         }
         return esif;
@@ -367,7 +393,8 @@
         GPSEventSource* src = dynamic_cast<GPSEventSource*> ( m_currentEventSource );
 
         G4GeneralParticleSource* gps = 0;
-        if ( src ) {
+        if ( src ) 
+        {
             gps = src->getGPS();
         }
 
@@ -379,7 +406,8 @@
         ParticleGunEventSource* src = dynamic_cast<ParticleGunEventSource*> ( m_currentEventSource );
 
         G4ParticleGun* gun = 0;
-        if ( src ) {
+        if ( src ) 
+        {
             gun = src->getParticleGun();
         }
 
CVSspam 0.2.8