6 modified files
slic/include
diff -u -r1.16 -r1.17
--- RunManager.hh 28 Nov 2012 01:18:37 -0000 1.16
+++ RunManager.hh 29 Nov 2012 00:32:45 -0000 1.17
@@ -1,11 +1,14 @@
-// $Header: /cvs/lcd/slic/include/RunManager.hh,v 1.16 2012/11/28 01:18:37 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/RunManager.hh,v 1.17 2012/11/29 00:32:45 jeremy Exp $
#ifndef SLIC_RUNMANAGER_HH
#define SLIC_RUNMANAGER_HH 1
+// geant4
#include "G4RunManager.hh"
+// slic
#include "Module.hh"
+#include "SlicApplication.hh"
namespace slic {
/**
@@ -27,7 +30,20 @@
void abortRun() {
//std::cout << "RunManager.abortRun - run will be aborted!!!" << std::endl;
+ log() << LOG::fatal << "Aborting run." << LOG::done;
m_abortRun = true;
+ // Set return code to generic error but don't override if error is already set.
+ if (SlicApplication::instance()->getReturnCode() == SlicApplication::OKAY) {
+ SlicApplication::instance()->setReturnCode(SlicApplication::UNKNOWN_ERROR);
+ }
+ G4RunManager::GetRunManager()->AbortRun(false);
+ }
+
+ void abortRun(int errorCode) {
+ log() << LOG::fatal << LOG::name << LOG::sep << "Aborting run with return code: " << errorCode << LOG::done;
+ m_abortRun = true;
+ SlicApplication::instance()->setReturnCode(errorCode);
+ G4RunManager::GetRunManager()->AbortRun(false);
}
void Initialize();
slic/include
diff -u -r1.41 -r1.42
--- SlicApplication.hh 28 Nov 2012 01:18:37 -0000 1.41
+++ SlicApplication.hh 29 Nov 2012 00:32:45 -0000 1.42
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/include/SlicApplication.hh,v 1.41 2012/11/28 01:18:37 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/SlicApplication.hh,v 1.42 2012/11/29 00:32:45 jeremy Exp $
#ifndef SLIC_SLICAPPLICATION_HH
#define SLIC_SLICAPPLICATION_HH 1
@@ -19,6 +19,7 @@
class G4UIExecutive;
namespace slic {
+
// slic
class FieldMessenger;
class SlicApplicationMessenger;
@@ -32,7 +33,8 @@
"output file already exists",
"failed to delete old output file",
"event underflow",
- "invalid geometry setup"
+ "invalid geometry setup",
+ "event generator was never setup"
};
/**
@@ -64,6 +66,7 @@
FAILED_DELETE_LCIO_FILE,
EVENT_UNDERFLOW,
INVALID_GEOMETRY_SETUP,
+ GENERATOR_NOT_SETUP,
ERROR_CODE_SIZE
};
slic/src
diff -u -r1.24 -r1.25
--- EventSourceManager.cc 27 Nov 2012 19:32:19 -0000 1.24
+++ EventSourceManager.cc 29 Nov 2012 00:32:45 -0000 1.25
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/EventSourceManager.cc,v 1.24 2012/11/27 19:32:19 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/EventSourceManager.cc,v 1.25 2012/11/29 00:32:45 jeremy Exp $
#include "EventSourceManager.hh"
// slic
@@ -8,11 +8,14 @@
#include "LcioEventSource.hh"
#include "FileUtil.hh"
#include "EventAction.hh"
+#include "SlicApplication.hh"
+#include "RunManager.hh"
// lcdd
#include "StringUtil.hh"
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");
@@ -21,7 +24,7 @@
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(
+ false), m_ngen(0), m_nskip(0), m_newSource(true), m_sourceType(eUnknown), m_lorentzTransformationAngle(
0.), m_zSmearingParam(0.) {
// messenger with generator command macro bindings
@@ -66,8 +69,7 @@
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;
+ log() << LOG::error << "WARNING: File <" << m_filename << "> does not have a known file extension." << LOG::done;
}
return est;
}
@@ -242,17 +244,27 @@
}
void EventSourceManager::beginRun(const G4Run* aRun) {
+
+#ifdef SLIC_LOG
+ log() << LOG::debug << LOG::name << "beginRun" << LOG::done;
+#endif
+
// Setup a new event source if neccessary.
setupEventSource();
// Call the beginRun() function of the current event source.
- m_currentEventSource->beginRun(aRun);
+ if (m_currentEventSource != 0) {
+ m_currentEventSource->beginRun(aRun);
- // Filename is now old so source won't reset.
- m_newFilename = false;
+ // Filename is now old so source won't reset.
+ m_newFilename = false;
- // Reset event counter.
- m_ngen = 0;
+ // Reset event counter.
+ m_ngen = 0;
+ } /*else {
+ log() << LOG::fatal << "No event generator was setup." << LOG::done;
+ RunManager::instance()->abortRun(SlicApplication::GENERATOR_NOT_SETUP);
+ }*/
}
void EventSourceManager::setupEventSource() {
slic/src
diff -u -r1.92 -r1.93
--- LcioManager.cc 28 Nov 2012 01:47:04 -0000 1.92
+++ LcioManager.cc 29 Nov 2012 00:32:45 -0000 1.93
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/LcioManager.cc,v 1.92 2012/11/28 01:47:04 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/LcioManager.cc,v 1.93 2012/11/29 00:32:45 jeremy Exp $
#include "LcioManager.hh"
// slic
@@ -101,19 +101,15 @@
// 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();
- }
+ log() << LOG::fatal << LOG::name << LOG::sep << "LCIO file already exists: " << fullFilename << LOG::done;
+ RunManager::instance()->abortRun(SlicApplication::OUTPUT_FILE_EXISTS);
// Deletion mode is on, so try to remove the current file.
- else if (m_fileExistsAction == eDelete) {
+ } else if (m_fileExistsAction == eDelete) {
if (FileUtil::removeFile(fullFilename) != 0) {
// 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_LCIO_FILE);
- RunManager::instance()->abortRun();
+ RunManager::instance()->abortRun(SlicApplication::FAILED_DELETE_LCIO_FILE);
} else {
log().okay("Deleted old LCIO file: " + fullFilename);
}
slic/src
diff -u -r1.36 -r1.37
--- PrimaryGeneratorAction.cc 27 Nov 2012 19:32:19 -0000 1.36
+++ PrimaryGeneratorAction.cc 29 Nov 2012 00:32:45 -0000 1.37
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/PrimaryGeneratorAction.cc,v 1.36 2012/11/27 19:32:19 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/PrimaryGeneratorAction.cc,v 1.37 2012/11/29 00:32:45 jeremy Exp $
#include "PrimaryGeneratorAction.hh"
@@ -30,9 +30,12 @@
}
void PrimaryGeneratorAction::GeneratePrimaries(G4Event *anEvent) {
- // Check if run needs to be aborted.
+
+ // Check if run needs to be aborted, in which case we immediately return without executing anything.
if (RunManager::instance()->isRunAborted()) {
G4RunManager::GetRunManager()->AbortRun();
+ log() << LOG::warning << LOG::name << LOG::sep << "Run was already aborted. Will not generate events." << LOG::done;
+ return;
}
EventSourceManager* mgr = EventSourceManager::instance();
slic/src
diff -u -r1.21 -r1.22
--- RunManager.cc 28 Nov 2012 01:18:37 -0000 1.21
+++ RunManager.cc 29 Nov 2012 00:32:45 -0000 1.22
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/RunManager.cc,v 1.21 2012/11/28 01:18:37 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/RunManager.cc,v 1.22 2012/11/29 00:32:45 jeremy Exp $
#include "RunManager.hh"
// lcdd
@@ -98,6 +98,12 @@
this->Initialize();
}
+ // Check if a generator was setup.
+ if (EventSourceManager::instance()->getCurrentSource() == 0) {
+ log() << LOG::fatal << "No event generator was setup." << LOG::done;
+ abortRun(SlicApplication::GENERATOR_NOT_SETUP);
+ }
+
// Check if run should be aborted due to initialization errors.
if (!this->isRunAborted()) {
@@ -112,9 +118,12 @@
// 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
+ log() << LOG::warning << LOG::head << "Generated " << nEventsGenerated << " events but " << n_event
<< " were requested." << LOG::done;
- SlicApplication::instance()->setReturnCode(SlicApplication::EVENT_UNDERFLOW);
+ // Set event underflow error but do not override an existing return code.
+ if (SlicApplication::instance()->getReturnCode() == SlicApplication::OKAY) {
+ SlicApplication::instance()->setReturnCode(SlicApplication::EVENT_UNDERFLOW);
+ }
}
} else {
log() << LOG::warning << LOG::head << "Run was aborted before G4 event loop was executed." << LOG::done;
CVSspam 0.2.12