25 std::vector<Section> sections;
27 double r_min =
args.value<
double>(
"rMin");
28 double r_max =
args.value<
double>(
"rMax");
29 double z_pos =
args.value<
double>(
"zPos");
34 auto phis = ns.vecDbl(
args.str(
"Phi"));
35 auto z_ls = ns.vecDbl(
args.str(
"z_l"));
36 auto z_ts = ns.vecDbl(
args.str(
"z_t"));
38 assert(phis.size() == z_ls.size());
39 assert(phis.size() == z_ts.size());
41 for (
unsigned i = 0;
i < phis.size();
i++) {
42 Section
s = {phis[
i], z_ls[
i], z_ts[
i]};
44 edm::LogVerbatim(
"TrackerGeom") <<
"DDCutTubsFromPoints: Sections :" << phis[
i] <<
" , " << z_ls[
i] <<
" , "
46 sections.emplace_back(
s);
55 edm::LogVerbatim(
"TrackerGeom") <<
"DDCutTubsFromPoints debug: Parent " <<
args.parentName() <<
"\tSolid "
56 << solidOutput <<
" NameSpace " << ns.name() <<
"\tnumber of sections "
74 std::vector<dd4hep::Solid> segments;
77 Section s1 = sections[0];
79 for (Section
s2 : sections) {
80 if (s1.phi !=
s2.phi) {
83 std::string segname(solidOutput +
"_seg_" + std::to_string(segment));
94 double P1_z_l = s1.z_l;
95 double P1_z_t = s1.z_t;
96 double P2_z_l =
s2.z_l;
97 double P2_z_t =
s2.z_t;
99 double P1_x_t =
cos(phi1) *
r;
100 double P1_x_l =
cos(phi1) *
r;
101 double P1_y_t =
sin(phi1) *
r;
102 double P1_y_l =
sin(phi1) *
r;
104 double P2_x_t =
cos(phi2) *
r;
105 double P2_x_l =
cos(phi2) *
r;
106 double P2_y_t =
sin(phi2) *
r;
107 double P2_y_l =
sin(phi2) *
r;
111 double P3_z_l = (P1_z_l + P2_z_l) / 2;
112 double P3_z_t = (P1_z_t + P2_z_t) / 2;
114 edm::LogVerbatim(
"TrackerGeom") <<
"DDCutTubsFromPoints: P1 l: " << segname << P1_x_l <<
" , " << P1_y_l <<
" , "
116 edm::LogVerbatim(
"TrackerGeom") <<
"DDCutTubsFromPoints: P1 t: " << segname << P1_x_t <<
" , " << P1_y_t <<
" , "
119 edm::LogVerbatim(
"TrackerGeom") <<
"DDCutTubsFromPoints: P2 l: " << segname << P2_x_l <<
" , " << P2_y_l <<
" , "
121 edm::LogVerbatim(
"TrackerGeom") <<
"DDCutTubsFromPoints: P2 t: " << segname << P2_x_t <<
" , " << P2_y_t <<
" , "
127 double dz = (P3_z_t - P3_z_l) / 2;
128 double offset = (P3_z_t + P3_z_l) / 2;
132 double D1_z_l = P1_z_l - P3_z_l;
133 double D2_z_l = P2_z_l - P3_z_l;
136 double n_x_l = (P1_y_l * D2_z_l) - (D1_z_l * P2_y_l);
137 double n_y_l = (D1_z_l * P2_x_l) - (P1_x_l * D2_z_l);
138 double n_z_l = (P1_x_l * P2_y_l) - (P1_y_l * P2_x_l);
140 edm::LogVerbatim(
"TrackerGeom") <<
"DDCutTubsFromPoints: l_Pos (" << n_x_l <<
"," << n_y_l <<
"," << n_z_l <<
")";
144 double norm = -
sqrt(n_x_l * n_x_l + n_y_l * n_y_l + n_z_l * n_z_l);
152 double D1_z_t = P1_z_t - P3_z_t;
153 double D2_z_t = P2_z_t - P3_z_t;
155 double n_x_t = (P1_y_t * D2_z_t) - (D1_z_t * P2_y_t);
156 double n_y_t = (D1_z_t * P2_x_t) - (P1_x_t * D2_z_t);
157 double n_z_t = (P1_x_t * P2_y_t) - (P1_y_t * P2_x_t);
159 edm::LogVerbatim(
"TrackerGeom") <<
"DDCutTubsFromPoints: t_Pos (" << n_x_t <<
"," << n_y_t <<
"," << n_z_t <<
")";
161 norm =
sqrt(n_x_t * n_x_t + n_y_t * n_y_t + n_z_t * n_z_t);
169 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);
171 edm::LogVerbatim(
"TrackerGeom") <<
"DDCutTubsFromPoints: CutTube(" << r_min <<
"," << r_max <<
"," <<
dz <<
","
172 << phi1 <<
"," << phi2 <<
"," << n_x_l <<
"," << n_y_l <<
"," << n_z_l <<
","
173 << n_x_t <<
"," << n_y_t <<
"," << n_z_t <<
")";
175 segments.emplace_back(seg);
182 assert(segments.size() >= 2);
184 dd4hep::Solid solid = segments[0];
189 for (
unsigned i = 1;
i < segments.size() - 1;
i++) {
191 std::string unionname = solidOutput +
"_uni" + std::to_string(
i + 1);
197 solid = ns.addSolid(solidOutput,
198 dd4hep::UnionSolid(solidOutput,
200 segments[segments.size() - 1],
204 double offset = -
shift + (min_z + (max_z - min_z) / 2.);
206 auto logical = ns.addVolume(
dd4hep::Volume(solidOutput, solid, ns.material(material)));
210 mother.placeVolume(logical, nCopy, dd4hep::Transform3D(dd4hep::Rotation3D(),
pos));
212 mother.placeVolume(logical, nCopy + 1, dd4hep::Transform3D(ns.rotation(
"pixfwdCommon:Z180"),
pos));