CMS 3D CMS Logo

GlobalTrackingGeometry.cc
Go to the documentation of this file.
1 
8 
10 
11 #include <memory>
12 
13 GlobalTrackingGeometry::GlobalTrackingGeometry(std::vector<const TrackingGeometry*>& geos)
14  : theGeometries(geos),
15  theDetTypes(nullptr),
16  theDetUnits(nullptr),
17  theDets(nullptr),
18  theDetUnitIds(nullptr),
19  theDetIds(nullptr) {}
20 
22  delete theDetTypes.load();
23  theDetTypes = nullptr;
24  delete theDetUnits.load();
25  theDetUnits = nullptr;
26  delete theDets.load();
27  theDets = nullptr;
28  delete theDetUnitIds.load();
29  theDetUnitIds = nullptr;
30  delete theDetIds.load();
31  theDetIds = nullptr;
32 }
33 
35  const TrackingGeometry* tg = slaveGeometry(id);
36 
37  if (tg != nullptr) {
38  return tg->idToDetUnit(id);
39  } else {
40  return nullptr;
41  }
42 }
43 
45  const TrackingGeometry* tg = slaveGeometry(id);
46 
47  if (tg != nullptr) {
48  return tg->idToDet(id);
49  } else {
50  return nullptr;
51  }
52 }
53 
55  int idx = id.det() - 1;
56  if (id.det() == DetId::Muon) {
57  idx += id.subdetId(); //-1; // remove the -1 from before since MTD is there
58  }
59  if (id.det() == DetId::Forward && id.subdetId() == ForwardSubdetector::FastTime) {
60  idx = 1;
61  }
62 
63  if (theGeometries[idx] == nullptr)
64  throw cms::Exception("NoGeometry") << "No Tracking Geometry is available for DetId " << id.rawId() << std::endl;
65 
66  return theGeometries[idx];
67 }
68 
70  if (!theDetTypes.load(std::memory_order_acquire)) {
71  std::unique_ptr<DetTypeContainer> ptr{new DetTypeContainer()};
72  for (auto theGeometrie : theGeometries) {
73  if (theGeometrie == nullptr)
74  continue;
75  DetTypeContainer detTypes(theGeometrie->detTypes());
76  if (detTypes.size() + ptr->size() < ptr->capacity())
77  ptr->resize(detTypes.size() + ptr->size());
78  for (auto detType : detTypes)
79  ptr->emplace_back(detType);
80  }
81  DetTypeContainer* expect = nullptr;
82  if (theDetTypes.compare_exchange_strong(expect, ptr.get(), std::memory_order_acq_rel)) {
83  ptr.release();
84  }
85  }
86  return *theDetTypes.load(std::memory_order_acquire);
87 }
88 
90  if (!theDetUnits.load(std::memory_order_acquire)) {
91  std::unique_ptr<DetContainer> ptr{new DetContainer()};
92  for (auto theGeometrie : theGeometries) {
93  if (theGeometrie == nullptr)
94  continue;
95  DetContainer detUnits(theGeometrie->detUnits());
96  if (detUnits.size() + ptr->size() < ptr->capacity())
97  ptr->resize(detUnits.size() + ptr->size());
98  for (auto detUnit : detUnits)
99  ptr->emplace_back(detUnit);
100  }
101  DetContainer* expect = nullptr;
102  if (theDetUnits.compare_exchange_strong(expect, ptr.get(), std::memory_order_acq_rel)) {
103  ptr.release();
104  }
105  }
106  return *theDetUnits.load(std::memory_order_acquire);
107 }
108 
110  if (!theDets.load(std::memory_order_acquire)) {
111  std::unique_ptr<DetContainer> ptr{new DetContainer()};
112  for (auto theGeometrie : theGeometries) {
113  if (theGeometrie == nullptr)
114  continue;
115  DetContainer dets(theGeometrie->dets());
116  if (dets.size() + ptr->size() < ptr->capacity())
117  ptr->resize(dets.size() + ptr->size());
118  for (auto det : dets)
119  ptr->emplace_back(det);
120  }
121  DetContainer* expect = nullptr;
122  if (theDets.compare_exchange_strong(expect, ptr.get(), std::memory_order_acq_rel)) {
123  ptr.release();
124  }
125  }
126  return *theDets.load(std::memory_order_acquire);
127 }
128 
130  if (!theDetUnitIds.load(std::memory_order_acquire)) {
131  std::unique_ptr<DetIdContainer> ptr{new DetIdContainer()};
132  for (auto theGeometrie : theGeometries) {
133  if (theGeometrie == nullptr)
134  continue;
135  DetIdContainer detUnitIds(theGeometrie->detUnitIds());
136  if (detUnitIds.size() + ptr->size() < ptr->capacity())
137  ptr->resize(detUnitIds.size() + ptr->size());
138  for (auto detUnitId : detUnitIds)
139  ptr->emplace_back(detUnitId);
140  }
141  DetIdContainer* expect = nullptr;
142  if (theDetUnitIds.compare_exchange_strong(expect, ptr.get(), std::memory_order_acq_rel)) {
143  ptr.release();
144  }
145  }
146  return *theDetUnitIds.load(std::memory_order_acquire);
147 }
148 
150  if (!theDetIds.load(std::memory_order_acquire)) {
151  std::unique_ptr<DetIdContainer> ptr{new DetIdContainer()};
152  for (auto theGeometrie : theGeometries) {
153  if (theGeometrie == nullptr)
154  continue;
155  DetIdContainer detIds(theGeometrie->detIds());
156  if (detIds.size() + ptr->size() < ptr->capacity())
157  ptr->resize(detIds.size() + ptr->size());
158  for (auto detId : detIds)
159  ptr->emplace_back(detId);
160  }
161  DetIdContainer* expect = nullptr;
162  if (theDetIds.compare_exchange_strong(expect, ptr.get(), std::memory_order_acq_rel)) {
163  ptr.release();
164  }
165  }
166  return *theDetIds.load(std::memory_order_acquire);
167 }
GlobalTrackingGeometry::theDetUnitIds
std::atomic< DetIdContainer * > theDetUnitIds
Definition: GlobalTrackingGeometry.h:60
GlobalTrackingGeometry::detIds
const DetIdContainer & detIds() const override
Returm a vector of all GeomDet DetIds (including those of GeomDetUnits)
Definition: GlobalTrackingGeometry.cc:149
TrackingGeometry
Definition: TrackingGeometry.h:26
GeomDet
Definition: GeomDet.h:27
GlobalTrackingGeometry::theGeometries
std::vector< const TrackingGeometry * > theGeometries
Definition: GlobalTrackingGeometry.h:52
GlobalTrackingGeometry::dets
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
Definition: GlobalTrackingGeometry.cc:109
GlobalTrackingGeometry::theDetIds
std::atomic< DetIdContainer * > theDetIds
Definition: GlobalTrackingGeometry.h:61
ForwardSubdetector.h
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
GlobalTrackingGeometry::theDets
std::atomic< DetContainer * > theDets
Definition: GlobalTrackingGeometry.h:59
GlobalTrackingGeometry::theDetTypes
std::atomic< DetTypeContainer * > theDetTypes
Definition: GlobalTrackingGeometry.h:57
DetId
Definition: DetId.h:17
TrackingGeometry::idToDet
virtual const GeomDet * idToDet(DetId) const =0
GlobalTrackingGeometry::detUnitIds
const DetIdContainer & detUnitIds() const override
Returm a vector of all GeomDetUnit DetIds.
Definition: GlobalTrackingGeometry.cc:129
TrackingGeometry::DetTypeContainer
std::vector< const GeomDetType * > DetTypeContainer
Definition: TrackingGeometry.h:28
TrackingGeometry::DetIdContainer
std::vector< DetId > DetIdContainer
Definition: TrackingGeometry.h:30
TrackingGeometry::DetContainer
std::vector< const GeomDet * > DetContainer
Definition: TrackingGeometry.h:29
FastTime
Definition: ForwardSubdetector.h:6
GlobalTrackingGeometry::detUnits
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
Definition: GlobalTrackingGeometry.cc:89
GlobalTrackingGeometry::theDetUnits
std::atomic< DetContainer * > theDetUnits
Definition: GlobalTrackingGeometry.h:58
GlobalTrackingGeometry::slaveGeometry
const TrackingGeometry * slaveGeometry(DetId id) const
Return the pointer to the actual geometry for a given DetId.
Definition: GlobalTrackingGeometry.cc:54
GlobalTrackingGeometry::GlobalTrackingGeometry
GlobalTrackingGeometry(std::vector< const TrackingGeometry * > &geos)
Definition: GlobalTrackingGeometry.cc:13
GlobalTrackingGeometry::~GlobalTrackingGeometry
~GlobalTrackingGeometry() override
Definition: GlobalTrackingGeometry.cc:21
GlobalTrackingGeometry.h
GlobalTrackingGeometry::idToDetUnit
const GeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: GlobalTrackingGeometry.cc:34
GlobalTrackingGeometry::detTypes
const DetTypeContainer & detTypes() const override
Return a vector of all det types.
Definition: GlobalTrackingGeometry.cc:69
Exception
Definition: hltDiff.cc:245
GlobalTrackingGeometry::idToDet
const GeomDet * idToDet(DetId) const override
Definition: GlobalTrackingGeometry.cc:44
TrackingGeometry::idToDetUnit
virtual const GeomDet * idToDetUnit(DetId) const =0
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Exception.h
DetId::Muon
Definition: DetId.h:26
DetId::Forward
Definition: DetId.h:30