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)) {
68 const DetId& detId ) {
105 << detId.
rawId() <<
" GeomId " 107 << cellIndex <<
" cells " <<
cells;
112 for (
int cell = 0; cell <
cells; ++cell) {
138 unsigned int cellAll(0), cellSelect(0);
140 for (
int u=0; u<2*
cells; ++u) {
142 if (((
v-u) < cells) && (u-
v) <= cells) {
143 id.iCell1 = u;
id.iCell2 =
v;
162 <<
" out of " << cellAll <<
" for wafer " 163 <<
id.iSec1 <<
":" <<
id.iSec2 <<
" in " 164 <<
" layer " <<
id.iLay;
170 <<
"]" <<
" front:" << f1.
x() <<
'/' 171 << f1.
y() <<
'/' << f1.
z() <<
" back:" 172 << f2.
x() <<
'/' << f2.
y() <<
'/' << f2.
z()
178 <<
"]" <<
" front:" << f1.
x() <<
'/' 179 << f1.
y() <<
'/' << f1.
z() <<
" back:" 180 << f2.
x() <<
'/' << f2.
y() <<
'/' << f2.
z()
189 <<
" with valid DetId from " << nOld
193 <<
" with valid DetId from " << nOld
197 <<
" with valid DetId from " << nOld
201 <<
" with valid DetId from " << nOld
205 << geomId.
rawId() <<
":" 212 if (detId ==
DetId())
return nullptr;
221 if (detId ==
DetId())
return false;
229 unsigned int cellIndex =
indexFor(detid);
233 if (cellIndex < maxSize) {
235 std::pair<float,float>
xy;
239 const HepGeom::Point3D<float> lcoord(xy.first,xy.second,0);
240 glob =
m_cellVec[cellIndex].getPosition(lcoord);
243 <<
" Local " << lcoord.x() <<
":" 244 << lcoord.y() <<
" ID " <<
id.iCell1
245 <<
":" <<
id.iSec1 <<
" Global " << glob;
248 const HepGeom::Point3D<float> lcoord(0,0,0);
249 glob =
m_cellVec2[cellIndex].getPosition(lcoord);
252 <<
" Local " << lcoord.x() <<
":" 253 << lcoord.y() <<
" ID " <<
id.iLay <<
":" 254 <<
id.iSec1 <<
":" <<
id.iCell1
255 <<
" Global " << glob;
259 id.iCell1,
id.iCell2,
true,
false);
260 const HepGeom::Point3D<float> lcoord(xy.first,xy.second,0);
261 glob =
m_cellVec[cellIndex].getPosition(lcoord);
264 <<
" Local " << lcoord.x() <<
":" 265 << lcoord.y() <<
" ID " <<
id.iLay <<
":" 266 <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" 267 <<
id.iCell1 <<
":" <<
id.iCell2
268 <<
" Global " << glob;
279 if (corners.size() > 1) {
280 int n = corners.size()-1;
282 for (
int i=0;
i<
n; ++
i) {
283 area += ((corners[j].x()+corners[
i].x())*
284 (corners[
i].
y()-corners[j].y()));
296 unsigned int cellIndex =
indexFor(detid);
301 float dr =
k_half*(rr.second-rr.first);
306 static const int signr[] = {1,1,-1,-1,1,1,-1,-1};
307 static const int signf[] = {-1,1,1,-1,-1,1,1,-1};
308 static const int signz[] = {-1,-1,-1,-1,1,1,1,1};
309 for (
unsigned int i = 0;
i < ncorner; ++
i) {
311 (r+signr[
i]*dr)*
sin(fi+signf[
i]*dfi),
312 (v.
z()+signz[
i]*
dz));
315 std::pair<float,float>
xy;
322 static const int signx[] = {0,-1,-1,0,1,1,0,-1,-1,0,1,1};
323 static const int signy[] = {-2,-1,1,2,1,-1,-2,-1,1,2,1,-1};
324 static const int signz[] = {-1,-1,-1,-1,-1,-1,1,1,1,1,1,1};
325 for (
unsigned int i = 0;
i < ncorner; ++
i) {
326 const HepGeom::Point3D<float> lcoord(xy.first+signx[
i]*dx,xy.second+signy[
i]*dy,signz[
i]*dz);
327 co[
i] =
m_cellVec[cellIndex].getPosition(lcoord);
331 id.iCell1,
id.iCell2,
true,
false);
335 static const int signx[] = {1,-1,-2,-1, 1,2,1,-1,-2,-1, 1,2};
336 static const int signy[] = {1, 1, 0,-1,-1,0,1, 1, 0,-1,-1,0};
337 static const int signz[] = {-1,-1,-1,-1,-1,-1,1,1,1,1,1,1};
338 for (
unsigned int i = 0;
i < ncorner; ++
i) {
339 const HepGeom::Point3D<float> lcoord(xy.first+signx[
i]*dx,xy.second+signy[
i]*dy,signz[
i]*dz);
340 co[
i] =
m_cellVec[cellIndex].getPosition(lcoord);
351 unsigned int cellIndex =
indexFor(detid);
356 float dr =
k_half*(rr.second-rr.first);
361 static const int signr[] = {1,1,-1,-1,1,1,-1,-1};
362 static const int signf[] = {-1,1,1,-1,-1,1,1,-1};
363 static const int signz[] = {-1,-1,-1,-1,1,1,1,1};
364 for (
unsigned int i = 0;
i < ncorner; ++
i) {
366 (r+signr[
i]*dr)*
sin(fi+signf[
i]*dfi),
367 (v.
z()+signz[
i]*
dz));
370 std::pair<float,float>
xy;
378 id.iCell1,
id.iCell2,
true,
false);
381 static const int signx[] = {-1,-1,1,1,-1,-1,1,1};
382 static const int signy[] = {-1,1,1,-1,-1,1,1,-1};
383 static const int signz[] = {-1,-1,-1,-1,1,1,1,1};
385 for (
unsigned int i = 0;
i < ncorner; ++
i) {
386 const HepGeom::Point3D<float> lcoord(xy.first+signx[
i]*dx,
387 xy.second+signy[
i]*dx,signz[
i]*dz);
388 co[
i] =
m_cellVec[cellIndex].getPosition(lcoord);
398 unsigned int cellIndex =
indexFor(detid);
403 float dr =
k_half*(rr.second-rr.first);
408 static const int signr[] = {1,1,-1,-1};
409 static const int signf[] = {-1,1,1,-1};
410 for (
unsigned int i = 0;
i < ncorner-1; ++
i) {
412 (r+signr[
i]*dr)*
sin(fi+signf[
i]*dfi),
417 std::pair<float,float>
xy;
423 id.iCell1,
id.iCell2,
true,
false);
428 static const int signx[] = {1,-1,-2,-1, 1,2};
429 static const int signy[] = {1, 1, 0,-1,-1,0};
430 for (
unsigned int i = 0;
i < ncorner-1; ++
i) {
431 const HepGeom::Point3D<float> lcoord(xy.first+signx[
i]*dx,xy.second+signy[
i]*dy,dz);
432 co[
i] =
m_cellVec[cellIndex].getPosition(lcoord);
443 int lay = ((momentum.
z()*
id.zSide > 0) ? (
id.iLay+1) : (
id.iLay-1));
446 <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" 447 <<
id.iCell1 <<
":" <<
id.iCell2
448 <<
" New Layer " << lay <<
" Range " 451 <<
" pz " << momentum.
z();
455 (momentum.
z() != 0.0)) {
458 double grad = (z - v.
z())/momentum.
z();
462 if (r >= rlimit.first && r <= rlimit.second) idnew =
getClosestCell(
p);
465 << z <<
":" << grad <<
" new position " <<
p 466 <<
" r-limit " << rlimit.first <<
":" 478 int lay = ((momentum.
z()*
id.zSide > 0) ? (
id.iLay+1) : (
id.iLay-1));
481 <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" 482 <<
id.iCell1 <<
":" <<
id.iCell2
483 <<
" New Layer " << lay <<
" Range " 486 <<
" pz " << momentum.
z();
490 (momentum.
z() != 0.0)) {
503 if (r >= rlimit.first && r <= rlimit.second) idnew =
getClosestCell(p);
507 << z <<
":" << charge <<
":" << tsos.
isValid()
508 <<
" new position " << p <<
" r limits " 509 << rlimit.first <<
":" << rlimit.second;
520 HepGeom::Point3D<float>
local;
522 local = HepGeom::Point3D<float>(r.
x(),r.
y(),0);
525 local = HepGeom::Point3D<float>(-r.
x(),r.
y(),0);
533 id.iCell1 = kxy.second;
534 id.iSec1 = kxy.first;
536 if (
id.iType != 1)
id.iType = -1;
550 id.iSec1 = kxy[0];
id.iSec2 = kxy[1];
id.iType = kxy[2];
551 id.iCell1 = kxy[3];
id.iCell2 = kxy[4];
555 <<
" Id " <<
id.zSide <<
":" <<
id.iLay
556 <<
":" <<
id.iSec1 <<
":" <<
id.iSec2
557 <<
":" <<
id.iType <<
":" <<
id.iCell1
578 else return "Unknown";
584 if (detId !=
DetId()) {
590 <<
" index " << cellIndex;
605 return (
nullptr == cell->
param() ?
nullptr : cell);
609 return (
nullptr == cell->
param() ?
nullptr : cell);
617 static const auto do_not_delete = [](
const void*){};
619 auto cell = std::shared_ptr<const CaloCellGeometry>(&
m_cellVec2[
index],do_not_delete);
620 if (
nullptr == cell->param())
return nullptr;
623 auto cell = std::shared_ptr<const CaloCellGeometry>(&
m_cellVec[
index],do_not_delete);
624 if (
nullptr == cell->param())
return nullptr;
636 cell->setPosition(pos);
640 if (
nullptr == cell->param())
return nullptr;
644 cell->setPosition(pos);
648 if (
nullptr == cell->param())
return nullptr;
654 edm::LogError(
"HGCalGeom") <<
"HGCalGeometry::addValidID is not implemented";
664 const std::vector<T>& vec)
const {
666 float phip = r.
phi();
668 float dzmin(9999), dphimin(9999), dphi10(0.175);
669 unsigned int cellIndex = vec.size();
670 for (
unsigned int k=0;
k<vec.size(); ++
k) {
671 float dphi = phip-vec[
k].phiPos();
673 while (dphi <= -
M_PI) dphi += 2*
M_PI;
676 if (dz < (dzmin+0.001)) {
678 if (
std::abs(dphi) < (dphimin+0.01)) {
682 if (cellIndex >= vec.size()) cellIndex =
k;
689 << phip <<
" Index " << cellIndex;
690 if (cellIndex < vec.size())
692 << vec[cellIndex].getPosition().z()
693 <<
":" << dzmin <<
" phi " 694 << vec[cellIndex].phiPos() <<
":" << dphimin;
726 iVector.reserve( numberOfCells );
727 dimVector.reserve( numberOfShapes * numberOfParametersPerShape );
728 dinsVector.reserve( numberOfCells );
732 int layer = mytr.
lay;
739 ParmVec params( numberOfParametersPerShape, 0 );
743 dimVector.insert( dimVector.end(), params.begin(), params.end());
752 ParmVec params( numberOfParametersPerShape, 0 );
760 dimVector.insert( dimVector.end(), params.begin(), params.end());
766 ParmVec params( numberOfParametersPerShape, 0 );
770 dimVector.insert( dimVector.end(), params.begin(), params.end());
776 for (
unsigned int i( 0 );
i < numberOfCells; ++
i) {
790 iVector.emplace_back( layer );
794 if (
nullptr != ptr ) {
795 ptr->getTransform( tr, (
Pt3DVec* )
nullptr );
799 tr = HepGeom::Translate3D(
gp.x(),
gp.y(),
gp.z());
802 const CLHEP::Hep3Vector
tt( tr.getTranslation());
803 trVector.emplace_back(
tt.x());
804 trVector.emplace_back(
tt.y());
805 trVector.emplace_back(
tt.z());
807 const CLHEP::HepRotation
rr( tr.getRotation());
808 const ROOT::Math::Transform3D rtr(
rr.xx(),
rr.xy(),
rr.xz(),
tt.x(),
812 rtr.GetRotation( ea );
813 trVector.emplace_back( ea.Phi());
814 trVector.emplace_back( ea.Theta());
815 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