CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends
HcalDDDGeometry Class Reference

#include <HcalDDDGeometry.h>

Inheritance diagram for HcalDDDGeometry:
CaloSubdetectorGeometry

Public Types

typedef std::vector< IdealObliquePrismHBCellVec
 
typedef std::vector< IdealObliquePrismHECellVec
 
typedef std::vector< IdealZPrismHFCellVec
 
typedef std::vector< IdealObliquePrismHOCellVec
 
- 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

DetId getClosestCell (const GlobalPoint &r) 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...
 
 HcalDDDGeometry (const HcalTopology &theTopo)
 
int insertCell (std::vector< HcalCellType > const &)
 
void newCell (const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId) override
 
 ~HcalDDDGeometry () override
 The HcalDDDGeometry will delete all its cell geometries at destruction time. More...
 
- 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 DetIdSet getCells (const GlobalPoint &r, double dR) const
 Get a list of all cells within a dR of the given cell. More...
 
virtual CellSet getCellSet (const GlobalPoint &r, double dR) const
 
virtual std::shared_ptr< const CaloCellGeometrygetGeometry (const DetId &id) const
 Get the cell geometry of a given detector id. Should return false if not found. More...
 
virtual void getSummary (TrVec &trVector, IVec &iVector, DimVec &dimVector, IVec &dinsVector) const
 
virtual void initializeParms ()
 
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 present (const DetId &id) const
 is this detid present in the geometry? More...
 
virtual ~CaloSubdetectorGeometry ()
 The base class DOES assume that it owns the CaloCellGeometry objects. More...
 

Protected Member Functions

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

Private Member Functions

void fillDetIds () const
 
void increaseReserve (unsigned int extra)
 
void newCellFast (const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId)
 
void newCellImpl (const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId)
 
void sortValidIds ()
 

Private Attributes

double etaMax_
 
std::vector< HcalCellTypehcalCells_
 
std::vector< DetIdm_emptyIds
 
std::atomic< bool > m_filledDetIds
 
HBCellVec m_hbCellVec
 
std::vector< DetIdm_hbIds
 
HECellVec m_heCellVec
 
std::vector< DetIdm_heIds
 
HFCellVec m_hfCellVec
 
std::vector< DetIdm_hfIds
 
HOCellVec m_hoCellVec
 
std::vector< DetIdm_hoIds
 
const HcalTopologytopo_
 

Friends

class HcalDDDGeometryLoader
 

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 17 of file HcalDDDGeometry.h.

Member Typedef Documentation

◆ HBCellVec

Definition at line 21 of file HcalDDDGeometry.h.

◆ HECellVec

Definition at line 22 of file HcalDDDGeometry.h.

◆ HFCellVec

Definition at line 24 of file HcalDDDGeometry.h.

◆ HOCellVec

Definition at line 23 of file HcalDDDGeometry.h.

Constructor & Destructor Documentation

◆ HcalDDDGeometry()

HcalDDDGeometry::HcalDDDGeometry ( const HcalTopology theTopo)
explicit

Definition at line 12 of file HcalDDDGeometry.cc.

13  : topo_(topo),
14  etaMax_(0),
15  m_hbCellVec(topo.getHBSize()),
16  m_heCellVec(topo.getHESize()),
17  m_hoCellVec(topo.getHOSize()),
18  m_hfCellVec(topo.getHFSize()),
19  m_filledDetIds(false) {}
std::atomic< bool > m_filledDetIds
const HcalTopology & topo_
HBCellVec m_hbCellVec
HECellVec m_heCellVec
HFCellVec m_hfCellVec
HOCellVec m_hoCellVec

◆ ~HcalDDDGeometry()

HcalDDDGeometry::~HcalDDDGeometry ( )
override

The HcalDDDGeometry will delete all its cell geometries at destruction time.

Definition at line 21 of file HcalDDDGeometry.cc.

21 {}

Member Function Documentation

◆ fillDetIds()

