CMS 3D CMS Logo

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 CaloCellGeometrygetGeometry (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 cog, bool debug) 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 bool valid (const DetId &id) 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 CaloCellGeometrycellGeomPtr (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
 
virtual unsigned int sizeForDenseIndex (const DetId &id) const
 
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 CaloCellGeometrycellGeomPtr (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

◆ AlignedRecord

Definition at line 40 of file HGCalGeometry.h.

◆ CCGFloat

Definition at line 33 of file HGCalGeometry.h.

◆ CellVec

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

Definition at line 31 of file HGCalGeometry.h.

◆ CellVec2

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

Definition at line 32 of file HGCalGeometry.h.

◆ CornersVec

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

Definition at line 38 of file HGCalGeometry.h.

◆ DetIdSet

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

Definition at line 37 of file HGCalGeometry.h.

◆ PGeometryRecord

Definition at line 41 of file HGCalGeometry.h.

◆ Pt3D

Definition at line 34 of file HGCalGeometry.h.

◆ Pt3DVec

Definition at line 35 of file HGCalGeometry.h.

Constructor & Destructor Documentation

◆ HGCalGeometry()

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
unsigned int totalGeomModules() const
Definition: HGCalTopology.h:93
std::vector< FlatHexagon > CellVec
Definition: HGCalGeometry.h:31
const HGCalTopology & m_topology
unsigned int totalModules() const
Definition: HGCalTopology.h:92
const double twoBysqrt3_
T sqrt(T t)
Definition: SSEVec.h:23
std::vector< DetId > m_validIds
CellVec2 m_cellVec2
ForwardSubdetector m_subdet
std::vector< FlatTrd > CellVec2
Definition: HGCalGeometry.h:32
DetId::Detector m_det
CellVec m_cellVec

◆ ~HGCalGeometry()

HGCalGeometry::~HGCalGeometry ( )
overridedefault

Member Function Documentation

◆ addValidID()

void HGCalGeometry::addValidID ( const DetId id)
protected

Definition at line 726 of file HGCalGeometry.cc.

726  {
727  edm::LogError("HGCalGeom") << "HGCalGeometry::addValidID is not implemented";
728 }
Log< level::Error, false > LogError

◆ cellElement()

std::string HGCalGeometry::cellElement ( ) const

Definition at line 640 of file HGCalGeometry.cc.

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

640  {
641  if (m_subdet == HGCEE || m_det == DetId::HGCalEE)
642  return "HGCalEE";
643  else if (m_subdet == HGCHEF || m_det == DetId::HGCalHSi)
644  return "HGCalHEFront";
645  else if (m_subdet == HGCHEB || m_det == DetId::HGCalHSc)
646  return "HGCalHEBack";
647  else
648  return "Unknown";
649 }
ForwardSubdetector m_subdet
DetId::Detector m_det

◆ cellGeomPtr() [1/2]

std::shared_ptr< const CaloCellGeometry > HGCalGeometry::cellGeomPtr ( uint32_t  index) const
overrideprotectedvirtual

Reimplemented from CaloSubdetectorGeometry.

Definition at line 681 of file HGCalGeometry.cc.

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

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

681  {
682  if ((index >= m_cellVec.size() && m_det != DetId::HGCalHSc) ||
683  (index >= m_cellVec2.size() && m_det == DetId::HGCalHSc) || (m_validGeomIds[index].rawId() == 0))
684  return nullptr;
685  static const auto do_not_delete = [](const void*) {};
686  if (m_det == DetId::HGCalHSc) {
687  auto cell = std::shared_ptr<const CaloCellGeometry>(&m_cellVec2[index], do_not_delete);
688  if (nullptr == cell->param())
689  return nullptr;
690  return cell;
691  } else {
692  auto cell = std::shared_ptr<const CaloCellGeometry>(&m_cellVec[index], do_not_delete);
693  if (nullptr == cell->param())
694  return nullptr;
695  return cell;
696  }
697 }
std::vector< DetId > m_validGeomIds
CellVec2 m_cellVec2
DetId::Detector m_det
CellVec m_cellVec

◆ cellGeomPtr() [2/2]

std::shared_ptr< const CaloCellGeometry > HGCalGeometry::cellGeomPtr ( uint32_t  index,
const GlobalPoint p 
) const
private

Definition at line 699 of file HGCalGeometry.cc.

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

699  {
700  if ((index >= m_cellVec.size() && m_det != DetId::HGCalHSc) ||
701  (index >= m_cellVec2.size() && m_det == DetId::HGCalHSc) || (m_validGeomIds[index].rawId() == 0))
702  return nullptr;
703  if (pos == GlobalPoint())
704  return cellGeomPtr(index);
705  if (m_det == DetId::HGCalHSc) {
706  auto cell = std::make_shared<FlatTrd>(m_cellVec2[index]);
707  cell->setPosition(pos);
708 #ifdef EDM_ML_DEBUG
709  edm::LogVerbatim("HGCalGeom") << "cellGeomPtr " << index << ":" << cell;
710 #endif
711  if (nullptr == cell->param())
712  return nullptr;
713  return cell;
714  } else {
715  auto cell = std::make_shared<FlatHexagon>(m_cellVec[index]);
716  cell->setPosition(pos);
717 #ifdef EDM_ML_DEBUG
718  edm::LogVerbatim("HGCalGeom") << "cellGeomPtr " << index << ":" << cell;
719 #endif
720  if (nullptr == cell->param())
721  return nullptr;
722  return cell;
723  }
724 }
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

◆ dbString()

static std::string HGCalGeometry::dbString ( )
inlinestatic

Definition at line 49 of file HGCalGeometry.h.

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

49 { return "PHGCalRcd"; }

◆ fillNamedParams()

void HGCalGeometry::fillNamedParams ( DDFilteredView  fv)
virtual

Definition at line 45 of file HGCalGeometry.cc.

45 {}

◆ get8Corners()

HGCalGeometry::CornersVec HGCalGeometry::get8Corners ( const DetId id) const

Definition at line 346 of file HGCalGeometry.cc.

References HGCalDDDConstants::cellSizeTrap(), cms::cuda::co, funct::cos(), HGCalTopology::dddConstants(), debugLocate, HGCalTopology::decode(), l1ctLayer1_cff::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_, alignCSCRings::r, findQualityFiles::rr, funct::sin(), findQualityFiles::v, HGCalTopology::waferHexagon6(), HGCalDDDConstants::waferZ(), geometryCSVtoXML::xx, geometryCSVtoXML::xy, and geometryCSVtoXML::zz.

346  {
347  unsigned int ncorner = FlatTrd::ncorner_;
348  HGCalGeometry::CornersVec co(ncorner, GlobalPoint(0, 0, 0));
349  unsigned int cellIndex = indexFor(detid);
351  if (cellIndex < m_cellVec2.size() && m_det == DetId::HGCalHSc) {
352  GlobalPoint v = getPosition(detid, false);
353  int type = std::min(id.iType, 1);
354  std::pair<double, double> rr = m_topology.dddConstants().cellSizeTrap(type, id.iSec1);
355  float dr = k_half * (rr.second - rr.first);
356  float dfi = m_cellVec2[cellIndex].param()[FlatTrd::k_Cell];
357  float dz = id.zSide * m_cellVec2[cellIndex].param()[FlatTrd::k_dZ];
358  float r = v.perp();
359  float fi = v.phi();
360  static const int signr[] = {1, 1, -1, -1, 1, 1, -1, -1};
361  static const int signf[] = {-1, 1, 1, -1, -1, 1, 1, -1};
362  static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
363  for (unsigned int i = 0; i < ncorner; ++i) {
364  co[i] = GlobalPoint((r + signr[i] * dr) * cos(fi + signf[i] * dfi),
365  (r + signr[i] * dr) * sin(fi + signf[i] * dfi),
366  (v.z() + signz[i] * dz));
367  }
368  } else if (cellIndex < m_cellVec.size() && m_det != DetId::HGCalHSc) {
369  std::pair<float, float> xy;
370  float dx(0);
371  static const int signx[] = {-1, -1, 1, 1, -1, -1, 1, 1};
372  static const int signy[] = {-1, 1, 1, -1, -1, 1, 1, -1};
373  static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
374  if (m_topology.waferHexagon6()) {
375  xy = m_topology.dddConstants().locateCellHex(id.iCell1, id.iSec1, true);
376  dx = m_cellVec[cellIndex].param()[FlatHexagon::k_r];
377  float dz = m_cellVec[cellIndex].param()[FlatHexagon::k_dZ];
378  for (unsigned int i = 0; i < ncorner; ++i) {
379  const HepGeom::Point3D<float> lcoord(xy.first + signx[i] * dx, xy.second + signy[i] * dx, signz[i] * dz);
380  co[i] = m_cellVec[cellIndex].getPosition(lcoord);
381  }
382  } else {
384  id.zSide, id.iLay, id.iSec1, id.iSec2, id.iCell1, id.iCell2, true, false, true, false, debugLocate);
385  dx = k_fac2 * m_cellVec[cellIndex].param()[FlatHexagon::k_r];
386  float dy = k_fac1 * m_cellVec[cellIndex].param()[FlatHexagon::k_R];
387  float dz = -id.zSide * m_cellVec[cellIndex].param()[FlatHexagon::k_dZ];
388  float zz = m_topology.dddConstants().waferZ(id.iLay, true);
389  for (unsigned int i = 0; i < ncorner; ++i) {
390  auto xyglob = m_topology.dddConstants().localToGlobal8(
391  id.zSide, id.iLay, id.iSec1, id.iSec2, (xy.first + signx[i] * dx), (xy.second + signy[i] * dy), true, false);
392  double xx = id.zSide * xyglob.first;
393  co[i] = GlobalPoint(xx, xyglob.second, id.zSide * (zz + signz[i] * dz));
394  }
395  }
396  }
397  return co;
398 }
double waferZ(int layer, bool reco) const
std::pair< double, double > cellSizeTrap(int type, int irad) const
const HGCalTopology & m_topology
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
bool waferHexagon6() const
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
__host__ __device__ VT * co
Definition: prefixScan.h:47
static constexpr double k_half
static constexpr double k_fac1
static constexpr unsigned int ncorner_
Definition: FlatTrd.h:97
GlobalPoint getPosition(const DetId &id, bool cog, bool debug) const
static constexpr uint32_t k_R
Definition: FlatHexagon.h:29
static constexpr uint32_t k_r
Definition: FlatHexagon.h:28
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
unsigned int indexFor(const DetId &id) const override
DecodedDetId decode(const DetId &id) const
CellVec2 m_cellVec2
static constexpr uint32_t k_dZ
Definition: FlatHexagon.h:27
std::pair< float, float > locateCellHex(int cell, int wafer, bool reco) const
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
const bool debugLocate
static constexpr uint32_t k_dZ
Definition: FlatTrd.h:26
DetId::Detector m_det
std::pair< float, float > localToGlobal8(int zside, int lay, int waferU, int waferV, double localX, double localY, bool reco, bool debug) const
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
CellVec m_cellVec

◆ getArea()

double HGCalGeometry::getArea ( const DetId detid) const

Returns area of a cell.

Definition at line 275 of file HGCalGeometry.cc.

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

275  {
276  HGCalGeometry::CornersVec corners = getNewCorners(detid);
277  double area(0);
278  if (corners.size() > 1) {
279  int n = corners.size() - 1;
280  int j = n - 1;
281  for (int i = 0; i < n; ++i) {
282  area += ((corners[j].x() + corners[i].x()) * (corners[i].y() - corners[j].y()));
283  j = i;
284  }
285  }
286  return std::abs(0.5 * area);
287 }
std::vector< GlobalPoint > CornersVec
Definition: HGCalGeometry.h:38
CornersVec getNewCorners(const DetId &id, bool debug=false) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ getCells()

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 635 of file HGCalGeometry.cc.

635  {
637  return dss;
638 }
std::set< DetId > DetIdSet
Definition: HGCalGeometry.h:37

◆ getClosestCell()

DetId HGCalGeometry::getClosestCell ( const GlobalPoint r) const
overridevirtual

Reimplemented from CaloSubdetectorGeometry.

Definition at line 533 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, DTRecHitClients_cfi::local, m_cellVec, m_cellVec2, m_det, m_topology, m_validGeomIds, alignCSCRings::r, HGCalTopology::tileTrapezoid(), HGCalTopology::waferHexagon6(), HGCalDDDConstants::waferTypeT(), and ecaldqm::zside().

Referenced by neighborZ().

533  {
534  unsigned int cellIndex = getClosestCellIndex(r);
535  if ((cellIndex < m_cellVec.size() && m_det != DetId::HGCalHSc) ||
536  (cellIndex < m_cellVec2.size() && m_det == DetId::HGCalHSc)) {
538  if (id.det == 0)
539  id.det = static_cast<int>(m_topology.detector());
540  HepGeom::Point3D<float> local;
541  if (r.z() > 0) {
542  local = HepGeom::Point3D<float>(r.x(), r.y(), 0);
543  id.zSide = 1;
544  } else {
545  local = HepGeom::Point3D<float>(-r.x(), r.y(), 0);
546  id.zSide = -1;
547  }
548  if (m_topology.waferHexagon6()) {
549  const auto& kxy = m_topology.dddConstants().assignCell(local.x(), local.y(), id.iLay, id.iType, true);
550  id.iCell1 = kxy.second;
551  id.iSec1 = kxy.first;
552  id.iType = m_topology.dddConstants().waferTypeT(kxy.first);
553  if (id.iType != 1)
554  id.iType = -1;
555  } else if (m_topology.tileTrapezoid()) {
556  id.iLay = m_topology.dddConstants().getLayer(r.z(), true);
557  const auto& kxy = m_topology.dddConstants().assignCellTrap(r.x(), r.y(), r.z(), id.iLay, true);
558  id.iSec1 = kxy[0];
559  id.iCell1 = kxy[1];
560  id.iType = kxy[2];
561  } else {
562  id.iLay = m_topology.dddConstants().getLayer(r.z(), true);
563  int zside = (r.z() > 0) ? 1 : -1;
564 #ifdef EDM_ML_DEBUG
565  edm::LogVerbatim("HGCalGeom") << "ZZ " << r.z() << ":" << zside << " Layer " << id.iLay << " Global " << r
566  << " Local " << local;
567 #endif
568  const auto& kxy =
569  m_topology.dddConstants().assignCellHex(local.x(), local.y(), zside, id.iLay, true, false, true);
570  id.iSec1 = kxy[0];
571  id.iSec2 = kxy[1];
572  id.iType = kxy[2];
573  id.iCell1 = kxy[3];
574  id.iCell2 = kxy[4];
575  }
576 #ifdef EDM_ML_DEBUG
577  edm::LogVerbatim("HGCalGeom") << "getClosestCell: local " << local << " Id " << id.det << ":" << id.zSide << ":"
578  << id.iLay << ":" << id.iSec1 << ":" << id.iSec2 << ":" << id.iType << ":"
579  << id.iCell1 << ":" << id.iCell2;
580 #endif
581 
582  //check if returned cell is valid
583  if (id.iCell1 >= 0)
584  return m_topology.encode(id);
585  }
586 
587  //if not valid or out of bounds return a null DetId
588  return DetId();
589 }
std::vector< DetId > m_validGeomIds
Log< level::Info, true > LogVerbatim
DetId::Detector detector() const
bool tileTrapezoid() const
const HGCalTopology & m_topology
bool waferHexagon6() const
int waferTypeT(int wafer) const
int zside(DetId const &)
std::array< int, 5 > assignCellHex(float x, float y, int zside, int lay, bool reco, bool extend, bool debug) const
unsigned int getClosestCellIndex(const GlobalPoint &r) const
DecodedDetId decode(const DetId &id) const
std::pair< int, int > assignCell(float x, float y, int lay, int subSec, bool reco) const
CellVec2 m_cellVec2
Definition: DetId.h:17
std::array< int, 3 > assignCellTrap(float x, float y, float z, int lay, bool reco) const
DetId encode(const DecodedDetId &id_) const
int getLayer(double z, bool reco) const
DetId::Detector m_det
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
CellVec m_cellVec

◆ getClosestCellHex()

DetId HGCalGeometry::getClosestCellHex ( const GlobalPoint r,
bool  extend 
) const

Definition at line 591 of file HGCalGeometry.cc.

References HGCalDDDConstants::assignCellHex(), HGCalTopology::dddConstants(), HGCalTopology::decode(), HGCalTopology::DecodedDetId::det, HGCalTopology::detector(), HGCalTopology::encode(), getClosestCellIndex(), HGCalDDDConstants::getLayer(), DetId::HGCalHSc, DTRecHitClients_cfi::local, m_cellVec, m_det, m_topology, m_validGeomIds, alignCSCRings::r, HGCalTopology::waferHexagon8(), and ecaldqm::zside().

591  {
592  unsigned int cellIndex = getClosestCellIndex(r);
593  if (cellIndex < m_cellVec.size() && m_det != DetId::HGCalHSc) {
595  if (id.det == 0)
596  id.det = static_cast<int>(m_topology.detector());
597  HepGeom::Point3D<float> local;
598  if (r.z() > 0) {
599  local = HepGeom::Point3D<float>(r.x(), r.y(), 0);
600  id.zSide = 1;
601  } else {
602  local = HepGeom::Point3D<float>(-r.x(), r.y(), 0);
603  id.zSide = -1;
604  }
605  if (m_topology.waferHexagon8()) {
606  id.iLay = m_topology.dddConstants().getLayer(r.z(), true);
607  int zside = (r.z() > 0) ? 1 : -1;
608 #ifdef EDM_ML_DEBUG
609  edm::LogVerbatim("HGCalGeom") << "ZZ " << r.z() << ":" << zside << " Layer " << id.iLay << " Global " << r
610  << " Local " << local;
611 #endif
612  const auto& kxy =
613  m_topology.dddConstants().assignCellHex(local.x(), local.y(), zside, id.iLay, true, extend, true);
614  id.iSec1 = kxy[0];
615  id.iSec2 = kxy[1];
616  id.iType = kxy[2];
617  id.iCell1 = kxy[3];
618  id.iCell2 = kxy[4];
619  }
620 #ifdef EDM_ML_DEBUG
621  edm::LogVerbatim("HGCalGeom") << "getClosestCell: local " << local << " Id " << id.det << ":" << id.zSide << ":"
622  << id.iLay << ":" << id.iSec1 << ":" << id.iSec2 << ":" << id.iType << ":"
623  << id.iCell1 << ":" << id.iCell2;
624 #endif
625 
626  //check if returned cell is valid
627  if (id.iCell1 >= 0)
628  return m_topology.encode(id);
629  }
630 
631  //if not valid or out of bounds return a null DetId
632  return DetId();
633 }
std::vector< DetId > m_validGeomIds
Log< level::Info, true > LogVerbatim
DetId::Detector detector() const
const HGCalTopology & m_topology
int zside(DetId const &)
std::array< int, 5 > assignCellHex(float x, float y, int zside, int lay, bool reco, bool extend, bool debug) const
unsigned int getClosestCellIndex(const GlobalPoint &r) const
DecodedDetId decode(const DetId &id) const
Definition: DetId.h:17
DetId encode(const DecodedDetId &id_) const
bool waferHexagon8() const
int getLayer(double z, bool reco) const
DetId::Detector m_det
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
CellVec m_cellVec

◆ getClosestCellIndex() [1/2]

unsigned int HGCalGeometry::getClosestCellIndex ( const GlobalPoint r) const
protected

Definition at line 730 of file HGCalGeometry.cc.

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

Referenced by getClosestCell(), and getClosestCellHex().

730  {
732 }
unsigned int getClosestCellIndex(const GlobalPoint &r) const
CellVec2 m_cellVec2
DetId::Detector m_det
CellVec m_cellVec

◆ getClosestCellIndex() [2/2]

template<class T >
unsigned int HGCalGeometry::getClosestCellIndex ( const GlobalPoint r,
const std::vector< T > &  vec 
) const
private

Definition at line 735 of file HGCalGeometry.cc.

References funct::abs(), PVValHelper::dz, getPosition(), dqmdumpme::k, M_PI, alignCSCRings::r, and z.

735  {
736  float phip = r.phi();
737  float zp = r.z();
738  float dzmin(9999), dphimin(9999), dphi10(0.175);
739  unsigned int cellIndex = vec.size();
740  for (unsigned int k = 0; k < vec.size(); ++k) {
741  float dphi = phip - vec[k].phiPos();
742  while (dphi > M_PI)
743  dphi -= 2 * M_PI;
744  while (dphi <= -M_PI)
745  dphi += 2 * M_PI;
746  if (std::abs(dphi) < dphi10) {
747  float dz = std::abs(zp - vec[k].getPosition().z());
748  if (dz < (dzmin + 0.001)) {
749  dzmin = dz;
750  if (std::abs(dphi) < (dphimin + 0.01)) {
751  cellIndex = k;
752  dphimin = std::abs(dphi);
753  } else {
754  if (cellIndex >= vec.size())
755  cellIndex = k;
756  }
757  }
758  }
759  }
760 #ifdef EDM_ML_DEBUG
761  edm::LogVerbatim("HGCalGeom") << "getClosestCellIndex::Input " << zp << ":" << phip << " Index " << cellIndex;
762  if (cellIndex < vec.size())
763  edm::LogVerbatim("HGCalGeom") << " Cell z " << vec[cellIndex].getPosition().z() << ":" << dzmin << " phi "
764  << vec[cellIndex].phiPos() << ":" << dphimin;
765 #endif
766  return cellIndex;
767 }
Log< level::Info, true > LogVerbatim
GlobalPoint getPosition(const DetId &id, bool cog, bool debug) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define M_PI

◆ getCorners()

HGCalGeometry::CornersVec HGCalGeometry::getCorners ( const DetId id) const

Returns the corner points of this cell's volume.

Definition at line 289 of file HGCalGeometry.cc.

References HGCalDDDConstants::cellSizeTrap(), cms::cuda::co, funct::cos(), HGCalTopology::dddConstants(), debugLocate, HGCalTopology::decode(), l1ctLayer1_cff::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_, alignCSCRings::r, findQualityFiles::rr, funct::sin(), findQualityFiles::v, HGCalTopology::waferHexagon6(), HGCalDDDConstants::waferZ(), geometryCSVtoXML::xx, geometryCSVtoXML::xy, and geometryCSVtoXML::zz.

289  {
290  unsigned int ncorner = ((m_det == DetId::HGCalHSc) ? FlatTrd::ncorner_ : FlatHexagon::ncorner_);
291  HGCalGeometry::CornersVec co(ncorner, GlobalPoint(0, 0, 0));
292  unsigned int cellIndex = indexFor(detid);
294  if (cellIndex < m_cellVec2.size() && m_det == DetId::HGCalHSc) {
295  GlobalPoint v = getPosition(detid, false);
296  int type = std::min(id.iType, 1);
297  std::pair<double, double> rr = m_topology.dddConstants().cellSizeTrap(type, id.iSec1);
298  float dr = k_half * (rr.second - rr.first);
299  float dfi = m_cellVec2[cellIndex].param()[FlatTrd::k_Cell];
300  float dz = id.zSide * m_cellVec2[cellIndex].param()[FlatTrd::k_dZ];
301  float r = v.perp();
302  float fi = v.phi();
303  static const int signr[] = {1, 1, -1, -1, 1, 1, -1, -1};
304  static const int signf[] = {-1, 1, 1, -1, -1, 1, 1, -1};
305  static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
306  for (unsigned int i = 0; i < ncorner; ++i) {
307  co[i] = GlobalPoint((r + signr[i] * dr) * cos(fi + signf[i] * dfi),
308  (r + signr[i] * dr) * sin(fi + signf[i] * dfi),
309  (v.z() + signz[i] * dz));
310  }
311  } else if (cellIndex < m_cellVec.size() && m_det != DetId::HGCalHSc) {
312  std::pair<float, float> xy;
313  if (m_topology.waferHexagon6()) {
314  xy = m_topology.dddConstants().locateCellHex(id.iCell1, id.iSec1, true);
315  float dx = m_cellVec[cellIndex].param()[FlatHexagon::k_r];
316  float dy = k_half * m_cellVec[cellIndex].param()[FlatHexagon::k_R];
317  float dz = m_cellVec[cellIndex].param()[FlatHexagon::k_dZ];
318  static const int signx[] = {0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1};
319  static const int signy[] = {-2, -1, 1, 2, 1, -1, -2, -1, 1, 2, 1, -1};
320  static const int signz[] = {-1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1};
321  for (unsigned int i = 0; i < ncorner; ++i) {
322  const HepGeom::Point3D<float> lcoord(xy.first + signx[i] * dx, xy.second + signy[i] * dy, signz[i] * dz);
323  co[i] = m_cellVec[cellIndex].getPosition(lcoord);
324  }
325  } else {
327  id.zSide, id.iLay, id.iSec1, id.iSec2, id.iCell1, id.iCell2, true, false, true, false, debugLocate);
328  float zz = m_topology.dddConstants().waferZ(id.iLay, true);
329  float dx = k_fac2 * m_cellVec[cellIndex].param()[FlatHexagon::k_r];
330  float dy = k_fac1 * m_cellVec[cellIndex].param()[FlatHexagon::k_R];
331  float dz = -id.zSide * m_cellVec[cellIndex].param()[FlatHexagon::k_dZ];
332  static const int signx[] = {1, -1, -2, -1, 1, 2, 1, -1, -2, -1, 1, 2};
333  static const int signy[] = {1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0};
334  static const int signz[] = {-1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1};
335  for (unsigned int i = 0; i < ncorner; ++i) {
336  auto xyglob = m_topology.dddConstants().localToGlobal8(
337  id.zSide, id.iLay, id.iSec1, id.iSec2, (xy.first + signx[i] * dx), (xy.second + signy[i] * dy), true, false);
338  double xx = id.zSide * xyglob.first;
339  co[i] = GlobalPoint(xx, xyglob.second, id.zSide * (zz + signz[i] * dz));
340  }
341  }
342  }
343  return co;
344 }
double waferZ(int layer, bool reco) const
std::pair< double, double > cellSizeTrap(int type, int irad) const
const HGCalTopology & m_topology
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
bool waferHexagon6() const
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
__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
static constexpr unsigned int ncorner_
Definition: FlatTrd.h:97
GlobalPoint getPosition(const DetId &id, bool cog, bool debug) const
static constexpr uint32_t k_R
Definition: FlatHexagon.h:29
static constexpr uint32_t k_r
Definition: FlatHexagon.h:28
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
unsigned int indexFor(const DetId &id) const override
DecodedDetId decode(const DetId &id) const
CellVec2 m_cellVec2
static constexpr uint32_t k_dZ
Definition: FlatHexagon.h:27
std::pair< float, float > locateCellHex(int cell, int wafer, bool reco) const
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
const bool debugLocate
static constexpr uint32_t k_dZ
Definition: FlatTrd.h:26
DetId::Detector m_det
std::pair< float, float > localToGlobal8(int zside, int lay, int waferU, int waferV, double localX, double localY, bool reco, bool debug) const
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
CellVec m_cellVec

