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

Phase2-hgx294Z Modify the getCorner algo of HGCalGeometry to take care of rotated layers #35998

Merged
merged 3 commits into from Nov 7, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions Geometry/HGCalCommonData/interface/HGCalDDDConstants.h
Expand Up @@ -81,6 +81,8 @@ class HGCalDDDConstants {
int layerIndex(int lay, bool reco) const;
unsigned int layers(bool reco) const;
unsigned int layersInit(bool reco) const;
std::pair<float, float> localToGlobal8(
int lay, int waferU, int waferV, double localX, double localY, bool reco, bool debug) const;
std::pair<float, float> locateCell(int cell, int lay, int type, bool reco) const;
std::pair<float, float> locateCell(
int lay, int waferU, int waferV, int cellU, int cellV, bool reco, bool all, bool debug = false) const;
Expand Down
24 changes: 24 additions & 0 deletions Geometry/HGCalCommonData/src/HGCalDDDConstants.cc
Expand Up @@ -613,6 +613,30 @@ unsigned int HGCalDDDConstants::layersInit(bool reco) const {
return (reco ? hgpar_->depthIndex_.size() : hgpar_->layerIndex_.size());
}

std::pair<float, float> HGCalDDDConstants::localToGlobal8(
int lay, int waferU, int waferV, double localX, double localY, bool reco, bool debug) const {
double x(localX), y(localY);
bool rotx =
((!hgpar_->layerType_.empty()) && (hgpar_->layerType_[lay - hgpar_->firstLayer_] == HGCalTypes::WaferCenterR));
#ifdef EDM_ML_DEBUG
if (debug)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need this if under ifdef?

edm::LogVerbatim("HGCalGeom") << "LocalToGlobal " << lay << ":" << (lay - hgpar_->firstLayer_) << ":" << rotx
<< " Local (" << x << ":" << y << ") Reco " << reco;
#endif
if (!reco) {
x *= HGCalParameters::k_ScaleToDDD;
y *= HGCalParameters::k_ScaleToDDD;
}
const auto& xy = waferPositionNoRot(lay, waferU, waferV, reco, debug);
x += xy.first;
y += xy.second;
#ifdef EDM_ML_DEBUG
if (debug)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

edm::LogVerbatim("HGCalGeom") << "With wafer " << x << ":" << y << " by addong " << xy.first << ":" << xy.second;
#endif
return (rotx ? getXY(lay, x, y, false) : std::make_pair(x, y));
}

std::pair<float, float> HGCalDDDConstants::locateCell(int cell, int lay, int type, bool reco) const {
// type refers to wafer # for hexagon cell
float x(999999.), y(999999.);
Expand Down
61 changes: 40 additions & 21 deletions Geometry/HGCalGeometry/src/HGCalGeometry.cc
Expand Up @@ -267,7 +267,7 @@ double HGCalGeometry::getArea(const DetId& detid) const {
j = i;
}
}
return (0.5 * area);
return std::abs(0.5 * area);
}

