File indexing completed on 2026-09-23 09:29:54
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef VECGEOM_VOLUMES_LOGICALVOLUME_H_
0010 #define VECGEOM_VOLUMES_LOGICALVOLUME_H_
0011
0012 #include "VecGeom/base/Cuda.h"
0013 #include "VecGeom/base/Global.h"
0014 #include "VecGeom/base/Vector.h"
0015 #include "VecGeom/volumes/UnplacedVolume.h"
0016
0017 #include <string>
0018 #include <list>
0019 #include <set>
0020 #include <typeindex>
0021 #include <typeinfo>
0022
0023 class TGeoShape;
0024
0025 namespace vecgeom {
0026
0027 VECGEOM_DEVICE_FORWARD_DECLARE(class LogicalVolume;);
0028 VECGEOM_DEVICE_FORWARD_DECLARE(class VPlacedVolume;);
0029 VECGEOM_DEVICE_FORWARD_DECLARE(class VLevelLocator;);
0030 VECGEOM_DEVICE_FORWARD_DECLARE(class VSafetyEstimator;);
0031 VECGEOM_DEVICE_FORWARD_DECLARE(class VNavigator;);
0032
0033 VECGEOM_DEVICE_DECLARE_CONV(class, LogicalVolume);
0034 class GeoManager;
0035
0036 inline namespace VECGEOM_IMPL_NAMESPACE {
0037
0038 class VLevelLocator;
0039 class VSafetyEstimator;
0040 class VNavigator;
0041 typedef VPlacedVolume const *Daughter;
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054 class LogicalVolume {
0055 friend class vecgeom::GeoManager;
0056
0057 private:
0058
0059 VUnplacedVolume const *fUnplacedVolume;
0060
0061 unsigned int fId;
0062
0063 std::string *fLabel;
0064
0065 static int gIdCount;
0066
0067
0068
0069 VLevelLocator const *fLevelLocator;
0070 VSafetyEstimator const *fSafetyEstimator;
0071 VNavigator const *fNavigator;
0072
0073
0074 Vector<Daughter> *fDaughters;
0075
0076 using CudaDaughter_t = cuda::VPlacedVolume const *;
0077 friend class CudaManager;
0078
0079
0080
0081
0082 public:
0083
0084 LogicalVolume(char const *const label, VUnplacedVolume const *const unplaced_vol);
0085
0086
0087 LogicalVolume(VUnplacedVolume const *const unplaced_vol) : LogicalVolume("", unplaced_vol) {}
0088
0089 #ifndef VECCORE_CUDA
0090
0091 LogicalVolume(LogicalVolume const &other) = delete;
0092 LogicalVolume *operator=(LogicalVolume const &other) = delete;
0093
0094 #else
0095 VECCORE_ATT_DEVICE
0096 LogicalVolume(VUnplacedVolume const *const unplaced_vol, unsigned int id, Vector<Daughter> *GetDaughter);
0097 #endif
0098
0099 ~LogicalVolume();
0100
0101
0102 VECCORE_ATT_HOST_DEVICE
0103 VECGEOM_FORCE_INLINE
0104 VUnplacedVolume const *GetUnplacedVolume() const { return fUnplacedVolume; }
0105
0106
0107
0108 VECCORE_ATT_HOST_DEVICE
0109 VECGEOM_FORCE_INLINE
0110 Vector<Daughter> const &GetDaughters() const { return *fDaughters; }
0111
0112
0113
0114 VECCORE_ATT_HOST_DEVICE
0115 VECGEOM_FORCE_INLINE
0116 Vector<Daughter> const *GetDaughtersp() const { return fDaughters; }
0117
0118
0119 VECCORE_ATT_HOST_DEVICE
0120 VECGEOM_FORCE_INLINE
0121 Vector<Daughter> *GetDaughtersp() { return fDaughters; }
0122
0123
0124 VECCORE_ATT_HOST_DEVICE
0125 VECGEOM_FORCE_INLINE
0126 bool IsReqCaching() const { return false; }
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137 size_t GetNTotal() const;
0138
0139
0140 static unsigned int GetIdCount() { return (unsigned int)gIdCount; }
0141
0142
0143 VECCORE_ATT_HOST_DEVICE
0144 VECGEOM_FORCE_INLINE
0145 VLevelLocator const *GetLevelLocator() const { return fLevelLocator; }
0146
0147
0148 VECCORE_ATT_HOST_DEVICE
0149 VECGEOM_FORCE_INLINE
0150 void SetLevelLocator(VLevelLocator const *locator) { fLevelLocator = locator; }
0151
0152
0153 VECCORE_ATT_HOST_DEVICE
0154 VECGEOM_FORCE_INLINE
0155 VSafetyEstimator const *GetSafetyEstimator() const { return fSafetyEstimator; }
0156
0157
0158 VECCORE_ATT_HOST_DEVICE
0159 VECGEOM_FORCE_INLINE
0160 void SetSafetyEstimator(VSafetyEstimator const *est) { fSafetyEstimator = est; }
0161
0162
0163 VECCORE_ATT_HOST_DEVICE
0164 VECGEOM_FORCE_INLINE
0165 VNavigator const *GetNavigator() const { return fNavigator; }
0166
0167
0168 VECCORE_ATT_HOST_DEVICE
0169 VECGEOM_FORCE_INLINE
0170 void SetNavigator(VNavigator const *n) { fNavigator = n; }
0171
0172
0173 VECCORE_ATT_HOST_DEVICE
0174 VECGEOM_FORCE_INLINE
0175 unsigned int id() const { return fId; }
0176
0177
0178 VECCORE_ATT_HOST_DEVICE
0179 const char *GetName() const
0180 {
0181 #ifndef VECCORE_CUDA
0182 return fLabel->c_str();
0183 #else
0184 return "- Names unavailable on GPU -";
0185 #endif
0186 }
0187
0188 std::string const &GetLabel() const { return *fLabel; }
0189
0190
0191 void SetLabel(char const *const label)
0192 {
0193 if (fLabel) delete fLabel;
0194 fLabel = new std::string(label);
0195 }
0196
0197
0198 VECCORE_ATT_HOST_DEVICE
0199 void Print(const int indent = 0) const;
0200
0201
0202
0203 VECCORE_ATT_HOST_DEVICE
0204 void PrintContent(const int depth = 0) const;
0205
0206
0207 VPlacedVolume *Place(char const *const label, Transformation3D const *const transformation) const;
0208
0209
0210 VPlacedVolume *Place(Transformation3D const *const transformation) const;
0211
0212
0213 VPlacedVolume *Place(char const *const label) const;
0214
0215
0216 VPlacedVolume *Place() const;
0217
0218
0219
0220
0221
0222 VPlacedVolume const *PlaceDaughter(char const *const label, LogicalVolume *const volume,
0223 Transformation3D const *const transformation);
0224
0225
0226
0227
0228 VPlacedVolume const *PlaceDaughter(LogicalVolume *const volume, Transformation3D const *const transformation);
0229
0230
0231 void PlaceDaughter(VPlacedVolume *const placed);
0232
0233
0234 bool ContainsAssembly() const;
0235
0236 friend std::ostream &operator<<(std::ostream &os, LogicalVolume const &vol);
0237
0238 #ifdef VECGEOM_CUDA_INTERFACE
0239 DevicePtr<cuda::LogicalVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const unplaced_vol, int id,
0240 DevicePtr<cuda::Vector<CudaDaughter_t>> GetDaughter) const;
0241 DevicePtr<cuda::LogicalVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const unplaced_vol, int id,
0242 DevicePtr<cuda::Vector<CudaDaughter_t>> GetDaughter,
0243 DevicePtr<cuda::LogicalVolume> const gpu_ptr) const;
0244 #endif
0245
0246 private:
0247 std::set<LogicalVolume *> GetSetOfDaughterLogicalVolumes() const;
0248
0249 };
0250
0251 #ifdef VECCORE_CUDA
0252 inline LogicalVolume::LogicalVolume(char const *const, VUnplacedVolume const *const)
0253 {
0254 assert(0 && "Cannot construct in CUDA");
0255 }
0256 #endif
0257
0258 }
0259 }
0260
0261 #endif