Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-19 09:10:07

0001 #ifndef METOOLS_SpinCorrelations_Amplitude2_Tensor_H
0002 #define METOOLS_SpinCorrelations_Amplitude2_Tensor_H
0003 
0004 #include <vector>
0005 #include <memory>
0006 #include "ATOOLS/Math/MyComplex.H"
0007 #include "METOOLS/SpinCorrelations/Amplitude2_Matrix.H"
0008 #include "METOOLS/Main/Spin_Structure.H"
0009 #include "ATOOLS/Phys/Particle.H"
0010 #include "ATOOLS/Math/Vector.H"
0011 
0012 namespace METOOLS {
0013   class Decay_Matrix;
0014 
0015 
0016   class Amplitude2_Tensor {
0017     std::vector<Amplitude2_Tensor*>* p_next;
0018     Complex m_value;
0019     ATOOLS::Particle* p_part;
0020     size_t m_nhel;
0021 
0022     Complex ContractRemaining(const std::vector<ATOOLS::Particle*> &parts,
0023                               const std::vector<int> &permutation,
0024                               size_t level,
0025                               const std::vector<Spin_Amplitudes> &diagrams,
0026                               std::vector<int> &spin_i, std::vector<int> &spin_j,
0027                               double factor) const;
0028 
0029   public:
0030     Amplitude2_Tensor(const std::vector<ATOOLS::Particle*>& parts, size_t level);
0031     Amplitude2_Tensor(const std::vector<ATOOLS::Particle*>& parts,
0032                       size_t level,
0033                       const std::vector<Spin_Amplitudes*>& diagrams,
0034                       std::vector<int>& spin_i,
0035                       std::vector<int>& spin_j);
0036     Amplitude2_Tensor(const std::vector<ATOOLS::Particle*>& parts,
0037                       const std::vector<int>& permutation,
0038                       size_t level,
0039                       const std::vector<Spin_Amplitudes>& diagrams,
0040                       std::vector<int>& spin_i, std::vector<int>& spin_j);
0041     Amplitude2_Tensor(const Amplitude2_Tensor& other);
0042     ~Amplitude2_Tensor();
0043 
0044     void Contract(const Amplitude2_Matrix* D);
0045     Amplitude2_Matrix ReduceToMatrix(const ATOOLS::Particle* leftover) const;
0046     void Add(const Amplitude2_Tensor* amp, const Complex& factor);
0047     void Multiply(const Complex& factor);
0048     /**
0049     * @param D The (pointer to) the Amplitude2_Matrix with which the Amplitude2_Tensor should be multiplied with.
0050     *
0051     * method multiplies the entries of an Amplitude2_Matrix D to all entries of the Ampltitude2_Tensor with the same
0052      * helicity
0053     */
0054     void Multiply(const Amplitude2_Matrix* D);
0055     /**
0056     * @return unpolarized matrix element squared.
0057     *
0058     * method for summing up all entries of the Amplitude2_Tensor to receive the unpolarized result
0059     */
0060     Complex Sum();
0061     Complex Trace() const;
0062     bool Contains(const ATOOLS::Particle* part) const;
0063     /**
0064     * @param part_number number of the searched particle according to Sherpa's internal particle ordering
0065     * @param level level of Amplitude2_Tensor which describes the searched particle, only for recursive calls;
0066      * default: 1
0067     *
0068     * @return Pair of level of and the pointer to searched particle; if particle is not found, pair of last level and
0069     *         an empty pointer is returned
0070     *
0071     * method for searching, whether (and where) a particle with a specific particle number is included in the Amplitude2_Tensor
0072     */
0073     std::pair<const int, const ATOOLS::Particle*> Search(int part_number, int level=1) const;
0074     /**
0075     * @param num current number of particles, necessary for recursive call of the function; default: 0
0076     *
0077     * @return The number of particles in the Amplitude2_Tensor
0078     *
0079     * method for determining the number of particles in the Amplitude2_Tensor
0080     */
0081     int NumberParticles(int num=0) const;
0082     /**
0083     * @return bool; false if the end of an Amplitude2_Tensor branch is reached
0084     * method for determining whether the end of an Amplitude2_Tensor branch is reached
0085     *
0086     */
0087     bool IsP_Next() const;
0088     void UpdateParticlePointers(const std::map<ATOOLS::Particle*,ATOOLS::Particle*>& pmap);
0089 
0090     inline const std::vector<Amplitude2_Tensor*> Next() const {return *p_next;}
0091     inline const ATOOLS::Particle CurrentParticle() const { return *p_part; }
0092     inline const Complex Value() const { return m_value; }
0093     inline const size_t SpinDegreesofFreedom() const { return m_nhel; }
0094 
0095     void Print(std::ostream& ostr, std::string label) const;
0096     friend std::ostream& operator<<(std::ostream&, const Amplitude2_Tensor&);
0097 
0098     static bool SortCrit(const std::pair<ATOOLS::Particle*, size_t>& p1,
0099                          const std::pair<ATOOLS::Particle*, size_t>& p2);
0100 
0101     /**
0102     * @param coeff vector containing the transformation coefficients,
0103      * first level of vectors contains the coefficients for the different particles, second level for the different
0104      * final helicities and third level for the different old helicities in dependency of the final ones one level
0105      * above; first level should be ordered according to the particle ordering in Amplitude2_Tensor which should be
0106      * transformed; second level and third level according to its helicity ordering
0107     * @param conj_coeff vector containing the coefficients for the transformation of the complex conjugate
0108      * matrix elements, form analog to coeff
0109     * @param level level describes the level of the Amplitude2_tensor the method is working on at the moment,
0110      * necessary for recursive call of the method
0111      * default: 0
0112     * @param coeff_tmp vector containing the transformation coefficients,
0113      * form analog to coeff, only for recursive calls to save selected transformation coefficients necessary for
0114      * calculating the transformation of single entries in Amplitude2_Tensor
0115      * default: std::vector<std::vector<std::vector<Complex>>>()
0116     * @param conj_coeff_tmp vector containing the selected coefficients for the transformation of the complex conjugate
0117      * matrix elements, form analog to coeff, for recursive calls only
0118      * default: std::vector<std::vector<std::vector<Complex>>>()
0119     * @param old_amps  pointer to Amplitude2_Tensor before transformation, default: NULL
0120     *
0121     * method for transforming the Amplitude2_Tensor to another basis for polarization definition,
0122     * for that transformation coefficients for the matrix elements and their complex conjugate must be handed in;
0123     * the method iterates two times through an Amplitude2_Tensor, first time to reach the entries which should be
0124     * changed and to select the coefficients which are important for calculation of the current new entry
0125     * (contained in second level of coeff); during the second time the new entry is calculated by multiplying
0126     * every entry of the old tensor by the corresponding coefficients
0127     */
0128     void PolBasisTrafo(const std::vector<std::vector<std::vector<Complex> > >& coeff,
0129                        const std::vector<std::vector<std::vector<Complex> > >& conj_coeff, int level=0,
0130                        std::vector<std::vector<std::vector<Complex> > > coeff_tmp=std::vector<std::vector<std::vector<Complex> > >(),
0131                        std::vector<std::vector<std::vector<Complex> > > conj_coeff_tmp=std::vector<std::vector<std::vector<Complex> > >(),
0132                        Amplitude2_Tensor* old_amps=NULL);
0133   };
0134 
0135   using Amplitude2_Tensor_SP = std::shared_ptr<METOOLS::Amplitude2_Tensor>;
0136 }
0137 
0138 
0139 #endif