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< CaloCellGeometry const * > 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

virtual DetId getClosestCell (const GlobalPoint &r) const
 
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) More...
 
 HcalDDDGeometry (const HcalTopology &theTopo)
 
int insertCell (std::vector< HcalCellType > const &)
 
virtual void newCell (const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId)
 
virtual ~HcalDDDGeometry ()
 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 ()
 
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 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
 
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

virtual const CaloCellGeometrycellGeomPtr (uint32_t index) const
 
- Protected Member Functions inherited from CaloSubdetectorGeometry
void addValidID (const DetId &id)
 
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

Definition at line 23 of file HcalDDDGeometry.h.

Definition at line 24 of file HcalDDDGeometry.h.

Definition at line 26 of file HcalDDDGeometry.h.

Definition at line 25 of file HcalDDDGeometry.h.

Constructor & Destructor Documentation

HcalDDDGeometry::HcalDDDGeometry ( const HcalTopology theTopo)
explicit

Definition at line 10 of file HcalDDDGeometry.cc.

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

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

Definition at line 21 of file HcalDDDGeometry.cc.

22 {
23 }

Member Function Documentation

const CaloCellGeometry * HcalDDDGeometry::cellGeomPtr ( uint32_t  index) const
protectedvirtual

Implements CaloSubdetectorGeometry.

Definition at line 224 of file HcalDDDGeometry.cc.

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

225 {
226  const CaloCellGeometry* cell ( 0 ) ;
227  if( m_hbCellVec.size() > din )
228  {
229  cell = &m_hbCellVec[ din ] ;
230  }
231  else
232  {
233  if( m_hbCellVec.size() +
234  m_heCellVec.size() > din )
235  {
236  const unsigned int index ( din - m_hbCellVec.size() ) ;
237  cell = &m_heCellVec[ index ] ;
238  }
239  else
240  {
241  if( m_hbCellVec.size() +
242  m_heCellVec.size() +
243  m_hoCellVec.size() > din )
244  {
245  const unsigned int index ( din
246  - m_hbCellVec.size()
247  - m_heCellVec.size() ) ;
248  cell = &m_hoCellVec[ index ] ;
249  }
250  else
251  {
252  if( m_hbCellVec.size() +
253  m_heCellVec.size() +
254  m_hoCellVec.size() +
255  m_hfCellVec.size() > din )
256  {
257  const unsigned int index ( din
258  - m_hbCellVec.size()
259  - m_heCellVec.size()
260  - m_hoCellVec.size() ) ;
261  cell = &m_hfCellVec[ index ] ;
262  }
263  }
264  }
265  }
266  return ( 0 == cell || 0 == cell->param() ? 0 : cell ) ;
267 }
HBCellVec m_hbCellVec
HECellVec m_heCellVec
HFCellVec m_hfCellVec
HOCellVec m_hoCellVec
void HcalDDDGeometry::fillDetIds ( ) const
private

Definition at line 26 of file HcalDDDGeometry.cc.

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

Referenced by getValidDetIds().

27 {
28  std::lock_guard<std::mutex> guard(s_fillLock);
29  if (m_filledDetIds) {
30  //another thread already did the work
31  return;
32  }
33  const std::vector<DetId>& baseIds ( CaloSubdetectorGeometry::getValidDetIds() ) ;
34  for( unsigned int i ( 0 ) ; i != baseIds.size() ; ++i )
35  {
36  const DetId id ( baseIds[i] );
37  if( id.subdetId() == HcalBarrel )
38  {
39  m_hbIds.push_back( id ) ;
40  }
41  else
42  {
43  if( id.subdetId() == HcalEndcap )
44  {
45  m_heIds.push_back( id ) ;
46  }
47  else
48  {
49  if( id.subdetId() == HcalOuter )
50  {
51  m_hoIds.push_back( id ) ;
52  }
53  else
54  {
55  if( id.subdetId() == HcalForward )
56  {
57  m_hfIds.push_back( id ) ;
58  }
59  }
60  }
61  }
62  }
63  std::sort( m_hbIds.begin(), m_hbIds.end() ) ;
64  std::sort( m_heIds.begin(), m_heIds.end() ) ;
65  std::sort( m_hoIds.begin(), m_hoIds.end() ) ;
66  std::sort( m_hfIds.begin(), m_hfIds.end() ) ;
67 
68  m_emptyIds.resize( 0 ) ;
69  m_filledDetIds = true;
70 }
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:18
std::vector< DetId > m_emptyIds
std::vector< DetId > m_hoIds
DetId HcalDDDGeometry::getClosestCell ( const GlobalPoint r) const
virtual

