herwig
is hosted by
Hepforge
,
IPPP Durham
Herwig
7.3.0
MatrixElement
Matchbox
Utility
AmplitudeCache.h
1
// -*- C++ -*-
2
//
3
// AmplitudeCache.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_AmplitudeCache_H
10
#define HERWIG_AmplitudeCache_H
11
12
#include "Herwig/MatrixElement/Matchbox/Utility/SpinorHelicity.h"
13
#include "
ThePEG/Config/algorithm.h
"
14
#include <array>
15
16
namespace
Herwig
{
17
18
using namespace
ThePEG
;
19
using
std::array;
20
21
namespace
SpinorHelicity {
22
30
template
<
typename
AmplitudeKey>
31
class
AmplitudeCache
{
32
33
typedef
map<AmplitudeKey,pair<bool,Complex> > AmplitudeCacheMap;
34
typedef
map<AmplitudeKey,pair<bool,LorentzVector<Complex> > > CurrentCacheMap;
35
39
enum
{ MAX_N = 7, SYM_N = MAX_N*(MAX_N+1)/2 };
40
44
int
theNPoints
;
45
50
mutable
Energy
theScale
;
51
55
mutable
array<double,MAX_N>
theMasses
;
56
60
mutable
array<LorentzMomentum,MAX_N>
theMomenta
;
61
65
mutable
array<int,MAX_N>
theCrossingSigns
;
66
70
mutable
array<PlusSpinor,MAX_N>
thePlusSpinors
;
71
75
mutable
array<PlusConjugateSpinor,MAX_N>
thePlusConjugateSpinors
;
76
80
mutable
array<double,SYM_N>
theInvariants
;
81
85
mutable
array<bool,SYM_N>
getInvariant
;
86
90
mutable
array<Complex,SYM_N>
thePlusProducts
;
91
95
mutable
array<bool,SYM_N>
getPlusProduct
;
96
100
mutable
array<LorentzVector<Complex>,SYM_N>
thePlusCurrents
;
101
105
mutable
array<bool,SYM_N>
getPlusCurrent
;
106
110
mutable
AmplitudeCacheMap
theCachedAmplitudes
;
111
115
mutable
typename
AmplitudeCacheMap::iterator
theLastAmplitude
;
116
120
mutable
CurrentCacheMap
theCachedCurrents
;
121
125
mutable
typename
CurrentCacheMap::iterator
theLastCurrent
;
126
131
inline
size_t
idx
(
size_t
i,
size_t
j)
const
{
132
return
MAX_N * i - (i + 1) * i / 2 + j;
133
}
134
138
struct
boolResetter
{
139
void
operator()(pair<
const
AmplitudeKey,pair<bool,Complex> >& flag)
const
{
140
flag.second.first =
true
;
141
}
142
void
operator()(pair<
const
AmplitudeKey,pair<
bool
,
LorentzVector<Complex>
> >& flag)
const
{
143
flag.second.first =
true
;
144
}
145
};
146
147
public
:
148
152
AmplitudeCache
() :
theNPoints
(0) {}
153
157
void
nPoints
(
int
n);
158
162
int
nPoints
()
const
{
163
return
theNPoints
;
164
}
165
170
void
amplitudeScale
(Energy s)
const
;
171
176
void
momentum
(
int
k,
const
LorentzMomentum& p,
177
bool
getSpinors =
true
,
178
Energy
mass
=
ZERO
)
const
;
179
183
void
reset
()
const
;
184
185
public
:
186
190
LorentzVector<double>
momentum
(
int
k)
const
{
return
theMomenta
[k]/
theScale
; }
191
196
Energy
amplitudeScale
()
const
{
return
theScale
; }
197
201
double
mass
(
int
k)
const
{
return
theMasses
[k]; }
202
207
int
crossingSign
(
int
i)
const
{
return
theCrossingSigns
[i]; }
208
213
double
crossingSign
(
int
i,
int
j)
const
{
return
theCrossingSigns
[i]*
theCrossingSigns
[j]; }
214
218
double
invariant
(
int
i,
int
j)
const
{
219
if
( i == j )
return
0.;
220
if
( i > j ) swap(i,j);
221
if
(
getInvariant
[
idx
(i,j)] ) {
222
getInvariant
[
idx
(i,j)] =
false
;
223
theInvariants
[
idx
(i,j)] = 2.*(
momentum
(i)*
momentum
(j));
224
}
225
return
theInvariants
[
idx
(i,j)];
226
}
227
231
Complex
plusProduct
(
int
i,
int
j)
const
{
232
if
( i== j )
233
return
0.;
234
bool
swapij = (i > j);
235
if
( swapij )
236
swap(i,j);
237
if
(
getPlusProduct
[
idx
(i,j)] ) {
238
getPlusProduct
[
idx
(i,j)] =
false
;
239
thePlusProducts
[
idx
(i,j)] =
240
Complex
(
PlusSpinorProduct
(
thePlusConjugateSpinors
[i],
241
thePlusSpinors
[j]).eval() /
theScale
);
242
}
243
return
swapij ? -
thePlusProducts
[
idx
(i,j)] :
thePlusProducts
[
idx
(i,j)];
244
}
245
249
Complex
minusProduct
(
int
i,
int
j)
const
{
250
if
( i== j )
251
return
0.;
252
return
-
crossingSign
(i,j)*conj(
plusProduct
(i,j));
253
}
254
258
LorentzVector<Complex>
plusCurrent
(
int
i,
int
j)
const
{
259
bool
swapij = (i > j);
260
if
( swapij )
261
swap(i,j);
262
if
(
getPlusCurrent
[
idx
(i,j)] ) {
263
getPlusCurrent
[
idx
(i,j)] =
false
;
264
if
( i != j ) {
265
thePlusCurrents
[
idx
(i,j)] =
266
PlusSpinorCurrent
(
thePlusConjugateSpinors
[i],
267
MinusSpinor
(
theMomenta
[j])).
eval
() /
theScale
;
268
}
else
{
269
thePlusCurrents
[
idx
(i,j)] = 2.*
momentum
(i);
270
}
271
}
272
return
swapij ?
crossingSign
(i,j)*
thePlusCurrents
[
idx
(i,j)].conjugate() :
thePlusCurrents
[
idx
(i,j)];
273
}
274
278
LorentzVector<Complex>
minusCurrent
(
int
i,
int
j)
const
{
279
return
plusCurrent
(j,i);
280
}
281
282
public
:
283
288
bool
getAmplitude
(
const
AmplitudeKey& key)
const
{
289
static
Complex
czero;
290
if
( (
theLastAmplitude
=
theCachedAmplitudes
.find(key) )
291
==
theCachedAmplitudes
.end() ) {
292
theLastAmplitude
=
theCachedAmplitudes
.insert(make_pair(key,make_pair(
true
,czero))).first;
293
}
294
return
theLastAmplitude
->second.first;
295
}
296
300
void
cacheAmplitude
(
Complex
amp)
const
{
301
theLastAmplitude
->second = make_pair(
false
,amp);
302
}
303
307
const
Complex
&
cachedAmplitude
()
const
{
308
return
theLastAmplitude
->second.second;
309
}
310
315
bool
getCurrent
(
const
AmplitudeKey& key)
const
{
316
static
LorentzVector<Complex>
czero;
317
if
( (
theLastCurrent
=
theCachedCurrents
.find(key) )
318
==
theCachedCurrents
.end() ) {
319
theLastCurrent
=
theCachedCurrents
.insert(make_pair(key,make_pair(
true
,czero))).first;
320
}
321
return
theLastCurrent
->second.first;
322
}
323
327
void
cacheCurrent
(
const
LorentzVector<Complex>
& curr)
const
{
328
theLastCurrent
->second = make_pair(
false
,curr);
329
}
330
334
const
LorentzVector<Complex>
&
cachedCurrent
()
const
{
335
return
theLastCurrent
->second.second;
336
}
337
338
};
339
340
}
341
342
}
343
344
#include "AmplitudeCache.tcc"
345
346
#endif
// HERWIG_AmplitudeCache_H
algorithm.h
Herwig::SpinorHelicity::AmplitudeCache
Caching for amplitudes using spinor helicity techniques.
Definition:
AmplitudeCache.h:31
Herwig::SpinorHelicity::AmplitudeCache::reset
void reset() const
Reset flags.
Herwig::SpinorHelicity::AmplitudeCache::theCachedCurrents
CurrentCacheMap theCachedCurrents
Cache intermediate currents by index.
Definition:
AmplitudeCache.h:120
Herwig::SpinorHelicity::AmplitudeCache::thePlusSpinors
array< PlusSpinor, MAX_N > thePlusSpinors
Plus spinors indexed by partons.
Definition:
AmplitudeCache.h:70
Herwig::SpinorHelicity::AmplitudeCache::crossingSign
int crossingSign(int i) const
Return the crossing sign for the i'th parton.
Definition:
AmplitudeCache.h:207
Herwig::SpinorHelicity::AmplitudeCache::plusCurrent
LorentzVector< Complex > plusCurrent(int i, int j) const
Return <i|\gamma^\mu|j].
Definition:
AmplitudeCache.h:258
Herwig::SpinorHelicity::AmplitudeCache::cachedCurrent
const LorentzVector< Complex > & cachedCurrent() const
Return a cached current.
Definition:
AmplitudeCache.h:334
Herwig::SpinorHelicity::AmplitudeCache::idx
size_t idx(size_t i, size_t j) const
Helper function to index symmetric arrays, assumes i <= j.
Definition:
AmplitudeCache.h:131
Herwig::SpinorHelicity::AmplitudeCache::invariant
double invariant(int i, int j) const
Return (ij)
Definition:
AmplitudeCache.h:218
Herwig::SpinorHelicity::AmplitudeCache::theCachedAmplitudes
AmplitudeCacheMap theCachedAmplitudes
Cache intermediate amplitudes by index.
Definition:
AmplitudeCache.h:110
Herwig::SpinorHelicity::AmplitudeCache::amplitudeScale
Energy amplitudeScale() const
Get the energy scale to obtain dimensionless quantities and flag all quantities to be recalculated.
Definition:
AmplitudeCache.h:196
Herwig::SpinorHelicity::AmplitudeCache::momentum
void momentum(int k, const LorentzMomentum &p, bool getSpinors=true, Energy mass=ZERO) const
Set the momentum for the k'th parton and its associated mass.
Herwig::SpinorHelicity::AmplitudeCache::minusProduct
Complex minusProduct(int i, int j) const
Return [ij].
Definition:
AmplitudeCache.h:249
Herwig::SpinorHelicity::AmplitudeCache::thePlusCurrents
array< LorentzVector< Complex >, SYM_N > thePlusCurrents
Spinor currents indexed by partons.
Definition:
AmplitudeCache.h:100
Herwig::SpinorHelicity::AmplitudeCache::AmplitudeCache
AmplitudeCache()
Constructor.
Definition:
AmplitudeCache.h:152
Herwig::SpinorHelicity::AmplitudeCache::momentum
LorentzVector< double > momentum(int k) const
Return the momentum for the k'th parton.
Definition:
AmplitudeCache.h:190
Herwig::SpinorHelicity::AmplitudeCache::crossingSign
double crossingSign(int i, int j) const
Return the crossing sign for the i'th and j'th parton.
Definition:
AmplitudeCache.h:213
Herwig::SpinorHelicity::AmplitudeCache::cachedAmplitude
const Complex & cachedAmplitude() const
Return a cached amplitude.
Definition:
AmplitudeCache.h:307
Herwig::SpinorHelicity::AmplitudeCache::nPoints
int nPoints() const
Return the number of points.
Definition:
AmplitudeCache.h:162
Herwig::SpinorHelicity::AmplitudeCache::amplitudeScale
void amplitudeScale(Energy s) const
Set the energy scale to obtain dimensionless quantities and flag all quantities to be recalculated.
Herwig::SpinorHelicity::AmplitudeCache::theInvariants
array< double, SYM_N > theInvariants
Invariants indexed by partons.
Definition:
AmplitudeCache.h:80
Herwig::SpinorHelicity::AmplitudeCache::cacheAmplitude
void cacheAmplitude(Complex amp) const
Cache an amplitude.
Definition:
AmplitudeCache.h:300
Herwig::SpinorHelicity::AmplitudeCache::thePlusProducts
array< Complex, SYM_N > thePlusProducts
Spinor products indexed by partons.
Definition:
AmplitudeCache.h:90
Herwig::SpinorHelicity::AmplitudeCache::theNPoints
int theNPoints
The number of points.
Definition:
AmplitudeCache.h:44
Herwig::SpinorHelicity::AmplitudeCache::getPlusProduct
array< bool, SYM_N > getPlusProduct
Flag products to be recalculated.
Definition:
AmplitudeCache.h:95
Herwig::SpinorHelicity::AmplitudeCache::getCurrent
bool getCurrent(const AmplitudeKey &key) const
Return true, if the given current needs to be recalculated.
Definition:
AmplitudeCache.h:315
Herwig::SpinorHelicity::AmplitudeCache::mass
double mass(int k) const
Return the mass associated to the k'th parton.
Definition:
AmplitudeCache.h:201
Herwig::SpinorHelicity::AmplitudeCache::theScale
Energy theScale
The energy scale to obtain dimensionless quantities.
Definition:
AmplitudeCache.h:50
Herwig::SpinorHelicity::AmplitudeCache::cacheCurrent
void cacheCurrent(const LorentzVector< Complex > &curr) const
Cache an current.
Definition:
AmplitudeCache.h:327
Herwig::SpinorHelicity::AmplitudeCache::theMasses
array< double, MAX_N > theMasses
Masses indexed by partons.
Definition:
AmplitudeCache.h:55
Herwig::SpinorHelicity::AmplitudeCache::getAmplitude
bool getAmplitude(const AmplitudeKey &key) const
Return true, if the given amplitude needs to be recalculated.
Definition:
AmplitudeCache.h:288
Herwig::SpinorHelicity::AmplitudeCache::theCrossingSigns
array< int, MAX_N > theCrossingSigns
Crossing signs indexed by partons.
Definition:
AmplitudeCache.h:65
Herwig::SpinorHelicity::AmplitudeCache::minusCurrent
LorentzVector< Complex > minusCurrent(int i, int j) const
Return [i|\gamma^\mu|j>
Definition:
AmplitudeCache.h:278
Herwig::SpinorHelicity::AmplitudeCache::theMomenta
array< LorentzMomentum, MAX_N > theMomenta
Momenta indexed by partons.
Definition:
AmplitudeCache.h:60
Herwig::SpinorHelicity::AmplitudeCache::plusProduct
Complex plusProduct(int i, int j) const
Return <ij>
Definition:
AmplitudeCache.h:231
Herwig::SpinorHelicity::AmplitudeCache::thePlusConjugateSpinors
array< PlusConjugateSpinor, MAX_N > thePlusConjugateSpinors
Plus conjugate spinors indexed by partons.
Definition:
AmplitudeCache.h:75
Herwig::SpinorHelicity::AmplitudeCache::getPlusCurrent
array< bool, SYM_N > getPlusCurrent
Flag currents to be recalculated.
Definition:
AmplitudeCache.h:105
Herwig::SpinorHelicity::AmplitudeCache::nPoints
void nPoints(int n)
Prepare for n-point amplitude.
Herwig::SpinorHelicity::AmplitudeCache::theLastAmplitude
AmplitudeCacheMap::iterator theLastAmplitude
The last query for a cached amplitude.
Definition:
AmplitudeCache.h:115
Herwig::SpinorHelicity::AmplitudeCache::getInvariant
array< bool, SYM_N > getInvariant
Flag products to be recalculated.
Definition:
AmplitudeCache.h:85
Herwig::SpinorHelicity::AmplitudeCache::theLastCurrent
CurrentCacheMap::iterator theLastCurrent
The last query for a cached current.
Definition:
AmplitudeCache.h:125
Herwig::SpinorHelicity::SpinorCurrent
Weyl spinor current.
Definition:
SpinorHelicity.h:335
Herwig::SpinorHelicity::SpinorCurrent::eval
ResultType eval() const
Return result.
Definition:
SpinorHelicity.h:390
Herwig::SpinorHelicity::SpinorProduct
Weyl spinor product.
Definition:
SpinorHelicity.h:256
Herwig::SpinorHelicity::WeylSpinor
Base class for Weyl spinors.
Definition:
SpinorHelicity.h:183
ThePEG::LorentzVector
Herwig
-*- C++ -*-
Definition:
BasicConsistency.h:17
ThePEG
ThePEG::Complex
std::complex< double > Complex
ThePEG::ZERO
constexpr ZeroUnit ZERO
Herwig::SpinorHelicity::AmplitudeCache::boolResetter
Helper to reset flags.
Definition:
AmplitudeCache.h:138
Generated on Thu Jun 20 2024 17:50:53 for Herwig by
1.9.6