22 std::vector<Section> sections;
24 float r_min =
args.value<
float>(
"rMin");
25 float r_max =
args.value<
float>(
"rMax");
26 float z_pos =
args.value<
float>(
"zPos");
31 auto phis = ns.vecFloat(
args.str(
"Phi"));
32 auto z_ls = ns.vecFloat(
args.str(
"z_l"));
33 auto z_ts = ns.vecFloat(
args.str(
"z_t"));
35 assert(phis.size() == z_ls.size());
36 assert(phis.size() == z_ts.size());
38 for (
unsigned i = 0;
i < phis.size();
i++) {
39 Section
s = {phis[
i], z_ls[
i], z_ts[
i]};
41 edm::LogVerbatim(
"TrackerGeom") <<
"DDCutTubsFromPoints: Sections :" << phis[
i] <<
" , " << z_ls[
i] <<
" , "
43 sections.emplace_back(
s);
52 edm::LogVerbatim(
"TrackerGeom") <<
"DDCutTubsFromPoints debug: Parent " <<
args.parentName() <<
"\tSolid "
53 << solidOutput <<
" NameSpace " << ns.name() <<
"\tnumber of sections "
71 std::vector<dd4hep::Solid> segments;
74 Section s1 = sections[0];
76 for (Section
s2 : sections) {
77 if (s1.phi !=
s2.phi) {
89 float P1_z_l = s1.z_l;
90 float P1_z_t = s1.z_t;
91 float P2_z_l =
s2.z_l;
92 float P2_z_t =
s2.z_t;
94 float P1_x_t =
cos(phi1) *
r;
95 float P1_x_l =
cos(phi1) *
r;
96 float P1_y_t =
sin(phi1) *
r;
97 float P1_y_l =
sin(phi1) *
r;
99 float P2_x_t =
cos(phi2) *
r;
100 float P2_x_l =
cos(phi2) *
r;
101 float P2_y_t =
sin(phi2) *
r;
102 float P2_y_l =
sin(phi2) *
r;
106 float P3_z_l = (P1_z_l + P2_z_l) / 2;
107 float P3_z_t = (P1_z_t + P2_z_t) / 2;
110 std::string segname(solidOutput +
"_seg_" + std::to_string(segment));
111 log <<
"DDCutTubsFromPoints: P1 l: " << segname << P1_x_l <<
" , " << P1_y_l <<
" , " << P1_z_l;
112 log <<
"DDCutTubsFromPoints: P1 t: " << segname << P1_x_t <<
" , " << P1_y_t <<
" , " << P1_z_t;
113 log <<
"DDCutTubsFromPoints: P2 l: " << segname << P2_x_l <<
" , " << P2_y_l <<
" , " << P2_z_l;
114 log <<
"DDCutTubsFromPoints: P2 t: " << segname << P2_x_t <<
" , " << P2_y_t <<
" , " << P2_z_t;
120 float dz = 0.5 * (P3_z_t - P3_z_l);
121 float offset = 0.5 * (P3_z_t + P3_z_l);
125 float D1_z_l = P1_z_l - P3_z_l;
126 float D2_z_l = P2_z_l - P3_z_l;
129 float n_x_l = (P1_y_l * D2_z_l) - (D1_z_l * P2_y_l);
130 float n_y_l = (D1_z_l * P2_x_l) - (P1_x_l * D2_z_l);
131 float n_z_l = (P1_x_l * P2_y_l) - (P1_y_l * P2_x_l);
133 edm::LogVerbatim(
"TrackerGeom") <<
"DDCutTubsFromPoints: l_Pos (" << n_x_l <<
"," << n_y_l <<
"," << n_z_l <<
")";
137 float norm = -
sqrt(n_x_l * n_x_l + n_y_l * n_y_l + n_z_l * n_z_l);
145 float D1_z_t = P1_z_t - P3_z_t;
146 float D2_z_t = P2_z_t - P3_z_t;
148 float n_x_t = (P1_y_t * D2_z_t) - (D1_z_t * P2_y_t);
149 float n_y_t = (D1_z_t * P2_x_t) - (P1_x_t * D2_z_t);
150 float n_z_t = (P1_x_t * P2_y_t) - (P1_y_t * P2_x_t);
152 edm::LogVerbatim(
"TrackerGeom") <<
"DDCutTubsFromPoints: t_Pos (" << n_x_t <<
"," << n_y_t <<
"," << n_z_t <<
")";
154 norm =
sqrt(n_x_t * n_x_t + n_y_t * n_y_t + n_z_t * n_z_t);
162 auto seg = dd4hep::CutTube(r_min, r_max,
dz, phi1, phi2, n_x_l, n_y_l, n_z_l, n_x_t, n_y_t, n_z_t);
164 edm::LogVerbatim(
"TrackerGeom") <<
"DDCutTubsFromPoints: CutTube(" << r_min <<
"," << r_max <<
"," <<
dz <<
","
165 << phi1 <<
"," << phi2 <<
"," << n_x_l <<
"," << n_y_l <<
"," << n_z_l <<
","
166 << n_x_t <<
"," << n_y_t <<
"," << n_z_t <<
")";
168 segments.emplace_back(seg);
175 assert(segments.size() >= 2);
177 dd4hep::Solid solid = segments[0];
182 for (
unsigned i = 1;
i < segments.size() - 1;
i++) {
183 solid = dd4hep::UnionSolid(
187 solid = dd4hep::UnionSolid(solidOutput,
189 segments[segments.size() - 1],
193 float offset = -
shift + (min_z + 0.5 * (max_z - min_z));
195 auto logical =
dd4hep::Volume(solidOutput, solid, ns.material(material));
199 mother.placeVolume(logical, nCopy, dd4hep::Transform3D(dd4hep::Rotation3D(),
pos));
201 mother.placeVolume(logical, nCopy + 1, dd4hep::Transform3D(ns.rotation(
"pixfwdCommon:Z180"),
pos));