CMS 3D CMS Logo

DetGeomDescBuilder.cc
Go to the documentation of this file.
2 
5 
6 /*
7  * Generic function to build geo (tree of DetGeomDesc) from old DD compact view.
8  */
9 std::unique_ptr<DetGeomDesc> detgeomdescbuilder::buildDetGeomDescFromCompactView(const DDCompactView& myCompactView) {
10  // Create DDFilteredView (no filter!!)
12  DDFilteredView fv(myCompactView, filter);
13 
14  // Geo info: root node.
15  auto geoInfoRoot = std::make_unique<DetGeomDesc>(fv);
16 
17  // Construct the tree of children geo info (DetGeomDesc).
19 
20  edm::LogInfo("PPSGeometryESProducer") << "Successfully built geometry.";
21 
22  return geoInfoRoot;
23 }
24 
25 /*
26  * Depth-first search recursion.
27  * Construct the tree of children geo info (DetGeomDesc) (old DD).
28  */
30  // Leaf
31  if (!fv.firstChild())
32  return;
33 
34  do {
35  // Create node, and add it to the geoInfoParent's list.
36  DetGeomDesc* child = new DetGeomDesc(fv);
37  geoInfo->addComponent(child);
38 
39  // Recursion
41  } while (fv.nextSibling());
42 
43  fv.parent();
44 }
45 
46 /*
47  * Generic function to build geo (tree of DetGeomDesc) from DD4hep compact view.
48  */
50  const cms::DDCompactView& myCompactView) {
51  // create DDFilteredView (no filter!!)
52  const cms::DDDetector* mySystem = myCompactView.detector();
53  const dd4hep::Volume& worldVolume = mySystem->worldVolume();
54  cms::DDFilteredView fv(mySystem, worldVolume);
55  if (fv.next(0) == false) {
56  edm::LogError("PPSGeometryESProducer") << "Filtered view is empty. Cannot build.";
57  }
58 
59  // Geo info: root node.
60  auto geoInfoRoot = std::make_unique<DetGeomDesc>(fv);
61 
62  // Construct the tree of children geo info (DetGeomDesc).
63  do {
64  // Create node, and add it to the geoInfoRoot's list.
65  DetGeomDesc* child = new DetGeomDesc(fv);
66  geoInfoRoot->addComponent(child);
67  } while (fv.next(0));
68 
69  edm::LogInfo("PPSGeometryESProducer") << "Successfully built geometry, it has " << (geoInfoRoot->components()).size()
70  << " DetGeomDesc nodes.";
71 
72  return geoInfoRoot;
73 }
MessageLogger.h
DetGeomDesc::addComponent
void addComponent(DetGeomDesc *)
Definition: DetGeomDesc.cc:79
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
cms::DDFilteredView
Definition: DDFilteredView.h:70
DDFilteredView::parent
bool parent()
set the current node to the parent node ...
Definition: DDFilteredView.cc:161
DDDetector.h
detgeomdescbuilder::buildDetGeomDescDescendants
void buildDetGeomDescDescendants(DDFilteredView &fv, DetGeomDesc *geoInfoParent)
Definition: DetGeomDescBuilder.cc:29
DDFilteredView::firstChild
bool firstChild()
set the current node to the first child ...
Definition: DDFilteredView.cc:86
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDFilteredView::nextSibling
bool nextSibling()
set the current node to the next sibling ...
Definition: DDFilteredView.cc:124
ALCARECOTkAlBeamHalo_cff.filter
filter
Definition: ALCARECOTkAlBeamHalo_cff.py:27
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:47
cms::DDDetector::worldVolume
dd4hep::Volume worldVolume() const
Handle to the world volume containing everything.
Definition: DDDetector.cc:40
DetGeomDescBuilder.h
DetGeomDesc
Definition: DetGeomDesc.h:49
cms::DDFilteredView::next
bool next(int)
set current node to the next node in the filtered tree
Definition: DDFilteredView.cc:491
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
detgeomdescbuilder::buildDetGeomDescFromCompactView
std::unique_ptr< DetGeomDesc > buildDetGeomDescFromCompactView(const DDCompactView &myCompactView)
Definition: DetGeomDescBuilder.cc:9
DDPassAllFilter
A DDFilter that always returns true.
Definition: DDFilter.h:26
cms::DDDetector
Definition: DDDetector.h:12
cms::DDCompactView
Definition: DDCompactView.h:31
DDFilteredView
Definition: DDFilteredView.h:20
child
Definition: simpleInheritance.h:11
cms::DDCompactView::detector
const cms::DDDetector * detector() const
Definition: DDCompactView.h:34
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443