7 #include "DD4hep/DetFactoryHelper.h" 27 const auto& thick =
args.value<
double>(
"ModuleThickness");
28 const auto& waferMode =
args.value<
int>(
"WaferMode");
29 const auto& waferSize =
args.value<
double>(
"WaferSize");
33 const auto& waferSepar =
args.value<
double>(
"SensorSeparation");
34 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferPartialRotated: Module " << parentName <<
" made of " << material
39 const auto&
tags =
args.value<std::vector<std::string>>(
"Tags");
40 const auto& partialTypes =
args.value<std::vector<int>>(
"PartialTypes");
41 const auto& placementIndex =
args.value<std::vector<int>>(
"PlacementIndex");
42 const auto& placementIndexTags =
args.value<std::vector<std::string>>(
"PlacementIndexTags");
44 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferPartialRotated: " <<
tags.size() <<
" variations of wafer types";
45 for (
unsigned int k = 0;
k <
tags.size(); ++
k) {
46 for (
unsigned int m = 0;
m < placementIndex.size(); ++
m) {
48 <<
" Placement Index " << placementIndex[
m] <<
" Tag " << placementIndexTags[
m];
52 const auto& layerNames =
args.value<std::vector<std::string>>(
"LayerNames");
53 const auto& materials =
args.value<std::vector<std::string>>(
"LayerMaterials");
54 const auto& layerThick =
args.value<std::vector<double>>(
"LayerThickness");
55 const auto& layerSizeOff =
args.value<std::vector<double>>(
"LayerSizeOffset");
56 const auto& layerType =
args.value<std::vector<int>>(
"LayerTypes");
58 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferPartialRotated: " << layerNames.size() <<
" types of volumes";
59 for (
unsigned int i = 0;
i < layerNames.size(); ++
i)
60 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << layerNames[
i] <<
" of thickness " 62 <<
cms::convert2mm(layerSizeOff[
i]) <<
" filled with " << materials[
i] <<
" type " 65 const auto&
layers =
args.value<std::vector<int>>(
"Layers");
67 std::ostringstream st1;
68 for (
unsigned int i = 0;
i <
layers.size(); ++
i)
69 st1 <<
" [" <<
i <<
"] " <<
layers[
i];
73 const auto& senseT =
args.value<
double>(
"SenseThick");
74 const auto& senseType =
args.value<
int>(
"SenseType");
76 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferPartialRotated: NameSpace " << ns.
name() <<
" Sensitive Layer Name " 77 << senseName <<
" Thickness " << senseT <<
" Type " << senseType;
81 edm::LogVerbatim(
"HGCalGeom") <<
"==>> Executing DDHGCalWaferPartialRotated...";
83 static constexpr
double tol = 0.00001 * dd4hep::mm;
86 for (
unsigned int k = 0;
k <
tags.size(); ++
k) {
87 for (
unsigned int m = 0;
m < placementIndex.size(); ++
m) {
90 std::vector<std::pair<double, double>> wxy =
92 std::vector<double> xM, yM;
93 for (
unsigned int i = 0;
i < (wxy.size() - 1); ++
i) {
94 xM.emplace_back(wxy[
i].
first);
97 std::vector<double>
zw = {-0.5 * thick, 0.5 * thick};
98 std::vector<double> zx(2, 0), zy(2, 0),
scale(2, 1.0);
106 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferPartialRotated: " << solid.name() <<
" extruded polygon made of " 111 <<
" placement index " << placementIndex[
m] <<
" and " << xM.size() <<
" edges";
112 for (
unsigned int j = 0;
j < xM.size(); ++
j)
118 std::vector<dd4hep::Volume> glogs(materials.size());
119 std::vector<int> copyNumber(materials.size(), 1);
120 double zi(-0.5 * thick), thickTot(0.0);
121 for (
unsigned int l = 0;
l <
layers.size();
l++) {
124 partialTypes[
k], placementIndex[
m], waferSize, layerSizeOff[
i], 0.0, 0.0, (waferMode > 0));
125 std::vector<double> xL, yL;
126 for (
unsigned int i0 = 0; i0 < (wxy.size() - 1); ++i0) {
127 xL.emplace_back(wxy[i0].
first);
128 yL.emplace_back(wxy[i0].
second);
131 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferPartialRotated:Layer " <<
l <<
":" <<
i <<
" T " << layerThick[
i]
132 <<
" Size offset " << layerSizeOff[
i] <<
" Copy " << copyNumber[
i]
133 <<
" Partial type " << partialTypes[
k];
135 if (copyNumber[
i] == 1) {
136 if (layerType[
i] > 0) {
140 zw[0] = -0.5 * layerThick[
i];
141 zw[1] = 0.5 * layerThick[
i];
150 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferPartialRotated: " << solid.name()
151 <<
" extruded polygon made of " << materials[
i] <<
" z|x|y|s (0) " 156 <<
" placement index " << placementIndex[
m] <<
" and " << xM.size() <<
" edges";
157 for (
unsigned int j = 0;
j < xL.size(); ++
j)
162 if ((layerType[
i] > 0) && (senseType >= 0)) {
164 zw[0] = -0.5 * senseT;
165 zw[1] = 0.5 * senseT;
171 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferPartialRotated: " << solid.name()
172 <<
" extruded polygon made of " << materials[
i] <<
" z|x|y|s (0) " 177 <<
" placement index " << placementIndex[
m] <<
" and " << xL.size() <<
" edges";
178 for (
unsigned int j = 0;
j < xL.size(); ++
j)
183 double zpos = (posSense.second > 0) ? -0.5 * (
waferThick - senseT) : 0.5 * (
waferThick - senseT);
185 int copy = 10 + senseType;
186 glogs[
i].placeVolume(glog,
copy, tran);
188 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferPartialRotated: " << glog.name() <<
" number " <<
copy 189 <<
" positioned in " << glogs[
i].name() <<
" at (0,0," <<
cms::convert2mm(zpos)
190 <<
") with no rotation";
194 glogM.placeVolume(glogs[
i], copyNumber[
i], tran0);
196 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferPartialRotated: " << glogs[
i].name() <<
" number " 197 << copyNumber[
i] <<
" positioned in " << glogM.name() <<
" at (0,0," 202 thickTot += layerThick[
i];
204 if (
std::abs(thickTot - thick) >= tol) {
205 if (thickTot > thick) {
208 <<
": thickness of all its components **** ERROR ****";
211 <<
" does not match with " <<
cms::convert2mm(thickTot) <<
" of the components";
Log< level::Info, true > LogVerbatim
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
constexpr NumType convert2mm(NumType length)
Log< level::Error, false > LogError
dd4hep::Material material(const std::string &name) const
static std::vector< std::pair< double, double > > waferXY(const int &part, const int &orient, const int &zside, const double &waferSize, const double &offset, const double &xpos, const double &ypos, const bool &v17)
U second(std::pair< T, U > const &p)
#define DECLARE_DDCMS_DETELEMENT(name, func)
static std::pair< int32_t, int32_t > cellOrient(int32_t placementIndex)
static constexpr long s_executed
std::string_view name() const
Abs< T >::type abs(const T &t)
int32_t waferThick(const int32_t property)
auto zw(V v) -> Vec2< typename std::remove_reference< decltype(v[0])>::type >
Log< level::Warning, false > LogWarning
dd4hep::Volume addVolumeNS(dd4hep::Volume vol) const
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
std::string prepend(const std::string &) const