Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged dd4hep-algorithms-v2 from repository ianna with cms-merge-topic
- Loading branch information
Showing
40 changed files
with
6,215 additions
and
344 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
<use name="FWCore/PluginManager"/> | ||
<use name="dd4hep"/> | ||
<use name="rootmath"/> | ||
<export> | ||
<lib name="1"/> | ||
</export> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0"?> | ||
<DDDefinition> | ||
<debug> | ||
<debug_shapes/> | ||
<debug_includes/> | ||
<debug_rotations/> | ||
|
||
<!-- | ||
<debug_rotations/> | ||
<debug_materials/> | ||
<debug_shapes/> | ||
<debug_volumes/> | ||
<debug_constants/> | ||
<debug_includes/> | ||
<debug_namespaces/> | ||
<debug_placements/> | ||
<debug_algorithms/> | ||
<debug_visattr/> | ||
--> | ||
</debug> | ||
<open_geometry/> | ||
<close_geometry/> | ||
|
||
<ConstantsSection label="" eval="true"> | ||
<Constant name="world_x" value="5*m"/> | ||
<Constant name="world_y" value="5*m"/> | ||
<Constant name="world_z" value="5*m"/> | ||
<Constant name="fm" value="1e-12*m"/> | ||
<Constant name="Air" value="materials_Air" type="string"/> | ||
<Constant name="Vacuum" value="materials_Vacuum" type="string"/> | ||
</ConstantsSection> | ||
|
||
<IncludeSection> | ||
<Include ref="testRotations.xml"/> | ||
<Include ref="testSolids.xml"/> | ||
<Include ref="materials.xml"/> | ||
</IncludeSection> | ||
|
||
</DDDefinition> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0"?> | ||
<DDDefinition xmlns="http://www.cern.ch/cms/DDL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cern.ch/cms/DDL ../../Schema/DDLSchema.xsd"> | ||
|
||
<RotationSection label="testRotations.xml"> | ||
<RotationByAxis name="z30" axis="z" angle="30*deg"/> | ||
<RotationSequence name="z30x20"> | ||
<RotationByAxis axis="z" angle="30*deg"/> | ||
<RotationByAxis axis="x" angle="20*deg"/> | ||
</RotationSequence> | ||
<RotationSequence name="x90y45"> | ||
<RotationByAxis axis="x" angle="90*deg"/> | ||
<RotationByAxis axis="y" angle="45*deg"/> | ||
</RotationSequence> | ||
<RotationSequence name="x90y90"> | ||
<RotationByAxis axis="x" angle="90*deg"/> | ||
<RotationByAxis axis="y" angle="90*deg"/> | ||
</RotationSequence> | ||
<RotationSequence name="x90y135"> | ||
<RotationByAxis axis="x" angle="90*deg"/> | ||
<RotationByAxis axis="y" angle="135*deg"/> | ||
</RotationSequence> | ||
<RotationSequence name="x90y180"> | ||
<RotationByAxis axis="x" angle="90*deg"/> | ||
<RotationByAxis axis="y" angle="180*deg"/> | ||
</RotationSequence> | ||
<RotationByAxis name="x90" axis="x" angle="90*deg"/> | ||
<Rotation name="cmsimIdentity" phiX="0" thetaX="90*deg" phiY="90*deg" thetaY="90*deg" phiZ="0" thetaZ="0"/> | ||
<RotationByAxis name="newrotIdentity" axis="z" angle="0*deg"/> <!-- This seems silly --> | ||
<ReflectionRotation name="180R" thetaX="90*deg" phiX="0*deg" thetaY="90*deg" phiY="90*deg" thetaZ="180*deg" phiZ="0*deg" /> | ||
</RotationSection> | ||
|
||
</DDDefinition> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?xml version="1.0"?> | ||
<DDDefinition xmlns="http://www.cern.ch/cms/DDL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cern.ch/cms/DDL ../../Schema/DDLSchema.xsd"> | ||
|
||
<SolidSection label="testSolids.xml"> | ||
<Trapezoid name="trap1" alp1="10*deg" alp2="10*deg" bl1="50*cm" bl2="75*cm" dz="1*m" h1="20*cm" h2="40*cm" phi="30*deg" theta="30*deg" tl1="50*cm" tl2="75*cm"/> | ||
<Trapezoid name="trap2" alp1="10*deg" alp2="10*deg" bl1="50*cm" bl2="75*cm" dz="1*m" h1="20*cm" h2="40*cm" tl1="50*cm" tl2="75*cm"/> | ||
<PseudoTrap name="ptrap1" dx1="10" dx2="3" dy1="30" dy2="10" dz="30" radius="10" atMinusZ="false"/> | ||
<PseudoTrap name="ptrap2" dx1="10" dx2="3" dy1="30" dy2="10" dz="30" radius="10" atMinusZ="true"/> | ||
<Box name="box1" dx="10*cm" dy="10*cm" dz="10*cm"/> | ||
<Cone name="cone1" dz="1*m" rMin1="50*cm" rMax1="100*cm" rMin2="75*cm" rMax2="125*cm" startPhi="0*deg" deltaPhi="360*deg"/> | ||
<Cone name="cone2" dz="1*m" rMin1="50*cm" rMax1="100*cm" rMin2="50*cm" rMax2="100*cm" startPhi="0*deg" deltaPhi="360*deg"/> | ||
<Cone name="cone2hole" dz="20*cm" rMin1="50*cm" rMax1="100*cm" rMin2="50*cm" rMax2="100*cm" startPhi="0*deg" deltaPhi="20*deg"/> | ||
<!-- While using this as a test solid I found that there is a | ||
problem with it. Can a Polycone come to a point "in the real world?" --> | ||
<Polycone name="pczsect" startPhi="0*deg" deltaPhi="360*deg"> | ||
<!-- see above comment ZSection z="1*m" rMin="50*cm" rMax="50*cm"/ --> | ||
<ZSection z="1*m" rMin="50*cm" rMax="55*cm"/> | ||
<ZSection z="1.5*m" rMin="50*cm" rMax="60*cm"/> | ||
<ZSection z="2*m" rMin="50*cm" rMax="75*cm"/> | ||
</Polycone> | ||
<Polycone name="pcrz" startPhi="0*deg" deltaPhi="360*deg"> | ||
<RZPoint r="50*cm" z="1*m"/> | ||
<RZPoint r="60*cm" z="1.5*m"/> | ||
<RZPoint r="75*cm" z="2*m"/> | ||
<RZPoint r="50*cm" z="2.5*m"/> | ||
</Polycone> | ||
<Polyhedra name="phzsect" numSide="18" startPhi="0*deg" deltaPhi="360*deg"> | ||
<ZSection z="1*m" rMin="50*cm" rMax="50*cm"/> | ||
<ZSection z="1.5*m" rMin="50*cm" rMax="60*cm"/> | ||
<ZSection z="2*m" rMin="50*cm" rMax="75*cm"/> | ||
</Polyhedra> | ||
<Polyhedra name="phrz" numSide="18" startPhi="0*deg" deltaPhi="360*deg"> | ||
<RZPoint r="50*cm" z="1*m"/> | ||
<RZPoint r="60*cm" z="1.5*m"/> | ||
<RZPoint r="75*cm" z="2*m"/> | ||
<RZPoint r="50*cm" z="2.5*m"/> | ||
</Polyhedra> | ||
<ExtrudedPolygon name="extrudedpgon"> | ||
<XYPoint x="-30*cm" y="-30*cm"/> | ||
<XYPoint x="-30*cm" y=" 30*cm"/> | ||
<XYPoint x=" 30*cm" y=" 30*cm"/> | ||
<XYPoint x=" 30*cm" y="-30*cm"/> | ||
<XYPoint x=" 15*cm" y="-30*cm"/> | ||
<XYPoint x=" 15*cm" y=" 15*cm"/> | ||
<XYPoint x="-15*cm" y=" 15*cm"/> | ||
<XYPoint x="-15*cm" y="-30*cm"/> | ||
<ZXYSection z="-60*cm" x="0*cm" y="30*cm" scale="0.8"/> | ||
<ZXYSection z="-15*cm" x="0*cm" y="-30*cm" scale="1."/> | ||
<ZXYSection z="10*cm" x="0*cm" y="0*cm" scale="0.6"/> | ||
<ZXYSection z="60*cm" x="0*cm" y="30*cm" scale="1.2"/> | ||
</ExtrudedPolygon> | ||
<Trd1 name="trd1" dx1="1*m" dx2="1.3*m" dz="3*m" dy1="30*cm"/> | ||
<Trd1 name="trd2" dx1="1*m" dx2="1.3*m" dz="3*m" dy1="30*cm" dy2="50*cm"/> | ||
<Tube name="tube1" rMin="1*m" rMax="1.5*m" dz="1*m"/> | ||
<Tubs name="tube2" rMin="1*m" rMax="2*m" dz="1*m" startPhi="30*deg" deltaPhi="150*deg"/> | ||
<CutTubs name="cuttubs" rMin="1*m" rMax="2*m" dz="1*m" startPhi="30*deg" deltaPhi="150*deg" lx="0" ly="-0.7" lz="-0.71" tx="0.7" ty="0" tz="0.71"/> | ||
<TruncTubs name="trunctubs1" zHalf="50*cm" rMin="20*cm" rMax="40*cm" startPhi="0*deg" deltaPhi="90*deg" cutAtStart="25*cm" cutAtDelta="35*cm" cutInside="true"/> | ||
<ShapelessSolid name="momma"/> | ||
<Box name="MotherOfAllBoxes" dx="10*m" dy="10*m" dz="10*m"/> | ||
<Torus name="torus" innerRadius="7.5*cm" outerRadius="10*cm" torusRadius="30*cm" startPhi="0*deg" deltaPhi="360*deg"/> | ||
<SubtractionSolid name="subsolid" firstSolid="cone2" secondSolid="cone2hole"/> | ||
<UnionSolid name="unionsolid" firstSolid="pcrz" secondSolid="cone1"> | ||
<Translation x="0" y="0" z="-1.0*m"/> | ||
</UnionSolid> | ||
<IntersectionSolid name="intsolid" firstSolid="cone1" secondSolid="cone2"> | ||
<RotationByAxis axis="y" angle="90*deg"/> | ||
<Translation x="0" y="0" z="50*cm"/> | ||
</IntersectionSolid> | ||
<Sphere name="asphere" innerRadius="1.*cm" outerRadius="1.1*cm" startPhi="0*deg" deltaPhi="180*deg" startTheta="15*deg" deltaTheta="90*deg"/> | ||
<EllipticalTube name="etube" xSemiAxis=".5*cm" ySemiAxis="1.*cm" zHeight="3.*cm"/> | ||
<SubtractionSolid name="subsolidOLD"> | ||
<rSolid name="cone2"/> | ||
<rSolid name="cone2hole"/> | ||
<rRotation name="testRotations:x90y45"/> | ||
</SubtractionSolid> | ||
</SolidSection> | ||
</DDDefinition> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#ifndef DETECTOR_DESCRIPTION_DD_ALGO_ARGUMENTS_H | ||
#define DETECTOR_DESCRIPTION_DD_ALGO_ARGUMENTS_H | ||
|
||
#include "XML/XML.h" | ||
#include "DD4hep/DetElement.h" | ||
#include "DetectorDescription/DDCMS/interface/DDXMLTags.h" | ||
#include "DetectorDescription/DDCMS/interface/DDNamespace.h" | ||
#include "DetectorDescription/DDCMS/interface/DDParsingContext.h" | ||
|
||
#include <map> | ||
#include <sstream> | ||
|
||
namespace cms | ||
{ | ||
constexpr unsigned int hash( const char* str, int h = 0 ) | ||
{ | ||
return !str[h] ? 5381 : ( hash( str, h+1 )*33 ) ^ str[h]; | ||
} | ||
|
||
inline unsigned int hash( const std::string& str ) | ||
{ | ||
return hash( str.c_str()); | ||
} | ||
|
||
dd4hep::Rotation3D makeRotation3D( double thetaX, double phiX, | ||
double thetaY, double phiY, | ||
double thetaZ, double phiZ ); | ||
|
||
dd4hep::Rotation3D makeRotation3D( dd4hep::Rotation3D rotation, | ||
const std::string& axis, double angle ); | ||
|
||
class DDAlgoArguments | ||
{ | ||
public: | ||
DDAlgoArguments( cms::DDParsingContext&, xml_h algorithm ); | ||
|
||
DDAlgoArguments() = delete; | ||
DDAlgoArguments( const DDAlgoArguments& copy ) = delete; | ||
DDAlgoArguments& operator=( const DDAlgoArguments& copy ) = delete; | ||
~DDAlgoArguments() = default; | ||
|
||
std::string name; | ||
cms::DDParsingContext& context; | ||
xml_h element; | ||
|
||
std::string parentName() const; | ||
std::string childName() const; | ||
bool find( const std::string& name ) const; | ||
template<typename T> T value( const std::string& name ) const; | ||
std::string str( const std::string& nam ) const; | ||
double dble( const std::string& nam ) const; | ||
int integer( const std::string& nam ) const; | ||
std::vector<double> vecDble( const std::string& nam ) const; | ||
std::vector<int> vecInt( const std::string& nam ) const; | ||
std::vector<std::string> vecStr( const std::string& nam ) const; | ||
|
||
private: | ||
|
||
xml_h rawArgument( const std::string& name ) const; | ||
std::string resolved_scalar_arg( const std::string& name ) const; | ||
}; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#ifndef DETECTOR_DESCRIPTION_DD_NAMESPACE_H | ||
#define DETECTOR_DESCRIPTION_DD_NAMESPACE_H | ||
|
||
#include "XML/XML.h" | ||
#include "DD4hep/Objects.h" | ||
#include "DD4hep/Shapes.h" | ||
#include "DD4hep/Volumes.h" | ||
|
||
namespace cms { | ||
|
||
class DDParsingContext; | ||
|
||
class DDNamespace { | ||
|
||
public: | ||
|
||
DDNamespace( DDParsingContext*, xml_h ); | ||
DDNamespace( DDParsingContext&, xml_h, bool ); | ||
DDNamespace( DDParsingContext* ); | ||
DDNamespace( DDParsingContext& ); | ||
~DDNamespace(); | ||
|
||
DDNamespace() = delete; | ||
DDNamespace( const DDNamespace& ) = delete; | ||
DDNamespace& operator=( const DDNamespace& ) = delete; | ||
|
||
std::string prepend( const std::string& ) const; | ||
std::string realName( const std::string& ) const; | ||
static std::string objName( const std::string& ); | ||
static std::string nsName( const std::string& ); | ||
|
||
template<typename T> T attr( xml_elt_t element, const xml_tag_t& name ) const { | ||
std::string val = realName( element.attr<std::string>( name )); | ||
element.setAttr( name, val ); | ||
return element.attr<T>( name ); | ||
} | ||
|
||
template<typename T> T attr( xml_elt_t element, const xml_tag_t& name, T defaultValue ) const { | ||
if( element.hasAttr( name )) { | ||
std::string val = realName( element.attr<std::string>( name )); | ||
element.setAttr( name, val ); | ||
return element.attr<T>( name ); | ||
} | ||
return defaultValue; | ||
} | ||
|
||
void addConstant( const std::string& name, const std::string& value, const std::string& type ) const; | ||
void addConstantNS( const std::string& name, const std::string& value, const std::string& type ) const; | ||
|
||
dd4hep::Material material( const std::string& name ) const; | ||
dd4hep::Solid solid( const std::string& name ) const; | ||
dd4hep::Solid addSolid( const std::string& name, dd4hep::Solid solid ) const; | ||
dd4hep::Solid addSolidNS( const std::string& name, dd4hep::Solid solid ) const; | ||
|
||
dd4hep::Volume volume( const std::string& name, bool exc = true ) const; | ||
dd4hep::Volume addVolume( dd4hep::Volume vol ) const; | ||
dd4hep::Volume addVolumeNS( dd4hep::Volume vol ) const; | ||
|
||
const dd4hep::Rotation3D& rotation( const std::string& name ) const; | ||
void addRotation( const std::string& name, const dd4hep::Rotation3D& rot ) const; | ||
|
||
DDParsingContext* context = nullptr; | ||
|
||
const std::string& name() const { | ||
return m_name; | ||
} | ||
|
||
private: | ||
std::string m_name; | ||
bool m_pop = false; | ||
}; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#ifndef DETECTOR_DESCRIPTION_DD_PARSING_CONTEXT_H | ||
#define DETECTOR_DESCRIPTION_DD_PARSING_CONTEXT_H | ||
|
||
#include "DD4hep/Detector.h" | ||
|
||
namespace cms { | ||
|
||
class DDParsingContext { | ||
|
||
public: | ||
|
||
DDParsingContext( dd4hep::Detector* det ) | ||
: description( det ) { | ||
namespaces.push_back(""); | ||
} | ||
|
||
~DDParsingContext() = default; | ||
const std::string& ns() const { return namespaces.back(); } | ||
|
||
dd4hep::Detector* description; | ||
std::map<std::string, dd4hep::Rotation3D> rotations; | ||
std::map<std::string, dd4hep::Solid> shapes; | ||
std::map<std::string, dd4hep::Volume> volumes; | ||
std::set<std::string> disabledAlgs; | ||
std::vector<std::string> namespaces; | ||
|
||
bool geo_inited = false; | ||
|
||
// Debug flags | ||
bool debug_includes = false; | ||
bool debug_constants = false; | ||
bool debug_materials = false; | ||
bool debug_rotations = false; | ||
bool debug_shapes = false; | ||
bool debug_volumes = false; | ||
bool debug_placements = false; | ||
bool debug_namespaces = false; | ||
bool debug_visattr = false; | ||
bool debug_algorithms = false; | ||
}; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#ifndef DETECTOR_DESCRIPTION_DD_PLUGINS_H | ||
#define DETECTOR_DESCRIPTION_DD_PLUGINS_H | ||
|
||
#include "DetectorDescription/DDCMS/interface/DDAlgoArguments.h" | ||
#include "DetectorDescription/DDCMS/interface/DDUnits.h" | ||
#include "DD4hep/Plugins.h" | ||
|
||
namespace dd4hep { | ||
|
||
class SensitiveDetector; | ||
|
||
template <typename T> class DDCMSDetElementFactory : public dd4hep::PluginFactoryBase { | ||
public: | ||
static long create( dd4hep::Detector& detector, | ||
cms::DDParsingContext& context, | ||
dd4hep::xml::Handle_t element, | ||
dd4hep::SensitiveDetector& sensitive ); | ||
}; | ||
} | ||
|
||
namespace { | ||
template <typename P, typename S> class Factory; | ||
DD4HEP_PLUGIN_FACTORY_ARGS_4( long, dd4hep::Detector*, | ||
cms::DDParsingContext*, ns::xml_h*, | ||
dd4hep::SensitiveDetector* ) | ||
{ | ||
return dd4hep::DDCMSDetElementFactory<P>::create( *a0, *a1, *a2, *a3 ); | ||
} | ||
} | ||
|
||
#define DECLARE_DDCMS_DETELEMENT(name,func) \ | ||
DD4HEP_OPEN_PLUGIN(dd4hep,ddcms_det_element_##name) { \ | ||
typedef DDCMSDetElementFactory< ddcms_det_element_##name > _IMP; \ | ||
template <> long \ | ||
_IMP::create(dd4hep::Detector& d, \ | ||
cms::DDParsingContext& c, \ | ||
xml::Handle_t e, \ | ||
dd4hep::SensitiveDetector& h) \ | ||
{ return func(d,c,e,h); } \ | ||
DD4HEP_PLUGINSVC_FACTORY(ddcms_det_element_##name,name, \ | ||
long(dd4hep::Detector*,cms::DDParsingContext*, \ | ||
ns::xml_h*,dd4hep::SensitiveDetector*),__LINE__) } | ||
|
||
#endif |
Oops, something went wrong.