void HcalDDDGeometry::fillDetIds ( ) const
private

Definition at line 23 of file HcalDDDGeometry.cc.

References CaloSubdetectorGeometry::getValidDetIds(), HcalBarrel, HcalEndcap, HcalForward, HcalOuter, mps_fire::i, l1ctLayer2EG_cff::id, m_emptyIds, m_filledDetIds, m_hbIds, m_heIds, m_hfIds, m_hoIds, s_fillLock, and jetsAK4_CHS_cff::sort.

Referenced by getValidDetIds().

23  {
24  std::lock_guard<std::mutex> guard(s_fillLock);
25  if (m_filledDetIds) {
26  //another thread already did the work
27  return;
28  }
29  const std::vector<DetId>& baseIds(CaloSubdetectorGeometry::getValidDetIds());
30  for (unsigned int i(0); i != baseIds.size(); ++i) {
31  const DetId id(baseIds[i]);
32  if (id.subdetId() == HcalBarrel) {
33  m_hbIds.emplace_back(id);
34  } else {
35  if (id.subdetId() == HcalEndcap) {
36  m_heIds.emplace_back(id);
37  } else {
38  if (id.subdetId() == HcalOuter) {
39  m_hoIds.emplace_back(id);
40  } else {
41  if (id.subdetId() == HcalForward) {
42  m_hfIds.emplace_back(id);
43  }
44  }
45  }
46  }
47  }
48  std::sort(m_hbIds.begin(), m_hbIds.end());
49  std::sort(m_heIds.begin(), m_heIds.end());
50  std::sort(m_hoIds.begin(), m_hoIds.end());
51  std::sort(m_hfIds.begin(), m_hfIds.end());
52 
53  m_emptyIds.resize(0);
54  m_filledDetIds = true;
55 }
std::vector< DetId > m_hfIds
std::vector< DetId > m_heIds
std::atomic< bool > m_filledDetIds
virtual const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const
Get a list of valid detector ids (for the given subdetector)
static std::mutex s_fillLock
std::vector< DetId > m_hbIds
Definition: DetId.h:17
std::vector< DetId > m_emptyIds
std::vector< DetId > m_hoIds

◆ getClosestCell()

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

Reimplemented from CaloSubdetectorGeometry.

Definition at line 69 of file HcalDDDGeometry.cc.

References etaMax_, hcalCells_, HcalForward, M_PI, phi, alignCSCRings::r, CosmicsPD_Skims::radius, and z.

69  {
70  constexpr double twopi = M_PI + M_PI;
71 
72  // Now find the closest eta_bin, eta value of a bin i is average
73  // of eta[i] and eta[i-1]
74  double abseta = fabs(r.eta());
75  double phi = r.phi();
76  if (phi < 0)
77  phi += twopi;
78  double radius = r.mag();
79  double z = fabs(r.z());
80 
81 #ifdef EDM_ML_DEBUG
82  constexpr double deg = M_PI / 180.;
83  edm::LogVerbatim("HCalGeom") << "HcalDDDGeometry::getClosestCell for eta " << r.eta() << " phi " << phi / deg << " z "
84  << r.z() << " radius " << radius;
85 #endif
86  HcalDetId bestId;
87  if (abseta <= etaMax_) {
88  for (const auto& hcalCell : hcalCells_) {
89  if (abseta >= hcalCell.etaMin() && abseta <= hcalCell.etaMax()) {
90  HcalSubdetector bc = hcalCell.detType();
91  int etaring = hcalCell.etaBin();
92  int phibin = 0;
93  if (hcalCell.unitPhi() == 4) {
94  // rings 40 and 41 are offset wrt the other phi numbering
95  // 1 1 1 2
96  // ------------------------------
97  // 72 36 36 1
98  phibin =
99  static_cast<int>((phi + hcalCell.phiOffset() + 0.5 * hcalCell.phiBinWidth()) / hcalCell.phiBinWidth());
100  if (phibin == 0)
101  phibin = hcalCell.nPhiBins();
102  phibin = phibin * 4 - 1;
103  } else {
104  phibin = static_cast<int>((phi + hcalCell.phiOffset()) / hcalCell.phiBinWidth()) + 1;
105  // convert to the convention of numbering 1,3,5, in 36 phi bins
106  phibin = (phibin - 1) * (hcalCell.unitPhi()) + 1;
107  }
108 
109  int dbin = 1;
110  int etabin = (r.z() > 0) ? etaring : -etaring;
111  if (bc == HcalForward) {
112  bestId = HcalDetId(bc, etabin, phibin, dbin);
113  break;
114  } else {
115  double rz = z;
116  if (hcalCell.depthType())
117  rz = radius;
118  if (rz < hcalCell.depthMax()) {
119  dbin = hcalCell.depthSegment();
120  bestId = HcalDetId(bc, etabin, phibin, dbin);
121  break;
122  }
123  }
124  }
125  }
126  }
127 
128 #ifdef EDM_ML_DEBUG
129  edm::LogVerbatim("HCalGeom") << "HcalDDDGeometry::getClosestCell " << bestId;
130 #endif
131  return bestId;
132 }
Log< level::Info, true > LogVerbatim
HcalSubdetector
Definition: HcalAssistant.h:31
std::vector< HcalCellType > hcalCells_
#define M_PI