HGCalGeometry::CornersVec HGCalGeometry::getCorners(const DetId& detid) const {
Expand Down Expand Up @@ -308,15 +308,18 @@ HGCalGeometry::CornersVec HGCalGeometry::getCorners(const DetId& detid) const {
}
} else {
xy = m_topology.dddConstants().locateCell(id.iLay, id.iSec1, id.iSec2, id.iCell1, id.iCell2, true, false);
float zz = m_topology.dddConstants().waferZ(id.iLay, true);
float dx = k_fac2 * m_cellVec[cellIndex].param()[FlatHexagon::k_r];
float dy = k_fac1 * m_cellVec[cellIndex].param()[FlatHexagon::k_R];
float dz = -id.zSide * m_cellVec[cellIndex].param()[FlatHexagon::k_dZ];
static const int signx[] = {1, -1, -2, -1, 1, 2, 1, -1, -2, -1, 1, 2};
static const int signy[] = {1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0};
static const int signz[] = {-1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1};
for (unsigned int i = 0; i < ncorner; ++i) {
const HepGeom::Point3D<float> lcoord(xy.first + signx[i] * dx, xy.second + signy[i] * dy, signz[i] * dz);
co[i] = m_cellVec[cellIndex].getPosition(lcoord);
auto xyglob = m_topology.dddConstants().localToGlobal8(
id.iLay, id.iSec1, id.iSec2, (xy.first + signx[i] * dx), (xy.second + signy[i] * dy), true, false);
double xx = id.zSide * xyglob.first;
co[i] = GlobalPoint(xx, xyglob.second, id.zSide * (zz + signz[i] * dz));
}
}
}
Expand Down Expand Up @@ -348,20 +351,29 @@ HGCalGeometry::CornersVec HGCalGeometry::get8Corners(const DetId& detid) const {
} else if (cellIndex < m_cellVec.size() && m_det != DetId::HGCalHSc) {
std::pair<float, float> xy;
float dx(0);
static const int signx[] = {-1, -1, 1, 1, -1, -1, 1, 1};
static const int signy[] = {-1, 1, 1, -1, -1, 1, 1, -1};
static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
if (m_topology.waferHexagon6()) {
xy = m_topology.dddConstants().locateCellHex(id.iCell1, id.iSec1, true);
dx = m_cellVec[cellIndex].param()[FlatHexagon::k_r];
float dz = m_cellVec[cellIndex].param()[FlatHexagon::k_dZ];
for (unsigned int i = 0; i < ncorner; ++i) {
const HepGeom::Point3D<float> lcoord(xy.first + signx[i] * dx, xy.second + signy[i] * dx, signz[i] * dz);
co[i] = m_cellVec[cellIndex].getPosition(lcoord);
}
} else {
xy = m_topology.dddConstants().locateCell(id.iLay, id.iSec1, id.iSec2, id.iCell1, id.iCell2, true, false);
dx = k_fac2 * m_cellVec[cellIndex].param()[FlatHexagon::k_r];
}
static const int signx[] = {-1, -1, 1, 1, -1, -1, 1, 1};
static const int signy[] = {-1, 1, 1, -1, -1, 1, 1, -1};
static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
float dz = m_cellVec[cellIndex].param()[FlatHexagon::k_dZ];
for (unsigned int i = 0; i < ncorner; ++i) {
const HepGeom::Point3D<float> lcoord(xy.first + signx[i] * dx, xy.second + signy[i] * dx, signz[i] * dz);
co[i] = m_cellVec[cellIndex].getPosition(lcoord);
float dy = k_fac1 * m_cellVec[cellIndex].param()[FlatHexagon::k_R];
float dz = -id.zSide * m_cellVec[cellIndex].param()[FlatHexagon::k_dZ];
float zz = m_topology.dddConstants().waferZ(id.iLay, true);
for (unsigned int i = 0; i < ncorner; ++i) {
auto xyglob = m_topology.dddConstants().localToGlobal8(
id.iLay, id.iSec1, id.iSec2, (xy.first + signx[i] * dx), (xy.second + signy[i] * dy), true, false);
double xx = id.zSide * xyglob.first;
co[i] = GlobalPoint(xx, xyglob.second, id.zSide * (zz + signz[i] * dz));
}
}
}
return co;
Expand All @@ -387,24 +399,31 @@ HGCalGeometry::CornersVec HGCalGeometry::getNewCorners(const DetId& detid) const
co[i] = GlobalPoint(
(r + signr[i] * dr) * cos(fi + signf[i] * dfi), (r + signr[i] * dr) * sin(fi + signf[i] * dfi), (v.z() + dz));
}
co[ncorner - 1] = GlobalPoint(0, 0, -2 * dz);
co[ncorner - 1] = co[0];
} else if (cellIndex < m_cellVec.size() && m_det != DetId::HGCalHSc) {
std::pair<float, float> xy;
if (m_topology.waferHexagon6()) {
xy = m_topology.dddConstants().locateCellHex(id.iCell1, id.iSec1, true);
} else {
xy = m_topology.dddConstants().locateCell(id.iLay, id.iSec1, id.iSec2, id.iCell1, id.iCell2, true, false);
}
float dx = k_fac2 * m_cellVec[cellIndex].param()[FlatHexagon::k_r];
float dy = k_fac1 * m_cellVec[cellIndex].param()[FlatHexagon::k_R];
float dz = -id.zSide * m_cellVec[cellIndex].param()[FlatHexagon::k_dZ];
static const int signx[] = {1, -1, -2, -1, 1, 2};
static const int signy[] = {1, 1, 0, -1, -1, 0};
for (unsigned int i = 0; i < ncorner - 1; ++i) {
const HepGeom::Point3D<float> lcoord(xy.first + signx[i] * dx, xy.second + signy[i] * dy, dz);
co[i] = m_cellVec[cellIndex].getPosition(lcoord);
if (m_topology.waferHexagon6()) {
xy = m_topology.dddConstants().locateCellHex(id.iCell1, id.iSec1, true);
for (unsigned int i = 0; i < ncorner - 1; ++i) {
const HepGeom::Point3D<float> lcoord(xy.first + signx[i] * dx, xy.second + signy[i] * dy, dz);
co[i] = m_cellVec[cellIndex].getPosition(lcoord);
}
} else {
xy = m_topology.dddConstants().locateCell(id.iLay, id.iSec1, id.iSec2, id.iCell1, id.iCell2, true, false);
float zz = m_topology.dddConstants().waferZ(id.iLay, true);
for (unsigned int i = 0; i < ncorner; ++i) {
auto xyglob = m_topology.dddConstants().localToGlobal8(
id.iLay, id.iSec1, id.iSec2, (xy.first + signx[i] * dx), (xy.second + signy[i] * dy), true, false);
double xx = id.zSide * xyglob.first;
co[i] = GlobalPoint(xx, xyglob.second, id.zSide * (zz + dz));
}
}
co[ncorner - 1] = GlobalPoint(0, 0, -2 * dz);
co[ncorner - 1] = co[0];
}
return co;
}
Expand Down
13 changes: 5 additions & 8 deletions Geometry/HGCalGeometry/test/python/testHGCalCorner_cfg.py
@@ -1,12 +1,9 @@
import FWCore.ParameterSet.Config as cms

