CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
HGCalGeometry Class Referencefinal

#include <HGCalGeometry.h>

Inheritance diagram for HGCalGeometry:
CaloSubdetectorGeometry

Public Types

typedef HGCalGeometryRecord AlignedRecord
 
typedef CaloCellGeometry::CCGFloat CCGFloat
 
typedef std::vector< FlatHexagonCellVec
 
typedef std::vector< FlatTrdCellVec2
 
typedef std::vector< GlobalPointCornersVec
 
typedef std::set< DetIdDetIdSet
 
typedef PHGCalRcd PGeometryRecord
 
typedef CaloCellGeometry::Pt3D Pt3D
 
typedef CaloCellGeometry::Pt3DVec Pt3DVec
 
- Public Types inherited from CaloSubdetectorGeometry
typedef CaloCellGeometry::CCGFloat CCGFloat
 
typedef std::vector
< std::shared_ptr< const
CaloCellGeometry > > 
CellSet
 
typedef std::set< DetIdDetIdSet
 
typedef std::vector< CCGFloatDimVec
 
typedef std::vector< unsigned int > IVec
 
typedef CaloCellGeometry::ParMgr ParMgr
 
typedef CaloCellGeometry::ParVec ParVec
 
typedef CaloCellGeometry::ParVecVec ParVecVec
 
typedef std::vector< CCGFloatTrVec
 

Public Member Functions

std::string cellElement () const
 
virtual void fillNamedParams (DDFilteredView fv)
 
CornersVec get8Corners (const DetId &id) const
 
double getArea (const DetId &detid) const
 Returns area of a cell. More...
 
DetIdSet getCells (const GlobalPoint &r, double dR) const override
 Get a list of all cells within a dR of the given cell. More...
 
DetId getClosestCell (const GlobalPoint &r) const override
 
DetId getClosestCellHex (const GlobalPoint &r, bool extend) const
 
CornersVec getCorners (const DetId &id) const
 Returns the corner points of this cell's volume. More...
 
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. More...
 
CornersVec getNewCorners (const DetId &id, bool debug=false) const
 
GlobalPoint getPosition (const DetId &id, bool debug=false) const
 
void getSummary (CaloSubdetectorGeometry::TrVec &trVector, CaloSubdetectorGeometry::IVec &iVector, CaloSubdetectorGeometry::DimVec &dimVector, CaloSubdetectorGeometry::IVec &dinsVector) const override
 
const std::vector< DetId > & getValidDetIds (DetId::Detector det=DetId::Detector(0), int subdet=0) const override
 Get a list of valid detector ids (for the given subdetector) More...
 
const std::vector< DetId > & getValidGeomDetIds (void) const
 
GlobalPoint getWaferPosition (const DetId &id) const
 
 HGCalGeometry (const HGCalTopology &topology)
 
void initializeParms () override
 
void localCorners (Pt3DVec &lc, const CCGFloat *pv, unsigned int i, Pt3D &ref)
 
DetId neighborZ (const DetId &idin, const GlobalVector &p) const
 
DetId neighborZ (const DetId &idin, const MagneticField *bField, int charge, const GlobalVector &momentum) const
 
void newCell (const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId) override
 
bool present (const DetId &id) const override
 is this detid present in the geometry? More...
 
void sortDetIds ()
 
const HGCalTopologytopology () const
 
 ~HGCalGeometry () override=default
 
- Public Member Functions inherited from CaloSubdetectorGeometry
void allocateCorners (CaloCellGeometry::CornersVec::size_type n)
 
void allocatePar (ParVec::size_type n, unsigned int m)
 
 CaloSubdetectorGeometry ()
 
 CaloSubdetectorGeometry (const CaloSubdetectorGeometry &)=delete
 avoid copies More...
 
CaloCellGeometry::CornersMgrcornersMgr ()
 
CCGFloat deltaEta (const DetId &detId) const
 
CCGFloat deltaPhi (const DetId &detId) const
 
virtual void fillDefaultNamedParameters () const
 
virtual CellSet getCellSet (const GlobalPoint &r, double dR) const
 
virtual unsigned int numberOfParametersPerShape () const
 
virtual unsigned int numberOfShapes () const
 
virtual unsigned int numberOfTransformParms () const
 
CaloSubdetectorGeometryoperator= (const CaloSubdetectorGeometry &)=delete
 
ParMgrparMgr ()
 
const ParMgrparMgrConst () const
 
ParVecVecparVecVec ()
 
const ParVecVecparVecVec () const
 
virtual ~CaloSubdetectorGeometry ()
 The base class DOES assume that it owns the CaloCellGeometry objects. More...
 

Static Public Member Functions

static std::string dbString ()
 
static std::string producerTag ()
 

Static Public Attributes

static constexpr unsigned int k_NumberOfParametersPerHex = 3
 
static constexpr unsigned int k_NumberOfParametersPerShape = 3
 
static constexpr unsigned int k_NumberOfParametersPerTrd = 12
 
static constexpr unsigned int k_NumberOfShapes = 100
 
static constexpr unsigned int k_NumberOfShapesTrd = 1000
 

Protected Member Functions

void addValidID (const DetId &id)
 
std::shared_ptr< const
CaloCellGeometry
cellGeomPtr (uint32_t index) const override
 
unsigned int getClosestCellIndex (const GlobalPoint &r) const
 
const CaloCellGeometrygetGeometryRawPtr (uint32_t index) const override
 
unsigned int indexFor (const DetId &id) const override
 
unsigned int sizeForDenseIndex () const
 
- Protected Member Functions inherited from CaloSubdetectorGeometry
void addValidID (const DetId &id)
 
virtual unsigned int sizeForDenseIndex (const DetId &id) const
 

Private Member Functions

std::shared_ptr< const
CaloCellGeometry
cellGeomPtr (uint32_t index, const GlobalPoint &p) const
 
template<class T >
unsigned int getClosestCellIndex (const GlobalPoint &r, const std::vector< T > &vec) const
 
DetId getGeometryDetId (DetId detId) const
 

Private Attributes

CellVec m_cellVec
 
CellVec2 m_cellVec2
 
DetId::Detector m_det
 
ForwardSubdetector m_subdet
 
const HGCalTopologym_topology
 
std::vector< DetIdm_validGeomIds
 
const double twoBysqrt3_
 

Static Private Attributes

static constexpr double k_fac1 = 0.5
 
static constexpr double k_fac2 = 1.0 / 3.0
 
static constexpr double k_half = 0.5
 

Additional Inherited Members

- Static Protected Member Functions inherited from CaloSubdetectorGeometry
static CCGFloat deltaR (const GlobalPoint &p1, const GlobalPoint &p2)
 
- Protected Attributes inherited from CaloSubdetectorGeometry
ParVecVec m_parVecVec
 
std::vector< DetIdm_validIds
 

Detailed Description

Definition at line 29 of file HGCalGeometry.h.

Member Typedef Documentation

Definition at line 40 of file HGCalGeometry.h.

Definition at line 33 of file HGCalGeometry.h.

typedef std::vector<FlatHexagon> HGCalGeometry::CellVec

Definition at line 31 of file HGCalGeometry.h.

typedef std::vector<FlatTrd> HGCalGeometry::CellVec2

Definition at line 32 of file HGCalGeometry.h.

typedef std::vector<GlobalPoint> HGCalGeometry::CornersVec

Definition at line 38 of file HGCalGeometry.h.

typedef std::set<DetId> HGCalGeometry::DetIdSet

Definition at line 37 of file HGCalGeometry.h.

Definition at line 41 of file HGCalGeometry.h.

Definition at line 34 of file HGCalGeometry.h.

Definition at line 35 of file HGCalGeometry.h.

Constructor & Destructor Documentation

HGCalGeometry::HGCalGeometry ( const HGCalTopology topology)

Definition at line 28 of file HGCalGeometry.cc.

References DetId::HGCalHSc, m_cellVec, m_cellVec2, m_det, m_topology, CaloSubdetectorGeometry::m_validIds, HGCalTopology::totalGeomModules(), and HGCalTopology::totalModules().

29  : m_topology(topology_),
30  m_validGeomIds(topology_.totalGeomModules()),
31  m_det(topology_.detector()),
32  m_subdet(topology_.subDetector()),
33  twoBysqrt3_(2.0 / std::sqrt(3.0)) {
34  if (m_det == DetId::HGCalHSc) {
35  m_cellVec2 = CellVec2(topology_.totalGeomModules());
36  } else {
37  m_cellVec = CellVec(topology_.totalGeomModules());
38  }
40 #ifdef EDM_ML_DEBUG
41  edm::LogVerbatim("HGCalGeom") << "Expected total # of Geometry Modules " << m_topology.totalGeomModules();
42 #endif
43 }
std::vector< DetId > m_validGeomIds
Log< level::Info, true > LogVerbatim
std::vector< FlatHexagon > CellVec
Definition: HGCalGeometry.h:31
const HGCalTopology & m_topology
const double twoBysqrt3_
unsigned int totalGeomModules() const
Definition: HGCalTopology.h:93
T sqrt(T t)
Definition: SSEVec.h:19
std::vector< DetId > m_validIds
CellVec2 m_cellVec2
ForwardSubdetector m_subdet
std::vector< FlatTrd > CellVec2
Definition: HGCalGeometry.h:32
unsigned int totalModules() const
Definition: HGCalTopology.h:92
DetId::Detector m_det
CellVec m_cellVec
HGCalGeometry::~HGCalGeometry ( )
overridedefault

Member Function Documentation

void HGCalGeometry::addValidID ( const DetId id)
protected

Definition at line 699 of file HGCalGeometry.cc.

699  {
700  edm::LogError("HGCalGeom") << "HGCalGeometry::addValidID is not implemented";
701 }
Log< level::Error, false > LogError
std::string HGCalGeometry::cellElement ( ) const

Definition at line 613 of file HGCalGeometry.cc.

References DetId::HGCalEE, DetId::HGCalHSc, DetId::HGCalHSi, HGCEE, HGCHEB, HGCHEF, m_det, and m_subdet.

613  {
614  if (m_subdet == HGCEE || m_det == DetId::HGCalEE)
615  return "HGCalEE";
616  else if (m_subdet == HGCHEF || m_det == DetId::HGCalHSi)
617  return "HGCalHEFront";
618  else if (m_subdet == HGCHEB || m_det == DetId::HGCalHSc)
619  return "HGCalHEBack";
620  else
621  return "Unknown";
622 }
ForwardSubdetector m_subdet
DetId::Detector m_det
std::shared_ptr< const CaloCellGeometry > HGCalGeometry::cellGeomPtr ( uint32_t  index) const
overrideprotectedvirtual

Reimplemented from CaloSubdetectorGeometry.

Definition at line 654 of file HGCalGeometry.cc.

References DetId::HGCalHSc, m_cellVec, m_cellVec2, m_det, and m_validGeomIds.

Referenced by cellGeomPtr(), getGeometry(), and getSummary().

