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 0;
124 geoId = (
id.subdetId() ==
HGCEE ?
130 const uint32_t cellIndex (
topology().detId2denseGeomId(geoId));
146 unsigned int cellIndex =
indexFor(
id);
150 std::pair<float,float>
xy;
156 const HepGeom::Point3D<float> lcoord(xy.first,xy.second,0);
157 glob =
m_cellVec[cellIndex].getPosition(lcoord);
159 std::cout <<
"getPosition:: index " << cellIndex <<
" Local " << lcoord.x()
160 <<
":" << lcoord.y() <<
" ID " << id_.
iCell <<
":" << id_.
iLay
161 <<
" Global " << glob << std::endl;
170 unsigned int cellIndex =
indexFor(
id);
173 std::pair<float,float>
xy;
179 float dz =
m_cellVec[cellIndex].param()[0];
180 float dx = 0.5*
m_cellVec[cellIndex].param()[11];
181 static const int signx[] = {-1,-1,1,1,-1,-1,1,1};
182 static const int signy[] = {-1,1,1,-1,-1,1,1,-1};
183 static const int signz[] = {-1,-1,-1,-1,1,1,1,1};
184 for (
unsigned int i = 0;
i != 8; ++
i) {
185 const HepGeom::Point3D<float> lcoord(xy.first+signx[
i]*dx,xy.second+signy[
i]*dx,signz[
i]*dz);
186 co[
i] =
m_cellVec[cellIndex].getPosition(lcoord);
196 HepGeom::Point3D<float> local;
198 local =
m_cellVec[cellIndex].getLocal(r);
200 if (r.
z() > 0) local = HepGeom::Point3D<float>(r.
x(),r.
y(),0);
201 else local = HepGeom::Point3D<float>(-r.
x(),r.
y(),0);
203 std::pair<int,int> kxy =
206 id_.
iCell = kxy.second;
210 id_.
iSec = kxy.first;
215 std::cout <<
"getClosestCell: local " << local <<
" Id " << id_.
zside
217 <<
":" << id_.
iCell << std::endl;
236 else return "Unknown";
240 unsigned int cellIndex =
m_cellVec.size();
244 geoId = (
id.subdetId() ==
HGCEE ?
252 std::cout <<
"indexFor " << std::hex <<
id.rawId() <<
":" << geoId.
rawId()
253 <<
std::dec <<
" index " << cellIndex << std::endl;
270 if (0 == cell->
param())
return 0;
275 edm::LogError(
"HGCalGeom") <<
"HGCalGeometry::addValidID is not implemented";
281 float phip = r.
phi();
283 unsigned int cellIndex =
m_cellVec.size();
284 float dzmin(9999), dphimin(9999), dphi10(0.175);
288 while (dphi <= -
M_PI) dphi += 2*
M_PI;
289 if (fabs(dphi) < dphi10) {
291 if (dz < (dzmin+0.001)) {
293 if (fabs(dphi) < (dphimin+0.01)) {
295 dphimin = fabs(dphi);
297 if (cellIndex >=
m_cellVec.size()) cellIndex =
k;
303 std::cout <<
"getClosestCellIndex::Input " << zp <<
":" << phip <<
" Index "
307 << dzmin <<
" phi " <<
m_cellVec[cellIndex].phiPos() <<
":"
339 iVector.reserve( numberOfCells );
340 dimVector.reserve( numberOfShapes * numberOfParametersPerShape );
341 dinsVector.reserve( numberOfCells );
348 params[1] = params[2] = 0;
349 params[3] = params[7] = vol.
h;
350 params[4] = params[8] = vol.
bl;
351 params[5] = params[9] = vol.
tl;
352 params[6] = params[10]= vol.
alpha;
354 dimVector.insert( dimVector.end(), params.begin(), params.end());
359 int layer = mytr.
lay;
365 params[1] = params[2] = 0;
366 params[3] = params[7] = vol.
h;
367 params[4] = params[8] = vol.
bl;
368 params[5] = params[9] = vol.
tl;
369 params[6] = params[10]= vol.
alpha;
371 dimVector.insert( dimVector.end(), params.begin(), params.end());
377 for (
unsigned int i( 0 );
i < numberOfCells; ++
i) {
382 dinsVector.push_back(
topology().detId2denseGeomId( detId ));
383 iVector.push_back( layer );
392 tr = HepGeom::Translate3D(
gp.x(),
gp.y(),
gp.z());
395 const CLHEP::Hep3Vector
tt( tr.getTranslation());
396 trVector.push_back(
tt.x());
397 trVector.push_back(
tt.y());
398 trVector.push_back(
tt.z());
400 const CLHEP::HepRotation
rr( tr.getRotation());
401 const ROOT::Math::Transform3D rtr(
rr.xx(),
rr.xy(),
rr.xz(),
tt.x(),
405 rtr.GetRotation( ea );
406 trVector.push_back( ea.Phi());
407 trVector.push_back( ea.Theta());
408 trVector.push_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
unsigned int sizeForDenseIndex() const
HGCalParameters::hgtrform getTrForm(unsigned int k) const
unsigned int getClosestCellIndex(const GlobalPoint &r) const
Geom::Phi< T > phi() const
Global3DPoint GlobalPoint
std::vector< unsigned int > IVec
virtual 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::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
virtual DetId getClosestCell(const GlobalPoint &r) const override
virtual 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
virtual void getTransform(Tr3D &tr, Pt3DVec *lptr) const
--------— only needed by specific utility; overloaded when needed -—
HGCHEDetId geometryCell() const
DetId encode(const DecodedDetId &id_) const
std::vector< DetId > m_validIds
const HGCalTopology & topology() const
virtual DetIdSet getCells(const GlobalPoint &r, double dR) const override
Get a list of all cells within a dR of the given cell.
virtual unsigned int indexFor(const DetId &id) const override
std::set< DetId > DetIdSet
HGCalGeometryMode 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)
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
CaloCellGeometry::CornersMgr * cornersMgr()
CaloCellGeometry::Tr3D Tr3D
CaloCellGeometry::Pt3D Pt3D
virtual const CaloCellGeometry * cellGeomPtr(uint32_t index) const override
virtual void fillNamedParams(DDFilteredView fv)
std::pair< int, int > assignCell(float x, float y, int lay, int subSec, bool reco) const
virtual const CaloCellGeometry * getGeometry(const DetId &id) const override
Get the cell geometry of a given detector id. Should return false if not found.
virtual void getSummary(CaloSubdetectorGeometry::TrVec &trVector, CaloSubdetectorGeometry::IVec &iVector, CaloSubdetectorGeometry::DimVec &dimVector, CaloSubdetectorGeometry::IVec &dinsVector) 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
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
int waferTypeT(int wafer) const
bool waferInLayer(int wafer, int lay, bool reco) const
unsigned int volumes() const