15 #include <Math/Transform3D.h> 16 #include <Math/EulerAngles.h> 24 : m_topology( topology_ ),
25 m_cellVec( topology_.totalGeomModules()),
26 m_validGeomIds( topology_.totalGeomModules()),
27 m_halfType( topology_.detectorType()),
28 m_subdet( topology_.subDetector()) {
32 std::cout <<
"Expected total # of Geometry Modules " 55 const DetId& detId ) {
73 const uint32_t cellIndex (
topology().detId2denseGeomId(detId));
79 std::cout <<
"Store for DetId " << std::hex << detId.
rawId() <<
" GeomId " 81 <<
" cells " << cells << std::endl;
84 for (
int cell = 0; cell < cells; ++cell) {
91 id.iSubSec = -
id.iSubSec;
93 id.iSubSec = -
id.iSubSec;
99 std::cout <<
"HGCalGeometry::newCell-> [" << cellIndex <<
"]" 100 <<
" front:" << f1.
x() <<
'/' << f1.
y() <<
'/' << f1.
z()
101 <<
" back:" << f2.
x() <<
'/' << f2.
y() <<
'/' << f2.
z()
102 <<
" eta|phi " <<
m_cellVec[cellIndex].etaPos() <<
":" 103 <<
m_cellVec[cellIndex].phiPos() <<
" id:";
112 std::cout <<
" with valid DetId from " << nOld <<
" to " << nNew
114 std::cout <<
"Cell[" << cellIndex <<
"] " << std::hex << geomId.
rawId()
121 if (
id ==
DetId())
return nullptr;
124 geoId = (
id.subdetId() ==
HGCEE ?
130 const uint32_t cellIndex (
topology().detId2denseGeomId(geoId));
137 if (
id ==
DetId())
return false;
140 geoId = (
id.subdetId() ==
HGCEE ?
152 unsigned int cellIndex =
indexFor(
id);
156 std::pair<float,float>
xy;
162 const HepGeom::Point3D<float> lcoord(xy.first,xy.second,0);
163 glob =
m_cellVec[cellIndex].getPosition(lcoord);
165 std::cout <<
"getPosition:: index " << cellIndex <<
" Local " << lcoord.x()
166 <<
":" << lcoord.y() <<
" ID " << id_.
iCell <<
":" << id_.
iLay 167 <<
" Global " << glob << std::endl;
176 unsigned int cellIndex =
indexFor(
id);
179 std::pair<float,float>
xy;
187 static const int signx[] = {-1,-1,1,1,-1,-1,1,1};
188 static const int signy[] = {-1,1,1,-1,-1,1,1,-1};
189 static const int signz[] = {-1,-1,-1,-1,1,1,1,1};
190 for (
unsigned int i = 0;
i != 8; ++
i) {
191 const HepGeom::Point3D<float> lcoord(xy.first+signx[
i]*dx,xy.second+signy[
i]*dx,signz[
i]*dz);
192 co[
i] =
m_cellVec[cellIndex].getPosition(lcoord);
202 HepGeom::Point3D<float>
local;
204 local =
m_cellVec[cellIndex].getLocal(r);
206 if (r.
z() > 0) local = HepGeom::Point3D<float>(r.
x(),r.
y(),0);
207 else local = HepGeom::Point3D<float>(-r.
x(),r.
y(),0);
209 std::pair<int,int> kxy =
212 id_.
iCell = kxy.second;
216 id_.
iSec = kxy.first;
221 std::cout <<
"getClosestCell: local " << local <<
" Id " << id_.
zside 223 <<
":" << id_.
iCell << std::endl;
243 else return "Unknown";
247 unsigned int cellIndex =
m_cellVec.size();
251 geoId = (
id.subdetId() ==
HGCEE ?
259 std::cout <<
"indexFor " << std::hex <<
id.rawId() <<
":" << geoId.
rawId()
260 <<
std::dec <<
" index " << cellIndex << std::endl;
274 nullptr == cell->
param() ?
nullptr : cell);
280 static const auto do_not_delete = [](
const void*){};
281 auto cell = std::shared_ptr<const CaloCellGeometry>(&
m_cellVec[
index],do_not_delete);
282 if (
nullptr == cell->param())
return nullptr;
291 cell->setPosition(pos);
295 if (
nullptr == cell->param())
return nullptr;
300 edm::LogError(
"HGCalGeom") <<
"HGCalGeometry::addValidID is not implemented";
306 float phip = r.
phi();
308 unsigned int cellIndex =
m_cellVec.size();
309 float dzmin(9999), dphimin(9999), dphi10(0.175);
313 while (dphi <= -
M_PI) dphi += 2*
M_PI;
314 if (fabs(dphi) < dphi10) {
316 if (dz < (dzmin+0.001)) {
318 if (fabs(dphi) < (dphimin+0.01)) {
320 dphimin = fabs(dphi);
322 if (cellIndex >=
m_cellVec.size()) cellIndex =
k;
328 std::cout <<
"getClosestCellIndex::Input " << zp <<
":" << phip <<
" Index " 332 << dzmin <<
" phi " <<
m_cellVec[cellIndex].phiPos() <<
":" 364 iVector.reserve( numberOfCells );
365 dimVector.reserve( numberOfShapes * numberOfParametersPerShape );
366 dinsVector.reserve( numberOfCells );
373 params[1] = params[2] = 0;
374 params[3] = params[7] = vol.
h;
375 params[4] = params[8] = vol.
bl;
376 params[5] = params[9] = vol.
tl;
377 params[6] = params[10]= vol.
alpha;
379 dimVector.insert( dimVector.end(), params.begin(), params.end());
384 int layer = mytr.
lay;
390 params[1] = params[2] = 0;
391 params[3] = params[7] = vol.
h;
392 params[4] = params[8] = vol.
bl;
393 params[5] = params[9] = vol.
tl;
394 params[6] = params[10]= vol.
alpha;
396 dimVector.insert( dimVector.end(), params.begin(), params.end());
402 for (
unsigned int i( 0 );
i < numberOfCells; ++
i) {
407 dinsVector.emplace_back(
topology().detId2denseGeomId( detId ));
408 iVector.emplace_back( layer );
412 if (
nullptr != ptr ) {
413 ptr->getTransform( tr, (
Pt3DVec* )
nullptr );
417 tr = HepGeom::Translate3D(
gp.x(),
gp.y(),
gp.z());
420 const CLHEP::Hep3Vector
tt( tr.getTranslation());
421 trVector.emplace_back(
tt.x());
422 trVector.emplace_back(
tt.y());
423 trVector.emplace_back(
tt.z());
425 const CLHEP::HepRotation
rr( tr.getRotation());
426 const ROOT::Math::Transform3D rtr(
rr.xx(),
rr.xy(),
rr.xz(),
tt.x(),
430 rtr.GetRotation( ea );
431 trVector.emplace_back( ea.Phi());
432 trVector.emplace_back( ea.Theta());
433 trVector.emplace_back( ea.Psi());
std::vector< DetId > m_validGeomIds
A base class to handle the particular shape of HGCal volumes.
std::vector< CCGFloat > DimVec
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
~HGCalGeometry() override
Geom::Phi< T > phi() const
Global3DPoint GlobalPoint
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
int layer() const
get the layer #
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
CaloCellGeometry::Pt3DVec Pt3DVec
std::pair< float, float > locateCellHex(int cell, int wafer, bool reco) const
uint32_t rawId() const
get the raw id
unsigned int totalGeomModules() const
HGCalGeometry(const HGCalTopology &topology)
HGCalDetId geometryCell() const
void initializeParms() override
unsigned int getTrFormN() const
const CCGFloat * param() const
virtual uint32_t detId2denseGeomId(const DetId &id) const
int numberCellsHexagon(int wafer) const
virtual unsigned int numberOfShapes() const
HGCHEDetId geometryCell() const
std::vector< float > ParmVec
DetId encode(const DecodedDetId &id_) const
std::vector< DetId > m_validIds
const HGCalTopology & topology() const
std::set< DetId > DetIdSet
HGCalGeometryMode::GeometryMode geomMode() const
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
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
AlgebraicVector EulerAngles
int layer() const
get the layer #
ForwardSubdetector m_subdet
const HGCalDDDConstants & dddConstants() const
HGCEEDetId geometryCell() 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
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
CaloCellGeometry::Pt3D Pt3D
virtual void fillNamedParams(DDFilteredView fv)
std::pair< int, int > assignCell(float x, float y, int lay, int subSec, bool reco) const
const CaloCellGeometry * getGeometryRawPtr(uint32_t index) const override
void addValidID(const DetId &id)
virtual unsigned int numberOfTransformParms() const
HGCalParameters::hgtrap getModule(unsigned int k, bool hexType, bool reco) const
int maxCells(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?
bool waferInLayer(int wafer, int lay, bool reco) const
unsigned int volumes() const