654  {
655  if ((index >= m_cellVec.size() && m_det != DetId::HGCalHSc) ||
656  (index >= m_cellVec2.size() && m_det == DetId::HGCalHSc) || (m_validGeomIds[index].rawId() == 0))
657  return nullptr;
658  static const auto do_not_delete = [](const void*) {};
659  if (m_det == DetId::HGCalHSc) {
660  auto cell = std::shared_ptr<const CaloCellGeometry>(&m_cellVec2[index], do_not_delete);
661  if (nullptr == cell->param())
662  return nullptr;
663  return cell;
664  } else {
665  auto cell = std::shared_ptr<const CaloCellGeometry>(&m_cellVec[index], do_not_delete);
666  if (nullptr == cell->param())
667  return nullptr;
668  return cell;
669  }
670 }
std::vector< DetId > m_validGeomIds
CellVec2 m_cellVec2
DetId::Detector m_det
CellVec m_cellVec
std::shared_ptr< const CaloCellGeometry > HGCalGeometry::cellGeomPtr ( uint32_t  index,
const GlobalPoint p 
) const
private

Definition at line 672 of file HGCalGeometry.cc.

References cellGeomPtr(), DetId::HGCalHSc, m_cellVec, m_cellVec2, m_det, and m_validGeomIds.

672  {
673  if ((index >= m_cellVec.size() && m_det != DetId::HGCalHSc) ||
674  (index >= m_cellVec2.size() && m_det == DetId::HGCalHSc) || (m_validGeomIds[index].rawId() == 0))
675  return nullptr;
676  if (pos == GlobalPoint())
677  return cellGeomPtr(index);
678  if (m_det == DetId::HGCalHSc) {
679  auto cell = std::make_shared<FlatTrd>(m_cellVec2[index]);
680  cell->setPosition(pos);
681 #ifdef EDM_ML_DEBUG
682  edm::LogVerbatim("HGCalGeom") << "cellGeomPtr " << index << ":" << cell;
683 #endif
684  if (nullptr == cell->param())
685  return nullptr;
686  return cell;
687  } else {
688  auto cell = std::make_shared<FlatHexagon>(m_cellVec[index]);
689  cell->setPosition(pos);
690 #ifdef EDM_ML_DEBUG
691  edm::LogVerbatim("HGCalGeom") << "cellGeomPtr " << index << ":" << cell;
692 #endif
693  if (nullptr == cell->param())
694  return nullptr;
695  return cell;
696  }
697 }
std::vector< DetId > m_validGeomIds
Log< level::Info, true > LogVerbatim
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
CellVec2 m_cellVec2
std::shared_ptr< const CaloCellGeometry > cellGeomPtr(uint32_t index) const override
DetId::Detector m_det
CellVec m_cellVec
static std::string HGCalGeometry::dbString ( )
inlinestatic

Definition at line 49 of file HGCalGeometry.h.

Referenced by CaloGeometryDBEP< T, U >::produceAligned().

49 { return "PHGCalRcd"; }
void HGCalGeometry::fillNamedParams ( DDFilteredView  fv)
virtual

Definition at line 45 of file HGCalGeometry.cc.

45 {}
HGCalGeometry::CornersVec HGCalGeometry::get8Corners ( const DetId id) const

Definition at line 328 of file HGCalGeometry.cc.

References HGCalDDDConstants::cellSizeTrap(), cms::cuda::co, funct::cos(), HGCalTopology::dddConstants(), debugLocate, HGCalTopology::decode(), runTauDisplay::dr, PVValHelper::dx, PVValHelper::dy, PVValHelper::dz, getPosition(), DetId::HGCalHSc, mps_fire::i, indexFor(), FlatTrd::k_Cell, FlatTrd::k_dZ, FlatHexagon::k_dZ, k_fac1, k_fac2, k_half, FlatHexagon::k_r, FlatHexagon::k_R, HGCalDDDConstants::localToGlobal8(), HGCalDDDConstants::locateCell(), HGCalDDDConstants::locateCellHex(), m_cellVec, m_cellVec2, m_det, m_topology, SiStripPI::min, FlatTrd::ncorner_, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), alignCSCRings::r, findQualityFiles::rr, funct::sin(), findQualityFiles::v, HGCalTopology::waferHexagon6(), HGCalDDDConstants::waferZ(), xy(), and PV3DBase< T, PVType, FrameType >::z().

328  {
329  unsigned int ncorner = FlatTrd::ncorner_;
330  HGCalGeometry::CornersVec co(ncorner, GlobalPoint(0, 0, 0));
331  unsigned int cellIndex = indexFor(detid);
333  if (cellIndex < m_cellVec2.size() && m_det == DetId::HGCalHSc) {
334  GlobalPoint v = getPosition(detid, false);
335  int type = std::min(id.iType, 1);
336  std::pair<double, double> rr = m_topology.dddConstants().cellSizeTrap(type, id.iSec1);
337  float dr = k_half * (rr.second - rr.first);
338  float dfi = m_cellVec2[cellIndex].param()[FlatTrd::k_Cell];
339  float dz = id.zSide * m_cellVec2[cellIndex].param()[FlatTrd::k_dZ];
340  float r = v.perp();
341  float fi = v.phi();
342  static const int signr[] = {1, 1, -1, -1, 1, 1, -1, -1};
343  static const int signf[] = {-1, 1, 1, -1, -1, 1, 1, -1};
344  static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
345  for (unsigned int i = 0; i < ncorner; ++i) {
346  co[i] = GlobalPoint((r + signr[i] * dr) * cos(fi + signf[i] * dfi),
347  (r + signr[i] * dr) * sin(fi + signf[i] * dfi),
348  (v.z() + signz[i] * dz));
349  }
350  } else if (cellIndex < m_cellVec.size() && m_det != DetId::HGCalHSc) {
351  std::pair<float, float> xy;
352  float dx(0);
353  static const int signx[] = {-1, -1, 1, 1, -1, -1, 1, 1};
354  static const int signy[] = {-1, 1, 1, -1, -1, 1, 1, -1};
355  static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
356  if (m_topology.waferHexagon6()) {
357  xy = m_topology.dddConstants().locateCellHex(id.iCell1, id.iSec1, true);
358  dx = m_cellVec[cellIndex].param()[FlatHexagon::k_r];
359  float dz = m_cellVec[cellIndex].param()[FlatHexagon::k_dZ];
360  for (unsigned int i = 0; i < ncorner; ++i) {
361  const HepGeom::Point3D<float> lcoord(xy.first + signx[i] * dx, xy.second + signy[i] * dx, signz[i] * dz);
362  co[i] = m_cellVec[cellIndex].getPosition(lcoord);
363  }
364  } else {
366  id.iLay, id.iSec1, id.iSec2, id.iCell1, id.iCell2, true, false, true, debugLocate);
367  dx = k_fac2 * m_cellVec[cellIndex].param()[FlatHexagon::k_r];
368  float dy = k_fac1 * m_cellVec[cellIndex].param()[FlatHexagon::k_R];
369  float dz = -id.zSide * m_cellVec[cellIndex].param()[FlatHexagon::k_dZ];
370  float zz = m_topology.dddConstants().waferZ(id.iLay, true);
371  for (unsigned int i = 0; i < ncorner; ++i) {
372  auto xyglob = m_topology.dddConstants().localToGlobal8(
373  id.iLay, id.iSec1, id.iSec2, (xy.first + signx[i] * dx), (xy.second + signy[i] * dy), true, false);
374  double xx = id.zSide * xyglob.first;
375  co[i] = GlobalPoint(xx, xyglob.second, id.zSide * (zz + signz[i] * dz));
376  }
377  }
378  }
379  return co;
380 }
std::pair< double, double > cellSizeTrap(int type, int irad) const
T perp() const
Definition: PV3DBase.h:69
const HGCalTopology & m_topology
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< GlobalPoint > CornersVec
Definition: HGCalGeometry.h:38
static constexpr double k_fac2
static constexpr uint32_t k_Cell
Definition: FlatTrd.h:45
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
__host__ __device__ VT * co
Definition: prefixScan.h:47
static constexpr double k_half
static constexpr double k_fac1
std::pair< float, float > locateCellHex(int cell, int wafer, bool reco) const
static constexpr unsigned int ncorner_
Definition: FlatTrd.h:97
static constexpr uint32_t k_R
Definition: FlatHexagon.h:29
static constexpr uint32_t k_r
Definition: FlatHexagon.h:28
T z() const
Definition: PV3DBase.h:61
std::pair< float, float > localToGlobal8(int lay, int waferU, int waferV, double localX, double localY, bool reco, bool debug) const
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
unsigned int indexFor(const DetId &id) const override
CellVec2 m_cellVec2
bool waferHexagon6() const
double waferZ(int layer, bool reco) const
DecodedDetId decode(const DetId &id) const
Basic2DVector< T > xy() const
static constexpr uint32_t k_dZ
Definition: FlatHexagon.h:27
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
const bool debugLocate
GlobalPoint getPosition(const DetId &id, bool debug=false) const
static constexpr uint32_t k_dZ
Definition: FlatTrd.h:26
DetId::Detector m_det
CellVec m_cellVec
double HGCalGeometry::getArea ( const DetId detid) const

Returns area of a cell.

Definition at line 257 of file HGCalGeometry.cc.

References funct::abs(), getNewCorners(), mps_fire::i, dqmiolumiharvest::j, dqmiodumpmetadata::n, and y.

257  {
258  HGCalGeometry::CornersVec corners = getNewCorners(detid);
259  double area(0);
260  if (corners.size() > 1) {
261  int n = corners.size() - 1;
262  int j = n - 1;
263  for (int i = 0; i < n; ++i) {
264  area += ((corners[j].x() + corners[i].x()) * (corners[i].y() - corners[j].y()));
265  j = i;
266  }
267  }
268  return std::abs(0.5 * area);
269 }
CornersVec getNewCorners(const DetId &id, bool debug=false) const
std::vector< GlobalPoint > CornersVec
Definition: HGCalGeometry.h:38
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HGCalGeometry::DetIdSet HGCalGeometry::getCells ( const GlobalPoint r,
double  dR 
) const
overridevirtual

Get a list of all cells within a dR of the given cell.

The default implementation makes a loop over all cell geometries. Cleverer implementations are suggested to use rough conversions between eta/phi and ieta/iphi and test on the boundaries.

Reimplemented from CaloSubdetectorGeometry.

Definition at line 608 of file HGCalGeometry.cc.

608  {
610  return dss;
611 }
std::set< DetId > DetIdSet
Definition: HGCalGeometry.h:37
DetId HGCalGeometry::getClosestCell ( const GlobalPoint r) const
overridevirtual

Reimplemented from CaloSubdetectorGeometry.

Definition at line 512 of file HGCalGeometry.cc.

