Commit in projects/lcdd/branches/v04-00-00-pre on MAIN | |||
include/lcdd/detectors/CurrentTrackState.hh | +46 | added 3164 | |
include/lcdd/hits/HitContribution.hh | +2 | 3163 -> 3164 | |
src/lcdd/detectors/BasicTrackerHitProcessor.cc | +13 | -9 | 3163 -> 3164 |
/CurrentTrackState.cc | +11 | added 3164 | |
/LegacyCalorimeterHitProcessor.cc | +42 | -1 | 3163 -> 3164 |
src/lcdd/hits/HitContribution.cc | +26 | 3163 -> 3164 | |
+140 | -10 |
Updates in LCDD related to SLIC MCParticle code refactoring.
--- projects/lcdd/branches/v04-00-00-pre/include/lcdd/detectors/CurrentTrackState.hh (rev 0) +++ projects/lcdd/branches/v04-00-00-pre/include/lcdd/detectors/CurrentTrackState.hh 2014-07-01 23:55:53 UTC (rev 3164) @@ -0,0 +1,46 @@
+/* + * CurrentTrackState.hh + * + * Created on: Jun 24, 2014 + * Author: jeremym + */ + +#ifndef LCDD_DETECTORS_CURRENTTRACKSTATE_HH_ +#define LCDD_DETECTORS_CURRENTTRACKSTATE_HH_ 1 + +// Geant4 +#include "globals.hh" + +class CurrentTrackState { + +private: + + CurrentTrackState() { + } + +public: + + static void setCurrentTrackID(G4int trackID) { + //G4cout << "setCurrentTrackID - " << trackID << G4endl; + _currentTrackID = trackID; + } + + static void setCurrentPrimaryID(G4int trackID) { + _currentPrimaryID = trackID; + } + + static G4int getCurrentTrackID() { + return _currentTrackID; + } + + static G4int getCurrentPrimaryID() { + return _currentPrimaryID; + } + +public: + + static G4int _currentTrackID; + static G4int _currentPrimaryID; +}; + +#endif /* CURRENTTRACKSTATE_HH_ */
--- projects/lcdd/branches/v04-00-00-pre/include/lcdd/hits/HitContribution.hh 2014-07-01 07:08:10 UTC (rev 3163) +++ projects/lcdd/branches/v04-00-00-pre/include/lcdd/hits/HitContribution.hh 2014-07-01 23:55:53 UTC (rev 3164) @@ -31,6 +31,8 @@
*/ HitContribution();
+ HitContribution(G4int trackID, const G4Step* aStep); +
/** * Fully qualified constructor. * @param[in] trackID The Geant4 track ID.
--- projects/lcdd/branches/v04-00-00-pre/src/lcdd/detectors/BasicTrackerHitProcessor.cc 2014-07-01 07:08:10 UTC (rev 3163) +++ projects/lcdd/branches/v04-00-00-pre/src/lcdd/detectors/BasicTrackerHitProcessor.cc 2014-07-01 23:55:53 UTC (rev 3164) @@ -2,11 +2,13 @@
// LCDD #include "lcdd/detectors/BasicTrackerHitProcessor.hh"
-//#include "lcdd/hits/TrackInformation.hh"
+#include "lcdd/detectors/CurrentTrackState.hh" +#include "lcdd/geant4/VUserTrackInformation.hh"
// Geant4 #include "G4Geantino.hh" #include "G4ChargedGeantino.hh"
+#include "globals.hh"
BasicTrackerHitProcessor::BasicTrackerHitProcessor(TrackerSD* tracker) : TrackerHitProcessor(tracker) {
@@ -31,12 +33,6 @@
return false; }
- // Get the TrackInformation. - //TrackInformation* trkInfo = TrackInformation::getTrackInformation(step->GetTrack()); - - // Set the hasTrackerHit flag to true on the TrackInformation. - //trkInfo->setHasTrackerHit(true); -
// Get the track. G4Track* track = step->GetTrack();
@@ -47,7 +43,8 @@
G4StepPoint* post = step->GetPostStepPoint(); // Get the track ID.
- G4int trackId = track->GetTrackID();
+ //G4int trackId = track->GetTrackID();
+ G4int trackID = CurrentTrackState::getCurrentTrackID();
// Get the global time (ns). G4double time = track->GetGlobalTime();
@@ -83,7 +80,7 @@
Id64bit id64 = _tracker->makeIdentifier(step); // Set the hit information from above.
- hit->setTrackID(trackId);
+ hit->setTrackID(trackID);
hit->setEdep(edep); hit->setPosition(mid); hit->setMomentum(momentum);
@@ -94,6 +91,13 @@
// Add the hit to the TrackerSD. _tracker->addHit(hit);
+ // Get the TrackInformation and flag track as having a tracker hit. + VUserTrackInformation* trackInformation = dynamic_cast<VUserTrackInformation*>(step->GetTrack()->GetUserInformation()); + if (trackInformation) + trackInformation->setHasTrackerHit(); + else + G4Exception("BasicTrackerHitProcessor::processHits", "", FatalException, "Missing required VUserTrackInformation."); +
// Return true because created new hit. return true; }
--- projects/lcdd/branches/v04-00-00-pre/src/lcdd/detectors/CurrentTrackState.cc (rev 0) +++ projects/lcdd/branches/v04-00-00-pre/src/lcdd/detectors/CurrentTrackState.cc 2014-07-01 23:55:53 UTC (rev 3164) @@ -0,0 +1,11 @@
+/* + * CurrentTrackState.cc + * + * Created on: Jun 24, 2014 + * Author: jeremym + */ + +#include "lcdd/detectors/CurrentTrackState.hh" + +int CurrentTrackState::_currentTrackID = -1; +int CurrentTrackState::_currentPrimaryID = -1;
--- projects/lcdd/branches/v04-00-00-pre/src/lcdd/detectors/LegacyCalorimeterHitProcessor.cc 2014-07-01 07:08:10 UTC (rev 3163) +++ projects/lcdd/branches/v04-00-00-pre/src/lcdd/detectors/LegacyCalorimeterHitProcessor.cc 2014-07-01 23:55:53 UTC (rev 3164) @@ -1,8 +1,11 @@
// $Header: /nfs/slac/g/lcd/cvs/lcdroot/lcdd/src/lcdd/detectors/LegacyCalorimeterHitProcessor.cc,v 1.5 2013-11-13 23:02:56 jeremy Exp $ // LCDD
+#include "lcdd/detectors/CurrentTrackState.hh"
#include "lcdd/detectors/LegacyCalorimeterHitProcessor.hh"
+#include "lcdd/util/TimerUtil.hh" +
// Geant4 #include "G4Geantino.hh" #include "G4ChargedGeantino.hh"
@@ -31,6 +34,12 @@
return false; }
+ static std::string segTimer = _calorimeter->GetName() + "_seg"; + static std::string segTimerTotal = segTimer + "_total"; + if (!TimerUtil::haveTimer(segTimerTotal)) + TimerUtil::createTimer(segTimerTotal); + TimerUtil::startTimer(segTimer); +
// Get the Segmentation from the CalorimeterSD. Segmentation* segmentation = _calorimeter->getSegmentation();
@@ -41,12 +50,36 @@
//segmentation->resetBins(); segmentation->setBins(step);
+ long segTime = TimerUtil::stopTimer(segTimer); + //TimerUtil::printOut(segTimer, G4cout); + + TimerUtil::addTime(segTimerTotal, segTime); + //TimerUtil::printOut(segTimerTotal, G4cout); + + // TODO: time this call
// Create a 64-bit ID from the step information. Id64bit id = _calorimeter->makeIdentifier(step); // Check for an existing hit with this identifier.
+ static std::string findHitTimer = _calorimeter->GetName() + "_findHit"; + static std::string findHitTimerTotal = findHitTimer + "_total"; + if (!TimerUtil::haveTimer(findHitTimerTotal)) + TimerUtil::createTimer(findHitTimerTotal); + TimerUtil::startTimer(findHitTimer); +
CalorimeterHit* hit = _calorimeter->findHit(id);
+ long findHitTime = TimerUtil::stopTimer(findHitTimer); + //TimerUtil::printOut(findHitTimer, G4cout); + TimerUtil::addTime(findHitTimerTotal, findHitTime); + //TimerUtil::printOut(findHitTimerTotal, G4cout); + + static std::string addHitTimer = _calorimeter->GetName() + "_addHit"; + static std::string addHitTimerTotal = addHitTimer + "_total"; + if (!TimerUtil::haveTimer(addHitTimerTotal)) + TimerUtil::createTimer(addHitTimerTotal); + TimerUtil::startTimer(addHitTimer); +
// Was there a hit found with this identifier? if (hit == NULL) {
@@ -80,8 +113,16 @@
} // Add hit contribution to the hit.
- hit->addHitContribution(HitContribution(step));
+ //hit->addHitContribution(HitContribution(step)); + //G4cout << "addHitContribution - track ID " << CurrentTrackState::getCurrentTrackID() << G4endl; + // FIXME: This should pass a pointer to a new object. It is copied, which is inefficient. + hit->addHitContribution(HitContribution(CurrentTrackState::getCurrentTrackID(), step));
+ long addHitTime = TimerUtil::stopTimer(addHitTimer); + TimerUtil::addTime(addHitTimerTotal, addHitTime); + //TimerUtil::printOut(addHitTimer, G4cout); + //TimerUtil::printOut(addHitTimerTotal, G4cout); +
// Return true, indicating that a hit was added or modified. return true; }
--- projects/lcdd/branches/v04-00-00-pre/src/lcdd/hits/HitContribution.cc 2014-07-01 07:08:10 UTC (rev 3163) +++ projects/lcdd/branches/v04-00-00-pre/src/lcdd/hits/HitContribution.cc 2014-07-01 23:55:53 UTC (rev 3164) @@ -24,6 +24,32 @@
; }
+HitContribution::HitContribution(int trackID, const G4Step* aStep) { + // Get the track. + const G4Track* track = aStep->GetTrack(); + + _trackID = trackID; + + // Set edep according to type of track. + //if (track->GetDefinition() == G4OpticalPhoton::OpticalPhotonDefinition()) { + // _edep = track->GetTotalEnergy(); + //} else { + _edep = aStep->GetTotalEnergyDeposit(); + //} + + // PDG ID. + _PdgId = track->GetDefinition()->GetPDGEncoding(); + + // Global time. + _globalTime = track->GetGlobalTime(); + + // Compute the step midpoint. + G4ThreeVector posVec = (0.5 * (aStep->GetPreStepPoint()->GetPosition() + aStep->GetPostStepPoint()->GetPosition())); + _position[0] = posVec[0]; + _position[1] = posVec[1]; + _position[2] = posVec[2]; +} +
HitContribution::HitContribution(const G4Step* aStep) { // Get the track. const G4Track* track = aStep->GetTrack();
Use REPLY-ALL to reply to list
To unsubscribe from the LCDET-SVN list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCDET-SVN&A=1