Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DD4Hep Shapes Validation #23393

Merged
merged 3 commits into from May 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion DetectorDescription/Core/interface/DDCompactView.h
Expand Up @@ -14,6 +14,7 @@
#include "DetectorDescription/Core/interface/DDPosData.h"
#include "DetectorDescription/Core/interface/DDTransform.h"
#include "DataFormats/Math/interface/Graph.h"
#include "DataFormats/Math/interface/GraphWalker.h"

class DDCompactViewImpl;
class DDDivision;
Expand All @@ -27,7 +28,6 @@ namespace DDI {
class Specific;
}


/**
Navigation through the compact view of the detector ...

Expand Down Expand Up @@ -84,6 +84,7 @@ class DDCompactView
{
public:
using Graph = math::Graph<DDLogicalPart, DDPosData* >;
using GraphWalker = math::GraphWalker<DDLogicalPart, DDPosData* >;

//! Creates a compact-view
explicit DDCompactView();
Expand All @@ -95,6 +96,7 @@ class DDCompactView

//! Provides read-only access to the data structure of the compact-view.
const Graph & graph() const;
GraphWalker walker() const;

//! returns the DDLogicalPart representing the root of the geometrical hierarchy
const DDLogicalPart & root() const;
Expand Down
9 changes: 6 additions & 3 deletions DetectorDescription/Core/interface/DDCompactViewImpl.h
Expand Up @@ -6,6 +6,7 @@
#include "DetectorDescription/Core/interface/DDPosData.h"
#include "DetectorDescription/Core/interface/DDTransform.h"
#include "DataFormats/Math/interface/Graph.h"
#include "DataFormats/Math/interface/GraphWalker.h"

class DDDivision;
struct DDPosData;
Expand All @@ -14,7 +15,8 @@ class DDCompactViewImpl
{
public:

using GraphNav = math::Graph<DDLogicalPart, DDPosData* >;
using Graph = math::Graph<DDLogicalPart, DDPosData* >;
using GraphWalker = math::GraphWalker<DDLogicalPart, DDPosData* >;

explicit DDCompactViewImpl();
DDCompactViewImpl(const DDLogicalPart & rootnodedata);
Expand All @@ -27,7 +29,8 @@ class DDCompactViewImpl

DDLogicalPart & current() const;

const GraphNav & graph() const { return graph_; }
const Graph& graph() const { return graph_; }
GraphWalker walker() const;

void position (const DDLogicalPart & self,
const DDLogicalPart & parent,
Expand All @@ -41,7 +44,7 @@ class DDCompactViewImpl
protected:
// internal use ! (see comments in DDCompactView(bool)!)
DDLogicalPart root_;
GraphNav graph_;
Graph graph_;
};

#endif
7 changes: 7 additions & 0 deletions DetectorDescription/Core/src/DDCompactView.cc
Expand Up @@ -61,6 +61,12 @@ const DDCompactView::Graph & DDCompactView::graph() const
return rep_->graph();
}

DDCompactView::GraphWalker
DDCompactView::walker() const
{
return rep_->walker();
}

const DDLogicalPart & DDCompactView::root() const
{
return rep_->root();
Expand All @@ -78,6 +84,7 @@ void DDCompactView::position (const DDLogicalPart & self,
const DDRotation & rot,
const DDDivision * div)
{
std::cout << "DDCompactView::position " << self << " with translation " << trans << " and rotation " << rot << "\n";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ianna this message should be triggered only for debug , either using some #ifdef or the MessageLogger.

int cpno = atoi(copyno.c_str());
position(self,parent,cpno,trans,rot, div);
}
Expand Down
10 changes: 8 additions & 2 deletions DetectorDescription/Core/src/DDCompactViewImpl.cc
Expand Up @@ -11,13 +11,13 @@ DDCompactViewImpl::DDCompactViewImpl( const DDLogicalPart & rootnodedata )

DDCompactViewImpl::~DDCompactViewImpl()
{
GraphNav::adj_list::size_type it = 0;
Graph::adj_list::size_type it = 0;
if( graph_.size() == 0 ) {
LogDebug("DDCompactViewImpl") << "In destructor, graph is empty. Root:" << root_ << std::endl;
} else {
LogDebug("DDCompactViewImpl") << "In destructor, graph is NOT empty. Root:" << root_ << " graph_.size() = " << graph_.size() << std::endl;
for(; it < graph_.size() ; ++it ) {
GraphNav::edge_range erange = graph_.edges( it );
Graph::edge_range erange = graph_.edges( it );
for(; erange.first != erange.second; ++(erange.first)) {
DDPosData * pd = graph_.edgeData( erange.first->second );
delete pd;
Expand All @@ -28,6 +28,12 @@ DDCompactViewImpl::~DDCompactViewImpl()
edm::LogInfo("DDCompactViewImpl") << std::endl << "DDD transient representation has been destructed." << std::endl << std::endl;
}

DDCompactViewImpl::GraphWalker
DDCompactViewImpl::walker() const
{
return GraphWalker( graph_, root_ );
}

void
DDCompactViewImpl::position( const DDLogicalPart & self,
const DDLogicalPart & parent,
Expand Down
19 changes: 9 additions & 10 deletions DetectorDescription/DDCMS/data/cms-test-shapes.xml
Expand Up @@ -13,19 +13,11 @@
<debug_algorithms/>

<!--
<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/>

Expand All @@ -45,7 +37,14 @@
<Include ref="DetectorDescription/DDCMS/data/testLogicalParts.xml"/>
<Include ref="DetectorDescription/DDCMS/data/testRotations.xml"/>
<Include ref="DetectorDescription/DDCMS/data/testSolids.xml"/>
<Include ref="DetectorDescription/DDCMS/data/testPosParts.xml"/>
<Include ref="DetectorDescription/DDCMS/data/materials.xml"/>
</IncludeSection>


<PosPartSection label="">
<PosPart copyNumber="2">
<rParent name="world_volume"/>
<rChild name="testLogicalParts:MotherOfAllBoxes"/>
</PosPart>
</PosPartSection>
</DDDefinition>
30 changes: 30 additions & 0 deletions DetectorDescription/DDCMS/data/cmsWorld.xml
@@ -0,0 +1,30 @@
<?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 ../../../DetectorDescription/Schema/DDLSchema.xsd">

<SolidSection label="cmsWorld.xml">
<Box name="OCMS" dx="10*m" dy="10*m" dz="10*m"/>
</SolidSection>

<LogicalPartSection label="cmsWorld.xml">
<LogicalPart name="World" category="unspecified">
<rSolid name="OCMS"/>
<rMaterial name="materials:Air"/>
</LogicalPart>
<LogicalPart name="OCMS" category="unspecified">
<rSolid name="OCMS"/>
<rMaterial name="materials:Air"/>
</LogicalPart>
<LogicalPart name="MCMS" category="unspecified">
<rSolid name="OCMS"/>
<rMaterial name="materials:Air"/>
</LogicalPart>
</LogicalPartSection>

<PosPartSection label="cmsWorld.xml">
<PosPart copyNumber="0">
<rParent name="OCMS"/>
<rChild name="testLogicalParts:MotherOfAllBoxes"/>
</PosPart>
</PosPartSection>

</DDDefinition>
2 changes: 1 addition & 1 deletion DetectorDescription/DDCMS/data/testLogicalParts.xml
@@ -1,7 +1,7 @@
<?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">

<LogicalPartSection label="lps">
<LogicalPartSection label="testLogicalParts.xml">
<LogicalPart name="trap1">
<rMaterial name="testMaterials:Air"/>
<rSolid name="testSolids:trap1"/>
Expand Down
142 changes: 142 additions & 0 deletions DetectorDescription/DDCMS/data/testPosParts.xml
@@ -0,0 +1,142 @@
<?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">
<PosPartSection label="pospart">
<PosPart copyNumber="0">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:trap1"/>
<rRotation name="testRotations:x90"/>
<Translation z="0*m" y="0*m" x="0*m"/>
</PosPart>
<PosPart copyNumber="1">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:trap1"/>
<rRotation name="testRotations:x90"/>
<Translation z="1*m" y="0*m" x="0*m"/>
</PosPart>
<PosPart copyNumber="2">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:trap1"/>
<rRotation name="testRotations:x90"/>
<Translation z="2*m" y="0*m" x="0*m"/>
</PosPart>
<PosPart copyNumber="3">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:trap1"/>
<rRotation name="testRotations:x90"/>
<Translation z="3*m" y="0*m" x="0*m"/>
</PosPart>
<PosPart copyNumber="4">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:trap1"/>
<rRotation name="testRotations:x90"/>
<Translation z="4*m" y="0*m" x="0*m"/>
</PosPart>
<PosPart copyNumber="5">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:trap1"/>
<rRotation name="testRotations:x90"/>
<Translation z="5*m" y="0*m" x="0*m"/>
</PosPart>

<PosPart copyNumber="0">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:trap2"/>
<rRotation name="testRotations:x90y45"/>
<Translation z="5*m" y="0*m" x="0*m"/>
</PosPart>

<PosPart copyNumber="0">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:trd1"/>
<rRotation name="testRotations:x90y90"/>
<Translation z="5*m" y="0*m" x="0*m"/>
</PosPart>

<PosPart copyNumber="0">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:trd2"/>
<rRotation name="testRotations:x90y135"/>
<Translation z="5*m" y="0*m" x="0*m"/>
</PosPart>

<PosPart copyNumber="1">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:trd2"/>
<rRotation name="testRotations:x90y135"/>
<Translation z="5.1*m" y="0*m" x="0*m"/>
</PosPart>

<PosPart copyNumber="0">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:intsolid"/>
<Translation z="-5*m" y="0*m" x="0*m"/>
</PosPart>

<PosPart copyNumber="0">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:pczsect2"/>
<Translation z="6.5*m" y="0" x="0"/>
</PosPart>
<PosPart copyNumber="0">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:pczsect3"/>
<Translation z="7.5*m" y="0" x="0"/>
</PosPart>

<PosPart copyNumber="0">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:ptrap1"/>
</PosPart>
<PosPart copyNumber="0">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:ptrap2"/>
</PosPart>
<PosPart copyNumber="0">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:box1"/>
<Translation z="-.5*m" y="0" x="0"/>
</PosPart>
<PosPart copyNumber="0">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:cone1"/>
<Translation z="-5*m" y="0" x="0"/>
</PosPart>
<PosPart copyNumber="0">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:cone3"/>
<Translation z="-6.5*m" y="0" x="0"/>
</PosPart>
<PosPart copyNumber="0">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:cone2"/>
<Translation z="-8*m" y="0" x="0"/>
</PosPart>
<PosPart copyNumber="0">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:subsolid"/>
<Translation z="-8*m" y="5*m" x="0"/>
</PosPart>
<PosPart copyNumber="0">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:torus"/>
<Translation z="-8.5*m" y="5.5*m" x="0"/>
</PosPart>
<PosPart copyNumber="0">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:extrudedpgon"/>
<Translation z="-8.5*m" y="5.5*m" x="0"/>
</PosPart>

<!-- beyond this point I'm not worrying about overlaps :( -->
<PosPart copyNumber="1">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:asphere"/>
<Translation z="-8.7*m" y="5.7*m" x="0."/>
</PosPart>
<PosPart copyNumber="1">
<rParent name="testLogicalParts:MotherOfAllBoxes"/>
<rChild name="testLogicalParts:etube"/>
<Translation z="-8.9*m" y="5.9*m" x="0."/>
</PosPart>
</PosPartSection>
</DDDefinition>
9 changes: 5 additions & 4 deletions DetectorDescription/DDCMS/data/testSolids.xml
Expand Up @@ -2,10 +2,11 @@
<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="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="trap1" alp1="10*deg" alp2="10*deg" bl1="30*cm" bl2="10*cm" dz="60*cm" h1="40*cm" h2="16*cm" phi="5*deg" theta="20*deg" tl1="40*cm" tl2="14*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"/>
<PseudoTrap name="ptrap1" dx1="10*cm" dx2="3*cm" dy1="30*cm" dy2="10*cm" dz="30*cm" radius="10*cm" atMinusZ="false"/>
<PseudoTrap name="ptrap2" dx1="10*cm" dx2="3*cm" dy1="30*cm" dy2="10*cm" dz="30*cm" radius="10*cm" 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"/>
Expand Down Expand Up @@ -66,7 +67,7 @@ problem with it. Can a Polycone come to a point "in the real world?" -->
<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"/>
<Sphere name="asphere" innerRadius="100.*cm" outerRadius="110.*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"/>
Expand Down