Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:15:56

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022 Chao Peng, Whitney Armstrong
0003 
0004 #pragma once
0005 #include "Math/Point2D.h"
0006 #include <vector>
0007 
0008 // some utility functions that can be shared
0009 namespace epic::geo {
0010 
0011 using Point = ROOT::Math::XYPoint;
0012 
0013 /** Fill rectangles in a ring (disk).
0014    *
0015    * @param ref  2D reference point.
0016    * @param sx   x side length
0017    * @param sy   y side length
0018    * @param rmin inner radius of disk
0019    * @param rmax  outer radius of disk to fill
0020    * @param phmin  phi min
0021    * @param phmax phi max
0022    */
0023 std::vector<Point> fillRectangles(Point ref, double sx, double sy, double rmin, double rmax,
0024                                   double phmin = -M_PI, double phmax = M_PI);
0025 // fill squares in a ring
0026 inline std::vector<Point> fillSquares(Point ref, double size, double rmin, double rmax,
0027                                       double phmin = -M_PI, double phmax = M_PI) {
0028   return fillRectangles(ref, size, size, rmin, rmax, phmin, phmax);
0029 }
0030 
0031 std::vector<Point> fillHexagons(Point ref, double lside, double rmin, double rmax,
0032                                 double phmin = -M_PI, double phmax = M_PI);
0033 
0034 bool isPointInsidePolygon(Point p, std::vector<Point> vertices);
0035 
0036 bool isBoxTotalInsidePolygon(Point box[4], std::vector<Point> vertices);
0037 
0038 bool isBoxPartialInsidePolygon(Point box[4], std::vector<Point> vertices);
0039 
0040 std::vector<std::pair<double, double>>
0041 getPolygonVertices(std::pair<double, double> center, double radius, double angle_0, int numSides);
0042 
0043 } // namespace epic::geo