CMS 3D CMS Logo

CaloGeometry.cc
Go to the documentation of this file.
4 
6 
7 const std::vector<DetId> CaloGeometry::k_emptyVec ( 0 ) ;
8 
10  m_geos ( kLength, nullptr )
11 {
12 }
13 
14 unsigned int
16  int subdet ,
17  bool& ok ) const
18 {
19  const unsigned int idet ( det ) ;
20 
21  ok = ( kMinDet <= idet &&
22  kMaxDet >= idet &&
23  0 < subdet &&
24  kMaxSub >= subdet ) ;
25 
26  return ( ( det - kMinDet )*kMaxSub + subdet - 1 ) ;
27 }
28 
29 void
31  int subdet ,
33 {
34  bool ok ;
35  const unsigned int index = makeIndex( det, subdet, ok ) ;
36  if( ok ) m_geos[index] = geom ;
37 
38 // std::cout<<"Detector="<<(int)det<<", subset="<<subdet<<", index="<<index
39 // <<", size="<<m_geos.size()<<std::endl;
40 
41  assert( ok ) ;
42 }
43 
46 {
47  bool ok ;
48 
49  const unsigned int index ( makeIndex( id.det(),
50  id.subdetId(),
51  ok ) ) ;
52  return ( ok ? m_geos[ index ] : nullptr ) ;
53 }
54 
57  int subdet ) const
58 {
59  bool ok ;
60 
61  const unsigned int index ( makeIndex( det,
62  subdet,
63  ok ) ) ;
64  return ( ok ? m_geos[ index ] : nullptr ) ;
65 }
66 
67 static const GlobalPoint notFound(0,0,0);
68 
69 const GlobalPoint&
70 CaloGeometry::getPosition( const DetId& id ) const
71 {
73  const CaloCellGeometry* cell ( ( nullptr == geom ? nullptr : geom->getGeometry( id ) ) ) ;
74  return ( nullptr == cell ? notFound : cell->getPosition() ) ;
75 }
76 
77 const CaloCellGeometry*
78 CaloGeometry::getGeometry( const DetId& id ) const
79 {
81  const CaloCellGeometry* cell ( nullptr == geom ? nullptr : geom->getGeometry( id ) ) ;
82  return cell ;
83 }
84 
85 bool
86 CaloGeometry::present( const DetId& id ) const
87 {
89  return ( nullptr == geom ? false : geom->present( id ) ) ;
90 }
91 
92 std::vector<DetId> CaloGeometry::getValidDetIds() const
93 {
94  std::vector<DetId> returnValue ;
95  returnValue.reserve( kLength ) ;
96 
97  bool doneHcal ( false ) ;
98  for( unsigned int i ( 0 ) ; i != m_geos.size() ; ++i )
99  {
100  if( nullptr != m_geos[i] )
101  {
102  const std::vector< DetId >& aVec = m_geos[i]->getValidDetIds();
103  if( aVec.empty() ) {
104  edm::LogWarning("EmptyDetIdList") << "Valid det id list at index " << i << " is empty!" << std::endl;
105  }
106  const bool isHcal ( !aVec.empty() && DetId::Hcal == aVec.front().det() ) ;
107  if( !doneHcal ||
108  !isHcal )
109  {
110  returnValue.insert( returnValue.end(), aVec.begin(), aVec.end() ) ;
111  if( !doneHcal &&
112  isHcal ) doneHcal = true ;
113  }
114  }
115  }
116  return returnValue ;
117 }
118 
119 const std::vector<DetId>&
121  int subdet ) const
122 {
123  bool ok ;
124 
125  const unsigned int index ( makeIndex( det,
126  subdet,
127  ok ) ) ;
128 
129  return ( ok && ( nullptr != m_geos[ index ] ) ?
130  m_geos[ index ]->getValidDetIds( det, subdet ) :
131  k_emptyVec ) ;
132 }
133 
134 
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:45
virtual const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
#define nullptr
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
virtual bool present(const DetId &id) const
is this detid present in the geometry?
const GlobalPoint & getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:70
static const std::vector< DetId > k_emptyVec
Definition: CaloGeometry.h:60
Definition: DetId.h:18
void setSubdetGeometry(DetId::Detector det, int subdet, const CaloSubdetectorGeometry *geom)
Register a subdetector geometry.
Definition: CaloGeometry.cc:30
std::vector< const CaloSubdetectorGeometry * > m_geos
Definition: CaloGeometry.h:62
Detector
Definition: DetId.h:24
bool present(const DetId &id) const
is this detid present in the geometry?
Definition: CaloGeometry.cc:86
static const GlobalPoint notFound(0, 0, 0)
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
Definition: CaloGeometry.cc:92
const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id.
Definition: CaloGeometry.cc:78
unsigned int makeIndex(DetId::Detector det, int subdet, bool &ok) const
Definition: CaloGeometry.cc:15