9 #include "DD4hep/DetFactoryHelper.h" 20 #include <unordered_set> 27 static constexpr double tol = 0.01 * dd4hep::mm;
28 static constexpr double tol2 = 0.00001 * dd4hep::mm;
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 for (
unsigned int i = 0;
i < materials.size(); ++
i) {
36 if (materials[
i] ==
"materials:M_NEMAFR4plate")
37 materials[
i] =
"materials:M_NEMA FR4 plate";
38 copyNumber.emplace_back(1);
41 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModuleAlgo: " << wafer.size() <<
" wafers";
42 for (
unsigned int i = 0;
i < wafer.size(); ++
i)
44 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModuleAlgo: " << materials.size() <<
" types of volumes";
45 for (
unsigned int i = 0;
i <
names.size(); ++
i)
48 <<
" first copy number " << copyNumber[
i];
50 const auto&
layers =
args.value<std::vector<int> >(
"Layers");
51 const auto& layerThick =
args.value<std::vector<double> >(
"LayerThick");
52 const auto& layerType =
args.value<std::vector<int> >(
"LayerType");
53 const auto& layerSense =
args.value<std::vector<int> >(
"LayerSense");
56 for (
unsigned int i = 0;
i <
layers.size(); ++
i)
59 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModuleAlgo: " << layerType.size() <<
" layers";
60 for (
unsigned int i = 0;
i < layerType.size(); ++
i)
61 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType[
i] <<
" sensitive class " 64 double zMinBlock =
args.value<
double>(
"zMinBlock");
65 double rMaxFine =
args.value<
double>(
"rMaxFine");
66 double waferW =
args.value<
double>(
"waferW");
67 double waferGap =
args.value<
double>(
"waferGap");
74 const auto& slopeB =
args.value<std::vector<double> >(
"SlopeBottom");
75 const auto& slopeT =
args.value<std::vector<double> >(
"SlopeTop");
76 const auto& zFront =
args.value<std::vector<double> >(
"ZFront");
77 const auto& rMaxFront =
args.value<std::vector<double> >(
"RMaxFront");
79 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModuleAlgo: Bottom slopes " << slopeB[0] <<
":" << slopeB[1] <<
" and " 80 << slopeT.size() <<
" slopes for top";
81 for (
unsigned int i = 0;
i < slopeT.size(); ++
i)
88 std::unordered_set<int> copies;
97 for (
unsigned int i = 0;
i <
layers.size();
i++) {
98 double zo = zi + layerThick[
i];
100 int laymax = laymin +
layers[
i];
103 for (
int ly = laymin; ly < laymax; ++ly) {
104 int ii = layerType[ly];
105 int copy = copyNumber[
ii];
106 double rinB = (layerSense[ly] == 0) ? (zo * slopeB[0]) : (zo * slopeB[1]);
107 zz += (0.5 * thick[
ii]);
108 thickTot += thick[
ii];
112 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModuleAlgo: Layer " << ly <<
":" <<
ii <<
" Front " 119 if (layerSense[ly] == 0) {
121 double rmax = routF *
cos(
alpha) - tol;
122 std::vector<double> pgonZ, pgonRin, pgonRout;
123 pgonZ.emplace_back(-0.5 * thick[
ii]);
124 pgonZ.emplace_back(0.5 * thick[
ii]);
125 pgonRin.emplace_back(rinB);
126 pgonRin.emplace_back(rinB);
127 pgonRout.emplace_back(rmax);
128 pgonRout.emplace_back(rmax);
136 for (
unsigned int k = 0;
k < pgonZ.size(); ++
k)
141 dd4hep::Solid solid = dd4hep::Tube(0.5 * thick[
ii], rinB, routF, 0.0, 2._pi);
145 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModuleAlgo: " << solid.name() <<
" Tubs made of " << materials[
ii]
148 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModuleAlgo test position in: " << glog.name() <<
" number " <<
copy;
150 double ww = (waferW + waferGap);
151 double dx = 0.5 *
ww;
152 double dy = 3.0 *
dx *
tan(30._deg);
153 double rr = 2.0 *
dx *
tan(30._deg);
154 int ncol =
static_cast<int>(2.0 * routF /
ww) + 1;
155 int nrow =
static_cast<int>(routF / (
ww *
tan(30._deg))) + 1;
157 int incm(0), inrm(0), kount(0),
ntot(0), nin(0), nfine(0), ncoarse(0);
159 <<
" Column " << ncol;
161 for (
int nr = -nrow;
nr <= nrow; ++
nr) {
162 int inr = (
nr >= 0) ?
nr : -
nr;
163 for (
int nc = -ncol; nc <= ncol; ++nc) {
164 int inc = (nc >= 0) ? nc : -nc;
165 if (inr % 2 == inc % 2) {
166 double xpos = nc *
dx;
167 double ypos =
nr *
dy;
183 double rpos =
std::sqrt(xpos * xpos + ypos * ypos);
187 glog.placeVolume(glog1, copyL, dd4hep::Transform3D(
rotation, tran));
194 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModuleAlgo: " << glog1.name() <<
" number " << copyL
195 <<
" positioned in " << glog.name() <<
" at (" <<
cms::convert2mm(xpos)
204 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModuleAlgo: # of columns " << incm <<
" # of rows " << inrm <<
" and " 205 << nin <<
":" << kount <<
":" <<
ntot <<
" wafers (" << nfine <<
":" << ncoarse
211 dd4hep::Rotation3D
rot;
212 module.placeVolume(glog,
copy, dd4hep::Transform3D(
rot, r1));
215 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModuleAlgo: " << glog.name() <<
" number " <<
copy <<
" positioned in " 218 zz += (0.5 * thick[
ii]);
222 if (fabs(thickTot - layerThick[
i]) > tol2) {
223 if (thickTot > layerThick[
i]) {
226 <<
" of all its components **** ERROR ****\n";
229 <<
" does not match with " <<
cms::convert2mm(thickTot) <<
" of the components\n";
235 edm::LogVerbatim(
"HGCalGeom") << copies.size() <<
" different wafer copy numbers";
237 for (std::unordered_set<int>::const_iterator itr = copies.begin(); itr != copies.end(); ++itr, ++
k)
239 edm::LogVerbatim(
"HGCalGeom") <<
"<<== End of DDHGCalModuleAlgo construction ...";
Log< level::Info, true > LogVerbatim
constexpr NumType convertRadToDeg(NumType radians)
constexpr NumType convert2mm(NumType length)
Log< level::Error, false > LogError
dd4hep::Material material(const std::string &name) const
const std::string names[nVars_]
static std::string to_string(const XMLCh *ch)
static constexpr uint32_t k_CornerSize
#define DECLARE_DDCMS_DETELEMENT(name, func)
static constexpr long s_executed
std::string_view name() const
Cos< T >::type cos(const T &t)
Tan< T >::type tan(const T &t)
static int32_t packTypeUV(int type, int u, int v)
Log< level::Warning, false > LogWarning
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
dd4hep::Volume volume(const std::string &name, bool exc=true) const
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
std::string prepend(const std::string &) const