diff --git a/DDCore/src/DetectorImp.cpp b/DDCore/src/DetectorImp.cpp index 9398950644c5db57c11359ebe4f4b85f25d3c6b5..107c60c06d751cfdc8aaa62141aca11fbe400f6b 100644 --- a/DDCore/src/DetectorImp.cpp +++ b/DDCore/src/DetectorImp.cpp @@ -668,6 +668,7 @@ void DetectorImp::endDocument(bool close_geometry) { m_trackingVol.setVisAttributes(trackingVis); add(trackingVis); #endif + m_worldVol.solid()->ComputeBBox(); /// Since we allow now for anonymous shapes, /// we will rename them to use the name of the volume they are assigned to mgr->CloseGeometry(); diff --git a/DDCore/src/Volumes.cpp b/DDCore/src/Volumes.cpp index 84adb2d7da0e573113d8b22b07c7c04608f2f6a1..bbc1e42dd5e6d9c569b406ff3294d860d9cf63dd 100644 --- a/DDCore/src/Volumes.cpp +++ b/DDCore/src/Volumes.cpp @@ -579,31 +579,22 @@ PlacedVolume _addNode(TGeoVolume* par, TGeoVolume* daughter, int id, TGeoMatrix* if ( !parent ) { except("dd4hep","Volume: Attempt to assign daughters to an invalid physical parent volume."); } - if ( !daughter ) { + else if ( !daughter ) { except("dd4hep","Volume: Attempt to assign an invalid physical daughter volume."); } - if ( !transform ) { + else if ( !transform ) { except("dd4hep","Volume: Attempt to place volume without placement matrix."); } if ( transform != detail::matrix::_identity() ) { string nam = string(daughter->GetName()) + "_placement"; transform->SetName(nam.c_str()); } -#if 0 - if ( transform->IsTranslation() ) { - cout << daughter->GetName() << ": Translation: " << transform->GetTranslation()[2] << endl; - } -#endif TGeoShape* shape = daughter->GetShape(); // Need to fix the daughter's BBox of assemblies, if the BBox was not calculated.... if ( shape->IsA() == TGeoShapeAssembly::Class() ) { TGeoShapeAssembly* as = (TGeoShapeAssembly*)shape; - if ( std::fabs(as->GetDX()) < numeric_limits<double>::epsilon() && - std::fabs(as->GetDY()) < numeric_limits<double>::epsilon() && - std::fabs(as->GetDZ()) < numeric_limits<double>::epsilon() ) { - as->NeedsBBoxRecompute(); - as->ComputeBBox(); - } + as->NeedsBBoxRecompute(); + as->ComputeBBox(); } const Double_t* r = transform->GetRotationMatrix(); if ( r ) { @@ -614,8 +605,7 @@ PlacedVolume _addNode(TGeoVolume* par, TGeoVolume* daughter, int id, TGeoMatrix* transform->SetBit(TGeoMatrix::kGeoRotation); if ( transform->IsRotation() ) { - TGeoRotation* rot = static_cast<TGeoRotation*>(transform); - Double_t det = + Double_t det = r[0]*r[4]*r[8] + r[3]*r[7]*r[2] + r[6]*r[1]*r[5] - r[2]*r[4]*r[6] - r[5]*r[7]*r[0] - r[8]*r[1]*r[3]; diff --git a/DDCore/src/plugins/ShapePlugins.cpp b/DDCore/src/plugins/ShapePlugins.cpp index aaa8a5ebcdf99dfb9673840c8970042a9620bd7f..fe5564822410a3d000410349c708ac57a121e98e 100644 --- a/DDCore/src/plugins/ShapePlugins.cpp +++ b/DDCore/src/plugins/ShapePlugins.cpp @@ -633,39 +633,34 @@ static Ref_t create_shape(Detector& description, xml_h e, Ref_t /* sens */) { volume.setVisAttributes(description, x_check.visStr()); solid->SetName(shape_type.c_str()); + Transform3D tr; if ( pos.ptr() && rot.ptr() ) { Rotation3D rot3D(RotationZYX(rot.z(0),rot.y(0),rot.x(0))); Position pos3D(pos.x(0),pos.y(0),pos.z(0)); - Transform3D tr(rot3D, pos3D); - if ( reflect ) { - rot3D = Rotation3D(1., 0., 0., 0., 1., 0., 0., 0., -1.) * rot3D; - tr = Transform3D(rot3D, pos3D); - } - else if ( reflectX ) { - tr = Transform3D(rot3D, pos3D) * Rotation3D(-1.,0.,0.,0.,1.,0.,0.,0.,1.); - } - else if ( reflectY ) { - tr = Transform3D(rot3D, pos3D) * Rotation3D(1.,0.,0.,0.,-1.,0.,0.,0.,1.); - } - else if ( reflectZ ) { - tr = Transform3D(rot3D, pos3D) * Rotation3D(1.,0.,0.,0.,1.,0.,0.,0.,-1.); - } - pv = assembly.placeVolume(volume,tr); + tr = Transform3D(rot3D, pos3D); } -#if 0 else if ( pos.ptr() ) { - pv = assembly.placeVolume(volume,Position(pos.x(0),pos.y(0),pos.z(0))); + tr = Transform3D(Rotation3D(),Position(pos.x(0),pos.y(0),pos.z(0))); } else if ( rot.ptr() ) { Rotation3D rot3D(RotationZYX(rot.z(0),rot.y(0),rot.x(0))); - if ( reflect ) - rot3D = Rotation3D(1., 0., 0., 0., 1., 0., 0., 0., -1.) * rot3D; - pv = assembly.placeVolume(volume,rot3D); + tr = Transform3D(rot3D,Position()); + } + + if ( reflect ) { + tr = tr * Rotation3D(1., 0., 0., 0., 1., 0., 0., 0., -1.); } - else { - pv = assembly.placeVolume(volume); + if ( reflectX ) { + tr = tr * Rotation3D(-1.,0.,0.,0.,1.,0.,0.,0.,1.); } -#endif + if ( reflectY ) { + tr = tr * Rotation3D(1.,0.,0.,0.,-1.,0.,0.,0.,1.); + } + if ( reflectZ ) { + tr = tr * Rotation3D(1.,0.,0.,0.,1.,0.,0.,0.,-1.); + } + pv = assembly.placeVolume(volume,tr); + if ( x_check.hasAttr(_U(id)) ) { pv.addPhysVolID("check",x_check.id()); } diff --git a/examples/ClientTests/compact/CheckShape.xml b/examples/ClientTests/compact/CheckShape.xml index a4d208d5f025be7cd67c4f8c3f689ca37834058c..12a6d2db9d3d19df3e2ff157c2b6af99b7941db4 100644 --- a/examples/ClientTests/compact/CheckShape.xml +++ b/examples/ClientTests/compact/CheckShape.xml @@ -16,7 +16,7 @@ </includes> <define> - <constant name="world_side" value="3000*cm"/> + <constant name="world_side" value="300*cm"/> <constant name="world_x" value="world_side"/> <constant name="world_y" value="world_side"/> <constant name="world_z" value="world_side"/> diff --git a/examples/ClientTests/compact/Check_Shape_TruncatedTube.xml b/examples/ClientTests/compact/Check_Shape_TruncatedTube.xml index f89db3fc123a54cedbc08cd762352f845dcd7220..362b5c049f811deb756794beebf965d81d74e0d7 100644 --- a/examples/ClientTests/compact/Check_Shape_TruncatedTube.xml +++ b/examples/ClientTests/compact/Check_Shape_TruncatedTube.xml @@ -5,11 +5,6 @@ <detectors> <detector id="1" name="Shape_TruncatedTube" type="DD4hep_TestShape_Creator"> - <check vis="Shape1_vis"> - <shape type="Box" dx="30*cm" dy="20*cm" dz="10*cm"/> - <position x="30" y="30" z="30"/> - <rotation x="0" y="0" z="0"/> - </check> <check vis="Shape1_vis"> <shape type="TruncatedTube" dz="50*cm" rmin="20*cm" rmax="40*cm" startphi="0*deg" deltaphi="90*deg" @@ -43,8 +38,8 @@ </check> --> - <test type="DD4hep_Mesh_Verifier" ref="${DD4hepExamplesINSTALL}/examples/ClientTests/ref/Ref_TruncatedTube.txt" create="CheckShape_create"/> - <ntest type="DD4hep_Mesh_Verifier" ref="${DD4hepExamplesINSTALL}/examples/ClientTests/ref/Ref_TruncatedTube.txt" create="1"/> + <ntest type="DD4hep_Mesh_Verifier" ref="${DD4hepExamplesINSTALL}/examples/ClientTests/ref/Ref_TruncatedTube.txt" create="CheckShape_create"/> + <test type="DD4hep_Mesh_Verifier" ref="${DD4hepExamplesINSTALL}/examples/ClientTests/ref/Ref_TruncatedTube.txt" create="1"/> </detector> </detectors> </lccdd> diff --git a/examples/DDCAD/compact/Check_Shape_Collada_duck.xml b/examples/DDCAD/compact/Check_Shape_Collada_duck.xml index b1a1aa8bda1adffce76534a1cd79de84a205bc2f..ad9f18d6296c0e332248cf4489cc68327b369a41 100644 --- a/examples/DDCAD/compact/Check_Shape_Collada_duck.xml +++ b/examples/DDCAD/compact/Check_Shape_Collada_duck.xml @@ -8,7 +8,7 @@ <check vis="Shape1_vis"> <shape type="CAD_Shape" ref="${DD4hepExamplesINSTALL}/examples/DDCAD/models/Collada/duck.dae" mesh="0"/> </check> - <test type="DD4hep_Mesh_Verifier" ref="${DD4hepExamplesINSTALL}/examples/DDCAD/ref/Ref_Collada_duck.txt" create="CheckShape_create"/> + <btest type="DD4hep_Mesh_Verifier" ref="${DD4hepExamplesINSTALL}/examples/DDCAD/ref/Ref_Collada_duck.txt" create="CheckShape_create"/> </detector> </detectors> </lccdd>