7 #include "DD4hep/DetFactoryHelper.h"
25 const auto& thick = args.
value<
double>(
"ModuleThickness");
26 const auto& waferSize = args.
value<
double>(
"WaferSize");
29 const auto& waferSepar = args.
value<
double>(
"SensorSeparation");
30 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferF: Module " << motherName <<
" made of " << material <<
" T "
35 const auto& layerNames = args.
value<std::vector<std::string>>(
"LayerNames");
36 const auto& materials = args.
value<std::vector<std::string>>(
"LayerMaterials");
37 const auto& layerThick = args.
value<std::vector<double>>(
"LayerThickness");
38 const auto& layerType = args.
value<std::vector<int>>(
"LayerTypes");
39 std::vector<int> copyNumber(materials.size(), 1);
41 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferF: " << layerNames.size() <<
" types of volumes";
42 for (
unsigned int i = 0;
i < layerNames.size(); ++
i)
43 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << layerNames[
i] <<
" of thickness "
47 const auto&
layers = args.
value<std::vector<int>>(
"Layers");
49 std::ostringstream st1;
50 for (
unsigned int i = 0; i <
layers.size(); ++
i)
51 st1 <<
" [" << i <<
"] " <<
layers[i];
55 const auto& cellType = args.
value<
int>(
"CellType");
56 const auto& cellNames = args.
value<std::vector<std::string>>(
"CellNames");
58 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferF: Cells/Wafer " <<
nCells <<
" Cell Type " << cellType <<
" NameSpace "
59 << ns.
name() <<
" # of cells " << cellNames.size();
60 for (
unsigned int k = 0;
k < cellNames.size(); ++
k)
65 static constexpr
double tol = 0.00001 * dd4hep::mm;
66 static const double sqrt3 =
std::sqrt(3.0);
67 double rM = 0.5 * waferSize;
68 double RM2 = rM / sqrt3;
69 double R = waferSize / (3.0 *
nCells);
70 double r = 0.5 * R * sqrt3;
71 double r2 = 0.5 * waferSize;
72 double R2 = r2 / sqrt3;
75 std::vector<double> xM = {rM, 0, -rM, -rM, 0, rM};
76 std::vector<double> yM = {RM2, 2 * RM2, RM2, -RM2, -2 * RM2, -RM2};
77 std::vector<double>
zw = {-0.5 * thick, 0.5 * thick};
78 std::vector<double> zx(2, 0), zy(2, 0),
scale(2, 1.0);
80 dd4hep::Material matter = ns.
material(material);
86 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferF: " << solid.name() <<
" extruded polygon made of " << material
90 <<
cms::convert2mm(zy[1]) <<
":" << scale[1] <<
" and " << xM.size() <<
" edges";
91 for (
unsigned int k = 0;
k < xM.size(); ++
k)
97 std::vector<double> xL = {
r2, 0, -
r2, -
r2, 0, r2};
98 std::vector<double> yL = {R2, 2 * R2, R2, -R2, -2 * R2, -R2};
99 std::vector<dd4hep::Volume> glogs(materials.size());
100 double zi(-0.5 * thick), thickTot(0.0);
101 for (
unsigned int l = 0;
l <
layers.size();
l++) {
103 if (copyNumber[i] == 1) {
104 if (layerType[i] > 0) {
108 zw[0] = -0.5 * layerThick[
i];
109 zw[1] = 0.5 * layerThick[
i];
117 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferF: " << solid.name() <<
" extruded polygon made of " << materials[
i]
121 <<
cms::convert2mm(zy[1]) <<
":" << scale[1] <<
" and " << xM.size() <<
" edges";
122 for (
unsigned int k = 0; k < xL.size(); ++
k)
127 glogM.placeVolume(glogs[i], copyNumber[i], tran0);
129 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferF: " << glogs[
i].name() <<
" number " << copyNumber[
i]
130 <<
" positioned in " << glogM.name() <<
" at (0,0,"
135 thickTot += layerThick[
i];
137 if (layerType[i] > 0) {
138 for (
int u = 0; u < 2 *
nCells; ++u) {
140 if (((
v - u) < nCells) && (u -
v) <= nCells) {
145 double yp = (u - 0.5 *
v - n2) * 2 * r;
146 double xp = (1.5 * (
v -
nCells) + 1.0) *
R;
148 if ((u == 0) && (
v == 0))
150 else if ((u == 0) && (
v == nCells - 1))
152 else if ((u == nCells) && (
v == 2 * nCells - 1))
154 else if ((u == 2 * nCells - 1) && (
v == 2 * nCells - 1))
156 else if ((u == 2 * nCells - 1) && (
v == nCells - 1))
158 else if ((u == nCells) && (
v == 0))
162 else if ((
v - u) == (nCells - 1))
164 else if (
v == (2 * nCells - 1))
166 else if (u == (2 * nCells - 1))
168 else if ((u -
v) == nCells)
174 glogs[
i].placeVolume(ns.
volume(cellNames[cell]),
copy, dd4hep::Transform3D(rotation, tran));
177 <<
"DDHGCalWaferF: " << cellNames[cell] <<
" number " << copy <<
" positioned in " << glogs[
i].name()
186 edm::LogVerbatim(
"HGCalGeom") <<
"\nDDHGCalWaferF::Counter : " << counter <<
"\n===============================\n";
188 if (
std::abs(thickTot - thick) >= tol) {
189 if (thickTot > thick) {
190 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" is smaller than " << thickTot
191 <<
": thickness of all its components **** ERROR ****";
193 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" does not match with " << thickTot
194 <<
" of the components";
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
Log< level::Info, true > LogVerbatim
dd4hep::Volume volume(const std::string &name, bool exc=true) const
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
static int32_t packCellTypeUV(int type, int u, int v)
constexpr NumType convert2mm(NumType length)
dd4hep::Volume addVolumeNS(dd4hep::Volume vol) const
T value(const std::string &name) const
Log< level::Error, false > LogError
std::string_view name() const
#define DECLARE_DDCMS_DETELEMENT(name, func)
static constexpr long s_executed
Abs< T >::type abs(const T &t)
dd4hep::Material material(const std::string &name) const
int32_t waferThick(const int32_t property)
std::string prepend(const std::string &) const
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ uint32_t const *__restrict__ nCells
static std::atomic< unsigned int > counter
auto zw(V v) -> Vec2< typename std::remove_reference< decltype(v[0])>::type >
Log< level::Warning, false > LogWarning
std::string parentName() const
Access value of rParent child node.