DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
OpticalSurfaces.cpp
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 
14 // Framework include files
15 #include <DD4hep/OpticalSurfaces.h>
16 #include <DD4hep/NamedObject.h>
17 #include <DD4hep/Detector.h>
18 #include <DD4hep/Printout.h>
19 #include <DD4hep/World.h>
20 
21 #include <DD4hep/detail/Handle.inl>
22 
23 // C/C++ includes
24 #include <sstream>
25 #include <iomanip>
26 
27 using namespace dd4hep;
28 
29 DD4HEP_INSTANTIATE_HANDLE(TGeoSkinSurface);
30 DD4HEP_INSTANTIATE_HANDLE(TGeoBorderSurface);
31 DD4HEP_INSTANTIATE_HANDLE(TGeoOpticalSurface);
32 
35  const std::string& full_name,
36  EModel model,
37  EFinish finish,
38  EType type,
39  double value)
40 {
41  std::unique_ptr<Object> obj(new Object(full_name.c_str(), model, finish, type, value));
42  detector.manager().AddOpticalSurface(m_element=obj.release());
43 }
44 
47  return access()->GetProperty(nam);
48 }
49 
51 OpticalSurface::Property OpticalSurface::property(const std::string& nam) const {
52  return access()->GetProperty(nam.c_str());
53 }
54 
56 SkinSurface::SkinSurface(Detector& detector, DetElement de, const std::string& nam, OpticalSurface surf, Volume vol)
57 {
58  if ( de.isValid() ) {
59  if ( vol.isValid() ) {
60  if ( surf.isValid() ) {
61  std::unique_ptr<Object> obj(new Object(nam.c_str(), surf->GetName(), surf.ptr(), vol.ptr()));
62  detector.surfaceManager().addSkinSurface(de, m_element=obj.release());
63  return;
64  }
65  except("SkinSurface","++ Cannot create SkinSurface %s without valid optical surface!",nam.c_str());
66  }
67  except("SkinSurface","++ Cannot create SkinSurface %s without valid volume!",nam.c_str());
68  }
69  except("SkinSurface",
70  "++ Cannot create SkinSurface %s which is not connected to a valid detector element!",nam.c_str());
71 }
72 
75  return (TGeoOpticalSurface*)(access()->GetSurface());
76 }
77 
80  OpticalSurface surf(surface());
81  return surf.property(nam);
82 }
83 
85 BorderSurface::Property SkinSurface::property(const std::string& nam) const {
86  OpticalSurface surf(surface());
87  return surf.property(nam.c_str());
88 }
89 
92  return access()->GetVolume();
93 }
94 
97  DetElement de,
98  const std::string& nam,
99  OpticalSurface surf,
100  PlacedVolume lft,
101  PlacedVolume rht)
102 {
103  if ( de.isValid() ) {
104  if ( lft.isValid() && rht.isValid() ) {
105  if ( surf.isValid() ) {
106  std::unique_ptr<Object> obj(new Object(nam.c_str(), surf->GetName(), surf.ptr(), lft.ptr(), rht.ptr()));
107  detector.surfaceManager().addBorderSurface(de, m_element=obj.release());
108  return;
109  }
110  except("BorderSurface","++ Cannot create BorderSurface %s without valid optical surface!",nam.c_str());
111  }
112  except("BorderSurface","++ Cannot create BorderSurface %s without valid placements!",nam.c_str());
113  }
114  except("BorderSurface",
115  "++ Cannot create BorderSurface %s which is not connected to a valid detector element!",nam.c_str());
116 }
117 
120  return (TGeoOpticalSurface*)(access()->GetSurface());
121 }
122 
125  OpticalSurface surf(surface());
126  return surf.property(nam);
127 }
128 
130 BorderSurface::Property BorderSurface::property(const std::string& nam) const {
131  OpticalSurface surf(surface());
132  return surf.property(nam.c_str());
133 }
134 
137  return (TGeoNode*)access()->GetNode1();
138 }
139 
142  return access()->GetNode2();
143 }
144 
dd4hep::BorderSurface::property
Property property(const char *name) const
Access to tabular properties of the optical surface.
Definition: OpticalSurfaces.cpp:124
dd4hep::Detector::manager
virtual TGeoManager & manager() const =0
Access the geometry manager of this instance.
dd4hep::OpticalSurfaceManager::addSkinSurface
void addSkinSurface(DetElement de, SkinSurface surf) const
Add skin surface to manager.
Definition: OpticalSurfaceManager.cpp:96
dd4hep::BorderSurface::right
PlacedVolume right() const
Access the right node of the border surface.
Definition: OpticalSurfaces.cpp:141
OpticalSurfaces.h
Detector.h
dd4hep::PlacedVolume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:163
dd4hep::OpticalSurface::Object
TGeoOpticalSurface Object
Definition: OpticalSurfaces.h:44
World.h
dd4hep::Handle::isValid
bool isValid() const
Check the validity of the object held by the handle.
Definition: Handle.h:128
dd4hep::SkinSurface::volume
Volume volume() const
Access the node of the skin surface.
Definition: OpticalSurfaces.cpp:91
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:188
dd4hep::Volume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:370
dd4hep::OpticalSurface::EFinish
Object::ESurfaceFinish EFinish
Definition: OpticalSurfaces.h:49
dd4hep::OpticalSurface::Property
const TGDMLMatrix * Property
Definition: OpticalSurfaces.h:51
dd4hep::BorderSurface::BorderSurface
BorderSurface()=default
Default constructor.
dd4hep::Detector::surfaceManager
virtual OpticalSurfaceManager surfaceManager() const =0
Access the optical surface manager.
dd4hep::SkinSurface::surface
OpticalSurface surface() const
Access surface data.
Definition: OpticalSurfaces.cpp:74
NamedObject.h
dd4hep::Handle< TGeoOpticalSurface >::m_element
TGeoOpticalSurface * m_element
Single and only data member: Reference to the actual element.
Definition: Handle.h:93
dd4hep::OpticalSurfaceManager::addBorderSurface
void addBorderSurface(DetElement de, BorderSurface surf) const
Add border surface to manager.
Definition: OpticalSurfaceManager.cpp:104
dd4hep::SkinSurface::Object
TGeoSkinSurface Object
Definition: OpticalSurfaces.h:113
dd4hep::BorderSurface::Object
TGeoBorderSurface Object
Definition: OpticalSurfaces.h:157
dd4hep::SkinSurface::property
Property property(const char *name) const
Access to tabular properties of the optical surface.
Definition: OpticalSurfaces.cpp:79
dd4hep::BorderSurface::surface
OpticalSurface surface() const
Access surface data.
Definition: OpticalSurfaces.cpp:119
dd4hep::BorderSurface::Property
const TGDMLMatrix * Property
Definition: OpticalSurfaces.h:158
dd4hep::Handle< TGeoOpticalSurface >::access
TGeoOpticalSurface * access() const
Checked object access. Throws invalid handle runtime exception if invalid handle.
dd4hep::Handle::ptr
T * ptr() const
Access to the held object.
Definition: Handle.h:153
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::BorderSurface::left
PlacedVolume left() const
Access the left node of the border surface.
Definition: OpticalSurfaces.cpp:136
DD4HEP_INSTANTIATE_HANDLE
DD4HEP_INSTANTIATE_HANDLE(TGeoSkinSurface)
dd4hep::OpticalSurface::EModel
Object::ESurfaceModel EModel
Definition: OpticalSurfaces.h:48
dd4hep::Detector
The main interface to the dd4hep detector description package.
Definition: Detector.h:90
dd4hep::SkinSurface::SkinSurface
SkinSurface()=default
Default constructor.
dd4hep::OpticalSurface::property
Property property(const char *name) const
Access to tabular properties of the surface.
Definition: OpticalSurfaces.cpp:46
dd4hep::OpticalSurface::EType
Object::ESurfaceType EType
Definition: OpticalSurfaces.h:50
Printout.h
dd4hep::OpticalSurface
Class to support the handling of optical surfaces.
Definition: OpticalSurfaces.h:42
dd4hep::OpticalSurface::OpticalSurface
OpticalSurface()=default
Default constructor.