Commit in lcdd on MAIN
include/lcdd/detectors/BasicTrackerHitProcessor.hh+35added 1.1
                      /StepCombiningTrackerHitProcessor.hh+77added 1.1
                      /TrackerHitProcessor.hh+35added 1.1
                      /CalorimeterHitProcessor.hh+3-31.9 -> 1.10
                      /HitProcessor.hh+3-21.1 -> 1.2
                      /LegacyCalorimeterHitProcessor.hh+4-11.1 -> 1.2
                      /TrackerSD.hh+7-11.4 -> 1.5
src/lcdd/detectors/BasicTrackerHitProcessor.cc+103added 1.1
                  /StepCombiningTrackerHitProcessor.cc+168added 1.1
                  /TrackerHitProcessor.cc+11added 1.1
                  /CalorimeterSD.cc+9-91.5 -> 1.6
                  /SensitiveDetectorFactory.cc+22-131.3 -> 1.4
                  /TrackerSD.cc+24-81.3 -> 1.4
+501-37
6 added + 7 modified, total 13 files
more work on LCDD-102; some minor changes to comments and the like

lcdd/include/lcdd/detectors
BasicTrackerHitProcessor.hh added at 1.1
diff -N BasicTrackerHitProcessor.hh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ BasicTrackerHitProcessor.hh	11 Jul 2013 22:39:17 -0000	1.1
@@ -0,0 +1,35 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/BasicTrackerHitProcessor.hh,v 1.1 2013/07/11 22:39:17 jeremy Exp $
+
+#ifndef LCDD_DETECTORS_BASICTRACKERHITPROCESSOR_HH
+#define LCDD_DETECTORS_BASICTRACKERHITPROCESSOR_HH 1
+
+// LCDD
+#include "lcdd/detectors/TrackerHitProcessor.hh"
+
+/**
+ * @brief Implements default TrackerSD hit processing behavior.
+ */
+class BasicTrackerHitProcessor : public TrackerHitProcessor
+{
+
+public:
+
+    /**
+     * Class constructor.
+     */
+    BasicTrackerHitProcessor(TrackerSD* tracker);
+
+    /**
+     * Class destructor.
+     */
+    virtual ~BasicTrackerHitProcessor();
+
+    /**
+     * Process steps to produce hits.
+     * @param[in] step A G4Step object.
+     * @return True if hits were added or modified; false if not.
+     */
+    bool processHits(G4Step* step);
+};
+
+#endif

lcdd/include/lcdd/detectors
StepCombiningTrackerHitProcessor.hh added at 1.1
diff -N StepCombiningTrackerHitProcessor.hh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ StepCombiningTrackerHitProcessor.hh	11 Jul 2013 22:39:17 -0000	1.1
@@ -0,0 +1,77 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/StepCombiningTrackerHitProcessor.hh,v 1.1 2013/07/11 22:39:17 jeremy Exp $
+
+#ifndef LCDD_DETECTORS_STEPCOMBININGTRACKERHITPROCESSOR_HH
+#define LCDD_DETECTORS_STEPCOMBININGTRACKERHITPROCESSOR_HH 1
+
+// LCDD
+#include "lcdd/detectors/TrackerHitProcessor.hh"
+
+// Geant4
+#include "G4Track.hh"
+
+/**
+ * Implementation of TrackerHitProcessor that combines information from multiple steps
+ * into a single TrackerHit.
+ */
+class StepCombiningTrackerHitProcessor : public TrackerHitProcessor
+{
+public:
+
+    /**
+     * Class constructor.
+     * @param[in] tracker Pointer to TrackerSD.
+     */
+    StepCombiningTrackerHitProcessor(TrackerSD* tracker);
+
+    /**
+     * Class destructor.
+     */
+    virtual ~StepCombiningTrackerHitProcessor();
+
+    /**
+     * Process steps to produce hits.
+     * @param[in] step A G4Step object.
+     * @return True if hit was created or modified; false if not.
+     */
+    bool processHits(G4Step* step);
+
+private:
+
+    /**
+     * Start a new hit.
+     * @param[in] step      The G4Step for the new hit.
+     * @param[in] stepPoint The G4StepPoint for the new hit.
+     */
+    void startHit(G4Step* step, G4StepPoint* aStepPoint);
+
+    /**
+     * Update an existing hit with current step data.
+     * @param[in] step A G4Step object.
+     */
+    void updateHit(G4Step* step);
+
+    /**
+     * Insert a new hit after all data is added.
+     */
+    bool insertHit(G4Step* step);
+
+    /**
+     * Clear the current hit.
+     */
+    void clear();
+
+private:
+
+    int _currentTrackID;
+    G4VPhysicalVolume* _currentPV;
+    G4ThreeVector _entryPoint;
+    G4ThreeVector _exitPoint;
+    G4ThreeVector _entryMomentum;
+    G4ThreeVector _exitMomentum;
+    G4double _edepTotal;
+    G4double _minTime;
+    bool _startedHit;
+    G4Track* _currentTrack;
+};
+
+#endif

