Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-28 09:32:20

0001 /// \file VolumeFactory.h
0002 /// \author Johannes de Fine Licht (johannes.definelicht@cern.ch)
0003 
0004 #ifndef VECGEOM_MANAGEMENT_VOLUMEFACTORY_H_
0005 #define VECGEOM_MANAGEMENT_VOLUMEFACTORY_H_
0006 
0007 #include "VecGeom/volumes/PlacedVolume.h"
0008 #include "VecGeom/base/Transformation3D.h"
0009 #include "VecGeom/volumes/LogicalVolume.h"
0010 
0011 namespace vecgeom {
0012 inline namespace VECGEOM_IMPL_NAMESPACE {
0013 
0014 class VolumeFactory {
0015 
0016 public:
0017   static VolumeFactory &Instance()
0018   {
0019     static VolumeFactory instance;
0020     return instance;
0021   }
0022 
0023   // takes an existing placed volume and creates new one (changes its type) to a given Helper and ImplKernel
0024   // but keeps the transformation specialization properties
0025   // (used only internally)
0026   template <template <typename> class SpecializedHelper, typename ImplKernel>
0027   static VPlacedVolume *ChangeTypeKeepTransformation(VPlacedVolume const *);
0028 
0029 #ifndef VECCORE_CUDA
0030 
0031   template <typename VolumeType>
0032   static VPlacedVolume *CreateByTransformation(LogicalVolume const *const logical_volume,
0033                                                Transformation3D const *const transformation,
0034                                                VPlacedVolume *const placement = NULL);
0035 
0036 #else
0037 
0038   template <typename VolumeType>
0039   VECCORE_ATT_DEVICE static VPlacedVolume *CreateByTransformation(LogicalVolume const *const logical_volume,
0040                                                                   Transformation3D const *const transformation,
0041                                                                   const int id, const int copy_no, const int child_id,
0042                                                                   VPlacedVolume *const placement = NULL);
0043 
0044 #endif
0045 
0046 private:
0047   VolumeFactory() {}
0048   VolumeFactory(VolumeFactory const &);
0049   VolumeFactory &operator=(VolumeFactory const &);
0050 };
0051 
0052 template <typename VolumeType>
0053 VECCORE_ATT_DEVICE VPlacedVolume *VolumeFactory::CreateByTransformation(LogicalVolume const *const logical_volume,
0054                                                                         Transformation3D const *const transformation,
0055 #ifdef VECCORE_CUDA
0056                                                                         const int id, const int copy_no,
0057                                                                         const int child_id,
0058 #endif
0059                                                                         VPlacedVolume *const placement)
0060 {
0061   return VolumeType::Create(logical_volume, transformation,
0062 #ifdef VECCORE_CUDA
0063                             id, copy_no, child_id,
0064 #endif
0065                             placement);
0066 }
0067 
0068 template <template <typename> class SpecializedHelper, typename ImplKernel>
0069 VPlacedVolume *VolumeFactory::ChangeTypeKeepTransformation(VPlacedVolume const *pvol)
0070 {
0071   return new SpecializedHelper<ImplKernel>(pvol);
0072 }
0073 } // namespace VECGEOM_IMPL_NAMESPACE
0074 } // namespace vecgeom
0075 
0076 #endif // VECGEOM_MANAGEMENT_VOLUMEFACTORY_H_