CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DDParsingContext.h
Go to the documentation of this file.
1 #ifndef DETECTOR_DESCRIPTION_DD_PARSING_CONTEXT_H
2 #define DETECTOR_DESCRIPTION_DD_PARSING_CONTEXT_H
3 
4 #include "DD4hep/Detector.h"
5 
6 #include <string>
7 #include <variant>
8 #include <unordered_map>
9 #include <unordered_set>
10 #include <vector>
11 
12 namespace cms {
13 
15  public:
16  DDParsingContext(dd4hep::Detector& det, bool makePayloadArg = false)
17  : makePayload(makePayloadArg), description(det) {
18  assemblies.reserve(100);
19  assemblySolids.reserve(100);
20  rotations.reserve(3000);
21  shapes.reserve(4000);
22  volumes.reserve(3000);
23  unresolvedMaterials.reserve(300);
24  unresolvedVectors.reserve(300);
25  unresolvedShapes.reserve(1000);
26 
27  namespaces.emplace_back("");
28  if (makePayload) {
29  rotRevMap.reserve(3000);
30  compMaterialsVec.reserve(400);
31  compMaterialsRefs.reserve(400);
32  }
33  }
34 
35  DDParsingContext() = delete;
36  DDParsingContext(const DDParsingContext&) = delete;
38 
39  ~DDParsingContext() = default;
40 
41  const std::string& ns() const { return namespaces.back(); }
42 
43  template <class TYPE>
44  struct BooleanShape {
45  BooleanShape(const std::string& aName, const std::string& bName, dd4hep::Transform3D t)
46  : firstSolidName(aName), secondSolidName(bName), transform(t) {}
47 
50  dd4hep::Transform3D transform;
51 
52  dd4hep::Solid make(dd4hep::Solid firstSolid, dd4hep::Solid secondSolid) {
53  return TYPE(firstSolid, secondSolid, transform);
54  }
55  };
56 
58  CompositeMaterial(const std::string& n, double f) : name(n), fraction(f) {}
59 
61  double fraction;
62  };
63 
64  // Debug flags
65  bool debug_includes = false;
66  bool debug_constants = false;
67  bool debug_materials = false;
68  bool debug_rotations = false;
69  bool debug_shapes = false;
70  bool debug_volumes = false;
71  bool debug_placements = false;
72  bool debug_namespaces = false;
73  bool debug_algorithms = false;
74  bool debug_specpars = false;
75  bool makePayload = false;
76 
78 
79  std::unordered_map<std::string, dd4hep::Assembly> assemblies;
80  std::unordered_set<std::string> assemblySolids;
81  std::unordered_map<std::string, dd4hep::Rotation3D> rotations;
82  std::unordered_map<std::string, std::string> rotRevMap;
83  std::unordered_map<std::string, dd4hep::Solid> shapes;
84  std::unordered_map<std::string, dd4hep::Volume> volumes;
85  std::vector<std::string> namespaces;
86 
87  std::unordered_map<std::string, std::vector<CompositeMaterial>> unresolvedMaterials;
88  std::vector<std::pair<std::string, double>> compMaterialsVec;
89  std::unordered_map<std::string, std::vector<CompositeMaterial>> compMaterialsRefs;
90  std::unordered_map<std::string, std::vector<std::string>> unresolvedVectors;
91  std::unordered_map<std::string,
92  std::variant<BooleanShape<dd4hep::UnionSolid>,
96  };
97 } // namespace cms
98 
99 #endif
const std::string & ns() const
std::vector< std::pair< std::string, double > > compMaterialsVec
std::unordered_map< std::string, dd4hep::Volume > volumes
dd4hep::Solid make(dd4hep::Solid firstSolid, dd4hep::Solid secondSolid)
list TYPE
Definition: runonSM.py:21
std::unordered_map< std::string, std::variant< BooleanShape< dd4hep::UnionSolid >, BooleanShape< dd4hep::SubtractionSolid >, BooleanShape< dd4hep::IntersectionSolid > > > unresolvedShapes
BooleanShape(const std::string &aName, const std::string &bName, dd4hep::Transform3D t)
DDParsingContext(dd4hep::Detector &det, bool makePayloadArg=false)
std::unordered_map< std::string, std::vector< std::string > > unresolvedVectors
~DDParsingContext()=default
std::unordered_map< std::string, dd4hep::Rotation3D > rotations
std::unordered_map< std::string, std::string > rotRevMap
std::unordered_map< std::string, dd4hep::Solid > shapes
CompositeMaterial(const std::string &n, double f)
std::vector< std::string > namespaces
std::unordered_map< std::string, dd4hep::Assembly > assemblies
std::unordered_map< std::string, std::vector< CompositeMaterial > > compMaterialsRefs
DDParsingContext & operator=(const DDParsingContext &)=delete
dd4hep::Detector & description
std::unordered_map< std::string, std::vector< CompositeMaterial > > unresolvedMaterials
std::unordered_set< std::string > assemblySolids