test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GlobalTrackingGeometry.cc
Go to the documentation of this file.
1 
8 #include <memory>
9 
10 GlobalTrackingGeometry::GlobalTrackingGeometry(std::vector<const TrackingGeometry*>& geos)
11  : theGeometries(geos),
12  theDetTypes(nullptr), theDetUnits(nullptr), theDets(nullptr), theDetUnitIds(nullptr), theDetIds(nullptr)
13 {}
14 
16 {
17  delete theDetTypes.load();
18  theDetTypes = nullptr;
19  delete theDetUnits.load();
20  theDetUnits = nullptr;
21  delete theDets.load();
22  theDets = nullptr;
23  delete theDetUnitIds.load();
24  theDetUnitIds = nullptr;
25  delete theDetIds.load();
26  theDetIds = nullptr;
27 }
28 
30 
31  const TrackingGeometry* tg = slaveGeometry(id);
32 
33  if (tg != 0) {
34  return tg->idToDetUnit(id);
35  } else {
36  return 0;
37  }
38 }
39 
40 
42 
43  const TrackingGeometry* tg = slaveGeometry(id);
44 
45  if (tg != 0) {
46  return tg->idToDet(id);
47  } else {
48  return 0;
49  }
50 }
51 
53 
54  int idx = id.det()-1;
55  if (id.det() == DetId::Muon) {
56 
57  idx+=id.subdetId()-1;
58  }
59 
60  if (theGeometries[idx]==0) throw cms::Exception("NoGeometry") << "No Tracking Geometry is available for DetId " << id.rawId() << std::endl;
61 
62  return theGeometries[idx];
63 }
64 
67 {
68  if (!theDetTypes.load(std::memory_order_acquire)) {
69  std::unique_ptr<DetTypeContainer> ptr{new DetTypeContainer()};
70  for( auto geom = theGeometries.cbegin(), geomEnd = theGeometries.cend(); geom != geomEnd; ++geom )
71  {
72  if( *geom == 0 ) continue;
73  DetTypeContainer detTypes(( *geom )->detTypes());
74  if( detTypes.size() + ptr->size() < ptr->capacity()) ptr->resize( detTypes.size() + ptr->size());
75  for( auto detType = detTypes.cbegin(), detTypeEnd = detTypes.cend(); detType != detTypeEnd; ++detType )
76  ptr->push_back( *detType );
77  }
78  DetTypeContainer* expect = nullptr;
79  if(theDetTypes.compare_exchange_strong(expect, ptr.get(), std::memory_order_acq_rel)) {
80  ptr.release();
81  }
82  }
83  return *theDetTypes.load(std::memory_order_acquire);
84 }
85 
88 {
89  if (!theDetUnits.load(std::memory_order_acquire)) {
90  std::unique_ptr<DetUnitContainer> ptr{new DetUnitContainer()};
91  for( auto geom = theGeometries.cbegin(), geomEnd = theGeometries.cend(); geom != geomEnd; ++geom )
92  {
93  if( *geom == 0 ) continue;
94  DetUnitContainer detUnits(( *geom )->detUnits());
95  if( detUnits.size() + ptr->size() < ptr->capacity()) ptr->resize( detUnits.size() + ptr->size());
96  for( auto detUnit = detUnits.cbegin(), detUnitEnd = detUnits.cend(); detUnit != detUnitEnd; ++detUnit )
97  ptr->push_back( *detUnit );
98  }
99  DetUnitContainer* expect = nullptr;
100  if(theDetUnits.compare_exchange_strong(expect, ptr.get(), std::memory_order_acq_rel)) {
101  ptr.release();
102  }
103  }
104  return *theDetUnits.load(std::memory_order_acquire);
105 }
106 
109 {
110  if (!theDets.load(std::memory_order_acquire)) {
111  std::unique_ptr<DetContainer> ptr{new DetContainer()};
112  for( auto geom = theGeometries.cbegin(), geomEnd = theGeometries.cend(); geom != geomEnd; ++geom )
113  {
114  if( *geom == 0 ) continue;
115  DetContainer dets(( *geom )->dets());
116  if( dets.size() + ptr->size() < ptr->capacity()) ptr->resize( dets.size() + ptr->size());
117  for( auto det = dets.cbegin(), detEnd = dets.cend(); det != detEnd; ++det )
118  ptr->push_back( *det );
119  }
120  DetContainer* expect = nullptr;
121  if(theDets.compare_exchange_strong(expect, ptr.get(), std::memory_order_acq_rel)) {
122  ptr.release();
123  }
124  }
125  return *theDets.load(std::memory_order_acquire);
126 }
127 
130 {
131  if (!theDetUnitIds.load(std::memory_order_acquire)) {
132  std::unique_ptr<DetIdContainer> ptr{new DetIdContainer()};
133  for( auto geom = theGeometries.cbegin(), geomEnd = theGeometries.cend(); geom != geomEnd; ++geom )
134  {
135  if( *geom == 0 ) continue;
136  DetIdContainer detUnitIds(( *geom )->detUnitIds());
137  if( detUnitIds.size() + ptr->size() < ptr->capacity()) ptr->resize( detUnitIds.size() + ptr->size());
138  for( auto detUnitId = detUnitIds.cbegin(), detUnitIdEnd = detUnitIds.cend(); detUnitId != detUnitIdEnd; ++detUnitId )
139  ptr->push_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 
151 {
152  if (!theDetIds.load(std::memory_order_acquire)) {
153  std::unique_ptr<DetIdContainer> ptr{new DetIdContainer()};
154  for( auto geom = theGeometries.cbegin(), geomEnd = theGeometries.cend(); geom != geomEnd; ++geom )
155  {
156  if( *geom == 0 ) continue;
157  DetIdContainer detIds(( *geom )->detIds());
158  if( detIds.size() + ptr->size() < ptr->capacity()) ptr->resize( detIds.size() + ptr->size());
159  for( auto detId = detIds.cbegin(), detIdEnd = detIds.cend(); detId != detIdEnd; ++detId )
160  ptr->push_back( *detId );
161  }
162  DetIdContainer* expect = nullptr;
163  if(theDetIds.compare_exchange_strong(expect, ptr.get(), std::memory_order_acq_rel)) {
164  ptr.release();
165  }
166  }
167  return *theDetIds.load(std::memory_order_acquire);
168 }
std::vector< GeomDetType const * > DetTypeContainer
std::vector< const TrackingGeometry * > theGeometries
std::atomic< DetIdContainer * > theDetUnitIds
#define nullptr
std::atomic< DetContainer * > theDets
virtual const GeomDet * idToDet(DetId) const
virtual const GeomDetUnit * idToDetUnit(DetId) const =0
Return the pointer to the GeomDetUnit corresponding to a given DetId.
virtual const GeomDetUnit * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
std::atomic< DetUnitContainer * > theDetUnits
std::atomic< DetIdContainer * > theDetIds
std::atomic< DetTypeContainer * > theDetTypes
const TrackingGeometry * slaveGeometry(DetId id) const
Return the pointer to the actual geometry for a given DetId.
virtual ~GlobalTrackingGeometry()
Destructor.
virtual const DetUnitContainer & detUnits() const
Returm a vector of all GeomDetUnit.
virtual const DetIdContainer & detIds() const
Returm a vector of all GeomDet DetIds (including those of GeomDetUnits)
virtual const DetContainer & dets() const
Returm a vector of all GeomDet (including all GeomDetUnits)
Definition: DetId.h:18
GlobalTrackingGeometry(std::vector< const TrackingGeometry * > &geos)
Constructor.
virtual const GeomDet * idToDet(DetId) const =0
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
virtual const DetTypeContainer & detTypes() const
Return a vector of all det types.
std::vector< GeomDet const * > DetContainer
std::vector< GeomDetUnit const * > DetUnitContainer
virtual const DetIdContainer & detUnitIds() const
Returm a vector of all GeomDetUnit DetIds.
std::vector< DetId > DetIdContainer