//////////////////////////////////////////////////////////////////////// /// \class RAT::DS::MCPMT /// /// \brief Monte Carlo PMT hits /// /// \author Stan Seibert \n /// Phil G Jones /// /// REVISION HISTORY:\n /// 2013-12-05 : P G Jones - Refactor, split MCPhoton into MCPhoton and /// MCPhotoelectron. \n /// /// \details The class represents a PMT in which at least one photon /// enters the bucket (MCPhoton) or creates a photoelectron (MCPhotoelectron). /// //////////////////////////////////////////////////////////////////////// #ifndef __RAT_DS_MCPMT___ #define __RAT_DS_MCPMT___ #include #include #include #include #include #include namespace RAT { namespace DS { class MCPMT : public TObject { public: /// construct the PMT, nothing to do MCPMT() : TObject(), id(0) { } /// Construct the PMT with an id MCPMT( const UInt_t id_ ) : id(id_) { } /// Get the PMT ID (Logical Channel Number) /// /// @return the pmt ID UInt_t GetID() const { return id; }; /// Set the PMT ID (Logical Channel Number) /// /// @param[in] pmtID the id for this PMT. void SetID( const UInt_t pmtID ) { id = pmtID; }; /// Get a MCPhoton using the index in the photons vector /// /// @param[in] index into the photons array /// @return reference to the MCPhoton /// @throws out_of_range if the index is out of range MCPhoton& GetMCPhoton( const size_t index ) { return mcPhotons.at( index ); }; /// @copydoc GetMCPhoton(size_t) const MCPhoton& GetMCPhoton( const size_t index ) const { return mcPhotons.at( index ); }; /// Get the number of MCPhotons stored /// /// @return the number of MCPhotons size_t GetMCPhotonCount() const { return mcPhotons.size(); }; /// Add a new MCPhoton to the collection /// /// @param[in] photon to add void AddMCPhoton( const MCPhoton& photon ) { mcPhotons.push_back( photon ); }; /// Prune/delete the MCPhoton collection void PruneMCPhotons() { clear_vector(mcPhotons ); }; /// Get a MCPE using the index in the mcPEs vector /// /// @param[in] index into the photoelectrons array /// @return reference to the MCPE /// @throws out_of_range if the index is out of range MCPE& GetMCPE( const size_t index ) { return mcPEs.at( index ); }; /// @copydoc GetMCPE(size_t) const MCPE& GetMCPE( const size_t index ) const { return mcPEs.at( index ); }; /// Get the number of MCPEs (MC photoelectrons) stored /// /// @return the number of MCPEs size_t GetMCPECount() const { return mcPEs.size(); }; /// Add a new MCPE to the collection /// /// @param[in] photoelectron to add void AddMCPE( const MCPE& photoelectron ) { mcPEs.push_back( photoelectron ); }; /// Prune/delete the MCPE collection void PruneMCPEs() { clear_vector( mcPEs ); }; /// Sort the mc photoelectrons by time ascending inline void SortMCPEs(); // This ROOT macro adds dictionary methods to this class. // The number should be incremented whenever this class's members are changed. // It assumes this class has no virtual methods, use ClassDef if change this. ClassDefNV( MCPMT, 3 ); protected: std::vector mcPhotons; ///< The photon information std::vector mcPEs; ///< The photoelectron information UInt_t id; ///< Logical Channel Number of the PMT }; /// Short function to compare to MCPEs and return true if lhs is before rhs /// /// Compares lhs < rhs /// /// @param[in] lhs /// @param[in] rhs /// @return true if lhs < rhs inline bool CompareMCPETimeAscending( const DS::MCPE& lhs, const DS::MCPE& rhs ) { return lhs.GetCreationTime() < rhs.GetCreationTime(); } inline void MCPMT::SortMCPEs() { sort( mcPEs.begin(), mcPEs.end(), CompareMCPETimeAscending ); } } // namespace DS } // namespace RAT #endif