References HGCalDDDConstants::assignCell(), HGCalDDDConstants::assignCellHex(), HGCalDDDConstants::assignCellTrap(), HGCalTopology::dddConstants(), HGCalTopology::decode(), HGCalTopology::DecodedDetId::det, HGCalTopology::detector(), HGCalTopology::encode(), getClosestCellIndex(), HGCalDDDConstants::getLayer(), DetId::HGCalHSc, m_cellVec, m_cellVec2, m_det, m_topology, m_validGeomIds, HGCalTopology::tileTrapezoid(), HGCalTopology::waferHexagon6(), HGCalDDDConstants::waferTypeT(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by neighborZ().

512  {
513  unsigned int cellIndex = getClosestCellIndex(r);
514  if ((cellIndex < m_cellVec.size() && m_det != DetId::HGCalHSc) ||
515  (cellIndex < m_cellVec2.size() && m_det == DetId::HGCalHSc)) {
517  if (id.det == 0)
518  id.det = static_cast<int>(m_topology.detector());
519  HepGeom::Point3D<float> local;
520  if (r.z() > 0) {
521  local = HepGeom::Point3D<float>(r.x(), r.y(), 0);
522  id.zSide = 1;
523  } else {
524  local = HepGeom::Point3D<float>(-r.x(), r.y(), 0);
525  id.zSide = -1;
526  }
527  if (m_topology.waferHexagon6()) {
528  const auto& kxy = m_topology.dddConstants().assignCell(local.x(), local.y(), id.iLay, id.iType, true);
529  id.iCell1 = kxy.second;
530  id.iSec1 = kxy.first;
531  id.iType = m_topology.dddConstants().waferTypeT(kxy.first);
532  if (id.iType != 1)
533  id.iType = -1;
534  } else if (m_topology.tileTrapezoid()) {
535  id.iLay = m_topology.dddConstants().getLayer(r.z(), true);
536  const auto& kxy = m_topology.dddConstants().assignCellTrap(r.x(), r.y(), r.z(), id.iLay, true);
537  id.iSec1 = kxy[0];
538  id.iCell1 = kxy[1];
539  id.iType = kxy[2];
540  } else {
541  id.iLay = m_topology.dddConstants().getLayer(r.z(), true);
542 #ifdef EDM_ML_DEBUG
543  edm::LogVerbatim("HGCalGeom") << "ZZ " << r.z() << " Layer " << id.iLay << " Global " << r << " Local " << local;
544 #endif
545  const auto& kxy = m_topology.dddConstants().assignCellHex(local.x(), local.y(), id.iLay, false, true);
546  id.iSec1 = kxy[0];
547  id.iSec2 = kxy[1];
548  id.iType = kxy[2];
549  id.iCell1 = kxy[3];
550  id.iCell2 = kxy[4];
551  }
552 #ifdef EDM_ML_DEBUG
553  edm::LogVerbatim("HGCalGeom") << "getClosestCell: local " << local << " Id " << id.det << ":" << id.zSide << ":"
554  << id.iLay << ":" << id.iSec1 << ":" << id.iSec2 << ":" << id.iType << ":"
555  << id.iCell1 << ":" << id.iCell2;
556 #endif
557 
558  //check if returned cell is valid
559  if (id.iCell1 >= 0)
560  return m_topology.encode(id);
561  }
562 
563  //if not valid or out of bounds return a null DetId
564  return DetId();
565 }
std::vector< DetId > m_validGeomIds
Log< level::Info, true > LogVerbatim
int getLayer(double z, bool reco) const
unsigned int getClosestCellIndex(const GlobalPoint &r) const
bool tileTrapezoid() const
const HGCalTopology & m_topology
T y() const
Definition: PV3DBase.h:60
DetId encode(const DecodedDetId &id_) const
T z() const
Definition: PV3DBase.h:61
CellVec2 m_cellVec2
bool waferHexagon6() const
DecodedDetId decode(const DetId &id) const
Definition: DetId.h:17
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
std::array< int, 5 > assignCellHex(float x, float y, int lay, bool reco, bool extend=false, bool debug=false) const
std::pair< int, int > assignCell(float x, float y, int lay, int subSec, bool reco) const
DetId::Detector m_det
std::array< int, 3 > assignCellTrap(float x, float y, float z, int lay, bool reco) const
DetId::Detector detector() const
T x() const
Definition: PV3DBase.h:59
int waferTypeT(int wafer) const
CellVec m_cellVec
DetId HGCalGeometry::getClosestCellHex ( const GlobalPoint r,
bool  extend 
) const

Definition at line 567 of file HGCalGeometry.cc.

References HGCalDDDConstants::assignCellHex(), HGCalTopology::dddConstants(), HGCalTopology::decode(), HGCalTopology::DecodedDetId::det, HGCalTopology::detector(), HGCalTopology::encode(), getClosestCellIndex(), HGCalDDDConstants::getLayer(), DetId::HGCalHSc, m_cellVec, m_det, m_topology, m_validGeomIds, HGCalTopology::waferHexagon8(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

567  {
568  unsigned int cellIndex = getClosestCellIndex(r);
569  if (cellIndex < m_cellVec.size() && m_det != DetId::HGCalHSc) {
571  if (id.det == 0)
572  id.det = static_cast<int>(m_topology.detector());
573  HepGeom::Point3D<float> local;
574  if (r.z() > 0) {
575  local = HepGeom::Point3D<float>(r.x(), r.y(), 0);
576  id.zSide = 1;
577  } else {
578  local = HepGeom::Point3D<float>(-r.x(), r.y(), 0);
579  id.zSide = -1;
580  }
581  if (m_topology.waferHexagon8()) {
582  id.iLay = m_topology.dddConstants().getLayer(r.z(), true);
583 #ifdef EDM_ML_DEBUG
584  edm::LogVerbatim("HGCalGeom") << "ZZ " << r.z() << " Layer " << id.iLay << " Global " << r << " Local " << local;
585 #endif
586  const auto& kxy = m_topology.dddConstants().assignCellHex(local.x(), local.y(), id.iLay, extend, true);
587  id.iSec1 = kxy[0];
588  id.iSec2 = kxy[1];
589  id.iType = kxy[2];
590  id.iCell1 = kxy[3];
591  id.iCell2 = kxy[4];
592  }
593 #ifdef EDM_ML_DEBUG
594  edm::LogVerbatim("HGCalGeom") << "getClosestCell: local " << local << " Id " << id.det << ":" << id.zSide << ":"
595  << id.iLay << ":" << id.iSec1 << ":" << id.iSec2 << ":" << id.iType << ":"
596  << id.iCell1 << ":" << id.iCell2;
597 #endif
598 
599  //check if returned cell is valid
600  if (id.iCell1 >= 0)
601  return m_topology.encode(id);
602  }
603 
604  //if not valid or out of bounds return a null DetId
605  return DetId();
606 }
std::vector< DetId > m_validGeomIds
Log< level::Info, true > LogVerbatim
int getLayer(double z, bool reco) const
unsigned int getClosestCellIndex(const GlobalPoint &r) const
const HGCalTopology & m_topology
T y() const
Definition: PV3DBase.h:60
DetId encode(const DecodedDetId &id_) const
T z() const
Definition: PV3DBase.h:61
DecodedDetId decode(const DetId &id) const
Definition: DetId.h:17
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
std::array< int, 5 > assignCellHex(float x, float y, int lay, bool reco, bool extend=false, bool debug=false) const
bool waferHexagon8() const
DetId::Detector m_det
DetId::Detector detector() const
T x() const
Definition: PV3DBase.h:59
CellVec m_cellVec
unsigned int HGCalGeometry::getClosestCellIndex ( const GlobalPoint r) const
protected

Definition at line 703 of file HGCalGeometry.cc.

References DetId::HGCalHSc, m_cellVec, m_cellVec2, and m_det.

Referenced by getClosestCell(), and getClosestCellHex().

703  {
705 }
unsigned int getClosestCellIndex(const GlobalPoint &r) const
CellVec2 m_cellVec2
DetId::Detector m_det
CellVec m_cellVec
template<class T >
unsigned int HGCalGeometry::getClosestCellIndex ( const GlobalPoint r,
const std::vector< T > &  vec 
) const
private

Definition at line 708 of file HGCalGeometry.cc.

References funct::abs(), PVValHelper::dz, getPosition(), isotrackApplyRegressor::k, M_PI, PV3DBase< T, PVType, FrameType >::phi(), z, and PV3DBase< T, PVType, FrameType >::z().

708  {
709  float phip = r.phi();
710  float zp = r.z();
711  float dzmin(9999), dphimin(9999), dphi10(0.175);
712  unsigned int cellIndex = vec.size();
713  for (unsigned int k = 0; k < vec.size(); ++k) {
714  float dphi = phip - vec[k].phiPos();
715  while (dphi > M_PI)
716  dphi -= 2 * M_PI;
717  while (dphi <= -M_PI)
718  dphi += 2 * M_PI;
719  if (std::abs(dphi) < dphi10) {
720  float dz = std::abs(zp - vec[k].getPosition().z());
721  if (dz < (dzmin + 0.001)) {
722  dzmin = dz;
723  if (std::abs(dphi) < (dphimin + 0.01)) {
724  cellIndex = k;
725  dphimin = std::abs(dphi);
726  } else {
727  if (cellIndex >= vec.size())
728  cellIndex = k;
729  }
730  }
731  }
732  }
733 #ifdef EDM_ML_DEBUG
734  edm::LogVerbatim("HGCalGeom") << "getClosestCellIndex::Input " << zp << ":" << phip << " Index " << cellIndex;
735  if (cellIndex < vec.size())
736  edm::LogVerbatim("HGCalGeom") << " Cell z " << vec[cellIndex].getPosition().z() << ":" << dzmin << " phi "
737  << vec[cellIndex].phiPos() << ":" << dphimin;
738 #endif
739  return cellIndex;
740 }
Log< level::Info, true > LogVerbatim
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T z() const
Definition: PV3DBase.h:61
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define M_PI
GlobalPoint getPosition(const DetId &id, bool debug=false) const
HGCalGeometry::CornersVec HGCalGeometry::getCorners ( const DetId id) const

Returns the corner points of this cell's volume.

Definition at line 271 of file HGCalGeometry.cc.

References HGCalDDDConstants::cellSizeTrap(), cms::cuda::co, funct::cos(), HGCalTopology::dddConstants(), debugLocate, HGCalTopology::decode(), runTauDisplay::dr, PVValHelper::dx, PVValHelper::dy, PVValHelper::dz, getPosition(), DetId::HGCalHSc, mps_fire::i, indexFor(), FlatTrd::k_Cell, FlatTrd::k_dZ, FlatHexagon::k_dZ, k_fac1, k_fac2, k_half, FlatHexagon::k_r, FlatHexagon::k_R, HGCalDDDConstants::localToGlobal8(), HGCalDDDConstants::locateCell(), HGCalDDDConstants::locateCellHex(), m_cellVec, m_cellVec2, m_det, m_topology, SiStripPI::min, FlatHexagon::ncorner_, FlatTrd::ncorner_, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), alignCSCRings::r, findQualityFiles::rr, funct::sin(), findQualityFiles::v, HGCalTopology::waferHexagon6(), HGCalDDDConstants::waferZ(), xy(), and PV3DBase< T, PVType, FrameType >::z().

271  {
272  unsigned int ncorner = ((m_det == DetId::HGCalHSc) ? FlatTrd::ncorner_ : FlatHexagon::ncorner_);
273  HGCalGeometry::CornersVec co(ncorner, GlobalPoint(0, 0, 0));
274  unsigned int cellIndex = indexFor(detid);
276  if (cellIndex < m_cellVec2.size() && m_det == DetId::HGCalHSc) {
277  GlobalPoint v = getPosition(detid, false);
278  int type = std::min(id.iType, 1);
279  std::pair<double, double> rr = m_topology.dddConstants().cellSizeTrap(type, id.iSec1);
280  float dr = k_half * (rr.second - rr.first);
281  float dfi = m_cellVec2[cellIndex].param()[FlatTrd::k_Cell];
282  float dz = id.zSide * m_cellVec2[cellIndex].param()[FlatTrd::k_dZ];
283  float r = v.perp();
284  float fi = v.phi();
285  static const int signr[] = {1, 1, -1, -1, 1, 1, -1, -1};
286  static const int signf[] = {-1, 1, 1, -1, -1, 1, 1, -1};
287  static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
288  for (unsigned int i = 0; i < ncorner; ++i) {
289  co[i] = GlobalPoint((r + signr[i] * dr) * cos(fi + signf[i] * dfi),
290  (r + signr[i] * dr) * sin(fi + signf[i] * dfi),
291  (v.z() + signz[i] * dz));
292  }
293  } else if (cellIndex < m_cellVec.size() && m_det != DetId::HGCalHSc) {
294  std::pair<float, float> xy;
295  if (m_topology.waferHexagon6()) {
296  xy = m_topology.dddConstants().locateCellHex(id.iCell1, id.iSec1, true);
297  float dx = m_cellVec[cellIndex].param()[FlatHexagon::k_r];
298  float dy = k_half * m_cellVec[cellIndex].param()[FlatHexagon::k_R];
299  float dz = m_cellVec[cellIndex].param()[FlatHexagon::k_dZ];
300  static const int signx[] = {0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1};
301  static const int signy[] = {-2, -1, 1, 2, 1, -1, -2, -1, 1, 2, 1, -1};
302  static const int signz[] = {-1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1};
303  for (unsigned int i = 0; i < ncorner; ++i) {
304  const HepGeom::Point3D<float> lcoord(xy.first + signx[i] * dx, xy.second + signy[i] * dy, signz[i] * dz);
305  co[i] = m_cellVec[cellIndex].getPosition(lcoord);
306  }
307  } else {
309  id.iLay, id.iSec1, id.iSec2, id.iCell1, id.iCell2, true, false, true, debugLocate);
310  float zz = m_topology.dddConstants().waferZ(id.iLay, true);
311  float dx = k_fac2 * m_cellVec[cellIndex].param()[FlatHexagon::k_r];
312  float dy = k_fac1 * m_cellVec[cellIndex].param()[FlatHexagon::k_R];
313  float dz = -id.zSide * m_cellVec[cellIndex].param()[FlatHexagon::k_dZ];
314  static const int signx[] = {1, -1, -2, -1, 1, 2, 1, -1, -2, -1, 1, 2};
315  static const int signy[] = {1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0};
316  static const int signz[] = {-1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1};
317  for (unsigned int i = 0; i < ncorner; ++i) {
318  auto xyglob = m_topology.dddConstants().localToGlobal8(
319  id.iLay, id.iSec1, id.iSec2, (xy.first + signx[i] * dx), (xy.second + signy[i] * dy), true, false);
320  double xx = id.zSide * xyglob.first;
321  co[i] = GlobalPoint(xx, xyglob.second, id.zSide * (zz + signz[i] * dz));
322  }
323  }
324  }
325  return co;
326 }
std::pair< double, double > cellSizeTrap(int type, int irad) const
T perp() const
Definition: PV3DBase.h:69
const HGCalTopology & m_topology
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< GlobalPoint > CornersVec
Definition: HGCalGeometry.h:38
static constexpr double k_fac2
static constexpr uint32_t k_Cell
Definition: FlatTrd.h:45
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
__host__ __device__ VT * co
Definition: prefixScan.h:47
static constexpr double k_half
static constexpr unsigned int ncorner_
Definition: FlatHexagon.h:81
static constexpr double k_fac1
std::pair< float, float > locateCellHex(int cell, int wafer, bool reco) const
static constexpr unsigned int ncorner_
Definition: FlatTrd.h:97
static constexpr uint32_t k_R
Definition: FlatHexagon.h:29
static constexpr uint32_t k_r
Definition: FlatHexagon.h:28
T z() const
Definition: PV3DBase.h:61
std::pair< float, float > localToGlobal8(int lay, int waferU, int waferV, double localX, double localY, bool reco, bool debug) const
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
unsigned int indexFor(const DetId &id) const override
CellVec2 m_cellVec2
bool waferHexagon6() const
double waferZ(int layer, bool reco) const
DecodedDetId decode(const DetId &id) const
Basic2DVector< T > xy() const
static constexpr uint32_t k_dZ
Definition: FlatHexagon.h:27
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
const bool debugLocate
GlobalPoint getPosition(const DetId &id, bool debug=false) const
static constexpr uint32_t k_dZ
Definition: FlatTrd.h:26
DetId::Detector m_det
CellVec m_cellVec
std::shared_ptr< const CaloCellGeometry > HGCalGeometry::getGeometry ( const DetId id) const
overridevirtual

