File indexing completed on 2025-01-18 09:14:06
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <DD4hep/detail/SegmentationsInterna.h>
0016 #include <DDDigi/segmentations/CartesianGridXYZ.h>
0017 #include <DDDigi/segmentations/SegmentationScanner.h>
0018
0019
0020 #if 0
0021
0022 namespace dd4hep {
0023
0024
0025 namespace digi {
0026
0027 template <>
0028 void init_segmentation_data<CartesianGridXYZ>(segmentation_data<CartesianGridXYZ>& data,
0029 const Segmentation& seg)
0030 {
0031 CartesianGridXYZHandle xyz_seg = seg;
0032 const auto& x_f = (*seg.decoder())["x"];
0033 const auto& y_f = (*seg.decoder())["y"];
0034 const auto& z_f = (*seg.decoder())["z"];
0035 data.segmentation_xyz = xyz_seg->implementation;
0036 data.x_grid_size = data.segmentation_xyz->gridSizeX();
0037 data.y_grid_size = data.segmentation_xyz->gridSizeY();
0038 data.z_grid_size = data.segmentation_xyz->gridSizeZ();
0039 data.x_offset = data.segmentation_xyz->offsetX();
0040 data.y_offset = data.segmentation_xyz->offsetY();
0041 data.z_offset = data.segmentation_xyz->offsetZ();
0042 data.x_f_offset = x_f.offset();
0043 data.y_f_offset = y_f.offset();
0044 data.z_f_offset = z_f.offset();
0045 data.x_mask = x_f.mask();
0046 data.y_mask = y_f.mask();
0047 data.z_mask = z_f.mask();
0048 }
0049
0050 template <typename SEGMENTATION, typename SOLID> void
0051 CellScanner<SEGMENTATION,SOLID>::operator()(DigiContext& ct,
0052 PlacedVolume pv,
0053 VolumeID vid,
0054 const cell_handler_t& cell_handler) {
0055 typename self_t::cell_data_t e;
0056 e.placement = pv;
0057 e.volume = pv.volume();
0058 e.solid = e.volume.solid();
0059 Box b = e.solid;
0060 double pos[3] = {0e0, 0e0, 0e0};
0061 typename self_t::solid_t sol = e.solid;
0062 long nx = 2e0 * b->GetDX() / segment.x_grid_size;
0063 long ny = 2e0 * b->GetDY() / segment.y_grid_size;
0064 long nz = 2e0 * b->GetDZ() / segment.z_grid_size;
0065 for ( e.x_bin = 0; e.x_bin < nx; ++e.x_bin ) {
0066 pos[0] = (e.x_bin + 0.5) * segment.x_grid_size;
0067 e.x_cid = (e.x_bin << segment.x_f_offset) & segment.x_mask;
0068 for ( e.y_bin = 0; e.y_bin < ny; ++e.y_bin ) {
0069 pos[1] = (e.x_bin + 0.5) * segment.x_grid_size;
0070 e.y_cid = (e.y_bin << segment.y_f_offset) & segment.y_mask;
0071 for ( e.z_bin=0; e.z_bin < nz; ++e.z_bin ) {
0072 e.z_cid = (e.z_bin << segment.z_f_offset) & segment.z_mask;
0073 pos[2] = (e.z_bin + 0.5) * segment.z_grid_size;
0074 if ( !sol->Contains(pos) ) continue;
0075 e.cell_id = vid | e.x_cid | e.y_cid | e.z_cid;
0076
0077 cell_handler(ct, *this, e);
0078 }
0079 }
0080 }
0081 }
0082 }
0083 }
0084
0085
0086 namespace dd4hep {
0087
0088
0089 namespace digi {
0090
0091 template <> void
0092 CellScanner<CartesianGridXYZ,Box>::operator()(DigiContext& ct,
0093 PlacedVolume pv,
0094 VolumeID vid,
0095 const cell_handler_t& cell_handler)
0096 {
0097 cell_data_t e;
0098 e.placement = pv;
0099 e.volume = pv.volume();
0100 e.solid = e.volume.solid();
0101 Box b = e.solid;
0102 long nx = 2e0 * b->GetDX() / segment.x_grid_size;
0103 long ny = 2e0 * b->GetDY() / segment.y_grid_size;
0104 long nz = 2e0 * b->GetDZ() / segment.z_grid_size;
0105 for ( e.x_bin=0; e.x_bin < nx; ++e.x_bin ) {
0106 e.x_cid = (e.x_bin << segment.x_f_offset) & segment.x_mask;
0107 for ( e.y_bin=0; e.y_bin < ny; ++e.y_bin ) {
0108 e.y_cid = (e.y_bin << segment.y_f_offset) & segment.y_mask;
0109 for ( e.z_bin=0; e.z_bin < nz; ++e.z_bin ) {
0110 e.z_cid = (e.z_bin << segment.z_f_offset) & segment.z_mask;
0111 e.cell_id = vid | e.x_cid | e.y_cid | e.y_cid;
0112 cell_handler(ct, *this, e);
0113 }
0114 }
0115 }
0116 }
0117 }
0118 }
0119
0120 DECLARE_DIGICELLSCANNER(DigiCellScanner,CartesianGridXYZ,Box)
0121
0122 namespace dd4hep {
0123 typedef IntersectionSolid Intersection;
0124 typedef SubtractionSolid Subtraction;
0125 typedef UnionSolid Union;
0126 }
0127 DECLARE_DIGICELLSCANNER(DigiCellScanner,CartesianGridXYZ,Intersection)
0128 DECLARE_DIGICELLSCANNER(DigiCellScanner,CartesianGridXYZ,Subtraction)
0129 DECLARE_DIGICELLSCANNER(DigiCellScanner,CartesianGridXYZ,Union)
0130 #endif
0131