1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
|
#ifndef VECGEOM_VOLUMES_UNPLACEDTUBE_H_
#define VECGEOM_VOLUMES_UNPLACEDTUBE_H_
#include "VecGeom/base/Cuda.h"
#include "VecGeom/base/Global.h"
#include "VecGeom/base/AlignedBase.h"
#include "VecGeom/volumes/UnplacedVolume.h"
#include "VecGeom/volumes/TubeStruct.h"
#include "VecGeom/volumes/kernel/TubeImplementation.h"
#include "VecGeom/volumes/Wedge.h"
#include "VecGeom/volumes/UnplacedVolumeImplHelper.h"
namespace vecgeom {
VECGEOM_DEVICE_FORWARD_DECLARE(class UnplacedTube;);
VECGEOM_DEVICE_DECLARE_CONV(class, UnplacedTube);
VECGEOM_DEVICE_DECLARE_CONV_TEMPLATE(class, SUnplacedTube, typename);
inline namespace VECGEOM_IMPL_NAMESPACE {
// Introduce Intermediate class ( so that we can do typecasting )
class UnplacedTube : public VUnplacedVolume {
private:
// tube defining parameters
TubeStruct<Precision> fTube;
public:
VECCORE_ATT_HOST_DEVICE
UnplacedTube(Precision const &_rmin, Precision const &_rmax, Precision const &_z, Precision const &_sphi,
Precision const &_dphi)
: fTube(_rmin, _rmax, _z, _sphi, _dphi)
{
DetectConvexity();
ComputeBBox();
}
VECCORE_ATT_HOST_DEVICE
TubeStruct<Precision> const &GetStruct() const { return fTube; }
VECCORE_ATT_HOST_DEVICE
void DetectConvexity();
VECCORE_ATT_HOST_DEVICE
VECGEOM_FORCE_INLINE
Precision rmin() const { return fTube.fRmin; }
VECCORE_ATT_HOST_DEVICE
VECGEOM_FORCE_INLINE
Precision rmax() const { return fTube.fRmax; }
VECCORE_ATT_HOST_DEVICE
VECGEOM_FORCE_INLINE
Precision z() const { return fTube.fZ; }
VECCORE_ATT_HOST_DEVICE
VECGEOM_FORCE_INLINE
Precision sphi() const { return fTube.fSphi; }
VECCORE_ATT_HOST_DEVICE
VECGEOM_FORCE_INLINE
Precision dphi() const { return fTube.fDphi; }
VECGEOM_FORCE_INLINE
void SetRMin(Precision const &_rmin) { fTube.SetRMin(_rmin); }
VECGEOM_FORCE_INLINE
void SetRMax(Precision const &_rmax) { fTube.SetRMax(_rmax); }
VECGEOM_FORCE_INLINE
void SetDz(Precision const &_z) { fTube.SetDz(_z); }
VECGEOM_FORCE_INLINE
void SetSPhi(Precision const &_sphi) { fTube.SetAndCheckSPhiAngle(_sphi); /*weird name*/ }
VECGEOM_FORCE_INLINE
void SetDPhi(Precision const &_dphi) { fTube.SetAndCheckDPhiAngle(_dphi); /*weird name*/ }
VECCORE_ATT_HOST_DEVICE
VECGEOM_FORCE_INLINE
evolution::Wedge const &GetWedge() const { return fTube.fPhiWedge; }
VECCORE_ATT_HOST_DEVICE
VECGEOM_FORCE_INLINE
Precision volume() const { return fTube.fZ * (fTube.fRmax2 - fTube.fRmin2) * fTube.fDphi; }
VECCORE_ATT_HOST_DEVICE
void Extent(Vector3D<Precision> &aMin, Vector3D<Precision> &aMax) const override;
Vector3D<Precision> SamplePointOnSurface() const override;
// VECCORE_ATT_HOST_DEVICE
Precision Capacity() const override { return volume(); }
// VECCORE_ATT_HOST_DEVICE
Precision SurfaceArea() const override
{
return GetTopArea() + GetLateralPhiArea() + GetLateralROutArea() + GetLateralRInArea();
}
// VECCORE_ATT_HOST_DEVICE
Precision GetTopArea() const
{ // Abhijit:: this is top and bottom circular area of tube
return 2 * 0.5 * (fTube.fRmax2 - fTube.fRmin2) * fTube.fDphi;
}
// VECCORE_ATT_HOST_DEVICE
Precision GetLateralPhiArea() const
{ // Abhijit:: this is vertical Phi_start and phi_end opening
// factor of 2 since fZ is half length
return (fTube.fDphi < kTwoPi) ? 4. * fTube.fZ * (fTube.fRmax - fTube.fRmin) : 0.;
}
// VECCORE_ATT_HOST_DEVICE
Precision GetLateralRInArea() const
{ // Abhijit:: this is Inner surface of tube along Z
// factor of 2 since fZ is half length
return 2. * fTube.fZ * fTube.fRmin * fTube.fDphi;
}
// VECCORE_ATT_HOST_DEVICE
Precision GetLateralROutArea() const
{ // Abhijit:: this is Outer surface of tube along Z
// factor of 2 since fZ is half length
return 2. * fTube.fZ * fTube.fRmax * fTube.fDphi;
}
// This computes where the random point would be placed
// 1::rTop, 2::rBot, 3::phiLeft, 4::phiRight, 5::zIn, 6::zOut
// VECCORE_ATT_HOST_DEVICE
int ChooseSurface() const;
VECCORE_ATT_HOST_DEVICE
bool Normal(Vector3D<Precision> const &point, Vector3D<Precision> &normal) const override;
VECCORE_ATT_HOST_DEVICE
virtual void Print() const override;
virtual void Print(std::ostream &os) const override;
#ifndef VECCORE_CUDA
virtual SolidMesh *CreateMesh3D(Transformation3D const &trans, size_t nSegments) const override;
#endif
std::string GetEntityType() const { return "Tube"; }
#ifdef VECGEOM_CUDA_INTERFACE
virtual size_t DeviceSizeOf() const override
{
return DevicePtr<cuda::SUnplacedTube<cuda::TubeTypes::UniversalTube>>::SizeOf();
}
virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const override;
virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const override;
#endif
};
template <>
struct Maker<UnplacedTube> {
template <typename... ArgTypes>
static UnplacedTube *MakeInstance(Precision const &_rmin, Precision const &_rmax, Precision const &_z,
Precision const &_sphi, Precision const &_dphi);
};
// this class finishes the implementation
template <typename TubeType = TubeTypes::UniversalTube>
class SUnplacedTube : public SIMDUnplacedVolumeImplHelper<TubeImplementation<TubeType>, UnplacedTube>,
public AlignedBase {
public:
using Kernel = TubeImplementation<TubeType>;
using BaseType_t = SIMDUnplacedVolumeImplHelper<TubeImplementation<TubeType>, UnplacedTube>;
using BaseType_t::BaseType_t;
template <TranslationCode transCodeT, RotationCode rotCodeT>
VECCORE_ATT_DEVICE
static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
#ifdef VECCORE_CUDA
const int id, const int copy_no, const int child_id,
#endif
VPlacedVolume *const placement = NULL);
#ifndef VECCORE_CUDA
virtual VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
Transformation3D const *const transformation,
const TranslationCode trans_code, const RotationCode rot_code,
VPlacedVolume *const placement = NULL) const override
{
return VolumeFactory::CreateByTransformation<SUnplacedTube<TubeType>>(volume, transformation, trans_code, rot_code,
placement);
}
#else
VECCORE_ATT_DEVICE
virtual VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
Transformation3D const *const transformation,
const TranslationCode trans_code, const RotationCode rot_code, const int id,
const int copy_no, const int child_id,
VPlacedVolume *const placement = NULL) const override
{
return VolumeFactory::CreateByTransformation<SUnplacedTube<TubeType>>(volume, transformation, trans_code, rot_code,
id, copy_no, child_id, placement);
}
#endif
};
using GenericUnplacedTube = SUnplacedTube<TubeTypes::UniversalTube>;
} // namespace VECGEOM_IMPL_NAMESPACE
} // namespace vecgeom
// we include this header here because SpecializedTube
// implements the Create function of SUnplacedTube<> (and to avoid a circular dependency)
#include "VecGeom/volumes/SpecializedTube.h"
#endif // VECGEOM_VOLUMES_UNPLACEDTUBE_H_
|