Commit in projects/lcdd/branches/v05-00-00-dev on MAIN | |||
examples/segmentation/ProjectiveCylinder.lcdd | +84 | added 3256 | |
include/lcdd/schema/ProjectiveCylinderType.hh | +57 | added 3256 | |
/projective_cylinder.hh | -38 | 3255 removed | |
schemas/lcdd/2.0/lcdd_sensitive_detectors.xsd | +12 | 3255 -> 3256 | |
src/lcdd/core/LCDDLibLoad.cc | +20 | -19 | 3255 -> 3256 |
src/lcdd/detectors/DDSegmentationCalorimeterHitProcessor.cc | +20 | -12 | 3255 -> 3256 |
/SensitiveDetectorFactory.cc | +34 | -1 | 3255 -> 3256 |
src/lcdd/processes/projective_cylinderProcess.cc | +77 | added 3256 | |
/projective_cylinder_oldProcess.cc | +1 | -1 | 3255 -> 3256 |
src/lcdd/segmentation/SegmentationFactory.cc | +1 | -1 | 3255 -> 3256 |
+306 | -72 |
Add binding for ProjectiveCylinder segmentation type from DD4hep.
--- projects/lcdd/branches/v05-00-00-dev/examples/segmentation/ProjectiveCylinder.lcdd (rev 0) +++ projects/lcdd/branches/v05-00-00-dev/examples/segmentation/ProjectiveCylinder.lcdd 2014-08-12 23:08:42 UTC (rev 3256) @@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?> +<lcdd xmlns:lcdd="http://www.lcsim.org/schemas/lcdd/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcdd/2.0/lcdd.xsd"> + <header> + <detector name="ProjectiveCylinder" /> + </header> + <iddict> + <idspec name="CalHits" length="64"> + <idfield signed="true" label="theta" length="32" start="0" /> + <idfield signed="true" label="phi" length="32" start="32" /> + </idspec> + </iddict> + <sensitive_detectors> + <calorimeter name="Cal" hits_collection="CalHits"> + <idspecref ref="CalHits" /> + <hit_processor type="DDSegmentationCalorimeterHitProcessor" /> + <projective_cylinder theta_bins="500" phi_bins="1000" offset_theta="0.0" offset_phi="0.0"/> + </calorimeter> + </sensitive_detectors> + <limits /> + <regions/> + <display /> + <gdml> + <define> + <rotation name="identity_rot" x="0.0" y="0.0" z="0.0" unit="radian" /> + <position name="identity_pos" x="0.0" y="0.0" z="0.0" unit="mm" /> + <constant name="world_x" value="5.0*m" /> + <constant name="world_y" value="5.0*m" /> + <constant name="world_z" value="5.0*m" /> + </define> + <materials> + <element name="N" formula="N" Z="7.0"> + <atom type="A" unit="g/mol" value="14.00674" /> + </element> + <element name="O" formula="O" Z="8.0"> + <atom type="A" unit="g/mol" value="15.9994" /> + </element> + <element name="Ar" formula="Ar" Z="18.0"> + <atom type="A" unit="g/mol" value="39.948" /> + </element> + <material name="Air"> + <D type="density" unit="g/cm3" value="0.0012" /> + <fraction n="0.754" ref="N" /> + <fraction n="0.234" ref="O" /> + <fraction n="0.012" ref="Ar" /> + </material> + <element name="Fe" formula="Fe" Z="26.0"> + <atom type="A" unit="g/mol" value="55.845" /> + </element> + <element name="C" formula="C" Z="6.0"> + <atom type="A" unit="g/mol" value="12.0107" /> + </element> + <material name="Steel235"> + <D value="7.85" unit="g/cm3" /> + <fraction n="0.998" ref="Fe" /> + <fraction n=".002" ref="C" /> + </material> + </materials> + <solids> + <box name="world_box" x="world_x" y="world_y" z="world_z" /> + <tube name="CalTube" deltaphi="6.283185307179586" rmin="0.9*m" rmax="1.0*m" z="3.0*m" /> + </solids> + <structure> + <volume name="CalVolume"> + <materialref ref="Steel235" /> + <solidref ref="CalTube" /> + <sdref ref="Cal" /> + </volume> + <volume name="world_volume"> + <materialref ref="Air" /> + <solidref ref="world_box" /> + <physvol> + <volumeref ref="CalVolume" /> + <positionref ref="identity_pos" /> + <rotationref ref="identity_rot" /> + </physvol> + </volume> + </structure> + <setup name="Default" version="1.0"> + <world ref="world_volume" /> + </setup> + </gdml> + <fields /> +</lcdd> +
--- projects/lcdd/branches/v05-00-00-dev/include/lcdd/schema/ProjectiveCylinderType.hh (rev 0) +++ projects/lcdd/branches/v05-00-00-dev/include/lcdd/schema/ProjectiveCylinderType.hh 2014-08-12 23:08:42 UTC (rev 3256) @@ -0,0 +1,57 @@
+/* + * ProjectiveCylinderType.hh + * + * Created on: Aug 12, 2014 + * Author: jeremym + */ + +#ifndef LCDD_SCHEMA_PROJECTIVECYLINDERTYPE_HH_ +#define LCDD_SCHEMA_PROJECTIVECYLINDERTYPE_HH_ 1 + +#include "lcdd/schema/SegmentationType.hh" + +class ProjectiveCylinderType : public SegmentationType { + +public: + + void set_theta_bins(const std::string theta_bins) { + _theta_bins = theta_bins; + } + + const std::string& get_theta_bins() { + return _theta_bins; + } + + void set_phi_bins(const std::string phi_bins) { + _phi_bins = phi_bins; + } + + const std::string& get_phi_bins() { + return _phi_bins; + } + + void set_offset_theta(const std::string offset_theta) { + _offset_theta = offset_theta; + } + + const std::string& get_offset_theta() { + return _offset_theta; + } + + void set_offset_phi(const std::string offset_phi) { + _offset_phi = offset_phi; + } + + const std::string& get_offset_phi() { + return _offset_phi; + } + +private: + + std::string _theta_bins; + std::string _phi_bins; + std::string _offset_theta; + std::string _offset_phi; +}; + +#endif /* LCDD_SCHEMA_PROJECTIVECYLINDERTYPE_HH_ */
--- projects/lcdd/branches/v05-00-00-dev/include/lcdd/schema/projective_cylinder.hh 2014-08-12 22:39:04 UTC (rev 3255) +++ projects/lcdd/branches/v05-00-00-dev/include/lcdd/schema/projective_cylinder.hh 2014-08-12 23:08:42 UTC (rev 3256) @@ -1,38 +0,0 @@
-#ifndef LCDD_SCHEMA_PROJECTIVE_CYLINDER_HH_ -#define LCDD_SCHEMA_PROJECTIVE_CYLINDER_HH_ 1 - -// LCDD -#include "ProjectiveCylinderSegmentationType.hh" - -// GDML -#include "Saxana/SAXObject.h" - -/** - * @brief The projective_cylinder element from the schema. - */ -class projective_cylinder_old: public SAXObject, public ProjectiveCylinderSegmentationType { - -public: - - /** - * Class constructor. - */ - projective_cylinder_old() { - } - - /** - * Class destructor. - */ - virtual ~projective_cylinder_old() { - } - - /** - * Get the type of this SAXObject. - * @return The type of this SAXObject. - */ - virtual SAXObject::Type type() { - return SAXObject::element; - } -}; - -#endif
--- projects/lcdd/branches/v05-00-00-dev/schemas/lcdd/2.0/lcdd_sensitive_detectors.xsd 2014-08-12 22:39:04 UTC (rev 3255) +++ projects/lcdd/branches/v05-00-00-dev/schemas/lcdd/2.0/lcdd_sensitive_detectors.xsd 2014-08-12 23:08:42 UTC (rev 3256) @@ -260,5 +260,17 @@
</xs:complexContent> </xs:complexType> <xs:element name="cartesian_grid_xz" substitutionGroup="segmentation" type="CartesianGridXZType"/>
+ + <xs:complexType name="ProjectiveCylinderType"> + <xs:complexContent> + <xs:extension base="SegmentationType"> + <xs:attribute name="theta_bins" type="xs:double" use="required"/> + <xs:attribute name="phi_bins" type="xs:double" use="required"/> + <xs:attribute name="offset_theta" type="xs:double" default="0.0"/> + <xs:attribute name="offset_phi" type="xs:double" default="0.0"/> + </xs:extension> + </xs:complexContent> + </xs:complexType> + <xs:element name="projective_cylinder" substitutionGroup="segmentation" type="ProjectiveCylinderType"/>
</xs:schema>
\ No newline at end of file
--- projects/lcdd/branches/v05-00-00-dev/src/lcdd/core/LCDDLibLoad.cc 2014-08-12 22:39:04 UTC (rev 3255) +++ projects/lcdd/branches/v05-00-00-dev/src/lcdd/core/LCDDLibLoad.cc 2014-08-12 23:08:42 UTC (rev 3256) @@ -9,43 +9,44 @@
*/ void LCDDLoadProcesses() {
- // header
+ // Header
LOAD_COMPONENT (headerProcess); LOAD_COMPONENT (detectorProcess); LOAD_COMPONENT (authorProcess); LOAD_COMPONENT (generatorProcess); LOAD_COMPONENT (commentProcess);
- // volume extended
+ // Volume extended
LOAD_COMPONENT (volumeExtendedProcess); LOAD_COMPONENT (physvolidProcess);
- // SDs
+ // Sensitive Detectors
LOAD_COMPONENT (calorimeterProcess); LOAD_COMPONENT (trackerProcess); LOAD_COMPONENT (sdrefProcess);
- // hit_processor
+ // Hit Processors
LOAD_COMPONENT (hit_processorProcess);
- // segmentations
+ // Segmentations (legacy)
LOAD_COMPONENT (grid_xyzProcess); LOAD_COMPONENT (projective_cylinderProcess); LOAD_COMPONENT (projective_zplaneProcess); LOAD_COMPONENT (global_grid_xyProcess); LOAD_COMPONENT (cell_readout_2dProcess);
- // DDSegmentation
+ // New DD4hep Segmentations
LOAD_COMPONENT (cartesian_grid_xyProcess); LOAD_COMPONENT (cartesian_grid_xzProcess); LOAD_COMPONENT (cartesian_grid_xyzProcess);
+ LOAD_COMPONENT (projective_cylinderProcess);
- // Ids
+ // Identifiers
LOAD_COMPONENT (idspecProcess); LOAD_COMPONENT (idfieldProcess); LOAD_COMPONENT (idspecrefProcess);
- // field
+ // B-fields
LOAD_COMPONENT (fieldrefProcess); LOAD_COMPONENT (global_fieldProcess); LOAD_COMPONENT (solenoidProcess);
@@ -56,36 +57,36 @@
LOAD_COMPONENT (box_dipoleProcess); LOAD_COMPONENT (field_map_3dProcess)
- // region
+ // Region
LOAD_COMPONENT (regionProcess); LOAD_COMPONENT (regionrefProcess);
- // display
+ // Visualization
LOAD_COMPONENT (visProcess); LOAD_COMPONENT (visrefProcess); LOAD_COMPONENT (colorProcess);
- // limit
+ // Physics limits
LOAD_COMPONENT (limitsetProcess); LOAD_COMPONENT (limitsetrefProcess); LOAD_COMPONENT (limitProcess); } /**
- * Function for loading LCDD subscribers.
+ * Function for loading LCDD subscribers to create runtime objects.
*/ void LCDDLoadSubscribers() {
- // subscribers
+ // Header
LOAD_COMPONENT (headerSubscriber);
- // SDs
+ // Sensitive Detectors
LOAD_COMPONENT (calorimeterSubscriber); LOAD_COMPONENT (trackerSubscriber);
- // Ids
+ // Identifiers
LOAD_COMPONENT (idspecSubscriber);
- // field
+ // B-fields
LOAD_COMPONENT (solenoidSubscriber); LOAD_COMPONENT (rz_field_mapSubscriber); LOAD_COMPONENT (dipoleSubscriber);
@@ -93,13 +94,13 @@
LOAD_COMPONENT (global_fieldSubscriber); LOAD_COMPONENT (field_map_3dSubscriber);
- // region
+ // Regions
LOAD_COMPONENT (regionSubscriber);
- // display
+ // Visualization
LOAD_COMPONENT (visSubscriber);
- // limit
+ // Physics limits
LOAD_COMPONENT (limitsetSubscriber); }
--- projects/lcdd/branches/v05-00-00-dev/src/lcdd/detectors/DDSegmentationCalorimeterHitProcessor.cc 2014-08-12 22:39:04 UTC (rev 3255) +++ projects/lcdd/branches/v05-00-00-dev/src/lcdd/detectors/DDSegmentationCalorimeterHitProcessor.cc 2014-08-12 23:08:42 UTC (rev 3256) @@ -27,7 +27,7 @@
bool DDSegmentationCalorimeterHitProcessor::processHits(G4Step* step) {
- //G4cout << "DDSegmentationCalorimeterHitProcessor::processHits" << G4endl;
+ G4cout << "DDSegmentationCalorimeterHitProcessor::processHits" << G4endl;
// Get the energy deposition. G4double edep = step->GetTotalEnergyDeposit();
@@ -69,16 +69,6 @@
// Create the encoded 64-bit cell ID from the Segmentation. DD4hep::DDSegmentation::CellID cellId = segmentation->cellID(localPosition, globalPosition, volumeId);
- G4cout << "fieldDescription = " << segmentation->decoder()->fieldDescription() << G4endl; - //segmentation->decoder()->setValue(cellId); - - //int ix = segmentation->decoder()->index("x"); - //int iy = segmentation->decoder()->index("y"); - - // FIXME: Commented code causes Seg Fault. - //G4cout << "x = " << segmentation->decoder()[ix] << G4endl; - //G4cout << "y = " << segmentation->decoder()[iy] << G4endl; -
// Check for an existing hit with this identifier. CalorimeterHit* hit = _calorimeter->getCalorimeterHitMap(getCollectionIndex())->get(cellId);
@@ -88,6 +78,24 @@
G4cout << "creating a new hit " << G4endl; G4cout << "cellID: " << std::hex << cellId << G4endl;
+ G4cout << "fieldDescription: " << segmentation->decoder()->fieldDescription() << G4endl; + + //segmentation->decoder()->setValue(cellId); + + //int size = segmentation->decoder()->size(); + //G4cout << "size: " << size << G4endl; + //for (int i=0; i<size; i++) { + //G4cout << "value[" << i << "] = " + G4cout << segmentation->decoder()[0] << G4endl; + //} + + //int ix = segmentation->decoder()->index("x"); + //int iy = segmentation->decoder()->index("y"); + + // FIXME: Commented code causes Seg Fault. + //G4cout << "x = " << segmentation->decoder()[ix] << G4endl; + //G4cout << "y = " << segmentation->decoder()[iy] << G4endl; +
int id0 = segmentation->decoder()->lowWord(); int id1 = segmentation->decoder()->highWord();
@@ -125,7 +133,7 @@
} else {
- //G4cout << "adding " << std::dec << edep << " to existing hit" << G4endl;
+ G4cout << "adding " << std::dec << edep << " to existing hit" << G4endl;
// Add energy deposition to an existing hit. hit->addEdep(edep);
--- projects/lcdd/branches/v05-00-00-dev/src/lcdd/detectors/SensitiveDetectorFactory.cc 2014-08-12 22:39:04 UTC (rev 3255) +++ projects/lcdd/branches/v05-00-00-dev/src/lcdd/detectors/SensitiveDetectorFactory.cc 2014-08-12 23:08:42 UTC (rev 3256) @@ -12,6 +12,7 @@
#include "lcdd/schema/cartesian_grid_xy.hh" #include "lcdd/schema/cartesian_grid_xz.hh" #include "lcdd/schema/cartesian_grid_xyz.hh"
+#include "lcdd/schema/projective_cylinder.hh"
// GDML #include "G4Evaluator/GDMLExpressionEvaluator.h"
@@ -20,10 +21,12 @@
#include "DDSegmentation/CartesianGridXY.h" #include "DDSegmentation/CartesianGridXZ.h" #include "DDSegmentation/CartesianGridXYZ.h"
+#include "DDSegmentation/ProjectiveCylinder.h"
using DD4hep::DDSegmentation::CartesianGridXY; using DD4hep::DDSegmentation::CartesianGridXZ; using DD4hep::DDSegmentation::CartesianGridXYZ;
+using DD4hep::DDSegmentation::ProjectiveCylinder;
#include <algorithm> #include <exception>
@@ -251,6 +254,32 @@
cartesianGridXZ->setOffsetZ(offsetZ); segmentation = cartesianGridXZ;
+ } else if (childTag == "projective_cylinder") { + + projective_cylinder* element = dynamic_cast<projective_cylinder*>(segitem.object); + ProjectiveCylinder* projectiveCylinder = new ProjectiveCylinder(calorimeter->getIdSpec()->getFieldDescription()); + + double thetaBins, phiBins, offsetTheta, offsetPhi; + thetaBins = phiBins = offsetTheta = offsetPhi; + + std::string rawValue = element->get_theta_bins(); + thetaBins = calc->Eval(rawValue); + + rawValue = element->get_phi_bins(); + phiBins = calc->Eval(rawValue); + + rawValue = element->get_offset_theta(); + offsetTheta = calc->Eval(rawValue); + + rawValue = element->get_offset_phi(); + offsetPhi = calc->Eval(rawValue); + + projectiveCylinder->setThetaBins(thetaBins); + projectiveCylinder->setPhiBins(phiBins); + projectiveCylinder->setOffsetTheta(offsetTheta); + projectiveCylinder->setOffsetPhi(offsetPhi); + + segmentation = projectiveCylinder;
} if (segmentation != NULL)
@@ -311,5 +340,9 @@
// FIXME This should automatically know all segmentation types. // Can they 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 == "projective_zplane" || s == "cell_readout_2d");
+ return (s == "projective_cylinder_old" || + s == "grid_xyz" || + s == "global_grid_xy" || + s == "projective_zplane" || + s == "cell_readout_2d");
}
--- projects/lcdd/branches/v05-00-00-dev/src/lcdd/processes/projective_cylinderProcess.cc (rev 0) +++ projects/lcdd/branches/v05-00-00-dev/src/lcdd/processes/projective_cylinderProcess.cc 2014-08-12 23:08:42 UTC (rev 3256) @@ -0,0 +1,77 @@
+/* + * projective_cylinderProcess.cc + * + * Created on: Aug 12, 2014 + * Author: jeremym + */ + +// LCDD +#include "lcdd/schema/projective_cylinder.hh" + +// GDML +#include "Saxana/ProcessingConfigurator.h" +#include "Saxana/ProcessingContext.h" +#include "Saxana/SAXProcessor.h" +#include "Saxana/StateStack.h" +#include "Saxana/SAXProcessingState.h" +#include "Saxana/SAXStateProcess.h" +#include "Saxana/SAXComponentFactory.h" + +// STL +#include <iostream> + +/** + * @brief SAX process for projective_cylinder element. + */ +class projective_cylinderProcess: public SAXStateProcess { + +public: + + projective_cylinderProcess(const ProcessingContext* context = 0) : + SAXStateProcess(context), m_obj(0) { + } + + virtual ~projective_cylinderProcess() { + } + + virtual const SAXComponentObject* Build() const { + return this; + } + + virtual void StartElement(const std::string&, const ASCIIAttributeList& attrs) { + + SAXObject** obj = Context()->GetTopObject(); + + projective_cylinder* element = new projective_cylinder; + + element->set_theta_bins(attrs.getValue("theta_bins")); + element->set_phi_bins(attrs.getValue("phi_bins")); + element->set_offset_theta(attrs.getValue("offset_theta")); + element->set_offset_phi(attrs.getValue("offset_phi")); + + m_obj = element; + *obj = element; + } + + virtual void EndElement(const std::string&) { + } + + virtual void Characters(const std::string&) { + } + + virtual void StackPopNotify(const std::string&) { + } + + virtual const std::string& State() const { + static std::string tag = "projective_cylinder"; + return tag; + } + +private: + + SAXObject* m_obj; +}; + +DECLARE_PROCESS_FACTORY(projective_cylinderProcess) + +
--- projects/lcdd/branches/v05-00-00-dev/src/lcdd/processes/projective_cylinder_oldProcess.cc 2014-08-12 22:39:04 UTC (rev 3255) +++ projects/lcdd/branches/v05-00-00-dev/src/lcdd/processes/projective_cylinder_oldProcess.cc 2014-08-12 23:08:42 UTC (rev 3256) @@ -1,5 +1,5 @@
// LCDD
-#include "lcdd/schema/projective_cylinder.hh"
+#include "lcdd/schema/projective_cylinder_old.hh"
// GDML #include "Saxana/ProcessingConfigurator.h"
--- projects/lcdd/branches/v05-00-00-dev/src/lcdd/segmentation/SegmentationFactory.cc 2014-08-12 22:39:04 UTC (rev 3255) +++ projects/lcdd/branches/v05-00-00-dev/src/lcdd/segmentation/SegmentationFactory.cc 2014-08-12 23:08:42 UTC (rev 3256) @@ -3,7 +3,7 @@
// LCDD #include "lcdd/schema/grid_xyz.hh" #include "lcdd/schema/global_grid_xy.hh"
-#include "lcdd/schema/projective_cylinder.hh"
+#include "lcdd/schema/projective_cylinder_old.hh"
#include "lcdd/schema/projective_zplane.hh" #include "lcdd/schema/cell_readout_2d.hh" #include "lcdd/segmentation/Segmentation.hh"
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