18 #include <Math/Transform3D.h> 19 #include <Math/EulerAngles.h> 27 : m_topology(topology_),
28 m_validGeomIds(topology_.totalGeomModules()),
30 m_subdet(topology_.subDetector()),
31 twoBysqrt3_(2.0 /
std::
sqrt(3.0)) {
68 for (
int cell = 0; cell <
cells; ++cell) {
79 edm::LogVerbatim(
"HGCalGeom") <<
"HGCalTBGeometry::newCell-> [" << cellIndex <<
"]" 80 <<
" front:" <<
f1.x() <<
'/' <<
f1.y() <<
'/' <<
f1.z() <<
" back:" <<
f2.x() <<
'/' 81 <<
f2.y() <<
'/' <<
f2.z() <<
" eta|phi " <<
m_cellVec[cellIndex].etaPos() <<
":" 106 unsigned int cellIndex =
indexFor(detid);
111 std::pair<float, float>
xy;
113 const HepGeom::Point3D<float> lcoord(
xy.first,
xy.second, 0);
114 glob =
m_cellVec[cellIndex].getPosition(lcoord);
116 edm::LogVerbatim(
"HGCalGeom") <<
"getPosition:: index " << cellIndex <<
" Local " << lcoord.x() <<
":" 117 << lcoord.y() <<
" ID " <<
id.iCell1 <<
":" <<
id.iSec1 <<
" Global " << glob;
123 unsigned int cellIndex =
indexFor(detid);
127 const HepGeom::Point3D<float> lcoord(0, 0, 0);
128 glob =
m_cellVec[cellIndex].getPosition(lcoord);
131 << cellIndex <<
" Global " << glob;
140 if (corners.size() > 1) {
141 int n = corners.size() - 1;
143 for (
int i = 0;
i <
n; ++
i) {
144 area += ((corners[
j].x() + corners[
i].x()) * (corners[
i].
y() - corners[
j].y()));
154 unsigned int cellIndex =
indexFor(detid);
157 std::pair<float, float>
xy;
162 static const int signx[] = {0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1};
163 static const int signy[] = {-2, -1, 1, 2, 1, -1, -2, -1, 1, 2, 1, -1};
164 static const int signz[] = {-1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1};
165 for (
unsigned int i = 0;
i < ncorner; ++
i) {
166 const HepGeom::Point3D<float> lcoord(
xy.first + signx[
i] *
dx,
xy.second + signy[
i] *
dy, signz[
i] *
dz);
176 unsigned int cellIndex =
indexFor(detid);
179 std::pair<float, float>
xy;
181 static const int signx[] = {-1, -1, 1, 1, -1, -1, 1, 1};
182 static const int signy[] = {-1, 1, 1, -1, -1, 1, 1, -1};
183 static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
187 for (
unsigned int i = 0;
i < ncorner; ++
i) {
188 const HepGeom::Point3D<float> lcoord(
xy.first + signx[
i] *
dx,
xy.second + signy[
i] *
dx, signz[
i] *
dz);
198 unsigned int cellIndex =
indexFor(detid);
201 edm::LogVerbatim(
"HGCalGeom") <<
"NewCorners for Layer " <<
id.iLay <<
" Wafer " <<
id.iSec1 <<
":" <<
id.iSec2
202 <<
" Cell " <<
id.iCell1 <<
":" <<
id.iCell2;
204 std::pair<float, float>
xy;
208 static const int signx[] = {1, -1, -2, -1, 1, 2};
209 static const int signy[] = {1, 1, 0, -1, -1, 0};
216 for (
unsigned int i = 0;
i < ncorner - 1; ++
i) {
217 const HepGeom::Point3D<float> lcoord(
xy.first + signx[
i] *
dx,
xy.second + signy[
i] *
dy,
dz);
229 int lay = ((momentum.
z() *
id.zSide > 0) ? (
id.iLay + 1) : (
id.iLay - 1));
231 edm::LogVerbatim(
"HGCalGeom") <<
"neighborz1:: ID " <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" 232 <<
id.iCell1 <<
":" <<
id.iCell2 <<
" New Layer " << lay <<
" Range " 237 (momentum.
z() != 0.0)) {
240 double grad = (
z -
v.z()) / momentum.
z();
244 if (
r >= rlimit.first &&
r <= rlimit.second)
247 edm::LogVerbatim(
"HGCalGeom") <<
"neighborz1:: Position " <<
v <<
" New Z " <<
z <<
":" << grad <<
" new position " 248 <<
p <<
" r-limit " << rlimit.first <<
":" << rlimit.second;
260 int lay = ((momentum.
z() *
id.zSide > 0) ? (
id.iLay + 1) : (
id.iLay - 1));
262 edm::LogVerbatim(
"HGCalGeom") <<
"neighborz2:: ID " <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" 263 <<
id.iCell1 <<
":" <<
id.iCell2 <<
" New Layer " << lay <<
" Range " 268 (momentum.
z() != 0.0)) {
280 if (
r >= rlimit.first &&
r <= rlimit.second)
285 << tsos.
isValid() <<
" new position " <<
p <<
" r limits " << rlimit.first <<
":" 298 HepGeom::Point3D<float>
local;
300 local = HepGeom::Point3D<float>(
r.x(),
r.y(), 0);
303 local = HepGeom::Point3D<float>(-
r.x(),
r.y(), 0);
307 id.iCell1 = kxy.second;
308 id.iSec1 = kxy.first;
313 edm::LogVerbatim(
"HGCalGeom") <<
"getClosestCell: local " <<
local <<
" Id " <<
id.det <<
":" <<
id.zSide <<
":" 314 <<
id.iLay <<
":" <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" <<
id.iType <<
":" 315 <<
id.iCell1 <<
":" <<
id.iCell2;
335 return "HGCalHEFront";
341 unsigned int cellIndex =
m_cellVec.size();
347 <<
" index " << cellIndex;
360 return (
nullptr == cell->
param() ? nullptr : cell);
366 static const auto do_not_delete = [](
const void*) {};
367 auto cell = std::shared_ptr<const CaloCellGeometry>(&
m_cellVec[
index], do_not_delete);
368 if (
nullptr == cell->param())
379 cell->setPosition(
pos);
383 if (
nullptr == cell->param())
389 edm::LogError(
"HGCalGeom") <<
"HGCalTBGeometry::addValidID is not implemented";
398 float phip =
r.phi();
400 float dzmin(9999), dphimin(9999), dphi10(0.175);
401 unsigned int cellIndex = vec.size();
402 for (
unsigned int k = 0;
k < vec.size(); ++
k) {
403 float dphi = phip - vec[
k].phiPos();
406 while (dphi <= -
M_PI)
410 if (
dz < (dzmin + 0.001)) {
412 if (
std::abs(dphi) < (dphimin + 0.01)) {
416 if (cellIndex >= vec.size())
423 edm::LogVerbatim(
"HGCalGeom") <<
"getClosestCellIndex::Input " << zp <<
":" << phip <<
" Index " << cellIndex;
424 if (cellIndex < vec.size())
425 edm::LogVerbatim(
"HGCalGeom") <<
" Cell z " << vec[cellIndex].getPosition().z() <<
":" << dzmin <<
" phi " 426 << vec[cellIndex].phiPos() <<
":" << dphimin;
434 bool operator()(
const DetId&
a,
const DetId&
b) {
return (
a.rawId() <
b.rawId()); }
453 iVector.reserve(numberOfCells);
455 dinsVector.reserve(numberOfCells);
468 dimVector.insert(dimVector.end(),
params.begin(),
params.end());
473 for (
unsigned int i(0);
i < numberOfCells; ++
i) {
477 iVector.emplace_back(
layer);
481 if (
nullptr != ptr) {
482 ptr->getTransform(tr, (
Pt3DVec*)
nullptr);
486 tr = HepGeom::Translate3D(
gp.x(),
gp.y(),
gp.z());
489 const CLHEP::Hep3Vector
tt(tr.getTranslation());
490 trVector.emplace_back(
tt.x());
491 trVector.emplace_back(
tt.y());
492 trVector.emplace_back(
tt.z());
494 const CLHEP::HepRotation
rr(tr.getRotation());
495 const ROOT::Math::Transform3D rtr(
496 rr.xx(),
rr.xy(),
rr.xz(),
tt.x(),
rr.yx(),
rr.yy(),
rr.yz(),
tt.y(),
rr.zx(),
rr.zy(),
rr.zz(),
tt.z());
499 trVector.emplace_back(ea.Phi());
500 trVector.emplace_back(ea.Theta());
501 trVector.emplace_back(ea.Psi());
CornersVec getNewCorners(const DetId &id, bool debug=false) const
unsigned int totalGeomModules() const
Log< level::Info, true > LogVerbatim
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
CaloCellGeometry::Pt3DVec Pt3DVec
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::vector< CCGFloat > DimVec
static constexpr unsigned int k_NumberOfParametersPerHex
const CaloCellGeometry * getGeometryRawPtr(uint32_t index) const override
std::pair< int, int > assignCell(float x, float y, int lay, int subSec, bool reco) const
bool waferInLayer(int wafer, int lay, bool reco) const
double getArea(const DetId &detid) const
Returns area of a cell.
int lastLayer(bool reco) const
static constexpr double k_fac1
virtual unsigned int numberOfTransformParms() const
DetId encode(const DecodedDetId &id_) const
unsigned int getClosestCellIndex(const GlobalPoint &r) const
static constexpr double k_half
Global3DPoint GlobalPoint
std::vector< unsigned int > IVec
int numberCellsHexagon(int wafer) const
void newCell(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId) override
double waferZ(int layer, bool reco) const
std::vector< CCGFloat > TrVec
std::pair< float, float > locateCellHex(int cell, int wafer, bool reco) const
HepGeom::Transform3D Tr3D
virtual unsigned int numberOfShapes() const
std::vector< GlobalPoint > CornersVec
Log< level::Error, false > LogError
__host__ __device__ VT * co
CaloCellGeometry::CCGFloat CCGFloat
static constexpr unsigned int k_NumberOfParametersPerTrd
ForwardSubdetector m_subdet
HGCalDetId geometryCell() const
static constexpr double k_fac2
std::pair< double, double > rangeR(double z, bool reco) const
std::vector< float > ParmVec
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
static constexpr unsigned int ncorner_
int waferTypeT(int wafer) const
static PlanePointer build(Args &&... args)
void addValidID(const DetId &id)
static constexpr unsigned int ncorner_
static constexpr uint32_t k_R
DetId getClosestCell(const GlobalPoint &r) const override
GlobalPoint globalPosition() const
static constexpr uint32_t k_r
std::set< DetId > DetIdSet
std::string cellElement() const
std::vector< float > ParmVec
std::vector< DetId > m_validIds
A base class to handle the hexagonal shape of HGCal silicon volumes.
Abs< T >::type abs(const T &t)
DetId getGeometryDetId(DetId detId) const
CaloCellGeometry::Pt3D Pt3D
HGCalTBGeometry(const HGCalTBTopology &topology)
DetIdSet getCells(const GlobalPoint &r, double dR) const override
Get a list of all cells within a dR of the given cell.
std::shared_ptr< const CaloCellGeometry > cellGeomPtr(uint32_t index) const override
DecodedDetId decode(const DetId &id) const
AlgebraicVector EulerAngles
unsigned int getTrFormN() const
const HGCalTBDDDConstants & dddConstants() const
HGCalTBParameters::hgtrap getModule(unsigned int k, bool hexType, bool reco) const
std::vector< FlatHexagon > CellVec
static constexpr uint32_t k_dZ
virtual void fillNamedParams(DDFilteredView fv)
constexpr uint32_t rawId() const
get the raw id
CornersVec get8Corners(const DetId &id) const
CaloCellGeometry::CornersMgr * cornersMgr()
const HGCalTBTopology & topology() const
bool valid(const DetId &id) const override
Is this a valid cell id.
int layer() const
get the layer #
virtual uint32_t detId2denseGeomId(const DetId &id) const
~HGCalTBGeometry() override
const HGCalTBTopology & m_topology
unsigned int totalModules() const
GlobalPoint getPosition(const DetId &id, bool debug=false) const
CaloCellGeometry::Tr3D Tr3D
CaloCellGeometry::Tr3D Tr3D
CornersVec getCorners(const DetId &id) const
Returns the corner points of this cell's volume.
std::vector< DetId > m_validGeomIds
#define TYPELOOKUP_DATA_REG(_dataclass_)
unsigned int indexFor(const DetId &id) const override
GlobalPoint getWaferPosition(const DetId &id) const
void initializeParms() override
DetId neighborZ(const DetId &idin, const GlobalVector &p) const
static constexpr unsigned int k_NumberOfShapes
bool present(const DetId &id) const override
is this detid present in the geometry?
unsigned int sizeForDenseIndex() const
HGCalTBParameters::hgtrform getTrForm(unsigned int k) const
const CCGFloat * param() const
void getSummary(CaloSubdetectorGeometry::TrVec &trVector, CaloSubdetectorGeometry::IVec &iVector, CaloSubdetectorGeometry::DimVec &dimVector, CaloSubdetectorGeometry::IVec &dinsVector) const override
void localCorners(Pt3DVec &lc, const CCGFloat *pv, unsigned int i, Pt3D &ref)
DetId::Detector detector() const
virtual unsigned int numberOfParametersPerShape() const