18 #include <Math/Transform3D.h>
19 #include <Math/EulerAngles.h>
27 : m_topology(topology_),
28 m_validGeomIds(topology_.totalGeomModules()),
29 m_det(topology_.detector()),
30 m_subdet(topology_.subDetector()),
31 twoBysqrt3_(2.0 / std::
sqrt(3.0)) {
94 for (
int cell = 0; cell <
cells; ++cell) {
109 if (typm.first >= 0) {
112 idc =
static_cast<DetId>(hid);
124 unsigned int cellAll(0), cellSelect(0);
126 for (
int u = 0; u < 2 *
cells; ++u) {
127 for (
int v = 0;
v < 2 *
cells; ++
v) {
128 if (((
v - u) < cells) && (u -
v) <= cells) {
146 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeometry keeps " << cellSelect <<
" out of " << cellAll <<
" for wafer "
147 <<
id.iSec1 <<
":" <<
id.iSec2 <<
" in "
148 <<
" layer " <<
id.iLay;
153 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeometry::newCell-> [" << cellIndex <<
"]"
154 <<
" front:" << f1.
x() <<
'/' << f1.
y() <<
'/' << f1.
z() <<
" back:" << f2.
x() <<
'/'
155 << f2.
y() <<
'/' << f2.
z() <<
" eta|phi " <<
m_cellVec2[cellIndex].etaPos() <<
":"
158 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeometry::newCell-> [" << cellIndex <<
"]"
159 <<
" front:" << f1.
x() <<
'/' << f1.
y() <<
'/' << f1.
z() <<
" back:" << f2.
x() <<
'/'
160 << f2.
y() <<
'/' << f2.
z() <<
" eta|phi " <<
m_cellVec[cellIndex].etaPos() <<
":"
182 if (detId ==
DetId())
191 if (detId ==
DetId())
199 unsigned int cellIndex =
indexFor(detid);
202 if (cellIndex < maxSize) {
204 std::pair<float, float>
xy;
207 const HepGeom::Point3D<float> lcoord(xy.first, xy.second, 0);
208 glob =
m_cellVec[cellIndex].getPosition(lcoord);
210 edm::LogVerbatim(
"HGCalGeom") <<
"getPosition:: index " << cellIndex <<
" Local " << lcoord.x() <<
":"
211 << lcoord.y() <<
" ID " <<
id.iCell1 <<
":" <<
id.iSec1 <<
" Global " << glob;
214 const HepGeom::Point3D<float> lcoord(0, 0, 0);
215 glob =
m_cellVec2[cellIndex].getPosition(lcoord);
217 edm::LogVerbatim(
"HGCalGeom") <<
"getPositionTrap:: index " << cellIndex <<
" Local " << lcoord.x() <<
":"
218 << lcoord.y() <<
" ID " <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iCell1
219 <<
" Global " << glob;
224 <<
id.iSec1 <<
":" <<
id.iSec2 <<
" Cell " <<
id.iCell1 <<
":" <<
id.iCell2;
227 double xx =
id.zSide * xy.first;
231 edm::LogVerbatim(
"HGCalGeom") <<
"getPositionWafer:: index " << cellIndex <<
" Local " << xy.first <<
":"
232 << xy.second <<
" ID " <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iSec2 <<
":"
233 <<
id.iCell1 <<
":" <<
id.iCell2 <<
" Global " << glob;
241 unsigned int cellIndex =
indexFor(detid);
244 if (cellIndex < maxSize) {
245 const HepGeom::Point3D<float> lcoord(0, 0, 0);
247 glob =
m_cellVec2[cellIndex].getPosition(lcoord);
249 glob =
m_cellVec[cellIndex].getPosition(lcoord);
253 << cellIndex <<
" Global " << glob;
262 if (corners.size() > 1) {
263 int n = corners.size() - 1;
265 for (
int i = 0;
i <
n; ++
i) {
266 area += ((corners[
j].x() + corners[
i].x()) * (corners[
i].
y() - corners[
j].y()));
276 unsigned int cellIndex =
indexFor(detid);
282 float dr =
k_half * (rr.second - rr.first);
287 static const int signr[] = {1, 1, -1, -1, 1, 1, -1, -1};
288 static const int signf[] = {-1, 1, 1, -1, -1, 1, 1, -1};
289 static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
290 for (
unsigned int i = 0;
i < ncorner; ++
i) {
292 (r + signr[
i] * dr) *
sin(fi + signf[
i] * dfi),
293 (v.
z() + signz[
i] *
dz));
296 std::pair<float, float>
xy;
302 static const int signx[] = {0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1};
303 static const int signy[] = {-2, -1, 1, 2, 1, -1, -2, -1, 1, 2, 1, -1};
304 static const int signz[] = {-1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1};
305 for (
unsigned int i = 0;
i < ncorner; ++
i) {
306 const HepGeom::Point3D<float> lcoord(xy.first + signx[
i] * dx, xy.second + signy[
i] * dy, signz[
i] * dz);
307 co[
i] =
m_cellVec[cellIndex].getPosition(lcoord);
315 static const int signx[] = {1, -1, -2, -1, 1, 2, 1, -1, -2, -1, 1, 2};
316 static const int signy[] = {1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0};
317 static const int signz[] = {-1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1};
318 for (
unsigned int i = 0;
i < ncorner; ++
i) {
320 id.iLay,
id.iSec1,
id.iSec2, (xy.first + signx[
i] * dx), (xy.second + signy[
i] * dy),
true,
false);
321 double xx =
id.zSide * xyglob.first;
322 co[
i] =
GlobalPoint(xx, xyglob.second,
id.zSide * (zz + signz[
i] * dz));
332 unsigned int cellIndex =
indexFor(detid);
338 float dr =
k_half * (rr.second - rr.first);
343 static const int signr[] = {1, 1, -1, -1, 1, 1, -1, -1};
344 static const int signf[] = {-1, 1, 1, -1, -1, 1, 1, -1};
345 static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
346 for (
unsigned int i = 0;
i < ncorner; ++
i) {
348 (r + signr[
i] * dr) *
sin(fi + signf[
i] * dfi),
349 (v.
z() + signz[
i] *
dz));
352 std::pair<float, float>
xy;
354 static const int signx[] = {-1, -1, 1, 1, -1, -1, 1, 1};
355 static const int signy[] = {-1, 1, 1, -1, -1, 1, 1, -1};
356 static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
361 for (
unsigned int i = 0;
i < ncorner; ++
i) {
362 const HepGeom::Point3D<float> lcoord(xy.first + signx[
i] * dx, xy.second + signy[
i] * dx, signz[
i] * dz);
363 co[
i] =
m_cellVec[cellIndex].getPosition(lcoord);
371 for (
unsigned int i = 0;
i < ncorner; ++
i) {
373 id.iLay,
id.iSec1,
id.iSec2, (xy.first + signx[
i] * dx), (xy.second + signy[
i] * dy),
true,
false);
374 double xx =
id.zSide * xyglob.first;
375 co[
i] =
GlobalPoint(xx, xyglob.second,
id.zSide * (zz + signz[
i] * dz));
385 unsigned int cellIndex =
indexFor(detid);
391 float dr =
k_half * (rr.second - rr.first);
396 static const int signr[] = {1, 1, -1, -1};
397 static const int signf[] = {-1, 1, 1, -1};
398 for (
unsigned int i = 0;
i < ncorner - 1; ++
i) {
400 (r + signr[
i] * dr) *
cos(fi + signf[
i] * dfi), (r + signr[
i] * dr) *
sin(fi + signf[
i] * dfi), (v.
z() +
dz));
402 co[ncorner - 1] = co[0];
404 std::pair<float, float>
xy;
408 static const int signx[] = {1, -1, -2, -1, 1, 2};
409 static const int signy[] = {1, 1, 0, -1, -1, 0};
412 for (
unsigned int i = 0;
i < ncorner - 1; ++
i) {
413 const HepGeom::Point3D<float> lcoord(xy.first + signx[
i] * dx, xy.second + signy[
i] * dy, dz);
414 co[
i] =
m_cellVec[cellIndex].getPosition(lcoord);
419 for (
unsigned int i = 0;
i < ncorner; ++
i) {
421 id.iLay,
id.iSec1,
id.iSec2, (xy.first + signx[
i] * dx), (xy.second + signy[
i] * dy),
true,
false);
422 double xx =
id.zSide * xyglob.first;
423 co[
i] =
GlobalPoint(xx, xyglob.second,
id.zSide * (zz + dz));
426 co[ncorner - 1] = co[0];
434 int lay = ((momentum.
z() *
id.zSide > 0) ? (
id.iLay + 1) : (
id.iLay - 1));
436 edm::LogVerbatim(
"HGCalGeom") <<
"neighborz1:: ID " <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iSec2 <<
":"
437 <<
id.iCell1 <<
":" <<
id.iCell2 <<
" New Layer " << lay <<
" Range "
442 (momentum.
z() != 0.0)) {
445 double grad = (z - v.
z()) / momentum.
z();
449 if (r >= rlimit.first && r <= rlimit.second)
452 edm::LogVerbatim(
"HGCalGeom") <<
"neighborz1:: Position " << v <<
" New Z " << z <<
":" << grad <<
" new position "
453 <<
p <<
" r-limit " << rlimit.first <<
":" << rlimit.second;
465 int lay = ((momentum.
z() *
id.zSide > 0) ? (
id.iLay + 1) : (
id.iLay - 1));
467 edm::LogVerbatim(
"HGCalGeom") <<
"neighborz2:: ID " <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iSec2 <<
":"
468 <<
id.iCell1 <<
":" <<
id.iCell2 <<
" New Layer " << lay <<
" Range "
473 (momentum.
z() != 0.0)) {
485 if (r >= rlimit.first && r <= rlimit.second)
489 edm::LogVerbatim(
"HGCalGeom") <<
"neighborz2:: Position " << v <<
" New Z " << z <<
":" << charge <<
":"
490 << tsos.
isValid() <<
" new position " << p <<
" r limits " << rlimit.first <<
":"
504 HepGeom::Point3D<float> local;
506 local = HepGeom::Point3D<float>(r.
x(), r.
y(), 0);
509 local = HepGeom::Point3D<float>(-r.
x(), r.
y(), 0);
514 id.iCell1 = kxy.second;
515 id.iSec1 = kxy.first;
528 edm::LogVerbatim(
"HGCalGeom") <<
"ZZ " << r.
z() <<
" Layer " <<
id.iLay <<
" Global " << r <<
" Local " << local;
538 edm::LogVerbatim(
"HGCalGeom") <<
"getClosestCell: local " << local <<
" Id " <<
id.det <<
":" <<
id.zSide <<
":"
539 <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" <<
id.iType <<
":"
540 <<
id.iCell1 <<
":" <<
id.iCell2;
558 HepGeom::Point3D<float> local;
560 local = HepGeom::Point3D<float>(r.
x(), r.
y(), 0);
563 local = HepGeom::Point3D<float>(-r.
x(), r.
y(), 0);
569 edm::LogVerbatim(
"HGCalGeom") <<
"ZZ " << r.
z() <<
" Layer " <<
id.iLay <<
" Global " << r <<
" Local " << local;
579 edm::LogVerbatim(
"HGCalGeom") <<
"getClosestCell: local " << local <<
" Id " <<
id.det <<
":" <<
id.zSide <<
":"
580 <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" <<
id.iType <<
":"
581 <<
id.iCell1 <<
":" <<
id.iCell2;
602 return "HGCalHEFront";
604 return "HGCalHEBack";
611 if (detId !=
DetId()) {
616 <<
" index " << cellIndex;
630 return (
nullptr == cell->
param() ?
nullptr : cell);
635 return (
nullptr == cell->
param() ?
nullptr : cell);
643 static const auto do_not_delete = [](
const void*) {};
645 auto cell = std::shared_ptr<const CaloCellGeometry>(&
m_cellVec2[
index], do_not_delete);
646 if (
nullptr == cell->param())
650 auto cell = std::shared_ptr<const CaloCellGeometry>(&
m_cellVec[
index], do_not_delete);
651 if (
nullptr == cell->param())
665 cell->setPosition(pos);
669 if (
nullptr == cell->param())
674 cell->setPosition(pos);
678 if (
nullptr == cell->param())
685 edm::LogError(
"HGCalGeom") <<
"HGCalGeometry::addValidID is not implemented";
694 float phip = r.
phi();
696 float dzmin(9999), dphimin(9999), dphi10(0.175);
697 unsigned int cellIndex = vec.size();
698 for (
unsigned int k = 0;
k < vec.size(); ++
k) {
699 float dphi = phip - vec[
k].phiPos();
702 while (dphi <= -
M_PI)
706 if (dz < (dzmin + 0.001)) {
708 if (
std::abs(dphi) < (dphimin + 0.01)) {
712 if (cellIndex >= vec.size())
719 edm::LogVerbatim(
"HGCalGeom") <<
"getClosestCellIndex::Input " << zp <<
":" << phip <<
" Index " << cellIndex;
720 if (cellIndex < vec.size())
721 edm::LogVerbatim(
"HGCalGeom") <<
" Cell z " << vec[cellIndex].getPosition().z() <<
":" << dzmin <<
" phi "
722 << vec[cellIndex].phiPos() <<
":" << dphimin;
749 iVector.reserve(numberOfCells);
750 dimVector.reserve(numberOfShapes * numberOfParametersPerShape);
751 dinsVector.reserve(numberOfCells);
765 dimVector.insert(dimVector.end(), params.begin(), params.end());
782 dimVector.insert(dimVector.end(), params.begin(), params.end());
792 dimVector.insert(dimVector.end(), params.begin(), params.end());
798 for (
unsigned int i(0);
i < numberOfCells; ++
i) {
811 iVector.emplace_back(layer);
815 if (
nullptr != ptr) {
816 ptr->getTransform(tr, (
Pt3DVec*)
nullptr);
820 tr = HepGeom::Translate3D(
gp.x(),
gp.y(),
gp.z());
823 const CLHEP::Hep3Vector
tt(tr.getTranslation());
824 trVector.emplace_back(
tt.x());
825 trVector.emplace_back(
tt.y());
826 trVector.emplace_back(
tt.z());
828 const CLHEP::HepRotation
rr(tr.getRotation());
829 const ROOT::Math::Transform3D rtr(
830 rr.xx(),
rr.xy(),
rr.xz(),
tt.x(),
rr.yx(),
rr.yy(),
rr.yz(),
tt.y(),
rr.zx(),
rr.zy(),
rr.zz(),
tt.z());
833 trVector.emplace_back(ea.Phi());
834 trVector.emplace_back(ea.Theta());
835 trVector.emplace_back(ea.Psi());
static constexpr unsigned int k_NumberOfShapes
std::vector< DetId > m_validGeomIds
Log< level::Info, true > LogVerbatim
std::pair< double, double > cellSizeTrap(int type, int irad) const
DetId getClosestCellHex(const GlobalPoint &r, bool extend) const
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
unsigned int sizeForDenseIndex() const
HGCalParameters::hgtrform getTrForm(unsigned int k) const
int lastLayer(bool reco) const
unsigned int getClosestCellIndex(const GlobalPoint &r) const
bool tileTrapezoid() const
DetId neighborZ(const DetId &idin, const GlobalVector &p) const
const HGCalParameters * getParameter() const
bool valid(const DetId &id) const override
Is this a valid cell id.
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
bool present(const DetId &id) const override
is this detid present in the geometry?
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
static constexpr double k_fac2
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
Log< level::Error, false > LogError
__host__ __device__ VT * co
CaloCellGeometry::CCGFloat CCGFloat
CornersVec getCorners(const DetId &id) const
Returns the corner points of this cell's volume.
static constexpr double k_half
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
int layerIndex(int lay, bool reco) const
static constexpr unsigned int ncorner_
constexpr std::array< uint8_t, layerIndexSize > layer
CaloCellGeometry::Pt3DVec Pt3DVec
static constexpr double k_fac1
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_
HGCalDetId geometryCell() const
DetId getClosestCell(const GlobalPoint &r) const override
static constexpr uint32_t k_R
void initializeParms() override
unsigned int getTrFormN() const
HGCSiliconDetId geometryCell() const
const CCGFloat * param() const
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
tuple maxSize
'/store/data/Commissioning08/BeamHalo/RECO/StuffAlmostToP5_v1/000/061/642/10A0FE34-A67D-DD11-AD05-000...
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
DetIdSet getCells(const GlobalPoint &r, double dR) const override
Get a list of all cells within a dR of the given cell.
std::pair< float, float > localToGlobal8(int lay, int waferU, int waferV, double localX, double localY, bool reco, bool debug) const
Cos< T >::type cos(const T &t)
static constexpr unsigned int k_NumberOfParametersPerTrd
unsigned int indexFor(const DetId &id) const override
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
const CaloCellGeometry * getGeometryRawPtr(uint32_t index) const override
HGCScintillatorDetId geometryCell() const
int ring() const
get the eta index
CornersVec get8Corners(const DetId &id) const
static constexpr uint32_t k_dX4
bool waferHexagon6() const
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
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
static constexpr unsigned int k_NumberOfParametersPerHex
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ cells
Basic2DVector< T > xy() const
GlobalPoint getWaferPosition(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
static constexpr uint32_t k_Phi
CaloCellGeometry::CornersMgr * cornersMgr()
CornersVec getNewCorners(const DetId &id) 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.
std::array< int, 5 > assignCellHex(float x, float y, int lay, bool reco, bool extend=false, bool debug=false) const
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
unsigned int totalModules() const
CaloCellGeometry::Tr3D Tr3D
int layer() const
get the layer #
CaloCellGeometry::Pt3D Pt3D
std::shared_ptr< const CaloCellGeometry > cellGeomPtr(uint32_t index) const override
static constexpr uint32_t k_dZ
virtual void fillNamedParams(DDFilteredView fv)
bool waferHexagon8() const
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
void getSummary(CaloSubdetectorGeometry::TrVec &trVector, CaloSubdetectorGeometry::IVec &iVector, CaloSubdetectorGeometry::DimVec &dimVector, CaloSubdetectorGeometry::IVec &dinsVector) const override
static constexpr uint32_t k_Alp1
void addValidID(const DetId &id)
virtual unsigned int numberOfTransformParms() const
static constexpr uint32_t k_dX3
Log< level::Warning, false > LogWarning
DetId::Detector detector() const
HGCalParameters::hgtrap getModule(unsigned int k, bool hexType, bool reco) const
std::pair< int, int > tileType(int layer, int ring, int phi) const
int waferTypeT(int wafer) const
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