process = cms.Process("PROD")
from Configuration.Eras.Era_Phase2C11_cff import Phase2C11
process = cms.Process("PROD",Phase2C11)
process.load("SimGeneral.HepPDTESSource.pdt_cfi")
process.load("Geometry.HGCalCommonData.testHGCalV14XML_cfi")
process.load("Geometry.HGCalCommonData.hgcalParametersInitialization_cfi")
process.load("Geometry.HGCalCommonData.hgcalNumberingInitialization_cfi")
process.load("Geometry.CaloEventSetup.HGCalV9Topology_cfi")
process.load("Geometry.HGCalGeometry.HGCalGeometryESProducer_cfi")
process.load('Configuration.Geometry.GeometryExtended2026D86Reco_cff')
process.load('FWCore.MessageService.MessageLogger_cfi')

if hasattr(process,'MessageLogger'):
Expand Down Expand Up @@ -49,6 +46,6 @@
detector = "HGCalHEScintillatorSensitive",
)

#process.p1 = cms.Path(process.generator*process.prodEE*process.prodHEF)
process.p1 = cms.Path(process.generator*process.prodEE*process.prodHEF)
#process.p1 = cms.Path(process.prodHEB)
process.p1 = cms.Path(process.generator*process.prodEE*process.prodHEF*process.prodHEB)
#process.p1 = cms.Path(process.generator*process.prodEE*process.prodHEF*process.prodHEB)