herwig is hosted by Hepforge, IPPP Durham
Herwig  7.2.1
MixingMatrix.h
1 // -*- C++ -*-
2 //
3 // MixingMatrix.h is a part of Herwig - A multi-purpose Monte Carlo event generator
4 // Copyright (C) 2002-2019 The Herwig Collaboration
5 //
6 // Herwig is licenced under version 3 of the GPL, see COPYING for details.
7 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
8 //
9 #ifndef HERWIG_MixingMatrix_H
10 #define HERWIG_MixingMatrix_H
11 
12 //
13 // This is the declaration of the MixingMatrix class.
14 //
15 
16 #include "ThePEG/Interface/Interfaced.h"
17 #include "ThePEG/Config/Complex.h"
18 #include "MixingMatrix.fh"
19 #include "ThePEG/Utilities/Exception.h"
20 
21 namespace Herwig {
22 using namespace ThePEG;
23 
24 /*@name Some convenient typedefs. */
26 
30  typedef vector<vector<Complex> > CMatrix;
31 
35  struct MixingElement{
36 
40  MixingElement(unsigned int irow, unsigned int icol,Complex ivalue)
41  : row(irow), col(icol), value(ivalue) {}
42 
46  unsigned int row;
47 
51  unsigned int col;
52 
57  };
58 
62  typedef vector<MixingElement> MixingVector;
63 
67  typedef pair<unsigned int, unsigned int> MatrixSize;
69 
78 class MixingMatrix: public Interfaced {
79 
81  class MixingMatrixError : public Exception {};
82 
83 public:
84 
92  MixingMatrix(const CMatrix & mix,const vector<long> & ids) :
93  mixingMatrix_(mix),ids_(ids), size_(make_pair(mix.size(),mix[0].size()))
94  {}
95 
99  MixingMatrix(unsigned int row, unsigned int col) :
100  mixingMatrix_(row,vector<Complex>(col,Complex(0.,0.))), size_(row,col)
101  {}
102 
108 
109 public:
110 
117  void persistentOutput(PersistentOStream & os) const;
118 
124  void persistentInput(PersistentIStream & is, int version);
126 
133  static void Init();
134 
141  void setMatrix(const CMatrix & mixing) {
142  mixingMatrix_ = mixing;
143  size_ = make_pair(mixing.size(),mixing[0].size());
144  }
145 
149  CMatrix getMatrix() const {return mixingMatrix_;}
150 
155  void setIds(const vector<long> & mixingCodes) {
156  if(mixingCodes.size() != size_.first) {
157  ostringstream codes;
158  for(unsigned int ix=0;ix<mixingCodes.size();++ix)
159  codes << mixingCodes[ix] << " ";
160  throw MixingMatrixError() << "MixingMatrix::setIds() - The number "
161  << "of PDG codes (" << mixingCodes.size()
162  << ") does not match the size of the "
163  << "matrix (" << size_.first
164  << ")"
165  << "Ids are " << codes.str()
167  return;
168  }
169  ids_ = mixingCodes;
170  }
171 
175  const vector<long> & getIds() const {return ids_;}
177 
182  void adjustPhase(long id);
183 
187  const Complex operator()(unsigned int row, unsigned int col) const {
188  return mixingMatrix_.at(row).at(col);
189  }
190 
194  Complex & operator()(unsigned int row, unsigned int col) {
195  return mixingMatrix_.at(row).at(col);
196  }
197 
201  void addCode(long id) {
202  if(ids_.size() >= size_.first) {
203  throw MixingMatrixError() << "MixingMatrix::addCode() - Trying to add a"
204  << "PDG code but the vector already contains the "
205  << "same number as the matrix size "
207  return;
208  }
209  ids_.push_back(id);
210  }
211 
215  MatrixSize size() const {return size_;}
216 
217 protected:
218 
225  virtual IBPtr clone() const {return new_ptr(*this);}
226 
231  virtual IBPtr fullclone() const {return new_ptr(*this);}
233 
234 private:
235 
240  MixingMatrix & operator=(const MixingMatrix &) = delete;
241 
245  CMatrix mixingMatrix_;
246 
250  vector<long> ids_;
251 
255  pair<unsigned int,unsigned int> size_;
256 
260  friend ostream & operator<<(ostream & os,const MixingMatrix & mix);
261 };
262 
266  ostream & operator<<(ostream &,const MixingMatrix &);
267 }
268 
269 #endif /* HERWIG_MixingMatrix_H */
MixingMatrix()
Standard Constructor.
Definition: MixingMatrix.h:106
CMatrix getMatrix() const
Get the mixing matrix.
Definition: MixingMatrix.h:149
const vector< long > & getIds() const
Get the vector containing mixing particles codes.
Definition: MixingMatrix.h:175
std::complex< double > Complex
unsigned int row
row
Definition: MixingMatrix.h:46
ThePEG::Ptr< InterfacedBase >::pointer IBPtr
pair< unsigned int, unsigned int > MatrixSize
The size of the matrix.
Definition: MixingMatrix.h:67
MixingMatrix(const CMatrix &mix, const vector< long > &ids)
Constructor that takes a mixing matrix and a vector id&#39;s as arguments.
Definition: MixingMatrix.h:92
void setMatrix(const CMatrix &mixing)
Set the mixing matrix.
Definition: MixingMatrix.h:141
ostream & operator<<(ostream &, const DecayIntegrator &)
Output information on the DecayIntegrator for debugging purposes.
MixingElement(unsigned int irow, unsigned int icol, Complex ivalue)
Constructor.
Definition: MixingMatrix.h:40
Exception class to indicate problem with mixing matrix .
Definition: MixingMatrix.h:81
vector< vector< Complex > > CMatrix
A complex valued nested vector.
Definition: MixingMatrix.h:30
vector< MixingElement > MixingVector
A vector of mixing elements.
Definition: MixingMatrix.h:62
vector< long > ids_
The PDG codes of the mixing particles.
Definition: MixingMatrix.h:250
void setIds(const vector< long > &mixingCodes)
Set the vector containing mixing particles codes.
Definition: MixingMatrix.h:155
pair< unsigned int, unsigned int > size_
Size of matrix.
Definition: MixingMatrix.h:255
Complex & operator()(unsigned int row, unsigned int col)
Set element of matrix.
Definition: MixingMatrix.h:194
const Complex operator()(unsigned int row, unsigned int col) const
Access element of matrix.
Definition: MixingMatrix.h:187
MatrixSize size() const
Return the size of the mixing matrix.
Definition: MixingMatrix.h:215
Struct for the elements of a mixing matrix.
Definition: MixingMatrix.h:35
-*- C++ -*-
This class is desinged to store the mixing matrices needed for Susy studies.
Definition: MixingMatrix.h:78
Complex value
value
Definition: MixingMatrix.h:56
virtual IBPtr fullclone() const
Make a clone of this object, possibly modifying the cloned object to make it sane.
Definition: MixingMatrix.h:231
MixingMatrix(unsigned int row, unsigned int col)
Contructor that initializes size of matrix.
Definition: MixingMatrix.h:99
virtual IBPtr clone() const
Make a simple clone of this object.
Definition: MixingMatrix.h:225
CMatrix mixingMatrix_
The mixing matrix.
Definition: MixingMatrix.h:245
void addCode(long id)
Add a PDG code to the stored vector.
Definition: MixingMatrix.h:201
unsigned int col
column
Definition: MixingMatrix.h:51