25 #include <unordered_set>
127 wafers_ = vsArgs[
"WaferNames"];
129 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << wafers_.size() <<
" wafers";
130 for (
unsigned int i = 0;
i < wafers_.size(); ++
i)
133 materials_ = vsArgs[
"MaterialNames"];
134 names_ = vsArgs[
"VolumeNames"];
135 thick_ = vArgs[
"Thickness"];
136 for (
unsigned int i = 0;
i < materials_.size(); ++
i) {
137 copyNumber_.emplace_back(1);
140 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << materials_.size() <<
" types of volumes";
141 for (
unsigned int i = 0;
i < names_.size(); ++
i)
142 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << names_[
i] <<
" of thickness " << thick_[
i]
143 <<
" filled with " << materials_[
i] <<
" first copy number " << copyNumber_[
i];
146 layerThick_ = vArgs[
"LayerThick"];
147 rMixLayer_ = vArgs[
"LayerRmix"];
149 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layers_.size() <<
" blocks";
150 for (
unsigned int i = 0;
i < layers_.size(); ++
i)
151 edm::LogVerbatim(
"HGCalGeom") <<
"Block [" <<
i <<
"] of thickness " << layerThick_[
i] <<
" Rmid " << rMixLayer_[
i]
152 <<
" with " << layers_[
i] <<
" layers";
155 layerSense_ =
dbl_to_int(vArgs[
"LayerSense"]);
156 firstLayer_ = (
int)(nArgs[
"FirstLayer"]);
157 absorbMode_ = (
int)(nArgs[
"AbsorberMode"]);
160 <<
"Absober mode " << absorbMode_;
162 layerCenter_ =
dbl_to_int(vArgs[
"LayerCenter"]);
164 for (
unsigned int i = 0;
i < layerCenter_.size(); ++
i)
167 if (firstLayer_ > 0) {
168 for (
unsigned int i = 0;
i < layerType_.size(); ++
i) {
169 if (layerSense_[
i] > 0) {
170 int ii = layerType_[
i];
171 copyNumber_[
ii] = firstLayer_;
173 edm::LogVerbatim(
"HGCalGeom") <<
"First copy number for layer type " <<
i <<
":" <<
ii <<
" with "
174 << materials_[
ii] <<
" changed to " << copyNumber_[
ii];
181 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerType_.size() <<
" layers";
182 for (
unsigned int i = 0;
i < layerType_.size(); ++
i)
183 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerType_[
i] <<
" sensitive class "
186 materialsTop_ = vsArgs[
"TopMaterialNames"];
187 namesTop_ = vsArgs[
"TopVolumeNames"];
188 layerThickTop_ = vArgs[
"TopLayerThickness"];
189 layerTypeTop_ =
dbl_to_int(vArgs[
"TopLayerType"]);
190 for (
unsigned int i = 0;
i < materialsTop_.size(); ++
i) {
191 copyNumberTop_.emplace_back(1);
194 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << materialsTop_.size() <<
" types of volumes in the top part";
195 for (
unsigned int i = 0;
i < materialsTop_.size(); ++
i)
196 edm::LogVerbatim(
"HGCalGeom") <<
"Volume [" <<
i <<
"] " << namesTop_[
i] <<
" of thickness " << layerThickTop_[
i]
197 <<
" filled with " << materialsTop_[
i] <<
" first copy number " << copyNumberTop_[
i];
198 edm::LogVerbatim(
"HGCalGeom") <<
"There are " << layerTypeTop_.size() <<
" layers in the top part";
199 for (
unsigned int i = 0;
i < layerTypeTop_.size(); ++
i)
200 edm::LogVerbatim(
"HGCalGeom") <<
"Layer [" <<
i <<
"] with material type " << layerTypeTop_[
i];
202 materialsBot_ = vsArgs[
"BottomMaterialNames"];
203 namesBot_ = vsArgs[
"BottomVolumeNames"];
204 layerTypeBot_ =
dbl_to_int(vArgs[
"BottomLayerType"]);
205 layerSenseBot_ =
dbl_to_int(vArgs[
"BottomLayerSense"]);
206 layerThickBot_ = vArgs[
"BottomLayerThickness"];
207 for (
unsigned int i = 0;
i < materialsBot_.size(); ++
i) {
208 copyNumberBot_.emplace_back(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 const double tol(0.01);
292 for (
unsigned int i = 0;
i < layers_.size();
i++) {
293 double zo = zi + layerThick_[
i];
295 int laymax = laymin + layers_[
i];
298 for (
int ly = laymin; ly < laymax; ++ly) {
299 int ii = layerType_[ly];
300 int copy = copyNumber_[
ii];
301 double hthick = 0.5 * thick_[
ii];
304 thickTot += thick_[
ii];
308 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: Layer " << ly <<
":" <<
ii <<
" Front " << zi <<
", " << routF
309 <<
" Back " << zo <<
", " << rinB <<
" superlayer thickness " << layerThick_[
i];
314 if (layerSense_[ly] < 1) {
315 std::vector<double> pgonZ, pgonRin, pgonRout;
316 if (layerSense_[ly] == 0 || absorbMode_ == 0) {
319 pgonZ.emplace_back(-hthick);
320 pgonZ.emplace_back(hthick);
321 pgonRin.emplace_back(rinB);
322 pgonRin.emplace_back(rinB);
323 pgonRout.emplace_back(rmax);
324 pgonRout.emplace_back(rmax);
338 for (
unsigned int isec = 0; isec < pgonZ.size(); ++isec) {
340 pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol;
347 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << solid.
name() <<
" polyhedra of " << sectors_
349 <<
convertRadToDeg(-alpha_ + 2._pi) <<
" with " << pgonZ.size() <<
" sections";
350 for (
unsigned int k = 0;
k < pgonZ.size(); ++
k)
351 edm::LogVerbatim(
"HGCalGeom") <<
"[" <<
k <<
"] z " << pgonZ[
k] <<
" R " << pgonRin[
k] <<
":" << pgonRout[
k];
357 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << solid.
name() <<
" Tubs made of " << matName
358 <<
" of dimensions " << rinB <<
", " << routF <<
", " << hthick
359 <<
", 0.0, 360.0 and positioned in: " << glog.
name() <<
" number " <<
copy;
361 positionMix(glog,
name,
copy, thick_[
ii], matter, rinB, rMixLayer_[
i], routF,
zz, cpv);
369 <<
module.name() <<
" at " <<
r1 <<
" with " <<
rot;
375 if (
std::abs(thickTot - layerThick_[
i]) < 0.00001) {
376 }
else if (thickTot > layerThick_[
i]) {
377 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" is smaller than " << thickTot
378 <<
": thickness of all its "
379 <<
"components **** ERROR ****";
380 }
else if (thickTot < layerThick_[
i]) {
381 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << layerThick_[
i] <<
" does not match with "
382 << thickTot <<
" of the components";
400 for (
unsigned int ly = 0; ly < layerTypeTop_.size(); ++ly) {
401 int ii = layerTypeTop_[ly];
402 copyNumberTop_[
ii] = copyM;
404 for (
unsigned int ly = 0; ly < layerTypeBot_.size(); ++ly) {
405 int ii = layerTypeBot_[ly];
406 copyNumberBot_[
ii] = copyM;
408 double hthick = 0.5 * thick;
415 <<
" of dimensions " << rmid <<
", " << rout <<
", " << hthick <<
", 0.0, 360.0";
420 <<
" at " << tran <<
" with " <<
rot;
422 double thickTot(0), zpos(-hthick);
423 for (
unsigned int ly = 0; ly < layerTypeTop_.size(); ++ly) {
424 int ii = layerTypeTop_[ly];
425 int copy = copyNumberTop_[
ii];
426 double hthickl = 0.5 * layerThickTop_[
ii];
427 thickTot += layerThickTop_[
ii];
430 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: Layer " << ly <<
":" <<
ii <<
" R " << rmid <<
":" << rout
431 <<
" Thick " << layerThickTop_[
ii];
442 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << solid.
name() <<
" Tubs made of " << matName
443 <<
" of dimensions " << rmid <<
", " << rout <<
", " << hthickl <<
", 0.0, 360.0";
450 << glog1.
name() <<
" at " <<
r1 <<
" with " <<
rot;
452 ++copyNumberTop_[
ii];
455 if (
std::abs(thickTot - thick) < 0.00001) {
456 }
else if (thickTot > thick) {
457 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" is smaller than " << thickTot
458 <<
": thickness of all its components in "
459 <<
"the top part **** ERROR ****";
460 }
else if (thickTot < thick) {
461 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" does not match with " << thickTot
462 <<
" of the components in top part";
466 name = nameM +
"Bottom";
471 <<
" of dimensions " << rin <<
", " << rmid <<
", " << hthick <<
", 0.0, 360.0";
476 <<
" at " << tran <<
" with " <<
rot;
480 for (
unsigned int ly = 0; ly < layerTypeBot_.size(); ++ly) {
481 int ii = layerTypeBot_[ly];
482 int copy = copyNumberBot_[
ii];
483 double hthickl = 0.5 * layerThickBot_[
ii];
484 thickTot += layerThickBot_[
ii];
487 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: Layer " << ly <<
":" <<
ii <<
" R " << rin <<
":" << rmid
488 <<
" Thick " << layerThickBot_[
ii];
499 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << solid.
name() <<
" Tubs made of " << matName
500 <<
" of dimensions " << rin <<
", " << rmid <<
", " << hthickl <<
", 0.0, 360.0";
507 << glog1.
name() <<
" at " <<
r1 <<
" with " <<
rot;
509 if (layerSenseBot_[ly] != 0) {
512 << (
copy - firstLayer_) <<
":" << layerCenter_[
copy - firstLayer_];
514 positionSensitive(glog2, rin, rmid,
zz + zpos, layerSenseBot_[ly], layerCenter_[
copy - firstLayer_], cpv);
517 ++copyNumberBot_[
ii];
519 if (
std::abs(thickTot - thick) < 0.00001) {
520 }
else if (thickTot > thick) {
521 edm::LogError(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" is smaller than " << thickTot
522 <<
": thickness of all its components in "
523 <<
"the top part **** ERROR ****";
524 }
else if (thickTot < thick) {
525 edm::LogWarning(
"HGCalGeom") <<
"Thickness of the partition " << thick <<
" does not match with " << thickTot
526 <<
" of the components in top part";
537 static const double sqrt3 =
std::sqrt(3.0);
538 double r = 0.5 * (waferSize_ + waferSepar_);
539 double R = 2.0 *
r / sqrt3;
540 double dy = 0.75 *
R;
541 int N = (
int)(0.5 * rout /
r) + 2;
542 std::pair<double, double> xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_));
544 int ium(0), ivm(0), iumAll(0), ivmAll(0), kount(0), ntot(0),
nin(0);
545 std::vector<int> ntype(6, 0);
546 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: " << glog.
ddname() <<
" rin:rout " << rin <<
":" << rout <<
" zpos "
547 << zpos <<
" N " <<
N <<
" for maximum u, v Offset; Shift " << xyoff.first <<
":"
548 << xyoff.second <<
" WaferSize " << (waferSize_ + waferSepar_);
550 for (
int u = -
N; u <=
N; ++u) {
552 for (
int v = -
N;
v <=
N; ++
v) {
556 double xpos = xyoff.first + nc *
r;
557 double ypos = xyoff.second +
nr *
dy;
563 int type = waferType_->getType(xpos, ypos, zpos);
564 int copy =
type * 1000000 + iv * 100 + iu;
575 if (copies_.count(
copy) == 0)
576 copies_.insert(
copy);
602 edm::LogVerbatim(
"HGCalGeom") <<
"DDHGCalHEAlgo: Maximum # of u " << ium <<
":" << iumAll <<
" # of v " << ivm <<
":"
603 << ivmAll <<
" and " <<
nin <<
":" << kount <<
":" << ntot <<
" wafers (" << ntype[0]
604 <<
":" << ntype[1] <<
":" << ntype[2] <<
":" << ntype[3] <<
":" << ntype[4] <<
":"
605 << ntype[5] <<
") for " << glog.
ddname() <<
" R " << rin <<
":" << rout;