//////////////////////////////////////////////////////////////////////// /// \class RAT::DS::MCPE /// /// \brief This class represents a single photoelectron generated at the /// photocathode of the PMT. /// /// \author Stan Seibert \n /// Phil G Jones /// /// REVISION HISTORY:\n /// 2013-10-16: P G Jones - Updates for MCPhoton & MCPhotoelectron /// 2014-07-03: J R Wilson - Resolving DS naming conflicts, change name to MCPE /// 2016-09-14: T Kaptanoglu - Added afterpulse flag /// 2016-10-23: N Barros - Added photon history word to MCPE /// /// \details An instance is created for every generated photoelectron in /// the simulation. The charge is just the numPE. //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// /// \class RAT::DS::MCPhoton::NoValueError /// /// \brief An exception that is thrown when a user attempts to retrieve /// exit values if the photon doesn't exit. /// /// \author Phil G Jones /// /// REVISION HISTORY: /// 2013-10-17 : P G Jones - Updates for MCPhoton & MCPE /// 2016-12-21 : N Barros - Added photon history word (unsigned short to MCPE) /// /// \details As brief /// //////////////////////////////////////////////////////////////////////// #ifndef __RAT_DS_MCPE__ #define __RAT_DS_MCPE__ #include #include #include #include #include namespace RAT { namespace DS { class MCPE : public TObject { public: // some bits are reserved after the WLS bit to identify on which components // WLS occurred enum PhotonHistory{hUnknown = 0, hCherenkov =1,hScintillation=2, // Generation information hRayleighScatt=3,hMieScatt=4, // Scattering information hWLS=5, // WLS information. hWLSCOMP0=6,hWLSCOMP1=7,hWLSCOMP2=8, // If the first bit is set, at least one of the other bits is also set hWLSCOMP3=9,hWLSCOMP4=10,hWLSCOMP5=11 // See the relevant OPTICS_*.ratdb file for the identification of the components }; enum PhHistoryStatus{hUnset = 0, hSet = 1}; class NoValueError : public DataNotFound { public: /// Sets up a DataNotFound error /// /// @param[in] className of class the variable is a member of /// @param[in] fieldName of the variable /// @param[in] detail regarding the error NoValueError( const std::string className, const std::string fieldName, const std::string detail) : DataNotFound(className, fieldName, detail) { } }; /// Construct the MCPE, set the noise and afterpulse flag to false MCPE() : TObject(), frontEndTime(0), charge(0), photonTrackID(0), noise(false), afterpulse(false), photonHistory(0) { } /// Set the creation position /// /// @param[in] pos is local coordinate position where the photoelectron was created. void SetPosition( const TVector3& pos ) { position = ROOT::Math::XYZVectorF(pos.X(), pos.Y(), pos.Z()); } /// Get the creation position /// /// @return the local coord position where the photoelectron was created /// @throws NoValueError if the photoelectron is noise or afterpulse TVector3 GetPosition() const { if( noise ) throw NoValueError( "MCPE", "position", "Photoelectron is noise." ); if( afterpulse ) throw NoValueError( "MCPE", "position", "Photoelectron is afterpulse." ); return TVector3(position.X(), position.Y(), position.Z()); } /// Set the creation time /// /// @param[in] time global time is in ns void SetCreationTime( const double time ) { creationTime = time; } /// Get the creation time /// /// @return the global time in ns double GetCreationTime() const { return creationTime; } /// Set the daq front end time /// /// @param[in] time in ns void SetFrontEndTime( const double time ) { frontEndTime = time; } /// Get the daq front end time /// /// @return the front end time double GetFrontEndTime() const { return frontEndTime; } /// Set the charge of the photoelectron /// /// @param[in] charge_ is the charge void SetCharge( const double charge_ ) { charge = charge_; } /// Get the charge of the photoelectron /// /// @return the charge double GetCharge() const { return charge; } /// Set the track ID of the photon that caused the photoelectron /// /// @param[in] id track id void SetPhotonTrackID( const UInt_t id ) { photonTrackID = id; } /// Get the photon track ID that caused the photoelectron, /// /// @return the track id /// @throws NoValueError if the photoelectron is noise or afterpulse UInt_t GetPhotonTrackID() const { if( noise ) throw NoValueError( "MCPE", "photonTrackID", "Photoelectron is noise." ); if( afterpulse ) throw NoValueError( "MCPE", "photonTrackID", "Photoelectron is afterpulse." ); return photonTrackID; } /// Set this photoelectron as noise /// /// @param[in] noise_ flag, default value is true void SetNoise( const Bool_t noise_=true ) { noise = noise_; } /// Return true if the photoelectron is noise /// /// @return indicates if this photoelectron is noise Bool_t GetNoise() const { return noise; } /// Get the photon history /// /// @return a PhotonHistory UShort_t GetHistory() const {return photonHistory; } /// Set/Unset an item to the photon history /// /// @param[in] bit history item bit, from PhotonHistory enum /// @param[in] status Status to set. If status = 1, set the bit. If status = 0, bit is unset void AddToHistory(PhotonHistory bit, PhHistoryStatus status = hSet) { photonHistory = (photonHistory & ~(0x1 << bit)) | (status << bit); } /// Set the full history (replace id already exists) /// void SetHistory(UShort_t word ) {photonHistory = word;} /// Get a flag from the history word /// /// @param[in] RAT::DS::PhotonHistory field (bit number) /// @return true if bit is set, false otherwise bool GetFromHistory(PhotonHistory bit) const { return (((photonHistory & (1U << bit)) >> bit) == 0x1);}; /// Set this photoelectron as an afterpulse /// /// @param[in] afterpulse_ flag, default value is false void SetAfterPulse( const Bool_t afterpulse_=true ) { afterpulse = afterpulse_; } /// Return true if the photoelectron is an afterpulse /// /// @return indicates if this photoelectron is an afterpulse Bool_t GetAfterPulse() const { return afterpulse; } // 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( MCPE, 4 ); protected: ROOT::Math::XYZVectorF position; ///< Local co-ordinate position of the photoelectron at creation Double32_t creationTime; ///< Global MC time for the creation of the photoelectron Double32_t frontEndTime; ///< Front end detection time in Global MC coordinates. Double32_t charge; ///< Charge of the photoelectron (always 1? -PGJ) UInt_t photonTrackID; ///< The track ID of the photon that caused the photoelectron creation Bool_t noise; ///< Flag if this photoelectron is noise rather than from photon origin Bool_t afterpulse; ///< Flag if this photoelectron is an afterpulse rather than from photon origin UShort_t photonHistory; ///< Word of the processes this photon was subject to }; } // namespace DS } // namespace RAT #endif