File indexing completed on 2025-01-30 10:26:15
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef VECGEOM_VOLUMES_SPECIALIZATIONS_TUBETRAITS_H_
0009 #define VECGEOM_VOLUMES_SPECIALIZATIONS_TUBETRAITS_H_
0010
0011 #include <string>
0012 #include <csignal>
0013
0014 namespace vecgeom {
0015 inline namespace VECGEOM_IMPL_NAMESPACE {
0016
0017 namespace TubeTraits {
0018
0019 #define DEFINE_TRAIT_TYPE(name) \
0020 struct name { \
0021 static std::string toString() { return #name; } \
0022 }
0023
0024
0025
0026 DEFINE_TRAIT_TYPE(UniversalTube);
0027
0028
0029 DEFINE_TRAIT_TYPE(NonHollowTube);
0030
0031 DEFINE_TRAIT_TYPE(NonHollowTubeWithSmallerThanPiSector);
0032
0033 DEFINE_TRAIT_TYPE(NonHollowTubeWithBiggerThanPiSector);
0034
0035 DEFINE_TRAIT_TYPE(NonHollowTubeWithPiSector);
0036
0037
0038 DEFINE_TRAIT_TYPE(HollowTube);
0039
0040 DEFINE_TRAIT_TYPE(HollowTubeWithSmallerThanPiSector);
0041
0042 DEFINE_TRAIT_TYPE(HollowTubeWithBiggerThanPiSector);
0043
0044 DEFINE_TRAIT_TYPE(HollowTubeWithPiSector);
0045
0046 #undef DEFINE_TRAIT_TYPE
0047
0048
0049 enum TreatmentType { YES = 0, NO, UNKNOWN };
0050
0051
0052 template <typename T>
0053 struct NeedsPhiTreatment {
0054 static const TreatmentType value = YES;
0055 };
0056 template <>
0057 struct NeedsPhiTreatment<NonHollowTube> {
0058 static const TreatmentType value = NO;
0059 };
0060 template <>
0061 struct NeedsPhiTreatment<HollowTube> {
0062 static const TreatmentType value = NO;
0063 };
0064 template <>
0065 struct NeedsPhiTreatment<UniversalTube> {
0066 static const TreatmentType value = UNKNOWN;
0067 };
0068
0069 template <typename T>
0070 VECGEOM_FORCE_INLINE
0071 bool checkPhiTreatment(const UnplacedTube &tube)
0072 {
0073 if (NeedsPhiTreatment<T>::value != UNKNOWN)
0074 return NeedsPhiTreatment<T>::value == YES;
0075 else
0076 return tube.dphi() < 2 * M_PI;
0077 }
0078
0079
0080 template <typename T>
0081 struct NeedsRminTreatment {
0082 static const TreatmentType value = YES;
0083 };
0084 template <>
0085 struct NeedsRminTreatment<NonHollowTube> {
0086 static const TreatmentType value = NO;
0087 };
0088 template <>
0089 struct NeedsRminTreatment<NonHollowTubeWithSmallerThanPiSector> {
0090 static const TreatmentType value = NO;
0091 };
0092 template <>
0093 struct NeedsRminTreatment<NonHollowTubeWithBiggerThanPiSector> {
0094 static const TreatmentType value = NO;
0095 };
0096 template <>
0097 struct NeedsRminTreatment<NonHollowTubeWithPiSector> {
0098 static const TreatmentType value = NO;
0099 };
0100 template <>
0101 struct NeedsRminTreatment<UniversalTube> {
0102 static const TreatmentType value = UNKNOWN;
0103 };
0104
0105 template <typename T>
0106 VECGEOM_FORCE_INLINE
0107 bool checkRminTreatment(const UnplacedTube &tube)
0108 {
0109 if (NeedsRminTreatment<T>::value != UNKNOWN)
0110 return NeedsRminTreatment<T>::value == YES;
0111 else
0112 return tube.rmin() > 0;
0113 }
0114
0115
0116 enum AngleType { NOANGLE = 0, SMALLER_THAN_PI, ONE_PI, BIGGER_THAN_PI, UNKNOWN_AT_COMPILE_TIME };
0117
0118 template <typename T>
0119 struct SectorType {
0120 static const AngleType value = NOANGLE;
0121 };
0122
0123 template <>
0124 struct SectorType<UniversalTube> {
0125 static const AngleType value = UNKNOWN_AT_COMPILE_TIME;
0126 };
0127
0128 template <>
0129 struct SectorType<NonHollowTubeWithSmallerThanPiSector> {
0130 static const AngleType value = SMALLER_THAN_PI;
0131 };
0132
0133 template <>
0134 struct SectorType<NonHollowTubeWithPiSector> {
0135 static const AngleType value = ONE_PI;
0136 };
0137
0138 template <>
0139 struct SectorType<NonHollowTubeWithBiggerThanPiSector> {
0140 static const AngleType value = BIGGER_THAN_PI;
0141 };
0142 template <>
0143 struct SectorType<HollowTubeWithSmallerThanPiSector> {
0144 static const AngleType value = SMALLER_THAN_PI;
0145 };
0146
0147 template <>
0148 struct SectorType<HollowTubeWithPiSector> {
0149 static const AngleType value = ONE_PI;
0150 };
0151
0152 template <>
0153 struct SectorType<HollowTubeWithBiggerThanPiSector> {
0154 static const AngleType value = BIGGER_THAN_PI;
0155 };
0156 }
0157
0158 }
0159
0160 #endif