7 #include "DD4hep/DetFactoryHelper.h" 27 const auto& thick =
args.value<
double>(
"ModuleThickness");
28 const auto& waferSize =
args.value<
double>(
"WaferSize");
32 const auto& waferSepar =
args.value<
double>(
"SensorSeparation");
33 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferPartialRotated: Module " << parentName <<
" made of " << material
38 const auto&
tags =
args.value<std::vector<std::string>>(
"Tags");
39 const auto& partialTypes =
args.value<std::vector<int>>(
"PartialTypes");
40 const auto& placementIndex =
args.value<std::vector<int>>(
"PlacementIndex");
41 const auto& placementIndexTags =
args.value<std::vector<std::string>>(
"PlacementIndexTags");
43 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferPartialRotated: " <<
tags.size() <<
" variations of wafer types";
44 for (
unsigned int k = 0;
k <
tags.size(); ++
k) {
45 for (
unsigned int m = 0;
m < placementIndex.size(); ++
m) {
47 <<
" Placement Index " << placementIndex[
m] <<
" Tag " << placementIndexTags[
m];
51 const auto& layerNames =
args.value<std::vector<std::string>>(
"LayerNames");
52 const auto& materials =
args.value<std::vector<std::string>>(
"LayerMaterials");
53 const auto& layerThick =
args.value<std::vector<double>>(
"LayerThickness");
54 const auto& layerSizeOff =
args.value<std::vector<double>>(
"LayerSizeOffset");
55 const auto& layerType =
args.value<std::vector<int>>(
"LayerTypes");
57 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferPartialRotated: " << layerNames.size() <<
" types of volumes";
58 for (
unsigned int i = 0;
i < layerNames.size(); ++
i)
59 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << layerNames[
i] <<
" of thickness " 61 <<
cms::convert2mm(layerSizeOff[
i]) <<
" filled with " << materials[
i] <<
" type " 64 const auto&
layers =
args.value<std::vector<int>>(
"Layers");
66 std::ostringstream st1;
67 for (
unsigned int i = 0;
i <
layers.size(); ++
i)
68 st1 <<
" [" <<
i <<
"] " <<
layers[
i];
72 const auto& senseT =
args.value<
double>(
"SenseThick");
73 const auto& senseType =
args.value<
int>(
"SenseType");
75 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferPartialRotated: NameSpace " << ns.
name() <<
" Sensitive Layer Name " 76 << senseName <<
" Thickness " << senseT <<
" Type " << senseType;
80 edm::LogVerbatim(
"HGCalGeom") <<
"==>> Executing DDHGCalWaferPartialRotated...";
82 static constexpr
double tol = 0.00001 * dd4hep::mm;
85 for (
unsigned int k = 0;
k <
tags.size(); ++
k) {
86 for (
unsigned int m = 0;
m < placementIndex.size(); ++
m) {
89 std::vector<std::pair<double, double>> wxy =
91 std::vector<double> xM, yM;
92 for (
unsigned int i = 0;
i < (wxy.size() - 1); ++
i) {
93 xM.emplace_back(wxy[
i].
first);
96 std::vector<double>
zw = {-0.5 * thick, 0.5 * thick};
97 std::vector<double> zx(2, 0), zy(2, 0),
scale(2, 1.0);
105 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferPartialRotated: " << solid.name() <<
" extruded polygon made of " 110 <<
" placement index " << placementIndex[
m] <<
" and " << xM.size() <<
" edges";
111 for (
unsigned int j = 0;
j < xM.size(); ++
j)
117 std::vector<dd4hep::Volume> glogs(materials.size());
118 std::vector<int> copyNumber(materials.size(), 1);
119 double zi(-0.5 * thick), thickTot(0.0);
120 for (
unsigned int l = 0;
l <
layers.size();
l++) {
123 std::vector<double> xL, yL;
124 for (
unsigned int i0 = 0; i0 < (wxy.size() - 1); ++i0) {
125 xL.emplace_back(wxy[i0].
first);
126 yL.emplace_back(wxy[i0].
second);
129 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferPartialRotated:Layer " <<
l <<
":" <<
i <<
" T " << layerThick[
i]
130 <<
" Size offset " << layerSizeOff[
i] <<
" Copy " << copyNumber[
i]
131 <<
" Partial type " << partialTypes[
k];
133 if (copyNumber[
i] == 1) {
134 if (layerType[
i] > 0) {
138 zw[0] = -0.5 * layerThick[
i];
139 zw[1] = 0.5 * layerThick[
i];
148 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferPartialRotated: " << solid.name()
149 <<
" extruded polygon made of " << materials[
i] <<
" z|x|y|s (0) " 154 <<
" placement index " << placementIndex[
m] <<
" and " << xM.size() <<
" edges";
155 for (
unsigned int j = 0;
j < xL.size(); ++
j)
160 if ((layerType[
i] > 0) && (senseType >= 0)) {
162 zw[0] = -0.5 * senseT;
163 zw[1] = 0.5 * senseT;
169 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferPartialRotated: " << solid.name()
170 <<
" extruded polygon made of " << materials[
i] <<
" z|x|y|s (0) " 175 <<
" placement index " << placementIndex[
m] <<
" and " << xL.size() <<
" edges";
176 for (
unsigned int j = 0;
j < xL.size(); ++
j)
181 double zpos = (posSense.second > 0) ? -0.5 * (
waferThick - senseT) : 0.5 * (
waferThick - senseT);
183 int copy = 10 + senseType;
184 glogs[
i].placeVolume(glog,
copy, tran);
186 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferPartialRotated: " << glog.name() <<
" number " <<
copy 187 <<
" positioned in " << glogs[
i].name() <<
" at (0, 0," <<
cms::convert2mm(zpos)
188 <<
") with no rotation";
192 glogM.placeVolume(glogs[
i], copyNumber[
i], tran0);
194 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalWaferPartialRotated: " << glogs[
i].name() <<
" number " 195 << copyNumber[
i] <<
" positioned in " << glogM.name() <<
" at (0,0," 200 thickTot += layerThick[
i];
202 if (
std::abs(thickTot - thick) >= tol) {
203 if (thickTot > thick) {
206 <<
": thickness of all its components **** ERROR ****";
209 <<
" 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(int part, int orient, int zside, double waferSize, double offset, double xpos, double ypos)
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