herwig is hosted by Hepforge, IPPP Durham
Herwig  7.2.1
DipoleSplittingGenerator.h
1 // -*- C++ -*-
2 //
3 // DipoleSplittingGenerator.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_DipoleSplittingGenerator_H
10 #define HERWIG_DipoleSplittingGenerator_H
11 //
12 // This is the declaration of the DipoleSplittingGenerator class.
13 //
14 
15 #include "ThePEG/Handlers/HandlerBase.h"
16 
17 #include "Herwig/Shower/Dipole/Kernels/DipoleSplittingKernel.h"
18 #include "DipoleSplittingReweight.h"
19 #include "Herwig/Shower/Dipole/Utility/DipoleMCCheck.h"
20 #include "Herwig/Sampling/exsample/exponential_generator.h"
21 
22 #include <tuple>
23 
24 namespace Herwig {
25 
26 using namespace ThePEG;
27 
39 
40 public:
41 
48 
52  virtual ~DipoleSplittingGenerator();
54 
55 public:
56 
60  Ptr<DipoleSplittingKernel>::tptr splittingKernel() const;
61 
65  Ptr<DipoleSplittingReweight>::tptr splittingReweight() const;
66 
70  Ptr<DipoleSplittingKinematics>::tptr splittingKinematics() const;
71 
75  void splittingKernel(Ptr<DipoleSplittingKernel>::tptr sp);
76 
80  void splittingReweight(Ptr<DipoleSplittingReweight>::tptr sp);
81 
85  void wrap(Ptr<DipoleSplittingGenerator>::ptr other);
86 
91  bool wrapping() const { return theOtherGenerator; }
92 
93 public:
94 
98  void resetVariations();
99 
103  void prepare(const DipoleSplittingInfo&);
104 
110  Energy generate(const DipoleSplittingInfo&,
111  map<string,double>& variations,
112  Energy optHardPt = ZERO,
113  Energy optCutoff = ZERO);
114 
121  Energy generateWrapped(DipoleSplittingInfo&,
122  map<string,double>& variations,
123  Energy optHardPt = ZERO,
124  Energy optCutoff = ZERO);
125 
129  void completeSplitting(DipoleSplittingInfo&) const;
130 
134  const DipoleSplittingInfo& lastSplitting() const { return generatedSplitting; }
135 
136 
138  double sudakov(const DipoleSplittingInfo&,Energy down);
140  double dosudakov(const DipoleSplittingInfo&,Energy down);
142  double wrappedSudakov(DipoleSplittingInfo& split,Energy down);
144  double sudakovExpansion(const DipoleSplittingInfo&,Energy down,Energy fixedScale);
146  double dosudakovExpansion(const DipoleSplittingInfo&,Energy down,Energy fixedScale);
148  double wrappedSudakovExpansion(DipoleSplittingInfo& split,Energy down,Energy fixedScale);
149 
153  void doPartialUnweighting(double wref) {
154  partialUnweighting = true;
155  theReferenceWeight = wref;
156  }
157 
158 public:
159 
164  void debugGenerator(ostream&) const;
165 
170  void debugLastEvent(ostream&) const;
171 
172 protected:
173 
177  void fixParameters(const DipoleSplittingInfo&,
178  Energy optHardPt = ZERO);
179 
185  void doGenerate(map<string,double>& variations,
186  Energy optCutoff = ZERO);
187 
188 public:
189 
194  int nDim() const;
195 
199  const vector<bool>& sampleFlags();
200 
207  const pair<vector<double>,vector<double> >& support();
208 
213  const vector<double>& parameterPoint() const { return parameters; }
214 
220  void startPresampling();
221 
226  void stopPresampling();
227 
232  unsigned long presamplingPoints() const { return splittingKernel()->presamplingPoints(); }
233 
238  unsigned long maxtry() const { return splittingKernel()->maxtry(); }
239 
244  unsigned long freezeGrid() const { return splittingKernel()->freezeGrid(); }
245 
249  double detuning() const { return splittingKernel()->detuning(); }
250 
256  bool haveOverestimate() const;
257 
261  double overestimate(const vector<double>&);
262 
267  double invertOverestimateIntegral(double) const;
268 
272  double evaluate(const vector<double>&);
273 
277  void veto(const vector<double>&, double p, double r);
278 
282  void accept(const vector<double>&, double p, double r);
283 
287  double splittingWeight() const {
288  if ( wrapping() )
289  return theOtherGenerator->splittingWeight();
290  return theSplittingWeight;
291  }
292 
296  void doCompensate(bool yes = true) { theDoCompensate = yes; }
297 
301  vector<std::tuple<Energy,double,bool> > splittingWeightVector() const {
302  if ( wrapping() )
303  return theOtherGenerator->splittingWeightVector();
304  return theSplittingWeightVector;
305  }
306 
307 public:
308 
311 
312  inline const vector<bool>& variable_flags () {
313  return sampleFlags();
314  }
315 
316  inline size_t evolution_variable () const { return 0; }
317 
318  inline double evolution_cutoff () { return support().first[0]; }
319 
320  inline const vector<double>& parameter_point () const {
321  return parameterPoint();
322  }
323 
324  inline void start_presampling () {
325  startPresampling();
326  }
327 
328  inline void stop_presampling () {
329  stopPresampling();
330  }
331 
332  inline size_t dimension () const {
333  return nDim();
334  }
335 
336  inline unsigned long presampling_points () const {
337  return presamplingPoints();
338  }
339 
341 
342 public:
343 
350  void persistentOutput(PersistentOStream & os) const;
351 
357  void persistentInput(PersistentIStream & is, int version);
359 
366  static void Init();
367 
368 protected:
369 
376  virtual IBPtr clone() const;
377 
382  virtual IBPtr fullclone() const;
384 
385 
386 // If needed, insert declarations of virtual function defined in the
387 // InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
388 
389 private:
390 
394  Ptr<DipoleSplittingGenerator>::ptr theOtherGenerator;
395 
400  Ptr<DipoleSplittingKernel>::ptr theSplittingKernel;
401 
405  Ptr<DipoleSplittingReweight>::ptr theSplittingReweight;
406 
412 
417 
423 
428  bool prepared;
429 
435 
439  vector<double> parameters;
440 
444  vector<bool> theFlags;
445 
449  pair<vector<double>,vector<double> > theSupport;
450 
454  Ptr<DipoleMCCheck>::ptr theMCCheck;
455 
460 
464  map<string,double> currentWeights;
465 
470 
471 
475  double theSudakovAccuracy=0.05;
476 
483 
487  bool partialUnweighting = false;
488 
493  vector<std::tuple<Energy,double,bool> > theSplittingWeightVector;
494 
495 private:
496 
502 
507  DipoleSplittingGenerator & operator=(const DipoleSplittingGenerator &) = delete;
508 
509 };
510 
511 }
512 
513 #include "ThePEG/Utilities/ClassTraits.h"
514 
515 namespace ThePEG {
516 
521 template <>
522 struct BaseClassTrait<Herwig::DipoleSplittingGenerator,1> {
524  typedef HandlerBase NthBase;
525 };
526 
529 template <>
531  : public ClassTraitsBase<Herwig::DipoleSplittingGenerator> {
533  static string className() { return "Herwig::DipoleSplittingGenerator"; }
541  static string library() { return "HwDipoleShower.so"; }
542 };
543 
546 }
547 
548 #endif /* HERWIG_DipoleSplittingGenerator_H */
DipoleSplittingInfo generatedSplitting
The dipole splitting to be completed.
static ClassDescription< DipoleSplittingGenerator > initDipoleSplittingGenerator
The static object used to initialize the description of this class.
unsigned long maxtry() const
Return the maximum number of trials to generate a splitting.
vector< double > parameters
The parameter point.
double detuning() const
Return the detuning factor applied to the sampling overestimate kernel.
ThePEG::Ptr< InterfacedBase >::pointer IBPtr
vector< std::tuple< Energy, double, bool > > splittingWeightVector() const
Return the weight vector associated to the currently generated splitting.
Ptr< DipoleMCCheck >::ptr theMCCheck
Pointer to a check histogram object.
pair< vector< double >, vector< double > > theSupport
The support.
void doCompensate(bool yes=true)
True, if sampler should apply compensation.
The generator for sudakov-type distributions.
DipoleSplittingGenerator is used by the dipole shower to sample splittings from a given dipole splitt...
unsigned long freezeGrid() const
Return the number of accepted points after which the grid should be frozen.
const vector< double > & parameterPoint() const
Return the parameter point associated to the splitting previously supplied through fixParameters...
bool prepared
True, if prepared to sample splittings of a given kind.
vector< bool > theFlags
The sampling flags.
bool theDoCompensate
True, if sampler should apply compensation.
const DipoleSplittingInfo & lastSplitting() const
Return the last generated splitting.
bool presampling
Wether or not the kernel is currently being presampled.
double splittingWeight() const
Return the weight associated to the currently generated splitting.
exsample::exponential_generator< DipoleSplittingGenerator, UseRandom > * theExponentialGenerator
Pointer to the exponential generator.
pair< double, double > generate(const Generator< Density > &gen, double r)
Generate a random variable and return its weight.
bool wrapping() const
Return true, if this is actually a wrapper around another splitting generator.
map< string, double > currentWeights
The currently used weight map.
vector< std::tuple< Energy, double, bool > > theSplittingWeightVector
The scale, weight and a bool for all veto steps and the accept step.
Ptr< DipoleSplittingGenerator >::ptr theOtherGenerator
Pointer to another generator to wrap around.
void doPartialUnweighting(double wref)
Turn on partial unweighting and set the reference weight.
double theSplittingWeight
The weight associated to the currently generated splitting.
-*- C++ -*-
Ptr< DipoleSplittingReweight >::ptr theSplittingReweight
The dipole splitting reweight.
unsigned long presamplingPoints() const
Return the number of points to presample this splitting generator.
double theReferenceWeight
Reference weight to improve convergence for subleading Nc corrections (by reducing time spent on even...
DipoleSplittingInfo contains all parameters to generate a full dipole splitting.
Ptr< DipoleSplittingKernel >::ptr theSplittingKernel
The dipole splitting kernel to sample splitting from.
constexpr ZeroUnit ZERO
DipoleSplittingInfo presampledSplitting
A backup of the dipole splitting to be completed, if this generator is presampled.