herwig is hosted by Hepforge, IPPP Durham
Herwig 7.3.0
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
21namespace Herwig {
22using namespace ThePEG;
23
24/*@name Some convenient typedefs. */
26
30 typedef vector<vector<Complex> > CMatrix;
31
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
78class MixingMatrix: public Interfaced {
79
81 class MixingMatrixError : public Exception {};
82
83public:
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
109public:
110
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
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
217protected:
218
225 virtual IBPtr clone() const {return new_ptr(*this);}
226
231 virtual IBPtr fullclone() const {return new_ptr(*this);}
233
234private:
235
241
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 */
Exception class to indicate problem with mixing matrix .
Definition: MixingMatrix.h:81
This class is desinged to store the mixing matrices needed for Susy studies.
Definition: MixingMatrix.h:78
friend ostream & operator<<(ostream &os, const MixingMatrix &mix)
Print the matrix to the stream.
CMatrix mixingMatrix_
The mixing matrix.
Definition: MixingMatrix.h:245
MixingMatrix()
Standard Constructor.
Definition: MixingMatrix.h:106
void persistentOutput(PersistentOStream &os) const
Function used to write out object persistently.
MatrixSize size() const
Return the size of the mixing matrix.
Definition: MixingMatrix.h:215
MixingMatrix(unsigned int row, unsigned int col)
Contructor that initializes size of matrix.
Definition: MixingMatrix.h:99
vector< long > ids_
The PDG codes of the mixing particles.
Definition: MixingMatrix.h:250
virtual IBPtr fullclone() const
Make a clone of this object, possibly modifying the cloned object to make it sane.
Definition: MixingMatrix.h:231
MixingMatrix(const CMatrix &mix, const vector< long > &ids)
Constructor that takes a mixing matrix and a vector id's as arguments.
Definition: MixingMatrix.h:92
const vector< long > & getIds() const
Get the vector containing mixing particles codes.
Definition: MixingMatrix.h:175
void persistentInput(PersistentIStream &is, int version)
Function used to read in object persistently.
CMatrix getMatrix() const
Get the mixing matrix.
Definition: MixingMatrix.h:149
void setIds(const vector< long > &mixingCodes)
Set the vector containing mixing particles codes.
Definition: MixingMatrix.h:155
static void Init()
The standard Init function used to initialize the interfaces.
void adjustPhase(long id)
Multiply row corresponding to id by .
MixingMatrix & operator=(const MixingMatrix &)=delete
The assignment operator is private and must never be called.
void setMatrix(const CMatrix &mixing)
Set the mixing matrix.
Definition: MixingMatrix.h:141
pair< unsigned int, unsigned int > size_
Size of matrix.
Definition: MixingMatrix.h:255
virtual IBPtr clone() const
Make a simple clone of this object.
Definition: MixingMatrix.h:225
const Complex operator()(unsigned int row, unsigned int col) const
Access element of matrix.
Definition: MixingMatrix.h:187
Complex & operator()(unsigned int row, unsigned int col)
Set element of matrix.
Definition: MixingMatrix.h:194
void addCode(long id)
Add a PDG code to the stored vector.
Definition: MixingMatrix.h:201
-*- C++ -*-
vector< MixingElement > MixingVector
A vector of mixing elements.
Definition: MixingMatrix.h:62
pair< unsigned int, unsigned int > MatrixSize
The size of the matrix.
Definition: MixingMatrix.h:67
vector< vector< Complex > > CMatrix
A complex valued nested vector.
Definition: MixingMatrix.h:30
std::complex< double > Complex
ThePEG::Ptr< InterfacedBase >::pointer IBPtr
ostream & operator<<(ostream &, const Collision &)
Struct for the elements of a mixing matrix.
Definition: MixingMatrix.h:35
unsigned int row
row
Definition: MixingMatrix.h:46
MixingElement(unsigned int irow, unsigned int icol, Complex ivalue)
Constructor.
Definition: MixingMatrix.h:40
unsigned int col
column
Definition: MixingMatrix.h:51
Complex value
value
Definition: MixingMatrix.h:56