Commit in projects/lcdd/branches/v04-01-00-pre on MAIN | |||
include/lcdd/detectors/CalorimeterHitProcessor.hh | +18 | -1 | 3229 -> 3230 |
/HitProcessor.hh | +27 | -3 | 3229 -> 3230 |
/LegacyCalorimeterHitProcessor.hh | +7 | -7 | 3229 -> 3230 |
/SensitiveDetector.hh | +5 | -2 | 3229 -> 3230 |
/TrackerHitProcessor.hh | +1 | 3229 -> 3230 | |
include/lcdd/schema/HitProcessorType.hh | +17 | 3229 -> 3230 | |
/HitsCollectionType.hh | -50 | 3229 removed | |
/hits_collection.hh | -40 | 3229 removed | |
include/lcdd/util/StoreInspector.hh | +46 | -47 | 3229 -> 3230 |
schemas/lcdd/1.0/lcdd_sensitive_detectors.xsd | +25 | -56 | 3229 -> 3230 |
src/lcdd/core/LCDDLibLoad.cc | -4 | 3229 -> 3230 | |
src/lcdd/detectors/BasicTrackerHitProcessor.cc | +1 | -1 | 3229 -> 3230 |
/CalorimeterSD.cc | +1 | -14 | 3229 -> 3230 |
/LegacyCalorimeterHitProcessor.cc | +8 | -11 | 3229 -> 3230 |
/SensitiveDetector.cc | +19 | -10 | 3229 -> 3230 |
/SensitiveDetectorFactory.cc | +46 | -68 | 3229 -> 3230 |
/TrackerSD.cc | +2 | -5 | 3229 -> 3230 |
src/lcdd/processes/hit_processorProcess.cc | +1 | 3229 -> 3230 | |
/hits_collectionProcess.cc | -44 | 3229 removed | |
+224 | -363 |
Remove the hits collection XML type and binding and replace it with optional collection_name attribute on the hits_processor.
--- projects/lcdd/branches/v04-01-00-pre/include/lcdd/detectors/CalorimeterHitProcessor.hh 2014-08-05 22:49:35 UTC (rev 3229) +++ projects/lcdd/branches/v04-01-00-pre/include/lcdd/detectors/CalorimeterHitProcessor.hh 2014-08-05 22:54:50 UTC (rev 3230) @@ -27,7 +27,8 @@
* Class constructor. * @param[in] ro The CellReadout used by the processor. */
- CalorimeterHitProcessor() {
+ CalorimeterHitProcessor() + : _calorimeter(NULL) {
} public:
@@ -45,6 +46,22 @@
CalorimeterSD* getCalorimeter() { return dynamic_cast<CalorimeterSD*>(getSensitiveDetector()); }
+ + /** + * Override super class method to set reference to CalorimeterSD. + * @param[in] detector The SensitiveDetector associated to this HitProcessor. + */ + void setSensitiveDetector(SensitiveDetector* detector) { + G4cout << "CalorimeterHitProcessor::setSensitiveDetector" << G4endl; + HitProcessor::setSensitiveDetector(detector); + _calorimeter = dynamic_cast<CalorimeterSD*>(getSensitiveDetector()); + G4cout << "collectionIndex: " << _collectionIndex << G4endl; + } + +protected: + + CalorimeterSD* _calorimeter; +
}; #endif
--- projects/lcdd/branches/v04-01-00-pre/include/lcdd/detectors/HitProcessor.hh 2014-08-05 22:49:35 UTC (rev 3229) +++ projects/lcdd/branches/v04-01-00-pre/include/lcdd/detectors/HitProcessor.hh 2014-08-05 22:54:50 UTC (rev 3230) @@ -4,6 +4,10 @@
// Geant4 #include "G4Step.hh"
+#include "lcdd/detectors/SensitiveDetector.hh" + +#include <string> +
class SensitiveDetector; /**
@@ -17,7 +21,9 @@
* Class constructor. */ HitProcessor()
- : _detector(NULL) {
+ : _detector(NULL),
+ _collectionName(""),
+ _collectionIndex(0) {
} public:
@@ -47,13 +53,31 @@
* Set the SensitiveDetector associated with this HitProcessor. * @param[in] detector The SensitiveDetector of this HitProcessor. */
- void setSensitiveDetector(SensitiveDetector* detector) {
+ virtual void setSensitiveDetector(SensitiveDetector* detector) {
_detector = detector;
+ if (_collectionName != "") { + for (int i=0, n=detector->GetNumberOfCollections(); i<n; i++) { + std::string aCollectionName = detector->GetCollectionName(i); + if (aCollectionName == _collectionName) { + _collectionIndex = i; + } + } + }
}
-private:
+ void setCollectionName(const std::string& collectionName) { + _collectionName = collectionName; + }
+ int getCollectionIndex() { + return _collectionIndex; + } + +protected: +
SensitiveDetector* _detector;
+ std::string _collectionName; + int _collectionIndex;
}; #endif
--- projects/lcdd/branches/v04-01-00-pre/include/lcdd/detectors/LegacyCalorimeterHitProcessor.hh 2014-08-05 22:49:35 UTC (rev 3229) +++ projects/lcdd/branches/v04-01-00-pre/include/lcdd/detectors/LegacyCalorimeterHitProcessor.hh 2014-08-05 22:54:50 UTC (rev 3230) @@ -7,22 +7,22 @@
#include "lcdd/detectors/HitProcessorFactory.hh" /**
- * @brief Implementation of hit processing behavior for CalorimeterSD objects with Segmentation. - * @todo Change name to SegmentedCalorimeterHitProcessor.
+ * @brief + * Implementation of hit processing behavior for CalorimeterSD objects with Segmentation.
*/
-class LegacyCalorimeterHitProcessor: public CalorimeterHitProcessor {
+class BasicCalorimeterHitProcessor: public CalorimeterHitProcessor {
public: /** * Class constructor. */
- LegacyCalorimeterHitProcessor();
+ BasicCalorimeterHitProcessor();
/** * Class destructor. */
- virtual ~LegacyCalorimeterHitProcessor();
+ virtual ~BasicCalorimeterHitProcessor();
/** * Process steps to produce hits.
@@ -39,11 +39,11 @@
public: HitProcessor* createHitProcessor() {
- return new LegacyCalorimeterHitProcessor();
+ return new BasicCalorimeterHitProcessor();
} const std::string& handlesType() {
- static std::string typeName = "LegacyCalorimeterHitProcessor";
+ static std::string typeName = "BasicCalorimeterHitProcessor";
return typeName; } };
--- projects/lcdd/branches/v04-01-00-pre/include/lcdd/detectors/SensitiveDetector.hh 2014-08-05 22:49:35 UTC (rev 3229) +++ projects/lcdd/branches/v04-01-00-pre/include/lcdd/detectors/SensitiveDetector.hh 2014-08-05 22:54:50 UTC (rev 3230) @@ -7,13 +7,14 @@
// LCDD #include "lcdd/detectors/StepReadout.hh"
-#include "lcdd/detectors/HitProcessor.hh"
#include "lcdd/id/IdSpec.hh" #include "lcdd/id/Id64bit.hh" class G4UImessenger; class G4VHitsCollection;
+class HitProcessor; +
/** * @brief A basic implementation of G4VSensitiveDetector. * @note Primary attributes include verbosity, energy cut,
@@ -26,7 +27,9 @@
* EType indicates the basic type of detector, e.g. tracker or calorimeter. */ enum EType {
- eNone = 0, eTracker = 1, eCalorimeter = 2
+ eNone = 0, + eTracker = 1, + eCalorimeter = 2
}; static const std::string& TRACKER;
--- projects/lcdd/branches/v04-01-00-pre/include/lcdd/detectors/TrackerHitProcessor.hh 2014-08-05 22:49:35 UTC (rev 3229) +++ projects/lcdd/branches/v04-01-00-pre/include/lcdd/detectors/TrackerHitProcessor.hh 2014-08-05 22:54:50 UTC (rev 3230) @@ -1,6 +1,7 @@
#ifndef LCDD_DETECTORS_TRACKERHITPROCESSOR_HH_ #define LCDD_DETECTORS_TRACKERHITPROCESSOR_HH_ 1
+#include "lcdd/detectors/HitProcessor.hh"
#include "lcdd/detectors/TrackerSD.hh" /**
--- projects/lcdd/branches/v04-01-00-pre/include/lcdd/schema/HitProcessorType.hh 2014-08-05 22:49:35 UTC (rev 3229) +++ projects/lcdd/branches/v04-01-00-pre/include/lcdd/schema/HitProcessorType.hh 2014-08-05 22:54:50 UTC (rev 3230) @@ -45,6 +45,22 @@
} /**
+ * Set the hits collection name of the HitProcessor. + * @param s The type of the HitProcessor. + */ + void set_collection_name(const std::string& s) { + _collection_name = s; + } + + /** + * Get the hits collection name of the HitProcessor. + * @return The type of the HitProcessor. + */ + const std::string& get_collection_name() const { + return _collection_name; + } + + /**
* Add child content. * @param tag The tag of the child. * @param so The SAXObject of the child.
@@ -56,6 +72,7 @@
private: std::string _type;
+ std::string _collection_name;
ContentSequence _sequence; };
--- projects/lcdd/branches/v04-01-00-pre/include/lcdd/schema/HitsCollectionType.hh 2014-08-05 22:49:35 UTC (rev 3229) +++ projects/lcdd/branches/v04-01-00-pre/include/lcdd/schema/HitsCollectionType.hh 2014-08-05 22:54:50 UTC (rev 3230) @@ -1,50 +0,0 @@
-#ifndef LCDD_SCHEMA_HITSCOLLECTIONTYPE_HH_ -#define LCDD_SCHEMA_HITSCOLLECTIONTYPE_HH_ 1 - -// STL -#include <string> - -// GDML -#include "Schema/ContentGroup.h" - -/** - * @brief - * The HitsCollectionType from the XML schema. - */ -class HitsCollectionType { - -public: - - /** - * Class constructor. - */ - HitsCollectionType() { - } - - /** - * Class destructor. - */ - virtual ~HitsCollectionType() { - } - - /** - * Set the name of the HitsCollection. - * @param s The name of the HitsCollection. - */ - void set_name(const std::string& s) { - _name = s; - } - - /** - * Get the name of the HitsCollection. - * @return The name of the HitsCollection. - */ - const std::string& get_name() const { - return _name; - } - -private: - std::string _name; -}; - -#endif
--- projects/lcdd/branches/v04-01-00-pre/include/lcdd/schema/hits_collection.hh 2014-08-05 22:49:35 UTC (rev 3229) +++ projects/lcdd/branches/v04-01-00-pre/include/lcdd/schema/hits_collection.hh 2014-08-05 22:54:50 UTC (rev 3230) @@ -1,40 +0,0 @@
-#ifndef LCDD_SCHEMA_HITS_COLLECTION_HH_ -#define LCDD_SCHEMA_HITS_COLLECTION_HH_ 1 - -// LCDD -#include "lcdd/schema/HitsCollectionType.hh" - -// GDML -#include "Saxana/SAXObject.h" - -/** - * @brief - * The hits_collection element from the XML schema. - */ -class hits_collection: public SAXObject, public HitsCollectionType { - -public: - - /** - * Class constructor. - */ - hits_collection() { - } - - /** - * Class destructor. - */ - virtual ~hits_collection() { - } - - /** - * Get the type of this SAXObject. - * @return The type of this SAXObject. - */ - virtual SAXObject::Type type() { - return SAXObject::element; - } - -}; - -#endif
--- projects/lcdd/branches/v04-01-00-pre/include/lcdd/util/StoreInspector.hh 2014-08-05 22:49:35 UTC (rev 3229) +++ projects/lcdd/branches/v04-01-00-pre/include/lcdd/util/StoreInspector.hh 2014-08-05 22:54:50 UTC (rev 3230) @@ -37,10 +37,9 @@
#include <cassert> #include <cmath>
-using std::endl; -
/**
- * @brief Templated class for printing the contents of a Geant4 or LCDD object store using a G4UIcommand.
+ * @brief + * Templated class for printing the contents of a Geant4 or LCDD object store using a G4UIcommand.
* @note * The store must have an STL vector or map as its backing data structure. */
@@ -153,12 +152,12 @@
* @return The same output stream. */ std::ostream& printStore(std::ostream& os) {
- os << "********* " + _name + " store ********" << endl << endl;
+ os << "********* " + _name + " store ********" << std::endl << std::endl;
for (const_iterator it = _container->begin(); it != _container->end(); it++) { printObject(os, getObjectName(it), getObject(it));
- os << "-------------------------------------" << endl;
+ os << "-------------------------------------" << std::endl;
}
- os << "*************************************" << endl << endl;
+ os << "*************************************" << std::endl << std::endl;
return os; }
@@ -169,8 +168,8 @@
* @param[in] object The object to print. */ std::ostream& printObject(std::ostream& os, const std::string& name, Object* obj) {
- os << _name << " - " << name << endl; - os << (*obj) << endl;
+ os << _name << " - " << name << std::endl; + os << (*obj) << std::endl;
return os; }
@@ -200,7 +199,7 @@
if (obj != 0) { printObject(std::cout, name, obj); } else {
- std::cerr << "ERROR: Object named " + name + " was not found in the " + _name + " store!" << endl;
+ std::cerr << "ERROR: Object named " + name + " was not found in the " + _name + " store!" << std::endl;
} } else { printStore(std::cout);
@@ -236,11 +235,11 @@
* @return The same output stream. */ std::ostream& operator<<(std::ostream& os, PhysicsLimitSet& limset) {
- os << endl;
+ os << std::endl;
for (PhysicsLimitSet::LimitSetMap::const_iterator it = limset.getLimitSetMap().begin(); it != limset.getLimitSetMap().end(); it++) { const PhysicsLimitSet::LimitNameType& name = it->first;
- os << name << endl;
+ os << name << std::endl;
std::string unit = ""; if (name == "ekin_min") {
@@ -259,10 +258,10 @@
const PhysicsLimitSet::LimitMap& limmap = it->second; for (PhysicsLimitSet::LimitMap::const_iterator iit = limmap.begin(); iit != limmap.end(); iit++) {
- os << '\t' << iit->first << '\t' << G4BestUnit(iit->second, unit) << endl;
+ os << '\t' << iit->first << '\t' << G4BestUnit(iit->second, unit) << std::endl;
} } else {
- os << "Unknown limit type " << name << endl;
+ os << "Unknown limit type " << name << std::endl;
} } return os;
@@ -275,10 +274,10 @@
* @return The same output stream. */ std::ostream& operator<<(std::ostream &os, G4LogicalVolume &lv) {
- os << "solid: " << lv.GetSolid()->GetName() << endl; - os << "material: " << lv.GetMaterial()->GetName() << endl; - os << "mass: " << G4BestUnit(lv.GetMass(), "Mass") << endl; - os << "daughters: " << lv.GetNoDaughters() << endl;
+ os << "solid: " << lv.GetSolid()->GetName() << std::endl; + os << "material: " << lv.GetMaterial()->GetName() << std::endl; + os << "mass: " << G4BestUnit(lv.GetMass(), "Mass") << std::endl; + os << "daughters: " << lv.GetNoDaughters() << std::endl;
G4UserLimits* lim = lv.GetUserLimits(); os << "limits: ";
@@ -287,7 +286,7 @@
} else { os << "NONE"; }
- os << endl;
+ os << std::endl;
G4VSensitiveDetector* sd = lv.GetSensitiveDetector(); os << "SD: ";
@@ -296,7 +295,7 @@
} else { os << "NONE"; }
- os << endl;
+ os << std::endl;
G4Region* reg = lv.GetRegion(); os << "region: ";
@@ -305,7 +304,7 @@
} else { os << "NONE"; }
- os << endl;
+ os << std::endl;
const G4VisAttributes* vis = lv.GetVisAttributes(); os << "visattributes: ";
@@ -314,7 +313,7 @@
} else { os << "NONE"; }
- os << endl;
+ os << std::endl;
return os; }
@@ -326,17 +325,17 @@
* @return The same output stream. */ std::ostream& operator<<(std::ostream &os, G4VPhysicalVolume &pv) {
- os << "lvolume: " << pv.GetLogicalVolume()->GetName() << endl; - os << "pos: " << pv.GetTranslation() << endl;
+ os << "lvolume: " << pv.GetLogicalVolume()->GetName() << std::endl; + os << "pos: " << pv.GetTranslation() << std::endl;
const G4RotationMatrix* rot = pv.GetRotation(); os << "rot: "; if (0 != rot) { rot->print(os); } else {
- os << "NONE" << endl;
+ os << "NONE" << std::endl;
}
- os << "copyNo: " << pv.GetCopyNo() << endl; - os << "# copies: " << pv.GetMultiplicity() << endl;
+ os << "copyNo: " << pv.GetCopyNo() << std::endl; + os << "# copies: " << pv.GetMultiplicity() << std::endl;
return os; } /**
@@ -346,12 +345,12 @@
* @return The same output stream. */ std::ostream& operator<<(std::ostream& os, IdSpec& id) {
- os << "# fields: " << id.getNumFields() << endl; - os << endl; - os << "label\tstart\tlength\tsigned" << endl;
+ os << "# fields: " << id.getNumFields() << std::endl; + os << std::endl; + os << "label\tstart\tlength\tsigned" << std::endl;
for (IdSpec::IdFields::const_iterator it = id.IdFieldsBegin(); it != id.IdFieldsEnd(); it++) { IdField* field = *it;
- os << field->getLabel() << '\t' << field->getStart() << '\t' << field->getLength() << '\t' << field->getSigned() << endl;
+ os << field->getLabel() << '\t' << field->getStart() << '\t' << field->getLength() << '\t' << field->getSigned() << std::endl;
} return os; }
@@ -363,14 +362,14 @@
* @return The same output stream. */ std::ostream& operator<<(std::ostream& os, SensitiveDetector& sd) {
- os << "fullPath: " << sd.GetFullPathName() << endl; - os << "HC: " << sd.getHCName() << endl; - os << "HCID: " << sd.getHCID() << endl; - os << "verbose: " << sd.getVerbose() << endl; - os << "ecut: " << sd.getEnergyCut() << endl; - os << "hasIdSpec: " << sd.hasIdSpec() << endl; - os << "isEndcap: " << sd.getEndcapFlag() << endl; - os << "isActive: " << sd.isActive() << endl;
+ os << "fullPath: " << sd.GetFullPathName() << std::endl; + os << "HC: " << sd.getHCName() << std::endl; + os << "HCID: " << sd.getHCID() << std::endl; + os << "verbose: " << sd.getVerbose() << std::endl; + os << "ecut: " << sd.getEnergyCut() << std::endl; + os << "hasIdSpec: " << sd.hasIdSpec() << std::endl; + os << "isEndcap: " << sd.getEndcapFlag() << std::endl; + os << "isActive: " << sd.isActive() << std::endl;
return os; }
@@ -381,13 +380,13 @@
* @return The same output stream. */ std::ostream& operator<<(std::ostream &os, G4Region ®) {
- os << "prod cut: " << reg.GetProductionCuts()->GetProductionCut(0) << endl;
+ os << "prod cut: " << reg.GetProductionCuts()->GetProductionCut(0) << std::endl;
UserRegionInformation* regInfo = static_cast<UserRegionInformation*>(reg.GetUserInformation()); if (0 != regInfo) {
- os << "store secondaries: " << regInfo->getStoreSecondaries() << endl; - os << "energy threshold: " << regInfo->getThreshold() << endl;
+ os << "store secondaries: " << regInfo->getStoreSecondaries() << std::endl; + os << "energy threshold: " << regInfo->getThreshold() << std::endl;
} else {
- os << "NO G4UserRegionInformation" << endl;
+ os << "NO G4UserRegionInformation" << std::endl;
} return os; }
@@ -411,10 +410,10 @@
*/ std::ostream& operator<<(std::ostream& os, G4VisAttributes &vis) { const G4Color& color = vis.GetColor();
- os << "RGB: " << color.GetRed() << " " << color.GetGreen() << " " << color.GetBlue() << endl; - os << "Alpha: " << color.GetAlpha() << endl; - os << "visible: " << vis.IsVisible() << endl; - os << "show daughters: " << !vis.IsDaughtersInvisible() << endl;
+ os << "RGB: " << color.GetRed() << " " << color.GetGreen() << " " << color.GetBlue() << std::endl; + os << "Alpha: " << color.GetAlpha() << std::endl; + os << "visible: " << vis.IsVisible() << std::endl; + os << "show daughters: " << !vis.IsDaughtersInvisible() << std::endl;
os << "forced drawing style: "; if (vis.IsForceDrawingStyle()) {
@@ -427,7 +426,7 @@
} else { os << "NONE"; }
- os << endl;
+ os << std::endl;
return os; }
--- projects/lcdd/branches/v04-01-00-pre/schemas/lcdd/1.0/lcdd_sensitive_detectors.xsd 2014-08-05 22:49:35 UTC (rev 3229) +++ projects/lcdd/branches/v04-01-00-pre/schemas/lcdd/1.0/lcdd_sensitive_detectors.xsd 2014-08-05 22:54:50 UTC (rev 3230) @@ -1,35 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE xs:schema >
-
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:lcdd="http://www.lcsim.org/schemas/lcdd/1.0/"> -
+ xmlns:lcdd="http://www.lcsim.org/schemas/lcdd/1.0/">
<xs:complexType name="HitProcessorType"> <xs:attribute name="type" type="xs:string" use="required"/>
- </xs:complexType> - - <xs:complexType name="HitsCollectionType"> - <xs:attribute name="name" type="xs:string" use="required"/> - </xs:complexType> - - <xs:complexType name="SensitiveDetectorType"> -
+ <xs:attribute name="collection_name" type="xs:string" use="optional"/> + </xs:complexType> + <xs:complexType name="SensitiveDetectorType">
<xs:annotation> <xs:documentation> Sensitive detector type with a name, ID, and hits collection </xs:documentation>
- </xs:annotation> -
+ </xs:annotation>
<xs:sequence> <xs:element minOccurs="0" maxOccurs="1" name="idspecref" type="ReferenceType" /> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="hit_processor" type="HitProcessorType" />
- <xs:element name="hits_collection" type="HitsCollectionType" />
</xs:choice> </xs:sequence>
-
<xs:attribute name="name" type="xs:ID" use="required" /> <xs:attribute name="hits_collection" type="xs:string" /> <xs:attribute name="endcap_flag" type="xs:boolean" default="false" />
@@ -42,10 +32,8 @@
<xs:maxInclusive value="2"/> </xs:restriction> </xs:simpleType>
- </xs:attribute> -
+ </xs:attribute>
</xs:complexType>
-
<xs:element abstract="true" name="sd" type="SensitiveDetectorType"> <xs:annotation> <xs:documentation>
@@ -53,7 +41,6 @@
</xs:documentation> </xs:annotation> </xs:element>
-
<xs:complexType name="SensitiveDetectorsType"> <xs:annotation> <xs:documentation>
@@ -64,19 +51,17 @@
<xs:element minOccurs="0" maxOccurs="unbounded" ref="sd" /> </xs:sequence> </xs:complexType>
-
<xs:element name="sensitive_detectors" type="SensitiveDetectorsType"> <xs:annotation> <xs:documentation>
- Sensitive detector container element
+ SD container element
</xs:documentation> </xs:annotation> </xs:element>
-
<xs:complexType name="CalorimeterType"> <xs:annotation> <xs:documentation>
- Calorimeter sensitive detector type
+ Calorimeter SD type
</xs:documentation> </xs:annotation> <xs:complexContent>
@@ -94,20 +79,18 @@
</xs:attribute> </xs:extension> </xs:complexContent>
- </xs:complexType> -
+ </xs:complexType>
<xs:element name="calorimeter" substitutionGroup="sd" type="CalorimeterType"> <xs:annotation> <xs:documentation>
- Calorimeter sensitive detector element
+ Calorimeter SD element
</xs:documentation> </xs:annotation> </xs:element>
-
<xs:complexType name="TrackerType"> <xs:annotation> <xs:documentation>
- Tracker sensitive detector type
+ Tracker SD type
</xs:documentation> </xs:annotation> <xs:complexContent>
@@ -116,15 +99,13 @@
</xs:extension> </xs:complexContent> </xs:complexType>
-
<xs:element name="tracker" substitutionGroup="sd" type="TrackerType"> <xs:annotation> <xs:documentation>
- Tracker element
+ Tracker SD element
</xs:documentation> </xs:annotation> </xs:element>
-
<xs:complexType name="SegmentationType"> <xs:annotation> <xs:documentation>
@@ -132,19 +113,17 @@
</xs:documentation> </xs:annotation> </xs:complexType>
-
<xs:element abstract="true" name="segmentation" type="SegmentationType"> <xs:annotation> <xs:documentation>
- Abstract segmentation
+ Abstract segmentation type
</xs:documentation> </xs:annotation> </xs:element>
-
<xs:complexType name="NonprojectiveSegmentationType"> <xs:annotation> <xs:documentation>
- NP segmentation type.
+ Nonprojective segmentation type
</xs:documentation> </xs:annotation> <xs:complexContent>
@@ -156,7 +135,6 @@
</xs:extension> </xs:complexContent> </xs:complexType>
-
<xs:complexType name="CellReadout2DSegmentationType"> <xs:annotation> <xs:documentation>
@@ -170,28 +148,25 @@
<xs:attribute default="mm" name="lunit" type="xs:string"/> </xs:extension> </xs:complexContent>
- </xs:complexType> -
+ </xs:complexType>
<xs:element name="cell_readout_2d" substitutionGroup="segmentation" type="CellReadout2DSegmentationType"> <xs:annotation> <xs:documentation>
- The element definition for the CellReadout2DSegmentationType.
+ Cell Readout 2D type
</xs:documentation> </xs:annotation>
- </xs:element> -
+ </xs:element>
<xs:element name="grid_xyz" substitutionGroup="segmentation" type="NonprojectiveSegmentationType"> <xs:annotation> <xs:documentation>
- NP segmentation element for polygons such as boxes and trapezoids.
+ Grid XYZ type
</xs:documentation> </xs:annotation> </xs:element>
-
<xs:complexType name="GlobalGridXYSegmentationType"> <xs:annotation> <xs:documentation>
- Type for global grid in XY.
+ Global grid XY type
</xs:documentation> </xs:annotation> <xs:complexContent>
@@ -202,19 +177,17 @@
</xs:extension> </xs:complexContent> </xs:complexType>
-
<xs:element name="global_grid_xy" substitutionGroup="segmentation" type="GlobalGridXYSegmentationType"> <xs:annotation> <xs:documentation>
- Element for global grid in XY.
+ Global grid XY element
</xs:documentation> </xs:annotation> </xs:element>
-
<xs:complexType name="ProjectiveCylinderSegmentationType"> <xs:annotation> <xs:documentation>
- Prj segmentation type
+ Projective segmentation type
</xs:documentation> </xs:annotation> <xs:complexContent>
@@ -224,19 +197,17 @@
</xs:extension> </xs:complexContent> </xs:complexType>
-
<xs:element name="projective_cylinder" substitutionGroup="segmentation" type="ProjectiveCylinderSegmentationType"> <xs:annotation> <xs:documentation>
- Prj segmentation element
+ Projective segmentation element
</xs:documentation> </xs:annotation> </xs:element>
-
<xs:complexType name="ProjectiveZPlaneSegmentationType"> <xs:annotation> <xs:documentation>
- Prj ZPlane segmentation type
+ Projective ZPlane segmentation type
</xs:documentation> </xs:annotation> <xs:complexContent>
@@ -246,13 +217,11 @@
</xs:extension> </xs:complexContent> </xs:complexType>
-
<xs:element name="projective_zplane" substitutionGroup="segmentation" type="ProjectiveZPlaneSegmentationType"> <xs:annotation> <xs:documentation>
- Prj ZPlane segmentation element
+ Projective ZPlane segmentation element
</xs:documentation> </xs:annotation> </xs:element>
- -</xs:schema>
+</xs:schema>
\ No newline at end of file
--- projects/lcdd/branches/v04-01-00-pre/src/lcdd/core/LCDDLibLoad.cc 2014-08-05 22:49:35 UTC (rev 3229) +++ projects/lcdd/branches/v04-01-00-pre/src/lcdd/core/LCDDLibLoad.cc 2014-08-05 22:54:50 UTC (rev 3230) @@ -27,7 +27,6 @@
// hit_processor LOAD_COMPONENT (hit_processorProcess);
- LOAD_COMPONENT (hits_collectionProcess);
// segmentations LOAD_COMPONENT (grid_xyzProcess);
@@ -74,9 +73,6 @@
// subscribers LOAD_COMPONENT (headerSubscriber);
- // volume extended - //LOAD_COMPONENT(volumeExtendedSubscriber); -
// SDs LOAD_COMPONENT (calorimeterSubscriber); LOAD_COMPONENT (trackerSubscriber);
--- projects/lcdd/branches/v04-01-00-pre/src/lcdd/detectors/BasicTrackerHitProcessor.cc 2014-08-05 22:49:35 UTC (rev 3229) +++ projects/lcdd/branches/v04-01-00-pre/src/lcdd/detectors/BasicTrackerHitProcessor.cc 2014-08-05 22:54:50 UTC (rev 3230) @@ -90,7 +90,7 @@
hit->setLength(length); // Add the hit to the TrackerSD.
- tracker->addHit(hit);
+ tracker->addHit(hit, _collectionIndex);
// Get the TrackInformation and flag track as having a tracker hit. VUserTrackInformation* trackInformation = dynamic_cast<VUserTrackInformation*>(step->GetTrack()->GetUserInformation());
--- projects/lcdd/branches/v04-01-00-pre/src/lcdd/detectors/CalorimeterSD.cc 2014-08-05 22:49:35 UTC (rev 3229) +++ projects/lcdd/branches/v04-01-00-pre/src/lcdd/detectors/CalorimeterSD.cc 2014-08-05 22:54:50 UTC (rev 3230) @@ -46,7 +46,7 @@
//std::cout << "initializing hits collection: " << collectionName[i] << std::endl; // Overwrite dummy collection with actual calorimeter hits collection.
- _hitsCollections[i] = new CalorimeterHitsCollection(GetName(), collectionName[i]);
+ _hitsCollections[i] = new CalorimeterHitsCollection(GetName(), collectionNames[i]);
// Set the HCID of the collection if it has not been set already. if (getHCID(i) < 0) {
@@ -70,19 +70,6 @@
return SensitiveDetector::ProcessHits(aStep, 0); }
-/* -std::ostream& CalorimeterSD::printHits(std::ostream& os) { - for (int i = 0; i < getNumberOfHitsCollections(); i++) { - os << getHitsCollection(i)->GetName() << std::endl; - for (CalorimeterHitList::const_iterator iter = _hitsVector[i].begin(); iter != _hitsVector[i].end(); iter++) { - os << " " << **iter; - } - } - os << std::endl; - return os; -} -*/ -
void CalorimeterSD::EndOfEvent(G4HCofThisEvent *) { // Delete hit maps.
--- projects/lcdd/branches/v04-01-00-pre/src/lcdd/detectors/LegacyCalorimeterHitProcessor.cc 2014-08-05 22:49:35 UTC (rev 3229) +++ projects/lcdd/branches/v04-01-00-pre/src/lcdd/detectors/LegacyCalorimeterHitProcessor.cc 2014-08-05 22:54:50 UTC (rev 3230) @@ -8,16 +8,14 @@
#include "G4Geantino.hh" #include "G4ChargedGeantino.hh"
-LegacyCalorimeterHitProcessor::LegacyCalorimeterHitProcessor() {
+BasicCalorimeterHitProcessor::BasicCalorimeterHitProcessor() {
}
-LegacyCalorimeterHitProcessor::~LegacyCalorimeterHitProcessor() {
+BasicCalorimeterHitProcessor::~BasicCalorimeterHitProcessor() {
}
-bool LegacyCalorimeterHitProcessor::processHits(G4Step* step) {
+bool BasicCalorimeterHitProcessor::processHits(G4Step* step) {
- CalorimeterSD* calorimeter = getCalorimeter(); -
// Get the energy deposition. G4double edep = step->GetTotalEnergyDeposit();
@@ -29,25 +27,24 @@
} // Cut on energy deposition <= cut but allow Geantinos.
- if (edep <= calorimeter->getEnergyCut() && isGeantino == false) {
+ if (edep <= _calorimeter->getEnergyCut() && isGeantino == false) {
return false; } // Get the Segmentation from the CalorimeterSD.
- Segmentation* segmentation = calorimeter->getSegmentation();
+ Segmentation* segmentation = _calorimeter->getSegmentation();
// Get the global cell position from the Segmentation. G4ThreeVector globalCellPosition = segmentation->getGlobalHitPosition(step); // Set the segmentation bin values from the step.
- //segmentation->resetBins();
segmentation->setBins(step); // Create a 64-bit ID from the step information.
- Id64bit id = calorimeter->makeIdentifier(step);
+ Id64bit id = _calorimeter->makeIdentifier(step);
// Check for an existing hit with this identifier.
- CalorimeterHit* hit = calorimeter->findHit(id);
+ CalorimeterHit* hit = _calorimeter->findHit(id);
// Was there a hit found with this identifier? if (hit == NULL) {
@@ -56,7 +53,7 @@
hit = new CalorimeterHit(id, edep, globalCellPosition); // Add the new hit to the calorimeter.
- calorimeter->addHit(hit);
+ _calorimeter->addHit(hit, _collectionIndex);
} else {
--- projects/lcdd/branches/v04-01-00-pre/src/lcdd/detectors/SensitiveDetector.cc 2014-08-05 22:49:35 UTC (rev 3229) +++ projects/lcdd/branches/v04-01-00-pre/src/lcdd/detectors/SensitiveDetector.cc 2014-08-05 22:54:50 UTC (rev 3230) @@ -3,6 +3,7 @@
// LCDD #include "lcdd/id/IdManager.hh" #include "lcdd/id/IdFactory.hh"
+#include "lcdd/detectors/HitProcessor.hh"
#include "lcdd/detectors/SensitiveDetectorMessenger.hh" // Geant4
@@ -25,10 +26,16 @@
const std::string& SensitiveDetector::UNKNOWN = "unknown"; SensitiveDetector::SensitiveDetector(G4String sdName, G4String hcName, EType sdType) :
- G4VSensitiveDetector(sdName), _idspec(0), _type(sdType) { - // insert hits collection name into SD's name vector - collectionName.insert(hcName);
+ G4VSensitiveDetector(sdName), + _idspec(NULL), + _type(sdType), + _verbose(false), + _endcap(false), + _ecut(0) {
+ // Insert the collection names into the SD's name vector. + collectionNames.insert(hcName); +
// register detector with G4SDManager G4SDManager::GetSDMpointer()->AddNewDetector(this);
@@ -36,17 +43,20 @@
_messenger = new SensitiveDetectorMessenger(this); // Only one HC
- _hcids.clear(); // Is this needed???
+ _hcids.clear(); // FIXME: Is this needed here???
_hcids.push_back(-1); } SensitiveDetector::SensitiveDetector(G4String sdName, const vector<G4String>& hcNames, EType sdType) :
- G4VSensitiveDetector(sdName), _idspec(0), _type(sdType) {
+ G4VSensitiveDetector(sdName), + _idspec(0), + _type(sdType) { +
_hcids.clear(); // Is this needed??? for (int i = 0; i < (int) hcNames.size(); i++) { // insert hits collection name into SD's name vector
- collectionName.insert(hcNames[i]);
+ collectionNames.insert(hcNames[i]);
_hcids.push_back(-1); }
@@ -191,11 +201,11 @@
} const std::string& SensitiveDetector::getHCName() const {
- return collectionName[0];
+ return collectionNames[0];
} const std::string& SensitiveDetector::getHCName(G4int nHC) const {
- return collectionName[nHC];
+ return collectionNames[nHC];
} void SensitiveDetector::setVerbose(unsigned int v) {
@@ -261,7 +271,6 @@
void SensitiveDetector::addHitProcessors(std::vector<HitProcessor*> processors) { for (HitProcessors::iterator it = processors.begin(); it != processors.end(); it++) {
- (*it)->setSensitiveDetector(this); - _hitProcessors.push_back(*it);
+ addHitProcessor((*it));
} }
--- projects/lcdd/branches/v04-01-00-pre/src/lcdd/detectors/SensitiveDetectorFactory.cc 2014-08-05 22:49:35 UTC (rev 3229) +++ projects/lcdd/branches/v04-01-00-pre/src/lcdd/detectors/SensitiveDetectorFactory.cc 2014-08-05 22:54:50 UTC (rev 3230) @@ -9,14 +9,15 @@
#include "lcdd/detectors/BasicTrackerHitProcessor.hh" #include "lcdd/detectors/ScoringTrackerHitProcessor.hh" #include "lcdd/schema/hit_processor.hh"
-#include "lcdd/schema/hits_collection.hh"
+#include <algorithm> +
SensitiveDetector* SensitiveDetectorFactory::createSensitiveDetector(const SAXObject* object) {
+
const SensitiveDetectorType* sensitiveDetectorType = dynamic_cast<const SensitiveDetectorType*>(object); SensitiveDetector* sensitiveDetector = 0; IdSpec* idspec = 0; std::vector<HitProcessor*> hitProcessors;
- std::vector<std::string> hitProcessorNames;
std::vector<G4String> hitsCollections; // The SAXObject must extend SensitiveDetectorType.
@@ -25,6 +26,12 @@
// Get the SensitiveDetector's basic type string. std::string sensitiveDetectorTypeName = sensitiveDetectorType->get_type();
+ // If there is a collection name on the SD itself, add it to the list. + std::string hitsCollectionName = sensitiveDetectorType->get_hitsCollectionName(); + if (hitsCollectionName != "") { + hitsCollections.push_back(sensitiveDetectorType->get_hitsCollectionName()); + } +
// Process element content for objects that need to be created before the SD. ContentSequence* seq = const_cast<ContentSequence*>(sensitiveDetectorType->get_content()); size_t count = seq->size();
@@ -48,50 +55,60 @@
G4Exception("", "", FatalException, "IdSpec does not exist."); }
- // Process hit_processor child tag.
+ // Process hit_processor child tag.
} else if (childTag == "hit_processor") { // Cast object to appropriate element type.
- const hit_processor* hitProcessor = dynamic_cast<const hit_processor*>(seq->content(i).object);
+ const hit_processor* element = dynamic_cast<const hit_processor*>(seq->content(i).object);
- // Push type name of HitProcessor onto list to be created later once SD is available. - hitProcessorNames.push_back(hitProcessor->get_type());
+ // Create the HitProcessor. + HitProcessorFactory* hitProcessorFactory = HitProcessorManager::instance()->getFactory(element->get_type()); + if (hitProcessorFactory == NULL) + G4Exception("", "", FatalException, "HitProcessorFactory was not found."); + HitProcessor* hitProcessor = hitProcessorFactory->createHitProcessor();
- // Process hits_collection child tag. - } else if (childTag == "hits_collection") {
+ // Set the hits collection name (optional). + G4String hitsCollection = element->get_collection_name(); + if (hitsCollection != "") { + G4cout << "set collection name on HitProcessor: " << hitsCollection << G4endl; + hitProcessor->setCollectionName(hitsCollection); + }
- // Cast object to appropriate element type. - const hits_collection* hitsCollection = dynamic_cast<const hits_collection*>(seq->content(i).object);
+ // Add hits collection name to the list unless it is already defined by the SD. + if (hitsCollection != "") { + if (std::find(hitsCollections.begin(), hitsCollections.end(), hitsCollection) == hitsCollections.end()) { + hitsCollections.push_back(hitsCollection); + } + }
- // Get the name of the hits collection. - const std::string& name = hitsCollection->get_name(); - - // Add hits collection to the list. - hitsCollections.push_back(name);
+ // Add the HitsProcessor to the list for the SD. + hitProcessors.push_back(hitProcessor);
} }
- // This is for backward compatibility when 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());
+ // Add default HitProcessor if none was provided explicitly in the SD's XML element. + if (hitProcessors.size() == 0) { + if (sensitiveDetectorTypeName == "tracker") { + hitProcessors.push_back(HitProcessorManager::instance()->getFactory("BasicTrackerHitProcessor")->createHitProcessor()); + } else if (sensitiveDetectorTypeName == "calorimeter") { + hitProcessors.push_back(HitProcessorManager::instance()->getFactory("BasicCalorimeterHitProcessor")->createHitProcessor()); + }
}
- // If no hits collections were added then make a default HitsCollection with the name of the SD.
+ // If no hits collection names were provided explicitly, then make a default one from the name of the SD.
if (hitsCollections.size() == 0) { hitsCollections.push_back(sensitiveDetectorType->get_name()); } // Create the SD object based on its type of calorimeter or tracker. if (sensitiveDetectorTypeName == "calorimeter") {
- // Create calorimeter SD.
+ // Create the CalorimeterSD with its hits collection names.
sensitiveDetector = createCalorimeter(object, hitsCollections); } else if (sensitiveDetectorTypeName == "tracker") {
- // Create tracker SD.
+ // Create the TrackerSD with its hits collection names.
sensitiveDetector = createTracker(object, hitsCollections); } else {
- // Type is not recognized. This shouldn't happen!
+ // The type is not recognized. This shouldn't ever happen!
G4cerr << "Invalid sensitive detector type: " << sensitiveDetectorTypeName << G4endl; G4Exception("", "", FatalException, "Unknown sensitive detector type."); }
@@ -104,50 +121,15 @@
// Set the IdSpec. sensitiveDetector->setIdSpec(idspec);
- // Create HitProcessors from list of type names. - for (std::vector<std::string>::iterator it = hitProcessorNames.begin(); it != hitProcessorNames.end(); it++) { - std::string type = (*it); - HitProcessorFactory* hitProcessorFactory = HitProcessorManager::instance()->getFactory(type); - if (hitProcessorFactory == 0) { - std::cerr << "HitProcessorFactory was not found for type: " << type << std::endl; - G4Exception("", "", FatalException, "HitProcessor not found"); - } - HitProcessor* processor = hitProcessorFactory->createHitProcessor();
+ // Add the list of HitProcessors. This will automatically cause the HitProcessor setup code + // to be called to configure it for this SD. + sensitiveDetector->addHitProcessors(hitProcessors);
- //std::cout << "create hits processor: " << type << std::endl; - - // Add the HitProcessor to the list. - hitProcessors.push_back(processor); - } - - // Add the HitProcessors from the list. - if (hitProcessors.size() > 0) { - // 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 in the detector's XML. - if (sensitiveDetectorTypeName == "tracker") { - // Add the default TrackerHitProcessor. - sensitiveDetector->addHitProcessor( - HitProcessorManager::instance()->getFactory("BasicTrackerHitProcessor")->createHitProcessor()); - } else if (sensitiveDetectorTypeName == "calorimeter") { - // Add the default CalorimeterHitProcessor. - sensitiveDetector->addHitProcessor( - HitProcessorManager::instance()->getFactory("LegacyCalorimeterHitProcessor")->createHitProcessor()); - } - } -
// Register the SensitiveDetector with the LCDDProcessor. std::string sensitiveDetectorName = sensitiveDetector->GetName();
- //std::cout << "adding sensitive detector: " << sensitiveDetectorName << std::endl; - //std::cout << " HCs: "; - //for (std::vector<G4String>::iterator it = hitsCollections.begin(); it != hitsCollections.end(); it++) { - // std::cout << (*it) << " "; - //} - //std::cout << std::endl;
LCDDProcessor::instance()->addSensitiveDetector(sensitiveDetectorName, sensitiveDetector); } else {
- // This should never really happen.
+ // This should never really happen!
G4Exception("", "", FatalException, "Failed cast to SensitiveDetectorType."); }
@@ -173,9 +155,6 @@
} }
- // Get the calorimeter XML object. - const calorimeter* cal = dynamic_cast<const calorimeter*>(object); -
// Create the calorimeter SD. return new CalorimeterSD(sensitiveDetectorType->get_name(), hitsCollections, segmentation); }
@@ -209,6 +188,5 @@
// FIXME This should automatically know all segmentation types somehow. // Can this be read from the schema? // http://xerces-c.sourcearchive.com/documentation/3.1.1-1/SchemaGrammar_8hpp_source.html
- return (s == "projective_cylinder" || s == "grid_xyz" || s == "global_grid_xy" || s == "nonprojective_cylinder" || s == "projective_zplane" - || s == "cell_readout_2d");
+ return (s == "projective_cylinder" || s == "grid_xyz" || s == "global_grid_xy" || s == "projective_zplane" || s == "cell_readout_2d");
}
--- projects/lcdd/branches/v04-01-00-pre/src/lcdd/detectors/TrackerSD.cc 2014-08-05 22:49:35 UTC (rev 3229) +++ projects/lcdd/branches/v04-01-00-pre/src/lcdd/detectors/TrackerSD.cc 2014-08-05 22:54:50 UTC (rev 3230) @@ -4,10 +4,7 @@
#include <iostream> TrackerSD::TrackerSD(G4String sdName, std::vector<G4String> hitsCollectionNames) :
- SensitiveDetector(sdName, hitsCollectionNames, SensitiveDetector::eTracker) -//, _HC(0) -{ - //_hits.clear();
+ SensitiveDetector(sdName, hitsCollectionNames, SensitiveDetector::eTracker) {
// The actual pointers to the collections are overridden later in Initialize. for (int i = 0; i < (int) hitsCollectionNames.size(); i++) { _hitsCollections.push_back(0);
@@ -24,7 +21,7 @@
//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]);
+ _hitsCollections[i] = new TrackerHitsCollection(GetName(), collectionNames[i]);
if (getHCID(i) < 0) { // Set the HCID.
--- projects/lcdd/branches/v04-01-00-pre/src/lcdd/processes/hit_processorProcess.cc 2014-08-05 22:49:35 UTC (rev 3229) +++ projects/lcdd/branches/v04-01-00-pre/src/lcdd/processes/hit_processorProcess.cc 2014-08-05 22:54:50 UTC (rev 3230) @@ -24,6 +24,7 @@
hit_processor* hitProcessor = new hit_processor; hitProcessor->set_type(attrs.getValue("type"));
+ hitProcessor->set_collection_name(attrs.getValue("collection_name"));
_obj = hitProcessor; *obj = hitProcessor;
--- projects/lcdd/branches/v04-01-00-pre/src/lcdd/processes/hits_collectionProcess.cc 2014-08-05 22:49:35 UTC (rev 3229) +++ projects/lcdd/branches/v04-01-00-pre/src/lcdd/processes/hits_collectionProcess.cc 2014-08-05 22:54:50 UTC (rev 3230) @@ -1,44 +0,0 @@
-// LCDD -#include "lcdd/processes/hits_collectionProcess.hh" -#include "lcdd/schema/hits_collection.hh" - -// GDML -#include "Saxana/ProcessingContext.h" -#include "Saxana/SAXComponentFactory.h" - -hits_collectionProcess::hits_collectionProcess() : - SAXStateProcess(0), _obj(0) { -} - -hits_collectionProcess::hits_collectionProcess(ProcessingContext* context) : - SAXStateProcess(context), _obj(0) { -} - -hits_collectionProcess::~hits_collectionProcess() { -} - -void hits_collectionProcess::StartElement(const std::string& name, const ASCIIAttributeList& attrs) { - SAXObject** obj = Context()->GetTopObject(); - hits_collection* hitsCollection = new hits_collection; - - hitsCollection->set_name(attrs.getValue("name")); - - _obj = hitsCollection; - *obj = hitsCollection; -} - -void hits_collectionProcess::EndElement(const std::string&) { -} - -void hits_collectionProcess::Characters(const std::string&) { -} - -void hits_collectionProcess::StackPopNotify(const std::string& name) { -} - -const std::string& hits_collectionProcess::State() const { - static std::string tag = "hits_collection"; - return tag; -} - -DECLARE_PROCESS_FACTORY(hits_collectionProcess)
Use REPLY-ALL to reply to list
To unsubscribe from the LCDET-SVN list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCDET-SVN&A=1