#ifndef __PNDDRCPHOTON_H__ #define __PNDDRCPHOTON_H__ //! A namespace for encapsulation. namespace Drc { /*! \enum PndDrc::PhotonFate An enum holding the fate of a photon. */ enum PhotonFate { //! Photon is still propagating PhotFlying, //! Photon has hit measuring device. PhotMeasured, //! Photon got lost outside. PhotLost, //! Photon got lost inside. PhotAbsorbed }; } class PndDrcOptDev; /*! \brief Representation of a photon. */ class PndDrcPhoton { private: //! Wavelength in nm. double m_lambda; //! Actual position of photon. XYZPoint m_position; //! Old position of photon. XYZPoint m_positionOld; //! Normalized direction of photon. XYZVector m_direction; //! The fate of the photon. Drc::PhotonFate m_fate; //! Number of suffered reflections. int m_reflections; //! Verbosity level 0-5. int m_verbosity; //! Pointer to device where photon is. PndDrcOptDev* m_dev; //! Time of flight. double m_time; public: //! Empty constructor. PndDrcPhoton(); //! Destructor. virtual ~PndDrcPhoton(){}; /*! \brief Verbosity Set the verbosity. Range is 0 to 5. \verbatim 0=quiet, 1=constructors,destructors, 2=member functions, 3=functionality 4=photons 5=everything \endverbatim \param level The verbosity level */ void setVerbosity(int level){m_verbosity=level;}; /*! \brief Verbosity. \return Verbosity \sa setVerbosity() */ const int verbosity() const {return m_verbosity;}; /*! \brief Set fate of photon \param fate The fate \sa PndDrc::PhotonFate */ void setFate(Drc::PhotonFate fate) {m_fate=fate;}; /*! \brief Fate of photon \return The fate \sa PndDrc::PhotonFate */ const Drc::PhotonFate fate() const {return m_fate;}; /*! \brief Reflections \return Reflections. */ int reflections() const {return m_reflections;}; /*! \brief Position \return Position. */ XYZPoint position() const {return m_position;}; /*! \brief Set position \param pos Position. */ void setPosition(const XYZPoint& pos); /*! \brief Direction \return Normalized direction. */ XYZVector direction() const {return m_direction;}; /*! \brief Set normalized direction \param dir Direction. */ void setDirection(const XYZVector& dir) {m_direction=dir.Unit();}; /*! \brief Wavelength \return Wavelength in nm. */ double wavelength() const {return m_lambda;}; /*! \brief Set wavelength \param lambda Wavelength in nm. */ void setWavelength(double lambda){m_lambda=lambda;}; /*! \brief Device where photon is \return Device. */ PndDrcOptDev* device() const {return m_dev;}; /*! \brief Set device where photon is \param dev The device. */ void setDevice(PndDrcOptDev* dev){m_dev=dev;}; /*! \brief Time of flight for photon \return Time of flight in [ns]. */ double time() const {return m_time;}; /*! \brief Set time of photon \param tim The time. */ void setTime(double tim){m_time=tim;}; /*! \brief Handles refraction and reflection of photon. After this routine, the photons direction, position and fate is set. \param normal The normal vector of the surface of the volume the photon is in. \param n_inside The refractive index of the current medium \param n_outside The refractive index of or the next volume or the vacuum outside. \return True if refraction occured, false if reflection occured. */ bool refract(XYZVector normal, double n_inside, double n_outside=1.0); /*! \brief Reflect the photon \param normal The normal vector of the surface. \sa refract() */ void reflect(const XYZVector& normal); /*! \brief Write photon coordinates to stream in root syntax. \param stream The stream. */ void print(fstream& stream) const; //! Write photon properties to cout. void print() const; /*! \brief Color number for usage in root \param lambda The wavelength in nm. \return Color number. */ int colorNumber(double lambda) const; }; #endif