CMS 3D CMS Logo

TrackerGeometry.cc
Go to the documentation of this file.
1 #include <typeinfo>
2 
8 
13 
14 #include <algorithm>
15 #include <iostream>
16 #include <map>
17 
18 namespace {
19  GeomDetEnumerators::SubDetector geometricDetToGeomDet(GeometricDet::GDEnumType gdenum) {
20  // provide a map between the GeometricDet enumerators and the GeomDet enumerators of the possible tracker subdetectors
23  if (gdenum == GeometricDet::GDEnumType::PixelEndCap)
25  if (gdenum == GeometricDet::GDEnumType::TIB)
27  if (gdenum == GeometricDet::GDEnumType::TID)
29  if (gdenum == GeometricDet::GDEnumType::TOB)
31  if (gdenum == GeometricDet::GDEnumType::TEC)
33  if (gdenum == GeometricDet::GDEnumType::PixelPhase1Barrel)
35  if (gdenum == GeometricDet::GDEnumType::PixelPhase1EndCap)
37  if (gdenum == GeometricDet::GDEnumType::PixelPhase2Barrel)
39  if (gdenum == GeometricDet::GDEnumType::PixelPhase2EndCap)
41  if (gdenum == GeometricDet::GDEnumType::OTPhase2Barrel)
43  if (gdenum == GeometricDet::GDEnumType::OTPhase2EndCap)
46  }
47 
48  class DetIdComparator {
49  public:
50  bool operator()(GeometricDet const* gd1, GeometricDet const* gd2) const {
51  uint32_t det1 = gd1->geographicalId();
52  uint32_t det2 = gd2->geographicalId();
53  return det1 < det2;
54  }
55  };
56 } // namespace
57 
58 TrackerGeometry::TrackerGeometry(GeometricDet const* gd) : theTrackerDet(gd) {
59  for (unsigned int i = 0; i < 6; ++i) {
61  theNumberOfLayers[i] = 0;
62  }
64 
65  LogDebug("BuildingSubDetTypeMap") << "GeometriDet and GeomDetEnumerators enumerator values of the subdetectors";
66  for (unsigned int i = 0; i < subdetgd.size(); ++i) {
67  assert(subdetgd[i]->geographicalId().subdetId() > 0 && subdetgd[i]->geographicalId().subdetId() < 7);
68  theSubDetTypeMap[subdetgd[i]->geographicalId().subdetId() - 1] = geometricDetToGeomDet(subdetgd[i]->type());
69  theNumberOfLayers[subdetgd[i]->geographicalId().subdetId() - 1] = subdetgd[i]->components().size();
70  LogTrace("BuildingSubDetTypeMap") << "subdet " << i << " Geometric Det type " << subdetgd[i]->type()
71  << " Geom Det type "
72  << theSubDetTypeMap[subdetgd[i]->geographicalId().subdetId() - 1] << " detid "
73  << subdetgd[i]->geographicalId() << " subdetid "
74  << subdetgd[i]->geographicalId().subdetId() << " number of layers "
75  << subdetgd[i]->components().size();
76  }
77  LogDebug("SubDetTypeMapContent") << "Content of theSubDetTypeMap";
78  for (unsigned int i = 1; i < 7; ++i) {
79  LogTrace("SubDetTypeMapContent") << " detid subdet " << i << " Geom Det type " << geomDetSubDetector(i);
80  }
81  LogDebug("NumberOfLayers") << "Content of theNumberOfLayers";
82  for (unsigned int i = 1; i < 7; ++i) {
83  LogTrace("NumberOfLayers") << " detid subdet " << i << " number of layers " << numberOfLayers(i);
84  }
85  std::vector<const GeometricDet*> deepcomp;
86  gd->deepComponents(deepcomp);
87 
88  sort(deepcomp.begin(), deepcomp.end(), DetIdComparator());
89 
90  LogDebug("ThicknessAndType") << " Total Number of Detectors " << deepcomp.size();
91  LogDebug("ThicknessAndType") << "Dump of sensors names and bounds";
92  for (auto det : deepcomp) {
93  fillTestMap(det);
94  LogDebug("ThicknessAndType") << det->geographicalId() << " " << det->name() << " " << det->bounds()->thickness();
95  }
96  LogDebug("DetTypeList") << " Content of DetTypetList : size " << theDetTypetList.size();
97  for (const auto& iVal : theDetTypetList) {
98  LogDebug("DetTypeList") << " DetId " << std::get<0>(iVal) << " Type "
99  << static_cast<std::underlying_type<TrackerGeometry::ModuleType>::type>(std::get<1>(iVal))
100  << " Thickness " << std::get<2>(iVal);
101  }
102 }
103 
105  for (auto d : theDets)
106  delete const_cast<GeomDet*>(d);
107  for (auto d : theDetTypes)
108  delete const_cast<GeomDetType*>(d);
109 }
110 
112  theDetTypes.shrink_to_fit(); // owns the DetTypes
113  theDetUnits.shrink_to_fit(); // they're all also into 'theDets', so we assume 'theDets' owns them
114  theDets.shrink_to_fit(); // owns *ONLY* the GeomDet * corresponding to GluedDets.
115  theDetUnitIds.shrink_to_fit();
116  theDetIds.shrink_to_fit();
117 
118  thePXBDets.shrink_to_fit(); // not owned: they're also in 'theDets'
119  thePXFDets.shrink_to_fit(); // not owned: they're also in 'theDets'
120  theTIBDets.shrink_to_fit(); // not owned: they're also in 'theDets'
121  theTIDDets.shrink_to_fit(); // not owned: they're also in 'theDets'
122  theTOBDets.shrink_to_fit(); // not owned: they're also in 'theDets'
123  theTECDets.shrink_to_fit(); // not owned: they're also in 'theDets'
124 }
125 
127  theDetTypes.emplace_back(p); // add to vector
128 }
129 
131  // set index
132  const_cast<GeomDet*>(p)->setIndex(theDetUnits.size());
133  theDetUnits.emplace_back(p); // add to vector
134  theMapUnit.insert(std::make_pair(p->geographicalId().rawId(), p));
135 }
136 
138 
140  // set index
141  const_cast<GeomDet*>(p)->setGdetIndex(theDets.size());
142  theDets.emplace_back(p); // add to vector
143  theMap.insert(std::make_pair(p->geographicalId().rawId(), p));
144  DetId id(p->geographicalId());
145  switch (id.subdetId()) {
147  thePXBDets.emplace_back(p);
148  break;
150  thePXFDets.emplace_back(p);
151  break;
153  theTIBDets.emplace_back(p);
154  break;
156  theTIDDets.emplace_back(p);
157  break;
159  theTOBDets.emplace_back(p);
160  break;
162  theTECDets.emplace_back(p);
163  break;
164  default:
165  edm::LogError("TrackerGeometry") << "ERROR - I was expecting a Tracker Subdetector, I got a " << id.subdetId();
166  }
167 }
168 
169 void TrackerGeometry::addDetId(DetId p) { theDetIds.emplace_back(p); }
170 
172 
174 
176 
178 
180 
182 
184  mapIdToDetUnit::const_iterator p = theMapUnit.find(s.rawId());
185  if (p != theMapUnit.end()) {
186  return static_cast<const TrackerGeomDet*>(p->second);
187  } else {
188  throw cms::Exception("WrongTrackerSubDet")
189  << "Invalid DetID: no GeomDetUnit associated with raw ID " << s.rawId() << " of subdet ID " << s.subdetId();
190  }
191 }
192 
194  mapIdToDet::const_iterator p = theMap.find(s.rawId());
195  if (p != theMap.end()) {
196  return static_cast<const TrackerGeomDet*>(p->second);
197  } else {
198  throw cms::Exception("WrongTrackerSubDet")
199  << "Invalid DetID: no GeomDetUnit associated with raw ID " << s.rawId() << " of subdet ID " << s.subdetId();
200  }
201 }
202 
204  if (subdet >= 1 && subdet <= 6) {
205  return theSubDetTypeMap[subdet - 1];
206  } else {
207  throw cms::Exception("WrongTrackerSubDet") << "Subdetector " << subdet;
208  }
209 }
210 
211 unsigned int TrackerGeometry::numberOfLayers(int subdet) const {
212  if (subdet >= 1 && subdet <= 6) {
213  return theNumberOfLayers[subdet - 1];
214  } else {
215  throw cms::Exception("WrongTrackerSubDet") << "Subdetector " << subdet;
216  }
217 }
218 
220  for (unsigned int i = 1; i < 7; ++i) {
221  if (subdet == geomDetSubDetector(i))
222  return true;
223  }
224  return false;
225 }
226 
228  const std::string& temp = gd->name();
229  std::string name = temp.substr(temp.find(':') + 1);
230  DetId detid = gd->geographicalId();
231  float thickness = gd->bounds()->thickness();
232  std::string nameTag;
234  if (theDetTypetList.empty()) {
235  theDetTypetList.emplace_back(detid, mtype, thickness);
236  } else {
237  auto& t = (*(theDetTypetList.end() - 1));
238  if (std::get<1>(t) != mtype)
239  theDetTypetList.emplace_back(detid, mtype, thickness);
240  else {
241  if (detid > std::get<0>(t))
242  std::get<0>(t) = detid;
243  }
244  }
245 }
246 
248  for (const auto& iVal : theDetTypetList) {
249  DetId detid_max = std::get<0>(iVal);
250  if (detid.rawId() <= detid_max.rawId())
251  return std::get<1>(iVal);
252  }
254 }
255 
257  for (const auto& iVal : theDetTypetList) {
258  DetId detid_max = std::get<0>(iVal);
259  if (detid.rawId() <= detid_max.rawId())
260  return std::get<2>(iVal);
261  }
262  return -1.0;
263 }
264 
266  // IT
267  if (name.find("Pixel") != std::string::npos) {
268  // Phase 1
269  if (name.find("BarrelActive") != std::string::npos)
270  return ModuleType::Ph1PXB;
271  else if (name.find("ForwardSensor") != std::string::npos)
272  return ModuleType::Ph1PXF;
273 
274  // Phase 2
275  // barrel
276  else if (name.find("BModule") != std::string::npos) {
277  if (name.find("InnerPixelActive") != std::string::npos) {
278  return ModuleType::Ph2PXB;
279  } else if (name.find("InnerPixel3DActive") != std::string::npos) {
280  return ModuleType::Ph2PXB3D;
281  }
282  }
283  // forward
284  else if (name.find("EModule") != std::string::npos) {
285  if (name.find("InnerPixelActive") != std::string::npos) {
286  return ModuleType::Ph2PXF;
287  } else if (name.find("InnerPixel3DActive") != std::string::npos) {
288  return ModuleType::Ph2PXF3D;
289  }
290  }
291  }
292 
293  // TIB
294  else if (name.find("TIB") != std::string::npos) {
295  if (name.find('0') != std::string::npos)
296  return ModuleType::IB1;
297  else
298  return ModuleType::IB2;
299  }
300 
301  // TOB
302  else if (name.find("TOB") != std::string::npos) {
303  if (name.find('0') != std::string::npos)
304  return ModuleType::OB1;
305  else
306  return ModuleType::OB2;
307  }
308 
309  // TID
310  else if (name.find("TID") != std::string::npos) {
311  if (name.find('0') != std::string::npos)
312  return ModuleType::W1A;
313  else if (name.find('1') != std::string::npos)
314  return ModuleType::W2A;
315  else if (name.find('2') != std::string::npos)
316  return ModuleType::W3A;
317  }
318 
319  // TEC
320  else if (name.find("TEC") != std::string::npos) {
321  if (name.find('0') != std::string::npos)
322  return ModuleType::W1B;
323  else if (name.find('1') != std::string::npos)
324  return ModuleType::W2B;
325  else if (name.find('2') != std::string::npos)
326  return ModuleType::W3B;
327  else if (name.find('3') != std::string::npos)
328  return ModuleType::W4;
329  else if (name.find('4') != std::string::npos)
330  return ModuleType::W5;
331  else if (name.find('5') != std::string::npos)
332  return ModuleType::W6;
333  else if (name.find('6') != std::string::npos)
334  return ModuleType::W7;
335  }
336 
337  // Phase 2 OT
338  if (name.find("BModule") != std::string::npos || name.find("EModule") != std::string::npos) {
339  if (name.find("PSMacroPixel") != std::string::npos)
340  return ModuleType::Ph2PSP;
341  else if (name.find("PSStrip") != std::string::npos)
342  return ModuleType::Ph2PSS;
343  else if (name.find("2S") != std::string::npos)
344  return ModuleType::Ph2SS;
345  }
346 
347  return ModuleType::UNKNOWN;
348 }
TrackerGeometry::idToDet
const TrackerGeomDet * idToDet(DetId) const override
Definition: TrackerGeometry.cc:193
GeomDetEnumerators::SubDetector
SubDetector
Definition: GeomDetEnumerators.h:10
SectorBuilder_Tib_cff.TIB
TIB
Definition: SectorBuilder_Tib_cff.py:16
TrackerGeometry::ModuleType::Ph1PXF
TrackerGeometry::moduleType
ModuleType moduleType(const std::string &name) const
Definition: TrackerGeometry.cc:265
TrackerGeometry::ModuleType::Ph2PXF
mps_fire.i
i
Definition: mps_fire.py:428
PixelSubdetector.h
TrackerGeometry::ModuleType::W6
MessageLogger.h
TrackerGeometry::addDet
void addDet(GeomDet const *p)
Definition: TrackerGeometry.cc:139
PixelSubdetector::PixelEndcap
Definition: PixelSubdetector.h:11
TrackerGeometry.h
GeomDet
Definition: GeomDet.h:27
PixelSubdetector::PixelBarrel
Definition: PixelSubdetector.h:11
TrackerGeometry::thePXFDets
DetContainer thePXFDets
Definition: TrackerGeometry.h:110
TrackerGeometry::ModuleType::Ph2PXB3D
GeomDetEnumerators::invalidDet
Definition: GeomDetEnumerators.h:31
TrackerGeometry::ModuleType::Ph2SS
TrackerGeometry::addDetId
void addDetId(DetId p)
Definition: TrackerGeometry.cc:169
GeometricDet::components
ConstGeometricDetContainer & components()
Definition: GeometricDet.h:149
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
TrackerGeometry::theTECDets
DetContainer theTECDets
Definition: TrackerGeometry.h:114
TrackerGeometry::ModuleType::W3A
TrackerGeometry::ModuleType::Ph2PXF3D
TrackerGeomDet
Definition: TrackerGeomDet.h:6
TrackerGeometry::ModuleType::W3B
GeomDetType.h
GeomDetType
Definition: GeomDetType.h:9
SectorBuilder_Tec_cff.TEC
TEC
Definition: SectorBuilder_Tec_cff.py:16
cms::cuda::assert
assert(be >=bs)
GeomDetEnumerators::P2OTB
Definition: GeomDetEnumerators.h:23
TrackerGeometry::theNumberOfLayers
unsigned int theNumberOfLayers[6]
Definition: TrackerGeometry.h:117
TrackerGeometry::ModuleType::Ph2PXB
TrackerGeometry::theDetIds
DetIdContainer theDetIds
Definition: TrackerGeometry.h:105
TrackerGeometry::getDetectorType
ModuleType getDetectorType(DetId) const
Definition: TrackerGeometry.cc:247
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
TrackerGeometry::addType
void addType(GeomDetType const *p)
Definition: TrackerGeometry.cc:126
TrackerGeometry::TrackerGeometry
TrackerGeometry(GeometricDet const *gd=nullptr)
Definition: TrackerGeometry.cc:58
TrackerGeometry::numberOfLayers
unsigned int numberOfLayers(int subdet) const
Definition: TrackerGeometry.cc:211
TrackerGeometry::idToDetUnit
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: TrackerGeometry.cc:183
TrackerGeometry::detsPXB
const DetContainer & detsPXB() const
Definition: TrackerGeometry.cc:171
TrackerGeometry::ModuleType::W2B
DetId
Definition: DetId.h:17
GeomDetEnumerators::PixelBarrel
Definition: GeomDetEnumerators.h:11
alignCSCRings.s
s
Definition: alignCSCRings.py:92
TrackerGeometry::detsTOB
const DetContainer & detsTOB() const
Definition: TrackerGeometry.cc:179
GeometricDet::name
const std::string & name() const
Definition: GeometricDet.h:90
TrackerGeometry::ModuleType::IB2
GeomDetEnumerators::P1PXEC
Definition: GeomDetEnumerators.h:26
Calorimetry_cff.thickness
thickness
Definition: Calorimetry_cff.py:115
TrackerGeometry::ModuleType::W2A
TrackerGeometry::theTIDDets
DetContainer theTIDDets
Definition: TrackerGeometry.h:112
TrackerGeometry::ModuleType
ModuleType
Definition: TrackerGeometry.h:29
TrackerGeometry::thePXBDets
DetContainer thePXBDets
Definition: TrackerGeometry.h:109
TrackerGeometry::detsPXF
const DetContainer & detsPXF() const
Definition: TrackerGeometry.cc:173
GeometricDet
Definition: GeometricDet.h:31
TrackerGeometry::theTOBDets
DetContainer theTOBDets
Definition: TrackerGeometry.h:113
StripSubdetector::TIB
static constexpr auto TIB
Definition: StripSubdetector.h:16
TrackerGeometry::getDetectorThickness
float getDetectorThickness(DetId) const
Definition: TrackerGeometry.cc:256
GeomDetEnumerators::P2OTEC
Definition: GeomDetEnumerators.h:24
TrackerGeometry::isThere
bool isThere(GeomDetEnumerators::SubDetector subdet) const
Definition: TrackerGeometry.cc:219
TrackerGeometry::detsTID
const DetContainer & detsTID() const
Definition: TrackerGeometry.cc:177
GeometricDet::GDEnumType
GDEnumType
Definition: GeometricDet.h:48
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TrackerGeometry::theSubDetTypeMap
GeomDetEnumerators::SubDetector theSubDetTypeMap[6]
Definition: TrackerGeometry.h:116
TrackerGeometry::ModuleType::W4
GeomDetEnumerators::P1PXB
Definition: GeomDetEnumerators.h:25
GeometricDet::geographicalId
const DetId & geographicalId() const
Definition: GeometricDet.h:96
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
TrackerGeometry::geomDetSubDetector
const GeomDetEnumerators::SubDetector geomDetSubDetector(int subdet) const
Definition: TrackerGeometry.cc:203
TrackerGeometry::ModuleType::W5
TrackerGeometry::ModuleType::OB1
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
TrackingGeometry::DetContainer
std::vector< const GeomDet * > DetContainer
Definition: TrackingGeometry.h:29
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
TrackerGeometry::fillTestMap
void fillTestMap(const GeometricDet *gd)
Definition: TrackerGeometry.cc:227
TrackerGeometry::detsTIB
const DetContainer & detsTIB() const
Definition: TrackerGeometry.cc:175
TrackerGeometry::theDetTypes
DetTypeContainer theDetTypes
Definition: TrackerGeometry.h:99
TrackerGeometry::theDetUnits
DetContainer theDetUnits
Definition: TrackerGeometry.h:100
TrackerGeometry::ModuleType::Ph2PSS
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
TrackerGeometry::theTIBDets
DetContainer theTIBDets
Definition: TrackerGeometry.h:111
TrackerGeometry::ModuleType::Ph1PXB
GeometricDet::deepComponents
ConstGeometricDetContainer deepComponents() const
Definition: GeometricDet.cc:242
GeometricDet.h
TrackerGeometry::theMap
mapIdToDet theMap
Definition: TrackerGeometry.h:107
TrackerGeometry::ModuleType::W1A
GeomDet.h
TrackerGeometry::theDetTypetList
std::vector< std::tuple< DetId, TrackerGeometry::ModuleType, float > > theDetTypetList
Definition: TrackerGeometry.h:118
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
StripSubdetector::TEC
static constexpr auto TEC
Definition: StripSubdetector.h:19
GeometricDet::bounds
std::unique_ptr< Bounds > bounds() const
Definition: GeometricDet.cc:215
GeometricDet::ConstGeometricDetContainer
std::vector< GeometricDet const * > ConstGeometricDetContainer
Definition: GeometricDet.h:34
DetId.h
TrackerGeometry::detsTEC
const DetContainer & detsTEC() const
Definition: TrackerGeometry.cc:181
TrackerGeometry::theDets
DetContainer theDets
Definition: TrackerGeometry.h:103
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
TrackerGeometry::ModuleType::OB2
Exception
Definition: hltDiff.cc:245
TrackerGeometry::addDetUnitId
void addDetUnitId(DetId p)
Definition: TrackerGeometry.cc:137
SectorBuilder_Tid_cff.TID
TID
Definition: SectorBuilder_Tid_cff.py:16
TrackerGeometry::ModuleType::IB1
StripSubdetector::TOB
static constexpr auto TOB
Definition: StripSubdetector.h:18
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
Exception.h
TrackerGeometry::theDetUnitIds
DetIdContainer theDetUnitIds
Definition: TrackerGeometry.h:104
GeomDetEnumerators::PixelEndcap
Definition: GeomDetEnumerators.h:12
TrackerGeometry::ModuleType::W7
ztail.d
d
Definition: ztail.py:151
GeomDetEnumerators::P2PXB
Definition: GeomDetEnumerators.h:27
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
TrackerGeometry::ModuleType::UNKNOWN
TrackerGeometry::~TrackerGeometry
~TrackerGeometry() override
Definition: TrackerGeometry.cc:104
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
SectorBuilder_Tob_cff.TOB
TOB
Definition: SectorBuilder_Tob_cff.py:16
StripSubdetector.h
TrackerGeometry::ModuleType::W1B
StripSubdetector::TID
static constexpr auto TID
Definition: StripSubdetector.h:17
TrackerGeometry::ModuleType::Ph2PSP
TrackerGeometry::finalize
void finalize()
Definition: TrackerGeometry.cc:111
GeomDetEnumerators::P2PXEC
Definition: GeomDetEnumerators.h:28
TrackerGeometry::addDetUnit
void addDetUnit(GeomDet const *p)
Definition: TrackerGeometry.cc:130
TrackerGeometry::theMapUnit
mapIdToDetUnit theMapUnit
Definition: TrackerGeometry.h:106