Reimplemented from CaloSubdetectorGeometry.

Definition at line 86 of file HcalDDDGeometry.cc.

References constexpr, PV3DBase< T, PVType, FrameType >::eta(), etaMax_, ALCARECOTkAlBeamHalo_cff::etaMin, hcalCells_, HcalForward, mps_fire::i, LogDebug, M_PI, PV3DBase< T, PVType, FrameType >::mag(), phi, PV3DBase< T, PVType, FrameType >::phi(), TCMET_cfi::radius, z, and PV3DBase< T, PVType, FrameType >::z().

87 {
88  constexpr double twopi = M_PI+M_PI;
89  constexpr double deg = M_PI/180.;
90 
91  // Now find the closest eta_bin, eta value of a bin i is average
92  // of eta[i] and eta[i-1]
93  double abseta = fabs(r.eta());
94  double phi = r.phi();
95  if (phi < 0) phi += twopi;
96  double radius = r.mag();
97  double z = fabs(r.z());
98 
99  LogDebug("HCalGeom") << "HcalDDDGeometry::getClosestCell for eta "
100  << r.eta() << " phi " << phi/deg << " z " << r.z()
101  << " radius " << radius;
102  HcalDetId bestId;
103  if (abseta <= etaMax_) {
104  for (unsigned int i=0; i<hcalCells_.size(); i++) {
105  if (abseta >=hcalCells_[i].etaMin() && abseta <=hcalCells_[i].etaMax()) {
106  HcalSubdetector bc = hcalCells_[i].detType();
107  int etaring = hcalCells_[i].etaBin();
108  int phibin = 0;
109  if (hcalCells_[i].unitPhi() == 4) {
110  // rings 40 and 41 are offset wrt the other phi numbering
111  // 1 1 1 2
112  // ------------------------------
113  // 72 36 36 1
114  phibin = static_cast<int>((phi+hcalCells_[i].phiOffset()+
115  0.5*hcalCells_[i].phiBinWidth())/
116  hcalCells_[i].phiBinWidth());
117  if (phibin == 0) phibin = hcalCells_[i].nPhiBins();
118  phibin = phibin*4 - 1;
119  } else {
120  phibin = static_cast<int>((phi+hcalCells_[i].phiOffset())/
121  hcalCells_[i].phiBinWidth()) + 1;
122  // convert to the convention of numbering 1,3,5, in 36 phi bins
123  phibin = (phibin-1)*(hcalCells_[i].unitPhi()) + 1;
124  }
125 
126  int dbin = 1;
127  int etabin = (r.z() > 0) ? etaring : -etaring;
128  if (bc == HcalForward) {
129  bestId = HcalDetId(bc, etabin, phibin, dbin);
130  break;
131  } else {
132  double rz = z;
133  if (hcalCells_[i].depthType()) rz = radius;
134  if (rz < hcalCells_[i].depthMax()) {
135  dbin = hcalCells_[i].depthSegment();
136  bestId = HcalDetId(bc, etabin, phibin, dbin);
137  break;
138  }
139  }
140  }
141  }
142  }
143 
144  LogDebug("HCalGeom") << "HcalDDDGeometry::getClosestCell " << bestId;
145 
146  return bestId;
147 }
#define LogDebug(id)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
#define constexpr
T mag() const
Definition: PV3DBase.h:67
T z() const
Definition: PV3DBase.h:64
HcalSubdetector
Definition: HcalAssistant.h:31
std::vector< HcalCellType > hcalCells_
#define M_PI
T eta() const
Definition: PV3DBase.h:76
std::vector< DetId > const & HcalDDDGeometry::getValidDetIds ( DetId::Detector  det = DetId::Detector ( 0 ),
int  subdet = 0 
) const
virtual

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 73 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.

