12 #include "DD4hep/DetFactoryHelper.h" 28 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalPassivePartial: Creating an instance";
32 double thick =
args.value<
double>(
"ModuleThickness");
33 double waferSize =
args.value<
double>(
"WaferSize");
34 double waferSepar =
args.value<
double>(
"SensorSeparation");
36 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalPassivePartial: Module " << parentName <<
" made of " << material <<
" T " 37 << thick <<
" Wafer 2r " << waferSize <<
" Half Separation " << waferSepar;
39 std::vector<std::string>
tags =
args.value<std::vector<std::string>>(
"Tags");
40 std::vector<int> partialTypes =
args.value<std::vector<int>>(
"PartialTypes");
41 std::vector<int> placementIndex =
args.value<std::vector<int>>(
"PlacementIndex");
42 std::vector<std::string> placementIndexTags =
args.value<std::vector<std::string>>(
"PlacementIndexTags");
44 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalPassivePartial: " <<
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 std::vector<std::string> layerNames =
args.value<std::vector<std::string>>(
"LayerNames");
53 std::vector<std::string> materials =
args.value<std::vector<std::string>>(
"LayerMaterials");
54 std::vector<double> layerThick =
args.value<std::vector<double>>(
"LayerThickness");
56 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalPassivePartial: " << layerNames.size() <<
" types of volumes";
57 for (
unsigned int i = 0;
i < layerNames.size(); ++
i)
58 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << layerNames[
i] <<
" of thickness " << layerThick[
i]
59 <<
" filled with " << materials[
i];
61 std::vector<int> layerType =
args.value<std::vector<int>>(
"LayerType");
63 std::ostringstream st1;
64 for (
unsigned int i = 0;
i < layerType.size(); ++
i)
65 st1 <<
" [" <<
i <<
"] " << layerType[
i];
66 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerType.size() <<
" blocks" << st1.str();
71 static constexpr
double tol = 0.00001;
74 for (
unsigned int k = 0;
k <
tags.size(); ++
k) {
75 for (
unsigned int m = 0;
m < placementIndex.size(); ++
m) {
78 std::vector<std::pair<double, double>> wxy =
80 std::vector<double> xM, yM;
81 for (
unsigned int i = 0;
i < (wxy.size() - 1); ++
i) {
82 xM.emplace_back(wxy[
i].
first);
85 std::vector<double>
zw = {-0.5 * thick, 0.5 * thick};
86 std::vector<double> zx(2, 0), zy(2, 0),
scale(2, 1.0);
93 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalPassivePartial: " << solid.name() <<
" extruded polygon made of " 94 << matter.name() <<
" z|x|y|s (0) " <<
zw[0] <<
":" << zx[0] <<
":" << zy[0]
95 <<
":" <<
scale[0] <<
" z|x|y|s (1) " <<
zw[1] <<
":" << zx[1] <<
":" << zy[1]
96 <<
":" <<
scale[1] <<
" and " << xM.size() <<
" edges";
97 for (
unsigned int kk = 0;
kk < xM.size(); ++
kk)
102 std::vector<dd4hep::Volume> glogs(materials.size());
103 std::vector<int> copyNumber;
104 copyNumber.resize(materials.size(), 1);
105 double zi(-0.5 * thick), thickTot(0.0);
106 for (
unsigned int l = 0;
l < layerType.size();
l++) {
107 unsigned int i = layerType[
l];
108 if (copyNumber[
i] == 1) {
109 zw[0] = -0.5 * layerThick[
i];
110 zw[1] = 0.5 * layerThick[
i];
119 <<
"DDHGCalPassivePartial: Layer " <<
i <<
":" <<
l <<
":" << solid.name()
120 <<
" extruded polygon made of " << matter.name() <<
" z|x|y|s (0) " <<
zw[0] <<
":" << zx[0] <<
":" 121 << zy[0] <<
":" <<
scale[0] <<
" z|x|y|s (1) " <<
zw[1] <<
":" << zx[1] <<
":" << zy[1] <<
":" 122 <<
scale[1] <<
" and " << xM.size() <<
" edges";
123 for (
unsigned int kk = 0;
kk < xM.size(); ++
kk)
128 glogM.placeVolume(glogs[
i], copyNumber[
i], tran);
130 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalPassivePartial: " << glogs[
i].name() <<
" number " << copyNumber[
i]
131 <<
" positioned in " << glogM.name() <<
" at " << tran <<
" with no rotation";
135 thickTot += layerThick[
i];
137 if ((
std::abs(thickTot - thick) >= tol) && (!layerType.empty())) {
138 if (thickTot > thick) {
139 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" is smaller than " << thickTot
140 <<
": thickness of all its components **** ERROR ****";
142 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" does not match with " 143 << thickTot <<
" of the components";
Log< level::Info, true > LogVerbatim
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
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 constexpr long s_executed
Abs< T >::type abs(const T &t)
HGCalPassivePartial(cms::DDParsingContext &ctxt, xml_h e)
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