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 21 of file DDHGCalTBModuleX.cc.

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

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

Referenced by algorithm(), DDHGCalTBModule::execute(), DDHGCalHEAlgo::execute(), DDHGCalModuleAlgo::execute(), DDHGCalModule::execute(), and DDHGCalEEAlgo::execute().

photonAnalyzer_cfi.rMax
rMax
Definition: photonAnalyzer_cfi.py:91
geometryCSVtoXML.zz
zz
Definition: geometryCSVtoXML.py:19
g4SimHits_cfi.Material
Material
Definition: g4SimHits_cfi.py:547
cms::DDNamespace::solid
dd4hep::Solid solid(const std::string &name) const
Definition: DDNamespace.cc:225
cms::DDNamespace::material
dd4hep::Material material(const std::string &name) const
Definition: DDNamespace.cc:121
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
min
T min(T a, T b)
Definition: MathUtil.h:58
findQualityFiles.rr
string rr
Definition: findQualityFiles.py:185
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:122
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
cms::DDNamespace::prepend
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:66
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:62
dqmdumpme.k
k
Definition: dqmdumpme.py:60
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:45
edm::LogError
Definition: MessageLogger.h:183
EgHLTOffHistBins_cfi.nr
nr
Definition: EgHLTOffHistBins_cfi.py:4
geant_units::operators::convertCmToMm
constexpr NumType convertCmToMm(NumType centimeters)
Definition: GeantUnits.h:68
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
createfilelist.int
int
Definition: createfilelist.py:10
tolerance
const double tolerance
Definition: HGCalGeomParameters.cc:27
edm::LogVerbatim
Definition: MessageLogger.h:297
cms::DDNamespace::addSolidNS
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
Definition: DDNamespace.cc:206
PVValHelper::dy
Definition: PVValidationHelpers.h:49
module
Definition: vlib.h:198
diffTwoXMLs.r1
r1
Definition: diffTwoXMLs.py:53
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
cuy.ii
ii
Definition: cuy.py:590
cms::DDNamespace::volume
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:190
PVValHelper::dx
Definition: PVValidationHelpers.h:48