23 const auto& wafers =
args.value<std::vector<std::string> >(
"WaferName");
24 const auto& covers =
args.value<std::vector<std::string> >(
"CoverName");
26 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModule: " << wafers.size() <<
" wafers";
28 for (
auto wafer : wafers) {
32 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModule: " << covers.size() <<
" covers";
34 for (
auto cover : covers) {
39 const auto& materials =
args.value<std::vector<std::string> >(
"MaterialNames");
40 const auto&
names =
args.value<std::vector<std::string> >(
"VolumeNames");
41 const auto& thick =
args.value<std::vector<double> >(
"Thickness");
42 std::vector<int> copyNumber;
43 for (
unsigned int i = 0;
i < materials.size(); ++
i) {
44 copyNumber.emplace_back(1);
47 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModule: " << materials.size() <<
" types of volumes";
48 for (
unsigned int i = 0;
i < names.size(); ++
i)
49 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << names[
i] <<
" of thickness " << thick[
i]
50 <<
" filled with " << materials[
i] <<
" first copy number " << copyNumber[
i];
52 const auto&
layers =
args.value<std::vector<int> >(
"Layers");
53 const auto& layerThick =
args.value<std::vector<double> >(
"LayerThick");
56 for (
unsigned int i = 0;
i <
layers.size(); ++
i)
60 const auto& layerType =
args.value<std::vector<int> >(
"LayerType");
61 const auto& layerSense =
args.value<std::vector<int> >(
"LayerSense");
63 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModule: " << layerType.size() <<
" layers";
64 for (
unsigned int i = 0;
i < layerType.size(); ++
i)
65 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType[
i] <<
" sensitive class " 68 const auto& zMinBlock =
args.value<
double>(
"zMinBlock");
69 const auto& rMaxFine =
args.value<
double>(
"rMaxFine");
70 const auto& waferW =
args.value<
double>(
"waferW");
71 const auto& waferGap =
args.value<
double>(
"waferGap");
72 const auto& absorbW =
args.value<
double>(
"absorberW");
73 const auto& absorbH =
args.value<
double>(
"absorberH");
75 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModule: zStart " << zMinBlock <<
" rFineCoarse " << rMaxFine
76 <<
" wafer width " << waferW <<
" gap among wafers " << waferGap <<
" absorber width " 77 << absorbW <<
" absorber height " << absorbH;
79 const auto& slopeB =
args.value<std::vector<double> >(
"SlopeBottom");
80 const auto& slopeT =
args.value<std::vector<double> >(
"SlopeTop");
81 const auto& zFront =
args.value<std::vector<double> >(
"ZFront");
82 const auto& rMaxFront =
args.value<std::vector<double> >(
"RMaxFront");
84 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModule: Bottom slopes " << slopeB[0] <<
":" << slopeB[1] <<
" and " 85 << slopeT.size() <<
" slopes for top";
86 for (
unsigned int i = 0;
i < slopeT.size(); ++
i)
87 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] Zmin " << zFront[
i] <<
" Rmax " << rMaxFront[
i] <<
" Slope " 93 std::unordered_set<int> copies;
103 double zi(zMinBlock);
104 double ww = (waferW + waferGap);
105 double dx = 0.5 * ww;
106 double dy = 3.0 * dx *
tan(30._deg);
107 double rr = 2.0 * dx *
tan(30._deg);
109 for (
unsigned int i = 0;
i < layers.size();
i++) {
110 double zo = zi + layerThick[
i];
112 int laymax = laymin + layers[
i];
115 for (
int ly = laymin; ly < laymax; ++ly) {
116 int ii = layerType[ly];
117 int copy = copyNumber[
ii];
118 double rinB = (layerSense[ly] == 0) ? (zo * slopeB[0]) : (zo * slopeB[1]);
119 zz += (0.5 * thick[
ii]);
120 thickTot += thick[
ii];
124 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModule: Layer " << ly <<
":" << ii <<
" Front " << zi <<
", " << routF
125 <<
" Back " << zo <<
", " << rinB <<
" superlayer thickness " << layerThick[
i];
130 if (layerSense[ly] == 0) {
131 dd4hep::Solid solid = dd4hep::Box(absorbW, absorbH, 0.5 * thick[ii]);
132 ns.addSolidNS(ns.prepend(name), solid);
135 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModule test: " << solid.name() <<
" box of dimension " << absorbW
136 <<
":" << absorbH <<
":" << 0.5 * thick[
ii];
139 dd4hep::Solid solid = dd4hep::Tube(rinB, routF, 0.5 * thick[ii], 0.0, 2 *
cms_units::piRadians);
140 ns.addSolidNS(ns.prepend(name), solid);
143 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModule: " << solid.name() <<
" Tubs made of " << materials[
ii]
144 <<
" of dimensions " << rinB <<
", " << routF <<
", " << 0.5 * thick[
ii]
147 int ncol =
static_cast<int>(2.0 * routF / ww) + 1;
148 int nrow =
static_cast<int>(routF / (ww *
tan(30._deg))) + 1;
150 int incm(0), inrm(0), kount(0), ntot(0),
nin(0), nfine(0), ncoarse(0);
151 edm::LogVerbatim(
"HGCalGeom") << glog.name() <<
" rout " << routF <<
" Row " << nrow <<
" Column " << ncol;
154 for (
int nr = -nrow;
nr <= nrow; ++
nr) {
155 int inr = (
nr >= 0) ?
nr : -
nr;
156 for (
int nc = -ncol; nc <= ncol; ++nc) {
157 int inc = (nc >= 0) ? nc : -nc;
158 if (inr % 2 == inc % 2) {
159 double xpos = nc *
dx;
160 double ypos =
nr *
dy;
162 yc[0] = ypos - 0.5 *
rr;
164 yc[1] = ypos + 0.5 *
rr;
168 yc[3] = ypos + 0.5 *
rr;
170 yc[4] = ypos - 0.5 *
rr;
173 bool cornerAll(
true);
174 for (
int k = 0;
k < 6; ++
k) {
176 if (rpos < rinB || rpos > routF)
184 if (layerSense[ly] == 1) {
185 double rpos =
std::sqrt(xpos * xpos + ypos * ypos);
186 glog1 = (rpos < rMaxFine) ? ns.volume(wafers[0]) : ns.volume(wafers[1]);
195 glog1 = ns.volume(covers[layerSense[ly] - 2]);
197 int copyL = inr * 100 + inc;
210 dd4hep::Position tran(xpos, ypos, 0.0);
211 glog.placeVolume(glog1, copyL, tran);
213 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: " << glog1.name() <<
" number " << copyL
214 <<
" positioned in " << glog.name() <<
" at " << tran;
221 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: # of columns " << incm <<
" # of rows " << inrm <<
" and " 222 <<
nin <<
":" << kount <<
":" << ntot <<
" wafers (" << nfine <<
":" << ncoarse
223 <<
") for " << glog.name() <<
" R " << rinB <<
":" << routF;
226 dd4hep::Position
r1(0, 0, zz);
227 module.placeVolume(glog, copy,
r1);
230 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModule test: " << glog.name() <<
" number " << copy
231 <<
" positioned in " << module.name() <<
" at " <<
r1;
233 zz += (0.5 * thick[
ii]);
237 if (fabs(thickTot - layerThick[
i]) < 0.00001) {
238 }
else if (thickTot > layerThick[i]) {
239 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << layerThick[
i] <<
" is smaller than thickness " 240 << thickTot <<
" of all its components **** ERROR ****\n";
241 }
else if (thickTot < layerThick[i]) {
242 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << layerThick[
i] <<
" does not match with " 243 << thickTot <<
" of the components\n";
const std::string names[nVars_]
constexpr long double piRadians(M_PIl)
Tan< T >::type tan(const T &t)