◆ getGeometry()

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 187 of file HGCalGeometry.cc.

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

187  {
188  if (detId == DetId())
189  return nullptr; // nothing to get
190  DetId geomId = getGeometryDetId(detId);
191  const uint32_t cellIndex(m_topology.detId2denseGeomId(geomId));
192  const GlobalPoint pos = (detId != geomId) ? getPosition(detId, false) : GlobalPoint();
193  return cellGeomPtr(cellIndex, pos);
194 }
const HGCalTopology & m_topology
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
GlobalPoint getPosition(const DetId &id, bool cog, bool debug) const
virtual uint32_t detId2denseGeomId(const DetId &id) const
DetId getGeometryDetId(DetId detId) const
Definition: DetId.h:17
std::shared_ptr< const CaloCellGeometry > cellGeomPtr(uint32_t index) const override

◆ getGeometryDetId()

DetId HGCalGeometry::getGeometryDetId ( DetId  detId) const
private

Definition at line 883 of file HGCalGeometry.cc.

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

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

883  {
884  DetId geomId;
885  if (m_topology.waferHexagon6()) {
886  geomId = static_cast<DetId>(HGCalDetId(detId).geometryCell());
887  } else if (m_topology.tileTrapezoid()) {
888  geomId = static_cast<DetId>(HGCScintillatorDetId(detId).geometryCell());
889  } else if (m_topology.isHFNose()) {
890  geomId = static_cast<DetId>(HFNoseDetId(detId).geometryCell());
891  } else {
892  geomId = static_cast<DetId>(HGCSiliconDetId(detId).geometryCell());
893  }
894  return geomId;
895 }
bool tileTrapezoid() const
const HGCalTopology & m_topology
bool waferHexagon6() const
HGCalDetId geometryCell() const
Definition: HGCalDetId.h:34
constexpr HGCScintillatorDetId geometryCell() const
HFNoseDetId geometryCell() const
Definition: HFNoseDetId.h:47
constexpr HGCSiliconDetId geometryCell() const
bool isHFNose() const
Definition: DetId.h:17

