File indexing completed on 2025-01-18 10:14:07
0001
0002
0003
0004 #ifndef VECGEOM_VOLUMES_GENERICPOLYCONESTRUCT_H_
0005 #define VECGEOM_VOLUMES_GENERICPOLYCONESTRUCT_H_
0006 #include "VecGeom/base/Global.h"
0007 #include "VecGeom/base/Vector3D.h"
0008 #include "VecGeom/base/Vector.h"
0009 #include "VecGeom/volumes/CoaxialConesStruct.h"
0010 #include "VecGeom/volumes/GenericPolyconeSection.h"
0011 namespace vecgeom {
0012
0013
0014
0015 inline namespace VECGEOM_IMPL_NAMESPACE {
0016
0017 template <typename T = double>
0018 struct GenericPolyconeStruct {
0019
0020
0021 Vector<Vector<T>> fVectOfRmin1Vect;
0022 Vector<Vector<T>> fVectOfRmax1Vect;
0023 Vector<Vector<T>> fVectOfRmin2Vect;
0024 Vector<Vector<T>> fVectOfRmax2Vect;
0025 Vector<T> fVectOfDz;
0026 T fSPhi;
0027 T fDPhi;
0028
0029 VECCORE_ATT_HOST_DEVICE
0030 GenericPolyconeStruct() {}
0031
0032 VECCORE_ATT_HOST_DEVICE
0033
0034 void Set(Vector<Vector<Precision>> vectOfRmin1Vect, Vector<Vector<Precision>> vectOfRmax1Vect,
0035 Vector<Vector<Precision>> vectOfRmin2Vect, Vector<Vector<Precision>> vectOfRmax2Vect, Vector<Precision> zS,
0036 Precision sPhi, Precision dPhi)
0037 {
0038 fSPhi = sPhi;
0039 fDPhi = dPhi;
0040 for (unsigned int i = 0; i < vectOfRmin1Vect.size(); i++) {
0041
0042
0043 GenericPolyconeSection section;
0044
0045 Precision dz = 0.5 * (zS[i + 1] - zS[i]);
0046 Precision shift = zS[i] + dz;
0047 CoaxialConesStruct<Precision> *coaxialCones = new CoaxialConesStruct<Precision>(
0048 vectOfRmin1Vect[i], vectOfRmax1Vect[i], vectOfRmin2Vect[i], vectOfRmax2Vect[i], dz, fSPhi, fDPhi);
0049 fCubicVolume += coaxialCones->Capacity();
0050 section.fShift = shift;
0051 section.fCoaxialCones = coaxialCones;
0052
0053
0054 fSections.push_back(section);
0055 }
0056 fZs = zS;
0057 fCubicVolume = Capacity();
0058 }
0059
0060
0061 Vector<GenericPolyconeSection> fSections;
0062
0063
0064
0065
0066
0067 Vector<Precision> fZs;
0068
0069 T fSurfaceArea;
0070 T fCubicVolume;
0071
0072
0073 #if (0)
0074 Precision ConicalSurfaceArea()
0075 {
0076 Precision conicalSurfaceArea = 0.;
0077 for (unsigned int i = 0; i < fSections.size(); i++) {
0078 conicalSurfaceArea += fSections[i].fCoaxialCones->ConicalSurfaceArea();
0079 }
0080 return conicalSurfaceArea;
0081 }
0082
0083 Precision SurfaceAreaOfZPlanes()
0084 {
0085 Precision surfaceAreaOfZPlanes = 0.;
0086 if (fSections.size() == 1) {
0087 return fSections[0].fCoaxialCones->SurfaceAreaOfZPlanes();
0088 } else if (fSections.size() > 1) {
0089 CoaxialConesStruct<Precision> *firstSectionCones = fSections[0].fCoaxialCones;
0090 CoaxialConesStruct<Precision> *lastSectionCones = fSections[fSections.size() - 1].fCoaxialCones;
0091 return (firstSectionCones->TotalSurfaceAreaOfLowerZPlanes() + lastSectionCones->TotalSurfaceAreaOfUpperZPlanes());
0092 }
0093
0094
0095
0096 }
0097 #endif
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115 VECCORE_ATT_HOST_DEVICE
0116 Precision Capacity()
0117 {
0118 Precision volume = 0.;
0119 for (unsigned int i = 0; i < fSections.size(); i++)
0120 volume += fSections[i].fCoaxialCones->Capacity();
0121 return volume;
0122 }
0123 #if (0)
0124 Precision SurfaceArea()
0125 {
0126
0127
0128
0129 return (ConicalSurfaceArea() + SurfaceAreaOfZPlanes());
0130 }
0131 #endif
0132 VECCORE_ATT_HOST_DEVICE
0133 int GetSectionIndex(Precision zposition) const
0134 {
0135
0136
0137 if (zposition < fZs[0]) return -1;
0138 for (unsigned int i = 0; i < fZs.size() - 1; ++i) {
0139 if (zposition >= fZs[i] && zposition <= fZs[i + 1]) return i;
0140 }
0141 return -2;
0142 }
0143
0144 VECCORE_ATT_HOST_DEVICE
0145 int GetNSections() const { return fSections.size(); }
0146
0147 VECCORE_ATT_HOST_DEVICE
0148 GenericPolyconeSection const &GetSection(Precision zposition) const
0149 {
0150
0151 int i = GetSectionIndex(zposition);
0152 return fSections[i];
0153 }
0154
0155 VECCORE_ATT_HOST_DEVICE
0156
0157 GenericPolyconeSection const &GetSection(int index) const { return fSections[index]; }
0158
0159 VECCORE_ATT_HOST_DEVICE
0160 Precision GetZAtPlane(unsigned int index) const
0161 {
0162 assert(index <= fSections.size());
0163 return fZs[index];
0164 }
0165 };
0166
0167 }
0168 }
0169
0170 #endif