CMS 3D CMS Logo

DDSolidShapes.h
Go to the documentation of this file.
1 #ifndef DETECTOR_DESCRIPTION_DDCMS_DD_SOLID_SHAPES_H
2 #define DETECTOR_DESCRIPTION_DDCMS_DD_SOLID_SHAPES_H
3 
4 #include <algorithm>
5 #include <array>
6 #include <iterator>
7 #include <string>
8 
10 
12 
13 namespace cms {
14  namespace dd {
15  template <class T>
16  struct NameValuePair {
17  using value_type = T;
18  const T value;
19  const char* const name;
20  };
21 
22  template <class T, class U>
23  struct ValuePair {
24  using value_type = T;
25  using name_type = U;
26  const T value;
27  const U name;
28  };
29 
30  template <class Mapping, class V>
31  std::string name(Mapping a, V value) {
32  auto pos = std::find_if(
33  std::begin(a), std::end(a), [&value](const typename Mapping::value_type& t) { return (t.value == value); });
34  if (pos != std::end(a)) {
35  return pos->name;
36  }
37 
38  return std::begin(a)->name;
39  }
40 
41  template <class Mapping>
43  auto pos = std::find_if(
44  std::begin(a), std::end(a), [&name](const typename Mapping::value_type& t) { return (t.name == name); });
45  if (pos != std::end(a)) {
46  return pos->value;
47  }
48  return std::begin(a)->value;
49  }
50 
51  template <class Mapping, class N>
53  auto pos = std::find_if(
54  std::begin(a), std::end(a), [&name](const typename Mapping::value_type& t) { return (t.name == name); });
55  if (pos != std::end(a)) {
56  return pos->value;
57  }
58  return std::begin(a)->value;
59  }
60 
61  template <class Mapping, class V>
62  typename Mapping::value_type::name_type name_from_value(Mapping a, V value) {
63  auto pos = std::find_if(
64  std::begin(a), std::end(a), [&value](const typename Mapping::value_type& t) { return (t.value == value); });
65  if (pos != std::end(a)) {
66  return pos->name;
67  }
68  return std::begin(a)->name;
69  }
70 
71  }; // namespace dd
72 
73  enum class DDSolidShape {
74  dd_not_init = 0,
75  ddbox = 1,
76  ddtubs = 2,
77  ddtrap = 3,
78  ddcons = 4,
79  ddpolycone = 5,
80  ddpolyhedra = 6,
81  ddunsupported1 = 7,
82  ddunsupported2 = 8,
83  ddtorus = 9,
84  ddunion = 10,
85  ddsubtraction = 11,
86  ddintersection = 12,
87  ddshapeless = 13,
88  ddpseudotrap = 14,
89  ddtrunctubs = 15,
90  ddsphere = 16,
91  ddellipticaltube = 17,
92  ddcuttubs = 18,
93  ddextrudedpolygon = 19,
94  ddtrd1 = 20,
95  ddtrd2 = 21,
96  ddassembly = 22
97  };
98 
99  const std::array<const cms::dd::NameValuePair<DDSolidShape>, 21> DDSolidShapeMap{
100  {{DDSolidShape::dd_not_init, "Solid not initialized"},
101  {DDSolidShape::ddbox, "Box"},
102  {DDSolidShape::ddtubs, "Tube"},
103  {DDSolidShape::ddtrap, "Trap"},
104  {DDSolidShape::ddcons, "ConeSegment"},
105  {DDSolidShape::ddpolycone, "Polycone"},
106  {DDSolidShape::ddpolyhedra, "Polyhedra"},
107  {DDSolidShape::ddtorus, "Torus"},
108  {DDSolidShape::ddunion, "Union"},
109  {DDSolidShape::ddsubtraction, "Subtraction"},
110  {DDSolidShape::ddintersection, "Intersection"},
111  {DDSolidShape::ddshapeless, "ShapelessSolid"},
112  {DDSolidShape::ddpseudotrap, "PseudoTrap"},
113  {DDSolidShape::ddtrunctubs, "TruncatedTube"},
114  {DDSolidShape::ddsphere, "Sphere"},
115  {DDSolidShape::ddellipticaltube, "EllipticalTube"},
116  {DDSolidShape::ddcuttubs, "CutTube"},
117  {DDSolidShape::ddextrudedpolygon, "ExtrudedPolygon"},
118  {DDSolidShape::ddtrd1, "Trd1"},
119  {DDSolidShape::ddtrd2, "Trd2"},
120  {DDSolidShape::ddassembly, "Assembly"}}};
121 
122  const std::array<const cms::dd::ValuePair<LegacySolidShape, cms::DDSolidShape>, 21> LegacySolidShapeMap{
128  {LegacySolidShape::ddpolycone_rz, cms::DDSolidShape::ddpolycone},
129  {LegacySolidShape::ddpolycone_rrz, cms::DDSolidShape::ddpolycone},
130  {LegacySolidShape::ddpolyhedra_rz, cms::DDSolidShape::ddpolyhedra},
131  {LegacySolidShape::ddpolyhedra_rrz, cms::DDSolidShape::ddpolyhedra},
144 
145 } // namespace cms
146 
147 #endif
DDSolidShapes.h
cms::DDSolidShape::ddellipticaltube
cms::dd::NameValuePair::value_type
T value_type
Definition: DDSolidShapes.h:17
DDSolidShape
DDSolidShape
Definition: DDSolidShapes.h:6
cms::DDSolidShape::ddtubs
cms::dd::NameValuePair::name
const char *const name
Definition: DDSolidShapes.h:19
pos
Definition: PixelAliasList.h:18
cms::DDSolidShape::ddtorus
cms::dd::ValuePair
Definition: DDSolidShapes.h:23
cms::DDSolidShape::ddcuttubs
cms::DDSolidShape::ddcons
cms::dd::name_from_value
Mapping::value_type::name_type name_from_value(Mapping a, V value)
Definition: DDSolidShapes.h:62
cms::DDSolidShape::ddunsupported1
cms::DDSolidShape::ddtrunctubs
cms::dd::NameValuePair::value
const T value
Definition: DDSolidShapes.h:18
cms::dd::name
std::string name(Mapping a, V value)
Definition: DDSolidShapes.h:31
cms::DDSolidShape::ddpseudotrap
cms::DDSolidShape::ddunion
cms::DDSolidShape::ddtrd1
mps_fire.end
end
Definition: mps_fire.py:242
N
#define N
Definition: blowfish.cc:9
cms::DDSolidShape::ddpolyhedra
cms::DDSolidShape::ddsphere
cms::dd::ValuePair::value
const T value
Definition: DDSolidShapes.h:26
createTree.dd
string dd
Definition: createTree.py:154
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
cms::dd::value
Mapping::value_type::value_type value(Mapping a, const std::string &name)
Definition: DDSolidShapes.h:42
cms::DDSolidShape
DDSolidShape
Definition: DDSolidShapes.h:73
cms::dd::ValuePair::name
const U name
Definition: DDSolidShapes.h:27
a
double a
Definition: hdecay.h:119
cms::DDSolidShape::ddpolycone
cms::cuda::V
uint32_t const T *__restrict__ const uint32_t *__restrict__ int32_t int Histo::index_type cudaStream_t V
Definition: HistoContainer.h:51
cms::DDSolidShape::ddtrap
cms::DDSolidShape::ddbox
cms::DDSolidShape::ddunsupported2
value
Definition: value.py:1
cms::dd::ValuePair::value_type
T value_type
Definition: DDSolidShapes.h:24
cms::DDSolidShape::ddassembly
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
cms::DDSolidShape::ddextrudedpolygon
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::dd::ValuePair::name_type
U name_type
Definition: DDSolidShapes.h:25
cms::DDSolidShape::ddintersection
T
long double T
Definition: Basic3DVectorLD.h:48
cms::DDSolidShape::ddtrd2
cms::DDSolidShape::ddsubtraction
cms::DDSolidShape::dd_not_init
cms::LegacySolidShapeMap
const std::array< const cms::dd::ValuePair< LegacySolidShape, cms::DDSolidShape >, 21 > LegacySolidShapeMap
Definition: DDSolidShapes.h:122
cms::DDSolidShape::ddshapeless
cms::dd::NameValuePair
Definition: DDSolidShapes.h:16
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
cms::DDSolidShapeMap
const std::array< const cms::dd::NameValuePair< DDSolidShape >, 21 > DDSolidShapeMap
Definition: DDSolidShapes.h:99
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21