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 }
detgeomdescbuilder::buildDetGeomDescDescendants
void buildDetGeomDescDescendants(DDFilteredView &fv, DetGeomDesc *geoInfoParent, const bool isRun2)
Definition: DetGeomDescBuilder.cc:31
MessageLogger.h
DetGeomDesc::addComponent
void addComponent(DetGeomDesc *)
Definition: DetGeomDesc.cc:111
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
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
CTPPSDetId::sdTimingDiamond
Definition: CTPPSDetId.h:44
DDFilteredView::nextSibling
bool nextSibling()
set the current node to the next sibling ...
Definition: DDFilteredView.cc:124
geometryPPS_CMSxz_fromDD_2016_cfi.isRun2
isRun2
Definition: geometryPPS_CMSxz_fromDD_2016_cfi.py:14
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:60
DetGeomDescBuilder.h
DetGeomDesc
Definition: DetGeomDesc.h:50
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
DDPassAllFilter
A DDFilter that always returns true.
Definition: DDFilter.h:26
cms::DDDetector
Definition: DDDetector.h:12
cms::DDCompactView
Definition: DDCompactView.h:31
CTPPSDetId.h
DDFilteredView
Definition: DDFilteredView.h:20
child
Definition: simpleInheritance.h:11
detgeomdescbuilder::buildDetGeomDescFromCompactView
std::unique_ptr< DetGeomDesc > buildDetGeomDescFromCompactView(const DDCompactView &myCompactView, const bool isRun2)
Definition: DetGeomDescBuilder.cc:10
cms::DDCompactView::detector
const cms::DDDetector * detector() const
Definition: DDCompactView.h:34
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443