Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run4-hgx251 Small update to the code #30534

Merged
merged 2 commits into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions Geometry/HGCalCommonData/plugins/DDHGCalEEAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class DDHGCalEEAlgo : public DDAlgorithm {
HGCalGeomTools geomTools_;
std::unique_ptr<HGCalWaferType> waferType_;

static constexpr double tol1_ = 0.01;
static constexpr double tol2_ = 0.00001;

std::vector<std::string> wafers_; // Wafers
std::vector<std::string> materials_; // Materials
std::vector<std::string> names_; // Names
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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_);
Expand All @@ -256,7 +256,7 @@ void DDHGCalEEAlgo::constructLayers(const DDLogicalPart& module, DDCompactView&
if (layerSense_[ly] < 1) {
std::vector<double> 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);
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -322,14 +322,14 @@ 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
}
Expand All @@ -346,7 +346,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<double, double> 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<int> ntype(6, 0);
Expand All @@ -363,7 +363,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<int, int> 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)) {
Expand Down
68 changes: 32 additions & 36 deletions Geometry/HGCalCommonData/plugins/DDHGCalHEAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ class DDHGCalHEAlgo : public DDAlgorithm {
HGCalGeomTools geomTools_;
std::unique_ptr<HGCalWaferType> waferType_;

static constexpr double tol1_ = 0.01;
static constexpr double tol2_ = 0.00001;

std::vector<std::string> wafers_; // Wafers
std::vector<std::string> materials_; // Materials
std::vector<std::string> names_; // Names
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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_);
Expand All @@ -315,7 +311,7 @@ void DDHGCalHEAlgo::constructLayers(const DDLogicalPart& module, DDCompactView&
std::vector<double> 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);
Expand All @@ -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 =
Expand Down Expand Up @@ -372,14 +368,14 @@ 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
}
Expand Down Expand Up @@ -452,14 +448,14 @@ 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
Expand Down Expand Up @@ -516,14 +512,14 @@ 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";
}
}
}

Expand Down
31 changes: 15 additions & 16 deletions Geometry/HGCalCommonData/plugins/dd4hep/DDHGCalEEAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ struct HGCalEEAlgo {
materials_ = args.value<std::vector<std::string>>("MaterialNames");
names_ = args.value<std::vector<std::string>>("VolumeNames");
thick_ = args.value<std::vector<double>>("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)
Expand Down Expand Up @@ -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
Expand All @@ -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_);
Expand All @@ -231,7 +230,7 @@ struct HGCalEEAlgo {
if (layerSense_[ly] < 1) {
std::vector<double> 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);
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -307,14 +306,14 @@ 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
Expand All @@ -334,7 +333,7 @@ struct HGCalEEAlgo {
double R = 2.0 * r / sqrt3;
double dy = 0.75 * R;
int N = (int)(0.5 * rout / r) + 2;
std::pair<double, double> 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<int> ntype(6, 0);
Expand All @@ -351,7 +350,7 @@ struct HGCalEEAlgo {
int nc = -2 * u + v;
double xpos = xyoff.first + nc * r;
double ypos = xyoff.second + nr * dy;
std::pair<int, int> 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)) {
Expand Down
Loading