1 #include "DD4hep/DetFactoryHelper.h" 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");
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 solidOutput = ns.
prepend(solidOutput);
53 edm::LogVerbatim(
"TrackerGeom") <<
"DDCutTubsFromPoints debug: Parent " <<
args.parentName() <<
"\tSolid " 54 << solidOutput <<
" NameSpace " << ns.
name() <<
"\tnumber of sections " 72 std::vector<dd4hep::Solid> segments;
75 Section s1 = sections[0];
77 for (Section s2 : sections) {
78 if (s1.phi != s2.phi) {
90 float P1_z_l = s1.z_l;
91 float P1_z_t = s1.z_t;
92 float P2_z_l = s2.z_l;
93 float P2_z_t = s2.z_t;
95 float P1_x_t =
cos(phi1) * r;
96 float P1_x_l =
cos(phi1) * r;
97 float P1_y_t =
sin(phi1) * r;
98 float P1_y_l =
sin(phi1) * r;
100 float P2_x_t =
cos(phi2) * r;
101 float P2_x_l =
cos(phi2) * r;
102 float P2_y_t =
sin(phi2) * r;
103 float P2_y_l =
sin(phi2) * r;
107 float P3_z_l = (P1_z_l + P2_z_l) / 2;
108 float P3_z_t = (P1_z_t + P2_z_t) / 2;
112 log <<
"DDCutTubsFromPoints: P1 l: " << segname << P1_x_l <<
" , " << P1_y_l <<
" , " << P1_z_l;
113 log <<
"DDCutTubsFromPoints: P1 t: " << segname << P1_x_t <<
" , " << P1_y_t <<
" , " << P1_z_t;
114 log <<
"DDCutTubsFromPoints: P2 l: " << segname << P2_x_l <<
" , " << P2_y_l <<
" , " << P2_z_l;
115 log <<
"DDCutTubsFromPoints: P2 t: " << segname << P2_x_t <<
" , " << P2_y_t <<
" , " << P2_z_t;
121 float dz = 0.5 * (P3_z_t - P3_z_l);
122 float offset = 0.5 * (P3_z_t + P3_z_l);
126 float D1_z_l = P1_z_l - P3_z_l;
127 float D2_z_l = P2_z_l - P3_z_l;
130 float n_x_l = (P1_y_l * D2_z_l) - (D1_z_l * P2_y_l);
131 float n_y_l = (D1_z_l * P2_x_l) - (P1_x_l * D2_z_l);
132 float n_z_l = (P1_x_l * P2_y_l) - (P1_y_l * P2_x_l);
134 edm::LogVerbatim(
"TrackerGeom") <<
"DDCutTubsFromPoints: l_Pos (" << n_x_l <<
"," << n_y_l <<
"," << n_z_l <<
")";
138 float norm = -
sqrt(n_x_l * n_x_l + n_y_l * n_y_l + n_z_l * n_z_l);
146 float D1_z_t = P1_z_t - P3_z_t;
147 float D2_z_t = P2_z_t - P3_z_t;
149 float n_x_t = (P1_y_t * D2_z_t) - (D1_z_t * P2_y_t);
150 float n_y_t = (D1_z_t * P2_x_t) - (P1_x_t * D2_z_t);
151 float n_z_t = (P1_x_t * P2_y_t) - (P1_y_t * P2_x_t);
153 edm::LogVerbatim(
"TrackerGeom") <<
"DDCutTubsFromPoints: t_Pos (" << n_x_t <<
"," << n_y_t <<
"," << n_z_t <<
")";
155 norm =
sqrt(n_x_t * n_x_t + n_y_t * n_y_t + n_z_t * n_z_t);
163 auto seg = dd4hep::CutTube(segname, 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);
165 edm::LogVerbatim(
"TrackerGeom") <<
"DDCutTubsFromPoints: CutTube(" << r_min <<
"," << r_max <<
"," <<
dz <<
"," 166 << phi1 <<
"," << phi2 <<
"," << n_x_l <<
"," << n_y_l <<
"," << n_z_l <<
"," 167 << n_x_t <<
"," << n_y_t <<
"," << n_z_t <<
")";
169 segments.emplace_back(seg);
176 assert(segments.size() >= 2);
178 dd4hep::Solid solid = segments[0];
183 for (
unsigned i = 1;
i < segments.size() - 1;
i++) {
184 solid = dd4hep::UnionSolid(solidOutput +
"_uni_" +
std::to_string(
i + 1),
190 solid = dd4hep::UnionSolid(solidOutput,
192 segments[segments.size() - 1],
195 edm::LogVerbatim(
"TrackerGeom") <<
"DDCutTubsFromPoints: " << solid.name() <<
" Union solid with " << segments.size()
199 float offset = -
shift + (min_z + 0.5 * (max_z - min_z));
205 mother.placeVolume(logical, nCopy, dd4hep::Transform3D(dd4hep::Rotation3D(),
pos));
207 mother.placeVolume(logical, nCopy + 1, dd4hep::Transform3D(ns.
rotation(
"pixfwdCommon:Z180"),
pos));
Log< level::Info, true > LogVerbatim
const dd4hep::Rotation3D & rotation(const std::string &name) const
Sin< T >::type sin(const T &t)
dd4hep::Material material(const std::string &name) const
static std::string to_string(const XMLCh *ch)
#define DECLARE_DDCMS_DETELEMENT(name, func)
static constexpr long s_executed
std::vector< float > vecFloat(const std::string &name) const
std::string_view name() const
Cos< T >::type cos(const T &t)
static unsigned int const shift
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
dd4hep::Volume volume(const std::string &name, bool exc=true) const
std::string prepend(const std::string &) const