File indexing completed on 2025-01-18 09:14:56
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)));
0028 xml_dim_t rot (x_det.child(_U(rotation)));
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(Rotation3D(RotationZYX(rot.z(),rot.y(),rot.x())),Position(pos.x(),pos.y(),pos.z()));
0034 PlacedVolume phv = mother.placeVolume(det_vol,transform);
0035
0036 det_vol.setVisAttributes(description, x_det.visStr());
0037 det_vol.setLimitSet(description, x_det.limitsStr());
0038 det_vol.setRegion(description, x_det.regionStr());
0039 if ( x_det.isSensitive() ) {
0040 SensitiveDetector sd = sens;
0041 xml_dim_t sd_typ = x_det.child(_U(sensitive));
0042 det_vol.setSensitiveDetector(sens);
0043 sd.setType(sd_typ.typeStr());
0044 }
0045 if ( x_det.hasAttr(_U(id)) ) {
0046 phv.addPhysVolID("system",x_det.id());
0047 }
0048 det.setPlacement(phv);
0049 return det;
0050 }
0051
0052
0053 DECLARE_DETELEMENT(Lhe_BoxSegment,create_element)