herwig is hosted by Hepforge, IPPP Durham
Herwig  7.1.4
DipoleSplittingGenerator.h
1 // -*- C++ -*-
2 //
3 // DipoleSplittingGenerator.h is a part of Herwig - A multi-purpose Monte Carlo event generator
4 // Copyright (C) 2002-2017 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 namespace Herwig {
23 
24 using namespace ThePEG;
25 
37 
38 public:
39 
46 
50  virtual ~DipoleSplittingGenerator();
52 
53 public:
54 
58  Ptr<DipoleSplittingKernel>::tptr splittingKernel() const;
59 
63  Ptr<DipoleSplittingReweight>::tptr splittingReweight() const;
64 
68  Ptr<DipoleSplittingKinematics>::tptr splittingKinematics() const;
69 
73  void splittingKernel(Ptr<DipoleSplittingKernel>::tptr sp);
74 
78  void splittingReweight(Ptr<DipoleSplittingReweight>::tptr sp);
79 
83  void wrap(Ptr<DipoleSplittingGenerator>::ptr other);
84 
89  bool wrapping() const { return theOtherGenerator; }
90 
91 public:
92 
96  void resetVariations();
97 
101  void prepare(const DipoleSplittingInfo&);
102 
108  Energy generate(const DipoleSplittingInfo&,
109  map<string,double>& variations,
110  Energy optHardPt = ZERO,
111  Energy optCutoff = ZERO);
112 
119  Energy generateWrapped(DipoleSplittingInfo&,
120  map<string,double>& variations,
121  Energy optHardPt = ZERO,
122  Energy optCutoff = ZERO);
123 
127  void completeSplitting(DipoleSplittingInfo&) const;
128 
132  const DipoleSplittingInfo& lastSplitting() const { return generatedSplitting; }
133 
134 
136  double sudakov(const DipoleSplittingInfo&,Energy down);
138  double dosudakov(const DipoleSplittingInfo&,Energy down);
140  double wrappedSudakov(DipoleSplittingInfo& split,Energy down);
142  double sudakovExpansion(const DipoleSplittingInfo&,Energy down,Energy fixedScale);
144  double dosudakovExpansion(const DipoleSplittingInfo&,Energy down,Energy fixedScale);
146  double wrappedSudakovExpansion(DipoleSplittingInfo& split,Energy down,Energy fixedScale);
147 
148 
149 public:
150 
155  void debugGenerator(ostream&) const;
156 
161  void debugLastEvent(ostream&) const;
162 
163 protected:
164 
168  void fixParameters(const DipoleSplittingInfo&,
169  Energy optHardPt = ZERO);
170 
176  void doGenerate(map<string,double>& variations,
177  Energy optCutoff = ZERO);
178 
179 public:
180 
185  int nDim() const;
186 
190  const vector<bool>& sampleFlags();
191 
198  const pair<vector<double>,vector<double> >& support();
199 
204  const vector<double>& parameterPoint() const { return parameters; }
205 
211  void startPresampling();
212 
217  void stopPresampling();
218 
223  unsigned long presamplingPoints() const { return splittingKernel()->presamplingPoints(); }
224 
229  unsigned long maxtry() const { return splittingKernel()->maxtry(); }
230 
235  unsigned long freezeGrid() const { return splittingKernel()->freezeGrid(); }
236 
240  double detuning() const { return splittingKernel()->detuning(); }
241 
247  bool haveOverestimate() const;
248 
252  double overestimate(const vector<double>&);
253 
258  double invertOverestimateIntegral(double) const;
259 
263  double evaluate(const vector<double>&);
264 
268  void veto(const vector<double>&, double p, double r);
269 
273  void accept(const vector<double>&, double p, double r);
274 
278  double splittingWeight() const {
279  if ( wrapping() )
280  return theOtherGenerator->splittingWeight();
281  return theSplittingWeight;
282  }
283 
287  void doCompensate(bool yes = true) { theDoCompensate = yes; }
288 
289 public:
290 
293 
294  inline const vector<bool>& variable_flags () {
295  return sampleFlags();
296  }
297 
298  inline size_t evolution_variable () const { return 0; }
299 
300  inline double evolution_cutoff () { return support().first[0]; }
301 
302  inline const vector<double>& parameter_point () const {
303  return parameterPoint();
304  }
305 
306  inline void start_presampling () {
307  startPresampling();
308  }
309 
310  inline void stop_presampling () {
311  stopPresampling();
312  }
313 
314  inline size_t dimension () const {
315  return nDim();
316  }
317 
318  inline unsigned long presampling_points () const {
319  return presamplingPoints();
320  }
321 
323 
324 public:
325 
332  void persistentOutput(PersistentOStream & os) const;
333 
339  void persistentInput(PersistentIStream & is, int version);
341 
348  static void Init();
349 
350 protected:
351 
358  virtual IBPtr clone() const;
359 
364  virtual IBPtr fullclone() const;
366 
367 
368 // If needed, insert declarations of virtual function defined in the
369 // InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
370 
371 private:
372 
376  Ptr<DipoleSplittingGenerator>::ptr theOtherGenerator;
377 
382  Ptr<DipoleSplittingKernel>::ptr theSplittingKernel;
383 
387  Ptr<DipoleSplittingReweight>::ptr theSplittingReweight;
388 
394 
399 
405 
410  bool prepared;
411 
417 
421  vector<double> parameters;
422 
426  vector<bool> theFlags;
427 
431  pair<vector<double>,vector<double> > theSupport;
432 
436  Ptr<DipoleMCCheck>::ptr theMCCheck;
437 
442 
446  map<string,double> currentWeights;
447 
452 
453 
457  double theSudakovAccuracy=0.05;
458 
459 
460 private:
461 
467 
473 
474 };
475 
476 }
477 
478 #include "ThePEG/Utilities/ClassTraits.h"
479 
480 namespace ThePEG {
481 
486 template <>
489  typedef HandlerBase NthBase;
490 };
491 
494 template <>
496  : public ClassTraitsBase<Herwig::DipoleSplittingGenerator> {
498  static string className() { return "Herwig::DipoleSplittingGenerator"; }
506  static string library() { return "HwDipoleShower.so"; }
507 };
508 
511 }
512 
513 #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
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.
Ptr< DipoleSplittingGenerator >::ptr theOtherGenerator
Pointer to another generator to wrap around.
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.
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.