9 #include "DD4hep/DetFactoryHelper.h"
10 #include "DD4hep/Printout.h"
32 using namespace ROOT::Math;
34 string det_name = x_det.nameStr();
35 Material air = det.air();
36 DetElement sdet (det_name,x_det.id());
37 Assembly assembly (det_name+
"_assembly");
38 Material m_Cu = det.material(
"Copper");
39 Material m_Al = det.material(
"Aluminum");
40 Material m_Be = det.material(
"Beryllium");
45 double IP_beampipe_OD = 55.00 * mm;
46 double IP_beampipe_thickness = 4.00 * mm;
47 double IP_beampipe_ID = IP_beampipe_OD - IP_beampipe_thickness;
48 double crossing_angle = 0.025;
51 double upstream_straight_length = 685.0 * mm;
52 double upstream_total_length = 4500.0 * mm;
53 double upstream_conic_length = upstream_total_length - upstream_straight_length;
54 double upstream_beampipe_exit_OD = 229.96 * mm;
55 double upstream_beampipe_exit_ID = upstream_beampipe_exit_OD - IP_beampipe_thickness;
56 double upstream_epipe_thickness = 4.0*mm;
59 double downstream_straight_length = 1300.0 * mm;
60 double downstream_taper_length = 310.0 * mm;
61 double downstream_total_length = 4500.0 * mm;
62 double downstream_conic_length = downstream_total_length - downstream_straight_length ;
63 double downstream_cone_rmax = 110.00*mm/2.0;
64 double downstream_epipe_thickness = 4.0*mm;
65 double downstream_beampipe_exit_OD = 62.0 * mm;
66 double downstream_beampipe_exit_ID = downstream_beampipe_exit_OD - downstream_epipe_thickness;
67 double downstream_hpipe_OD = IP_beampipe_ID/2;
68 double downstream_hpipe_thickness = 4.0*mm;
70 double upstream_delta_r = upstream_conic_length*std::tan(crossing_angle/2.0);
71 double downstream_delta_r = (downstream_conic_length+downstream_straight_length)*std::tan(crossing_angle);
76 Tube downstream_IP_tube(IP_beampipe_ID/2.0, IP_beampipe_OD/2.0, downstream_straight_length/2.0);
77 Tube downstream_IP_vacuum(0.0, IP_beampipe_ID/2.0, downstream_straight_length/2.0);
78 Tube upstream_IP_tube(IP_beampipe_ID/2.0, IP_beampipe_OD/2.0, upstream_straight_length/2.0);
79 Tube upstream_IP_vacuum(0.0, IP_beampipe_OD/2.0, upstream_straight_length/2.0);
81 Volume v_upstream_IP_tube(
"v_upstream_IP_tube", upstream_IP_tube, m_Al);
82 Volume v_downstream_IP_tube(
"v_downstream_IP_tube", downstream_IP_tube, m_Al);
86 sdet.setAttributes(det, v_upstream_IP_tube , x_det.regionStr(), x_det.limitsStr(),
"OrangeVis");
87 sdet.setAttributes(det, v_downstream_IP_tube, x_det.regionStr(), x_det.limitsStr(),
"OrangeVis");
89 auto pv_upstream_IP_tube = assembly.placeVolume(
90 v_upstream_IP_tube, Position(0, 0, -upstream_straight_length / 2.0));
92 auto pv_downstream_IP_tube = assembly.placeVolume(
93 v_downstream_IP_tube, Position(0, 0, downstream_straight_length / 2.0));
97 Tube upstream_electron_tube(IP_beampipe_ID/2.0 - upstream_epipe_thickness,
98 IP_beampipe_ID/2.0, upstream_conic_length/2.0);
99 Cone upstream_conic_section(upstream_conic_length / 2.0,
100 IP_beampipe_ID / 2.0, IP_beampipe_OD / 2.0,
101 IP_beampipe_ID / 2.0 + upstream_delta_r,
102 IP_beampipe_OD / 2.0+ upstream_delta_r + IP_beampipe_thickness);
103 Cone upstream_conic_section_vacuum(upstream_conic_length / 2.0,
104 0.0, IP_beampipe_ID / 2.0,
105 0.0, IP_beampipe_ID / 2.0 + upstream_delta_r);
106 Volume v_upstream_conic_section(
"v_upstream_conic_section", upstream_conic_section, m_Al);
107 Volume v_upstream_electron_tube(
"v_upstream_conic_section", upstream_electron_tube, m_Al);
108 sdet.setAttributes(det, v_upstream_conic_section, x_det.regionStr(), x_det.limitsStr(),
"OrangeVis");
109 sdet.setAttributes(det, v_upstream_electron_tube, x_det.regionStr(), x_det.limitsStr(),
"OrangeVis");
112 auto pv_upstream_conic_section = assembly.placeVolume(
113 v_upstream_conic_section,
115 Position(-upstream_delta_r/2.0,0, -upstream_straight_length - upstream_conic_length / 2.0)) *
116 RotationY(crossing_angle / 2.0) * RotationX(M_PI));
117 auto pv_upstream_electron_tube =
118 assembly.placeVolume(v_upstream_electron_tube,
119 Position(0, 0, -upstream_straight_length - upstream_conic_length / 2.0));
125 Tube downstream_hadron_tube(downstream_hpipe_OD/2.0 - downstream_epipe_thickness,
126 downstream_hpipe_OD/2.0, downstream_conic_length / 2.0);
127 Cone downstream_conic_section(downstream_conic_length / 2.0, IP_beampipe_ID / 2.0,
128 IP_beampipe_OD / 2.0, downstream_cone_rmax,
129 downstream_cone_rmax + downstream_epipe_thickness);
130 Cone downstream_taper_section(downstream_taper_length / 2.0,
131 downstream_cone_rmax, downstream_cone_rmax + downstream_epipe_thickness,
132 downstream_beampipe_exit_ID/2.0, downstream_beampipe_exit_OD/2.0);
134 UnionSolid downstream_pipe_split0(downstream_conic_section, downstream_hadron_tube,
135 Transform3D(Position(downstream_delta_r / 2.0, 0.0, 0.0)) *
136 RotationY(crossing_angle));
139 Cone downstream_conic_section_vacuum(downstream_conic_length / 2.0,
140 0.0, IP_beampipe_ID / 2.0,
141 0.0, downstream_cone_rmax);
142 Tube downstream_hadron_vacuum(0.0, downstream_hpipe_OD / 2.0 - downstream_epipe_thickness,
143 downstream_conic_length / 1.9);
144 UnionSolid downstream_pipe_vacuum_split0(downstream_conic_section_vacuum, downstream_hadron_vacuum,
145 Transform3D(Position(downstream_delta_r / 2.0, 0.0, 0.0)) *
146 RotationY(crossing_angle));
147 SubtractionSolid downstream_pipe_split1(downstream_pipe_split0,
148 downstream_pipe_vacuum_split0);
149 Volume v_downstream_pipe_split1(
"v_downstream_pipe_split1", downstream_pipe_split1, m_Al);
150 sdet.setAttributes(det, v_downstream_pipe_split1, x_det.regionStr(), x_det.limitsStr(),
"OrangeVis");
151 auto pv_downstream_pipe_split1 = assembly.placeVolume(v_downstream_pipe_split1,
153 downstream_straight_length +
154 downstream_conic_length / 2.0));
155 Volume v_downstream_taper_section(
"v_downstream_taper_section", downstream_taper_section, m_Al);
156 sdet.setAttributes(det, v_downstream_taper_section, x_det.regionStr(), x_det.limitsStr(),
"OrangeVis");
157 auto pv_downstream_taper_section = assembly.placeVolume(
158 v_downstream_taper_section, Position(0, 0,
159 downstream_straight_length + downstream_conic_length +
160 downstream_taper_length / 2.0));
175 auto pv_assembly = det.pickMotherVolume(sdet).placeVolume(assembly);
176 pv_assembly.addPhysVolID(
"system",sdet.id()).addPhysVolID(
"barrel",0);
177 sdet.setPlacement(pv_assembly);
178 assembly->GetShape()->ComputeBBox() ;