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 ) {
102 << detId.
rawId() <<
" GeomId " 104 << cellIndex <<
" cells " << cells;
109 for (
int cell = 0; cell < cells; ++cell) {
135 unsigned int cellAll(0), cellSelect(0);
137 for (
int u=0; u<2*cells; ++u) {
138 for (
int v=0;
v<2*cells; ++
v) {
139 if (((
v-u) < cells) && (u-
v) <= cells) {
140 id.iCell1 = u;
id.iCell2 =
v;
159 <<
" out of " << cellAll <<
" for wafer " 160 <<
id.iSec1 <<
":" <<
id.iSec2 <<
" in " 161 <<
" layer " <<
id.iLay;
167 <<
"]" <<
" front:" << f1.
x() <<
'/' 168 << f1.
y() <<
'/' << f1.
z() <<
" back:" 169 << f2.
x() <<
'/' << f2.
y() <<
'/' << f2.
z()
175 <<
"]" <<
" front:" << f1.
x() <<
'/' 176 << f1.
y() <<
'/' << f1.
z() <<
" back:" 177 << f2.
x() <<
'/' << f2.
y() <<
'/' << f2.
z()
186 <<
" with valid DetId from " << nOld
190 <<
" with valid DetId from " << nOld
194 <<
" with valid DetId from " << nOld
198 <<
" with valid DetId from " << nOld
202 << geomId.
rawId() <<
":" 209 if (detId ==
DetId())
return nullptr;
218 if (detId ==
DetId())
return false;
226 unsigned int cellIndex =
indexFor(
id);
230 if (cellIndex < maxSize) {
232 std::pair<float,float>
xy;
236 const HepGeom::Point3D<float> lcoord(xy.first,xy.second,0);
237 glob =
m_cellVec[cellIndex].getPosition(lcoord);
240 <<
" Local " << lcoord.x() <<
":" 241 << lcoord.y() <<
" ID " << id_.
iCell1 242 <<
":" << id_.
iSec1 <<
" Global " << glob;
245 const HepGeom::Point3D<float> lcoord(0,0,0);
246 glob =
m_cellVec2[cellIndex].getPosition(lcoord);
249 <<
" Local " << lcoord.x() <<
":" 250 << lcoord.y() <<
" ID " << id_.
iLay <<
":" 252 <<
" Global " << glob;
257 const HepGeom::Point3D<float> lcoord(xy.first,xy.second,0);
258 glob =
m_cellVec[cellIndex].getPosition(lcoord);
261 <<
" Local " << lcoord.x() <<
":" 262 << lcoord.y() <<
" ID " << id_.
iLay <<
":" 265 <<
" Global " << glob;
277 unsigned int cellIndex =
indexFor(
id);
281 std::pair<float,float>
xy;
295 static const int signx[] = {-1,-1,1,1,-1,-1,1,1};
296 static const int signy[] = {-1,1,1,-1,-1,1,1,-1};
297 static const int signz[] = {-1,-1,-1,-1,1,1,1,1};
298 for (
unsigned int i = 0;
i < ncorner; ++
i) {
299 const HepGeom::Point3D<float> lcoord(xy.first+signx[
i]*dx,xy.second+signy[
i]*dx,signz[
i]*dz);
306 static const int signx[] = {0,-1,-1,0,1,1,0,-1,-1,0,1,1};
307 static const int signy[] = {-2,-1,1,2,1,-1,-2,-1,1,2,1,-1};
308 static const int signz[] = {-1,-1,-1,-1,-1,-1,1,1,1,1,1,1};
309 for (
unsigned int i = 0;
i < ncorner; ++
i) {
310 const HepGeom::Point3D<float> lcoord(xy.first+signx[
i]*dx,xy.second+signy[
i]*dy,signz[
i]*dz);
311 co[
i] =
m_cellVec[cellIndex].getPosition(lcoord);
322 unsigned int cellIndex =
indexFor(
id);
326 std::pair<float,float>
xy;
341 static const int signx[] = {-1,-1,1,1,-1,-1,1,1};
342 static const int signy[] = {-1,1,1,-1,-1,1,1,-1};
343 static const int signz[] = {-1,-1,-1,-1,1,1,1,1};
344 for (
unsigned int i = 0;
i < ncorner; ++
i) {
345 const HepGeom::Point3D<float> lcoord(xy.first+signx[
i]*dx,
346 xy.second+signy[
i]*dx,signz[
i]*dz);
360 HepGeom::Point3D<float>
local;
362 local = HepGeom::Point3D<float>(r.
x(),r.
y(),0);
365 local = HepGeom::Point3D<float>(-r.
x(),r.
y(),0);
374 id_.
iSec1 = kxy.first;
395 <<
" Id " << id_.
zSide <<
":" << id_.
iLay 418 else return "Unknown";
424 if (detId !=
DetId()) {
430 <<
" index " << cellIndex;
445 return (
nullptr == cell->
param() ?
nullptr : cell);
449 return (
nullptr == cell->
param() ?
nullptr : cell);
457 static const auto do_not_delete = [](
const void*){};
459 auto cell = std::shared_ptr<const CaloCellGeometry>(&
m_cellVec2[
index],do_not_delete);
460 if (
nullptr == cell->param())
return nullptr;
463 auto cell = std::shared_ptr<const CaloCellGeometry>(&
m_cellVec[
index],do_not_delete);
464 if (
nullptr == cell->param())
return nullptr;
476 cell->setPosition(pos);
480 if (
nullptr == cell->param())
return nullptr;
484 cell->setPosition(pos);
488 if (
nullptr == cell->param())
return nullptr;
494 edm::LogError(
"HGCalGeom") <<
"HGCalGeometry::addValidID is not implemented";
504 const std::vector<T>& vec)
const {
506 float phip = r.
phi();
508 float dzmin(9999), dphimin(9999), dphi10(0.175);
509 unsigned int cellIndex = vec.size();
510 for (
unsigned int k=0;
k<vec.size(); ++
k) {
511 float dphi = phip-vec[
k].phiPos();
513 while (dphi <= -
M_PI) dphi += 2*
M_PI;
516 if (dz < (dzmin+0.001)) {
518 if (
std::abs(dphi) < (dphimin+0.01)) {
522 if (cellIndex >= vec.size()) cellIndex =
k;
529 << phip <<
" Index " << cellIndex;
530 if (cellIndex < vec.size())
532 << vec[cellIndex].getPosition().z()
533 <<
":" << dzmin <<
" phi " 534 << vec[cellIndex].phiPos() <<
":" << dphimin;
566 iVector.reserve( numberOfCells );
567 dimVector.reserve( numberOfShapes * numberOfParametersPerShape );
568 dinsVector.reserve( numberOfCells );
572 int layer = mytr.
lay;
579 ParmVec params( numberOfParametersPerShape, 0 );
583 dimVector.insert( dimVector.end(), params.begin(), params.end());
592 ParmVec params( numberOfParametersPerShape, 0 );
593 params[1] = params[2] = 0;
594 params[3] = params[7] = vol.
h;
595 params[4] = params[8] = vol.
bl;
596 params[5] = params[9] = vol.
tl;
597 params[6] = params[10]= vol.
alpha;
599 dimVector.insert( dimVector.end(), params.begin(), params.end());
605 ParmVec params( numberOfParametersPerShape, 0 );
609 dimVector.insert( dimVector.end(), params.begin(), params.end());
615 for (
unsigned int i( 0 );
i < numberOfCells; ++
i) {
629 iVector.emplace_back( layer );
633 if (
nullptr != ptr ) {
634 ptr->getTransform( tr, (
Pt3DVec* )
nullptr );
638 tr = HepGeom::Translate3D(
gp.x(),
gp.y(),
gp.z());
641 const CLHEP::Hep3Vector
tt( tr.getTranslation());
642 trVector.emplace_back(
tt.x());
643 trVector.emplace_back(
tt.y());
644 trVector.emplace_back(
tt.z());
646 const CLHEP::HepRotation
rr( tr.getRotation());
647 const ROOT::Math::Transform3D rtr(
rr.xx(),
rr.xy(),
rr.xz(),
tt.x(),
651 rtr.GetRotation( ea );
652 trVector.emplace_back( ea.Phi());
653 trVector.emplace_back( ea.Theta());
654 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
HFNoseDetId geometryCell() const
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
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 #
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
CornersVec get8Corners(const DetId &id) 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
DetId getGeometryDetId(DetId detId) const