Print

Print


Commit in lcdd on MAIN
include/G4CalorimeterSD.hh+4-21.15 -> 1.16
       /G4UnsegmentedCalorimeterSD.hh+3-21.1 -> 1.2
src/G4UnsegmentedCalorimeterSD.cc+6-71.1 -> 1.2
   /SensitiveDetectorFactory.cc+60-721.21 -> 1.22
+73-83
4 modified files
more updates for unseg cal; allow segmentation for writing of correct cell id independent of hit position

lcdd/include
G4CalorimeterSD.hh 1.15 -> 1.16
diff -u -r1.15 -r1.16
--- G4CalorimeterSD.hh	7 Dec 2010 00:52:00 -0000	1.15
+++ G4CalorimeterSD.hh	8 Dec 2010 21:06:24 -0000	1.16
@@ -1,4 +1,4 @@
-// $Id: G4CalorimeterSD.hh,v 1.15 2010/12/07 00:52:00 jeremy Exp $
+// $Id: G4CalorimeterSD.hh,v 1.16 2010/12/08 21:06:24 jeremy Exp $
 #ifndef LCDD_G4CALORIMETERSD_HH
 #define LCDD_G4CALORIMETERSD_HH 1
 
@@ -10,7 +10,9 @@
 #include "HitComparator.hh"
 
 // lcdd
-class G4Segmentation;
+#include "G4Segmentation.hh"
+
+// class G4Segmentation
 
 /**
    @class G4CalorimeterSD

lcdd/include
G4UnsegmentedCalorimeterSD.hh 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- G4UnsegmentedCalorimeterSD.hh	7 Dec 2010 00:52:00 -0000	1.1
+++ G4UnsegmentedCalorimeterSD.hh	8 Dec 2010 21:06:24 -0000	1.2
@@ -1,4 +1,4 @@
-// $Id: G4UnsegmentedCalorimeterSD.hh,v 1.1 2010/12/07 00:52:00 jeremy Exp $
+// $Id: G4UnsegmentedCalorimeterSD.hh,v 1.2 2010/12/08 21:06:24 jeremy Exp $
 
 #ifndef G4UNSEGMENTEDCALORIMETERSD_HH_
 #define G4UNSEGMENTEDCALORIMETERSD_HH_
@@ -16,7 +16,8 @@
 
         G4UnsegmentedCalorimeterSD(
                 G4String sdName,
-                G4String hcName);
+                G4String hcName,
+                G4Segmentation* seg);
 
     protected:
 

lcdd/src
G4UnsegmentedCalorimeterSD.cc 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- G4UnsegmentedCalorimeterSD.cc	7 Dec 2010 00:52:00 -0000	1.1
+++ G4UnsegmentedCalorimeterSD.cc	8 Dec 2010 21:06:24 -0000	1.2
@@ -1,13 +1,12 @@
-// $Id: G4UnsegmentedCalorimeterSD.cc,v 1.1 2010/12/07 00:52:00 jeremy Exp $
+// $Id: G4UnsegmentedCalorimeterSD.cc,v 1.2 2010/12/08 21:06:24 jeremy Exp $
 #include "G4UnsegmentedCalorimeterSD.hh"
 
 G4UnsegmentedCalorimeterSD::G4UnsegmentedCalorimeterSD(
         G4String sdName,
-        G4String hcName ) :
-    G4CalorimeterSD( sdName, hcName, 0 )
-{
-
-}
+        G4String hcName,
+        G4Segmentation* seg ) :
+    G4CalorimeterSD( sdName, hcName, seg )
+{}
 
 G4bool G4UnsegmentedCalorimeterSD::ProcessHits(
         G4Step* aStep,
@@ -44,7 +43,7 @@
     /* Get the step mid position. */
     G4ThreeVector hitPos = midPosition();
 
-    std::cout << "hit at " << hitPos << std::endl;
+    //std::cout << "hit at " << hitPos << std::endl;
 
     /* Create a 64-bit ID. */
     Id64bit id64 = makeId();

lcdd/src
SensitiveDetectorFactory.cc 1.21 -> 1.22
diff -u -r1.21 -r1.22
--- SensitiveDetectorFactory.cc	7 Dec 2010 00:52:00 -0000	1.21
+++ SensitiveDetectorFactory.cc	8 Dec 2010 21:06:24 -0000	1.22
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/SensitiveDetectorFactory.cc,v 1.21 2010/12/07 00:52:00 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/SensitiveDetectorFactory.cc,v 1.22 2010/12/08 21:06:24 jeremy Exp $
 #include "SensitiveDetectorFactory.hh"
 
 // lcdd
@@ -26,6 +26,7 @@
         std::string sd_type = sdt->get_type();
 
         /* Create calorimeter subdetector. */
