Warning, file /include/VecGeom/volumes/ReducedPolycone.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef VOLUMES_REDUCEDPOLYCONE_H_
0009 #define VOLUMES_REDUCEDPOLYCONE_H_
0010
0011 #include "VecGeom/base/Vector2D.h"
0012 #include "VecGeom/base/Vector.h"
0013 #include <iostream>
0014 #include "VecGeom/volumes/CoaxialCones.h"
0015
0016 namespace vecgeom {
0017
0018 VECGEOM_DEVICE_FORWARD_DECLARE(struct Line2D;);
0019 VECGEOM_DEVICE_DECLARE_CONV(struct, Line2D);
0020 VECGEOM_DEVICE_FORWARD_DECLARE(struct Section;);
0021 VECGEOM_DEVICE_DECLARE_CONV(struct, Section);
0022 VECGEOM_DEVICE_FORWARD_DECLARE(class ReducedPolycone;);
0023 VECGEOM_DEVICE_DECLARE_CONV(class, ReducedPolycone);
0024 VECGEOM_DEVICE_FORWARD_DECLARE(struct IndexStruct;);
0025 VECGEOM_DEVICE_DECLARE_CONV(struct, IndexStruct);
0026
0027 inline namespace VECGEOM_IMPL_NAMESPACE {
0028
0029 struct IndexStruct {
0030 unsigned int index{0};
0031 double distance{0.};
0032
0033 IndexStruct() = default;
0034 VECCORE_ATT_HOST_DEVICE
0035 IndexStruct(unsigned int ind, double dist) : index(ind), distance(dist) {}
0036 };
0037
0038
0039 struct Line2D {
0040 Vector2D<Precision> p1;
0041 Vector2D<Precision> p2;
0042
0043 VECCORE_ATT_HOST_DEVICE
0044 Line2D() {}
0045
0046 VECCORE_ATT_HOST_DEVICE
0047 ~Line2D() {}
0048
0049 VECCORE_ATT_HOST_DEVICE
0050 Line2D(Vector2D<Precision> p1v, Vector2D<Precision> p2v)
0051 {
0052 p1 = p1v;
0053 p2 = p2v;
0054 }
0055 #ifndef VECCORE_CUDA
0056 void Print()
0057 {
0058 std::cerr << p1 << " : ";
0059 std::cerr << p2 << std::endl;
0060 }
0061 #endif
0062 VECCORE_ATT_HOST_DEVICE
0063 Line2D(Precision rmax, Precision zval)
0064 {
0065 p1 = Vector2D<Precision>(0, zval);
0066 p2 = Vector2D<Precision>(rmax, zval);
0067 }
0068 VECCORE_ATT_HOST_DEVICE
0069 Precision GetHorizontalDistance(double yVal)
0070 {
0071 if (p1.x() == p2.x()) {
0072 return p1.x();
0073 } else {
0074 return p1.x() + ((p2.x() - p1.x()) / (p2.y() - p1.y())) * (yVal - p1.y());
0075 }
0076 }
0077 };
0078
0079
0080 struct Section {
0081 Precision rMin1;
0082 Precision rMax1;
0083 Precision rMin2;
0084 Precision rMax2;
0085 Precision z1;
0086 Precision z2;
0087
0088 VECCORE_ATT_HOST_DEVICE
0089 Section() {}
0090
0091 VECCORE_ATT_HOST_DEVICE
0092 ~Section() {}
0093
0094 VECCORE_ATT_HOST_DEVICE
0095 Section(Precision rmin1, Precision rmax1, Precision Z1, Precision rmin2, Precision rmax2, Precision Z2)
0096 : rMin1(rmin1), rMax1(rmax1), rMin2(rmin2), rMax2(rmax2), z1(Z1), z2(Z2)
0097 {
0098 }
0099 #ifndef VECCORE_CUDA
0100 void Print()
0101 {
0102
0103 std::cerr << "Rmin1 : " << rMin1 << " :: Rmax1 : " << rMax1 << " :: Z1 : " << z1 << std::endl
0104 << "Rmin2 : " << rMin2 << " :: Rmax2 : " << rMax2 << " :: Z2 : " << z2 << std::endl;
0105 }
0106 #endif
0107 };
0108
0109
0110
0111 class ReducedPolycone {
0112 Vector<Vector2D<Precision>> fRZVect;
0113 Precision fRMax;
0114
0115 Vector<Section> fSectionVect;
0116
0117
0118
0119 Vector<Vector<Section>> fCoaxialConesSectionVect;
0120
0121 public:
0122 VECCORE_ATT_HOST_DEVICE
0123 ReducedPolycone(Vector<Vector2D<Precision>> const &rzVect);
0124 VECCORE_ATT_HOST_DEVICE
0125 ~ReducedPolycone();
0126 VECCORE_ATT_HOST_DEVICE
0127 void SetRZ(Vector<Vector2D<Precision>> const &rzVect);
0128 VECCORE_ATT_HOST_DEVICE
0129 void SetRMax();
0130 VECCORE_ATT_HOST_DEVICE
0131 void ConvertToUniqueVector(Vector<Precision> &vect);
0132 VECCORE_ATT_HOST_DEVICE
0133 void GetUniqueZVector(Vector<Precision> &z);
0134 VECCORE_ATT_HOST_DEVICE
0135 void GetLineVector(Vector<Line2D> &lineVect);
0136 VECCORE_ATT_HOST_DEVICE
0137 void CalcPoIVectorFor2DPolygon(Vector<Vector2D<Precision>> &poiVect, Vector<Precision> const &z);
0138 VECCORE_ATT_HOST_DEVICE
0139 bool ContourCheck(Vector<Precision> const &z);
0140 VECCORE_ATT_HOST_DEVICE
0141 bool Contour(Vector<Precision> const &z);
0142 VECCORE_ATT_HOST_DEVICE
0143 bool ContourGeneric(Vector<Precision> const &z);
0144 VECCORE_ATT_HOST_DEVICE
0145 bool PointExist(Vector2D<Precision> const &pt);
0146 VECCORE_ATT_HOST_DEVICE
0147 void CreateNewContour();
0148 VECCORE_ATT_HOST_DEVICE
0149 void ProcessContour(Vector<Precision> const &z);
0150 VECCORE_ATT_HOST_DEVICE
0151 void ProcessGenericContour(Vector<Precision> const &z);
0152 VECCORE_ATT_HOST_DEVICE
0153 void GetRandZVectorAtDiffZ(Vector<Vector2D<Precision>> const &poiVect, Vector<Precision> &dz,
0154 Vector<Vector<Precision>> &supVect);
0155 VECCORE_ATT_HOST_DEVICE
0156 Section CreateSectionFromTwoLines(Line2D const &l1, Line2D const &l2);
0157 VECCORE_ATT_HOST_DEVICE
0158 void Swap(Precision &a, Precision &b);
0159 VECCORE_ATT_HOST_DEVICE
0160 bool Check();
0161 VECCORE_ATT_HOST_DEVICE
0162 bool CheckGeneric();
0163 VECCORE_ATT_HOST_DEVICE
0164 bool GetPolyconeParameters(Vector<Precision> &rmin, Vector<Precision> &rmax, Vector<Precision> &z);
0165
0166 VECCORE_ATT_HOST_DEVICE
0167 bool GetLineIntersection(Precision p0_x, Precision p0_y, Precision p1_x, Precision p1_y, Precision p2_x,
0168 Precision p2_y, Precision p3_x, Precision p3_y, Precision *i_x, Precision *i_y);
0169
0170 VECCORE_ATT_HOST_DEVICE
0171 bool GetLineIntersection(Line2D const &l1, Line2D const &l2);
0172
0173 VECCORE_ATT_HOST_DEVICE
0174 bool GetLineIntersection(Line2D const &l1, Line2D const &l2, Vector2D<Precision> &poi)
0175 {
0176
0177 if (l1.p2.x() == l2.p1.x() && l1.p2.y() == l2.p1.y()) {
0178 poi.x() = l1.p2.x();
0179 poi.y() = l1.p2.y();
0180 return true;
0181 }
0182 return GetLineIntersection(l1.p1.x(), l1.p1.y(), l1.p2.x(), l1.p2.y(), l2.p1.x(), l2.p1.y(), l2.p2.x(), l2.p2.y(),
0183 &poi.x(), &poi.y());
0184 }
0185
0186 VECCORE_ATT_HOST_DEVICE
0187 Vector<Line2D> FindLinesInASection(unsigned int secIndex);
0188
0189 VECCORE_ATT_HOST_DEVICE
0190 Vector<Line2D> GetVectorOfSortedLinesByHorizontalDistance(unsigned int secIndex);
0191
0192
0193
0194
0195
0196
0197
0198 VECCORE_ATT_HOST_DEVICE
0199 void GetPolyconeParameters(Vector<Vector<Precision>> &vectOfRmin1Vect, Vector<Vector<Precision>> &vectOfRmax1Vect,
0200 Vector<Vector<Precision>> &vectOfRmin2Vect, Vector<Vector<Precision>> &vectOfRmax2Vect,
0201 Vector<Precision> &zS, Vector3D<Precision> &aMin, Vector3D<Precision> &aMax);
0202 };
0203
0204 }
0205 }
0206
0207 #endif