14 #include "DD4hep/DetFactoryHelper.h"
99 nsectors =
args.value<
int>(
"Sector");
100 nsectortot =
args.value<
int>(
"SectorTot");
101 nEndcap =
args.value<
int>(
"Endcap");
103 zShift =
args.value<
double>(
"ZShift");
104 zFront =
args.value<
double>(
"ZFront");
105 zEnd =
args.value<
double>(
"ZEnd");
106 ziNose =
args.value<
double>(
"ZiNose");
107 ziL0Nose =
args.value<
double>(
"ZiL0Nose");
108 ziBody =
args.value<
double>(
"ZiBody");
109 ziL0Body =
args.value<
double>(
"ZiL0Body");
110 z0Beam =
args.value<
double>(
"Z0Beam");
111 ziDip =
args.value<
double>(
"ZiDip");
112 dzStep =
args.value<
double>(
"DzStep");
113 zShiftHac2 =
args.value<
double>(
"ZShiftHac2");
114 double gap =
args.value<
double>(
"Gap");
115 double z1 =
args.value<
double>(
"Z1");
116 double r1 =
args.value<
double>(
"R1");
117 rout =
args.value<
double>(
"Rout");
118 heboxDepth =
args.value<
double>(
"HEboxDepth");
119 drEnd =
args.value<
double>(
"DrEnd");
121 angBot =
args.value<
double>(
"AngBot");
122 angGap =
args.value<
double>(
"AngGap");
124 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: General material " << genMaterial <<
"\tSectors " << nsectors
125 <<
", " << nsectortot <<
"\tEndcaps " << nEndcap <<
"\tRotation matrix for half "
134 <<
etamin <<
" Bottom angle " << angBot <<
" Gap angle " << angGap <<
" Z-Shift "
142 ziKink = z1Beam + rout /
slope;
143 riKink = ziKink *
tan(angBot);
144 riDip = ziDip *
tan(angBot);
145 roDip = rout - heboxDepth;
146 dzShift = (z1Beam - z0Beam) -
gap /
sin(angGap);
164 modName =
args.value<std::vector<std::string> >(
"ModuleName");
165 modMat =
args.value<std::vector<std::string> >(
"ModuleMat");
166 modType =
args.value<std::vector<int> >(
"ModuleType");
167 sectionModule =
args.value<std::vector<int> >(
"SectionModule");
168 thick =
args.value<std::vector<double> >(
"ModuleThick");
169 trimLeft =
args.value<std::vector<double> >(
"TrimLeft");
170 trimRight =
args.value<std::vector<double> >(
"TrimRight");
171 eModule =
args.value<std::vector<int> >(
"EquipModule");
172 layerN =
args.value<std::vector<int> >(
"LayerN");
173 layerN0 =
args.value<std::vector<int> >(
"LayerN0");
174 layerN1 =
args.value<std::vector<int> >(
"LayerN1");
175 layerN2 =
args.value<std::vector<int> >(
"LayerN2");
176 layerN3 =
args.value<std::vector<int> >(
"LayerN3");
177 layerN4 =
args.value<std::vector<int> >(
"LayerN4");
178 layerN5 =
args.value<std::vector<int> >(
"LayerN5");
181 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << modName[
i] <<
" type " << modType[
i] <<
" Sections "
182 << sectionModule[
i] <<
" thickness of absorber/air " <<
cms::convert2mm(thick[
i])
184 <<
" equip module " << eModule[
i] <<
" with " << layerN[
i] <<
" layers";
186 for (
int j = 0;
j < layerN[
i];
j++) {
190 for (
int j = 0;
j < layerN[
i];
j++) {
194 for (
int j = 0;
j < layerN[
i];
j++) {
198 for (
int j = 0;
j < layerN[
i];
j++) {
202 for (
int j = 0;
j < layerN[
i];
j++) {
206 for (
int j = 0;
j < layerN[
i];
j++) {
215 phiSections =
args.value<
int>(
"PhiSections");
216 phiName =
args.value<std::vector<std::string> >(
"PhiName");
218 layerName =
args.value<std::vector<std::string> >(
"LayerName");
219 layerType =
args.value<std::vector<int> >(
"LayerType");
220 layerT =
args.value<std::vector<double> >(
"LayerT");
221 scintT =
args.value<std::vector<double> >(
"ScintT");
226 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: Phi Sections " << phiSections;
227 for (
int i = 0;
i < phiSections;
i++)
229 edm::LogVerbatim(
"HCalGeom") <<
"\tPlastic: " << plastMat <<
"\tScintillator: " << scintMat <<
"\tRotation matrix "
230 << rotmat <<
"\n\tNumber of layers " <<
layers;
242 zminBlock.emplace_back(ziL0Nose);
243 zmaxBlock.emplace_back(zminBlock[module] + layerT[0] + 0.5 * dzStep);
244 rinBlock1.emplace_back(zminBlock[module] *
tan(angTop));
245 rinBlock2.emplace_back(zmaxBlock[module] *
tan(angTop));
246 routBlock1.emplace_back((zminBlock[module] - z1Beam) *
slope);
247 routBlock2.emplace_back((zmaxBlock[module] - z1Beam) *
slope);
252 zminBlock.emplace_back(ziL0Body);
253 zmaxBlock.emplace_back(zminBlock[module] + layerT[0] + 0.5 * dzStep);
254 rinBlock1.emplace_back(zminBlock[module] *
tan(angBot));
255 rinBlock2.emplace_back(zmaxBlock[module] *
tan(angBot));
256 routBlock1.emplace_back(zminBlock[module] *
tan(angTop));
257 routBlock2.emplace_back(zmaxBlock[module] *
tan(angTop));
262 zminBlock.emplace_back(ziNose);
263 zmaxBlock.emplace_back(ziBody);
264 rinBlock1.emplace_back(zminBlock[module] *
tan(angTop));
265 rinBlock2.emplace_back(zmaxBlock[module] *
tan(angTop));
266 routBlock1.emplace_back((zminBlock[module] - z1Beam) *
slope);
267 routBlock2.emplace_back((zmaxBlock[module] - z1Beam) *
slope);
272 zminBlock.emplace_back(ziBody);
273 zmaxBlock.emplace_back(zminBlock[module] + layerN[3] * dzStep);
274 rinBlock1.emplace_back(zminBlock[module] *
tan(angBot));
275 rinBlock2.emplace_back(zmaxBlock[module] *
tan(angBot));
276 routBlock1.emplace_back((zmaxBlock[module - 1] - z1Beam) *
slope);
277 routBlock2.emplace_back(rout);
282 zminBlock.emplace_back(zmaxBlock[module - 1]);
283 zmaxBlock.emplace_back(zminBlock[module] + layerN[4] * dzStep);
284 rinBlock1.emplace_back(zminBlock[module] *
tan(angBot));
285 rinBlock2.emplace_back(zmaxBlock[module] *
tan(angBot));
286 routBlock1.emplace_back(rout);
287 routBlock2.emplace_back(rout);
292 zminBlock.emplace_back(zmaxBlock[module - 1]);
293 zmaxBlock.emplace_back(zminBlock[module] + layerN[5] * dzStep);
294 rinBlock1.emplace_back(zminBlock[module] *
tan(angBot));
295 rinBlock2.emplace_back(zmaxBlock[module] *
tan(angBot));
296 routBlock1.emplace_back(rout);
297 routBlock2.emplace_back(roDip);
301 for (
int i = 0;
i < module;
i++)
302 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: Module " <<
i <<
"\tZ/Rin/Rout "
309 idOffset =
args.value<
int>(
"IdOffset");
312 <<
" NameSpace " << ns.
name() <<
" Offset " << idOffset;
315 tolPos =
args.value<
double>(
"TolPos");
316 tolAbs =
args.value<
double>(
"TolAbs");
324 constructGeneralVolume(ns,
parent);
326 edm::LogVerbatim(
"HCalGeom") <<
"<<== End of DDHCalEndcapAlgo construction ...";
336 for (
int i = 0;
i < 3;
i++)
340 dd4hep::Rotation3D
rot = getRotation(
rotation, ns);
346 double alpha = (1._pi) / nsectors;
347 double dphi = nsectortot * (2._pi) / nsectors;
353 std::vector<double> pgonZ, pgonRmin, pgonRmax;
355 double zf = ziBody + zShiftHac2;
356 pgonZ.emplace_back(zf - dzShift);
357 pgonRmin.emplace_back(zf *
tan(angBot));
358 pgonRmax.emplace_back((zf - z1Beam) *
slope);
360 pgonZ.emplace_back(zFront - dzShift);
361 pgonRmin.emplace_back(zFront *
tan(angTop));
362 pgonRmax.emplace_back((zFront - z1Beam) *
slope);
363 pgonZ.emplace_back(ziL0Body - dzShift);
364 pgonRmin.emplace_back(ziL0Body *
tan(angTop));
365 pgonRmax.emplace_back((ziL0Body - z1Beam) *
slope);
366 pgonZ.emplace_back(ziL0Body - dzShift);
367 pgonRmin.emplace_back(ziL0Body *
tan(angBot));
368 pgonRmax.emplace_back((ziL0Body - z1Beam) *
slope);
370 pgonZ.emplace_back(ziKink - dzShift);
371 pgonRmin.emplace_back(riKink);
372 pgonRmax.emplace_back(rout);
373 pgonZ.emplace_back(ziDip - dzShift);
374 pgonRmin.emplace_back(riDip);
375 pgonRmax.emplace_back(rout);
376 pgonZ.emplace_back(ziDip - dzShift + delz);
377 pgonRmin.emplace_back(riDip);
378 pgonRmax.emplace_back(roDip);
379 pgonZ.emplace_back(zEnd - dzShift);
380 pgonRmin.emplace_back(zEnd *
tan(angBot));
381 pgonRmax.emplace_back(roDip);
382 pgonZ.emplace_back(zEnd);
383 pgonRmin.emplace_back(zEnd *
tan(angBot));
384 pgonRmax.emplace_back(roDip);
389 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << solid.name() <<
" Polyhedra made of " << genMaterial
392 for (
unsigned int i = 0;
i < pgonZ.size();
i++)
400 parent.placeVolume(genlogic, 1, dd4hep::Transform3D(
rot, r0));
402 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << genlogic.name() <<
" number 1 positioned in "
404 <<
") with rotation: " <<
rot;
408 rot = getRotation(rotHalf, ns);
409 parent.placeVolume(genlogic, 2, dd4hep::Transform3D(
rot, r0));
411 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << genlogic.name() <<
" number 2 "
413 <<
") with rotation: " <<
rot;
419 std::vector<double> pgonZMod, pgonRminMod, pgonRmaxMod;
420 for (
unsigned int i = 0;
i < (pgonZ.size() - 1);
i++) {
421 pgonZMod.emplace_back(pgonZ[
i] + dzShift);
422 pgonRminMod.emplace_back(pgonRmin[
i]);
423 pgonRmaxMod.emplace_back(pgonRmax[
i]);
427 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << solid.name() <<
" Polyhedra made of " << genMaterial
430 for (
unsigned int i = 0;
i < pgonZMod.size();
i++)
440 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << genlogich.name() <<
" number 1 positioned in "
441 << genlogic.name() <<
" at (0,0," << -
cms::convert2mm(dzShift) <<
") with no rotation";
448 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << solid.name() <<
" Polyhedra made of " << genMaterial
451 for (
unsigned int i = 0;
i < pgonZMod.size();
i++)
458 for (
int ii = 0;
ii < nsectortot;
ii++) {
460 dd4hep::Rotation3D rot0;
462 rot0 = dd4hep::RotationZ(phi);
468 genlogich.placeVolume(seclogic,
ii + 1, rot0);
470 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << seclogic.name() <<
" number " << (
ii + 1)
471 <<
" positioned in " << genlogich.name() <<
" at (0, 0, 0) with rotation: " << rot0;
476 constructInsideSector(ns, seclogic);
480 std::vector<double> pgonZBack, pgonRminBack, pgonRmaxBack;
481 pgonZBack.emplace_back(zEnd - dzShift);
482 pgonRminBack.emplace_back(pgonZBack[0] *
tan(angBot) + drEnd);
483 pgonRmaxBack.emplace_back(roDip);
484 pgonZBack.emplace_back(zEnd);
485 pgonRminBack.emplace_back(pgonZBack[1] *
tan(angBot) + drEnd);
486 pgonRmaxBack.emplace_back(roDip);
489 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << solid.name() <<
" Polyhedra made of " << absMat <<
" with "
492 for (
unsigned int i = 0;
i < pgonZBack.size();
i++)
500 genlogic.placeVolume(glog, 1);
502 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << glog.name() <<
" number 1 positioned in " << genlogic.name()
503 <<
" at (0,0,0) with no rotation";
512 double alpha = (1._pi) / nsectors;
517 if (eModule[
i] > 0) {
518 int nsec = sectionModule[
i];
524 std::vector<double> pgonZ, pgonRmin, pgonRmax;
526 double zf = zminBlock[
i] + zShiftHac2;
527 pgonZ.emplace_back(zf);
528 pgonRmin.emplace_back(zf *
tan(angBot));
529 pgonRmax.emplace_back((zf - z1Beam) *
slope);
530 pgonZ.emplace_back(ziKink);
531 pgonRmin.emplace_back(riKink);
532 pgonRmax.emplace_back(rout);
534 pgonZ.emplace_back(zminBlock[
i]);
535 pgonRmin.emplace_back(rinBlock1[
i]);
536 pgonRmax.emplace_back(routBlock1[
i]);
539 pgonZ.emplace_back(ziDip);
540 pgonRmin.emplace_back(riDip);
541 pgonRmax.emplace_back(rout);
542 pgonZ.emplace_back(pgonZ[1] + deltaz);
543 pgonRmin.emplace_back(pgonRmin[1]);
544 pgonRmax.emplace_back(roDip);
546 pgonZ.emplace_back(zmaxBlock[
i]);
547 pgonRmin.emplace_back(rinBlock2[
i]);
548 pgonRmax.emplace_back(routBlock2[
i]);
553 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << solid.name() <<
" Polyhedra made of " << modMat[
i]
556 for (
unsigned int k = 0;
k < pgonZ.size();
k++)
564 sector.placeVolume(glog,
i + 1);
566 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << glog.name() <<
" number " << (
i + 1)
567 <<
" positioned in " << sector.name() <<
" at (0,0,0) with no rotation";
571 constructInsideModule0(ns, glog,
i);
573 constructInsideModule(ns, glog,
i);
585 dd4hep::Rotation3D
rot = getRotation(rotmat, ns);
590 int layer0 = getLayer(
mod, 1);
592 double xpos, ypos, zpos;
596 double yh, bl, tl, alp;
597 parameterLayer0(
mod,
layer,
iphi, yh, bl, tl, alp, xpos, ypos, zpos);
599 solid = dd4hep::Trap(ns.
prepend(
name), 0.5 * layerT[
layer], 0, 0, yh, bl, tl, alp, yh, bl, tl, alp);
601 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << solid.name() <<
" Trap made of " << plastMat
612 module.placeVolume(glog, idOffset +
layer + 1, dd4hep::Transform3D(
rot,
r1));
615 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << glog.name() <<
" number " << (idOffset +
layer + 1)
616 <<
" positioned in " << module.name() <<
" at (" <<
cms::convert2mm(xpos) <<
", "
618 <<
" with rotation: " <<
rot;
622 int copyNo = layer0 * 10 + layerType[
layer];
624 constructScintLayer(ns, glog, scintT[
layer], yh, bl, tl, alp,
name, copyNo);
628 double zi = zminBlock[
mod] + layerT[
layer];
629 double zo = zi + 0.5 * dzStep;
630 double rinF, routF, rinB, routB;
632 rinF = zi *
tan(angTop);
633 routF = (zi - z1Beam) *
slope;
634 rinB = zo *
tan(angTop);
635 routB = (zo - z1Beam) *
slope;
637 rinF = zi *
tan(angBot);
638 routF = zi *
tan(angTop);
639 rinB = zo *
tan(angBot);
640 routB = zo *
tan(angTop);
650 double yh1, bl1, tl1, yh2, bl2, tl2,
theta, phi, alp;
652 0, rinF, routF, rinB, routB, zi, zo, yh1, bl1, tl1, yh2, bl2, tl2, alp,
theta, phi, xpos, ypos, zpos);
653 double fact = tolAbs;
668 solid = dd4hep::Trap(ns.
prepend(
name), 0.5 * thick[
mod],
theta, phi, yh1, bl1, tl1, alp, yh2, bl2, tl2, alp);
670 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << solid.name() <<
" Trap made of " << absMat
682 module.placeVolume(glog, 1, dd4hep::Transform3D(
rot,
r2));
685 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << glog.name() <<
" number 1 positioned in " << module.name()
698 dd4hep::Rotation3D
rot = getRotation(rotmat, ns);
702 double alpha = (1._pi) / nsectors;
703 double zi = zminBlock[
mod];
705 for (
int i = 0;
i < layerN[
mod];
i++) {
710 double zo = zi + 0.5 * dzStep;
713 double ziAir = zo - thick[
mod];
716 rinF = ziAir *
tan(angTop);
717 rinB = zo *
tan(angTop);
719 rinF = ziAir *
tan(angBot);
720 rinB = zo *
tan(angBot);
722 double routF = (ziAir - z1Beam) *
slope;
723 double routB = (zo - z1Beam) *
slope;
724 if (routF > routBlock2[
mod])
725 routF = routBlock2[
mod];
726 if (routB > routBlock2[
mod])
727 routB = routBlock2[
mod];
736 double yh1, bl1, tl1, yh2, bl2, tl2,
theta, phi, alp;
737 double xpos, ypos, zpos;
739 iphi, rinF, routF, rinB, routB, ziAir, zo, yh1, bl1, tl1, yh2, bl2, tl2, alp,
theta, phi, xpos, ypos, zpos);
742 solid = dd4hep::Trap(ns.
prepend(
name), 0.5 * thick[
mod],
theta, phi, yh1, bl1, tl1, alp, yh2, bl2, tl2, alp);
744 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << solid.name() <<
" Trap made of " << matter.name()
755 module.placeVolume(glog,
layer + 1, dd4hep::Transform3D(
rot,
r1));
759 <<
" positioned in " << module.name() <<
" at (" <<
cms::convert2mm(xpos) <<
", "
761 <<
") with rotation: " <<
rot;
765 double yh = 0.5 * (routF - rinB) - getTrim(
mod,
iphi);
769 solid = dd4hep::Trap(ns.
prepend(
name), 0.5 * layerT[
layer], 0, 0, yh, bl, tl, alp, yh, bl, tl, alp);
771 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << solid.name() <<
" Trap made of " << plastMat
780 ypos = 0.5 * (routF + rinB) - xpos;
784 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << plog.name() <<
" number " << (idOffset +
layer + 1)
785 <<
" positioned in " << glog.name() <<
" at (0, " <<
cms::convert2mm(ypos)
786 <<
", 0) with no rotation";
792 constructScintLayer(ns, plog, scintT[
layer], yh, bl, tl, alp,
name, copyNo);
795 zi = zo - 0.5 * dzStep;
811 dd4hep::Solid solid = dd4hep::Trap(ns.
prepend(
name), 0.5 *
dz, 0, 0, yh, bl, tl, alp, yh, bl, tl, alp);
813 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << solid.name() <<
" Trap made of " << scintMat
823 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalEndcapAlgo: " << glog.name() <<
" number " <<
id <<
" positioned in "
824 <<
detector.name() <<
" at (0,0,0) with no rotation";
872 double alpha = (1._pi) / nsectors;
881 zo = zi + layerT[
layer];
884 zi = zo - layerT[
layer];
888 rin = zo *
tan(angTop);
889 rout = (zi - z1Beam) *
slope;
891 rin = zo *
tan(angBot);
892 rout = zi *
tan(angTop);
894 yh = 0.5 * (rout - rin);
897 xpos = 0.5 * (rin + rout);
898 ypos = 0.5 * (bl + tl);
899 zpos = 0.5 * (zi + zo);
939 double alpha = (1._pi) / nsectors;
948 yh1 = 0.5 * (routF - rinB);
951 yh2 = 0.5 * (routF - rinB);
954 double dx = 0.25 * (bl2 + tl2 - bl1 - tl1);
955 double dy = 0.5 * (rinB + routF - rinB - routF);
956 xpos = 0.25 * (rinB + routF + rinB + routF);
957 ypos = 0.25 * (bl2 + tl2 + bl1 + tl1);
958 zpos = 0.5 * (zi + zo);
968 theta = atan(
r / (zo - zi));