CMS 3D CMS Logo

Functions
DDHGCalGeom Namespace Reference

Functions

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 > &copyNumber, 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)
 

Function Documentation

◆ constructLayers()

void DDHGCalGeom::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 > &  copyNumber,
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 
)

Definition at line 23 of file DDHGCalTBModuleX.cc.

References funct::abs(), cms::DDNamespace::addSolidNS(), cms::convert2mm(), filterCSVwithJSON::copy, PVValHelper::dx, PVValHelper::dy, cuy::ii, createfilelist::int, dqmdumpme::k, cms::DDNamespace::material(), g4SimHits_cfi::Material, SiStripPI::min, callgraph::module, Skims_PA_cff::name, names, EgHLTOffHistBins_cfi::nr, HGCalTypes::packTypeUV(), PixelTestBeamValidation_cfi::Position, cms::DDNamespace::prepend(), diffTwoXMLs::r1, photonAnalyzer_cfi::rMax, findQualityFiles::rr, cms::DDNamespace::solid(), mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, funct::tan(), cond::impl::to_string(), tolerance, cms::DDNamespace::volume(), and geometryCSVtoXML::zz.

Referenced by algorithm(), DDHGCalTBModule::execute(), DDHGCalModule::execute(), DDHGCalModuleAlgo::execute(), DDHGCalHEFileAlgo::execute(), DDHGCalHEAlgo::execute(), DDHGCalEEAlgo::execute(), DDHGCalEEFileAlgo::execute(), DDHGCalMixLayer::execute(), DDHGCalSiliconModule::execute(), DDHGCalMixRotatedLayer::execute(), and DDHGCalSiliconRotatedModule::execute().

