DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
VolumeProcessor.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 #ifndef DD4HEP_VOLUMEPROCESSOR_H
14 #define DD4HEP_VOLUMEPROCESSOR_H
15 
16 // Framework includes
17 #include <DD4hep/DetElement.h>
18 #include <DD4hep/Volumes.h>
19 
20 // C/C++ include files
21 #include <memory>
22 
24 namespace dd4hep {
25 
27 
38  public:
40  PlacedVolumeProcessor() = default;
46  virtual ~PlacedVolumeProcessor() noexcept(false);
48  PlacedVolumeProcessor& operator=(const PlacedVolumeProcessor& copy) = default;
50  virtual int operator()(PlacedVolume pv, int level) = 0;
52  virtual int process(PlacedVolume pv, int level, bool recursive);
53  };
54 
56 
66  template <typename T> class PlacementProcessor : virtual public PlacedVolumeProcessor {
67  public:
70  public:
72  PlacementProcessor() = delete;
74  PlacementProcessor(T& p) : processor(p) {}
76  PlacementProcessor(T&& p) = delete;
82  virtual ~PlacementProcessor() = default;
86  virtual int operator()(PlacedVolume pv, int level) final
87  { return (processor)(pv, level); }
88  };
89 
91  template <typename T> inline
93  { return PlacementProcessor<typename std::remove_reference<T>::type>(std::forward<T>(proc)); }
94 
96 
102  template <typename T> class PlacementProcessorShared : public PlacedVolumeProcessor {
103  public:
105  std::shared_ptr<T> processor;
106  public:
110  PlacementProcessorShared(std::shared_ptr<T>& p) : processor(p) {}
114  virtual ~PlacementProcessorShared() = default;
118  virtual int operator()(PlacedVolume pv, int level) final
119  { return (*processor)(pv, level); }
120  };
121 
123 
136  public:
138  PlacedVolumeScanner() = default;
143 
145  template <typename Q>
146  PlacedVolumeScanner(Q& proc, DetElement start, int level=0, bool recursive=true)
147  { scan(proc, start.placement(), level, recursive); }
148 
150  template <typename Q>
151  PlacedVolumeScanner(const Q& proc, DetElement start, int level=0, bool recursive=true)
152  { scan(proc, start.placement(), level, recursive); }
153 
155  template <typename Q>
156  PlacedVolumeScanner(Q& proc, PlacedVolume start, int level=0, bool recursive=true)
157  { scan(proc, start, level, recursive); }
158 
160  template <typename Q>
161  PlacedVolumeScanner(const Q& proc, PlacedVolume start, int level=0, bool recursive=true)
162  { scan(proc, start, level, recursive); }
163 
165  int scanPlacements(PlacedVolumeProcessor& proc, PlacedVolume start, int level=0, bool recursive=true) const {
166  return proc.process(start, level, recursive);
167  }
169  template <typename Q>
170  int scan(Q& p, PlacedVolume start, int level=0, bool recursive=true) const {
171  auto proc = placementProcessor(p);
172  return proc.process(start, level, recursive);
173  }
175  template <typename Q>
176  int scan(const Q& p, PlacedVolume start, int level=0, bool recursive=true) const {
177  auto proc = placementProcessor(p);
178  return proc.process(start, level, recursive);
179  }
180  };
181 } /* End namespace dd4hep */
182 #endif // DD4HEP_VOLUMEPROCESSOR_H
dd4hep::PlacedVolumeProcessor
Generic PlacedVolume processor.
Definition: VolumeProcessor.h:37
dd4hep::PlacedVolumeScanner::operator=
PlacedVolumeScanner & operator=(const PlacedVolumeScanner &copy)=default
Assignment operator.
Volumes.h
dd4hep::PlacedVolumeProcessor::PlacedVolumeProcessor
PlacedVolumeProcessor()=default
Initializing constructor.
dd4hep::PlacedVolumeScanner::scanPlacements
int scanPlacements(PlacedVolumeProcessor &proc, PlacedVolume start, int level=0, bool recursive=true) const
PlacedVolume element tree scanner using wrapped PlacedVolumeProcessor objects.
Definition: VolumeProcessor.h:165
dd4hep::PlacementProcessorShared::operator=
PlacementProcessorShared & operator=(const PlacementProcessorShared &copy)=default
Default assignment.
dd4hep::PlacedVolume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:173
dd4hep::DetElement::placement
PlacedVolume placement() const
Access to the physical volume of this detector element.
Definition: DetElement.cpp:321
dd4hep::PlacementProcessor::PlacementProcessor
PlacementProcessor(PlacementProcessor &&copy)=default
R-value copy from a temporary (Since processor is reference)
dd4hep::PlacementProcessor::PlacementProcessor
PlacementProcessor(T &&p)=delete
Default move constructor is disabled.
dd4hep::PlacementProcessor::PlacementProcessor
PlacementProcessor()=delete
Default constructor.
dd4hep::PlacedVolumeScanner::PlacedVolumeScanner
PlacedVolumeScanner(Q &proc, PlacedVolume start, int level=0, bool recursive=true)
Constructor performing the scan internally.
Definition: VolumeProcessor.h:156
dd4hep::PlacedVolumeScanner::PlacedVolumeScanner
PlacedVolumeScanner()=default
Default constructor.
dd4hep::PlacedVolumeProcessor::~PlacedVolumeProcessor
virtual ~PlacedVolumeProcessor() noexcept(false)
Default destructor.
Definition: VolumeProcessor.cpp:21
dd4hep::PlacementProcessorShared::PlacementProcessorShared
PlacementProcessorShared()=delete
Default constructor.
dd4hep::PlacementProcessorShared::operator()
virtual int operator()(PlacedVolume pv, int level) final
Callback to output detector information of an single DetElement.
Definition: VolumeProcessor.h:118
dd4hep::PlacementProcessor::processor
T & processor
Reference to execution object implementing operator()(PlacedVolume pv, int level)
Definition: VolumeProcessor.h:69
dd4hep::PlacementProcessorShared::~PlacementProcessorShared
virtual ~PlacementProcessorShared()=default
Default destructor.
dd4hep::PlacedVolumeScanner::PlacedVolumeScanner
PlacedVolumeScanner(const Q &proc, PlacedVolume start, int level=0, bool recursive=true)
Constructor performing the scan internally.
Definition: VolumeProcessor.h:161
dd4hep::PlacedVolumeProcessor::PlacedVolumeProcessor
PlacedVolumeProcessor(PlacedVolumeProcessor &&copy)=default
R-value copy from a temporary (Since processor is reference)
dd4hep::PlacementProcessor::~PlacementProcessor
virtual ~PlacementProcessor()=default
Default destructor.
dd4hep::PlacedVolumeProcessor::process
virtual int process(PlacedVolume pv, int level, bool recursive)
Callback to output PlacedVolume information of an entire Placement.
Definition: VolumeProcessor.cpp:25
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:188
dd4hep::PlacementProcessor::operator=
PlacementProcessor & operator=(const PlacementProcessor &copy)=default
Default assignment.
dd4hep::PlacedVolumeScanner::PlacedVolumeScanner
PlacedVolumeScanner(const PlacedVolumeScanner &copy)=default
Copy constructor.
dd4hep::PlacementProcessor::PlacementProcessor
PlacementProcessor(const PlacementProcessor &copy)=default
Default copy constructor.
dd4hep::PlacedVolumeScanner
Helper to run placement scan through volume hierarchies scans.
Definition: VolumeProcessor.h:135
dd4hep::PlacedVolumeScanner::scan
int scan(const Q &p, PlacedVolume start, int level=0, bool recursive=true) const
PlacedVolume element tree scanner using wrapped PlacedVolumeProcessor objects.
Definition: VolumeProcessor.h:176
dd4hep::PlacementProcessor::operator()
virtual int operator()(PlacedVolume pv, int level) final
Callback to output detector information of an single placement.
Definition: VolumeProcessor.h:86
dd4hep::PlacementProcessorShared::PlacementProcessorShared
PlacementProcessorShared(const PlacementProcessorShared &copy)=default
Default copy constructor.
dd4hep::PlacementProcessor::PlacementProcessor
PlacementProcessor(T &p)
Default constructor.
Definition: VolumeProcessor.h:74
dd4hep::PlacedVolumeScanner::PlacedVolumeScanner
PlacedVolumeScanner(const Q &proc, DetElement start, int level=0, bool recursive=true)
Constructor performing the scan internally.
Definition: VolumeProcessor.h:151
dd4hep::PlacementProcessorShared::processor
std::shared_ptr< T > processor
Reference to execution object implementing operator()(PlacedVolume pv, int level)
Definition: VolumeProcessor.h:105
dd4hep::PlacedVolumeProcessor::PlacedVolumeProcessor
PlacedVolumeProcessor(const PlacedVolumeProcessor &copy)=default
Default copy constructor.
dd4hep::PlacementProcessorShared
Wrapper to call objects in the form of a PlacedVolume processor.
Definition: VolumeProcessor.h:102
dd4hep::PlacementProcessor
PlacedVolume scanner using a Processor object.
Definition: VolumeProcessor.h:66
DetElement.h
dd4hep::PlacementProcessorShared::PlacementProcessorShared
PlacementProcessorShared(std::shared_ptr< T > &p)
Default constructor.
Definition: VolumeProcessor.h:110
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::placementProcessor
PlacementProcessor< typename std::remove_reference< T >::type > placementProcessor(T &&proc)
Instantiation helper.
Definition: VolumeProcessor.h:92
dd4hep::PlacedVolumeScanner::scan
int scan(Q &p, PlacedVolume start, int level=0, bool recursive=true) const
PlacedVolume element tree scanner using wrapped PlacedVolumeProcessor objects.
Definition: VolumeProcessor.h:170
dd4hep::detail::tools::copy
void copy(Alignment from, Alignment to)
Copy alignment object from source object.
Definition: AlignmentTools.cpp:43
dd4hep::PlacedVolumeScanner::PlacedVolumeScanner
PlacedVolumeScanner(Q &proc, DetElement start, int level=0, bool recursive=true)
Constructor performing the scan internally.
Definition: VolumeProcessor.h:146