//////////////////////////////////////////////////////////////////////// /// \class RAT::Segmentor /// /// \brief Class assigns each PMT to an equal solid angle detector segment /// labelled by an int. Returns these SegmentIDs and the /// populations of each Segment. /// /// /// \author Jack Dunger /// /// REVISION HISTORY: ///- 2014-04-4 : J.Dunger - New file. ///- 2014-04-11 : P Jones - Moved to DU. ///- 2014-10-14 : J.Dunger - Added HWStatus check ///- 2015-02-15 : J.Dunger - Add arbitary orientations of segments ///- 2015-05-20 : J.Dunger - Add arbitary pattern origin /// /// \details Divides detector into ndiv divisions in both theta, phi /// to give ndiv * ndiv approximately equal solid angle segments. /// Returns a vector of ints, one entry for each PMT, the /// values indicating which segment each PMT belongs to (IDs). /// The first segment begins at theta=phi=0, the labels then /// increase by one moving around phi and by ndiv moving around /// theta. The SetPatternZaxis sets where the 'north pole' of the /// pattern is, the x,y axes are calculated automatically. /// /// //////////////////////////////////////////////////////////////////////// #ifndef __RAT_Segmentor__ #define __RAT_Segmentor__ #include #include #include namespace RAT { namespace DU { class Segmentor : public TObject { public: /// Default to 10 divisions, pattern centered at detector north Segmentor(): fNDivisions(10), fPatternZaxis(TVector3(0,0,1)), fPatternXaxis((TVector3(1,0,0))), fPatternYaxis(TVector3(0,1,0)), fPatternOrigin(TVector3(0,0,0)) {} /// Recalculates segments on new runs void BeginOfRun() { Calculate(); } /// Set the number of divisions, recalculates the segment IDs and populations /// /// @param[in] numberOfDivisions void SetNumberOfDivisions( const unsigned int numberOfDivisions ) { fNDivisions = numberOfDivisions; Calculate(); } /// Get the number of divisions /// /// @return number of divisions unsigned int GetNumberOfDivisions() const { return fNDivisions; } /// Set the z-axis of the segmentation pattern /// /// param[in] patternZaxis vector in direction of new pattern z-axis void SetPatternZaxis (const TVector3& patternZaxis); /// Set the z-axis of the segmentation pattern and the number of segments /// /// @param[in] numberOfDivisions The new number of divisions /// @param[in] patternZaxis vector in direction of new pattern z-axis void SetPatternZaxis (const TVector3& patternZaxis, const int numberOfDivisions); /// Set the origin, z-axis of the segmentation pattern /// /// @param[in] numberOfDivisions The new number of divisions /// @param[in] patternOrigin The new pattern origin /// @param[in] patternZaxis The pattern axis relative to the new origin void SetPatternOrigin(const TVector3& patternOrigin, const TVector3& patternZaxis, const int numberOfDivisions); ///Get origin of the segmentation pattern /// /// @returns the pattern origin TVector3 GetPatternOrigin() const {return fPatternOrigin;} ///Get the z-axis of the segmentation pattern /// /// @returns the z-axis of the co-ordinate pattern TVector3 GetPatternZaxis() const {return fPatternZaxis;} /// Get the x-axis of the segmentation pattern /// /// @returns the x-axis of the co-ordinate pattern TVector3 GetPatternXaxis() const {return fPatternXaxis;} /// Get the y-axis of the segmentation pattern /// /// @returns the y-axis of the co-ordinate pattern TVector3 GetPatternYaxis() const {return fPatternYaxis;} /// Get the Segment IDs /// /// @return vector of segment IDs by PMT ID std::vector GetSegmentIDs() const { return fSegmentIDs; } /// Get the online population per segment /// /// @return vector of populations by segment ID std::vector GetSegmentPopulations() const { return fPopulations; } // This ROOT macro adds dictionary methods to this class. // The number is 0 as this class is never, and should never be written to disc. // It assumes this class has no virtual methods, use ClassDef if change this. ClassDefNV( Segmentor, 0 ); private: /// Calculate the Segment IDs and proportions given the current PMTInfo void Calculate(); std::vector fSegmentIDs; ///< Segment ID by PMT ID (LCN) std::vector fPopulations; ///< Count of online (tube and channel) PMTs in each segment unsigned int fNDivisions; ///< The number of divisions to use TVector3 fPatternZaxis; ///< Unit z-axis of the pattern TVector3 fPatternXaxis; ///< Unit x-axis of the pattern TVector3 fPatternYaxis; ///< Unit y-axis of the pattern TVector3 fPatternOrigin; ///< Pattern origin in SNO+ co-ordinates }; } //::DU } //Namespace RAT #endif //__RAT_Segmentor__