File indexing completed on 2026-08-06 09:24:19
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef HERWIG_MixingMatrix_H
0010 #define HERWIG_MixingMatrix_H
0011
0012
0013
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
0025
0026
0027
0028
0029
0030 typedef vector<vector<Complex> > CMatrix;
0031
0032
0033
0034
0035 struct MixingElement{
0036
0037
0038
0039
0040 MixingElement(unsigned int irow, unsigned int icol,Complex ivalue)
0041 : row(irow), col(icol), value(ivalue) {}
0042
0043
0044
0045
0046 unsigned int row;
0047
0048
0049
0050
0051 unsigned int col;
0052
0053
0054
0055
0056 Complex value;
0057 };
0058
0059
0060
0061
0062 typedef vector<MixingElement> MixingVector;
0063
0064
0065
0066
0067 typedef pair<unsigned int, unsigned int> MatrixSize;
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078 class MixingMatrix: public Interfaced {
0079
0080
0081 class MixingMatrixError : public Exception {};
0082
0083 public:
0084
0085
0086
0087
0088
0089
0090
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
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
0105
0106 MixingMatrix() {}
0107
0108
0109 public:
0110
0111
0112
0113
0114
0115
0116
0117 void persistentOutput(PersistentOStream & os) const;
0118
0119
0120
0121
0122
0123
0124 void persistentInput(PersistentIStream & is, int version);
0125
0126
0127
0128
0129
0130
0131
0132
0133 static void Init();
0134
0135
0136
0137
0138
0139
0140
0141 void setMatrix(const CMatrix & mixing) {
0142 mixingMatrix_ = mixing;
0143 size_ = make_pair(mixing.size(),mixing[0].size());
0144 }
0145
0146
0147
0148
0149 CMatrix getMatrix() const {return mixingMatrix_;}
0150
0151
0152
0153
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
0174
0175 const vector<long> & getIds() const {return ids_;}
0176
0177
0178
0179
0180
0181
0182 void adjustPhase(long id);
0183
0184
0185
0186
0187 const Complex operator()(unsigned int row, unsigned int col) const {
0188 return mixingMatrix_.at(row).at(col);
0189 }
0190
0191
0192
0193
0194 Complex & operator()(unsigned int row, unsigned int col) {
0195 return mixingMatrix_.at(row).at(col);
0196 }
0197
0198
0199
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
0214
0215 MatrixSize size() const {return size_;}
0216
0217 protected:
0218
0219
0220
0221
0222
0223
0224
0225 virtual IBPtr clone() const {return new_ptr(*this);}
0226
0227
0228
0229
0230
0231 virtual IBPtr fullclone() const {return new_ptr(*this);}
0232
0233
0234 private:
0235
0236
0237
0238
0239
0240 MixingMatrix & operator=(const MixingMatrix &) = delete;
0241
0242
0243
0244
0245 CMatrix mixingMatrix_;
0246
0247
0248
0249
0250 vector<long> ids_;
0251
0252
0253
0254
0255 pair<unsigned int,unsigned int> size_;
0256
0257
0258
0259
0260 friend ostream & operator<<(ostream & os,const MixingMatrix & mix);
0261 };
0262
0263
0264
0265
0266 ostream & operator<<(ostream &,const MixingMatrix &);
0267 }
0268
0269 #endif