diff --git a/DDCore/include/DD4hep/CartesianGridXY.h b/DDCore/include/DD4hep/CartesianGridXY.h index 1efcffea4666892b7c942a4315106cf3182668a5..9f31f7887b5f1e0b915adafb65fbe879e28485fd 100644 --- a/DDCore/include/DD4hep/CartesianGridXY.h +++ b/DDCore/include/DD4hep/CartesianGridXY.h @@ -87,10 +87,18 @@ namespace DD4hep { double gridSizeX() const; /// access the grid size in Y double gridSizeY() const; + /// set the grid size in X + void setGridSizeX(double cellSize) const; + /// set the grid size in Y + void setGridSizeY(double cellSize) const; /// access the coordinate offset in X double offsetX() const; /// access the coordinate offset in Y double offsetY() const; + /// set the coordinate offset in X + void setOffsetX(double offset) const; + /// set the coordinate offset in Y + void setOffsetY(double offset) const; /// access the field name used for X const std::string& fieldNameX() const; /// access the field name used for Y diff --git a/DDCore/include/DD4hep/CartesianGridXYZ.h b/DDCore/include/DD4hep/CartesianGridXYZ.h index 6953184168d568aa22d9c8141fc10f65a74e7ee8..4e5dce48f0ad324d32ff1f614a14dfd4c9df007c 100644 --- a/DDCore/include/DD4hep/CartesianGridXYZ.h +++ b/DDCore/include/DD4hep/CartesianGridXYZ.h @@ -87,12 +87,24 @@ namespace DD4hep { double gridSizeY() const; /// access the grid size in Z double gridSizeZ() const; + /// set the grid size in X + void setGridSizeX(double cellSize) const; + /// set the grid size in Y + void setGridSizeY(double cellSize) const; + /// set the grid size in Z + void setGridSizeZ(double cellSize) const; /// access the coordinate offset in X double offsetX() const; /// access the coordinate offset in Y double offsetY() const; /// access the coordinate offset in Z double offsetZ() const; + /// set the coordinate offset in X + void setOffsetX(double offset) const; + /// set the coordinate offset in Y + void setOffsetY(double offset) const; + /// set the coordinate offset in Z + void setOffsetZ(double offset) const; /// access the field name used for X const std::string& fieldNameX() const; /// access the field name used for Y diff --git a/DDCore/include/DD4hep/CartesianGridXZ.h b/DDCore/include/DD4hep/CartesianGridXZ.h index df9de68133747d82313673c10f45ec8d1ad8bad2..6da8b60c0d1fae3333b51fcc7ef4f75a77698396 100644 --- a/DDCore/include/DD4hep/CartesianGridXZ.h +++ b/DDCore/include/DD4hep/CartesianGridXZ.h @@ -86,10 +86,18 @@ namespace DD4hep { double gridSizeX() const; /// access the grid size in Z double gridSizeZ() const; + /// set the grid size in X + void setGridSizeX(double cellSize) const; + /// set the grid size in Z + void setGridSizeZ(double cellSize) const; /// access the coordinate offset in X double offsetX() const; /// access the coordinate offset in Z double offsetZ() const; + /// set the coordinate offset in X + void setOffsetX(double offset) const; + /// set the coordinate offset in Z + void setOffsetZ(double offset) const; /// access the field name used for X const std::string& fieldNameX() const; /// access the field name used for Z diff --git a/DDCore/include/DD4hep/CartesianGridYZ.h b/DDCore/include/DD4hep/CartesianGridYZ.h index 61c4727fd9102a1786b0f2f81303ca0eb110640b..13d4a3e834d5b46bb70586b588d7bb92f241c69d 100644 --- a/DDCore/include/DD4hep/CartesianGridYZ.h +++ b/DDCore/include/DD4hep/CartesianGridYZ.h @@ -81,18 +81,22 @@ namespace DD4hep { Position position(const CellID& cellID) const; /// determine the cell ID based on the position CellID cellID(const Position& local, const Position& global, const VolumeID& volID) const; - /// access the grid size in X - double gridSizeX() const; /// access the grid size in Y double gridSizeY() const; /// access the grid size in Z double gridSizeZ() const; - /// access the coordinate offset in X - double offsetX() const; + /// set the grid size in Y + void setGridSizeY(double cellSize) const; + /// set the grid size in Z + void setGridSizeZ(double cellSize) const; /// access the coordinate offset in Y double offsetY() const; /// access the coordinate offset in Z double offsetZ() const; + /// set the coordinate offset in Y + void setOffsetY(double offset) const; + /// set the coordinate offset in Z + void setOffsetZ(double offset) const; /// access the field name used for X const std::string& fieldNameX() const; /// access the field name used for Y diff --git a/DDCore/include/DD4hep/Handle.inl b/DDCore/include/DD4hep/Handle.inl index 1e2cdf2385441a9ecca3b00f913c8fb502efa71c..deb942d5d5482a6c8d68dd24020f24a4487fdc4c 100644 --- a/DDCore/include/DD4hep/Handle.inl +++ b/DDCore/include/DD4hep/Handle.inl @@ -46,11 +46,24 @@ namespace DD4hep { } /* End namespace DD4hep */ +#if 0 +#include <iostream> + + std::cout << "element:" << (void*)m_element << std::endl;\ + std::cout << "type: " << (char*)(m_element ? typeName(typeid(*m_element)).c_str() : "---") << std::endl;\ + std::cout << "type: " << (void*)(m_element ? &typeid(*m_element) : 0) << std::endl;\ + std::cout << "target: " << typeName(typeid(X)) << std::endl;\ + std::cout << "target: " << (void*)&typeid(X) << std::endl;\ + std::cout << "cast: " << dynamic_cast<X*>((TObject*)m_element) << std::endl;\ + std::cout << "cast: " << dynamic_cast<X*>(m_element) << std::endl;\ + +#endif + #define DD4HEP_INSTANTIATE_HANDLE(X) \ namespace DD4hep { \ template <> void Handle<X>::verifyObject() const { \ increment_object_validations(); \ - if (m_element && dynamic_cast<X*>((TObject*)m_element) == 0) { \ + if (m_element && dynamic_cast<X*>(m_element) == 0) { \ bad_assignment(typeid(*m_element), typeid(X)); \ } \ }} \ diff --git a/DDCore/include/DD4hep/PolarGridRPhi.h b/DDCore/include/DD4hep/PolarGridRPhi.h index caf9a0f7ec63ee65dcd96d8a5cd4935775f645db..d8cf860db5778c33fac55cddca91c3b84310aacb 100644 --- a/DDCore/include/DD4hep/PolarGridRPhi.h +++ b/DDCore/include/DD4hep/PolarGridRPhi.h @@ -83,10 +83,18 @@ namespace DD4hep { double gridSizeR() const; /// access the grid size in Phi double gridSizePhi() const; + /// set the grid size in R + void setGridSizeR(double cellSize) const; + /// set the grid size in Phi + void setGridSizePhi(double cellSize) const; /// access the coordinate offset in R double offsetR() const; /// access the coordinate offset in Phi double offsetPhi() const; + /// set the coordinate offset in R + void setOffsetR(double offset) const; + /// set the coordinate offset in Phi + void setOffsetPhi(double offset) const; /// access the field name used for R const std::string& fieldNameR() const; /// access the field name used for Phi diff --git a/DDCore/include/DD4hep/PolarGridRPhi2.h b/DDCore/include/DD4hep/PolarGridRPhi2.h index 5eaa808f0bbdf4aadc073f78e5c1af87ab53e3bd..7fbb67fd3d0e90c240dca1de4289a27c5dcaeeec 100644 --- a/DDCore/include/DD4hep/PolarGridRPhi2.h +++ b/DDCore/include/DD4hep/PolarGridRPhi2.h @@ -87,11 +87,32 @@ namespace DD4hep { double offsetR() const; /// access the coordinate offset in Phi double offsetPhi() const; + /// set the coordinate offset in R + void setOffsetR(double offset) const; + /// set the coordinate offset in Phi + void setOffsetPhi(double offset) const; /// access the grid size in R std::vector<double> gridRValues() const; /// access the grid size in Phi std::vector<double> gridPhiValues() const; - /// access the field name used for R + /// set the grid Boundaries in R + void setGridSizeR(double cellSize, int rID) const; + /// set the grid size in Phi + void setGridSizePhi(double cellSize, int phiID) const; + /// set the grid boundaries for R + /** @param rValues The boundaries of the segments in radius, + * the first value is the lower boundary of the first bin, + * the highest value is the upper boundary of the last bin + */ + void setGridRValues(std::vector<double> const& rValues) const; + /// set the grid size in Phi for each bin in R + /** @param phiValues The size in phi for each bin in R, + * this vector is one smaller than the vector + * for PolarGridRPhi2::setGridRValues + */ + void setGridPhiValues(std::vector<double> const& phiValues) const; + + /// access the field name used for R const std::string& fieldNameR() const; /// access the field name used for Phi const std::string& fieldNamePhi() const; diff --git a/DDCore/include/DD4hep/objects/SegmentationsInterna.h b/DDCore/include/DD4hep/objects/SegmentationsInterna.h index db063b514b2e443fa9f83971284a203b50213c79..4f78a962fcff5c2427716c650110ba7ae52d1c5a 100644 --- a/DDCore/include/DD4hep/objects/SegmentationsInterna.h +++ b/DDCore/include/DD4hep/objects/SegmentationsInterna.h @@ -56,6 +56,7 @@ namespace DD4hep { const std::string& name() const; /// Set the segmentation name void setName(const std::string& value); + /// Access the segmentation type const std::string& type() const; /// Access the description of the segmentation @@ -83,6 +84,7 @@ namespace DD4hep { /// Calculates the neighbours of the given cell ID and adds them to the list of neighbours void neighbours(const CellID& cellID, std::set<CellID>& neighbours) const; + /** Data members. */ /// Magic word to check object integrity unsigned long magic; /// Flag to use segmentation for hit positioning diff --git a/DDCore/src/CartesianGridXY.cpp b/DDCore/src/CartesianGridXY.cpp index 7f75342d22d172563fe8b50223ed65a75dd2edf5..51aa81712a486c535c47b6bde6740dc483d53cb7 100644 --- a/DDCore/src/CartesianGridXY.cpp +++ b/DDCore/src/CartesianGridXY.cpp @@ -44,6 +44,16 @@ double CartesianGridXY::gridSizeY() const { return access()->implementation->gridSizeY(); } +/// set the grid size in X +void CartesianGridXY::setGridSizeX(double cellSize) const { + access()->implementation->setGridSizeX(cellSize); +} + +/// set the grid size in Y +void CartesianGridXY::setGridSizeY(double cellSize) const { + access()->implementation->setGridSizeY(cellSize); +} + /// access the coordinate offset in X double CartesianGridXY::offsetX() const { return access()->implementation->offsetX(); @@ -54,6 +64,16 @@ double CartesianGridXY::offsetY() const { return access()->implementation->offsetY(); } +/// set the coordinate offset in X +void CartesianGridXY::setOffsetX(double offset) const { + access()->implementation->setOffsetX(offset); +} + +/// set the coordinate offset in Y +void CartesianGridXY::setOffsetY(double offset) const { + access()->implementation->setOffsetY(offset); +} + /// access the field name used for X const string& CartesianGridXY::fieldNameX() const { return access()->implementation->fieldNameX(); diff --git a/DDCore/src/CartesianGridXYZ.cpp b/DDCore/src/CartesianGridXYZ.cpp index 50b9ccb197bf351cfbacc91cf105ae286d5b2e94..de16d3be9e32b7438a2efb7974961cbe273a8caf 100644 --- a/DDCore/src/CartesianGridXYZ.cpp +++ b/DDCore/src/CartesianGridXYZ.cpp @@ -49,6 +49,21 @@ double CartesianGridXYZ::gridSizeZ() const { return access()->implementation->gridSizeZ(); } +/// set the grid size in X +void CartesianGridXYZ::setGridSizeX(double cellSize) const { + access()->implementation->setGridSizeX(cellSize); +} + +/// set the grid size in Y +void CartesianGridXYZ::setGridSizeY(double cellSize) const { + access()->implementation->setGridSizeY(cellSize); +} + +/// set the grid size in Z +void CartesianGridXYZ::setGridSizeZ(double cellSize) const { + access()->implementation->setGridSizeZ(cellSize); +} + /// access the coordinate offset in X double CartesianGridXYZ::offsetX() const { return access()->implementation->offsetX(); @@ -64,6 +79,21 @@ double CartesianGridXYZ::offsetZ() const { return access()->implementation->offsetZ(); } +/// set the coordinate offset in X +void CartesianGridXYZ::setOffsetX(double offset) const { + access()->implementation->setOffsetX(offset); +} + +/// set the coordinate offset in Y +void CartesianGridXYZ::setOffsetY(double offset) const { + access()->implementation->setOffsetY(offset); +} + +/// set the coordinate offset in Z +void CartesianGridXYZ::setOffsetZ(double offset) const { + access()->implementation->setOffsetZ(offset); +} + /// access the field name used for X const string& CartesianGridXYZ::fieldNameX() const { return access()->implementation->fieldNameX(); diff --git a/DDCore/src/CartesianGridXZ.cpp b/DDCore/src/CartesianGridXZ.cpp index f28a75c0af87c41485d94c08358a69765bfb2490..765c156e6a52ce29ee7b6520e54e01cd8d243ef4 100644 --- a/DDCore/src/CartesianGridXZ.cpp +++ b/DDCore/src/CartesianGridXZ.cpp @@ -44,6 +44,16 @@ double CartesianGridXZ::gridSizeZ() const { return access()->implementation->gridSizeZ(); } +/// set the grid size in X +void CartesianGridXZ::setGridSizeX(double cellSize) const { + access()->implementation->setGridSizeX(cellSize); +} + +/// set the grid size in Z +void CartesianGridXZ::setGridSizeZ(double cellSize) const { + access()->implementation->setGridSizeZ(cellSize); +} + /// access the coordinate offset in X double CartesianGridXZ::offsetX() const { return access()->implementation->offsetX(); @@ -54,6 +64,16 @@ double CartesianGridXZ::offsetZ() const { return access()->implementation->offsetZ(); } +/// set the coordinate offset in X +void CartesianGridXZ::setOffsetX(double offset) const { + access()->implementation->setOffsetX(offset); +} + +/// set the coordinate offset in Z +void CartesianGridXZ::setOffsetZ(double offset) const { + access()->implementation->setOffsetZ(offset); +} + /// access the field name used for X const string& CartesianGridXZ::fieldNameX() const { return access()->implementation->fieldNameX(); diff --git a/DDCore/src/CartesianGridYZ.cpp b/DDCore/src/CartesianGridYZ.cpp index 7e9a590583af9416d21ba1beb823fdbda536a07a..9e3cb22ec0f481a6e722da6ec2b4c2578c2e8315 100644 --- a/DDCore/src/CartesianGridYZ.cpp +++ b/DDCore/src/CartesianGridYZ.cpp @@ -44,6 +44,16 @@ double CartesianGridYZ::gridSizeZ() const { return access()->implementation->gridSizeZ(); } +/// set the grid size in Y +void CartesianGridYZ::setGridSizeY(double cellSize) const { + access()->implementation->setGridSizeY(cellSize); +} + +/// set the grid size in Z +void CartesianGridYZ::setGridSizeZ(double cellSize) const { + access()->implementation->setGridSizeZ(cellSize); +} + /// access the coordinate offset in Y double CartesianGridYZ::offsetY() const { return access()->implementation->offsetY(); @@ -54,6 +64,16 @@ double CartesianGridYZ::offsetZ() const { return access()->implementation->offsetZ(); } +/// set the coordinate offset in Y +void CartesianGridYZ::setOffsetY(double offset) const { + access()->implementation->setOffsetY(offset); +} + +/// set the coordinate offset in Z +void CartesianGridYZ::setOffsetZ(double offset) const { + access()->implementation->setOffsetZ(offset); +} + /// access the field name used for Y const string& CartesianGridYZ::fieldNameY() const { return access()->implementation->fieldNameY(); diff --git a/DDCore/src/PolarGridRPhi.cpp b/DDCore/src/PolarGridRPhi.cpp index 416e372b4c1895c26fe67e9dca0478b4ccf45d74..e7bfe7b5e6a61960fcc6add59684acffddd260bd 100644 --- a/DDCore/src/PolarGridRPhi.cpp +++ b/DDCore/src/PolarGridRPhi.cpp @@ -54,6 +54,26 @@ double PolarGridRPhi::offsetPhi() const { return access()->implementation->offsetPhi(); } +/// set the coordinate offset in R +void PolarGridRPhi::setOffsetR(double offset) const { + access()->implementation->setOffsetR(offset); +} + +/// set the coordinate offset in Phi +void PolarGridRPhi::setOffsetPhi(double offset) const { + access()->implementation->setOffsetPhi(offset); +} + +/// set the grid size in R +void PolarGridRPhi::setGridSizeR(double cellSize) const { + access()->implementation->setGridSizeR(cellSize); +} + +/// set the grid size in Phi +void PolarGridRPhi::setGridSizePhi(double cellSize) const { + access()->implementation->setGridSizePhi(cellSize); +} + /// access the field name used for R const string& PolarGridRPhi::fieldNameR() const { return access()->implementation->fieldNameR(); diff --git a/DDCore/src/PolarGridRPhi2.cpp b/DDCore/src/PolarGridRPhi2.cpp index 47e18d1de2a3328d3b2204405a80f777e3f846fb..3717e530dda3966c5707dc080c835051ebc39fb0 100644 --- a/DDCore/src/PolarGridRPhi2.cpp +++ b/DDCore/src/PolarGridRPhi2.cpp @@ -43,6 +43,25 @@ vector<double> PolarGridRPhi2::gridRValues() const { vector<double> PolarGridRPhi2::gridPhiValues() const { return access()->implementation->gridPhiValues(); } +/// set the grid Boundaries in R +void PolarGridRPhi2::setGridSizeR(double cellSize, int rID) const { + access()->implementation->setGridRValues(cellSize,rID); +} + +/// set the grid size in Phi +void PolarGridRPhi2::setGridSizePhi(double cellSize, int phiID) const { + access()->implementation->setGridSizePhi(cellSize,phiID); +} + +/// set the grid boundaries for R +void PolarGridRPhi2::setGridRValues(std::vector<double> const& rValues) const { + access()->implementation->setGridRValues(rValues); +} + +/// set the grid size in Phi for each bin in R +void PolarGridRPhi2::setGridPhiValues(std::vector<double> const& phiValues) const { + access()->implementation->setGridPhiValues(phiValues); +} /// access the coordinate offset in R double PolarGridRPhi2::offsetR() const { @@ -54,6 +73,16 @@ double PolarGridRPhi2::offsetPhi() const { return access()->implementation->offsetPhi(); } +/// set the coordinate offset in R +void PolarGridRPhi2::setOffsetR(double offset) const { + access()->implementation->setOffsetR(offset); +} + +/// set the coordinate offset in Phi +void PolarGridRPhi2::setOffsetPhi(double offset) const { + access()->implementation->setOffsetPhi(offset); +} + /// access the field name used for R const string& PolarGridRPhi2::fieldNameR() const { return access()->implementation->fieldNameR(); diff --git a/DDCore/src/World.cpp b/DDCore/src/World.cpp index 064774816e50309b5548b4b602cf47285624b09f..c3417d15009e2010d4198abcd67df5ef88e2a517 100644 --- a/DDCore/src/World.cpp +++ b/DDCore/src/World.cpp @@ -40,4 +40,3 @@ World::AlignmentsLoader& World::alignmentsLoader() const { LCDD& World::lcdd() const { return *(access()->lcdd); } - diff --git a/DDTest/CMakeLists.txt b/DDTest/CMakeLists.txt index ed7e136df2063ef7c0111cb3fdae9c4365e28e93..c090767d5739dc756ded6d16de31c79d964e307a 100644 --- a/DDTest/CMakeLists.txt +++ b/DDTest/CMakeLists.txt @@ -23,12 +23,13 @@ dd4hep_add_test_reg ( test_surface BUILD_EXEC REGEX_FAIL "TEST_FAILE EXEC_ARGS file:${CMAKE_CURRENT_SOURCE_DIR}/units.xml ) dd4hep_add_test_reg ( test_bitfield64 BUILD_EXEC REGEX_FAIL "TEST_FAILED" ) -dd4hep_add_test_reg ( test_DetType BUILD_EXEC REGEX_FAIL "TEST_FAILED" ) +dd4hep_add_test_reg ( test_DetType BUILD_EXEC REGEX_FAIL "TEST_FAILED" ) dd4hep_add_test_reg ( test_PolarGridRPhi2 BUILD_EXEC REGEX_FAIL "TEST_FAILED" ) dd4hep_add_test_reg ( test_cellDimensions BUILD_EXEC REGEX_FAIL "TEST_FAILED" ) dd4hep_add_test_reg ( test_cellDimensionsRPhi2 BUILD_EXEC REGEX_FAIL "TEST_FAILED" ) +dd4hep_add_test_reg ( test_segmentationHandles BUILD_EXEC REGEX_FAIL "TEST_FAILED" ) if (DD4HEP_USE_GEANT4) dd4hep_add_test_reg ( test_EventReaders BUILD_EXEC REGEX_FAIL "TEST_FAILED" EXEC_ARGS ${CMAKE_CURRENT_SOURCE_DIR} ) -endif() \ No newline at end of file +endif() diff --git a/DDTest/src/test_segmentationHandles.cc b/DDTest/src/test_segmentationHandles.cc new file mode 100644 index 0000000000000000000000000000000000000000..a281589a7781ecf0f2e0a1f10d6c5eaf7086007a --- /dev/null +++ b/DDTest/src/test_segmentationHandles.cc @@ -0,0 +1,115 @@ +#include "DD4hep/Segmentations.h" +#include "DD4hep/CartesianGridXY.h" +#include "DD4hep/CartesianGridYZ.h" +#include "DD4hep/CartesianGridXZ.h" +#include "DD4hep/CartesianGridXYZ.h" +#include "DD4hep/DDTest.h" + +#include <iostream> +#include <iomanip> +#include <vector> +#include <algorithm> +#include <exception> +#include <cmath> + + +DD4hep::DDTest test = DD4hep::DDTest( "CellDimensions" ) ; +using namespace DD4hep; +using namespace DD4hep::Geometry; + +int main() { + try{ + BitField64 bf("system:8,barrel:3,layer:8,slice:5,x:16,y:16"); + Segmentation base("CartesianGridXY","Test",&bf); + CartesianGridXY seg(base); + const double xSize=12343.43243; + const double ySize=M_PI; + + test( seg.isValid(), " Assignment from Segmentation -> "+typeName(typeid(seg))+" worked" ); + + seg.setGridSizeX(xSize); + seg.setGridSizeY(ySize); + + DD4hep::DDSegmentation::VolumeID volID = 0; + + test( fabs(seg.cellDimensions(volID)[0] - xSize ) < 1e-11, " CG_XY: Dimension for X" ); + test( fabs(seg.cellDimensions(volID)[1] - ySize ) < 1e-11, " CG_XY: Dimension for Y" ); + + } catch( std::exception &e ){ + test.log( e.what() ); + test.error( "exception occurred" ); + } + + try{ + BitField64 bf("system:8,barrel:3,layer:8,slice:5,x:16,z:16"); + Segmentation base("CartesianGridXZ","Test",&bf); + CartesianGridXZ seg(base); + + const double xSize=12343.43243; + const double zSize=M_PI; + + test( seg.isValid(), " Assignment from Segmentation -> "+typeName(typeid(seg))+" worked" ); + + seg.setGridSizeX(xSize); + seg.setGridSizeZ(zSize); + + VolumeID volID = 0; + + test( fabs(seg.cellDimensions(volID)[0] - xSize ) < 1e-11, " CG_XZ: Dimension for X" ); + test( fabs(seg.cellDimensions(volID)[1] - zSize ) < 1e-11, " CG_XZ: Dimension for Z" ); + + } catch( std::exception &e ){ + test.log( e.what() ); + test.error( "exception occurred" ); + } + + try{ + BitField64 bf("system:8,barrel:3,layer:8,slice:5,y:16,z:16"); + Segmentation base("CartesianGridYZ","Test",&bf); + CartesianGridYZ seg = base; + + test( seg.isValid(), " Assignment from Segmentation -> "+typeName(typeid(seg))+" worked" ); + + const double ySize=12343.43243; + const double zSize=M_PI; + + seg.setGridSizeY(ySize); + seg.setGridSizeZ(zSize); + + DD4hep::DDSegmentation::VolumeID volID = 0; + + test( fabs(seg.cellDimensions(volID)[0] - ySize ) < 1e-11, " CG_YZ: Dimension for Y" ); + test( fabs(seg.cellDimensions(volID)[1] - zSize ) < 1e-11, " CG_YZ: Dimension for Z" ); + + } catch( std::exception &e ){ + test.log( e.what() ); + test.error( "exception occurred" ); + } + + try{ + BitField64 bf("system:8,barrel:3,layer:8,slice:7,x:10,y:10,z:10"); + Segmentation base("CartesianGridXYZ","Test",&bf); + CartesianGridXYZ seg = base; + + test( seg.isValid(), " Assignment from Segmentation -> "+typeName(typeid(seg))+" worked" ); + + const double xSize=42.24; + const double ySize=12343.43243; + const double zSize=M_PI; + + seg.setGridSizeX(xSize); + seg.setGridSizeY(ySize); + seg.setGridSizeZ(zSize); + + DD4hep::DDSegmentation::VolumeID volID = 0; + + test( fabs(seg.cellDimensions(volID)[0] - xSize ) < 1e-11, " CG_XYZ: Dimension for X" ); + test( fabs(seg.cellDimensions(volID)[1] - ySize ) < 1e-11, " CG_XYZ: Dimension for Y" ); + test( fabs(seg.cellDimensions(volID)[2] - zSize ) < 1e-11, " CG_XYZ: Dimension for Z" ); + + } catch( std::exception &e ){ + test.log( e.what() ); + test.error( "exception occurred" ); + } + return 0; +}