projects/slic/branches/v00-00-01_SLIC-218-dev/include
--- projects/slic/branches/v00-00-01_SLIC-218-dev/include/MCParticleManager.hh 2014-01-15 22:10:28 UTC (rev 2885)
+++ projects/slic/branches/v00-00-01_SLIC-218-dev/include/MCParticleManager.hh 2014-01-15 23:05:42 UTC (rev 2886)
@@ -87,6 +87,12 @@
_visitedParticles.clear();
}
+ void createMCParticleCollection() {
+ if (_mcpVec == 0) {
+ _mcpVec = new LCCollectionVec(EVENT::LCIO::MCPARTICLE);
+ }
+ }
+
void generateEvent(LCCollectionVec* mcparticles, G4Event* event);
void applyLorentzTransformation(LCCollection*, const G4double);
projects/slic/branches/v00-00-01_SLIC-218-dev/include
--- projects/slic/branches/v00-00-01_SLIC-218-dev/include/StdHepEventSource.hh 2014-01-15 22:10:28 UTC (rev 2885)
+++ projects/slic/branches/v00-00-01_SLIC-218-dev/include/StdHepEventSource.hh 2014-01-15 23:05:42 UTC (rev 2886)
@@ -3,8 +3,7 @@
#ifndef SLIC_STDHEPEVENTSOURCE_HH
#define SLIC_STDHEPEVENTSOURCE_HH 1
-// slic
-#include "StdHepLoader.hh"
+// SLIC
#include "EventSourceWithInputFile.hh"
#include "StdHepGenerator.hh"
projects/slic/branches/v00-00-01_SLIC-218-dev/src
--- projects/slic/branches/v00-00-01_SLIC-218-dev/src/LcioManager.cc 2014-01-15 22:10:28 UTC (rev 2885)
+++ projects/slic/branches/v00-00-01_SLIC-218-dev/src/LcioManager.cc 2014-01-15 23:05:42 UTC (rev 2886)
@@ -340,18 +340,21 @@
/* Get the current MCParticle collection. */
LCCollection* mcpColl = MCParticleManager::instance()->getMCParticleCollection();
- /* Set the event weight. */
- float eventWeight = mcpColl->getParameters().getFloatVal("_weight");
- if (eventWeight != 0.0) {
- lcevt->setWeight(eventWeight);
- }
+ if (mcpColl != 0) {
- /* Set the idrup. */
- int idrup = mcpColl->getParameters().getIntVal("_idrup");
- if (idrup != 0) {
- lcevt->parameters().setValue("_idrup", idrup);
- }
+ /* Set the event weight. */
+ float eventWeight = mcpColl->getParameters().getFloatVal("_weight");
+ if (eventWeight != 0.0) {
+ lcevt->setWeight(eventWeight);
+ }
+ /* Set the idrup. */
+ int idrup = mcpColl->getParameters().getIntVal("_idrup");
+ if (idrup != 0) {
+ lcevt->parameters().setValue("_idrup", idrup);
+ }
+ }
+
/* Set the current LCEvent. */
setCurrentLCEvent(lcevt);
projects/slic/branches/v00-00-01_SLIC-218-dev/src
--- projects/slic/branches/v00-00-01_SLIC-218-dev/src/TrackManager.cc 2014-01-15 22:10:28 UTC (rev 2885)
+++ projects/slic/branches/v00-00-01_SLIC-218-dev/src/TrackManager.cc 2014-01-15 23:05:42 UTC (rev 2886)
@@ -18,13 +18,16 @@
void TrackManager::saveTrackSummaries(const G4Event* anEvent, LCEvent* lcEvent) {
- PrimaryParticleMapIterator it;
+ /* If Geant4 event generation was used, then an empty MCParticle collection needs to be created. */
+ if (MCParticleManager::instance()->getMCParticleCollection() == 0) {
+ MCParticleManager::instance()->createMCParticleCollection();
+ }
- /* Get the map of MCParticles to G4PrimaryParticles. The latter has the track IDs. */
+ /* Get the map of MCParticles to G4PrimaryParticles. */
PrimaryParticleMap* particleMap = MCParticleManager::instance()->getPrimaryParticleMap();
- /* Copy MCParticle information from generated primary particles into the corresponding TrackSummary objects. */
- for (it = particleMap->begin(); it != particleMap->end(); it++) {
+ /* Copy MCParticle pointers into the corresponding TrackSummary objects. */
+ for (PrimaryParticleMapIterator it = particleMap->begin(); it != particleMap->end(); it++) {
if (it->second->GetTrackID() < 0) continue;
@@ -36,7 +39,7 @@
}
}
- /* Set parents to be saved also on particles that will be persisted. */
+ /* Set parents to be saved on particles that will be persisted. */
for (G4int k = _trackSummaries->size()-1; k >= 0; k--) {
if (((*_trackSummaries)[k])->getToBeSaved())
((*_trackSummaries)[k])->setParentToBeSaved();
@@ -67,9 +70,11 @@
/*
* Only particles created in the simulation need to be added as the primaries
- * were put into the collection during event generation.
+ * were put into the collection during event generation. Also, if the parent ID
+ * is zero, then the information should be written, as this track was (probably?)
+ * generated using the GPS or G4ParticleGun.
*/
- if(trackSummary->getMCParticle()->getGeneratorStatus() == 0 ) {
+ if(trackSummary->getMCParticle()->getGeneratorStatus() == 0 || (trackSummary->getParentID() == 0)) {
if (trackSummary->getMCParticle() != 0) {
mcpVec->push_back(trackSummary->getMCParticle());
}