2 #include "DD4hep/DetFactoryHelper.h"
13 #include <unordered_set>
20 static constexpr
double tol2 = 0.00001;
22 const auto& wafers =
args.value<std::vector<std::string> >(
"WaferName");
23 const auto& covers =
args.value<std::vector<std::string> >(
"CoverName");
25 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModule: " << wafers.size() <<
" wafers";
27 for (
auto wafer : wafers) {
31 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModule: " << covers.size() <<
" covers";
33 for (
auto cover : covers) {
38 const auto& materials =
args.value<std::vector<std::string> >(
"MaterialNames");
39 const auto&
names =
args.value<std::vector<std::string> >(
"VolumeNames");
40 const auto& thick =
args.value<std::vector<double> >(
"Thickness");
41 std::vector<int> copyNumber;
42 copyNumber.resize(materials.size(), 1);
44 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModule: " << materials.size() <<
" types of volumes";
45 for (
unsigned int i = 0;
i <
names.size(); ++
i)
47 <<
" filled with " << materials[
i] <<
" first copy number " << copyNumber[
i];
49 const auto&
layers =
args.value<std::vector<int> >(
"Layers");
50 const auto& layerThick =
args.value<std::vector<double> >(
"LayerThick");
53 for (
unsigned int i = 0;
i <
layers.size(); ++
i)
57 const auto& layerType =
args.value<std::vector<int> >(
"LayerType");
58 const auto& layerSense =
args.value<std::vector<int> >(
"LayerSense");
60 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModule: " << layerType.size() <<
" layers";
61 for (
unsigned int i = 0;
i < layerType.size(); ++
i)
62 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType[
i] <<
" sensitive class "
65 const auto& zMinBlock =
args.value<
double>(
"zMinBlock");
66 const auto& rMaxFine =
args.value<
double>(
"rMaxFine");
67 const auto& waferW =
args.value<
double>(
"waferW");
68 const auto& waferGap =
args.value<
double>(
"waferGap");
69 const auto& absorbW =
args.value<
double>(
"absorberW");
70 const auto& absorbH =
args.value<
double>(
"absorberH");
72 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModule: zStart " << zMinBlock <<
" rFineCoarse " << rMaxFine
73 <<
" wafer width " << waferW <<
" gap among wafers " << waferGap <<
" absorber width "
74 << absorbW <<
" absorber height " << absorbH;
76 const auto& slopeB =
args.value<std::vector<double> >(
"SlopeBottom");
77 const auto& slopeT =
args.value<std::vector<double> >(
"SlopeTop");
78 const auto& zFront =
args.value<std::vector<double> >(
"ZFront");
79 const auto& rMaxFront =
args.value<std::vector<double> >(
"RMaxFront");
81 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModule: Bottom slopes " << slopeB[0] <<
":" << slopeB[1] <<
" and "
82 << slopeT.size() <<
" slopes for top";
83 for (
unsigned int i = 0;
i < slopeT.size(); ++
i)
84 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] Zmin " << zFront[
i] <<
" Rmax " << rMaxFront[
i] <<
" Slope "
90 std::unordered_set<int> copies;
100 double zi(zMinBlock);
101 double ww = (waferW + waferGap);
102 double dx = 0.5 * ww;
103 double dy = 3.0 *
dx *
tan(30._deg);
104 double rr = 2.0 *
dx *
tan(30._deg);
106 for (
unsigned int i = 0;
i <
layers.size();
i++) {
107 double zo = zi + layerThick[
i];
109 int laymax = laymin +
layers[
i];
112 for (
int ly = laymin; ly < laymax; ++ly) {
113 int ii = layerType[ly];
114 int copy = copyNumber[
ii];
115 double rinB = (layerSense[ly] == 0) ? (zo * slopeB[0]) : (zo * slopeB[1]);
116 zz += (0.5 * thick[
ii]);
117 thickTot += thick[
ii];
121 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModule: Layer " << ly <<
":" <<
ii <<
" Front " << zi <<
", " << routF
122 <<
" Back " << zo <<
", " << rinB <<
" superlayer thickness " << layerThick[
i];
127 if (layerSense[ly] == 0) {
128 dd4hep::Solid solid = dd4hep::Box(absorbW, absorbH, 0.5 * thick[
ii]);
132 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModule test: " << solid.name() <<
" box of dimension " << absorbW
133 <<
":" << absorbH <<
":" << 0.5 * thick[
ii];
140 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModule: " << solid.name() <<
" Tubs made of " << materials[
ii]
141 <<
" of dimensions " << rinB <<
", " << routF <<
", " << 0.5 * thick[
ii]
144 int ncol = static_cast<int>(2.0 * routF / ww) + 1;
145 int nrow = static_cast<int>(routF / (ww *
tan(30._deg))) + 1;
147 int incm(0), inrm(0), kount(0), ntot(0),
nin(0), nfine(0), ncoarse(0);
148 edm::LogVerbatim(
"HGCalGeom") << glog.name() <<
" rout " << routF <<
" Row " << nrow <<
" Column " << ncol;
151 for (
int nr = -nrow;
nr <= nrow; ++
nr) {
152 int inr = (
nr >= 0) ?
nr : -
nr;
153 for (
int nc = -ncol; nc <= ncol; ++nc) {
154 int inc = (nc >= 0) ? nc : -nc;
155 if (inr % 2 == inc % 2) {
156 double xpos = nc *
dx;
157 double ypos =
nr *
dy;
159 yc[0] = ypos - 0.5 *
rr;
161 yc[1] = ypos + 0.5 *
rr;
165 yc[3] = ypos + 0.5 *
rr;
167 yc[4] = ypos - 0.5 *
rr;
170 bool cornerAll(
true);
171 for (
int k = 0;
k < 6; ++
k) {
173 if (rpos < rinB || rpos > routF)
181 if (layerSense[ly] == 1) {
182 double rpos =
std::sqrt(xpos * xpos + ypos * ypos);
183 glog1 = (rpos < rMaxFine) ? ns.
volume(wafers[0]) : ns.
volume(wafers[1]);
192 glog1 = ns.
volume(covers[layerSense[ly] - 2]);
204 glog.placeVolume(glog1, copyL, tran);
206 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: " << glog1.name() <<
" number " << copyL
207 <<
" positioned in " << glog.name() <<
" at " << tran;
214 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: # of columns " << incm <<
" # of rows " << inrm <<
" and "
215 <<
nin <<
":" << kount <<
":" << ntot <<
" wafers (" << nfine <<
":" << ncoarse
216 <<
") for " << glog.name() <<
" R " << rinB <<
":" << routF;
220 module.placeVolume(glog,
copy,
r1);
224 <<
" positioned in " << module.name() <<
" at " <<
r1;
226 zz += (0.5 * thick[
ii]);
230 if (fabs(thickTot - layerThick[
i]) > tol2) {
231 if (thickTot > layerThick[
i]) {
232 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << layerThick[
i] <<
" is smaller than thickness "
233 << thickTot <<
" of all its components **** ERROR ****\n";
235 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << layerThick[
i] <<
" does not match with "
236 << thickTot <<
" of the components\n";