From b49c94838fa69e9d1d3c000227aad67f31e59edb Mon Sep 17 00:00:00 2001 From: Sunanda Date: Fri, 3 Jul 2020 22:24:55 +0200 Subject: [PATCH 1/2] Small update to the code --- .../HGCalCommonData/plugins/DDHGCalEEAlgo.cc | 30 ++++----- .../HGCalCommonData/plugins/DDHGCalHEAlgo.cc | 62 ++++++++--------- .../plugins/dd4hep/DDHGCalEEAlgo.cc | 29 ++++---- .../plugins/dd4hep/DDHGCalHEAlgo.cc | 66 ++++++++----------- 4 files changed, 81 insertions(+), 106 deletions(-) diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.cc b/Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.cc index 7b13e4923ba3c..7ecb5a9dbee0f 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.cc @@ -55,6 +55,9 @@ class DDHGCalEEAlgo : public DDAlgorithm { HGCalGeomTools geomTools_; std::unique_ptr waferType_; + static constexpr double tol1_ = 0.01; + static constexpr double tol2_ = 0.00001; + std::vector wafers_; // Wafers std::vector materials_; // Materials std::vector names_; // Names @@ -110,9 +113,7 @@ void DDHGCalEEAlgo::initialize(const DDNumericArguments& nArgs, materials_ = vsArgs["MaterialNames"]; names_ = vsArgs["VolumeNames"]; thick_ = vArgs["Thickness"]; - for (unsigned int i = 0; i < materials_.size(); ++i) { - copyNumber_.emplace_back(1); - } + copyNumber_.resize(materials_.size(), 1); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: " << materials_.size() << " types of volumes"; for (unsigned int i = 0; i < names_.size(); ++i) @@ -230,7 +231,6 @@ void DDHGCalEEAlgo::constructLayers(const DDLogicalPart& module, DDCompactView& #endif double zi(zMinBlock_); int laymin(0); - const double tol(0.01); for (unsigned int i = 0; i < layers_.size(); i++) { double zo = zi + layerThick_[i]; double routF = HGCalGeomTools::radius(zi, zFrontT_, rMaxFront_, slopeT_); @@ -256,7 +256,7 @@ void DDHGCalEEAlgo::constructLayers(const DDLogicalPart& module, DDCompactView& if (layerSense_[ly] < 1) { std::vector pgonZ, pgonRin, pgonRout; if (layerSense_[ly] == 0 || absorbMode_ == 0) { - double rmax = routF * cosAlpha_ - tol; + double rmax = routF * cosAlpha_ - tol1_; pgonZ.emplace_back(-hthick); pgonZ.emplace_back(hthick); pgonRin.emplace_back(rinB); @@ -285,7 +285,7 @@ void DDHGCalEEAlgo::constructLayers(const DDLogicalPart& module, DDCompactView& #endif for (unsigned int isec = 0; isec < pgonZ.size(); ++isec) { pgonZ[isec] -= zz; - pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol; + pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol1_; } } DDSolid solid = @@ -322,14 +322,12 @@ void DDHGCalEEAlgo::constructLayers(const DDLogicalPart& module, DDCompactView& } // End of loop over layers in a block zi = zo; laymin = laymax; - if (std::abs(thickTot - layerThick_[i]) < 0.00001) { - } else if (thickTot > layerThick_[i]) { - edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " is smaller than " << thickTot - << ": thickness of all its " - << "components **** ERROR ****"; - } else if (thickTot < layerThick_[i]) { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " does not match with " - << thickTot << " of the components"; + if (std::abs(thickTot - layerThick_[i]) >= tol2_) { + if (thickTot > layerThick_[i]) { + edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " is smaller than " << thickTot << ": thickness of all its components **** ERROR ****"; + } else { + edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " does not match with " << thickTot << " of the components"; + } } } // End of loop over blocks } @@ -346,7 +344,7 @@ void DDHGCalEEAlgo::positionSensitive(const DDLogicalPart& glog, double R = 2.0 * r / sqrt3; double dy = 0.75 * R; int N = (int)(0.5 * rout / r) + 2; - std::pair xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_)); + const auto& xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_)); #ifdef EDM_ML_DEBUG int ium(0), ivm(0), iumAll(0), ivmAll(0), kount(0), ntot(0), nin(0); std::vector ntype(6, 0); @@ -363,7 +361,7 @@ void DDHGCalEEAlgo::positionSensitive(const DDLogicalPart& glog, int nc = -2 * u + v; double xpos = xyoff.first + nc * r; double ypos = xyoff.second + nr * dy; - std::pair corner = HGCalGeomTools::waferCorner(xpos, ypos, r, R, rin, rout, false); + const auto& corner = HGCalGeomTools::waferCorner(xpos, ypos, r, R, rin, rout, false); #ifdef EDM_ML_DEBUG ++ntot; if (((corner.first <= 0) && std::abs(u) < 5 && std::abs(v) < 5) || (std::abs(u) < 2 && std::abs(v) < 2)) { diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.cc b/Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.cc index 772b10aff6332..9d0a9a02e1a95 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.cc @@ -65,6 +65,9 @@ class DDHGCalHEAlgo : public DDAlgorithm { HGCalGeomTools geomTools_; std::unique_ptr waferType_; + static constexpr double tol1_ = 0.01; + static constexpr double tol2_ = 0.00001; + std::vector wafers_; // Wafers std::vector materials_; // Materials std::vector names_; // Names @@ -133,9 +136,7 @@ void DDHGCalHEAlgo::initialize(const DDNumericArguments& nArgs, materials_ = vsArgs["MaterialNames"]; names_ = vsArgs["VolumeNames"]; thick_ = vArgs["Thickness"]; - for (unsigned int i = 0; i < materials_.size(); ++i) { - copyNumber_.emplace_back(1); - } + copyNumber_.resize(materials_.size(), 1); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << materials_.size() << " types of volumes"; for (unsigned int i = 0; i < names_.size(); ++i) @@ -187,9 +188,7 @@ void DDHGCalHEAlgo::initialize(const DDNumericArguments& nArgs, namesTop_ = vsArgs["TopVolumeNames"]; layerThickTop_ = vArgs["TopLayerThickness"]; layerTypeTop_ = dbl_to_int(vArgs["TopLayerType"]); - for (unsigned int i = 0; i < materialsTop_.size(); ++i) { - copyNumberTop_.emplace_back(1); - } + copyNumberTop_.resize(materialsTop_.size(), 1); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << materialsTop_.size() << " types of volumes in the top part"; for (unsigned int i = 0; i < materialsTop_.size(); ++i) @@ -204,9 +203,7 @@ void DDHGCalHEAlgo::initialize(const DDNumericArguments& nArgs, layerTypeBot_ = dbl_to_int(vArgs["BottomLayerType"]); layerSenseBot_ = dbl_to_int(vArgs["BottomLayerSense"]); layerThickBot_ = vArgs["BottomLayerThickness"]; - for (unsigned int i = 0; i < materialsBot_.size(); ++i) { - copyNumberBot_.emplace_back(1); - } + copyNumberBot_.resize(materialsBot_.size(), 1); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << materialsBot_.size() << " types of volumes in the bottom part"; for (unsigned int i = 0; i < materialsBot_.size(); ++i) @@ -288,7 +285,6 @@ void DDHGCalHEAlgo::constructLayers(const DDLogicalPart& module, DDCompactView& #endif double zi(zMinBlock_); int laymin(0); - const double tol(0.01); for (unsigned int i = 0; i < layers_.size(); i++) { double zo = zi + layerThick_[i]; double routF = HGCalGeomTools::radius(zi, zFrontT_, rMaxFront_, slopeT_); @@ -315,7 +311,7 @@ void DDHGCalHEAlgo::constructLayers(const DDLogicalPart& module, DDCompactView& std::vector pgonZ, pgonRin, pgonRout; if (layerSense_[ly] == 0 || absorbMode_ == 0) { double rmax = - (std::min(routF, HGCalGeomTools::radius(zz + hthick, zFrontT_, rMaxFront_, slopeT_)) * cosAlpha_) - tol; + (std::min(routF, HGCalGeomTools::radius(zz + hthick, zFrontT_, rMaxFront_, slopeT_)) * cosAlpha_) - tol1_; pgonZ.emplace_back(-hthick); pgonZ.emplace_back(hthick); pgonRin.emplace_back(rinB); @@ -337,7 +333,7 @@ void DDHGCalHEAlgo::constructLayers(const DDLogicalPart& module, DDCompactView& pgonRout); for (unsigned int isec = 0; isec < pgonZ.size(); ++isec) { pgonZ[isec] -= zz; - pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol; + pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol1_; } } DDSolid solid = @@ -372,14 +368,12 @@ void DDHGCalHEAlgo::constructLayers(const DDLogicalPart& module, DDCompactView& } // End of loop over layers in a block zi = zo; laymin = laymax; - if (std::abs(thickTot - layerThick_[i]) < 0.00001) { - } else if (thickTot > layerThick_[i]) { - edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " is smaller than " << thickTot - << ": thickness of all its " - << "components **** ERROR ****"; - } else if (thickTot < layerThick_[i]) { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " does not match with " - << thickTot << " of the components"; + if (std::abs(thickTot - layerThick_[i]) >= tol2_) { + if (thickTot > layerThick_[i]) { + edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " is smaller than " << thickTot << ": thickness of all its components **** ERROR ****"; + } else { + edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " does not match with " << thickTot << " of the components"; + } } } // End of loop over blocks } @@ -452,14 +446,12 @@ void DDHGCalHEAlgo::positionMix(const DDLogicalPart& glog, ++copyNumberTop_[ii]; zpos += hthickl; } - if (std::abs(thickTot - thick) < 0.00001) { - } else if (thickTot > thick) { - edm::LogError("HGCalGeom") << "Thickness of the partition " << thick << " is smaller than " << thickTot - << ": thickness of all its components in " - << "the top part **** ERROR ****"; - } else if (thickTot < thick) { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick << " does not match with " << thickTot - << " of the components in top part"; + if (std::abs(thickTot - thick) >= tol2_) { + if (thickTot > thick) { + edm::LogError("HGCalGeom") << "Thickness of the partition " << thick << " is smaller than " << thickTot << ": thickness of all its components in the top part **** ERROR ****"; + } else { + edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick << " does not match with " << thickTot << " of the components in top part"; + } } // Make the bottom part next @@ -516,14 +508,12 @@ void DDHGCalHEAlgo::positionMix(const DDLogicalPart& glog, zpos += hthickl; ++copyNumberBot_[ii]; } - if (std::abs(thickTot - thick) < 0.00001) { - } else if (thickTot > thick) { - edm::LogError("HGCalGeom") << "Thickness of the partition " << thick << " is smaller than " << thickTot - << ": thickness of all its components in " - << "the top part **** ERROR ****"; - } else if (thickTot < thick) { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick << " does not match with " << thickTot - << " of the components in top part"; + if (std::abs(thickTot - thick) >= tol2_) { + if (thickTot > thick) { + edm::LogError("HGCalGeom") << "Thickness of the partition " << thick << " is smaller than " << thickTot << ": thickness of all its components in the top part **** ERROR ****"; + } else { + edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick << " does not match with " << thickTot << " of the components in top part"; + } } } diff --git a/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalEEAlgo.cc b/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalEEAlgo.cc index 52149fb34dc72..1a3379fa4d743 100644 --- a/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalEEAlgo.cc +++ b/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalEEAlgo.cc @@ -77,9 +77,7 @@ struct HGCalEEAlgo { materials_ = args.value>("MaterialNames"); names_ = args.value>("VolumeNames"); thick_ = args.value>("Thickness"); - for (unsigned int i = 0; i < materials_.size(); ++i) { - copyNumber_.emplace_back(1); - } + copyNumber_.resize(materials_.size(), 1); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "DDHGCalEEAlgo: " << materials_.size() << " types of volumes"; for (unsigned int i = 0; i < names_.size(); ++i) @@ -196,6 +194,8 @@ struct HGCalEEAlgo { } void ConstructLayers(const dd4hep::Volume module, cms::DDParsingContext& ctxt, xml_h e) { + static constexpr double tol1 = 0.01; + static constexpr double tol2 = 0.00001; cms::DDNamespace ns(ctxt, e, true); #ifdef EDM_ML_DEBUG @@ -204,7 +204,6 @@ struct HGCalEEAlgo { double zi(zMinBlock_); int laymin(0); - const double tol(0.01); for (unsigned int i = 0; i < layers_.size(); i++) { double zo = zi + layerThick_[i]; double routF = HGCalGeomTools::radius(zi, zFrontT_, rMaxFront_, slopeT_); @@ -231,7 +230,7 @@ struct HGCalEEAlgo { if (layerSense_[ly] < 1) { std::vector pgonZ, pgonRin, pgonRout; if (layerSense_[ly] == 0 || absorbMode_ == 0) { - double rmax = routF * cosAlpha_ - tol; + double rmax = routF * cosAlpha_ - tol1; pgonZ.emplace_back(-hthick); pgonZ.emplace_back(hthick); pgonRin.emplace_back(rinB); @@ -260,7 +259,7 @@ struct HGCalEEAlgo { #endif for (unsigned int isec = 0; isec < pgonZ.size(); ++isec) { pgonZ[isec] -= zz; - pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol; + pgonRout[isec] = pgonRout[isec] * cosAlpha_ - tol1; } } @@ -307,14 +306,12 @@ struct HGCalEEAlgo { } // End of loop over layers in a block zi = zo; laymin = laymax; - if (std::abs(thickTot - layerThick_[i]) < 0.00001) { - } else if (thickTot > layerThick_[i]) { - edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " is smaller than " << thickTot - << ": thickness of all its " - << "components **** ERROR ****"; - } else if (thickTot < layerThick_[i]) { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " does not match with " - << thickTot << " of the components"; + if (std::abs(thickTot - layerThick_[i]) >= tol2) { + if (thickTot > layerThick_[i]) { + edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " is smaller than " << thickTot << ": thickness of all its components **** ERROR ****"; + } else { + edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " does not match with " << thickTot << " of the components"; + } } } // End of loop over layers in a block @@ -334,7 +331,7 @@ struct HGCalEEAlgo { double R = 2.0 * r / sqrt3; double dy = 0.75 * R; int N = (int)(0.5 * rout / r) + 2; - std::pair xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_)); + const auto& xyoff = geomTools_.shiftXY(layercenter, (waferSize_ + waferSepar_)); #ifdef EDM_ML_DEBUG int ium(0), ivm(0), iumAll(0), ivmAll(0), kount(0), ntot(0), nin(0); std::vector ntype(6, 0); @@ -351,7 +348,7 @@ struct HGCalEEAlgo { int nc = -2 * u + v; double xpos = xyoff.first + nc * r; double ypos = xyoff.second + nr * dy; - std::pair corner = HGCalGeomTools::waferCorner(xpos, ypos, r, R, rin, rout, false); + const auto& corner = HGCalGeomTools::waferCorner(xpos, ypos, r, R, rin, rout, false); #ifdef EDM_ML_DEBUG ++ntot; if (((corner.first <= 0) && std::abs(u) < 5 && std::abs(v) < 5) || (std::abs(u) < 2 && std::abs(v) < 2)) { diff --git a/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalHEAlgo.cc b/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalHEAlgo.cc index 4d920e4edc0c6..14a68e74b1527 100644 --- a/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalHEAlgo.cc +++ b/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalHEAlgo.cc @@ -42,9 +42,7 @@ struct HGCalHEAlgo { materials = args.value>("MaterialNames"); volumeNames = args.value>("VolumeNames"); thickness = args.value>("Thickness"); - for (unsigned int i = 0; i < materials.size(); ++i) { - copyNumber.emplace_back(1); - } + copyNumber.resize(materials.size(), 1); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << materials.size() << " types of volumes"; for (unsigned int i = 0; i < volumeNames.size(); ++i) @@ -96,9 +94,7 @@ struct HGCalHEAlgo { namesTop = args.value>("TopVolumeNames"); layerThickTop = args.value>("TopLayerThickness"); layerTypeTop = args.value>("TopLayerType"); - for (unsigned int i = 0; i < materialsTop.size(); ++i) { - copyNumberTop.emplace_back(1); - } + copyNumberTop.resize(materialsTop.size(), 1); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << materialsTop.size() << " types of volumes in the top part"; for (unsigned int i = 0; i < materialsTop.size(); ++i) @@ -113,9 +109,7 @@ struct HGCalHEAlgo { layerTypeBot = args.value>("BottomLayerType"); layerSenseBot = args.value>("BottomLayerSense"); layerThickBot = args.value>("BottomLayerThickness"); - for (unsigned int i = 0; i < materialsBot.size(); ++i) { - copyNumberBot.emplace_back(1); - } + copyNumberBot.resize(materialsBot.size(), 1); #ifdef EDM_ML_DEBUG edm::LogVerbatim("HGCalGeom") << "DDHGCalHEAlgo: " << materialsBot.size() << " types of volumes in the bottom part"; for (unsigned int i = 0; i < materialsBot.size(); ++i) @@ -173,7 +167,6 @@ struct HGCalHEAlgo { double zi(zMinBlock); int laymin(0); - const double tol(0.01); for (unsigned int i = 0; i < layerNumbers.size(); i++) { double zo = zi + layerThick[i]; double routF = HGCalGeomTools::radius(zi, zFrontT, rMaxFront, slopeT); @@ -202,7 +195,7 @@ struct HGCalHEAlgo { std::vector pgonZ, pgonRin, pgonRout; if (layerSense[ly] == 0 || absorbMode == 0) { double rmax = - (std::min(routF, HGCalGeomTools::radius(zz + hthick, zFrontT, rMaxFront, slopeT)) * cosAlpha) - tol; + (std::min(routF, HGCalGeomTools::radius(zz + hthick, zFrontT, rMaxFront, slopeT)) * cosAlpha) - tol1; pgonZ.emplace_back(-hthick); pgonZ.emplace_back(hthick); pgonRin.emplace_back(rinB); @@ -224,7 +217,7 @@ struct HGCalHEAlgo { pgonRout); for (unsigned int isec = 0; isec < pgonZ.size(); ++isec) { pgonZ[isec] -= zz; - pgonRout[isec] = pgonRout[isec] * cosAlpha - tol; + pgonRout[isec] = pgonRout[isec] * cosAlpha - tol1; } } @@ -265,14 +258,12 @@ struct HGCalHEAlgo { } // End of loop over layers in a block zi = zo; laymin = laymax; - if (std::abs(thickTot - layerThick[i]) < 0.00001) { - } else if (thickTot > layerThick[i]) { - edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick[i] << " is smaller than " << thickTot - << ": thickness of all its " - << "components **** ERROR ****"; - } else if (thickTot < layerThick[i]) { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick[i] << " does not match with " - << thickTot << " of the components"; + if (std::abs(thickTot - layerThick[i]) >= tol2) { + if (thickTot > layerThick[i]) { + edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick[i] << " is smaller than " << thickTot << ": thickness of all its components **** ERROR ****"; + } else { + edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick[i] << " does not match with " << thickTot << " of the components"; + } } } // End of loop over blocks @@ -365,14 +356,12 @@ struct HGCalHEAlgo { ++copyNumberTop[ii]; zpos += hthickl; } - if (std::abs(thickTot - thick) < 0.00001) { - } else if (thickTot > thick) { - edm::LogError("HGCalGeom") << "Thickness of the partition " << thick << " is smaller than " << thickTot - << ": thickness of all its components in " - << "the top part **** ERROR ****"; - } else if (thickTot < thick) { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick << " does not match with " << thickTot - << " of the components in top part"; + if (std::abs(thickTot - thick) >= tol2) { + if (thickTot > thick) { + edm::LogError("HGCalGeom") << "Thickness of the partition " << thick << " is smaller than " << thickTot << ": thickness of all its components in the top part **** ERROR ****"; + } else { + edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick << " does not match with " << thickTot << " of the components in top part"; + } } // Make the bottom part next @@ -438,14 +427,12 @@ struct HGCalHEAlgo { zpos += hthickl; ++copyNumberBot[ii]; } - if (std::abs(thickTot - thick) < 0.00001) { - } else if (thickTot > thick) { - edm::LogError("HGCalGeom") << "Thickness of the partition " << thick << " is smaller than " << thickTot - << ": thickness of all its components in " - << "the top part **** ERROR ****"; - } else if (thickTot < thick) { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick << " does not match with " << thickTot - << " of the components in top part"; + if (std::abs(thickTot - thick) >= tol2) { + if (thickTot > thick) { + edm::LogError("HGCalGeom") << "Thickness of the partition " << thick << " is smaller than " << thickTot << ": thickness of all its components in the top part **** ERROR ****"; + } else { + edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick << " does not match with " << thickTot << " of the components in top part"; + } } } @@ -463,7 +450,7 @@ struct HGCalHEAlgo { double R = 2.0 * r / sqrt3; double dy = 0.75 * R; int N = (int)(0.5 * rout / r) + 2; - std::pair xyoff = geomTools.shiftXY(layercenter, (waferSize + waferSepar)); + const auto& xyoff = geomTools.shiftXY(layercenter, (waferSize + waferSepar)); #ifdef EDM_ML_DEBUG int ium(0), ivm(0), iumAll(0), ivmAll(0), kount(0), ntot(0), nin(0); std::vector ntype(6, 0); @@ -479,7 +466,7 @@ struct HGCalHEAlgo { int nc = -2 * u + v; double xpos = xyoff.first + nc * r; double ypos = xyoff.second + nr * dy; - std::pair corner = HGCalGeomTools::waferCorner(xpos, ypos, r, R, rin, rout, false); + const auto& corner = HGCalGeomTools::waferCorner(xpos, ypos, r, R, rin, rout, false); #ifdef EDM_ML_DEBUG ++ntot; #endif @@ -578,6 +565,9 @@ struct HGCalHEAlgo { std::vector rMaxFront; // Corresponding rMax's std::unordered_set copies; // List of copy #'s double alpha, cosAlpha; + + static constexpr double tol1 = 0.01; + static constexpr double tol2 = 0.00001; }; static long algorithm(dd4hep::Detector& /* description */, From 1f5321545a8559eea63e5f6663f951f28984a9f8 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Fri, 3 Jul 2020 22:40:48 +0200 Subject: [PATCH 2/2] Code check --- .../HGCalCommonData/plugins/DDHGCalEEAlgo.cc | 6 +++-- .../HGCalCommonData/plugins/DDHGCalHEAlgo.cc | 24 ++++++++++++------- .../plugins/dd4hep/DDHGCalEEAlgo.cc | 12 ++++++---- .../plugins/dd4hep/DDHGCalHEAlgo.cc | 24 ++++++++++++------- 4 files changed, 41 insertions(+), 25 deletions(-) diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.cc b/Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.cc index 7ecb5a9dbee0f..8bf87078cbe6b 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.cc @@ -324,9 +324,11 @@ void DDHGCalEEAlgo::constructLayers(const DDLogicalPart& module, DDCompactView& laymin = laymax; if (std::abs(thickTot - layerThick_[i]) >= tol2_) { if (thickTot > layerThick_[i]) { - edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " is smaller than " << thickTot << ": thickness of all its components **** ERROR ****"; + edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " is smaller than " << thickTot + << ": thickness of all its components **** ERROR ****"; } else { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " does not match with " << thickTot << " of the components"; + edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " does not match with " + << thickTot << " of the components"; } } } // End of loop over blocks diff --git a/Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.cc b/Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.cc index 9d0a9a02e1a95..279ace8dacf4a 100644 --- a/Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.cc +++ b/Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.cc @@ -369,11 +369,13 @@ void DDHGCalHEAlgo::constructLayers(const DDLogicalPart& module, DDCompactView& zi = zo; laymin = laymax; if (std::abs(thickTot - layerThick_[i]) >= tol2_) { - if (thickTot > layerThick_[i]) { - edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " is smaller than " << thickTot << ": thickness of all its components **** ERROR ****"; - } else { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " does not match with " << thickTot << " of the components"; - } + if (thickTot > layerThick_[i]) { + edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " is smaller than " << thickTot + << ": thickness of all its components **** ERROR ****"; + } else { + edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " does not match with " + << thickTot << " of the components"; + } } } // End of loop over blocks } @@ -448,9 +450,11 @@ void DDHGCalHEAlgo::positionMix(const DDLogicalPart& glog, } if (std::abs(thickTot - thick) >= tol2_) { if (thickTot > thick) { - edm::LogError("HGCalGeom") << "Thickness of the partition " << thick << " is smaller than " << thickTot << ": thickness of all its components in the top part **** ERROR ****"; + edm::LogError("HGCalGeom") << "Thickness of the partition " << thick << " is smaller than " << thickTot + << ": thickness of all its components in the top part **** ERROR ****"; } else { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick << " does not match with " << thickTot << " of the components in top part"; + edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick << " does not match with " << thickTot + << " of the components in top part"; } } @@ -510,9 +514,11 @@ void DDHGCalHEAlgo::positionMix(const DDLogicalPart& glog, } if (std::abs(thickTot - thick) >= tol2_) { if (thickTot > thick) { - edm::LogError("HGCalGeom") << "Thickness of the partition " << thick << " is smaller than " << thickTot << ": thickness of all its components in the top part **** ERROR ****"; + edm::LogError("HGCalGeom") << "Thickness of the partition " << thick << " is smaller than " << thickTot + << ": thickness of all its components in the top part **** ERROR ****"; } else { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick << " does not match with " << thickTot << " of the components in top part"; + edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick << " does not match with " << thickTot + << " of the components in top part"; } } } diff --git a/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalEEAlgo.cc b/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalEEAlgo.cc index 1a3379fa4d743..0a43bde5683d9 100644 --- a/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalEEAlgo.cc +++ b/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalEEAlgo.cc @@ -307,11 +307,13 @@ struct HGCalEEAlgo { zi = zo; laymin = laymax; if (std::abs(thickTot - layerThick_[i]) >= tol2) { - if (thickTot > layerThick_[i]) { - edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " is smaller than " << thickTot << ": thickness of all its components **** ERROR ****"; - } else { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " does not match with " << thickTot << " of the components"; - } + if (thickTot > layerThick_[i]) { + edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " is smaller than " + << thickTot << ": thickness of all its components **** ERROR ****"; + } else { + edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick_[i] << " does not match with " + << thickTot << " of the components"; + } } } // End of loop over layers in a block diff --git a/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalHEAlgo.cc b/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalHEAlgo.cc index 14a68e74b1527..8f03a832b7839 100644 --- a/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalHEAlgo.cc +++ b/Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalHEAlgo.cc @@ -259,11 +259,13 @@ struct HGCalHEAlgo { zi = zo; laymin = laymax; if (std::abs(thickTot - layerThick[i]) >= tol2) { - if (thickTot > layerThick[i]) { - edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick[i] << " is smaller than " << thickTot << ": thickness of all its components **** ERROR ****"; - } else { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick[i] << " does not match with " << thickTot << " of the components"; - } + if (thickTot > layerThick[i]) { + edm::LogError("HGCalGeom") << "Thickness of the partition " << layerThick[i] << " is smaller than " + << thickTot << ": thickness of all its components **** ERROR ****"; + } else { + edm::LogWarning("HGCalGeom") << "Thickness of the partition " << layerThick[i] << " does not match with " + << thickTot << " of the components"; + } } } // End of loop over blocks @@ -358,9 +360,11 @@ struct HGCalHEAlgo { } if (std::abs(thickTot - thick) >= tol2) { if (thickTot > thick) { - edm::LogError("HGCalGeom") << "Thickness of the partition " << thick << " is smaller than " << thickTot << ": thickness of all its components in the top part **** ERROR ****"; + edm::LogError("HGCalGeom") << "Thickness of the partition " << thick << " is smaller than " << thickTot + << ": thickness of all its components in the top part **** ERROR ****"; } else { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick << " does not match with " << thickTot << " of the components in top part"; + edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick << " does not match with " << thickTot + << " of the components in top part"; } } @@ -429,9 +433,11 @@ struct HGCalHEAlgo { } if (std::abs(thickTot - thick) >= tol2) { if (thickTot > thick) { - edm::LogError("HGCalGeom") << "Thickness of the partition " << thick << " is smaller than " << thickTot << ": thickness of all its components in the top part **** ERROR ****"; + edm::LogError("HGCalGeom") << "Thickness of the partition " << thick << " is smaller than " << thickTot + << ": thickness of all its components in the top part **** ERROR ****"; } else { - edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick << " does not match with " << thickTot << " of the components in top part"; + edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick << " does not match with " << thickTot + << " of the components in top part"; } } }