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 ) {
71 const uint32_t cellIndex (
topology().detId2denseGeomId(detId));
77 std::cout <<
"Store for DetId " << std::hex << detId.
rawId() <<
" GeomId " 79 <<
" cells " << cells << std::endl;
82 for (
int cell = 0; cell < cells; ++cell) {
89 id.iSubSec = -
id.iSubSec;
91 id.iSubSec = -
id.iSubSec;
97 std::cout <<
"HGCalGeometry::newCell-> [" << cellIndex <<
"]" 98 <<
" front:" << f1.
x() <<
'/' << f1.
y() <<
'/' << f1.
z()
99 <<
" back:" << f2.
x() <<
'/' << f2.
y() <<
'/' << f2.
z()
100 <<
" eta|phi " <<
m_cellVec[cellIndex].etaPos() <<
":" 101 <<
m_cellVec[cellIndex].phiPos() <<
" id:";
109 std::cout <<
" with valid DetId from " << nOld <<
" to " << nNew
111 std::cout <<
"Cell[" << cellIndex <<
"] " << std::hex << geomId.
rawId()
118 if (
id ==
DetId())
return nullptr;
126 const uint32_t cellIndex (
topology().detId2denseGeomId(geoId));
133 if (
id ==
DetId())
return false;
147 unsigned int cellIndex =
indexFor(
id);
151 std::pair<float,float>
xy;
156 xy = std::pair<float,float>(0,0);
158 const HepGeom::Point3D<float> lcoord(xy.first,xy.second,0);
159 glob =
m_cellVec[cellIndex].getPosition(lcoord);
161 std::cout <<
"getPosition:: index " << cellIndex <<
" Local " << lcoord.x()
162 <<
":" << lcoord.y() <<
" ID " << id_.
iCell <<
":" << id_.
iLay 163 <<
" Global " << glob << std::endl;
172 unsigned int cellIndex =
indexFor(
id);
175 std::pair<float,float>
xy;
180 xy = std::pair<float,float>(0,0);
184 static const int signx[] = {-1,-1,1,1,-1,-1,1,1};
185 static const int signy[] = {-1,1,1,-1,-1,1,1,-1};
186 static const int signz[] = {-1,-1,-1,-1,1,1,1,1};
187 for (
unsigned int i = 0;
i != 8; ++
i) {
188 const HepGeom::Point3D<float> lcoord(xy.first+signx[
i]*dx,xy.second+signy[
i]*dx,signz[
i]*dz);
189 co[
i] =
m_cellVec[cellIndex].getPosition(lcoord);
199 HepGeom::Point3D<float>
local;
202 if (r.
z() > 0) local = HepGeom::Point3D<float>(r.
x(),r.
y(),0);
203 else local = HepGeom::Point3D<float>(-r.
x(),r.
y(),0);
204 std::pair<int,int> kxy =
207 id_.
iCell = kxy.second;
208 id_.
iSec = kxy.first;
212 std::cout <<
"getClosestCell: local " << local <<
" Id " << id_.
zside 214 <<
":" << id_.
iCell << std::endl;
235 else return "Unknown";
239 unsigned int cellIndex =
m_cellVec.size();
247 std::cout <<
"indexFor " << std::hex <<
id.rawId() <<
":" 264 nullptr == cell->
param() ?
nullptr : cell);
270 static const auto do_not_delete = [](
const void*){};
271 auto cell = std::shared_ptr<const CaloCellGeometry>(&
m_cellVec[
index],do_not_delete);
272 if (
nullptr == cell->param())
return nullptr;
281 cell->setPosition(pos);
285 if (
nullptr == cell->param())
return nullptr;
290 edm::LogError(
"HGCalGeom") <<
"HGCalGeometry::addValidID is not implemented";
296 float phip = r.
phi();
298 unsigned int cellIndex =
m_cellVec.size();
299 float dzmin(9999), dphimin(9999), dphi10(0.175);
303 while (dphi <= -
M_PI) dphi += 2*
M_PI;
304 if (fabs(dphi) < dphi10) {
306 if (dz < (dzmin+0.001)) {
308 if (fabs(dphi) < (dphimin+0.01)) {
310 dphimin = fabs(dphi);
312 if (cellIndex >=
m_cellVec.size()) cellIndex =
k;
318 std::cout <<
"getClosestCellIndex::Input " << zp <<
":" << phip <<
" Index " 322 << dzmin <<
" phi " <<
m_cellVec[cellIndex].phiPos() <<
":" 354 iVector.reserve( numberOfCells );
355 dimVector.reserve( numberOfShapes * numberOfParametersPerShape );
356 dinsVector.reserve( numberOfCells );
362 int layer = mytr.
lay;
368 params[1] = params[2] = 0;
369 params[3] = params[7] = vol.
h;
370 params[4] = params[8] = vol.
bl;
371 params[5] = params[9] = vol.
tl;
372 params[6] = params[10]= vol.
alpha;
374 dimVector.insert( dimVector.end(), params.begin(), params.end());
380 for (
unsigned int i( 0 );
i < numberOfCells; ++
i) {
383 dinsVector.emplace_back(
topology().detId2denseGeomId( detId ));
384 iVector.emplace_back( layer );
388 if (
nullptr != ptr ) {
389 ptr->getTransform( tr, (
Pt3DVec* )
nullptr );
393 tr = HepGeom::Translate3D(
gp.x(),
gp.y(),
gp.z());
396 const CLHEP::Hep3Vector
tt( tr.getTranslation());
397 trVector.emplace_back(
tt.x());
398 trVector.emplace_back(
tt.y());
399 trVector.emplace_back(
tt.z());
401 const CLHEP::HepRotation
rr( tr.getRotation());
402 const ROOT::Math::Transform3D rtr(
rr.xx(),
rr.xy(),
rr.xz(),
tt.x(),
406 rtr.GetRotation( ea );
407 trVector.emplace_back( ea.Phi());
408 trVector.emplace_back( ea.Theta());
409 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
HepGeom::Transform3D Tr3D
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
std::vector< float > ParmVec
DetId encode(const DecodedDetId &id_) const
std::vector< DetId > m_validIds
const HGCalTopology & topology() const
std::set< DetId > DetIdSet
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
ForwardSubdetector m_subdet
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
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 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