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

Fix shape constructors for Trap and PseudoTrap #397

Merged
merged 7 commits into from
May 30, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions DDCore/include/DD4hep/Shapes.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ namespace dd4hep {
TruncatedTube& operator=(const TruncatedTube& copy) = default;
};

/// Class describing a elliptical tube shape of a section of a tube
/// Class describing a elliptical tube shape
/**
* TGeoEltu - cylindrical tube class. It takes 3 parameters :
* Semi axis of ellipsis in x and y and half-length dz.
Expand Down Expand Up @@ -502,8 +502,8 @@ namespace dd4hep {
template <typename Q> Trap(const Handle<Q>& e) : Solid_type<Object>(e) { }
/// Constructor to create a new anonymous object with attribute initialization
Trap(double z, double theta, double phi,
double y1, double x1, double x2, double alpha1,
double y2, double x3, double x4, double alpha2);
double h1, double bl1, double tl1, double alpha1,
double h2, double bl2, double tl2, double alpha2);
/// Constructor to create a new anonymous object for right angular wedge from STEP (Se G4 manual for details)
Trap(double pz, double py, double px, double pLTX) { make(pz,py,px,pLTX); }
/// Constructor to create a new anonymous object with attribute initialization
Expand All @@ -512,9 +512,9 @@ namespace dd4hep {
/// Assignment operator
Trap& operator=(const Trap& copy) = default;
/// Set the trap dimensions
Trap& setDimensions(double z, double theta, double phi,
double y1, double x1, double x2, double alpha1,
double y2, double x3, double x4, double alpha2);
Trap& setDimensions(double z, double theta, double phi,
double h1, double bl1, double tl1, double alpha1,
double h2, double bl2, double tl2, double alpha2);
};

/// Class describing a pseudo trap shape (CMS'ism)
Expand Down
12 changes: 12 additions & 0 deletions DDCore/include/Parsers/detail/Dimension.h
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,16 @@ namespace dd4hep {
Dimension position(bool throw_if_not_present = true) const;
/// Child access: rotation
Dimension rotation(bool throw_if_not_present = true) const;
/// Child access: cone
Dimension cone(bool throw_if_not_present = true) const;
/// Child access: sphere
Dimension sphere(bool throw_if_not_present = true) const;
/// Child access: torus
Dimension torus(bool throw_if_not_present = true) const;
/// Child access: trap
Dimension trap(bool throw_if_not_present = true) const;
/// Child access: trapezoid
Dimension trapezoid(bool throw_if_not_present = true) const;
/// Child access: trd
Dimension trd(bool throw_if_not_present = true) const;
/// Child access: tubs
Expand All @@ -562,6 +572,8 @@ namespace dd4hep {
Dimension staves(bool throw_if_not_present = true) const;
/// Child access: beampipe
Dimension beampipe(bool throw_if_not_present = true) const;
/// Child access: beampipe
Dimension envelope(bool throw_if_not_present = true) const;

/// Access "name" attribute as STL string
std::string nameStr() const;
Expand Down
6 changes: 6 additions & 0 deletions DDCore/include/Parsers/detail/Dimension.imp
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,15 @@ XML_ATTR_ACCESSOR_DOUBLE(temperature)
XML_CHILD_ACCESSOR_XML_DIM(dimensions)
XML_CHILD_ACCESSOR_XML_DIM(position)
XML_CHILD_ACCESSOR_XML_DIM(rotation)
XML_CHILD_ACCESSOR_XML_DIM(cone)
XML_CHILD_ACCESSOR_XML_DIM(sphere)
XML_CHILD_ACCESSOR_XML_DIM(torus)
XML_CHILD_ACCESSOR_XML_DIM(trap)
XML_CHILD_ACCESSOR_XML_DIM(trapezoid)
XML_CHILD_ACCESSOR_XML_DIM(trd)
XML_CHILD_ACCESSOR_XML_DIM(tubs)
XML_CHILD_ACCESSOR_XML_DIM(staves)
XML_CHILD_ACCESSOR_XML_DIM(envelope)
XML_CHILD_ACCESSOR_XML_DIM(beampipe)

std::string dd4hep::DD4HEP_DIMENSION_NS::Dimension::padType() const {
Expand Down
4 changes: 4 additions & 0 deletions DDCore/include/XML/UnicodeValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ UNICODE (end_module);
UNICODE (end_modules);
UNICODE (endcap);
UNICODE (endphi);
UNICODE (envelope);
UNICODE (epsilon);
UNICODE (eunit);
UNICODE (end_x);
Expand Down Expand Up @@ -387,6 +388,7 @@ UNICODE (sensor);
UNICODE (sequence);
UNICODE (setup);
UNICODE (shape);
UNICODE (shield);
UNICODE (show_daughters);
UNICODE (showDaughters);
UNICODE (size);
Expand All @@ -399,6 +401,7 @@ UNICODE (solids);
UNICODE (solidref);
UNICODE (spacer);
UNICODE (sphere);
UNICODE (station);
UNICODE (status);
UNICODE (start);
UNICODE (start_x);
Expand Down Expand Up @@ -430,6 +433,7 @@ UNICODE (tracker);
UNICODE (tracking_cylinder);
UNICODE (tracking_volume);
UNICODE (trap);
UNICODE (trapezoid);
UNICODE (trd);
UNICODE (true);
UNICODE (tube);
Expand Down
17 changes: 0 additions & 17 deletions DDCore/python/DD4hep.py

This file was deleted.

4 changes: 4 additions & 0 deletions DDCore/python/dd4hep_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ def __init__(self):
import_namespace_item('core','NamedObject')
import_namespace_item('core','run_interpreter')

def import_detail():
import_namespace_item('detail','DD4hepUI')

def import_geometry():
import_namespace_item('core','setPrintLevel')
import_namespace_item('core','setPrintFormat')
Expand Down Expand Up @@ -235,6 +238,7 @@ def import_tgeo():

import_tgeo()
import_geometry()
import_detail()
#
# Import units from TGeo.
# Calling import_units makes all the units local to the dd4hep module.
Expand Down
7 changes: 7 additions & 0 deletions DDCore/src/DetectorData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,5 +281,12 @@ void DetectorData::adoptData(DetectorData& source, bool clr) {
m_properties = source.m_properties;
//m_extensions = source.m_extensions;
m_volManager = source.m_volManager;

// Update world element
m_world.setPlacement(m_manager->GetTopNode());
// Need to update some global stuff
if ( gGeoManager != m_manager ) delete gGeoManager;
gGeoManager = m_manager;

if ( clr ) source.clearData();
}
55 changes: 33 additions & 22 deletions DDCore/src/Shapes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,9 @@ Hyperboloid& Hyperboloid::setDimensions(double rin, double stin, double rout, do

/// Constructor to be used when creating a new object with attribute initialization
Sphere::Sphere(double rmin, double rmax, double theta, double delta_theta, double phi, double delta_phi) {
_assign(new TGeoSphere(rmin, rmax, theta/units::deg, delta_theta/units::deg, phi/units::deg, delta_phi/units::deg), "", "sphere", true);
_assign(new TGeoSphere(rmin, rmax,
theta/units::deg, delta_theta/units::deg,
phi/units::deg, delta_phi/units::deg), "", "sphere", true);
}

/// Set the Sphere dimensions
Expand All @@ -475,42 +477,51 @@ Torus& Torus::setDimensions(double r, double rmin, double rmax, double phi, doub
}

/// Constructor to be used when creating a new anonymous object with attribute initialization
Trap::Trap(double z, double theta, double phi, double y1, double x1, double x2, double alpha1, double y2, double x3, double x4,
double alpha2) {
_assign(new TGeoTrap(z, theta, phi, y1, x1, x2, alpha1/units::deg, y2, x3, x4, alpha2/units::deg), "", "trap", true);
Trap::Trap(double z, double theta, double phi,
double h1, double bl1, double tl1, double alpha1,
double h2, double bl2, double tl2, double alpha2) {
_assign(new TGeoTrap(z, theta/units::deg, phi/units::deg,
h1, bl1, tl1, alpha1/units::deg,
h2, bl2, tl2, alpha2/units::deg), "", "trap", true);
}

/// Constructor to be used when creating a new anonymous object with attribute initialization
void Trap::make(double pz, double py, double px, double pLTX) {
double z = pz / 2e0;
double theta = 0e0;
double phi = 0e0;
double y1 = py / 2e0;
double x1 = px / 2e0;
double x2 = pLTX / 2e0;
double z = pz / 2e0;
double theta = 0e0;
double phi = 0e0;
double h = py / 2e0;
double bl = px / 2e0;
double tl = pLTX / 2e0;
double alpha1 = (pLTX - px) / py;
_assign(new TGeoTrap(z, theta, phi, y1, x1, x2, alpha1/units::deg, y1, x1, x2, alpha1/units::deg), "", "trap", true);
_assign(new TGeoTrap(z, theta, phi,
h, bl, tl, alpha1/units::deg,
h, bl, tl, alpha1/units::deg), "", "trap", true);
}

/// Set the trap dimensions
Trap& Trap::setDimensions(double z, double theta, double phi, double y1, double x1, double x2, double alpha1, double y2,
double x3, double x4, double alpha2) {
double params[] = { z, theta, phi, y1, x1, x2, alpha1/units::deg, y2, x3, x4, alpha2/units::deg };
Trap& Trap::setDimensions(double z, double theta, double phi,
double h1, double bl1, double tl1, double alpha1,
double h2, double bl2, double tl2, double alpha2) {
double params[] = { z, theta/units::deg, phi/units::deg,
h1, bl1, tl1, alpha1/units::deg,
h2, bl2, tl2, alpha2/units::deg };
_setDimensions(params);
return *this;
}

/// Internal helper method to support object construction
void PseudoTrap::make(double x1, double x2, double y1, double y2, double z, double r, bool atMinusZ) {
double x = atMinusZ ? x1 : x2;
double h = 0;
bool intersec = false; // union or intersection solid
double halfOpeningAngle = std::asin( x / std::abs( r ))/units::deg;
double x = atMinusZ ? x1 : x2;
double h = 0;
bool intersec = false; // union or intersection solid
double displacement = 0;
double startPhi = 0;
double halfZ = z/2.;
/* calculate the displacement of the tubs w.r.t. to the trap, determine the opening angle of the tubs */
double delta = std::sqrt( r * r - x * x );
double startPhi = 0;
double halfZ = z;
double halfOpeningAngle = std::asin( x / std::abs( r ))/units::deg;

/// calculate the displacement of the tubs w.r.t. to the trap, determine the opening angle of the tubs
double delta = std::sqrt( r * r - x * x );

if( r < 0 && std::abs( r ) >= x ) {
intersec = true; // intersection solid
Expand Down
Loading