◆ getGeometryRawPtr()

const CaloCellGeometry * HGCalGeometry::getGeometryRawPtr ( uint32_t  index) const
overrideprotectedvirtual

Implements CaloSubdetectorGeometry.

Definition at line 666 of file HGCalGeometry.cc.

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

Referenced by present().

666  {
667  // Modify the RawPtr class
668  if (m_det == DetId::HGCalHSc) {
669  if (m_cellVec2.size() < index)
670  return nullptr;
671  const CaloCellGeometry* cell(&m_cellVec2[index]);
672  return (nullptr == cell->param() ? nullptr : cell);
673  } else {
674  if (m_cellVec.size() < index)
675  return nullptr;
676  const CaloCellGeometry* cell(&m_cellVec[index]);
677  return (nullptr == cell->param() ? nullptr : cell);
678  }
679 }
CellVec2 m_cellVec2
DetId::Detector m_det
CellVec m_cellVec

◆ getNewCorners()

HGCalGeometry::CornersVec HGCalGeometry::getNewCorners ( const DetId id,
bool  debug = false 
) const

Definition at line 400 of file HGCalGeometry.cc.

References HGCalDDDConstants::cellSizeTrap(), cms::cuda::co, funct::cos(), HGCalTopology::dddConstants(), debug, HGCalTopology::decode(), l1ctLayer1_cff::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, alignCSCRings::r, findQualityFiles::rr, funct::sin(), findQualityFiles::v, HGCalTopology::waferHexagon6(), HGCalDDDConstants::waferZ(), geometryCSVtoXML::xx, geometryCSVtoXML::xy, and geometryCSVtoXML::zz.

