herwig is hosted by Hepforge, IPPP Durham
Herwig 7.3.0
MatchboxPhasespace.h
1// -*- C++ -*-
2//
3// MatchboxPhasespace.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_MatchboxPhasespace_H
10#define HERWIG_MatchboxPhasespace_H
11//
12// This is the declaration of the MatchboxPhasespace class.
13//
14
15#include "ThePEG/Handlers/StandardXComb.h"
16#include "ThePEG/Handlers/HandlerBase.h"
17#include "ThePEG/MatrixElement/Tree2toNDiagram.h"
18#include "Herwig/MatrixElement/Matchbox/Utility/LastMatchboxXCombInfo.h"
19#include "Herwig/MatrixElement/Matchbox/Utility/ProcessData.fh"
20#include "Herwig/MatrixElement/Matchbox/MatchboxFactory.fh"
21#include "Herwig/MatrixElement/Matchbox/Phasespace/PhasespaceCouplings.h"
22
23namespace Herwig {
24
25using namespace ThePEG;
26
35
39 const double* numbers;
40
44 size_t nRnd;
45
50 : numbers(0), nRnd(0) {}
51
55 explicit StreamingRnd(const double* newNumbers,
56 size_t n)
57 : numbers(newNumbers), nRnd(n) {}
58
62 inline double operator()() {
63 assert(numbers && nRnd > 0);
64 const double ret = numbers[0];
65 ++numbers; --nRnd;
66 return ret;
67 }
68
69};
70
80 public HandlerBase,
81 public LastXCombInfo<StandardXComb>,
83
84public:
85
90
91public:
92
97 virtual void setXComb(tStdXCombPtr xc) {
98 theLastXComb = xc;
100 }
101
105 Ptr<MatchboxFactory>::tcptr factory() const;
106
110 Ptr<ProcessData>::tptr processData() const;
111
115 virtual double generateKinematics(const double* r,
116 vector<Lorentz5Momentum>& momenta);
117
121 virtual double generateTwoToNKinematics(const double*,
122 vector<Lorentz5Momentum>& momenta) = 0;
123
127 virtual double generateTwoToOneKinematics(const double*,
128 vector<Lorentz5Momentum>& momenta);
129
134 virtual int nDim(const cPDVector&) const;
135
140 virtual int nDimPhasespace(int nFinal) const = 0;
141
146 virtual bool haveX1X2() const { return false; }
147
152 virtual bool wantCMS() const { return true; }
153
158
163
168 pair<double,Lorentz5Momentum> timeLikeWeight(const Tree2toNDiagram& diag,
169 int branch, double flatCut) const;
170
176 const Lorentz5Momentum& incoming,
177 int branch, double flatCut) const;
178
182 double diagramWeight(const Tree2toNDiagram& diag) const {
183 assert( !diagramWeights().empty() );
184 return diagramWeights().find(diag.id())->second;
185 }
186
190 void fillDiagramWeights(double flatCut = 0.0);
191
196 diagramWeights().clear();
197 }
198
202 Ptr<MatchboxPhasespace>::ptr cloneMe() const {
203 return dynamic_ptr_cast<Ptr<MatchboxPhasespace>::ptr>(clone());
204 }
205
209 virtual void cloneDependencies(const std::string& prefix = "");
210
211public:
212
216 virtual bool isInvertible() const { return false; }
217
222 virtual double invertKinematics(const vector<Lorentz5Momentum>& momenta,
223 double* r) const;
224
229 virtual double invertTwoToNKinematics(const vector<Lorentz5Momentum>&,
230 double*) const {
231 return 0.;
232 }
233
238 virtual double invertTwoToOneKinematics(const vector<Lorentz5Momentum>&, double*) const;
239
240public:
241
245 void singularLimit(size_t i, size_t j) {
246 if ( i > j )
247 swap(i,j);
248 singularLimits().insert(make_pair(i,j));
249 }
250
254 const pair<size_t,size_t>& lastSingularIndices() const {
255 assert(lastSingularLimit() != singularLimits().end());
256 return *lastSingularLimit();
257 }
258
262 bool matchConstraints(const vector<Lorentz5Momentum>& momenta);
263
264protected:
265
271 void setCoupling(long a, long b, long c,
272 double coupling, bool includeCrossings = true);
273
274public:
275
283
289 void persistentInput(PersistentIStream & is, int version);
291
292public:
293
300 static void Init();
301
302
303// If needed, insert declarations of virtual function defined in the
304// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
305
306
307private:
308
313
318
322 Ptr<PhasespaceCouplings>::ptr theCouplings;
323
327 string doSetCoupling(string);
328
332 string doSetPhysicalCoupling(string);
333
340
347
353
354};
355
356}
357
358#endif /* HERWIG_MatchboxPhasespace_H */
Provide easy access to MatchboxXComb XComb extensions.
const set< pair< size_t, size_t > > & singularLimits() const
Return the singular limits.
const map< int, double > & diagramWeights() const
Return the diagram weights indexed by diagram id.
const set< pair< size_t, size_t > >::const_iterator & lastSingularLimit() const
Return the last matched singular limit.
MatchboxXCombData * lastMatchboxXComb() const
Return a pointer to the last selected XComb.
MatchboxPhasespace defines an abstract interface to a phase space generator.
virtual bool isInvertible() const
Return true, if this phase space generator is invertible.
MatchboxPhasespace & operator=(const MatchboxPhasespace &)=delete
The assignment operator is private and must never be called.
void persistentOutput(PersistentOStream &os) const
Function used to write out object persistently.
Ptr< MatchboxPhasespace >::ptr cloneMe() const
Clone this phase space generator.
virtual bool wantCMS() const
Return true, if this phase space generator expects the incoming partons in their center-of-mass syste...
MatchboxPhasespace()
The default constructor.
Ptr< MatchboxFactory >::tcptr factory() const
Return the factory object.
virtual int nDim(const cPDVector &) const
Return the number of random numbers required to produce a given multiplicity final state.
string doSetCoupling(string)
Interface function to setcoupling.
virtual int nDimPhasespace(int nFinal) const =0
Return the number of random numbers required to produce a given multiplicity final state.
void persistentInput(PersistentIStream &is, int version)
Function used to read in object persistently.
int theLoopParticleIdMax
The last id in a range of id's meant to denote fictitious 'ghost' particles to be used by the diagram...
virtual void cloneDependencies(const std::string &prefix="")
Clone the dependencies, using a given prefix.
virtual Selector< MEBase::DiagramIndex > selectDiagrams(const MEBase::DiagramVector &) const
Fill a diagram selector for the last phase space point.
Ptr< ProcessData >::tptr processData() const
Return the process data object.
virtual double generateTwoToNKinematics(const double *, vector< Lorentz5Momentum > &momenta)=0
Generate a phase space point and return its weight.
void singularLimit(size_t i, size_t j)
Limit phasespace generation to a given collinear or soft limit.
Energy singularCutoff
A cutoff below which a region is considered singular.
static void Init()
The standard Init function used to initialize the interfaces.
virtual bool haveX1X2() const
Return true, if this phasespace generator will generate incoming partons itself.
double diagramWeight(const Tree2toNDiagram &diag) const
Return the weight appropriate to the given diagram.
virtual double generateKinematics(const double *r, vector< Lorentz5Momentum > &momenta)
Generate a phase space point and return its weight.
bool matchConstraints(const vector< Lorentz5Momentum > &momenta)
Return true, if constraints on phasespace generation have been met.
bool theUseMassGenerators
True, if mass generators should be used instead of fixed masses.
const pair< size_t, size_t > & lastSingularIndices() const
Return the last matched singular limit.
void setCoupling(long a, long b, long c, double coupling, bool includeCrossings=true)
Set a coupling for the given vertex; the convention is that all legs are outgoing,...
virtual double invertTwoToNKinematics(const vector< Lorentz5Momentum > &, double *) const
Invert the given phase space point to the random numbers which would have generated it.
virtual double generateTwoToOneKinematics(const double *, vector< Lorentz5Momentum > &momenta)
Generate a 2 -> 1 phase space point and return its weight.
Ptr< PhasespaceCouplings >::ptr theCouplings
Couplings to be used in diagram weighting.
double spaceLikeWeight(const Tree2toNDiagram &diag, const Lorentz5Momentum &incoming, int branch, double flatCut) const
Return the weight appropriate to the given spacelike branch of the diagram.
pair< double, Lorentz5Momentum > timeLikeWeight(const Tree2toNDiagram &diag, int branch, double flatCut) const
Return the momentum and weight appropriate to the given timelike branch of the diagram.
string doSetPhysicalCoupling(string)
Interface function to setcoupling.
virtual void setXComb(tStdXCombPtr xc)
Set the XComb object steering the Born matrix element this class represents virtual corrections to.
int theLoopParticleIdMin
The first id in a range of id's meant to denote fictitious 'ghost' particles to be used by the diagra...
virtual double invertKinematics(const vector< Lorentz5Momentum > &momenta, double *r) const
Invert the given phase space point to the random numbers which would have generated it.
void fillDiagramWeights(double flatCut=0.0)
Fill the diagram weights.
virtual double invertTwoToOneKinematics(const vector< Lorentz5Momentum > &, double *) const
Invert the given 2 -> 1 phase space point to the random numbers which would have generated it.
bool useMassGenerators() const
True, if mass generators should be used instead of fixed masses.
void clearDiagramWeights()
Clear the diagram weights.
virtual IBPtr clone() const=0
vector< DiagPtr > DiagramVector
-*- C++ -*-
vector< cPDPtr > cPDVector
Wrap around a vector of random numbers to behave as a stream of those.
double operator()()
Return next random number.
size_t nRnd
The number of random numbers available.
const double * numbers
The random numbers.
StreamingRnd()
Default constructor.
StreamingRnd(const double *newNumbers, size_t n)
Construct from random numbers.