14 #include "DD4hep/DetFactoryHelper.h"
98 nsectors =
args.value<
int>(
"Sector");
99 nsectortot =
args.value<
int>(
"SectorTot");
100 nEndcap =
args.value<
int>(
"Endcap");
102 zShift =
args.value<
double>(
"ZShift");
103 zFront =
args.value<
double>(
"ZFront");
104 zEnd =
args.value<
double>(
"ZEnd");
105 ziNose =
args.value<
double>(
"ZiNose");
106 ziL0Nose =
args.value<
double>(
"ZiL0Nose");
107 ziBody =
args.value<
double>(
"ZiBody");
108 ziL0Body =
args.value<
double>(
"ZiL0Body");
109 z0Beam =
args.value<
double>(
"Z0Beam");
110 ziDip =
args.value<
double>(
"ZiDip");
111 dzStep =
args.value<
double>(
"DzStep");
112 zShiftHac2 =
args.value<
double>(
"ZShiftHac2");
113 double gap =
args.value<
double>(
"Gap");
114 double z1 =
args.value<
double>(
"Z1");
115 double r1 =
args.value<
double>(
"R1");
116 rout =
args.value<
double>(
"Rout");
117 heboxDepth =
args.value<
double>(
"HEboxDepth");
118 drEnd =
args.value<
double>(
"DrEnd");
120 angBot =
args.value<
double>(
"AngBot");
121 angGap =
args.value<
double>(
"AngGap");
123 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: General material " << genMaterial <<
"\tSectors " << nsectors
124 <<
", " << nsectortot <<
"\tEndcaps " << nEndcap <<
"\tRotation matrix for half "
133 <<
" Gap angle " << angGap <<
" Z-Shift " <<
convertCmToMm(zShift) <<
" "
141 ziKink = z1Beam + rout /
slope;
142 riKink = ziKink *
tan(angBot);
143 riDip = ziDip *
tan(angBot);
144 roDip = rout - heboxDepth;
145 dzShift = (z1Beam - z0Beam) -
gap /
sin(angGap);
163 modName =
args.value<std::vector<std::string> >(
"ModuleName");
164 modMat =
args.value<std::vector<std::string> >(
"ModuleMat");
165 modType =
args.value<std::vector<int> >(
"ModuleType");
166 sectionModule =
args.value<std::vector<int> >(
"SectionModule");
167 thick =
args.value<std::vector<double> >(
"ModuleThick");
168 trimLeft =
args.value<std::vector<double> >(
"TrimLeft");
169 trimRight =
args.value<std::vector<double> >(
"TrimRight");
170 eModule =
args.value<std::vector<int> >(
"EquipModule");
171 layerN =
args.value<std::vector<int> >(
"LayerN");
172 layerN0 =
args.value<std::vector<int> >(
"LayerN0");
173 layerN1 =
args.value<std::vector<int> >(
"LayerN1");
174 layerN2 =
args.value<std::vector<int> >(
"LayerN2");
175 layerN3 =
args.value<std::vector<int> >(
"LayerN3");
176 layerN4 =
args.value<std::vector<int> >(
"LayerN4");
177 layerN5 =
args.value<std::vector<int> >(
"LayerN5");
180 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << modName[
i] <<
" type " << modType[
i] <<
" Sections "
181 << sectionModule[
i] <<
" thickness of absorber/air " <<
convertCmToMm(thick[
i])
183 <<
" equip module " << eModule[
i] <<
" with " << layerN[
i] <<
" layers";
185 for (
int j = 0;
j < layerN[
i];
j++) {
189 for (
int j = 0;
j < layerN[
i];
j++) {
193 for (
int j = 0;
j < layerN[
i];
j++) {
197 for (
int j = 0;
j < layerN[
i];
j++) {
201 for (
int j = 0;
j < layerN[
i];
j++) {
205 for (
int j = 0;
j < layerN[
i];
j++) {
214 phiSections =
args.value<
int>(
"PhiSections");
215 phiName =
args.value<std::vector<std::string> >(
"PhiName");
217 layerName =
args.value<std::vector<std::string> >(
"LayerName");
218 layerType =
args.value<std::vector<int> >(
"LayerType");
219 layerT =
args.value<std::vector<double> >(
"LayerT");
220 scintT =
args.value<std::vector<double> >(
"ScintT");
225 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: Phi Sections " << phiSections;
226 for (
int i = 0;
i < phiSections;
i++)
228 edm::LogVerbatim(
"HCalGeom") <<
"\tPlastic: " << plastMat <<
"\tScintillator: " << scintMat <<
"\tRotation matrix "
229 << rotmat <<
"\n\tNumber of layers " <<
layers;
231 edm::LogVerbatim(
"HCalGeom") <<
"\t" << layerName[
i] <<
"\tType " << layerType[
i] <<
"\tThickness "
241 zminBlock.emplace_back(ziL0Nose);
242 zmaxBlock.emplace_back(zminBlock[
module] + layerT[0] + 0.5 * dzStep);
243 rinBlock1.emplace_back(zminBlock[
module] *
tan(angTop));
244 rinBlock2.emplace_back(zmaxBlock[
module] *
tan(angTop));
245 routBlock1.emplace_back((zminBlock[
module] - z1Beam) *
slope);
246 routBlock2.emplace_back((zmaxBlock[
module] - z1Beam) *
slope);
251 zminBlock.emplace_back(ziL0Body);
252 zmaxBlock.emplace_back(zminBlock[
module] + layerT[0] + 0.5 * dzStep);
253 rinBlock1.emplace_back(zminBlock[
module] *
tan(angBot));
254 rinBlock2.emplace_back(zmaxBlock[
module] *
tan(angBot));
255 routBlock1.emplace_back(zminBlock[
module] *
tan(angTop));
256 routBlock2.emplace_back(zmaxBlock[
module] *
tan(angTop));
261 zminBlock.emplace_back(ziNose);
262 zmaxBlock.emplace_back(ziBody);
263 rinBlock1.emplace_back(zminBlock[
module] *
tan(angTop));
264 rinBlock2.emplace_back(zmaxBlock[
module] *
tan(angTop));
265 routBlock1.emplace_back((zminBlock[
module] - z1Beam) *
slope);
266 routBlock2.emplace_back((zmaxBlock[
module] - z1Beam) *
slope);
271 zminBlock.emplace_back(ziBody);
272 zmaxBlock.emplace_back(zminBlock[
module] + layerN[3] * dzStep);
273 rinBlock1.emplace_back(zminBlock[
module] *
tan(angBot));
274 rinBlock2.emplace_back(zmaxBlock[
module] *
tan(angBot));
275 routBlock1.emplace_back((zmaxBlock[
module - 1] - z1Beam) *
slope);
276 routBlock2.emplace_back(rout);
281 zminBlock.emplace_back(zmaxBlock[
module - 1]);
282 zmaxBlock.emplace_back(zminBlock[
module] + layerN[4] * dzStep);
283 rinBlock1.emplace_back(zminBlock[
module] *
tan(angBot));
284 rinBlock2.emplace_back(zmaxBlock[
module] *
tan(angBot));
285 routBlock1.emplace_back(rout);
286 routBlock2.emplace_back(rout);
291 zminBlock.emplace_back(zmaxBlock[
module - 1]);
292 zmaxBlock.emplace_back(zminBlock[
module] + layerN[5] * dzStep);
293 rinBlock1.emplace_back(zminBlock[
module] *
tan(angBot));
294 rinBlock2.emplace_back(zmaxBlock[
module] *
tan(angBot));
295 routBlock1.emplace_back(rout);
296 routBlock2.emplace_back(roDip);
308 idOffset =
args.value<
int>(
"IdOffset");
311 <<
" NameSpace " << ns.
name() <<
" Offset " << idOffset;
314 tolPos =
args.value<
double>(
"TolPos");
315 tolAbs =
args.value<
double>(
"TolAbs");
323 constructGeneralVolume(ns,
parent);
325 edm::LogVerbatim(
"HCalGeom") <<
"<<== End of DDHCalEndcapAlgo construction ...";
335 for (
int i = 0;
i < 3;
i++)
339 dd4hep::Rotation3D
rot = getRotation(
rotation, ns);
345 double alpha = (1._pi) / nsectors;
346 double dphi = nsectortot * (2._pi) / nsectors;
352 std::vector<double> pgonZ, pgonRmin, pgonRmax;
354 double zf = ziBody + zShiftHac2;
355 pgonZ.emplace_back(zf - dzShift);
356 pgonRmin.emplace_back(zf *
tan(angBot));
357 pgonRmax.emplace_back((zf - z1Beam) *
slope);
359 pgonZ.emplace_back(zFront - dzShift);
360 pgonRmin.emplace_back(zFront *
tan(angTop));
361 pgonRmax.emplace_back((zFront - z1Beam) *
slope);
362 pgonZ.emplace_back(ziL0Body - dzShift);
363 pgonRmin.emplace_back(ziL0Body *
tan(angTop));
364 pgonRmax.emplace_back((ziL0Body - z1Beam) *
slope);
365 pgonZ.emplace_back(ziL0Body - dzShift);
366 pgonRmin.emplace_back(ziL0Body *
tan(angBot));
367 pgonRmax.emplace_back((ziL0Body - z1Beam) *
slope);
369 pgonZ.emplace_back(ziKink - dzShift);
370 pgonRmin.emplace_back(riKink);
371 pgonRmax.emplace_back(rout);
372 pgonZ.emplace_back(ziDip - dzShift);
373 pgonRmin.emplace_back(riDip);
374 pgonRmax.emplace_back(rout);
375 pgonZ.emplace_back(ziDip - dzShift + delz);
376 pgonRmin.emplace_back(riDip);
377 pgonRmax.emplace_back(roDip);
378 pgonZ.emplace_back(zEnd - dzShift);
379 pgonRmin.emplace_back(zEnd *
tan(angBot));
380 pgonRmax.emplace_back(roDip);
381 pgonZ.emplace_back(zEnd);
382 pgonRmin.emplace_back(zEnd *
tan(angBot));
383 pgonRmax.emplace_back(roDip);
388 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << solid.name() <<
" Polyhedra made of " << genMaterial
391 for (
unsigned int i = 0;
i < pgonZ.size();
i++)
398 parent.placeVolume(genlogic, 1, dd4hep::Transform3D(
rot, r0));
400 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << genlogic.name() <<
" number 1 positioned in "
402 <<
") with rotation: " <<
rot;
406 rot = getRotation(rotHalf, ns);
407 parent.placeVolume(genlogic, 2, dd4hep::Transform3D(
rot, r0));
409 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << genlogic.name() <<
" number 2 "
411 <<
") with rotation: " <<
rot;
417 std::vector<double> pgonZMod, pgonRminMod, pgonRmaxMod;
418 for (
unsigned int i = 0;
i < (pgonZ.size() - 1);
i++) {
419 pgonZMod.emplace_back(pgonZ[
i] + dzShift);
420 pgonRminMod.emplace_back(pgonRmin[
i]);
421 pgonRmaxMod.emplace_back(pgonRmax[
i]);
425 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << solid.name() <<
" Polyhedra made of " << genMaterial
428 for (
unsigned int i = 0;
i < pgonZMod.size();
i++)
438 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << genlogich.name() <<
" number 1 positioned in "
439 << genlogic.name() <<
" at (0,0," << -
convertCmToMm(dzShift) <<
") with no rotation";
446 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << solid.name() <<
" Polyhedra made of " << genMaterial
449 for (
unsigned int i = 0;
i < pgonZMod.size();
i++)
456 for (
int ii = 0;
ii < nsectortot;
ii++) {
458 dd4hep::Rotation3D rot0;
460 rot0 = dd4hep::RotationZ(phi);
466 genlogich.placeVolume(seclogic,
ii + 1, rot0);
468 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << seclogic.name() <<
" number " <<
ii + 1
469 <<
" positioned in " << genlogich.name() <<
" at (0, 0, 0) with rotation: " << rot0;
474 constructInsideSector(ns, seclogic);
478 std::vector<double> pgonZBack, pgonRminBack, pgonRmaxBack;
479 pgonZBack.emplace_back(zEnd - dzShift);
480 pgonRminBack.emplace_back(pgonZBack[0] *
tan(angBot) + drEnd);
481 pgonRmaxBack.emplace_back(roDip);
482 pgonZBack.emplace_back(zEnd);
483 pgonRminBack.emplace_back(pgonZBack[1] *
tan(angBot) + drEnd);
484 pgonRmaxBack.emplace_back(roDip);
487 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << solid.name() <<
" Polyhedra made of " << absMat <<
" with "
490 for (
unsigned int i = 0;
i < pgonZBack.size();
i++)
498 genlogic.placeVolume(glog, 1);
500 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << glog.name() <<
" number 1 positioned in " << genlogic.name()
501 <<
" at (0,0,0) with no rotation";
510 double alpha = (1._pi) / nsectors;
515 if (eModule[
i] > 0) {
516 int nsec = sectionModule[
i];
522 std::vector<double> pgonZ, pgonRmin, pgonRmax;
524 double zf = zminBlock[
i] + zShiftHac2;
525 pgonZ.emplace_back(zf);
526 pgonRmin.emplace_back(zf *
tan(angBot));
527 pgonRmax.emplace_back((zf - z1Beam) *
slope);
528 pgonZ.emplace_back(ziKink);
529 pgonRmin.emplace_back(riKink);
530 pgonRmax.emplace_back(rout);
532 pgonZ.emplace_back(zminBlock[
i]);
533 pgonRmin.emplace_back(rinBlock1[
i]);
534 pgonRmax.emplace_back(routBlock1[
i]);
537 pgonZ.emplace_back(ziDip);
538 pgonRmin.emplace_back(riDip);
539 pgonRmax.emplace_back(rout);
540 pgonZ.emplace_back(pgonZ[1] + deltaz);
541 pgonRmin.emplace_back(pgonRmin[1]);
542 pgonRmax.emplace_back(roDip);
544 pgonZ.emplace_back(zmaxBlock[
i]);
545 pgonRmin.emplace_back(rinBlock2[
i]);
546 pgonRmax.emplace_back(routBlock2[
i]);
551 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << solid.name() <<
" Polyhedra made of " << modMat[
i]
554 for (
unsigned int k = 0;
k < pgonZ.size();
k++)
562 sector.placeVolume(glog,
i + 1);
564 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << glog.name() <<
" number " <<
i + 1 <<
" positioned in "
565 << sector.name() <<
" at (0,0,0) with no rotation";
569 constructInsideModule0(ns, glog,
i);
571 constructInsideModule(ns, glog,
i);
583 dd4hep::Rotation3D
rot = getRotation(rotmat, ns);
587 int layer = getLayer(
mod, 0);
588 int layer0 = getLayer(
mod, 1);
590 double xpos, ypos, zpos;
594 double yh, bl, tl, alp;
595 parameterLayer0(
mod, layer,
iphi, yh, bl, tl, alp, xpos, ypos, zpos);
597 solid = dd4hep::Trap(ns.
prepend(
name), 0.5 * layerT[layer], 0, 0, yh, bl, tl, alp, yh, bl, tl, alp);
599 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << solid.name() <<
" Trap made of " << plastMat
600 <<
" of dimensions " <<
convertCmToMm(0.5 * layerT[layer]) <<
", 0, 0, "
609 module.placeVolume(glog, idOffset + layer + 1, dd4hep::Transform3D(
rot,
r1));
612 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << glog.name() <<
" number " << (idOffset + layer + 1)
618 int copyNo = layer0 * 10 + layerType[layer];
619 name = modName[
mod] + layerName[layer] + phiName[
iphi];
620 constructScintLayer(ns, glog, scintT[layer], yh, bl, tl, alp,
name, copyNo);
624 double zi = zminBlock[
mod] + layerT[layer];
625 double zo = zi + 0.5 * dzStep;
626 double rinF, routF, rinB, routB;
628 rinF = zi *
tan(angTop);
629 routF = (zi - z1Beam) *
slope;
630 rinB = zo *
tan(angTop);
631 routB = (zo - z1Beam) *
slope;
633 rinF = zi *
tan(angBot);
634 routF = zi *
tan(angTop);
635 rinB = zo *
tan(angBot);
636 routB = zo *
tan(angTop);
645 double yh1, bl1, tl1, yh2, bl2, tl2,
theta, phi, alp;
647 0, rinF, routF, rinB, routB, zi, zo, yh1, bl1, tl1, yh2, bl2, tl2, alp,
theta, phi, xpos, ypos, zpos);
648 double fact = tolAbs;
662 solid = dd4hep::Trap(ns.
prepend(
name), 0.5 * thick[
mod],
theta, phi, yh1, bl1, tl1, alp, yh2, bl2, tl2, alp);
664 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << solid.name() <<
" Trap made of " << absMat
675 module.placeVolume(glog, 1, dd4hep::Transform3D(
rot,
r2));
678 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << glog.name() <<
" number 1 positioned in " <<
module.name()
691 dd4hep::Rotation3D
rot = getRotation(rotmat, ns);
695 double alpha = (1._pi) / nsectors;
696 double zi = zminBlock[
mod];
698 for (
int i = 0;
i < layerN[
mod];
i++) {
702 int layer = getLayer(
mod,
i);
703 double zo = zi + 0.5 * dzStep;
706 double ziAir = zo - thick[
mod];
709 rinF = ziAir *
tan(angTop);
710 rinB = zo *
tan(angTop);
712 rinF = ziAir *
tan(angBot);
713 rinB = zo *
tan(angBot);
715 double routF = (ziAir - z1Beam) *
slope;
716 double routB = (zo - z1Beam) *
slope;
717 if (routF > routBlock2[
mod])
718 routF = routBlock2[
mod];
719 if (routB > routBlock2[
mod])
720 routB = routBlock2[
mod];
729 double yh1, bl1, tl1, yh2, bl2, tl2,
theta, phi, alp;
730 double xpos, ypos, zpos;
732 iphi, rinF, routF, rinB, routB, ziAir, zo, yh1, bl1, tl1, yh2, bl2, tl2, alp,
theta, phi, xpos, ypos, zpos);
735 solid = dd4hep::Trap(ns.
prepend(
name), 0.5 * thick[
mod],
theta, phi, yh1, bl1, tl1, alp, yh2, bl2, tl2, alp);
737 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << solid.name() <<
" Trap made of " << matter.name()
748 module.placeVolume(glog, layer + 1, dd4hep::Transform3D(
rot,
r1));
751 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << glog.name() <<
" number " << (layer + 1)
754 <<
") with rotation: " <<
rot;
758 double yh = 0.5 * (routF - rinB) - getTrim(
mod,
iphi);
762 solid = dd4hep::Trap(ns.
prepend(
name), 0.5 * layerT[layer], 0, 0, yh, bl, tl, alp, yh, bl, tl, alp);
764 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << solid.name() <<
" Trap made of " << plastMat
765 <<
" of dimensions " <<
convertCmToMm(0.5 * layerT[layer]) <<
", 0, 0, "
772 ypos = 0.5 * (routF + rinB) - xpos;
773 glog.placeVolume(plog, idOffset + layer + 1,
dd4hep::Position(0., ypos, 0.));
776 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << plog.name() <<
" number " << (idOffset + layer + 1)
777 <<
" positioned in " << glog.name() <<
" at (0, " <<
convertCmToMm(ypos)
778 <<
", 0) with no rotation";
782 int copyNo = layer * 10 + layerType[layer];
783 name = modName[
mod] + layerName[layer] + phiName[
iphi];
784 constructScintLayer(ns, plog, scintT[layer], yh, bl, tl, alp,
name, copyNo);
787 zi = zo - 0.5 * dzStep;
803 dd4hep::Solid solid = dd4hep::Trap(ns.
prepend(
name), 0.5 *
dz, 0, 0, yh, bl, tl, alp, yh, bl, tl, alp);
805 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << solid.name() <<
" Trap made of " << scintMat
815 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << glog.name() <<
" number " <<
id <<
" positioned in "
816 <<
detector.name() <<
" at (0,0,0) with no rotation";
864 double alpha = (1._pi) / nsectors;
873 zo = zi + layerT[layer];
876 zi = zo - layerT[layer];
880 rin = zo *
tan(angTop);
881 rout = (zi - z1Beam) *
slope;
883 rin = zo *
tan(angBot);
884 rout = zi *
tan(angTop);
886 yh = 0.5 * (rout - rin);
889 xpos = 0.5 * (rin + rout);
890 ypos = 0.5 * (bl + tl);
891 zpos = 0.5 * (zi + zo);
930 double alpha = (1._pi) / nsectors;
939 yh1 = 0.5 * (routF - rinB);
942 yh2 = 0.5 * (routF - rinB);
945 double dx = 0.25 * (bl2 + tl2 - bl1 - tl1);
946 double dy = 0.5 * (rinB + routF - rinB - routF);
947 xpos = 0.25 * (rinB + routF + rinB + routF);
948 ypos = 0.25 * (bl2 + tl2 + bl1 + tl1);
949 zpos = 0.5 * (zi + zo);
959 theta = atan(
r / (zo - zi));
983 dd4hep::SensitiveDetector& ) {