File indexing completed on 2025-01-18 09:14:01
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include "DD4hep/DetFactoryHelper.h"
0018
0019 using namespace std;
0020 using namespace dd4hep;
0021 using namespace dd4hep::detail;
0022
0023 static Ref_t create_element(Detector& description, xml_h e, Ref_t sens) {
0024 xml_det_t x_det = e;
0025 string name = x_det.nameStr();
0026 xml_comp_t box (x_det.child(_U(box)));
0027 xml_dim_t pos (x_det.child(_U(position), false));
0028 xml_dim_t rot (x_det.child(_U(rotation), false));
0029 Material mat (description.material(x_det.materialStr()));
0030 DetElement det (name,x_det.id());
0031 Volume det_vol(name+"_vol",Box(box.x(),box.y(),box.z()), mat);
0032 Volume mother = description.pickMotherVolume(det);
0033 Transform3D transform;
0034
0035 if ( pos && rot ) {
0036 transform = Transform3D(Rotation3D(RotationZYX(rot.z(),rot.y(),rot.x())),
0037 Position(pos.x(),pos.y(),pos.z()));
0038 }
0039 else if ( rot ) {
0040 transform = Transform3D(Rotation3D(RotationZYX(rot.z(),rot.y(),rot.x())),
0041 Position());
0042 }
0043 else if ( pos ) {
0044 transform = Transform3D(Rotation3D(), Position(pos.x(),pos.y(),pos.z()));
0045 }
0046 PlacedVolume phv = mother.placeVolume(det_vol,transform);
0047 det_vol.setVisAttributes(description, x_det.visStr());
0048 det_vol.setLimitSet(description, x_det.limitsStr());
0049 det_vol.setRegion(description, x_det.regionStr());
0050 if ( x_det.isSensitive() ) {
0051 SensitiveDetector sd = sens;
0052 xml_dim_t sd_typ = x_det.child(_U(sensitive));
0053 det_vol.setSensitiveDetector(sens);
0054 sd.setType(sd_typ.typeStr());
0055 }
0056 if ( x_det.hasAttr(_U(id)) ) {
0057 phv.addPhysVolID("system",x_det.id());
0058 }
0059 det.setPlacement(phv);
0060 return det;
0061 }
0062
0063
0064 DECLARE_DETELEMENT(DD4hep_BoxSegment,create_element)
0065