Print

Print


Commit in lcdd on MAIN
include/lcdd/detectors/TrackerSD.hh+8-131.6 -> 1.7
src/lcdd/detectors/TrackerSD.cc+44-161.5 -> 1.6
+52-29
2 modified files
add support for multiple hits collections from tracker SD

lcdd/include/lcdd/detectors
TrackerSD.hh 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- TrackerSD.hh	22 Aug 2013 22:32:16 -0000	1.6
+++ TrackerSD.hh	17 Sep 2013 00:25:40 -0000	1.7
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/TrackerSD.hh,v 1.6 2013/08/22 22:32:16 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/lcdd/detectors/TrackerSD.hh,v 1.7 2013/09/17 00:25:40 jeremy Exp $
 
 #ifndef LCDD_DETECTORS_TRACKERSD_HH
 #define LCDD_DETECTORS_TRACKERSD_HH 1
@@ -14,7 +14,7 @@
 {
 public:
 
-    typedef std::vector<TrackerHit*> G4TrackerHitList;
+    //typedef std::vector<TrackerHit*> TrackerHitList;
 
 public:
 
@@ -23,13 +23,7 @@
      * @param[in] sdName The name of the sensitive detector.
      * @param[in] hcName The hit collection name.
      */
-    TrackerSD(G4String sdName, G4String hcName);
-
-    /**
-     * Class constructor.
-     * @param[in] sdName The name of the sensitive detector.
-     */
-    //TrackerSD(G4String sdName);
+    TrackerSD(G4String sdName, std::vector<G4String> hitsCollectionNames);
 
     /**
      * Class destructor.
@@ -72,13 +66,13 @@
      * Get the list of tracker hits.
      * @return The list of tracker hits.
      */
-    G4TrackerHitList getTrackerHitList();
+    //G4TrackerHitList getTrackerHitList();
 
     /**
      * Add a TrackerHit.
      * @param[in] hit The Tracker hit to add.
      */
-    void addHit(TrackerHit* hit, bool addToHitList = true);
+    void addHit(TrackerHit* hit, int hcid = 0);
 
 protected:
 
@@ -90,8 +84,9 @@
     virtual G4bool ProcessHits(G4Step* step, G4TouchableHistory* touchable);
 
 protected:
-    G4TrackerHitsCollection* _HC;
-    G4TrackerHitList _hits;
+    //G4TrackerHitsCollection* _HC;
+    //G4TrackerHitList _hits;
+    std::vector<TrackerHitsCollection*> _hitsCollections;
 };
 
 #endif

lcdd/src/lcdd/detectors
TrackerSD.cc 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- TrackerSD.cc	22 Aug 2013 22:32:17 -0000	1.5
+++ TrackerSD.cc	17 Sep 2013 00:25:40 -0000	1.6
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/TrackerSD.cc,v 1.5 2013/08/22 22:32:17 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/TrackerSD.cc,v 1.6 2013/09/17 00:25:40 jeremy Exp $
 
 // LCDD
 //#include "lcdd/id/IdManager.hh"
@@ -15,16 +15,22 @@
 // STL
 #include <iostream>
 
-TrackerSD::TrackerSD(G4String sdName, G4String hcName) :
-        SensitiveDetector(sdName, hcName, SensitiveDetector::eTracker), _HC(0)
-{
-    _hits.clear();
+TrackerSD::TrackerSD(G4String sdName, std::vector<G4String> hitsCollectionNames) :
+        SensitiveDetector(sdName, hitsCollectionNames, SensitiveDetector::eTracker)
+//, _HC(0)
+{
+    //_hits.clear();
+    // The actual pointers to the collections are overridden later in Initialize.
+    for (int i = 0; i < (int) hitsCollectionNames.size(); i++) {
+        _hitsCollections.push_back(0);
+    }
 }
 
 TrackerSD::~TrackerSD()
 {
 }
 
+/*
 void TrackerSD::Initialize(G4HCofThisEvent *HCE)
 {
     clearHits();
@@ -40,6 +46,28 @@
     // add collection to HC of event
     HCE->AddHitsCollection(getHCID(), _HC);
 }
+*/
+
+void TrackerSD::Initialize(G4HCofThisEvent *HCE)
+{
+    // Loop over number of hits collections defined by this detector.
+    for (int i = 0; i < getNumberOfHitsCollections(); i++) {
+
+        //std::cout << "TrackerSD::Initialize - initializing hits collection <" << collectionName[i] << ">" << std::endl;
+
+        // Overwrite pointer to the dummy collection that was added in the constructor.
+        _hitsCollections[i] = new TrackerHitsCollection(GetName(), collectionName[i]);
+
+        if (getHCID(i) < 0) {
+            // Set the HCID.
+            setHCID(GetCollectionID(i), i);
+        }
+
+        // Add the hits collection to the Geant4 HCE.
+        HCE->AddHitsCollection(getHCID(i), _hitsCollections[i]);
+    }
+}
+
 
 G4bool TrackerSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
 {
@@ -49,15 +77,18 @@
 
 std::ostream& TrackerSD::printHits(std::ostream& os)
 {
+    /*
     for (G4TrackerHitList::const_iterator iter = _hits.begin(); iter != _hits.end(); iter++) {
         os << (*(const_cast<const TrackerHit*>(*iter)));
     }
     os << std::endl;
+    */
     return os;
 }
 
 void TrackerSD::EndOfEvent(G4HCofThisEvent *)
 {
+    /*
 #ifdef G4VERBOSE
     if ( getVerbose() > 0 ) {
         std::cout << GetName() << " has " << _HC->GetSize() << " hits." << std::endl;
@@ -67,31 +98,28 @@
         printHits ( std::cout );
     }
 #endif
+*/
+
+    clearHits();
 }
 
 double TrackerSD::getEdep() const
 {
     double edep = 0.0;
+    /*
     for (G4TrackerHitList::const_iterator it = _hits.begin(); it != _hits.end(); it++) {
         edep += (*it)->getEdep();
     }
+    */
     return edep;
 }
 
 void TrackerSD::clearHits()
 {
-    _hits.clear();
+    //_hits.clear();
 }
 
-TrackerSD::G4TrackerHitList TrackerSD::getTrackerHitList()
+void TrackerSD::addHit(TrackerHit* hit, int hcid)
 {
-    return _hits;
-}
-
-void TrackerSD::addHit(TrackerHit* hit, bool addToHitList)
-{
-    _HC->insert(hit);
-    if (addToHitList) {
-        _hits.push_back(hit);
-    }
+    _hitsCollections[hcid]->insert(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