75 {
76  if( 0 != subdet &&
77  not m_filledDetIds ) fillDetIds() ;
78  return ( 0 == subdet ? CaloSubdetectorGeometry::getValidDetIds() :
79  ( HcalBarrel == subdet ? m_hbIds :
80  ( HcalEndcap == subdet ? m_heIds :
81  ( HcalOuter == subdet ? m_hoIds :
82  ( HcalForward == subdet ? m_hfIds : m_emptyIds ) ) ) ) ) ;
83 }
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
void fillDetIds() const
std::vector< DetId > m_emptyIds
std::vector< DetId > m_hoIds
void HcalDDDGeometry::increaseReserve ( unsigned int  extra)
private

Definition at line 269 of file HcalDDDGeometry.cc.

References CaloSubdetectorGeometry::m_validIds.

Referenced by HcalDDDGeometryLoader::fill().

269  {
270  m_validIds.reserve(m_validIds.size()+extra);
271 }
std::vector< DetId > m_validIds
int HcalDDDGeometry::insertCell ( std::vector< HcalCellType > const &  cells)

Definition at line 150 of file HcalDDDGeometry.cc.

References ALCARECOTkAlBeamHalo_cff::etaMax, etaMax_, hcalCells_, mps_fire::i, LogDebug, and pileupDistInMC::num.

Referenced by HcalDDDGeometryLoader::fill().

150  {
151 
152  hcalCells_.insert(hcalCells_.end(), cells.begin(), cells.end());
153  int num = static_cast<int>(hcalCells_.size());
154  for (unsigned int i=0; i<cells.size(); i++) {
155  if (cells[i].etaMax() > etaMax_ ) etaMax_ = cells[i].etaMax();
156  }
157 
158  LogDebug("HCalGeom") << "HcalDDDGeometry::insertCell " << cells.size()
159  << " cells inserted == Total " << num
160  << " EtaMax = " << etaMax_;
161  return num;
162 }
#define LogDebug(id)
std::vector< HcalCellType > hcalCells_
void HcalDDDGeometry::newCell ( const GlobalPoint f1,
const GlobalPoint f2,
const GlobalPoint f3,
const CCGFloat parm,
const DetId detId 
)
virtual

Implements CaloSubdetectorGeometry.

Definition at line 202 of file HcalDDDGeometry.cc.

References CaloSubdetectorGeometry::addValidID(), and newCellImpl().

207 {
208  newCellImpl(f1,f2,f3,parm,detId);
209  addValidID( detId );
210 }
void newCellImpl(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId)
void addValidID(const DetId &id)
void HcalDDDGeometry::newCellFast ( const GlobalPoint f1,
const GlobalPoint f2,
const GlobalPoint f3,
const CCGFloat parm,
const DetId detId 
)
private

Definition at line 213 of file HcalDDDGeometry.cc.

References CaloSubdetectorGeometry::m_validIds, and newCellImpl().

Referenced by HcalDDDGeometryLoader::makeCell().

218 {
219  newCellImpl(f1,f2,f3,parm,detId);
220  m_validIds.push_back(detId);
221 }
std::vector< DetId > m_validIds
void newCellImpl(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId)
void HcalDDDGeometry::newCellImpl ( const GlobalPoint f1,
const GlobalPoint f2,
const GlobalPoint f3,
const CCGFloat parm,
const DetId detId 
)
private

Definition at line 165 of file HcalDDDGeometry.cc.

References CaloSubdetectorGeometry::cornersMgr(), DetId::det(), HcalTopology::detId2denseId(), cropTnPTrees::din, IdealZPrism::EM, IdealZPrism::HADR, DetId::Hcal, HcalBarrel, HcalEndcap, HcalOuter, diffTreeTool::index, m_hbCellVec, m_heCellVec, m_hfCellVec, m_hoCellVec, and topo_.

Referenced by newCell(), and newCellFast().