Referenced by getArea().

400  {
401  unsigned int ncorner = (m_det == DetId::HGCalHSc) ? 5 : 7;
402  HGCalGeometry::CornersVec co(ncorner, GlobalPoint(0, 0, 0));
403  unsigned int cellIndex = indexFor(detid);
405  if (debug)
406  edm::LogVerbatim("HGCalGeom") << "NewCorners for Layer " << id.iLay << " Wafer " << id.iSec1 << ":" << id.iSec2
407  << " Cell " << id.iCell1 << ":" << id.iCell2;
408  if (cellIndex < m_cellVec2.size() && m_det == DetId::HGCalHSc) {
409  GlobalPoint v = getPosition(detid, false);
410  int type = std::min(id.iType, 1);
411  std::pair<double, double> rr = m_topology.dddConstants().cellSizeTrap(type, id.iSec1);
412  float dr = k_half * (rr.second - rr.first);
413  float dfi = m_cellVec2[cellIndex].param()[FlatTrd::k_Cell];
414  float dz = -id.zSide * m_cellVec2[cellIndex].param()[FlatTrd::k_dZ];
415  float r = v.perp();
416  float fi = v.phi();
417  static const int signr[] = {1, 1, -1, -1};
418  static const int signf[] = {-1, 1, 1, -1};
419  for (unsigned int i = 0; i < ncorner - 1; ++i) {
420  co[i] = GlobalPoint(
421  (r + signr[i] * dr) * cos(fi + signf[i] * dfi), (r + signr[i] * dr) * sin(fi + signf[i] * dfi), (v.z() + dz));
422  }
423  // Used to pass downstream the thickness of this cell
424  co[ncorner - 1] = GlobalPoint(0, 0, -2 * dz);
425  } else if (cellIndex < m_cellVec.size() && m_det != DetId::HGCalHSc) {
426  std::pair<float, float> xy;
427  float dx = k_fac2 * m_cellVec[cellIndex].param()[FlatHexagon::k_r];
428  float dy = k_fac1 * m_cellVec[cellIndex].param()[FlatHexagon::k_R];
429  float dz = -id.zSide * m_cellVec[cellIndex].param()[FlatHexagon::k_dZ];
430  static const int signx[] = {1, -1, -2, -1, 1, 2};
431  static const int signy[] = {1, 1, 0, -1, -1, 0};
432 #ifdef EDM_ML_DEBUG
433  if (debug)
434  edm::LogVerbatim("HGCalGeom") << "kfac " << k_fac1 << ":" << k_fac2 << " dx:dy:dz " << dx << ":" << dy << ":"
435  << dz;
436 #endif
437  if (m_topology.waferHexagon6()) {
438  xy = m_topology.dddConstants().locateCellHex(id.iCell1, id.iSec1, true);
439  for (unsigned int i = 0; i < ncorner - 1; ++i) {
440  const HepGeom::Point3D<float> lcoord(xy.first + signx[i] * dx, xy.second + signy[i] * dy, dz);
441  co[i] = m_cellVec[cellIndex].getPosition(lcoord);
442  }
443  } else {
445  id.zSide, id.iLay, id.iSec1, id.iSec2, id.iCell1, id.iCell2, true, false, true, false, debug);
446  float zz = m_topology.dddConstants().waferZ(id.iLay, true);
447  for (unsigned int i = 0; i < ncorner; ++i) {
448  double xloc = xy.first + signx[i] * dx;
449  double yloc = xy.second + signy[i] * dy;
450 #ifdef EDM_ML_DEBUG
451  if (debug)
452  edm::LogVerbatim("HGCalGeom") << "Corner " << i << " x " << xy.first << ":" << xloc << " y " << xy.second
453  << ":" << yloc << " z " << zz << ":" << id.zSide * (zz + dz);
454 #endif
455  auto xyglob =
456  m_topology.dddConstants().localToGlobal8(id.zSide, id.iLay, id.iSec1, id.iSec2, xloc, yloc, true, debug);
457  double xx = id.zSide * xyglob.first;
458  co[i] = GlobalPoint(xx, xyglob.second, id.zSide * (zz + dz));
459  }
460  }
461  // Used to pass downstream the thickness of this cell
462  co[ncorner - 1] = GlobalPoint(0, 0, -2 * dz);
463  }
464  return co;
465 }
double waferZ(int layer, bool reco) const
Log< level::Info, true > LogVerbatim
std::pair< double, double > cellSizeTrap(int type, int irad) const
const HGCalTopology & m_topology
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
bool waferHexagon6() const
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
__host__ __device__ VT * co
Definition: prefixScan.h:47
static constexpr double k_half
static constexpr double k_fac1
GlobalPoint getPosition(const DetId &id, bool cog, bool debug) const
static constexpr uint32_t k_R
Definition: FlatHexagon.h:29
static constexpr uint32_t k_r
Definition: FlatHexagon.h:28
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
unsigned int indexFor(const DetId &id) const override
DecodedDetId decode(const DetId &id) const
CellVec2 m_cellVec2
#define debug
Definition: HDRShower.cc:19
static constexpr uint32_t k_dZ
Definition: FlatHexagon.h:27
std::pair< float, float > locateCellHex(int cell, int wafer, bool reco) const
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
static constexpr uint32_t k_dZ
Definition: FlatTrd.h:26
DetId::Detector m_det
std::pair< float, float > localToGlobal8(int zside, int lay, int waferU, int waferV, double localX, double localY, bool reco, bool debug) const
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
CellVec m_cellVec

