File indexing completed on 2025-01-18 09:14:36
0001 #include "DDSegmentation/Segmentation.h"
0002 #include "DDSegmentation/CartesianGridXY.h"
0003 #include "DDSegmentation/CartesianGridYZ.h"
0004 #include "DDSegmentation/CartesianGridXZ.h"
0005 #include "DDSegmentation/CartesianGridXYZ.h"
0006 #include "DD4hep/DDTest.h"
0007
0008 #include <iostream>
0009 #include <iomanip>
0010 #include <vector>
0011 #include <algorithm>
0012 #include <exception>
0013 #include <cmath>
0014
0015
0016 int main() {
0017
0018 dd4hep::DDTest test( "CellDimensions" ) ;
0019
0020 try{
0021
0022 dd4hep::DDSegmentation::CartesianGridXY seg("system:8,barrel:3,layer:8,slice:5,x:16,y:16");
0023
0024 const double xSize=12343.43243;
0025 const double ySize=M_PI;
0026
0027 seg.setGridSizeX(xSize);
0028 seg.setGridSizeY(ySize);
0029
0030 dd4hep::DDSegmentation::VolumeID volID = 0;
0031
0032 test( fabs(seg.cellDimensions(volID)[0] - xSize ) < 1e-11, " CG_XY: Dimension for X" );
0033 test( fabs(seg.cellDimensions(volID)[1] - ySize ) < 1e-11, " CG_XY: Dimension for Y" );
0034
0035 } catch( std::exception &e ){
0036
0037
0038 test.log( e.what() );
0039 test.error( "exception occurred" );
0040 }
0041
0042 try{
0043
0044 dd4hep::DDSegmentation::CartesianGridXZ seg("system:8,barrel:3,layer:8,slice:5,x:16,z:16");
0045
0046 const double xSize=12343.43243;
0047 const double zSize=M_PI;
0048
0049 seg.setGridSizeX(xSize);
0050 seg.setGridSizeZ(zSize);
0051
0052 dd4hep::DDSegmentation::VolumeID volID = 0;
0053
0054 test( fabs(seg.cellDimensions(volID)[0] - xSize ) < 1e-11, " CG_XZ: Dimension for X" );
0055 test( fabs(seg.cellDimensions(volID)[1] - zSize ) < 1e-11, " CG_XZ: Dimension for Z" );
0056
0057 } catch( std::exception &e ){
0058
0059
0060 test.log( e.what() );
0061 test.error( "exception occurred" );
0062 }
0063
0064 try{
0065
0066 dd4hep::DDSegmentation::CartesianGridYZ seg("system:8,barrel:3,layer:8,slice:5,y:16,z:16");
0067
0068 const double ySize=12343.43243;
0069 const double zSize=M_PI;
0070
0071 seg.setGridSizeY(ySize);
0072 seg.setGridSizeZ(zSize);
0073
0074 dd4hep::DDSegmentation::VolumeID volID = 0;
0075
0076 test( fabs(seg.cellDimensions(volID)[0] - ySize ) < 1e-11, " CG_YZ: Dimension for Y" );
0077 test( fabs(seg.cellDimensions(volID)[1] - zSize ) < 1e-11, " CG_YZ: Dimension for Z" );
0078
0079 } catch( std::exception &e ){
0080
0081
0082 test.log( e.what() );
0083 test.error( "exception occurred" );
0084 }
0085
0086 try{
0087
0088 dd4hep::DDSegmentation::CartesianGridXYZ seg("system:8,barrel:3,layer:8,slice:7,x:10,y:10,z:10");
0089
0090 const double xSize=42.24;
0091 const double ySize=12343.43243;
0092 const double zSize=M_PI;
0093
0094 seg.setGridSizeX(xSize);
0095 seg.setGridSizeY(ySize);
0096 seg.setGridSizeZ(zSize);
0097
0098 dd4hep::DDSegmentation::VolumeID volID = 0;
0099
0100 test( fabs(seg.cellDimensions(volID)[0] - xSize ) < 1e-11, " CG_XYZ: Dimension for X" );
0101 test( fabs(seg.cellDimensions(volID)[1] - ySize ) < 1e-11, " CG_XYZ: Dimension for Y" );
0102 test( fabs(seg.cellDimensions(volID)[2] - zSize ) < 1e-11, " CG_XYZ: Dimension for Z" );
0103
0104 } catch( std::exception &e ){
0105
0106
0107 test.log( e.what() );
0108 test.error( "exception occurred" );
0109 }
0110
0111 return 0;
0112 }