1 #include "DD4hep/DetFactoryHelper.h"
2 #include <DD4hep/DD4hepUnits.h>
18 string mother =
args.parentName();
19 string genMat =
args.str(
"GeneralMaterial");
20 double detectorTilt =
args.dble(
"DetectorTilt");
21 double layerL =
args.dble(
"LayerL");
23 double radiusLo =
args.dble(
"RadiusLo");
24 int stringsLo =
args.integer(
"StringsLo");
25 string detectorLo =
args.str(
"StringDetLoName");
27 double radiusUp =
args.dble(
"RadiusUp");
28 int stringsUp =
args.integer(
"StringsUp");
29 string detectorUp =
args.str(
"StringDetUpName");
31 double cylinderT =
args.dble(
"CylinderThickness");
32 double cylinderInR =
args.dble(
"CylinderInnerRadius");
33 string cylinderMat =
args.str(
"CylinderMaterial");
34 double MFRingInR =
args.dble(
"MFRingInnerRadius");
35 double MFRingOutR =
args.dble(
"MFRingOuterRadius");
36 double MFRingT =
args.dble(
"MFRingThickness");
37 double MFRingDz =
args.dble(
"MFRingDeltaz");
38 string MFIntRingMat =
args.str(
"MFIntRingMaterial");
39 string MFExtRingMat =
args.str(
"MFExtRingMaterial");
41 double supportT =
args.dble(
"SupportThickness");
43 string centMat =
args.str(
"CentRingMaterial");
47 string fillerMat =
args.str(
"FillerMaterial");
48 double fillerDz =
args.dble(
"FillerDeltaz");
50 string ribMat =
args.str(
"RibMaterial");
57 double dohmtoMF =
args.dble(
"DOHMtoMFDist");
58 double dohmCarrierPhiOff =
args.dble(
"DOHMCarrierPhiOffset");
59 string dohmPrimName =
args.str(
"StringDOHMPrimName");
60 string dohmAuxName =
args.str(
"StringDOHMAuxName");
62 string dohmCarrierMaterial =
args.str(
"DOHMCarrierMaterial");
63 string dohmCableMaterial =
args.str(
"DOHMCableMaterial");
64 double dohmPrimL =
args.dble(
"DOHMPRIMLength");
65 string dohmPrimMaterial =
args.str(
"DOHMPRIMMaterial");
66 double dohmAuxL =
args.dble(
"DOHMAUXLength");
67 string dohmAuxMaterial =
args.str(
"DOHMAUXMaterial");
69 string pillarMaterial =
args.str(
"PillarMaterial");
71 double fwIntPillarDz =
args.dble(
"FWIntPillarDz");
72 double fwIntPillarDPhi =
args.dble(
"FWIntPillarDPhi");
75 double bwIntPillarDz =
args.dble(
"BWIntPillarDz");
76 double bwIntPillarDPhi =
args.dble(
"BWIntPillarDPhi");
80 double fwExtPillarDz =
args.dble(
"FWExtPillarDz");
81 double fwExtPillarDPhi =
args.dble(
"FWExtPillarDPhi");
84 double bwExtPillarDz =
args.dble(
"BWExtPillarDz");
85 double bwExtPillarDPhi =
args.dble(
"BWExtPillarDPhi");
93 <<
" positioned: " << pvl.motherVol()->GetName() <<
" " << pvl.position();
96 LogDebug(
"TIBGeom") <<
"Parent " << mother <<
" NameSpace " << ns.
name() <<
" General Material " << genMat;
97 LogDebug(
"TIBGeom") <<
"Lower layer Radius " << radiusLo <<
" Number " << stringsLo <<
" String " << detectorLo;
98 LogDebug(
"TIBGeom") <<
"Upper layer Radius " << radiusUp <<
" Number " << stringsUp <<
" String " << detectorUp;
99 LogDebug(
"TIBGeom") <<
"Cylinder Material/thickness " << cylinderMat <<
" " << cylinderT <<
" Rib Material " << ribMat
100 <<
" at " << ribW.size() <<
" positions with width/phi";
101 for (
unsigned int i = 0;
i < ribW.size();
i++) {
102 LogDebug(
"TIBGeom") <<
"\tribW[" <<
i <<
"] = " << ribW[
i] <<
"\tribPhi[" <<
i
105 LogDebug(
"TIBGeom") <<
"DOHM Primary "
106 <<
" Material " << dohmPrimMaterial <<
" Length " << dohmPrimL;
108 <<
" Material " << dohmAuxMaterial <<
" Length " << dohmAuxL;
109 for (
double i : dohmListFW) {
111 LogDebug(
"TIBGeom") <<
"DOHM Primary at FW Position " <<
i;
113 LogDebug(
"TIBGeom") <<
"DOHM Aux at FW Position " << -
i;
115 for (
double i : dohmListBW) {
117 LogDebug(
"TIBGeom") <<
"DOHM Primary at BW Position " <<
i;
119 LogDebug(
"TIBGeom") <<
"DOHM Aux at BW Position " << -
i;
121 LogDebug(
"TIBGeom") <<
"FW Internal Pillar [Dz, DPhi] " << fwIntPillarDz <<
", " << fwIntPillarDPhi;
122 for (
unsigned int i = 0;
i < fwIntPillarZ.size();
i++) {
123 if (fwIntPillarPhi[
i] > 0.) {
124 LogDebug(
"TIBGeom") <<
" at positions [z, phi] " << fwIntPillarZ[
i] <<
" " << fwIntPillarPhi[
i];
127 LogDebug(
"TIBGeom") <<
"BW Internal Pillar [Dz, DPhi] " << bwIntPillarDz <<
", " << bwIntPillarDPhi;
128 for (
unsigned int i = 0;
i < bwIntPillarZ.size();
i++) {
129 if (bwIntPillarPhi[
i] > 0.) {
130 LogDebug(
"TIBGeom") <<
" at positions [z, phi] " << bwIntPillarZ[
i] <<
" " << bwIntPillarPhi[
i];
133 LogDebug(
"TIBGeom") <<
"FW External Pillar [Dz, DPhi] " << fwExtPillarDz <<
", " << fwExtPillarDPhi;
134 for (
unsigned int i = 0;
i < fwExtPillarZ.size();
i++) {
135 if (fwExtPillarPhi[
i] > 0.) {
136 LogDebug(
"TIBGeom") <<
" at positions [z, phi] " << fwExtPillarZ[
i] <<
" " << fwExtPillarPhi[
i];
139 LogDebug(
"TIBGeom") <<
"BW External Pillar [Dz, DPhi] " << bwExtPillarDz <<
", " << bwExtPillarDPhi;
140 for (
unsigned int i = 0;
i < bwExtPillarZ.size();
i++) {
141 if (bwExtPillarPhi[
i] > 0.) {
142 LogDebug(
"TIBGeom") <<
" at positions [z, phi] " << bwExtPillarZ[
i] <<
" " << bwExtPillarPhi[
i];
146 const string&
idName = mother;
147 double rmin = MFRingInR;
148 double rmax = MFRingOutR;
151 <<
" with Rin " << rmin <<
" Rout " << rmax <<
" ZHalf " << 0.5 * layerL;
155 double rin = rmin + MFRingT;
157 double rout = cylinderInR;
161 <<
" with Rin " << rin <<
" Rout " << rout <<
" ZHalf " << 0.5 * layerL;
163 pv =
layer.placeVolume(layerIn, 1);
166 double rposdet = radiusLo;
167 double dphi = 2_pi / stringsLo;
169 for (
int n = 0;
n < stringsLo;
n++) {
170 double phi = (
n + 0.5) * dphi;
171 double phix = phi - detectorTilt + 90_deg;
172 double theta = 90_deg;
173 double phiy = phix + 90._deg;
176 pv = layerIn.placeVolume(detIn,
n + 1, Transform3D(
rotation, trdet));
180 rin = cylinderInR + cylinderT;
181 rout = rmax - MFRingT;
185 <<
" with Rin " << rin <<
" Rout " << rout <<
" ZHalf " << 0.5 * layerL;
187 pv =
layer.placeVolume(layerOut, 1);
191 dphi = 2_pi / stringsUp;
193 for (
int n = 0;
n < stringsUp;
n++) {
194 double phi = (
n + 0.5) * dphi;
195 double phix = phi - detectorTilt - 90_deg;
196 double theta = 90_deg;
197 double phiy = phix + 90._deg;
200 pv = layerOut.placeVolume(detOut,
n + 1, Transform3D(
rotation, trdet));
209 rout = cylinderInR + cylinderT;
212 LogDebug(
"TIBGeom") << solid.name() <<
" Tubs made of " << cylinderMat <<
" from 0 to " <<
convertRadToDeg(2_pi)
213 <<
" with Rin " << rin <<
" Rout " << rout <<
" ZHalf " << 0.5 * layerL;
215 pv =
layer.placeVolume(cylinder, 1);
226 <<
" with Rin " << rin <<
" Rout " << rout <<
" ZHalf " << 0.5 * layerL;
228 pv = cylinder.placeVolume(cylinderIn, 1);
236 LogDebug(
"TIBGeom") << solid.name() <<
" Tubs made of " << fillerMat <<
" from " << 0. <<
" to "
237 <<
convertRadToDeg(2_pi) <<
" with Rin " << rin <<
" Rout " << rout <<
" ZHalf " << fillerDz;
239 pv = cylinderIn.placeVolume(cylinderFiller, 1,
Position(0.0, 0.0, 0.5 * layerL - fillerDz));
242 pv = cylinderIn.placeVolume(cylinderFiller, 2,
Position(0.0, 0.0, -0.5 * layerL + fillerDz));
249 for (
size_t i = 0;
i < ribW.size();
i++) {
251 double width = 2. * ribW[
i] / (rin + rout);
252 double dz = 0.5 * layerL - 2. * fillerDz;
253 double _rmi =
std::min(rin + 0.5 * dd4hep::mm, rout - 0.5 * dd4hep::mm);
254 double _rma =
std::max(rin + 0.5 * dd4hep::mm, rout - 0.5 * dd4hep::mm);
258 << rout - 0.5 * dd4hep::mm <<
" ZHalf " <<
dz;
260 double phix = ribPhi[
i];
261 double theta = 90_deg;
262 double phiy = phix + 90._deg;
265 pv = cylinderIn.placeVolume(cylinderRib, 1, Transform3D(
rotation, tran));
274 rout = rin + MFRingT;
277 LogDebug(
"TIBGeom") << solid.name() <<
" Tubs made of " << MFIntRingMat <<
" from 0 to " <<
convertRadToDeg(2_pi)
278 <<
" with Rin " << rin <<
" Rout " << rout <<
" ZHalf " << MFRingDz;
282 pv =
layer.placeVolume(inmfr, 1,
Position(0.0, 0.0, -0.5 * layerL + MFRingDz));
285 pv =
layer.placeVolume(inmfr, 2,
Position(0.0, 0.0, +0.5 * layerL - MFRingDz));
290 rin = rout - MFRingT;
293 LogDebug(
"TIBGeom") << solid.name() <<
" Tubs made of " << MFExtRingMat <<
" from 0 to " <<
convertRadToDeg(2_pi)
294 <<
" with Rin " << rin <<
" Rout " << rout <<
" ZHalf " << MFRingDz;
297 pv =
layer.placeVolume(outmfr, 1,
Position(0.0, 0.0, -0.5 * layerL + MFRingDz));
299 pv =
layer.placeVolume(outmfr, 2,
Position(0.0, 0.0, +0.5 * layerL - MFRingDz));
306 double centZ = centRing1par[0];
307 double centDz = 0.5 * centRing1par[1];
308 rin = centRing1par[2];
309 rout = centRing1par[3];
314 <<
" with Rin " << rin <<
" Rout " << rout <<
" ZHalf " << centDz;
320 centZ = centRing2par[0];
321 centDz = 0.5 * centRing2par[1];
322 rin = centRing2par[2];
323 rout = centRing2par[3];
327 <<
" with Rin " << rin <<
" Rout " << rout <<
" ZHalf " << centDz;
339 double dohmCarrierRin = MFRingOutR - MFRingT;
340 double dohmCarrierRout = MFRingOutR;
341 double dohmCarrierDz = 0.5 * (dohmPrimL + dohmtoMF);
342 double dohmCarrierZ = 0.5 * layerL - 2. * MFRingDz - dohmCarrierDz;
345 name, Tube(dohmCarrierRin, dohmCarrierRout, dohmCarrierDz, dohmCarrierPhiOff, 180._deg - dohmCarrierPhiOff));
346 LogDebug(
"TIBGeom") << solid.name() <<
" Tubs made of " << dohmCarrierMaterial <<
" from " << dohmCarrierPhiOff
347 <<
" to " << 180._deg - dohmCarrierPhiOff <<
" with Rin " << dohmCarrierRin <<
" Rout "
348 << MFRingOutR <<
" ZHalf " << dohmCarrierDz;
352 dphi = 2_pi / stringsUp;
354 Rotation3D dohmRotation;
355 double dohmR = 0.5 * (dohmCarrierRin + dohmCarrierRout);
357 for (
int j = 0;
j < 4;
j++) {
358 vector<double> dohmList;
362 int dohmCarrierReplica = 0;
371 dohmList = dohmListFW;
372 tran =
Position(0., 0., dohmCarrierZ);
375 dohmCarrierReplica = 1;
381 dohmList = dohmListFW;
382 tran =
Position(0., 0., dohmCarrierZ);
383 rotstr =
idName +
"FwDown";
385 dohmCarrierReplica = 2;
391 dohmList = dohmListBW;
392 tran =
Position(0., 0., -dohmCarrierZ);
395 dohmCarrierReplica = 1;
401 dohmList = dohmListBW;
402 tran =
Position(0., 0., -dohmCarrierZ);
403 rotstr =
idName +
"BwDown";
405 dohmCarrierReplica = 2;
413 for (
size_t i = 0;
i < placeDohm * dohmList.size();
i++) {
414 double phi = (
std::abs(dohmList[
i]) + 0.5 - 1.) * dphi;
415 double phix = phi + 90_deg;
418 double theta = 90_deg;
419 double phiy = phix + 90._deg;
426 if (dohmList[
i] < 0.) {
428 dohm = ns.
volume(dohmAuxName);
429 dohmZ = dohmCarrierDz - 0.5 * dohmAuxL - dohmtoMF;
431 dohmReplica = primReplica;
434 dohm = ns.
volume(dohmPrimName);
435 dohmZ = dohmCarrierDz - 0.5 * dohmPrimL - dohmtoMF;
437 dohmReplica = auxReplica;
440 pv = dohmCarrier.placeVolume(dohm, dohmReplica, Transform3D(dohmRotation, dohmTrasl));
444 pv =
layer.placeVolume(dohmCarrier, dohmCarrierReplica, Transform3D(
rotation, tran));
449 for (
int j = 0;
j < 4;
j++) {
450 vector<double> pillarZ;
451 vector<double> pillarPhi;
452 double pillarDz = 0, pillarDPhi = 0, pillarRin = 0, pillarRout = 0;
457 pillarZ = fwIntPillarZ;
458 pillarPhi = fwIntPillarPhi;
459 pillarRin = MFRingInR;
460 pillarRout = MFRingInR + MFRingT;
461 pillarDz = fwIntPillarDz;
462 pillarDPhi = fwIntPillarDPhi;
466 pillarZ = bwIntPillarZ;
467 pillarPhi = bwIntPillarPhi;
468 pillarRin = MFRingInR;
469 pillarRout = MFRingInR + MFRingT;
470 pillarDz = bwIntPillarDz;
471 pillarDPhi = bwIntPillarDPhi;
475 pillarZ = fwExtPillarZ;
476 pillarPhi = fwExtPillarPhi;
477 pillarRin = MFRingOutR - MFRingT;
478 pillarRout = MFRingOutR;
479 pillarDz = fwExtPillarDz;
480 pillarDPhi = fwExtPillarDPhi;
484 pillarZ = bwExtPillarZ;
485 pillarPhi = bwExtPillarPhi;
486 pillarRin = MFRingOutR - MFRingT;
487 pillarRout = MFRingOutR;
488 pillarDz = bwExtPillarDz;
489 pillarDPhi = bwExtPillarDPhi;
493 solid = ns.
addSolidNS(
name, Tube(pillarRin, pillarRout, pillarDz, -pillarDPhi, 2. * pillarDPhi));
495 LogDebug(
"TIBGeom") << solid.name() <<
" Tubs made of " << pillarMaterial <<
" from " << -pillarDPhi <<
" to "
496 << pillarDPhi <<
" with Rin " << pillarRin <<
" Rout " << pillarRout <<
" ZHalf " << pillarDz;
498 Rotation3D pillarRota;
499 int pillarReplica = 0;
500 for (
unsigned int i = 0;
i < pillarZ.size();
i++) {
501 if (pillarPhi[
i] > 0.) {
502 pillarTran =
Position(0., 0., pillarZ[
i]);
503 pillarRota =
makeRotation3D(90._deg, pillarPhi[
i], 90._deg, 90._deg + pillarPhi[
i], 0., 0.);
504 pv =
layer.placeVolume(Pillar,
i, Transform3D(pillarRota, pillarTran));