lcdd/include
diff -u -r1.7 -r1.8
--- SensitiveDetectorFactory.hh 30 Mar 2006 19:43:58 -0000 1.7
+++ SensitiveDetectorFactory.hh 7 Feb 2007 05:18:02 -0000 1.8
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/include/SensitiveDetectorFactory.hh,v 1.7 2006/03/30 19:43:58 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/include/SensitiveDetectorFactory.hh,v 1.8 2007/02/07 05:18:02 jeremy Exp $
// LCDD
#include "LCDDProcessor.hh"
@@ -52,6 +52,11 @@
static G4ScorerSD* createScorerSD(const SAXObject* object);
+ /**
+ * Lookup the IdSpec of a detector SAX object based on the idspecref.
+ * @throw G4Exception if the idspecref has a bad reference value.
+ * @return The IdSpec of this detector, or null if one does not exist.
+ */
static IdSpec* findIdSpec(const SensitiveDetectorType* sdt);
static void setBaseSensitiveDetectorAttributes(G4SensitiveDetector* sd, const SensitiveDetectorType* sdt);
lcdd/src
diff -u -r1.12 -r1.13
--- SensitiveDetectorFactory.cc 27 Sep 2005 00:12:25 -0000 1.12
+++ SensitiveDetectorFactory.cc 7 Feb 2007 05:18:02 -0000 1.13
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/SensitiveDetectorFactory.cc,v 1.12 2005/09/27 00:12:25 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/SensitiveDetectorFactory.cc,v 1.13 2007/02/07 05:18:02 jeremy Exp $
#include "SensitiveDetectorFactory.hh"
/* LCDD */
@@ -98,16 +98,34 @@
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 attributes on sensitive detector.
HitComparator* hitCompare = 0;
+
+ // Find the IdSpec.
+ IdSpec* idspec = findIdSpec( sdt );
+
+ // The attribute value for hit_compare is not valid.
+ if ( hitCompareStr != "id" && hitCompareStr != "position" ) {
+ G4Exception("Invalid selection for hit comparison <" + hitCompareStr + ">, for calorimeter <" + sdt->get_name() + ">.");
+ }
+
+ // Compare on IDs.
if ( hitCompareStr == "id" ) {
- hitCompare = new IdComparator();
+ if ( idspec ) {
+ //std::cout << "id compare" << std::endl;
+ 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;
+ }
}
- else if ( hitCompareStr == "position" ) {
+
+ // Compare on position.
+ if ( !hitCompare ) {
+ //std::cout << "position compare" << std::endl;
hitCompare = new PositionComparator();
}
- else {
- G4Exception("Invalid hit compare type " + hitCompareStr);
- }
// create SD with seg and comparator
if ( seg ) {
@@ -183,11 +201,17 @@
// find idspec
if ( child_tag == "idspecref" ) {
+ //std::cout << "found idspecref" << std::endl;
+
IdSpecType::idspecref* id_ref =
dynamic_cast<IdSpecType::idspecref*> ( seq->content(i).object );
idspec = IdManager::instance()->getIdSpec( id_ref->get_ref() );
+ if ( !idspec ) {
+ G4Exception("The IdSpec <" + id_ref->get_ref() + "> referenced by detector <" + sdt->get_name() + "> does not exist!");
+ }
+
break;
}
}