44  {
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];
50  int copy = copyNumber[ii];
51  double zz = zi + (0.5 * layerThick[ii]);
52  double zo = zi + layerThick[ii];
53  thickTot += layerThick[ii];
54 
55  std::string name = "HGCal" + names[ii] + std::to_string(copy);
56 #ifdef EDM_ML_DEBUG
57  edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " << name << " Layer " << ly << ":" << ii << " Z "
58  << cms::convert2mm(zi) << ":" << cms::convert2mm(zo) << " Thick "
59  << cms::convert2mm(layerThick[ii]) << " Sense " << layerSense[ly];
60 #endif
61  dd4hep::Material matter = ns.material(materials[ii]);
62  dd4hep::Volume glog;
63  if (layerSense[ly] == 0) {
64  dd4hep::Solid solid = dd4hep::Box(absorbW, absorbH, 0.5 * layerThick[ii]);
65  ns.addSolidNS(ns.prepend(name), solid);
66  glog = dd4hep::Volume(solid.name(), solid, matter);
67 #ifdef EDM_ML_DEBUG
68  edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " << solid.name() << " box of dimension "
69  << cms::convert2mm(absorbW) << ":" << cms::convert2mm(absorbH) << ":"
70  << cms::convert2mm(0.5 * layerThick[ii]);
71 #endif
72  dd4hep::Position r1(0, 0, zz);
73  module.placeVolume(glog, copy, r1);
74 #ifdef EDM_ML_DEBUG
75  edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " << glog.name() << " number " << copy << " positioned in "
76  << module.name() << " at (0,0," << cms::convert2mm(zz) << ") with no rotation";
77 #endif
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;
84 #ifdef EDM_ML_DEBUG
85  int incm(0), inrm(0);
86  edm::LogVerbatim("HGCalGeom") << module.name() << " Copy " << copy << " Type " << layerSense[ly] << " rout "
87  << cms::convert2mm(rMax) << " Row " << nrow << " column " << ncol << " ncrMax "
88  << maxModule[ly] << " Z " << cms::convert2mm(zz) << " Center " << ignoreCenter
89  << " name " << name << " matter " << matter.name();
90  int kount(0);
91 #endif
92  if (maxModule[ly] >= 0) {
93  nrow = std::min(nrow, maxModule[ly]);
94  ncol = std::min(ncol, maxModule[ly]);
95  }
96  for (int nr = -nrow; nr <= nrow; ++nr) {
97  int inr = std::abs(nr);
98  for (int nc = -ncol; nc <= ncol; ++nc) {
99  int inc = std::abs(nc);
100  if ((inr % 2 == inc % 2) && (!ignoreCenter || nc != 0 || nr != 0)) {
101  double xpos = nc * dx;
102  double ypos = nr * dy;
103  double xc[6], yc[6];
104  xc[0] = xpos + dx;
105  yc[0] = ypos - 0.5 * rr;
106  xc[1] = xpos + dx;
107  yc[1] = ypos + 0.5 * rr;
108  xc[2] = xpos;
109  yc[2] = ypos + rr;
110  xc[3] = xpos - dx;
111  yc[3] = ypos + 0.5 * rr;
112  xc[4] = xpos + dx;
113  yc[4] = ypos - 0.5 * rr;
114  xc[5] = xpos;
115  yc[5] = ypos - rr;
116  bool cornerAll(true);
117  for (int k = 0; k < 6; ++k) {
118  double rpos = std::sqrt(xc[k] * xc[k] + yc[k] * yc[k]);
119  if (rpos > rMax)
120  cornerAll = false;
121  }
122  if (cornerAll) {
123  double rpos = std::sqrt(xpos * xpos + ypos * ypos);
124  dd4hep::Position tran(xpos, ypos, zz);
125  int copyx = HGCalTypes::packTypeUV(0, nc, nr);
126  if (layerSense[ly] == 1) {
127  dd4hep::Solid solid = ns.solid(covers[0]);
128  std::string name0 = name + "M" + std::to_string(copyx);
129  name0 = ns.prepend(name0);
130  dd4hep::Volume glog1 = dd4hep::Volume(name0, solid, matter);
131  module.placeVolume(glog1, copy, tran);
132 #ifdef EDM_ML_DEBUG
133  edm::LogVerbatim("HGCalGeom")
134  << "DDHGCalTBModuleX: " << glog1.name() << " number " << copy << " positioned in "
135  << module.name() << " at (" << cms::convert2mm(xpos) << "," << cms::convert2mm(ypos) << ","
136  << cms::convert2mm(zz) << ") with no rotation";
137 #endif
138  dd4hep::Volume glog2 = (rpos < rMaxFine) ? ns.volume(wafers[0]) : ns.volume(wafers[1]);
139  glog1.placeVolume(glog2, copyx);
140 #ifdef EDM_ML_DEBUG
141  edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: " << glog2.name() << " number " << copyx
142  << " positioned in " << glog1.name() << " at (0,0,0) with no rotation";
143 #endif
144  if (layerSense[ly] == 1)
145  copies.insert(copy);
146  } else {
147  dd4hep::Volume glog2 = ns.volume(covers[layerSense[ly] - 1]);
148  copyx += (copy * 1000000);
149  module.placeVolume(glog2, copyx, tran);
150 #ifdef EDM_ML_DEBUG
151  edm::LogVerbatim("HGCalGeom")
152  << "DDHGCalTBModuleX: " << glog2.name() << " number " << copyx << " positioned in "
153  << module.name() << " at (" << cms::convert2mm(xpos) << "," << cms::convert2mm(ypos) << ","
154  << cms::convert2mm(zz) << ") with no rotation";
155 #endif
156  }
157 #ifdef EDM_ML_DEBUG
158  if (inc > incm)
159  incm = inc;
160  if (inr > inrm)
161  inrm = inr;
162  kount++;
163 #endif
164  }
165  }
166  }
167  }
168 #ifdef EDM_ML_DEBUG
169  edm::LogVerbatim("HGCalGeom") << "DDHGCalTBModuleX: # of columns " << incm << " # of rows " << inrm << " and "
170  << kount << " wafers for " << module.name();
171 #endif
172  }
173  ++copyNumber[ii];
174  zi = zo;
175  } // End of loop over layers in a block
176 
177  if (fabs(thickTot - totalWidth) > tolerance) {
178  if (thickTot > totalWidth) {
179  edm::LogError("HGCalGeom") << "Thickness of the partition " << cms::convert2mm(totalWidth)
180  << " is smaller than " << cms::convert2mm(thickTot)
181  << ": total thickness of all its components in " << module.name() << " Layers "
182  << firstLayer << ":" << lastLayer << ":" << ignoreCenter << "**** ERROR ****";
183  } else {
184  edm::LogWarning("HGCalGeom") << "Thickness of the partition " << cms::convert2mm(totalWidth)
185  << " does not match with " << cms::convert2mm(thickTot) << " of the components in "
186  << module.name() << " Layers " << firstLayer << ":" << lastLayer << ":"
187  << ignoreCenter;
188  }
189  }
190  }
Log< level::Info, true > LogVerbatim
const double tolerance
constexpr NumType convert2mm(NumType length)
Definition: DDutils.h:7
std::string to_string(const V &value)
Definition: OMSAccess.h:71
Log< level::Error, false > LogError
dd4hep::Material material(const std::string &name) const
Definition: DDNamespace.cc:166
const std::string names[nVars_]
T sqrt(T t)
Definition: SSEVec.h:19
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dd4hep::Solid solid(const std::string &name) const
Definition: DDNamespace.cc:311
dd4hep::Volume Volume
ii
Definition: cuy.py:589
static int32_t packTypeUV(int type, int u, int v)
Definition: HGCalTypes.cc:3
Log< level::Warning, false > LogWarning
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:276
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
Definition: DDNamespace.cc:292
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:99