CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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  }; // namespace dd
61 
62  enum class DDSolidShape {
63  dd_not_init = 0,
64  ddbox = 1,
65  ddtubs = 2,
66  ddtrap = 3,
67  ddcons = 4,
68  ddpolycone = 5,
69  ddpolyhedra = 6,
70  ddtorus = 7,
71  ddunion = 8,
72  ddsubtraction = 9,
73  ddintersection = 10,
74  ddshapeless = 11,
75  ddpseudotrap = 12,
76  ddtrunctubs = 13,
77  ddsphere = 14,
78  ddellipticaltube = 15,
79  ddcuttubs = 16,
80  ddextrudedpolygon = 17,
81  ddtrd1 = 18,
82  };
83 
84  const std::array<const cms::dd::NameValuePair<DDSolidShape>, 19> DDSolidShapeMap{
85  {{DDSolidShape::dd_not_init, "Solid not initialized"},
86  {DDSolidShape::ddbox, "Box"},
87  {DDSolidShape::ddtubs, "Tube"},
88  {DDSolidShape::ddtrap, "Trap"},
89  {DDSolidShape::ddcons, "ConeSegment"},
90  {DDSolidShape::ddpolycone, "Polycone"},
91  {DDSolidShape::ddpolyhedra, "Polyhedra"},
92  {DDSolidShape::ddtorus, "Torus"},
93  {DDSolidShape::ddunion, "Union"},
94  {DDSolidShape::ddsubtraction, "Subtraction"},
95  {DDSolidShape::ddintersection, "Intersection"},
96  {DDSolidShape::ddshapeless, "ShapelessSolid"},
97  {DDSolidShape::ddpseudotrap, "PseudoTrap"},
98  {DDSolidShape::ddtrunctubs, "TruncatedTube"},
99  {DDSolidShape::ddsphere, "Sphere"},
100  {DDSolidShape::ddellipticaltube, "EllipticalTube"},
101  {DDSolidShape::ddcuttubs, "CutTube"},
102  {DDSolidShape::ddextrudedpolygon, "ExtrudedPolygon"},
103  {DDSolidShape::ddtrd1, "Trd1"}}};
104 
105  const std::array<const cms::dd::ValuePair<LegacySolidShape, cms::DDSolidShape>, 20> LegacySolidShapeMap{
111  {LegacySolidShape::ddpolycone_rz, cms::DDSolidShape::ddpolycone},
112  {LegacySolidShape::ddpolycone_rrz, cms::DDSolidShape::ddpolycone},
113  {LegacySolidShape::ddpolyhedra_rz, cms::DDSolidShape::ddpolyhedra},
114  {LegacySolidShape::ddpolyhedra_rrz, cms::DDSolidShape::ddpolyhedra},
126 
127 } // namespace cms
128 
129 #endif
DDSolidShapes.h
cms::DDSolidShape::ddellipticaltube
cms::dd::NameValuePair::value_type
T value_type
Definition: DDSolidShapes.h:17
cms::cuda::V
cudaStream_t T uint32_t const T *__restrict__ const uint32_t *__restrict__ uint32_t int cudaStream_t V
Definition: HistoContainer.h:99
DDSolidShape
DDSolidShape
Definition: DDSolidShapes.h:6
cms::DDSolidShape::ddtubs
cms::dd::NameValuePair::name
const char *const name
Definition: DDSolidShapes.h:19
cms::LegacySolidShapeMap
const std::array< const cms::dd::ValuePair< LegacySolidShape, cms::DDSolidShape >, 20 > LegacySolidShapeMap
Definition: DDSolidShapes.h:105
pos
Definition: PixelAliasList.h:18
cms::DDSolidShape::ddtorus
cms::dd::ValuePair
Definition: DDSolidShapes.h:23
cms::DDSolidShape::ddcuttubs
cms::DDSolidShape::ddcons
end
#define end
Definition: vmac.h:39
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
N
#define N
Definition: blowfish.cc:9
cms::DDSolidShape::ddpolyhedra
cms::DDSolidShape::ddsphere
cms::dd::ValuePair::value
const T value
Definition: DDSolidShapes.h:26
OrderedSet.t
t
Definition: OrderedSet.py:90
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
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::DDSolidShape
DDSolidShape
Definition: DDSolidShapes.h:62
cms::dd::ValuePair::name
const U name
Definition: DDSolidShapes.h:27
a
double a
Definition: hdecay.h:119
cms::DDSolidShapeMap
const std::array< const cms::dd::NameValuePair< DDSolidShape >, 19 > DDSolidShapeMap
Definition: DDSolidShapes.h:84
cms::DDSolidShape::ddpolycone
cms::DDSolidShape::ddtrap
cms::DDSolidShape::ddbox
value
Definition: value.py:1
cms::dd::ValuePair::value_type
T value_type
Definition: DDSolidShapes.h:24
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
cms::DDSolidShape::ddextrudedpolygon
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::ddsubtraction
cms::DDSolidShape::dd_not_init
cms::DDSolidShape::ddshapeless
cms::dd::NameValuePair
Definition: DDSolidShapes.h:16
begin
#define begin
Definition: vmac.h:32
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21