18 #include "DD4hep/DetFactoryHelper.h"
151 nsectors =
args.value<
int>(
"NSector");
152 nsectortot =
args.value<
int>(
"NSectorTot");
153 nhalf =
args.value<
int>(
"NHalf");
154 rinner =
args.value<
double>(
"RIn");
155 router =
args.value<
double>(
"ROut");
156 rzones =
args.value<
int>(
"RZones");
160 theta =
args.value<std::vector<double> >(
"Theta");
161 rmax =
args.value<std::vector<double> >(
"RMax");
162 zoff =
args.value<std::vector<double> >(
"ZOff");
163 for (
int i = 0;
i < rzones;
i++) {
167 rmax[2] = (zoff[3] - zoff[2]) / ttheta[2];
170 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: General material " << genMaterial <<
"\tSectors " << nsectors
171 <<
", " << nsectortot <<
"\tHalves " << nhalf <<
"\tRotation matrix " << rotns <<
":"
174 for (
int i = 0;
i < rzones;
i++)
185 layerId =
args.value<std::vector<int> >(
"Id");
186 layerLabel =
args.value<std::vector<std::string> >(
"LayerLabel");
187 layerMat =
args.value<std::vector<std::string> >(
"LayerMat");
188 layerWidth =
args.value<std::vector<double> >(
"LayerWidth");
189 layerD1 =
args.value<std::vector<double> >(
"D1");
190 layerD2 =
args.value<std::vector<double> >(
"D2");
191 layerAlpha =
args.value<std::vector<double> >(
"Alpha2");
192 layerT1 =
args.value<std::vector<double> >(
"T1");
193 layerT2 =
args.value<std::vector<double> >(
"T2");
194 layerAbsorb =
args.value<std::vector<int> >(
"AbsL");
195 layerGap =
args.value<std::vector<double> >(
"Gap");
198 edm::LogVerbatim(
"HCalGeom") << layerLabel[
i] <<
"\t" << layerId[
i] <<
"\t" << layerMat[
i] <<
"\t"
207 absorbName =
args.value<std::vector<std::string> >(
"AbsorbName");
208 absorbMat =
args.value<std::vector<std::string> >(
"AbsorbMat");
209 absorbD =
args.value<std::vector<double> >(
"AbsorbD");
210 absorbT =
args.value<std::vector<double> >(
"AbsorbT");
211 nAbsorber = absorbName.size();
213 for (
int i = 0;
i < nAbsorber;
i++)
214 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << absorbName[
i] <<
" Material " << absorbMat[
i] <<
" d "
218 middleD =
args.value<
double>(
"MiddleD");
219 middleW =
args.value<
double>(
"MiddleW");
221 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: Middle material " << middleMat <<
" d "
224 midName =
args.value<std::vector<std::string> >(
"MidAbsName");
225 midMat =
args.value<std::vector<std::string> >(
"MidAbsMat");
226 midW =
args.value<std::vector<double> >(
"MidAbsW");
227 midT =
args.value<std::vector<double> >(
"MidAbsT");
228 nMidAbs = midName.size();
230 for (
int i = 0;
i < nMidAbs;
i++)
231 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << midName[
i] <<
" Material " << midMat[
i] <<
" W "
236 sideMat =
args.value<std::vector<std::string> >(
"SideMat");
237 sideD =
args.value<std::vector<double> >(
"SideD");
238 sideT =
args.value<std::vector<double> >(
"SideT");
240 for (
unsigned int i = 0;
i < sideMat.size();
i++)
241 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: Side material " << sideMat[
i] <<
" d "
244 sideAbsName =
args.value<std::vector<std::string> >(
"SideAbsName");
245 sideAbsMat =
args.value<std::vector<std::string> >(
"SideAbsMat");
246 sideAbsW =
args.value<std::vector<double> >(
"SideAbsW");
247 nSideAbs = sideAbsName.size();
249 for (
int i = 0;
i < nSideAbs;
i++)
250 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << sideAbsName[
i] <<
" Material " << sideAbsMat[
i] <<
" W "
262 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: Detector (" <<
nLayers <<
") Rotation matrix " << rotns <<
":"
263 << detRot <<
"\n\t\t" << detMat <<
"\t" << detMatPl <<
"\t" << detMatSc;
265 detType =
args.value<std::vector<int> >(
"DetType");
266 detdP1 =
args.value<std::vector<double> >(
"DetdP1");
267 detdP2 =
args.value<std::vector<double> >(
"DetdP2");
268 detT11 =
args.value<std::vector<double> >(
"DetT11");
269 detT12 =
args.value<std::vector<double> >(
"DetT12");
270 detTsc =
args.value<std::vector<double> >(
"DetTsc");
271 detT21 =
args.value<std::vector<double> >(
"DetT21");
272 detT22 =
args.value<std::vector<double> >(
"DetT22");
273 detWidth1 =
args.value<std::vector<double> >(
"DetWidth1");
274 detWidth2 =
args.value<std::vector<double> >(
"DetWidth2");
275 detPosY =
args.value<std::vector<int> >(
"DetPosY");
288 idNameSpace = ns.
name();
289 idOffset =
args.value<
int>(
"IdOffset");
292 <<
" NameSpace " << idNameSpace <<
" Offset " << idOffset;
294 <<
"DDHCalBarrelAlgo: General volume...";
297 double alpha = (1._pi) / nsectors;
298 double dphi = nsectortot * (2._pi) / nsectors;
304 int nf =
ntot - nsec;
308 double zmax = zoff[3];
309 double zstep5 = zoff[4];
310 double zstep4 = (zoff[1] + rmax[1] * ttheta[1]);
311 if ((zoff[2] + rmax[1] * ttheta[2]) > zstep4)
312 zstep4 = (zoff[2] + rmax[1] * ttheta[2]);
313 double zstep3 = (zoff[1] + rmax[0] * ttheta[1]);
314 double zstep2 = (zoff[0] + rmax[0] * ttheta[0]);
315 double zstep1 = (zoff[0] + rinner * ttheta[0]);
316 double rout = router;
317 double rout1 = rmax[3];
319 double rmid1 = rmax[0];
320 double rmid2 = rmax[1];
321 double rmid3 = (zoff[4] - zoff[2]) / ttheta[2];
322 double rmid4 = rmax[2];
324 std::vector<double> pgonZ = {-
zmax,
340 std::vector<double> pgonRmin = {
341 rmid4, rmid3, rmid3, rmid2, rmid1, rmid1, rin, rin, rin, rmid1, rmid1, rmid2, rmid3, rmid3, rmid4};
343 std::vector<double> pgonRmax = {
344 rout1, rout1, rout, rout, rout, rout, rout, rout, rout, rout, rout, rout, rout, rout1, rout1};
346 std::vector<double> pgonZHalf = {0, zstep1, zstep2, zstep3, zstep4, zstep5, zstep5,
zmax};
348 std::vector<double> pgonRminHalf = {rin, rin, rmid1, rmid1, rmid2, rmid3, rmid3, rmid4};
350 std::vector<double> pgonRmaxHalf = {rout, rout, rout, rout, rout, rout, rout1, rout1};
357 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Polyhedra made of " << genMaterial
360 for (
unsigned int i = 0;
i < pgonZ.size();
i++)
369 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Polyhedra made of " << genMaterial
372 for (
unsigned int i = 0;
i < pgonZHalf.size();
i++)
382 parentName.placeVolume(genlogic, 1);
384 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << genlogic.name() <<
" number 1 positioned in "
385 << parentName.name() <<
" at (0, 0, 0) with no rotation";
392 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Polyhedra made of " << genMaterial
395 for (
unsigned int i = 0;
i < pgonZHalf.size();
i++)
401 genlogic.placeVolume(genlogich, 1);
403 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << genlogich.name() <<
" number 1 positioned in "
404 << genlogic.name() <<
" at (0, 0, 0) with no rotation";
407 dd4hep::Rotation3D
rot = getRotation(rotHalf, rotns, ns);
408 genlogic.placeVolume(genlogich, 2,
rot);
410 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << genlogich.name() <<
" number 2 positioned in "
411 << genlogic.name() <<
" at (0, 0, 0) with " <<
rot;
420 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Polyhedra made of " << matter.name()
423 for (
unsigned int i = 0;
i < pgonZHalf.size();
i++)
429 for (
int ii = 0;
ii < nsectortot;
ii++) {
439 genlogich.placeVolume(seclogic,
ii + 1,
rotation);
441 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << seclogic.name() <<
" number " <<
ii + 1
442 <<
" positioned in " << genlogich.name() <<
" at (0, 0, 0) with " <<
rotation;
454 double width = layerWidth[
i];
455 double rout = rin +
width;
458 for (
int j = 0;
j < rzones - 1;
j++) {
464 double zout = zoff[
in] + rin * ttheta[
in];
469 std::vector<double> pgonZ, pgonRmin, pgonRmax;
471 pgonZ.emplace_back(0);
472 pgonRmin.emplace_back(rin);
473 pgonRmax.emplace_back(rout);
475 pgonZ.emplace_back(zout);
476 pgonRmin.emplace_back(rin);
477 pgonRmax.emplace_back(rout);
481 pgonZ.emplace_back(zoff[
in] + rout * ttheta[
in]);
482 pgonRmin.emplace_back(pgonRmax[1]);
483 pgonRmax.emplace_back(pgonRmax[1]);
489 pgonZ[1] = (zoff[
out] + rmax[
out] * ttheta[
out]);
490 pgonZ.emplace_back(pgonZ[1]);
491 pgonRmin.emplace_back(pgonRmin[1]);
492 pgonRmax.emplace_back(rmax[
in]);
494 pgonZ.emplace_back(zoff[
in] + rmax[
in] * ttheta[
in]);
495 pgonRmin.emplace_back(pgonRmin[2]);
496 pgonRmax.emplace_back(pgonRmax[2]);
500 pgonZ.emplace_back(zoff[
in] + rmax[
in] * ttheta[
in]);
501 pgonRmin.emplace_back(rmax[
in]);
502 pgonRmax.emplace_back(pgonRmax[1]);
505 pgonZ.emplace_back(zoff[
out] + rmax[
in] * ttheta[
out]);
506 pgonRmin.emplace_back(pgonRmin[2]);
507 pgonRmax.emplace_back(pgonRmax[2]);
511 pgonZ.emplace_back(zoff[
out] + rout * ttheta[
out]);
512 pgonRmin.emplace_back(rout);
513 pgonRmax.emplace_back(rout);
520 double alpha1 =
alpha;
521 if (layerGap[
i] > 1.
e-6) {
522 double rmid = 0.5 * (rin + rout);
524 alpha1 = atan(
width / rmid);
534 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" (Layer " <<
i <<
") Polyhedra made of "
535 << matter.name() <<
" with 1 sector from " <<
convertRadToDeg(-alpha1) <<
" to "
537 for (
unsigned int k = 0;
k < pgonZ.size();
k++)
542 seclogic.placeVolume(glog, layerId[
i]);
544 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << glog.name() <<
" number " << layerId[
i]
545 <<
" positioned in " << seclogic.name() <<
" at (0,0,0) with no rotation";
547 constructInsideLayers(glog,
576 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: \t\tInside layer " <<
id <<
"...";
581 dd4hep::Rotation3D
rot = getRotation(detRot, rotns, ns);
589 double rsi,
dx,
dy,
dz, x, y;
595 for (
i = 0;
i < rzones - 1;
i++) {
600 dy = 0.5 * rsi * (
tan(alpha1) -
tan(alpha2));
601 dz = 0.5 * (zoff[
in] + rsi * ttheta[
in]);
603 y = 0.5 * rsi * (
tan(alpha1) +
tan(alpha2));
609 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Box made of " << matter.name()
616 mother = constructSideLayer(laylog,
name, nAbs, rin, alpha1, ns);
620 mother.placeVolume(glog, idOffset + 1, r11);
621 mother.placeVolume(glog, idOffset + 2, dd4hep::Transform3D(
rot, r12));
623 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << glog.name() <<
" Number " << (idOffset + 1)
624 <<
" positioned in " << mother.name() <<
" at (" <<
cms::convert2mm(x) <<
","
626 <<
"DDHCalBarrelAlgo: " << glog.name() <<
" Number " << (idOffset + 2)
627 <<
" positioned in " << mother.name() <<
" at (" <<
cms::convert2mm(x) <<
","
631 constructInsideDetectors(glog, nam0 +
"1",
id,
dx,
dy,
dz, 1, ns);
637 for (
i = 0;
i < rzones - 1;
i++) {
642 dy = 0.5 * rsi *
tan(alpha2);
643 dz = 0.5 * (zoff[
in] + rsi * ttheta[
in]);
650 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Box made of " << matter.name()
657 mother = constructMidLayer(laylog,
name, rin, alpha1, ns);
661 mother.placeVolume(glog, idOffset + 3, r21);
662 mother.placeVolume(glog, idOffset + 4, dd4hep::Transform3D(
rot, r22));
664 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << glog.name() <<
" Number " << (idOffset + 3)
665 <<
" positioned in " << mother.name() <<
" at (" <<
cms::convert2mm(x) <<
","
667 <<
") with no rotation\nDDHCalBarrelAlgo: " << glog.name() <<
" Number "
668 << (idOffset + 4) <<
" positioned in " << mother.name() <<
" at ("
673 constructInsideDetectors(glog, nam0 +
"2",
id,
dx,
dy,
dz, 2, ns);
679 int k =
abs(nAbs) - 1;
681 double rsi = rin + sideD[
k];
683 for (
int i = 0;
i < rzones - 1;
i++) {
687 std::vector<double> pgonZ, pgonRmin, pgonRmax;
689 pgonZ.emplace_back(0.0);
690 pgonRmin.emplace_back(rsi);
691 pgonRmax.emplace_back(rsi + sideT[
k]);
693 pgonZ.emplace_back(zoff[
in] + rsi * ttheta[
in]);
694 pgonRmin.emplace_back(rsi);
695 pgonRmax.emplace_back(pgonRmax[0]);
697 pgonZ.emplace_back(zoff[
in] + pgonRmax[0] * ttheta[
in]);
698 pgonRmin.emplace_back(pgonRmax[1]);
699 pgonRmax.emplace_back(pgonRmax[1]);
704 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Polyhedra made of " << sideMat[
k]
707 for (
unsigned int ii = 0;
ii < pgonZ.size();
ii++)
713 laylog.placeVolume(glog, 1);
715 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << glog.name() <<
" Number 1 positioned in " << laylog.name()
716 <<
" at (0,0,0) with no rotation";
720 double rmid = pgonRmax[0];
721 for (
int i = 0;
i < nSideAbs;
i++) {
722 double alpha1 = atan(sideAbsW[
i] / rmid);
729 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Polyhedra made of " << sideAbsMat[
i]
731 <<
convertRadToDeg(alpha1) <<
" and with " << pgonZ.size() <<
" sections";
732 for (
unsigned int ii = 0;
ii < pgonZ.size();
ii++)
738 mother.placeVolume(
log, 1);
740 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " <<
log.name() <<
" Number 1 positioned in "
741 << mother.name() <<
" at (0,0,0) with no rotation";
755 for (
int k = 0;
k < nAbsorber;
k++) {
757 double rsi = rin + absorbD[
k];
759 for (
int i = 0;
i < rzones - 1;
i++) {
763 std::vector<double> pgonZ, pgonRmin, pgonRmax;
765 pgonZ.emplace_back(0.0);
766 pgonRmin.emplace_back(rsi);
767 pgonRmax.emplace_back(rsi + absorbT[
k]);
769 pgonZ.emplace_back(zoff[
in] + rsi * ttheta[
in]);
770 pgonRmin.emplace_back(rsi);
771 pgonRmax.emplace_back(pgonRmax[0]);
773 pgonZ.emplace_back(zoff[
in] + pgonRmax[0] * ttheta[
in]);
774 pgonRmin.emplace_back(pgonRmax[1]);
775 pgonRmax.emplace_back(pgonRmax[1]);
780 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Polyhedra made of " << matter.name()
783 for (
unsigned int ii = 0;
ii < pgonZ.size();
ii++)
789 laylog.placeVolume(
log, 1);
791 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " <<
log.name() <<
" Number 1 positioned in " << laylog.name()
792 <<
" at (0,0,0) with no rotation";
795 double rmin = pgonRmin[0];
796 double rmax = pgonRmax[0];
798 for (
int i = 0;
i < 1;
i++) {
799 double alpha1 = atan(midW[
i] / rmin);
805 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Polyhedra made of "
806 << matter1.name() <<
" with 1 sector from " <<
convertRadToDeg(-alpha1) <<
" to "
807 <<
convertRadToDeg(alpha1) <<
" and with " << pgonZ.size() <<
" sections";
808 for (
unsigned int ii = 0;
ii < pgonZ.size();
ii++)
814 mother.placeVolume(
log, 1);
816 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " <<
log.name() <<
" Number 1 positioned in "
817 << mother.name() <<
" at (0,0,0) with no rotation";
823 double rmid = rmin + middleD;
828 pgonZ[1] = zoff[
in] + rmid * ttheta[
in];
831 pgonZ[2] = zoff[
in] + rmax * ttheta[
in];
832 double alpha1 = atan(middleW / rmin);
837 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Polyhedra made of " << matter1.name()
839 <<
convertRadToDeg(alpha1) <<
" and with " << pgonZ.size() <<
" sections";
840 for (
unsigned int ii = 0;
ii < pgonZ.size();
ii++)
846 mother.placeVolume(glog, 1);
848 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << glog.name() <<
" Number 1 positioned in "
849 << mother.name() <<
" at (0,0,0) with no rotation";
852 for (
int i = 1;
i < nMidAbs;
i++) {
853 namek =
name + midName[
i];
854 rmid = rmin + midT[
i];
859 pgonZ[1] = zoff[
in] + rmin * ttheta[
in];
862 pgonZ[2] = zoff[
in] + rmid * ttheta[
in];
863 alpha1 = atan(midW[
i] / rmin);
868 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Polyhedra made of "
869 << matter2.name() <<
" with 1 sector from " <<
convertRadToDeg(-alpha1) <<
" to "
870 <<
convertRadToDeg(alpha1) <<
" and with " << pgonZ.size() <<
" sections";
871 for (
unsigned int ii = 0;
ii < pgonZ.size();
ii++)
877 mother.placeVolume(
log,
i);
879 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " <<
log.name() <<
" Number " <<
i <<
" positioned in "
880 << mother.name() <<
" at (0,0,0) with no rotation";
898 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: \t\tInside detector " <<
id <<
"...";
910 double dx1, dx2, shiftX;
913 wid = 0.5 * detWidth1[
id];
914 dx1 = 0.5 * detT11[
id];
915 dx2 = 0.5 * detT21[
id];
920 wid = 0.5 * detWidth2[
id];
921 dx1 = 0.5 * detT12[
id];
922 dx2 = 0.5 * detT22[
id];
926 solid = dd4hep::Box(ns.
prepend(plname +
"1"), dx1, wid,
dz);
929 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Box made of " << plmatter.name()
934 double x = shiftX + dx1 -
dx;
937 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << glog.name() <<
" Number 1 positioned in " <<
detector.name()
939 <<
",0) with no rotation";
941 solid = dd4hep::Box(ns.
prepend(scname), 0.5 * detTsc[
id], wid,
dz);
944 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Box made of " << scmatter.name()
949 x += dx1 + 0.5 * detTsc[
id];
950 int copyNo =
id * 10 + detType[
id];
953 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << glog.name() <<
" Number " << copyNo <<
" positioned in "
955 <<
",0) with no rotation";
957 solid = dd4hep::Box(ns.
prepend(plname +
"2"), dx2, wid,
dz);
960 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Box made of " << plmatter.name()
965 x += 0.5 * detTsc[
id] + dx2;
968 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << glog.name() <<
" Number 1 positioned in " <<
detector.name()
970 <<
",0) with no rotation";
986 edm::LogVerbatim(
"HCalGeom") <<
"<<== End of DDHCalBarrelAlgo construction";