CMS 3D CMS Logo

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, bool validateArg = false)
17  : makePayload(makePayloadArg), validate(validateArg), description(det) {
18  assemblies.reserve(100);
19  assemblySolids.reserve(100);
20  rotations.reserve(3000);
21  shapes.reserve(4000);
22  volumes.reserve(3000);
23  unresolvedVectors.reserve(300);
24  unresolvedShapes.reserve(1000);
25 
26  namespaces.emplace_back("");
27  if (makePayload) {
28  rotRevMap.reserve(3000);
29  compMaterialsVec.reserve(400);
30  compMaterialsRefs.reserve(400);
31  }
32  }
33 
34  DDParsingContext() = delete;
35  DDParsingContext(const DDParsingContext&) = delete;
37 
38  ~DDParsingContext() = default;
39 
40  const std::string& ns() const { return namespaces.back(); }
41 
42  template <class TYPE>
43  struct BooleanShape {
44  BooleanShape(const std::string& aName, const std::string& bName, dd4hep::Transform3D t)
45  : firstSolidName(aName), secondSolidName(bName), transform(t) {}
46 
49  dd4hep::Transform3D transform;
50 
51  dd4hep::Solid make(dd4hep::Solid firstSolid, dd4hep::Solid secondSolid) {
52  return TYPE(firstSolid, secondSolid, transform);
53  }
54  };
55 
57  CompositeMaterial(const std::string& n, double f) : name(n), fraction(f) {}
58 
60  double fraction;
61  };
62 
63  // Debug flags
64  bool debug_includes = false;
65  bool debug_constants = false;
66  bool debug_materials = false;
67  bool debug_rotations = false;
68  bool debug_shapes = false;
69  bool debug_volumes = false;
70  bool debug_placements = false;
71  bool debug_namespaces = false;
72  bool debug_algorithms = false;
73  bool debug_specpars = false;
74  bool makePayload = false;
75  bool validate = 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::vector<std::pair<std::string, double>> compMaterialsVec;
88  std::unordered_map<std::string, std::vector<CompositeMaterial>> compMaterialsRefs;
89  std::unordered_map<std::string, std::vector<std::string>> unresolvedVectors;
90  std::unordered_map<std::string,
91  std::variant<BooleanShape<dd4hep::UnionSolid>,
95  };
96 } // namespace cms
97 
98 #endif
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)
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)
std::unordered_map< std::string, std::vector< std::string > > unresolvedVectors
~DDParsingContext()=default
const std::string & ns() const
std::unordered_map< std::string, dd4hep::Rotation3D > rotations
std::unordered_map< std::string, std::string > rotRevMap
DDParsingContext(dd4hep::Detector &det, bool makePayloadArg=false, bool validateArg=false)
double f[11][100]
std::unordered_map< std::string, dd4hep::Solid > shapes
CompositeMaterial(const std::string &n, double f)
Namespace of DDCMS conversion namespace.
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_set< std::string > assemblySolids