Get the cell geometry of a given detector id. Should return false if not found.

Reimplemented from CaloSubdetectorGeometry.

Definition at line 181 of file HGCalGeometry.cc.

References cellGeomPtr(), HGCalTopology::detId2denseGeomId(), getGeometryDetId(), getPosition(), and m_topology.

181  {
182  if (detId == DetId())
183  return nullptr; // nothing to get
184  DetId geomId = getGeometryDetId(detId);
185  const uint32_t cellIndex(m_topology.detId2denseGeomId(geomId));
186  const GlobalPoint pos = (detId != geomId) ? getPosition(detId, false) : GlobalPoint();
187  return cellGeomPtr(cellIndex, pos);
188 }
const HGCalTopology & m_topology
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
virtual uint32_t detId2denseGeomId(const DetId &id) const
Definition: DetId.h:17
std::shared_ptr< const CaloCellGeometry > cellGeomPtr(uint32_t index) const override
GlobalPoint getPosition(const DetId &id, bool debug=false) const
DetId getGeometryDetId(DetId detId) const
DetId HGCalGeometry::getGeometryDetId ( DetId  detId) const
private

Definition at line 856 of file HGCalGeometry.cc.

References HGCalDetId::geometryCell(), HGCScintillatorDetId::geometryCell(), HGCSiliconDetId::geometryCell(), HFNoseDetId::geometryCell(), HGCalTopology::isHFNose(), m_topology, HGCalTopology::tileTrapezoid(), and HGCalTopology::waferHexagon6().

Referenced by getGeometry(), indexFor(), newCell(), and present().

856  {
857  DetId geomId;
858  if (m_topology.waferHexagon6()) {
859  geomId = static_cast<DetId>(HGCalDetId(detId).geometryCell());
860  } else if (m_topology.tileTrapezoid()) {
861  geomId = static_cast<DetId>(HGCScintillatorDetId(detId).geometryCell());
862  } else if (m_topology.isHFNose()) {
863  geomId = static_cast<DetId>(HFNoseDetId(detId).geometryCell());
864  } else {
865  geomId = static_cast<DetId>(HGCSiliconDetId(detId).geometryCell());
866  }
867  return geomId;
868 }
bool tileTrapezoid() const
const HGCalTopology & m_topology
HFNoseDetId geometryCell() const
Definition: HFNoseDetId.h:46
HGCalDetId geometryCell() const
Definition: HGCalDetId.h:34
HGCSiliconDetId geometryCell() const
HGCScintillatorDetId geometryCell() const
bool waferHexagon6() const
bool isHFNose() const
Definition: DetId.h:17
const CaloCellGeometry * HGCalGeometry::getGeometryRawPtr ( uint32_t  index) const
overrideprotectedvirtual

Implements CaloSubdetectorGeometry.

Definition at line 639 of file HGCalGeometry.cc.

References DetId::HGCalHSc, m_cellVec, m_cellVec2, m_det, and CaloCellGeometry::param().

Referenced by present().

639  {
640  // Modify the RawPtr class
641  if (m_det == DetId::HGCalHSc) {
642  if (m_cellVec2.size() < index)
643  return nullptr;
644  const CaloCellGeometry* cell(&m_cellVec2[index]);
645  return (nullptr == cell->param() ? nullptr : cell);
646  } else {
647  if (m_cellVec2.size() < index)
648  return nullptr;
649  const CaloCellGeometry* cell(&m_cellVec[index]);
650  return (nullptr == cell->param() ? nullptr : cell);
651  }
652 }
CellVec2 m_cellVec2
DetId::Detector m_det
CellVec m_cellVec
HGCalGeometry::CornersVec HGCalGeometry::getNewCorners ( const DetId id,
bool  debug = false 
) const

Definition at line 382 of file HGCalGeometry.cc.

