herwig is hosted by Hepforge, IPPP Durham
Herwig 7.3.0
ColourBasis.h
1// -*- C++ -*-
2//
3// ColourBasis.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_ColourBasis_H
10#define HERWIG_ColourBasis_H
11//
12// This is the declaration of the ColourBasis class.
13//
14
15#include "ThePEG/Handlers/HandlerBase.h"
16
17#include "ThePEG/MatrixElement/Tree2toNDiagram.h"
18#include "ThePEG/MatrixElement/MEBase.h"
19
20#include "Herwig/MatrixElement/Matchbox/Utility/MatchboxXComb.h"
21#include "Herwig/MatrixElement/Matchbox/MatchboxFactory.fh"
22
23#include <iterator>
24#include <tuple>
25
26namespace Herwig {
27
28using std::iterator_traits;
29using std::distance;
30
31using namespace ThePEG;
32
33using boost::numeric::ublas::matrix;
34using boost::numeric::ublas::symmetric_matrix;
35using boost::numeric::ublas::compressed_matrix;
36using boost::numeric::ublas::upper;
37
46class ColourBasis: public HandlerBase {
47
48public:
49
56
60 virtual ~ColourBasis();
62
63public:
64
68 Ptr<MatchboxFactory>::tptr factory() const;
69
73 Ptr<ColourBasis>::ptr cloneMe() const {
74 return dynamic_ptr_cast<Ptr<ColourBasis>::ptr>(clone());
75 }
76
80 virtual void clear();
81
86 size_t prepare(const cPDVector&, bool);
87
91 size_t prepare(const MEBase::DiagramVector&, bool);
92
96 const map<cPDVector,map<size_t,size_t> >& indexMap() const { return theIndexMap; }
97
103 virtual map<size_t,vector<vector<size_t> > > basisList(const vector<PDT::Colour>&) const {
104 return map<size_t,vector<vector<size_t> > >();
105 }
106
114 const string& orderingString(const cPDVector& sub,
115 const map<size_t,size_t>& colourToAmplitude,
116 size_t tensorId);
117
125 const set<vector<size_t> >& ordering(const cPDVector& sub,
126 const map<size_t,size_t>& colourToAmplitude,
127 size_t tensorId, size_t shift = 0);
128
133 double me2(const cPDVector&, const map<vector<int>,CVector>&) const;
134
139 double interference(const cPDVector&,
140 const map<vector<int>,CVector>&,
141 const map<vector<int>,CVector>&) const;
142
147 double colourCorrelatedME2(const pair<size_t,size_t>&,
148 const cPDVector&,
149 const map<vector<int>,CVector>&) const;
150
156 const CVector&, const CVector&) const;
157
162 Complex colourCorrelatedInterference(const pair<size_t,size_t>&,
163 const cPDVector&,
164 const CVector&, const CVector&) const;
165
170 double me2(const cPDVector&, const matrix<Complex>&) const;
171
176 double colourCorrelatedME2(const pair<size_t,size_t>&,
177 const cPDVector&,
178 const matrix<Complex>&) const;
179
183 const symmetric_matrix<double,upper>& scalarProducts(const cPDVector&) const;
184
188 const symmetric_matrix<double,upper>& correlator(const cPDVector&,
189 const pair<size_t,size_t>&) const;
190
195 virtual bool haveColourFlows() const { return false; }
196
202 const map<vector<int>,CVector>& amps);
203
207 size_t tensorIdFromFlow(tcDiagPtr diag, const ColourLines * cl);
208
212 struct matchRep {
213 PDT::Colour m;
215 : m(n) {}
216 bool operator()(PDT::Colour c) const {
217 return c == m;
218 }
219 };
220
224 virtual bool largeN() const { return theLargeN; }
225
229 void doLargeN(bool yes = true) { theLargeN = yes; }
230
234 vector<PDT::Colour> projectColour(const cPDVector&) const;
235
241 virtual vector<PDT::Colour> normalOrder(const vector<PDT::Colour>&) const;
242
247 vector<PDT::Colour> normalOrderMap(const cPDVector& sub);
248
252 const vector<PDT::Colour>& normalOrderedLegs(const cPDVector& sub) const;
253
260 const std::tuple<vector<PDT::Colour>,vector<PDT::Colour>,
261 size_t,size_t,size_t,map<size_t,size_t> >&
263 const cPDVector& subTo,
264 size_t ij, size_t i, size_t j,
265 const map<size_t,size_t>& emissionMap);
266
271 const pair<compressed_matrix<double>,vector<pair<size_t,size_t> > >&
272 charge(const cPDVector& subFrom,
273 const cPDVector& subTo,
274 size_t ij, size_t i, size_t j,
275 const map<size_t,size_t>& emissionMap);
276
280 string file(const vector<PDT::Colour>&) const;
281
285 void chargeProduct(const compressed_matrix<double>& ti,
286 const vector<pair<size_t,size_t> >& tiNonZero,
287 const symmetric_matrix<double,upper>& X,
288 const compressed_matrix<double>& tj,
289 const vector<pair<size_t,size_t> >& tjNonZero,
290 symmetric_matrix<double,upper>& result) const;
291
295 void chargeProductAdd(const compressed_matrix<double>& ti,
296 const vector<pair<size_t,size_t> >& tiNonZero,
297 const matrix<Complex>& X,
298 const compressed_matrix<double>& tj,
299 const vector<pair<size_t,size_t> >& tjNonZero,
300 matrix<Complex>& result,
301 double factor = 1.) const;
302
303public:
304
308 static list<pair<int,bool> > colouredPath(pair<int,bool> a, pair<int,bool> b,
309 Ptr<Tree2toNDiagram>::tcptr);
310
314 static list<list<list<pair<int,bool> > > > colourFlows(Ptr<Tree2toNDiagram>::tcptr);
315
320 static string cfstring(const list<list<pair<int,bool> > >&);
321
326 virtual map<size_t,size_t> indexChange(const vector<PDT::Colour>&,
327 const size_t,
328 const map<size_t,size_t>&) const {
329 map<size_t,size_t> aMap;
330 return aMap;
331 }
332
333
334protected:
335
340 virtual size_t prepareBasis(const vector<PDT::Colour>&) = 0;
341
346 virtual double scalarProduct(size_t a, size_t b,
347 const vector<PDT::Colour>& abBasis) const = 0;
348
356 virtual double tMatrixElement(size_t i, size_t a, size_t b,
357 const vector<PDT::Colour>& aBasis,
358 const vector<PDT::Colour>& bBasis,
359 size_t k, size_t l,
360 const map<size_t,size_t>& dict) const = 0;
361
366 virtual bool colourConnected(const cPDVector&,
367 const vector<PDT::Colour>&,
368 const pair<int,bool>&,
369 const pair<int,bool>&,
370 size_t) const;
371
376 virtual bool colourConnected(const vector<PDT::Colour>&,
377 int, int, size_t) const {
378 return false;
379 }
380
384 vector<string> makeFlows(Ptr<Tree2toNDiagram>::tcptr, size_t) const;
385
389 map<Ptr<Tree2toNDiagram>::tcptr,vector<ColourLines*> >&
391
395 void updateColourLines(Ptr<Tree2toNDiagram>::tcptr);
396
397
398public:
399
407
413 void persistentInput(PersistentIStream & is, int version);
415
422 static void Init();
423
424
425// If needed, insert declarations of virtual function defined in the
426// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
427
428
429protected:
430
438 virtual void doinit();
439
444 virtual void doinitrun();
445
450 virtual void dofinish();
452
453private:
454
455 typedef map<vector<PDT::Colour>,symmetric_matrix<double,upper> >
456 ScalarProductMap;
457
458 typedef map<vector<PDT::Colour>,map<pair<size_t,size_t>,symmetric_matrix<double,upper> > >
459 CorrelatorMap;
460
461 typedef map<std::tuple<vector<PDT::Colour>,vector<PDT::Colour>,
462 size_t,size_t,size_t,map<size_t,size_t> >,
463 pair<compressed_matrix<double>,vector<pair<size_t,size_t> > > > TSMap;
464
469
473 map<cPDVector,vector<PDT::Colour> > theNormalOrderedLegs;
474
479 map<cPDVector,map<size_t,size_t> > theIndexMap;
480
484 map<std::tuple<cPDVector,cPDVector,
485 size_t,size_t,size_t,map<size_t,size_t> >,
486 std::tuple<vector<PDT::Colour>,vector<PDT::Colour>,
487 size_t,size_t,size_t,map<size_t,size_t> > >
489
494 ScalarProductMap theScalarProducts;
495
501 CorrelatorMap theCorrelators;
502
507
511 map<Ptr<Tree2toNDiagram>::tcptr,vector<string> > theFlowMap;
512
516 map<Ptr<Tree2toNDiagram>::tcptr,vector<ColourLines*> > theColourLineMap;
517
521 map<cPDVector,map<size_t,string> > theOrderingStringIdentifiers;
522
526 map<cPDVector,map<size_t,set<vector<size_t> > > > theOrderingIdentifiers;
527
531 void writeBasis(const string& prefix = "") const;
532
536 void readBasis();
537
541 bool readBasis(const vector<PDT::Colour>&);
542
546 virtual void readBasisDetails(const vector<PDT::Colour>&) {}
547
551 void write(const symmetric_matrix<double,upper>&, ostream&) const;
552
556 void read(symmetric_matrix<double,upper>&, istream&);
557
561 void write(const compressed_matrix<double>&, ostream&,
562 const vector<pair<size_t,size_t> >&) const;
563
567 void read(compressed_matrix<double>&, istream&,
568 vector<pair<size_t,size_t> >&);
569
575
580 mutable bool didWrite;
581
585 matrix<double> tmp;
586
591
596 ColourBasis & operator=(const ColourBasis &) = delete;
597
598};
599
600}
601
602#endif /* HERWIG_ColourBasis_H */
ColourBasis is an interface to a colour basis implementation.
Definition: ColourBasis.h:46
size_t prepare(const cPDVector &, bool)
Prepare for the given sub process and return the basis dimensionality.
virtual bool colourConnected(const cPDVector &, const vector< PDT::Colour > &, const pair< int, bool > &, const pair< int, bool > &, size_t) const
Return true, if a large-N colour connection exists for the given external legs and basis tensor.
const vector< PDT::Colour > & normalOrderedLegs(const cPDVector &sub) const
Get the normal ordered legs.
const symmetric_matrix< double, upper > & scalarProducts(const cPDVector &) const
Return the scalar product matrix for the given process.
virtual double scalarProduct(size_t a, size_t b, const vector< PDT::Colour > &abBasis) const =0
Return the scalar product of basis tensors labelled a and b in the basis used for the given normal or...
map< Ptr< Tree2toNDiagram >::tcptr, vector< string > > theFlowMap
Map diagrams to colour flows indexed by basis tensor.
Definition: ColourBasis.h:511
virtual map< size_t, vector< vector< size_t > > > basisList(const vector< PDT::Colour > &) const
Return a map of basis tensor indices to vectors identifying a certain ordering corresponding to the g...
Definition: ColourBasis.h:103
bool readBasis(const vector< PDT::Colour > &)
Read in the basis computation which are supposed to be known.
double colourCorrelatedME2(const pair< size_t, size_t > &, const cPDVector &, const matrix< Complex > &) const
For the given subprocess and amplitude given as amp amp^\dagger calculate the colour correlated ampli...
void read(compressed_matrix< double > &, istream &, vector< pair< size_t, size_t > > &)
Read in compressed matrices.
map< Ptr< Tree2toNDiagram >::tcptr, vector< ColourLines * > > & colourLineMap()
Return the colour line map.
void chargeProductAdd(const compressed_matrix< double > &ti, const vector< pair< size_t, size_t > > &tiNonZero, const matrix< Complex > &X, const compressed_matrix< double > &tj, const vector< pair< size_t, size_t > > &tjNonZero, matrix< Complex > &result, double factor=1.) const
Calculate T_i X T_j^\dagger.
virtual size_t prepareBasis(const vector< PDT::Colour > &)=0
Prepare the basis for the normal ordered legs and return the dimensionality of the basis.
const map< cPDVector, map< size_t, size_t > > & indexMap() const
Return the index map.
Definition: ColourBasis.h:96
virtual void doinitrun()
Initialize this object.
TSMap theCharges
Colour charge or quark splitting matrix representations.
Definition: ColourBasis.h:506
Ptr< MatchboxFactory >::tptr factory() const
Return the factory which produced this matrix element.
virtual bool haveColourFlows() const
Return true, if the colour basis is capable of assigning colour flows.
Definition: ColourBasis.h:195
static void Init()
The standard Init function used to initialize the interfaces.
Ptr< ColourBasis >::ptr cloneMe() const
Clone this colour basis.
Definition: ColourBasis.h:73
ColourBasis()
The default constructor.
Complex interference(const cPDVector &, const CVector &, const CVector &) const
For the given subprocess and amplitude vector calculate the amplitude squared.
double interference(const cPDVector &, const map< vector< int >, CVector > &, const map< vector< int >, CVector > &) const
For the given subprocess and amplitude vectors calculate the interference.
void write(const compressed_matrix< double > &, ostream &, const vector< pair< size_t, size_t > > &) const
Write out compressed matrices.
double me2(const cPDVector &, const matrix< Complex > &) const
For the given subprocess and amplitude given as amp amp^\dagger calculate the amplitude squared.
void persistentOutput(PersistentOStream &os) const
Function used to write out object persistently.
virtual void readBasisDetails(const vector< PDT::Colour > &)
Gather any implementation dependend details when reading a basis.
Definition: ColourBasis.h:546
virtual void doinit()
Initialize this object after the setup phase before saving an EventGenerator to disk.
bool theLargeN
True, if this basis is running in large-N mode.
Definition: ColourBasis.h:468
static list< list< list< pair< int, bool > > > > colourFlows(Ptr< Tree2toNDiagram >::tcptr)
Get all colour flows for the given diagram.
static list< pair< int, bool > > colouredPath(pair< int, bool > a, pair< int, bool > b, Ptr< Tree2toNDiagram >::tcptr)
Find a coloured path from a to b within the given diagram.
virtual bool largeN() const
Return true, if this basis is running in large-N mode.
Definition: ColourBasis.h:224
Selector< const ColourLines * > colourGeometries(tcDiagPtr diag, const map< vector< int >, CVector > &amps)
Return a Selector with possible colour geometries for the selected diagram weighted by their relative...
virtual vector< PDT::Colour > normalOrder(const vector< PDT::Colour > &) const
Perform a normal ordering of the external legs.
Complex colourCorrelatedInterference(const pair< size_t, size_t > &, const cPDVector &, const CVector &, const CVector &) const
For the given subprocess and amplitude vector calculate the colour correlated amplitude.
void read(symmetric_matrix< double, upper > &, istream &)
Read in symmetric matrices.
map< cPDVector, map< size_t, string > > theOrderingStringIdentifiers
Store ordering identifiers.
Definition: ColourBasis.h:521
size_t prepare(const MEBase::DiagramVector &, bool)
Prepare for the given diagrams.
void write(const symmetric_matrix< double, upper > &, ostream &) const
Write out symmetric matrices.
virtual map< size_t, size_t > indexChange(const vector< PDT::Colour > &, const size_t, const map< size_t, size_t > &) const
Returns a map of how the order of the vectors of a colour basis are changed when the indices are chan...
Definition: ColourBasis.h:326
void chargeProduct(const compressed_matrix< double > &ti, const vector< pair< size_t, size_t > > &tiNonZero, const symmetric_matrix< double, upper > &X, const compressed_matrix< double > &tj, const vector< pair< size_t, size_t > > &tjNonZero, symmetric_matrix< double, upper > &result) const
Calculate T_i^\dagger X T_j.
void readBasis()
Read in the basis computation which are supposed to be known.
CorrelatorMap theCorrelators
The correlator matrices T_i\cdot T_j -> T_i^\dagger S_{n+1} T_j with T_i = <c_{n+1,...
Definition: ColourBasis.h:501
size_t tensorIdFromFlow(tcDiagPtr diag, const ColourLines *cl)
Return the colour tensor used for the selected colour flow.
void doLargeN(bool yes=true)
Switch to large n.
Definition: ColourBasis.h:229
map< cPDVector, map< size_t, size_t > > theIndexMap
Index mappings to normal order from given leg assignments, indexed by the original leg assignment.
Definition: ColourBasis.h:479
vector< PDT::Colour > projectColour(const cPDVector &) const
Convert particle data to colour information.
string file(const vector< PDT::Colour > &) const
Convert the legs to a string.
string theSearchPath
The search path.
Definition: ColourBasis.h:590
map< cPDVector, map< size_t, set< vector< size_t > > > > theOrderingIdentifiers
Store ordering identifiers.
Definition: ColourBasis.h:526
map< Ptr< Tree2toNDiagram >::tcptr, vector< ColourLines * > > theColourLineMap
Map diagrams to colour line objects.
Definition: ColourBasis.h:516
map< cPDVector, vector< PDT::Colour > > theNormalOrderedLegs
Map external legs to normal ordered versions.
Definition: ColourBasis.h:473
const set< vector< size_t > > & ordering(const cPDVector &sub, const map< size_t, size_t > &colourToAmplitude, size_t tensorId, size_t shift=0)
Given a physical subprocess, a colour to amplitude label map and a basis tensor index,...
double me2(const cPDVector &, const map< vector< int >, CVector > &) const
For the given subprocess and amplitude vectors calculate the amplitude squared.
static string cfstring(const list< list< pair< int, bool > > > &)
Convert a flow to a string representation appropriate for ColourLines.
virtual void dofinish()
Finalize this object.
ScalarProductMap theScalarProducts
The scalar product matrix S_n = <c_{n,a}|c_{n,b}> , indexed by normal ordered leg assignments.
Definition: ColourBasis.h:494
matrix< double > tmp
Temporary storage.
Definition: ColourBasis.h:585
void writeBasis(const string &prefix="") const
Write out yet unknown basis computations.
virtual ~ColourBasis()
The destructor.
virtual bool colourConnected(const vector< PDT::Colour > &, int, int, size_t) const
Return true, if a large-N colour connection exists for the given external legs and basis tensor.
Definition: ColourBasis.h:376
ColourBasis & operator=(const ColourBasis &)=delete
The assignment operator is private and must never be called.
vector< PDT::Colour > normalOrderMap(const cPDVector &sub)
Determine the mapping of process to colour indices and return the normal ordered vector of colour ind...
const std::tuple< vector< PDT::Colour >, vector< PDT::Colour >, size_t, size_t, size_t, map< size_t, size_t > > & normalOrderEmissionMap(const cPDVector &subFrom, const cPDVector &subTo, size_t ij, size_t i, size_t j, const map< size_t, size_t > &emissionMap)
Generate the emission/splitting map for basis labels from sub-process information; we consider the sp...
void updateColourLines(Ptr< Tree2toNDiagram >::tcptr)
Update the colour line map for a given diagram.
const pair< compressed_matrix< double >, vector< pair< size_t, size_t > > > & charge(const cPDVector &subFrom, const cPDVector &subTo, size_t ij, size_t i, size_t j, const map< size_t, size_t > &emissionMap)
Return the colour charge matrix representation for the given splitting ij -> i,j with other legs rela...
virtual void clear()
Clear this colour basis.
double colourCorrelatedME2(const pair< size_t, size_t > &, const cPDVector &, const map< vector< int >, CVector > &) const
For the given subprocess and amplitude vector calculate the colour correlated amplitude.
vector< string > makeFlows(Ptr< Tree2toNDiagram >::tcptr, size_t) const
Match up colour flows for given diagram to basis tensors.
const symmetric_matrix< double, upper > & correlator(const cPDVector &, const pair< size_t, size_t > &) const
Return the correlator matrix for the given process.
virtual double tMatrixElement(size_t i, size_t a, size_t b, const vector< PDT::Colour > &aBasis, const vector< PDT::Colour > &bBasis, size_t k, size_t l, const map< size_t, size_t > &dict) const =0
Return the matrix element of a colour charge or quark splitting <c_{n+1,a}|T_i|c_{n,...
const string & orderingString(const cPDVector &sub, const map< size_t, size_t > &colourToAmplitude, size_t tensorId)
Given a physical subprocess, a colour to amplitude label map and a basis tensor index,...
bool didWrite
True, if an attempt to write out basis information has been completed.
Definition: ColourBasis.h:580
void persistentInput(PersistentIStream &is, int version)
Function used to read in object persistently.
bool didRead
True, if an attempt to read in basis information has been completed.
Definition: ColourBasis.h:574
map< std::tuple< cPDVector, cPDVector, size_t, size_t, size_t, map< size_t, size_t > >, std::tuple< vector< PDT::Colour >, vector< PDT::Colour >, size_t, size_t, size_t, map< size_t, size_t > > > theEmissionMaps
Translations of emission maps.
Definition: ColourBasis.h:488
virtual IBPtr clone() const=0
vector< DiagPtr > DiagramVector
boost::numeric::ublas::vector< Complex > CVector
Define complex vector from boost::uBLAS.
-*- C++ -*-
std::complex< double > Complex
vector< cPDPtr > cPDVector
Match colour representation.
Definition: ColourBasis.h:212