◆ getPosition() [1/2]

GlobalPoint HGCalGeometry::getPosition ( const DetId id,
bool  cog,
bool  debug 
) const

Definition at line 208 of file HGCalGeometry.cc.

References HGCalTopology::dddConstants(), debug, HGCalTopology::decode(), DetId::det(), DetId::Forward, indexFor(), HGCalDDDConstants::locateCell(), HGCalDDDConstants::locateCellHex(), m_cellVec, m_cellVec2, m_topology, reco_skim_cfg_mod::maxSize, DetId::rawId(), HGCalTopology::tileTrapezoid(), HGCalTopology::waferHexagon6(), HGCalDDDConstants::waferZ(), geometryCSVtoXML::xx, geometryCSVtoXML::xy, and geometryCSVtoXML::zz.

Referenced by HGCDigitizer::checkPosition(), HGCalRadiationMap::computeRadius(), get8Corners(), getClosestCellIndex(), getCorners(), getGeometry(), HGCalTriggerGeometryV9Imp2::getModulePosition(), HGCalTriggerGeometryV9Imp3::getModulePosition(), getNewCorners(), hgcal::RecHitTools::getPosition(), getPosition(), HGCalTriggerGeometryV9Imp2::getTriggerCellPosition(), HGCalTriggerGeometryV9Imp3::getTriggerCellPosition(), HGCalUncalibRecHitRecWeightsAlgo< HGCDataFrame >::makeRecHit(), and neighborZ().

