Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-03-13 09:29:29

0001 /*
0002  * ReducedPolycone.h
0003  *
0004  *  Created on: Sep 20, 2018
0005  *      Author: rasehgal
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 // A Container to store index and distance
0029 struct IndexStruct {
0030   unsigned int index;
0031   double distance;
0032   VECCORE_ATT_HOST_DEVICE
0033   IndexStruct(unsigned int ind, double dist) : index(ind), distance(dist) {}
0034 };
0035 
0036 // Just a Container for 2D Line
0037 struct Line2D {
0038   Vector2D<Precision> p1;
0039   Vector2D<Precision> p2;
0040 
0041   VECCORE_ATT_HOST_DEVICE
0042   Line2D() {}
0043 
0044   VECCORE_ATT_HOST_DEVICE
0045   ~Line2D() {}
0046 
0047   VECCORE_ATT_HOST_DEVICE
0048   Line2D(Vector2D<Precision> p1v, Vector2D<Precision> p2v)
0049   {
0050     p1 = p1v;
0051     p2 = p2v;
0052   }
0053 #ifndef VECCORE_CUDA
0054   void Print()
0055   {
0056     std::cout << p1 << " : ";
0057     std::cout << p2 << std::endl;
0058   }
0059 #endif
0060   VECCORE_ATT_HOST_DEVICE
0061   Line2D(Precision rmax, Precision zval)
0062   {
0063     p1 = Vector2D<Precision>(0, zval);
0064     p2 = Vector2D<Precision>(rmax, zval);
0065   }
0066   VECCORE_ATT_HOST_DEVICE
0067   Precision GetHorizontalDistance(double yVal)
0068   {
0069     if (p1.x() == p2.x()) {
0070       return p1.x();
0071     } else {
0072       return p1.x() + ((p2.x() - p1.x()) / (p2.y() - p1.y())) * (yVal - p1.y());
0073     }
0074   }
0075 };
0076 
0077 // Just a container for a Section
0078 struct Section {
0079   Precision rMin1;
0080   Precision rMax1;
0081   Precision rMin2;
0082   Precision rMax2;
0083   Precision z1;
0084   Precision z2;
0085 
0086   VECCORE_ATT_HOST_DEVICE
0087   Section() {}
0088 
0089   VECCORE_ATT_HOST_DEVICE
0090   ~Section() {}
0091 
0092   VECCORE_ATT_HOST_DEVICE
0093   Section(Precision rmin1, Precision rmax1, Precision Z1, Precision rmin2, Precision rmax2, Precision Z2)
0094       : rMin1(rmin1), rMax1(rmax1), rMin2(rmin2), rMax2(rmax2), z1(Z1), z2(Z2)
0095   {
0096   }
0097 #ifndef VECCORE_CUDA
0098   void Print()
0099   {
0100 
0101     std::cout << "Rmin1 : " << rMin1 << " :: Rmax1 : " << rMax1 << " :: Z1 : " << z1 << std::endl
0102               << "Rmin2 : " << rMin2 << " :: Rmax2 : " << rMax2 << " :: Z2 : " << z2 << std::endl;
0103   }
0104 #endif
0105 };
0106 
0107 // struct ConeParam;
0108 
0109 class ReducedPolycone {
0110   Vector<Vector2D<Precision>> fRZVect;
0111   Precision fRMax;
0112   // For SimplePolycone
0113   Vector<Section> fSectionVect;
0114 
0115   // For GenericPolycone
0116   // Vector<Section> fCoaxialCones;
0117   Vector<Vector<Section>> fCoaxialConesSectionVect;
0118 
0119 public:
0120   VECCORE_ATT_HOST_DEVICE
0121   ReducedPolycone(Vector<Vector2D<Precision>> rzVect);
0122   VECCORE_ATT_HOST_DEVICE
0123   ~ReducedPolycone();
0124   VECCORE_ATT_HOST_DEVICE
0125   void SetRZ(Vector<Vector2D<Precision>>);
0126   VECCORE_ATT_HOST_DEVICE
0127   void SetRMax();
0128   VECCORE_ATT_HOST_DEVICE
0129   void ConvertToUniqueVector(Vector<Precision> &vect);
0130   VECCORE_ATT_HOST_DEVICE
0131   Vector<Precision> GetUniqueZVector();
0132   VECCORE_ATT_HOST_DEVICE
0133   void PrintVector(Vector<Precision> vect);
0134   VECCORE_ATT_HOST_DEVICE
0135   Vector<Line2D> GetLineVector();
0136   VECCORE_ATT_HOST_DEVICE
0137   void CalcPoIVectorFor2DPolygon(Vector<Vector2D<Precision>> &poiVect, Vector<Precision> z);
0138   VECCORE_ATT_HOST_DEVICE
0139   bool ContourCheck(Vector<Precision> z);
0140   VECCORE_ATT_HOST_DEVICE
0141   bool Contour(Vector<Precision> z);
0142   VECCORE_ATT_HOST_DEVICE
0143   bool ContourGeneric(Vector<Precision> z);
0144   VECCORE_ATT_HOST_DEVICE
0145   bool PointExist(Vector2D<Precision> pt);
0146   VECCORE_ATT_HOST_DEVICE
0147   void CreateNewContour();
0148   VECCORE_ATT_HOST_DEVICE
0149   void ProcessContour(Vector<Precision> z);
0150   VECCORE_ATT_HOST_DEVICE
0151   void ProcessGenericContour(Vector<Precision> z);
0152   VECCORE_ATT_HOST_DEVICE
0153   Vector<Vector<Precision>> GetRandZVectorAtDiffZ(Vector<Vector2D<Precision>> poiVect, Vector<Precision> &dz);
0154   VECCORE_ATT_HOST_DEVICE
0155   Section CreateSectionFromTwoLines(Line2D l1, Line2D l2);
0156   VECCORE_ATT_HOST_DEVICE
0157   void Swap(Precision &a, Precision &b);
0158   VECCORE_ATT_HOST_DEVICE
0159   bool Check();
0160   VECCORE_ATT_HOST_DEVICE
0161   bool CheckGeneric();
0162   VECCORE_ATT_HOST_DEVICE
0163   bool GetPolyconeParameters(Vector<Precision> &rmin, Vector<Precision> &rmax, Vector<Precision> &z);
0164 
0165   VECCORE_ATT_HOST_DEVICE
0166   bool GetLineIntersection(Precision p0_x, Precision p0_y, Precision p1_x, Precision p1_y, Precision p2_x,
0167                            Precision p2_y, Precision p3_x, Precision p3_y, Precision *i_x, Precision *i_y);
0168 
0169   VECCORE_ATT_HOST_DEVICE
0170   bool GetLineIntersection(Line2D l1, Line2D l2);
0171 
0172   VECCORE_ATT_HOST_DEVICE
0173   bool GetLineIntersection(Line2D l1, Line2D l2, Vector2D<Precision> &poi)
0174   {
0175     // Vector2D<Precision>  poi(0.,0.);
0176     if (l1.p2.x() == l2.p1.x() && l1.p2.y() == l2.p1.y()) {
0177       poi.x() = l1.p2.x();
0178       poi.y() = l1.p2.y();
0179       return true;
0180     }
0181     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(),
0182                                &poi.x(), &poi.y());
0183   }
0184 
0185   VECCORE_ATT_HOST_DEVICE
0186   Vector<Line2D> FindLinesInASection(unsigned int secIndex);
0187 
0188   VECCORE_ATT_HOST_DEVICE
0189   Vector<Line2D> GetVectorOfSortedLinesByHorizontalDistance(unsigned int secIndex);
0190 
0191   /*
0192     VECCORE_ATT_HOST_DEVICE
0193     void GetPolyconeParameters(Vector<Vector<ConeParam>> &sectionsParamVector, Vector<Precision> &zS,
0194                                Vector3D<Precision> &aMin, Vector3D<Precision> &aMax);
0195   */
0196 
0197   VECCORE_ATT_HOST_DEVICE
0198   void GetPolyconeParameters(Vector<Vector<Precision>> &vectOfRmin1Vect, Vector<Vector<Precision>> &vectOfRmax1Vect,
0199                              Vector<Vector<Precision>> &vectOfRmin2Vect, Vector<Vector<Precision>> &vectOfRmax2Vect,
0200                              Vector<Precision> &zS, Vector3D<Precision> &aMin, Vector3D<Precision> &aMax);
0201 };
0202 
0203 } // namespace VECGEOM_IMPL_NAMESPACE
0204 } /* namespace vecgeom */
0205 
0206 #endif /* VOLUMES_REDUCEDPOLYCONE_H_ */