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 ,
32  const CaloSubdetectorGeometry* geom ) {
33  bool ok ;
34  const unsigned int index = makeIndex( det, subdet, ok ) ;
35  if( ok ) m_geos[index] = geom ;
36 
37 // std::cout<<"Detector="<<(int)det<<", subset="<<subdet<<", index="<<index
38 // <<", size="<<m_geos.size()<<std::endl;
39 
40  assert( ok ) ;
41 }
42 
45 {
46  bool ok ;
47 
48  const unsigned int index ( makeIndex( id.det(),
49  id.subdetId(),
50  ok ) ) ;
51  return ( ok ? m_geos[ index ] : nullptr ) ;
52 }
53 
56  int subdet ) const
57 {
58  bool ok ;
59 
60  const unsigned int index ( makeIndex( det,
61  subdet,
62  ok ) ) ;
63  return ( ok ? m_geos[ index ] : nullptr ) ;
64 }
65 
66 static const GlobalPoint notFound(0,0,0);
67 
69 CaloGeometry::getPosition( const DetId& id ) const {
71  if (geom) {
72  GlobalPoint pos = geom->getGeometry(id)->getPosition();
73  return pos;
74  } else {
75  return notFound;
76  }
77 }
78 
79 std::shared_ptr<const CaloCellGeometry>
80 CaloGeometry::getGeometry( const DetId& id ) const {
82  if (geom) {
83  auto cell = geom->getGeometry(id);
84  return cell;
85  } else {
86  return std::shared_ptr<const CaloCellGeometry>();
87  }
88 }
89 
90 bool
91 CaloGeometry::present( const DetId& id ) const
92 {
94  return ( nullptr == geom ? false : geom->present( id ) ) ;
95 }
96 
97 std::vector<DetId> CaloGeometry::getValidDetIds() const
98 {
99  std::vector<DetId> returnValue ;
100  returnValue.reserve( kLength ) ;
101 
102  bool doneHcal ( false ) ;
103  for( unsigned int i ( 0 ) ; i != m_geos.size() ; ++i )
104  {
105  if( nullptr != m_geos[i] )
106  {
107  const std::vector< DetId >& aVec = m_geos[i]->getValidDetIds();
108  if( aVec.empty() ) {
109  edm::LogWarning("EmptyDetIdList") << "Valid det id list at index " << i << " is empty!" << std::endl;
110  }
111  const bool isHcal ( !aVec.empty() && DetId::Hcal == aVec.front().det() ) ;
112  if( !doneHcal ||
113  !isHcal )
114  {
115  returnValue.insert( returnValue.end(), aVec.begin(), aVec.end() ) ;
116  if( !doneHcal &&
117  isHcal ) doneHcal = true ;
118  }
119  }
120  }
121  return returnValue ;
122 }
123 
124 const std::vector<DetId>&
126  int subdet ) const
127 {
128  bool ok ;
129 
130  const unsigned int index ( makeIndex( det,
131  subdet,
132  ok ) ) ;
133 
134  return ( ok && ( nullptr != m_geos[ index ] ) ?
135  m_geos[ index ]->getValidDetIds( det, subdet ) :
136  k_emptyVec ) ;
137 }
138 
139 
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:44
#define nullptr
virtual bool present(const DetId &id) const
is this detid present in the geometry?
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:69
static const std::vector< DetId > k_emptyVec
Definition: CaloGeometry.h:61
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:63
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
Detector
Definition: DetId.h:24
bool present(const DetId &id) const
is this detid present in the geometry?
Definition: CaloGeometry.cc:91
static const GlobalPoint notFound(0, 0, 0)
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
Definition: CaloGeometry.cc:97
unsigned int makeIndex(DetId::Detector det, int subdet, bool &ok) const
Definition: CaloGeometry.cc:15
std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id.
Definition: CaloGeometry.cc:80