15 #include <Math/Transform3D.h> 16 #include <Math/EulerAngles.h> 24 : m_topology( topology_ ),
25 m_validGeomIds( topology_.totalGeomModules()),
26 mode_( topology_.geomMode()),
28 m_subdet( topology_.subDetector()),
29 twoBysqrt3_(2.0/
std::
sqrt(3.0)) {
65 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) {
141 for (
int v=0;
v<2*cells; ++
v) {
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 << geomId.
rawId() <<
":" 208 if (
id ==
DetId())
return nullptr;
225 if (
id ==
DetId())
return false;
241 unsigned int cellIndex =
indexFor(
id);
245 if (cellIndex < maxSize) {
247 std::pair<float,float>
xy;
251 const HepGeom::Point3D<float> lcoord(xy.first,xy.second,0);
252 glob =
m_cellVec[cellIndex].getPosition(lcoord);
255 <<
" Local " << lcoord.x() <<
":" 256 << lcoord.y() <<
" ID " << id_.
iCell1 257 <<
":" << id_.
iSec1 <<
" Global " << glob;
260 const HepGeom::Point3D<float> lcoord(0,0,0);
261 glob =
m_cellVec2[cellIndex].getPosition(lcoord);
264 <<
" Local " << lcoord.x() <<
":" 265 << lcoord.y() <<
" ID " << id_.
iLay <<
":" 267 <<
" Global " << glob;
272 const HepGeom::Point3D<float> lcoord(xy.first,xy.second,0);
273 glob =
m_cellVec[cellIndex].getPosition(lcoord);
276 <<
" Local " << lcoord.x() <<
":" 277 << lcoord.y() <<
" ID " << id_.
iLay <<
":" 280 <<
" Global " << glob;
292 unsigned int cellIndex =
indexFor(
id);
296 std::pair<float,float>
xy;
310 static const int signx[] = {-1,-1,1,1,-1,-1,1,1};
311 static const int signy[] = {-1,1,1,-1,-1,1,1,-1};
312 static const int signz[] = {-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]*dx,signz[
i]*dz);
321 static const int signx[] = {0,-1,-1,0,1,1,0,-1,-1,0,1,1};
322 static const int signy[] = {-2,-1,1,2,1,-1,-2,-1,1,2,1,-1};
323 static const int signz[] = {-1,-1,-1,-1,-1,-1,1,1,1,1,1,1};
324 for (
unsigned int i = 0;
i != ncorner; ++
i) {
325 const HepGeom::Point3D<float> lcoord(xy.first+signx[
i]*dx,xy.second+signy[
i]*dy,signz[
i]*dz);
326 co[
i] =
m_cellVec[cellIndex].getPosition(lcoord);
338 HepGeom::Point3D<float>
local;
340 local = HepGeom::Point3D<float>(r.
x(),r.
y(),0);
343 local = HepGeom::Point3D<float>(-r.
x(),r.
y(),0);
352 id_.
iSec1 = kxy.first;
373 <<
" Id " << id_.
zSide <<
":" << id_.
iLay 396 else return "Unknown";
416 <<
" index " << cellIndex;
431 return (
nullptr == cell->
param() ?
nullptr : cell);
435 return (
nullptr == cell->
param() ?
nullptr : cell);
443 static const auto do_not_delete = [](
const void*){};
445 auto cell = std::shared_ptr<const CaloCellGeometry>(&
m_cellVec2[
index],do_not_delete);
446 if (
nullptr == cell->param())
return nullptr;
449 auto cell = std::shared_ptr<const CaloCellGeometry>(&
m_cellVec[
index],do_not_delete);
450 if (
nullptr == cell->param())
return nullptr;
462 cell->setPosition(pos);
466 if (
nullptr == cell->param())
return nullptr;
470 cell->setPosition(pos);
474 if (
nullptr == cell->param())
return nullptr;
480 edm::LogError(
"HGCalGeom") <<
"HGCalGeometry::addValidID is not implemented";
490 const std::vector<T>& vec)
const {
492 float phip = r.
phi();
494 float dzmin(9999), dphimin(9999), dphi10(0.175);
495 unsigned int cellIndex = vec.size();
496 for (
unsigned int k=0;
k<vec.size(); ++
k) {
497 float dphi = phip-vec[
k].phiPos();
499 while (dphi <= -
M_PI) dphi += 2*
M_PI;
502 if (dz < (dzmin+0.001)) {
504 if (
std::abs(dphi) < (dphimin+0.01)) {
508 if (cellIndex >= vec.size()) cellIndex =
k;
515 << phip <<
" Index " << cellIndex;
516 if (cellIndex < vec.size())
518 << vec[cellIndex].getPosition().z()
519 <<
":" << dzmin <<
" phi " 520 << vec[cellIndex].phiPos() <<
":" << dphimin;
552 iVector.reserve( numberOfCells );
553 dimVector.reserve( numberOfShapes * numberOfParametersPerShape );
554 dinsVector.reserve( numberOfCells );
558 int layer = mytr.
lay;
565 ParmVec params( numberOfParametersPerShape, 0 );
569 dimVector.insert( dimVector.end(), params.begin(), params.end());
578 ParmVec params( numberOfParametersPerShape, 0 );
579 params[1] = params[2] = 0;
580 params[3] = params[7] = vol.
h;
581 params[4] = params[8] = vol.
bl;
582 params[5] = params[9] = vol.
tl;
583 params[6] = params[10]= vol.
alpha;
585 dimVector.insert( dimVector.end(), params.begin(), params.end());
591 ParmVec params( numberOfParametersPerShape, 0 );
595 dimVector.insert( dimVector.end(), params.begin(), params.end());
601 for (
unsigned int i( 0 );
i < numberOfCells; ++
i) {
613 iVector.emplace_back( layer );
617 if (
nullptr != ptr ) {
618 ptr->getTransform( tr, (
Pt3DVec* )
nullptr );
622 tr = HepGeom::Translate3D(
gp.x(),
gp.y(),
gp.z());
625 const CLHEP::Hep3Vector
tt( tr.getTranslation());
626 trVector.emplace_back(
tt.x());
627 trVector.emplace_back(
tt.y());
628 trVector.emplace_back(
tt.z());
630 const CLHEP::HepRotation
rr( tr.getRotation());
631 const ROOT::Math::Transform3D rtr(
rr.xx(),
rr.xy(),
rr.xz(),
tt.x(),
635 rtr.GetRotation( ea );
636 trVector.emplace_back( ea.Phi());
637 trVector.emplace_back( ea.Theta());
638 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::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
unsigned int getClosestCellIndex(const GlobalPoint &r) const
const HGCalParameters * getParameter() const
const HGCalTopology & m_topology
~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
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
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
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
virtual unsigned int numberOfShapes() const
std::vector< float > ParmVec
DetId encode(const DecodedDetId &id_) const
int layer() const
get the layer #
std::vector< DetId > m_validIds
std::pair< float, float > locateCellTrap(int lay, int ieta, int iphi, bool reco) const
A base class to handle the hexagonal shape of HGCal silicon volumes.
Abs< T >::type abs(const T &t)
std::set< DetId > DetIdSet
HGCScintillatorDetId geometryCell() const
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.
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
std::vector< FlatTrd > CellVec2
const HGCalDDDConstants & dddConstants() const
DetId getClosestCell(const GlobalPoint &r) const override
CaloCellGeometry::CornersMgr * cornersMgr()
void getSummary(CaloSubdetectorGeometry::TrVec &trVector, CaloSubdetectorGeometry::IVec &iVector, CaloSubdetectorGeometry::DimVec &dimVector, CaloSubdetectorGeometry::IVec &dinsVector) const override
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
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
void addValidID(const DetId &id)
bool valid(const DetId &id) const override
Is this a valid cell id.
virtual unsigned int numberOfTransformParms() const
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 #
bool waferInLayer(int wafer, int lay, bool reco) const