Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:13:56

0001 // This file is part of VecGeom and is distributed under the
0002 // conditions in the file LICENSE.txt in the top directory.
0003 // For the full list of authors see CONTRIBUTORS.txt and `git log`.
0004 
0005 /// \author created by Sandro Wenzel
0006 
0007 #ifndef VECGEOM_MANAGEMENT_FLATVOXELMANAGER_H_
0008 #define VECGEOM_MANAGEMENT_FLATVOXELMANAGER_H_
0009 
0010 #include "VecGeom/base/Global.h"
0011 #include "VecGeom/volumes/PlacedVolume.h"
0012 #include "VecGeom/volumes/LogicalVolume.h"
0013 #include "VecGeom/base/Vector3D.h"
0014 #include "VecGeom/management/GeoManager.h"
0015 #include "VecGeom/base/FlatVoxelHashMap.h"
0016 #include <vector>
0017 
0018 namespace vecgeom {
0019 inline namespace VECGEOM_IMPL_NAMESPACE {
0020 
0021 class VPlacedVolume;
0022 
0023 // A singleton class which manages structures for fast voxelized safety lookup
0024 class FlatVoxelManager {
0025 
0026 public:
0027   // the actual class encapsulating the Embree structures
0028   struct VoxelStructure {
0029     FlatVoxelHashMap<float, true> *fVoxels = nullptr; // voxels keeping track of best known safety
0030     FlatVoxelHashMap<int, false> *fVoxelToCandidate =
0031         nullptr; // keep list of candidate objects to check for safety (-1 = mother, ...)
0032     FlatVoxelHashMap<int, false> *fVoxelToLocateCandidates =
0033         nullptr; // keep list of candidate objects to check for LevelLocate
0034 
0035     LogicalVolume const *fVol = nullptr; // keep track to which volume this belongs
0036   };
0037 
0038 private:
0039   // keeps/registers an acceleration structure for logical volumes
0040   std::vector<VoxelStructure const *> fStructureHolder;
0041 
0042 public:
0043   // initialized the helper structure for a given logical volume
0044   void InitStructure(LogicalVolume const *lvol);
0045 
0046   static FlatVoxelManager &Instance()
0047   {
0048     static FlatVoxelManager manager;
0049     return manager;
0050   }
0051 
0052   // removed/deletes the helper structure for a given logical volume
0053   void RemoveStructure(LogicalVolume const *lvol);
0054 
0055   VoxelStructure const *GetStructure(LogicalVolume const *lvol) const { return fStructureHolder[lvol->id()]; }
0056 
0057   static VoxelStructure *BuildStructure(LogicalVolume const *lvol);
0058 
0059   static FlatVoxelHashMap<int, false> *BuildLocateVoxels(LogicalVolume const *lvol);
0060   static FlatVoxelHashMap<int, false> *BuildSafetyVoxels(LogicalVolume const *lvol);
0061 }; // end class
0062 } // namespace VECGEOM_IMPL_NAMESPACE
0063 } // namespace vecgeom
0064 
0065 #endif /* MANAGEMENT_FLATVOXELMANAGER_H_ */