Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #ifndef METOOLS_Explicit_C_Object_H
0002 #define METOOLS_Explicit_C_Object_H
0003 
0004 #include "ATOOLS/Math/MyComplex.H"
0005 #include <iostream>
0006 #include <vector>
0007 
0008 namespace METOOLS {
0009 
0010   /*!
0011     \class CObject
0012     \brief The base class of all currents.
0013 
0014     The functionality of this class is defined in its derived classes.
0015   */
0016   class CObject {
0017   protected:
0018 
0019     /*!
0020       \var int m_c[2]
0021       \brief The color and anti-colour indices of the current. The two elements are for color 
0022       and anti-color respectively. They take the values of +/-[1,2,3] for the SM.
0023       \var int m_h
0024       \brief The helicity state identifier of the current. This is later mapped to an entry 
0025       in a vector containing all possible helicity states, ie. confgurations of helicities 
0026       of each particle.
0027       \var int m_s
0028       \brief Whether the current is part of an NLO subtraction or not.
0029     */
0030     int m_c[2], m_h, m_s;
0031 
0032   public:
0033 
0034     // constructor
0035     inline CObject() {}
0036 
0037     // destructor
0038     virtual ~CObject();
0039 
0040     // member functions
0041     virtual CObject* Copy() const = 0;
0042 
0043     virtual void Delete() = 0;
0044 
0045     virtual void Add(const CObject *c) = 0;
0046     virtual void Divide(const double &d) = 0;
0047     virtual void Multiply(const Complex &c) = 0;
0048     virtual void Invert() = 0;
0049 
0050     virtual bool IsZero() const = 0;
0051 
0052     // inline functions
0053     /*!
0054       \fn inline int &operator()(const int i)
0055       \brief Returns the color or anticolor, depending on the index (0 and 1 respectively)
0056      */
0057     inline int &operator()(const int i) { return m_c[i]; }
0058     /*!
0059       \fn inline int operator()(const int i) const
0060       \brief Returns the color or anticolor, depending on the index (0 and 1 respectively)
0061      */
0062     inline int operator()(const int i) const { return m_c[i]; }
0063 
0064     inline void SetH(const int &h) { m_h=h; }
0065     inline void SetS(const int &s) { m_s=s; }
0066 
0067     inline const int &H() const { return m_h; }
0068     inline const int &S() const { return m_s; }
0069 
0070     /*!
0071       \fn inline bool operator==(const CObject &o) const
0072       \brief Compares the color and m_s of the two currents, not the helicity.
0073      */
0074     inline bool operator==(const CObject &o) const
0075     { return m_c[0]==o.m_c[0] && m_c[1]==o.m_c[1] && m_s==o.m_s; }
0076 
0077     /*!
0078       \fn template <typename CType> inline CType *Get()
0079       \brief Returns a pointer of CType to this object.
0080      */
0081     template <typename CType> inline CType *Get()
0082     { return static_cast<CType*>((void*)this); }
0083 
0084   };// end of class CObject
0085 
0086   struct CObject_Vector: public std::vector<CObject*> {
0087 
0088     CObject_Vector(const size_t &n=0): std::vector<CObject*>(n) {}
0089 
0090     template <typename CType> inline std::vector<CType*> *Get()
0091     { return static_cast<std::vector<CType*>*>((void*)this); }
0092     template <typename CType> inline const std::vector<CType*> *Get() const
0093     { return static_cast<const std::vector<CType*>*>((void*)this); }
0094 
0095   };// end of struct CObject_Vector
0096 
0097   struct CObject_Matrix: public std::vector<CObject_Vector> {
0098 
0099     template <typename CType> inline std::vector<std::vector<CType*> > *Get()
0100     { return static_cast<std::vector<std::vector<CType*> >*>((void*)this); }
0101     template <typename CType> inline const std::vector<std::vector<CType*> > *Get() const
0102     { return static_cast<const std::vector<std::vector<CType*> >*>((void*)this); }
0103 
0104   };// end of struct CObject_Matrix
0105 
0106   std::ostream &operator<<(std::ostream &str,const CObject &s);
0107 
0108 }// end of namespace METOOLS
0109 
0110 #endif