Commit in slic on MAIN | |||
include/RunManager.hh | +2 | -2 | 1.15 -> 1.16 |
/SlicApplication.hh | +33 | -8 | 1.40 -> 1.41 |
src/LcioManager.cc | +3 | -2 | 1.90 -> 1.91 |
/RunManager.cc | +24 | -28 | 1.20 -> 1.21 |
/SlicApplication.cc | +3 | -5 | 1.57 -> 1.58 |
+65 | -45 |
add print out of error string upon exit; further minor refactoring to error handling
diff -u -r1.15 -r1.16 --- RunManager.hh 27 Nov 2012 19:32:18 -0000 1.15 +++ RunManager.hh 28 Nov 2012 01:18:37 -0000 1.16 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/RunManager.hh,v 1.15 2012/11/27 19:32:18 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/RunManager.hh,v 1.16 2012/11/28 01:18:37 jeremy Exp $
#ifndef SLIC_RUNMANAGER_HH #define SLIC_RUNMANAGER_HH 1
@@ -37,7 +37,7 @@
protected: void BeamOn(G4int n_event, const char* macroFile = 0, G4int n_select = -1);
- void DoEventLoop(G4int, const char*, G4int);
+ //void DoEventLoop(G4int, const char*, G4int);
void InitializePhysics(); void InitializeGeometry();
diff -u -r1.40 -r1.41 --- SlicApplication.hh 27 Nov 2012 19:32:18 -0000 1.40 +++ SlicApplication.hh 28 Nov 2012 01:18:37 -0000 1.41 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/SlicApplication.hh,v 1.40 2012/11/27 19:32:18 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/SlicApplication.hh,v 1.41 2012/11/28 01:18:37 jeremy Exp $
#ifndef SLIC_SLICAPPLICATION_HH #define SLIC_SLICAPPLICATION_HH 1
@@ -12,7 +12,7 @@
#include "G4ApplicationState.hh" // std
-#include <cstdlib>
+//#include <cstdlib>
// geant4 class G4RunManager;
@@ -24,6 +24,17 @@
class SlicApplicationMessenger; class RunManager;
+static const char* ErrorCodeStrings[] = { + "okay", + "unknown error", + "caught unknown exception", + "caught STD exception", + "output file already exists", + "failed to delete old output file", + "event underflow", + "invalid geometry setup" +}; +
/** * @class SlicApplication * @brief Singleton class for a Geant4 application.
@@ -45,14 +56,20 @@
* Error codes. */ enum ErrorCode {
- UNKNOWN_ERROR = 1, - UNKNOWN_EXCEPTION = 2, - STD_EXCEPTION = 3, - OUTPUT_FILE_EXISTS = 4, - FAILED_DELETE = 5, - EVENT_UNDERFLOW = 6
+ OKAY = 0, + UNKNOWN_ERROR, + UNKNOWN_EXCEPTION, + STD_EXCEPTION, + OUTPUT_FILE_EXISTS, + FAILED_DELETE_LCIO_FILE, + EVENT_UNDERFLOW, + INVALID_GEOMETRY_SETUP, + ERROR_CODE_SIZE
};
+private: + +
public: /**
@@ -157,6 +174,14 @@
*/ std::string getGeant4VersionString();
+ const char* getErrorCodeString(unsigned int errorCode) { + if (errorCode > (ERROR_CODE_SIZE - 1)) { + log() << LOG::error << "invalid error code requested: " << errorCode << LOG::done; + throw new std::exception(); + } + return ErrorCodeStrings[errorCode]; + } +
private: /**
diff -u -r1.90 -r1.91 --- LcioManager.cc 27 Nov 2012 19:32:19 -0000 1.90 +++ LcioManager.cc 28 Nov 2012 01:18:37 -0000 1.91 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/LcioManager.cc,v 1.90 2012/11/27 19:32:19 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/LcioManager.cc,v 1.91 2012/11/28 01:18:37 jeremy Exp $
#include "LcioManager.hh" // slic
@@ -101,6 +101,7 @@
// Failure mode is on, so kill the current run. if (m_fileExistsAction == eFail) {
+ //std::cout << "HELLO" << std::endl;
log() << LOG::fatal << LOG::head << "LCIO file already exists: " << fullFilename << LOG::done; SlicApplication::instance()->setReturnCode(SlicApplication::OUTPUT_FILE_EXISTS); RunManager::instance()->abortRun();
@@ -111,7 +112,7 @@
// Fatal error. File could not be removed. log() << LOG::fatal << LOG::head << "Unable to delete old LCIO file: " << fullFilename << LOG::done;
- SlicApplication::instance()->setReturnCode(SlicApplication::FAILED_DELETE);
+ SlicApplication::instance()->setReturnCode(SlicApplication::FAILED_DELETE_LCIO_FILE);
RunManager::instance()->abortRun(); } else { log().okay("Deleted old LCIO file: " + fullFilename);
diff -u -r1.20 -r1.21 --- RunManager.cc 27 Nov 2012 19:32:19 -0000 1.20 +++ RunManager.cc 28 Nov 2012 01:18:37 -0000 1.21 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/RunManager.cc,v 1.20 2012/11/27 19:32:19 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/RunManager.cc,v 1.21 2012/11/28 01:18:37 jeremy Exp $
#include "RunManager.hh" // lcdd
@@ -80,10 +80,12 @@
void RunManager::InitializeGeometry() { if (!LCDDParser::instance()->isValidSetup()) {
- G4Exception("", "", FatalException, "Current LCDD geometry setup is not valid.");
+ //G4Exception("", "", FatalException, "Current LCDD geometry setup is not valid.");
+ SlicApplication::instance()->setReturnCode(SlicApplication::INVALID_GEOMETRY_SETUP);
+ this->abortRun();
+ } else {
+ G4RunManager::InitializeGeometry();
}
- - G4RunManager::InitializeGeometry();
} void RunManager::BeamOn(G4int n_event, const char* macroFile, G4int n_select) {
@@ -96,32 +98,26 @@
this->Initialize(); }
- // Run events. - m_numberOfEventsToRun = n_event; - G4RunManager::BeamOn(n_event, macroFile, n_select); - - // Print number of events generated. - EventSourceManager* eventManager = EventSourceManager::instance(); - eventManager->printNumEventsGenerated(); - - // Check if event underflow occurred where number of events provided was less than requested. - int nEventsGenerated = eventManager->getNumEventsGenerated(); - if (nEventsGenerated < m_numberOfEventsToRun) { - log() << LOG::error << LOG::head << "Generated " << nEventsGenerated << " events but " << n_event - << " were requested." << LOG::done; - SlicApplication::instance()->setReturnCode(SlicApplication::EVENT_UNDERFLOW); - } -}
+ // Check if run should be aborted due to initialization errors. + if (!this->isRunAborted()) {
-void RunManager::DoEventLoop(G4int n_event, const char* macroFile, G4int n_select) { - // The event loop is only called if the run is not already aborted, - // e.g. in the setup of some manager or event action class called before here. - if (!m_abortRun) { - log() << LOG::okay << LOG::head << "Generating " << n_event << " events." << LOG::done; - G4RunManager::DoEventLoop(n_event, macroFile, n_select);
+ // Run number of events that were requested. + m_numberOfEventsToRun = n_event; + G4RunManager::BeamOn(n_event, macroFile, n_select); + + // Print number of events that were actually generated. + EventSourceManager* eventManager = EventSourceManager::instance(); + eventManager->printNumEventsGenerated(); + + // Check if event underflow occurred where number of events provided was less than requested. + int nEventsGenerated = eventManager->getNumEventsGenerated(); + if (nEventsGenerated < m_numberOfEventsToRun) { + log() << LOG::error << LOG::head << "Generated " << nEventsGenerated << " events but " << n_event + << " were requested." << LOG::done; + SlicApplication::instance()->setReturnCode(SlicApplication::EVENT_UNDERFLOW); + }
} else {
- log() << LOG::warning << LOG::head << "Run was aborted before G4 event loop was executed." - << LOG::done;
+ log() << LOG::warning << LOG::head << "Run was aborted before G4 event loop was executed." << LOG::done;
} }
diff -u -r1.57 -r1.58 --- SlicApplication.cc 27 Nov 2012 19:32:19 -0000 1.57 +++ SlicApplication.cc 28 Nov 2012 01:18:37 -0000 1.58 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/SlicApplication.cc,v 1.57 2012/11/27 19:32:19 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/SlicApplication.cc,v 1.58 2012/11/28 01:18:37 jeremy Exp $
#include "SlicApplication.hh"
@@ -32,7 +32,6 @@
// geant4 visualization #ifdef G4VIS_USE #include "G4VisExecutive.hh"
-//#include "G4BlineTracer.hh"
#endif // geant4 UI
@@ -76,7 +75,9 @@
#ifdef SLIC_LOG log() << LOG::okay << LOG::head << "SLIC is exiting." << LOG::done;
+ log() << "return code: " << getReturnCode() << " => " << getErrorCodeString(getReturnCode()) << LOG::done;
#endif
+
} void SlicApplication::initialize(int argc, char** argv) {
@@ -141,9 +142,6 @@
// VRML writer within SLIC. new VRML2WriterMessenger();
- - // B-field visualization. - //new G4BlineTracer();
} #endif
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1