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

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

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, 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(), tolerance, cms::DDNamespace::volume(), and geometryCSVtoXML::zz.

Referenced by algorithm(), DDHGCalTBModule::execute(), DDHGCalModuleAlgo::execute(), DDHGCalModule::execute(), DDHGCalHEFileAlgo::execute(), DDHGCalEEFileAlgo::execute(), DDHGCalEEAlgo::execute(), and DDHGCalHEAlgo::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:560
cms::DDNamespace::solid
dd4hep::Solid solid(const std::string &name) const
Definition: DDNamespace.cc:240
cms::DDNamespace::material
dd4hep::Material material(const std::string &name) const
Definition: DDNamespace.cc:116
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
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:124
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
cms::DDNamespace::prepend
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:60
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:75
dqmdumpme.k
k
Definition: dqmdumpme.py:60
HGCalTypes::packTypeUV
static int32_t packTypeUV(int type, int u, int v)
Definition: HGCalTypes.cc:3
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:47
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:26
cms::DDNamespace::addSolidNS
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
Definition: DDNamespace.cc:221
PVValHelper::dy
Definition: PVValidationHelpers.h:49
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
diffTwoXMLs.r1
r1
Definition: diffTwoXMLs.py:53
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
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:205
PVValHelper::dx
Definition: PVValidationHelpers.h:48