References HGCalDDDConstants::cellSizeTrap(), cms::cuda::co, funct::cos(), HGCalTopology::dddConstants(), HGCalTopology::decode(), runTauDisplay::dr, PVValHelper::dx, PVValHelper::dy, PVValHelper::dz, getPosition(), DetId::HGCalHSc, mps_fire::i, indexFor(), FlatTrd::k_Cell, FlatTrd::k_dZ, FlatHexagon::k_dZ, k_fac1, k_fac2, k_half, FlatHexagon::k_r, FlatHexagon::k_R, HGCalDDDConstants::localToGlobal8(), HGCalDDDConstants::locateCell(), HGCalDDDConstants::locateCellHex(), m_cellVec, m_cellVec2, m_det, m_topology, SiStripPI::min, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), alignCSCRings::r, findQualityFiles::rr, funct::sin(), findQualityFiles::v, HGCalTopology::waferHexagon6(), HGCalDDDConstants::waferZ(), xy(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by FWRecoGeometryESProducer::addCaloGeometry(), and getArea().

382  {
383  unsigned int ncorner = (m_det == DetId::HGCalHSc) ? 5 : 7;
384  HGCalGeometry::CornersVec co(ncorner, GlobalPoint(0, 0, 0));
385  unsigned int cellIndex = indexFor(detid);
387  if (debug)
388  edm::LogVerbatim("HGCalGeom") << "NewCorners for Layer " << id.iLay << " Wafer " << id.iSec1 << ":" << id.iSec2
389  << " Cell " << id.iCell1 << ":" << id.iCell2;
390  if (cellIndex < m_cellVec2.size() && m_det == DetId::HGCalHSc) {
391  GlobalPoint v = getPosition(detid, false);
392  int type = std::min(id.iType, 1);
393  std::pair<double, double> rr = m_topology.dddConstants().cellSizeTrap(type, id.iSec1);
394  float dr = k_half * (rr.second - rr.first);
395  float dfi = m_cellVec2[cellIndex].param()[FlatTrd::k_Cell];
396  float dz = -id.zSide * m_cellVec2[cellIndex].param()[FlatTrd::k_dZ];
397  float r = v.perp();
398  float fi = v.phi();
399  static const int signr[] = {1, 1, -1, -1};
400  static const int signf[] = {-1, 1, 1, -1};
401  for (unsigned int i = 0; i < ncorner - 1; ++i) {
402  co[i] = GlobalPoint(
403  (r + signr[i] * dr) * cos(fi + signf[i] * dfi), (r + signr[i] * dr) * sin(fi + signf[i] * dfi), (v.z() + dz));
404  }
405  co[ncorner - 1] = co[0];
406  } else if (cellIndex < m_cellVec.size() && m_det != DetId::HGCalHSc) {
407  std::pair<float, float> xy;
408  float dx = k_fac2 * m_cellVec[cellIndex].param()[FlatHexagon::k_r];
409  float dy = k_fac1 * m_cellVec[cellIndex].param()[FlatHexagon::k_R];
410  float dz = -id.zSide * m_cellVec[cellIndex].param()[FlatHexagon::k_dZ];
411  static const int signx[] = {1, -1, -2, -1, 1, 2};
412  static const int signy[] = {1, 1, 0, -1, -1, 0};
413 #ifdef EDM_ML_DEBUG
414  if (debug)
415  edm::LogVerbatim("HGCalGeom") << "kfac " << k_fac1 << ":" << k_fac2 << " dx:dy:dz " << dx << ":" << dy << ":"
416  << dz;
417 #endif
418  if (m_topology.waferHexagon6()) {
419  xy = m_topology.dddConstants().locateCellHex(id.iCell1, id.iSec1, true);
420  for (unsigned int i = 0; i < ncorner - 1; ++i) {
421  const HepGeom::Point3D<float> lcoord(xy.first + signx[i] * dx, xy.second + signy[i] * dy, dz);
422  co[i] = m_cellVec[cellIndex].getPosition(lcoord);
423  }
424  } else {
426  id.iLay, id.iSec1, id.iSec2, id.iCell1, id.iCell2, true, false, true, debug);
427  float zz = m_topology.dddConstants().waferZ(id.iLay, true);
428  for (unsigned int i = 0; i < ncorner; ++i) {
429  double xloc = xy.first + signx[i] * dx;
430  double yloc = xy.second + signy[i] * dy;
431 #ifdef EDM_ML_DEBUG
432  if (debug)
433  edm::LogVerbatim("HGCalGeom") << "Corner " << i << " x " << xy.first << ":" << xloc << " y " << xy.second
434  << ":" << yloc << " z " << zz << ":" << id.zSide * (zz + dz);
435 #endif
436  auto xyglob = m_topology.dddConstants().localToGlobal8(id.iLay, id.iSec1, id.iSec2, xloc, yloc, true, debug);
437  double xx = id.zSide * xyglob.first;
438  co[i] = GlobalPoint(xx, xyglob.second, id.zSide * (zz + dz));
439  }
440  }
441  co[ncorner - 1] = co[0];
442  }
443  return co;
444 }
Log< level::Info, true > LogVerbatim
std::pair< double, double > cellSizeTrap(int type, int irad) const
T perp() const
Definition: PV3DBase.h:69
const HGCalTopology & m_topology
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< GlobalPoint > CornersVec
Definition: HGCalGeometry.h:38
static constexpr double k_fac2
static constexpr uint32_t k_Cell
Definition: FlatTrd.h:45
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
__host__ __device__ VT * co
Definition: prefixScan.h:47
static constexpr double k_half
static constexpr double k_fac1
std::pair< float, float > locateCellHex(int cell, int wafer, bool reco) const
static constexpr uint32_t k_R
Definition: FlatHexagon.h:29
static constexpr uint32_t k_r
Definition: FlatHexagon.h:28
T z() const
Definition: PV3DBase.h:61
std::pair< float, float > localToGlobal8(int lay, int waferU, int waferV, double localX, double localY, bool reco, bool debug) const
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
unsigned int indexFor(const DetId &id) const override
CellVec2 m_cellVec2
bool waferHexagon6() const
double waferZ(int layer, bool reco) const
DecodedDetId decode(const DetId &id) const
Basic2DVector< T > xy() const
#define debug
Definition: HDRShower.cc:19
static constexpr uint32_t k_dZ
Definition: FlatHexagon.h:27
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
GlobalPoint getPosition(const DetId &id, bool debug=false) const
static constexpr uint32_t k_dZ
Definition: FlatTrd.h:26
DetId::Detector m_det
CellVec m_cellVec
GlobalPoint HGCalGeometry::getPosition ( const DetId id,
bool  debug = false 
) const

Definition at line 198 of file HGCalGeometry.cc.

References HGCalTopology::dddConstants(), HGCalTopology::decode(), indexFor(), HGCalDDDConstants::locateCell(), HGCalDDDConstants::locateCellHex(), m_cellVec, m_cellVec2, m_topology, reco_skim_cfg_mod::maxSize, HGCalTopology::tileTrapezoid(), HGCalTopology::waferHexagon6(), HGCalDDDConstants::waferZ(), and xy().

Referenced by FWRecoGeometryESProducer::addCaloGeometry(), HGCalTBAnalyzer::analyzeDigi(), HGCalTBAnalyzer::analyzeRecHits(), HGCDigitizer::checkPosition(), HGCalRadiationMap::computeRadius(), HGCalTriggerNtupleHGCDigis::fill(), get8Corners(), getClosestCellIndex(), getCorners(), getGeometry(), HGCalTriggerGeometryV9Imp2::getModulePosition(), HGCalTriggerGeometryV9Imp3::getModulePosition(), getNewCorners(), hgcal::RecHitTools::getPosition(), HGCalTriggerGeometryV9Imp2::getTriggerCellPosition(), HGCalTriggerGeometryV9Imp3::getTriggerCellPosition(), and neighborZ().

198  {
199  unsigned int cellIndex = indexFor(detid);
200  GlobalPoint glob;
201  unsigned int maxSize = (m_topology.tileTrapezoid() ? m_cellVec2.size() : m_cellVec.size());
202  if (cellIndex < maxSize) {
204  std::pair<float, float> xy;
205  if (m_topology.waferHexagon6()) {
206  xy = m_topology.dddConstants().locateCellHex(id.iCell1, id.iSec1, true);
207  const HepGeom::Point3D<float> lcoord(xy.first, xy.second, 0);
208  glob = m_cellVec[cellIndex].getPosition(lcoord);
209  if (debug)
210  edm::LogVerbatim("HGCalGeom") << "getPosition:: index " << cellIndex << " Local " << lcoord.x() << ":"
211  << lcoord.y() << " ID " << id.iCell1 << ":" << id.iSec1 << " Global " << glob;
212  } else if (m_topology.tileTrapezoid()) {
213  const HepGeom::Point3D<float> lcoord(0, 0, 0);
214  glob = m_cellVec2[cellIndex].getPosition(lcoord);
215  if (debug)
216  edm::LogVerbatim("HGCalGeom") << "getPositionTrap:: index " << cellIndex << " Local " << lcoord.x() << ":"
217  << lcoord.y() << " ID " << id.iLay << ":" << id.iSec1 << ":" << id.iCell1
218  << " Global " << glob;
219  } else {
220  if (debug)
221  edm::LogVerbatim("HGCalGeom") << "getPosition for " << HGCSiliconDetId(detid) << " Layer " << id.iLay
222  << " Wafer " << id.iSec1 << ":" << id.iSec2 << " Cell " << id.iCell1 << ":"
223  << id.iCell2;
225  id.iLay, id.iSec1, id.iSec2, id.iCell1, id.iCell2, true, true, false, debug);
226  double xx = id.zSide * xy.first;
227  double zz = id.zSide * m_topology.dddConstants().waferZ(id.iLay, true);
228  glob = GlobalPoint(xx, xy.second, zz);
229  if (debug)
230  edm::LogVerbatim("HGCalGeom") << "getPositionWafer:: index " << cellIndex << " Local " << xy.first << ":"
231  << xy.second << " ID " << id.iLay << ":" << id.iSec1 << ":" << id.iSec2 << ":"
232  << id.iCell1 << ":" << id.iCell2 << " Global " << glob;
233  }
234  }
235  return glob;
236 }
Log< level::Info, true > LogVerbatim
bool tileTrapezoid() const
const HGCalTopology & m_topology
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
std::pair< float, float > locateCellHex(int cell, int wafer, bool reco) const
tuple maxSize
&#39;/store/data/Commissioning08/BeamHalo/RECO/StuffAlmostToP5_v1/000/061/642/10A0FE34-A67D-DD11-AD05-000...
unsigned int indexFor(const DetId &id) const override
CellVec2 m_cellVec2
bool waferHexagon6() const
double waferZ(int layer, bool reco) const
DecodedDetId decode(const DetId &id) const
Basic2DVector< T > xy() const
#define debug
Definition: HDRShower.cc:19
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
CellVec m_cellVec
void HGCalGeometry::getSummary ( CaloSubdetectorGeometry::TrVec trVector,
CaloSubdetectorGeometry::IVec iVector,
CaloSubdetectorGeometry::DimVec dimVector,
CaloSubdetectorGeometry::IVec dinsVector 
) const
overridevirtual

Reimplemented from CaloSubdetectorGeometry.

Definition at line 754 of file HGCalGeometry.cc.

References HGCalParameters::hgtrap::alpha, HGCalParameters::hgtrap::bl, cellGeomPtr(), HGCalParameters::hgtrap::cellSize, HGCalTopology::dddConstants(), HGCalTopology::detId2denseGeomId(), HGCalParameters::hgtrap::dz, HGCalParameters::firstModule_, HGCalDDDConstants::getModule(), HGCalDDDConstants::getParameter(), HGCalDDDConstants::getTrForm(), HGCalDDDConstants::getTrFormN(), runTauDisplay::gp, HGCalParameters::hgtrap::h, DetId::HGCalHSc, mps_fire::i, HGCalTopology::isHFNose(), FlatTrd::k_Alp1, FlatTrd::k_Alp2, FlatTrd::k_Cell, FlatTrd::k_dX1, FlatTrd::k_dX2, FlatTrd::k_dX3, FlatTrd::k_dX4, FlatTrd::k_dY1, FlatTrd::k_dY2, FlatTrd::k_dZ, FlatHexagon::k_dZ, k_NumberOfParametersPerHex, k_NumberOfParametersPerTrd, k_NumberOfShapes, FlatTrd::k_Phi, FlatHexagon::k_r, FlatHexagon::k_R, FlatTrd::k_Theta, HGCalParameters::lastModule_, HGCalParameters::hgtrform::lay, HGCalDetId::layer(), HGCScintillatorDetId::layer(), HFNoseDetId::layer(), HGCSiliconDetId::layer(), phase1PixelTopology::layer, HGCalDDDConstants::layerIndex(), m_det, m_topology, m_validGeomIds, CaloSubdetectorGeometry::numberOfParametersPerShape(), CaloSubdetectorGeometry::numberOfShapes(), CaloSubdetectorGeometry::numberOfTransformParms(), submitPVValidationJobs::params, findQualityFiles::rr, HGCalDDDConstants::sectors(), HGCalTopology::tileTrapezoid(), HGCalParameters::hgtrap::tl, HGCalTopology::totalGeomModules(), groupFilesInBlocks::tt, twoBysqrt3_, HGCalTopology::waferHexagon6(), and HGCalDDDConstants::waferInLayer().

