File indexing completed on 2025-07-14 08:13:13
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <DD4hep/OpticalSurfaces.h>
0016 #include <DD4hep/NamedObject.h>
0017 #include <DD4hep/Detector.h>
0018 #include <DD4hep/Printout.h>
0019 #include <DD4hep/World.h>
0020
0021 #include <DD4hep/detail/Handle.inl>
0022
0023
0024
0025 using namespace dd4hep;
0026
0027 DD4HEP_INSTANTIATE_HANDLE(TGeoSkinSurface);
0028 DD4HEP_INSTANTIATE_HANDLE(TGeoBorderSurface);
0029 DD4HEP_INSTANTIATE_HANDLE(TGeoOpticalSurface);
0030
0031
0032 OpticalSurface::OpticalSurface(Detector& detector,
0033 const std::string& full_name,
0034 EModel model,
0035 EFinish finish,
0036 EType type,
0037 double value)
0038 {
0039 std::unique_ptr<Object> obj(new Object(full_name.c_str(), model, finish, type, value));
0040 detector.manager().AddOpticalSurface(m_element=obj.release());
0041 }
0042
0043
0044 OpticalSurface::Property OpticalSurface::property(const char* nam) const {
0045 return access()->GetProperty(nam);
0046 }
0047
0048
0049 OpticalSurface::Property OpticalSurface::property(const std::string& nam) const {
0050 return access()->GetProperty(nam.c_str());
0051 }
0052
0053
0054 SkinSurface::SkinSurface(Detector& detector, DetElement de, const std::string& nam, OpticalSurface surf, Volume vol)
0055 {
0056 if ( de.isValid() ) {
0057 if ( vol.isValid() ) {
0058 if ( surf.isValid() ) {
0059 std::unique_ptr<Object> obj(new Object(nam.c_str(), surf->GetName(), surf.ptr(), vol.ptr()));
0060 detector.surfaceManager().addSkinSurface(de, m_element=obj.release());
0061 return;
0062 }
0063 except("SkinSurface","++ Cannot create SkinSurface %s without valid optical surface!",nam.c_str());
0064 }
0065 except("SkinSurface","++ Cannot create SkinSurface %s without valid volume!",nam.c_str());
0066 }
0067 except("SkinSurface",
0068 "++ Cannot create SkinSurface %s which is not connected to a valid detector element!",nam.c_str());
0069 }
0070
0071
0072 OpticalSurface SkinSurface::surface() const {
0073 return (TGeoOpticalSurface*)(access()->GetSurface());
0074 }
0075
0076
0077 BorderSurface::Property SkinSurface::property(const char* nam) const {
0078 OpticalSurface surf(surface());
0079 return surf.property(nam);
0080 }
0081
0082
0083 BorderSurface::Property SkinSurface::property(const std::string& nam) const {
0084 OpticalSurface surf(surface());
0085 return surf.property(nam.c_str());
0086 }
0087
0088
0089 Volume SkinSurface::volume() const {
0090 return access()->GetVolume();
0091 }
0092
0093
0094 BorderSurface::BorderSurface(Detector& detector,
0095 DetElement de,
0096 const std::string& nam,
0097 OpticalSurface surf,
0098 PlacedVolume lft,
0099 PlacedVolume rht)
0100 {
0101 if ( de.isValid() ) {
0102 if ( lft.isValid() && rht.isValid() ) {
0103 if ( surf.isValid() ) {
0104 std::unique_ptr<Object> obj(new Object(nam.c_str(), surf->GetName(), surf.ptr(), lft.ptr(), rht.ptr()));
0105 detector.surfaceManager().addBorderSurface(de, m_element=obj.release());
0106 return;
0107 }
0108 except("BorderSurface","++ Cannot create BorderSurface %s without valid optical surface!",nam.c_str());
0109 }
0110 except("BorderSurface","++ Cannot create BorderSurface %s without valid placements!",nam.c_str());
0111 }
0112 except("BorderSurface",
0113 "++ Cannot create BorderSurface %s which is not connected to a valid detector element!",nam.c_str());
0114 }
0115
0116
0117 OpticalSurface BorderSurface::surface() const {
0118 return (TGeoOpticalSurface*)(access()->GetSurface());
0119 }
0120
0121
0122 BorderSurface::Property BorderSurface::property(const char* nam) const {
0123 OpticalSurface surf(surface());
0124 return surf.property(nam);
0125 }
0126
0127
0128 BorderSurface::Property BorderSurface::property(const std::string& nam) const {
0129 OpticalSurface surf(surface());
0130 return surf.property(nam.c_str());
0131 }
0132
0133
0134 PlacedVolume BorderSurface::left() const {
0135 return (TGeoNode*)access()->GetNode1();
0136 }
0137
0138
0139 PlacedVolume BorderSurface::right() const {
0140 return access()->GetNode2();
0141 }
0142