170 {
171 
172  assert( detId.det()==DetId::Hcal );
173 
174  const unsigned int din(topo_.detId2denseId(detId));
175 
176  HcalDetId hId(detId);
177 
178  if( hId.subdet()==HcalBarrel ) {
179  m_hbCellVec[ din ] = IdealObliquePrism( f1, cornersMgr(), parm ) ;
180  } else {
181  if( hId.subdet()==HcalEndcap ) {
182  const unsigned int index ( din - m_hbCellVec.size() ) ;
183  m_heCellVec[ index ] = IdealObliquePrism( f1, cornersMgr(), parm ) ;
184  } else {
185  if( hId.subdet()==HcalOuter ) {
186  const unsigned int index ( din
187  - m_hbCellVec.size()
188  - m_heCellVec.size() ) ;
189  m_hoCellVec[ index ] = IdealObliquePrism( f1, cornersMgr(), parm ) ;
190  } else { // assuming HcalForward here!
191  const unsigned int index ( din
192  - m_hbCellVec.size()
193  - m_heCellVec.size()
194  - m_hoCellVec.size() ) ;
195  m_hfCellVec[ index ] = IdealZPrism( f1, cornersMgr(), parm, hId.depth()==1 ? IdealZPrism::EM : IdealZPrism::HADR ) ;
196  }
197  }
198  }
199 }
virtual unsigned int detId2denseId(const DetId &id) const
return a linear packed id
const HcalTopology & topo_
HBCellVec m_hbCellVec
HECellVec m_heCellVec
CaloCellGeometry::CornersMgr * cornersMgr()
HFCellVec m_hfCellVec
HOCellVec m_hoCellVec
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
void HcalDDDGeometry::sortValidIds ( )
private

Definition at line 273 of file HcalDDDGeometry.cc.

References CaloSubdetectorGeometry::m_validIds.

Referenced by HcalDDDGeometryLoader::load().

273  {
274  std::sort(m_validIds.begin(),m_validIds.end());
275 }
std::vector< DetId > m_validIds

Friends And Related Function Documentation

friend class HcalDDDGeometryLoader
friend

Definition at line 21 of file HcalDDDGeometry.h.

Member Data Documentation

double HcalDDDGeometry::etaMax_
private

Definition at line 77 of file HcalDDDGeometry.h.

Referenced by getClosestCell(), and insertCell().

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

Definition at line 69 of file HcalDDDGeometry.h.

Referenced by getClosestCell(), and insertCell().

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

Definition at line 74 of file HcalDDDGeometry.h.

Referenced by fillDetIds(), and getValidDetIds().

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

Definition at line 83 of file HcalDDDGeometry.h.

Referenced by fillDetIds(), and getValidDetIds().

HBCellVec HcalDDDGeometry::m_hbCellVec
private

Definition at line 79 of file HcalDDDGeometry.h.

Referenced by cellGeomPtr(), and newCellImpl().

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

Definition at line 70 of file HcalDDDGeometry.h.

Referenced by fillDetIds(), and getValidDetIds().

HECellVec HcalDDDGeometry::m_heCellVec
private

Definition at line 80 of file HcalDDDGeometry.h.

Referenced by cellGeomPtr(), and newCellImpl().

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

Definition at line 71 of file HcalDDDGeometry.h.

Referenced by fillDetIds(), and getValidDetIds().

HFCellVec HcalDDDGeometry::m_hfCellVec
private

Definition at line 82 of file HcalDDDGeometry.h.

Referenced by cellGeomPtr(), and newCellImpl().

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

Definition at line 73 of file HcalDDDGeometry.h.

Referenced by fillDetIds(), and getValidDetIds().

HOCellVec HcalDDDGeometry::m_hoCellVec
private

Definition at line 81 of file HcalDDDGeometry.h.

Referenced by cellGeomPtr(), and newCellImpl().

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

Definition at line 72 of file HcalDDDGeometry.h.

Referenced by fillDetIds(), and getValidDetIds().

const HcalTopology& HcalDDDGeometry::topo_
private

Definition at line 76 of file HcalDDDGeometry.h.

Referenced by newCellImpl().