CMS 3D CMS Logo

DDVolumeProcessor.h
Go to the documentation of this file.
1 #ifndef DETECTOR_DESCRIPTION_DD_VOLUME_PROCESSOR_H
2 #define DETECTOR_DESCRIPTION_DD_VOLUME_PROCESSOR_H
3 
4 #include "DD4hep/VolumeProcessor.h"
7 
8 #include <string>
9 #include <string_view>
10 #include <vector>
11 
12 namespace cms {
13 
14  class DDVolumeProcessor : public dd4hep::PlacedVolumeProcessor {
15  public:
18  using PlacedVolumeProcessor = dd4hep::PlacedVolumeProcessor;
19 
20  DDVolumeProcessor() = default;
21  ~DDVolumeProcessor() override = default;
22 
23  std::string_view stripNamespace(std::string_view v) {
24  auto first = v.find_first_of(":");
25  v.remove_prefix(std::min(first + 1, v.size()));
26  return v;
27  }
28 
29  std::string_view stripCopyNo(std::string_view v) {
30  auto found = v.find_last_of("_");
31  if (found != v.npos) {
32  v.remove_suffix(v.size() - found);
33  }
34  return v;
35  }
36 
37  std::vector<std::string_view> split(std::string_view str, const char* delims) {
38  std::vector<std::string_view> ret;
39 
41  auto pos = str.find_first_of(delims, start);
42  while (pos != std::string_view::npos) {
43  if (pos != start) {
44  ret.emplace_back(str.substr(start, pos - start));
45  }
46  start = pos + 1;
47  pos = str.find_first_of(delims, start);
48  }
49  if (start < str.length())
50  ret.emplace_back(str.substr(start, str.length() - start));
51  return ret;
52  }
53 
54  bool compare(std::string_view s1, std::string_view s2) {
55  if (s1 == s2)
56  return true;
57  edm::LogVerbatim("Geometry") << '\"' << s1 << "\" does not match \"" << s2 << "\"\n";
58  return false;
59  }
60 
62  int process(PlacedVolume pv, int level, bool recursive) override {
63  m_volumes.emplace_back(pv.name());
65  m_volumes.pop_back();
66  return ret;
67  }
68 
70  int operator()(PlacedVolume pv, int level) override {
71  Volume vol = pv.volume();
72  edm::LogVerbatim("Geometry").log([&level, &vol, this](auto& log) {
73  log << "\nHierarchical level:" << level << " Placement:";
74  for (const auto& i : m_volumes)
75  log << "/" << i << ", \n";
76  log << "\n\tMaterial:" << vol.material().name() << "\tSolid: " << vol.solid().name() << "\n";
77  });
78  ++m_count;
79  return 1;
80  }
81  int count() const { return m_count; }
82 
83  private:
84  int m_count = 0;
85  std::vector<std::string_view> m_volumes;
86  };
87 } // namespace cms
88 
89 #endif
personalPlayback.level
level
Definition: personalPlayback.py:22
cms::DDVolumeProcessor::split
std::vector< std::string_view > split(std::string_view str, const char *delims)
Definition: DDVolumeProcessor.h:37
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:355
cms::DDVolumeProcessor::PlacedVolume
dd4hep::PlacedVolume PlacedVolume
Definition: DDVolumeProcessor.h:17
mps_fire.i
i
Definition: mps_fire.py:355
start
Definition: start.py:1
MessageLogger.h
cms::DDVolumeProcessor::stripCopyNo
std::string_view stripCopyNo(std::string_view v)
Definition: DDVolumeProcessor.h:29
cms::DDVolumeProcessor::m_volumes
std::vector< std::string_view > m_volumes
Definition: DDVolumeProcessor.h:85
cms::DDVolumeProcessor::m_count
int m_count
Definition: DDVolumeProcessor.h:84
min
T min(T a, T b)
Definition: MathUtil.h:58
cms::DDVolumeProcessor::DDVolumeProcessor
DDVolumeProcessor()=default
pos
Definition: PixelAliasList.h:18
indexGen.s2
s2
Definition: indexGen.py:107
cms::PlacedVolume
dd4hep::PlacedVolume PlacedVolume
Definition: DDFilteredView.h:46
findQualityFiles.v
v
Definition: findQualityFiles.py:179
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
dqmdumpme.first
first
Definition: dqmdumpme.py:55
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
cms::DDVolumeProcessor::process
int process(PlacedVolume pv, int level, bool recursive) override
Callback to retrieve PlacedVolume information of an entire Placement.
Definition: DDVolumeProcessor.h:62
cms::DDVolumeProcessor::operator()
int operator()(PlacedVolume pv, int level) override
Volume callback.
Definition: DDVolumeProcessor.h:70
str
#define str(s)
Definition: TestProcessor.cc:48
cms::DDVolumeProcessor::PlacedVolumeProcessor
dd4hep::PlacedVolumeProcessor PlacedVolumeProcessor
Definition: DDVolumeProcessor.h:18
DDSpecParRegistry.h
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:45
cms::DDVolumeProcessor::stripNamespace
std::string_view stripNamespace(std::string_view v)
Definition: DDVolumeProcessor.h:23
LaserDQM_cfg.process
process
Definition: LaserDQM_cfg.py:3
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
edm::LogVerbatim::log
LogVerbatim & log(F &&iF)
Definition: MessageLogger.h:327
edm::LogVerbatim
Definition: MessageLogger.h:297
cms::DDVolumeProcessor::count
int count() const
Definition: DDVolumeProcessor.h:81
cms::DDVolumeProcessor::~DDVolumeProcessor
~DDVolumeProcessor() override=default
cms::DDVolumeProcessor::Volume
dd4hep::Volume Volume
Definition: DDVolumeProcessor.h:16
cms::DDVolumeProcessor
Definition: DDVolumeProcessor.h:14
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
postprocess-scan-build.recursive
recursive
Definition: postprocess-scan-build.py:10
command_line.start
start
Definition: command_line.py:167
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
cms::DDVolumeProcessor::compare
bool compare(std::string_view s1, std::string_view s2)
Definition: DDVolumeProcessor.h:54