lcdd/include/lcdd/detectors
TrackerHitProcessor.hh added at 1.1
diff -N TrackerHitProcessor.hh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ TrackerHitProcessor.hh	11 Jul 2013 22:39:17 -0000	1.1
@@ -0,0 +1,35 @@
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/TrackerHitProcessor.hh,v 1.1 2013/07/11 22:39:17 jeremy Exp $
+
+#ifndef LCDD_DETECTORS_TRACKERHITPROCESSOR_HH
+#define LCDD_DETECTORS_TRACKERHITPROCESSOR_HH 1
+
+#include "lcdd/detectors/TrackerSD.hh"
+
+class TrackerHitProcessor : public HitProcessor
+{
+public:
+
+    /**
+     * Class constructor.
+     * @param[in] tracker Pointer to TrackerSD.
+     */
+    TrackerHitProcessor(TrackerSD* tracker);
+
+    /**
+     * Class destructor.
+     */
+    virtual ~TrackerHitProcessor();
+
+    /**
+     * Process hits to produce steps.
+     * @param[in] step The G4Step object.
+     * @return True if hits were created or modified; false if not.
+     */
+    virtual bool processHits(G4Step* step) = 0;
+
+protected:
+
+    TrackerSD* _tracker;
+};
+
+#endif

lcdd/include/lcdd/detectors
CalorimeterHitProcessor.hh 1.9 -> 1.10
diff -u -r1.9 -r1.10
--- CalorimeterHitProcessor.hh	11 Jul 2013 20:41:53 -0000	1.9
+++ CalorimeterHitProcessor.hh	11 Jul 2013 22:39:17 -0000	1.10
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/CalorimeterHitProcessor.hh,v 1.9 2013/07/11 20:41:53 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/CalorimeterHitProcessor.hh,v 1.10 2013/07/11 22:39:17 jeremy Exp $
 
 #ifndef LCDD_DETECTORS_CALORIMETERHITPROCESSOR_HH
 #define LCDD_DETECTORS_CALORIMETERHITPROCESSOR_HH 1
