16 #include <Math/Transform3D.h>
17 #include <Math/EulerAngles.h>
25 : m_topology( topology_ ),
26 m_cellVec( topology_.totalGeomModules()),
27 m_validGeomIds( topology_.totalGeomModules()),
28 m_halfType( topology_.detectorType()),
29 m_subdet( topology_.subDetector()) {
33 std::cout <<
"Expected total # of Geometry Modules "
56 const DetId& detId ) {
70 const uint32_t cellIndex (
topology().detId2denseGeomId(detId));
78 for (
int cell = 0; cell < cells; ++cell) {
83 id.iSubSec = -
id.iSubSec;
85 id.iSubSec = -
id.iSubSec;
90 std::cout <<
"HGCalGeometry::newCell-> [" << cellIndex <<
"]"
91 <<
" front:" << f1.
x() <<
'/' << f1.
y() <<
'/' << f1.
z()
92 <<
" back:" << f2.
x() <<
'/' << f2.
y() <<
'/' << f2.
z()
93 <<
" eta|phi " <<
m_cellVec[cellIndex].etaPos() <<
":"
94 <<
m_cellVec[cellIndex].phiPos() <<
" id:";
103 std::cout <<
" with valid DetId from " << nOld <<
" to " << nNew
105 std::cout <<
"Cell[" << cellIndex <<
"] " << std::hex << geomId.
rawId()
112 if (
id ==
DetId())
return 0;
115 geoId = (
id.subdetId() ==
HGCEE ?
121 const uint32_t cellIndex (
topology().detId2denseGeomId(geoId));
137 unsigned int cellIndex =
indexFor(
id);
141 std::pair<float,float>
xy;
147 const HepGeom::Point3D<float> lcoord(xy.first,xy.second,0);
148 glob =
m_cellVec[cellIndex].getPosition(lcoord);
150 std::cout <<
"getPosition:: index " << cellIndex <<
" Local " << lcoord.x()
151 <<
":" << lcoord.y() <<
" ID " << id_.
iCell <<
":" << id_.
iLay
152 <<
" Global " << glob << std::endl;
161 unsigned int cellIndex =
indexFor(
id);
164 std::pair<float,float>
xy;
170 float dz =
m_cellVec[cellIndex].param()[0];
171 float dx = 0.5*
m_cellVec[cellIndex].param()[11];
172 static const int signx[] = {-1,-1,1,1,-1,-1,1,1};
173 static const int signy[] = {-1,1,1,-1,-1,1,1,-1};
174 static const int signz[] = {-1,-1,-1,-1,1,1,1,1};
175 for (
unsigned int i = 0;
i != 8; ++
i) {
176 const HepGeom::Point3D<float> lcoord(xy.first+signx[
i]*dx,xy.second+signy[
i]*dx,signz[
i]*dz);
177 co[
i] =
m_cellVec[cellIndex].getPosition(lcoord);
187 HepGeom::Point3D<float> local;
189 local =
m_cellVec[cellIndex].getLocal(r);
191 if (r.
z() > 0) local = HepGeom::Point3D<float>(r.
x(),r.
y(),0);
192 else local = HepGeom::Point3D<float>(-r.
x(),r.
y(),0);
194 std::pair<int,int> kxy =
197 id_.
iCell = kxy.second;
201 id_.
iSec = kxy.first;
206 std::cout <<
"getClosestCell: local " << local <<
" Id " << id_.
zside
208 <<
":" << id_.
iCell << std::endl;
227 else return "Unknown";
231 unsigned int cellIndex =
m_cellVec.size();
235 geoId = (
id.subdetId() ==
HGCEE ?
243 std::cout <<
"indexFor " << std::hex <<
id.rawId() <<
":" << geoId.
rawId()
244 <<
std::dec <<
" index " << cellIndex << std::endl;
261 if (0 == cell->
param())
return 0;
266 edm::LogError(
"HGCalGeom") <<
"HGCalGeometry::addValidID is not implemented";
272 float phip = r.
phi();
274 unsigned int cellIndex =
m_cellVec.size();
275 float dzmin(9999), dphimin(9999), dphi10(0.175);
279 while (dphi <= -
M_PI) dphi += 2*
M_PI;
280 if (fabs(dphi) < dphi10) {
282 if (dz < (dzmin+0.001)) {
284 if (fabs(dphi) < (dphimin+0.01)) {
286 dphimin = fabs(dphi);
288 if (cellIndex >=
m_cellVec.size()) cellIndex =
k;
294 std::cout <<
"getClosestCellIndex::Input " << zp <<
":" << phip <<
" Index "
298 << dzmin <<
" phi " <<
m_cellVec[cellIndex].phiPos() <<
":"
334 iVector.reserve( numberOfCells );
335 dimVector.reserve( numberOfShapes * numberOfParametersPerShape );
336 dinsVector.reserve( numberOfCells );
343 params[1] = params[2] = 0;
344 params[3] = params[7] = vol.
h;
345 params[4] = params[8] = vol.
bl;
346 params[5] = params[9] = vol.
tl;
347 params[6] = params[10]= vol.
alpha;
349 dimVector.insert( dimVector.end(), params.begin(), params.end());
354 int layer = mytr.
lay;
360 params[1] = params[2] = 0;
361 params[3] = params[7] = vol.
h;
362 params[4] = params[8] = vol.
bl;
363 params[5] = params[9] = vol.
tl;
364 params[6] = params[10]= vol.
alpha;
366 dimVector.insert( dimVector.end(), params.begin(), params.end());
372 for(
unsigned int i( 0 );
i < numberOfCells; ++
i )
378 dinsVector.push_back(
topology().detId2denseGeomId( detId ));
379 iVector.push_back( layer );
390 tr = HepGeom::Translate3D( gp.x(), gp.y(), gp.z());
393 const CLHEP::Hep3Vector
tt( tr.getTranslation());
394 trVector.push_back(
tt.x());
395 trVector.push_back(
tt.y());
396 trVector.push_back(
tt.z());
399 const CLHEP::HepRotation
rr( tr.getRotation());
400 const ROOT::Math::Transform3D rtr(
rr.xx(),
rr.xy(),
rr.xz(),
tt.x(),
404 rtr.GetRotation( ea );
405 trVector.push_back( ea.Phi());
406 trVector.push_back( ea.Theta());
407 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< 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
std::vector< float > ParmVec
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
virtual void getSummary(CaloSubdetectorGeometry::TrVec &trVector, CaloSubdetectorGeometry::IVec &iVector, CaloSubdetectorGeometry::DimVec &dimVector, CaloSubdetectorGeometry::IVec &dinsVector) const
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.
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