17 #include "DD4hep/DetFactoryHelper.h"
150 nsectors =
args.value<
int>(
"NSector");
151 nsectortot =
args.value<
int>(
"NSectorTot");
152 nhalf =
args.value<
int>(
"NHalf");
153 rinner =
args.value<
double>(
"RIn");
154 router =
args.value<
double>(
"ROut");
155 rzones =
args.value<
int>(
"RZones");
159 theta =
args.value<std::vector<double> >(
"Theta");
160 rmax =
args.value<std::vector<double> >(
"RMax");
161 zoff =
args.value<std::vector<double> >(
"ZOff");
162 for (
int i = 0;
i < rzones;
i++) {
166 rmax[2] = (zoff[3] - zoff[2]) / ttheta[2];
169 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: General material " << genMaterial <<
"\tSectors " << nsectors
170 <<
", " << nsectortot <<
"\tHalves " << nhalf <<
"\tRotation matrix " << rotns <<
":"
173 for (
int i = 0;
i < rzones;
i++)
184 layerId =
args.value<std::vector<int> >(
"Id");
185 layerLabel =
args.value<std::vector<std::string> >(
"LayerLabel");
186 layerMat =
args.value<std::vector<std::string> >(
"LayerMat");
187 layerWidth =
args.value<std::vector<double> >(
"LayerWidth");
188 layerD1 =
args.value<std::vector<double> >(
"D1");
189 layerD2 =
args.value<std::vector<double> >(
"D2");
190 layerAlpha =
args.value<std::vector<double> >(
"Alpha2");
191 layerT1 =
args.value<std::vector<double> >(
"T1");
192 layerT2 =
args.value<std::vector<double> >(
"T2");
193 layerAbsorb =
args.value<std::vector<int> >(
"AbsL");
194 layerGap =
args.value<std::vector<double> >(
"Gap");
197 edm::LogVerbatim(
"HCalGeom") << layerLabel[
i] <<
"\t" << layerId[
i] <<
"\t" << layerMat[
i] <<
"\t"
206 absorbName =
args.value<std::vector<std::string> >(
"AbsorbName");
207 absorbMat =
args.value<std::vector<std::string> >(
"AbsorbMat");
208 absorbD =
args.value<std::vector<double> >(
"AbsorbD");
209 absorbT =
args.value<std::vector<double> >(
"AbsorbT");
210 nAbsorber = absorbName.size();
212 for (
int i = 0;
i < nAbsorber;
i++)
213 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << absorbName[
i] <<
" Material " << absorbMat[
i] <<
" d "
217 middleD =
args.value<
double>(
"MiddleD");
218 middleW =
args.value<
double>(
"MiddleW");
223 midName =
args.value<std::vector<std::string> >(
"MidAbsName");
224 midMat =
args.value<std::vector<std::string> >(
"MidAbsMat");
225 midW =
args.value<std::vector<double> >(
"MidAbsW");
226 midT =
args.value<std::vector<double> >(
"MidAbsT");
227 nMidAbs = midName.size();
229 for (
int i = 0;
i < nMidAbs;
i++)
230 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << midName[
i] <<
" Material " << midMat[
i] <<
" W "
235 sideMat =
args.value<std::vector<std::string> >(
"SideMat");
236 sideD =
args.value<std::vector<double> >(
"SideD");
237 sideT =
args.value<std::vector<double> >(
"SideT");
239 for (
unsigned int i = 0;
i < sideMat.size();
i++)
240 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: Side material " << sideMat[
i] <<
" d "
243 sideAbsName =
args.value<std::vector<std::string> >(
"SideAbsName");
244 sideAbsMat =
args.value<std::vector<std::string> >(
"SideAbsMat");
245 sideAbsW =
args.value<std::vector<double> >(
"SideAbsW");
246 nSideAbs = sideAbsName.size();
248 for (
int i = 0;
i < nSideAbs;
i++)
249 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << sideAbsName[
i] <<
" Material " << sideAbsMat[
i] <<
" W "
261 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: Detector (" <<
nLayers <<
") Rotation matrix " << rotns <<
":"
262 << detRot <<
"\n\t\t" << detMat <<
"\t" << detMatPl <<
"\t" << detMatSc;
264 detType =
args.value<std::vector<int> >(
"DetType");
265 detdP1 =
args.value<std::vector<double> >(
"DetdP1");
266 detdP2 =
args.value<std::vector<double> >(
"DetdP2");
267 detT11 =
args.value<std::vector<double> >(
"DetT11");
268 detT12 =
args.value<std::vector<double> >(
"DetT12");
269 detTsc =
args.value<std::vector<double> >(
"DetTsc");
270 detT21 =
args.value<std::vector<double> >(
"DetT21");
271 detT22 =
args.value<std::vector<double> >(
"DetT22");
272 detWidth1 =
args.value<std::vector<double> >(
"DetWidth1");
273 detWidth2 =
args.value<std::vector<double> >(
"DetWidth2");
274 detPosY =
args.value<std::vector<int> >(
"DetPosY");
287 idNameSpace = ns.
name();
288 idOffset =
args.value<
int>(
"IdOffset");
291 <<
" NameSpace " << idNameSpace <<
" Offset " << idOffset;
293 <<
"DDHCalBarrelAlgo: General volume...";
296 double alpha = (1._pi) / nsectors;
297 double dphi = nsectortot * (2._pi) / nsectors;
303 int nf = ntot - nsec;
307 double zmax = zoff[3];
308 double zstep5 = zoff[4];
309 double zstep4 = (zoff[1] + rmax[1] * ttheta[1]);
310 if ((zoff[2] + rmax[1] * ttheta[2]) > zstep4)
311 zstep4 = (zoff[2] + rmax[1] * ttheta[2]);
312 double zstep3 = (zoff[1] + rmax[0] * ttheta[1]);
313 double zstep2 = (zoff[0] + rmax[0] * ttheta[0]);
314 double zstep1 = (zoff[0] + rinner * ttheta[0]);
315 double rout = router;
316 double rout1 = rmax[3];
318 double rmid1 = rmax[0];
319 double rmid2 = rmax[1];
320 double rmid3 = (zoff[4] - zoff[2]) / ttheta[2];
321 double rmid4 = rmax[2];
323 std::vector<double> pgonZ = {-
zmax,
339 std::vector<double> pgonRmin = {
340 rmid4, rmid3, rmid3, rmid2, rmid1, rmid1, rin, rin, rin, rmid1, rmid1, rmid2, rmid3, rmid3, rmid4};
342 std::vector<double> pgonRmax = {
343 rout1, rout1, rout, rout, rout, rout, rout, rout, rout, rout, rout, rout, rout, rout1, rout1};
345 std::vector<double> pgonZHalf = {0, zstep1, zstep2, zstep3, zstep4, zstep5, zstep5,
zmax};
347 std::vector<double> pgonRminHalf = {rin, rin, rmid1, rmid1, rmid2, rmid3, rmid3, rmid4};
349 std::vector<double> pgonRmaxHalf = {rout, rout, rout, rout, rout, rout, rout1, rout1};
356 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Polyhedra made of " << genMaterial
359 for (
unsigned int i = 0;
i < pgonZ.size();
i++)
367 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Polyhedra made of " << genMaterial
370 for (
unsigned int i = 0;
i < pgonZHalf.size();
i++)
381 parentName.placeVolume(genlogic, 1);
383 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << genlogic.name() <<
" number 1 positioned in "
384 << parentName.name() <<
" at (0, 0, 0) with no rotation";
391 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Polyhedra made of " << genMaterial
394 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 (" <<
convertCmToMm(x) <<
","
626 <<
"DDHCalBarrelAlgo: " << glog.name() <<
" Number " << idOffset + 2
627 <<
" positioned in " << mother.name() <<
" at (" <<
convertCmToMm(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 (" <<
convertCmToMm(x) <<
","
667 <<
") with no rotation\nDDHCalBarrelAlgo: " << glog.name() <<
" Number "
668 << idOffset + 4 <<
" positioned in " << mother.name() <<
" at (" <<
convertCmToMm(x)
672 constructInsideDetectors(glog, nam0 +
"2",
id,
dx,
dy,
dz, 2, ns);
678 int k =
abs(nAbs) - 1;
680 double rsi = rin + sideD[
k];
682 for (
int i = 0;
i < rzones - 1;
i++) {
686 std::vector<double> pgonZ, pgonRmin, pgonRmax;
688 pgonZ.emplace_back(0.0);
689 pgonRmin.emplace_back(rsi);
690 pgonRmax.emplace_back(rsi + sideT[
k]);
692 pgonZ.emplace_back(zoff[
in] + rsi * ttheta[
in]);
693 pgonRmin.emplace_back(rsi);
694 pgonRmax.emplace_back(pgonRmax[0]);
696 pgonZ.emplace_back(zoff[
in] + pgonRmax[0] * ttheta[
in]);
697 pgonRmin.emplace_back(pgonRmax[1]);
698 pgonRmax.emplace_back(pgonRmax[1]);
703 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Polyhedra made of " << sideMat[
k]
706 for (
unsigned int ii = 0;
ii < pgonZ.size();
ii++)
712 laylog.placeVolume(glog, 1);
714 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << glog.name() <<
" Number 1 positioned in " << laylog.name()
715 <<
" at (0,0,0) with no rotation";
719 double rmid = pgonRmax[0];
720 for (
int i = 0;
i < nSideAbs;
i++) {
721 double alpha1 = atan(sideAbsW[
i] / rmid);
728 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Polyhedra made of " << sideAbsMat[
i]
730 <<
convertRadToDeg(alpha1) <<
" and with " << pgonZ.size() <<
" sections";
731 for (
unsigned int ii = 0;
ii < pgonZ.size();
ii++)
737 mother.placeVolume(
log, 1);
739 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " <<
log.name() <<
" Number 1 positioned in "
740 << mother.name() <<
" at (0,0,0) with no rotation";
754 for (
int k = 0;
k < nAbsorber;
k++) {
756 double rsi = rin + absorbD[
k];
758 for (
int i = 0;
i < rzones - 1;
i++) {
762 std::vector<double> pgonZ, pgonRmin, pgonRmax;
764 pgonZ.emplace_back(0.0);
765 pgonRmin.emplace_back(rsi);
766 pgonRmax.emplace_back(rsi + absorbT[
k]);
768 pgonZ.emplace_back(zoff[
in] + rsi * ttheta[
in]);
769 pgonRmin.emplace_back(rsi);
770 pgonRmax.emplace_back(pgonRmax[0]);
772 pgonZ.emplace_back(zoff[
in] + pgonRmax[0] * ttheta[
in]);
773 pgonRmin.emplace_back(pgonRmax[1]);
774 pgonRmax.emplace_back(pgonRmax[1]);
779 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Polyhedra made of " << matter.name()
782 for (
unsigned int ii = 0;
ii < pgonZ.size();
ii++)
788 laylog.placeVolume(
log, 1);
790 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " <<
log.name() <<
" Number 1 positioned in " << laylog.name()
791 <<
" at (0,0,0) with no rotation";
794 double rmin = pgonRmin[0];
795 double rmax = pgonRmax[0];
797 for (
int i = 0;
i < 1;
i++) {
798 double alpha1 = atan(midW[
i] / rmin);
804 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Polyhedra made of "
805 << matter1.name() <<
" with 1 sector from " <<
convertRadToDeg(-alpha1) <<
" to "
806 <<
convertRadToDeg(alpha1) <<
" and with " << pgonZ.size() <<
" sections";
807 for (
unsigned int ii = 0;
ii < pgonZ.size();
ii++)
813 mother.placeVolume(
log, 1);
815 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " <<
log.name() <<
" Number 1 positioned in "
816 << mother.name() <<
" at (0,0,0) with no rotation";
822 double rmid = rmin + middleD;
827 pgonZ[1] = zoff[
in] + rmid * ttheta[
in];
830 pgonZ[2] = zoff[
in] + rmax * ttheta[
in];
831 double alpha1 = atan(middleW / rmin);
836 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Polyhedra made of " << matter1.name()
838 <<
convertRadToDeg(alpha1) <<
" and with " << pgonZ.size() <<
" sections";
839 for (
unsigned int ii = 0;
ii < pgonZ.size();
ii++)
845 mother.placeVolume(glog, 1);
847 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << glog.name() <<
" Number 1 positioned in "
848 << mother.name() <<
" at (0,0,0) with no rotation";
851 for (
int i = 1;
i < nMidAbs;
i++) {
852 namek =
name + midName[
i];
853 rmid = rmin + midT[
i];
858 pgonZ[1] = zoff[
in] + rmin * ttheta[
in];
861 pgonZ[2] = zoff[
in] + rmid * ttheta[
in];
862 alpha1 = atan(midW[
i] / rmin);
867 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Polyhedra made of "
868 << matter2.name() <<
" with 1 sector from " <<
convertRadToDeg(-alpha1) <<
" to "
869 <<
convertRadToDeg(alpha1) <<
" and with " << pgonZ.size() <<
" sections";
870 for (
unsigned int ii = 0;
ii < pgonZ.size();
ii++)
876 mother.placeVolume(
log,
i);
878 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " <<
log.name() <<
" Number " <<
i <<
" positioned in "
879 << mother.name() <<
" at (0,0,0) with no rotation";
897 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: \t\tInside detector " <<
id <<
"...";
909 double dx1, dx2, shiftX;
912 wid = 0.5 * detWidth1[
id];
913 dx1 = 0.5 * detT11[
id];
914 dx2 = 0.5 * detT21[
id];
919 wid = 0.5 * detWidth2[
id];
920 dx1 = 0.5 * detT12[
id];
921 dx2 = 0.5 * detT22[
id];
925 solid = dd4hep::Box(ns.
prepend(plname +
"1"), dx1, wid,
dz);
928 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Box made of " << plmatter.name()
933 double x = shiftX + dx1 -
dx;
936 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << glog.name() <<
" Number 1 positioned in " <<
detector.name()
939 solid = dd4hep::Box(ns.
prepend(scname), 0.5 * detTsc[
id], wid,
dz);
942 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Box made of " << scmatter.name()
947 x += dx1 + 0.5 * detTsc[
id];
948 int copyNo =
id * 10 + detType[
id];
951 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << glog.name() <<
" Number " << copyNo <<
" positioned in "
953 <<
",0) with no rotation";
955 solid = dd4hep::Box(ns.
prepend(plname +
"2"), dx2, wid,
dz);
958 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << solid.name() <<
" Box made of " << plmatter.name()
963 x += 0.5 * detTsc[
id] + dx2;
966 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalBarrelAlgo: " << glog.name() <<
" Number 1 positioned in " <<
detector.name()
983 dd4hep::SensitiveDetector& ) {
986 edm::LogVerbatim(
"HCalGeom") <<
"<<== End of DDHCalBarrelAlgo construction";