26 #include <unordered_set>
69 static constexpr
double tol1_ = 0.01;
70 static constexpr
double tol2_ = 0.00001;
132 wafers_ = vsArgs[
"WaferNames"];
134 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << wafers_.size() <<
" wafers";
135 for (
unsigned int i = 0;
i < wafers_.size(); ++
i)
138 materials_ = vsArgs[
"MaterialNames"];
139 names_ = vsArgs[
"VolumeNames"];
140 thick_ = vArgs[
"Thickness"];
141 copyNumber_.resize(materials_.size(), 1);
143 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << materials_.size() <<
" types of volumes";
144 for (
unsigned int i = 0;
i < names_.size(); ++
i)
145 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << names_[
i] <<
" of thickness " << thick_[
i]
146 <<
" filled with " << materials_[
i] <<
" first copy number " << copyNumber_[
i];
149 layerThick_ = vArgs[
"LayerThick"];
150 rMixLayer_ = vArgs[
"LayerRmix"];
152 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layers_.size() <<
" blocks";
153 for (
unsigned int i = 0;
i < layers_.size(); ++
i)
154 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] of thickness " << layerThick_[
i] <<
" Rmid " << rMixLayer_[
i]
155 <<
" with " << layers_[
i] <<
" layers";
158 layerSense_ =
dbl_to_int(vArgs[
"LayerSense"]);
159 firstLayer_ = (
int)(nArgs[
"FirstLayer"]);
160 absorbMode_ = (
int)(nArgs[
"AbsorberMode"]);
161 sensitiveMode_ = (
int)(nArgs[
"SensitiveMode"]);
164 <<
"Absober:Sensitive mode " << absorbMode_ <<
":" << sensitiveMode_;
166 layerCenter_ =
dbl_to_int(vArgs[
"LayerCenter"]);
168 for (
unsigned int i = 0;
i < layerCenter_.size(); ++
i)
171 if (firstLayer_ > 0) {
172 for (
unsigned int i = 0;
i < layerType_.size(); ++
i) {
173 if (layerSense_[
i] > 0) {
174 int ii = layerType_[
i];
175 copyNumber_[
ii] = firstLayer_;
177 edm::LogVerbatim(
"HGCalGeom") <<
"First copy number for layer type " <<
i <<
":" <<
ii <<
" with "
178 << materials_[
ii] <<
" changed to " << copyNumber_[
ii];
185 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerType_.size() <<
" layers";
186 for (
unsigned int i = 0;
i < layerType_.size(); ++
i)
187 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType_[
i] <<
" sensitive class "
190 materialsTop_ = vsArgs[
"TopMaterialNames"];
191 namesTop_ = vsArgs[
"TopVolumeNames"];
192 layerThickTop_ = vArgs[
"TopLayerThickness"];
193 layerTypeTop_ =
dbl_to_int(vArgs[
"TopLayerType"]);
194 copyNumberTop_.resize(materialsTop_.size(), 1);
196 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << materialsTop_.size() <<
" types of volumes in the top part";
197 for (
unsigned int i = 0;
i < materialsTop_.size(); ++
i)
198 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << namesTop_[
i] <<
" of thickness " << layerThickTop_[
i]
199 <<
" filled with " << materialsTop_[
i] <<
" first copy number " << copyNumberTop_[
i];
200 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerTypeTop_.size() <<
" layers in the top part";
201 for (
unsigned int i = 0;
i < layerTypeTop_.size(); ++
i)
202 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerTypeTop_[
i];
204 materialsBot_ = vsArgs[
"BottomMaterialNames"];
205 namesBot_ = vsArgs[
"BottomVolumeNames"];
206 layerTypeBot_ =
dbl_to_int(vArgs[
"BottomLayerType"]);
207 layerSenseBot_ =
dbl_to_int(vArgs[
"BottomLayerSense"]);
208 layerThickBot_ = vArgs[
"BottomLayerThickness"];
209 copyNumberBot_.resize(materialsBot_.size(), 1);
211 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << materialsBot_.size() <<
" types of volumes in the bottom part";
212 for (
unsigned int i = 0;
i < materialsBot_.size(); ++
i)
213 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << namesBot_[
i] <<
" of thickness " << layerThickBot_[
i]
214 <<
" filled with " << materialsBot_[
i] <<
" first copy number " << copyNumberBot_[
i];
215 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerTypeBot_.size() <<
" layers in the bottom part";
216 for (
unsigned int i = 0;
i < layerTypeBot_.size(); ++
i)
217 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerTypeBot_[
i]
218 <<
" sensitive class " << layerSenseBot_[
i];
220 zMinBlock_ = nArgs[
"zMinBlock"];
221 rad100to200_ = vArgs[
"rad100to200"];
222 rad200to300_ = vArgs[
"rad200to300"];
223 zMinRadPar_ = nArgs[
"zMinForRadPar"];
224 choiceType_ = (
int)(nArgs[
"choiceType"]);
225 nCutRadPar_ = (
int)(nArgs[
"nCornerCut"]);
226 fracAreaMin_ = nArgs[
"fracAreaMin"];
227 waferSize_ = nArgs[
"waferSize"];
228 waferSepar_ = nArgs[
"SensorSeparation"];
229 sectors_ = (
int)(nArgs[
"Sectors"]);
230 alpha_ = (1._pi) / sectors_;
231 cosAlpha_ =
cos(alpha_);
233 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: zStart " << zMinBlock_ <<
" radius for wafer type separation uses "
234 << rad100to200_.size() <<
" parameters; zmin " << zMinRadPar_ <<
" cutoff "
235 << choiceType_ <<
":" << nCutRadPar_ <<
":" << fracAreaMin_ <<
" wafer width "
236 << waferSize_ <<
" separations " << waferSepar_ <<
" sectors " << sectors_ <<
":"
238 for (
unsigned int k = 0;
k < rad100to200_.size(); ++
k)
239 edm::LogVerbatim(
"HGCalGeom") <<
"[" <<
k <<
"] 100-200 " << rad100to200_[
k] <<
" 200-300 " << rad200to300_[
k];
241 slopeB_ = vArgs[
"SlopeBottom"];
242 zFrontB_ = vArgs[
"ZFrontBottom"];
243 rMinFront_ = vArgs[
"RMinFront"];
244 slopeT_ = vArgs[
"SlopeTop"];
245 zFrontT_ = vArgs[
"ZFrontTop"];
246 rMaxFront_ = vArgs[
"RMaxFront"];
248 for (
unsigned int i = 0;
i < slopeB_.size(); ++
i)
249 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] Zmin " << zFrontB_[
i] <<
" Rmin " << rMinFront_[
i]
250 <<
" Slope " << slopeB_[
i];
251 for (
unsigned int i = 0;
i < slopeT_.size(); ++
i)
252 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] Zmin " << zFrontT_[
i] <<
" Rmax " << rMaxFront_[
i]
253 <<
" Slope " << slopeT_[
i];
260 waferType_ = std::make_unique<HGCalWaferType>(
261 rad100to200_, rad200to300_, (waferSize_ + waferSepar_), zMinRadPar_, choiceType_, nCutRadPar_, fracAreaMin_);
275 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << copies_.size() <<
" different wafer copy numbers";
277 for (std::unordered_set<int>::const_iterator
itr = copies_.begin();
itr != copies_.end(); ++
itr, ++
k) {
281 edm::LogVerbatim(
"HGCalGeom") <<
"<<== End of DDHGCalHEAlgo construction...";
289 double zi(zMinBlock_);
291 for (
unsigned int i = 0;
i < layers_.size();
i++) {
292 double zo = zi + layerThick_[
i];
294 int laymax = laymin + layers_[
i];
297 for (
int ly = laymin; ly < laymax; ++ly) {
298 int ii = layerType_[ly];
299 int copy = copyNumber_[
ii];
300 double hthick = 0.5 * thick_[
ii];
303 thickTot += thick_[
ii];
307 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: Layer " << ly <<
":" <<
ii <<
" Front " << zi <<
", " << routF
308 <<
" Back " << zo <<
", " << rinB <<
" superlayer thickness " << layerThick_[
i];
313 if (layerSense_[ly] < 1) {
314 std::vector<double> pgonZ, pgonRin, pgonRout;
315 if (layerSense_[ly] == 0 || absorbMode_ == 0) {
318 pgonZ.emplace_back(-hthick);
319 pgonZ.emplace_back(hthick);
320 pgonRin.emplace_back(rinB);
321 pgonRin.emplace_back(rinB);
322 pgonRout.emplace_back(rmax);
323 pgonRout.emplace_back(rmax);
337 for (
unsigned int isec = 0; isec < pgonZ.size(); ++isec) {
339 pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol1_;
346 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << solid.
name() <<
" polyhedra of " << sectors_
348 <<
convertRadToDeg(-alpha_ + 2._pi) <<
" with " << pgonZ.size() <<
" sections";
349 for (
unsigned int k = 0;
k < pgonZ.size(); ++
k)
350 edm::LogVerbatim(
"HGCalGeom") <<
"[" <<
k <<
"] z " << pgonZ[
k] <<
" R " << pgonRin[
k] <<
":" << pgonRout[
k];
359 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << solid.
name() <<
" Tubs made of " << matName
360 <<
" of dimensions " << rinB <<
":" << rins <<
", " << routF <<
":" << routs
361 <<
", " << hthick <<
", 0.0, 360.0 and positioned in: " << glog.
name()
362 <<
" number " <<
copy;
364 positionMix(glog,
name,
copy, thick_[
ii], matter, rins, rMixLayer_[
i], routs,
zz, cpv);
372 << module.
name() <<
" at " <<
r1 <<
" with " <<
rot;
378 if (
std::abs(thickTot - layerThick_[
i]) >= tol2_) {
379 if (thickTot > layerThick_[
i]) {
380 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" is smaller than " << thickTot
381 <<
": thickness of all its components **** ERROR ****";
383 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" does not match with "
384 << thickTot <<
" of the components";
403 for (
unsigned int ly = 0; ly < layerTypeTop_.size(); ++ly) {
404 int ii = layerTypeTop_[ly];
405 copyNumberTop_[
ii] = copyM;
407 for (
unsigned int ly = 0; ly < layerTypeBot_.size(); ++ly) {
408 int ii = layerTypeBot_[ly];
409 copyNumberBot_[
ii] = copyM;
411 double hthick = 0.5 * thick;
418 <<
" of dimensions " << rmid <<
", " << rout <<
", " << hthick <<
", 0.0, 360.0";
423 <<
" at " << tran <<
" with " <<
rot;
425 double thickTot(0), zpos(-hthick);
426 for (
unsigned int ly = 0; ly < layerTypeTop_.size(); ++ly) {
427 int ii = layerTypeTop_[ly];
428 int copy = copyNumberTop_[
ii];
429 double hthickl = 0.5 * layerThickTop_[
ii];
430 thickTot += layerThickTop_[
ii];
433 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: Layer " << ly <<
":" <<
ii <<
" R " << rmid <<
":" << rout
434 <<
" Thick " << layerThickTop_[
ii];
445 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << solid.
name() <<
" Tubs made of " << matName
446 <<
" of dimensions " << rmid <<
", " << rout <<
", " << hthickl <<
", 0.0, 360.0";
453 << glog1.
name() <<
" at " <<
r1 <<
" with " <<
rot;
455 ++copyNumberTop_[
ii];
458 if (
std::abs(thickTot - thick) >= tol2_) {
459 if (thickTot > thick) {
460 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" is smaller than " << thickTot
461 <<
": thickness of all its components in the top part **** ERROR ****";
463 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" does not match with " << thickTot
464 <<
" of the components in top part";
469 name = nameM +
"Bottom";
474 <<
" of dimensions " << rin <<
", " << rmid <<
", " << hthick <<
", 0.0, 360.0";
479 <<
" at " << tran <<
" with " <<
rot;
483 for (
unsigned int ly = 0; ly < layerTypeBot_.size(); ++ly) {
484 int ii = layerTypeBot_[ly];
485 int copy = copyNumberBot_[
ii];
486 double hthickl = 0.5 * layerThickBot_[
ii];
487 thickTot += layerThickBot_[
ii];
490 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: Layer " << ly <<
":" <<
ii <<
" R " << rin <<
":" << rmid
491 <<
" Thick " << layerThickBot_[
ii];
502 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << solid.
name() <<
" Tubs made of " << matName
503 <<
" of dimensions " << rin <<
", " << rmid <<
", " << hthickl <<
", 0.0, 360.0";
510 << glog1.
name() <<
" at " <<
r1 <<
" with " <<
rot;
512 if (layerSenseBot_[ly] != 0) {
515 << (
copy - firstLayer_) <<
":" << layerCenter_[
copy - firstLayer_];
517 positionSensitive(glog2, rin, rmid,
zz + zpos, layerSenseBot_[ly], layerCenter_[
copy - firstLayer_], cpv);
520 ++copyNumberBot_[
ii];
522 if (
std::abs(thickTot - thick) >= tol2_) {
523 if (thickTot > thick) {
524 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" is smaller than " << thickTot
525 <<
": thickness of all its components in the top part **** ERROR ****";
527 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" does not match with " << thickTot
528 <<
" of the components in top part";
540 static const double sqrt3 =
std::sqrt(3.0);
541 double r = 0.5 * (waferSize_ + waferSepar_);
542 double R = 2.0 *
r / sqrt3;
543 double dy = 0.75 *
R;
544 int N = (
int)(0.5 * rout /
r) + 2;
545 std::pair<double, double> xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_));
547 int ium(0), ivm(0), iumAll(0), ivmAll(0), kount(0), ntot(0),
nin(0);
548 std::vector<int> ntype(6, 0);
549 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << glog.
ddname() <<
" rin:rout " << rin <<
":" << rout <<
" zpos "
550 << zpos <<
" N " <<
N <<
" for maximum u, v Offset; Shift " << xyoff.first <<
":"
551 << xyoff.second <<
" WaferSize " << (waferSize_ + waferSepar_);
553 for (
int u = -
N; u <=
N; ++u) {
554 for (
int v = -
N;
v <=
N; ++
v) {
557 double xpos = xyoff.first + nc *
r;
558 double ypos = xyoff.second +
nr *
dy;
566 int type = waferType_->getType(xpos, ypos, zpos);
574 if (copies_.count(
copy) == 0)
575 copies_.insert(
copy);
601 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: Maximum # of u " << ium <<
":" << iumAll <<
" # of v " << ivm <<
":"
602 << ivmAll <<
" and " <<
nin <<
":" << kount <<
":" << ntot <<
" wafers (" << ntype[0]
603 <<
":" << ntype[1] <<
":" << ntype[2] <<
":" << ntype[3] <<
":" << ntype[4] <<
":"
604 << ntype[5] <<
") for " << glog.
ddname() <<
" R " << rin <<
":" << rout;