757  {
758  unsigned int numberOfCells = m_topology.totalGeomModules(); // total Geom Modules both sides
759  unsigned int numberOfShapes = k_NumberOfShapes;
760  unsigned int numberOfParametersPerShape = ((m_det == DetId::HGCalHSc) ? (unsigned int)(k_NumberOfParametersPerTrd)
761  : (unsigned int)(k_NumberOfParametersPerHex));
762 
763  trVector.reserve(numberOfCells * numberOfTransformParms());
764  iVector.reserve(numberOfCells);
765  dimVector.reserve(numberOfShapes * numberOfParametersPerShape);
766  dinsVector.reserve(numberOfCells);
767 
768  for (unsigned itr = 0; itr < m_topology.dddConstants().getTrFormN(); ++itr) {
770  int layer = mytr.lay;
771 
772  if (m_topology.waferHexagon6()) {
773  for (int wafer = 0; wafer < m_topology.dddConstants().sectors(); ++wafer) {
774  if (m_topology.dddConstants().waferInLayer(wafer, layer, true)) {
775  HGCalParameters::hgtrap vol = m_topology.dddConstants().getModule(wafer, true, true);
776  ParmVec params(numberOfParametersPerShape, 0);
777  params[FlatHexagon::k_dZ] = vol.dz;
780  dimVector.insert(dimVector.end(), params.begin(), params.end());
781  }
782  }
783  } else if (m_topology.tileTrapezoid()) {
784  int indx = m_topology.dddConstants().layerIndex(layer, true);
785  for (int md = m_topology.dddConstants().getParameter()->firstModule_[indx];
787  ++md) {
789  ParmVec params(numberOfParametersPerShape, 0);
790  params[FlatTrd::k_dZ] = vol.dz;
791  params[FlatTrd::k_Theta] = params[FlatTrd::k_Phi] = 0;
792  params[FlatTrd::k_dY1] = params[FlatTrd::k_dY2] = vol.h;
793  params[FlatTrd::k_dX1] = params[FlatTrd::k_dX3] = vol.bl;
794  params[FlatTrd::k_dX2] = params[FlatTrd::k_dX4] = vol.tl;
795  params[FlatTrd::k_Alp1] = params[FlatTrd::k_Alp2] = vol.alpha;
796  params[FlatTrd::k_Cell] = vol.cellSize;
797  dimVector.insert(dimVector.end(), params.begin(), params.end());
798  }
799  } else {
800  for (int wafer = 0; wafer < m_topology.dddConstants().sectors(); ++wafer) {
801  if (m_topology.dddConstants().waferInLayer(wafer, layer, true)) {
802  HGCalParameters::hgtrap vol = m_topology.dddConstants().getModule(wafer, true, true);
803  ParmVec params(numberOfParametersPerShape, 0);
804  params[FlatHexagon::k_dZ] = vol.dz;
805  params[FlatHexagon::k_r] = vol.cellSize;
806  params[FlatHexagon::k_R] = twoBysqrt3_ * params[FlatHexagon::k_r];
807  dimVector.insert(dimVector.end(), params.begin(), params.end());
808  }
809  }
810  }
811  }
812 
813  for (unsigned int i(0); i < numberOfCells; ++i) {
814  DetId detId = m_validGeomIds[i];
815  int layer(0);
816  if (m_topology.waferHexagon6()) {
817  layer = HGCalDetId(detId).layer();
818  } else if (m_topology.tileTrapezoid()) {
819  layer = HGCScintillatorDetId(detId).layer();
820  } else if (m_topology.isHFNose()) {
821  layer = HFNoseDetId(detId).layer();
822  } else {
823  layer = HGCSiliconDetId(detId).layer();
824  }
825  dinsVector.emplace_back(m_topology.detId2denseGeomId(detId));
826  iVector.emplace_back(layer);
827 
828  Tr3D tr;
829  auto ptr = cellGeomPtr(i);
830  if (nullptr != ptr) {
831  ptr->getTransform(tr, (Pt3DVec*)nullptr);
832 
833  if (Tr3D() == tr) { // there is no rotation
834  const GlobalPoint& gp(ptr->getPosition());
835  tr = HepGeom::Translate3D(gp.x(), gp.y(), gp.z());
836  }
837 
838  const CLHEP::Hep3Vector tt(tr.getTranslation());
839  trVector.emplace_back(tt.x());
840  trVector.emplace_back(tt.y());
841  trVector.emplace_back(tt.z());
842  if (6 == numberOfTransformParms()) {
843  const CLHEP::HepRotation rr(tr.getRotation());
844  const ROOT::Math::Transform3D rtr(
845  rr.xx(), rr.xy(), rr.xz(), tt.x(), rr.yx(), rr.yy(), rr.yz(), tt.y(), rr.zx(), rr.zy(), rr.zz(), tt.z());
847  rtr.GetRotation(ea);
848  trVector.emplace_back(ea.Phi());
849  trVector.emplace_back(ea.Theta());
850  trVector.emplace_back(ea.Psi());
851  }
852  }
853  }
854 }
static constexpr unsigned int k_NumberOfShapes
Definition: HGCalGeometry.h:46
std::vector< DetId > m_validGeomIds
virtual unsigned int numberOfParametersPerShape() const
HGCalParameters::hgtrform getTrForm(unsigned int k) const
bool tileTrapezoid() const
const HGCalParameters * getParameter() const
const HGCalTopology & m_topology
static constexpr uint32_t k_Theta
Definition: FlatTrd.h:27
std::vector< float > ParmVec
static constexpr uint32_t k_Cell
Definition: FlatTrd.h:45
static constexpr uint32_t k_dY1
Definition: FlatTrd.h:31
int layerIndex(int lay, bool reco) const
constexpr std::array< uint8_t, layerIndexSize > layer
const double twoBysqrt3_
unsigned int totalGeomModules() const
Definition: HGCalTopology.h:93
std::vector< int > firstModule_
static constexpr uint32_t k_R
Definition: FlatHexagon.h:29
unsigned int getTrFormN() const
virtual uint32_t detId2denseGeomId(const DetId &id) const
static constexpr uint32_t k_r
Definition: FlatHexagon.h:28
int layer() const
get the layer #
Definition: HFNoseDetId.h:56
virtual unsigned int numberOfShapes() const
int layer() const
get the layer #
static constexpr uint32_t k_dX1
Definition: FlatTrd.h:32
static constexpr unsigned int k_NumberOfParametersPerTrd
Definition: HGCalGeometry.h:43
static constexpr uint32_t k_dY2
Definition: FlatTrd.h:38
static constexpr uint32_t k_dX4
Definition: FlatTrd.h:41
bool waferHexagon6() const
bool isHFNose() const
static constexpr unsigned int k_NumberOfParametersPerHex
Definition: HGCalGeometry.h:44
Definition: DetId.h:17
std::vector< int > lastModule_
AlgebraicVector EulerAngles
Definition: Definitions.h:34
static constexpr uint32_t k_dZ
Definition: FlatHexagon.h:27
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
static constexpr uint32_t k_Phi
Definition: FlatTrd.h:29
CaloCellGeometry::Pt3DVec Pt3DVec
CaloCellGeometry::Tr3D Tr3D
int layer() const
get the layer #
std::shared_ptr< const CaloCellGeometry > cellGeomPtr(uint32_t index) const override
static constexpr uint32_t k_dZ
Definition: FlatTrd.h:26
DetId::Detector m_det
static constexpr uint32_t k_Alp1
Definition: FlatTrd.h:36
virtual unsigned int numberOfTransformParms() const
static constexpr uint32_t k_dX3
Definition: FlatTrd.h:39
HGCalParameters::hgtrap getModule(unsigned int k, bool hexType, bool reco) const
int layer() const
get the layer #
Definition: HGCalDetId.h:46
static constexpr uint32_t k_dX2
Definition: FlatTrd.h:34
bool waferInLayer(int wafer, int lay, bool reco) const
static constexpr uint32_t k_Alp2
Definition: FlatTrd.h:43
const std::vector<DetId>& HGCalGeometry::getValidDetIds ( DetId::Detector  det = DetId::Detector(0),
int  subdet = 0 
) const
inlineoverridevirtual

Get a list of valid detector ids (for the given subdetector)

Note
The implementation in this class is relevant for SubdetectorGeometries which handle only a single subdetector at a time. It does not look at the det and subdet arguments.

Reimplemented from CaloSubdetectorGeometry.

Definition at line 89 of file HGCalGeometry.h.

References CaloSubdetectorGeometry::m_validIds.

Referenced by HGcalHitIdCheck::analyze().

89  {
90  return m_validIds;
91  }
std::vector< DetId > m_validIds
const std::vector<DetId>& HGCalGeometry::getValidGeomDetIds ( void  ) const
inline

Definition at line 92 of file HGCalGeometry.h.

References m_validGeomIds.

92 { return m_validGeomIds; }
std::vector< DetId > m_validGeomIds
GlobalPoint HGCalGeometry::getWaferPosition ( const DetId id) const

Definition at line 238 of file HGCalGeometry.cc.

References TauDecayModes::dec, indexFor(), m_cellVec, m_cellVec2, m_topology, reco_skim_cfg_mod::maxSize, DetId::rawId(), and HGCalTopology::tileTrapezoid().

238  {
239  unsigned int cellIndex = indexFor(detid);
240  GlobalPoint glob;
241  unsigned int maxSize = (m_topology.tileTrapezoid() ? m_cellVec2.size() : m_cellVec.size());
242  if (cellIndex < maxSize) {
243  const HepGeom::Point3D<float> lcoord(0, 0, 0);
244  if (m_topology.tileTrapezoid()) {
245  glob = m_cellVec2[cellIndex].getPosition(lcoord);
246  } else {
247  glob = m_cellVec[cellIndex].getPosition(lcoord);
248  }
249 #ifdef EDM_ML_DEBUG
250  edm::LogVerbatim("HGCalGeom") << "getPositionTrap:: ID " << std::hex << detid.rawId() << std::dec << " index "
251  << cellIndex << " Global " << glob;
252 #endif
253  }
254  return glob;
255 }
Log< level::Info, true > LogVerbatim
bool tileTrapezoid() const
const HGCalTopology & m_topology
tuple maxSize
&#39;/store/data/Commissioning08/BeamHalo/RECO/StuffAlmostToP5_v1/000/061/642/10A0FE34-A67D-DD11-AD05-000...
unsigned int indexFor(const DetId &id) const override
CellVec2 m_cellVec2
CellVec m_cellVec
unsigned int HGCalGeometry::indexFor ( const DetId id) const
overrideprotectedvirtual

