CMS 3D CMS Logo

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