1 #include "DD4hep/DetFactoryHelper.h" 21 string genMat = args.
str(
"GeneralMaterial");
22 double detectorTilt = args.
dble(
"DetectorTilt");
23 double layerL = args.
dble(
"LayerL");
25 double radiusLo = args.
dble(
"RadiusLo");
26 int stringsLo = args.
integer(
"StringsLo");
27 string detectorLo = args.
str(
"StringDetLoName");
29 double radiusUp = args.
dble(
"RadiusUp");
30 int stringsUp = args.
integer(
"StringsUp");
31 string detectorUp = args.
str(
"StringDetUpName");
33 double cylinderT = args.
dble(
"CylinderThickness");
34 double cylinderInR = args.
dble(
"CylinderInnerRadius");
35 string cylinderMat = args.
str(
"CylinderMaterial");
36 double MFRingInR = args.
dble(
"MFRingInnerRadius");
37 double MFRingOutR = args.
dble(
"MFRingOuterRadius");
38 double MFRingT = args.
dble(
"MFRingThickness");
39 double MFRingDz = args.
dble(
"MFRingDeltaz");
40 string MFIntRingMat = args.
str(
"MFIntRingMaterial");
41 string MFExtRingMat = args.
str(
"MFExtRingMaterial");
43 double supportT = args.
dble(
"SupportThickness");
45 string centMat = args.
str(
"CentRingMaterial");
49 string fillerMat = args.
str(
"FillerMaterial");
50 double fillerDz = args.
dble(
"FillerDeltaz");
52 string ribMat = args.
str(
"RibMaterial");
59 double dohmtoMF = args.
dble(
"DOHMtoMFDist");
60 double dohmCarrierPhiOff = args.
dble(
"DOHMCarrierPhiOffset");
61 string dohmPrimName = args.
str(
"StringDOHMPrimName");
62 string dohmAuxName = args.
str(
"StringDOHMAuxName");
64 string dohmCarrierMaterial = args.
str(
"DOHMCarrierMaterial");
65 string dohmCableMaterial = args.
str(
"DOHMCableMaterial");
66 double dohmPrimL = args.
dble(
"DOHMPRIMLength");
67 string dohmPrimMaterial = args.
str(
"DOHMPRIMMaterial");
68 double dohmAuxL = args.
dble(
"DOHMAUXLength");
69 string dohmAuxMaterial = args.
str(
"DOHMAUXMaterial");
71 string pillarMaterial = args.
str(
"PillarMaterial");
73 double fwIntPillarDz = args.
dble(
"FWIntPillarDz");
74 double fwIntPillarDPhi = args.
dble(
"FWIntPillarDPhi");
77 double bwIntPillarDz = args.
dble(
"BWIntPillarDz");
78 double bwIntPillarDPhi = args.
dble(
"BWIntPillarDPhi");
82 double fwExtPillarDz = args.
dble(
"FWExtPillarDz");
83 double fwExtPillarDPhi = args.
dble(
"FWExtPillarDPhi");
86 double bwExtPillarDz = args.
dble(
"BWExtPillarDz");
87 double bwExtPillarDPhi = args.
dble(
"BWExtPillarDPhi");
95 <<
" positioned: " << pvl.motherVol()->GetName() <<
" " << pvl.position();
98 LogDebug(
"TIBGeom") <<
"Parent " << mother <<
" NameSpace " << ns.
name() <<
" General Material " << genMat;
99 LogDebug(
"TIBGeom") <<
"Lower layer Radius " << radiusLo <<
" Number " << stringsLo <<
" String " << detectorLo;
100 LogDebug(
"TIBGeom") <<
"Upper layer Radius " << radiusUp <<
" Number " << stringsUp <<
" String " << detectorUp;
101 LogDebug(
"TIBGeom") <<
"Cylinder Material/thickness " << cylinderMat <<
" " << cylinderT <<
" Rib Material " << ribMat
102 <<
" at " << ribW.size() <<
" positions with width/phi";
103 for (
unsigned int i = 0;
i < ribW.size();
i++) {
104 LogDebug(
"TIBGeom") <<
"\tribW[" <<
i <<
"] = " << ribW[
i] <<
"\tribPhi[" <<
i 107 LogDebug(
"TIBGeom") <<
"DOHM Primary " 108 <<
" Material " << dohmPrimMaterial <<
" Length " << dohmPrimL;
110 <<
" Material " << dohmAuxMaterial <<
" Length " << dohmAuxL;
111 for (
double i : dohmListFW) {
113 LogDebug(
"TIBGeom") <<
"DOHM Primary at FW Position " <<
i;
115 LogDebug(
"TIBGeom") <<
"DOHM Aux at FW Position " << -
i;
117 for (
double i : dohmListBW) {
119 LogDebug(
"TIBGeom") <<
"DOHM Primary at BW Position " <<
i;
121 LogDebug(
"TIBGeom") <<
"DOHM Aux at BW Position " << -
i;
123 LogDebug(
"TIBGeom") <<
"FW Internal Pillar [Dz, DPhi] " << fwIntPillarDz <<
", " << fwIntPillarDPhi;
124 for (
unsigned int i = 0;
i < fwIntPillarZ.size();
i++) {
125 if (fwIntPillarPhi[
i] > 0.) {
126 LogDebug(
"TIBGeom") <<
" at positions [z, phi] " << fwIntPillarZ[
i] <<
" " << fwIntPillarPhi[
i];
129 LogDebug(
"TIBGeom") <<
"BW Internal Pillar [Dz, DPhi] " << bwIntPillarDz <<
", " << bwIntPillarDPhi;
130 for (
unsigned int i = 0;
i < bwIntPillarZ.size();
i++) {
131 if (bwIntPillarPhi[
i] > 0.) {
132 LogDebug(
"TIBGeom") <<
" at positions [z, phi] " << bwIntPillarZ[
i] <<
" " << bwIntPillarPhi[
i];
135 LogDebug(
"TIBGeom") <<
"FW External Pillar [Dz, DPhi] " << fwExtPillarDz <<
", " << fwExtPillarDPhi;
136 for (
unsigned int i = 0;
i < fwExtPillarZ.size();
i++) {
137 if (fwExtPillarPhi[
i] > 0.) {
138 LogDebug(
"TIBGeom") <<
" at positions [z, phi] " << fwExtPillarZ[
i] <<
" " << fwExtPillarPhi[
i];
141 LogDebug(
"TIBGeom") <<
"BW External Pillar [Dz, DPhi] " << bwExtPillarDz <<
", " << bwExtPillarDPhi;
142 for (
unsigned int i = 0;
i < bwExtPillarZ.size();
i++) {
143 if (bwExtPillarPhi[
i] > 0.) {
144 LogDebug(
"TIBGeom") <<
" at positions [z, phi] " << bwExtPillarZ[
i] <<
" " << bwExtPillarPhi[
i];
148 const string&
idName = mother;
149 double rmin = MFRingInR;
150 double rmax = MFRingOutR;
151 Solid solid = ns.
addSolidNS(idName, Tube(rmin, rmax, 0.5 * layerL));
153 <<
" with Rin " << rmin <<
" Rout " << rmax <<
" ZHalf " << 0.5 * layerL;
157 double rin = rmin + MFRingT;
159 double rout = cylinderInR;
160 string name = idName +
"Down";
161 solid = ns.
addSolidNS(name, Tube(rin, rout, 0.5 * layerL));
163 <<
" with Rin " << rin <<
" Rout " << rout <<
" ZHalf " << 0.5 * layerL;
165 pv = layer.placeVolume(layerIn, 1);
168 double rposdet = radiusLo;
169 double dphi = 2_pi / stringsLo;
171 for (
int n = 0;
n < stringsLo;
n++) {
172 double phi = (
n + 0.5) * dphi;
173 double phix = phi - detectorTilt + 90_deg;
174 double theta = 90_deg;
175 double phiy = phix + 90._deg;
177 Position trdet(rposdet *
cos(phi), rposdet *
sin(phi), 0);
178 pv = layerIn.placeVolume(detIn,
n + 1, Transform3D(rotation, trdet));
182 rin = cylinderInR + cylinderT;
183 rout = rmax - MFRingT;
184 name = idName +
"Up";
185 solid = ns.
addSolidNS(name, Tube(rin, rout, 0.5 * layerL));
187 <<
" with Rin " << rin <<
" Rout " << rout <<
" ZHalf " << 0.5 * layerL;
189 pv = layer.placeVolume(layerOut, 1);
193 dphi = 2_pi / stringsUp;
195 for (
int n = 0;
n < stringsUp;
n++) {
196 double phi = (
n + 0.5) * dphi;
197 double phix = phi - detectorTilt - 90_deg;
198 double theta = 90_deg;
199 double phiy = phix + 90._deg;
201 Position trdet(rposdet *
cos(phi), rposdet *
sin(phi), 0);
202 pv = layerOut.placeVolume(detOut,
n + 1, Transform3D(rotation, trdet));
211 rout = cylinderInR + cylinderT;
212 name = idName +
"Cylinder";
213 solid = ns.
addSolidNS(name, Tube(rin, rout, 0.5 * layerL));
214 LogDebug(
"TIBGeom") << solid.name() <<
" Tubs made of " << cylinderMat <<
" from 0 to " <<
convertRadToDeg(2_pi)
215 <<
" with Rin " << rin <<
" Rout " << rout <<
" ZHalf " << 0.5 * layerL;
217 pv = layer.placeVolume(cylinder, 1);
225 name = idName +
"CylinderIn";
226 solid = ns.
addSolidNS(name, Tube(rin, rout, 0.5 * layerL));
228 <<
" with Rin " << rin <<
" Rout " << rout <<
" ZHalf " << 0.5 * layerL;
230 pv = cylinder.placeVolume(cylinderIn, 1);
236 name = idName +
"Filler";
237 solid = ns.
addSolidNS(name, Tube(rin, rout, fillerDz));
238 LogDebug(
"TIBGeom") << solid.name() <<
" Tubs made of " << fillerMat <<
" from " << 0. <<
" to " 239 <<
convertRadToDeg(2_pi) <<
" with Rin " << rin <<
" Rout " << rout <<
" ZHalf " << fillerDz;
241 pv = cylinderIn.placeVolume(cylinderFiller, 1, Position(0.0, 0.0, 0.5 * layerL - fillerDz));
244 pv = cylinderIn.placeVolume(cylinderFiller, 2, Position(0.0, 0.0, -0.5 * layerL + fillerDz));
251 for (
size_t i = 0;
i < ribW.size();
i++) {
252 name = idName +
"Rib" + std::to_string(
i);
253 double width = 2. * ribW[
i] / (rin + rout);
254 double dz = 0.5 * layerL - 2. * fillerDz;
255 double _rmi =
std::min(rin + 0.5_mm, rout - 0.5_mm);
256 double _rma =
std::max(rin + 0.5_mm, rout - 0.5_mm);
257 solid = ns.
addSolidNS(name, Tube(_rmi, _rma, dz, -0.5 * width, width));
259 <<
" to " << 0.5 *
convertRadToDeg(width) <<
" with Rin " << rin + 0.5_mm <<
" Rout " 260 << rout - 0.5_mm <<
" ZHalf " <<
dz;
262 double phix = ribPhi[
i];
263 double theta = 90_deg;
264 double phiy = phix + 90._deg;
266 Position tran(0, 0, 0);
267 pv = cylinderIn.placeVolume(cylinderRib, 1, Transform3D(rotation, tran));
276 rout = rin + MFRingT;
277 name = idName +
"InnerMFRing";
278 solid = ns.
addSolidNS(name, Tube(rin, rout, MFRingDz));
279 LogDebug(
"TIBGeom") << solid.name() <<
" Tubs made of " << MFIntRingMat <<
" from 0 to " <<
convertRadToDeg(2_pi)
280 <<
" with Rin " << rin <<
" Rout " << rout <<
" ZHalf " << MFRingDz;
284 pv = layer.placeVolume(inmfr, 1, Position(0.0, 0.0, -0.5 * layerL + MFRingDz));
287 pv = layer.placeVolume(inmfr, 2, Position(0.0, 0.0, +0.5 * layerL - MFRingDz));
292 rin = rout - MFRingT;
293 name = idName +
"OuterMFRing";
294 solid = ns.
addSolidNS(name, Tube(rin, rout, MFRingDz));
295 LogDebug(
"TIBGeom") << solid.name() <<
" Tubs made of " << MFExtRingMat <<
" from 0 to " <<
convertRadToDeg(2_pi)
296 <<
" with Rin " << rin <<
" Rout " << rout <<
" ZHalf " << MFRingDz;
299 pv = layer.placeVolume(outmfr, 1, Position(0.0, 0.0, -0.5 * layerL + MFRingDz));
301 pv = layer.placeVolume(outmfr, 2, Position(0.0, 0.0, +0.5 * layerL - MFRingDz));
308 double centZ = centRing1par[0];
309 double centDz = 0.5 * centRing1par[1];
310 rin = centRing1par[2];
311 rout = centRing1par[3];
312 name = idName +
"CentRing1";
313 solid = ns.
addSolidNS(name, Tube(rin, rout, centDz));
316 <<
" with Rin " << rin <<
" Rout " << rout <<
" ZHalf " << centDz;
319 pv = layer.placeVolume(cent1, 1, Position(0.0, 0.0, centZ));
322 centZ = centRing2par[0];
323 centDz = 0.5 * centRing2par[1];
324 rin = centRing2par[2];
325 rout = centRing2par[3];
326 name = idName +
"CentRing2";
327 solid = ns.
addSolidNS(name, Tube(rin, rout, centDz));
329 <<
" with Rin " << rin <<
" Rout " << rout <<
" ZHalf " << centDz;
332 pv = layer.placeVolume(cent2, 1, Position(0e0, 0e0, centZ));
340 name = idName +
"DOHMCarrier";
341 double dohmCarrierRin = MFRingOutR - MFRingT;
342 double dohmCarrierRout = MFRingOutR;
343 double dohmCarrierDz = 0.5 * (dohmPrimL + dohmtoMF);
344 double dohmCarrierZ = 0.5 * layerL - 2. * MFRingDz - dohmCarrierDz;
347 name, Tube(dohmCarrierRin, dohmCarrierRout, dohmCarrierDz, dohmCarrierPhiOff, 180._deg - dohmCarrierPhiOff));
348 LogDebug(
"TIBGeom") << solid.name() <<
" Tubs made of " << dohmCarrierMaterial <<
" from " << dohmCarrierPhiOff
349 <<
" to " << 180._deg - dohmCarrierPhiOff <<
" with Rin " << dohmCarrierRin <<
" Rout " 350 << MFRingOutR <<
" ZHalf " << dohmCarrierDz;
354 dphi = 2_pi / stringsUp;
356 Rotation3D dohmRotation;
357 double dohmR = 0.5 * (dohmCarrierRin + dohmCarrierRout);
359 for (
int j = 0;
j < 4;
j++) {
360 vector<double> dohmList;
364 int dohmCarrierReplica = 0;
369 name = idName +
"DOHMCarrierFW";
370 dohmList = dohmListFW;
371 tran = Position(0., 0., dohmCarrierZ);
372 rotstr = idName +
"FwUp";
373 rotation = Rotation3D();
374 dohmCarrierReplica = 1;
378 name = idName +
"DOHMCarrierFW";
379 dohmList = dohmListFW;
380 tran = Position(0., 0., dohmCarrierZ);
381 rotstr = idName +
"FwDown";
382 rotation =
makeRotation3D(90._deg, 180._deg, 90._deg, 270._deg, 0., 0.);
383 dohmCarrierReplica = 2;
387 name = idName +
"DOHMCarrierBW";
388 dohmList = dohmListBW;
389 tran = Position(0., 0., -dohmCarrierZ);
390 rotstr = idName +
"BwUp";
391 rotation =
makeRotation3D(90._deg, 180._deg, 90._deg, 90._deg, 180._deg, 0.);
392 dohmCarrierReplica = 1;
396 name = idName +
"DOHMCarrierBW";
397 dohmList = dohmListBW;
398 tran = Position(0., 0., -dohmCarrierZ);
399 rotstr = idName +
"BwDown";
400 rotation =
makeRotation3D(90._deg, 0., 90._deg, 270._deg, 180._deg, 0.);
401 dohmCarrierReplica = 2;
410 for (
size_t i = 0;
i < placeDohm * dohmList.size();
i++) {
411 double phi = (
std::abs(dohmList[
i]) + 0.5 - 1.) * dphi;
412 double phix = phi + 90_deg;
415 double theta = 90_deg;
416 double phiy = phix + 90._deg;
423 if (dohmList[i] < 0.) {
425 dohm = ns.
volume(dohmAuxName);
426 dohmZ = dohmCarrierDz - 0.5 * dohmAuxL - dohmtoMF;
428 dohmReplica = primReplica;
431 dohm = ns.
volume(dohmPrimName);
432 dohmZ = dohmCarrierDz - 0.5 * dohmPrimL - dohmtoMF;
434 dohmReplica = auxReplica;
436 Position dohmTrasl(dohmR *
cos(phi), dohmR *
sin(phi), dohmZ);
437 pv = dohmCarrier.placeVolume(dohm, dohmReplica, Transform3D(dohmRotation, dohmTrasl));
441 pv = layer.placeVolume(dohmCarrier, dohmCarrierReplica, Transform3D(rotation, tran));
446 for (
int j = 0;
j < 4;
j++) {
447 vector<double> pillarZ;
448 vector<double> pillarPhi;
449 double pillarDz = 0, pillarDPhi = 0, pillarRin = 0, pillarRout = 0;
453 name = idName +
"FWIntPillar";
454 pillarZ = fwIntPillarZ;
455 pillarPhi = fwIntPillarPhi;
456 pillarRin = MFRingInR;
457 pillarRout = MFRingInR + MFRingT;
458 pillarDz = fwIntPillarDz;
459 pillarDPhi = fwIntPillarDPhi;
462 name = idName +
"BWIntPillar";
463 pillarZ = bwIntPillarZ;
464 pillarPhi = bwIntPillarPhi;
465 pillarRin = MFRingInR;
466 pillarRout = MFRingInR + MFRingT;
467 pillarDz = bwIntPillarDz;
468 pillarDPhi = bwIntPillarDPhi;
471 name = idName +
"FWExtPillar";
472 pillarZ = fwExtPillarZ;
473 pillarPhi = fwExtPillarPhi;
474 pillarRin = MFRingOutR - MFRingT;
475 pillarRout = MFRingOutR;
476 pillarDz = fwExtPillarDz;
477 pillarDPhi = fwExtPillarDPhi;
480 name = idName +
"BWExtPillar";
481 pillarZ = bwExtPillarZ;
482 pillarPhi = bwExtPillarPhi;
483 pillarRin = MFRingOutR - MFRingT;
484 pillarRout = MFRingOutR;
485 pillarDz = bwExtPillarDz;
486 pillarDPhi = bwExtPillarDPhi;
490 solid = ns.
addSolidNS(name, Tube(pillarRin, pillarRout, pillarDz, -pillarDPhi, 2. * pillarDPhi));
492 LogDebug(
"TIBGeom") << solid.name() <<
" Tubs made of " << pillarMaterial <<
" from " << -pillarDPhi <<
" to " 493 << pillarDPhi <<
" with Rin " << pillarRin <<
" Rout " << pillarRout <<
" ZHalf " << pillarDz;
495 Rotation3D pillarRota;
496 int pillarReplica = 0;
497 for (
unsigned int i = 0;
i < pillarZ.size();
i++) {
498 if (pillarPhi[
i] > 0.) {
499 pillarTran = Position(0., 0., pillarZ[
i]);
500 pillarRota =
makeRotation3D(90._deg, pillarPhi[i], 90._deg, 90._deg + pillarPhi[i], 0., 0.);
501 pv = layer.placeVolume(Pillar, i, Transform3D(pillarRota, pillarTran));
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
dd4hep::Volume volume(const std::string &name, bool exc=true) const
constexpr NumType convertRadToDeg(NumType radians)
dd4hep::Volume addVolumeNS(dd4hep::Volume vol) const
Sin< T >::type sin(const T &t)
static long algorithm(Detector &, cms::DDParsingContext &context, xml_h element, SensitiveDetector &)
Geom::Theta< T > theta() const
int integer(const std::string &nam) const
Shortcut to access integer arguments.
dd4hep::Rotation3D makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
std::string_view name() const
dd4hep::PlacedVolume PlacedVolume
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
dd4hep::Material material(const std::string &name) const
Namespace of DDCMS conversion namespace.
std::vector< double > vecDble(const std::string &nam) const
Shortcut to access vector<double> arguments.
double dble(const std::string &nam) const
Shortcut to access double arguments.
#define DECLARE_DDCMS_DETELEMENT(name, func)
vector< double > VecDouble
std::string parentName() const
Access value of rParent child node.
std::string str(const std::string &nam) const
Shortcut to access string arguments.