24 #include <unordered_set>
54 std::map<int, HGCalGeomParameters::layerParameters>
layers;
55 std::vector<HGCalParameters::hgtrform> trforms;
56 std::vector<bool> trformUse;
63 int lay = (nsiz > 0) ?
copy[nsiz - 1] : 0;
64 int zp = (nsiz > 2) ?
copy[nsiz - 3] : -1;
68 throw cms::Exception(
"DDException") <<
"Funny layer # " << lay <<
" zp " << zp <<
" in " << nsiz <<
" components";
71 php.
layer_.emplace_back(lay);
72 auto itr =
layers.find(lay);
74 double rin(0), rout(0);
77 const DDPolyhedra& polyhedra = static_cast<DDPolyhedra>(sol);
78 const std::vector<double>& rmin = polyhedra.
rMinVec();
79 const std::vector<double>& rmax = polyhedra.
rMaxVec();
83 const DDTubs& tube = static_cast<DDTubs>(sol);
92 const CLHEP::HepRep3x3
rotation(
x.X(),
y.X(),
z.X(),
x.Y(),
y.Y(),
z.Y(),
x.Z(),
y.Z(),
z.Z());
93 const CLHEP::HepRotation hr(
rotation);
101 const CLHEP::Hep3Vector h3v(
xx,
yy,
zz);
109 trforms.emplace_back(mytrf);
110 trformUse.emplace_back(
false);
119 std::unordered_map<int32_t, int32_t> copies;
121 std::vector<int32_t> wafer2copy;
122 std::vector<HGCalGeomParameters::cellParameters> wafers;
124 DDValue val1(attribute, sdTag2, 0.0);
129 throw cms::Exception(
"DDException") <<
"Attribute " << val1 <<
" not found but needed.";
132 std::unordered_set<std::string>
names;
138 int wafer = (nsiz > 0) ?
copy[nsiz - 1] : 0;
139 int layer = (nsiz > 1) ?
copy[nsiz - 2] : 0;
141 throw cms::Exception(
"DDException") <<
"Funny wafer # " << wafer <<
" in " << nsiz <<
" components";
144 <<
" among " << nsiz <<
" components";
146 auto itr = copies.find(wafer);
147 auto cpy = copiesInLayers[
layer].find(wafer);
148 if (itr != copies.end() && cpy == copiesInLayers[
layer].end()) {
149 copiesInLayers[
layer][wafer] = itr->second;
151 if (itr == copies.end()) {
152 copies[wafer] = wafer2copy.size();
153 copiesInLayers[
layer][wafer] = wafer2copy.size();
160 wafer2copy.emplace_back(wafer);
163 wafers.emplace_back(cell);
165 std::vector<double>
zv, rv;
167 const DDPolyhedra& polyhedra = static_cast<DDPolyhedra>(sol);
200 std::map<int, int> wafertype;
201 std::map<int, HGCalGeomParameters::cellParameters> cellsf, cellsc;
202 DDValue val2(attribute, sdTag3, 0.0);
207 throw cms::Exception(
"DDException") <<
"Attribute " << val2 <<
" not found but needed.";
215 int cellx = (nsiz > 0) ?
copy[nsiz - 1] : 0;
216 int wafer = (nsiz > 1) ?
copy[nsiz - 2] : 0;
221 <<
"Funny cell # " << cell <<
" type " <<
type <<
" in " << nsiz <<
" components";
223 auto ktr = wafertype.find(wafer);
224 if (ktr == wafertype.end())
225 wafertype[wafer] =
type;
227 std::map<int, HGCalGeomParameters::cellParameters>::iterator itr;
230 itr = cellsf.find(cell);
231 newc = (itr == cellsf.end());
233 itr = cellsc.find(cell);
234 newc = (itr == cellsc.end());
238 bool half = (
name.find(
"Half") != std::string::npos);
251 edm::LogVerbatim(
"HGCalGeom") <<
"Wafer " << wafer <<
" Type " <<
type <<
" Cell " << cellx <<
" local "
252 <<
xx <<
":" <<
yy <<
" new " <<
p1 <<
":" <<
p2;
268 layers, trforms, trformUse, copies, copiesInLayers, wafer2copy, wafers, wafertype, cellsf, cellsc, php);
279 std::map<int, HGCalGeomParameters::layerParameters>
layers;
280 std::vector<HGCalParameters::hgtrform> trforms;
281 std::vector<bool> trformUse;
282 std::vector<std::pair<int, int> > trused;
285 const std::vector<double>& pars = fv.
parameters();
289 int lay = (nsiz > 0) ?
copy[0] : 0;
290 int zp = (nsiz > 2) ?
copy[2] : -1;
294 throw cms::Exception(
"DDException") <<
"Funny layer # " << lay <<
" zp " << zp <<
" in " << nsiz <<
" components";
297 php.
layer_.emplace_back(lay);
298 auto itr =
layers.find(lay);
300 if (itr ==
layers.end()) {
301 double rin(0), rout(0);
302 if (dd4hep::isA<dd4hep::Polyhedra>(fv.
solid())) {
305 }
else if (dd4hep::isA<dd4hep::Tube>(fv.
solid())) {
306 dd4hep::Tube tubeSeg(fv.
solid());
313 std::pair<int, int> layz(lay, zp);
314 if (
std::find(trused.begin(), trused.end(), layz) == trused.end()) {
315 trused.emplace_back(layz);
318 const CLHEP::HepRep3x3
rotation(
x.X(),
y.X(),
z.X(),
x.Y(),
y.Y(),
z.Y(),
x.Z(),
y.Z(),
z.Z());
319 const CLHEP::HepRotation hr(
rotation);
327 const CLHEP::Hep3Vector h3v(
xx,
yy,
zz);
335 trforms.emplace_back(mytrf);
336 trformUse.emplace_back(
false);
345 std::unordered_map<int32_t, int32_t> copies;
347 std::vector<int32_t> wafer2copy;
348 std::vector<HGCalGeomParameters::cellParameters> wafers;
353 throw cms::Exception(
"DDException") <<
"Attribute " << sdTag2 <<
" not found but needed.";
356 std::unordered_set<std::string>
names;
361 int wafer = (nsiz > 0) ?
copy[0] : 0;
364 throw cms::Exception(
"DDException") <<
"Funny wafer # " << wafer <<
" in " << nsiz <<
" components";
367 <<
" among " << nsiz <<
" components";
369 auto itr = copies.find(wafer);
370 auto cpy = copiesInLayers[
layer].find(wafer);
371 if (itr != copies.end() && cpy == copiesInLayers[
layer].end()) {
372 copiesInLayers[
layer][wafer] = itr->second;
374 if (itr == copies.end()) {
375 copies[wafer] = wafer2copy.size();
376 copiesInLayers[
layer][wafer] = wafer2copy.size();
383 wafer2copy.emplace_back(wafer);
386 wafers.emplace_back(cell);
389 const std::vector<double>& pars = fv1.
parameters();
424 std::map<int, int> wafertype;
425 std::map<int, HGCalGeomParameters::cellParameters> cellsf, cellsc;
430 throw cms::Exception(
"DDException") <<
"Attribute " << sdTag3 <<
" not found but needed.";
437 int cellx = (nsiz > 0) ?
copy[0] : 0;
438 int wafer = (nsiz > 1) ?
copy[1] : 0;
443 <<
"Funny cell # " << cell <<
" type " <<
type <<
" in " << nsiz <<
" components";
445 auto ktr = wafertype.find(wafer);
446 if (ktr == wafertype.end())
447 wafertype[wafer] =
type;
449 std::map<int, HGCalGeomParameters::cellParameters>::iterator itr;
452 itr = cellsf.find(cell);
453 newc = (itr == cellsf.end());
455 itr = cellsc.find(cell);
456 newc = (itr == cellsc.end());
460 bool half = (
name.find(
"Half") != std::string::npos);
473 edm::LogVerbatim(
"HGCalGeom") <<
"Wafer " << wafer <<
" Type " <<
type <<
" Cell " << cellx <<
" local "
474 <<
xx <<
":" <<
yy <<
" new " <<
p1 <<
":" <<
p2;
490 layers, trforms, trformUse, copies, copiesInLayers, wafer2copy, wafers, wafertype, cellsf, cellsc, php);
494 std::vector<HGCalParameters::hgtrform>& trforms,
495 std::vector<bool>& trformUse,
496 const std::unordered_map<int32_t, int32_t>& copies,
498 const std::vector<int32_t>& wafer2copy,
499 const std::vector<HGCalGeomParameters::cellParameters>& wafers,
500 const std::map<int, int>& wafertype,
501 const std::map<int, HGCalGeomParameters::cellParameters>& cellsf,
502 const std::map<int, HGCalGeomParameters::cellParameters>& cellsc,
504 if (((cellsf.size() + cellsc.size()) == 0) || (wafers.empty()) || (
layers.empty())) {
505 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: mismatch between geometry and specpar: cells "
506 << cellsf.size() <<
":" << cellsc.size() <<
" wafers " << wafers.size()
507 <<
" layers " <<
layers.size();
510 for (
unsigned int i = 0;
i <
layers.size(); ++
i) {
522 for (
unsigned int i = 0;
i < php.
layer_.size(); ++
i) {
523 for (
unsigned int i1 = 0;
i1 < trforms.size(); ++
i1) {
524 if (!trformUse[
i1] && php.
layerGroup_[trforms[
i1].lay - 1] == (
int)(
i + 1)) {
526 trforms[
i1].lay = (
i + 1);
527 trformUse[
i1] =
true;
530 for (
unsigned int i2 =
i1 + 1;
i2 < trforms.size(); ++
i2) {
531 if (!trformUse[
i2] && trforms[
i2].zp == trforms[
i1].zp &&
535 trformUse[
i2] =
true;
546 for (
unsigned i = 0;
i < wafer2copy.size(); ++
i) {
550 auto ktr = wafertype.find(wafer2copy[
i]);
551 int typet = (ktr == wafertype.end()) ? 0 : (ktr->second);
553 double r = wafers[
i].xyz.perp();
555 for (
int k = 1;
k < 4; ++
k) {
566 std::vector<HGCalGeomParameters::cellParameters>::const_iterator itrf = wafers.end();
567 for (
unsigned int i = 0;
i < cellsf.size(); ++
i) {
568 auto itr = cellsf.find(
i);
569 if (itr == cellsf.end()) {
570 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: missing info for fine cell number " <<
i;
572 double xx = (itr->second).xyz.x();
573 double yy = (itr->second).xyz.y();
574 int waf = (itr->second).wafer;
582 for (
unsigned int i = 0;
i < cellsc.size(); ++
i) {
583 auto itr = cellsc.find(
i);
584 if (itr == cellsc.end()) {
585 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: missing info for coarse cell number " <<
i;
587 double xx = (itr->second).xyz.x();
588 double yy = (itr->second).xyz.y();
589 int waf = (itr->second).wafer;
602 php.
depth_.emplace_back(
i + 1);
642 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomParameters: wafer radius " << php.
waferR_ <<
" and dimensions of the "
656 <<
" coarse cells in a wafer";
675 for (std::unordered_map<int, int>::const_iterator itr = theModules.begin(); itr != theModules.end(); ++itr, ++k2) {
676 edm::LogVerbatim(
"HGCalGeom") <<
"[" << k2 <<
"] " << itr->first <<
":" << itr->second;
685 std::map<int, HGCalGeomParameters::layerParameters>
layers;
697 if (nsiz < levelTop) {
698 int lay =
copy[nsiz - 1];
705 <<
" lay " << lay <<
" z " <<
zside;
709 <<
"Funny layer # " << lay <<
" zp " <<
zside <<
" in " << nsiz <<
" components";
712 php.
layer_.emplace_back(lay);
713 const DDTubs& tube = static_cast<DDTubs>(sol);
716 auto itr =
layers.find(lay);
717 if (itr ==
layers.end()) {
722 (itr->second).rmin =
std::min(rin, (itr->second).rmin);
723 (itr->second).rmax =
std::max(rout, (itr->second).rmax);
725 if (trforms.find(std::make_pair(lay,
zside)) == trforms.end()) {
728 const CLHEP::HepRep3x3
rotation(
x.X(),
y.X(),
z.X(),
x.Y(),
y.Y(),
z.Y(),
x.Z(),
y.Z(),
z.Z());
729 const CLHEP::HepRotation hr(
rotation);
744 trforms[std::make_pair(lay,
zside)] = mytrf;
762 std::map<int, HGCalGeomParameters::layerParameters>
layers;
773 int nsiz = static_cast<int>(fv.
level());
774 if (nsiz < levelTop) {
782 <<
" size " << nsiz <<
":" << levelTop <<
" lay " << lay <<
" z " <<
zside <<
":"
787 <<
"Funny layer # " << lay <<
" zp " <<
zside <<
" in " << nsiz <<
" components";
790 php.
layer_.emplace_back(lay);
791 const std::vector<double>& pars = fv.
parameters();
794 auto itr =
layers.find(lay);
795 if (itr ==
layers.end()) {
800 (itr->second).rmin =
std::min(rin, (itr->second).rmin);
801 (itr->second).rmax =
std::max(rout, (itr->second).rmax);
803 if (trforms.find(std::make_pair(lay,
zside)) == trforms.end()) {
806 const CLHEP::HepRep3x3
rotation(
x.X(),
y.X(),
z.X(),
x.Y(),
y.Y(),
z.Y(),
x.Z(),
y.Z(),
z.Z());
807 const CLHEP::HepRotation hr(
rotation);
822 trforms[std::make_pair(lay,
zside)] = mytrf;
839 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomParameters (DDD)::loadGeometryHexagonModule called with tags " << sdTag1
840 <<
":" << sdTag2 <<
" firstLayer " << firstLayer <<
":" << php.
firstMixedLayer_;
841 int ntot1(0), ntot2(0);
843 std::map<int, HGCalGeomParameters::layerParameters>
layers;
844 std::map<std::pair<int, int>,
double> zvals;
849 DDValue val1(attribute, sdTag2, 0.0);
858 int nsiz = static_cast<int>(
copy.size());
859 if (levelTop < nsiz) {
860 int lay =
copy[levelTop];
866 <<
"Funny layer # " << lay <<
" zp " <<
zside <<
" in " << nsiz <<
" components";
868 if (zvals.find(std::make_pair(lay,
zside)) == zvals.end()) {
871 std::ostringstream st1;
872 st1 <<
"Name0 " << fv1.
name() <<
" LTop " << levelTop <<
":" << lay <<
" ZSide " <<
zside <<
" # of levels "
874 for (
const auto&
c :
copy)
876 st1 <<
" Z " << zvals[std::make_pair(lay,
zside)];
885 DDValue val2(attribute, sdTag1, 0.0);
894 int nsiz = static_cast<int>(
copy.size());
895 if (levelTop < nsiz) {
896 int lay =
copy[levelTop];
902 std::ostringstream st2;
903 st2 <<
"Name1 " << sol.
name() <<
" shape " << sol.
shape() <<
" LTop " << levelTop <<
":" << lay <<
" ZSide "
905 for (
const auto&
c :
copy)
911 <<
"Funny layer # " << lay <<
" zp " <<
zside <<
" in " << nsiz <<
" components";
913 if (zvals.find(std::make_pair(lay,
zside)) != zvals.end()) {
915 php.
layer_.emplace_back(lay);
916 auto itr =
layers.find(lay);
917 if (itr ==
layers.end()) {
918 const DDTubs& tube = static_cast<DDTubs>(sol);
923 double zp = zvals[std::make_pair(lay, 1)];
927 std::ostringstream st3;
928 st3 <<
"Name1 " << fv2.
name() <<
" LTop " << levelTop <<
":" << lay <<
" ZSide " <<
zside <<
" # of levels "
930 for (
const auto&
c :
copy)
932 st3 <<
" R " << rin <<
":" << rout;
937 if (trforms.find(std::make_pair(lay,
zside)) == trforms.end()) {
940 const CLHEP::HepRep3x3
rotation(
x.X(),
y.X(),
z.X(),
x.Y(),
y.Y(),
z.Y(),
x.Z(),
y.Z(),
z.Z());
941 const CLHEP::HepRotation hr(
rotation);
948 const CLHEP::Hep3Vector h3v(
xx,
yy, zvals[std::make_pair(lay,
zside)]);
956 trforms[std::make_pair(lay,
zside)] = mytrf;
964 edm::LogVerbatim(
"HGCalGeom") <<
"Total # of views " << ntot1 <<
":" << ntot2;
975 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomParameters (DD4Hep)::loadGeometryHexagonModule called with tags " << sdTag1
976 <<
":" << sdTag2 <<
" firstLayer " << firstLayer;
977 int ntot1(0), ntot2(0);
979 std::map<int, HGCalGeomParameters::layerParameters>
layers;
981 std::map<std::pair<int, int>,
double> zvals;
990 int nsiz = static_cast<int>(fv1.
level());
991 if (nsiz > levelTop) {
993 int lay =
copy[nsiz - levelTop - 1];
999 <<
"Funny layer # " << lay <<
" zp " <<
zside <<
" in " << nsiz <<
" components";
1001 if (zvals.find(std::make_pair(lay,
zside)) == zvals.end()) {
1004 std::ostringstream st1;
1005 st1 <<
"Name0 " << fv1.
name() <<
" LTop " << levelTop <<
":" << lay <<
" ZSide " <<
zside <<
" # of levels "
1007 for (
const auto&
c :
copy)
1009 st1 <<
" Z " << zvals[std::make_pair(lay,
zside)];
1021 int nsiz = static_cast<int>(fv2.
level());
1025 if (nsiz > levelTop) {
1027 int lay =
copy[nsiz - levelTop - 1];
1032 std::ostringstream st2;
1034 << levelTop <<
":" << lay <<
" ZSide " <<
zside <<
":" << php.
levelZSide_ <<
" # of levels " << nsiz;
1041 <<
"Funny layer # " << lay <<
" zp " <<
zside <<
" in " << nsiz <<
" components";
1043 if (zvals.find(std::make_pair(lay,
zside)) != zvals.end()) {
1045 php.
layer_.emplace_back(lay);
1046 auto itr =
layers.find(lay);
1047 if (itr ==
layers.end()) {
1048 const std::vector<double>& pars = fv2.
parameters();
1053 double zp = zvals[std::make_pair(lay, 1)];
1057 std::ostringstream st3;
1058 st3 <<
"Name2 " << fv2.
name() <<
" LTop " << levelTop <<
":" << lay <<
" ZSide " <<
zside <<
" # of levels "
1060 for (
const auto&
c :
copy)
1062 st3 <<
" R " << rin <<
":" << rout;
1067 if (trforms.find(std::make_pair(lay,
zside)) == trforms.end()) {
1070 const CLHEP::HepRep3x3
rotation(
x.X(),
y.X(),
z.X(),
x.Y(),
y.Y(),
z.Y(),
x.Z(),
y.Z(),
z.Z());
1071 const CLHEP::HepRotation hr(
rotation);
1078 const CLHEP::Hep3Vector h3v(
xx,
yy, zvals[std::make_pair(lay,
zside)]);
1086 trforms[std::make_pair(lay,
zside)] = mytrf;
1093 edm::LogVerbatim(
"HGCalGeom") <<
"Total # of views " << ntot1 <<
":" << ntot2;
1100 const int& firstLayer,
1102 double rmin(0), rmax(0);
1103 for (
unsigned int i = 0;
i <
layers.size(); ++
i) {
1105 if (
layer.first == (
int)(
i + firstLayer)) {
1111 rmin =
layer.second.rmin;
1112 rmax =
layer.second.rmax;
1114 if (rmin >
layer.second.rmin)
1115 rmin =
layer.second.rmin;
1116 if (rmax <
layer.second.rmax)
1117 rmax =
layer.second.rmax;
1123 php.
rLimit_.emplace_back(rmin);
1124 php.
rLimit_.emplace_back(rmax);
1129 for (
unsigned int i = 0;
i < php.
layer_.size(); ++
i) {
1130 for (
auto& trform : trforms) {
1131 if (trform.first.first == (
int)(
i + firstLayer)) {
1204 php.
boundR_ = fv.
get<std::vector<double> >(sdTag4,
"RadiusBound");
1206 php.
rLimit_ = fv.
get<std::vector<double> >(sdTag4,
"RadiusLimits");
1214 php.
slopeMin_ = fv.
get<std::vector<double> >(sdTag4,
"Slope");
1219 const auto&
dummy = fv.
get<std::vector<double> >(sdTag2,
"WaferSize");
1223 php.
cellSize_ = fv.
get<std::vector<double> >(sdTag3,
"CellSize");
1231 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeomParameters: wafer radius ranges"
1232 <<
" for cell grouping " << php.
boundR_[0] <<
":" << php.
boundR_[1] <<
":"
1237 <<
"for the 3 ranges:";
1243 for (
unsigned int k = 0;
k < php.
cellSize_.size(); ++
k)
1295 std::vector<int> layerType,
waferIndex, waferProperties;
1332 const auto&
dummy = fv.
get<std::vector<double> >(sdTag1,
"RadiusCuts");
1333 if (
dummy.size() > 3) {
1342 php.
slopeMin_ = fv.
get<std::vector<double> >(sdTag1,
"SlopeBottom");
1343 php.
zFrontMin_ = fv.
get<std::vector<double> >(sdTag1,
"ZFrontBottom");
1345 php.
rMinFront_ = fv.
get<std::vector<double> >(sdTag1,
"RMinFront");
1348 php.
slopeTop_ = fv.
get<std::vector<double> >(sdTag1,
"SlopeTop");
1349 php.
zFrontTop_ = fv.
get<std::vector<double> >(sdTag1,
"ZFrontTop");
1351 php.
rMaxFront_ = fv.
get<std::vector<double> >(sdTag1,
"RMaxFront");
1354 for (
unsigned int k = 0;
k < kmax; ++
k)
1357 const auto& dummy2 = fv.
get<std::vector<double> >(sdTag1,
"LayerOffset");
1358 if (!dummy2.empty()) {
1364 for (
auto const& it : vmap) {
1365 if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"RadiusMixBoundary")) {
1366 for (
const auto&
i : it.second)
1368 }
else if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"ZRanges")) {
1369 for (
const auto&
i : it.second)
1371 }
else if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"LayerCenter")) {
1372 for (
const auto&
i : it.second)
1381 std::vector<int> layerType,
waferIndex, waferProperties;
1383 for (
auto const& it : vmap) {
1384 if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"WaferIndexEE")) {
1385 for (
const auto&
i : it.second)
1387 }
else if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"WaferPropertiesEE")) {
1388 for (
const auto&
i : it.second)
1389 waferProperties.emplace_back(std::round(
i));
1393 for (
auto const& it : vmap) {
1394 if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"WaferIndexHE")) {
1395 for (
const auto&
i : it.second)
1397 }
else if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"WaferPropertiesHE")) {
1398 for (
const auto&
i : it.second)
1399 waferProperties.emplace_back(std::round(
i));
1405 for (
auto const& it : vmap) {
1406 if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"LayerTypesEE")) {
1407 for (
const auto&
i : it.second)
1408 layerType.emplace_back(std::round(
i));
1412 for (
auto const& it : vmap) {
1413 if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"LayerTypesHE")) {
1414 for (
const auto&
i : it.second)
1415 layerType.emplace_back(std::round(
i));
1432 <<
"parameters for 120 to 200 micron "
1437 <<
"parameters for 200 to 300 micron "
1462 const std::vector<int>& layerType,
1464 const std::vector<int>& waferProperties) {
1471 for (
unsigned int k = 0;
k < layerType.size(); ++
k) {
1480 php.
layerRotV_.emplace_back(std::make_pair(cth, sth));
1541 std::vector<int> tileHEX1, tileHEX2, tileHEX3, tileHEX4;
1542 std::vector<double> tileRMin, tileRMax;
1543 std::vector<int> tileRingMin, tileRingMax;
1550 tileRMin = fv.
vector(
"TileRMin");
1551 tileRMax = fv.
vector(
"TileRMax");
1575 for (
auto const& it : vmap) {
1576 if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"RadiusMixBoundary")) {
1577 for (
const auto&
i : it.second)
1579 }
else if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"ZRanges")) {
1580 for (
const auto&
i : it.second)
1582 }
else if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"LayerCenter")) {
1583 for (
const auto&
i : it.second)
1590 php.
rMinLayerBH_ = fv.
get<std::vector<double> >(sdTag1,
"RMinLayerBH");
1597 php.
slopeMin_ = fv.
get<std::vector<double> >(sdTag1,
"SlopeBottom");
1598 php.
zFrontMin_ = fv.
get<std::vector<double> >(sdTag1,
"ZFrontBottom");
1600 php.
rMinFront_ = fv.
get<std::vector<double> >(sdTag1,
"RMinFront");
1603 php.
slopeTop_ = fv.
get<std::vector<double> >(sdTag1,
"SlopeTop");
1604 php.
zFrontTop_ = fv.
get<std::vector<double> >(sdTag1,
"ZFrontTop");
1606 php.
rMaxFront_ = fv.
get<std::vector<double> >(sdTag1,
"RMaxFront");
1609 for (
unsigned int k = 0;
k < kmax; ++
k)
1612 const auto& dummy2 = fv.
get<std::vector<double> >(sdTag1,
"LayerOffset");
1620 std::vector<int> tileHEX1, tileHEX2, tileHEX3, tileHEX4;
1621 std::vector<double> tileRMin, tileRMax;
1622 std::vector<int> tileRingMin, tileRingMax;
1623 for (
auto const& it : vmap) {
1624 if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"TileIndex")) {
1625 for (
const auto&
i : it.second)
1626 tileIndx.emplace_back(std::round(
i));
1627 }
else if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"TileProperty")) {
1628 for (
const auto&
i : it.second)
1630 }
else if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"TileHEX1")) {
1631 for (
const auto&
i : it.second)
1632 tileHEX1.emplace_back(std::round(
i));
1633 }
else if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"TileHEX2")) {
1634 for (
const auto&
i : it.second)
1635 tileHEX2.emplace_back(std::round(
i));
1636 }
else if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"TileHEX3")) {
1637 for (
const auto&
i : it.second)
1638 tileHEX3.emplace_back(std::round(
i));
1639 }
else if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"TileHEX4")) {
1640 for (
const auto&
i : it.second)
1641 tileHEX4.emplace_back(std::round(
i));
1642 }
else if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"TileRMin")) {
1643 for (
const auto&
i : it.second)
1645 }
else if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"TileRMax")) {
1646 for (
const auto&
i : it.second)
1648 }
else if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"TileRingMin")) {
1649 for (
const auto&
i : it.second)
1650 tileRingMin.emplace_back(std::round(
i));
1651 }
else if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"TileRingMax")) {
1652 for (
const auto&
i : it.second)
1653 tileRingMax.emplace_back(std::round(
i));
1703 const std::vector<int>& tileIndx,
1705 const std::vector<int>& tileHEX1,
1706 const std::vector<int>& tileHEX2,
1707 const std::vector<int>& tileHEX3,
1708 const std::vector<int>& tileHEX4,
1709 const std::vector<double>& tileRMin,
1710 const std::vector<double>& tileRMax,
1711 const std::vector<int>& tileRingMin,
1712 const std::vector<int>& tileRingMax) {
1714 for (
unsigned int k = 0;
k < tileIndx.size(); ++
k) {
1725 <<
":" << tileHEX2[
k] <<
":" << tileHEX3[
k] <<
":" << tileHEX4[
k] <<
std::dec;
1729 for (
unsigned int k = 0;
k < tileRMin.size(); ++
k) {
1732 edm::LogVerbatim(
"HGCalGeom") <<
"TileRingR[" <<
k <<
"] " << tileRMin[
k] <<
":" << tileRMax[
k];
1736 for (
unsigned k = 0;
k < tileRingMin.size(); ++
k) {
1739 edm::LogVerbatim(
"HGCalGeom") <<
"TileRingRange[" <<
k <<
"] " << tileRingMin[
k] <<
":" << tileRingMax[
k];
1748 edm::LogVerbatim(
"HGCalGeom") <<
"Input waferWidth " << waferW <<
":" << rmin <<
" R Limits: " << rin <<
":" << rout
1749 <<
" Fine " << rMaxFine;
1757 double dx = 0.5 * waferW;
1758 double dy = 3.0 *
dx *
tan(30._deg);
1759 double rr = 2.0 *
dx *
tan(30._deg);
1760 int ncol = (
int)(2.0 * rout / waferW) + 1;
1761 int nrow = (
int)(rout / (waferW *
tan(30._deg))) + 1;
1762 int ns2 = (2 * ncol + 1) * (2 * nrow + 1) * php.
layer_.size();
1763 int incm(0), inrm(0), kount(0),
ntot(0);
1769 for (
int nr = -nrow;
nr <= nrow; ++
nr) {
1770 int inr = (
nr >= 0) ?
nr : -
nr;
1771 for (
int nc = -ncol; nc <= ncol; ++nc) {
1772 int inc = (nc >= 0) ? nc : -nc;
1773 if (inr % 2 == inc % 2) {
1774 double xpos = nc *
dx;
1775 double ypos =
nr *
dy;
1777 double rpos =
std::sqrt(xpos * xpos + ypos * ypos);
1778 int typet = (rpos < rMaxFine) ? 1 : 2;
1780 for (
int k = 1;
k < 4; ++
k) {
1781 if ((rpos + rmin) <= php.
boundR_[
k]) {
1796 <<
" Location " <<
corner.first <<
" Position " << xpos <<
":" << ypos
1797 <<
" Layers " << php.
layer_.size();
1804 for (
unsigned int il = 0; il < php.
layer_.size(); ++il) {
1805 std::pair<int, int>
corner =
1808 auto cpy = copiesInLayers[php.
layer_[il]].find(
copy);
1809 if (cpy == copiesInLayers[php.
layer_[il]].end())
1827 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalWaferHexagon: # of columns " << incm <<
" # of rows " << inrm <<
" and "
1828 << kount <<
":" <<
ntot <<
" wafers; R " << rin <<
":" << rout;
1830 for (
unsigned int k = 0;
k < copiesInLayers.size(); ++
k) {
1831 const auto& theModules = copiesInLayers[
k];
1834 for (std::unordered_map<int, int>::const_iterator itr = theModules.begin(); itr != theModules.end(); ++itr, ++k2) {
1835 edm::LogVerbatim(
"HGCalGeom") <<
"[" << k2 <<
"] " << itr->first <<
":" << itr->second;
1854 edm::LogVerbatim(
"HGCalGeom") <<
"Input waferWidth " << waferW <<
":" << waferS <<
" R Max: " << rout;
1862 double r = 0.5 * (waferW + waferS);
1864 double dy = 0.75 *
R;
1865 double r1 = 0.5 * waferW;
1867 int N = (
r == 0) ? 3 : ((
int)(0.5 * rout /
r) + 3);
1868 int ns1 = (2 *
N + 1) * (2 *
N + 1);
1871 edm::LogVerbatim(
"HGCalGeom") <<
"wafer " << waferW <<
":" << waferS <<
" r " <<
r <<
" dy " <<
dy <<
" N " <<
N
1872 <<
" sizes " << ns1 <<
":" << ns2;
1873 std::vector<int> indtypes(ns1 + 1);
1879 int ipos(0), lpos(0), uvmax(0), nwarn(0);
1880 std::vector<int> uvmx(php.
zLayerHex_.size(), 0);
1881 for (
int v = -
N;
v <=
N; ++
v) {
1882 for (
int u = -
N; u <=
N; ++u) {
1884 int nc = -2 * u +
v;
1885 double xpos = nc *
r;
1886 double ypos =
nr *
dy;
1891 wafersInLayers[indx] = ipos;
1901 double xpos0 = xpos + xyoff.first;
1902 double ypos0 = ypos + xyoff.second;
1913 typesInLayers[kndx] = lpos;
1916 indtypes.emplace_back(kndx);
1918 std::pair<int, int>
corner =
1923 <<
" u " << u <<
" v " <<
v <<
" with " <<
corner.first <<
" corners";
1931 edm::LogVerbatim(
"HGCalGeom") <<
"Layer " << lay <<
" u|v " << u <<
":" <<
v <<
" with corner "
1949 <<
"Layer:u:v " <<
i <<
":" << lay <<
":" << u <<
":" <<
v <<
" Part " << corner0.first <<
":"
1950 <<
part <<
" Orient " << corner0.second <<
":" <<
orient <<
" Position " << xpos0 <<
":" << ypos0
1952 <<
" Compatibiliety Flag " <<
ok;
1958 waferTypes[
wl] = corner0;
1961 <<
"Layer " << lay <<
" u|v " << u <<
":" <<
v <<
" Index " << std::hex <<
wl <<
std::dec <<
" pos "
1962 << xpos0 <<
":" << ypos0 <<
" R " <<
r1 <<
":" << R1 <<
" Range " << php.
rMinLayHex_[
i] <<
":"
1964 <<
corner.second <<
" croner0 " << corner0.first <<
":" << corner0.second;
1969 edm::LogVerbatim(
"HGCalGeom") <<
"Layer " << lay <<
" u|v " << u <<
":" <<
v <<
" with corner "
1978 edm::LogWarning(
"HGCalGeom") <<
"HGCalGeomParameters::loadWafer8: there are " << nwarn
1979 <<
" wafers with non-matching partial- orientation types";
2017 int id = indtypes[
k];
2038 << xyoff.first <<
":" << xyoff.second;
2059 for (
auto const& it : vmap) {
2060 if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"waferFine")) {
2061 for (
const auto&
i : it.second)
2063 }
else if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first),
"waferCoarse")) {
2064 for (
const auto&
i : it.second)
2075 for (
unsigned int k = 0;
k < php.
cellFine_.size(); ++
k)
2096 for (
unsigned int k = 0;
k < 2; ++
k) {
2121 for (
unsigned int k = 0;
k < 2; ++
k) {
2131 <<
" dEta = " << php.
cellSize_[
k] <<
"\nOld[0] new R = " << rv <<
" Eta = " <<
eta;
2139 edm::LogVerbatim(
"HGCalGeom") <<
"Old [" << kount <<
"] new R = " << rv <<
" Eta = " <<
eta;
2147 std::vector<double>::iterator
low,
high;
2164 edm::LogVerbatim(
"HGCalGeom") <<
"Modified irlow " << irlow <<
" dr " << drlow;
2183 edm::LogVerbatim(
"HGCalGeom") <<
"Modified irhigh " << irhigh <<
" dr " << drhigh;
2189 edm::LogVerbatim(
"HGCalGeom") <<
"Old Layer " <<
k <<
" Type " <<
kk <<
" Low edge " << irlow <<
":" << drlow
2190 <<
" Top edge " << irhigh <<
":" << drhigh;
2195 for (
unsigned int k = 0;
k < 2; ++
k) {
2224 mytr.
h = 0.5 * (rmax - rmin);
2253 const std::vector<double>& fvec =
value.doubles();
2254 int nval = fvec.size();
2258 <<
"HGCalGeomParameters: # of " <<
str <<
" bins " << nval <<
" < " <<
nmin <<
" ==> illegal";
2261 if (nval < 1 &&
nmin == 0) {
2263 <<
"HGCalGeomParameters: # of " <<
str <<
" bins " << nval <<
" < 1 ==> illegal"
2264 <<
" (nmin=" <<
nmin <<
")";
2270 throw cms::Exception(
"DDException") <<
"HGCalGeomParameters: cannot get array " <<
str;
2272 std::vector<double> fvec;
2278 const std::vector<HGCalGeomParameters::cellParameters>& wafers,
2279 std::vector<HGCalGeomParameters::cellParameters>::const_iterator& itrf,
2283 if (itrf == wafers.end()) {
2284 for (std::vector<HGCalGeomParameters::cellParameters>::const_iterator itr = wafers.begin(); itr != wafers.end();
2286 if (itr->wafer == wafer) {
2292 double dx(0),
dy(0);
2293 if (itrf != wafers.end()) {
2294 dx = (
xx - itrf->xyz.x());
2297 dy = (
yy - itrf->xyz.y());
2301 return std::make_pair(
dx,
dy);
2305 std::for_each(
v.begin(),
v.end(), [
s](
double&
n) {
n *=
s; });