2 added + 8 modified, total 10 files
projects/slic/branches/v04-00-00-pre/include
--- projects/slic/branches/v04-00-00-pre/include/StackingAction.hh (rev 0)
+++ projects/slic/branches/v04-00-00-pre/include/StackingAction.hh 2014-07-02 00:03:13 UTC (rev 3166)
@@ -0,0 +1,25 @@
+#ifndef SLIC_STACKINGACTION_HH
+#define SLIC_STACKINGACTION_HH 1
+
+#include "globals.hh"
+#include "G4UserStackingAction.hh"
+
+/**
+ * Implementation of G4UserStackingAction for SLIC.
+ * This is copied from Mokka and right now it just
+ * suspends backscattering tracks until the end
+ * of shower development.
+ */
+class StackingAction : public G4UserStackingAction {
+
+public:
+ StackingAction();
+ virtual ~StackingAction();
+
+public:
+
+ G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track* aTrack);
+};
+
+#endif
+
projects/slic/branches/v04-00-00-pre/include
--- projects/slic/branches/v04-00-00-pre/include/TrackUtil.hh 2014-07-02 00:01:15 UTC (rev 3165)
+++ projects/slic/branches/v04-00-00-pre/include/TrackUtil.hh 2014-07-02 00:03:13 UTC (rev 3166)
@@ -36,7 +36,8 @@
/**
* Setup the UserTrackInformation for the G4Track, which also requires first
- * creating a TrackSummary containing all the track information.
+ * creating a TrackSummary containing all the track information. This will register
+ * the TrackSummary in the global list for the event.
* @return The UserTrackInformation that was created for the track.
*/
static UserTrackInformation* setupUserTrackInformation(const G4Track* track, G4bool save) {
projects/slic/branches/v04-00-00-pre/include
--- projects/slic/branches/v04-00-00-pre/include/UserTrackInformation.hh 2014-07-02 00:01:15 UTC (rev 3165)
+++ projects/slic/branches/v04-00-00-pre/include/UserTrackInformation.hh 2014-07-02 00:03:13 UTC (rev 3166)
@@ -1,6 +1,9 @@
#ifndef slic_UserTrackInformation_hh_
#define slic_UserTrackInformation_hh_ 1
+// LCDD
+#include "lcdd/geant4/VUserTrackInformation.hh"
+
// SLIC
#include "TrackSummary.hh"
@@ -15,7 +18,8 @@
* @class UserTrackInformation
* @brief The implementation of the G4VUserTrackInformation class for storing track information within the event
*/
-class UserTrackInformation: public G4VUserTrackInformation {
+class UserTrackInformation : public VUserTrackInformation {
+ //: public G4VUserTrackInformation {
public:
@@ -51,6 +55,11 @@
return _trackSummary;
}
+ void setHasTrackerHit() {
+ if (_trackSummary != NULL)
+ _trackSummary->setHasTrackerHit();
+ }
+
/**
* Print out the track information.
*/
projects/slic/branches/v04-00-00-pre/src
--- projects/slic/branches/v04-00-00-pre/src/MCParticleManager.cc 2014-07-02 00:01:15 UTC (rev 3165)
+++ projects/slic/branches/v04-00-00-pre/src/MCParticleManager.cc 2014-07-02 00:03:13 UTC (rev 3166)
@@ -181,7 +181,7 @@
if (alpha == 0)
return; // nothing to do
- G4cout << "Applying Lorentz Transformation angle: " << alpha << G4endl;
+ //G4cout << "Applying Lorentz Transformation angle: " << alpha << G4endl;
// parameters of the Lorentz transformation matrix
const G4double gamma = sqrt(1 + sqr(tan(alpha)));
projects/slic/branches/v04-00-00-pre/src
--- projects/slic/branches/v04-00-00-pre/src/RunManager.cc 2014-07-02 00:01:15 UTC (rev 3165)
+++ projects/slic/branches/v04-00-00-pre/src/RunManager.cc 2014-07-02 00:03:13 UTC (rev 3166)
@@ -9,6 +9,7 @@
#include "PrimaryGeneratorAction.hh"
#include "RunAction.hh"
#include "SlicApplication.hh"
+#include "StackingAction.hh"
#include "SteppingAction.hh"
#include "TrackingAction.hh"
@@ -30,11 +31,12 @@
}
void RunManager::initializeUserActions() {
- SetUserAction(new PrimaryGeneratorAction);
- SetUserAction(new RunAction);
- SetUserAction(new EventAction);
- SetUserAction(new TrackingAction);
- SetUserAction(new SteppingAction);
+ SetUserAction(new PrimaryGeneratorAction());
+ SetUserAction(new RunAction());
+ SetUserAction(new EventAction());
+ SetUserAction(new TrackingAction());
+ SetUserAction(new SteppingAction());
+ SetUserAction(new StackingAction());
m_userActionsInitialized = true;
}
projects/slic/branches/v04-00-00-pre/src
--- projects/slic/branches/v04-00-00-pre/src/StackingAction.cc (rev 0)
+++ projects/slic/branches/v04-00-00-pre/src/StackingAction.cc 2014-07-02 00:03:13 UTC (rev 3166)
@@ -0,0 +1,24 @@
+/*
+ * StackingAction.cc
+ *
+ * Created on: Jun 26, 2014
+ * Author: jeremym
+ */
+
+#include "StackingAction.hh"
+#include "G4Track.hh"
+#include "G4DecayProducts.hh"
+#include "G4ios.hh"
+
+StackingAction::StackingAction() {
+}
+
+StackingAction::~StackingAction() {
+}
+
+G4ClassificationOfNewTrack StackingAction::ClassifyNewTrack(const G4Track* aTrack) {
+ G4ClassificationOfNewTrack classification = fUrgent;
+ if(aTrack->GetTrackStatus()==fSuspend) classification = fWaiting;
+ return classification;
+}
+
projects/slic/branches/v04-00-00-pre/src
--- projects/slic/branches/v04-00-00-pre/src/SteppingAction.cc 2014-07-02 00:01:15 UTC (rev 3165)
+++ projects/slic/branches/v04-00-00-pre/src/SteppingAction.cc 2014-07-02 00:03:13 UTC (rev 3166)
@@ -3,6 +3,7 @@
// SLIC
#include "SteppingAction.hh"
#include "UserTrackInformation.hh"
+#include "TrackUtil.hh"
// LCDD
#include "lcdd/geant4/UserRegionInformation.hh"
@@ -24,9 +25,26 @@
/* Check for back scattering. */
if (isBackScattering(step)) {
+
+ // Get track information.
UserTrackInformation* trackInfo =
(UserTrackInformation*)fpSteppingManager->GetTrack()->GetUserInformation();
+
+ // Need to start making track information if doesn't exist because these tracks or daughters could leave tracker hits.
+ if (trackInfo == NULL)
+ // Add new track information but don't save. The tracker hit processor can turn saving on.
+ trackInfo = TrackUtil::setupUserTrackInformation(fpSteppingManager->GetTrack(), false);
+
+ TrackSummary* trackSummary = trackInfo->getTrackSummary();
+
+ //G4cout << "setting backscattering flag" << G4endl;
+ trackInfo->getTrackSummary()->update(fpSteppingManager->GetTrack());
trackInfo->getTrackSummary()->setBackScattering();
+
+ // Suspend backscattering tracks to postpone them to the end of shower development.
+ fpSteppingManager->GetTrack()->SetTrackStatus(fSuspend);
+
+ //G4cout << "suspended backscattering track " << fpSteppingManager->GetTrack()->GetTrackID() << G4endl;
}
/* Check if the track should be killed. */
projects/slic/branches/v04-00-00-pre/src
--- projects/slic/branches/v04-00-00-pre/src/TrackManager.cc 2014-07-02 00:01:15 UTC (rev 3165)
+++ projects/slic/branches/v04-00-00-pre/src/TrackManager.cc 2014-07-02 00:03:13 UTC (rev 3166)
@@ -43,32 +43,14 @@
}
}
- /* Force tracks to be saved that have TrackerHits associated to them. */
- G4HCofThisEvent* hitsCollections = anEvent->GetHCofThisEvent();
- for (int i = 0; i < hitsCollections->GetNumberOfCollections(); i++) {
- G4VHitsCollection* hitsCollection = hitsCollections->GetHC(i);
- TrackerHitsCollection* trackerHitsCollection = NULL;
- if ((trackerHitsCollection = dynamic_cast<TrackerHitsCollection*>(hitsCollection)) != NULL) {
- for (int j = 0; j < trackerHitsCollection->GetSize(); j++) {
- TrackerHit* trackerHit = (TrackerHit*)trackerHitsCollection->GetHit(j);
- if (trackerHit->getTrackID() > 0) {
- TrackSummary* trackSummary = findTrackSummary(trackerHit->getTrackID());
- if (trackSummary != NULL) {
- trackSummary->setToBeSaved();
- }
- }
- }
- }
- }
-
G4bool writeCompleteEvent = LcioManager::instance()->getWriteCompleteEvent();
- /* Set parents to be saved 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--) {
- /* Save all TrackSummary objects if full event is being written. */
- if (writeCompleteEvent)
- (*_trackSummaries)[k]->setToBeSaved();
- /* Force parents to be saved if TrackSummary will be saved. */
+ // Save all TrackSummary objects if full event is being written.
+ //if (writeCompleteEvent)
+ // (*_trackSummaries)[k]->setToBeSaved();
+ // Force parents to be saved if TrackSummary will be saved.
if (((*_trackSummaries)[k])->getToBeSaved())
((*_trackSummaries)[k])->setParentToBeSaved();
}
@@ -84,7 +66,8 @@
TrackSummary* trackSummary;
for (l = 0; l < _trackSummaries->size(); l++) {
trackSummary = (*_trackSummaries)[l];
- if (trackSummary->getToBeSaved() | writeCompleteEvent) {
+ //| writeCompleteEvent
+ if (trackSummary->getToBeSaved()) {
/* Build the MCParticle in case it hasn't been created yet. */
if (trackSummary->getMCParticle() == 0) {
@@ -105,15 +88,15 @@
if(trackSummary->getMCParticle()->getGeneratorStatus() == 0 || geant4Generator) {
if (trackSummary->getMCParticle() != NULL) {
mcpVec->push_back(trackSummary->getMCParticle());
+ // DEBUG
+ if (trackSummary->getParentID() <= 0)
+ G4cout << "WARNING: sim particle with track ID " << trackSummary->getTrackID() << " has no parent!" << G4endl;
}
}
- }
- else {
- /*
- * If the track will not be saved then associate the information to its first persisted ancestor.
- * This will allow association between track IDs from sensitive detector's in LCDD to their appropriate
- * MCParticle objects in the output collection.
- */
+ } else {
+ // If the track will not be saved then associate the information to its first persisted ancestor.
+ // This will allow association between track IDs from sensitive detector's in LCDD to their appropriate
+ // MCParticle objects in the output collection.
findFirstSavedAncestor(trackSummary);
}
}
projects/slic/branches/v04-00-00-pre/src
--- projects/slic/branches/v04-00-00-pre/src/TrackSummary.cc 2014-07-02 00:01:15 UTC (rev 3165)
+++ projects/slic/branches/v04-00-00-pre/src/TrackSummary.cc 2014-07-02 00:03:13 UTC (rev 3166)
@@ -135,8 +135,12 @@
// passed by here.
return;
- // TODO: Check if this code block must be called. I think this happens elsewhere, too.
TrackSummary* myParent = findParent();
+ /*
+ if (myParent == this) {
+ G4cout << "summary for " << this->getTrackID() << " is its own parent (probably a primary)" << G4endl;
+ }
+ */
if (myParent) {
// std::cout << " **** TrackSummary::SetParentToBeSaved for trackID: " << myParent->GetTrackID() << " this trackid: " << GetTrackID() << std::endl ;
@@ -158,14 +162,19 @@
_mcparticle->addParent(theParentMCParticle);
}
}
+ // DEBUG
+ } else {
+ if (this->getParentID() != 0)
+ G4cout << "WARNING: no parent track ID " << this->getParentID() << " found for " << this->getTrackID() << G4endl;
}
}
TrackSummary* TrackSummary::findParent() const {
TrackSummary* trackSummary = 0;
- if (_parentTrackID == 0)
+ if (_parentTrackID == 0) {
return trackSummary;
+ }
return m_trackManager->findTrackSummary(_parentTrackID);
}
projects/slic/branches/v04-00-00-pre/src
--- projects/slic/branches/v04-00-00-pre/src/TrackingAction.cc 2014-07-02 00:01:15 UTC (rev 3165)
+++ projects/slic/branches/v04-00-00-pre/src/TrackingAction.cc 2014-07-02 00:03:13 UTC (rev 3166)
@@ -1,6 +1,9 @@
// $Header: /nfs/slac/g/lcd/cvs/lcdroot/slic/src/TrackingAction.cc,v 1.14 2012-11-27 19:32:19 jeremy Exp $
#include "TrackingAction.hh"
+// LCDD
+#include "lcdd/detectors/CurrentTrackState.hh"
+
// SLIC
#include "TrackUtil.hh"
#include "UserTrackInformation.hh"
@@ -12,53 +15,77 @@
void TrackingAction::PreUserTrackingAction(const G4Track* track) {
- G4bool isPrimary = (track->GetParentID() == 0);
+ G4int trackID = track->GetTrackID();
+ G4int parentID = track->GetParentID();
+
+ G4bool isTruePrimary = (track->GetParentID() == 0);
UserRegionInformation* regionInfo = TrackUtil::getRegionInformation(track);
G4bool insideTrackerRegion = regionInfo->getStoreSecondaries();
- //G4bool decayInsideTracker = false;
- UserTrackInformation* trackInfo = dynamic_cast<UserTrackInformation*>(track->GetUserInformation());
+ UserTrackInformation* trackInfo = TrackUtil::getUserTrackInformation(track);
+ bool hasTrackInfo = (trackInfo != NULL);
+ bool aboveEnergyThreshold = (track->GetKineticEnergy() > regionInfo->getThreshold());
- /* Track is primary? */
- //if (!isPrimary) {
+ // This happens when backscattering track are un-suspended.
+ if (hasTrackInfo) {
+ // Track is backscattering?
+ if (trackInfo->getTrackSummary()->getBackScattering()) {
+ // Update current track ID for calorimeter SDs and return.
+ CurrentTrackState::setCurrentTrackID(trackID);
+ return;
+ }
+ return;
+ }
- /* Inside tracker region? */
- //if (insideTrackerRegion) {
- //const G4VProcess* theCreatorProcess = track->GetCreatorProcess();
+ // Primary OR in tracker region and above energy threshold?
+ if (isTruePrimary || (insideTrackerRegion && aboveEnergyThreshold)) {
- /* Decay in tracker? */
- //if (theCreatorProcess)
- // decayInsideTracker = theCreatorProcess->GetProcessName() == "Decay";
- //}
- //}
+ // Update track ID for calorimeter SDs.
+ CurrentTrackState::setCurrentTrackID(trackID);
- /* Default setting of not saving this track's information to the LCIO output. */
- G4bool save = false;
+ // Turn on trajectory storage.
+ fpTrackingManager->SetStoreTrajectory(true);
- /* Store trajectory? */
- if (isPrimary || (insideTrackerRegion && track->GetKineticEnergy() > regionInfo->getThreshold())) {
+ // Has track information?
+ if (!hasTrackInfo) {
+ // Create the track information and save it.
+ TrackUtil::setupUserTrackInformation(track, true);
+ }
- /* These tracks should be saved. */
- save = true;
-
- /* Turn on trajectory storage in Geant4. */
- fpTrackingManager->SetStoreTrajectory(true);
+ } else {
+ // Inside tracker region and below energy threshold?
+ if (insideTrackerRegion && !aboveEnergyThreshold) {
+ // Has track information?
+ if (!hasTrackInfo) {
+ // Create track information but do not save it.
+ TrackUtil::setupUserTrackInformation(track, false);
+ }
+ } else {
+ // Track is outside tracking region so turn off trajectory storage.
+ // These are generally tracks from calorimeter showers.
+ fpTrackingManager->SetStoreTrajectory(false);
+ }
}
- /* Turn off trajectory storing. */
- else {
- fpTrackingManager->SetStoreTrajectory(false);
- }
-
- /* Setup the UserTrackInformation if it does not exist. */
- if (!trackInfo) {
- TrackUtil::setupUserTrackInformation(track, save);
- }
}
void TrackingAction::PostUserTrackingAction(const G4Track* track) {
- /* Update the TrackSummary with final information about the track. */
+
+ // Get the track information and summary.
UserTrackInformation* trackInfo = TrackUtil::getUserTrackInformation(track);
- if (trackInfo) {
- trackInfo->getTrackSummary()->update(track);
+ TrackSummary* trackSummary = NULL;
+ if (trackInfo != NULL)
+ trackSummary = trackInfo->getTrackSummary();
+
+ // Track has secondaries?
+ if (fpTrackingManager->GimmeSecondaries()->size() > 0 && trackInfo == NULL) {
+ // Tracks with secondaries always get track information but they are not saved by default.
+ trackSummary = TrackUtil::setupUserTrackInformation(track, false)->getTrackSummary();
}
+
+ // Track summary exists?
+ if (trackSummary != NULL) {
+ // Update the track summary.
+ trackSummary->update(track);
+ }
}
-}
+
+} // namespace slic
SVNspam 0.1