Reimplemented from CaloSubdetectorGeometry.

Definition at line 624 of file HGCalGeometry.cc.

References TauDecayModes::dec, HGCalTopology::detId2denseGeomId(), getGeometryDetId(), DetId::HGCalHSc, m_cellVec, m_cellVec2, m_det, m_topology, and DetId::rawId().

Referenced by get8Corners(), getCorners(), getNewCorners(), getPosition(), and getWaferPosition().

624  {
625  unsigned int cellIndex = ((m_det == DetId::HGCalHSc) ? m_cellVec2.size() : m_cellVec.size());
626  if (detId != DetId()) {
627  DetId geomId = getGeometryDetId(detId);
628  cellIndex = m_topology.detId2denseGeomId(geomId);
629 #ifdef EDM_ML_DEBUG
630  edm::LogVerbatim("HGCalGeom") << "indexFor " << std::hex << detId.rawId() << ":" << geomId.rawId() << std::dec
631  << " index " << cellIndex;
632 #endif
633  }
634  return cellIndex;
635 }
Log< level::Info, true > LogVerbatim
const HGCalTopology & m_topology
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
virtual uint32_t detId2denseGeomId(const DetId &id) const
CellVec2 m_cellVec2
Definition: DetId.h:17
DetId::Detector m_det
CellVec m_cellVec
DetId getGeometryDetId(DetId detId) const
void HGCalGeometry::initializeParms ( )
overridevirtual

Reimplemented from CaloSubdetectorGeometry.

Definition at line 47 of file HGCalGeometry.cc.

47 {}
void HGCalGeometry::localCorners ( Pt3DVec lc,
const CCGFloat pv,
unsigned int  i,
Pt3D ref 
)

Definition at line 49 of file HGCalGeometry.cc.

References DetId::HGCalHSc, FlatHexagon::localCorners(), FlatTrd::localCorners(), and m_det.

49  {
50  if (m_det == DetId::HGCalHSc) {
51  FlatTrd::localCorners(lc, pv, ref);
52  } else {
53  FlatHexagon::localCorners(lc, pv, ref);
54  }
55 }
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
Definition: FlatHexagon.cc:154
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
Definition: FlatTrd.cc:153
DetId::Detector m_det
DetId HGCalGeometry::neighborZ ( const DetId idin,
const GlobalVector p 
) const

Definition at line 446 of file HGCalGeometry.cc.

References HGCalTopology::dddConstants(), HGCalTopology::decode(), HGCalDDDConstants::firstLayer(), getClosestCell(), getPosition(), HGCalDDDConstants::lastLayer(), m_topology, AlCaHLTBitMon_ParallelJobs::p, alignCSCRings::r, HGCalDDDConstants::rangeR(), topology(), findQualityFiles::v, HGCalDDDConstants::waferZ(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), z, and PV3DBase< T, PVType, FrameType >::z().

446  {
447  DetId idnew;
449  int lay = ((momentum.z() * id.zSide > 0) ? (id.iLay + 1) : (id.iLay - 1));
450 #ifdef EDM_ML_DEBUG
451  edm::LogVerbatim("HGCalGeom") << "neighborz1:: ID " << id.iLay << ":" << id.iSec1 << ":" << id.iSec2 << ":"
452  << id.iCell1 << ":" << id.iCell2 << " New Layer " << lay << " Range "
453  << m_topology.dddConstants().firstLayer() << ":"
454  << m_topology.dddConstants().lastLayer(true) << " pz " << momentum.z();
455 #endif
456  if ((lay >= m_topology.dddConstants().firstLayer()) && (lay <= m_topology.dddConstants().lastLayer(true)) &&
457  (momentum.z() != 0.0)) {
458  GlobalPoint v = getPosition(idin, false);
459  double z = id.zSide * m_topology.dddConstants().waferZ(lay, true);
460  double grad = (z - v.z()) / momentum.z();
461  GlobalPoint p(v.x() + grad * momentum.x(), v.y() + grad * momentum.y(), z);
462  double r = p.perp();
463  auto rlimit = topology().dddConstants().rangeR(z, true);
464  if (r >= rlimit.first && r <= rlimit.second)
465  idnew = getClosestCell(p);
466 #ifdef EDM_ML_DEBUG
467  edm::LogVerbatim("HGCalGeom") << "neighborz1:: Position " << v << " New Z " << z << ":" << grad << " new position "
468  << p << " r-limit " << rlimit.first << ":" << rlimit.second;
469 #endif
470  }
471  return idnew;
472 }
Log< level::Info, true > LogVerbatim
T perp() const
Definition: PV3DBase.h:69
int lastLayer(bool reco) const
const HGCalTopology & m_topology
T y() const
Definition: PV3DBase.h:60
std::pair< double, double > rangeR(double z, bool reco) const
DetId getClosestCell(const GlobalPoint &r) const override
T z() const
Definition: PV3DBase.h:61
const HGCalTopology & topology() const
double waferZ(int layer, bool reco) const
DecodedDetId decode(const DetId &id) const
Definition: DetId.h:17
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
GlobalPoint getPosition(const DetId &id, bool debug=false) const
int firstLayer() const
T x() const
Definition: PV3DBase.h:59
DetId HGCalGeometry::neighborZ ( const DetId idin,
const MagneticField bField,
int  charge,
const GlobalVector momentum 
) const

Definition at line 474 of file HGCalGeometry.cc.

References alongMomentum, Plane::build(), HGCalTopology::dddConstants(), HGCalTopology::decode(), HGCalDDDConstants::firstLayer(), getClosestCell(), getPosition(), TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::isValid(), HGCalDDDConstants::lastLayer(), M_PI, m_topology, AlCaHLTBitMon_ParallelJobs::p, PV3DBase< T, PVType, FrameType >::perp(), Propagator::propagate(), alignCSCRings::r, HGCalDDDConstants::rangeR(), topology(), findQualityFiles::v, HGCalDDDConstants::waferZ(), z, and PV3DBase< T, PVType, FrameType >::z().

477  {
478  DetId idnew;
480  int lay = ((momentum.z() * id.zSide > 0) ? (id.iLay + 1) : (id.iLay - 1));
481 #ifdef EDM_ML_DEBUG
482  edm::LogVerbatim("HGCalGeom") << "neighborz2:: ID " << id.iLay << ":" << id.iSec1 << ":" << id.iSec2 << ":"
483  << id.iCell1 << ":" << id.iCell2 << " New Layer " << lay << " Range "
484  << m_topology.dddConstants().firstLayer() << ":"
485  << m_topology.dddConstants().lastLayer(true) << " pz " << momentum.z();
486 #endif
487  if ((lay >= m_topology.dddConstants().firstLayer()) && (lay <= m_topology.dddConstants().lastLayer(true)) &&
488  (momentum.z() != 0.0)) {
489  GlobalPoint v = getPosition(idin, false);
490  double z = id.zSide * m_topology.dddConstants().waferZ(lay, true);
491  FreeTrajectoryState fts(v, momentum, charge, bField);
493  AnalyticalPropagator myAP(bField, alongMomentum, 2 * M_PI);
494  TrajectoryStateOnSurface tsos = myAP.propagate(fts, *nPlane);
495  GlobalPoint p;
496  auto rlimit = topology().dddConstants().rangeR(z, true);
497  if (tsos.isValid()) {
498  p = tsos.globalPosition();
499  double r = p.perp();
500  if (r >= rlimit.first && r <= rlimit.second)
501  idnew = getClosestCell(p);
502  }
503 #ifdef EDM_ML_DEBUG
504  edm::LogVerbatim("HGCalGeom") << "neighborz2:: Position " << v << " New Z " << z << ":" << charge << ":"
505  << tsos.isValid() << " new position " << p << " r limits " << rlimit.first << ":"
506  << rlimit.second;
507 #endif
508  }
509  return idnew;
510 }
Log< level::Info, true > LogVerbatim
T perp() const
Definition: PV3DBase.h:69
int lastLayer(bool reco) const
const HGCalTopology & m_topology
GlobalPoint globalPosition() const
std::pair< double, double > rangeR(double z, bool reco) const
DetId getClosestCell(const GlobalPoint &r) const override
static PlanePointer build(Args &&...args)
Definition: Plane.h:33
T z() const
Definition: PV3DBase.h:61
const HGCalTopology & topology() const
double waferZ(int layer, bool reco) const
#define M_PI
DecodedDetId decode(const DetId &id) const
Definition: DetId.h:17
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
GlobalPoint getPosition(const DetId &id, bool debug=false) const
int firstLayer() const
void HGCalGeometry::newCell ( const GlobalPoint f1,
const GlobalPoint f2,
const GlobalPoint f3,
const CCGFloat parm,
const DetId detId 
)
overridevirtual

Implements CaloSubdetectorGeometry.

Definition at line 57 of file HGCalGeometry.cc.

