//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      Device/Pol/PolFilter.h
//! @brief     Defines class PolFilter.
//!
//! @homepage  http://www.bornagainproject.org
//! @license   GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors   Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
//  ************************************************************************************************

#ifdef SWIG
#error no need to expose this header to Swig
#endif // SWIG
#ifndef BORNAGAIN_DEVICE_POL_POLFILTER_H
#define BORNAGAIN_DEVICE_POL_POLFILTER_H

#include "Base/Spin/SpinMatrix.h"
#include "Base/Spin/Spinor.h"
#include "Base/Type/Cloneable.h"

//! Polarization filter, characterized by direction and transmissions of the selected/parallel and
//! suppressed/antiparallel spin components.

class PolFilter : public Cloneable {
public:
    PolFilter(const R3& direction, double transmission_parallel, double transmission_antiparallel);
    ~PolFilter() override = default;

    PolFilter* clone() const override;

    //! Return the analyzer "density-like" matrix (in z-spin basis)
    const SpinMatrix& matrix() const { return m_ana_matrix; }

    R3 direction() const { return m_direction; }
    double transmissionParallel() const { return m_t_plus; }
    double transmissionAntiparallel() const { return m_t_minus; }

private:
    R3 m_direction;          //!< analyzer direction, unit vector
    const double m_t_plus;   //!< transmission of spin components in direction of analyzer
    const double m_t_minus;  //!< transmission of spin components against the direction of analyzer
    SpinMatrix m_ana_matrix; //!< analyzer operator in spin-z basis
};

#endif // BORNAGAIN_DEVICE_POL_POLFILTER_H