◆ getGeometryRawPtr()

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

Implements CaloSubdetectorGeometry.

Definition at line 187 of file HcalDDDGeometry.cc.

References cropTnPTrees::din, m_hbCellVec, m_heCellVec, m_hfCellVec, m_hoCellVec, and CaloCellGeometry::param().

187  {
188  // Modify the RawPtr class
189  const CaloCellGeometry* cell(nullptr);
190  if (m_hbCellVec.size() > din) {
191  cell = (&m_hbCellVec[din]);
192  } else if (m_hbCellVec.size() + m_heCellVec.size() > din) {
193  const unsigned int ind(din - m_hbCellVec.size());
194  cell = (&m_heCellVec[ind]);
195  } else if (m_hbCellVec.size() + m_heCellVec.size() + m_hoCellVec.size() > din) {
196  const unsigned int ind(din - m_hbCellVec.size() - m_heCellVec.size());
197  cell = (&m_hoCellVec[ind]);
198  } else if (m_hbCellVec.size() + m_heCellVec.size() + m_hoCellVec.size() + m_hfCellVec.size() > din) {
199  const unsigned int ind(din - m_hbCellVec.size() - m_heCellVec.size() - m_hoCellVec.size());
200  cell = (&m_hfCellVec[ind]);
201  }
202 
203  return ((nullptr == cell || nullptr == cell->param()) ? nullptr : cell);
204 }
HBCellVec m_hbCellVec
HECellVec m_heCellVec
HFCellVec m_hfCellVec
HOCellVec m_hoCellVec

◆ getValidDetIds()

std::vector< DetId > const & HcalDDDGeometry::getValidDetIds ( DetId::Detector  det = DetId::Detector(0),
int  subdet = 0 
) const
overridevirtual

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 57 of file HcalDDDGeometry.cc.

References fillDetIds(), CaloSubdetectorGeometry::getValidDetIds(), HcalBarrel, HcalEndcap, HcalForward, HcalOuter, m_emptyIds, m_filledDetIds, m_hbIds, m_heIds, m_hfIds, and m_hoIds.

57  {
58  if (0 != subdet && not m_filledDetIds)
59  fillDetIds();
60  return (0 == subdet
62  : (HcalBarrel == subdet
63  ? m_hbIds
64  : (HcalEndcap == subdet
65  ? m_heIds
66  : (HcalOuter == subdet ? m_hoIds : (HcalForward == subdet ? m_hfIds : m_emptyIds)))));
67 }
std::vector< DetId > m_hfIds
std::vector< DetId > m_heIds
std::atomic< bool > m_filledDetIds
virtual const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const
Get a list of valid detector ids (for the given subdetector)
std::vector< DetId > m_hbIds
std::vector< DetId > m_emptyIds
std::vector< DetId > m_hoIds
void fillDetIds() const

