18 #include <Math/Transform3D.h> 19 #include <Math/EulerAngles.h> 29 : m_topology(topology_),
30 m_validGeomIds(topology_.totalGeomModules()),
32 m_subdet(topology_.subDetector()),
33 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) {
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);
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;
213 const HepGeom::Point3D<float> lcoord(0, 0, 0);
214 glob =
m_cellVec2[cellIndex].getPosition(lcoord);
216 edm::LogVerbatim(
"HGCalGeom") <<
"getPositionTrap:: index " << cellIndex <<
" Local " << lcoord.x() <<
":" 217 << lcoord.y() <<
" ID " <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iCell1
218 <<
" Global " << glob;
222 <<
" Wafer " <<
id.iSec1 <<
":" <<
id.iSec2 <<
" Cell " <<
id.iCell1 <<
":" 225 id.iLay,
id.iSec1,
id.iSec2,
id.iCell1,
id.iCell2,
true,
true,
false,
debug);
226 double xx =
id.zSide *
xy.first;
230 edm::LogVerbatim(
"HGCalGeom") <<
"getPositionWafer:: index " << cellIndex <<
" Local " <<
xy.first <<
":" 231 <<
xy.second <<
" ID " <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" 232 <<
id.iCell1 <<
":" <<
id.iCell2 <<
" Global " << glob;
239 unsigned int cellIndex =
indexFor(detid);
243 const HepGeom::Point3D<float> lcoord(0, 0, 0);
245 glob =
m_cellVec2[cellIndex].getPosition(lcoord);
247 glob =
m_cellVec[cellIndex].getPosition(lcoord);
251 << cellIndex <<
" Global " << glob;
260 if (corners.size() > 1) {
261 int n = corners.size() - 1;
263 for (
int i = 0;
i <
n; ++
i) {
264 area += ((corners[
j].x() + corners[
i].x()) * (corners[
i].
y() - corners[
j].y()));
274 unsigned int cellIndex =
indexFor(detid);
285 static const int signr[] = {1, 1, -1, -1, 1, 1, -1, -1};
286 static const int signf[] = {-1, 1, 1, -1, -1, 1, 1, -1};
287 static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
288 for (
unsigned int i = 0;
i < ncorner; ++
i) {
290 (
r + signr[
i] *
dr) *
sin(fi + signf[
i] * dfi),
291 (
v.z() + signz[
i] *
dz));
294 std::pair<float, float>
xy;
300 static const int signx[] = {0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1};
301 static const int signy[] = {-2, -1, 1, 2, 1, -1, -2, -1, 1, 2, 1, -1};
302 static const int signz[] = {-1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1};
303 for (
unsigned int i = 0;
i < ncorner; ++
i) {
304 const HepGeom::Point3D<float> lcoord(
xy.first + signx[
i] *
dx,
xy.second + signy[
i] *
dy, signz[
i] *
dz);
309 id.iLay,
id.iSec1,
id.iSec2,
id.iCell1,
id.iCell2,
true,
false,
true,
debugLocate);
314 static const int signx[] = {1, -1, -2, -1, 1, 2, 1, -1, -2, -1, 1, 2};
315 static const int signy[] = {1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0};
316 static const int signz[] = {-1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1};
317 for (
unsigned int i = 0;
i < ncorner; ++
i) {
319 id.iLay,
id.iSec1,
id.iSec2, (
xy.first + signx[
i] *
dx), (
xy.second + signy[
i] *
dy),
true,
false);
320 double xx =
id.zSide * xyglob.first;
331 unsigned int cellIndex =
indexFor(detid);
342 static const int signr[] = {1, 1, -1, -1, 1, 1, -1, -1};
343 static const int signf[] = {-1, 1, 1, -1, -1, 1, 1, -1};
344 static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
345 for (
unsigned int i = 0;
i < ncorner; ++
i) {
347 (
r + signr[
i] *
dr) *
sin(fi + signf[
i] * dfi),
348 (
v.z() + signz[
i] *
dz));
351 std::pair<float, float>
xy;
353 static const int signx[] = {-1, -1, 1, 1, -1, -1, 1, 1};
354 static const int signy[] = {-1, 1, 1, -1, -1, 1, 1, -1};
355 static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
360 for (
unsigned int i = 0;
i < ncorner; ++
i) {
361 const HepGeom::Point3D<float> lcoord(
xy.first + signx[
i] *
dx,
xy.second + signy[
i] *
dx, signz[
i] *
dz);
366 id.iLay,
id.iSec1,
id.iSec2,
id.iCell1,
id.iCell2,
true,
false,
true,
debugLocate);
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;
385 unsigned int cellIndex =
indexFor(detid);
388 edm::LogVerbatim(
"HGCalGeom") <<
"NewCorners for Layer " <<
id.iLay <<
" Wafer " <<
id.iSec1 <<
":" <<
id.iSec2
389 <<
" Cell " <<
id.iCell1 <<
":" <<
id.iCell2;
399 static const int signr[] = {1, 1, -1, -1};
400 static const int signf[] = {-1, 1, 1, -1};
401 for (
unsigned int i = 0;
i < ncorner - 1; ++
i) {
403 (
r + signr[
i] *
dr) *
cos(fi + signf[
i] * dfi), (
r + signr[
i] *
dr) *
sin(fi + signf[
i] * dfi), (
v.z() +
dz));
405 co[ncorner - 1] =
co[0];
407 std::pair<float, float>
xy;
411 static const int signx[] = {1, -1, -2, -1, 1, 2};
412 static const int signy[] = {1, 1, 0, -1, -1, 0};
420 for (
unsigned int i = 0;
i < ncorner - 1; ++
i) {
421 const HepGeom::Point3D<float> lcoord(
xy.first + signx[
i] *
dx,
xy.second + signy[
i] *
dy,
dz);
426 id.iLay,
id.iSec1,
id.iSec2,
id.iCell1,
id.iCell2,
true,
false,
true,
debug);
428 for (
unsigned int i = 0;
i < ncorner; ++
i) {
429 double xloc =
xy.first + signx[
i] *
dx;
430 double yloc =
xy.second + signy[
i] *
dy;
433 edm::LogVerbatim(
"HGCalGeom") <<
"Corner " <<
i <<
" x " <<
xy.first <<
":" << xloc <<
" y " <<
xy.second
434 <<
":" << yloc <<
" z " <<
zz <<
":" <<
id.zSide * (
zz +
dz);
437 double xx =
id.zSide * xyglob.first;
441 co[ncorner - 1] =
co[0];
449 int lay = ((momentum.
z() *
id.zSide > 0) ? (
id.iLay + 1) : (
id.iLay - 1));
451 edm::LogVerbatim(
"HGCalGeom") <<
"neighborz1:: ID " <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" 452 <<
id.iCell1 <<
":" <<
id.iCell2 <<
" New Layer " << lay <<
" Range " 457 (momentum.
z() != 0.0)) {
460 double grad = (
z -
v.z()) / momentum.
z();
464 if (
r >= rlimit.first &&
r <= rlimit.second)
467 edm::LogVerbatim(
"HGCalGeom") <<
"neighborz1:: Position " <<
v <<
" New Z " <<
z <<
":" << grad <<
" new position " 468 <<
p <<
" r-limit " << rlimit.first <<
":" << rlimit.second;
480 int lay = ((momentum.
z() *
id.zSide > 0) ? (
id.iLay + 1) : (
id.iLay - 1));
482 edm::LogVerbatim(
"HGCalGeom") <<
"neighborz2:: ID " <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" 483 <<
id.iCell1 <<
":" <<
id.iCell2 <<
" New Layer " << lay <<
" Range " 488 (momentum.
z() != 0.0)) {
500 if (
r >= rlimit.first &&
r <= rlimit.second)
505 << tsos.
isValid() <<
" new position " <<
p <<
" r limits " << rlimit.first <<
":" 519 HepGeom::Point3D<float>
local;
521 local = HepGeom::Point3D<float>(
r.x(),
r.y(), 0);
524 local = HepGeom::Point3D<float>(-
r.x(),
r.y(), 0);
529 id.iCell1 = kxy.second;
530 id.iSec1 = kxy.first;
543 edm::LogVerbatim(
"HGCalGeom") <<
"ZZ " <<
r.z() <<
" Layer " <<
id.iLay <<
" Global " <<
r <<
" Local " <<
local;
553 edm::LogVerbatim(
"HGCalGeom") <<
"getClosestCell: local " <<
local <<
" Id " <<
id.det <<
":" <<
id.zSide <<
":" 554 <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" <<
id.iType <<
":" 555 <<
id.iCell1 <<
":" <<
id.iCell2;
573 HepGeom::Point3D<float>
local;
575 local = HepGeom::Point3D<float>(
r.x(),
r.y(), 0);
578 local = HepGeom::Point3D<float>(-
r.x(),
r.y(), 0);
584 edm::LogVerbatim(
"HGCalGeom") <<
"ZZ " <<
r.z() <<
" Layer " <<
id.iLay <<
" Global " <<
r <<
" Local " <<
local;
594 edm::LogVerbatim(
"HGCalGeom") <<
"getClosestCell: local " <<
local <<
" Id " <<
id.det <<
":" <<
id.zSide <<
":" 595 <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" <<
id.iType <<
":" 596 <<
id.iCell1 <<
":" <<
id.iCell2;
617 return "HGCalHEFront";
619 return "HGCalHEBack";
626 if (detId !=
DetId()) {
631 <<
" index " << cellIndex;
645 return (
nullptr == cell->
param() ? nullptr : cell);
650 return (
nullptr == cell->
param() ? nullptr : cell);
658 static const auto do_not_delete = [](
const void*) {};
660 auto cell = std::shared_ptr<const CaloCellGeometry>(&
m_cellVec2[
index], do_not_delete);
661 if (
nullptr == cell->param())
665 auto cell = std::shared_ptr<const CaloCellGeometry>(&
m_cellVec[
index], do_not_delete);
666 if (
nullptr == cell->param())
680 cell->setPosition(
pos);
684 if (
nullptr == cell->param())
689 cell->setPosition(
pos);
693 if (
nullptr == cell->param())
700 edm::LogError(
"HGCalGeom") <<
"HGCalGeometry::addValidID is not implemented";
709 float phip =
r.phi();
711 float dzmin(9999), dphimin(9999), dphi10(0.175);
712 unsigned int cellIndex = vec.size();
713 for (
unsigned int k = 0;
k < vec.size(); ++
k) {
714 float dphi = phip - vec[
k].phiPos();
717 while (dphi <= -
M_PI)
721 if (
dz < (dzmin + 0.001)) {
723 if (
std::abs(dphi) < (dphimin + 0.01)) {
727 if (cellIndex >= vec.size())
734 edm::LogVerbatim(
"HGCalGeom") <<
"getClosestCellIndex::Input " << zp <<
":" << phip <<
" Index " << cellIndex;
735 if (cellIndex < vec.size())
736 edm::LogVerbatim(
"HGCalGeom") <<
" Cell z " << vec[cellIndex].getPosition().z() <<
":" << dzmin <<
" phi " 737 << vec[cellIndex].phiPos() <<
":" << dphimin;
745 bool operator()(
const DetId&
a,
const DetId&
b) {
return (
a.rawId() <
b.rawId()); }
764 iVector.reserve(numberOfCells);
766 dinsVector.reserve(numberOfCells);
780 dimVector.insert(dimVector.end(),
params.begin(),
params.end());
797 dimVector.insert(dimVector.end(),
params.begin(),
params.end());
807 dimVector.insert(dimVector.end(),
params.begin(),
params.end());
813 for (
unsigned int i(0);
i < numberOfCells; ++
i) {
826 iVector.emplace_back(
layer);
830 if (
nullptr != ptr) {
831 ptr->getTransform(tr, (
Pt3DVec*)
nullptr);
835 tr = HepGeom::Translate3D(
gp.x(),
gp.y(),
gp.z());
838 const CLHEP::Hep3Vector
tt(tr.getTranslation());
839 trVector.emplace_back(
tt.x());
840 trVector.emplace_back(
tt.y());
841 trVector.emplace_back(
tt.z());
843 const CLHEP::HepRotation
rr(tr.getRotation());
844 const ROOT::Math::Transform3D rtr(
845 rr.xx(),
rr.xy(),
rr.xz(),
tt.x(),
rr.yx(),
rr.yy(),
rr.yz(),
tt.y(),
rr.zx(),
rr.zy(),
rr.zz(),
tt.z());
848 trVector.emplace_back(ea.Phi());
849 trVector.emplace_back(ea.Theta());
850 trVector.emplace_back(ea.Psi());
DetId getClosestCellHex(const GlobalPoint &r, bool extend) const
static constexpr unsigned int k_NumberOfShapes
double waferZ(int layer, bool reco) const
std::vector< DetId > m_validGeomIds
Log< level::Info, true > LogVerbatim
DetId neighborZ(const DetId &idin, const GlobalVector &p) const
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
A base class to handle the particular shape of HGCal volumes.
std::vector< CCGFloat > DimVec
std::pair< double, double > cellSizeTrap(int type, int irad) const
unsigned int totalGeomModules() const
int layer() const
get the layer #
std::vector< FlatHexagon > CellVec
const HGCalParameters * getParameter() const
DetId::Detector detector() const
bool tileTrapezoid() const
GlobalPoint getWaferPosition(const DetId &id) const
HGCalParameters::hgtrap getModule(unsigned int k, bool hexType, bool reco) const
virtual unsigned int numberOfTransformParms() 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)
unsigned int totalModules() const
bool waferHexagon6() const
Global3DPoint GlobalPoint
std::vector< unsigned int > IVec
static constexpr uint32_t k_Theta
int lastLayer(bool reco) const
bool present(const DetId &id) const override
is this detid present in the geometry?
int waferTypeT(int wafer) 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
static constexpr double k_fac2
HepGeom::Transform3D Tr3D
virtual unsigned int numberOfShapes() const
static constexpr uint32_t k_Cell
static constexpr uint32_t k_dY1
Log< level::Error, false > LogError
CornersVec getCorners(const DetId &id) const
Returns the corner points of this cell's volume.
__host__ __device__ VT * co
CaloCellGeometry::CCGFloat CCGFloat
CaloCellGeometry::Tr3D Tr3D
HGCalDetId geometryCell() const
static constexpr double k_half
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
CornersVec getNewCorners(const DetId &id, bool debug=false) const
static constexpr unsigned int ncorner_
constexpr std::array< uint8_t, layerIndexSize > layer
CaloCellGeometry::Pt3DVec Pt3DVec
static constexpr double k_fac1
static PlanePointer build(Args &&... args)
bool waferInLayer(int wafer, int lay, bool reco) const
std::pair< int, int > tileType(int layer, int ring, int phi) const
int layer() const
get the layer #
HGCalGeometry(const HGCalTopology &topology)
static constexpr unsigned int ncorner_
std::vector< int > firstModule_
DetId getClosestCell(const GlobalPoint &r) const override
static constexpr uint32_t k_R
void initializeParms() override
GlobalPoint globalPosition() const
static constexpr uint32_t k_r
unsigned int getClosestCellIndex(const GlobalPoint &r) const
std::vector< float > ParmVec
static constexpr uint32_t k_dX1
std::vector< DetId > m_validIds
int layerIndex(int lay, bool reco) const
std::pair< float, float > localToGlobal8(int lay, int waferU, int waferV, double localX, double localY, bool reco, bool debug) const
DetIdSet getCells(const GlobalPoint &r, double dR) const override
Get a list of all cells within a dR of the given cell.
virtual uint32_t detId2denseGeomId(const DetId &id) const
Cos< T >::type cos(const T &t)
static constexpr unsigned int k_NumberOfParametersPerTrd
int layer() const
get the layer #
unsigned int indexFor(const DetId &id) const override
unsigned int sizeForDenseIndex() const
A base class to handle the hexagonal shape of HGCal silicon volumes.
DecodedDetId decode(const DetId &id) const
Abs< T >::type abs(const T &t)
std::set< DetId > DetIdSet
static constexpr uint32_t k_dY2
std::pair< int, int > assignCell(float x, float y, int lay, int subSec, bool reco) const
DetId getGeometryDetId(DetId detId) const
const CaloCellGeometry * getGeometryRawPtr(uint32_t index) const override
static constexpr uint32_t k_dX4
const HGCalTopology & topology() const
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
HFNoseDetId geometryCell() const
void localCorners(Pt3DVec &lc, const CCGFloat *pv, unsigned int i, Pt3D &ref)
#define TYPELOOKUP_DATA_REG(_dataclass_)
int ring() const
get the eta index
std::pair< double, double > rangeR(double z, bool reco) const
static constexpr unsigned int k_NumberOfParametersPerHex
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ cells
std::vector< int > lastModule_
int numberCellsHexagon(int wafer) const
AlgebraicVector EulerAngles
std::array< int, 3 > assignCellTrap(float x, float y, float z, int lay, bool reco) const
ForwardSubdetector m_subdet
bool cellInLayer(int waferU, int waferV, int cellU, int cellV, int lay, bool reco) const
static constexpr uint32_t k_dZ
std::vector< FlatTrd > CellVec2
static constexpr uint32_t k_Phi
constexpr uint32_t rawId() const
get the raw id
CaloCellGeometry::CornersMgr * cornersMgr()
DetId encode(const DecodedDetId &id_) const
std::pair< float, float > locateCellHex(int cell, int wafer, bool reco) const
int layer() const
get the layer #
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.
HGCScintillatorDetId geometryCell() const
unsigned int getTrFormN() const
HGCalParameters::hgtrform getTrForm(unsigned int k) const
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
CaloCellGeometry::Tr3D Tr3D
bool waferHexagon8() const
std::array< int, 5 > assignCellHex(float x, float y, int lay, bool reco, bool extend=false, bool debug=false) const
GlobalPoint getPosition(const DetId &id, bool debug=false) const
CaloCellGeometry::Pt3D Pt3D
std::shared_ptr< const CaloCellGeometry > cellGeomPtr(uint32_t index) const override
int getLayer(double z, bool reco) const
static constexpr uint32_t k_dZ
virtual void fillNamedParams(DDFilteredView fv)
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)
static constexpr uint32_t k_dX3
Log< level::Warning, false > LogWarning
HGCSiliconDetId geometryCell() const
std::string cellElement() const
double getArea(const DetId &detid) const
Returns area of a cell.
const HGCalDDDConstants & dddConstants() const
const CCGFloat * param() const
static constexpr uint32_t k_dX2
CornersVec get8Corners(const DetId &id) const
virtual unsigned int numberOfParametersPerShape() const
static constexpr uint32_t k_Alp2