CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloGeometry.cc
Go to the documentation of this file.
4 
5 const std::vector<DetId> CaloGeometry::k_emptyVec ( 0 ) ;
6 
8  m_geos ( kLength, 0 )
9 {
10 }
11 
12 unsigned int
14  int subdet ,
15  bool& ok ) const
16 {
17  const unsigned int idet ( det ) ;
18 
19  ok = ( kMinDet <= idet &&
20  kMaxDet >= idet &&
21  0 < subdet &&
22  kMaxSub >= subdet ) ;
23 
24  return ( ( det - kMinDet )*kMaxSub + subdet - 1 ) ;
25 }
26 
27 void
29  int subdet ,
31 {
32  bool ok ;
33  const unsigned int index = makeIndex( det, subdet, ok ) ;
34  if( ok ) m_geos[index] = geom ;
35 
36 // std::cout<<"Detector="<<(int)det<<", subset="<<subdet<<", index="<<index
37 // <<", size="<<m_geos.size()<<std::endl;
38 
39  assert( ok ) ;
40 }
41 
44 {
45  bool ok ;
46 
47  const unsigned int index ( makeIndex( id.det(),
48  id.subdetId(),
49  ok ) ) ;
50  return ( ok ? m_geos[ index ] : 0 ) ;
51 }
52 
55  int subdet ) const
56 {
57  bool ok ;
58 
59  const unsigned int index ( makeIndex( det,
60  subdet,
61  ok ) ) ;
62  return ( ok ? m_geos[ index ] : 0 ) ;
63 }
64 
65 static const GlobalPoint notFound(0,0,0);
66 
67 const GlobalPoint&
68 CaloGeometry::getPosition( const DetId& id ) const
69 {
71  const CaloCellGeometry* cell ( ( 0 == geom ? 0 : geom->getGeometry( id ) ) ) ;
72  return ( 0 == cell ? notFound : cell->getPosition() ) ;
73 }
74 
75 const CaloCellGeometry*
76 CaloGeometry::getGeometry( const DetId& id ) const
77 {
79  const CaloCellGeometry* cell ( 0 == geom ? 0 : geom->getGeometry( id ) ) ;
80  return cell ;
81 }
82 
83 bool
84 CaloGeometry::present( const DetId& id ) const
85 {
87  return ( 0 == geom ? false : geom->present( id ) ) ;
88 }
89 
90 std::vector<DetId> CaloGeometry::getValidDetIds() const
91 {
92  std::vector<DetId> returnValue ;
93  returnValue.reserve( kLength ) ;
94 
95  bool doneHcal ( false ) ;
96  for( unsigned int i ( 0 ) ; i != m_geos.size() ; ++i )
97  {
98  if( 0 != m_geos[i] )
99  {
100  const std::vector< DetId >& aVec ( m_geos[i]->getValidDetIds() ) ;
101  const bool isHcal ( DetId::Hcal == aVec.front().det() ) ;
102  if( !doneHcal ||
103  !isHcal )
104  {
105  returnValue.insert( returnValue.end(), aVec.begin(), aVec.end() ) ;
106  if( !doneHcal &&
107  isHcal ) doneHcal = true ;
108  }
109  }
110  }
111  return returnValue ;
112 }
113 
114 const std::vector<DetId>&
116  int subdet ) const
117 {
118  bool ok ;
119 
120  const unsigned int index ( makeIndex( det,
121  subdet,
122  ok ) ) ;
123 
124  return ( ok && ( 0 != m_geos[ index ] ) ?
125  m_geos[ index ]->getValidDetIds( det, subdet ) :
126  k_emptyVec ) ;
127 }
128 
129 
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:43
int i
Definition: DBlmapReader.cc:9
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:68
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:28
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:84
static const GlobalPoint notFound(0, 0, 0)
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
Definition: CaloGeometry.cc:90
const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id.
Definition: CaloGeometry.cc:76
unsigned int makeIndex(DetId::Detector det, int subdet, bool &ok) const
Definition: CaloGeometry.cc:13
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.