Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-27 09:12:21

0001 /**
0002  *  @file   PandoraSDK/include/Geometry/DetectorGap.h
0003  * 
0004  *  @brief  Header file for the detector gap class.
0005  * 
0006  *  $Log: $
0007  */
0008 #ifndef PANDORA_DETECTOR_GAP_H
0009 #define PANDORA_DETECTOR_GAP_H 1
0010 
0011 #include "Pandora/ObjectCreation.h"
0012 
0013 namespace pandora
0014 {
0015 
0016 typedef std::vector<CartesianVector> VertexPointList;
0017 template<typename T, typename S> class PandoraObjectFactory;
0018 
0019 //------------------------------------------------------------------------------------------------------------------------------------------
0020 
0021 /**
0022  *  @brief  DetectorGap class
0023  */
0024 class DetectorGap
0025 {
0026 public:
0027     /**
0028      *  @brief  Destructor
0029      */
0030     virtual ~DetectorGap();
0031 
0032     /**
0033      *  @brief  Whether a specified position lies within the gap
0034      * 
0035      *  @param  positionVector the position vector
0036      *  @param  hitType the hit type, providing context to aid interpretation of provided position vector
0037      *  @param  gapTolerance tolerance allowed when declaring a point to be "in" a gap region, units mm
0038      * 
0039      *  @return boolean
0040      */
0041     virtual bool IsInGap(const CartesianVector &positionVector, const HitType hitType, const float gapTolerance = 0.f) const = 0;
0042 };
0043 
0044 //------------------------------------------------------------------------------------------------------------------------------------------
0045 
0046 /**
0047  *  @brief  LineGap class, associated only with 2D TPC hit types and applied only to the z coordinate when sampling position vectors
0048  */
0049 class LineGap : public DetectorGap
0050 {
0051 public:
0052     bool IsInGap(const CartesianVector &positionVector, const HitType hitType, const float gapTolerance) const;
0053 
0054     /**
0055      *  @brief  Get the line gap type
0056      * 
0057      *  @param  the line gap type
0058      */
0059     LineGapType GetLineGapType() const;
0060 
0061     /**
0062      *  @brief  Get the line start x coordinate
0063      * 
0064      *  @param  the line start x coordinate
0065      */
0066     float GetLineStartX() const;
0067 
0068     /**
0069      *  @brief  Get the line end x coordinate
0070      * 
0071      *  @param  the line end x coordinate
0072      */
0073     float GetLineEndX() const;
0074 
0075     /**
0076      *  @brief  Get the line start z coordinate
0077      * 
0078      *  @param  the line start z coordinate
0079      */
0080     float GetLineStartZ() const;
0081 
0082     /**
0083      *  @brief  Get the line end z coordinate
0084      * 
0085      *  @param  the line end z coordinate
0086      */
0087     float GetLineEndZ() const;
0088 
0089 private:
0090     /**
0091      *  @brief  Constructor
0092      * 
0093      *  @param  parameters the gap parameters
0094      */
0095     LineGap(const object_creation::Geometry::LineGap::Parameters &parameters);
0096 
0097     const LineGapType       m_lineGapType;          ///< The type of line gap, e.g. TPC wire-type gap (u, v, w), or drift-type gap
0098     const float             m_lineStartX;           ///< The line x start coordinate, units mm
0099     const float             m_lineEndX;             ///< The line x end coordinate, units mm
0100     const float             m_lineStartZ;           ///< The line z start coordinate, units mm
0101     const float             m_lineEndZ;             ///< The line z end coordinate, units mm
0102 
0103     friend class PandoraObjectFactory<object_creation::Geometry::LineGap::Parameters, object_creation::Geometry::LineGap::Object>;
0104 };
0105 
0106 //------------------------------------------------------------------------------------------------------------------------------------------
0107 
0108 /**
0109  *  @brief  BoxGap class, associated with all 3D hit types
0110  */
0111 class BoxGap : public DetectorGap
0112 {
0113 public:
0114     bool IsInGap(const CartesianVector &positionVector, const HitType hitType, const float gapTolerance) const;
0115 
0116     /**
0117      *  @brief  Get the gap vertex
0118      * 
0119      *  @param  the gap vertex
0120      */
0121     const CartesianVector &GetVertex() const;
0122 
0123     /**
0124      *  @brief  Get the vector describing first side meeting vertex
0125      * 
0126      *  @param  the vector describing first side meeting vertex
0127      */
0128     const CartesianVector &GetSide1() const;
0129 
0130     /**
0131      *  @brief  Get the vector describing second side meeting vertex
0132      * 
0133      *  @param  the vector describing second side meeting vertex
0134      */
0135     const CartesianVector &GetSide2() const;
0136 
0137     /**
0138      *  @brief  Get the vector describing third side meeting vertex
0139      * 
0140      *  @param  the vector describing third side meeting vertex
0141      */
0142     const CartesianVector &GetSide3() const;
0143 
0144 private:
0145     /**
0146      *  @brief  Constructor
0147      * 
0148      *  @param  parameters the gap parameters
0149      */
0150     BoxGap(const object_creation::Geometry::BoxGap::Parameters &parameters);
0151 
0152     const CartesianVector   m_vertex;               ///< Cartesian coordinates of a gap vertex, units mm
0153     const CartesianVector   m_side1;                ///< Cartesian vector describing first side meeting vertex, units mm
0154     const CartesianVector   m_side2;                ///< Cartesian vector describing second side meeting vertex, units mm
0155     const CartesianVector   m_side3;                ///< Cartesian vector describing third side meeting vertex, units mm
0156 
0157     friend class PandoraObjectFactory<object_creation::Geometry::BoxGap::Parameters, object_creation::Geometry::BoxGap::Object>;
0158 };
0159 
0160 //------------------------------------------------------------------------------------------------------------------------------------------
0161 
0162 /**
0163  *  @brief  ConcentricGap class, associated with all 3D hit types
0164  */
0165 class ConcentricGap : public DetectorGap
0166 {
0167 public:
0168     bool IsInGap(const CartesianVector &positionVector, const HitType hitType, const float gapTolerance) const;
0169 
0170     /**
0171      *  @brief  Get the min cylindrical polar z coordinate, origin interaction point
0172      * 
0173      *  @param  the min cylindrical polar z coordinate
0174      */
0175     float GetMinZCoordinate() const;
0176 
0177     /**
0178      *  @brief  Get the max cylindrical polar z coordinate, origin interaction point
0179      * 
0180      *  @param  the max cylindrical polar z coordinate
0181      */
0182     float GetMaxZCoordinate() const;
0183 
0184     /**
0185      *  @brief  Get the inner cylindrical polar r coordinate, origin interaction point
0186      * 
0187      *  @param  the inner cylindrical polar r coordinate
0188      */
0189     float GetInnerRCoordinate() const;
0190 
0191     /**
0192      *  @brief  Get the inner cylindrical polar phi coordinate
0193      * 
0194      *  @param  the inner cylindrical polar phi coordinate
0195      */
0196     float GetInnerPhiCoordinate() const;
0197 
0198     /**
0199      *  @brief  Get the order of symmetry of the innermost edge of gap
0200      * 
0201      *  @param  the order of symmetry of the innermost edge of gap
0202      */
0203     unsigned int GetInnerSymmetryOrder() const;
0204 
0205     /**
0206      *  @brief  Get the outer cylindrical polar r coordinate, origin interaction point
0207      * 
0208      *  @param  the outer cylindrical polar r coordinate
0209      */
0210     float GetOuterRCoordinate() const;
0211 
0212     /**
0213      *  @brief  Get the outer cylindrical polar phi coordinate
0214      * 
0215      *  @param  the outer cylindrical polar phi coordinate
0216      */
0217     float GetOuterPhiCoordinate() const;
0218 
0219     /**
0220      *  @brief  Get the order of symmetry of the outermost edge of gap
0221      * 
0222      *  @param  the order of symmetry of the outermost edge of gap
0223      */
0224     unsigned int GetOuterSymmetryOrder() const;
0225 
0226 private:
0227     /**
0228      *  @brief  Constructor
0229      * 
0230      *  @param  parameters the gap parameters
0231      */
0232     ConcentricGap(const object_creation::Geometry::ConcentricGap::Parameters &parameters);
0233 
0234     /**
0235      *  @brief  Populate list of polygon vertices, assuming regular polygon in XY plane at constant z coordinate
0236      * 
0237      *  @brief  rCoordinate polygon r coordinate
0238      *  @brief  zCoordinate polygon z coordinate
0239      *  @brief  phiCoordinate polygon phi coordinate
0240      *  @brief  symmetryOrder polygon symmetry order
0241      *  @param  vertexPointList to receive the vertex point list, with vertexPointList[symmetryOrder] = vertexPointList[0]
0242      */
0243     void GetPolygonVertices(const float rCoordinate, const float zCoordinate, const float phiCoordinate,
0244         const unsigned int symmetryOrder, VertexPointList &vertexPointList) const;
0245 
0246     /**
0247      *  @brief  Winding number test for a point in a 2D polygon in the XY plane (z coordinates are ignored)
0248      * 
0249      *  @param  point the test point
0250      *  @param  vertexPointList vertex points of a polygon, with vertexPointList[symmetryOrder] = vertexPointList[0]
0251      *  @param  symmetryOrder order of symmetry of polygon
0252      * 
0253      *  @return whether point is inside polygon
0254      */
0255     bool IsIn2DPolygon(const CartesianVector &point, const VertexPointList &vertexPointList, const unsigned int symmetryOrder) const;
0256 
0257     const float             m_minZCoordinate;       ///< Min cylindrical polar z coordinate, origin interaction point, units mm
0258     const float             m_maxZCoordinate;       ///< Max cylindrical polar z coordinate, origin interaction point, units mm
0259     const float             m_innerRCoordinate;     ///< Inner cylindrical polar r coordinate, origin interaction point, units mm
0260     const float             m_innerPhiCoordinate;   ///< Inner cylindrical polar phi coordinate (angle wrt cartesian x axis)
0261     const unsigned int      m_innerSymmetryOrder;   ///< Order of symmetry of the innermost edge of gap
0262     const float             m_outerRCoordinate;     ///< Outer cylindrical polar r coordinate, origin interaction point, units mm
0263     const float             m_outerPhiCoordinate;   ///< Outer cylindrical polar phi coordinate (angle wrt cartesian x axis)
0264     const unsigned int      m_outerSymmetryOrder;   ///< Order of symmetry of the outermost edge of gap
0265 
0266     VertexPointList         m_innerVertexPointList; ///< The vertex points of the inner polygon
0267     VertexPointList         m_outerVertexPointList; ///< The vertex points of the outer polygon
0268 
0269     friend class PandoraObjectFactory<object_creation::Geometry::ConcentricGap::Parameters, object_creation::Geometry::ConcentricGap::Object>;
0270 };
0271 
0272 //------------------------------------------------------------------------------------------------------------------------------------------
0273 //------------------------------------------------------------------------------------------------------------------------------------------
0274 
0275 inline LineGapType LineGap::GetLineGapType() const
0276 {
0277     return m_lineGapType;
0278 }
0279 
0280 //------------------------------------------------------------------------------------------------------------------------------------------
0281 
0282 inline float LineGap::GetLineStartX() const
0283 {
0284     return m_lineStartX;
0285 }
0286 
0287 //------------------------------------------------------------------------------------------------------------------------------------------
0288 
0289 inline float LineGap::GetLineEndX() const
0290 {
0291     return m_lineEndX;
0292 }
0293 
0294 //------------------------------------------------------------------------------------------------------------------------------------------
0295 
0296 inline float LineGap::GetLineStartZ() const
0297 {
0298     return m_lineStartZ;
0299 }
0300 
0301 //------------------------------------------------------------------------------------------------------------------------------------------
0302 
0303 inline float LineGap::GetLineEndZ() const
0304 {
0305     return m_lineEndZ;
0306 }
0307 
0308 //------------------------------------------------------------------------------------------------------------------------------------------
0309 //------------------------------------------------------------------------------------------------------------------------------------------
0310 
0311 inline const CartesianVector &BoxGap::GetVertex() const
0312 {
0313     return m_vertex;
0314 }
0315 
0316 //------------------------------------------------------------------------------------------------------------------------------------------
0317 
0318 inline const CartesianVector &BoxGap::GetSide1() const
0319 {
0320     return m_side1;
0321 }
0322 
0323 //------------------------------------------------------------------------------------------------------------------------------------------
0324 
0325 inline const CartesianVector &BoxGap::GetSide2() const
0326 {
0327     return m_side2;
0328 }
0329 
0330 //------------------------------------------------------------------------------------------------------------------------------------------
0331 
0332 inline const CartesianVector &BoxGap::GetSide3() const
0333 {
0334     return m_side3;
0335 }
0336 
0337 //------------------------------------------------------------------------------------------------------------------------------------------
0338 //------------------------------------------------------------------------------------------------------------------------------------------
0339 
0340 inline float ConcentricGap::GetMinZCoordinate() const
0341 {
0342     return m_minZCoordinate;
0343 }
0344 
0345 //------------------------------------------------------------------------------------------------------------------------------------------
0346 
0347 inline float ConcentricGap::GetMaxZCoordinate() const
0348 {
0349     return m_maxZCoordinate;
0350 }
0351 
0352 //------------------------------------------------------------------------------------------------------------------------------------------
0353 
0354 inline float ConcentricGap::GetInnerRCoordinate() const
0355 {
0356     return m_innerRCoordinate;
0357 }
0358 
0359 //------------------------------------------------------------------------------------------------------------------------------------------
0360 
0361 inline float ConcentricGap::GetInnerPhiCoordinate() const
0362 {
0363     return m_innerPhiCoordinate;
0364 }
0365 
0366 //------------------------------------------------------------------------------------------------------------------------------------------
0367 
0368 inline unsigned int ConcentricGap::GetInnerSymmetryOrder() const
0369 {
0370     return m_innerSymmetryOrder;
0371 }
0372 
0373 //------------------------------------------------------------------------------------------------------------------------------------------
0374 
0375 inline float ConcentricGap::GetOuterRCoordinate() const
0376 {
0377     return m_outerRCoordinate;
0378 }
0379 
0380 //------------------------------------------------------------------------------------------------------------------------------------------
0381 
0382 inline float ConcentricGap::GetOuterPhiCoordinate() const
0383 {
0384     return m_outerPhiCoordinate;
0385 }
0386 
0387 //------------------------------------------------------------------------------------------------------------------------------------------
0388 
0389 inline unsigned int ConcentricGap::GetOuterSymmetryOrder() const
0390 {
0391     return m_outerSymmetryOrder;
0392 }
0393 
0394 } // namespace pandora
0395 
0396 #endif // #ifndef PANDORA_DETECTOR_GAP_H