Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:24:19

0001 // -*- C++ -*-
0002 //
0003 // MixingMatrix.h is a part of Herwig - A multi-purpose Monte Carlo event generator
0004 // Copyright (C) 2002-2019 The Herwig Collaboration
0005 //
0006 // Herwig is licenced under version 3 of the GPL, see COPYING for details.
0007 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
0008 //
0009 #ifndef HERWIG_MixingMatrix_H
0010 #define HERWIG_MixingMatrix_H
0011 
0012 //
0013 // This is the declaration of the MixingMatrix class.
0014 //
0015 
0016 #include "ThePEG/Interface/Interfaced.h"
0017 #include "ThePEG/Config/Complex.h"
0018 #include "MixingMatrix.fh"
0019 #include "ThePEG/Utilities/Exception.h"
0020 
0021 namespace Herwig {
0022 using namespace ThePEG;
0023 
0024 /*@name Some convenient typedefs. */
0025 //@{
0026 
0027   /**
0028    * A complex valued nested vector. 
0029    */
0030   typedef vector<vector<Complex> > CMatrix;
0031   
0032   /**
0033    * Struct for the elements of a mixing matrix
0034    */
0035   struct MixingElement{
0036 
0037     /**
0038      *  Constructor
0039      */
0040     MixingElement(unsigned int irow, unsigned int icol,Complex ivalue) 
0041       : row(irow), col(icol), value(ivalue) {}
0042 
0043     /**
0044      * row
0045      */
0046     unsigned int row;
0047 
0048     /**
0049      * column
0050      */
0051     unsigned int col;
0052 
0053     /**
0054      *  value
0055      */
0056     Complex value;
0057   };
0058 
0059   /**
0060    * A vector of mixing elements.
0061    */
0062   typedef vector<MixingElement> MixingVector;
0063 
0064   /**
0065    * The size of the matrix 
0066    */
0067   typedef pair<unsigned int, unsigned int> MatrixSize;
0068   //@}
0069 
0070 /**
0071  * This class is desinged to store the mixing matrices needed for Susy
0072  * studies. The actual matrix is stored as a nested complex vector. It
0073  * also stores a vector of PDG codes correspoding to the mass states of 
0074  * mixing states.
0075  * 
0076  * @see Interfaced
0077  */
0078 class MixingMatrix: public Interfaced {
0079 
0080   /** Exception class to indicate problem with mixing matrix .*/
0081   class MixingMatrixError : public Exception {};
0082 
0083 public:
0084 
0085   /** @name Constructors */
0086   //@{
0087   /**
0088    * Constructor that takes a mixing matrix and a vector id's as arguments 
0089    * @param mix Mixing matrix
0090    * @param ids The ids of the mixing sparticles
0091    */
0092   MixingMatrix(const CMatrix & mix,const vector<long> & ids) : 
0093     mixingMatrix_(mix),ids_(ids), size_(make_pair(mix.size(),mix[0].size())) 
0094   {}
0095 
0096   /**
0097    * Contructor that initializes size of matrix
0098    */
0099   MixingMatrix(unsigned int row, unsigned int col) :
0100     mixingMatrix_(row,vector<Complex>(col,Complex(0.,0.))), size_(row,col)
0101   {}
0102 
0103   /**
0104    * Standard Constructor.
0105    */
0106   MixingMatrix() {}
0107   //@}
0108 
0109 public:
0110 
0111   /** @name Functions used by the persistent I/O system. */
0112   //@{
0113   /**
0114    * Function used to write out object persistently.
0115    * @param os the persistent output stream written to.
0116    */
0117   void persistentOutput(PersistentOStream & os) const;
0118 
0119   /**
0120    * Function used to read in object persistently.
0121    * @param is the persistent input stream read from.
0122    * @param version the version number of the object when written.
0123    */
0124   void persistentInput(PersistentIStream & is, int version);
0125   //@}
0126 
0127   /**
0128    * The standard Init function used to initialize the interfaces.
0129    * Called exactly once for each class by the class description system
0130    * before the main function starts or
0131    * when this class is dynamically loaded.
0132    */
0133   static void Init();
0134 
0135   /** @name Get and Set functions. */
0136   //@{
0137   /**
0138    * Set the mixing matrix
0139    * @param mixing The Mixing matrix stored as nested complex vector
0140    */
0141   void setMatrix(const CMatrix & mixing)  {
0142     mixingMatrix_ = mixing;
0143     size_ = make_pair(mixing.size(),mixing[0].size());
0144   }
0145 
0146   /**
0147    *Get the mixing matrix
0148    */
0149   CMatrix getMatrix() const {return mixingMatrix_;}
0150 
0151   /**
0152    * Set the vector containing mixing particles codes
0153    * @param mixingCodes vector containing PDG codes for mixing particles
0154    */
0155   void setIds(const vector<long> & mixingCodes)  {
0156     if(mixingCodes.size() != size_.first) {
0157       ostringstream codes;
0158       for(unsigned int ix=0;ix<mixingCodes.size();++ix)
0159     codes << mixingCodes[ix] << " ";
0160       throw MixingMatrixError() << "MixingMatrix::setIds() - The number "
0161                 << "of PDG codes (" << mixingCodes.size()
0162                 << ") does not match the size of the "
0163                 << "matrix (" << size_.first
0164                 << ")"
0165                 << "Ids are " << codes.str() 
0166                 << Exception::warning;
0167       return;
0168     }
0169     ids_ = mixingCodes;
0170   }
0171   
0172   /**
0173    * Get the vector containing mixing particles codes
0174    */
0175   const vector<long> & getIds() const {return ids_;}
0176   //@}
0177   
0178   /**
0179    * Multiply row corresponding to id by \f$i\f$
0180    * @param id PDG code of particle
0181    */
0182   void adjustPhase(long id);
0183     
0184   /**
0185    * Access element of matrix
0186    */  
0187   const Complex operator()(unsigned int row, unsigned int col) const {
0188     return mixingMatrix_.at(row).at(col);
0189   }
0190 
0191   /**
0192    * Set element of matrix
0193    */
0194   Complex & operator()(unsigned int row, unsigned int col) {
0195     return mixingMatrix_.at(row).at(col);
0196   }
0197   
0198   /**
0199    * Add a PDG code to the stored vector
0200    */
0201   void addCode(long id) {
0202     if(ids_.size() >= size_.first) {
0203       throw MixingMatrixError() << "MixingMatrix::addCode() - Trying to add a"
0204                 << "PDG code but the vector already contains the "
0205                 << "same number as the matrix size " 
0206                 << Exception::warning;
0207       return;
0208     }
0209     ids_.push_back(id);
0210   }
0211   
0212   /**
0213    * Return the size of the mixing matrix
0214    */
0215   MatrixSize size() const {return size_;}
0216   
0217 protected:
0218 
0219   /** @name Clone Methods. */
0220   //@{
0221   /**
0222    * Make a simple clone of this object.
0223    * @return a pointer to the new object.
0224    */
0225   virtual IBPtr clone() const {return new_ptr(*this);}
0226 
0227   /** Make a clone of this object, possibly modifying the cloned object
0228    * to make it sane.
0229    * @return a pointer to the new object.
0230    */
0231   virtual IBPtr fullclone() const {return new_ptr(*this);}
0232   //@}
0233 
0234 private:
0235 
0236   /**
0237    * The assignment operator is private and must never be called.
0238    * In fact, it should not even be implemented.
0239    */
0240   MixingMatrix & operator=(const MixingMatrix &) = delete;
0241 
0242   /**
0243    * The mixing matrix
0244    */
0245   CMatrix mixingMatrix_;
0246 
0247   /**
0248    * The PDG codes of the mixing particles
0249    */
0250   vector<long> ids_;
0251 
0252   /**
0253    * Size of matrix
0254    */
0255   pair<unsigned int,unsigned int> size_;
0256   
0257   /**
0258    * Print the matrix to the stream
0259    */
0260   friend ostream & operator<<(ostream & os,const MixingMatrix & mix);
0261 };
0262 
0263   /**
0264    * Output operator for the MixingMatrix
0265    */
0266   ostream & operator<<(ostream &,const MixingMatrix &);
0267 }
0268 
0269 #endif /* HERWIG_MixingMatrix_H */