9 #include "DD4hep/Detector.h" 10 #include "DD4hep/DD4hepRootPersistency.h" 11 #include "DD4hep/DetectorTools.h" 12 #include "DD4hep/VolumeProcessor.h" 23 class VolumeProcessor :
public dd4hep::PlacedVolumeProcessor {
25 VolumeProcessor() =
default;
26 ~VolumeProcessor()
override =
default;
30 m_volumes.emplace_back(pv.name());
37 int operator()(dd4hep::PlacedVolume pv,
int level)
override {
39 cout <<
"Hierarchical level:" << level <<
" Placement:";
40 for(
const auto&
i : m_volumes)
cout <<
"/" <<
i;
41 cout <<
"\n\tMaterial:" << vol.material().name()
42 <<
"\tSolid: " << vol.solid().name()
43 <<
" [" << vol.solid()->IsA()->GetName() <<
"]\n";
47 int count()
const {
return m_count; }
51 vector<string> m_volumes;
70 cout <<
"DDTestNavigateGeometry::analyze:\n";
76 for(
const auto&
p: reg->vectors ) {
78 for(
const auto& i :
p.second )
89 string detElementPath;
92 DetElement startDetEl, world = detector.world();
93 PlacedVolume startPVol = world.placement();
94 if( !detElementPath.empty())
95 startDetEl = dd4hep::detail::tools::findElement(detector, detElementPath);
96 else if( !placedVolPath.empty())
97 startPVol = dd4hep::detail::tools::findNode(world.placement(), placedVolPath);
98 if( !startPVol.isValid()) {
99 if( !startDetEl.isValid()) {
100 except(
"VolumeScanner",
"Failed to find start conditions for the volume scan");
102 startPVol = startDetEl.placement();
105 VolumeProcessor
proc;
106 PlacedVolumeScanner().scanPlacements(proc, startPVol, 0,
true);
108 printout(ALWAYS,
"VolumeScanner",
"+++ Visited a total of %d placed volumes.", proc.count());
TrainProcessor *const proc
#define DEFINE_FWK_MODULE(type)
void analyze(edm::Event const &iEvent, edm::EventSetup const &) override
Namespace of DDCMS conversion namespace.
DDTestNavigateGeometry(const edm::ParameterSet &)
virtual example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
bool get(HolderT &iHolder) const