208  {
209  unsigned int cellIndex = indexFor(detid);
210  GlobalPoint glob;
211  unsigned int maxSize = (m_topology.tileTrapezoid() ? m_cellVec2.size() : m_cellVec.size());
212  if (cellIndex < maxSize) {
214  std::pair<float, float> xy;
215  if (m_topology.waferHexagon6()) {
216  xy = m_topology.dddConstants().locateCellHex(id.iCell1, id.iSec1, true);
217  const HepGeom::Point3D<float> lcoord(xy.first, xy.second, 0);
218  glob = m_cellVec[cellIndex].getPosition(lcoord);
219  if (debug)
220  edm::LogVerbatim("HGCalGeom") << "getPosition:: index " << cellIndex << " Local " << lcoord.x() << ":"
221  << lcoord.y() << " ID " << id.iCell1 << ":" << id.iSec1 << " Global " << glob;
222  } else if (m_topology.tileTrapezoid()) {
223  const HepGeom::Point3D<float> lcoord(0, 0, 0);
224  glob = m_cellVec2[cellIndex].getPosition(lcoord);
225  if (debug)
226  edm::LogVerbatim("HGCalGeom") << "getPositionTrap:: index " << cellIndex << " Local " << lcoord.x() << ":"
227  << lcoord.y() << " ID " << id.iLay << ":" << id.iSec1 << ":" << id.iCell1
228  << " Global " << glob;
229  } else {
230  if (debug) {
231  if (detid.det() == DetId::Forward)
232  edm::LogVerbatim("HGCalGeom") << "getPosition for " << HFNoseDetId(detid) << " Layer " << id.iLay << " Wafer "
233  << id.iSec1 << ":" << id.iSec2 << " Cell " << id.iCell1 << ":" << id.iCell2;
234  else
235  edm::LogVerbatim("HGCalGeom") << "getPosition for " << HGCSiliconDetId(detid) << " Layer " << id.iLay
236  << " Wafer " << id.iSec1 << ":" << id.iSec2 << " Cell " << id.iCell1 << ":"
237  << id.iCell2;
238  }
240  id.zSide, id.iLay, id.iSec1, id.iSec2, id.iCell1, id.iCell2, true, true, false, cog, debug);
241  double xx = id.zSide * xy.first;
242  double zz = id.zSide * m_topology.dddConstants().waferZ(id.iLay, true);
243  glob = GlobalPoint(xx, xy.second, zz);
244  if (debug)
245  edm::LogVerbatim("HGCalGeom") << "getPositionWafer:: index " << cellIndex << " Local " << xy.first << ":"
246  << xy.second << " ID " << id.iLay << ":" << id.iSec1 << ":" << id.iSec2 << ":"
247  << id.iCell1 << ":" << id.iCell2 << " Global " << glob;
248  }
249  } else {
250  edm::LogVerbatim("HGCalGeom") << "Cannot recognize " << std::hex << detid.rawId() << " cellIndex " << cellIndex
251  << ":" << maxSize << " Type " << m_topology.tileTrapezoid();
252  }
253  return glob;
254 }
double waferZ(int layer, bool reco) const
Log< level::Info, true > LogVerbatim
bool tileTrapezoid() const
const HGCalTopology & m_topology
bool waferHexagon6() const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
unsigned int indexFor(const DetId &id) const override
DecodedDetId decode(const DetId &id) const
CellVec2 m_cellVec2
#define debug
Definition: HDRShower.cc:19
std::pair< float, float > locateCellHex(int cell, int wafer, bool reco) const
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
CellVec m_cellVec

◆ getPosition() [2/2]

GlobalPoint HGCalGeometry::getPosition ( const DetId id,
bool  debug = false 
) const

Definition at line 204 of file HGCalGeometry.cc.

References debug, and getPosition().

204  {
205  return getPosition(detid, false, debug);
206 }
GlobalPoint getPosition(const DetId &id, bool cog, bool debug) const
#define debug
Definition: HDRShower.cc:19

◆ getSummary()

void HGCalGeometry::getSummary ( CaloSubdetectorGeometry::TrVec trVector,
CaloSubdetectorGeometry::IVec iVector,
CaloSubdetectorGeometry::DimVec dimVector,
CaloSubdetectorGeometry::IVec dinsVector 
) const
overridevirtual

Reimplemented from CaloSubdetectorGeometry.

Definition at line 781 of file HGCalGeometry.cc.

References HGCalParameters::hgtrap::alpha, HGCalParameters::hgtrap::bl, cellGeomPtr(), HGCalParameters::hgtrap::cellSize, HGCalTopology::dddConstants(), hcalRecHitTable_cff::detId, 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, nano_mu_digi_cff::layer, HGCalDetId::layer(), HFNoseDetId::layer(), HGCScintillatorDetId::layer(), HGCSiliconDetId::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().

784  {
785  unsigned int numberOfCells = m_topology.totalGeomModules(); // total Geom Modules both sides
786  unsigned int numberOfShapes = k_NumberOfShapes;
787  unsigned int numberOfParametersPerShape = ((m_det == DetId::HGCalHSc) ? (unsigned int)(k_NumberOfParametersPerTrd)
788  : (unsigned int)(k_NumberOfParametersPerHex));
789 
790  trVector.reserve(numberOfCells * numberOfTransformParms());
791  iVector.reserve(numberOfCells);
792  dimVector.reserve(numberOfShapes * numberOfParametersPerShape);
793  dinsVector.reserve(numberOfCells);
794 
795  for (unsigned itr = 0; itr < m_topology.dddConstants().getTrFormN(); ++itr) {
797  int layer = mytr.lay;
798 
799  if (m_topology.waferHexagon6()) {
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);
804  params[FlatHexagon::k_dZ] = vol.dz;
807  dimVector.insert(dimVector.end(), params.begin(), params.end());
808  }
809  }
810  } else if (m_topology.tileTrapezoid()) {
811  int indx = m_topology.dddConstants().layerIndex(layer, true);
812  for (int md = m_topology.dddConstants().getParameter()->firstModule_[indx];
814  ++md) {
817  params[FlatTrd::k_dZ] = vol.dz;
824  dimVector.insert(dimVector.end(), params.begin(), params.end());
825  }
826  } else {
827  for (int wafer = 0; wafer < m_topology.dddConstants().sectors(); ++wafer) {
828  if (m_topology.dddConstants().waferInLayer(wafer, layer, true)) {
829  HGCalParameters::hgtrap vol = m_topology.dddConstants().getModule(wafer, true, true);
831  params[FlatHexagon::k_dZ] = vol.dz;
834  dimVector.insert(dimVector.end(), params.begin(), params.end());
835  }
836  }
837  }
838  }
839 
840  for (unsigned int i(0); i < numberOfCells; ++i) {
842  int layer(0);
843  if (m_topology.waferHexagon6()) {
845  } else if (m_topology.tileTrapezoid()) {
847  } else if (m_topology.isHFNose()) {
849  } else {
851  }
852  dinsVector.emplace_back(m_topology.detId2denseGeomId(detId));
853  iVector.emplace_back(layer);
854 
855  Tr3D tr;
856  auto ptr = cellGeomPtr(i);
857  if (nullptr != ptr) {
858  ptr->getTransform(tr, (Pt3DVec*)nullptr);
859 
860  if (Tr3D() == tr) { // there is no rotation
861  const GlobalPoint& gp(ptr->getPosition());
862  tr = HepGeom::Translate3D(gp.x(), gp.y(), gp.z());
863  }
864 
865  const CLHEP::Hep3Vector tt(tr.getTranslation());
866  trVector.emplace_back(tt.x());
867  trVector.emplace_back(tt.y());
868  trVector.emplace_back(tt.z());
869  if (6 == numberOfTransformParms()) {
870  const CLHEP::HepRotation rr(tr.getRotation());
871  const ROOT::Math::Transform3D rtr(
872  rr.xx(), rr.xy(), rr.xz(), tt.x(), rr.yx(), rr.yy(), rr.yz(), tt.y(), rr.zx(), rr.zy(), rr.zz(), tt.z());
874  rtr.GetRotation(ea);
875  trVector.emplace_back(ea.Phi());
876  trVector.emplace_back(ea.Theta());
877  trVector.emplace_back(ea.Psi());
878  }
879  }
880  }
881 }
static constexpr unsigned int k_NumberOfShapes
Definition: HGCalGeometry.h:46
std::vector< DetId > m_validGeomIds
unsigned int totalGeomModules() const
Definition: HGCalTopology.h:93
int layer() const
get the layer #
Definition: HFNoseDetId.h:57
const HGCalParameters * getParameter() const
bool tileTrapezoid() const
HGCalParameters::hgtrap getModule(unsigned int k, bool hexType, bool reco) const
virtual unsigned int numberOfTransformParms() const
const HGCalTopology & m_topology
bool waferHexagon6() const
static constexpr uint32_t k_Theta
Definition: FlatTrd.h:27
virtual unsigned int numberOfShapes() const
static constexpr uint32_t k_Cell
Definition: FlatTrd.h:45
static constexpr uint32_t k_dY1
Definition: FlatTrd.h:31
CaloCellGeometry::Tr3D Tr3D
bool waferInLayer(int wafer, int lay, bool reco) const
const double twoBysqrt3_
std::vector< int > firstModule_
Definition: TTTypes.h:54
static constexpr uint32_t k_R
Definition: FlatHexagon.h:29
static constexpr uint32_t k_r
Definition: FlatHexagon.h:28
std::vector< float > ParmVec
static constexpr uint32_t k_dX1
Definition: FlatTrd.h:32
int layerIndex(int lay, bool reco) const
virtual uint32_t detId2denseGeomId(const DetId &id) const
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 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
static constexpr uint32_t k_Phi
Definition: FlatTrd.h:29
int layer() const
get the layer #
Definition: HGCalDetId.h:46
CaloCellGeometry::Pt3DVec Pt3DVec
unsigned int getTrFormN() const
constexpr int32_t layer() const
get the layer #
HGCalParameters::hgtrform getTrForm(unsigned int k) const
CaloCellGeometry::Tr3D Tr3D
std::shared_ptr< const CaloCellGeometry > cellGeomPtr(uint32_t index) const override
constexpr int layer() const
get the layer #
static constexpr uint32_t k_dZ
Definition: FlatTrd.h:26
DetId::Detector m_det
static constexpr uint32_t k_Alp1
Definition: FlatTrd.h:36
static constexpr uint32_t k_dX3
Definition: FlatTrd.h:39
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
static constexpr uint32_t k_dX2
Definition: FlatTrd.h:34
virtual unsigned int numberOfParametersPerShape() const
static constexpr uint32_t k_Alp2
Definition: FlatTrd.h:43

