Print

Print


Commit in slic/src on MAIN
LcioHitsCollectionBuilder.cc+13-71.12 -> 1.13
HitsCollectionUtil.cc+52-551.2 -> 1.3
+65-62
2 modified files
apply changes to make multiple Hit collections per Sensitive detector possible

slic/src
LcioHitsCollectionBuilder.cc 1.12 -> 1.13
diff -u -r1.12 -r1.13
--- LcioHitsCollectionBuilder.cc	27 Apr 2007 01:54:34 -0000	1.12
+++ LcioHitsCollectionBuilder.cc	10 Dec 2007 17:27:17 -0000	1.13
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/LcioHitsCollectionBuilder.cc,v 1.12 2007/04/27 01:54:34 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/LcioHitsCollectionBuilder.cc,v 1.13 2007/12/10 17:27:17 wenzel Exp $
 
 #include "LcioHitsCollectionBuilder.hh"
 
@@ -66,21 +66,25 @@
 
     LCCollectionVec* collVect = 0;
 
+
     for (std::vector<int>::const_iterator iter = hcids.begin();
 	 iter != hcids.end();
 	 iter++) {
 
       hcid = *iter;
-
-      log().debug("Creating hits collections for HCID: " + StringUtil::toString( hcid ) );
+      log().debug(" Creating hits collections for HCID: " + StringUtil::toString( hcid ) );
 
       // retrieve Sensitive Detector ptr
       G4SensitiveDetector* SD =
 	static_cast<G4SensitiveDetector*>
 	( G4SDManager::GetSDMpointer()->FindSensitiveDetector( HCtbl->GetSDname( hcid ) ) );
-
+        
       // get hits collection
-      G4VHitsCollection* HC = HCE->GetHC( hcid );
+      for (int i =0;i<SD->getNrofHC();i++)
+      { 
+      if (SD->getHCID(i)==hcid)
+      {
+          G4VHitsCollection* HC = HCE->GetHC( hcid );
 
       // add a LCCollectionVec if got a HC
       if ( HC ) {
@@ -99,13 +103,15 @@
 
 	// add collection vector to LCEvent
 	m_currentLCEvent->addCollection( collVect, HC->GetName() );
-      }
+   }
+      
       else {
 	G4Exception( "LcioHitsCollectionBuilder::createHitCollections() - No collection found for Hits Collection ID");
       }
     }
+      }
+  }
   }
-
   // create the CollectionVec (decides which overloaded subfunction to call)
   IMPL::LCCollectionVec* LcioHitsCollectionBuilder::createCollectionVec(G4VHitsCollection* g4HC,
 								       G4SensitiveDetector::EType SDtype)

slic/src
HitsCollectionUtil.cc 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- HitsCollectionUtil.cc	19 Oct 2005 22:51:16 -0000	1.2
+++ HitsCollectionUtil.cc	10 Dec 2007 17:27:18 -0000	1.3
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/HitsCollectionUtil.cc,v 1.2 2005/10/19 22:51:16 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/HitsCollectionUtil.cc,v 1.3 2007/12/10 17:27:18 wenzel Exp $
 #include "HitsCollectionUtil.hh"
 
 // lcdd
@@ -10,61 +10,58 @@
 #include "G4HCtable.hh"
 #include "G4EventManager.hh"
 #include "G4Event.hh"
-
-namespace slic
-{
-  std::vector<int> HitsCollectionUtil::getHCIDs()
-  {
-    G4SDManager* SDmgr = G4SDManager::GetSDMpointer();
-    G4HCtable* HCtbl = SDmgr->GetHCtable();
-    G4int num_entries = HCtbl->entries();
-
-    std::vector<int> hcids;
-
-    for (G4int i = 0;
-	 i < num_entries;
-	 i++) {
-
-      // get the name of this SD
-      G4String sdname = HCtbl->GetSDname( i );
-
-      // retrieve corresponding Sensitive Detector from Geant4 store and cast to LCDD type
-      G4SensitiveDetector* SD =
-	static_cast<G4SensitiveDetector*> ( G4SDManager::GetSDMpointer()->FindSensitiveDetector( sdname ) );
-
-      // add HCID from the SD to the list
-      if (SD) {
-	hcids.push_back( SD->getHCID() );
-      }
+#include <set>
+namespace slic {
+    std::vector<int> HitsCollectionUtil::getHCIDs() {
+        
+        G4SDManager* SDmgr = G4SDManager::GetSDMpointer();
+        G4HCtable* HCtbl = SDmgr->GetHCtable();
+        G4int num_entries = HCtbl->entries();
+        // use set to make sure that every sensitive detector is only queried once for its Hit Collections
+        std::set<G4SensitiveDetector*> usedSD;
+        std::set<G4SensitiveDetector*>::const_iterator usedSDiter;
+        std::vector<int> hcids;
+        for (G4int i = 0;i < num_entries;i++) {
+            // get the name of this SD
+            G4String sdname = HCtbl->GetSDname( i );
+            // retrieve corresponding Sensitive Detector from Geant4 store and cast to LCDD type
+            G4SensitiveDetector* SD =
+                    static_cast<G4SensitiveDetector*> ( G4SDManager::GetSDMpointer()->FindSensitiveDetector( sdname ) );
+            if (SD) {usedSD.insert(SD);}
+        }
+        usedSDiter = usedSD.begin();
+        for ( usedSDiter = usedSD.begin( );  usedSDiter != usedSD.end( ); usedSDiter++ ) {
+            G4SensitiveDetector* SD2 = (*usedSDiter);
+            for(G4int j= 0; j < SD2->getNrofHC(); j++) {
+                hcids.push_back( SD2->getHCID(j) );
+            }
+        }
+        return hcids;
     }
-
-    return hcids;
-  }
-
-  std::vector<std::string> HitsCollectionUtil::getHCNames()
-  {
-    std::vector<int> hcids = getHCIDs();
-
-    const G4Event* currEvent =
-      G4EventManager::GetEventManager()->GetConstCurrentEvent();
-
-    G4HCofThisEvent* hce = currEvent->GetHCofThisEvent();
-
-    std::vector<std::string> hcnames;
-
-    if ( currEvent ) {
-
-      G4VHitsCollection* hc = 0;
-
-      for (std::vector<int>::const_iterator iter = hcids.begin();
-	   iter != hcids.end();
-	   iter++) {
-	hc = hce->GetHC( (*iter) );
-	hcnames.push_back( hc->GetName() );
-      }
+    
+    std::vector<std::string> HitsCollectionUtil::getHCNames() {
+        std::vector<int> hcids = getHCIDs();
+        
+        const G4Event* currEvent =
+        G4EventManager::GetEventManager()->GetConstCurrentEvent();
+        
+        G4HCofThisEvent* hce = currEvent->GetHCofThisEvent();
+        
+        std::vector<std::string> hcnames;
+        
+        if ( currEvent ) {
+            
+            G4VHitsCollection* hc = 0;
+            
+            for (std::vector<int>::const_iterator iter = hcids.begin();
+            iter != hcids.end();
+            iter++) {
+                hc = hce->GetHC( (*iter) );
+                hcnames.push_back( hc->GetName() );
+            }
+        }
+        
+        return hcnames;
     }
-
-    return hcnames;
-  }
 }
 
CVSspam 0.2.8