◆ increaseReserve()

void HcalDDDGeometry::increaseReserve ( unsigned int  extra)
private

Definition at line 206 of file HcalDDDGeometry.cc.

References CaloSubdetectorGeometry::m_validIds.

206 { m_validIds.reserve(m_validIds.size() + extra); }
std::vector< DetId > m_validIds

◆ insertCell()

int HcalDDDGeometry::insertCell ( std::vector< HcalCellType > const &  cells)

Definition at line 134 of file HcalDDDGeometry.cc.

References cells, etaMax_, hcalCells_, and EgammaValidation_cff::num.

134  {
135  hcalCells_.insert(hcalCells_.end(), cells.begin(), cells.end());
136  int num = static_cast<int>(hcalCells_.size());
137  for (const auto& cell : cells) {
138  if (cell.etaMax() > etaMax_)
139  etaMax_ = cell.etaMax();
140  }
141 #ifdef EDM_ML_DEBUG
142  edm::LogVerbatim("HCalGeom") << "HcalDDDGeometry::insertCell " << cells.size() << " cells inserted == Total " << num
143  << " EtaMax = " << etaMax_;
144 #endif
145  return num;
146 }
Log< level::Info, true > LogVerbatim
std::vector< HcalCellType > hcalCells_
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ cells

◆ newCell()

void HcalDDDGeometry::newCell ( const GlobalPoint f1,
const GlobalPoint f2,
const GlobalPoint f3,
const CCGFloat parm,
const DetId detId 
)
overridevirtual

Implements CaloSubdetectorGeometry.

Definition at line 175 of file HcalDDDGeometry.cc.

References CaloSubdetectorGeometry::addValidID(), DeadROC_duringRun::f1, DeadROC_duringRun::f2, and newCellImpl().

176  {
177  newCellImpl(f1, f2, f3, parm, detId);
178  addValidID(detId);
179 }
void newCellImpl(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId)
void addValidID(const DetId &id)

◆ newCellFast()

void HcalDDDGeometry::newCellFast ( const GlobalPoint f1,
const GlobalPoint f2,
const GlobalPoint f3,
const CCGFloat parm,
const DetId detId 
)
private

Definition at line 181 of file HcalDDDGeometry.cc.

References DeadROC_duringRun::f1, DeadROC_duringRun::f2, CaloSubdetectorGeometry::m_validIds, and newCellImpl().

182  {
183  newCellImpl(f1, f2, f3, parm, detId);
184  m_validIds.emplace_back(detId);
185 }
std::vector< DetId > m_validIds
void newCellImpl(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId)

◆ newCellImpl()

void HcalDDDGeometry::newCellImpl ( const GlobalPoint f1,
const GlobalPoint f2,
const GlobalPoint f3,
const CCGFloat parm,
const DetId detId 
)
private

Definition at line 148 of file HcalDDDGeometry.cc.

References cms::cuda::assert(), CaloSubdetectorGeometry::cornersMgr(), DetId::det(), HcalTopology::detId2denseId(), cropTnPTrees::din, IdealZPrism::EM, DeadROC_duringRun::f1, IdealZPrism::HADR, DetId::Hcal, HcalBarrel, HcalEndcap, HcalOuter, m_hbCellVec, m_heCellVec, m_hfCellVec, m_hoCellVec, and topo_.

Referenced by newCell(), and newCellFast().

