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;
280 unsigned int cellIndex =
indexFor(detid);
285 float dr = 0.5*(rr.second-rr.first);
290 static const int signr[] = {1,1,-1,-1,1,1,-1,-1};
291 static const int signf[] = {-1,1,1,-1,-1,1,1,-1};
292 static const int signz[] = {-1,-1,-1,-1,1,1,1,1};
293 for (
unsigned int i = 0;
i < ncorner; ++
i) {
295 (r+signr[
i]*dr)*
sin(fi+signf[
i]*dfi),
296 (v.
z()+signz[
i]*
dz));
299 std::pair<float,float>
xy;
305 id.iCell1,
id.iCell2,
true,
false);
310 static const int signx[] = {0,-1,-1,0,1,1,0,-1,-1,0,1,1};
311 static const int signy[] = {-2,-1,1,2,1,-1,-2,-1,1,2,1,-1};
312 static const int signz[] = {-1,-1,-1,-1,-1,-1,1,1,1,1,1,1};
313 for (
unsigned int i = 0;
i < ncorner; ++
i) {
314 const HepGeom::Point3D<float> lcoord(xy.first+signx[
i]*dx,xy.second+signy[
i]*dy,signz[
i]*dz);
315 co[
i] =
m_cellVec[cellIndex].getPosition(lcoord);
325 unsigned int cellIndex =
indexFor(detid);
330 float dr = 0.5*(rr.second-rr.first);
335 static const int signr[] = {1,1,-1,-1,1,1,-1,-1};
336 static const int signf[] = {-1,1,1,-1,-1,1,1,-1};
337 static const int signz[] = {-1,-1,-1,-1,1,1,1,1};
338 for (
unsigned int i = 0;
i < ncorner; ++
i) {
340 (r+signr[
i]*dr)*
sin(fi+signf[
i]*dfi),
341 (v.
z()+signz[
i]*
dz));
344 std::pair<float,float>
xy;
350 id.iCell1,
id.iCell2,
true,
false);
352 static const int signx[] = {-1,-1,1,1,-1,-1,1,1};
353 static const int signy[] = {-1,1,1,-1,-1,1,1,-1};
354 static const int signz[] = {-1,-1,-1,-1,1,1,1,1};
357 for (
unsigned int i = 0;
i < ncorner; ++
i) {
358 const HepGeom::Point3D<float> lcoord(xy.first+signx[
i]*dx,
359 xy.second+signy[
i]*dx,signz[
i]*dz);
360 co[
i] =
m_cellVec[cellIndex].getPosition(lcoord);
370 unsigned int cellIndex =
indexFor(detid);
375 float dr = 0.5*(rr.second-rr.first);
380 static const int signr[] = {1,1,-1,-1};
381 static const int signf[] = {-1,1,1,-1};
382 for (
unsigned int i = 0;
i < ncorner-1; ++
i) {
384 (r+signr[
i]*dr)*
sin(fi+signf[
i]*dfi),
389 std::pair<float,float>
xy;
395 id.iCell1,
id.iCell2,
true,
false);
400 static const int signx[] = {0,-1,-1,0,1,1};
401 static const int signy[] = {-2,-1,1,2,1,-1};
402 for (
unsigned int i = 0;
i < ncorner-1; ++
i) {
403 const HepGeom::Point3D<float> lcoord(xy.first+signx[
i]*dx,xy.second+signy[
i]*dy,dz);
404 co[
i] =
m_cellVec[cellIndex].getPosition(lcoord);
415 int lay = ((momentum.
z()*
id.zSide > 0) ? (
id.iLay+1) : (
id.iLay-1));
418 <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" 419 <<
id.iCell1 <<
":" <<
id.iCell2
420 <<
" New Layer " << lay <<
" Range " 423 <<
" pz " << momentum.
z();
427 (momentum.
z() != 0.0)) {
430 double grad = (z - v.
z())/momentum.
z();
435 << z <<
":" << grad <<
" new position " <<
r;
446 int lay = ((momentum.
z()*
id.zSide > 0) ? (
id.iLay+1) : (
id.iLay-1));
449 <<
id.iSec1 <<
":" <<
id.iSec2 <<
":" 450 <<
id.iCell1 <<
":" <<
id.iCell2
451 <<
" New Layer " << lay <<
" Range " 454 <<
" pz " << momentum.
z();
458 (momentum.
z() != 0.0)) {
473 << z <<
":" << charge <<
":" << tsos.
isValid()
474 <<
" new position " <<
r;
485 HepGeom::Point3D<float>
local;
487 local = HepGeom::Point3D<float>(r.
x(),r.
y(),0);
490 local = HepGeom::Point3D<float>(-r.
x(),r.
y(),0);
498 id.iCell1 = kxy.second;
499 id.iSec1 = kxy.first;
501 if (
id.iType != 1)
id.iType = -1;
515 id.iSec1 = kxy[0];
id.iSec2 = kxy[1];
id.iType = kxy[2];
516 id.iCell1 = kxy[3];
id.iCell2 = kxy[4];
520 <<
" Id " <<
id.zSide <<
":" <<
id.iLay
521 <<
":" <<
id.iSec1 <<
":" <<
id.iSec2
522 <<
":" <<
id.iType <<
":" <<
id.iCell1
543 else return "Unknown";
549 if (detId !=
DetId()) {
555 <<
" index " << cellIndex;
570 return (
nullptr == cell->
param() ?
nullptr : cell);
574 return (
nullptr == cell->
param() ?
nullptr : cell);
582 static const auto do_not_delete = [](
const void*){};
584 auto cell = std::shared_ptr<const CaloCellGeometry>(&
m_cellVec2[
index],do_not_delete);
585 if (
nullptr == cell->param())
return nullptr;
588 auto cell = std::shared_ptr<const CaloCellGeometry>(&
m_cellVec[
index],do_not_delete);
589 if (
nullptr == cell->param())
return nullptr;
601 cell->setPosition(pos);
605 if (
nullptr == cell->param())
return nullptr;
609 cell->setPosition(pos);
613 if (
nullptr == cell->param())
return nullptr;
619 edm::LogError(
"HGCalGeom") <<
"HGCalGeometry::addValidID is not implemented";
629 const std::vector<T>& vec)
const {
631 float phip = r.
phi();
633 float dzmin(9999), dphimin(9999), dphi10(0.175);
634 unsigned int cellIndex = vec.size();
635 for (
unsigned int k=0;
k<vec.size(); ++
k) {
636 float dphi = phip-vec[
k].phiPos();
638 while (dphi <= -
M_PI) dphi += 2*
M_PI;
641 if (dz < (dzmin+0.001)) {
643 if (
std::abs(dphi) < (dphimin+0.01)) {
647 if (cellIndex >= vec.size()) cellIndex =
k;
654 << phip <<
" Index " << cellIndex;
655 if (cellIndex < vec.size())
657 << vec[cellIndex].getPosition().z()
658 <<
":" << dzmin <<
" phi " 659 << vec[cellIndex].phiPos() <<
":" << dphimin;
691 iVector.reserve( numberOfCells );
692 dimVector.reserve( numberOfShapes * numberOfParametersPerShape );
693 dinsVector.reserve( numberOfCells );
697 int layer = mytr.
lay;
704 ParmVec params( numberOfParametersPerShape, 0 );
708 dimVector.insert( dimVector.end(), params.begin(), params.end());
717 ParmVec params( numberOfParametersPerShape, 0 );
725 dimVector.insert( dimVector.end(), params.begin(), params.end());
731 ParmVec params( numberOfParametersPerShape, 0 );
735 dimVector.insert( dimVector.end(), params.begin(), params.end());
741 for (
unsigned int i( 0 );
i < numberOfCells; ++
i) {
755 iVector.emplace_back( layer );
759 if (
nullptr != ptr ) {
760 ptr->getTransform( tr, (
Pt3DVec* )
nullptr );
764 tr = HepGeom::Translate3D(
gp.x(),
gp.y(),
gp.z());
767 const CLHEP::Hep3Vector
tt( tr.getTranslation());
768 trVector.emplace_back(
tt.x());
769 trVector.emplace_back(
tt.y());
770 trVector.emplace_back(
tt.z());
772 const CLHEP::HepRotation
rr( tr.getRotation());
773 const ROOT::Math::Transform3D rtr(
rr.xx(),
rr.xy(),
rr.xz(),
tt.x(),
777 rtr.GetRotation( ea );
778 trVector.emplace_back( ea.Phi());
779 trVector.emplace_back( ea.Theta());
780 trVector.emplace_back( ea.Psi());
std::vector< DetId > m_validGeomIds
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::pair< double, double > cellSizeTrap(int type, int irad) 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
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
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)
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