◆ getValidDetIds()

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 90 of file HGCalGeometry.h.

References CaloSubdetectorGeometry::m_validIds.

90  {
91  return m_validIds;
92  }
std::vector< DetId > m_validIds

◆ getValidGeomDetIds()

const std::vector<DetId>& HGCalGeometry::getValidGeomDetIds ( void  ) const
inline

Definition at line 93 of file HGCalGeometry.h.

References m_validGeomIds.

93 { return m_validGeomIds; }
std::vector< DetId > m_validGeomIds

◆ getWaferPosition()

GlobalPoint HGCalGeometry::getWaferPosition ( const DetId id) const

Definition at line 256 of file HGCalGeometry.cc.

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

256  {
257  unsigned int cellIndex = indexFor(detid);
258  GlobalPoint glob;
259  unsigned int maxSize = (m_topology.tileTrapezoid() ? m_cellVec2.size() : m_cellVec.size());
260  if (cellIndex < maxSize) {
261  const HepGeom::Point3D<float> lcoord(0, 0, 0);
262  if (m_topology.tileTrapezoid()) {
263  glob = m_cellVec2[cellIndex].getPosition(lcoord);
264  } else {
265  glob = m_cellVec[cellIndex].getPosition(lcoord);
266  }
267 #ifdef EDM_ML_DEBUG
268  edm::LogVerbatim("HGCalGeom") << "getPositionTrap:: ID " << std::hex << detid.rawId() << std::dec << " index "
269  << cellIndex << " Global " << glob;
270 #endif
271  }
272  return glob;
273 }
Log< level::Info, true > LogVerbatim
bool tileTrapezoid() const
const HGCalTopology & m_topology
unsigned int indexFor(const DetId &id) const override
CellVec2 m_cellVec2
CellVec m_cellVec

◆ indexFor()

unsigned int HGCalGeometry::indexFor ( const DetId id) const
overrideprotectedvirtual

Reimplemented from CaloSubdetectorGeometry.

Definition at line 651 of file HGCalGeometry.cc.

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

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

651  {
652  unsigned int cellIndex = ((m_det == DetId::HGCalHSc) ? m_cellVec2.size() : m_cellVec.size());
653  if (detId != DetId()) {
654  DetId geomId = getGeometryDetId(detId);
655  cellIndex = m_topology.detId2denseGeomId(geomId);
656 #ifdef EDM_ML_DEBUG
657  edm::LogVerbatim("HGCalGeom") << "indexFor " << std::hex << detId.rawId() << ":" << geomId.rawId() << std::dec
658  << " index " << cellIndex;
659 #endif
660  }
661  return cellIndex;
662 }
Log< level::Info, true > LogVerbatim
const HGCalTopology & m_topology
virtual uint32_t detId2denseGeomId(const DetId &id) const
DetId getGeometryDetId(DetId detId) const
CellVec2 m_cellVec2
Definition: DetId.h:17
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
DetId::Detector m_det
CellVec m_cellVec

◆ initializeParms()

void HGCalGeometry::initializeParms ( )
overridevirtual

Reimplemented from CaloSubdetectorGeometry.

Definition at line 47 of file HGCalGeometry.cc.

47 {}

◆ localCorners()

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

◆ neighborZ() [1/2]

DetId HGCalGeometry::neighborZ ( const DetId idin,
const GlobalVector p 
) const

Definition at line 467 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().

467  {
468  DetId idnew;
470  int lay = ((momentum.z() * id.zSide > 0) ? (id.iLay + 1) : (id.iLay - 1));
471 #ifdef EDM_ML_DEBUG
472  edm::LogVerbatim("HGCalGeom") << "neighborz1:: ID " << id.iLay << ":" << id.iSec1 << ":" << id.iSec2 << ":"
473  << id.iCell1 << ":" << id.iCell2 << " New Layer " << lay << " Range "
474  << m_topology.dddConstants().firstLayer() << ":"
475  << m_topology.dddConstants().lastLayer(true) << " pz " << momentum.z();
476 #endif
477  if ((lay >= m_topology.dddConstants().firstLayer()) && (lay <= m_topology.dddConstants().lastLayer(true)) &&
478  (momentum.z() != 0.0)) {
479  GlobalPoint v = getPosition(idin, false);
480  double z = id.zSide * m_topology.dddConstants().waferZ(lay, true);
481  double grad = (z - v.z()) / momentum.z();
482  GlobalPoint p(v.x() + grad * momentum.x(), v.y() + grad * momentum.y(), z);
483  double r = p.perp();
484  auto rlimit = topology().dddConstants().rangeR(z, true);
485  if (r >= rlimit.first && r <= rlimit.second)
486  idnew = getClosestCell(p);
487 #ifdef EDM_ML_DEBUG
488  edm::LogVerbatim("HGCalGeom") << "neighborz1:: Position " << v << " New Z " << z << ":" << grad << " new position "
489  << p << " r-limit " << rlimit.first << ":" << rlimit.second;
490 #endif
491  }
492  return idnew;
493 }
double waferZ(int layer, bool reco) const
Log< level::Info, true > LogVerbatim
const HGCalTopology & m_topology
int lastLayer(bool reco) const
int firstLayer() const
DetId getClosestCell(const GlobalPoint &r) const override
GlobalPoint getPosition(const DetId &id, bool cog, bool debug) const
DecodedDetId decode(const DetId &id) const
const HGCalTopology & topology() const
std::pair< double, double > rangeR(double z, bool reco) const
Definition: DetId.h:17
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98

