8 #include <unordered_set> 11 #include "DD4hep/DetFactoryHelper.h" 24 const std::vector<std::string>& wafers,
25 const std::vector<std::string>& covers,
26 const std::vector<int>& layerType,
27 const std::vector<int>& layerSense,
28 const std::vector<int>& maxModule,
29 const std::vector<std::string>&
names,
30 const std::vector<std::string>& materials,
31 std::vector<int>& copyNumber,
32 const std::vector<double>& layerThick,
33 const double& absorbW,
34 const double& absorbH,
35 const double& waferTot,
37 const double& rMaxFine,
38 std::unordered_set<int>& copies,
45 static constexpr
double tolerance = 0.00001 * dd4hep::mm;
46 static const double tan30deg =
tan(30._deg);
47 double zi(zFront), thickTot(0);
48 for (
int ly = firstLayer; ly <= lastLayer; ++ly) {
49 int ii = layerType[ly];
51 double zz = zi + (0.5 * layerThick[
ii]);
52 double zo = zi + layerThick[
ii];
53 thickTot += layerThick[
ii];
63 if (layerSense[ly] == 0) {
64 dd4hep::Solid solid = dd4hep::Box(absorbW, absorbH, 0.5 * layerThick[
ii]);
68 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << solid.name() <<
" box of dimension " 75 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << glog.name() <<
" number " <<
copy <<
" positioned in " 78 }
else if (layerSense[ly] > 0) {
79 double dx = 0.5 * waferTot;
80 double dy = 3.0 *
dx * tan30deg;
81 double rr = 2.0 *
dx * tan30deg;
82 int ncol = (
int)(2.0 *
rMax / waferTot) + 1;
83 int nrow = (
int)(
rMax / (waferTot * tan30deg)) + 1;
89 <<
" name " <<
name <<
" matter " << matter.name();
92 if (maxModule[ly] >= 0) {
93 nrow =
std::min(nrow, maxModule[ly]);
94 ncol =
std::min(ncol, maxModule[ly]);
96 for (
int nr = -nrow;
nr <= nrow; ++
nr) {
98 for (
int nc = -ncol; nc <= ncol; ++nc) {
100 if ((inr % 2 == inc % 2) && (!ignoreCenter || nc != 0 ||
nr != 0)) {
101 double xpos = nc *
dx;
102 double ypos =
nr *
dy;
105 yc[0] = ypos - 0.5 *
rr;
107 yc[1] = ypos + 0.5 *
rr;
111 yc[3] = ypos + 0.5 *
rr;
113 yc[4] = ypos - 0.5 *
rr;
116 bool cornerAll(
true);
117 for (
int k = 0;
k < 6; ++
k) {
123 double rpos =
std::sqrt(xpos * xpos + ypos * ypos);
126 if (layerSense[ly] == 1) {
127 dd4hep::Solid solid = ns.
solid(covers[0]);
134 <<
"DDHGCalTBModuleX: " << glog1.name() <<
" number " <<
copy <<
" positioned in " 139 glog1.placeVolume(glog2, copyx);
141 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << glog2.name() <<
" number " << copyx
142 <<
" positioned in " << glog1.name() <<
" at (0,0,0) with no rotation";
144 if (layerSense[ly] == 1)
148 copyx += (
copy * 1000000);
149 module.placeVolume(glog2, copyx, tran);
152 <<
"DDHGCalTBModuleX: " << glog2.name() <<
" number " << copyx <<
" positioned in " 169 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: # of columns " << incm <<
" # of rows " << inrm <<
" and " 170 << kount <<
" wafers for " <<
module.name();
177 if (fabs(thickTot - totalWidth) >
tolerance) {
178 if (thickTot > totalWidth) {
181 <<
": total thickness of all its components in " <<
module.name() <<
" Layers " 182 << firstLayer <<
":" << lastLayer <<
":" << ignoreCenter <<
"**** ERROR ****";
185 <<
" does not match with " <<
cms::convert2mm(thickTot) <<
" of the components in " 186 <<
module.name() <<
" Layers " << firstLayer <<
":" << lastLayer <<
":" 197 const auto& wafers =
args.value<std::vector<std::string> >(
"WaferName");
198 const auto& covers =
args.value<std::vector<std::string> >(
"CoverName");
201 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: Material " << genMat <<
" with " << wafers.size() <<
" wafers";
203 for (
auto wafer : wafers) {
207 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << covers.size() <<
" covers";
209 for (
auto cover : covers) {
214 const auto& materials =
args.value<std::vector<std::string> >(
"MaterialNames");
215 const auto&
names =
args.value<std::vector<std::string> >(
"VolumeNames");
216 const auto& layerThick =
args.value<std::vector<double> >(
"Thickness");
217 std::vector<int> copyNumber;
218 copyNumber.resize(materials.size(), 1);
220 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << materials.size() <<
" types of volumes";
221 for (
unsigned int i = 0;
i <
names.size(); ++
i)
224 <<
" first copy number " << copyNumber[
i];
226 const auto& blockThick =
args.value<std::vector<double> >(
"BlockThick");
227 const auto& inOut =
args.value<
int>(
"InOut");
228 const auto& layerFrontIn =
args.value<std::vector<int> >(
"LayerFrontIn");
229 const auto& layerBackIn =
args.value<std::vector<int> >(
"LayerBackIn");
230 std::vector<int> layerFrontOut;
231 std::vector<int> layerBackOut;
233 layerFrontOut =
args.value<std::vector<int> >(
"LayerFrontOut");
234 layerBackOut =
args.value<std::vector<int> >(
"LayerBackOut");
237 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << blockThick.size() <<
" blocks with in/out " << inOut;
238 for (
unsigned int i = 0;
i < blockThick.size(); ++
i) {
241 <<
" with inner layers " << layerFrontIn[
i] <<
":" << layerBackIn[
i]
242 <<
" and outer layers " << layerFrontOut[
i] <<
":" << layerBackOut[
i];
245 <<
" with inner layers " << layerFrontIn[
i] <<
":" << layerBackIn[
i];
248 const auto& layerType =
args.value<std::vector<int> >(
"LayerType");
249 const auto& layerSense =
args.value<std::vector<int> >(
"LayerSense");
250 const auto& maxModule =
args.value<std::vector<int> >(
"MaxModule");
252 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << layerType.size() <<
" layers";
253 for (
unsigned int i = 0;
i < layerType.size(); ++
i)
254 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType[
i] <<
" sensitive class " 255 << layerSense[
i] <<
" and " << maxModule[
i] <<
" maximum row/columns";
257 const auto& zMinBlock =
args.value<
double>(
"zMinBlock");
258 const auto& rMaxFine =
args.value<
double>(
"rMaxFine");
259 const auto& waferW =
args.value<
double>(
"waferW");
260 const auto& waferGap =
args.value<
double>(
"waferGap");
261 const auto& absorbW =
args.value<
double>(
"absorberW");
262 const auto& absorbH =
args.value<
double>(
"absorberH");
263 const auto&
rMax =
args.value<
double>(
"rMax");
264 const auto& rMaxB =
args.value<
double>(
"rMaxB");
265 double waferTot = waferW + waferGap;
270 <<
" gap among wafers " <<
cms::convert2mm(waferGap) <<
" absorber width " 275 std::unordered_set<int> copies;
279 double zi(zMinBlock);
280 for (
unsigned int i = 0;
i < blockThick.size();
i++) {
281 double zo = zi + blockThick[
i];
289 dd4hep::Solid solid = dd4hep::Tube(0, rMaxB, 0.5 * blockThick[
i], 0.0, 2._pi);
292 double zz = zi + 0.5 * blockThick[
i];
294 parent.placeVolume(glog,
i, r1);
296 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: " << glog.name() <<
" number " <<
i <<
" positioned in " 298 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: \t\tInside Block " <<
i <<
" Layers " << layerFrontIn[
i] <<
":" 320 -0.5 * blockThick[
i],
326 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalTBModuleX: \t\tInside Block " <<
i <<
" Layers " << layerFrontOut[
i]
348 -0.5 * blockThick[
i],
357 <<
cms::convert2mm(zi) <<
" with " << copies.size() <<
" different wafer copy numbers";
Log< level::Info, true > LogVerbatim
constexpr NumType convert2mm(NumType length)
std::string to_string(const V &value)
Log< level::Error, false > LogError
dd4hep::Material material(const std::string &name) const
const std::string names[nVars_]
#define DECLARE_DDCMS_DETELEMENT(name, func)
static constexpr long s_executed
std::string_view name() const
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
void constructLayers(const cms::DDNamespace &ns, const std::vector< std::string > &wafers, const std::vector< std::string > &covers, const std::vector< int > &layerType, const std::vector< int > &layerSense, const std::vector< int > &maxModule, const std::vector< std::string > &names, const std::vector< std::string > &materials, std::vector< int > ©Number, const std::vector< double > &layerThick, const double &absorbW, const double &absorbH, const double &waferTot, const double &rMax, const double &rMaxFine, std::unordered_set< int > &copies, int firstLayer, int lastLayer, double zFront, double totalWidth, bool ignoreCenter, dd4hep::Volume &module)
dd4hep::Solid solid(const std::string &name) const
static int32_t packTypeUV(int type, int u, int v)
Log< level::Warning, false > LogWarning
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
dd4hep::Volume volume(const std::string &name, bool exc=true) const
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
std::string prepend(const std::string &) const