1 #include "DD4hep/DetFactoryHelper.h" 12 dd4hep::SensitiveDetector& ) {
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");
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);
49 assert(!sections.empty());
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);
176 offsets.emplace_back(offset);
182 assert(segments.size() >= 2);
184 dd4hep::Solid solid = segments[0];
187 double shift = offsets[0];
189 for (
unsigned i = 1;
i < segments.size() - 1;
i++) {
191 std::string unionname = solidOutput +
"_uni" + std::to_string(
i + 1);
194 unionname, dd4hep::UnionSolid(unionname, solid, segments[
i], dd4hep::Position(0., 0., offsets[i] - shift)));
198 dd4hep::UnionSolid(solidOutput,
200 segments[segments.size() - 1],
201 dd4hep::Position(0., 0., offsets[segments.size() - 1] -
shift)));
204 double offset = -shift + (min_z + (max_z - min_z) / 2.);
209 auto pos = dd4hep::Position(0., 0., z_pos - offset);
210 mother.placeVolume(logical, nCopy, dd4hep::Transform3D(dd4hep::Rotation3D(),
pos));
212 mother.placeVolume(logical, nCopy + 1, dd4hep::Transform3D(ns.
rotation(
"pixfwdCommon:Z180"),
pos));
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Sin< T >::type sin(const T &t)
T value(const std::string &name) const
dd4hep::Volume addVolume(dd4hep::Volume vol) const
Add rotation matrix to current namespace.
std::string_view name() const
static constexpr long s_executed
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e, dd4hep::SensitiveDetector &)
Cos< T >::type cos(const T &t)
dd4hep::Material material(const std::string &name) const
std::vector< double > vecDbl(const std::string &name) const
dd4hep::Solid addSolid(const std::string &name, dd4hep::Solid solid) const
const dd4hep::Rotation3D & rotation(const std::string &name) const
static unsigned int const shift
#define DECLARE_DDCMS_DETELEMENT(name, func)
std::string parentName() const
Access value of rParent child node.
std::string str(const std::string &nam) const
Shortcut to access string arguments.