References HGCalDDDConstants::cellInLayer(), cells, CaloSubdetectorGeometry::cornersMgr(), HGCalTopology::dddConstants(), TauDecayModes::dec, HGCalTopology::decode(), HGCalTopology::detId2denseGeomId(), HGCalTopology::encode(), getGeometryDetId(), DetId::HGCalHSc, HGCalTopology::isHFNose(), HGCScintillatorDetId::layer(), m_cellVec, m_cellVec2, m_det, m_topology, m_validGeomIds, CaloSubdetectorGeometry::m_validIds, HGCalDDDConstants::numberCellsHexagon(), DetId::rawId(), HGCScintillatorDetId::ring(), HGCScintillatorDetId::setSiPM(), HGCScintillatorDetId::setType(), HGCalTopology::tileTrapezoid(), HGCalDDDConstants::tileType(), findQualityFiles::v, HGCalTopology::valid(), HGCalTopology::waferHexagon6(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by HGCalGeometryLoader::buildGeom().

58  {
59  DetId geomId = getGeometryDetId(detId);
60  int cells(0);
62  if (m_topology.waferHexagon6()) {
64 #ifdef EDM_ML_DEBUG
65  edm::LogVerbatim("HGCalGeom") << "NewCell " << HGCalDetId(detId) << " GEOM " << HGCalDetId(geomId);
66 #endif
67  } else if (m_topology.tileTrapezoid()) {
68  cells = 1;
69 #ifdef EDM_ML_DEBUG
70  edm::LogVerbatim("HGCalGeom") << "NewCell " << HGCScintillatorDetId(detId) << " GEOM "
71  << HGCScintillatorDetId(geomId);
72 #endif
73  } else {
74  cells = m_topology.dddConstants().numberCellsHexagon(id.iLay, id.iSec1, id.iSec2, false);
75 #ifdef EDM_ML_DEBUG
76  edm::LogVerbatim("HGCalGeom") << "NewCell " << HGCSiliconDetId(detId) << " GEOM " << HGCSiliconDetId(geomId);
77 #endif
78  }
79  const uint32_t cellIndex(m_topology.detId2denseGeomId(geomId));
80 
81  if (m_det == DetId::HGCalHSc) {
82  m_cellVec2.at(cellIndex) = FlatTrd(cornersMgr(), f1, f2, f3, parm);
83  } else {
84  m_cellVec.at(cellIndex) = FlatHexagon(cornersMgr(), f1, f2, f3, parm);
85  }
86  m_validGeomIds.at(cellIndex) = geomId;
87 
88 #ifdef EDM_ML_DEBUG
89  edm::LogVerbatim("HGCalGeom") << "Store for DetId " << std::hex << detId.rawId() << " GeomId " << geomId.rawId()
90  << std::dec << " Index " << cellIndex << " cells " << cells;
91  unsigned int nOld = m_validIds.size();
92 #endif
93  if (m_topology.waferHexagon6()) {
94  for (int cell = 0; cell < cells; ++cell) {
95  id.iCell1 = cell;
96  DetId idc = m_topology.encode(id);
97  if (m_topology.valid(idc)) {
98  m_validIds.emplace_back(idc);
99 #ifdef EDM_ML_DEBUG
100  edm::LogVerbatim("HGCalGeom") << "Valid Id [" << cell << "] " << HGCalDetId(idc);
101 #endif
102  }
103  }
104  } else if (m_topology.tileTrapezoid()) {
105  DetId idc = m_topology.encode(id);
106  if (m_topology.valid(idc)) {
107  HGCScintillatorDetId hid(idc);
108  std::pair<int, int> typm = m_topology.dddConstants().tileType(hid.layer(), hid.ring(), 0);
109  if (typm.first >= 0) {
110  hid.setType(typm.first);
111  hid.setSiPM(typm.second);
112  idc = static_cast<DetId>(hid);
113  }
114  m_validIds.emplace_back(idc);
115 #ifdef EDM_ML_DEBUG
116  edm::LogVerbatim("HGCalGeom") << "Valid Id [0] " << HGCScintillatorDetId(idc);
117 #endif
118  } else {
119  edm::LogWarning("HGCalGeom") << "Check " << HGCScintillatorDetId(idc) << " from " << HGCScintillatorDetId(detId)
120  << " ERROR ???";
121  }
122  } else {
123 #ifdef EDM_ML_DEBUG
124  unsigned int cellAll(0), cellSelect(0);
125 #endif
126  for (int u = 0; u < 2 * cells; ++u) {
127  for (int v = 0; v < 2 * cells; ++v) {
128  if (((v - u) < cells) && (u - v) <= cells) {
129  id.iCell1 = u;
130  id.iCell2 = v;
131  DetId idc = m_topology.encode(id);
132 #ifdef EDM_ML_DEBUG
133  ++cellAll;
134 #endif
135  if (m_topology.dddConstants().cellInLayer(id.iSec1, id.iSec2, u, v, id.iLay, true)) {
136  m_validIds.emplace_back(idc);
137 #ifdef EDM_ML_DEBUG
138  ++cellSelect;
139  edm::LogVerbatim("HGCalGeom") << "Valid Id [" << u << ", " << v << "] " << HGCSiliconDetId(idc);
140 #endif
141  }
142  }
143  }
144  }
145 #ifdef EDM_ML_DEBUG
146  edm::LogVerbatim("HGCalGeom") << "HGCalGeometry keeps " << cellSelect << " out of " << cellAll << " for wafer "
147  << id.iSec1 << ":" << id.iSec2 << " in "
148  << " layer " << id.iLay;
149 #endif
150  }
151 #ifdef EDM_ML_DEBUG
152  if (m_det == DetId::HGCalHSc) {
153  edm::LogVerbatim("HGCalGeom") << "HGCalGeometry::newCell-> [" << cellIndex << "]"
154  << " front:" << f1.x() << '/' << f1.y() << '/' << f1.z() << " back:" << f2.x() << '/'
155  << f2.y() << '/' << f2.z() << " eta|phi " << m_cellVec2[cellIndex].etaPos() << ":"
156  << m_cellVec2[cellIndex].phiPos();
157  } else {
158  edm::LogVerbatim("HGCalGeom") << "HGCalGeometry::newCell-> [" << cellIndex << "]"
159  << " front:" << f1.x() << '/' << f1.y() << '/' << f1.z() << " back:" << f2.x() << '/'
160  << f2.y() << '/' << f2.z() << " eta|phi " << m_cellVec[cellIndex].etaPos() << ":"
161  << m_cellVec[cellIndex].phiPos();
162  }
163  unsigned int nNew = m_validIds.size();
164  if (m_topology.waferHexagon6()) {
165  edm::LogVerbatim("HGCalGeom") << "ID: " << HGCalDetId(detId) << " with valid DetId from " << nOld << " to " << nNew;
166  } else if (m_topology.tileTrapezoid()) {
167  edm::LogVerbatim("HGCalGeom") << "ID: " << HGCScintillatorDetId(detId) << " with valid DetId from " << nOld
168  << " to " << nNew;
169  } else if (m_topology.isHFNose()) {
170  edm::LogVerbatim("HGCalGeom") << "ID: " << HFNoseDetId(detId) << " with valid DetId from " << nOld << " to "
171  << nNew;
172  } else {
173  edm::LogVerbatim("HGCalGeom") << "ID: " << HGCSiliconDetId(detId) << " with valid DetId from " << nOld << " to "
174  << nNew;
175  }
176  edm::LogVerbatim("HGCalGeom") << "Cell[" << cellIndex << "] " << std::hex << geomId.rawId() << ":"
177  << m_validGeomIds[cellIndex].rawId() << std::dec;
178 #endif
179 }
std::vector< DetId > m_validGeomIds
Log< level::Info, true > LogVerbatim
A base class to handle the particular shape of HGCal volumes.
Definition: FlatTrd.h:19
bool tileTrapezoid() const
bool valid(const DetId &id) const override
Is this a valid cell id.
const HGCalTopology & m_topology
bool cellInLayer(int waferU, int waferV, int cellU, int cellV, int lay, bool reco) const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
T y() const
Definition: PV3DBase.h:60
virtual uint32_t detId2denseGeomId(const DetId &id) const
int numberCellsHexagon(int wafer) const
DetId encode(const DecodedDetId &id_) const
std::vector< DetId > m_validIds
T z() const
Definition: PV3DBase.h:61
A base class to handle the hexagonal shape of HGCal silicon volumes.
Definition: FlatHexagon.h:20
CellVec2 m_cellVec2
bool waferHexagon6() const
bool isHFNose() const
DecodedDetId decode(const DetId &id) const
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ cells
Definition: DetId.h:17
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
CaloCellGeometry::CornersMgr * cornersMgr()
DetId::Detector m_det
Log< level::Warning, false > LogWarning
std::pair< int, int > tileType(int layer, int ring, int phi) const
T x() const
Definition: PV3DBase.h:59
CellVec m_cellVec
DetId getGeometryDetId(DetId detId) const
bool HGCalGeometry::present ( const DetId id) const
overridevirtual

is this detid present in the geometry?

Reimplemented from CaloSubdetectorGeometry.

Definition at line 190 of file HGCalGeometry.cc.

References HGCalTopology::detId2denseGeomId(), getGeometryDetId(), getGeometryRawPtr(), and m_topology.

190  {
191  if (detId == DetId())
192  return false;
193  DetId geomId = getGeometryDetId(detId);
194  const uint32_t index(m_topology.detId2denseGeomId(geomId));
195  return (nullptr != getGeometryRawPtr(index));
196 }
const HGCalTopology & m_topology
virtual uint32_t detId2denseGeomId(const DetId &id) const
const CaloCellGeometry * getGeometryRawPtr(uint32_t index) const override
Definition: DetId.h:17
DetId getGeometryDetId(DetId detId) const
static std::string HGCalGeometry::producerTag ( )
inlinestatic
unsigned int HGCalGeometry::sizeForDenseIndex ( ) const
protected

Definition at line 637 of file HGCalGeometry.cc.

References m_topology, and HGCalTopology::totalGeomModules().

637 { return m_topology.totalGeomModules(); }
const HGCalTopology & m_topology
unsigned int totalGeomModules() const
Definition: HGCalTopology.h:93
void HGCalGeometry::sortDetIds ( void  )

Definition at line 749 of file HGCalGeometry.cc.

References CaloSubdetectorGeometry::m_validIds.

Referenced by HGCalGeometryLoader::build().

749  {
750  m_validIds.shrink_to_fit();
751  std::sort(m_validIds.begin(), m_validIds.end(), rawIdSort());
752 }
std::vector< DetId > m_validIds
const HGCalTopology& HGCalGeometry::topology ( ) const
inline

Member Data Documentation

constexpr double HGCalGeometry::k_fac1 = 0.5
staticprivate

Definition at line 135 of file HGCalGeometry.h.

Referenced by get8Corners(), getCorners(), and getNewCorners().

constexpr double HGCalGeometry::k_fac2 = 1.0 / 3.0
staticprivate

Definition at line 136 of file HGCalGeometry.h.

Referenced by get8Corners(), getCorners(), and getNewCorners().

constexpr double HGCalGeometry::k_half = 0.5
staticprivate

Definition at line 134 of file HGCalGeometry.h.

Referenced by get8Corners(), getCorners(), and getNewCorners().

constexpr unsigned int HGCalGeometry::k_NumberOfParametersPerHex = 3
static

Definition at line 44 of file HGCalGeometry.h.

Referenced by HGCalGeometryLoader::build(), and getSummary().

constexpr unsigned int HGCalGeometry::k_NumberOfParametersPerShape = 3
static

Definition at line 45 of file HGCalGeometry.h.

Referenced by CaloGeometryDBEP< T, U >::produceAligned().

constexpr unsigned int HGCalGeometry::k_NumberOfParametersPerTrd = 12
static

Definition at line 43 of file HGCalGeometry.h.

Referenced by HGCalGeometryLoader::build(), and getSummary().

constexpr unsigned int HGCalGeometry::k_NumberOfShapes = 100
static
constexpr unsigned int HGCalGeometry::k_NumberOfShapesTrd = 1000
static

Definition at line 47 of file HGCalGeometry.h.

Referenced by HGCalGeometryLoader::build().

CellVec HGCalGeometry::m_cellVec
private
CellVec2 HGCalGeometry::m_cellVec2
private
DetId::Detector HGCalGeometry::m_det
private
ForwardSubdetector HGCalGeometry::m_subdet
private

Definition at line 143 of file HGCalGeometry.h.

Referenced by cellElement().

const HGCalTopology& HGCalGeometry::m_topology
private
std::vector<DetId> HGCalGeometry::m_validGeomIds
private
const double HGCalGeometry::twoBysqrt3_
private

Definition at line 144 of file HGCalGeometry.h.

Referenced by getSummary().