9 #include "DD4hep/DetFactoryHelper.h" 21 dd4hep::SensitiveDetector& ) {
26 const auto& materials = args.
value<std::vector<std::string> >(
"MaterialNames");
27 const auto&
names = args.
value<std::vector<std::string> >(
"VolumeNames");
28 const auto& thick = args.
value<std::vector<double> >(
"Thickness");
29 std::vector<int> copyNumber;
30 for (
unsigned int i = 0;
i < materials.size(); ++
i)
31 copyNumber.emplace_back(1);
34 edm::LogVerbatim(
"HGCalGeom") <<
"DDAHcalModuleAlgo: " << materials.size() <<
" types of volumes";
35 for (
unsigned int i = 0;
i < names.size(); ++
i)
36 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << names[
i] <<
" of thickness " << thick[
i]
37 <<
" filled with " << materials[
i] <<
" first copy number " << copyNumber[
i];
39 const auto&
layers = args.
value<std::vector<int> >(
"Layers");
40 const auto& layerThick = args.
value<std::vector<double> >(
"LayerThick");
41 const auto& layerType = args.
value<std::vector<int> >(
"LayerType");
42 const auto& layerSense = args.
value<std::vector<int> >(
"LayerSense");
45 for (
unsigned int i = 0;
i <
layers.size(); ++
i)
48 edm::LogVerbatim(
"HGCalGeom") <<
"DDAHcalModuleAlgo: " << layerType.size() <<
" layers";
49 for (
unsigned int i = 0;
i < layerType.size(); ++
i)
50 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType[
i] <<
" sensitive class " 53 const auto& widths = args.
value<std::vector<double> >(
"Widths");
54 const auto& heights = args.
value<std::vector<double> >(
"Heights");
55 const auto& tileN = args.
value<std::vector<int> >(
"TileN");
56 const auto& tileStep = args.
value<std::vector<double> >(
"TileStep");
58 edm::LogVerbatim(
"HGCalGeom") <<
"DDAHcalModuleAlgo: " << widths.size() <<
" sizes for width " 60 for (
unsigned int i = 0;
i < widths.size(); ++
i)
62 edm::LogVerbatim(
"HGCalGeom") <<
"DDAHcalModuleAlgo: " << tileN.size() <<
" tile positioning parameters";
63 for (
unsigned int i = 0;
i < tileN.size(); ++
i)
66 const auto& zMinBlock = args.
value<
double>(
"zMinBlock");
69 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalModule: zStart " << zMinBlock <<
" NameSpace " << idNameSpace;
77 for (
unsigned int i = 0;
i < layers.size();
i++) {
78 double zo = zi + layerThick[
i];
79 int laymax = laymin + layers[
i];
82 for (
int ly = laymin; ly < laymax; ++ly) {
83 int ii = layerType[ly];
85 zz += (0.5 * thick[
ii]);
86 thickTot += thick[
ii];
90 edm::LogVerbatim(
"HGCalGeom") <<
"DDAHcalModuleAlgo test: Layer " << ly <<
":" << ii <<
" Front " << zi
91 <<
" Back " << zo <<
" superlayer thickness " << layerThick[
i];
95 if (layerSense[ly] == 0) {
96 dd4hep::Solid solid = dd4hep::Box(0.5 * widths[0], 0.5 * heights[0], 0.5 * thick[ii]);
100 edm::LogVerbatim(
"HGCalGeom") <<
"DDAHcalModuleAlgo: " << solid.name() <<
" Box made of " << materials[
ii]
101 <<
" of dimensions " << 0.5 * widths[0] <<
", " << 0.5 * heights[0] <<
", " 105 dd4hep::Solid solid = dd4hep::Box(0.5 * widths[1], 0.5 * heights[1], 0.5 * thick[ii]);
109 edm::LogVerbatim(
"HGCalGeom") <<
"DDAHcalModuleAlgo: " << solid.name() <<
" Box made of " << materials[
ii]
110 <<
" of dimensions " << 0.5 * widths[1] <<
", " << 0.5 * heights[1] <<
", " 113 int ncol = tileN[0] / 2;
114 int nrow = tileN[1] / 2;
117 edm::LogVerbatim(
"HGCalGeom") << glog.name() <<
" Row " << nrow <<
" Column " << ncol;
119 for (
int nr = -nrow;
nr <= nrow; ++
nr) {
120 int inr = (
nr >= 0) ?
nr : -
nr;
121 double ypos = (
nr >= 0) ? (inr - 0.5) * tileStep[1] : -(inr - 0.5) * tileStep[1];
122 for (
int nc = -ncol; nc <= ncol; ++nc) {
123 int inc = (nc >= 0) ? nc : -nc;
124 double xpos = (nc >= 0) ? (inc - 0.5) * tileStep[0] : -(inc - 0.5) * tileStep[0];
125 if (
nr != 0 && nc != 0) {
126 dd4hep::Position tran(xpos, ypos, 0.0);
134 glog.placeVolume(glog1, copy, dd4hep::Transform3D(rotation, tran));
137 edm::LogVerbatim(
"HGCalGeom") <<
"DDAHcalModuleAlgo: " << tile <<
" number " << copy <<
" positioned in " 138 << glog.name() <<
" at " << tran <<
" with " <<
rotation;
144 edm::LogVerbatim(
"HGCalGeom") <<
"DDAHcalModuleAlgo: " << kount <<
" tiles for " << glog.name();
147 dd4hep::Position
r1(0, 0, zz);
148 dd4hep::Rotation3D
rot;
149 module.placeVolume(glog, copy, dd4hep::Transform3D(rot, r1));
152 edm::LogVerbatim(
"HGCalGeom") <<
"DDAHcalModuleAlgo: " << glog.name() <<
" number " << copy <<
" positioned in " 153 << module.name() <<
" at " << r1 <<
" with " <<
rot;
155 zz += (0.5 * thick[
ii]);
159 if (fabs(thickTot - layerThick[
i]) < 0.00001) {
160 }
else if (thickTot > layerThick[i]) {
161 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << layerThick[
i] <<
" is smaller than thickness " 162 << thickTot <<
" of all its components **** ERROR ****\n";
163 }
else if (thickTot < layerThick[i]) {
164 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << layerThick[
i] <<
" does not match with " 165 << thickTot <<
" of the components\n";
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
static constexpr int kSignRowColumn_
dd4hep::Volume volume(const std::string &name, bool exc=true) const
T value(const std::string &name) const
const std::string names[nVars_]
std::string_view name() const
dd4hep::Material material(const std::string &name) const
std::string prepend(const std::string &) const
static constexpr int kRowColumn_
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e, dd4hep::SensitiveDetector &)
#define DECLARE_DDCMS_DETELEMENT(name, func)
static constexpr int kColumn_
Constants used.
std::string parentName() const
Access value of rParent child node.