+        // TODO Check if "calorimeter" in the sd_type.
         if ( sd_type == "calorimeter" || sd_type == "optical_calorimeter" || sd_type
                 == "unsegmented_calorimeter" )
         {
@@ -102,91 +103,78 @@
         }
     }
 
-    //if ( !fnd_seg )
-    //{
-    //    G4Exception( "FATAL ERROR: Segmentation tag is required to create a calorimeter." );
-    //}
+    // Get the calorimeter XML object.
+    const calorimeter* cal = dynamic_cast< const calorimeter* > ( object );
 
+    // Find out hit aggregation algorithm.
+    const std::string& hitCompareStr = cal->get_compare();
 
-    // create SD with seg and comparator
-    if ( seg )
-    {
-        const calorimeter* cal = dynamic_cast< const calorimeter* > ( object );
-
-        const std::string& hitCompareStr = cal->get_compare();
+    // Comparison algorithm to be used for combining hits, to be determined from SD.
+    HitComparator* hitCompare = 0;
 
-        // Comparison algorithm to be used for combining hits, to be determined from SD.
-        HitComparator* hitCompare = 0;
+    // Find the IdSpec.
+    IdSpec* idspec = findIdSpec( sdt );
 
-        // Find the IdSpec.
-        IdSpec* idspec = findIdSpec( sdt );
+    if ( hitCompareStr != "id" && hitCompareStr != "position" )
+    {
+        G4Exception( "Invalid selection for hit comparison <" + hitCompareStr
+                + ">, for calorimeter <" + sdt->get_name() + ">." );
+    }
 
-        if ( hitCompareStr != "id" && hitCompareStr != "position" )
+    // Compare on IDs.
+    if ( hitCompareStr == "id" )
+    {
+        if ( idspec )
         {
-            G4Exception( "Invalid selection for hit comparison <" + hitCompareStr
-                    + ">, for calorimeter <" + sdt->get_name() + ">." );
+            hitCompare = new IdComparator();
         }
-
-        // Compare on IDs.
-        if ( hitCompareStr == "id" )
+        else
         {
-            if ( idspec )
-            {
-                hitCompare = new IdComparator();
-            }
-            else
-            {
-                std::cerr << "WARNING: IdSpec for <" << sdt->get_name()
-                        << "> does not exist!  Position comparison will be used for hit aggregation instead of id."
-                        << std::endl;
-            }
+            std::cerr << "WARNING: IdSpec for <" << sdt->get_name()
+                    << "> does not exist!  Position comparison will be used for hit aggregation instead of id."
+                    << std::endl;
         }
+    }
 
-        // Compare on position.
-        if ( !hitCompare )
-        {
-            hitCompare = new PositionComparator();
-        }
+    // Compare on position.
+    if ( !hitCompare )
+    {
+        hitCompare = new PositionComparator();
+    }
 
-        if ( sd_type == "calorimeter" )
-        {
-            sd = new G4CalorimeterSD(
-                    sdt->get_name(),
-                    sdt->get_hitsCollectionName(),
-                    seg,
-                    hitCompare );
-        }
-        else if ( sd_type == "optical_calorimeter" )
-        {
-            //
-            // in case of optical alorimeter there are 2 hit collections  
-            //
-            //G4String  hcnames[2];
-            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 G4OpticalCalorimeterSD( sdt->get_name(), hcnames, seg, hitCompare );
-        }
-        else
-        {
-            G4Exception( "SensitiveDetectorFactory - Unknown sensitive detector type: "
-                    + sd_type );
-        }
+    if ( sd_type == "calorimeter" )
+    {
+        sd = new G4CalorimeterSD(
+                sdt->get_name(),
+                sdt->get_hitsCollectionName(),
+                seg,
+                hitCompare );
+    }
+    else if ( sd_type == "optical_calorimeter" )
+    {
+        //
+        // in case of optical alorimeter there are 2 hit collections
+        //
+        //G4String  hcnames[2];
+        // TODO Fix hardcoded collection names.
+        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 G4OpticalCalorimeterSD( 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.
+        sd = new G4UnsegmentedCalorimeterSD(
+                sdt->get_name(),
+                sdt->get_hitsCollectionName(),
+                seg );
     }
-    // shouldn't happen if fnd_seg fails...
     else
     {
-        if ( sd_type == "unsegmented_calorimeter" )
-        {
-            sd = new G4UnsegmentedCalorimeterSD(
-                    sdt->get_name(),
-                    sdt->get_hitsCollectionName() );
-        }
-        else
-        {
-            G4Exception( "Segmentation is required for segmented calorimeter types." );
-        }
+        G4Exception( "SensitiveDetectorFactory - Unknown sensitive detector type: "
+                + sd_type );
     }
 
     return sd;
CVSspam 0.2.8