File indexing completed on 2025-01-18 10:14:07
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
0035 inline namespace VECGEOM_IMPL_NAMESPACE {
0036
0037 class Region;
0038
0039
0040 class VLevelLocator;
0041 class VSafetyEstimator;
0042 class VNavigator;
0043 typedef VPlacedVolume const *Daughter;
0044 class GeoManager;
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057 class LogicalVolume {
0058 friend class GeoManager;
0059
0060 private:
0061
0062 VUnplacedVolume const *fUnplacedVolume;
0063
0064 unsigned int fId;
0065
0066 std::string *fLabel;
0067
0068 static int gIdCount;
0069
0070
0071
0072
0073
0074
0075 void *fUserExtensionPtr;
0076
0077 void *fMaterialPtr;
0078
0079 void *fMaterialCutsPtr;
0080
0081 void *fBasketManagerPtr;
0082
0083 Region *fRegion = nullptr;
0084
0085
0086
0087 VLevelLocator const *fLevelLocator;
0088 VSafetyEstimator const *fSafetyEstimator;
0089 VNavigator const *fNavigator;
0090
0091
0092 Vector<Daughter> *fDaughters;
0093
0094 using CudaDaughter_t = cuda::VPlacedVolume const *;
0095 friend class CudaManager;
0096
0097
0098
0099
0100 public:
0101 #ifndef VECCORE_CUDA
0102
0103 LogicalVolume(char const *const label, VUnplacedVolume const *const unplaced_vol);
0104
0105
0106 LogicalVolume(VUnplacedVolume const *const unplaced_vol) : LogicalVolume("", unplaced_vol) {}
0107
0108
0109 LogicalVolume(LogicalVolume const &other) = delete;
0110 LogicalVolume *operator=(LogicalVolume const &other) = delete;
0111
0112 #else
0113 VECCORE_ATT_DEVICE
0114 LogicalVolume(VUnplacedVolume const *const unplaced_vol,
0115 unsigned int id, Vector<Daughter> *GetDaughter);
0116 #endif
0117
0118 ~LogicalVolume();
0119
0120
0121 VECCORE_ATT_HOST_DEVICE
0122 VECGEOM_FORCE_INLINE
0123 VUnplacedVolume const *GetUnplacedVolume() const { return fUnplacedVolume; }
0124
0125
0126
0127 VECCORE_ATT_HOST_DEVICE
0128 VECGEOM_FORCE_INLINE
0129 Vector<Daughter> const &GetDaughters() const { return *fDaughters; }
0130
0131
0132
0133 VECCORE_ATT_HOST_DEVICE
0134 VECGEOM_FORCE_INLINE
0135 Vector<Daughter> const *GetDaughtersp() const { return fDaughters; }
0136
0137
0138 VECCORE_ATT_HOST_DEVICE
0139 VECGEOM_FORCE_INLINE
0140 Vector<Daughter> *GetDaughtersp() { return fDaughters; }
0141
0142
0143 VECCORE_ATT_HOST_DEVICE
0144 VECGEOM_FORCE_INLINE
0145 bool IsReqCaching() const { return false; }
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156 size_t GetNTotal() const;
0157
0158
0159 static unsigned int GetIdCount() { return (unsigned int)gIdCount; }
0160
0161
0162 VECGEOM_FORCE_INLINE
0163 void *GetUserExtensionPtr() const { return fUserExtensionPtr; }
0164
0165
0166 VECCORE_ATT_HOST_DEVICE
0167 VECGEOM_FORCE_INLINE
0168 void *GetMaterialPtr() const { return fMaterialPtr; }
0169
0170
0171 VECCORE_ATT_HOST_DEVICE
0172 VECGEOM_FORCE_INLINE
0173 void *GetMaterialCutsPtr() const { return fMaterialCutsPtr; }
0174
0175
0176 VECCORE_ATT_HOST_DEVICE
0177 VECGEOM_FORCE_INLINE
0178 void *GetBasketManagerPtr() const { return fBasketManagerPtr; }
0179
0180
0181 VECCORE_ATT_HOST_DEVICE
0182 VECGEOM_FORCE_INLINE
0183 VLevelLocator const *GetLevelLocator() const { return fLevelLocator; }
0184
0185
0186 VECCORE_ATT_HOST_DEVICE
0187 VECGEOM_FORCE_INLINE
0188 void SetLevelLocator(VLevelLocator const *locator) { fLevelLocator = locator; }
0189
0190
0191 VECCORE_ATT_HOST_DEVICE
0192 VECGEOM_FORCE_INLINE
0193 VSafetyEstimator const *GetSafetyEstimator() const { return fSafetyEstimator; }
0194
0195
0196 VECCORE_ATT_HOST_DEVICE
0197 VECGEOM_FORCE_INLINE
0198 void SetSafetyEstimator(VSafetyEstimator const *est) { fSafetyEstimator = est; }
0199
0200
0201 VECCORE_ATT_HOST_DEVICE
0202 VECGEOM_FORCE_INLINE
0203 VNavigator const *GetNavigator() const { return fNavigator; }
0204
0205
0206 VECCORE_ATT_HOST_DEVICE
0207 VECGEOM_FORCE_INLINE
0208 void SetNavigator(VNavigator const *n) { fNavigator = n; }
0209
0210
0211 VECCORE_ATT_HOST_DEVICE
0212 VECGEOM_FORCE_INLINE
0213 unsigned int id() const { return fId; }
0214
0215
0216 VECCORE_ATT_HOST_DEVICE
0217 const char *GetName() const
0218 {
0219 #ifndef VECCORE_CUDA
0220 return fLabel->c_str();
0221 #else
0222 return "- Names unavailable on GPU -";
0223 #endif
0224 }
0225
0226 std::string const &GetLabel() const { return *fLabel; }
0227
0228
0229 void SetLabel(char const *const label)
0230 {
0231 if (fLabel) delete fLabel;
0232 fLabel = new std::string(label);
0233 }
0234
0235
0236 VECGEOM_FORCE_INLINE
0237 void SetUserExtensionPtr(void *userpointer) { fUserExtensionPtr = userpointer; }
0238
0239
0240 VECGEOM_FORCE_INLINE
0241 void SetMaterialPtr(void *matpointer) { fMaterialPtr = matpointer; }
0242
0243
0244 VECGEOM_FORCE_INLINE
0245 void SetMaterialCutsPtr(void *matcutpointer) { fMaterialCutsPtr = matcutpointer; }
0246
0247
0248 VECGEOM_FORCE_INLINE
0249 VECCORE_ATT_HOST_DEVICE
0250 void SetBasketManagerPtr(void *basketpointer) { fBasketManagerPtr = basketpointer; }
0251
0252
0253 VECCORE_ATT_HOST_DEVICE
0254 void Print(const int indent = 0) const;
0255
0256
0257
0258 VECCORE_ATT_HOST_DEVICE
0259 void PrintContent(const int depth = 0) const;
0260
0261
0262 VPlacedVolume *Place(char const *const label, Transformation3D const *const transformation) const;
0263
0264
0265 VPlacedVolume *Place(Transformation3D const *const transformation) const;
0266
0267
0268 VPlacedVolume *Place(char const *const label) const;
0269
0270
0271 VPlacedVolume *Place() const;
0272
0273
0274
0275
0276
0277 VPlacedVolume const *PlaceDaughter(char const *const label, LogicalVolume *const volume,
0278 Transformation3D const *const transformation);
0279
0280
0281
0282
0283 VPlacedVolume const *PlaceDaughter(LogicalVolume *const volume, Transformation3D const *const transformation);
0284
0285
0286 void PlaceDaughter(VPlacedVolume *const placed);
0287
0288
0289 bool ContainsAssembly() const;
0290
0291 friend std::ostream &operator<<(std::ostream &os, LogicalVolume const &vol);
0292
0293
0294 Region *GetRegion() { return fRegion; }
0295
0296
0297
0298
0299
0300
0301
0302 void SetRegion(Region *region, bool pushdown = true);
0303
0304 #ifdef VECGEOM_CUDA_INTERFACE
0305 DevicePtr<cuda::LogicalVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const unplaced_vol, int id,
0306 DevicePtr<cuda::Vector<CudaDaughter_t>> GetDaughter) const;
0307 DevicePtr<cuda::LogicalVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const unplaced_vol, int id,
0308 DevicePtr<cuda::Vector<CudaDaughter_t>> GetDaughter,
0309 DevicePtr<cuda::LogicalVolume> const gpu_ptr) const;
0310 #endif
0311
0312 private:
0313 std::set<LogicalVolume *> GetSetOfDaughterLogicalVolumes() const;
0314
0315 };
0316
0317 inline void LogicalVolume::SetRegion(Region *region, bool pushdown)
0318 {
0319 fRegion = region;
0320 if (pushdown) {
0321 for (auto &lv : GetSetOfDaughterLogicalVolumes()) {
0322 lv->SetRegion(region, true);
0323 }
0324 }
0325 }
0326
0327 }
0328 }
0329
0330 #endif