CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackerGeometry.cc
Go to the documentation of this file.
1 #include <typeinfo>
2 
7 
11 
12 #include <algorithm>
13 #include <iostream>
14 #include <map>
15 
16 TrackerGeometry::TrackerGeometry(GeometricDet const* gd) : theTrackerDet(gd){}
17 
19  for (auto d : theDets) delete const_cast<GeomDet*>(d);
20  for (auto d : theDetTypes) delete const_cast<GeomDetType*>(d);
21 }
22 
24  theDetTypes.shrink_to_fit(); // owns the DetTypes
25  theDetUnits.shrink_to_fit(); // they're all also into 'theDets', so we assume 'theDets' owns them
26  theDets.shrink_to_fit(); // owns *ONLY* the GeomDet * corresponding to GluedDets.
27  theDetUnitIds.shrink_to_fit();
28  theDetIds.shrink_to_fit();
29 
30  thePXBDets.shrink_to_fit(); // not owned: they're also in 'theDets'
31  thePXFDets.shrink_to_fit(); // not owned: they're also in 'theDets'
32  theTIBDets.shrink_to_fit(); // not owned: they're also in 'theDets'
33  theTIDDets.shrink_to_fit(); // not owned: they're also in 'theDets'
34  theTOBDets.shrink_to_fit(); // not owned: they're also in 'theDets'
35  theTECDets.shrink_to_fit(); // not owned: they're also in 'theDets'
36 }
37 
38 
40  theDetTypes.push_back(p); // add to vector
41 }
42 
44  // set index
45  const_cast<GeomDetUnit *>(p)->setIndex(theDetUnits.size());
46  theDetUnits.push_back(p); // add to vector
47  theMapUnit.insert(std::make_pair(p->geographicalId().rawId(),p));
48 }
49 
51  theDetUnitIds.push_back(p);
52 }
53 
55  theDets.push_back(p); // add to vector
56  theMap.insert(std::make_pair(p->geographicalId().rawId(),p));
57  DetId id(p->geographicalId());
58  switch(id.subdetId()){
60  thePXBDets.push_back(p);
61  break;
63  thePXFDets.push_back(p);
64  break;
66  theTIBDets.push_back(p);
67  break;
69  theTIDDets.push_back(p);
70  break;
72  theTOBDets.push_back(p);
73  break;
75  theTECDets.push_back(p);
76  break;
77  default:
78  edm::LogError("TrackerGeometry")<<"ERROR - I was expecting a Tracker Subdetector, I got a "<<id.subdetId();
79  }
80 
81 
82 }
83 
85  theDetIds.push_back(p);
86 }
87 
90 {
91  return theDetUnits;
92 }
93 
96 {
97  return theDets;
98 }
99 
102 {
103  return thePXBDets;
104 }
105 
108 {
109  return thePXFDets;
110 }
111 
114 {
115  return theTIBDets;
116 }
117 
120 {
121  return theTIDDets;
122 }
123 
126 {
127  return theTOBDets;
128 }
129 
132 {
133  return theTECDets;
134 }
135 
136 const TrackerGeomDet *
138 {
139  mapIdToDetUnit::const_iterator p=theMapUnit.find(s.rawId());
140  if (p != theMapUnit.end())
141  return static_cast<const TrackerGeomDet *>(p->second);
142  edm::LogError("TrackerGeometry")<<"Invalid DetID: no GeomDetUnit associated";
143  return nullptr;
144 }
145 
146 const TrackerGeomDet*
148 {
149  mapIdToDet::const_iterator p=theMap.find(s.rawId());
150  if (p != theMap.end())
151  return static_cast<const TrackerGeomDet *>(p->second);
152  edm::LogError("TrackerGeometry")<<"Invalid DetID: no GeomDet associated";
153  return nullptr;
154 }
155 
158 {
159  return theDetTypes;
160 }
161 
162 
165 {
166  return theDetUnitIds;
167 }
168 
171 {
172  return theDetIds;
173 }
174 
175 
virtual const TrackerGeomDet * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
std::vector< GeomDetType const * > DetTypeContainer
void addDet(GeomDet const *p)
mapIdToDet theMap
TrackerGeometry(GeometricDet const *gd=0)
DetIdContainer theDetIds
DetIdContainer theDetUnitIds
DetContainer theTECDets
DetContainer theDets
void addDetId(DetId p)
DetUnitContainer theDetUnits
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
virtual const DetUnitContainer & detUnits() const
Returm a vector of all GeomDetUnit.
void addDetUnit(GeomDetUnit const *p)
virtual const DetIdContainer & detIds() const
Returm a vector of all GeomDet DetIds (including those of GeomDetUnits)
mapIdToDetUnit theMapUnit
const DetContainer & detsTEC() const
DetTypeContainer theDetTypes
virtual ~TrackerGeometry()
void addType(GeomDetType const *p)
virtual const DetTypeContainer & detTypes() const
Return a vector of all det types.
const DetContainer & detsPXB() const
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:77
DetContainer theTIDDets
const DetContainer & detsTIB() const
Definition: DetId.h:18
DetContainer thePXBDets
DetContainer thePXFDets
void addDetUnitId(DetId p)
DetContainer theTIBDets
DetContainer theTOBDets
virtual const DetIdContainer & detUnitIds() const
Returm a vector of all GeomDetUnit DetIds.
const DetContainer & detsPXF() const
const DetContainer & detsTOB() const
std::vector< GeomDet const * > DetContainer
std::vector< GeomDetUnit const * > DetUnitContainer
virtual const DetContainer & dets() const
Returm a vector of all GeomDet (including all GeomDetUnits)
const DetContainer & detsTID() const
virtual const TrackerGeomDet * idToDet(DetId) const
std::vector< DetId > DetIdContainer