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)) {
97 for (
int cell = 0; cell <
cells; ++cell) {
112 if (typm.first >= 0) {
115 idc =
static_cast<DetId>(hid);
127 unsigned int cellAll(0), cellSelect(0);
129 for (
int u = 0; u < 2 *
cells; ++u) {
130 for (
int v = 0;
v < 2 *
cells; ++
v) {
152 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeometry keeps " << cellSelect <<
" out of " << cellAll <<
" for wafer " 153 <<
id.iSec1 <<
":" <<
id.iSec2 <<
" in " 154 <<
" layer " <<
id.iLay;
159 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeometry::newCell-> [" << cellIndex <<
"]" 160 <<
" front:" <<
f1.x() <<
'/' <<
f1.y() <<
'/' <<
f1.z() <<
" back:" <<
f2.x() <<
'/' 161 <<
f2.y() <<
'/' <<
f2.z() <<
" eta|phi " <<
m_cellVec2[cellIndex].etaPos() <<
":" 164 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalGeometry::newCell-> [" << cellIndex <<
"]" 165 <<
" front:" <<
f1.x() <<
'/' <<
f1.y() <<
'/' <<
f1.z() <<
" back:" <<
f2.x() <<
'/' 166 <<
f2.y() <<
'/' <<
f2.z() <<
" eta|phi " <<
m_cellVec[cellIndex].etaPos() <<
":" 209 unsigned int cellIndex =
indexFor(detid);
214 std::pair<float, float>
xy;
217 const HepGeom::Point3D<float> lcoord(
xy.first,
xy.second, 0);
218 glob =
m_cellVec[cellIndex].getPosition(lcoord);
220 edm::LogVerbatim(
"HGCalGeom") <<
"getPosition:: index " << cellIndex <<
" Local " << lcoord.x() <<
":" 221 << lcoord.y() <<
" ID " <<
id.iCell1 <<
":" <<
id.iSec1 <<
" Global " << glob;
223 const HepGeom::Point3D<float> lcoord(0, 0, 0);
224 glob =
m_cellVec2[cellIndex].getPosition(lcoord);
226 edm::LogVerbatim(
"HGCalGeom") <<
"getPositionTrap:: index " << cellIndex <<
" Local " << lcoord.x() <<
":" 227 << lcoord.y() <<
" ID " <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iCell1
228 <<
" Global " << glob;
233 <<
id.iSec1 <<
":" <<
id.iSec2 <<
" Cell " <<
id.iCell1 <<
":" <<
id.iCell2;
236 <<
" Wafer " <<
id.iSec1 <<
":" <<
id.iSec2 <<
" Cell " <<
id.iCell1 <<
":" 240 id.zSide,
id.iLay,
id.iSec1,
id.iSec2,
id.iCell1,
id.iCell2,
true,
true,
false, cog,
debug);
241 double xx =
id.zSide *
xy.first;
245 edm::LogVerbatim(
"HGCalGeom") <<
"getPositionWafer:: index " << cellIndex <<
" Local " <<
xy.first <<
":" 246 <<
xy.second <<
" ID " <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" 247 <<
id.iCell1 <<
":" <<
id.iCell2 <<
" Global " << glob;
250 edm::LogVerbatim(
"HGCalGeom") <<
"Cannot recognize " << std::hex << detid.
rawId() <<
" cellIndex " << cellIndex
257 unsigned int cellIndex =
indexFor(detid);
261 const HepGeom::Point3D<float> lcoord(0, 0, 0);
263 glob =
m_cellVec2[cellIndex].getPosition(lcoord);
265 glob =
m_cellVec[cellIndex].getPosition(lcoord);
269 << cellIndex <<
" Global " << glob;
278 if (corners.size() > 1) {
279 int n = corners.size() - 1;
281 for (
int i = 0;
i <
n; ++
i) {
282 area += ((corners[
j].x() + corners[
i].x()) * (corners[
i].
y() - corners[
j].y()));
292 unsigned int cellIndex =
indexFor(detid);
303 static const int signr[] = {1, 1, -1, -1, 1, 1, -1, -1};
304 static const int signf[] = {-1, 1, 1, -1, -1, 1, 1, -1};
305 static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
306 for (
unsigned int i = 0;
i < ncorner; ++
i) {
308 (
r + signr[
i] *
dr) *
sin(fi + signf[
i] * dfi),
309 (
v.z() + signz[
i] *
dz));
312 std::pair<float, float>
xy;
318 static const int signx[] = {0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1};
319 static const int signy[] = {-2, -1, 1, 2, 1, -1, -2, -1, 1, 2, 1, -1};
320 static const int signz[] = {-1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1};
321 for (
unsigned int i = 0;
i < ncorner; ++
i) {
322 const HepGeom::Point3D<float> lcoord(
xy.first + signx[
i] *
dx,
xy.second + signy[
i] *
dy, signz[
i] *
dz);
327 id.zSide,
id.iLay,
id.iSec1,
id.iSec2,
id.iCell1,
id.iCell2,
true,
false,
true,
false,
debugLocate);
332 static const int signx[] = {1, -1, -2, -1, 1, 2, 1, -1, -2, -1, 1, 2};
333 static const int signy[] = {1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0};
334 static const int signz[] = {-1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1};
335 for (
unsigned int i = 0;
i < ncorner; ++
i) {
337 id.zSide,
id.iLay,
id.iSec1,
id.iSec2, (
xy.first + signx[
i] *
dx), (
xy.second + signy[
i] *
dy),
true,
false);
338 double xx =
id.zSide * xyglob.first;
349 unsigned int cellIndex =
indexFor(detid);
360 static const int signr[] = {1, 1, -1, -1, 1, 1, -1, -1};
361 static const int signf[] = {-1, 1, 1, -1, -1, 1, 1, -1};
362 static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
363 for (
unsigned int i = 0;
i < ncorner; ++
i) {
365 (
r + signr[
i] *
dr) *
sin(fi + signf[
i] * dfi),
366 (
v.z() + signz[
i] *
dz));
369 std::pair<float, float>
xy;
371 static const int signx[] = {-1, -1, 1, 1, -1, -1, 1, 1};
372 static const int signy[] = {-1, 1, 1, -1, -1, 1, 1, -1};
373 static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
378 for (
unsigned int i = 0;
i < ncorner; ++
i) {
379 const HepGeom::Point3D<float> lcoord(
xy.first + signx[
i] *
dx,
xy.second + signy[
i] *
dx, signz[
i] *
dz);
384 id.zSide,
id.iLay,
id.iSec1,
id.iSec2,
id.iCell1,
id.iCell2,
true,
false,
true,
false,
debugLocate);
389 for (
unsigned int i = 0;
i < ncorner; ++
i) {
391 id.zSide,
id.iLay,
id.iSec1,
id.iSec2, (
xy.first + signx[
i] *
dx), (
xy.second + signy[
i] *
dy),
true,
false);
392 double xx =
id.zSide * xyglob.first;
403 unsigned int cellIndex =
indexFor(detid);
406 edm::LogVerbatim(
"HGCalGeom") <<
"NewCorners for Layer " <<
id.iLay <<
" Wafer " <<
id.iSec1 <<
":" <<
id.iSec2
407 <<
" Cell " <<
id.iCell1 <<
":" <<
id.iCell2;
417 static const int signr[] = {1, 1, -1, -1};
418 static const int signf[] = {-1, 1, 1, -1};
419 for (
unsigned int i = 0;
i < ncorner - 1; ++
i) {
421 (
r + signr[
i] *
dr) *
cos(fi + signf[
i] * dfi), (
r + signr[
i] *
dr) *
sin(fi + signf[
i] * dfi), (
v.z() +
dz));
426 std::pair<float, float>
xy;
430 static const int signx[] = {1, -1, -2, -1, 1, 2};
431 static const int signy[] = {1, 1, 0, -1, -1, 0};
439 for (
unsigned int i = 0;
i < ncorner - 1; ++
i) {
440 const HepGeom::Point3D<float> lcoord(
xy.first + signx[
i] *
dx,
xy.second + signy[
i] *
dy,
dz);
445 id.zSide,
id.iLay,
id.iSec1,
id.iSec2,
id.iCell1,
id.iCell2,
true,
false,
true,
false,
debug);
447 for (
unsigned int i = 0;
i < ncorner; ++
i) {
448 double xloc =
xy.first + signx[
i] *
dx;
449 double yloc =
xy.second + signy[
i] *
dy;
452 edm::LogVerbatim(
"HGCalGeom") <<
"Corner " <<
i <<
" x " <<
xy.first <<
":" << xloc <<
" y " <<
xy.second
453 <<
":" << yloc <<
" z " <<
zz <<
":" <<
id.zSide * (
zz +
dz);
457 double xx =
id.zSide * xyglob.first;
470 int lay = ((momentum.
z() *
id.zSide > 0) ? (
id.iLay + 1) : (
id.iLay - 1));
472 edm::LogVerbatim(
"HGCalGeom") <<
"neighborz1:: ID " <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" 473 <<
id.iCell1 <<
":" <<
id.iCell2 <<
" New Layer " << lay <<
" Range " 478 (momentum.
z() != 0.0)) {
481 double grad = (
z -
v.z()) / momentum.
z();
485 if (
r >= rlimit.first &&
r <= rlimit.second)
488 edm::LogVerbatim(
"HGCalGeom") <<
"neighborz1:: Position " <<
v <<
" New Z " <<
z <<
":" << grad <<
" new position " 489 <<
p <<
" r-limit " << rlimit.first <<
":" << rlimit.second;
501 int lay = ((momentum.
z() *
id.zSide > 0) ? (
id.iLay + 1) : (
id.iLay - 1));
503 edm::LogVerbatim(
"HGCalGeom") <<
"neighborz2:: ID " <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" 504 <<
id.iCell1 <<
":" <<
id.iCell2 <<
" New Layer " << lay <<
" Range " 509 (momentum.
z() != 0.0)) {
521 if (
r >= rlimit.first &&
r <= rlimit.second)
526 << tsos.
isValid() <<
" new position " <<
p <<
" r limits " << rlimit.first <<
":" 540 HepGeom::Point3D<float>
local;
542 local = HepGeom::Point3D<float>(
r.x(),
r.y(), 0);
545 local = HepGeom::Point3D<float>(-
r.x(),
r.y(), 0);
550 id.iCell1 = kxy.second;
551 id.iSec1 = kxy.first;
563 int zside = (
r.z() > 0) ? 1 : -1;
566 <<
" Local " <<
local;
577 edm::LogVerbatim(
"HGCalGeom") <<
"getClosestCell: local " <<
local <<
" Id " <<
id.det <<
":" <<
id.zSide <<
":" 578 <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" <<
id.iType <<
":" 579 <<
id.iCell1 <<
":" <<
id.iCell2;
597 HepGeom::Point3D<float>
local;
599 local = HepGeom::Point3D<float>(
r.x(),
r.y(), 0);
602 local = HepGeom::Point3D<float>(-
r.x(),
r.y(), 0);
607 int zside = (
r.z() > 0) ? 1 : -1;
610 <<
" Local " <<
local;
621 edm::LogVerbatim(
"HGCalGeom") <<
"getClosestCell: local " <<
local <<
" Id " <<
id.det <<
":" <<
id.zSide <<
":" 622 <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" <<
id.iType <<
":" 623 <<
id.iCell1 <<
":" <<
id.iCell2;
644 return "HGCalHEFront";
646 return "HGCalHEBack";
658 <<
" index " << cellIndex;
672 return (
nullptr == cell->
param() ? nullptr : cell);
677 return (
nullptr == cell->
param() ? nullptr : cell);
685 static const auto do_not_delete = [](
const void*) {};
687 auto cell = std::shared_ptr<const CaloCellGeometry>(&
m_cellVec2[
index], do_not_delete);
688 if (
nullptr == cell->param())
692 auto cell = std::shared_ptr<const CaloCellGeometry>(&
m_cellVec[
index], do_not_delete);
693 if (
nullptr == cell->param())
707 cell->setPosition(
pos);
711 if (
nullptr == cell->param())
716 cell->setPosition(
pos);
720 if (
nullptr == cell->param())
727 edm::LogError(
"HGCalGeom") <<
"HGCalGeometry::addValidID is not implemented";
736 float phip =
r.phi();
738 float dzmin(9999), dphimin(9999), dphi10(0.175);
739 unsigned int cellIndex = vec.size();
740 for (
unsigned int k = 0;
k < vec.size(); ++
k) {
741 float dphi = phip - vec[
k].phiPos();
744 while (dphi <= -
M_PI)
748 if (
dz < (dzmin + 0.001)) {
750 if (
std::abs(dphi) < (dphimin + 0.01)) {
754 if (cellIndex >= vec.size())
761 edm::LogVerbatim(
"HGCalGeom") <<
"getClosestCellIndex::Input " << zp <<
":" << phip <<
" Index " << cellIndex;
762 if (cellIndex < vec.size())
763 edm::LogVerbatim(
"HGCalGeom") <<
" Cell z " << vec[cellIndex].getPosition().z() <<
":" << dzmin <<
" phi " 764 << vec[cellIndex].phiPos() <<
":" << dphimin;
772 bool operator()(
const DetId&
a,
const DetId&
b) {
return (
a.rawId() <
b.rawId()); }
791 iVector.reserve(numberOfCells);
793 dinsVector.reserve(numberOfCells);
807 dimVector.insert(dimVector.end(),
params.begin(),
params.end());
824 dimVector.insert(dimVector.end(),
params.begin(),
params.end());
834 dimVector.insert(dimVector.end(),
params.begin(),
params.end());
840 for (
unsigned int i(0);
i < numberOfCells; ++
i) {
853 iVector.emplace_back(
layer);
857 if (
nullptr != ptr) {
858 ptr->getTransform(tr, (
Pt3DVec*)
nullptr);
862 tr = HepGeom::Translate3D(
gp.x(),
gp.y(),
gp.z());
865 const CLHEP::Hep3Vector
tt(tr.getTranslation());
866 trVector.emplace_back(
tt.x());
867 trVector.emplace_back(
tt.y());
868 trVector.emplace_back(
tt.z());
870 const CLHEP::HepRotation
rr(tr.getRotation());
871 const ROOT::Math::Transform3D rtr(
872 rr.xx(),
rr.xy(),
rr.xz(),
tt.x(),
rr.yx(),
rr.yy(),
rr.yz(),
tt.y(),
rr.zx(),
rr.zy(),
rr.zz(),
tt.z());
875 trVector.emplace_back(ea.Phi());
876 trVector.emplace_back(ea.Theta());
877 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< 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
constexpr Detector det() const
get the detector field from this detid
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_
CaloCellGeometry::Pt3DVec Pt3DVec
static constexpr double k_fac1
static PlanePointer build(Args &&... args)
bool waferInLayer(int wafer, int lay, bool reco) const
HGCalGeometry(const HGCalTopology &topology)
static constexpr unsigned int ncorner_
std::vector< int > firstModule_
DetId getClosestCell(const GlobalPoint &r) const override
GlobalPoint getPosition(const DetId &id, bool cog, bool debug) const
static constexpr uint32_t k_R
void initializeParms() override
GlobalPoint globalPosition() const
constexpr HGCScintillatorDetId geometryCell() const
static constexpr uint32_t k_r
std::array< int, 5 > assignCellHex(float x, float y, int zside, int lay, bool reco, bool extend, bool debug) const
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
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
bool cellInLayer(int waferU, int waferV, int cellU, int cellV, int lay, int zside, bool reco) const
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
std::pair< int, int > tileType(int layer, int ring, int phi) const
static constexpr uint32_t k_dX4
const HGCalTopology & topology() const
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
HFNoseDetId geometryCell() const
constexpr HGCSiliconDetId geometryCell() const
void localCorners(Pt3DVec &lc, const CCGFloat *pv, unsigned int i, Pt3D &ref)
std::pair< double, double > rangeR(double z, bool reco) const
static constexpr unsigned int k_NumberOfParametersPerHex
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
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.
unsigned int getTrFormN() const
constexpr int32_t layer() const
get the layer #
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
CaloCellGeometry::Pt3D Pt3D
std::shared_ptr< const CaloCellGeometry > cellGeomPtr(uint32_t index) const override
constexpr void setType(int type)
int getLayer(double z, bool reco) const
#define TYPELOOKUP_DATA_REG(_dataclass_)
constexpr int layer() const
get the layer #
static constexpr uint32_t k_dZ
virtual void fillNamedParams(DDFilteredView fv)
constexpr void setSiPM(int sipm)
constexpr int ring() const
get the eta index
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
std::string cellElement() const
std::pair< float, float > localToGlobal8(int zside, int lay, int waferU, int waferV, double localX, double localY, bool reco, bool debug) 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