11 #include "DD4hep/DetFactoryHelper.h"
14 using namespace dd4hep;
24 template <
typename volume_t>
26 const xml_comp_t& x_routing,
27 const std::vector<double>& layerR) {
29 unsigned int nphi = x_routing.nphi();
31 double phiStep = 2 *
M_PI / nphi;
32 double phi0 = x_routing.phi0();
33 double rmin = x_routing.rmin();
34 double rmax = x_routing.rmax();
35 double n = x_routing.number();
37 for (
int side = -1; side < 2; side += 2) {
39 for (
unsigned int ib = 1; ib < layerR.size(); ++ib) {
40 for (
unsigned int iphi = 0; iphi < nphi; ++iphi) {
42 double phi = phi0 + iphi * phiStep;
45 double gap = x_routing.gap();
46 double clength = layerR[ib] - layerR[ib - 1] - 2. *
gap;
47 double rpos = 0.5 * (layerR[ib] + layerR[ib - 1]);
48 double xpos = rpos * cos(phi);
49 double ypos = rpos * sin(phi);
50 double zpos = side * x_routing.z_offset();
52 Assembly cableboxAssembly(
"CableBox");
53 if (x_routing.hasChild(_U(
box))) {
55 xml_comp_t x_box = x_routing.child(_U(
box));
56 Box box(x_box.dz(), n * ib *
rmax, 0.5 * clength);
57 Volume boxVolume(
"CableBand",
box,
58 oddd.material(x_routing.materialStr()));
59 boxVolume.setVisAttributes(oddd, x_box.visStr());
61 cableboxAssembly.placeVolume(
62 boxVolume, Position(side * (rmax + x_box.dz()), 0., 0.));
65 Tube cable(rmin, rmax, 0.5 * clength);
66 Volume cableVolume(
"Cable", cable,
67 oddd.material(x_routing.materialStr()));
68 cableVolume.setVisAttributes(oddd, x_routing.visStr());
70 for (
unsigned int icable = 0; icable < n * ib; ++icable) {
72 cableboxAssembly.placeVolume(
73 cableVolume, Position(0., (-n * ib + 1 + 2 * icable) * rmax, 0.));
76 barrelVolume.placeVolume(
79 Position(xpos, ypos, zpos)));
93 template <
typename volume_t>
95 const xml_comp_t& x_routing,
96 const std::vector<double>& endcapZ) {
98 unsigned int nphi = x_routing.nphi();
100 double phiStep = 2 *
M_PI / nphi;
101 double phi0 = x_routing.phi0();
102 double rmin = x_routing.rmin();
103 double rmax = x_routing.rmax();
104 double r = x_routing.r();
105 double n = x_routing.number();
108 for (
unsigned int iec = 1; iec < endcapZ.size(); ++iec) {
109 for (
unsigned int iphi = 0; iphi < nphi; ++iphi) {
111 double phi = phi0 + iphi * phiStep;
114 double gap = x_routing.gap();
115 double clength =
std::abs(endcapZ[iec] - endcapZ[iec - 1]) - 2. *
gap;
116 double xpos = r * cos(phi);
117 double ypos = r * sin(phi);
118 double zpos = 0.5 * (endcapZ[iec] + endcapZ[iec - 1]);
120 Assembly cableboxAssembly(
"CableBox");
121 if (x_routing.hasChild(_U(
box))) {
123 xml_comp_t x_box = x_routing.child(_U(
box));
124 Box box(x_box.dz(), n * iec *
rmax, 0.5 * clength);
125 Volume boxVolume(
"CableBand",
box,
126 oddd.material(x_routing.materialStr()));
127 boxVolume.setVisAttributes(oddd, x_box.visStr());
129 cableboxAssembly.placeVolume(boxVolume,
130 Position(rmax + x_box.dz(), 0., 0.));
133 Tube cable(rmin, rmax, 0.5 * clength);
134 Volume cableVolume(
"Cable", cable,
135 oddd.material(x_routing.materialStr()));
136 cableVolume.setVisAttributes(oddd, x_routing.visStr());
138 for (
unsigned int icable = 0; icable < n * iec; ++icable) {
140 cableboxAssembly.placeVolume(
141 cableVolume, Position(0., (-n * iec + 1 + 2 * icable) * rmax, 0.));
144 endcapVolume.placeVolume(
146 Transform3D(RotationZ(+phi), Position(xpos, ypos, zpos)));
159 template <
typename volume_t>
161 const xml_comp_t& x_mother_comp,
162 std::vector<double>& layerR) {
163 size_t supportNum = 0;
164 for (xml_coll_t sup(x_mother_comp, _U(support)); sup; ++sup, ++supportNum) {
165 xml_comp_t x_support = sup;
167 string supportName = _toString((
int)supportNum,
"SupportCylinder%d");
170 if (x_support.hasChild(_Unicode(connector))) {
171 layerR.push_back(0.5 * (x_support.rmin() + x_support.rmax()));
174 for (
int side = -1; side < x_support.nsides(); side += 2) {
176 Volume supportVolume(
177 supportName, Tube(x_support.rmin(), x_support.rmax(), x_support.dz()),
178 oddd.material(x_support.materialStr()));
179 supportVolume.setVisAttributes(oddd, x_support.visStr());
181 motherVolume.placeVolume(supportVolume,
182 Position(0., 0., side * x_support.z_offset()));
195 template <
typename volume_t>
197 const xml_comp_t& x_mother_comp) {
199 for (xml_coll_t cring(x_mother_comp, _Unicode(cooling_ring)); cring;
200 ++cring, ++cringNum) {
201 xml_comp_t x_cooling_ring = cring;
203 double r = x_cooling_ring.r();
204 double nPhi = x_cooling_ring.nphi();
205 double phiStep = 2. *
M_PI / nPhi;
206 double zpos = x_cooling_ring.z_offset();
207 double dz = 2 * (r *
M_PI / nPhi - x_cooling_ring.gap());
210 for (
unsigned int iphi = 0; iphi < nPhi; ++iphi) {
211 Volume coolingSegement(
212 "CoolingRingSegment",
213 Tube(x_cooling_ring.rmin(), x_cooling_ring.rmax(),
dz),
214 oddd.material(x_cooling_ring.materialStr()));
215 coolingSegement.setVisAttributes(oddd, x_cooling_ring.visStr());
218 double phi = iphi * phiStep;
219 Position segementPos(r * cos(phi), r * sin(phi), zpos);
221 motherVolume.placeVolume(