18 #include <Math/Transform3D.h> 19 #include <Math/EulerAngles.h> 27 : m_topology(topology_),
28 m_validGeomIds(topology_.totalGeomModules()),
29 mode_(topology_.geomMode()),
31 m_subdet(topology_.subDetector()),
32 twoBysqrt3_(2.0 /
std::
sqrt(3.0)) {
95 for (
int cell = 0; cell <
cells; ++cell) {
118 unsigned int cellAll(0), cellSelect(0);
120 for (
int u = 0; u < 2 *
cells; ++u) {
121 for (
int v = 0;
v < 2 *
cells; ++
v) {
122 if (((
v - u) < cells) && (u -
v) <= cells) {
140 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeometry keeps " << cellSelect <<
" out of " << cellAll <<
" for wafer " 141 <<
id.iSec1 <<
":" <<
id.iSec2 <<
" in " 142 <<
" layer " <<
id.iLay;
147 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeometry::newCell-> [" << cellIndex <<
"]" 148 <<
" front:" << f1.
x() <<
'/' << f1.
y() <<
'/' << f1.
z() <<
" back:" << f2.
x() <<
'/' 149 << f2.
y() <<
'/' << f2.
z() <<
" eta|phi " <<
m_cellVec2[cellIndex].etaPos() <<
":" 152 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeometry::newCell-> [" << cellIndex <<
"]" 153 <<
" front:" << f1.
x() <<
'/' << f1.
y() <<
'/' << f1.
z() <<
" back:" << f2.
x() <<
'/' 154 << f2.
y() <<
'/' << f2.
z() <<
" eta|phi " <<
m_cellVec[cellIndex].etaPos() <<
":" 176 if (detId ==
DetId())
185 if (detId ==
DetId())
193 unsigned int cellIndex =
indexFor(detid);
196 if (cellIndex < maxSize) {
198 std::pair<float, float>
xy;
201 const HepGeom::Point3D<float> lcoord(xy.first, xy.second, 0);
202 glob =
m_cellVec[cellIndex].getPosition(lcoord);
204 edm::LogVerbatim(
"HGCalGeom") <<
"getPosition:: index " << cellIndex <<
" Local " << lcoord.x() <<
":" 205 << lcoord.y() <<
" ID " <<
id.iCell1 <<
":" <<
id.iSec1 <<
" Global " << glob;
208 const HepGeom::Point3D<float> lcoord(0, 0, 0);
209 glob =
m_cellVec2[cellIndex].getPosition(lcoord);
211 edm::LogVerbatim(
"HGCalGeom") <<
"getPositionTrap:: index " << cellIndex <<
" Local " << lcoord.x() <<
":" 212 << lcoord.y() <<
" ID " <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iCell1
213 <<
" Global " << glob;
217 const HepGeom::Point3D<float> lcoord(xy.first, xy.second, 0);
218 glob =
m_cellVec[cellIndex].getPosition(lcoord);
220 edm::LogVerbatim(
"HGCalGeom") <<
"getPositionWafer:: index " << cellIndex <<
" Local " << lcoord.x() <<
":" 221 << lcoord.y() <<
" ID " <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" 222 <<
id.iCell1 <<
":" <<
id.iCell2 <<
" Global " << glob;
232 if (corners.size() > 1) {
233 int n = corners.size() - 1;
235 for (
int i = 0;
i <
n; ++
i) {
236 area += ((corners[
j].x() + corners[
i].x()) * (corners[
i].
y() - corners[
j].y()));
246 unsigned int cellIndex =
indexFor(detid);
251 float dr =
k_half * (rr.second - rr.first);
256 static const int signr[] = {1, 1, -1, -1, 1, 1, -1, -1};
257 static const int signf[] = {-1, 1, 1, -1, -1, 1, 1, -1};
258 static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
259 for (
unsigned int i = 0;
i < ncorner; ++
i) {
261 (r + signr[
i] * dr) *
sin(fi + signf[
i] * dfi),
262 (v.
z() + signz[
i] *
dz));
265 std::pair<float, float>
xy;
271 static const int signx[] = {0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1};
272 static const int signy[] = {-2, -1, 1, 2, 1, -1, -2, -1, 1, 2, 1, -1};
273 static const int signz[] = {-1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1};
274 for (
unsigned int i = 0;
i < ncorner; ++
i) {
275 const HepGeom::Point3D<float> lcoord(xy.first + signx[
i] * dx, xy.second + signy[
i] * dy, signz[
i] * dz);
276 co[
i] =
m_cellVec[cellIndex].getPosition(lcoord);
283 static const int signx[] = {1, -1, -2, -1, 1, 2, 1, -1, -2, -1, 1, 2};
284 static const int signy[] = {1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0};
285 static const int signz[] = {-1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1};
286 for (
unsigned int i = 0;
i < ncorner; ++
i) {
287 const HepGeom::Point3D<float> lcoord(xy.first + signx[
i] * dx, xy.second + signy[
i] * dy, signz[
i] * dz);
288 co[
i] =
m_cellVec[cellIndex].getPosition(lcoord);
298 unsigned int cellIndex =
indexFor(detid);
303 float dr =
k_half * (rr.second - rr.first);
308 static const int signr[] = {1, 1, -1, -1, 1, 1, -1, -1};
309 static const int signf[] = {-1, 1, 1, -1, -1, 1, 1, -1};
310 static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
311 for (
unsigned int i = 0;
i < ncorner; ++
i) {
313 (r + signr[
i] * dr) *
sin(fi + signf[
i] * dfi),
314 (v.
z() + signz[
i] *
dz));
317 std::pair<float, float>
xy;
326 static const int signx[] = {-1, -1, 1, 1, -1, -1, 1, 1};
327 static const int signy[] = {-1, 1, 1, -1, -1, 1, 1, -1};
328 static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
330 for (
unsigned int i = 0;
i < ncorner; ++
i) {
331 const HepGeom::Point3D<float> lcoord(xy.first + signx[
i] * dx, xy.second + signy[
i] * dx, signz[
i] * dz);
332 co[
i] =
m_cellVec[cellIndex].getPosition(lcoord);
341 unsigned int cellIndex =
indexFor(detid);
346 float dr =
k_half * (rr.second - rr.first);
351 static const int signr[] = {1, 1, -1, -1};
352 static const int signf[] = {-1, 1, 1, -1};
353 for (
unsigned int i = 0;
i < ncorner - 1; ++
i) {
355 (r + signr[
i] * dr) *
cos(fi + signf[
i] * dfi), (r + signr[
i] * dr) *
sin(fi + signf[
i] * dfi), (v.
z() +
dz));
359 std::pair<float, float>
xy;
368 static const int signx[] = {1, -1, -2, -1, 1, 2};
369 static const int signy[] = {1, 1, 0, -1, -1, 0};
370 for (
unsigned int i = 0;
i < ncorner - 1; ++
i) {
371 const HepGeom::Point3D<float> lcoord(xy.first + signx[
i] * dx, xy.second + signy[
i] * dy, dz);
372 co[
i] =
m_cellVec[cellIndex].getPosition(lcoord);
382 int lay = ((momentum.
z() *
id.zSide > 0) ? (
id.iLay + 1) : (
id.iLay - 1));
384 edm::LogVerbatim(
"HGCalGeom") <<
"neighborz1:: ID " <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" 385 <<
id.iCell1 <<
":" <<
id.iCell2 <<
" New Layer " << lay <<
" Range " 390 (momentum.
z() != 0.0)) {
393 double grad = (z - v.
z()) / momentum.
z();
397 if (r >= rlimit.first && r <= rlimit.second)
400 edm::LogVerbatim(
"HGCalGeom") <<
"neighborz1:: Position " << v <<
" New Z " << z <<
":" << grad <<
" new position " 401 <<
p <<
" r-limit " << rlimit.first <<
":" << rlimit.second;
413 int lay = ((momentum.
z() *
id.zSide > 0) ? (
id.iLay + 1) : (
id.iLay - 1));
415 edm::LogVerbatim(
"HGCalGeom") <<
"neighborz2:: ID " <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" 416 <<
id.iCell1 <<
":" <<
id.iCell2 <<
" New Layer " << lay <<
" Range " 421 (momentum.
z() != 0.0)) {
433 if (r >= rlimit.first && r <= rlimit.second)
437 edm::LogVerbatim(
"HGCalGeom") <<
"neighborz2:: Position " << v <<
" New Z " << z <<
":" << charge <<
":" 438 << tsos.
isValid() <<
" new position " << p <<
" r limits " << rlimit.first <<
":" 450 HepGeom::Point3D<float>
local;
452 local = HepGeom::Point3D<float>(r.
x(), r.
y(), 0);
455 local = HepGeom::Point3D<float>(-r.
x(), r.
y(), 0);
460 id.iCell1 = kxy.second;
461 id.iSec1 = kxy.first;
481 edm::LogVerbatim(
"HGCalGeom") <<
"getClosestCell: local " << local <<
" Id " <<
id.zSide <<
":" <<
id.iLay <<
":" 482 <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" <<
id.iType <<
":" <<
id.iCell1 <<
":" 504 return "HGCalHEFront";
506 return "HGCalHEBack";
513 if (detId !=
DetId()) {
518 <<
" index " << cellIndex;
532 return (
nullptr == cell->
param() ?
nullptr : cell);
537 return (
nullptr == cell->
param() ?
nullptr : cell);
545 static const auto do_not_delete = [](
const void*) {};
547 auto cell = std::shared_ptr<const CaloCellGeometry>(&
m_cellVec2[
index], do_not_delete);
548 if (
nullptr == cell->param())
552 auto cell = std::shared_ptr<const CaloCellGeometry>(&
m_cellVec[
index], do_not_delete);
553 if (
nullptr == cell->param())
567 cell->setPosition(pos);
571 if (
nullptr == cell->param())
576 cell->setPosition(pos);
580 if (
nullptr == cell->param())
587 edm::LogError(
"HGCalGeom") <<
"HGCalGeometry::addValidID is not implemented";
596 float phip = r.
phi();
598 float dzmin(9999), dphimin(9999), dphi10(0.175);
599 unsigned int cellIndex = vec.size();
600 for (
unsigned int k = 0;
k < vec.size(); ++
k) {
601 float dphi = phip - vec[
k].phiPos();
604 while (dphi <= -
M_PI)
608 if (dz < (dzmin + 0.001)) {
610 if (
std::abs(dphi) < (dphimin + 0.01)) {
614 if (cellIndex >= vec.size())
621 edm::LogVerbatim(
"HGCalGeom") <<
"getClosestCellIndex::Input " << zp <<
":" << phip <<
" Index " << cellIndex;
622 if (cellIndex < vec.size())
623 edm::LogVerbatim(
"HGCalGeom") <<
" Cell z " << vec[cellIndex].getPosition().z() <<
":" << dzmin <<
" phi " 624 << vec[cellIndex].phiPos() <<
":" << dphimin;
651 iVector.reserve(numberOfCells);
652 dimVector.reserve(numberOfShapes * numberOfParametersPerShape);
653 dinsVector.reserve(numberOfCells);
657 int layer = mytr.
lay;
667 dimVector.insert(dimVector.end(), params.begin(), params.end());
684 dimVector.insert(dimVector.end(), params.begin(), params.end());
694 dimVector.insert(dimVector.end(), params.begin(), params.end());
700 for (
unsigned int i(0);
i < numberOfCells; ++
i) {
713 iVector.emplace_back(layer);
717 if (
nullptr != ptr) {
718 ptr->getTransform(tr, (
Pt3DVec*)
nullptr);
722 tr = HepGeom::Translate3D(
gp.x(),
gp.y(),
gp.z());
725 const CLHEP::Hep3Vector
tt(tr.getTranslation());
726 trVector.emplace_back(
tt.x());
727 trVector.emplace_back(
tt.y());
728 trVector.emplace_back(
tt.z());
730 const CLHEP::HepRotation
rr(tr.getRotation());
731 const ROOT::Math::Transform3D rtr(
732 rr.xx(),
rr.xy(),
rr.xz(),
tt.x(),
rr.yx(),
rr.yy(),
rr.yz(),
tt.y(),
rr.zx(),
rr.zy(),
rr.zz(),
tt.z());
735 trVector.emplace_back(ea.Phi());
736 trVector.emplace_back(ea.Theta());
737 trVector.emplace_back(ea.Psi());
std::vector< DetId > m_validGeomIds
std::pair< double, double > cellSizeTrap(int type, int irad) const
HGCalGeometryMode::GeometryMode mode_
A base class to handle the particular shape of HGCal volumes.
int getLayer(double z, bool reco) const
std::vector< CCGFloat > DimVec
std::vector< FlatHexagon > CellVec
virtual unsigned int numberOfParametersPerShape() const
std::string cellElement() const
std::shared_ptr< const CaloCellGeometry > cellGeomPtr(uint32_t index) const override
unsigned int sizeForDenseIndex() const
HGCalParameters::hgtrform getTrForm(unsigned int k) const
int lastLayer(bool reco) const
unsigned int getClosestCellIndex(const GlobalPoint &r) const
DetId neighborZ(const DetId &idin, const GlobalVector &p) const
const HGCalParameters * getParameter() const
const HGCalTopology & m_topology
Sin< T >::type sin(const T &t)
~HGCalGeometry() override
bool cellInLayer(int waferU, int waferV, int cellU, int cellV, int lay, bool reco) const
Geom::Phi< T > phi() const
Global3DPoint GlobalPoint
constexpr uint32_t rawId() const
get the raw id
std::vector< unsigned int > IVec
static constexpr uint32_t k_Theta
GlobalPoint globalPosition() const
void newCell(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId) override
std::vector< float > ParmVec
std::vector< GlobalPoint > CornersVec
std::vector< CCGFloat > TrVec
GlobalPoint getPosition(const DetId &id) const
HepGeom::Transform3D Tr3D
double getArea(const DetId &detid) const
Returns area of a cell.
HFNoseDetId geometryCell() const
static constexpr uint32_t k_Cell
static constexpr uint32_t k_dY1
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
CaloCellGeometry::CCGFloat CCGFloat
CornersVec getCorners(const DetId &id) const
Returns the corner points of this cell's volume.
CaloCellGeometry::Tr3D Tr3D
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
int layerIndex(int lay, bool reco) const
static constexpr unsigned int ncorner_
CaloCellGeometry::Pt3DVec Pt3DVec
std::pair< float, float > locateCellHex(int cell, int wafer, bool reco) const
std::pair< double, double > rangeR(double z, bool reco) const
unsigned int totalGeomModules() const
HGCalGeometry(const HGCalTopology &topology)
static constexpr unsigned int ncorner_
std::vector< int > firstModule_
static unsigned int k_NumberOfShapes
HGCalDetId geometryCell() const
static constexpr uint32_t k_R
void initializeParms() override
unsigned int getTrFormN() const
HGCSiliconDetId geometryCell() const
const CCGFloat * param() const
static unsigned int k_NumberOfParametersPerHex
virtual uint32_t detId2denseGeomId(const DetId &id) const
int numberCellsHexagon(int wafer) const
static constexpr uint32_t k_r
int layer() const
get the layer #
virtual unsigned int numberOfShapes() const
std::vector< float > ParmVec
DetId encode(const DecodedDetId &id_) const
int layer() const
get the layer #
static constexpr uint32_t k_dX1
std::vector< DetId > m_validIds
static PlanePointer build(Args &&...args)
const HGCalTopology & topology() const
Cos< T >::type cos(const T &t)
A base class to handle the hexagonal shape of HGCal silicon volumes.
Abs< T >::type abs(const T &t)
std::set< DetId > DetIdSet
static constexpr uint32_t k_dY2
HGCScintillatorDetId geometryCell() const
CornersVec get8Corners(const DetId &id) const
static constexpr uint32_t k_dX4
static unsigned int k_NumberOfParametersPerTrd
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
DetIdSet getCells(const GlobalPoint &r, double dR) const override
Get a list of all cells within a dR of the given cell.
double waferZ(int layer, bool reco) const
void localCorners(Pt3DVec &lc, const CCGFloat *pv, unsigned int i, Pt3D &ref)
#define TYPELOOKUP_DATA_REG(_dataclass_)
DecodedDetId decode(const DetId &id) const
std::vector< int > lastModule_
AlgebraicVector EulerAngles
ForwardSubdetector m_subdet
static constexpr uint32_t k_dZ
std::vector< FlatTrd > CellVec2
const HGCalDDDConstants & dddConstants() const
DetId getClosestCell(const GlobalPoint &r) const override
static constexpr uint32_t k_Phi
CaloCellGeometry::CornersMgr * cornersMgr()
CornersVec getNewCorners(const DetId &id) const
void getSummary(CaloSubdetectorGeometry::TrVec &trVector, CaloSubdetectorGeometry::IVec &iVector, CaloSubdetectorGeometry::DimVec &dimVector, CaloSubdetectorGeometry::IVec &dinsVector) const override
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
unsigned int totalModules() const
std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const override
Get the cell geometry of a given detector id. Should return false if not found.
CaloCellGeometry::Tr3D Tr3D
int layer() const
get the layer #
CaloCellGeometry::Pt3D Pt3D
std::array< int, 5 > assignCellHex(float x, float y, int lay, bool reco) const
static constexpr uint32_t k_dZ
virtual void fillNamedParams(DDFilteredView fv)
std::pair< int, int > assignCell(float x, float y, int lay, int subSec, bool reco) const
std::array< int, 3 > assignCellTrap(float x, float y, float z, int lay, bool reco) const
const CaloCellGeometry * getGeometryRawPtr(uint32_t index) const override
static constexpr uint32_t k_Alp1
void addValidID(const DetId &id)
bool valid(const DetId &id) const override
Is this a valid cell id.
virtual unsigned int numberOfTransformParms() const
static constexpr uint32_t k_dX3
HGCalParameters::hgtrap getModule(unsigned int k, bool hexType, bool reco) const
int waferTypeT(int wafer) const
unsigned int indexFor(const DetId &id) const override
bool present(const DetId &id) const override
is this detid present in the geometry?
int layer() const
get the layer #
static constexpr uint32_t k_dX2
bool waferInLayer(int wafer, int lay, bool reco) const
DetId getGeometryDetId(DetId detId) const
static constexpr uint32_t k_Alp2