149  {
150  assert(detId.det() == DetId::Hcal);
151 
152  const unsigned int din(topo_.detId2denseId(detId));
153 
154  HcalDetId hId(detId);
155 
156  if (hId.subdet() == HcalBarrel) {
158  } else {
159  if (hId.subdet() == HcalEndcap) {
160  const unsigned int index(din - m_hbCellVec.size());
162  } else {
163  if (hId.subdet() == HcalOuter) {
164  const unsigned int index(din - m_hbCellVec.size() - m_heCellVec.size());
166  } else { // assuming HcalForward here!
167  const unsigned int index(din - m_hbCellVec.size() - m_heCellVec.size() - m_hoCellVec.size());
168  m_hfCellVec[index] =
169  IdealZPrism(f1, cornersMgr(), parm, hId.depth() == 1 ? IdealZPrism::EM : IdealZPrism::HADR);
170  }
171  }
172  }
173 }
unsigned int detId2denseId(const DetId &id) const override
return a linear packed id
assert(be >=bs)
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
const HcalTopology & topo_
HBCellVec m_hbCellVec
HECellVec m_heCellVec
CaloCellGeometry::CornersMgr * cornersMgr()
HFCellVec m_hfCellVec
HOCellVec m_hoCellVec

◆ sortValidIds()

void HcalDDDGeometry::sortValidIds ( )
private

Friends And Related Function Documentation

◆ HcalDDDGeometryLoader

friend class HcalDDDGeometryLoader
friend

Definition at line 19 of file HcalDDDGeometry.h.

Member Data Documentation

◆ etaMax_

double HcalDDDGeometry::etaMax_
private

Definition at line 67 of file HcalDDDGeometry.h.

Referenced by getClosestCell(), and insertCell().

◆ hcalCells_

std::vector<HcalCellType> HcalDDDGeometry::hcalCells_
private

Definition at line 59 of file HcalDDDGeometry.h.

Referenced by getClosestCell(), and insertCell().

◆ m_emptyIds

std::vector<DetId> HcalDDDGeometry::m_emptyIds
mutableprivate

Definition at line 64 of file HcalDDDGeometry.h.

Referenced by fillDetIds(), and getValidDetIds().

◆ m_filledDetIds

std::atomic<bool> HcalDDDGeometry::m_filledDetIds
mutableprivate

Definition at line 73 of file HcalDDDGeometry.h.

Referenced by fillDetIds(), and getValidDetIds().

◆ m_hbCellVec

HBCellVec HcalDDDGeometry::m_hbCellVec
private

Definition at line 69 of file HcalDDDGeometry.h.

Referenced by getGeometryRawPtr(), and newCellImpl().

◆ m_hbIds

std::vector<DetId> HcalDDDGeometry::m_hbIds
mutableprivate

Definition at line 60 of file HcalDDDGeometry.h.

Referenced by fillDetIds(), and getValidDetIds().

◆ m_heCellVec

HECellVec HcalDDDGeometry::m_heCellVec
private

Definition at line 70 of file HcalDDDGeometry.h.

Referenced by getGeometryRawPtr(), and newCellImpl().

◆ m_heIds

std::vector<DetId> HcalDDDGeometry::m_heIds
mutableprivate

Definition at line 61 of file HcalDDDGeometry.h.

Referenced by fillDetIds(), and getValidDetIds().

◆ m_hfCellVec

HFCellVec HcalDDDGeometry::m_hfCellVec
private

Definition at line 72 of file HcalDDDGeometry.h.

Referenced by getGeometryRawPtr(), and newCellImpl().

◆ m_hfIds

std::vector<DetId> HcalDDDGeometry::m_hfIds
mutableprivate

Definition at line 63 of file HcalDDDGeometry.h.

Referenced by fillDetIds(), and getValidDetIds().

◆ m_hoCellVec

HOCellVec HcalDDDGeometry::m_hoCellVec
private

Definition at line 71 of file HcalDDDGeometry.h.

Referenced by getGeometryRawPtr(), and newCellImpl().

◆ m_hoIds

std::vector<DetId> HcalDDDGeometry::m_hoIds
mutableprivate

Definition at line 62 of file HcalDDDGeometry.h.

Referenced by fillDetIds(), and getValidDetIds().

◆ topo_

const HcalTopology& HcalDDDGeometry::topo_
private

Definition at line 66 of file HcalDDDGeometry.h.

Referenced by newCellImpl().