◆ neighborZ() [2/2]

DetId HGCalGeometry::neighborZ ( const DetId idin,
const MagneticField bField,
int  charge,
const GlobalVector momentum 
) const

Definition at line 495 of file HGCalGeometry.cc.

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

498  {
499  DetId idnew;
501  int lay = ((momentum.z() * id.zSide > 0) ? (id.iLay + 1) : (id.iLay - 1));
502 #ifdef EDM_ML_DEBUG
503  edm::LogVerbatim("HGCalGeom") << "neighborz2:: ID " << id.iLay << ":" << id.iSec1 << ":" << id.iSec2 << ":"
504  << id.iCell1 << ":" << id.iCell2 << " New Layer " << lay << " Range "
505  << m_topology.dddConstants().firstLayer() << ":"
506  << m_topology.dddConstants().lastLayer(true) << " pz " << momentum.z();
507 #endif
508  if ((lay >= m_topology.dddConstants().firstLayer()) && (lay <= m_topology.dddConstants().lastLayer(true)) &&
509  (momentum.z() != 0.0)) {
510  GlobalPoint v = getPosition(idin, false);
511  double z = id.zSide * m_topology.dddConstants().waferZ(lay, true);
512  FreeTrajectoryState fts(v, momentum, charge, bField);
515  TrajectoryStateOnSurface tsos = myAP.propagate(fts, *nPlane);
516  GlobalPoint p;
517  auto rlimit = topology().dddConstants().rangeR(z, true);
518  if (tsos.isValid()) {
519  p = tsos.globalPosition();
520  double r = p.perp();
521  if (r >= rlimit.first && r <= rlimit.second)
522  idnew = getClosestCell(p);
523  }
524 #ifdef EDM_ML_DEBUG
525  edm::LogVerbatim("HGCalGeom") << "neighborz2:: Position " << v << " New Z " << z << ":" << charge << ":"
526  << tsos.isValid() << " new position " << p << " r limits " << rlimit.first << ":"
527  << rlimit.second;
528 #endif
529  }
530  return idnew;
531 }
double waferZ(int layer, bool reco) const
Log< level::Info, true > LogVerbatim
T z() const
Definition: PV3DBase.h:61
const HGCalTopology & m_topology
int lastLayer(bool reco) const
int firstLayer() const
static PlanePointer build(Args &&... args)
Definition: Plane.h:33
DetId getClosestCell(const GlobalPoint &r) const override
GlobalPoint getPosition(const DetId &id, bool cog, bool debug) const
GlobalPoint globalPosition() const
DecodedDetId decode(const DetId &id) const
const HGCalTopology & topology() const
#define M_PI
std::pair< double, double > rangeR(double z, bool reco) const
Definition: DetId.h:17
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98

◆ newCell()

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(), hgcalTBTopologyTester_cfi::cells, CaloSubdetectorGeometry::cornersMgr(), HGCalTopology::dddConstants(), TauDecayModes::dec, HGCalTopology::decode(), DetId::det(), hcalRecHitTable_cff::detId, HGCalTopology::detId2denseGeomId(), HGCalTopology::encode(), DeadROC_duringRun::f1, DeadROC_duringRun::f2, DetId::Forward, 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(), and HGCalTopology::waferHexagon6().

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

◆ present()

bool HGCalGeometry::present ( const DetId id) const
overridevirtual

is this detid present in the geometry?

Reimplemented from CaloSubdetectorGeometry.

Definition at line 196 of file HGCalGeometry.cc.

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

196  {
197  if (detId == DetId())
198  return false;
199  DetId geomId = getGeometryDetId(detId);
200  const uint32_t index(m_topology.detId2denseGeomId(geomId));
201  return (nullptr != getGeometryRawPtr(index));
202 }
const HGCalTopology & m_topology
virtual uint32_t detId2denseGeomId(const DetId &id) const
DetId getGeometryDetId(DetId detId) const
const CaloCellGeometry * getGeometryRawPtr(uint32_t index) const override
Definition: DetId.h:17

◆ producerTag()

static std::string HGCalGeometry::producerTag ( )
inlinestatic

◆ sizeForDenseIndex() [1/2]

unsigned int CaloSubdetectorGeometry::sizeForDenseIndex
protected

Definition at line 256 of file CaloSubdetectorGeometry.cc.

256  {
258 }
uint32_t sizeForDenseIndexing() const

◆ sizeForDenseIndex() [2/2]

unsigned int HGCalGeometry::sizeForDenseIndex ( ) const
protected

Definition at line 664 of file HGCalGeometry.cc.

References m_topology, and HGCalTopology::totalGeomModules().

664 { return m_topology.totalGeomModules(); }
unsigned int totalGeomModules() const
Definition: HGCalTopology.h:93
const HGCalTopology & m_topology

◆ sortDetIds()

void HGCalGeometry::sortDetIds ( void  )

Definition at line 776 of file HGCalGeometry.cc.

References CaloSubdetectorGeometry::m_validIds, and jetUpdater_cfi::sort.

776  {
777  m_validIds.shrink_to_fit();
778  std::sort(m_validIds.begin(), m_validIds.end(), rawIdSort());
779 }
std::vector< DetId > m_validIds

◆ topology()

const HGCalTopology& HGCalGeometry::topology ( ) const
inline

Member Data Documentation

◆ k_fac1

constexpr double HGCalGeometry::k_fac1 = 0.5
staticprivate

Definition at line 136 of file HGCalGeometry.h.

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

◆ k_fac2

constexpr double HGCalGeometry::k_fac2 = 1.0 / 3.0
staticprivate

Definition at line 137 of file HGCalGeometry.h.

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

◆ k_half

constexpr double HGCalGeometry::k_half = 0.5
staticprivate

Definition at line 135 of file HGCalGeometry.h.

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

◆ k_NumberOfParametersPerHex

constexpr unsigned int HGCalGeometry::k_NumberOfParametersPerHex = 3
static

Definition at line 44 of file HGCalGeometry.h.

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

◆ k_NumberOfParametersPerShape

constexpr unsigned int HGCalGeometry::k_NumberOfParametersPerShape = 3
static

Definition at line 45 of file HGCalGeometry.h.

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

◆ k_NumberOfParametersPerTrd

constexpr unsigned int HGCalGeometry::k_NumberOfParametersPerTrd = 12
static

Definition at line 43 of file HGCalGeometry.h.

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

◆ k_NumberOfShapes

constexpr unsigned int HGCalGeometry::k_NumberOfShapes = 100
static

◆ k_NumberOfShapesTrd

constexpr unsigned int HGCalGeometry::k_NumberOfShapesTrd = 1000
static

Definition at line 47 of file HGCalGeometry.h.

Referenced by HGCalGeometryLoader::build().

◆ m_cellVec

CellVec HGCalGeometry::m_cellVec
private

◆ m_cellVec2

CellVec2 HGCalGeometry::m_cellVec2
private

◆ m_det

DetId::Detector HGCalGeometry::m_det
private

◆ m_subdet

ForwardSubdetector HGCalGeometry::m_subdet
private

Definition at line 144 of file HGCalGeometry.h.

Referenced by cellElement().

◆ m_topology

const HGCalTopology& HGCalGeometry::m_topology
private

◆ m_validGeomIds

std::vector<DetId> HGCalGeometry::m_validGeomIds
private

◆ twoBysqrt3_

const double HGCalGeometry::twoBysqrt3_
private

Definition at line 145 of file HGCalGeometry.h.

Referenced by getSummary().