8 #include <unordered_set>
11 #include "DD4hep/DetFactoryHelper.h"
22 const std::vector<std::string>& wafers,
23 const std::vector<std::string>& covers,
24 const std::vector<int>& layerType,
25 const std::vector<int>& layerSense,
26 const std::vector<int>& maxModule,
27 const std::vector<std::string>&
names,
28 const std::vector<std::string>& materials,
29 std::vector<int>& copyNumber,
30 const std::vector<double>& layerThick,
31 const double& absorbW,
32 const double& absorbH,
33 const double& waferTot,
35 const double& rMaxFine,
36 std::unordered_set<int>& copies,
43 static constexpr
double tolerance = 0.00001;
44 static const double tan30deg =
tan(30._deg);
45 double zi(zFront), thickTot(0);
46 for (
int ly = firstLayer; ly <= lastLayer; ++ly) {
47 int ii = layerType[ly];
49 double zz = zi + (0.5 * layerThick[
ii]);
50 double zo = zi + layerThick[
ii];
51 thickTot += layerThick[
ii];
61 if (layerSense[ly] == 0) {
62 dd4hep::Solid solid = dd4hep::Box(absorbW, absorbH, 0.5 * layerThick[
ii]);
66 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << solid.name() <<
" box of dimension "
73 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << glog.name() <<
" number " <<
copy <<
" positioned in "
74 <<
module.name() <<
" at " <<
r1 <<
" with no rotation";
76 }
else if (layerSense[ly] > 0) {
77 double dx = 0.5 * waferTot;
78 double dy = 3.0 *
dx * tan30deg;
79 double rr = 2.0 *
dx * tan30deg;
80 int ncol = (
int)(2.0 *
rMax / waferTot) + 1;
81 int nrow = (
int)(
rMax / (waferTot * tan30deg)) + 1;
86 << maxModule[ly] <<
" Z " <<
convertCmToMm(
zz) <<
" Center " << ignoreCenter
87 <<
" name " <<
name <<
" matter " << matter.name();
90 if (maxModule[ly] >= 0) {
91 nrow =
std::min(nrow, maxModule[ly]);
92 ncol =
std::min(ncol, maxModule[ly]);
94 for (
int nr = -nrow;
nr <= nrow; ++
nr) {
96 for (
int nc = -ncol; nc <= ncol; ++nc) {
98 if ((inr % 2 == inc % 2) && (!ignoreCenter || nc != 0 ||
nr != 0)) {
99 double xpos = nc *
dx;
100 double ypos =
nr *
dy;
103 yc[0] = ypos - 0.5 *
rr;
105 yc[1] = ypos + 0.5 *
rr;
109 yc[3] = ypos + 0.5 *
rr;
111 yc[4] = ypos - 0.5 *
rr;
114 bool cornerAll(
true);
115 for (
int k = 0;
k < 6; ++
k) {
121 double rpos =
std::sqrt(xpos * xpos + ypos * ypos);
123 int copyx = inr * 100 + inc;
128 if (layerSense[ly] == 1) {
129 dd4hep::Solid solid = ns.
solid(covers[0]);
136 <<
"DDHGCalTBModuleX: " << glog1.name() <<
" number " <<
copy <<
" positioned in "
137 <<
module.name() <<
" at " << tran <<
" with no rotation";
140 glog1.placeVolume(glog2, copyx);
143 <<
"DDHGCalTBModuleX: " << glog2.name() <<
" number " << copyx <<
" positioned in "
144 << glog1.name() <<
" at (0, 0, 0) with no rotation";
146 if (layerSense[ly] == 1)
150 copyx += (
copy * 1000000);
151 module.placeVolume(glog2, copyx, tran);
154 <<
"DDHGCalTBModuleX: " << glog2.name() <<
" number " << copyx <<
" positioned in "
155 <<
module.name() <<
" at " << tran <<
" with no rotation";
170 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: # of columns " << incm <<
" # of rows " << inrm <<
" and "
171 << kount <<
" wafers for " <<
module.name();
178 if (fabs(thickTot - totalWidth) <
tolerance) {
179 }
else if (thickTot > totalWidth) {
180 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << totalWidth <<
" is smaller than " << thickTot
181 <<
": total thickness of all its components in " <<
module.name() <<
" Layers "
182 << firstLayer <<
":" << lastLayer <<
":" << ignoreCenter <<
"**** ERROR ****";
183 }
else if (thickTot < totalWidth) {
184 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << totalWidth <<
" does not match with " << thickTot
185 <<
" of the components in " <<
module.name() <<
" Layers " << firstLayer <<
":"
186 << lastLayer <<
":" << ignoreCenter;
194 dd4hep::SensitiveDetector& ) {
198 const auto& wafers =
args.value<std::vector<std::string> >(
"WaferName");
199 const auto& covers =
args.value<std::vector<std::string> >(
"CoverName");
202 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: Material " << genMat <<
" with " << wafers.size() <<
" wafers";
204 for (
auto wafer : wafers) {
208 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << covers.size() <<
" covers";
210 for (
auto cover : covers) {
215 const auto& materials =
args.value<std::vector<std::string> >(
"MaterialNames");
216 const auto&
names =
args.value<std::vector<std::string> >(
"VolumeNames");
217 const auto& layerThick =
args.value<std::vector<double> >(
"Thickness");
218 std::vector<int> copyNumber;
219 for (
unsigned int k = 0;
k < layerThick.size(); ++
k) {
220 copyNumber.emplace_back(1);
223 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << materials.size() <<
" types of volumes";
224 for (
unsigned int i = 0;
i <
names.size(); ++
i)
227 <<
" first copy number " << copyNumber[
i];
229 const auto& blockThick =
args.value<std::vector<double> >(
"BlockThick");
230 const auto& inOut =
args.value<
int>(
"InOut");
231 const auto& layerFrontIn =
args.value<std::vector<int> >(
"LayerFrontIn");
232 const auto& layerBackIn =
args.value<std::vector<int> >(
"LayerBackIn");
233 std::vector<int> layerFrontOut;
234 std::vector<int> layerBackOut;
236 layerFrontOut =
args.value<std::vector<int> >(
"LayerFrontOut");
237 layerBackOut =
args.value<std::vector<int> >(
"LayerBackOut");
240 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << blockThick.size() <<
" blocks with in/out " << inOut;
241 for (
unsigned int i = 0;
i < blockThick.size(); ++
i) {
244 <<
" with inner layers " << layerFrontIn[
i] <<
":" << layerBackIn[
i]
245 <<
" and outer layers " << layerFrontOut[
i] <<
":" << layerBackOut[
i];
248 <<
" with inner layers " << layerFrontIn[
i] <<
":" << layerBackIn[
i];
251 const auto& layerType =
args.value<std::vector<int> >(
"LayerType");
252 const auto& layerSense =
args.value<std::vector<int> >(
"LayerSense");
253 const auto& maxModule =
args.value<std::vector<int> >(
"MaxModule");
255 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << layerType.size() <<
" layers";
256 for (
unsigned int i = 0;
i < layerType.size(); ++
i)
257 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType[
i] <<
" sensitive class "
258 << layerSense[
i] <<
" and " << maxModule[
i] <<
" maximum row/columns";
260 const auto& zMinBlock =
args.value<
double>(
"zMinBlock");
261 const auto& rMaxFine =
args.value<
double>(
"rMaxFine");
262 const auto& waferW =
args.value<
double>(
"waferW");
263 const auto& waferGap =
args.value<
double>(
"waferGap");
264 const auto& absorbW =
args.value<
double>(
"absorberW");
265 const auto& absorbH =
args.value<
double>(
"absorberH");
266 const auto&
rMax =
args.value<
double>(
"rMax");
267 const auto& rMaxB =
args.value<
double>(
"rMaxB");
268 double waferTot = waferW + waferGap;
273 <<
" gap among wafers " <<
convertCmToMm(waferGap) <<
" absorber width "
278 std::unordered_set<int> copies;
282 double zi(zMinBlock);
283 for (
unsigned int i = 0;
i < blockThick.size();
i++) {
284 double zo = zi + blockThick[
i];
292 dd4hep::Solid solid = dd4hep::Tube(0, rMaxB, 0.5 * blockThick[
i], 0.0, 2._pi);
295 double zz = zi + 0.5 * blockThick[
i];
299 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << glog.name() <<
" number " <<
i <<
" positioned in "
300 <<
args.parentName() <<
" at " <<
r1 <<
" with no rotation";
301 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: \t\tInside Block " <<
i <<
" Layers " << layerFrontIn[
i] <<
":"
303 <<
" thickness " <<
convertCmToMm(blockThick[
i]) <<
" ignore Center 0";
323 -0.5 * blockThick[
i],
329 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: \t\tInside Block " <<
i <<
" Layers " << layerFrontOut[
i]
330 <<
":" << layerBackOut[
i] <<
" zFront " <<
convertCmToMm(-0.5 * blockThick[
i])
331 <<
" thickness " <<
convertCmToMm(blockThick[
i]) <<
" ignore Center 1";
351 -0.5 * blockThick[
i],
360 <<
convertCmToMm(zi) <<
" with " << copies.size() <<
" different wafer copy numbers";