Commit in lcdd/src/lcdd/detectors on LCDD-102_BRANCH | |||
SensitiveDetectorFactory.cc | +14 | -18 | 1.4.2.3 -> 1.4.2.4 |
fix bug I accidentally introduced
diff -u -r1.4.2.3 -r1.4.2.4 --- SensitiveDetectorFactory.cc 14 Aug 2013 02:34:40 -0000 1.4.2.3 +++ SensitiveDetectorFactory.cc 17 Aug 2013 23:51:14 -0000 1.4.2.4 @@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/SensitiveDetectorFactory.cc,v 1.4.2.3 2013/08/14 02:34:40 jeremy Exp $
+// $Header: /cvs/lcd/lcdd/src/lcdd/detectors/SensitiveDetectorFactory.cc,v 1.4.2.4 2013/08/17 23:51:14 jeremy Exp $
// LCDD #include "lcdd/detectors/SensitiveDetectorFactory.hh"
@@ -14,8 +14,6 @@
SensitiveDetector* SensitiveDetectorFactory::createSensitiveDetector(const SAXObject* object) {
- //std::cout << "SensitiveDetectorFactory::createSensitiveDetector" << std::endl; -
const SensitiveDetectorType* sensitiveDetectorType = dynamic_cast<const SensitiveDetectorType*>(object); SensitiveDetector* sensitiveDetector = 0; IdSpec* idspec = 0;
@@ -79,17 +77,20 @@
// Get the name of the hits collection. const std::string& name = hitsCollection->get_name();
- //std::cout << "adding hits collection: " << name << std::endl; -
// Add hits collection to the list. hitsCollections.push_back(name); } }
- // Add the default HitsCollection, which is the name of the SD, if none were specified in the XML.
+ // Backward compatibility if hits collection is specified as an attribute value on the detector's XML element. + std::string hitsCollectionName = sensitiveDetectorType->get_hitsCollectionName(); + if (hitsCollectionName != "") { + hitsCollections.push_back(sensitiveDetectorType->get_hitsCollectionName()); + } + + // If no hits collections were added then make a default HitsCollection with the name of the SD.
if (hitsCollections.size() == 0) { hitsCollections.push_back(sensitiveDetectorType->get_name());
- //std::cout << "added default hits collection: " << sensitiveDetectorType->get_name() << std::endl;
} // Create the SD object based on its type of calorimeter or tracker.
@@ -115,23 +116,21 @@
// Add the HitProcessors from the list. if (hitProcessors.size() > 0) {
- // Add HitProcessors created from XML.
+ // Add HitProcessors created from XML if they were listed explicitly as child elements.
sensitiveDetector->addHitProcessors(hitProcessors); } else {
- // Need to add default HitProcessors because none were specified.
+ // Need to add default HitProcessors because none were specified in the detector's XML.
if (sensitiveDetectorTypeName == "tracker") {
- // Default TrackerHitProcessor.
+ // Add the default TrackerHitProcessor.
sensitiveDetector->addHitProcessor(HitProcessorManager::instance()->getFactory("BasicTrackerHitProcessor")->createHitProcessor(sensitiveDetector)); } else if (sensitiveDetectorTypeName == "calorimeter" ) {
- // Default CalorimeterHitProcessor.
+ // Add the default CalorimeterHitProcessor.
sensitiveDetector->addHitProcessor(HitProcessorManager::instance()->getFactory("LegacyCalorimeterHitProcessor")->createHitProcessor(sensitiveDetector)); } } // Register the SensitiveDetector with the LCDDProcessor. std::string sensitiveDetectorName = sensitiveDetector->GetName();
- std::cout << "registering SD: " << sensitiveDetectorName << std::endl; - std::cout << " # hit processors: " << sensitiveDetector->getHitProcessors().size() << std::endl;
LCDDProcessor::instance()->addSensitiveDetector(sensitiveDetectorName, sensitiveDetector); } else { // This should never really happen.
@@ -188,13 +187,10 @@
// Get the name of the SensitiveDetector. //std::string name = trackerElement->get_name();
- std::string name = hitsCollections[0]; - - // Get the name of the hits collection. - //std::string hitCollection = trackerElement->get_hitsCollectionName();
+ std::string hitsCollectionName = hitsCollections[0];
// Create the basic TrackerSD.
- TrackerSD* sd = new TrackerSD(name, name);
+ TrackerSD* sd = new TrackerSD(trackerElement->get_name(), hitsCollectionName);
return sd; }
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