8 #include <unordered_set>
11 #include "DD4hep/DetFactoryHelper.h"
23 const std::vector<std::string>& wafers,
24 const std::vector<std::string>& covers,
25 const std::vector<int>& layerType,
26 const std::vector<int>& layerSense,
27 const std::vector<int>& maxModule,
28 const std::vector<std::string>&
names,
29 const std::vector<std::string>& materials,
30 std::vector<int>& copyNumber,
31 const std::vector<double>& layerThick,
32 const double& absorbW,
33 const double& absorbH,
34 const double& waferTot,
36 const double& rMaxFine,
37 std::unordered_set<int>& copies,
44 static constexpr
double tolerance = 0.00001;
45 static const double tan30deg =
tan(30._deg);
46 double zi(zFront), thickTot(0);
47 for (
int ly = firstLayer; ly <= lastLayer; ++ly) {
48 int ii = layerType[ly];
50 double zz = zi + (0.5 * layerThick[
ii]);
51 double zo = zi + layerThick[
ii];
52 thickTot += layerThick[
ii];
62 if (layerSense[ly] == 0) {
63 dd4hep::Solid solid = dd4hep::Box(absorbW, absorbH, 0.5 * layerThick[
ii]);
67 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << solid.name() <<
" box of dimension "
72 module.placeVolume(glog,
copy,
r1);
74 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << glog.name() <<
" number " <<
copy <<
" positioned in "
75 << module.name() <<
" at " <<
r1 <<
" with no rotation";
77 }
else if (layerSense[ly] > 0) {
78 double dx = 0.5 * waferTot;
79 double dy = 3.0 *
dx * tan30deg;
80 double rr = 2.0 *
dx * tan30deg;
81 int ncol = (
int)(2.0 *
rMax / waferTot) + 1;
82 int nrow = (
int)(
rMax / (waferTot * tan30deg)) + 1;
85 edm::LogVerbatim(
"HGCalGeom") << module.name() <<
" Copy " <<
copy <<
" Type " << layerSense[ly] <<
" rout "
87 << maxModule[ly] <<
" Z " <<
convertCmToMm(
zz) <<
" Center " << ignoreCenter
88 <<
" name " <<
name <<
" matter " << matter.name();
91 if (maxModule[ly] >= 0) {
92 nrow =
std::min(nrow, maxModule[ly]);
93 ncol =
std::min(ncol, maxModule[ly]);
95 for (
int nr = -nrow;
nr <= nrow; ++
nr) {
97 for (
int nc = -ncol; nc <= ncol; ++nc) {
99 if ((inr % 2 == inc % 2) && (!ignoreCenter || nc != 0 ||
nr != 0)) {
100 double xpos = nc *
dx;
101 double ypos =
nr *
dy;
104 yc[0] = ypos - 0.5 *
rr;
106 yc[1] = ypos + 0.5 *
rr;
110 yc[3] = ypos + 0.5 *
rr;
112 yc[4] = ypos - 0.5 *
rr;
115 bool cornerAll(
true);
116 for (
int k = 0;
k < 6; ++
k) {
122 double rpos =
std::sqrt(xpos * xpos + ypos * ypos);
125 if (layerSense[ly] == 1) {
126 dd4hep::Solid solid = ns.
solid(covers[0]);
130 module.placeVolume(glog1,
copy, tran);
133 <<
"DDHGCalTBModuleX: " << glog1.name() <<
" number " <<
copy <<
" positioned in "
134 << module.name() <<
" at " << tran <<
" with no rotation";
137 glog1.placeVolume(glog2, copyx);
140 <<
"DDHGCalTBModuleX: " << glog2.name() <<
" number " << copyx <<
" positioned in "
141 << glog1.name() <<
" at (0, 0, 0) with no rotation";
143 if (layerSense[ly] == 1)
147 copyx += (
copy * 1000000);
148 module.placeVolume(glog2, copyx, tran);
151 <<
"DDHGCalTBModuleX: " << glog2.name() <<
" number " << copyx <<
" positioned in "
152 << module.name() <<
" at " << tran <<
" with no rotation";
167 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: # of columns " << incm <<
" # of rows " << inrm <<
" and "
168 << kount <<
" wafers for " << module.name();
175 if (fabs(thickTot - totalWidth) >
tolerance) {
176 if (thickTot > totalWidth) {
177 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << totalWidth <<
" is smaller than " << thickTot
178 <<
": total thickness of all its components in " << module.name() <<
" Layers "
179 << firstLayer <<
":" << lastLayer <<
":" << ignoreCenter <<
"**** ERROR ****";
181 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << totalWidth <<
" does not match with "
182 << thickTot <<
" of the components in " << module.name() <<
" Layers "
183 << firstLayer <<
":" << lastLayer <<
":" << ignoreCenter;
193 const auto& wafers =
args.value<std::vector<std::string> >(
"WaferName");
194 const auto& covers =
args.value<std::vector<std::string> >(
"CoverName");
197 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: Material " << genMat <<
" with " << wafers.size() <<
" wafers";
199 for (
auto wafer : wafers) {
203 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << covers.size() <<
" covers";
205 for (
auto cover : covers) {
210 const auto& materials =
args.value<std::vector<std::string> >(
"MaterialNames");
211 const auto&
names =
args.value<std::vector<std::string> >(
"VolumeNames");
212 const auto& layerThick =
args.value<std::vector<double> >(
"Thickness");
213 std::vector<int> copyNumber;
214 copyNumber.resize(materials.size(), 1);
216 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << materials.size() <<
" types of volumes";
217 for (
unsigned int i = 0;
i <
names.size(); ++
i)
220 <<
" first copy number " << copyNumber[
i];
222 const auto& blockThick =
args.value<std::vector<double> >(
"BlockThick");
223 const auto& inOut =
args.value<
int>(
"InOut");
224 const auto& layerFrontIn =
args.value<std::vector<int> >(
"LayerFrontIn");
225 const auto& layerBackIn =
args.value<std::vector<int> >(
"LayerBackIn");
226 std::vector<int> layerFrontOut;
227 std::vector<int> layerBackOut;
229 layerFrontOut =
args.value<std::vector<int> >(
"LayerFrontOut");
230 layerBackOut =
args.value<std::vector<int> >(
"LayerBackOut");
233 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << blockThick.size() <<
" blocks with in/out " << inOut;
234 for (
unsigned int i = 0;
i < blockThick.size(); ++
i) {
237 <<
" with inner layers " << layerFrontIn[
i] <<
":" << layerBackIn[
i]
238 <<
" and outer layers " << layerFrontOut[
i] <<
":" << layerBackOut[
i];
241 <<
" with inner layers " << layerFrontIn[
i] <<
":" << layerBackIn[
i];
244 const auto& layerType =
args.value<std::vector<int> >(
"LayerType");
245 const auto& layerSense =
args.value<std::vector<int> >(
"LayerSense");
246 const auto& maxModule =
args.value<std::vector<int> >(
"MaxModule");
248 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << layerType.size() <<
" layers";
249 for (
unsigned int i = 0;
i < layerType.size(); ++
i)
250 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType[
i] <<
" sensitive class "
251 << layerSense[
i] <<
" and " << maxModule[
i] <<
" maximum row/columns";
253 const auto& zMinBlock =
args.value<
double>(
"zMinBlock");
254 const auto& rMaxFine =
args.value<
double>(
"rMaxFine");
255 const auto& waferW =
args.value<
double>(
"waferW");
256 const auto& waferGap =
args.value<
double>(
"waferGap");
257 const auto& absorbW =
args.value<
double>(
"absorberW");
258 const auto& absorbH =
args.value<
double>(
"absorberH");
259 const auto&
rMax =
args.value<
double>(
"rMax");
260 const auto& rMaxB =
args.value<
double>(
"rMaxB");
261 double waferTot = waferW + waferGap;
266 <<
" gap among wafers " <<
convertCmToMm(waferGap) <<
" absorber width "
271 std::unordered_set<int> copies;
275 double zi(zMinBlock);
276 for (
unsigned int i = 0;
i < blockThick.size();
i++) {
277 double zo = zi + blockThick[
i];
285 dd4hep::Solid solid = dd4hep::Tube(0, rMaxB, 0.5 * blockThick[
i], 0.0, 2._pi);
288 double zz = zi + 0.5 * blockThick[
i];
292 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << glog.name() <<
" number " <<
i <<
" positioned in "
293 <<
args.parentName() <<
" at " <<
r1 <<
" with no rotation";
294 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: \t\tInside Block " <<
i <<
" Layers " << layerFrontIn[
i] <<
":"
296 <<
" thickness " <<
convertCmToMm(blockThick[
i]) <<
" ignore Center 0";
316 -0.5 * blockThick[
i],
322 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: \t\tInside Block " <<
i <<
" Layers " << layerFrontOut[
i]
323 <<
":" << layerBackOut[
i] <<
" zFront " <<
convertCmToMm(-0.5 * blockThick[
i])
324 <<
" thickness " <<
convertCmToMm(blockThick[
i]) <<
" ignore Center 1";
344 -0.5 * blockThick[
i],
353 <<
convertCmToMm(zi) <<
" with " << copies.size() <<
" different wafer copy numbers";