1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
#include "Geometry/VeryForwardGeometryBuilder/interface/DetGeomDescBuilder.h"
#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h"
#include "DetectorDescription/DDCMS/interface/DDDetector.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
/*
* Generic function to build geo (tree of DetGeomDesc) from old DD compact view.
*/
std::unique_ptr<DetGeomDesc> detgeomdescbuilder::buildDetGeomDescFromCompactView(const DDCompactView& myCompactView,
const bool isRun2) {
// Create DDFilteredView (no filter!!)
DDPassAllFilter filter;
DDFilteredView fv(myCompactView, filter);
// Geo info: root node.
auto geoInfoRoot = std::make_unique<DetGeomDesc>(fv, isRun2);
// Construct the tree of children geo info (DetGeomDesc).
detgeomdescbuilder::buildDetGeomDescDescendants(fv, geoInfoRoot.get(), isRun2);
edm::LogInfo("PPSGeometryESProducer") << "Successfully built geometry.";
return geoInfoRoot;
}
/*
* Depth-first search recursion.
* Construct the tree of children geo info (DetGeomDesc) (old DD).
*/
void detgeomdescbuilder::buildDetGeomDescDescendants(DDFilteredView& fv, DetGeomDesc* geoInfo, const bool isRun2) {
// Leaf
if (!fv.firstChild())
return;
do {
// Create node
DetGeomDesc* child = new DetGeomDesc(fv, isRun2);
// legacy Run2 z sign fix for diamond detectors
const auto& detId = child->geographicalID();
if (isRun2 && detId.subdetId() == CTPPSDetId::sdTimingDiamond)
child->invertZSign();
// add the to the geoInfoParent's list.
geoInfo->addComponent(child);
// Recursion
buildDetGeomDescDescendants(fv, child, isRun2);
} while (fv.nextSibling());
fv.parent();
}
/*
* Generic function to build geo (tree of DetGeomDesc) from DD4hep compact view.
*/
std::unique_ptr<DetGeomDesc> detgeomdescbuilder::buildDetGeomDescFromCompactView(
const cms::DDCompactView& myCompactView, const bool isRun2) {
// create DDFilteredView (no filter!!)
const cms::DDDetector* mySystem = myCompactView.detector();
const dd4hep::Volume& worldVolume = mySystem->worldVolume();
cms::DDFilteredView fv(mySystem, worldVolume);
if (fv.next(0) == false) {
edm::LogError("PPSGeometryESProducer") << "Filtered view is empty. Cannot build.";
}
// Geo info: root node.
auto geoInfoRoot = std::make_unique<DetGeomDesc>(fv, isRun2);
// Construct the tree of children geo info (DetGeomDesc).
do {
// Create node
DetGeomDesc* child = new DetGeomDesc(fv, isRun2);
// legacy Run2 z sign fix for diamond detectors
const auto& detId = child->geographicalID();
if (isRun2 && detId.subdetId() == CTPPSDetId::sdTimingDiamond)
child->invertZSign();
// add the node to the geoInfoRoot's list.
geoInfoRoot->addComponent(child);
} while (fv.next(0));
edm::LogInfo("PPSGeometryESProducer") << "Successfully built geometry, it has " << (geoInfoRoot->components()).size()
<< " DetGeomDesc nodes.";
return geoInfoRoot;
}
|