//////////////////////////////////////////////////////////////////// /// \class RAT::DU::ShadowingCalculator /// /// \brief Calculates whether the path (refracted or straight) /// between two points in the detector is shadowed by /// any of the geometry. /// /// \author Rob Stainforth /// /// REVISION HISTORY:\n /// 06/2015 : Rob Stainforth - First Revision, new file. /// 19/11/2015 : M Mottram - clear member vectors at start of BeginOfRun. /// /// \detail This utility can be used to check whether the path /// between two points in the detector are shadowed /// (read: intersect) with any of detector geometry. /// For example, paths could intersect with the belly /// plates at the AV equator, or either of the rope systems /// in place to hold-up and hold-down the AV. /// Currently this utility can test for instances of the /// following types of shadowing: /// /// - AV Hold-Down Ropes (if applicable; it is geometry dependent) /// - Support Ropes (Hold-up) /// - Belly Plates /// - NCD Anchors /// - AV Pipes /// - Neck Boss /// /// This utility requires a DU::LightPathCalculator object /// in order to check for an instance of shadowing. /// /// It can be used in RAT, ROOT or external programs that link to /// the libRATEvent library. /// //////////////////////////////////////////////////////////////////// #ifndef __RAT_DU_ShadowingCalculator__ #define __RAT_DU_ShadowingCalculator__ #include #include #include #include #include #include namespace RAT { namespace DU { class ShadowingCalculator { public: ///////////////////////////////// //////// METHODS //////// ///////////////////////////////// /// Called at the start of a run, loads and constructs /// from the database a series of points which trace out /// the detector geometry. These points are then checked /// against in the subsequent shadowing-check methods. void BeginOfRun(); /// For the following boolean functions: /// TRUE: Shadowed, FALSE: Not Shadowed. /// Check specifically for shadowing from the AV Hold-Down ropes. /// /// @return Shadowed flag (true/false). /// @param[in] The light path to check for shadowing for. Bool_t CheckForAVHDRopeShadowing( RAT::DU::LightPathCalculator& lPath ); /// Check specifically for shadowing from the Support Ropes. /// /// @return Shadowed flag (true/false). /// @param[in] The light path to check for shadowing for. Bool_t CheckForSupportRopeShadowing( RAT::DU::LightPathCalculator& lPath ); /// Check specifically for shadowing from the belly-plates. /// /// @return Shadowed flag (true/false). /// @param[in] The light path to check for shadowing for. Bool_t CheckForBellyPlateShadowing( RAT::DU::LightPathCalculator& lPath ); /// Check specifically for shadowing from the NCD Anchors. /// /// @return Shadowed flag (true/false). /// @param[in] The light path to check for shadowing for. Bool_t CheckForNCDAnchorShadowing( RAT::DU::LightPathCalculator& lPath ); /// Check specifically for shadowing from the AV Pipes. /// /// @return Shadowed flag (true/false). /// @param[in] The light path to check for shadowing for. Bool_t CheckForAVPipeShadowing( RAT::DU::LightPathCalculator& lPath ); /// Check specifically for shadowing from the neck boss. /// /// @return Shadowed flag (true/false). /// @param[in] The light path to check for shadowing for. Bool_t CheckForNeckBossShadowing( RAT::DU::LightPathCalculator& lPath ); /// Check whether the current path between two points is shadowed by some means. /// This essentially executes all the above CheckFor*Shadowing() methods above. /// /// @return Shadowed flag (true/false) /// @param[in] The light path to check for shadowing for. Bool_t CheckForShadowing( RAT::DU::LightPathCalculator& lPath ); ///////////////////////////////// //////// GETTERS //////// ///////////////////////////////// /// @return the AV hold-down shadowing flag. Bool_t GetAVHDRopeShadowFlag() const { return fAVHDRopeShadowFlag; } /// @return the belly plate shadowing flag. Bool_t GetBellyPlateShadowFlag() const { return fBellyPlateShadowFlag; } /// @return the NCD anchor shadowing flag. Bool_t GetNCDAnchorShadowFlag() const { return fNCDAnchorShadowFlag; } /// @return the support rope shadowing flag. Bool_t GetSupportRopeShadowFlag() const { return fSupportRopeShadowFlag; } /// @return the AV pipe shadowing flag. Bool_t GetAVPipeShadowFlag() const { return fAVPipeShadowFlag; } /// @return the neck boss shadowing flag. Bool_t GetNeckBossShadowFlag() const { return fNeckBossShadowFlag; } /// @return the top-level shadowing flag. /// This returns true if any of the above flags are true. Bool_t GetShadowFlag() const { return fShadowFlag; } ///////////////////////////////// //////// SETTERS //////// ///////////////////////////////// /// Set the tolerances of accepted proximity to geometry to be considered shadowed /// by all detector geometry. /// /// @param[in] Tolerance (mm). void SetAllGeometryTolerances( const Double_t geoTol ); /// Set the tolerance of accepted proximity to geometry to be considered shadowed /// by the AV hold-down ropes. /// /// @param[in] Tolerance (mm). void SetAVHDRopeTolerance( const Double_t avhdTol ){ fAVHDRopeTolerance = avhdTol; } /// Set the tolerance of accepted proximity to geometry to be considered shadowed /// by the support ropes. /// /// @param[in] Tolerance (mm). void SetSupportRopeTolerance( const Double_t suppTol ){ fSupportRopeTolerance = suppTol; } /// Set the tolerance of accepted proximity to geometry to be considered shadowed /// by the belly plates. /// /// @param[in] Tolerance (mm). void SetBellyPlateTolerance( const Double_t bpTol ){ fBellyPlateTolerance = bpTol; } /// Set the tolerance of accepted proximity to geometry to be considered shadowed /// by the NCD anchors. /// /// @param[in] Tolerance (mm). void SetNCDAnchorTolerance( const Double_t ncdTol ){ fNCDAnchorTolerance = ncdTol; } /// Set the tolerance of accepted proximity to geometry to be considered shadowed /// by the AV pipes. /// /// @param[in] Tolerance (mm). void SetAVPipeTolerance( const Double_t avPipeTol ){ fAVPipeTolerance = avPipeTol; } /// Set the tolerance of accepted proximity to geometry to be considered shadowed /// by the neck boss. /// /// @param[in] Tolerance (mm). void SetNeckBossTolerance( const Double_t neckBossTol ){ fNeckBossTolerance = neckBossTol; } private: ///////////////////////////////////////////////// ///////// PRIVATE MEMBER METHODS //////// ///////////////////////////////////////////////// /// Load the Shadowing Geometry information from the database. /// This is called in preparation for checks for shadowing /// by ShadowingCalculator::BeginOfRun. /// Load the AV Hold-Down rope geometry information void LoadAVHDRopeInfo(); /// Load the support rope geometry information void LoadSupportRopeInfo(); /// Load the belly plate geometry information void LoadBellyPlateInfo(); /// Load the NCD anchor geometry information void LoadNCDAnchorInfo(); /// Load the AV Pipe geometry information void LoadAVPipeInfo(); /// Load the neck boss geometry information void LoadNeckBossInfo(); /// Fill an an empty vector of 'positions' with the /// (x,y,z) coordinates stored in the RATDB 'tblName' and index 'indexName', /// Depending on the field, the x,y,z coordinates are stored in fields /// 'xField', 'yField' and 'zField', in almost all instances (but not all), /// these fields are 'x', 'y', 'z'. /// /// @param[in,out] positions The vector of (x,y,z) coordinates to be filled from the table entry /// @param[in] tableName The name of the RATDB table in the database /// @param[in] indexName The index name from the RATDB table in the database /// @param[in] xField The field corresponding to the x coordinate entries /// @param[in] yField The field corresponding to the y coordinate entries /// @param[in] zField The field corresponding to the z coordinate entries void FillXYZPositions( std::vector< TVector3 >& positions, const std::string& tableName, const std::string& indexName, const std::string& xField = "x", const std::string& yField = "y", const std::string& zField = "z" ); /// Calculate vector from some initial point ('startPos'), with an initial /// starting direction, 'startDir' to the edge of a sphere of given radius ('radiusFromCentre') /// /// @param[in] startPos starting position within (or outside of) a sphere /// @param[in] startDir Unit starting direction vector from startPos /// @param[in] radiusFromCentre The radius of the spherical edge required to be calculated /// @param[in] outside Whether the starting position is outside of the sphere in question /// /// @return The vector at the spheres edge TVector3 VectorToSphereEdge( const TVector3& startPos, const TVector3& startDir, const Double_t radiusFromCentre, const Bool_t outside ); /// Calculate vector from some initial point ('startPos'), with an initial /// starting direction, 'startDir' to the edge of a cylinder of given radius ('cylinderRadius') /// /// @param[in] startPos starting position within (or outside of) a cylinder /// @param[in] startDir Unit starting direction vector from startPos /// @param[in] cylinderBaseOrigin The location of the origin of the base of the cylinder /// @param[in] cylinderRadius The radius of the cylinder /// /// @return The vector at the spheres edge TVector3 VectorToCylinderEdge( const TVector3& startPos, const TVector3& startDir, const TVector3& cylinderBaseOrigin, const Double_t cylinderRadius ); /// Calculate the maximum angle between the event position /// and the path direction for the path to intersect with the /// sphere of radius 'edgeRadius' /// /// @param[in] eventPos The starting point of the light path (typically an event position) /// @param[in] edgeRadius The radius of the nearest sphere to the event position /// /// @return Calculate the closest angular displacement of a path close to a surface interface Double_t ClosestAngle( const TVector3& eventPos, const Double_t edgeRadius ); /////////////////////////////////////////////////// ///////// PRIVATE MEMBER VARIABLES //////// /////////////////////////////////////////////////// /// The shadowing booleans - these are only initialised when shadowing checks are called Bool_t fAVHDRopeShadowFlag; ///< TRUE: The light path intersected with AVHD rope position coordinates FALSE: It didn't Bool_t fBellyPlateShadowFlag; ///< TRUE: The light path intersected with belly plate position coordinates FALSE: It didn't Bool_t fNCDAnchorShadowFlag; ///< TRUE: The light path intersected with NCD anchor position coordinates FALSE: It didn't Bool_t fSupportRopeShadowFlag; ///< TRUE: The light path intersected with support rope position coordinates FALSE: It didn't Bool_t fAVPipeShadowFlag; ///< TRUE: The light path intersected with AV pipe position coordinates FALSE: It didn't Bool_t fNeckBossShadowFlag; ///< TRUE: The light path intersected with the neck boss position coordinates FALSE: It didn't Bool_t fShadowFlag; ///< TRUE: The light path intersected due to one of the above 4 geometry intersections FALSE: It didn't Double_t fAVHDRopeTolerance; ///< Accepted tolerance/proxity to the AV hold-down ropes. Double_t fSupportRopeTolerance; ///< Accepted tolerance/proxity to the support ropes. Double_t fBellyPlateTolerance; ///< Accepted tolerance/proxity to the belly plates. Double_t fNCDAnchorTolerance; ///< Accepted tolerance/proxity to the NCD anchors. Double_t fAVPipeTolerance; ///< Accepted tolerance/proxity to the AV pipes. Double_t fNeckBossTolerance; ///< Accepted tolerance/proxity to the neck boss. /// The shadowing geometric information Double_t fAVInnerRadius; ///< Inner radius of the AV. Double_t fAVOuterRadius; ///< Outer radius of the AV. Double_t fNeckOuterRadius; ///< Outer radius of the AV neck. /// There are seven AV pipes, for which five share the same dimensions (av_pipe-1,2,3,4,6) and /// two share the same dimensions( av_pipe-labs, av_pipe_labr ). See doc-DB 2228 for information, and /// labelling for which pipe is which. Bool_t fExistAVPipe; ///< Whether or not AV pipes are in the geometry (true: yes, false: no). std::vector< TVector3 > fAVPipe1Points; ///< Location of "av_pipe-1" std::vector< TVector3 > fAVPipe2Points; ///< Location of "av_pipe-2" std::vector< TVector3 > fAVPipe3Points; ///< Location of "av_pipe-3" std::vector< TVector3 > fAVPipe4Points; ///< Location of "av_pipe-4" std::vector< TVector3 > fAVPipeLabSPoints; ///< Location of "av_pipe-labs" std::vector< TVector3 > fAVPipe6Points; ///< Location of "av_pipe-6" std::vector< TVector3 > fAVPipeLabRPoints; ///< Location of "av_pipe-labr" std::vector< TVector3 > fAVPipePoints; ///< Location of all the AV pipes Double_t fAVPipeXRadius; ///< Radius of av_pipe-1,2,3,4 and 6 Double_t fAVPipeLabXRadius; ///< Radius of av_pipe-labs and av_pipe_labr /// NCD geometry information Bool_t fExistNCDAnchor; ///< Whether or not NCD anchors are in the geometry (true: yes, false: no). std::vector< TVector3 > fNCDAnchorPoints; ///< NCD Anchor Locations Double_t fNCDAnchorHalfHeight; ///< Half-height of an NCD anchor Double_t fNCDAnchorRadius; ///< Radius of an NCD anchor /// Belly plate geometry information Bool_t fExistBellyPlate; ///< Whether or not belly plates are in the geometry (true: yes, false: no). std::vector< TVector3 > fBellyPlateCentrePoints; ///< Belly Plate Centre Locations std::vector< TVector3 > fBellyPlatePoints; ///< Belly Plate Locations Double_t fBellyPlateHalfHeight; ///< Half-height of an individual belly plate /// AV Hold-Down rope geometry information. /// Information is split between the 'upper' AV hold-down rope information /// and the 'lower' AV hold-down rope information. Splitting point is at the /// equator of the AV. Bool_t fExistAVHDRope; ///< Whether or not AVHD ropes are in the geometry (true: yes, false: no). std::vector< TVector3 > fAVHDRopeSlingPoints; ///< The points which define an individual sling, for which 10 slings form the hold down net std::vector< Double_t > fAVHDRopeSlingRolls; ///< The angular displacement of each sling about the z-axis std::vector< TVector3 > fAVHDRopeEquatorPoints; ///< Points on the equator where the AVHD passes std::vector< TVector3 > fAVHDRopeUpperAVPoints; ///< Points above the equator where the AV hold down ropes lay std::vector< TVector3 > fAVHDRopeLowerAVPoints; ///< Points below the equator where the AV hold down ropes lay Double_t fAVHDRopeRadius; ///< Radius of the AVHD Ropes /// Support rope geometry infromation. Bool_t fExistSupportRope; ///< Whether or not support ropes are in the geometry (true: yes, false: no). std::vector< TVector3 > fSupportRopeEquatorPoints; ///< Points on the equator where the support ropes loop through the belly plates std::vector< TVector3 > fSupportRopeUpperAVPoints; ///< Points above the AV equatow where the support ropes lay Double_t fSupportRopeRadius; ///< Radius of the support Ropes Double_t fSupportRopeHeight; ///< The height of the support rope // Neck boss information. Bool_t fExistNeckBoss; ///< Whether or the neck boss is in the geometry (true: yes, false: no). Double_t fNeckBossTheta; ///< The theta position of the lower bevelled neck boss ring on the AV }; } // namespace DU } // namespace RAT #endif