1 #include "DD4hep/DetFactoryHelper.h" 17 LogDebug(
"PixelGeom") <<
"+++ Parsing arguments for Algorithm:" << args.
name <<
" rParent:" << parentName;
18 string genMat = args.
value<
string>(
"GeneralMaterial");
20 double layerDz = args.
value<
double>(
"LayerDz");
21 double sensorEdge = args.
value<
double>(
"SensorEdge");
22 double coolDz = args.
value<
double>(
"CoolDz");
23 double coolWidth = args.
value<
double>(
"CoolWidth");
24 double coolSide = args.
value<
double>(
"CoolSide");
25 double coolThick = args.
value<
double>(
"CoolThick");
26 double coolDist = args.
value<
double>(
"CoolDist");
27 string coolMat = args.
value<
string>(
"CoolMaterial");
28 string tubeMat = args.
value<
string>(
"CoolTubeMaterial");
29 LogDebug(
"PixelGeom") <<
"Parent " << parentName <<
" NameSpace " << ns.
name() <<
"\n" 30 <<
"\tLadders " << number <<
"\tGeneral Material " << genMat <<
"\tLength " << layerDz
31 <<
"\tSensorEdge " << sensorEdge <<
"\tSpecification of Cooling Pieces:\n" 32 <<
"\tLength " << coolDz <<
" Width " << coolWidth <<
" Side " << coolSide
33 <<
" Thickness of Shell " << coolThick <<
" Radial distance " << coolDist <<
" Materials " 34 << coolMat <<
", " << tubeMat;
35 vector<string>
ladder = args.
value<vector<string> >(
"LadderName");
36 vector<double> ladderWidth = args.
value<vector<double> >(
"LadderWidth");
37 vector<double> ladderThick = args.
value<vector<double> >(
"LadderThick");
38 LogDebug(
"PixelGeom") <<
"Full Ladder " << ladder[0] <<
" width/thickness " << ladderWidth[0] <<
", " 39 << ladderThick[0] <<
"\tHalf Ladder " << ladder[1] <<
" width/thickness " << ladderWidth[1]
40 <<
", " << ladderThick[1];
43 double dphi = 2_pi /
number;
44 double d2 = 0.5 * coolWidth;
45 double d1 = d2 - coolSide *
sin(0.5 * dphi);
46 double x1 = (d1 + d2) / (2. *
sin(0.5 * dphi));
47 double x2 = coolDist *
sin(0.5 * dphi);
48 double rmin = (coolDist - 0.5 * (d1 + d2)) *
cos(0.5 * dphi) - 0.5 * ladderThick[0];
49 double rmax = (coolDist + 0.5 * (d1 + d2)) *
cos(0.5 * dphi) + 0.5 * ladderThick[0];
50 double rmxh = rmax - 0.5 * ladderThick[0] + ladderThick[1];
51 LogDebug(
"PixelGeom") <<
"Rmin/Rmax " << rmin <<
", " << rmax <<
" d1/d2 " << d1 <<
", " << d2 <<
" x1/x2 " << x1
54 double rtmi = rmin + 0.5 * ladderThick[0] - ladderThick[1];
55 double rtmx =
sqrt(rmxh * rmxh + ladderWidth[1] * ladderWidth[1]);
56 Solid solid = ns.
addSolid(idName, Tube(rtmi, rtmx, 0.5 * layerDz, 0, 2_pi));
57 LogDebug(
"PixelGeom") <<
"IDname " << idName <<
" Tubs made of " << genMat <<
" from 0 to " <<
convertRadToDeg(2_pi)
58 <<
" with Rin " << rtmi <<
" Rout " << rtmx <<
" ZHalf " << 0.5 * layerDz;
61 double rr = 0.5 * (rmax + rmin);
62 double dr = 0.5 * (rmax - rmin);
63 double h1 = 0.5 * coolSide *
cos(0.5 * dphi);
65 solid = ns.
addSolid(name, Trap(0.5 * coolDz, 0, 0, h1, d2, d1, 0, h1, d2, d1, 0));
66 LogDebug(
"PixelGeom") <<
"Solid " << solid.name() <<
" Trap made of " << tubeMat <<
" of dimensions " << 0.5 * coolDz
67 <<
", 0, 0, " << h1 <<
", " << d2 <<
", " << d1 <<
", 0, " << h1 <<
", " << d2 <<
", " << d1
74 name = idName +
"Coolant";
75 solid = ns.
addSolid(name, Trap(0.5 * coolDz, 0, 0, h1, d2, d1, 0, h1, d2, d1, 0));
76 LogDebug(
"PixelGeom") <<
"Solid " << solid.name() <<
" Trap made of " << coolMat <<
" of dimensions " << 0.5 * coolDz
77 <<
", 0, 0, " << h1 <<
", " << d2 <<
", " << d1 <<
", 0, " << h1 <<
", " << d2 <<
", " << d1
81 pv = coolTube.placeVolume(cool, 1);
82 LogDebug(
"PixelGeom") <<
"Cool " << cool.name() <<
" number 1 positioned in " << coolTube.name()
83 <<
" at (0,0,0) with no rotation";
85 string ladderFull = ladder[0];
86 string ladderHalf = ladder[1];
87 int nphi = number / 2,
copy = 1, iup = -1;
93 double phi = phi0 +
i * dphi;
94 double phix, phiy, rrr,
xx;
98 if (
i == 0 ||
i == nphi) {
99 rrr = rr + dr + 0.5 * (ladderThick[1] - ladderThick[0]);
100 xx = (0.5 * ladderWidth[1] - sensorEdge) *
sin(phi);
101 tran = Position(xx, rrr *
sin(phi), 0);
102 rots = idName + std::to_string(
copy);
104 phiy = 90_deg + phix;
105 LogDebug(
"PixelGeom") <<
"Creating a new " 106 <<
"rotation: " << rots <<
"\t90., " <<
convertRadToDeg(phix) <<
", 90.," 111 pv = layer.placeVolume(ladderHalfVol,
copy, Transform3D(rot, tran));
114 LogDebug(
"PixelGeom") <<
"ladderHalfVol: " << ladderHalfVol.name() <<
" number " <<
copy <<
" positioned in " 115 << layer.name() <<
" at " << tran <<
" with " <<
rot;
118 rrr = rr - dr - 0.5 * (ladderThick[1] - ladderThick[0]);
119 tran = Position(-xx, rrr *
sin(phi), 0);
120 rots = idName + std::to_string(
copy);
122 phiy = 90_deg + phix;
127 pv = layer.placeVolume(ladderHalfVol,
copy, Transform3D(rot, tran));
130 LogDebug(
"PixelGeom") <<
"ladderHalfVol: " << ladderHalfVol.name() <<
" number " <<
copy <<
" positioned in " 131 << layer.name() <<
" at " << tran <<
" with " <<
rot;
136 tran = Position(rrr *
cos(phi), rrr *
sin(phi), 0);
137 rots = idName + std::to_string(
copy);
142 phiy = phix + 90._deg;
143 LogDebug(
"PixelGeom") <<
"DDPixBarLayerAlgo test: Creating a new " 144 <<
"rotation: " << rots <<
"\t90., " <<
convertRadToDeg(phix) <<
", 90.," 149 pv = layer.placeVolume(ladderFullVol,
copy, Transform3D(rot, tran));
152 LogDebug(
"PixelGeom") <<
"test: " << ladderFullVol.name() <<
" number " <<
copy <<
" positioned in " 153 << layer.name() <<
" at " << tran <<
" with " <<
rot;
156 rrr = coolDist *
cos(0.5 * dphi);
157 tran = Position(rrr *
cos(phi) - x2 *
sin(phi), rrr *
sin(phi) + x2 *
cos(phi), 0);
158 rots = idName + std::to_string(
i + 100);
159 phix = phi + 0.5 * dphi;
162 phiy = phix + 90._deg;
167 pv = layer.placeVolume(coolTube,
i + 1, Transform3D(rot, tran));
170 LogDebug(
"PixelGeom") <<
"coolTube: " << coolTube.name() <<
" number " <<
i + 1 <<
" positioned in " << layer.name()
171 <<
" at " << tran <<
" with " <<
rot;
173 LogDebug(
"PixelGeom") <<
"Layer: " << layer.name();
dd4hep::Volume volume(const std::string &name, bool exc=true) const
constexpr NumType convertRadToDeg(NumType radians)
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.
dd4hep::Rotation3D makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
std::string_view name() const
dd4hep::PlacedVolume PlacedVolume
static std::string objName(const std::string &)
Cos< T >::type cos(const T &t)
dd4hep::Material material(const std::string &name) const
static long algorithm(Detector &description, cms::DDParsingContext &ctxt, xml_h e, SensitiveDetector &)
Namespace of DDCMS conversion namespace.
dd4hep::Solid addSolid(const std::string &name, dd4hep::Solid solid) const
#define DECLARE_DDCMS_DETELEMENT(name, func)
std::string parentName() const
Access value of rParent child node.