@@ -11,7 +11,7 @@
 #include "lcdd/detectors/CalorimeterSD.hh"
 
 /**
- * Interface for processing step data to produce CalorimeterHits.
+ * @brief Interface for processing step data to produce CalorimeterHits.
  */
 class CalorimeterHitProcessor : public HitProcessor
 {
@@ -32,7 +32,7 @@
 public:
 
     /**
-     * Process the step to make hits.
+     * Process steps to make hits.
      * @param[in] step The G4Step object of the energy deposition.
      */
     virtual bool processHits(G4Step* step) = 0;

lcdd/include/lcdd/detectors
HitProcessor.hh 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- HitProcessor.hh	11 Jul 2013 20:41:54 -0000	1.1
+++ HitProcessor.hh	11 Jul 2013 22:39:17 -0000	1.2
@@ -5,7 +5,7 @@
 #include "G4Step.hh"
 
 /**
- * This is a pure virtual class defining an interface for processing hits within sensitive detectors.
+ * @brief Pure virtual class defining an interface for processing hits within sensitive detectors.
  */
 class HitProcessor
 {
@@ -18,8 +18,9 @@
     virtual ~HitProcessor();
 
     /**
-     * Process G4Step to produce hits.
+     * Process steps to produce hits.
      * @param[in] step A G4Step object.
+     * @return True if hits were created or modified; false if not.
      */
 	virtual bool processHits(G4Step* step) = 0;
 

lcdd/include/lcdd/detectors
LegacyCalorimeterHitProcessor.hh 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- LegacyCalorimeterHitProcessor.hh	11 Jul 2013 20:41:54 -0000	1.1
+++ LegacyCalorimeterHitProcessor.hh	11 Jul 2013 22:39:17 -0000	1.2
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/LegacyCalorimeterHitProcessor.hh,v 1.1 2013/07/11 20:41:54 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/LegacyCalorimeterHitProcessor.hh,v 1.2 2013/07/11 22:39:17 jeremy Exp $
 
 #ifndef LCDD_DETECTORS_LEGACYCALORIMETERHITPROCESSOR
 #define LCDD_DETECTORS_LEGACYCALORIMETERHITPROCESSOR 1
@@ -6,6 +6,9 @@
 // LCDD
 #include "lcdd/detectors/CalorimeterHitProcessor.hh"
 
+/**
+ * @brief Implementation of hit processing behavior for CalorimeterSD objects with Segmentation.
+ */
 class LegacyCalorimeterHitProcessor : public CalorimeterHitProcessor
 {
 

lcdd/include/lcdd/detectors
TrackerSD.hh 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- TrackerSD.hh	10 Jul 2013 18:06:17 -0000	1.4
+++ TrackerSD.hh	11 Jul 2013 22:39:17 -0000	1.5
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/TrackerSD.hh,v 1.4 2013/07/10 18:06:17 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/TrackerSD.hh,v 1.5 2013/07/11 22:39:17 jeremy Exp $
 
 #ifndef LCDD_DETECTORS_TRACKERSD_HH
 #define LCDD_DETECTORS_TRACKERSD_HH 1
@@ -68,6 +68,12 @@
      */
     G4TrackerHitList getTrackerHitList();
 
+    /**
+     * Add a TrackerHit.
+     * @param[in] hit The Tracker hit to add.
+     */
+    void addHit(TrackerHit* hit, bool addToHitList = true);
+
 protected:
 
     /**

lcdd/src/lcdd/detectors
BasicTrackerHitProcessor.cc added at 1.1
diff -N BasicTrackerHitProcessor.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ BasicTrackerHitProcessor.cc	11 Jul 2013 22:39:17 -0000	1.1
@@ -0,0 +1,103 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/BasicTrackerHitProcessor.cc,v 1.1 2013/07/11 22:39:17 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/BasicTrackerHitProcessor.hh"
+#include "lcdd/hits/TrackInformation.hh"
+
+// Geant4
+#include "G4Geantino.hh"
+#include "G4ChargedGeantino.hh"
+
+BasicTrackerHitProcessor::BasicTrackerHitProcessor(TrackerSD* tracker)
+    : TrackerHitProcessor(tracker)
+{}
+
+BasicTrackerHitProcessor::~BasicTrackerHitProcessor()
+{}
+
+bool BasicTrackerHitProcessor::processHits(G4Step* step)
+{
+    // Get the total energy deposition.
+    G4double edep = step->GetTotalEnergyDeposit();
+
+    // Check for Geantino particle type.
+    G4ParticleDefinition* def = step->GetTrack()->GetDefinition();
+    bool isGeantino = false;
+    if (def == G4Geantino::Definition() || def == G4ChargedGeantino::Definition()) {
+        isGeantino = true;
+    }
+
+    // Check edep < cut and not Geantino.
+    if (edep <= _tracker->getEnergyCut() && isGeantino == false) {
+        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();
+
+    // Get the pre-step point.
+    G4StepPoint* pre = step->GetPreStepPoint();
+
+    // Get the post-step point.
+    G4StepPoint* post = step->GetPostStepPoint();
+
+    // Get the track ID.
+    G4int trackId = track->GetTrackID();
+
+    // Get the global time (ns).
+    G4double time = track->GetGlobalTime();
+
+    // Compute the midpoint.
+    G4ThreeVector mid = (0.5 * (pre->GetPosition() + post->GetPosition()));
+
+    // Get the start position from the pre-step point.
+    G4ThreeVector start = step->GetPreStepPoint()->GetPosition();
+
+    // Get the end position from the post-step point.
+    G4ThreeVector end = step->GetPostStepPoint()->GetPosition();
+
+    // Compute the average momentum.
+    double averageMomentum = (pre->GetMomentum().mag() + post->GetMomentum().mag()) / 2;
+
+    // Compute the momentum.
+    G4ThreeVector momentum = (end - start);
+
+    // If the momentum is > 0 then set to average momentum.
+    // FIXME: Not sure I understand this!!!
+    if (momentum.mag() > 0) {
+        momentum.setMag(averageMomentum);
+    }
+
+    // Compute the step's path length.
+    G4double length = sqrt(
+            pow(start.x() - end.x(), 2) +
+            pow(start.y() - end.y(), 2) +
+            pow(start.z() - end.z(), 2));
+
+    // Create the new hit.
+    TrackerHit* hit = new TrackerHit();
+
+    // Create the hit's identifier.
+    Id64bit id64 = _tracker->makeIdentifier(step);
+
+    // Set the hit information from above.
+    hit->setTrackID(trackId);
+    hit->setEdep(edep);
+    hit->setPos(mid);
+    hit->setMomentum(momentum);
+    hit->setTdep(time);
+    hit->setId(id64.getId0());
+    hit->setLength(length);
+
+    // Add the hit to the TrackerSD.
+    _tracker->addHit(hit);
+
+    // Return true because created new hit.
+    return true;
+}

lcdd/src/lcdd/detectors
StepCombiningTrackerHitProcessor.cc added at 1.1
diff -N StepCombiningTrackerHitProcessor.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ StepCombiningTrackerHitProcessor.cc	11 Jul 2013 22:39:17 -0000	1.1
@@ -0,0 +1,168 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/StepCombiningTrackerHitProcessor.cc,v 1.1 2013/07/11 22:39:17 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/StepCombiningTrackerHitProcessor.hh"
+#include "lcdd/hits/TrackInformation.hh"
+
+// Geant
+#include "G4Geantino.hh"
+#include "G4ChargedGeantino.hh"
+
+StepCombiningTrackerHitProcessor::StepCombiningTrackerHitProcessor(TrackerSD* tracker) :
+        TrackerHitProcessor(tracker)
+{
+}
+
+StepCombiningTrackerHitProcessor::~StepCombiningTrackerHitProcessor()
+{
+}
+
+G4bool StepCombiningTrackerHitProcessor::processHits(G4Step* step)
+{
+    // The return value indicating whether a hit was inserted.
+    bool r = false;
+
+    // Started a hit already?
+    if (!_startedHit) {
+
+        // Start a new hit on the pre-step.
+        startHit(step, step->GetPreStepPoint());
+    }
+
+    // Check if the cached trackID is valid.
+    if (_currentTrackID != -1) {
+
+        // Is this step's trackID different from the cached trackID?
+        if (step->GetTrack()->GetTrackID() != _currentTrackID) {
+
+            // Insert the hit on the old track.
+            r = insertHit(step);
+
+            // Start a new hit on the pre-step.
+            startHit(step, step->GetPreStepPoint());
+        }
+    }
+
+    // Update the hit.
+    updateHit(step);
+
+    // Check whether a new volume is being entered on this step.
+    G4VPhysicalVolume* preVolume = step->GetPreStepPoint()->GetTouchableHandle()->GetVolume();
+    G4VPhysicalVolume* postVolume = step->GetPostStepPoint()->GetTouchableHandle()->GetVolume();
+    if (preVolume != postVolume) {
+
+        // Insert the current hit.
+        r = insertHit(step);
+
+        // Check if pre and post steps have the same detector.
+        G4VSensitiveDetector* preSD = preVolume->GetLogicalVolume()->GetSensitiveDetector();
+        G4VSensitiveDetector* postSD = postVolume->GetLogicalVolume()->GetSensitiveDetector();
+        if (preSD == postSD) {
+            // Start a new hit for the adjacent volume.
+            startHit(step, step->GetPostStepPoint());
+        }
+    } else if (_currentTrack->GetTrackStatus() == fStopAndKill) {
+        // Special case where the track status is StopAndKill.
+        // We won't see this track again, so need to insert the hit on this step.
+        r = insertHit(step);
+    }
+
+    return r;
+}
+
+void StepCombiningTrackerHitProcessor::updateHit(G4Step* step)
+{
+    // Update can only happen if a hit has been started.
+    if (_startedHit) {
+
+        // incr edep
+        _edepTotal += step->GetTotalEnergyDeposit();
+
+        // first time only
+        if (_minTime == 0) {
+            _minTime = step->GetTrack()->GetGlobalTime();
+        }
+
+        // exit point and momentum
+        _exitPoint = step->GetPostStepPoint()->GetPosition();
+        _exitMomentum = step->GetPostStepPoint()->GetMomentum();
+    }
+}
+
+void StepCombiningTrackerHitProcessor::clear()
+{
+    _minTime = 0;
+    _edepTotal = 0;
+    _currentPV = 0;
+    _currentTrackID = -1;
+    _startedHit = false;
+}
+
+bool StepCombiningTrackerHitProcessor::insertHit(G4Step* step)
+{
+    // Another hit was not started.
+    if (!_startedHit) {
+        G4cerr << "StepCombiningTrackerHitProcessor::insertHit - Never started a hit!" << G4endl;
+        return false;
+    }
+
+    // Check for Geantino particle type.
+    G4ParticleDefinition* def = step->GetTrack()->GetDefinition();
+    bool isGeantino = false;
+    if (def == G4Geantino::Definition() || def == G4ChargedGeantino::Definition()) {
+        isGeantino = true;
+    }
+
+    // Total energy is below cut.
+    if (_edepTotal <= _tracker->getEnergyCut() && isGeantino == false) {
+        clear();
+        return false;
+    }
+
+    // Compute the mid point.
+    G4ThreeVector midpoint = (0.5 * (_entryPoint + _exitPoint));
+
+    // Compute the mean momentum.
+    G4ThreeVector meanMomentum = (0.5 * (_entryMomentum + _exitMomentum));
+
+    // Compute distance from entry to exit points.
+    G4double pathlength = sqrt(
+            pow(_entryPoint.x() - _exitPoint.x(), 2) +
+            pow(_entryPoint.y() - _exitPoint.y(), 2) +
+            pow(_entryPoint.z() - _exitPoint.z(), 2));
+
+    // Set the hit data from the cache.
+    TrackerHit* hit = new TrackerHit();
+    hit->setTdep(_minTime);
+    hit->setEdep(_edepTotal);
+    hit->setPos(midpoint);
+    hit->setMomentum(meanMomentum);
+    hit->setTrackID(_currentTrackID);
+    hit->setLength(pathlength);
+
+    // Set the hit's identifier.
+    Id64bit id64 = _tracker->makeIdentifier(step);
+    hit->setId(id64.getId0());
+
+    // Add the hit to the TrackerSD.
+    _tracker->addHit(hit, false);
+
+    // Set hasTrackerHit flag on TrackInformation.
+    TrackInformation::getTrackInformation( _currentTrack )->setHasTrackerHit( true);
+
+    // Clear the cached hit data.
+    clear();
+
+    return true;
+}
+
+void StepCombiningTrackerHitProcessor::startHit(G4Step* step, G4StepPoint* stepPoint)
+{
+    _currentTrack = step->GetTrack();
+    _currentPV = stepPoint->GetPhysicalVolume();
+    _entryPoint = _exitPoint = stepPoint->GetPosition();
+    _entryMomentum = _exitMomentum = stepPoint->GetMomentum();
+    _currentTrackID = step->GetTrack()->GetTrackID();
+    _startedHit = true;
+}
+

lcdd/src/lcdd/detectors
TrackerHitProcessor.cc added at 1.1
diff -N TrackerHitProcessor.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ TrackerHitProcessor.cc	11 Jul 2013 22:39:17 -0000	1.1
@@ -0,0 +1,11 @@
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/TrackerHitProcessor.cc,v 1.1 2013/07/11 22:39:17 jeremy Exp $
+
+// LCDD
+#include "lcdd/detectors/TrackerHitProcessor.hh"
+
+TrackerHitProcessor::TrackerHitProcessor(TrackerSD* tracker)
+    : _tracker(tracker)
+{}
+
+TrackerHitProcessor::~TrackerHitProcessor()
+{}

lcdd/src/lcdd/detectors
CalorimeterSD.cc 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- CalorimeterSD.cc	11 Jul 2013 20:41:54 -0000	1.5
+++ CalorimeterSD.cc	11 Jul 2013 22:39:17 -0000	1.6
@@ -1,19 +1,19 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CalorimeterSD.cc,v 1.5 2013/07/11 20:41:54 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/CalorimeterSD.cc,v 1.6 2013/07/11 22:39:17 jeremy Exp $
 
 // LCDD
 #include "lcdd/detectors/CalorimeterSD.hh"
 #include "lcdd/detectors/Segmentation.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
+//#include "lcdd/detectors/ReadoutUtil.hh"
 #include "lcdd/detectors/PositionComparator.hh"
-#include "lcdd/hits/HitContribution.hh"
-#include "lcdd/id/IdFactory.hh"
-#include "lcdd/id/IdManager.hh"
+//#include "lcdd/hits/HitContribution.hh"
+//#include "lcdd/id/IdFactory.hh"
+//#include "lcdd/id/IdManager.hh"
 
 // Geant4
-#include "G4Track.hh"
-#include "G4StepPoint.hh"
-#include "G4Timer.hh"
-#include "G4Geantino.hh"
+//#include "G4Track.hh"
+//#include "G4StepPoint.hh"
+//#include "G4Timer.hh"
+//#include "G4Geantino.hh"
 
 // STL
 #include <iostream>

lcdd/src/lcdd/detectors
SensitiveDetectorFactory.cc 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- SensitiveDetectorFactory.cc	11 Jul 2013 20:41:54 -0000	1.3
+++ SensitiveDetectorFactory.cc	11 Jul 2013 22:39:17 -0000	1.4
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/SensitiveDetectorFactory.cc,v 1.3 2013/07/11 20:41:54 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/SensitiveDetectorFactory.cc,v 1.4 2013/07/11 22:39:17 jeremy Exp $
 
 // LCDD
 #include "lcdd/detectors/SensitiveDetectorFactory.hh"
@@ -9,6 +9,8 @@
 #include "lcdd/detectors/UnsegmentedCalorimeterSD.hh"
 #include "lcdd/detectors/PositionComparator.hh"
 #include "lcdd/detectors/LegacyCalorimeterHitProcessor.hh"
+#include "lcdd/detectors/BasicTrackerHitProcessor.hh"
+#include "lcdd/detectors/StepCombiningTrackerHitProcessor.hh"
 #include "lcdd/id/IdComparator.hh"
 #include "lcdd/util/StringUtil.hh"
 
@@ -134,7 +136,7 @@
         std::vector<G4String> hcnames;
         hcnames.push_back("Edep_" + sdt->get_hitsCollectionName());
         hcnames.push_back("Ceren_" + sdt->get_hitsCollectionName());
-        //std::cout<< " now creating optical calorimeter"<<std::endl;
+
         sd = new OpticalCalorimeterSD(sdt->get_name(), hcnames, seg, hitCompare);
     } else if (sd_type == "unsegmented_calorimeter") {
         // Segmentation could be null but that is fine for this type of calorimeter.
@@ -149,25 +151,32 @@
 
 TrackerSD* SensitiveDetectorFactory::createTrackerSD(const SAXObject* object)
 {
-    const tracker* trk = dynamic_cast<const tracker*>(object);
-
-    bool combineHits = StringUtil::toBool(trk->get_combine_hits());
+    // Cast the SAXObject to tracker element.
+    const tracker* trackerElement = dynamic_cast<const tracker*>(object);
 
-    TrackerSD* sd = 0;
+    // Get the name of the SensitiveDetector.
+    std::string name = trackerElement->get_name();
 
-    std::string nm = trk->get_name();
-    std::string hc = trk->get_hitsCollectionName();
+    // Get the name of the hit collection.
+    std::string hitCollection = trackerElement->get_hitsCollectionName();
 
-    if (checkHCName(hc)) {
+    // Check if the hit collection name is valid.
+    if (checkHCName(hitCollection)) {
+        G4cerr << "invalid hit collection name: " << hitCollection << G4endl;
         G4Exception("SensitiveDetectorFactory", "", FatalException, "Name of the hits collection is invalid.");
     }
 
-    /* tracker that aggregates hits */
+    // Create the basic TrackerSD.
+    TrackerSD* sd = new TrackerSD(name, hitCollection);
+
+    // Check for hit aggregation setting and set the HitProcessor accordingly.
+    bool combineHits = StringUtil::toBool(trackerElement->get_combine_hits());
     if (combineHits) {
-        sd = new TrackerCombineSD(nm, hc);
+        // Add the StepCombiningTrackerHitProcessor which will aggregate hits.
+        sd->addHitProcessor(new StepCombiningTrackerHitProcessor(sd));
     } else {
-        /* regular tracker */
-        sd = new TrackerSD(nm, hc);
+        // Add the BasicTrackerHitProcessor.
+        sd->addHitProcessor(new BasicTrackerHitProcessor(sd));
     }
 
     return sd;

lcdd/src/lcdd/detectors
TrackerSD.cc 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- TrackerSD.cc	11 Jul 2013 20:41:54 -0000	1.3
+++ TrackerSD.cc	11 Jul 2013 22:39:17 -0000	1.4
@@ -1,16 +1,16 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/TrackerSD.cc,v 1.3 2013/07/11 20:41:54 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/TrackerSD.cc,v 1.4 2013/07/11 22:39:17 jeremy Exp $
 
 // LCDD
-#include "lcdd/id/IdManager.hh"
-#include "lcdd/id/IdFactory.hh"
-#include "lcdd/id/IdVec.hh"
+//#include "lcdd/id/IdManager.hh"
+//#include "lcdd/id/IdFactory.hh"
+//#include "lcdd/id/IdVec.hh"
 #include "lcdd/detectors/TrackerSD.hh"
-#include "lcdd/detectors/ReadoutUtil.hh"
-#include "lcdd/hits/TrackerHit.hh"
-#include "lcdd/hits/TrackInformation.hh"
+//#include "lcdd/detectors/ReadoutUtil.hh"
+//#include "lcdd/hits/TrackerHit.hh"
+//#include "lcdd/hits/TrackInformation.hh"
 
 // Geant4
-#include "G4Geantino.hh"
+//#include "G4Geantino.hh"
 
 // STL
 #include <iostream>
@@ -43,6 +43,13 @@
 
 G4bool TrackerSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
 {
+    // Call parent class's method which will activate registered HitProcessors.
+    return SensitiveDetector::ProcessHits(aStep, 0);
+}
+
+/*
+G4bool TrackerSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
+{
     // set cached step
     SensitiveDetector::ProcessHits(aStep, 0);
 
@@ -98,6 +105,7 @@
 
     return true;
 }
+*/
 
 std::ostream& TrackerSD::printHits(std::ostream& os)
 {
@@ -139,3 +147,11 @@
 {
     return _hits;
 }
+
+void TrackerSD::addHit(TrackerHit* hit, bool addToHitList)
+{
+    _HC->insert(hit);
+    if (addToHitList) {
+        _hits.push_back(hit);
+    }
+}
CVSspam 0.2.12


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