File indexing completed on 2025-01-18 09:15:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "DD4hep/DetFactoryHelper.h"
0011 #include <XML/Helper.h>
0012
0013 using namespace std;
0014 using namespace dd4hep;
0015
0016 static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector ) {
0017
0018 using namespace ROOT::Math;
0019 xml_det_t x_det = e;
0020 string det_name = x_det.nameStr();
0021 DetElement sdet(det_name, x_det.id());
0022 Assembly assembly(det_name + "_assembly");
0023 Material m_Steel = description.material("StainlessSteel");
0024 string vis_name = x_det.visStr();
0025
0026
0027 xml::Component box_dim = x_det.child(_Unicode(dimensions_outer));
0028 double height = box_dim.attr<double>(_Unicode(y));
0029 double width = box_dim.attr<double>(_Unicode(x));
0030 double depth = box_dim.attr<double>(_Unicode(z));
0031
0032 Box box_outer(width, height, depth);
0033
0034
0035 xml::Component box_dim_2 = x_det.child(_Unicode(dimensions_inner));
0036 double height_2 = box_dim_2.attr<double>(_Unicode(y));
0037 double width_2 = box_dim_2.attr<double>(_Unicode(x));
0038 double depth_2 = box_dim_2.attr<double>(_Unicode(z));
0039
0040 Box box_inner(width_2, height_2, depth_2);
0041
0042
0043 xml::Component box_pos = x_det.child(_Unicode(position));
0044 double x = box_pos.attr<double>(_Unicode(x));
0045 double y = box_pos.attr<double>(_Unicode(y));
0046 double z = box_pos.attr<double>(_Unicode(z));
0047
0048
0049 BooleanSolid collimator = SubtractionSolid(box_outer, box_inner);
0050
0051
0052 Volume v_collimator(det_name + "_vol_collimator", collimator, m_Steel);
0053
0054 sdet.setAttributes(description, v_collimator, x_det.regionStr(), x_det.limitsStr(), vis_name);
0055
0056 assembly.placeVolume(v_collimator, Position(x, y, z));
0057
0058
0059 auto pv_assembly = description.pickMotherVolume(sdet).placeVolume(
0060 assembly, Transform3D(RotationZYX(0.0, 0.0, 0.0), Position(0, 0, 0)));
0061
0062 sdet.setPlacement(pv_assembly);
0063
0064 assembly->GetShape()->ComputeBBox();
0065
0066 return sdet;
0067 }
0068
0069 DECLARE_DETELEMENT(LumiCollimator, create_detector)