27 static constexpr
double tol = 0.01;
28 static constexpr
double tol2 = 0.00001;
30 const auto& wafer =
args.value<std::vector<std::string> >(
"WaferName");
31 auto materials =
args.value<std::vector<std::string> >(
"MaterialNames");
32 const auto&
names =
args.value<std::vector<std::string> >(
"VolumeNames");
33 const auto& thick =
args.value<std::vector<double> >(
"Thickness");
34 std::vector<int> copyNumber;
35 copyNumber.resize(materials.size(), 1);
36 for (
unsigned int i = 0;
i < materials.size(); ++
i) {
37 if (materials[
i] ==
"materials:M_NEMAFR4plate")
38 materials[
i] =
"materials:M_NEMA FR4 plate";
41 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: " << wafer.size() <<
" wafers";
42 for (
unsigned int i = 0;
i < wafer.size(); ++
i)
44 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: " << 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");
51 const auto& layerType =
args.value<std::vector<int> >(
"LayerType");
52 const auto& layerSense =
args.value<std::vector<int> >(
"LayerSense");
55 for (
unsigned int i = 0;
i <
layers.size(); ++
i)
58 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: " << layerType.size() <<
" layers";
59 for (
unsigned int i = 0;
i < layerType.size(); ++
i)
60 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType[
i] <<
" sensitive class "
63 double zMinBlock =
args.value<
double>(
"zMinBlock");
64 double rMaxFine =
args.value<
double>(
"rMaxFine");
65 double waferW =
args.value<
double>(
"waferW");
68 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: zStart " << zMinBlock <<
" rFineCoarse " << rMaxFine
69 <<
" wafer width " << waferW <<
" sectors " <<
sectors;
71 const auto& slopeB =
args.value<std::vector<double> >(
"SlopeBottom");
72 const auto& slopeT =
args.value<std::vector<double> >(
"SlopeTop");
73 const auto& zFront =
args.value<std::vector<double> >(
"ZFront");
74 const auto& rMaxFront =
args.value<std::vector<double> >(
"RMaxFront");
76 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: Bottom slopes " << slopeB[0] <<
":" << slopeB[1] <<
" and "
77 << slopeT.size() <<
" slopes for top";
78 for (
unsigned int i = 0;
i < slopeT.size(); ++
i)
79 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] Zmin " << zFront[
i] <<
" Rmax " << rMaxFront[
i] <<
" Slope "
82 std::string idNameSpace = static_cast<std::string>(ns.name());
85 std::unordered_set<int> copies;
94 for (
unsigned int i = 0;
i <
layers.size();
i++) {
95 double zo = zi + layerThick[
i];
97 int laymax = laymin +
layers[
i];
100 for (
int ly = laymin; ly < laymax; ++ly) {
101 int ii = layerType[ly];
102 int copy = copyNumber[
ii];
103 double rinB = (layerSense[ly] == 0) ? (zo * slopeB[0]) : (zo * slopeB[1]);
104 zz += (0.5 * thick[
ii]);
105 thickTot += thick[
ii];
109 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: Layer " << ly <<
":" <<
ii <<
" Front " << zi <<
", " << routF
110 <<
" Back " << zo <<
", " << rinB <<
" superlayer thickness " << layerThick[
i];
114 if (layerSense[ly] == 0) {
116 double rmax = routF *
cos(
alpha) - tol;
117 std::vector<double> pgonZ, pgonRin, pgonRout;
118 pgonZ.emplace_back(-0.5 * thick[
ii]);
119 pgonZ.emplace_back(0.5 * thick[
ii]);
120 pgonRin.emplace_back(rinB);
121 pgonRin.emplace_back(rinB);
122 pgonRout.emplace_back(rmax);
123 pgonRout.emplace_back(rmax);
125 ns.addSolidNS(ns.prepend(
name), solid);
131 for (
unsigned int k = 0;
k < pgonZ.size(); ++
k)
132 edm::LogVerbatim(
"HGCalGeom") <<
"[" <<
k <<
"] z " << pgonZ[
k] <<
" R " << pgonRin[
k] <<
":" << pgonRout[
k];
136 ns.addSolidNS(ns.prepend(
name), solid);
139 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: " << solid.name() <<
" Tubs made of " << materials[
ii]
140 <<
" of dimensions " << rinB <<
", " << routF <<
", " << 0.5 * thick[
ii]
142 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule test position in: " << glog.name() <<
" number " <<
copy;
144 double dx = 0.5 * waferW;
145 double dy = 3.0 *
dx *
tan(30._deg);
146 double rr = 2.0 *
dx *
tan(30._deg);
147 int ncol = static_cast<int>(2.0 * routF / waferW) + 1;
148 int nrow = static_cast<int>(routF / (waferW *
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;
153 for (
int nr = -nrow;
nr <= nrow; ++
nr) {
154 int inr = (
nr >= 0) ?
nr : -
nr;
155 for (
int nc = -ncol; nc <= ncol; ++nc) {
156 int inc = (nc >= 0) ? nc : -nc;
157 if (inr % 2 == inc % 2) {
158 double xpos = nc *
dx;
159 double ypos =
nr *
dy;
175 double rpos =
std::sqrt(xpos * xpos + ypos * ypos);
178 dd4hep::Volume glog1 = (rpos < rMaxFine) ? ns.volume(wafer[0]) : ns.volume(wafer[1]);
179 glog.placeVolume(glog1, copyL, dd4hep::Transform3D(
rotation, tran));
187 <<
"DDHGCalModule: " << glog1.name() <<
" number " << copyL <<
" positioned in " << glog.name()
188 <<
" at " << tran <<
" with " <<
rotation;
196 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: # of columns " << incm <<
" # of rows " << inrm <<
" and "
197 <<
nin <<
":" << kount <<
":" << ntot <<
" wafers (" << nfine <<
":" << ncoarse
198 <<
") for " << glog.name() <<
" R " << rinB <<
":" << routF;
202 dd4hep::Rotation3D
rot;
203 module.placeVolume(glog,
copy, dd4hep::Transform3D(
rot,
r1));
206 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: " << glog.name() <<
" number " <<
copy <<
" positioned in "
207 << module.name() <<
" at " <<
r1 <<
" with " <<
rot;
209 zz += (0.5 * thick[
ii]);
213 if (fabs(thickTot - layerThick[
i]) > tol2) {
214 if (thickTot > layerThick[
i]) {
215 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << layerThick[
i] <<
" is smaller than thickness "
216 << thickTot <<
" of all its components **** ERROR ****\n";
218 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << layerThick[
i] <<
" does not match with "
219 << thickTot <<
" of the components\n";
225 edm::LogVerbatim(
"HGCalGeom") << copies.size() <<
" different wafer copy numbers";
227 for (std::unordered_set<int>::const_iterator
itr = copies.begin();
itr != copies.end(); ++
itr, ++
k)
229 edm::LogVerbatim(
"HGCalGeom") <<
"<<== End of DDHGCalModule construction ...";