Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /**
0002  * @file TubeTypes.h
0003  * @author Georgios Bitzes (georgios.bitzes@cern.ch)
0004  *
0005  * Contains all possible tube types
0006  **/
0007 
0008 #ifndef VECGEOM_VOLUMES_KERNEL_SHAPETYPES_TUBETYPES_H_
0009 #define VECGEOM_VOLUMES_KERNEL_SHAPETYPES_TUBETYPES_H_
0010 
0011 namespace vecgeom {
0012 
0013 VECGEOM_DEVICE_DECLARE_NS_CONV(TubeTypes, struct, UniversalTube, UniversalTube);
0014 
0015 #ifndef VECGEOM_NO_SPECIALIZATION
0016 
0017 VECGEOM_DEVICE_DECLARE_NS_CONV(TubeTypes, struct, NonHollowTube, UniversalTube);
0018 VECGEOM_DEVICE_DECLARE_NS_CONV(TubeTypes, struct, NonHollowTubeWithSmallerThanPiSector, UniversalTube);
0019 VECGEOM_DEVICE_DECLARE_NS_CONV(TubeTypes, struct, NonHollowTubeWithBiggerThanPiSector, UniversalTube);
0020 VECGEOM_DEVICE_DECLARE_NS_CONV(TubeTypes, struct, NonHollowTubeWithPiSector, UniversalTube);
0021 
0022 VECGEOM_DEVICE_DECLARE_NS_CONV(TubeTypes, struct, HollowTube, UniversalTube);
0023 VECGEOM_DEVICE_DECLARE_NS_CONV(TubeTypes, struct, HollowTubeWithSmallerThanPiSector, UniversalTube);
0024 VECGEOM_DEVICE_DECLARE_NS_CONV(TubeTypes, struct, HollowTubeWithBiggerThanPiSector, UniversalTube);
0025 VECGEOM_DEVICE_DECLARE_NS_CONV(TubeTypes, struct, HollowTubeWithPiSector, UniversalTube);
0026 
0027 #endif // VECGEOM_NO_SPECIALIZATION
0028 
0029 inline namespace VECGEOM_IMPL_NAMESPACE {
0030 namespace TubeTypes {
0031 
0032 #define DEFINE_TUBE_TYPE(name)                      \
0033   struct name {                                     \
0034     VECCORE_ATT_HOST_DEVICE                         \
0035     static char const *toString() { return #name; } \
0036   }
0037 
0038 // A tube that encompasses all cases - not specialized and will do extra checks at runtime
0039 DEFINE_TUBE_TYPE(UniversalTube);
0040 
0041 //#ifndef VECGEOM_NO_SPECIALIZATION
0042 
0043 // A tube not having rmin or phi sector
0044 DEFINE_TUBE_TYPE(NonHollowTube);
0045 // A tube without rmin but with a phi sector smaller than pi
0046 DEFINE_TUBE_TYPE(NonHollowTubeWithSmallerThanPiSector);
0047 // A tube without rmin but with a phi sector greater than pi
0048 DEFINE_TUBE_TYPE(NonHollowTubeWithBiggerThanPiSector);
0049 // A tube without rmin but with a phi sector equal to pi
0050 DEFINE_TUBE_TYPE(NonHollowTubeWithPiSector);
0051 
0052 // A tube with rmin and no phi sector
0053 DEFINE_TUBE_TYPE(HollowTube);
0054 // A tube with rmin and a phi sector smaller than pi
0055 DEFINE_TUBE_TYPE(HollowTubeWithSmallerThanPiSector);
0056 // A tube with rmin and a phi sector greater than pi
0057 DEFINE_TUBE_TYPE(HollowTubeWithBiggerThanPiSector);
0058 // A tube with rmin and a phi sector equal to pi
0059 DEFINE_TUBE_TYPE(HollowTubeWithPiSector);
0060 
0061 //#endif // VECGEOM_NO_SPECIALIZATION
0062 
0063 #undef DEFINE_TUBE_TYPE
0064 
0065 // Mapping of tube types to certain characteristics
0066 enum ETreatmentType { kYes = 0, kNo, kUnknown };
0067 
0068 // asking for phi treatment
0069 template <typename T>
0070 struct NeedsPhiTreatment {
0071   static const ETreatmentType value = kYes;
0072 };
0073 
0074 #ifndef VECGEOM_NO_SPECIALIZATION
0075 
0076 template <>
0077 struct NeedsPhiTreatment<NonHollowTube> {
0078   static const ETreatmentType value = kNo;
0079 };
0080 template <>
0081 struct NeedsPhiTreatment<HollowTube> {
0082   static const ETreatmentType value = kNo;
0083 };
0084 
0085 #endif // VECGEOM_NO_SPECIALIZATION
0086 
0087 template <>
0088 struct NeedsPhiTreatment<UniversalTube> {
0089   static const ETreatmentType value = kUnknown;
0090 };
0091 
0092 template <typename T, typename UnplacedTube>
0093 VECGEOM_FORCE_INLINE
0094 VECCORE_ATT_HOST_DEVICE
0095 bool checkPhiTreatment(const UnplacedTube &tube)
0096 {
0097   if (NeedsPhiTreatment<T>::value != kUnknown)
0098     return NeedsPhiTreatment<T>::value == kYes;
0099   else
0100     return tube.fDphi < vecgeom::kTwoPi;
0101 }
0102 
0103 // asking for rmin treatment
0104 template <typename T>
0105 struct NeedsRminTreatment {
0106   static const ETreatmentType value = kUnknown; // unknown will trigger real rmin check
0107 };
0108 
0109 #ifndef VECGEOM_NO_SPECIALIZATION
0110 
0111 template <>
0112 struct NeedsRminTreatment<NonHollowTube> {
0113   static const ETreatmentType value = kNo;
0114 };
0115 template <>
0116 struct NeedsRminTreatment<NonHollowTubeWithSmallerThanPiSector> {
0117   static const ETreatmentType value = kNo;
0118 };
0119 template <>
0120 struct NeedsRminTreatment<NonHollowTubeWithBiggerThanPiSector> {
0121   static const ETreatmentType value = kNo;
0122 };
0123 template <>
0124 struct NeedsRminTreatment<NonHollowTubeWithPiSector> {
0125   static const ETreatmentType value = kNo;
0126 };
0127 
0128 #endif // VECGEOM_NO_SPECIALIZATION
0129 
0130 template <>
0131 struct NeedsRminTreatment<UniversalTube> {
0132   static const ETreatmentType value = kUnknown;
0133 };
0134 
0135 template <typename T, typename UnplacedTube>
0136 VECGEOM_FORCE_INLINE
0137 VECCORE_ATT_HOST_DEVICE
0138 bool checkRminTreatment(const UnplacedTube &tube)
0139 {
0140   if (NeedsRminTreatment<T>::value != kUnknown)
0141     return NeedsRminTreatment<T>::value == kYes;
0142   else
0143     return tube.rmin() > 0;
0144 }
0145 
0146 // sector size
0147 enum EAngleType { kNoAngle = 0, kSmallerThanPi, kOnePi, kBiggerThanPi, kUnknownAngle };
0148 
0149 template <typename T>
0150 struct SectorType {
0151   static const EAngleType value = kNoAngle;
0152 };
0153 
0154 template <>
0155 struct SectorType<UniversalTube> {
0156   static const EAngleType value = kUnknownAngle;
0157 };
0158 
0159 #ifndef VECGEOM_NO_SPECIALIZATION
0160 
0161 template <>
0162 struct SectorType<NonHollowTubeWithSmallerThanPiSector> {
0163   static const EAngleType value = kSmallerThanPi;
0164 };
0165 
0166 template <>
0167 struct SectorType<NonHollowTubeWithPiSector> {
0168   static const EAngleType value = kOnePi;
0169 };
0170 
0171 template <>
0172 struct SectorType<NonHollowTubeWithBiggerThanPiSector> {
0173   static const EAngleType value = kBiggerThanPi;
0174 };
0175 template <>
0176 struct SectorType<HollowTubeWithSmallerThanPiSector> {
0177   static const EAngleType value = kSmallerThanPi;
0178 };
0179 
0180 template <>
0181 struct SectorType<HollowTubeWithPiSector> {
0182   static const EAngleType value = kOnePi;
0183 };
0184 
0185 template <>
0186 struct SectorType<HollowTubeWithBiggerThanPiSector> {
0187   static const EAngleType value = kBiggerThanPi;
0188 };
0189 
0190 #endif // VECGEOM_NO_SPECIALIZATION
0191 
0192 } // End namespace TubeTypes
0193 } // End VECGEOM_IMPL_NAMESPACE
0194 } // End global namespace vecgeom
0195 
0196 #endif // VECGEOM_VOLUMES_KERNEL_SHAPETYPES_TUBETYPES_H_