Page MenuHomeHEPForge

No OneTemporary

This file is larger than 256 KB, so syntax highlighting was skipped.
diff --git a/DipoleShower/AlphaS/Makefile.am b/DipoleShower/AlphaS/Makefile.am
new file mode 100644
--- /dev/null
+++ b/DipoleShower/AlphaS/Makefile.am
@@ -0,0 +1,13 @@
+pkglib_LTLIBRARIES = HwDipoleShowerAlphaS.la
+HwDipoleShowerAlphaS_la_LDFLAGS = -module -version-info 11:1:0
+
+HwDipoleShowerAlphaS_la_SOURCES = \
+alpha_s.h \
+alpha_s.cc \
+lo_alpha_s.h \
+lo_alpha_s.cc \
+nlo_alpha_s.h \
+nlo_alpha_s.cc \
+gsl.h \
+gsl.tcc \
+gsl.cc
diff --git a/DipoleShower/AlphaS/alpha_s.cc b/DipoleShower/AlphaS/alpha_s.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/AlphaS/alpha_s.cc
@@ -0,0 +1,229 @@
+// -*- C++ -*-
+
+// couplings/alpha_s.cc is part of matchbox
+// (C) 2008 Simon Platzer -- sp@particle.uni-karlsruhe.de
+
+#include "alpha_s.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/Interface/Parameter.h"
+#include "ThePEG/Interface/Command.h"
+#include "ThePEG/Interface/Switch.h"
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+#include "ThePEG/Repository/Repository.h"
+#include "ThePEG/PDT/ParticleData.h"
+
+using namespace matchbox;
+
+alpha_s::alpha_s()
+ : AlphaSBase(), min_active_flavours_(3), max_active_flavours_(6),
+ matched_(false), scale_factor_(1.), quark_masses_squared_(),
+ lambda_squared_(), alpha_s_in_(.1176), scale_in_(91.1876*GeV),
+ lambda_range_(1.*MeV2,1.e6*MeV2), fixed_(false) {
+}
+
+alpha_s::~alpha_s() {}
+
+void alpha_s::persistentOutput(PersistentOStream & os) const {
+ os << min_active_flavours_ << max_active_flavours_ << matched_ << scale_factor_;
+ for (size_t f = 0; f < 7; ++f)
+ os << ounit(quark_masses_squared_[f],MeV2)
+ << ounit(lambda_squared_[f],MeV2);
+ os << alpha_s_in_ << ounit(scale_in_,GeV)
+ << ounit(lambda_range_.first,MeV2) << ounit(lambda_range_.second,MeV2)
+ << fixed_;
+}
+
+void alpha_s::persistentInput(PersistentIStream & is, int) {
+ is >> min_active_flavours_ >> max_active_flavours_ >> matched_ >> scale_factor_;
+ for (size_t f = 0; f < 7; ++f)
+ is >> iunit(quark_masses_squared_[f],MeV2)
+ >> iunit(lambda_squared_[f],MeV2);
+ is >> alpha_s_in_ >> iunit(scale_in_,GeV)
+ >> iunit(lambda_range_.first,MeV2) >> iunit(lambda_range_.second,MeV2)
+ >> fixed_;
+}
+
+AbstractClassDescription<alpha_s> alpha_s::initalpha_s;
+// Definition of the static class description member.
+
+void alpha_s::Init() {
+
+ static ClassDocumentation<alpha_s> documentation
+ ("Base class for strong coupoling as used in matchbox");
+
+
+ static Parameter<alpha_s,unsigned int> interfacemin_active_flavours
+ ("min_active_flavours",
+ "Minimum number of active flavours",
+ &alpha_s::min_active_flavours_, 3, 0, 6,
+ true, false, Interface::limited);
+
+ static Parameter<alpha_s,unsigned int> interfacemax_active_flavours
+ ("max_active_flavours",
+ "Maximum number of active flavours",
+ &alpha_s::max_active_flavours_, 6, 0, 6,
+ true, false, Interface::limited);
+
+
+ static Parameter<alpha_s,double> interfaceinput_alpha_s
+ ("input_alpha_s",
+ "alpha_s value at input scale",
+ &alpha_s::alpha_s_in_, .1176, 0.0, 1.0,
+ true, false, Interface::limited);
+
+
+ static Parameter<alpha_s,Energy> interfaceinput_scale
+ ("input_scale",
+ "Input scale for alpha_s value",
+ &alpha_s::scale_in_, GeV, 91.1876*GeV, 0.*GeV, 0.*GeV,
+ true, false, Interface::lowerlim);
+
+
+ static Command<alpha_s> interfacecheck
+ ("check",
+ "check",
+ &alpha_s::check, false);
+
+ static Parameter<alpha_s,double> interfacescale_factor
+ ("scale_factor",
+ "scale factor for argument",
+ &alpha_s::scale_factor_, 1., 0.0, 100.0,
+ true, false, Interface::limited);
+
+
+ static Switch<alpha_s,bool> interfacefixed
+ ("fixed",
+ "",
+ &alpha_s::fixed_, false, false, false);
+ static SwitchOption interfacefixedOn
+ (interfacefixed,
+ "On",
+ "",
+ true);
+ static SwitchOption interfacefixedOff
+ (interfacefixed,
+ "Off",
+ "",
+ false);
+
+}
+
+string alpha_s::check (string args) {
+
+ istringstream argin(args);
+
+ double Q_low, Q_high;
+ long n_steps;
+
+ argin >> Q_low >> Q_high >> n_steps;
+
+ string fname;
+ argin >> fname;
+
+ cout << "checking alpha_s in range [" << Q_low << "," << Q_high << "] GeV in "
+ << n_steps << " steps.\nResults are written to " << fname << "\n";
+
+ double step_width = (Q_high-Q_low)/n_steps;
+
+ match_thresholds();
+
+ cout << "threshold matching results:\n"
+ << "(m_Q^2 -> Lambda^2) / GeV^2 for dynamic flavours in range ["
+ << min_active_flavours_ << "," << max_active_flavours_ << "]\n";
+
+ for (size_t f = 0; f < 7; ++f) {
+ cout << (quark_masses_squared_[f]/GeV2) << " "
+ << (lambda_squared_[f]/GeV2) << "\n";
+ }
+
+ ofstream out (fname.c_str());
+
+ for (long k = 0; k <= n_steps; ++k) {
+
+ Energy Q = Q_low*GeV + k*step_width*GeV;
+
+ out << (Q/GeV) << " " << (operator () (Q*Q)) << "\n";
+
+ }
+
+ return "alpha_s check finished";
+
+}
+
+void alpha_s::match_thresholds () {
+
+ if (matched_)
+ return;
+
+ // get the quark masses
+ quark_masses_squared_[0] = 0.*MeV2;
+
+ for (long f = 1; f < 7; ++f) {
+ quark_masses_squared_[static_cast<size_t>(f)]
+ = sqr(getParticleData(f)->mass());
+ }
+
+ unsigned int active_at_input = active_flavours(sqr(scale_in_));
+
+ // solve for input lambda
+ solve_input_lambda<alpha_s> input_equation (this,active_at_input,alpha_s_in_,sqr(scale_in_));
+
+ gsl::bisection_root_solver<solve_input_lambda<alpha_s>,100> input_solver(input_equation);
+
+ lambda_squared_[active_at_input] =
+ MeV2 *
+ input_solver.solve(make_pair(lambda_range_.first/MeV2,
+ lambda_range_.second/MeV2));
+
+ // get lambdas down to min active flavours
+ unsigned int below = active_at_input;
+
+ while (below > min_active_flavours_) {
+
+ solve_lambda_below<alpha_s> match_equation (this,below,
+ lambda_squared_[below],
+ quark_masses_squared_[below]);
+ gsl::bisection_root_solver<solve_lambda_below<alpha_s>,100> match_solver(match_equation);
+ lambda_squared_[below-1] =
+ MeV2 *
+ match_solver.solve(make_pair(lambda_range_.first/MeV2,
+ lambda_range_.second/MeV2));
+
+ --below;
+ }
+
+ // get lambdas up to max active flavours
+ unsigned int above = active_at_input;
+
+ while (above < max_active_flavours_) {
+ solve_lambda_above<alpha_s> match_equation (this,above,
+ lambda_squared_[above],
+ quark_masses_squared_[above+1]);
+ gsl::bisection_root_solver<solve_lambda_above<alpha_s>,100> match_solver(match_equation);
+ lambda_squared_[above+1] =
+ MeV2 *
+ match_solver.solve(make_pair(lambda_range_.first/MeV2,
+ lambda_range_.second/MeV2));
+ ++above;
+ }
+
+ if (min_active_flavours_ > 0) {
+ for (size_t f = 0; f < min_active_flavours_; ++f) {
+ lambda_squared_[f] = lambda_squared_[min_active_flavours_];
+ }
+ }
+
+ if (max_active_flavours_ < 6) {
+ for (size_t f = max_active_flavours_+1; f < 7; ++f) {
+ lambda_squared_[f] = lambda_squared_[max_active_flavours_];
+ }
+ }
+
+ matched_ = true;
+
+ return;
+
+}
diff --git a/DipoleShower/AlphaS/alpha_s.h b/DipoleShower/AlphaS/alpha_s.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/AlphaS/alpha_s.h
@@ -0,0 +1,350 @@
+// -*- C++ -*-
+
+// couplings/alpha_s.h is part of matchbox
+// (C) 2008 Simon Platzer -- sp@particle.uni-karlsruhe.de
+
+#ifndef matchbox_couplings_alpha_s_h
+#define matchbox_couplings_alpha_s_h
+
+#include <string>
+
+#include <boost/array.hpp>
+
+#include "ThePEG/Interface/Interfaced.h"
+#include "ThePEG/StandardModel/AlphaSBase.h"
+
+#include "gsl.h"
+
+namespace matchbox {
+
+ using namespace ThePEG;
+
+ template<class AlphaS>
+ struct solve_lambda_below {
+
+ typedef AlphaS alpha_s;
+
+ inline solve_lambda_below (alpha_s* a,
+ unsigned int n,
+ Energy2 lambda2n,
+ Energy2 mass2)
+ : alpha(a), nf_in(n), lambda2_nf_in(lambda2n), threshold(mass2) {}
+
+ alpha_s * alpha;
+ unsigned int nf_in;
+ Energy2 lambda2_nf_in;
+ Energy2 threshold;
+
+ inline double operator () (double lambda2) {
+ return ((*alpha)(threshold,lambda2_nf_in,nf_in) -
+ (*alpha)(threshold,lambda2*MeV2,nf_in-1));
+ }
+
+ };
+
+ template<class AlphaS>
+ struct solve_lambda_above {
+
+ typedef AlphaS alpha_s;
+
+ inline solve_lambda_above (alpha_s * a,
+ unsigned int n,
+ Energy2 lambda2n,
+ Energy2 mass2)
+ : alpha(a), nf_in(n), lambda2_nf_in(lambda2n), threshold(mass2) {}
+
+ alpha_s * alpha;
+ unsigned int nf_in;
+ Energy2 lambda2_nf_in;
+ Energy2 threshold;
+
+ inline double operator () (double lambda2) {
+ return ((*alpha)(threshold,lambda2_nf_in,nf_in) -
+ (*alpha)(threshold,lambda2*MeV2,nf_in+1));
+ }
+
+ };
+
+ template<class AlphaS>
+ struct solve_input_lambda {
+
+ typedef AlphaS alpha_s;
+
+ inline solve_input_lambda (alpha_s * a,
+ unsigned int n,
+ double inalpha,
+ Energy2 inscale)
+ : alpha(a), nf_in(n), alpha_in(inalpha), scale_in(inscale) {}
+
+ alpha_s * alpha;
+ unsigned int nf_in;
+ double alpha_in;
+ Energy2 scale_in;
+
+ inline double operator () (double lambda2) {
+ return ((*alpha)(scale_in,lambda2*MeV2,nf_in) - alpha_in);
+ }
+
+ };
+
+ /**
+ * Base class for the strong coupling.
+ *
+ * @see \ref alpha_sInterfaces "The interfaces"
+ * defined for alpha_s.
+ */
+ class alpha_s
+ : public AlphaSBase {
+
+ public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ alpha_s();
+
+ /**
+ * The destructor.
+ */
+ virtual ~alpha_s();
+ //@}
+
+ public:
+
+ /** @name Virtual functions as required by AlphaSBase. */
+ //@{
+ /**
+ * The \f$\alpha_S\f$. Return the QCD coupling for a given \a scale
+ * using the given standard model object \a sm.
+ */
+ virtual inline double value(Energy2 scale, const StandardModelBase &) const {
+ return operator() (scale);
+ }
+
+ /**
+ * Return the flavour thresholds used. The returned vector contains
+ * (in position <code>i</code>) the scales when the active number of
+ * flavours changes from <code>i</code> to <code>i+1</code>.
+ */
+ virtual inline vector<Energy2> flavourThresholds() const {
+ vector<Energy2> res (7);
+ copy(quark_masses_squared_.begin(),quark_masses_squared_.end(),res.begin());
+ return res;
+ }
+
+ /**
+ * Return the \f$\Lambda_{QCD}\f$ used for different numbers of
+ * active flavours.
+ */
+ virtual inline vector<Energy> LambdaQCDs() const {
+ vector<Energy> res;
+ for (size_t k = 0; k < 7; ++k)
+ res.push_back(sqrt(lambda_squared_[k]));
+ return res;
+ }
+ //@}
+
+ public:
+
+ /// return alpha_s as function of scale
+ inline double operator () (Energy2 scale) const {
+
+ if ( fixed_ )
+ return alpha_s_in_;
+
+ assert(matched());
+ unsigned int active = active_flavours(scale_factor_*scale);
+ return operator () (scale_factor_*scale,lambda_squared_[active],active);
+
+ }
+
+ /// return alpha_s as function of scale, QCD scale
+ /// and number of active flavours
+ virtual double operator () (Energy2 scale,
+ Energy2 lambda2,
+ unsigned int nf) const = 0;
+
+ /// match thresholds and write alpha_s
+ /// to specified file; arguments are
+ /// Q_low/GeV Q_high/GeV n_steps filename
+ string check (string args);
+
+ public:
+
+ /// return minimum number of active flavours
+ inline unsigned int min_active_flavours () const { return min_active_flavours_; }
+
+ /// set minimum number of active flavours
+ inline void min_active_flavours (unsigned int nf) { min_active_flavours_ = nf; }
+
+ /// return maximum number of active flavours
+ inline unsigned int max_active_flavours () const { return max_active_flavours_; }
+
+ /// set maximum number of active flavours
+ inline void max_active_flavours (unsigned int nf) { max_active_flavours_ = nf; }
+
+ /// return the number of active flavours at the given scale
+ inline unsigned int active_flavours (Energy2 scale) const {
+ unsigned int active = 0;
+ if (scale > 0.*GeV2) {
+ while(quark_mass_squared(active) < scale) {
+ if (++active == 7)
+ break;
+ }
+ active -= 1;
+ } else {
+ active = 0;
+ }
+ return active;
+ }
+
+ /// return the lambda squared for the given number of flavours
+ inline Energy2 lambda_squared (unsigned int f) const {
+ assert(f < 7);
+ return lambda_squared_[f];
+ }
+
+ /// return the mass squared for given flavour
+ inline Energy2 quark_mass_squared (unsigned int f) const {
+ assert(f < 7);
+ return quark_masses_squared_[f];
+ }
+
+ /// set the mass squared for given flavour
+ inline void quark_mass_squared (unsigned int f, Energy2 m2) {
+ assert(f < 7);
+ quark_masses_squared_[f] = m2;
+ matched_ = false;
+ }
+
+ public:
+
+ /// perform the threshold matching
+ /// given alpha_s value at reference scale
+ void match_thresholds ();
+
+ /// return true, if threshold matching has been
+ /// performed
+ inline bool matched () const { return matched_; }
+
+ protected:
+
+ /** @name Standard Interfaced functions. */
+ //@{
+
+ /**
+ * Initialize this object after the setup phase before saving an
+ * EventGenerator to disk.
+ * @throws InitException if object could not be initialized properly.
+ */
+ virtual inline void doinit() throw(InitException) {
+ match_thresholds();
+ AlphaSBase::doinit();
+ }
+
+ //@}
+
+ /// return the scale factor
+ double scale_factor () const { return scale_factor_; }
+
+ public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @name os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @name is the persistent input stream read from.
+ * @name version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+ private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is an abstract class with persistent data.
+ */
+ static AbstractClassDescription<alpha_s> initalpha_s;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ alpha_s & operator=(const alpha_s &);
+
+ private:
+
+ unsigned int min_active_flavours_;
+ unsigned int max_active_flavours_;
+
+ bool matched_;
+
+ double scale_factor_;
+
+ boost::array<Energy2,7> quark_masses_squared_;
+ boost::array<Energy2,7> lambda_squared_;
+
+ double alpha_s_in_;
+ Energy scale_in_;
+
+ pair<Energy2,Energy2> lambda_range_;
+
+ bool fixed_;
+
+ };
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+ /** @cond TRAITSPECIALIZATIONS */
+
+ /** This template specialization informs ThePEG about the
+ * base classes of alpha_s. */
+ template <>
+ struct BaseClassTrait<matchbox::alpha_s,1> {
+ /** Typedef of the first base class of alpha_s. */
+ typedef AlphaSBase NthBase;
+ };
+
+ /** This template specialization informs ThePEG about the name of
+ * the alpha_s class and the shared object where it is defined. */
+ template <>
+ struct ClassTraits<matchbox::alpha_s>
+ : public ClassTraitsBase<matchbox::alpha_s> {
+ /** Return a platform-independent class name */
+ static string className() { return "matchbox::alpha_s"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * alpha_s is implemented. It may also include several, space-separated,
+ * libraries if the class alpha_s depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShowerAlphaS.so"; }
+ };
+
+ /** @endcond */
+
+}
+
+#endif /* matchbox_couplings_alpha_s_h */
diff --git a/DipoleShower/AlphaS/gsl.cc b/DipoleShower/AlphaS/gsl.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/AlphaS/gsl.cc
@@ -0,0 +1,26 @@
+// -*- C++ -*-
+
+// math/gsl.cc is part of matchbox
+// (C) 2008 Simon Platzer -- sp@particle.uni-karlsruhe.de
+
+#include "ThePEG/Utilities/Throw.h"
+
+#include "gsl.h"
+
+using namespace matchbox::gsl;
+
+/// gsl error handler throwing gsl_exception
+void error_handler_wrapper (const char * msg,
+ const char *, int, int) {
+ ThePEG::Throw<gsl_exception> () << "Matchbox GSL interface : GSL exception : "
+ << msg << ThePEG::Exception::runerror;
+}
+
+struct error_handler_resetter_ {
+ inline error_handler_resetter_ () {
+ gsl_set_error_handler(&error_handler_wrapper);
+ }
+};
+
+static error_handler_resetter_ error_handler_resetter;
+
diff --git a/DipoleShower/AlphaS/gsl.h b/DipoleShower/AlphaS/gsl.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/AlphaS/gsl.h
@@ -0,0 +1,52 @@
+// -*- C++ -*-
+
+// math/gsl.h is part of matchbox
+// (C) 2008 Simon Platzer -- sp@particle.uni-karlsruhe.de
+
+#ifndef matchbox_math_gsl_h
+#define matchbox_math_gsl_h
+
+#include "gsl/gsl_math.h"
+#include "gsl/gsl_roots.h"
+
+#include "ThePEG/Utilities/Exception.h"
+
+namespace matchbox {
+
+ namespace gsl {
+
+ /// exception class for GSL problems
+ struct gsl_exception : public ThePEG::Exception { };
+
+ /// wrapper araound the bisection root solver
+ template<class Function, unsigned long MaxIterations>
+ struct bisection_root_solver {
+
+ /// constructor -- allocates the solver
+ inline bisection_root_solver (const Function& thef) : f(thef) {
+ s = gsl_root_fsolver_alloc (gsl_root_fsolver_bisection);
+ }
+
+ /// destructor -- frees the solver
+ ~bisection_root_solver () {
+ gsl_root_fsolver_free (s);
+ }
+
+ /// solve for root given initial interval
+ double solve (std::pair<double,double> interval, double precision = .000001);
+
+ /// function object representing the equation to be solved
+ Function f;
+
+ /// the gsl solver used
+ gsl_root_fsolver * s;
+
+ };
+
+ }
+
+}
+
+#include "gsl.tcc"
+
+#endif // matchbox_math_gsl_h
diff --git a/DipoleShower/AlphaS/gsl.tcc b/DipoleShower/AlphaS/gsl.tcc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/AlphaS/gsl.tcc
@@ -0,0 +1,53 @@
+// -*- C++ -*-
+
+// math/gsl.tcc is part of matchbox
+// (C) 2008 Simon Platzer -- sp@particle.uni-karlsruhe.de
+
+#include <cassert>
+
+#include "gsl/gsl_errno.h"
+
+namespace matchbox { namespace gsl {
+
+template<class Function>
+double function_wrapper (double x, void * fptr) {
+ return (*reinterpret_cast<Function *>(fptr)).operator () (x);
+}
+
+/// given a unary function, return an appropriate
+/// gsl function object
+template<class Function>
+gsl_function make_function (Function& f) {
+ gsl_function conv;
+ conv.function = &function_wrapper<Function>;
+ conv.params = &f;
+ return conv;
+}
+
+template<class Function, unsigned long MaxIterations>
+double bisection_root_solver<Function,MaxIterations>::solve (std::pair<double,double> interval, double precision) {
+
+ assert(interval.first < interval.second);
+
+ gsl_function F = make_function(f);
+
+ gsl_root_fsolver_set (s, &F, interval.first, interval.second);
+
+ unsigned long iterations = 0;
+ double sol;
+ int status;
+
+ do {
+ ++iterations;
+ status = gsl_root_fsolver_iterate (s);
+ sol = gsl_root_fsolver_root (s);
+ interval.first = gsl_root_fsolver_x_lower(s);
+ interval.second = gsl_root_fsolver_x_upper(s);
+ status = gsl_root_test_interval (interval.first,interval.second,0,precision);
+ } while (status == GSL_CONTINUE && iterations < MaxIterations);
+
+ return sol;
+
+}
+
+ }}
diff --git a/DipoleShower/AlphaS/lo_alpha_s.cc b/DipoleShower/AlphaS/lo_alpha_s.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/AlphaS/lo_alpha_s.cc
@@ -0,0 +1,67 @@
+// -*- C++ -*-
+
+// couplings/lo_alpha_s.cc is part of matchbox
+// (C) 2008 Simon Platzer -- sp@particle.uni-karlsruhe.de
+
+#include "lo_alpha_s.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/Interface/Parameter.h"
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace matchbox;
+
+lo_alpha_s::lo_alpha_s()
+ : alpha_s(), freezing_scale_(1.*GeV) {}
+
+lo_alpha_s::~lo_alpha_s() {}
+
+IBPtr lo_alpha_s::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr lo_alpha_s::fullclone() const {
+ return new_ptr(*this);
+}
+
+void lo_alpha_s::persistentOutput(PersistentOStream & os) const {
+ os << ounit(freezing_scale_,GeV);
+}
+
+void lo_alpha_s::persistentInput(PersistentIStream & is, int) {
+ is >> iunit(freezing_scale_,GeV);
+}
+
+ClassDescription<lo_alpha_s> lo_alpha_s::initlo_alpha_s;
+// Definition of the static class description member.
+
+void lo_alpha_s::Init() {
+
+ static ClassDocumentation<lo_alpha_s> documentation
+ ("LO running alpha_s");
+
+
+ static Parameter<lo_alpha_s,Energy> interfacefreezing_scale
+ ("freezing_scale",
+ "Freeze alpha_s below given scale",
+ &lo_alpha_s::freezing_scale_, GeV, 1.0*GeV, 0.0*GeV, 0*GeV,
+ true, false, Interface::lowerlim);
+
+}
+
+double lo_alpha_s::operator () (Energy2 scale,
+ Energy2 lambda2,
+ unsigned int nf) const {
+
+ if (scale < sqr(freezing_scale_)) {
+ scale = sqr(freezing_scale_);
+ nf = active_flavours(scale);
+ lambda2 = lambda_squared(nf);
+ }
+
+ double beta0 = (33.-2.*nf)/(12.*Constants::pi);
+
+ return 1./(beta0*log(scale/lambda2));
+
+}
diff --git a/DipoleShower/AlphaS/lo_alpha_s.h b/DipoleShower/AlphaS/lo_alpha_s.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/AlphaS/lo_alpha_s.h
@@ -0,0 +1,164 @@
+// -*- C++ -*-
+
+// couplings/lo_alpha_s.h is part of matchbox
+// (C) 2008 Simon Platzer -- sp@particle.uni-karlsruhe.de
+
+#ifndef matchbox_couplings_lo_alpha_s_h
+#define matchbox_couplings_lo_alpha_s_h
+
+#include "alpha_s.h"
+
+namespace matchbox {
+
+ using namespace ThePEG;
+
+ /**
+ * LO running alpha_s
+ *
+ * @see \ref lo_alpha_sInterfaces "The interfaces"
+ * defined for lo_alpha_s.
+ */
+ class lo_alpha_s
+ : public alpha_s {
+
+ public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ lo_alpha_s();
+
+ /**
+ * The destructor.
+ */
+ virtual ~lo_alpha_s();
+ //@}
+
+ public:
+
+ /// return alpha_s as function of scale, QCD scale
+ /// and number of active flavours
+ virtual double operator () (Energy2 scale,
+ Energy2 lambda2,
+ unsigned int nf) const;
+
+ public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @name os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @name is the persistent input stream read from.
+ * @name version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+ protected:
+
+ /** @name Standard Interfaced functions. */
+ //@{
+
+ /**
+ * Initialize this object after the setup phase before saving an
+ * EventGenerator to disk.
+ * @throws InitException if object could not be initialized properly.
+ */
+ virtual inline void doinit() throw(InitException) {
+ freezing_scale_ *= scale_factor();
+ alpha_s::doinit();
+ }
+
+ //@}
+
+ protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+ private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is an abstract class with persistent data.
+ */
+ static ClassDescription<lo_alpha_s> initlo_alpha_s;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ lo_alpha_s & operator=(const lo_alpha_s &);
+
+ private:
+
+ Energy freezing_scale_;
+
+ };
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+ /** @cond TRAITSPECIALIZATIONS */
+
+ /** This template specialization informs ThePEG about the
+ * base classes of lo_alpha_s. */
+ template <>
+ struct BaseClassTrait<matchbox::lo_alpha_s,1> {
+ /** Typedef of the first base class of lo_alpha_s. */
+ typedef matchbox::alpha_s NthBase;
+ };
+
+ /** This template specialization informs ThePEG about the name of
+ * the lo_alpha_s class and the shared object where it is defined. */
+ template <>
+ struct ClassTraits<matchbox::lo_alpha_s>
+ : public ClassTraitsBase<matchbox::lo_alpha_s> {
+ /** Return a platform-independent class name */
+ static string className() { return "matchbox::lo_alpha_s"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * lo_alpha_s is implemented. It may also include several, space-separated,
+ * libraries if the class lo_alpha_s depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShowerAlphaS.so"; }
+ };
+
+ /** @endcond */
+
+}
+
+#endif /* matchbox_couplings_lo_alpha_s_h */
diff --git a/DipoleShower/AlphaS/nlo_alpha_s.cc b/DipoleShower/AlphaS/nlo_alpha_s.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/AlphaS/nlo_alpha_s.cc
@@ -0,0 +1,111 @@
+// -*- C++ -*-
+
+// couplings/nlo_alpha_s.cc is part of matchbox
+// (C) 2008 Simon Platzer -- sp@particle.uni-karlsruhe.de
+
+#include "nlo_alpha_s.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/Interface/Parameter.h"
+#include "ThePEG/Interface/Switch.h"
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace matchbox;
+
+nlo_alpha_s::nlo_alpha_s()
+ : alpha_s(), freezing_scale_(1.*GeV), exact_evaluation_(true) {
+}
+
+nlo_alpha_s::~nlo_alpha_s() {}
+
+IBPtr nlo_alpha_s::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr nlo_alpha_s::fullclone() const {
+ return new_ptr(*this);
+}
+
+void nlo_alpha_s::persistentOutput(PersistentOStream & os) const {
+ os << ounit(freezing_scale_,GeV) << exact_evaluation_;
+}
+
+void nlo_alpha_s::persistentInput(PersistentIStream & is, int) {
+ is >> iunit(freezing_scale_,GeV) >> exact_evaluation_;
+}
+
+ClassDescription<nlo_alpha_s> nlo_alpha_s::initnlo_alpha_s;
+// Definition of the static class description member.
+
+void nlo_alpha_s::Init() {
+
+ static ClassDocumentation<nlo_alpha_s> documentation
+ ("NLO running alpha_s");
+
+
+ static Parameter<nlo_alpha_s,Energy> interfacefreezing_scale
+ ("freezing_scale",
+ "Freeze alpha_s below given scale",
+ &nlo_alpha_s::freezing_scale_, GeV, 1.0*GeV, 0.0*GeV, 0*GeV,
+ true, false, Interface::lowerlim);
+
+
+ static Switch<nlo_alpha_s,bool> interfaceexact_evaluation
+ ("exact_evaluation",
+ "Wether to exactly evaluate the running or use running for large scales",
+ &nlo_alpha_s::exact_evaluation_, true, true, false);
+ static SwitchOption interfaceexact_evaluationexact
+ (interfaceexact_evaluation,
+ "exact",
+ "Perform exact evaluation",
+ true);
+ static SwitchOption interfaceexact_evaluationlarge_scale
+ (interfaceexact_evaluation,
+ "large_scale",
+ "Perform approximate evaluation for large scales",
+ false);
+
+}
+
+double nlo_alpha_s::operator () (Energy2 scale,
+ Energy2 lambda2,
+ unsigned int nf) const {
+
+ if (scale < sqr(freezing_scale_)) {
+ scale = sqr(freezing_scale_);
+ nf = active_flavours(scale);
+ lambda2 = lambda_squared(nf);
+ }
+
+ double beta0 = (33.-2.*nf)/(12.*Constants::pi);
+ double beta1 = (153.-19.*nf)/(24.*sqr(Constants::pi));
+
+ if (exact_evaluation_) {
+
+ rg_solver().f.slog = log(scale/lambda2);
+ rg_solver().f.nf = nf;
+
+ double slog = rg_solver().f.slog;
+
+ double center =
+ (1./(beta0*slog))*
+ (1. - (beta1/sqr(beta0)) * log(slog)/slog +
+ sqr(beta1/(sqr(beta0)*slog)) * (sqr(log(slog)-.5) - 5./4.));
+
+ return rg_solver().solve(make_pair(.5*center,1.5*center));
+
+ } else {
+
+ double slog = log(scale/lambda2);
+
+ return
+ (1./(beta0*slog))*
+ (1. - (beta1/sqr(beta0)) * log(slog)/slog +
+ sqr(beta1/(sqr(beta0)*slog)) * (sqr(log(slog)-.5) - 5./4.));
+
+ }
+
+ return 0.;
+
+}
diff --git a/DipoleShower/AlphaS/nlo_alpha_s.h b/DipoleShower/AlphaS/nlo_alpha_s.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/AlphaS/nlo_alpha_s.h
@@ -0,0 +1,192 @@
+// -*- C++ -*-
+
+// couplings/nlo_alpha_s.h is part of matchbox
+// (C) 2008 Simon Platzer -- sp@particle.uni-karlsruhe.de
+
+#ifndef matchbox_couplings_nlo_alpha_s_h
+#define matchbox_couplings_nlo_alpha_s_h
+
+#include "alpha_s.h"
+
+namespace matchbox {
+
+ using namespace ThePEG;
+
+ /**
+ * NLO running alpha_s
+ *
+ * @see \ref nlo_alpha_sInterfaces "The interfaces"
+ * defined for nlo_alpha_s.
+ */
+ class nlo_alpha_s
+ : public alpha_s {
+
+ public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ nlo_alpha_s();
+
+ /**
+ * The destructor.
+ */
+ virtual ~nlo_alpha_s();
+ //@}
+
+ public:
+
+ /// return alpha_s as function of scale, QCD scale
+ /// and number of active flavours
+ virtual double operator () (Energy2 scale,
+ Energy2 lambda2,
+ unsigned int nf) const;
+
+ public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @name os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @name is the persistent input stream read from.
+ * @name version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+ protected:
+
+ /** @name Standard Interfaced functions. */
+ //@{
+
+ /**
+ * Initialize this object after the setup phase before saving an
+ * EventGenerator to disk.
+ * @throws InitException if object could not be initialized properly.
+ */
+ virtual inline void doinit() throw(InitException) {
+ freezing_scale_ *= scale_factor();
+ alpha_s::doinit();
+ }
+
+ //@}
+
+ protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+ private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is an abstract class with persistent data.
+ */
+ static ClassDescription<nlo_alpha_s> initnlo_alpha_s;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ nlo_alpha_s & operator=(const nlo_alpha_s &);
+
+ private:
+
+ struct rg_solution {
+
+ inline double operator () (double alpha) {
+
+ double beta0 = (33.-2.*nf)/(12.*Constants::pi);
+ double beta1 = (153.-19.*nf)/(24.*sqr(Constants::pi));
+
+ return ((1./alpha)+(beta1/beta0)*log(alpha/(beta0+beta1*alpha))- beta0*slog);
+
+ }
+
+ double slog;
+ unsigned int nf;
+
+ };
+
+ Energy freezing_scale_;
+
+ bool exact_evaluation_;
+
+ static rg_solution& rg () {
+ static rg_solution rg_;
+ return rg_;
+ }
+
+ static gsl::bisection_root_solver<rg_solution,100>& rg_solver () {
+ static gsl::bisection_root_solver<rg_solution,100> rg_solver_(rg());
+ return rg_solver_;
+ }
+
+ };
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+ /** @cond TRAITSPECIALIZATIONS */
+
+ /** This template specialization informs ThePEG about the
+ * base classes of nlo_alpha_s. */
+ template <>
+ struct BaseClassTrait<matchbox::nlo_alpha_s,1> {
+ /** Typedef of the first base class of nlo_alpha_s. */
+ typedef matchbox::alpha_s NthBase;
+ };
+
+ /** This template specialization informs ThePEG about the name of
+ * the nlo_alpha_s class and the shared object where it is defined. */
+ template <>
+ struct ClassTraits<matchbox::nlo_alpha_s>
+ : public ClassTraitsBase<matchbox::nlo_alpha_s> {
+ /** Return a platform-independent class name */
+ static string className() { return "matchbox::nlo_alpha_s"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * nlo_alpha_s is implemented. It may also include several, space-separated,
+ * libraries if the class nlo_alpha_s depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShowerAlphaS.so"; }
+ };
+
+ /** @endcond */
+
+}
+
+#endif /* matchbox_couplings_nlo_alpha_s_h */
diff --git a/DipoleShower/Base/Dipole.cc b/DipoleShower/Base/Dipole.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Base/Dipole.cc
@@ -0,0 +1,293 @@
+// -*- C++ -*-
+//
+// Dipole.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the Dipole class.
+//
+
+#include "Dipole.h"
+#include "Herwig++/DipoleShower/Utility/DipolePartonSplitter.h"
+
+using namespace Herwig;
+
+Dipole::Dipole()
+ : theParticles(), thePDFs(),
+ theFractions(1.0,1.0), theIndices(),
+ theScales(0.0*GeV,0.0*GeV) {}
+
+Dipole::Dipole(const pair<PPtr,PPtr>& newParticles,
+ const pair<PDF,PDF>& newPDFs,
+ pair<double,double> newFractions)
+ : theParticles(newParticles),
+ thePDFs(newPDFs),
+ theFractions(newFractions), theIndices(),
+ theScales(sqrt(newParticles.first->scale()),sqrt(newParticles.second->scale())) {
+ theIndices.first = DipoleIndex(theParticles.first->dataPtr(),
+ theParticles.second->dataPtr(),
+ newPDFs.first,newPDFs.second);
+ theIndices.second = theIndices.first;
+ theIndices.second.swap();
+}
+
+void Dipole::update() {
+ theIndices.first = DipoleIndex(theParticles.first->dataPtr(),
+ theParticles.second->dataPtr(),
+ thePDFs.first,thePDFs.second);
+ theIndices.second = theIndices.first;
+ theIndices.second.swap();
+ assert(DipolePartonSplitter::colourConnected(theParticles.first,theParticles.second));
+}
+
+pair<Dipole,Dipole> Dipole::split (DipoleSplittingInfo& dsplit,
+ bool colourSpectator) const {
+
+ // check contracts
+ assert(dsplit.splittingKinematics());
+ assert(dsplit.emitterData() && dsplit.emissionData() && dsplit.spectatorData());
+ if ( !colourSpectator ) {
+ assert(index(dsplit.configuration()) == dsplit.index());
+ assert(emitterX(dsplit.configuration()) == dsplit.emitterX());
+ assert(spectatorX(dsplit.configuration()) == dsplit.spectatorX());
+ } else {
+ assert(emitterX(dsplit.configuration()) == dsplit.emitterX());
+ assert(emitterPDF(dsplit.configuration()) == dsplit.index().emitterPDF());
+ assert((dsplit.configuration().first ? theParticles.first->dataPtr() : theParticles.second->dataPtr())
+ == dsplit.index().emitterData());
+ }
+
+
+
+ // generate full kinematics
+ dsplit.splittingKinematics()->generateKinematics(emitter(dsplit.configuration())->momentum(),
+ spectator(dsplit.configuration())->momentum(),
+ dsplit);
+
+ tPPtr oldSpectator = spectator(dsplit.configuration());
+ PPtr newSpectator;
+
+ // get a new spectator
+ if ( !colourSpectator ) {
+ newSpectator =
+ dsplit.spectatorData()->produceParticle(dsplit.splittingKinematics()->lastSpectatorMomentum());
+ DipolePartonSplitter::change(oldSpectator,newSpectator,spectatorPDF(dsplit.configuration()).pdf());
+ dsplit.spectator(oldSpectator);
+ dsplit.splitSpectator(newSpectator);
+ } else {
+ newSpectator = oldSpectator;
+ }
+
+ // perform the splitting
+ tPPtr oldEmitter = emitter(dsplit.configuration());
+ PPtr newEmitter =
+ dsplit.emitterData()->produceParticle(dsplit.splittingKinematics()->lastEmitterMomentum());
+ PPtr newEmission =
+ dsplit.emissionData()->produceParticle(dsplit.splittingKinematics()->lastEmissionMomentum());
+
+ newEmitter->scale(sqr(dsplit.lastPt()));
+ newEmission->scale(sqr(dsplit.lastPt()));
+ newSpectator->scale(oldSpectator->scale());
+
+ DipolePartonSplitter::split(oldEmitter,newEmitter,newEmission,
+ oldSpectator,emitterPDF(dsplit.configuration()).pdf());
+
+ dsplit.emitter(oldEmitter);
+ dsplit.splitEmitter(newEmitter);
+ dsplit.emission(newEmission);
+
+ double emitter_x = emitterX(dsplit.configuration()) / dsplit.lastEmitterZ();
+ double spectator_x = spectatorX(dsplit.configuration()) / dsplit.lastSpectatorZ();
+
+ PDF emitter_pdf = emitterPDF(dsplit.configuration());
+ PDF spectator_pdf = spectatorPDF(dsplit.configuration());
+
+ // now check how we need to arrange the children
+
+ // assignment is 0 = emitter, 1 = emission, 2 = spectator
+ int left = 0;
+ int middle = 1;
+ int right = 2;
+
+ if (dsplit.configuration().first) {
+
+ // spectator is unique
+ right = 2;
+
+ // middle is the one connecting to the spectator
+ if (DipolePartonSplitter::colourConnected(newSpectator,newEmission)) {
+ middle = 1;
+ left = 0;
+ } else {
+ assert(DipolePartonSplitter::colourConnected(newSpectator,newEmitter));
+ middle = 0;
+ left = 1;
+ }
+
+ } else {
+
+ // spectator is unique
+ left = 2;
+
+ // middle is the one connecting to the spectator
+ if (DipolePartonSplitter::colourConnected(newSpectator,newEmission)) {
+ middle = 1;
+ right = 0;
+ } else {
+ assert(DipolePartonSplitter::colourConnected(newSpectator,newEmitter));
+ middle = 0;
+ right = 1;
+ }
+
+ }
+
+ pair<PPtr,PPtr> left_particles;
+ pair<PPtr,PPtr> right_particles;
+
+ pair<PDF,PDF> left_pdfs;
+ pair<PDF,PDF> right_pdfs;
+
+ pair<double,double> left_fractions;
+ pair<double,double> right_fractions;
+
+ switch (left) {
+
+ case 0:
+ left_particles.first = newEmitter;
+ left_pdfs.first = emitter_pdf;
+ left_fractions.first = emitter_x;
+ break;
+
+ case 1:
+ left_particles.first = newEmission;
+ left_pdfs.first = PDF();
+ left_fractions.first = 1.;
+ break;
+
+ case 2:
+ left_particles.first = newSpectator;
+ left_pdfs.first = spectator_pdf;
+ left_fractions.first = spectator_x;
+ break;
+
+ }
+
+ switch (middle) {
+
+ case 0:
+ left_particles.second = newEmitter;
+ left_pdfs.second = emitter_pdf;
+ left_fractions.second = emitter_x;
+ break;
+
+ case 1:
+ left_particles.second = newEmission;
+ left_pdfs.second = PDF();
+ left_fractions.second = 1.;
+ break;
+
+ case 2:
+ left_particles.second = newSpectator;
+ left_pdfs.second = spectator_pdf;
+ left_fractions.second = spectator_x;
+ break;
+
+ }
+
+ right_particles.first = left_particles.second;
+ right_pdfs.first = left_pdfs.second;
+ right_fractions.first = left_fractions.second;
+
+ switch (right) {
+
+ case 0:
+ right_particles.second = newEmitter;
+ right_pdfs.second = emitter_pdf;
+ right_fractions.second = emitter_x;
+ break;
+
+ case 1:
+ right_particles.second = newEmission;
+ right_pdfs.second = PDF();
+ right_fractions.second = 1.;
+ break;
+
+ case 2:
+ right_particles.second = newSpectator;
+ right_pdfs.second = spectator_pdf;
+ right_fractions.second = spectator_x;
+ break;
+
+ }
+
+ return make_pair(Dipole(left_particles,left_pdfs,left_fractions),
+ Dipole(right_particles,right_pdfs,right_fractions));
+
+}
+
+void Dipole::recoil (DipoleSplittingInfo& dsplit) {
+
+ // check contracts
+ assert(dsplit.splittingKinematics());
+ assert(dsplit.spectatorData());
+ assert(spectatorX(dsplit.configuration()) == dsplit.spectatorX());
+ assert(spectatorPDF(dsplit.configuration()) == dsplit.index().spectatorPDF());
+ assert((dsplit.configuration().first ? theParticles.first->dataPtr() : theParticles.second->dataPtr())
+ == dsplit.index().spectatorData());
+
+ tPPtr oldSpectator = spectator(dsplit.configuration());
+ PPtr newSpectator =
+ dsplit.spectatorData()->produceParticle(dsplit.splittingKinematics()->lastSpectatorMomentum());
+ DipolePartonSplitter::change(oldSpectator,newSpectator,spectatorPDF(dsplit.configuration()).pdf());
+
+ newSpectator->scale(sqr(dsplit.lastPt()));
+
+ dsplit.spectator(oldSpectator);
+ dsplit.splitSpectator(newSpectator);
+
+ if ( dsplit.configuration().first ) {
+ theParticles.second = newSpectator;
+ theFractions.second /= dsplit.lastSpectatorZ();
+ } else {
+ theParticles.first = newSpectator;
+ theFractions.first /= dsplit.lastSpectatorZ();
+ }
+
+}
+
+void Dipole::print(ostream& os) const {
+
+ os << "--- ";
+ if ( !thePDFs.first.pdf() && !thePDFs.second.pdf() )
+ os << "FF";
+ else if ( thePDFs.first.pdf() && !thePDFs.second.pdf() )
+ os << "IF";
+ else if ( !thePDFs.first.pdf() && thePDFs.second.pdf() )
+ os << "FI";
+ else
+ os << "II";
+ os << " Dipole ------------------------------------------------------------------\n";
+
+ if ( !theParticles.first || !theParticles.second ) {
+ os << " *** This Dipole has not been setup properly. ***\n";
+ } else {
+
+ os << " particles\n"
+ << *theParticles.first
+ << *theParticles.second;
+
+ os << " scales/GeV = ("
+ << (theScales.first/GeV) << ","
+ << (theScales.second/GeV) << ") fractions = ("
+ << theFractions.first << "," << theFractions.second << ")\n";
+ }
+
+ os << "--------------------------------------------------------------------------------\n";
+
+ os << flush;
+
+}
diff --git a/DipoleShower/Base/Dipole.h b/DipoleShower/Base/Dipole.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Base/Dipole.h
@@ -0,0 +1,268 @@
+// -*- C++ -*-
+//
+// Dipole.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_Dipole_H
+#define HERWIG_Dipole_H
+//
+// This is the declaration of the Dipole class.
+//
+
+#include "Herwig++/DipoleShower/Kinematics/DipoleSplittingKinematics.h"
+#include "Herwig++/DipoleShower/Base/DipoleSplittingInfo.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief The Dipole class is used by the dipole shower to
+ * represent a dipole of two coloured partons.
+ *
+ */
+class Dipole {
+
+public:
+
+ /**
+ * The default constructor
+ */
+ Dipole();
+
+ /**
+ * The standard constructor
+ */
+ Dipole(const pair<PPtr,PPtr>& newParticles,
+ const pair<PDF,PDF>& newPDFs,
+ pair<double,double> newFractions);
+
+public:
+
+ /**
+ * Get the left particle.
+ */
+ tPPtr leftParticle() const { return theParticles.first; }
+
+ /**
+ * Get the right particle.
+ */
+ tPPtr rightParticle() const { return theParticles.second; }
+
+ /**
+ * Get the left PDF.
+ */
+ const PDF& leftPDF() const { return thePDFs.first; }
+
+ /**
+ * Get the right PDF.
+ */
+ const PDF& rightPDF() const { return thePDFs.second; }
+
+ /**
+ * Get the left fraction.
+ */
+ double leftFraction() const { return theFractions.first; }
+
+ /**
+ * Get the right fraction.
+ */
+ double rightFraction() const { return theFractions.second; }
+
+ /**
+ * Set the left particle.
+ */
+ void leftParticle(PPtr p) { theParticles.first = p; }
+
+ /**
+ * Set the right particle.
+ */
+ void rightParticle(PPtr p) { theParticles.second = p; }
+
+ /**
+ * Set the left PDF
+ */
+ void leftPDF(const PDF& p) { thePDFs.first = p; }
+
+ /**
+ * Set the right PDF
+ */
+ void rightPDF(const PDF& p) { thePDFs.second = p; }
+
+ /**
+ * Set the momentum fraction for the left particle.
+ */
+ void leftFraction(double x) { theFractions.first = x; }
+
+ /**
+ * Set the momentum fraction for the right particle.
+ */
+ void rightFraction(double x) { theFractions.second = x; }
+
+ /**
+ * Get the scale for the left particle.
+ */
+ Energy leftScale() const { return theScales.first; }
+
+ /**
+ * Set the scale for the left particle.
+ */
+ void leftScale(Energy s) { theScales.first = s; }
+
+ /**
+ * Get the scale for the right particle.
+ */
+ Energy rightScale() const { return theScales.second; }
+
+ /**
+ * Set the scale for the right particle.
+ */
+ void rightScale(Energy s) { theScales.second = s; }
+
+ /**
+ * Update information, if modified.
+ */
+ void update();
+
+public:
+
+ /**
+ * Return the dipole index for the selected
+ * emitter-spectator assignment.
+ */
+ const DipoleIndex& index(pair<bool,bool> conf) const {
+ return conf.first ? theIndices.first : theIndices.second;
+ }
+
+ /**
+ * Return the emitter particle for the
+ * selected configuration.
+ */
+ tPPtr emitter(pair<bool,bool> conf) const {
+ return conf.first ? theParticles.first : theParticles.second;
+ }
+
+ /**
+ * Return the spectator particle for the
+ * selected configuration.
+ */
+ tPPtr spectator(pair<bool,bool> conf) const {
+ return conf.first ? theParticles.second : theParticles.first;
+ }
+
+ /**
+ * Return the scale associated to the emitter
+ * for the selected configuration.
+ */
+ Energy emitterScale(pair<bool,bool> conf) const {
+ return conf.first ? theScales.first : theScales.second;
+ }
+
+ /**
+ * Set the scale associated to the emitter
+ * for the selected configuration.
+ */
+ void emitterScale(pair<bool,bool> conf, Energy scale) {
+ (conf.first ? theScales.first : theScales.second) = scale;
+ }
+
+ /**
+ * Return the momentum fraction of the emitter
+ * for the selected configuration.
+ */
+ double emitterX(pair<bool,bool> conf) const {
+ return conf.first ? theFractions.first : theFractions.second;
+ }
+
+ /**
+ * Return the PDF of the emitter
+ * for the selected configuration.
+ */
+ const PDF& emitterPDF(pair<bool,bool> conf) const {
+ return conf.first ? thePDFs.first : thePDFs.second;
+ }
+
+ /**
+ * Return the momentum fraction of the spectator
+ * for the selected configuration.
+ */
+ double spectatorX(pair<bool,bool> conf) const {
+ return conf.first ? theFractions.second : theFractions.first;
+ }
+
+ /**
+ * Return the PDF of the spectator
+ * for the selected configuration.
+ */
+ const PDF& spectatorPDF(pair<bool,bool> conf) const {
+ return conf.first ? thePDFs.second : thePDFs.first;
+ }
+
+public:
+
+ /**
+ * Split this dipole according to the given splitting.
+ * If colourSpectator is true, do not change the spectator.
+ */
+ pair<Dipole,Dipole> split (DipoleSplittingInfo& dsplit,
+ bool colourSpectator) const;
+
+ /**
+ * Produce a new spectator according to the
+ * given splitting.
+ */
+ void recoil (DipoleSplittingInfo& dsplit);
+
+public:
+
+ /**
+ * Put information to ostream
+ */
+ void print(ostream&) const;
+
+private:
+
+ /**
+ * The particles forming the dipole
+ */
+ pair<PPtr,PPtr> theParticles;
+
+ /**
+ * The PDF objects.
+ */
+ pair<PDF,PDF> thePDFs;
+
+ /**
+ * The momentum fractions associated
+ * to the incoming particles
+ */
+ pair<double,double> theFractions;
+
+ /**
+ * The dipole indices, if the first or second particle
+ * is considered as emitter.
+ */
+ pair<DipoleIndex,DipoleIndex> theIndices;
+
+ /**
+ * The scale associated to the first and second
+ * particle, respectively.
+ */
+ pair<Energy,Energy> theScales;
+
+};
+
+inline ostream& operator << (ostream& os, const Dipole& di) {
+ di.print(os);
+ return os;
+}
+
+}
+
+#endif /* HERWIG_Dipole_H */
diff --git a/DipoleShower/Base/DipoleChain.cc b/DipoleShower/Base/DipoleChain.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Base/DipoleChain.cc
@@ -0,0 +1,326 @@
+// -*- C++ -*-
+//
+// DipoleChain.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the DipoleChain class.
+//
+
+#include "DipoleChain.h"
+#include "Herwig++/DipoleShower/Utility/DipolePartonSplitter.h"
+
+#include <boost/utility.hpp>
+using boost::next;
+using boost::prior;
+
+using namespace Herwig;
+
+DipoleChain::DipoleChain()
+ : ggSingleDipole(false) {}
+
+bool DipoleChain::circular () const {
+ return
+ (theDipoles.front().leftParticle() ==
+ theDipoles.back().rightParticle());
+}
+
+bool DipoleChain::hasLeftNeighbour (list<Dipole>::const_iterator dc) const {
+ if ( dc == dipoles().begin() )
+ return circular();
+ return true;
+}
+
+Dipole& DipoleChain::leftNeighbour (list<Dipole>::iterator dc) {
+ assert(hasLeftNeighbour(dc));
+ if ( dc == dipoles().begin() )
+ return dipoles().back();
+ return *(--dc);
+}
+
+const Dipole& DipoleChain::leftNeighbour (list<Dipole>::const_iterator dc) const {
+ assert(hasLeftNeighbour(dc));
+ if ( dc == dipoles().begin() )
+ return dipoles().back();
+ return *(--dc);
+}
+
+list<Dipole>::iterator DipoleChain::leftNeighbourIterator(list<Dipole>::iterator dc) {
+ assert(hasLeftNeighbour(dc));
+ if ( dc == dipoles().begin() )
+ return --dipoles().end();
+ return --dc;
+}
+
+bool DipoleChain::hasRightNeighbour (list<Dipole>::const_iterator dc) const {
+ if (dc == --dipoles().end())
+ return circular();
+ return true;
+}
+
+Dipole& DipoleChain::rightNeighbour (list<Dipole>::iterator dc) {
+ assert(hasRightNeighbour(dc));
+ if ( dc == --dipoles().end() )
+ return dipoles().front();
+ return *(++dc);
+}
+
+const Dipole& DipoleChain::rightNeighbour (list<Dipole>::const_iterator dc) const {
+ assert(hasRightNeighbour(dc));
+ if ( dc == --dipoles().end() )
+ return dipoles().front();
+ return *(++dc);
+}
+
+list<Dipole>::iterator DipoleChain::rightNeighbourIterator(list<Dipole>::iterator dc) {
+ assert(hasRightNeighbour(dc));
+ if ( dc == --dipoles().end() )
+ return dipoles().begin();
+ return ++dc;
+}
+
+void DipoleChain::check() {
+ if ( theDipoles.begin() == prior(theDipoles.end()) ) {
+ if ( theDipoles.front().leftParticle()->hasColour() &&
+ theDipoles.front().leftParticle()->hasAntiColour() ) {
+ assert(theDipoles.front().rightParticle()->hasColour() &&
+ theDipoles.front().rightParticle()->hasAntiColour());
+ ggSingleDipole = true;
+ }
+ }
+}
+
+list<Dipole>::iterator DipoleChain::insertSplitting(list<Dipole>::iterator emittingDipole,
+ pair<Dipole,Dipole> children,
+ pair<list<Dipole>::iterator,list<Dipole>::iterator>& childIterators) {
+
+ assert(DipolePartonSplitter::colourConnected(children.first.leftParticle(),children.first.rightParticle()) ||
+ DipolePartonSplitter::colourConnected(children.second.leftParticle(),children.second.rightParticle()));
+
+ bool was_circular = circular();
+
+ if (hasLeftNeighbour(emittingDipole)) {
+
+ list<Dipole>::iterator theLeftNeighbour =
+ leftNeighbourIterator(emittingDipole);
+
+ theLeftNeighbour->rightParticle(children.first.leftParticle());
+ if ( children.first.leftParticle()->scale() < sqr(theLeftNeighbour->rightScale()) )
+ theLeftNeighbour->rightScale(sqrt(children.first.leftParticle()->scale()));
+ theLeftNeighbour->rightPDF(children.first.leftPDF());
+ theLeftNeighbour->rightFraction(children.first.leftFraction());
+
+ theLeftNeighbour->update();
+
+ }
+
+ if (hasRightNeighbour(emittingDipole)) {
+
+ list<Dipole>::iterator theRightNeighbour =
+ rightNeighbourIterator(emittingDipole);
+
+ theRightNeighbour->leftParticle(children.second.rightParticle());
+ if ( children.second.rightParticle()->scale() < sqr(theRightNeighbour->leftScale()) )
+ theRightNeighbour->leftScale(sqrt(children.second.rightParticle()->scale()));
+ theRightNeighbour->leftPDF(children.second.rightPDF());
+ theRightNeighbour->leftFraction(children.second.rightFraction());
+
+ theRightNeighbour->update();
+
+ }
+
+ if (DipolePartonSplitter::colourConnected(children.first.leftParticle(),children.first.rightParticle()) &&
+ DipolePartonSplitter::colourConnected(children.second.leftParticle(),children.second.rightParticle())) {
+
+ // nothing special to do, just replace the emitting dipole
+ // by the right one and insert the left one before it
+
+ *emittingDipole = children.second;
+
+ childIterators.second = emittingDipole;
+ childIterators.first = dipoles().insert(emittingDipole,children.first);
+
+ if ( ggSingleDipole ) {
+ ggSingleDipole = false;
+ Dipole miss;
+ miss.leftParticle(dipoles().back().rightParticle());
+ miss.rightParticle(dipoles().front().leftParticle());
+ miss.leftScale(dipoles().back().rightScale());
+ miss.rightScale(dipoles().front().leftScale());
+ miss.leftPDF(dipoles().back().rightPDF());
+ miss.rightPDF(dipoles().front().leftPDF());
+ miss.leftFraction(dipoles().back().rightFraction());
+ miss.rightFraction(dipoles().front().leftFraction());
+ miss.update();
+ dipoles().push_back(miss);
+ }
+
+ return dipoles().end();
+
+ }
+
+ if (!DipolePartonSplitter::colourConnected(children.first.leftParticle(),children.first.rightParticle())) {
+
+ if ( !was_circular && !ggSingleDipole ) {
+ *emittingDipole = children.second;
+ childIterators.second = emittingDipole;
+ assert(emittingDipole != dipoles().begin());
+ childIterators.first = prior(emittingDipole);
+ return emittingDipole;
+ }
+
+ *emittingDipole = children.second;
+
+ if ( ggSingleDipole ) {
+ ggSingleDipole = false;
+ Dipole miss;
+ miss.leftParticle(children.second.rightParticle());
+ miss.rightParticle(children.first.leftParticle());
+ miss.leftScale(children.second.rightScale());
+ miss.rightScale(children.first.leftScale());
+ miss.leftPDF(children.second.rightPDF());
+ miss.rightPDF(children.first.leftPDF());
+ miss.leftFraction(children.second.rightFraction());
+ miss.rightFraction(children.first.leftFraction());
+ miss.update();
+ dipoles().push_back(miss);
+ childIterators.first = dipoles().begin();
+ childIterators.second = prior(dipoles().end());
+ return dipoles().end();
+ }
+
+ childIterators.second = emittingDipole;
+ if ( emittingDipole == dipoles().begin() )
+ childIterators.first = --dipoles().end();
+ else
+ childIterators.first = prior(emittingDipole);
+
+ if ( emittingDipole == dipoles().begin() )
+ return dipoles().end();
+
+ dipoles().splice(dipoles().begin(),dipoles(),emittingDipole,dipoles().end());
+
+ // explicitly fix iterators in case the splice implementation
+ // at hand does invalidate iterators (the SGI docu says, it doesn't,
+ // but it seems that this behaviour is not part of the standard)
+ childIterators.second = dipoles().begin();
+ childIterators.first = --dipoles().end();
+
+ return dipoles().end();
+
+ }
+
+ if (!DipolePartonSplitter::colourConnected(children.second.leftParticle(),children.second.rightParticle())) {
+
+ if ( !was_circular && !ggSingleDipole ) {
+ *emittingDipole = children.first;
+ childIterators.first = emittingDipole;
+ assert(emittingDipole != --dipoles().end());
+ childIterators.second = next(emittingDipole);
+ return next(emittingDipole);
+ }
+
+ *emittingDipole = children.first;
+
+ if ( ggSingleDipole ) {
+ ggSingleDipole = false;
+ Dipole miss;
+ miss.leftParticle(children.second.rightParticle());
+ miss.rightParticle(children.first.leftParticle());
+ miss.leftScale(children.second.rightScale());
+ miss.rightScale(children.first.leftScale());
+ miss.leftPDF(children.second.rightPDF());
+ miss.rightPDF(children.first.leftPDF());
+ miss.leftFraction(children.second.rightFraction());
+ miss.rightFraction(children.first.leftFraction());
+ miss.update();
+ dipoles().push_front(miss);
+ childIterators.first = dipoles().begin();
+ childIterators.second = prior(dipoles().end());
+ return dipoles().end();
+ }
+
+ childIterators.first = emittingDipole;
+ if ( emittingDipole == --dipoles().end() )
+ childIterators.second = dipoles().begin();
+ else
+ childIterators.second = next(emittingDipole);
+
+ if ( emittingDipole == --dipoles().end() )
+ return dipoles().end();
+
+ dipoles().splice(dipoles().begin(),dipoles(),next(emittingDipole),dipoles().end());
+
+ // explicitly fix iterators in case the splice implementation
+ // at hand does invalidate iterators (the SGI docu says, it doesn't,
+ // but it seems that this behaviour is not part of the standard)
+ childIterators.first = dipoles().begin();
+ childIterators.second = --dipoles().end();
+
+ return dipoles().end();
+
+ }
+
+ return dipoles().end();
+
+}
+
+void DipoleChain::updateDipole(list<Dipole>::iterator dip) {
+
+ dip->update();
+
+ if (hasLeftNeighbour(dip)) {
+
+ list<Dipole>::iterator theLeftNeighbour =
+ leftNeighbourIterator(dip);
+
+ theLeftNeighbour->rightParticle(dip->leftParticle());
+ theLeftNeighbour->rightPDF(dip->leftPDF());
+ theLeftNeighbour->rightFraction(dip->leftFraction());
+
+ theLeftNeighbour->update();
+
+ }
+
+ if (hasRightNeighbour(dip)) {
+
+ list<Dipole>::iterator theRightNeighbour =
+ rightNeighbourIterator(dip);
+
+ theRightNeighbour->leftParticle(dip->rightParticle());
+ theRightNeighbour->leftPDF(dip->rightPDF());
+ theRightNeighbour->leftFraction(dip->rightFraction());
+
+ theRightNeighbour->update();
+
+ }
+
+}
+
+void DipoleChain::print(ostream& os) const {
+
+ os << "--- DipoleChain ----------------------------------------------------------------\n";
+
+ if ( theDipoles.empty() ) {
+ os << " *** This DipoleChain is empty. ***\n";
+ } else {
+
+ os << " " << (!circular() ? "non-" : "") << "circular with "
+ << theDipoles.size() << " dipoles\n";
+
+ for (list<Dipole>::const_iterator dit = theDipoles.begin();
+ dit != theDipoles.end(); ++dit) {
+ os << (*dit);
+ }
+
+ }
+
+ os << "--------------------------------------------------------------------------------\n";
+
+ os << flush;
+
+}
diff --git a/DipoleShower/Base/DipoleChain.h b/DipoleShower/Base/DipoleChain.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Base/DipoleChain.h
@@ -0,0 +1,153 @@
+// -*- C++ -*-
+//
+// DipoleChain.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_DipoleChain_H
+#define HERWIG_DipoleChain_H
+//
+// This is the declaration of the DipoleChain class.
+//
+
+#include "Dipole.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief The DipoleChain class is used by the dipole shower to
+ * represent a chain of dipoles.
+ *
+ */
+class DipoleChain {
+
+public:
+
+ /**
+ * Default constructor
+ */
+ DipoleChain();
+
+ /**
+ * Return true, if this chain is circular.
+ */
+ bool circular () const;
+
+ /*
+ * Return true, if the dipole referred to
+ * has a left neighbour
+ */
+ bool hasLeftNeighbour(list<Dipole>::const_iterator dc) const;
+
+ /*
+ * Return a reference to the left neighbour,
+ * if existing
+ */
+ Dipole& leftNeighbour(list<Dipole>::iterator dc);
+
+ /*
+ * Return a const reference to the left neighbour,
+ * if existing
+ */
+ const Dipole& leftNeighbour(list<Dipole>::const_iterator dc) const;
+
+ /**
+ * Return an iterator to the left neighbour
+ */
+ list<Dipole>::iterator leftNeighbourIterator(list<Dipole>::iterator dc);
+
+ /*
+ * Return true, if the dipole referred to
+ * has a right neighbour
+ */
+ bool hasRightNeighbour (list<Dipole>::const_iterator dc) const;
+
+ /*
+ * Return a reference to the right neighbour,
+ * if existing
+ */
+ Dipole& rightNeighbour (list<Dipole>::iterator dc);
+
+ /*
+ * Return a const reference to the right neighbour,
+ * if existing
+ */
+ const Dipole& rightNeighbour (list<Dipole>::const_iterator dc) const;
+
+ /**
+ * Return an iterator to the right neighbour
+ */
+ list<Dipole>::iterator rightNeighbourIterator(list<Dipole>::iterator dc);
+
+public:
+
+ /**
+ * Access the dipole list
+ */
+ list<Dipole>& dipoles() { return theDipoles; }
+
+ /**
+ * Return the dipole list
+ */
+ const list<Dipole>& dipoles() const { return theDipoles; }
+
+ /**
+ * Check for gg single dipole
+ */
+ void check();
+
+public:
+
+ /*
+ * Insert the given splitting; if this contains a chain-breakup emission and
+ * the chain is circular, reshuffle the chain to make it non-circular; if it is
+ * already non-circular return the iterator starting the new chain. If no
+ * splitting is needed return the end iterator of the dipole list.
+ * Set the iterators pointing to the children dipoles.
+ */
+ list<Dipole>::iterator insertSplitting(list<Dipole>::iterator emittingDipole,
+ pair<Dipole,Dipole> children,
+ pair<list<Dipole>::iterator,list<Dipole>::iterator>& childIterators);
+
+ /**
+ * Indicate a change in the given dipole.
+ */
+ void updateDipole(list<Dipole>::iterator dip);
+
+public:
+
+ /**
+ * Put information to ostream
+ */
+ void print(ostream&) const;
+
+private:
+
+ /**
+ * The dipoles contained in this chain
+ */
+ list<Dipole> theDipoles;
+
+ /**
+ * Switch on special treatment for
+ * gg single dipole
+ */
+ bool ggSingleDipole;
+
+};
+
+inline ostream& operator << (ostream& os, const DipoleChain& di) {
+ di.print(os);
+ return os;
+}
+
+}
+
+#endif /* HERWIG_DipoleChain_H */
diff --git a/DipoleShower/Base/DipoleChainOrdering.cc b/DipoleShower/Base/DipoleChainOrdering.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Base/DipoleChainOrdering.cc
@@ -0,0 +1,146 @@
+// -*- C++ -*-
+//
+// DipoleChainOrdering.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the DipoleChainOrdering class.
+//
+
+#include "DipoleChainOrdering.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/Interface/Switch.h"
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+DipoleChainOrdering::DipoleChainOrdering()
+ : DipoleEvolutionOrdering(), virtualityOrdering(false) {}
+
+DipoleChainOrdering::~DipoleChainOrdering() {}
+
+IBPtr DipoleChainOrdering::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr DipoleChainOrdering::fullclone() const {
+ return new_ptr(*this);
+}
+
+Energy DipoleChainOrdering::hardScale(tPPtr emitter, tPPtr spectator,
+ double emitterX, double spectatorX,
+ const DipoleSplittingKernel& split,
+ const DipoleIndex& index) const {
+
+ Energy scale =
+ split.splittingKinematics()->dipoleScale(emitter->momentum(),
+ spectator->momentum());
+
+ return
+ virtualityOrdering ?
+ split.splittingKinematics()->QMax(scale,emitterX,spectatorX,index) :
+ split.splittingKinematics()->ptMax(scale,emitterX,spectatorX,index,split);
+
+}
+
+
+void DipoleChainOrdering::setEvolutionScale(Energy scale,
+ const DipoleSplittingInfo&,
+ DipoleChain& chain,
+ pair<list<Dipole>::iterator,list<Dipole>::iterator>) const {
+
+ for ( list<Dipole>::iterator dip = chain.dipoles().begin();
+ dip != chain.dipoles().end(); ++dip ) {
+
+ if ( dip->emitterScale(make_pair(true,false)) > scale )
+ dip->emitterScale(make_pair(true,false),scale);
+
+ if ( dip->emitterScale(make_pair(false,true)) > scale )
+ dip->emitterScale(make_pair(false,true),scale);
+
+ }
+
+}
+
+void DipoleChainOrdering::setEvolutionScale(Energy scale,
+ const DipoleSplittingInfo&,
+ DipoleChain& chain,
+ list<Dipole>::iterator) const {
+
+ for ( list<Dipole>::iterator dip = chain.dipoles().begin();
+ dip != chain.dipoles().end(); ++dip ) {
+
+ if ( dip->emitterScale(make_pair(true,false)) > scale )
+ dip->emitterScale(make_pair(true,false),scale);
+
+ if ( dip->emitterScale(make_pair(false,true)) > scale )
+ dip->emitterScale(make_pair(false,true),scale);
+
+ }
+
+}
+
+Energy DipoleChainOrdering::evolutionScale(const DipoleSplittingInfo& split,
+ const DipoleSplittingKernel& spkernel) const {
+ return
+ virtualityOrdering ?
+ spkernel.splittingKinematics()->QFromPt(split.lastPt(),split) :
+ split.lastPt();
+}
+
+Energy DipoleChainOrdering::maxPt(Energy scale,
+ const DipoleSplittingInfo& split,
+ const DipoleSplittingKernel& spkernel) const {
+ return
+ virtualityOrdering ?
+ spkernel.splittingKinematics()->ptMax(scale,split.emitterX(),split.spectatorX(),split.index(),spkernel) :
+ scale;
+}
+
+// If needed, insert default implementations of virtual function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void DipoleChainOrdering::persistentOutput(PersistentOStream & os) const {
+ os << virtualityOrdering;
+}
+
+void DipoleChainOrdering::persistentInput(PersistentIStream & is, int) {
+ is >> virtualityOrdering;
+}
+
+ClassDescription<DipoleChainOrdering> DipoleChainOrdering::initDipoleChainOrdering;
+// Definition of the static class description member.
+
+void DipoleChainOrdering::Init() {
+
+ static ClassDocumentation<DipoleChainOrdering> documentation
+ ("DipoleChainOrdering performs ordering on "
+ "complete colour singlet dipole chains.");
+
+
+ static Switch<DipoleChainOrdering,bool> interfaceVirtualityOrdering
+ ("Ordering",
+ "[experimental] Switch between virtuality and pt ordering.",
+ &DipoleChainOrdering::virtualityOrdering, false, false, false);
+ static SwitchOption interfaceVirtualityOrderingPt
+ (interfaceVirtualityOrdering,
+ "Pt",
+ "Perform pt ordering",
+ false);
+ static SwitchOption interfaceVirtualityOrderingVirtuality
+ (interfaceVirtualityOrdering,
+ "Virtuality",
+ "Perform virtuality ordering",
+ true);
+
+ interfaceVirtualityOrdering.rank(-1);
+
+}
+
diff --git a/DipoleShower/Base/DipoleChainOrdering.h b/DipoleShower/Base/DipoleChainOrdering.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Base/DipoleChainOrdering.h
@@ -0,0 +1,200 @@
+// -*- C++ -*-
+//
+// DipoleChainOrdering.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_DipoleChainOrdering_H
+#define HERWIG_DipoleChainOrdering_H
+//
+// This is the declaration of the DipoleChainOrdering class.
+//
+
+#include "DipoleEvolutionOrdering.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief DipoleChainOrdering performs ordering on
+ * complete colour singlet dipole chains.
+ *
+ */
+class DipoleChainOrdering: public DipoleEvolutionOrdering {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ DipoleChainOrdering();
+
+ /**
+ * The destructor.
+ */
+ virtual ~DipoleChainOrdering();
+ //@}
+
+public:
+
+ /**
+ * For the given dipole and splitting kernel return
+ * the hard scale.
+ */
+ virtual Energy hardScale(tPPtr emitter, tPPtr spectator,
+ double emitterX, double spectatorX,
+ const DipoleSplittingKernel&,
+ const DipoleIndex&) const;
+
+ /**
+ * For the given performed splitting, dipole chain
+ * and dipoles originating from the splitting, set the next
+ * scale.
+ */
+ virtual void setEvolutionScale(Energy scale,
+ const DipoleSplittingInfo&,
+ DipoleChain&,
+ pair<list<Dipole>::iterator,list<Dipole>::iterator>) const;
+
+ /**
+ * For the given performed splitting, dipole chain
+ * and dipole taking a recoil, set the next
+ * scale.
+ */
+ virtual void setEvolutionScale(Energy scale,
+ const DipoleSplittingInfo&,
+ DipoleChain&,
+ list<Dipole>::iterator) const;
+
+ /**
+ * For the given selected splitting return
+ * the evolution scale.
+ */
+ virtual Energy evolutionScale(const DipoleSplittingInfo& split,
+ const DipoleSplittingKernel&) const;
+
+ /**
+ * Return the maximum pt corresponding to the given
+ * evolution scale.
+ */
+ virtual Energy maxPt(Energy scale,
+ const DipoleSplittingInfo&,
+ const DipoleSplittingKernel&) const;
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+private:
+
+ /**
+ * True, if virtuality instead of pt ordering
+ * should be performed.
+ */
+ bool virtualityOrdering;
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<DipoleChainOrdering> initDipoleChainOrdering;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ DipoleChainOrdering & operator=(const DipoleChainOrdering &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of DipoleChainOrdering. */
+template <>
+struct BaseClassTrait<Herwig::DipoleChainOrdering,1> {
+ /** Typedef of the first base class of DipoleChainOrdering. */
+ typedef Herwig::DipoleEvolutionOrdering NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the DipoleChainOrdering class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::DipoleChainOrdering>
+ : public ClassTraitsBase<Herwig::DipoleChainOrdering> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::DipoleChainOrdering"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * DipoleChainOrdering is implemented. It may also include several, space-separated,
+ * libraries if the class DipoleChainOrdering depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_DipoleChainOrdering_H */
diff --git a/DipoleShower/Base/DipoleEventRecord.cc b/DipoleShower/Base/DipoleEventRecord.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Base/DipoleEventRecord.cc
@@ -0,0 +1,824 @@
+// -*- C++ -*-
+//
+// DipoleEventRecord.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the DipoleEventRecord class.
+//
+
+#include "DipoleEventRecord.h"
+#include "Herwig++/DipoleShower/Utility/DipolePartonSplitter.h"
+#include "Herwig++/Shower/ShowerHandler.h"
+
+#include "ThePEG/Repository/EventGenerator.h"
+#include "ThePEG/PDF/PartonExtractor.h"
+
+#include <boost/utility.hpp>
+using boost::next;
+using boost::prior;
+
+#include <algorithm>
+
+using namespace Herwig;
+
+PList DipoleEventRecord::colourOrdered() {
+
+ PList colour_ordered;
+
+ size_t done_size = outgoing().size();
+ if (incoming().first->coloured())
+ ++done_size;
+ if (incoming().second->coloured())
+ ++done_size;
+
+ while (colour_ordered.size() != done_size) {
+
+ PPtr current;
+
+ // start with singlets, as long as we have some
+
+ if (find(colour_ordered.begin(),colour_ordered.end(),incoming().first) ==
+ colour_ordered.end() && incoming().first->coloured()) {
+ if (!incoming().first->hasColour() || !incoming().first->hasAntiColour())
+ current = incoming().first;
+ }
+
+ if (!current) {
+ for (PList::iterator p = outgoing().begin();
+ p != outgoing().end(); ++p) {
+ if (find(colour_ordered.begin(),colour_ordered.end(),*p) ==
+ colour_ordered.end() && (**p).coloured()) {
+ if (!(**p).hasColour() || !(**p).hasAntiColour()) {
+ current = *p;
+ break;
+ }
+ }
+ }
+ }
+
+ if (!current) {
+ if (find(colour_ordered.begin(),colour_ordered.end(),incoming().second) ==
+ colour_ordered.end() && incoming().second->coloured()) {
+ if (!incoming().second->hasColour() || !incoming().second->hasAntiColour())
+ current = incoming().second;
+ }
+ }
+
+ // then go on with anything else
+
+ if (!current) {
+ if (find(colour_ordered.begin(),colour_ordered.end(),incoming().first) ==
+ colour_ordered.end() && incoming().first->coloured()) {
+ current = incoming().first;
+ }
+ }
+
+ if (!current) {
+ for (PList::iterator p = outgoing().begin();
+ p != outgoing().end(); ++p) {
+ if (find(colour_ordered.begin(),colour_ordered.end(),*p) ==
+ colour_ordered.end() && (**p).coloured()) {
+ current = *p;
+ break;
+ }
+ }
+ }
+
+ if (!current) {
+ if (find(colour_ordered.begin(),colour_ordered.end(),incoming().second) ==
+ colour_ordered.end() && incoming().second->coloured()) {
+ current = incoming().second;
+ }
+ }
+
+ assert(current);
+
+ PPtr next;
+ Ptr<ColourLine>::ptr walk_the_line;
+
+ while (true) {
+
+ if (!walk_the_line) {
+ if (current->hasColour()) {
+ walk_the_line = current->colourLine();
+ }
+ else if (current->hasAntiColour()) {
+ walk_the_line = current->antiColourLine();
+ }
+ }
+
+ if (!next)
+ for (tPVector::const_iterator p = walk_the_line->coloured().begin();
+ p != walk_the_line->coloured().end(); ++p) {
+ if (*p == current)
+ continue;
+ if (find(outgoing().begin(),outgoing().end(),*p) != outgoing().end() ||
+ *p == incoming().first ||
+ *p == incoming().second) {
+ next = *p;
+ if (next->hasColour() && next->hasAntiColour()) {
+ walk_the_line = walk_the_line == next->colourLine() ? next->antiColourLine() : next->colourLine();
+ }
+ break;
+ }
+ }
+
+ if (!next)
+ for (tPVector::const_iterator p = walk_the_line->antiColoured().begin();
+ p != walk_the_line->antiColoured().end(); ++p) {
+ if (*p == current)
+ continue;
+ if (find(outgoing().begin(),outgoing().end(),*p) != outgoing().end() ||
+ *p == incoming().first ||
+ *p == incoming().second) {
+ next = *p;
+ if (next->hasColour() && next->hasAntiColour()) {
+ walk_the_line = walk_the_line == next->colourLine() ? next->antiColourLine() : next->colourLine();
+ }
+ break;
+ }
+ }
+
+ assert(next);
+
+ colour_ordered.push_back(current);
+ current = next;
+
+ // done if next is not a gluon or next is already in colour_ordered
+
+ if ((current->hasColour() && !current->hasAntiColour()) ||
+ (!current->hasColour() && current->hasAntiColour())) {
+ colour_ordered.push_back(current);
+ break;
+ }
+
+ if (next->hasColour() && next->hasAntiColour()) {
+ if (find(colour_ordered.begin(),colour_ordered.end(),next) != colour_ordered.end())
+ break;
+ }
+
+ next = PPtr();
+
+ }
+
+ }
+
+ return colour_ordered;
+
+}
+
+void DipoleEventRecord::popChain() {
+ assert(!theChains.empty());
+ theDoneChains.push_back(DipoleChain());
+ theDoneChains.back().dipoles().splice(theDoneChains.back().dipoles().begin(),theChains.front().dipoles());
+ theChains.pop_front();
+}
+
+void DipoleEventRecord::popChain(list<DipoleChain>::iterator ch) {
+ assert(!theChains.empty());
+ theDoneChains.push_back(DipoleChain());
+ theDoneChains.back().dipoles().splice(theDoneChains.back().dipoles().begin(),ch->dipoles());
+ theChains.erase(ch);
+}
+
+void DipoleEventRecord::popChains(const list<list<DipoleChain>::iterator>& chs) {
+
+ assert(!theChains.empty());
+
+ for ( list<list<DipoleChain>::iterator>::const_iterator ch =
+ chs.begin(); ch != chs.end(); ++ch ) {
+ theDoneChains.push_back(DipoleChain());
+ theDoneChains.back().dipoles().splice(theDoneChains.back().dipoles().begin(),(*ch)->dipoles());
+ }
+
+ for ( list<list<DipoleChain>::iterator>::const_iterator ch =
+ chs.begin(); ch != chs.end(); ++ch )
+ theChains.erase(*ch);
+
+}
+
+void DipoleEventRecord::findChains(const PList& ordered) {
+
+ theChains.clear();
+ theDoneChains.clear();
+
+ DipoleChain current_chain;
+
+ if (ordered.size() > 2) {
+
+ for (PList::const_iterator p = ordered.begin();
+ p != ordered.end(); ++p) {
+
+ PList::const_iterator next_it =
+ p != --ordered.end() ? next(p) : ordered.begin();
+
+ if (!DipolePartonSplitter::colourConnected(*p,*next_it)) {
+ current_chain.check();
+ theChains.push_back(current_chain);
+ current_chain.dipoles().clear();
+ continue;
+ }
+
+ pair<bool,bool> initial_state (false,false);
+ initial_state.first = (*p == incoming().first || *p == incoming().second);
+ initial_state.second = (*next_it == incoming().first || *next_it == incoming().second);
+
+ pair<int,int> which_in (-1,-1);
+ if (initial_state.first)
+ which_in.first = *p == incoming().first ? 0 : 1;
+ if (initial_state.second)
+ which_in.second = *next_it == incoming().first ? 0 : 1;
+
+ pair<double,double> xs (1.,1.);
+ if (initial_state.first)
+ xs.first = *p == incoming().first ? fractions().first : fractions().second;
+ if (initial_state.second)
+ xs.second = *next_it == incoming().first ? fractions().first : fractions().second;
+
+ pair<PDF,PDF> pdf;
+
+ if ( which_in.first == 0 )
+ pdf.first = pdfs().first;
+ else if ( which_in.first == 1 )
+ pdf.first = pdfs().second;
+
+ if ( which_in.second == 0 )
+ pdf.second = pdfs().first;
+ else if ( which_in.second == 1 )
+ pdf.second = pdfs().second;
+
+ current_chain.dipoles().push_back(Dipole(make_pair(*p,*next_it),pdf,xs));
+
+ }
+ } else {
+
+ // treat 2 -> singlet, singlet -> 2 and 1 + singlet -> 1 + singlet special
+ // to prevent duplicate dipole
+
+ assert(DipolePartonSplitter::colourConnected(ordered.front(),ordered.back()));
+
+ pair<bool,bool> initial_state (false,false);
+ initial_state.first = (ordered.front() == incoming().first || ordered.front() == incoming().second);
+ initial_state.second = (ordered.back() == incoming().first || ordered.back() == incoming().second);
+
+ pair<int,int> which_in (-1,-1);
+ if (initial_state.first)
+ which_in.first = ordered.front() == incoming().first ? 0 : 1;
+ if (initial_state.second)
+ which_in.second = ordered.back() == incoming().first ? 0 : 1;
+
+ pair<double,double> xs (1.,1.);
+ if (initial_state.first)
+ xs.first = ordered.front() == incoming().first ? fractions().first : fractions().second;
+ if (initial_state.second)
+ xs.second = ordered.back() == incoming().first ? fractions().first : fractions().second;
+
+ pair<PDF,PDF> pdf;
+
+ if ( which_in.first == 0 )
+ pdf.first = pdfs().first;
+ else if ( which_in.first == 1 )
+ pdf.first = pdfs().second;
+
+ if ( which_in.second == 0 )
+ pdf.second = pdfs().first;
+ else if ( which_in.second == 1 )
+ pdf.second = pdfs().second;
+
+ current_chain.dipoles().push_back(Dipole(make_pair(ordered.front(),ordered.back()),pdf,xs));
+
+ }
+
+ if (!current_chain.dipoles().empty()) {
+ current_chain.check();
+ theChains.push_back(current_chain);
+ }
+
+}
+
+void DipoleEventRecord::getAll(const ParticleVector& childs,
+ set<PPtr>& hardSet,
+ set<PPtr>& outgoingSet) {
+
+ for ( ParticleVector::const_iterator p = childs.begin();
+ p != childs.end(); ++p ) {
+ if ( ShowerHandler::currentHandler()->eventHandler()->currentCollision()->isRemnant(*p) )
+ continue;
+ if ( (**p).children().empty() ) {
+ if ( (**p).coloured() &&
+ outgoingSet.find(*p) == outgoingSet.end() )
+ outgoingSet.insert(*p);
+ else if ( !(**p).coloured() &&
+ hardSet.find(*p) == hardSet.end() )
+ hardSet.insert(*p);
+ } else {
+ getAll((**p).children(),hardSet,outgoingSet);
+ }
+ }
+
+}
+
+// shamelessly stolen from ShowerTree
+void DipoleEventRecord::colourIsolate(const vector<PPtr> & original,
+ const vector<PPtr> & copy) {
+ // vectors must have same size
+ assert(original.size()==copy.size());
+ // create a temporary map with all the particles to make looping easier
+ vector<PPair> particles;
+ particles.reserve(original.size());
+ for(unsigned int ix=0;ix<original.size();++ix)
+ particles.push_back(make_pair(copy[ix],original[ix]));
+ // reset the colour of the copies
+ vector<PPair>::const_iterator cit,cjt;
+ for(cit=particles.begin();cit!=particles.end();++cit)
+ if((*cit).first->colourInfo()) (*cit).first->colourInfo(new_ptr(ColourBase()));
+ map<tColinePtr,tColinePtr> cmap;
+ // make the colour connections of the copies
+ for(cit=particles.begin();cit!=particles.end();++cit) {
+ ColinePtr c1,newline;
+ // if particle has a colour line
+ if((*cit).second->colourLine()&&!(*cit).first->colourLine()) {
+ c1=(*cit).second->colourLine();
+ newline=ColourLine::create((*cit).first);
+ cmap[c1]=newline;
+ for(cjt=particles.begin();cjt!=particles.end();++cjt) {
+ if(cjt==cit) continue;
+ if((*cjt).second->colourLine()==c1)
+ newline->addColoured((*cjt).first);
+ else if((*cjt).second->antiColourLine()==c1)
+ newline->addColoured((*cjt).first,true);
+ }
+ }
+ // if anticolour line
+ if((*cit).second->antiColourLine()&&!(*cit).first->antiColourLine()) {
+ c1=(*cit).second->antiColourLine();
+ newline=ColourLine::create((*cit).first,true);
+ cmap[c1]=newline;
+ for(cjt=particles.begin();cjt!=particles.end();++cjt) {
+ if(cjt==cit) continue;
+ if((*cjt).second->colourLine()==c1)
+ newline->addColoured((*cjt).first);
+ else if((*cjt).second->antiColourLine()==c1)
+ newline->addColoured((*cjt).first,true);
+ }
+ }
+ }
+ for ( map<tColinePtr,tColinePtr>::const_iterator c = cmap.begin();
+ c != cmap.end(); ++c ) {
+ theColourLines[c->second] = c->first;
+ }
+ // sort out sinks and sources
+ for(cit=particles.begin();cit!=particles.end();++cit) {
+ tColinePtr cline[2];
+ tColinePair cpair;
+ for(unsigned int ix=0;ix<4;++ix) {
+ cline[0] = ix<2 ? cit->second->colourLine() : cit->second->antiColourLine();
+ cline[1] = ix<2 ? cit->first ->colourLine() : cit->first ->antiColourLine();
+ if(cline[0]) {
+ switch (ix) {
+ case 0: case 2:
+ cpair = cline[0]->sinkNeighbours();
+ break;
+ case 1: case 3:
+ cpair = cline[0]->sourceNeighbours();
+ break;
+ };
+ }
+ else {
+ cpair = make_pair(tColinePtr(),tColinePtr());
+ }
+ if(cline[0]&&cpair.first) {
+ map<tColinePtr,tColinePtr>::const_iterator
+ mit[2] = {cmap.find(cpair.first),cmap.find(cpair.second)};
+ if(mit[0]!=cmap.end()&&mit[1]!=cmap.end()) {
+ if(ix==0||ix==2) {
+ cline[1]->setSinkNeighbours(mit[0]->second,mit[1]->second);
+ }
+ else {
+ cline[1]->setSourceNeighbours(mit[0]->second,mit[1]->second);
+ }
+ }
+ }
+ }
+ }
+}
+
+// shamelessly stolen from ShowerTree
+void DipoleEventRecord::updateColour(PPtr particle) {
+ // if attached to a colour line
+ if(particle->colourLine()) {
+ bool reset=false;
+ // if colour line from hard process reconnect
+ if(theColourLines.find(particle->colourLine())!=theColourLines.end()) {
+ ColinePtr c1=particle->colourLine();
+ c1->removeColoured(particle);
+ theColourLines[c1]->addColoured(particle);
+ reset=true;
+ }
+ // ensure properly connected to the line
+ if(!reset) {
+ ColinePtr c1=particle->colourLine();
+ c1->removeColoured(particle);
+ c1->addColoured(particle);
+ }
+ }
+ // if attached to an anticolour line
+ if(particle->antiColourLine()) {
+ bool reset=false;
+ // if anti colour line from hard process reconnect
+ if(theColourLines.find(particle->antiColourLine())!=theColourLines.end()) {
+ ColinePtr c1=particle->antiColourLine();
+ c1->removeColoured(particle,true);
+ theColourLines[c1]->addColoured(particle,true);
+ reset=true;
+ }
+ if(!reset) {
+ ColinePtr c1=particle->antiColourLine();
+ c1->removeColoured(particle,true);
+ c1->addColoured(particle,true);
+ }
+ }
+ for ( ParticleVector::const_iterator c = particle->children().begin();
+ c != particle->children().end(); ++c ) {
+ updateColour(*c);
+ }
+}
+
+
+const map<PPtr,PPtr>&
+DipoleEventRecord::prepare(tSubProPtr subpro,
+ tStdXCombPtr xc,
+ const pair<PDF,PDF>& pdf,
+ bool dipoles) {
+
+ theSubProcess = subpro;
+
+ theOutgoing.clear();
+ theHard.clear();
+ theColourLines.clear();
+ theOriginals.clear();
+
+ PPair in = subpro->incoming();
+
+ assert(ShowerHandler::currentHandler());
+ tPPair beam = ShowerHandler::currentHandler()->generator()->currentEvent()->incoming();
+
+ // don't take these from the XComb as it may be null
+ pair<double,double> xs;
+ Direction<0> dir(true);
+ xs.first = in.first->momentum().dirPlus()/beam.first->momentum().dirPlus();
+ dir.reverse();
+ xs.second = in.second->momentum().dirPlus()/beam.second->momentum().dirPlus();
+
+ theXComb = xc;
+ thePDFs = pdf;
+ theFractions = xs;
+
+ set<PPtr> allHard;
+ set<PPtr> allOutgoing;
+
+ getAll(in.first->children(),allHard,allOutgoing);
+ getAll(in.second->children(),allHard,allOutgoing);
+
+ vector<PPtr> original;
+ vector<PPtr> copies;
+ original.push_back(in.first);
+ original.push_back(in.second);
+ copy(allOutgoing.begin(),allOutgoing.end(),back_inserter(original));
+ for ( vector<PPtr>::const_iterator p = original.begin();
+ p != original.end(); ++p ) {
+ PPtr copy = new_ptr(Particle(**p));
+ copies.push_back(copy);
+ theOriginals[*p] = copy;
+ }
+
+ colourIsolate(original,copies);
+
+ theIncoming.first = copies[0];
+ ParticleVector children = theIncoming.first->children();
+ for ( ParticleVector::const_iterator c = children.begin();
+ c != children.end(); ++c )
+ theIncoming.first->abandonChild(*c);
+ theIncoming.second = copies[1];
+ children = theIncoming.second->children();
+ for ( ParticleVector::const_iterator c = children.begin();
+ c != children.end(); ++c )
+ theIncoming.second->abandonChild(*c);
+ copy(copies.begin()+2,copies.end(),back_inserter(theOutgoing));
+
+ for ( set<PPtr>::const_iterator p = allHard.begin(); p != allHard.end(); ++p ) {
+ PPtr copy = new_ptr(Particle(**p));
+ theHard.push_back(copy);
+ theOriginals[*p] = copy;
+ }
+
+ if ( dipoles ) {
+ PList cordered = colourOrdered();
+ findChains(cordered);
+ }
+
+ PList::const_iterator XFirst, XLast;
+
+ if ( !theHard.empty() ) {
+ XFirst = theHard.begin();
+ XLast = theHard.end();
+ } else {
+ XFirst = theOutgoing.begin();
+ XLast = theOutgoing.end();
+ }
+
+ thePX = (**XFirst).momentum();
+ ++XFirst;
+ for ( ; XFirst != XLast; ++XFirst )
+ thePX += (**XFirst).momentum();
+
+ return theOriginals;
+
+}
+
+void DipoleEventRecord::clear() {
+ theSubProcess = SubProPtr();
+ theXComb = StdXCombPtr();
+ thePDFs = pair<PDF,PDF>();
+ theIncoming = PPair();
+ theOutgoing.clear();
+ theIntermediates.clear();
+ theHard.clear();
+ theChains.clear();
+ theDoneChains.clear();
+ theOriginals.clear();
+ theColourLines.clear();
+}
+
+void DipoleEventRecord::update(DipoleSplittingInfo& dsplit) {
+
+ if ( incoming().first == dsplit.emitter() ) {
+ theIntermediates.push_back(dsplit.emitter());
+ theIncoming.first = dsplit.splitEmitter();
+ theFractions.first /= dsplit.lastEmitterZ();
+ } else if ( incoming().first == dsplit.spectator() ) {
+ theIntermediates.push_back(dsplit.spectator());
+ theIncoming.first = dsplit.splitSpectator();
+ theFractions.first /= dsplit.lastSpectatorZ();
+ }
+
+ if ( incoming().second == dsplit.emitter() ) {
+ theIntermediates.push_back(dsplit.emitter());
+ theIncoming.second = dsplit.splitEmitter();
+ theFractions.second /= dsplit.lastEmitterZ();
+ } else if ( incoming().second == dsplit.spectator() ) {
+ theIntermediates.push_back(dsplit.spectator());
+ theIncoming.second = dsplit.splitSpectator();
+ theFractions.second /= dsplit.lastSpectatorZ();
+ }
+
+ PList::iterator pos;
+
+ pos = find(theOutgoing.begin(), theOutgoing.end(), dsplit.emitter());
+ if (pos != theOutgoing.end()) {
+ theIntermediates.push_back(*pos);
+ *pos = dsplit.splitEmitter();
+ }
+
+ pos = find(theOutgoing.begin(), theOutgoing.end(), dsplit.spectator());
+ if (pos != theOutgoing.end()) {
+ theIntermediates.push_back(*pos);
+ *pos = dsplit.splitSpectator();
+ }
+
+ theOutgoing.push_back(dsplit.emission());
+
+ if (dsplit.splittingKinematics()->doesTransform()) {
+
+ for (PList::iterator p = theIntermediates.begin();
+ p != theIntermediates.end(); ++p) {
+ (**p).set5Momentum(dsplit.splittingKinematics()->transform((**p).momentum()));
+ }
+
+ for (PList::iterator h = theHard.begin();
+ h != theHard.end(); ++h) {
+ (**h).set5Momentum(dsplit.splittingKinematics()->transform((**h).momentum()));
+ }
+
+ for (PList::iterator p = theOutgoing.begin();
+ p != theOutgoing.end(); ++p)
+ if ((*p) != dsplit.splitEmitter() &&
+ (*p) != dsplit.splitSpectator() &&
+ (*p) != dsplit.emission())
+ (**p).set5Momentum(dsplit.splittingKinematics()->transform((**p).momentum()));
+
+ }
+
+}
+
+void
+DipoleEventRecord::split(list<Dipole>::iterator dip,
+ list<DipoleChain>::iterator ch,
+ DipoleSplittingInfo& dsplit,
+ pair<list<Dipole>::iterator,list<Dipole>::iterator>& childIterators,
+ DipoleChain*& firstChain, DipoleChain*& secondChain,
+ bool colourSpectator) {
+
+ static DipoleChain empty;
+
+ pair<Dipole,Dipole> children = dip->split(dsplit,colourSpectator);
+
+ list<Dipole>::iterator breakup =
+ ch->insertSplitting(dip,children,childIterators);
+
+ if ( breakup == ch->dipoles().end() ) {
+ firstChain = &(*ch);
+ secondChain = &empty;
+ } else {
+
+ DipoleChain other;
+ other.dipoles().splice(other.dipoles().end(),ch->dipoles(),breakup,ch->dipoles().end());
+
+ chains().push_back(other);
+ firstChain = &(*ch);
+ secondChain = &(chains().back());
+
+ // explicitly fix iterators in case the splice implementation
+ // at hand does invalidate iterators (the SGI docu says, it doesn't,
+ // but it seems that this behaviour is not part of the standard)
+ childIterators.first = --firstChain->dipoles().end();
+ childIterators.second = secondChain->dipoles().begin();
+
+ }
+
+ if ( !colourSpectator )
+ update(dsplit); // otherwise done by recoil(...)
+
+}
+
+void DipoleEventRecord::recoil(list<Dipole>::iterator dip,
+ list<DipoleChain>::iterator ch,
+ DipoleSplittingInfo& dsplit) {
+
+ dip->recoil(dsplit);
+ ch->updateDipole(dip);
+
+ update(dsplit);
+
+}
+
+list<pair<list<Dipole>::iterator,list<DipoleChain>::iterator> >
+DipoleEventRecord::inDipoles() {
+
+ list<pair<list<Dipole>::iterator,list<DipoleChain>::iterator> > res;
+
+ for ( list<DipoleChain>::iterator chit = theDoneChains.begin();
+ chit != theDoneChains.end(); ++chit ) {
+
+ bool haveOne = false;
+
+ for ( list<Dipole>::iterator dit = chit->dipoles().begin();
+ dit != chit->dipoles().end(); ++dit ) {
+ if ( dit->leftPDF().pdf() || dit->rightPDF().pdf() ) {
+ haveOne = true;
+ break;
+ }
+ }
+
+ if ( haveOne ) {
+ theChains.splice(theChains.begin(),theDoneChains,chit);
+ for ( list<Dipole>::iterator dit = theChains.front().dipoles().begin();
+ dit != theChains.front().dipoles().end(); ++dit ) {
+ if ( dit->leftPDF().pdf() || dit->rightPDF().pdf() ) {
+ res.push_back(make_pair(dit,theChains.begin()));
+ }
+ }
+ }
+
+ }
+
+ return res;
+
+}
+
+void DipoleEventRecord::transform(const SpinOneLorentzRotation& rot) {
+
+
+ Lorentz5Momentum tmp;
+
+ for (PList::iterator p = theIntermediates.begin();
+ p != theIntermediates.end(); ++p) {
+ tmp = (**p).momentum(); tmp = rot * tmp;
+ (**p).set5Momentum(tmp);
+ }
+
+ for (PList::iterator h = theHard.begin();
+ h != theHard.end(); ++h) {
+ tmp = (**h).momentum(); tmp = rot * tmp;
+ (**h).set5Momentum(tmp);
+ }
+
+ for (PList::iterator p = theOutgoing.begin();
+ p != theOutgoing.end(); ++p) {
+ tmp = (**p).momentum(); tmp = rot * tmp;
+ (**p).set5Momentum(tmp);
+ }
+
+}
+
+tPPair DipoleEventRecord::fillEventRecord(StepPtr step, bool firstInteraction, bool) {
+
+ PPtr inSubPro = subProcess()->incoming().first;
+ PPtr inParticle;
+ if ( !(inSubPro->parents().empty()) )
+ inParticle = inSubPro->parents()[0];
+ else
+ inParticle = inSubPro;
+ PPtr inParton = theOriginals[inSubPro];
+ theOriginals.erase(inSubPro);
+ updateColour(incoming().first);
+ if ( inParticle != inSubPro )
+ inParticle->abandonChild(inSubPro);
+ inParton->addChild(inSubPro);
+ if ( inParticle != inSubPro )
+ inParticle->addChild(incoming().first);
+ theIntermediates.push_back(inSubPro);
+ theIntermediates.push_back(inParton);
+
+ inSubPro = subProcess()->incoming().second;
+ if ( !(inSubPro->parents().empty()) )
+ inParticle = inSubPro->parents()[0];
+ else
+ inParticle = inSubPro;
+ inParton = theOriginals[inSubPro];
+ theOriginals.erase(inSubPro);
+ updateColour(incoming().second);
+ if ( inParticle != inSubPro )
+ inParticle->abandonChild(inSubPro);
+ inParton->addChild(inSubPro);
+ if ( inParticle != inSubPro )
+ inParticle->addChild(incoming().second);
+ theIntermediates.push_back(inSubPro);
+ theIntermediates.push_back(inParton);
+
+ while ( !theOriginals.empty() ) {
+ PPtr outSubPro = theOriginals.begin()->first;
+ PPtr outParton = theOriginals.begin()->second;
+ theOriginals.erase(theOriginals.begin());
+ updateColour(outParton);
+ outSubPro->addChild(outParton);
+ theIntermediates.push_back(outSubPro);
+ }
+
+ step->addIntermediates(theIntermediates.begin(),theIntermediates.end());
+
+ for (PList::const_iterator p = theOutgoing.begin();
+ p != theOutgoing.end(); ++p)
+ step->addDecayProduct(*p);
+
+ for (PList::const_iterator p = theHard.begin();
+ p != theHard.end(); ++p)
+ step->addDecayProduct(*p);
+
+ if ( firstInteraction &&
+ (theIncoming.first->coloured() ||
+ theIncoming.second->coloured() ) ) {
+ ShowerHandler::currentHandler()->lastExtractor()->newRemnants(theSubProcess->incoming(),theIncoming,step);
+ }
+
+ step->addIntermediate(theIncoming.first);
+ step->addIntermediate(theIncoming.second);
+
+ return theIncoming;
+
+}
+
+void DipoleEventRecord::debugLastEvent(ostream& os) const {
+
+ bool first = ShowerHandler::currentHandler()->firstInteraction();
+
+ os << "--- DipoleEventRecord ----------------------------------------------------------\n";
+
+ os << " the " << (first ? "hard" : "secondary") << " subprocess is:\n"
+ << (*theSubProcess);
+
+ os << " using PDF's " << thePDFs.first.pdf() << " and "
+ << thePDFs.second.pdf() << "\n";
+
+ os << " chains showering currently:\n";
+
+ for ( list<DipoleChain>::const_iterator chit = theChains.begin();
+ chit != theChains.end(); ++chit )
+ os << (*chit);
+
+ os << " chains which finished showering:\n";
+
+ for ( list<DipoleChain>::const_iterator chit = theDoneChains.begin();
+ chit != theDoneChains.end(); ++chit )
+ os << (*chit);
+
+ os << "--------------------------------------------------------------------------------\n";
+
+ os << flush;
+
+}
diff --git a/DipoleShower/Base/DipoleEventRecord.h b/DipoleShower/Base/DipoleEventRecord.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Base/DipoleEventRecord.h
@@ -0,0 +1,375 @@
+// -*- C++ -*-
+//
+// DipoleEventRecord.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_DipoleEventRecord_H
+#define HERWIG_DipoleEventRecord_H
+//
+// This is the declaration of the DipoleEventRecord class.
+//
+
+#include "ThePEG/PDF/PDF.h"
+#include "ThePEG/Handlers/StandardXComb.h"
+#include "Dipole.h"
+#include "DipoleChain.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief The DipoleEventRecord class is
+ * used internally by the dipole shower.
+ */
+class DipoleEventRecord {
+
+public:
+
+ /**
+ * The default constructor.
+ */
+ DipoleEventRecord() {}
+
+ /**
+ * The default destructor just cleans up.
+ */
+ ~DipoleEventRecord() { clear(); }
+
+public:
+
+ /**
+ * Return the incoming partons at the current
+ * stage of the evolution.
+ */
+ PPair& incoming() { return theIncoming; }
+
+ /**
+ * Return the incoming partons at the current
+ * stage of the evolution.
+ */
+ const PPair& incoming() const { return theIncoming; }
+
+ /**
+ * Return the outgoing partons at the current
+ * stage of the evolution.
+ */
+ PList& outgoing() { return theOutgoing; }
+
+ /**
+ * Return the outgoing partons at the current
+ * stage of the evolution.
+ */
+ const PList& outgoing() const { return theOutgoing; }
+
+ /**
+ * Return the intermediate particles at the current
+ * stage of the evolution.
+ */
+ PList& intermediates() { return theIntermediates; }
+
+ /**
+ * Return the intermediate particles at the current
+ * stage of the evolution.
+ */
+ const PList& intermediates() const { return theIntermediates; }
+
+ /**
+ * Return any non-coloured outgoing particles in the
+ * current subprocess.
+ */
+ PList& hard() { return theHard; }
+
+ /**
+ * Return any non-coloured outgoing particles in the
+ * current subprocess.
+ */
+ const PList& hard() const { return theHard; }
+
+ /**
+ * Return the subprocess currently showered
+ */
+ tSubProPtr subProcess() const { return theSubProcess; }
+
+ /**
+ * Return the XComb describing the hard process.
+ */
+ tStdXCombPtr xcombPtr() const { return theXComb; }
+
+ /**
+ * Return the XComb describing the hard process.
+ */
+ const StandardXComb& xcomb() const { return *theXComb; }
+
+ /**
+ * Return the momentum fractions.
+ */
+ const pair<double,double>& fractions() const { return theFractions; }
+
+ /**
+ * Return the PDFs
+ */
+ const pair<PDF,PDF>& pdfs() const { return thePDFs; }
+
+ /**
+ * Return the momentum of the hard system
+ */
+ const Lorentz5Momentum& pX() const { return thePX; }
+
+ /**
+ * Transform all intermediate, hard and outgoing
+ * partciles using the given transformation.
+ */
+ void transform(const SpinOneLorentzRotation& rot);
+
+public:
+
+ /**
+ * Return the dipole chains to be showered.
+ */
+ const list<DipoleChain>& chains() const { return theChains; }
+
+ /**
+ * Access the dipole chains to be showered.
+ */
+ list<DipoleChain>& chains() { return theChains; }
+
+ /**
+ * Return the dipole chains which ceased evolving.
+ */
+ const list<DipoleChain>& doneChains() const { return theDoneChains; }
+
+ /**
+ * Access the dipole chains which ceased evolving.
+ */
+ list<DipoleChain>& doneChains() { return theDoneChains; }
+
+ /**
+ * Return true, if there are chains to be
+ * showered.
+ */
+ bool haveChain() const { return !theChains.empty(); }
+
+ /**
+ * Return the current dipole chain
+ */
+ DipoleChain& currentChain() { assert(haveChain()); return theChains.front(); }
+
+ /**
+ * Pop the current dipole chain
+ */
+ void popChain();
+
+ /**
+ * Remove the given chain.
+ */
+ void popChain(list<DipoleChain>::iterator);
+
+ /**
+ * Remove the given chains.
+ */
+ void popChains(const list<list<DipoleChain>::iterator>&);
+
+public:
+
+ /**
+ * Split the dipole pointed to by the given iterator.
+ * Return references to the affected chains, and update
+ * iterators pointing to the children in the returned
+ * chains.
+ */
+
+ void split(list<Dipole>::iterator dip,
+ DipoleSplittingInfo& dsplit,
+ pair<list<Dipole>::iterator,list<Dipole>::iterator>& childIterators,
+ DipoleChain*& firstChain, DipoleChain*& secondChain) {
+ split(dip,theChains.begin(),dsplit,childIterators,firstChain,secondChain,false);
+ }
+
+ /**
+ * Split the dipole pointed to by the given iterator
+ * in the indicated chain, indicating a splitting with
+ * a colour spectator.
+ * Return references to the affected chains, and update
+ * iterators pointing to the children in the returned
+ * chains.
+ */
+ void split(list<Dipole>::iterator dip,
+ list<DipoleChain>::iterator ch,
+ DipoleSplittingInfo& dsplit,
+ pair<list<Dipole>::iterator,list<Dipole>::iterator>& childIterators,
+ DipoleChain*& firstChain, DipoleChain*& secondChain,
+ bool colourSpectator = true);
+
+ /**
+ * Let the given dipole take the recoil of
+ * the indicated splitting.
+ */
+ void recoil(list<Dipole>::iterator dip,
+ list<DipoleChain>::iterator ch,
+ DipoleSplittingInfo& dsplit);
+
+ /**
+ * Update the particles upon insertion of the
+ * given splitting.
+ */
+ void update(DipoleSplittingInfo& dsplit);
+
+ /**
+ * Return the dipole(s) containing the incoming
+ * partons after the evolution has ended. Put back
+ * the chains containing these to the chains to be
+ * showered.
+ */
+ list<pair<list<Dipole>::iterator,list<DipoleChain>::iterator> >
+ inDipoles();
+
+ /**
+ * Fill the given step and return incoming partons.
+ */
+ tPPair fillEventRecord(StepPtr step, bool firstInteraction, bool realigned);
+
+public:
+
+ /**
+ * Prepare the event record for the given
+ * subprocess.
+ */
+ const map<PPtr,PPtr>& prepare(tSubProPtr subpro,
+ tStdXCombPtr xc,
+ const pair<PDF,PDF>& pdf,
+ bool dipoles = true);
+
+ /**
+ * Clear the event record: Give up ownership
+ * on any object involved in the evolution.
+ */
+ void clear();
+
+public:
+
+ /**
+ * Print event record at current state.
+ */
+ void debugLastEvent(ostream&) const;
+
+protected:
+
+ /**
+ * Sort the coloured partons into a colour ordered ensemble.
+ */
+ PList colourOrdered();
+
+ /**
+ * Find the chains to be showered.
+ */
+ void findChains(const PList& ordered);
+
+ /**
+ * Add all particles to the relevant sets
+ */
+ void getAll(const ParticleVector& childs,
+ set<PPtr>& hardSet,
+ set<PPtr>& outgoingSet);
+
+ /**
+ * Isolate the colour of the process from the rest of the event.
+ * Called in the constructor
+ */
+ void colourIsolate(const vector<PPtr> & original, const vector<PPtr> & copy);
+
+ /**
+ * Update the colour information of a particle prior to insertion into the
+ * event record.
+ */
+ void updateColour(PPtr particle);
+
+private:
+
+ struct getMomentum {
+ const Lorentz5Momentum& operator() (PPtr particle) const {
+ return particle->momentum();
+ }
+ };
+
+ /**
+ * The subprocess currently showered.
+ */
+ SubProPtr theSubProcess;
+
+ /**
+ * Pointer to the XComb which generated the hard process.
+ */
+ StdXCombPtr theXComb;
+
+ /**
+ * The PDFs to be considered.
+ */
+ pair<PDF,PDF> thePDFs;
+
+ /**
+ * The momentum of the hard system
+ */
+ Lorentz5Momentum thePX;
+
+ /**
+ * Momentum fractions of the incoming partons.
+ */
+ pair<double,double> theFractions;
+
+ /**
+ * The incoming partons at the current
+ * stage of the evolution.
+ */
+ PPair theIncoming;
+
+ /**
+ * The outgoing partons at the current
+ * stage of the evolution.
+ */
+ PList theOutgoing;
+
+ /**
+ * The intermediate particles at the current
+ * stage of the evolution.
+ */
+ PList theIntermediates;
+
+ /**
+ * Any non-coloured outgoing particles in the
+ * current subprocess.
+ */
+ PList theHard;
+
+ /**
+ * Map originals to copies.
+ */
+ map<PPtr,PPtr> theOriginals;
+
+ /**
+ * Map colour lines from copies to originals.
+ */
+ map<ColinePtr,ColinePtr> theColourLines;
+
+ /**
+ * The dipole chains currently showered.
+ */
+ list<DipoleChain> theChains;
+
+ /**
+ * The dipole chains which ceased evolving.
+ */
+ list<DipoleChain> theDoneChains;
+
+};
+
+
+}
+
+#endif /* HERWIG_DipoleEventRecord_H */
diff --git a/DipoleShower/Base/DipoleEvolutionOrdering.cc b/DipoleShower/Base/DipoleEvolutionOrdering.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Base/DipoleEvolutionOrdering.cc
@@ -0,0 +1,48 @@
+// -*- C++ -*-
+//
+// DipoleEvolutionOrdering.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the DipoleEvolutionOrdering class.
+//
+
+#include "DipoleEvolutionOrdering.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+DipoleEvolutionOrdering::DipoleEvolutionOrdering()
+ : HandlerBase() {}
+
+DipoleEvolutionOrdering::~DipoleEvolutionOrdering() {}
+
+// If needed, insert default implementations of virtual function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void DipoleEvolutionOrdering::persistentOutput(PersistentOStream &) const {
+}
+
+void DipoleEvolutionOrdering::persistentInput(PersistentIStream &, int) {
+}
+
+AbstractClassDescription<DipoleEvolutionOrdering> DipoleEvolutionOrdering::initDipoleEvolutionOrdering;
+// Definition of the static class description member.
+
+void DipoleEvolutionOrdering::Init() {
+
+ static ClassDocumentation<DipoleEvolutionOrdering> documentation
+ ("DipoleEvolutionOrdering defines a particular evolution "
+ "algortihm for the dipole shower.");
+
+}
+
diff --git a/DipoleShower/Base/DipoleEvolutionOrdering.h b/DipoleShower/Base/DipoleEvolutionOrdering.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Base/DipoleEvolutionOrdering.h
@@ -0,0 +1,184 @@
+// -*- C++ -*-
+//
+// DipoleEvolutionOrdering.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_DipoleEvolutionOrdering_H
+#define HERWIG_DipoleEvolutionOrdering_H
+//
+// This is the declaration of the DipoleEvolutionOrdering class.
+//
+
+#include "ThePEG/Handlers/HandlerBase.h"
+
+#include "Herwig++/DipoleShower/Base/Dipole.h"
+#include "Herwig++/DipoleShower/Base/DipoleChain.h"
+#include "Herwig++/DipoleShower/Kernels/DipoleSplittingKernel.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief DipoleEvolutionOrdering defines a particular evolution
+ * algortihm for the dipole shower.
+ *
+ */
+class DipoleEvolutionOrdering: public HandlerBase {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ DipoleEvolutionOrdering();
+
+ /**
+ * The destructor.
+ */
+ virtual ~DipoleEvolutionOrdering();
+ //@}
+
+public:
+
+ /**
+ * Return true, if this ordering requests
+ * an independent dipole evolution.
+ */
+ virtual bool independentDipoles() const { return false; }
+
+ /**
+ * For the given dipole and splitting kernel return
+ * the hard scale.
+ */
+ virtual Energy hardScale(tPPtr emitter, tPPtr spectator,
+ double emitterX, double spectatorX,
+ const DipoleSplittingKernel&,
+ const DipoleIndex&) const = 0;
+
+ /**
+ * For the given performed splitting, dipole chain
+ * and dipoles originating from the splitting, set the next
+ * scale.
+ */
+ virtual void setEvolutionScale(Energy scale,
+ const DipoleSplittingInfo&,
+ DipoleChain&,
+ pair<list<Dipole>::iterator,list<Dipole>::iterator>) const = 0;
+
+ /**
+ * For the given performed splitting, dipole chain
+ * and dipole taking a recoil, set the next
+ * scale.
+ */
+ virtual void setEvolutionScale(Energy scale,
+ const DipoleSplittingInfo&,
+ DipoleChain&,
+ list<Dipole>::iterator) const = 0;
+
+ /**
+ * For the given selected splitting return the evolution scale.
+ */
+ virtual Energy evolutionScale(const DipoleSplittingInfo&,
+ const DipoleSplittingKernel&) const = 0;
+
+ /**
+ * Return the maximum pt corresponding to the given
+ * evolution scale.
+ */
+ virtual Energy maxPt(Energy scale,
+ const DipoleSplittingInfo&,
+ const DipoleSplittingKernel&) const = 0;
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is an abstract class with persistent data.
+ */
+ static AbstractClassDescription<DipoleEvolutionOrdering> initDipoleEvolutionOrdering;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ DipoleEvolutionOrdering & operator=(const DipoleEvolutionOrdering &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of DipoleEvolutionOrdering. */
+template <>
+struct BaseClassTrait<Herwig::DipoleEvolutionOrdering,1> {
+ /** Typedef of the first base class of DipoleEvolutionOrdering. */
+ typedef HandlerBase NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the DipoleEvolutionOrdering class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::DipoleEvolutionOrdering>
+ : public ClassTraitsBase<Herwig::DipoleEvolutionOrdering> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::DipoleEvolutionOrdering"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * DipoleEvolutionOrdering is implemented. It may also include several, space-separated,
+ * libraries if the class DipoleEvolutionOrdering depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_DipoleEvolutionOrdering_H */
diff --git a/DipoleShower/Base/DipoleSplittingGenerator.cc b/DipoleShower/Base/DipoleSplittingGenerator.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Base/DipoleSplittingGenerator.cc
@@ -0,0 +1,555 @@
+// -*- C++ -*-
+//
+// DipoleSplittingGenerator.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the DipoleSplittingGenerator class.
+//
+
+#include "DipoleSplittingGenerator.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/Interface/Reference.h"
+#include "ThePEG/Repository/EventGenerator.h"
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+#include "Herwig++/DipoleShower/DipoleShowerHandler.h"
+
+using namespace Herwig;
+
+DipoleSplittingGenerator::DipoleSplittingGenerator()
+ : HandlerBase(),
+ theExponentialGenerator(0), prepared(false), presampling(false) {
+ if ( ShowerHandler::currentHandler() )
+ setGenerator(ShowerHandler::currentHandler()->generator());
+}
+
+DipoleSplittingGenerator::~DipoleSplittingGenerator() {
+ if ( theExponentialGenerator ) {
+ delete theExponentialGenerator;
+ theExponentialGenerator = 0;
+ }
+}
+
+IBPtr DipoleSplittingGenerator::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr DipoleSplittingGenerator::fullclone() const {
+ return new_ptr(*this);
+}
+
+void DipoleSplittingGenerator::wrap(Ptr<DipoleSplittingGenerator>::ptr other) {
+ assert(!prepared);
+ theOtherGenerator = other;
+}
+
+void DipoleSplittingGenerator::prepare(const DipoleSplittingInfo& sp) {
+
+ generatedSplitting = sp;
+
+ generatedSplitting.splittingKinematics(splittingKernel()->splittingKinematics());
+ generatedSplitting.splittingParameters().resize(splittingKernel()->nDimAdditional());
+
+ if ( wrapping() ) {
+ generatedSplitting.emitterData(theSplittingKernel->emitter(generatedSplitting.index()));
+ generatedSplitting.spectatorData(theSplittingKernel->spectator(generatedSplitting.index()));
+ generatedSplitting.emissionData(theSplittingKernel->emission(generatedSplitting.index()));
+ parameters.resize(theOtherGenerator->nDim());
+ prepared = true;
+ return;
+ }
+
+ generatedSplitting.emitterData(splittingKernel()->emitter(generatedSplitting.index()));
+ generatedSplitting.spectatorData(splittingKernel()->spectator(generatedSplitting.index()));
+ generatedSplitting.emissionData(splittingKernel()->emission(generatedSplitting.index()));
+
+ presampledSplitting = generatedSplitting;
+
+ prepared = true;
+
+ parameters.resize(nDim());
+
+ theExponentialGenerator =
+ new exsample::exponential_generator<DipoleSplittingGenerator,UseRandom>();
+
+ theExponentialGenerator->sampling_parameters().maxtry = maxtry();
+ theExponentialGenerator->sampling_parameters().presampling_points = presamplingPoints();
+
+ theExponentialGenerator->function(this);
+ theExponentialGenerator->initialize();
+
+}
+
+void DipoleSplittingGenerator::fixParameters(const DipoleSplittingInfo& sp) {
+
+ assert(generator());
+
+ assert(!presampling);
+ assert(prepared);
+
+ assert(sp.index() == generatedSplitting.index());
+
+ generatedSplitting.scale(sp.scale());
+ parameters[3] = sp.scale()/generator()->maximumCMEnergy();
+
+ Energy maxPossible =
+ generatedSplitting.splittingKinematics()->ptMax(sp.scale(),
+ sp.emitterX(), sp.spectatorX(),
+ generatedSplitting.index(),
+ *splittingKernel());
+
+ if ( maxPossible >= sp.hardPt() )
+ generatedSplitting.hardPt(sp.hardPt());
+ else
+ generatedSplitting.hardPt(maxPossible);
+
+ parameters[0] = splittingKinematics()->ptToRandom(generatedSplitting.hardPt(),
+ sp.scale(),generatedSplitting.index());
+
+ size_t shift = 4;
+
+ if ( generatedSplitting.index().emitterPDF().pdf() &&
+ generatedSplitting.index().spectatorPDF().pdf() ) {
+ generatedSplitting.emitterX(sp.emitterX());
+ generatedSplitting.spectatorX(sp.spectatorX());
+ parameters[4] = sp.emitterX();
+ parameters[5] = sp.spectatorX();
+ shift += 2;
+ }
+
+ if ( generatedSplitting.index().emitterPDF().pdf() &&
+ !generatedSplitting.index().spectatorPDF().pdf() ) {
+ generatedSplitting.emitterX(sp.emitterX());
+ parameters[4] = sp.emitterX();
+ ++shift;
+ }
+
+ if ( !generatedSplitting.index().emitterPDF().pdf() &&
+ generatedSplitting.index().spectatorPDF().pdf() ) {
+ generatedSplitting.spectatorX(sp.spectatorX());
+ parameters[4] = sp.spectatorX();
+ ++shift;
+ }
+
+ if ( splittingReweight() ) {
+ parameters[shift] = splittingReweight()->evaluate(sp);
+ ++shift;
+ }
+
+ if ( splittingKernel()->nDimAdditional() )
+ copy(sp.lastSplittingParameters().begin(),sp.lastSplittingParameters().end(),parameters.begin()+shift);
+
+ if ( sp.emitter() )
+ generatedSplitting.emitter(sp.emitter());
+
+ if ( sp.spectator() )
+ generatedSplitting.spectator(sp.spectator());
+
+}
+
+int DipoleSplittingGenerator::nDim() const {
+
+ assert(!wrapping());
+ assert(prepared);
+
+ int ret = 4; // 0 pt, 1 z, 2 phi, 3 scale, 4/5 xs + parameters
+
+ if ( generatedSplitting.index().emitterPDF().pdf() ) {
+ ++ret;
+ }
+
+ if ( generatedSplitting.index().spectatorPDF().pdf() ) {
+ ++ret;
+ }
+
+ if ( splittingReweight() )
+ ++ret;
+
+ ret += splittingKernel()->nDimAdditional();
+
+ return ret;
+
+}
+
+const vector<bool>& DipoleSplittingGenerator::sampleFlags() {
+
+ assert(!wrapping());
+
+ if ( !theFlags.empty() )
+ return theFlags;
+
+ theFlags.resize(nDim(),false);
+ theFlags[0] = true; theFlags[1] = true; theFlags[2] = true; // 0 pt, 1 z, 2 phi
+ return theFlags;
+}
+
+const pair<vector<double>,vector<double> >& DipoleSplittingGenerator::support() {
+
+ assert(!wrapping());
+
+ if ( !theSupport.first.empty() )
+ return theSupport;
+
+ vector<double> lower(nDim(),0.);
+ vector<double> upper(nDim(),1.);
+
+ pair<double,double> kSupport =
+ generatedSplitting.splittingKinematics()->kappaSupport(generatedSplitting);
+
+ pair<double,double> xSupport =
+ generatedSplitting.splittingKinematics()->xiSupport(generatedSplitting);
+
+ lower[0] = kSupport.first;
+ lower[1] = xSupport.first;
+
+ upper[0] = kSupport.second;
+ upper[1] = xSupport.second;
+
+ if ( splittingReweight() ) {
+ pair<double,double> bounds = splittingReweight()->reweightBounds(generatedSplitting.index());
+ int pos = 4;
+ if ( generatedSplitting.index().emitterPDF().pdf() ) {
+ ++pos;
+ }
+ if ( generatedSplitting.index().spectatorPDF().pdf() ) {
+ ++pos;
+ }
+ lower[pos] = bounds.first;
+ upper[pos] = bounds.second;
+ }
+
+ theSupport.first = lower;
+ theSupport.second = upper;
+
+ return theSupport;
+
+}
+
+void DipoleSplittingGenerator::startPresampling() {
+ assert(!wrapping());
+ splittingKernel()->startPresampling(generatedSplitting.index());
+ presampling = true;
+}
+
+void DipoleSplittingGenerator::stopPresampling() {
+ assert(!wrapping());
+ splittingKernel()->stopPresampling(generatedSplitting.index());
+ presampling = false;
+}
+
+bool DipoleSplittingGenerator::haveOverestimate() const {
+
+ assert(!wrapping());
+ assert(prepared);
+
+ return
+ generatedSplitting.splittingKinematics()->haveOverestimate() &&
+ splittingKernel()->haveOverestimate(generatedSplitting);
+
+}
+
+bool DipoleSplittingGenerator::overestimate(const vector<double>& point) {
+
+ assert(!wrapping());
+ assert(prepared);
+ assert(!presampling);
+ assert(haveOverestimate());
+
+ if ( ! generatedSplitting.splittingKinematics()->generateSplitting(point[0],point[1],point[2],
+ generatedSplitting) )
+ return 0.;
+
+ generatedSplitting.splittingKinematics()->prepareSplitting(generatedSplitting);
+
+ return
+ ( generatedSplitting.splittingKinematics()->jacobianOverestimate() *
+ splittingKernel()->overestimate(generatedSplitting) *
+ (splittingReweight() ? splittingReweight()->evaluate(generatedSplitting) : 1.) );
+
+}
+
+double DipoleSplittingGenerator::invertOverestimateIntegral(double value) const {
+
+ assert(!wrapping());
+ assert(prepared);
+ assert(!presampling);
+ assert(haveOverestimate());
+
+ return
+ splittingKernel()->invertOverestimateIntegral(generatedSplitting,value);
+
+}
+
+double DipoleSplittingGenerator::evaluate(const vector<double>& point) {
+
+ assert(!wrapping());
+ assert(prepared);
+ assert(generator());
+
+ DipoleSplittingInfo& split =
+ ( !presampling ? generatedSplitting : presampledSplitting );
+
+ split.continuesEvolving();
+
+ size_t shift = 4;
+
+ if ( presampling ) {
+
+ split.scale(point[3] * generator()->maximumCMEnergy());
+
+ if ( split.index().emitterPDF().pdf() &&
+ split.index().spectatorPDF().pdf() ) {
+ split.emitterX(point[4]);
+ split.spectatorX(point[5]);
+ shift += 2;
+ }
+
+ if ( split.index().emitterPDF().pdf() &&
+ !split.index().spectatorPDF().pdf() ) {
+ split.emitterX(point[4]);
+ ++shift;
+ }
+
+ if ( !split.index().emitterPDF().pdf() &&
+ split.index().spectatorPDF().pdf() ) {
+ split.spectatorX(point[4]);
+ ++shift;
+ }
+
+ if ( splittingReweight() )
+ ++shift;
+
+ if ( splittingKernel()->nDimAdditional() )
+ copy(point.begin()+shift,point.end(),split.splittingParameters().begin());
+
+ split.hardPt(split.splittingKinematics()->ptMax(split.scale(),
+ split.emitterX(),
+ split.spectatorX(),
+ split.index(),
+ *splittingKernel()));
+
+ }
+
+ if ( ! split.splittingKinematics()->generateSplitting(point[0],point[1],point[2],split) ) {
+ split.lastValue(0.);
+ return 0.;
+ }
+
+ split.splittingKinematics()->prepareSplitting(split);
+
+ if ( split.stoppedEvolving() ) {
+ split.lastValue(0.);
+ return 0.;
+ }
+
+ double kernel = splittingKernel()->evaluate(split);
+ if ( splittingReweight() ) {
+ if ( !presampling )
+ kernel *= splittingReweight()->evaluate(split);
+ else
+ kernel *= point[shift-1];
+ }
+ double jac = split.splittingKinematics()->jacobian();
+
+ split.lastValue( abs(jac) * kernel );
+
+ if ( kernel < 0. )
+ return 0.;
+
+ return split.lastValue();
+
+}
+
+void DipoleSplittingGenerator::doGenerate() {
+
+ assert(!wrapping());
+
+ double res = 0.;
+
+ Energy startPt = generatedSplitting.hardPt();
+
+ while (true) {
+ try {
+ res = theExponentialGenerator->generate();
+ } catch (exsample::exponential_regenerate&) {
+ generatedSplitting.hardPt(startPt);
+ continue;
+ } catch (exsample::hit_and_miss_maxtry&) {
+ throw DipoleShowerHandler::RedoShower();
+ } catch (exsample::selection_maxtry&) {
+ throw DipoleShowerHandler::RedoShower();
+ }
+ break;
+ }
+
+ if ( res == 0. ) {
+ generatedSplitting.lastPt(0.0*GeV);
+ generatedSplitting.hardPt(0.0*GeV);
+ generatedSplitting.didStopEvolving();
+ } else {
+
+ generatedSplitting.hardPt(generatedSplitting.lastPt());
+ generatedSplitting.continuesEvolving();
+
+ if ( theMCCheck )
+ theMCCheck->book(generatedSplitting.emitterX(),
+ generatedSplitting.spectatorX(),
+ generatedSplitting.scale(),
+ startPt,
+ generatedSplitting.lastPt(),
+ generatedSplitting.lastZ(),
+ 1.);
+
+ }
+
+}
+
+Energy DipoleSplittingGenerator::generate(const DipoleSplittingInfo& split) {
+
+ fixParameters(split);
+
+ if ( wrapping() ) {
+ return theOtherGenerator->generateWrapped(generatedSplitting);
+ }
+
+ doGenerate();
+
+ return generatedSplitting.lastPt();
+
+}
+
+Energy DipoleSplittingGenerator::generateWrapped(DipoleSplittingInfo& split) {
+
+ assert(!wrapping());
+
+ DipoleSplittingInfo backup = generatedSplitting;
+ generatedSplitting = split;
+
+ fixParameters(split);
+
+ try {
+ doGenerate();
+ } catch (...) {
+ split = generatedSplitting;
+ generatedSplitting = backup;
+ throw;
+ }
+
+ Energy pt = generatedSplitting.lastPt();
+
+ split = generatedSplitting;
+ generatedSplitting = backup;
+
+ return pt;
+
+}
+
+void DipoleSplittingGenerator::completeSplitting(DipoleSplittingInfo& sp) const {
+ pair<bool,bool> conf = sp.configuration();
+ sp = generatedSplitting;
+ sp.configuration(conf);
+}
+
+Ptr<DipoleSplittingKernel>::tptr DipoleSplittingGenerator::splittingKernel() const {
+ if ( wrapping() )
+ return theOtherGenerator->splittingKernel();
+ return theSplittingKernel;
+}
+
+Ptr<DipoleSplittingReweight>::tptr DipoleSplittingGenerator::splittingReweight() const {
+ if ( wrapping() )
+ return theOtherGenerator->splittingReweight();
+ return theSplittingReweight;
+}
+
+Ptr<DipoleSplittingKinematics>::tptr DipoleSplittingGenerator::splittingKinematics() const {
+ if ( wrapping() )
+ return theOtherGenerator->splittingKinematics();
+ return theSplittingKernel->splittingKinematics();
+}
+
+void DipoleSplittingGenerator::splittingKernel(Ptr<DipoleSplittingKernel>::tptr sp) {
+ theSplittingKernel = sp;
+ if ( theSplittingKernel->mcCheck() )
+ theMCCheck = theSplittingKernel->mcCheck();
+}
+
+void DipoleSplittingGenerator::splittingReweight(Ptr<DipoleSplittingReweight>::tptr sp) {
+ theSplittingReweight = sp;
+}
+
+void DipoleSplittingGenerator::debugGenerator(ostream& os) const {
+
+ os << "--- DipoleSplittingGenerator ---------------------------------------------------\n";
+
+ os << " generating splittings using\n"
+ << " splittingKernel = " << splittingKernel()->name()
+ << " splittingKinematics = " << generatedSplitting.splittingKinematics()->name() << "\n"
+ << " to sample splittings of type:\n";
+
+ os << generatedSplitting;
+
+ os << "--------------------------------------------------------------------------------\n";
+
+}
+
+void DipoleSplittingGenerator::debugLastEvent(ostream& os) const {
+
+ os << "--- DipoleSplittingGenerator ---------------------------------------------------\n";
+
+ os << " last generated event:\n";
+
+ os << generatedSplitting;
+
+ os << "--------------------------------------------------------------------------------\n";
+
+}
+
+// If needed, insert default implementations of virtual function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void DipoleSplittingGenerator::persistentOutput(PersistentOStream & os) const {
+ os << theOtherGenerator << theSplittingKernel << theSplittingReweight << theMCCheck;
+}
+
+void DipoleSplittingGenerator::persistentInput(PersistentIStream & is, int) {
+ is >> theOtherGenerator >> theSplittingKernel >> theSplittingReweight >> theMCCheck;
+}
+
+ClassDescription<DipoleSplittingGenerator> DipoleSplittingGenerator::initDipoleSplittingGenerator;
+// Definition of the static class description member.
+
+void DipoleSplittingGenerator::Init() {
+
+ static ClassDocumentation<DipoleSplittingGenerator> documentation
+ ("DipoleSplittingGenerator is used by the dipole shower "
+ "to sample splittings from a given dipole splitting kernel.");
+
+
+ static Reference<DipoleSplittingGenerator,DipoleSplittingKernel> interfaceSplittingKernel
+ ("SplittingKernel",
+ "Set the splitting kernel to sample from.",
+ &DipoleSplittingGenerator::theSplittingKernel, false, false, true, false, false);
+
+ static Reference<DipoleSplittingGenerator,DipoleSplittingReweight> interfaceSplittingReweight
+ ("SplittingReweight",
+ "Set the splitting reweight.",
+ &DipoleSplittingGenerator::theSplittingReweight, false, false, true, true, false);
+
+ static Reference<DipoleSplittingGenerator,DipoleMCCheck> interfaceMCCheck
+ ("MCCheck",
+ "[debug option] MCCheck",
+ &DipoleSplittingGenerator::theMCCheck, false, false, true, true, false);
+
+ interfaceMCCheck.rank(-1);
+
+}
+
diff --git a/DipoleShower/Base/DipoleSplittingGenerator.h b/DipoleShower/Base/DipoleSplittingGenerator.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Base/DipoleSplittingGenerator.h
@@ -0,0 +1,428 @@
+// -*- C++ -*-
+//
+// DipoleSplittingGenerator.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_DipoleSplittingGenerator_H
+#define HERWIG_DipoleSplittingGenerator_H
+//
+// This is the declaration of the DipoleSplittingGenerator class.
+//
+
+#include "ThePEG/Handlers/HandlerBase.h"
+
+#include "Herwig++/DipoleShower/Kernels/DipoleSplittingKernel.h"
+#include "DipoleSplittingReweight.h"
+#include "Herwig++/DipoleShower/Utility/DipoleMCCheck.h"
+#include "Herwig++/Exsample2/exsample/exponential_generator.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief DipoleSplittingGenerator is used by the dipole shower
+ * to sample splittings from a given dipole splitting kernel.
+ *
+ * @see \ref DipoleSplittingGeneratorInterfaces "The interfaces"
+ * defined for DipoleSplittingGenerator.
+ */
+class DipoleSplittingGenerator: public HandlerBase {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ DipoleSplittingGenerator();
+
+ /**
+ * The destructor.
+ */
+ virtual ~DipoleSplittingGenerator();
+ //@}
+
+public:
+
+ /**
+ * Return the dipole splitting kernel.
+ */
+ Ptr<DipoleSplittingKernel>::tptr splittingKernel() const;
+
+ /**
+ * Return the dipole splitting reweight.
+ */
+ Ptr<DipoleSplittingReweight>::tptr splittingReweight() const;
+
+ /**
+ * Return the dipole splitting kinematics.
+ */
+ Ptr<DipoleSplittingKinematics>::tptr splittingKinematics() const;
+
+ /**
+ * Set the dipole splitting kernel.
+ */
+ void splittingKernel(Ptr<DipoleSplittingKernel>::tptr sp);
+
+ /**
+ * Set the dipole splitting reweight.
+ */
+ void splittingReweight(Ptr<DipoleSplittingReweight>::tptr sp);
+
+ /**
+ * Make a wrapper around another generator.
+ */
+ void wrap(Ptr<DipoleSplittingGenerator>::ptr other);
+
+ /**
+ * Return true, if this is actually a wrapper around
+ * another splitting generator.
+ */
+ bool wrapping() const { return theOtherGenerator; }
+
+public:
+
+ /**
+ * Prepare to fill the given splitting.
+ */
+ void prepare(const DipoleSplittingInfo&);
+
+ /**
+ * Fix parameters from the fiven DipoleSplittingInfo
+ * and generate the next splitting. Return the
+ * pt selected for the next splitting.
+ */
+ Energy generate(const DipoleSplittingInfo&);
+
+ /**
+ * Fix parameters from the fiven DipoleSplittingInfo
+ * and generate the next splitting. Return the
+ * pt selected for the next splitting when called
+ * from a wrapping generator.
+ */
+ Energy generateWrapped(DipoleSplittingInfo&);
+
+ /**
+ * Complete the given splitting.
+ */
+ void completeSplitting(DipoleSplittingInfo&) const;
+
+ /**
+ * Return the last generated splitting
+ */
+ const DipoleSplittingInfo& lastSplitting() const { return generatedSplitting; }
+
+public:
+
+ /**
+ * Print debug information on the splitting
+ * handled.
+ */
+ void debugGenerator(ostream&) const;
+
+ /**
+ * Print debug information on the last
+ * generated event.
+ */
+ void debugLastEvent(ostream&) const;
+
+protected:
+
+ /**
+ * Update parameters given a splitting.
+ */
+ void fixParameters(const DipoleSplittingInfo&);
+
+ /**
+ * With the parameters previuosly supplied
+ * through fixParameters generate the next
+ * splitting.
+ */
+ void doGenerate();
+
+public:
+
+ /**
+ * Return the number of random numbers
+ * needed to sample this kernel.
+ */
+ int nDim() const;
+
+ /**
+ * Flag, which variables are free variables.
+ */
+ const vector<bool>& sampleFlags();
+
+ /**
+ * Return the support of the splitting kernel.
+ * The lower bound on the first variable is
+ * assumed to correspond to the cutoff on the
+ * evolution variable.
+ */
+ const pair<vector<double>,vector<double> >& support();
+
+ /**
+ * Return the parameter point associated to the splitting
+ * previously supplied through fixParameters.
+ */
+ const vector<double>& parameterPoint() const { return parameters; }
+
+ /**
+ * Indicate that presampling of this kernel
+ * will be performed in the next calls to
+ * evaluate until stopPresampling() is called.
+ */
+ void startPresampling();
+
+ /**
+ * Indicate that presampling of this kernel
+ * is done until startPresampling() is called.
+ */
+ void stopPresampling();
+
+ /**
+ * Return the number of points to presample this
+ * splitting generator.
+ */
+ unsigned long presamplingPoints() const { return splittingKernel()->presamplingPoints(); }
+
+ /**
+ * Return the maximum number of trials
+ * to generate a splitting.
+ */
+ unsigned long maxtry() const { return splittingKernel()->maxtry(); }
+
+ /**
+ * Return true, if this splitting generator
+ * is able to deliver an overestimate to the sampled
+ * kernel.
+ */
+ bool haveOverestimate() const;
+
+ /**
+ * Return an overestimate to the sampled kernel.
+ */
+ bool overestimate(const vector<double>&);
+
+ /**
+ * Invert the integral over the overestimate to equal
+ * the given value.
+ */
+ double invertOverestimateIntegral(double) const;
+
+ /**
+ * Evalute the splitting kernel.
+ */
+ double evaluate(const vector<double>&);
+
+public:
+
+ /**@name Wrap to the exsample2 interface until this is finally cleaned up. */
+ //@{
+
+ inline const vector<bool>& variable_flags () {
+ return sampleFlags();
+ }
+
+ inline size_t evolution_variable () const { return 0; }
+
+ inline double evolution_cutoff () { return support().first[0]; }
+
+ inline const vector<double>& parameter_point () const {
+ return parameterPoint();
+ }
+
+ inline void start_presampling () {
+ startPresampling();
+ }
+
+ inline void stop_presampling () {
+ stopPresampling();
+ }
+
+ inline size_t dimension () const {
+ return nDim();
+ }
+
+ inline unsigned long presampling_points () const {
+ return presamplingPoints();
+ }
+
+ //@}
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+private:
+
+ /**
+ * Pointer to another generator to wrap around.
+ */
+ Ptr<DipoleSplittingGenerator>::ptr theOtherGenerator;
+
+ /**
+ * The dipole splitting kernel to sample
+ * splitting from.
+ */
+ Ptr<DipoleSplittingKernel>::ptr theSplittingKernel;
+
+ /**
+ * The dipole splitting reweight.
+ */
+ Ptr<DipoleSplittingReweight>::ptr theSplittingReweight;
+
+ /**
+ * Pointer to the exponential generator
+ */
+ exsample::exponential_generator<DipoleSplittingGenerator,UseRandom>*
+ theExponentialGenerator;
+
+ /**
+ * The dipole splitting to be completed.
+ */
+ DipoleSplittingInfo generatedSplitting;
+
+ /**
+ * A backup of the dipole splitting to be
+ * completed, if this generator is presampled.
+ */
+ DipoleSplittingInfo presampledSplitting;
+
+ /**
+ * True, if prepared to sample splittings
+ * of a given kind.
+ */
+ bool prepared;
+
+ /**
+ * Wether or not the kernel is currently
+ * being presampled.
+ */
+ bool presampling;
+
+ /**
+ * The parameter point.
+ */
+ vector<double> parameters;
+
+ /**
+ * The sampling flags
+ */
+ vector<bool> theFlags;
+
+ /**
+ * The support.
+ */
+ pair<vector<double>,vector<double> > theSupport;
+
+ /**
+ * Pointer to a check histogram object
+ */
+ Ptr<DipoleMCCheck>::ptr theMCCheck;
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<DipoleSplittingGenerator> initDipoleSplittingGenerator;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ DipoleSplittingGenerator & operator=(const DipoleSplittingGenerator &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of DipoleSplittingGenerator. */
+template <>
+struct BaseClassTrait<Herwig::DipoleSplittingGenerator,1> {
+ /** Typedef of the first base class of DipoleSplittingGenerator. */
+ typedef HandlerBase NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the DipoleSplittingGenerator class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::DipoleSplittingGenerator>
+ : public ClassTraitsBase<Herwig::DipoleSplittingGenerator> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::DipoleSplittingGenerator"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * DipoleSplittingGenerator is implemented. It may also include several, space-separated,
+ * libraries if the class DipoleSplittingGenerator depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_DipoleSplittingGenerator_H */
diff --git a/DipoleShower/Base/DipoleSplittingInfo.cc b/DipoleShower/Base/DipoleSplittingInfo.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Base/DipoleSplittingInfo.cc
@@ -0,0 +1,152 @@
+// -*- C++ -*-
+//
+// DipoleSplittingInfo.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the DipoleIndex and DipoleSplittingInfo classes.
+//
+
+#include "DipoleSplittingInfo.h"
+#include "ThePEG/Handlers/StandardXComb.h"
+
+#include <iterator>
+
+using std::ostream_iterator;
+
+using namespace Herwig;
+
+DipoleIndex::DipoleIndex()
+ : theInitialStateEmitter(false), theInitialStateSpectator(false) {}
+
+DipoleIndex::DipoleIndex(tcPDPtr newEmitter, tcPDPtr newSpectator,
+ const PDF& newEmitterPDF, const PDF& newSpectatorPDF)
+ : theEmitterData(newEmitter), theInitialStateEmitter(newEmitterPDF.pdf()),
+ theEmitterPDF(newEmitterPDF),
+ theSpectatorData(newSpectator), theInitialStateSpectator(newSpectatorPDF.pdf()),
+ theSpectatorPDF(newSpectatorPDF) {}
+
+
+bool DipoleIndex::operator ==(const DipoleIndex& x) const {
+ return
+ theEmitterData == x.theEmitterData &&
+ theInitialStateEmitter == x.theInitialStateEmitter &&
+ theEmitterPDF == x.theEmitterPDF &&
+ theSpectatorData == x.theSpectatorData &&
+ theInitialStateSpectator == x.theInitialStateSpectator &&
+ theSpectatorPDF == x.theSpectatorPDF;
+}
+
+bool DipoleIndex::operator <(const DipoleIndex& x) const {
+ if ( theEmitterData == x.theEmitterData ) {
+ if ( theInitialStateEmitter == x.theInitialStateEmitter ) {
+ if ( theEmitterPDF == x.theEmitterPDF ) {
+ if ( theSpectatorData == x.theSpectatorData ) {
+ if ( theInitialStateSpectator == x.theInitialStateSpectator ) {
+ return theSpectatorPDF < x.theSpectatorPDF;
+ }
+ return theInitialStateSpectator < x.theInitialStateSpectator;
+ }
+ return theSpectatorData < x.theSpectatorData;
+ }
+ return theEmitterPDF < x.theEmitterPDF;
+ }
+ return theInitialStateEmitter < x.theInitialStateEmitter;
+ }
+ return theEmitterData < x.theEmitterData;
+}
+
+void DipoleIndex::swap() {
+ std::swap(theEmitterData,theSpectatorData);
+ std::swap(theInitialStateEmitter,theInitialStateSpectator);
+ std::swap(theEmitterPDF,theSpectatorPDF);
+}
+
+pair<DipoleIndex,DipoleIndex> DipoleIndex::split(tcPDPtr emm) const {
+
+ DipoleIndex first(emitterData(),emm,emitterPDF(),PDF());
+ DipoleIndex second(emm,spectatorData(),PDF(),spectatorPDF());
+
+ return make_pair(first,second);
+
+}
+
+void DipoleIndex::print(ostream& os) const {
+ os << "[" << emitterData()->PDGName();
+ if ( emitterPDF().pdf() ) {
+ os << "<-" << emitterPDF().particle()->PDGName()
+ << "(" << emitterPDF().pdf() << ")";
+ }
+ os << "," << spectatorData()->PDGName();
+ if ( spectatorPDF().pdf() ) {
+ os << "<-" << spectatorPDF().particle()->PDGName()
+ << "(" << spectatorPDF().pdf() << ")";
+ }
+ os << "]";
+ os << flush;
+}
+
+DipoleSplittingInfo::DipoleSplittingInfo()
+ : theConfiguration(false,false),
+ theScale(0.0*GeV),
+ theEmitterX(1.0), theSpectatorX(1.0),
+ theHardPt(0.0*GeV), theLastPt(0.0*GeV),
+ theLastZ(0.0), theLastPhi(0.0), theLastEmitterZ(0.0),
+ theLastSpectatorZ(0.0), theLastValue(0.0),
+ theStoppedEvolving(false) {}
+
+void DipoleSplittingInfo::print(ostream& os) const {
+
+ os << "--- DipoleSplittingInfo --------------------------------------------------------\n";
+
+ os << " index = " << theIndex << "\n";
+ os << " configuration = (" << theConfiguration.first << "," << theConfiguration.second << ")\n"
+ << " momentum fractions = [" << theEmitterX << "," << theSpectatorX << "]\n"
+ << " generated starting from hard pt/GeV = " << theHardPt/GeV << "\n";
+
+ if ( theEmitterData && theEmissionData && theSpectatorData ) {
+
+ os << " splitting products = [(" << theEmitterData->PDGName()
+ << "," << theEmissionData->PDGName() << "),"
+ << theSpectatorData->PDGName() << "]\n";
+
+ } else {
+
+ os << " splitting products not available.\n";
+
+ }
+
+ if ( theSplittingKinematics ) {
+ os << " kinematic variables associated to '" << theSplittingKinematics->name() << "':\n"
+ << " scale = " << (theScale/GeV)
+ << " pt/GeV = " << (theLastPt/GeV) << " z = " << theLastZ << " phi = " << theLastPhi << "\n"
+ << " emitter z = " << theLastEmitterZ << " spectator z = " << theLastSpectatorZ << "\n"
+ << " splitting kernel value = " << theLastValue << "\n"
+ << " further parameters = ";
+ copy(theLastSplittingParameters.begin(),theLastSplittingParameters.end(),ostream_iterator<double>(os," "));
+ os << "\n the splitting " << (theStoppedEvolving ? "terminated " : "did not terminate ") << "the evolution\n";
+ } else {
+ os << " No kinematic variables have been generated yet.\n";
+ }
+
+ if ( theEmitter && theSpectator && theSplitEmitter && theSplitSpectator && theEmission ) {
+ os << " the splitting has been performed:\n"
+ << " emitter before emission:\n" << (*theEmitter)
+ << " spectator before emission:\n" << (*theSpectator)
+ << " emitter after emission:\n" << (*theSplitEmitter)
+ << " emission:\n" << (*theEmission)
+ << " spectator after emission:\n" << (*theSplitSpectator);
+ } else {
+ os << " the splitting has not yet been performed.\n";
+ }
+
+ os << "--------------------------------------------------------------------------------\n";
+
+ os << flush;
+
+}
+
diff --git a/DipoleShower/Base/DipoleSplittingInfo.h b/DipoleShower/Base/DipoleSplittingInfo.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Base/DipoleSplittingInfo.h
@@ -0,0 +1,590 @@
+// -*- C++ -*-
+//
+// DipoleSplittingInfo.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_DipoleSplittingInfo_H
+#define HERWIG_DipoleSplittingInfo_H
+//
+// This is the declaration of the DipoleIndex and DipoleSplittingInfo classes.
+//
+
+#include "ThePEG/PDF/PDF.h"
+#include "ThePEG/PDT/ParticleData.h"
+#include "ThePEG/Handlers/StandardXComb.fh"
+
+#include "Herwig++/DipoleShower/Kinematics/DipoleSplittingKinematics.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+class DipoleSplittingKinematics;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief DipoleIndex is used to index splitting generators
+ * for a particular dipole.
+ *
+ */
+class DipoleIndex {
+
+public:
+
+ /**
+ * The default constructor.
+ */
+ DipoleIndex();
+
+ /**
+ * The standard constructor
+ */
+ DipoleIndex(tcPDPtr newEmitter, tcPDPtr newSpectator,
+ const PDF& newEmitterPDF = PDF(), const PDF& newSpectatorPDF = PDF());
+
+public:
+
+ /**
+ * Compare for equality.
+ */
+ bool operator ==(const DipoleIndex& x) const;
+
+ /**
+ * Compare for ordering.
+ */
+ bool operator <(const DipoleIndex& x) const;
+
+ /**
+ * Swap emitter and spectator.
+ */
+ void swap();
+
+ /**
+ * Produce a pair of dipole indices given
+ * a particle data object for the emission.
+ * The ME correction is ignored in the children.
+ * The emission is inserted between the emitter
+ * and spectator, being a spectator in the first
+ * dipole index containing the original emitter,
+ * and an emitter in the second dipole, containing
+ * the original spectator.
+ */
+ pair<DipoleIndex,DipoleIndex> split(tcPDPtr) const;
+
+public:
+
+ /**
+ * Return the emitter particle data object.
+ */
+ tcPDPtr emitterData() const { return theEmitterData; }
+
+ /**
+ * Return true, if the emitter is an incoming parton
+ */
+ bool initialStateEmitter() const { return theInitialStateEmitter; }
+
+ /**
+ * Return the PDF object associated with the emitter
+ */
+ const PDF& emitterPDF() const { return theEmitterPDF; }
+
+ /**
+ * Return the spectator particle data object.
+ */
+ tcPDPtr spectatorData() const { return theSpectatorData; }
+
+ /**
+ * Return true, if the spectator is an incoming parton
+ */
+ bool initialStateSpectator() const { return theInitialStateSpectator; }
+
+ /**
+ * Return the PDF object associated with the spectator
+ */
+ const PDF& spectatorPDF() const { return theSpectatorPDF; }
+
+public:
+
+ /**
+ * Put information to ostream
+ */
+ void print(ostream&) const;
+
+private:
+
+ /**
+ * The particle data object of the emitter.
+ */
+ tcPDPtr theEmitterData;
+
+ /**
+ * Wether or not the emitter is an incoming parton.
+ */
+ bool theInitialStateEmitter;
+
+ /**
+ * The PDF object for the emitter.
+ */
+ PDF theEmitterPDF;
+
+ /**
+ * The particle data object of the spectator.
+ */
+ tcPDPtr theSpectatorData;
+
+ /**
+ * Wether or not the spectator is an incoming parton.
+ */
+ bool theInitialStateSpectator;
+
+ /**
+ * The PDF object for the spectator.
+ */
+ PDF theSpectatorPDF;
+
+};
+
+inline ostream& operator << (ostream& os, const DipoleIndex& di) {
+ di.print(os);
+ return os;
+}
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief DipoleSplittingInfo contains all parameters to generate a full
+ * dipole splitting.
+ *
+ */
+class DipoleSplittingInfo {
+
+public:
+
+ /**
+ * The default constructor.
+ */
+ DipoleSplittingInfo();
+
+public:
+
+ /**
+ * Return the dipole index
+ */
+ const DipoleIndex& index() const { return theIndex; }
+
+ /**
+ * Return which of the particles
+ * in the dipole should be considered emitter (true)
+ * and spectator (false)
+ */
+ const pair<bool,bool>& configuration() const { return theConfiguration; }
+
+ /**
+ * Return the particle data object of the emitter
+ * after the splitting.
+ */
+ tcPDPtr emitterData() const { return theEmitterData; }
+
+ /**
+ * Return the particle data object of the emission
+ * after the splitting.
+ */
+ tcPDPtr emissionData() const { return theEmissionData; }
+
+ /**
+ * Return the particle data object of the spectator
+ * after the splitting.
+ */
+ tcPDPtr spectatorData() const { return theSpectatorData; }
+
+ /**
+ * Return the momentum fraction of the emitter.
+ */
+ double emitterX() const { return theEmitterX; }
+
+ /**
+ * Return the momentum fraction of the spectator.
+ */
+ double spectatorX() const { return theSpectatorX; }
+
+public:
+
+ /**
+ * Return a pointer to the DipoleSplittingKinematics object
+ * which is to be used to perform the splitting.
+ */
+ Ptr<DipoleSplittingKinematics>::tptr splittingKinematics() const { return theSplittingKinematics; }
+
+ /**
+ * Return the dipole scale
+ */
+ Energy scale() const { return theScale; }
+
+ /**
+ * Return the pt below which this
+ * splitting has been generated.
+ */
+ Energy hardPt() const { return theHardPt; }
+
+ /**
+ * Return the last generated pt
+ */
+ Energy lastPt() const { return theLastPt; }
+
+ /**
+ * Return the last generated momentum fraction.
+ */
+ double lastZ() const { return theLastZ; }
+
+ /**
+ * Return the last generated azimuthal angle.
+ */
+ double lastPhi() const { return theLastPhi; }
+
+ /**
+ * Return the momentum fraction, by which the emitter's
+ * momentum fraction should be divided after the splitting.
+ */
+ double lastEmitterZ() const { return theLastEmitterZ; }
+
+ /**
+ * Return the momentum fraction, by which the spectator's
+ * momentum fraction should be divided after the splitting.
+ */
+ double lastSpectatorZ() const { return theLastSpectatorZ; }
+
+ /**
+ * Return any additional parameters needed to
+ * evaluate the splitting kernel or to generate the
+ * full splitting.
+ */
+ const vector<double>& lastSplittingParameters() const { return theLastSplittingParameters; }
+
+ /**
+ * Return true, if this splitting will terminate
+ * the evolution of the dipole considered.
+ */
+ bool stoppedEvolving() const { return theStoppedEvolving; }
+
+public:
+
+ /**
+ * Set the index.
+ */
+ void index(const DipoleIndex& ind) { theIndex = ind; }
+
+ /**
+ * Set the DipoleSplittingKinematics object
+ */
+ void splittingKinematics(Ptr<DipoleSplittingKinematics>::tptr newSplittingKinematics) {
+ theSplittingKinematics = newSplittingKinematics;
+ }
+
+ /**
+ * Set the particle data object of the emitter
+ * after the splitting.
+ */
+ void emitterData(tcPDPtr p) { theEmitterData = p; }
+
+ /**
+ * Set the particle data object of the emission
+ * after the splitting.
+ */
+ void emissionData(tcPDPtr p) { theEmissionData = p; }
+
+ /**
+ * Set the particle data object of the spectator
+ * after the splitting.
+ */
+ void spectatorData(tcPDPtr p) { theSpectatorData = p; }
+
+ /**
+ * Set the dipole scale
+ */
+ void scale(Energy s) { theScale = s; }
+
+ /**
+ * Set the emitter's momentum fraction
+ */
+ void emitterX(double x) { theEmitterX = x; }
+
+ /**
+ * Set the spectator's momentum fraction
+ */
+ void spectatorX(double x) { theSpectatorX = x; }
+
+ /**
+ * Set the pt below which this
+ * splitting has been generated.
+ */
+ void hardPt(Energy p) { theHardPt = p; }
+
+ /**
+ * Set the last generated pt
+ */
+ void lastPt(Energy p) { theLastPt = p; }
+
+ /**
+ * Set the last generated momentum fraction.
+ */
+ void lastZ(double z) { theLastZ = z; }
+
+ /**
+ * Set the last generated azimuthal angle.
+ */
+ void lastPhi(double p) { theLastPhi = p; }
+
+ /**
+ * Set the momentum fraction, by which the emitter's
+ * momentum fraction should be divided after the splitting.
+ */
+ void lastEmitterZ(double z) { theLastEmitterZ = z; }
+
+ /**
+ * Set the momentum fraction, by which the spectator's
+ * momentum fraction should be divided after the splitting.
+ */
+ void lastSpectatorZ(double z) { theLastSpectatorZ = z; }
+
+ /**
+ * Return the last splitting kernel value encountered.
+ */
+ double lastValue() const { return theLastValue; }
+
+ /**
+ * Set the last splitting kernel value encountered.
+ */
+ void lastValue(double v) { theLastValue = v; }
+
+ /**
+ * Set the last splitting parameters.
+ */
+ void lastSplittingParameters(const vector<double>& p) { theLastSplittingParameters = p; }
+
+ /**
+ * Access the splitting parameters
+ */
+ vector<double>& splittingParameters() { return theLastSplittingParameters; }
+
+ /**
+ * Indicate that this splitting will terminate
+ * the evolution of the dipole considered.
+ */
+ void didStopEvolving() { theStoppedEvolving = true; }
+
+ /**
+ * Indicate that this splitting will not terminate
+ * the evolution of the dipole considered.
+ */
+ void continuesEvolving() { theStoppedEvolving = false; }
+
+ /**
+ * Reset the configuration.
+ */
+ void configuration(pair<bool,bool> newConfig) { theConfiguration = newConfig; }
+
+public:
+
+ /**
+ * Set a pointer to the emitter parton before emission.
+ */
+ void emitter(tPPtr newEmitter) { theEmitter = newEmitter; }
+
+ /**
+ * Set a pointer to the spectator parton before emission.
+ */
+ void spectator(tPPtr newSpectator) { theSpectator = newSpectator; }
+
+ /**
+ * Set a pointer to the emitter parton after emission.
+ */
+ void splitEmitter(tPPtr newEmitter) { theSplitEmitter = newEmitter; }
+
+ /**
+ * Set a pointer to the spectator parton after emission.
+ */
+ void splitSpectator(tPPtr newSpectator) { theSplitSpectator = newSpectator; }
+
+ /**
+ * Set a pointer to the emitted parton.
+ */
+ void emission(tPPtr newEmission) { theEmission = newEmission; }
+
+ /**
+ * Return a pointer to the emitter parton before emission.
+ */
+ tPPtr emitter() const { return theEmitter; }
+
+ /**
+ * Return a pointer to the spectator parton before emission.
+ */
+ tPPtr spectator() const { return theSpectator; }
+
+ /**
+ * Return a pointer to the emitter parton after emission.
+ */
+ tPPtr splitEmitter() const { return theSplitEmitter; }
+
+ /**
+ * Return a pointer to the spectator parton after emission.
+ */
+ tPPtr splitSpectator() const { return theSplitSpectator; }
+
+ /**
+ * Return a pointer to the emitted parton.
+ */
+ tPPtr emission() const { return theEmission; }
+
+public:
+
+ /**
+ * Put information to ostream
+ */
+ void print(ostream&) const;
+
+private:
+
+ /**
+ * The DipoleIndex associated
+ * with this splitting.
+ */
+ DipoleIndex theIndex;
+
+ /**
+ * Flags indicateing which of the particles
+ * in the dipole should be considered emitter (true)
+ * and spectator (false)
+ */
+ pair<bool,bool> theConfiguration;
+
+ /**
+ * The particle data object of the emitter
+ * after the splitting.
+ */
+ tcPDPtr theEmitterData;
+
+ /**
+ * The particle data object of the emission
+ * after the splitting.
+ */
+ tcPDPtr theEmissionData;
+
+ /**
+ * The particle data object of the spectator
+ * after the splitting.
+ */
+ tcPDPtr theSpectatorData;
+
+ /**
+ * A pointer to the DipoleSplittingKinematics object
+ * which is to be used to perform the splitting.
+ */
+ Ptr<DipoleSplittingKinematics>::tptr theSplittingKinematics;
+
+ /**
+ * The scale for this dipole.
+ */
+ Energy theScale;
+
+ /**
+ * The momentum fraction of the emitter.
+ */
+ double theEmitterX;
+
+ /**
+ * The momentum fraction of the spectator.
+ */
+ double theSpectatorX;
+
+ /**
+ * The pt below which this splitting has
+ * been generated.
+ */
+ Energy theHardPt;
+
+ /**
+ * The last generated pt
+ */
+ Energy theLastPt;
+
+ /**
+ * The last generated momentum fraction.
+ */
+ double theLastZ;
+
+ /**
+ * The last generated azimuthal angle.
+ */
+ double theLastPhi;
+
+ /**
+ * The momentum fraction, by which the emitter's
+ * momentum fraction should be divided after the splitting.
+ */
+ double theLastEmitterZ;
+
+ /**
+ * The momentum fraction, by which the spectator's
+ * momentum fraction should be divided after the splitting.
+ */
+ double theLastSpectatorZ;
+
+ /**
+ * The last splitting kernel value encountered.
+ */
+ double theLastValue;
+
+ /**
+ * Any additional parameters needed to
+ * evaluate the splitting kernel or to generate the
+ * full splitting.
+ */
+ vector<double> theLastSplittingParameters;
+
+ /**
+ * True, if this splitting will terminate
+ * the evolution of the dipole considered.
+ */
+ bool theStoppedEvolving;
+
+ /**
+ * A pointer to the emitter parton before emission.
+ */
+ PPtr theEmitter;
+
+ /**
+ * A pointer to the spectator parton before emission.
+ */
+ PPtr theSpectator;
+
+ /**
+ * A pointer to the emitter parton after emission.
+ */
+ PPtr theSplitEmitter;
+
+ /**
+ * A pointer to the spectator parton after emission.
+ */
+ PPtr theSplitSpectator;
+
+ /**
+ * A pointer to the emitted parton.
+ */
+ PPtr theEmission;
+
+};
+
+inline ostream& operator << (ostream& os, const DipoleSplittingInfo& di) {
+ di.print(os);
+ return os;
+}
+
+}
+
+#endif /* HERWIG_DipoleSplittingInfo_H */
diff --git a/DipoleShower/Base/DipoleSplittingReweight.cc b/DipoleShower/Base/DipoleSplittingReweight.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Base/DipoleSplittingReweight.cc
@@ -0,0 +1,52 @@
+// -*- C++ -*-
+//
+// DipoleSplittingReweight.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the DipoleSplittingReweight class.
+//
+
+#include "DipoleSplittingReweight.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/Interface/Reference.h"
+#include "ThePEG/Repository/EventGenerator.h"
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+#include "Herwig++/DipoleShower/DipoleShowerHandler.h"
+
+using namespace Herwig;
+
+DipoleSplittingReweight::DipoleSplittingReweight()
+ : HandlerBase() {}
+
+DipoleSplittingReweight::~DipoleSplittingReweight() {}
+
+
+// If needed, insert default implementations of virtual function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void DipoleSplittingReweight::persistentOutput(PersistentOStream & ) const {
+}
+
+void DipoleSplittingReweight::persistentInput(PersistentIStream &, int) {
+}
+
+AbstractClassDescription<DipoleSplittingReweight> DipoleSplittingReweight::initDipoleSplittingReweight;
+// Definition of the static class description member.
+
+void DipoleSplittingReweight::Init() {
+
+ static ClassDocumentation<DipoleSplittingReweight> documentation
+ ("DipoleSplittingReweight is used by the dipole shower "
+ "to reweight splittings from a given dipole splitting kernel.");
+
+}
+
diff --git a/DipoleShower/Base/DipoleSplittingReweight.h b/DipoleShower/Base/DipoleSplittingReweight.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Base/DipoleSplittingReweight.h
@@ -0,0 +1,143 @@
+// -*- C++ -*-
+//
+// DipoleSplittingReweight.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_DipoleSplittingReweight_H
+#define HERWIG_DipoleSplittingReweight_H
+//
+// This is the declaration of the DipoleSplittingReweight class.
+//
+
+#include "ThePEG/Handlers/HandlerBase.h"
+#include "DipoleSplittingInfo.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief DipoleSplittingReweight is used by the dipole shower
+ * to reweight splittings from a given dipole splitting kernel.
+ *
+ * @see \ref DipoleSplittingReweightInterfaces "The interfaces"
+ * defined for DipoleSplittingReweight.
+ */
+class DipoleSplittingReweight: public HandlerBase {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ DipoleSplittingReweight();
+
+ /**
+ * The destructor.
+ */
+ virtual ~DipoleSplittingReweight();
+ //@}
+
+public:
+
+ /**
+ * Return the range of reweight factors for the given dipole type.
+ */
+ virtual pair<double,double> reweightBounds(const DipoleIndex&) const = 0;
+
+ /**
+ * Return the reweight factor for the given splitting type.
+ */
+ virtual double evaluate(const DipoleSplittingInfo&) const = 0;
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static AbstractClassDescription<DipoleSplittingReweight> initDipoleSplittingReweight;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ DipoleSplittingReweight & operator=(const DipoleSplittingReweight &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of DipoleSplittingReweight. */
+template <>
+struct BaseClassTrait<Herwig::DipoleSplittingReweight,1> {
+ /** Typedef of the first base class of DipoleSplittingReweight. */
+ typedef HandlerBase NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the DipoleSplittingReweight class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::DipoleSplittingReweight>
+ : public ClassTraitsBase<Herwig::DipoleSplittingReweight> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::DipoleSplittingReweight"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * DipoleSplittingReweight is implemented. It may also include several, space-separated,
+ * libraries if the class DipoleSplittingReweight depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_DipoleSplittingReweight_H */
diff --git a/DipoleShower/Base/Makefile.am b/DipoleShower/Base/Makefile.am
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Base/Makefile.am
@@ -0,0 +1,12 @@
+noinst_LTLIBRARIES = libHwDipoleShowerBase.la
+
+libHwDipoleShowerBase_la_SOURCES = \
+ DipoleSplittingInfo.h DipoleSplittingInfo.cc \
+ Dipole.h Dipole.cc \
+ DipoleChain.h DipoleChain.cc \
+ DipoleEventRecord.h DipoleEventRecord.cc \
+ DipoleSplittingGenerator.h DipoleSplittingGenerator.cc \
+ DipoleSplittingReweight.h DipoleSplittingReweight.cc \
+ DipoleEvolutionOrdering.h DipoleEvolutionOrdering.cc \
+ DipoleChainOrdering.h DipoleChainOrdering.cc
+
diff --git a/DipoleShower/DipoleShowerHandler.cc b/DipoleShower/DipoleShowerHandler.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/DipoleShowerHandler.cc
@@ -0,0 +1,834 @@
+// -*- C++ -*-
+//
+// DipoleShowerHandler.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the DipoleShowerHandler class.
+//
+
+#include "DipoleShowerHandler.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/Interface/Reference.h"
+#include "ThePEG/Interface/RefVector.h"
+#include "ThePEG/Interface/Parameter.h"
+#include "ThePEG/Interface/Switch.h"
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+// include theses to have complete types
+#include "Herwig++/Shower/Base/Evolver.h"
+#include "Herwig++/Shower/Base/ShowerParticle.h"
+#include "Herwig++/PDF/MPIPDF.h"
+#include "Herwig++/PDF/MinBiasPDF.h"
+#include "Herwig++/Shower/Base/ShowerTree.h"
+#include "Herwig++/Shower/Base/KinematicsReconstructor.h"
+#include "Herwig++/Shower/Base/PartnerFinder.h"
+#include "Herwig++/PDF/HwRemDecayer.h"
+
+#include "Herwig++/DipoleShower/Utility/DipolePartonSplitter.h"
+
+using namespace Herwig;
+
+DipoleShowerHandler::DipoleShowerHandler()
+ : ShowerHandler(), chainOrderVetoScales(true),
+ nEmissions(0), discardNoEmissions(false),
+ doFSR(true), doISR(true), realignmentScheme(0),
+ verbosity(0), printEvent(0), nTries(0),
+ didRadiate(false), didRealign(false),
+ theFactorizationScaleFactor(1.0),
+ theRenormalizationScaleFactor(1.0) {}
+
+DipoleShowerHandler::~DipoleShowerHandler() {}
+
+IBPtr DipoleShowerHandler::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr DipoleShowerHandler::fullclone() const {
+ return new_ptr(*this);
+}
+
+tPPair DipoleShowerHandler::cascade(tSubProPtr sub, XCPtr) {
+
+ prepareCascade(sub);
+
+ if ( !doFSR && ! doISR )
+ return sub->incoming();
+
+ eventRecord().clear();
+ eventRecord().prepare(sub,dynamic_ptr_cast<tStdXCombPtr>(lastXCombPtr()),pdfs());
+
+ if ( eventRecord().outgoing().empty() && !doISR )
+ return sub->incoming();
+ if ( !eventRecord().incoming().first->coloured() &&
+ !eventRecord().incoming().second->coloured() &&
+ !doFSR )
+ return sub->incoming();
+
+ nTries = 0;
+
+ while ( true ) {
+
+ try {
+
+ didRadiate = false;
+ didRealign = false;
+
+ hardScales();
+
+ if ( verbosity > 1 ) {
+ generator()->log() << "DipoleShowerHandler starting off:\n";
+ eventRecord().debugLastEvent(generator()->log());
+ generator()->log() << flush;
+ }
+
+ unsigned int nEmitted = 0;
+
+ doCascade(nEmitted);
+
+ if ( discardNoEmissions ) {
+ if ( !didRadiate )
+ throw Veto();
+ if ( nEmissions )
+ if ( nEmissions != nEmitted )
+ throw Veto();
+ }
+
+ if ( intrinsicPtGenerator ) {
+ if ( eventRecord().incoming().first->coloured() &&
+ eventRecord().incoming().second->coloured() ) {
+ SpinOneLorentzRotation rot =
+ intrinsicPtGenerator->kick(eventRecord().incoming(),
+ eventRecord().intermediates());
+ eventRecord().transform(rot);
+ }
+ }
+
+ didRealign = realign();
+
+ constituentReshuffle();
+
+ break;
+
+ } catch (RedoShower&) {
+
+ if ( ++nTries > maxtry() )
+ throw ShowerTriesVeto(maxtry());
+
+ eventRecord().clear();
+ eventRecord().prepare(sub,dynamic_ptr_cast<tStdXCombPtr>(lastXCombPtr()),pdfs());
+
+ continue;
+
+ } catch (...) {
+ throw;
+ }
+
+ }
+
+ return eventRecord().fillEventRecord(newStep(),firstInteraction(),didRealign);
+
+}
+
+void DipoleShowerHandler::constituentReshuffle() {
+
+ if ( constituentReshuffler ) {
+ constituentReshuffler->reshuffle(eventRecord().outgoing(),
+ eventRecord().incoming(),
+ eventRecord().intermediates());
+ }
+
+}
+
+void DipoleShowerHandler::hardScales() {
+
+ Energy maxPt = generator()->maximumCMEnergy();
+ if ( eventRecord().incoming().first->coloured() &&
+ eventRecord().incoming().second->coloured() ) {
+ for ( PList::const_iterator p = eventRecord().outgoing().begin();
+ p != eventRecord().outgoing().end(); ++p )
+ maxPt = min(maxPt,(**p).momentum().perp());
+ }
+
+ for ( list<DipoleChain>::iterator ch = eventRecord().chains().begin();
+ ch != eventRecord().chains().end(); ++ch ) {
+
+ Energy minVetoScale = -1.*GeV;
+
+ for ( list<Dipole>::iterator dip = ch->dipoles().begin();
+ dip != ch->dipoles().end(); ++dip ) {
+
+ // max scale per config
+ Energy maxFirst = 0.0*GeV;
+ Energy maxSecond = 0.0*GeV;
+
+ for ( vector<Ptr<DipoleSplittingKernel>::ptr>::iterator k =
+ kernels.begin(); k != kernels.end(); ++k ) {
+
+ pair<bool,bool> conf = make_pair(true,false);
+
+ if ( (**k).canHandle(dip->index(conf)) ) {
+ Energy scale =
+ evolutionOrdering()->hardScale(dip->emitter(conf),dip->spectator(conf),
+ dip->emitterX(conf),dip->spectatorX(conf),
+ **k,dip->index(conf));
+ maxFirst = max(maxFirst,scale);
+ }
+
+ conf = make_pair(false,true);
+
+ if ( (**k).canHandle(dip->index(conf)) ) {
+ Energy scale =
+ evolutionOrdering()->hardScale(dip->emitter(conf),dip->spectator(conf),
+ dip->emitterX(conf),dip->spectatorX(conf),
+ **k,dip->index(conf));
+ maxSecond = max(maxSecond,scale);
+ }
+
+ }
+
+ if ( dip->leftParticle()->vetoScale() >= ZERO ) {
+ maxFirst = min(maxFirst,sqrt(dip->leftParticle()->vetoScale()));
+ if ( minVetoScale >= ZERO )
+ minVetoScale = min(minVetoScale,sqrt(dip->leftParticle()->vetoScale()));
+ else
+ minVetoScale = sqrt(dip->leftParticle()->vetoScale());
+ }
+
+ if ( dip->rightParticle()->vetoScale() >= ZERO ) {
+ maxSecond = min(maxSecond,sqrt(dip->rightParticle()->vetoScale()));
+ if ( minVetoScale >= ZERO )
+ minVetoScale = min(minVetoScale,sqrt(dip->rightParticle()->vetoScale()));
+ else
+ minVetoScale = sqrt(dip->rightParticle()->vetoScale());
+ }
+
+ maxFirst = min(maxPt,maxFirst);
+ dip->emitterScale(make_pair(true,false),maxFirst);
+
+ maxSecond = min(maxPt,maxSecond);
+ dip->emitterScale(make_pair(false,true),maxSecond);
+
+ }
+
+ if ( !evolutionOrdering()->independentDipoles() &&
+ chainOrderVetoScales &&
+ minVetoScale >= ZERO ) {
+ for ( list<Dipole>::iterator dip = ch->dipoles().begin();
+ dip != ch->dipoles().end(); ++dip ) {
+ dip->leftScale(min(dip->leftScale(),minVetoScale));
+ dip->rightScale(min(dip->rightScale(),minVetoScale));
+ }
+ }
+
+ }
+
+}
+
+Energy DipoleShowerHandler::getWinner(DipoleSplittingInfo& winner,
+ const Dipole& dip,
+ pair<bool,bool> conf) {
+
+ if ( !dip.index(conf).initialStateEmitter() &&
+ !doFSR ) {
+ winner.didStopEvolving();
+ return 0.0*GeV;
+ }
+
+ if ( dip.index(conf).initialStateEmitter() &&
+ !doISR ) {
+ winner.didStopEvolving();
+ return 0.0*GeV;
+ }
+
+ DipoleSplittingInfo candidate;
+ candidate.index(dip.index(conf));
+ candidate.configuration(conf);
+ candidate.emitterX(dip.emitterX(conf));
+ candidate.spectatorX(dip.spectatorX(conf));
+
+ if ( generators().find(candidate.index()) == generators().end() )
+ getGenerators(candidate.index());
+
+ //
+ // NOTE -- needs proper fixing at some point
+ //
+ // For some very strange reason, equal_range gives back
+ // key ranges it hasn't been asked for. This particularly
+ // happens e.g. for FI dipoles of the same kind, but different
+ // PDF (hard vs MPI PDF). I can't see a reason for this,
+ // as DipoleIndex properly implements comparison for equality
+ // and (lexicographic) ordering; for the time being, we
+ // use equal_range, extented by an explicit check for wether
+ // the key is indeed what we wanted. See line after (*) comment
+ // below.
+ //
+
+ pair<GeneratorMap::iterator,GeneratorMap::iterator> gens
+ = generators().equal_range(candidate.index());
+
+ tPPtr emitter = dip.emitter(conf);
+ tPPtr spectator = dip.spectator(conf);
+ Energy startScale = dip.emitterScale(conf);
+ Energy winnerScale = 0.0*GeV;
+ GeneratorMap::iterator winnerGen = generators().end();
+
+ for ( GeneratorMap::iterator gen = gens.first; gen != gens.second; ++gen ) {
+
+ // (*) see NOTE above
+ if ( !(gen->first == candidate.index()) )
+ continue;
+
+ if ( startScale <= gen->second->splittingKinematics()->IRCutoff() )
+ continue;
+
+ Energy dScale =
+ gen->second->splittingKinematics()->dipoleScale(emitter->momentum(),
+ spectator->momentum());
+
+ // in very exceptional cases happening in DIS
+ if ( isnan(dScale/GeV ) )
+ throw RedoShower();
+
+ candidate.scale(dScale);
+ candidate.continuesEvolving();
+ candidate.hardPt(evolutionOrdering()->maxPt(startScale,candidate,*(gen->second->splittingKernel())));
+
+ gen->second->generate(candidate);
+ Energy nextScale = evolutionOrdering()->evolutionScale(gen->second->lastSplitting(),*(gen->second->splittingKernel()));
+
+ if ( nextScale > winnerScale ) {
+ winner = candidate;
+ gen->second->completeSplitting(winner);
+ winnerGen = gen;
+ winnerScale = nextScale;
+ }
+
+ }
+
+ if ( winnerGen == generators().end() ) {
+ winner.didStopEvolving();
+ return 0.0*GeV;
+ }
+
+ if ( winner.stoppedEvolving() )
+ return 0.0*GeV;
+
+ return winnerScale;
+
+}
+
+void DipoleShowerHandler::doCascade(unsigned int& emDone) {
+
+ if ( nEmissions )
+ if ( emDone == nEmissions )
+ return;
+
+ DipoleSplittingInfo winner;
+ DipoleSplittingInfo dipoleWinner;
+
+ while ( eventRecord().haveChain() ) {
+
+ if ( verbosity > 2 ) {
+ generator()->log() << "DipoleShowerHandler selecting splittings for the chain:\n"
+ << eventRecord().currentChain() << flush;
+ }
+
+ list<Dipole>::iterator winnerDip = eventRecord().currentChain().dipoles().end();
+
+ Energy winnerScale = 0.0*GeV;
+ Energy nextLeftScale = 0.0*GeV;
+ Energy nextRightScale = 0.0*GeV;
+
+ for ( list<Dipole>::iterator dip = eventRecord().currentChain().dipoles().begin();
+ dip != eventRecord().currentChain().dipoles().end(); ++dip ) {
+
+ nextLeftScale = getWinner(dipoleWinner,*dip,make_pair(true,false));
+
+ if ( nextLeftScale > winnerScale ) {
+ winnerScale = nextLeftScale;
+ winner = dipoleWinner;
+ winnerDip = dip;
+ }
+
+ nextRightScale = getWinner(dipoleWinner,*dip,make_pair(false,true));
+
+ if ( nextRightScale > winnerScale ) {
+ winnerScale = nextRightScale;
+ winner = dipoleWinner;
+ winnerDip = dip;
+ }
+
+ if ( evolutionOrdering()->independentDipoles() ) {
+ Energy dipScale = max(nextLeftScale,nextRightScale);
+ if ( dip->leftScale() > dipScale )
+ dip->leftScale(dipScale);
+ if ( dip->rightScale() > dipScale )
+ dip->rightScale(dipScale);
+ }
+
+ }
+
+ if ( verbosity > 1 ) {
+ if ( winnerDip != eventRecord().currentChain().dipoles().end() )
+ generator()->log() << "DipoleShowerHandler selected the splitting:\n"
+ << winner << " for the dipole\n"
+ << (*winnerDip) << flush;
+ else
+ generator()->log() << "DipoleShowerHandler could not select a splitting above the IR cutoff\n"
+ << flush;
+ }
+
+ // pop the chain if no dipole did radiate
+ if ( winnerDip == eventRecord().currentChain().dipoles().end() ) {
+ eventRecord().popChain();
+ continue;
+ }
+
+ // otherwise perform the splitting
+
+ didRadiate = true;
+
+ pair<list<Dipole>::iterator,list<Dipole>::iterator> children;
+
+ DipoleChain* firstChain = 0;
+ DipoleChain* secondChain = 0;
+
+ eventRecord().split(winnerDip,winner,children,firstChain,secondChain);
+
+ assert(firstChain && secondChain);
+
+ evolutionOrdering()->setEvolutionScale(winnerScale,winner,*firstChain,children);
+
+ if ( !secondChain->dipoles().empty() )
+ evolutionOrdering()->setEvolutionScale(winnerScale,winner,*secondChain,children);
+
+ if ( verbosity > 1 ) {
+ generator()->log() << "DipoleShowerHandler did split the last selected dipole into:\n"
+ << (*children.first) << (*children.second) << flush;
+ }
+
+ if ( verbosity > 2 ) {
+ generator()->log() << "After splitting the last selected dipole, "
+ << "DipoleShowerHandler encountered the following chains:\n"
+ << (*firstChain) << (*secondChain) << flush;
+ }
+
+ if ( nEmissions )
+ if ( ++emDone == nEmissions )
+ return;
+
+ }
+
+}
+
+bool DipoleShowerHandler::realign() {
+
+ if ( !didRadiate && !intrinsicPtGenerator )
+ return false;
+
+ if ( eventRecord().incoming().first->coloured() ||
+ eventRecord().incoming().second->coloured() ) {
+
+ if ( eventRecord().incoming().first->momentum().perp2()/GeV2 < 1e-10 &&
+ eventRecord().incoming().second->momentum().perp2()/GeV2 < 1e-10 )
+ return false;
+
+ pair<Lorentz5Momentum,Lorentz5Momentum> inMomenta
+ (eventRecord().incoming().first->momentum(),
+ eventRecord().incoming().second->momentum());
+
+ SpinOneLorentzRotation transform((inMomenta.first+inMomenta.second).findBoostToCM());
+
+ Axis dir = (transform * inMomenta.first).vect().unit();
+ Axis rot (-dir.y(),dir.x(),0);
+ double theta = dir.theta();
+
+ if ( lastParticles().first->momentum().z() < ZERO )
+ theta = -theta;
+
+ transform.rotate(-theta,rot);
+
+ inMomenta.first = transform*inMomenta.first;
+ inMomenta.second = transform*inMomenta.second;
+
+ assert(inMomenta.first.z() > ZERO &&
+ inMomenta.second.z() < ZERO);
+
+ Energy2 sHat =
+ (eventRecord().incoming().first->momentum() +
+ eventRecord().incoming().second->momentum()).m2();
+
+ Energy q = inMomenta.first.z();
+ pair<Energy,Energy> masses(eventRecord().incoming().first->mass(),
+ eventRecord().incoming().second->mass());
+ pair<Energy,Energy> qs;
+
+ if ( !eventRecord().incoming().first->coloured() ) {
+ assert(masses.second == ZERO);
+ qs.first = eventRecord().incoming().first->momentum().z();
+ qs.second = (sHat-sqr(masses.first))/(2.*(qs.first+sqrt(sqr(masses.first)+sqr(qs.first))));
+ } else if ( !eventRecord().incoming().second->coloured() ) {
+ assert(masses.first == ZERO);
+ qs.second = eventRecord().incoming().second->momentum().z();
+ qs.first = (sHat-sqr(masses.second))/(2.*(qs.second+sqrt(sqr(masses.second)+sqr(qs.second))));
+ } else {
+ assert(masses.first == ZERO && masses.second == ZERO);
+ if ( realignmentScheme == 0 ) {
+ double yX = eventRecord().pX().rapidity();
+ double yInt = (transform*eventRecord().pX()).rapidity();
+ double dy = yX-yInt;
+ qs.first = (sqrt(sHat)/2.)*exp(dy);
+ qs.second = (sqrt(sHat)/2.)*exp(-dy);
+ } else if ( realignmentScheme == 1 ) {
+ Energy sS = sqrt((lastParticles().first->momentum() +
+ lastParticles().second->momentum()).m2());
+ qs.first = eventRecord().fractions().first * sS / 2.;
+ qs.second = eventRecord().fractions().second * sS / 2.;
+ }
+ }
+
+ double beta =
+ (qs.first-qs.second) /
+ ( sqrt(sqr(masses.first)+sqr(qs.first)) +
+ sqrt(sqr(masses.second)+sqr(qs.second)) );
+ transform.boostZ(beta);
+
+ Lorentz5Momentum tmp;
+
+ if ( eventRecord().incoming().first->coloured() ) {
+ tmp = eventRecord().incoming().first->momentum();
+ tmp = transform * tmp;
+ eventRecord().incoming().first->set5Momentum(tmp);
+ }
+ if ( eventRecord().incoming().second->coloured() ) {
+ tmp = eventRecord().incoming().second->momentum();
+ tmp = transform * tmp;
+ eventRecord().incoming().second->set5Momentum(tmp);
+ }
+ eventRecord().transform(transform);
+ return true;
+
+ }
+
+ return false;
+
+}
+
+void DipoleShowerHandler::resetAlphaS(Ptr<AlphaSBase>::tptr as) {
+
+ for ( vector<Ptr<DipoleSplittingKernel>::ptr>::iterator k = kernels.begin();
+ k != kernels.end(); ++k )
+ (**k).alphaS(as);
+
+ // clear the generators to be rebuild
+ // actually, there shouldn't be any generators
+ // when this happens.
+ generators().clear();
+
+}
+
+void DipoleShowerHandler::resetReweight(Ptr<DipoleSplittingReweight>::tptr rw) {
+ for ( GeneratorMap::iterator k = generators().begin();
+ k != generators().end(); ++k )
+ k->second->splittingReweight(rw);
+}
+
+void DipoleShowerHandler::getGenerators(const DipoleIndex& ind,
+ Ptr<DipoleSplittingReweight>::tptr rw) {
+
+ bool gotone = false;
+
+ for ( vector<Ptr<DipoleSplittingKernel>::ptr>::iterator k =
+ kernels.begin(); k != kernels.end(); ++k ) {
+ if ( (**k).canHandle(ind) ) {
+
+ if ( verbosity > 0 ) {
+ generator()->log() << "DipoleShowerHandler encountered the dipole configuration\n"
+ << ind << " in event number "
+ << eventHandler()->currentEvent()->number()
+ << "\nwhich can be handled by the splitting kernel '"
+ << (**k).name() << "'.\n" << flush;
+ }
+
+ gotone = true;
+
+ Ptr<DipoleSplittingGenerator>::ptr nGenerator =
+ new_ptr(DipoleSplittingGenerator());
+ nGenerator->splittingKernel(*k);
+ nGenerator->splittingKernel()->renormalizationScaleFactor(theRenormalizationScaleFactor);
+ nGenerator->splittingKernel()->factorizationScaleFactor(theFactorizationScaleFactor);
+
+ GeneratorMap::const_iterator equivalent = generators().end();
+
+ for ( GeneratorMap::const_iterator eq = generators().begin();
+ eq != generators().end(); ++eq ) {
+ if ( !eq->second->wrapping() )
+ if ( (**k).canHandleEquivalent(ind,*(eq->second->splittingKernel()),eq->first) ) {
+
+ equivalent = eq;
+
+ if ( verbosity > 0 ) {
+ generator()->log() << "The dipole configuration "
+ << ind
+ << " can equivalently be handled by the existing\n"
+ << "generator for configuration "
+ << eq->first << " using the kernel '"
+ << eq->second->splittingKernel()->name()
+ << "'\n" << flush;
+ }
+
+ break;
+
+ }
+ }
+
+ if ( equivalent != generators().end() ) {
+ nGenerator->wrap(equivalent->second);
+ }
+
+ DipoleSplittingInfo dummy;
+ dummy.index(ind);
+ nGenerator->splittingReweight(rw);
+ nGenerator->prepare(dummy);
+
+ generators().insert(make_pair(ind,nGenerator));
+
+
+ }
+ }
+
+ if ( !gotone ) {
+ generator()->logWarning(Exception()
+ << "DipoleShowerHandler could not "
+ << "find a splitting kernel which is able "
+ << "to handle splittings off the dipole "
+ << ind << ".\n"
+ << "Please check the input files."
+ << Exception::warning);
+ }
+
+}
+
+// If needed, insert default implementations of virtual function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+void DipoleShowerHandler::doinit() {
+ ShowerHandler::doinit();
+ if ( theGlobalAlphaS )
+ resetAlphaS(theGlobalAlphaS);
+}
+
+void DipoleShowerHandler::dofinish() {
+ ShowerHandler::dofinish();
+}
+
+void DipoleShowerHandler::doinitrun() {
+ ShowerHandler::doinitrun();
+}
+
+void DipoleShowerHandler::persistentOutput(PersistentOStream & os) const {
+ os << kernels << theEvolutionOrdering
+ << constituentReshuffler << intrinsicPtGenerator
+ << theGlobalAlphaS << chainOrderVetoScales
+ << nEmissions << discardNoEmissions << doFSR << doISR
+ << realignmentScheme << verbosity << printEvent
+ << theFactorizationScaleFactor << theRenormalizationScaleFactor;
+}
+
+void DipoleShowerHandler::persistentInput(PersistentIStream & is, int) {
+ is >> kernels >> theEvolutionOrdering
+ >> constituentReshuffler >> intrinsicPtGenerator
+ >> theGlobalAlphaS >> chainOrderVetoScales
+ >> nEmissions >> discardNoEmissions >> doFSR >> doISR
+ >> realignmentScheme >> verbosity >> printEvent
+ >> theFactorizationScaleFactor >> theRenormalizationScaleFactor;
+}
+
+ClassDescription<DipoleShowerHandler> DipoleShowerHandler::initDipoleShowerHandler;
+// Definition of the static class description member.
+
+void DipoleShowerHandler::Init() {
+
+ static ClassDocumentation<DipoleShowerHandler> documentation
+ ("The DipoleShowerHandler class manages the showering using "
+ "the dipole shower algorithm.",
+ "The shower evolution was performed using the algorithm described in "
+ "\\cite{Platzer:2009jq} and \\cite{Platzer:2011bc}.",
+ "%\\cite{Platzer:2009jq}\n"
+ "\\bibitem{Platzer:2009jq}\n"
+ "S.~Platzer and S.~Gieseke,\n"
+ "``Coherent Parton Showers with Local Recoils,''\n"
+ " JHEP {\\bf 1101}, 024 (2011)\n"
+ "arXiv:0909.5593 [hep-ph].\n"
+ "%%CITATION = ARXIV:0909.5593;%%\n"
+ "%\\cite{Platzer:2011bc}\n"
+ "\\bibitem{Platzer:2011bc}\n"
+ "S.~Platzer and S.~Gieseke,\n"
+ "``Dipole Showers and Automated NLO Matching in Herwig++,''\n"
+ "arXiv:1109.6256 [hep-ph].\n"
+ "%%CITATION = ARXIV:1109.6256;%%");
+
+ static RefVector<DipoleShowerHandler,DipoleSplittingKernel> interfaceKernels
+ ("Kernels",
+ "Set the splitting kernels to be used by the dipole shower.",
+ &DipoleShowerHandler::kernels, -1, false, false, true, false, false);
+
+
+ static Reference<DipoleShowerHandler,DipoleEvolutionOrdering> interfaceEvolutionOrdering
+ ("EvolutionOrdering",
+ "Set the evolution ordering to be used.",
+ &DipoleShowerHandler::theEvolutionOrdering, false, false, true, false, false);
+
+
+ static Reference<DipoleShowerHandler,ConstituentReshuffler> interfaceConstituentReshuffler
+ ("ConstituentReshuffler",
+ "The object to be used to reshuffle partons to their constitutent mass shells.",
+ &DipoleShowerHandler::constituentReshuffler, false, false, true, true, false);
+
+
+ static Reference<DipoleShowerHandler,IntrinsicPtGenerator> interfaceIntrinsicPtGenerator
+ ("IntrinsicPtGenerator",
+ "Set the object in charge to generate intrinsic pt for incoming partons.",
+ &DipoleShowerHandler::intrinsicPtGenerator, false, false, true, true, false);
+
+ static Reference<DipoleShowerHandler,AlphaSBase> interfaceGlobalAlphaS
+ ("GlobalAlphaS",
+ "Set a global strong coupling for all splitting kernels.",
+ &DipoleShowerHandler::theGlobalAlphaS, false, false, true, true, false);
+
+
+ static Switch<DipoleShowerHandler,bool> interfaceDoFSR
+ ("DoFSR",
+ "Switch on or off final state radiation.",
+ &DipoleShowerHandler::doFSR, true, false, false);
+ static SwitchOption interfaceDoFSROn
+ (interfaceDoFSR,
+ "On",
+ "Switch on final state radiation.",
+ true);
+ static SwitchOption interfaceDoFSROff
+ (interfaceDoFSR,
+ "Off",
+ "Switch off final state radiation.",
+ false);
+
+ static Switch<DipoleShowerHandler,bool> interfaceDoISR
+ ("DoISR",
+ "Switch on or off initial state radiation.",
+ &DipoleShowerHandler::doISR, true, false, false);
+ static SwitchOption interfaceDoISROn
+ (interfaceDoISR,
+ "On",
+ "Switch on initial state radiation.",
+ true);
+ static SwitchOption interfaceDoISROff
+ (interfaceDoISR,
+ "Off",
+ "Switch off initial state radiation.",
+ false);
+
+
+ static Switch<DipoleShowerHandler,int> interfaceRealignmentScheme
+ ("RealignmentScheme",
+ "The realignment scheme to use.",
+ &DipoleShowerHandler::realignmentScheme, 0, false, false);
+ static SwitchOption interfaceRealignmentSchemePreserveRapidity
+ (interfaceRealignmentScheme,
+ "PreserveRapidity",
+ "Preserve the rapidity of non-coloured outgoing system.",
+ 0);
+ static SwitchOption interfaceRealignmentSchemeEvolutionFractions
+ (interfaceRealignmentScheme,
+ "EvolutionFractions",
+ "Use momentum fractions as generated by the evolution.",
+ 1);
+ static SwitchOption interfaceRealignmentSchemeCollisionFrame
+ (interfaceRealignmentScheme,
+ "CollisionFrame",
+ "Determine realignment from collision frame.",
+ 2);
+
+
+ static Switch<DipoleShowerHandler,bool> interfaceChainOrderVetoScales
+ ("ChainOrderVetoScales",
+ "[experimental] Switch on or off the chain ordering for veto scales.",
+ &DipoleShowerHandler::chainOrderVetoScales, true, false, false);
+ static SwitchOption interfaceChainOrderVetoScalesOn
+ (interfaceChainOrderVetoScales,
+ "On",
+ "Switch on chain ordering for veto scales.",
+ true);
+ static SwitchOption interfaceChainOrderVetoScalesOff
+ (interfaceChainOrderVetoScales,
+ "Off",
+ "Switch off chain ordering for veto scales.",
+ false);
+
+ interfaceChainOrderVetoScales.rank(-1);
+
+
+ static Parameter<DipoleShowerHandler,unsigned int> interfaceNEmissions
+ ("NEmissions",
+ "[debug option] Limit the number of emissions to be generated. Zero does not limit the number of emissions.",
+ &DipoleShowerHandler::nEmissions, 0, 0, 0,
+ false, false, Interface::lowerlim);
+
+ interfaceNEmissions.rank(-1);
+
+
+ static Switch<DipoleShowerHandler,bool> interfaceDiscardNoEmissions
+ ("DiscardNoEmissions",
+ "[debug option] Discard events without radiation.",
+ &DipoleShowerHandler::discardNoEmissions, false, false, false);
+ static SwitchOption interfaceDiscardNoEmissionsOn
+ (interfaceDiscardNoEmissions,
+ "On",
+ "Discard events without radiation.",
+ true);
+ static SwitchOption interfaceDiscardNoEmissionsOff
+ (interfaceDiscardNoEmissions,
+ "Off",
+ "Do not discard events without radiation.",
+ false);
+
+ interfaceDiscardNoEmissions.rank(-1);
+
+
+ static Parameter<DipoleShowerHandler,int> interfaceVerbosity
+ ("Verbosity",
+ "[debug option] Set the level of debug information provided.",
+ &DipoleShowerHandler::verbosity, 0, 0, 0,
+ false, false, Interface::lowerlim);
+
+ interfaceVerbosity.rank(-1);
+
+
+ static Parameter<DipoleShowerHandler,int> interfacePrintEvent
+ ("PrintEvent",
+ "[debug option] The number of events for which debugging information should be provided.",
+ &DipoleShowerHandler::printEvent, 0, 0, 0,
+ false, false, Interface::lowerlim);
+
+ interfacePrintEvent.rank(-1);
+
+ static Parameter<DipoleShowerHandler,double> interfaceFactorizationScaleFactor
+ ("FactorizationScaleFactor",
+ "The factorization scale factor.",
+ &DipoleShowerHandler::theFactorizationScaleFactor, 1.0, 0.0, 0,
+ false, false, Interface::lowerlim);
+
+ static Parameter<DipoleShowerHandler,double> interfaceRenormalizationScaleFactor
+ ("RenormalizationScaleFactor",
+ "The renormalization scale factor.",
+ &DipoleShowerHandler::theRenormalizationScaleFactor, 1.0, 0.0, 0,
+ false, false, Interface::lowerlim);
+
+}
+
diff --git a/DipoleShower/DipoleShowerHandler.h b/DipoleShower/DipoleShowerHandler.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/DipoleShowerHandler.h
@@ -0,0 +1,399 @@
+// -*- C++ -*-
+//
+// DipoleShowerHandler.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_DipoleShowerHandler_H
+#define HERWIG_DipoleShowerHandler_H
+//
+// This is the declaration of the DipoleShowerHandler class.
+//
+
+#include "Herwig++/Shower/ShowerHandler.h"
+
+#include "Herwig++/DipoleShower/Base/DipoleSplittingInfo.h"
+#include "Herwig++/DipoleShower/Base/DipoleSplittingReweight.h"
+#include "Herwig++/DipoleShower/Kernels/DipoleSplittingKernel.h"
+#include "Herwig++/DipoleShower/Base/DipoleSplittingGenerator.h"
+#include "Herwig++/DipoleShower/Base/DipoleEventRecord.h"
+#include "Herwig++/DipoleShower/Base/DipoleEvolutionOrdering.h"
+#include "Herwig++/DipoleShower/Utility/ConstituentReshuffler.h"
+#include "Herwig++/DipoleShower/Utility/IntrinsicPtGenerator.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief The DipoleShowerHandler class manages the showering using
+ * the dipole shower algorithm.
+ *
+ * @see \ref DipoleShowerHandlerInterfaces "The interfaces"
+ * defined for DipoleShowerHandler.
+ */
+class DipoleShowerHandler: public ShowerHandler {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ DipoleShowerHandler();
+
+ /**
+ * The destructor.
+ */
+ virtual ~DipoleShowerHandler();
+ //@}
+
+public:
+
+ /**
+ * Indicate a problem in the shower.
+ */
+ struct RedoShower {};
+
+ /**
+ * Insert an additional splitting kernel.
+ */
+ void addSplitting(Ptr<DipoleSplittingKernel>::ptr sp) {
+ kernels.push_back(sp);
+ }
+
+ /**
+ * Reset the alpha_s for all splitting kernels.
+ */
+ void resetAlphaS(Ptr<AlphaSBase>::tptr);
+
+ /**
+ * Reset the splitting reweight for all splitting kernels.
+ */
+ void resetReweight(Ptr<DipoleSplittingReweight>::tptr);
+
+protected:
+
+ typedef multimap<DipoleIndex,Ptr<DipoleSplittingGenerator>::ptr> GeneratorMap;
+
+ /**
+ * The main method which manages the showering of a subprocess.
+ */
+ virtual tPPair cascade(tSubProPtr sub, XCPtr xcomb);
+
+ /**
+ * Build splitting generators for the given
+ * dipole index.
+ */
+ void getGenerators(const DipoleIndex&,
+ Ptr<DipoleSplittingReweight>::tptr rw =
+ Ptr<DipoleSplittingReweight>::tptr());
+
+ /**
+ * Setup the hard scales.
+ */
+ void hardScales();
+
+ /**
+ * Return the evolution ordering
+ */
+ Ptr<DipoleEvolutionOrdering>::tptr evolutionOrdering() const { return theEvolutionOrdering; }
+
+ /**
+ * Reshuffle to constituent mass shells
+ */
+ void constituentReshuffle();
+
+ /**
+ * Access the generator map
+ */
+ GeneratorMap& generators() { return theGenerators; }
+
+ /**
+ * Access the event record
+ */
+ DipoleEventRecord& eventRecord() { return theEventRecord; }
+
+ /**
+ * Return the event record
+ */
+ const DipoleEventRecord& eventRecord() const { return theEventRecord; }
+
+ /**
+ * Return the splitting kernels.
+ */
+ const vector<Ptr<DipoleSplittingKernel>::ptr>& splittingKernels() const {
+ return kernels;
+ }
+
+ /**
+ * Realign the event such as to have the incoming partons along thre
+ * beam axes.
+ */
+ bool realign();
+
+private:
+
+ /**
+ * Perform the cascade.
+ */
+ void doCascade(unsigned int& emDone);
+
+ /**
+ * Get the winning splitting for the
+ * given dipole and configuration.
+ */
+ Energy getWinner(DipoleSplittingInfo& winner,
+ const Dipole& dip,
+ pair<bool,bool> conf);
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+protected:
+
+ /** @name Standard Interfaced functions. */
+ //@{
+ /**
+ * Initialize this object after the setup phase before saving an
+ * EventGenerator to disk.
+ * @throws InitException if object could not be initialized properly.
+ */
+ virtual void doinit();
+
+ /**
+ * Initialize this object. Called in the run phase just before
+ * a run begins.
+ */
+ virtual void doinitrun();
+
+ /**
+ * Finalize this object. Called in the run phase just after a
+ * run has ended. Used eg. to write out statistics.
+ */
+ virtual void dofinish();
+ //@}
+
+
+private:
+
+ /**
+ * The splitting kernels to be used.
+ */
+ vector<Ptr<DipoleSplittingKernel>::ptr> kernels;
+
+ /**
+ * The evolution ordering considered
+ */
+ Ptr<DipoleEvolutionOrdering>::ptr theEvolutionOrdering;
+
+ /**
+ * The ConstituentReshuffler to be used
+ */
+ Ptr<ConstituentReshuffler>::ptr constituentReshuffler;
+
+ /**
+ * The intrinsic pt generator to be used.
+ */
+ Ptr<IntrinsicPtGenerator>::ptr intrinsicPtGenerator;
+
+ /**
+ * A global alpha_s to be used for all splitting kernels.
+ */
+ Ptr<AlphaSBase>::ptr theGlobalAlphaS;
+
+ /**
+ * Apply chain ordering to events from matrix
+ * element corrections.
+ */
+ bool chainOrderVetoScales;
+
+ /**
+ * Limit the number of emissions.
+ * Limit applied if > 0.
+ */
+ unsigned int nEmissions;
+
+ /**
+ * Discard events which did not radiate.
+ */
+ bool discardNoEmissions;
+
+ /**
+ * Switch on or off final state radiation.
+ */
+ bool doFSR;
+
+ /**
+ * Switch on or off initial state radiation.
+ */
+ bool doISR;
+
+ /**
+ * The realignment scheme
+ */
+ int realignmentScheme;
+
+private:
+
+ /**
+ * The verbosity level.
+ * 0 - print no info
+ * 1 - print diagnostic information on setting up
+ * splitting generators etc.
+ * 2 - print detailed event information for up to
+ * printEvent events.
+ * 3 - print dipole chains after each splitting.
+ */
+ int verbosity;
+
+ /**
+ * See verbosity.
+ */
+ int printEvent;
+
+private:
+
+ /**
+ * The splitting generators indexed by the dipole
+ * indices they can work on.
+ */
+ GeneratorMap theGenerators;
+
+ /**
+ * The evnt record used.
+ */
+ DipoleEventRecord theEventRecord;
+
+ /**
+ * The number of shoer tries so far.
+ */
+ unsigned int nTries;
+
+ /**
+ * Whether or not we did radiate anything
+ */
+ bool didRadiate;
+
+ /**
+ * Whether or not we did realign the event
+ */
+ bool didRealign;
+
+private:
+
+ /**
+ * The factorization scale factor.
+ */
+ double theFactorizationScaleFactor;
+
+ /**
+ * The renormalization scale factor.
+ */
+ double theRenormalizationScaleFactor;
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<DipoleShowerHandler> initDipoleShowerHandler;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ DipoleShowerHandler & operator=(const DipoleShowerHandler &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of DipoleShowerHandler. */
+template <>
+struct BaseClassTrait<Herwig::DipoleShowerHandler,1> {
+ /** Typedef of the first base class of DipoleShowerHandler. */
+ typedef Herwig::ShowerHandler NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the DipoleShowerHandler class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::DipoleShowerHandler>
+ : public ClassTraitsBase<Herwig::DipoleShowerHandler> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::DipoleShowerHandler"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * DipoleShowerHandler is implemented. It may also include several, space-separated,
+ * libraries if the class DipoleShowerHandler depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_DipoleShowerHandler_H */
diff --git a/DipoleShower/Kernels/DipoleSplittingKernel.cc b/DipoleShower/Kernels/DipoleSplittingKernel.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/DipoleSplittingKernel.cc
@@ -0,0 +1,182 @@
+// -*- C++ -*-
+//
+// DipoleSplittingKernel.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the DipoleSplittingKernel class.
+//
+
+#include "DipoleSplittingKernel.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/Interface/Reference.h"
+#include "ThePEG/Interface/Parameter.h"
+#include "ThePEG/Interface/Switch.h"
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+DipoleSplittingKernel::DipoleSplittingKernel()
+ : HandlerBase(), theScreeningScale(0.0*GeV),
+ thePresamplingPoints(10000), theMaxtry(100000),
+ theStrictLargeN(false),
+ theFactorizationScaleFactor(1.0),
+ theRenormalizationScaleFactor(1.0) {}
+
+DipoleSplittingKernel::~DipoleSplittingKernel() {}
+
+
+// If needed, insert default implementations of virtual function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void DipoleSplittingKernel::persistentOutput(PersistentOStream & os) const {
+ os << theAlphaS << ounit(theScreeningScale,GeV) << theSplittingKinematics << thePDFRatio
+ << thePresamplingPoints << theMaxtry
+ << theFlavour << theMCCheck << theStrictLargeN
+ << theFactorizationScaleFactor
+ << theRenormalizationScaleFactor;
+}
+
+void DipoleSplittingKernel::persistentInput(PersistentIStream & is, int) {
+ is >> theAlphaS >> iunit(theScreeningScale,GeV) >> theSplittingKinematics >> thePDFRatio
+ >> thePresamplingPoints >> theMaxtry
+ >> theFlavour >> theMCCheck >> theStrictLargeN
+ >> theFactorizationScaleFactor
+ >> theRenormalizationScaleFactor;
+}
+
+double DipoleSplittingKernel::alphaPDF(const DipoleSplittingInfo& split) const {
+
+ Energy pt = split.lastPt();
+
+ Energy2 scale = sqr(pt) + sqr(theScreeningScale);
+
+ double ret = alphaS()->value(theRenormalizationScaleFactor*scale) / (2.*Constants::pi);
+
+ if ( split.index().initialStateEmitter() ) {
+ assert(pdfRatio());
+ ret *=
+ split.lastEmitterZ() *
+ (*pdfRatio())(split.index().emitterPDF(),
+ theFactorizationScaleFactor*scale,
+ split.index().emitterData(),split.emitterData(),
+ split.emitterX(),split.lastEmitterZ());
+ }
+
+ if ( split.index().initialStateSpectator() ) {
+ assert(pdfRatio());
+ ret *=
+ split.lastSpectatorZ() *
+ (*pdfRatio())(split.index().spectatorPDF(),
+ theFactorizationScaleFactor*scale,
+ split.index().spectatorData(),split.spectatorData(),
+ split.spectatorX(),split.lastSpectatorZ());
+ }
+
+
+ if ( ret < 0. )
+ ret = 0.;
+
+ return ret;
+
+}
+
+AbstractClassDescription<DipoleSplittingKernel> DipoleSplittingKernel::initDipoleSplittingKernel;
+// Definition of the static class description member.
+
+void DipoleSplittingKernel::Init() {
+
+ static ClassDocumentation<DipoleSplittingKernel> documentation
+ ("DipoleSplittingKernel is the base class for all kernels "
+ "used within the dipole shower.");
+
+ static Reference<DipoleSplittingKernel,AlphaSBase> interfaceAlphaS
+ ("AlphaS",
+ "The strong coupling to be used by this splitting kernel.",
+ &DipoleSplittingKernel::theAlphaS, false, false, true, true, false);
+
+
+ static Parameter<DipoleSplittingKernel,Energy> interfaceScreeningScale
+ ("ScreeningScale",
+ "A colour screening scale",
+ &DipoleSplittingKernel::theScreeningScale, GeV, 0.0*GeV, 0.0*GeV, 0*GeV,
+ false, false, Interface::lowerlim);
+
+
+ static Reference<DipoleSplittingKernel,DipoleSplittingKinematics> interfaceSplittingKinematics
+ ("SplittingKinematics",
+ "The splitting kinematics to be used by this splitting kernel.",
+ &DipoleSplittingKernel::theSplittingKinematics, false, false, true, false, false);
+
+
+ static Reference<DipoleSplittingKernel,PDFRatio> interfacePDFRatio
+ ("PDFRatio",
+ "Set the optional PDF ratio object to evaluate this kernel",
+ &DipoleSplittingKernel::thePDFRatio, false, false, true, true, false);
+
+ static Parameter<DipoleSplittingKernel,unsigned long> interfacePresamplingPoints
+ ("PresamplingPoints",
+ "The number of points used to presample this kernel.",
+ &DipoleSplittingKernel::thePresamplingPoints, 10000, 1, 0,
+ false, false, Interface::lowerlim);
+
+ static Parameter<DipoleSplittingKernel,unsigned long> interfaceMaxtry
+ ("Maxtry",
+ "The maximum number of attempts to generate a splitting.",
+ &DipoleSplittingKernel::theMaxtry, 10000, 1, 0,
+ false, false, Interface::lowerlim);
+
+ static Reference<DipoleSplittingKernel,ParticleData> interfaceFlavour
+ ("Flavour",
+ "Set the flavour to be produced if ambiguous.",
+ &DipoleSplittingKernel::theFlavour, false, false, true, true, false);
+
+ static Reference<DipoleSplittingKernel,DipoleMCCheck> interfaceMCCheck
+ ("MCCheck",
+ "[debug option] MCCheck",
+ &DipoleSplittingKernel::theMCCheck, false, false, true, true, false);
+
+ interfaceMCCheck.rank(-1);
+
+ static Switch<DipoleSplittingKernel,bool> interfaceStrictLargeN
+ ("StrictLargeN",
+ "Work in a strict large-N limit.",
+ &DipoleSplittingKernel::theStrictLargeN, false, false, false);
+ static SwitchOption interfaceStrictLargeNOn
+ (interfaceStrictLargeN,
+ "On",
+ "Replace C_F -> C_A/2 where present",
+ true);
+ static SwitchOption interfaceStrictLargeNOff
+ (interfaceStrictLargeN,
+ "Off",
+ "Keep C_F=4/3",
+ false);
+
+ interfaceStrictLargeN.rank(-2);
+
+ static Parameter<DipoleSplittingKernel,double> interfaceFactorizationScaleFactor
+ ("FactorizationScaleFactor",
+ "The factorization scale factor.",
+ &DipoleSplittingKernel::theFactorizationScaleFactor, 1.0, 0.0, 0,
+ false, false, Interface::lowerlim);
+
+ interfaceFactorizationScaleFactor.rank(-2);
+
+ static Parameter<DipoleSplittingKernel,double> interfaceRenormalizationScaleFactor
+ ("RenormalizationScaleFactor",
+ "The renormalization scale factor.",
+ &DipoleSplittingKernel::theRenormalizationScaleFactor, 1.0, 0.0, 0,
+ false, false, Interface::lowerlim);
+
+ interfaceRenormalizationScaleFactor.rank(-2);
+
+}
+
diff --git a/DipoleShower/Kernels/DipoleSplittingKernel.h b/DipoleShower/Kernels/DipoleSplittingKernel.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/DipoleSplittingKernel.h
@@ -0,0 +1,378 @@
+// -*- C++ -*-
+//
+// DipoleSplittingKernel.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_DipoleSplittingKernel_H
+#define HERWIG_DipoleSplittingKernel_H
+//
+// This is the declaration of the DipoleSplittingKernel class.
+//
+
+#include "ThePEG/Handlers/HandlerBase.h"
+#include "ThePEG/StandardModel/AlphaSBase.h"
+#include "ThePEG/PDF/PDF.h"
+
+#include "Herwig++/DipoleShower/Utility/PDFRatio.h"
+#include "Herwig++/DipoleShower/Base/DipoleSplittingInfo.h"
+#include "Herwig++/DipoleShower/Kinematics/DipoleSplittingKinematics.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief DipoleSplittingKernel is the base class for all kernels
+ * used within the dipole shower.
+ *
+ * @see \ref DipoleSplittingKernelInterfaces "The interfaces"
+ * defined for DipoleSplittingKernel.
+ */
+class DipoleSplittingKernel: public HandlerBase {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ DipoleSplittingKernel();
+
+ /**
+ * The destructor.
+ */
+ virtual ~DipoleSplittingKernel();
+ //@}
+
+public:
+
+ /**
+ * Return the alpha_s to be used
+ */
+ Ptr<AlphaSBase>::tptr alphaS() const { return theAlphaS; }
+
+ /**
+ * Set the alpha_s to be used
+ */
+ void alphaS(Ptr<AlphaSBase>::tptr ap) { theAlphaS = ap; }
+
+ /**
+ * Return the splitting kinematics object
+ */
+ Ptr<DipoleSplittingKinematics>::tptr splittingKinematics() const { return theSplittingKinematics; }
+
+ /**
+ * Return the mc check object
+ */
+ Ptr<DipoleMCCheck>::ptr mcCheck() const { return theMCCheck; }
+
+ /**
+ * Set the splitting kinematics object
+ */
+ void splittingKinematics(Ptr<DipoleSplittingKinematics>::tptr sp) { theSplittingKinematics = sp; }
+
+ /**
+ * Return the PDFRatio object
+ */
+ Ptr<PDFRatio>::tptr pdfRatio() const { return thePDFRatio; }
+
+ /**
+ * Set the PDFRatio object
+ */
+ void pdfRatio(Ptr<PDFRatio>::tptr sp) { thePDFRatio = sp; }
+
+ /**
+ * Return the number of additional parameter
+ * random variables needed to evaluate this kernel
+ * except the momentum fractions of incoming partons.
+ * These will be accessible through the
+ * lastSplittingParameters() container of the splitting
+ * info object.
+ */
+ virtual int nDimAdditional() const { return 0; }
+
+public:
+
+ /**
+ * Return true, if this splitting kernel
+ * applies to the given dipole index.
+ */
+ virtual bool canHandle(const DipoleIndex&) const = 0;
+
+ /**
+ * Return true, if this splitting kernel is
+ * the same for the given index a, as the given
+ * splitting kernel for index b.
+ */
+ virtual bool canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const = 0;
+
+ /**
+ * Return the emitter data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emitter(const DipoleIndex&) const = 0;
+
+ /**
+ * Return the emission data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emission(const DipoleIndex&) const = 0;
+
+ /**
+ * Return the spectator data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr spectator(const DipoleIndex&) const = 0;
+
+ /**
+ * Return the flavour produced, if this cannot
+ * be determined from the dipole.
+ */
+ PDPtr flavour() const { return theFlavour; }
+
+ /**
+ * Return true, if this splitting kernel is supposed to work in a
+ * strict large-N limit, i.e. replacing C_F by C_A/2
+ */
+ bool strictLargeN() const { return theStrictLargeN; }
+
+public:
+
+ /**
+ * Inform this splitting kernel, that it is being
+ * presampled until a call to stopPresampling
+ */
+ virtual void startPresampling(const DipoleIndex&) {}
+
+ /**
+ * Inform this splitting kernel, that it is not being
+ * presampled until a call to startPresampling
+ */
+ virtual void stopPresampling(const DipoleIndex&) {}
+
+ /**
+ * Return the number of points to presample this
+ * splitting generator.
+ */
+ unsigned long presamplingPoints() const { return thePresamplingPoints; }
+
+ /**
+ * Return the maximum number of trials
+ * to generate a splitting.
+ */
+ unsigned long maxtry() const { return theMaxtry; }
+
+ /**
+ * Evaluate this splitting kernel for the given
+ * dipole splitting.
+ */
+ virtual double evaluate(const DipoleSplittingInfo&) const = 0;
+
+ /**
+ * Return true, if this kernel is capable of
+ * delivering an overestimate to the kernel, and
+ * of inverting the integral over the overestimate
+ * w.r.t. the phasepsace provided by the given
+ * DipoleSplittingInfo object.
+ */
+ virtual bool haveOverestimate(const DipoleSplittingInfo&) const { return false; }
+
+ /**
+ * Return the overestimate to this splitting kernel
+ * for the given dipole splitting.
+ */
+ virtual double overestimate(const DipoleSplittingInfo&) const { return -1.; }
+
+ /**
+ * Invert the integral over the overestimate
+ * w.r.t. the phasepsace provided by the given
+ * DipoleSplittingInfo object to equal
+ * the given value.
+ */
+ virtual double invertOverestimateIntegral(const DipoleSplittingInfo&, double) const { return -1.; }
+
+public:
+
+ /**
+ * Get the factorization scale factor
+ */
+ double factorizationScaleFactor() const { return theFactorizationScaleFactor; }
+
+ /**
+ * Set the factorization scale factor
+ */
+ void factorizationScaleFactor(double f) { theFactorizationScaleFactor = f; }
+
+ /**
+ * Get the renormalization scale factor
+ */
+ double renormalizationScaleFactor() const { return theRenormalizationScaleFactor; }
+
+ /**
+ * Set the renormalization scale factor
+ */
+ void renormalizationScaleFactor(double f) { theRenormalizationScaleFactor = f; }
+
+protected:
+
+ /**
+ * Return the common factor of (alphas/2pi)*(pdf ratio)
+ */
+ double alphaPDF(const DipoleSplittingInfo&) const;
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+private:
+
+ /**
+ * The alpha_s to be used.
+ */
+ Ptr<AlphaSBase>::ptr theAlphaS;
+
+ /**
+ * An optional 'colour screening' scale
+ * for alternative intrinsic pt generation.
+ */
+ Energy theScreeningScale;
+
+ /**
+ * The splitting kinematics to be used.
+ */
+ Ptr<DipoleSplittingKinematics>::ptr theSplittingKinematics;
+
+ /**
+ * An optional PDF ratio object to be used
+ * when evaluating this kernel.
+ */
+ Ptr<PDFRatio>::ptr thePDFRatio;
+
+ /**
+ * The number of points to presample this
+ * splitting generator.
+ */
+ unsigned long thePresamplingPoints;
+
+ /**
+ * The maximum number of trials
+ * to generate a splitting.
+ */
+ unsigned long theMaxtry;
+
+ /**
+ * The flavour produced, if this cannot
+ * be determined from the dipole.
+ */
+ PDPtr theFlavour;
+
+ /**
+ * Pointer to a check histogram object
+ */
+ Ptr<DipoleMCCheck>::ptr theMCCheck;
+
+ /**
+ * True, if this splitting kernel is supposed to work in a
+ * strict large-N limit, i.e. replacing C_F by C_A/2
+ */
+ bool theStrictLargeN;
+
+ /**
+ * The factorization scale factor.
+ */
+ double theFactorizationScaleFactor;
+
+ /**
+ * The renormalization scale factor.
+ */
+ double theRenormalizationScaleFactor;
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is an abstract class with persistent data.
+ */
+ static AbstractClassDescription<DipoleSplittingKernel> initDipoleSplittingKernel;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ DipoleSplittingKernel & operator=(const DipoleSplittingKernel &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of DipoleSplittingKernel. */
+template <>
+struct BaseClassTrait<Herwig::DipoleSplittingKernel,1> {
+ /** Typedef of the first base class of DipoleSplittingKernel. */
+ typedef HandlerBase NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the DipoleSplittingKernel class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::DipoleSplittingKernel>
+ : public ClassTraitsBase<Herwig::DipoleSplittingKernel> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::DipoleSplittingKernel"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * DipoleSplittingKernel is implemented. It may also include several, space-separated,
+ * libraries if the class DipoleSplittingKernel depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_DipoleSplittingKernel_H */
diff --git a/DipoleShower/Kernels/FFMgx2ggxDipoleKernel.cc b/DipoleShower/Kernels/FFMgx2ggxDipoleKernel.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/FFMgx2ggxDipoleKernel.cc
@@ -0,0 +1,109 @@
+// -*- C++ -*-
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the FFMgx2ggxDipoleKernel class.
+//
+
+#include "FFMgx2ggxDipoleKernel.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+FFMgx2ggxDipoleKernel::FFMgx2ggxDipoleKernel()
+ : DipoleSplittingKernel() {}
+
+FFMgx2ggxDipoleKernel::~FFMgx2ggxDipoleKernel() {}
+
+IBPtr FFMgx2ggxDipoleKernel::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr FFMgx2ggxDipoleKernel::fullclone() const {
+ return new_ptr(*this);
+}
+
+bool FFMgx2ggxDipoleKernel::canHandle(const DipoleIndex& ind) const {
+ return
+ ind.emitterData()->id() == ParticleID::g &&
+ !ind.initialStateEmitter() && !ind.initialStateSpectator() &&
+ // massless quarks shall be treated by massless FFgx2ggxDipoleKernel
+ !( abs(ind.spectatorData()->id()) < 6 && ind.spectatorData()->mass() == ZERO );
+}
+
+bool FFMgx2ggxDipoleKernel::canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const {
+
+ assert(canHandle(a));
+
+ if ( !canHandle(b) )
+ return false;
+
+ return
+ sk.emitter(b)->id() == ParticleID::g &&
+ sk.emission(b)->id() == ParticleID::g &&
+ abs(spectator(a)->id()) == abs(sk.spectator(b)->id());
+
+}
+
+tcPDPtr FFMgx2ggxDipoleKernel::emitter(const DipoleIndex&) const {
+ return getParticleData(ParticleID::g);
+}
+
+tcPDPtr FFMgx2ggxDipoleKernel::emission(const DipoleIndex&) const {
+ return getParticleData(ParticleID::g);
+}
+
+tcPDPtr FFMgx2ggxDipoleKernel::spectator(const DipoleIndex& ind) const {
+ return ind.spectatorData();
+}
+
+double FFMgx2ggxDipoleKernel::evaluate(const DipoleSplittingInfo& split) const {
+
+ double ret = alphaPDF(split);
+
+ // masses
+ double muj2 = sqr( split.spectatorData()->mass() / split.scale() );
+
+ double z = split.lastZ();
+ double y = sqr(split.lastPt() / split.scale()) / (z*(1.-z)) / (1.-muj2);
+
+ double vijk = sqrt( sqr(2.*muj2+(1.-muj2)*(1.-y))-4.*muj2 ) / ((1.-muj2)*(1.-y));
+ double viji = 1.;
+
+ double zp = 0.5*(1.+viji*vijk);
+ double zm = 0.5*(1.-viji*vijk);
+
+ // free parameter of the subtraction scheme
+ double kappa = 0.;
+
+ ret *= 3.*(1./(1.-z*(1.-y))+1./(1.-(1.-z)*(1.-y)) + (z*(1.-z)-(1.-kappa)*zp*zm-2.)/vijk);
+
+ return ret > 0. ? ret : 0.;
+
+}
+
+// If needed, insert default implementations of function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void FFMgx2ggxDipoleKernel::persistentOutput(PersistentOStream & ) const {
+}
+
+void FFMgx2ggxDipoleKernel::persistentInput(PersistentIStream & , int) {
+}
+
+ClassDescription<FFMgx2ggxDipoleKernel> FFMgx2ggxDipoleKernel::initFFMgx2ggxDipoleKernel;
+// Definition of the static class description member.
+
+void FFMgx2ggxDipoleKernel::Init() {
+
+ static ClassDocumentation<FFMgx2ggxDipoleKernel> documentation
+ ("FFMgx2ggxDipoleKernel");
+
+}
+
diff --git a/DipoleShower/Kernels/FFMgx2ggxDipoleKernel.h b/DipoleShower/Kernels/FFMgx2ggxDipoleKernel.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/FFMgx2ggxDipoleKernel.h
@@ -0,0 +1,181 @@
+// -*- C++ -*-
+#ifndef HERWIG_FFMgx2ggxDipoleKernel_H
+#define HERWIG_FFMgx2ggxDipoleKernel_H
+//
+// This is the declaration of the FFMgx2ggxDipoleKernel class.
+//
+
+#include "DipoleSplittingKernel.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer and Martin Stoll
+ *
+ * \brief FFMgx2ggxDipoleKernel implements the g -> gg
+ * splitting off a final-final dipole
+ *
+ */
+class FFMgx2ggxDipoleKernel: public DipoleSplittingKernel {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ FFMgx2ggxDipoleKernel();
+
+ /**
+ * The destructor.
+ */
+ virtual ~FFMgx2ggxDipoleKernel();
+ //@}
+
+public:
+
+ /**
+ * Return true, if this splitting kernel
+ * applies to the given dipole index.
+ */
+ virtual bool canHandle(const DipoleIndex&) const;
+
+ /**
+ * Return true, if this splitting kernel is
+ * the same for the given index a, as the given
+ * splitting kernel for index b.
+ */
+ virtual bool canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const;
+
+ /**
+ * Return the emitter data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emitter(const DipoleIndex&) const;
+
+ /**
+ * Return the emission data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emission(const DipoleIndex&) const;
+
+ /**
+ * Return the spectator data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr spectator(const DipoleIndex&) const;
+
+ /**
+ * Evaluate this splitting kernel for the given
+ * dipole splitting.
+ */
+ virtual double evaluate(const DipoleSplittingInfo&) const;
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<FFMgx2ggxDipoleKernel> initFFMgx2ggxDipoleKernel;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ FFMgx2ggxDipoleKernel & operator=(const FFMgx2ggxDipoleKernel &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of FFMgx2ggxDipoleKernel. */
+template <>
+struct BaseClassTrait<Herwig::FFMgx2ggxDipoleKernel,1> {
+ /** Typedef of the first base class of FFMgx2ggxDipoleKernel. */
+ typedef Herwig::DipoleSplittingKernel NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the FFMgx2ggxDipoleKernel class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::FFMgx2ggxDipoleKernel>
+ : public ClassTraitsBase<Herwig::FFMgx2ggxDipoleKernel> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::FFMgx2ggxDipoleKernel"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * FFMgx2ggxDipoleKernel is implemented. It may also include several, space-separated,
+ * libraries if the class FFMgx2ggxDipoleKernel depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_FFMgx2ggxDipoleKernel_H */
diff --git a/DipoleShower/Kernels/FFMgx2qqxDipoleKernel.cc b/DipoleShower/Kernels/FFMgx2qqxDipoleKernel.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/FFMgx2qqxDipoleKernel.cc
@@ -0,0 +1,122 @@
+// -*- C++ -*-
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the FFMgx2qqxDipoleKernel class.
+//
+
+#include "FFMgx2qqxDipoleKernel.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+FFMgx2qqxDipoleKernel::FFMgx2qqxDipoleKernel()
+ : DipoleSplittingKernel() {}
+
+FFMgx2qqxDipoleKernel::~FFMgx2qqxDipoleKernel() {}
+
+IBPtr FFMgx2qqxDipoleKernel::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr FFMgx2qqxDipoleKernel::fullclone() const {
+ return new_ptr(*this);
+}
+
+/**
+ * TODO: only correct if either ALL quarks are massless or
+ * ALL quarks have masses >0.*GeV
+ */
+bool FFMgx2qqxDipoleKernel::canHandle(const DipoleIndex& ind) const {
+ return
+ ind.emitterData()->id() == ParticleID::g &&
+ !ind.initialStateEmitter() && !ind.initialStateSpectator() &&
+ // massless quarks shall be treated by massless FFgx2qqxDipoleKernel
+ !( abs(ind.spectatorData()->id()) < 6 && ind.spectatorData()->mass() == ZERO );
+}
+
+bool FFMgx2qqxDipoleKernel::canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const {
+ assert(canHandle(a));
+
+ if ( !canHandle(b) )
+ return false;
+
+ return
+ sk.emitter(b)->id() + sk.emission(b)->id() == 0 &&
+ abs(sk.emitter(b)->id()) < 6 &&
+ abs(sk.emitter(b)->id()) == abs(emitter(a)->id()) &&
+ abs(sk.spectator(b)->id()) == abs(spectator(a)->id());
+}
+
+tcPDPtr FFMgx2qqxDipoleKernel::emitter(const DipoleIndex&) const {
+ assert(flavour());
+ assert(abs(flavour()->id()) < 6);
+ return flavour();
+}
+
+tcPDPtr FFMgx2qqxDipoleKernel::emission(const DipoleIndex&) const {
+ assert(flavour());
+ assert(abs(flavour()->id()) < 6);
+ return flavour()->CC();
+}
+
+tcPDPtr FFMgx2qqxDipoleKernel::spectator(const DipoleIndex& ind) const {
+ return ind.spectatorData();
+}
+
+/*
+ * TODO: remove unnecessary if statement
+ */
+double FFMgx2qqxDipoleKernel::evaluate(const DipoleSplittingInfo& split) const {
+
+ double ret = alphaPDF(split);
+
+ // masses
+ double muQ2 = sqr( split.emitterData()->mass() / split.scale() );
+ double muj2 = sqr( split.spectatorData()->mass() / split.scale() );
+
+ double z = split.lastZ();
+ double y = ( sqr(split.lastPt()/split.scale()) + muQ2*(1.-2.*z+2.*z*z) ) /
+ (z*(1.-z)) / (1.-2.*muQ2-muj2);
+
+ double vijk = sqrt( sqr(2.*muj2+(1.-2.*muQ2-muj2)*(1.-y))-4.*muj2 ) / ((1.-2.*muQ2-muj2)*(1.-y));
+ double viji = sqrt( sqr((1.-2.*muQ2-muj2)*y)-4.*sqr(muQ2) ) / ((1.-2.*muQ2-muj2)*y+2.*muQ2);
+
+ double zp = 0.5*(1.+viji*vijk);
+ double zm = 0.5*(1.-viji*vijk);
+
+ // free parameter of the subtraction scheme
+ double kappa = 0.;
+
+ ret *= 0.5 / vijk *
+ ( 1. - 2.*( z*(1.-z) - (1.-kappa)*zp*zm - kappa*muQ2/(2*muQ2+(1.-2*muQ2-muj2)*y) ) );
+
+ return ret > 0. ? ret : 0.;
+
+}
+
+// If needed, insert default implementations of function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void FFMgx2qqxDipoleKernel::persistentOutput(PersistentOStream & ) const {
+}
+
+void FFMgx2qqxDipoleKernel::persistentInput(PersistentIStream & , int) {
+}
+
+ClassDescription<FFMgx2qqxDipoleKernel> FFMgx2qqxDipoleKernel::initFFMgx2qqxDipoleKernel;
+// Definition of the static class description member.
+
+void FFMgx2qqxDipoleKernel::Init() {
+
+ static ClassDocumentation<FFMgx2qqxDipoleKernel> documentation
+ ("FFMgx2qqxDipoleKernel");
+
+}
+
diff --git a/DipoleShower/Kernels/FFMgx2qqxDipoleKernel.h b/DipoleShower/Kernels/FFMgx2qqxDipoleKernel.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/FFMgx2qqxDipoleKernel.h
@@ -0,0 +1,181 @@
+// -*- C++ -*-
+#ifndef HERWIG_FFMgx2qqxDipoleKernel_H
+#define HERWIG_FFMgx2qqxDipoleKernel_H
+//
+// This is the declaration of the FFMgx2qqxDipoleKernel class.
+//
+
+#include "DipoleSplittingKernel.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer and Martin Stoll
+ *
+ * \brief FFMgx2qqxDipoleKernel implements the g -> qqbar
+ * splitting off a final-final dipole
+ *
+ */
+class FFMgx2qqxDipoleKernel: public DipoleSplittingKernel {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ FFMgx2qqxDipoleKernel();
+
+ /**
+ * The destructor.
+ */
+ virtual ~FFMgx2qqxDipoleKernel();
+ //@}
+
+public:
+
+ /**
+ * Return true, if this splitting kernel
+ * applies to the given dipole index.
+ */
+ virtual bool canHandle(const DipoleIndex&) const;
+
+ /**
+ * Return true, if this splitting kernel is
+ * the same for the given index a, as the given
+ * splitting kernel for index b.
+ */
+ virtual bool canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const;
+
+ /**
+ * Return the emitter data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emitter(const DipoleIndex&) const;
+
+ /**
+ * Return the emission data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emission(const DipoleIndex&) const;
+
+ /**
+ * Return the spectator data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr spectator(const DipoleIndex&) const;
+
+ /**
+ * Evaluate this splitting kernel for the given
+ * dipole splitting.
+ */
+ virtual double evaluate(const DipoleSplittingInfo&) const;
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<FFMgx2qqxDipoleKernel> initFFMgx2qqxDipoleKernel;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ FFMgx2qqxDipoleKernel & operator=(const FFMgx2qqxDipoleKernel &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of FFMgx2qqxDipoleKernel. */
+template <>
+struct BaseClassTrait<Herwig::FFMgx2qqxDipoleKernel,1> {
+ /** Typedef of the first base class of FFMgx2qqxDipoleKernel. */
+ typedef Herwig::DipoleSplittingKernel NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the FFMgx2qqxDipoleKernel class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::FFMgx2qqxDipoleKernel>
+ : public ClassTraitsBase<Herwig::FFMgx2qqxDipoleKernel> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::FFMgx2qqxDipoleKernel"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * FFMgx2qqxDipoleKernel is implemented. It may also include several, space-separated,
+ * libraries if the class FFMgx2qqxDipoleKernel depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_FFMgx2qqxDipoleKernel_H */
diff --git a/DipoleShower/Kernels/FFMqx2qgxDipoleKernel.cc b/DipoleShower/Kernels/FFMqx2qgxDipoleKernel.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/FFMqx2qgxDipoleKernel.cc
@@ -0,0 +1,107 @@
+// -*- C++ -*-
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the FFMqx2qgxDipoleKernel class.
+//
+
+#include "FFMqx2qgxDipoleKernel.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+FFMqx2qgxDipoleKernel::FFMqx2qgxDipoleKernel()
+ : DipoleSplittingKernel() {}
+
+FFMqx2qgxDipoleKernel::~FFMqx2qgxDipoleKernel() {}
+
+IBPtr FFMqx2qgxDipoleKernel::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr FFMqx2qgxDipoleKernel::fullclone() const {
+ return new_ptr(*this);
+}
+
+bool FFMqx2qgxDipoleKernel::canHandle(const DipoleIndex& ind) const {
+ return
+ abs(ind.emitterData()->id()) < 6 &&
+ !ind.initialStateEmitter() && !ind.initialStateSpectator() &&
+ // massless quarks shall be treated by massless FFqx2qgxDipoleKernel
+ !( /*abs(ind.emitterData()->id()) < 6 &&*/ ind.emitterData()->mass() == ZERO ) &&
+ !( abs(ind.spectatorData()->id()) < 6 && ind.spectatorData()->mass() == ZERO );
+}
+
+bool FFMqx2qgxDipoleKernel::canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const {
+
+ assert(canHandle(a));
+
+ if ( !canHandle(b) )
+ return false;
+
+ return
+ sk.emission(b)->id() == ParticleID::g &&
+ abs(sk.emitter(b)->id()) < 6 &&
+ abs(sk.emitter(b)->id()) == abs(emitter(a)->id()) &&
+ abs(sk.spectator(b)->id()) == abs(spectator(a)->id());
+
+}
+
+tcPDPtr FFMqx2qgxDipoleKernel::emitter(const DipoleIndex& ind) const {
+ return ind.emitterData();
+}
+
+tcPDPtr FFMqx2qgxDipoleKernel::emission(const DipoleIndex&) const {
+ return getParticleData(ParticleID::g);
+}
+
+tcPDPtr FFMqx2qgxDipoleKernel::spectator(const DipoleIndex& ind) const {
+ return ind.spectatorData();
+}
+
+double FFMqx2qgxDipoleKernel::evaluate(const DipoleSplittingInfo& split) const {
+
+ double ret = alphaPDF(split);
+
+ // masses
+ double muQ2 = sqr( split.emitterData()->mass() / split.scale() );
+ double muj2 = sqr( split.spectatorData()->mass() / split.scale() );
+
+ double z = split.lastZ();
+ double y = ( sqr(split.lastPt()/split.scale()) + muQ2*sqr(1.-z) ) /
+ (z*(1.-z)) / (1.-muQ2-muj2);
+
+ double vijk = sqrt( sqr(2.*muj2+(1.-muQ2-muj2)*(1.-y))-4.*muj2 ) / ((1.-muQ2-muj2)*(1.-y));
+ double vbar = sqrt( 1.+sqr(muQ2)+sqr(muj2)-2.*(muQ2+muj2+muQ2*muj2) ) / (1.-muQ2-muj2);
+
+ ret *= (4./3.)*( 2./(1.-z*(1.-y)) - vbar/vijk*( 1.+z + muQ2*2./(y*(1.-muQ2-muj2)) ) );
+
+ return ret > 0. ? ret : 0.;
+
+}
+
+// If needed, insert default implementations of function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void FFMqx2qgxDipoleKernel::persistentOutput(PersistentOStream & ) const {
+}
+
+void FFMqx2qgxDipoleKernel::persistentInput(PersistentIStream & , int) {
+}
+
+ClassDescription<FFMqx2qgxDipoleKernel> FFMqx2qgxDipoleKernel::initFFMqx2qgxDipoleKernel;
+// Definition of the static class description member.
+
+void FFMqx2qgxDipoleKernel::Init() {
+
+ static ClassDocumentation<FFMqx2qgxDipoleKernel> documentation
+ ("FFMqx2qgxDipoleKernel");
+
+}
+
diff --git a/DipoleShower/Kernels/FFMqx2qgxDipoleKernel.h b/DipoleShower/Kernels/FFMqx2qgxDipoleKernel.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/FFMqx2qgxDipoleKernel.h
@@ -0,0 +1,181 @@
+// -*- C++ -*-
+#ifndef HERWIG_FFMqx2qgxDipoleKernel_H
+#define HERWIG_FFMqx2qgxDipoleKernel_H
+//
+// This is the declaration of the FFMqx2qgxDipoleKernel class.
+//
+
+#include "DipoleSplittingKernel.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer and Martin Stoll
+ *
+ * \brief FFMqx2qgxDipoleKernel implements the q -> qg
+ * splitting off a final-final dipole
+ *
+ */
+class FFMqx2qgxDipoleKernel: public DipoleSplittingKernel {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ FFMqx2qgxDipoleKernel();
+
+ /**
+ * The destructor.
+ */
+ virtual ~FFMqx2qgxDipoleKernel();
+ //@}
+
+public:
+
+ /**
+ * Return true, if this splitting kernel
+ * applies to the given dipole index.
+ */
+ virtual bool canHandle(const DipoleIndex&) const;
+
+ /**
+ * Return true, if this splitting kernel is
+ * the same for the given index a, as the given
+ * splitting kernel for index b.
+ */
+ virtual bool canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const;
+
+ /**
+ * Return the emitter data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emitter(const DipoleIndex&) const;
+
+ /**
+ * Return the emission data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emission(const DipoleIndex&) const;
+
+ /**
+ * Return the spectator data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr spectator(const DipoleIndex&) const;
+
+ /**
+ * Evaluate this splitting kernel for the given
+ * dipole splitting.
+ */
+ virtual double evaluate(const DipoleSplittingInfo&) const;
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<FFMqx2qgxDipoleKernel> initFFMqx2qgxDipoleKernel;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ FFMqx2qgxDipoleKernel & operator=(const FFMqx2qgxDipoleKernel &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of FFMqx2qgxDipoleKernel. */
+template <>
+struct BaseClassTrait<Herwig::FFMqx2qgxDipoleKernel,1> {
+ /** Typedef of the first base class of FFMqx2qgxDipoleKernel. */
+ typedef Herwig::DipoleSplittingKernel NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the FFMqx2qgxDipoleKernel class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::FFMqx2qgxDipoleKernel>
+ : public ClassTraitsBase<Herwig::FFMqx2qgxDipoleKernel> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::FFMqx2qgxDipoleKernel"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * FFMqx2qgxDipoleKernel is implemented. It may also include several, space-separated,
+ * libraries if the class FFMqx2qgxDipoleKernel depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_FFMqx2qgxDipoleKernel_H */
diff --git a/DipoleShower/Kernels/FFgx2ggxDipoleKernel.cc b/DipoleShower/Kernels/FFgx2ggxDipoleKernel.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/FFgx2ggxDipoleKernel.cc
@@ -0,0 +1,96 @@
+// -*- C++ -*-
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the FFgx2ggxDipoleKernel class.
+//
+
+#include "FFgx2ggxDipoleKernel.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+FFgx2ggxDipoleKernel::FFgx2ggxDipoleKernel()
+ : DipoleSplittingKernel() {}
+
+FFgx2ggxDipoleKernel::~FFgx2ggxDipoleKernel() {}
+
+IBPtr FFgx2ggxDipoleKernel::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr FFgx2ggxDipoleKernel::fullclone() const {
+ return new_ptr(*this);
+}
+
+bool FFgx2ggxDipoleKernel::canHandle(const DipoleIndex& ind) const {
+ return
+ ind.emitterData()->id() == ParticleID::g &&
+ ind.spectatorData()->mass() == ZERO &&
+ !ind.initialStateEmitter() && !ind.initialStateSpectator();
+}
+
+bool FFgx2ggxDipoleKernel::canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const {
+
+ assert(canHandle(a));
+
+ if ( !canHandle(b) )
+ return false;
+
+ return
+ sk.emitter(b)->id() == ParticleID::g &&
+ sk.emission(b)->id() == ParticleID::g;
+
+
+}
+
+tcPDPtr FFgx2ggxDipoleKernel::emitter(const DipoleIndex&) const {
+ return getParticleData(ParticleID::g);
+}
+
+tcPDPtr FFgx2ggxDipoleKernel::emission(const DipoleIndex&) const {
+ return getParticleData(ParticleID::g);
+}
+
+tcPDPtr FFgx2ggxDipoleKernel::spectator(const DipoleIndex& ind) const {
+ return ind.spectatorData();
+}
+
+double FFgx2ggxDipoleKernel::evaluate(const DipoleSplittingInfo& split) const {
+
+ double ret = alphaPDF(split);
+
+ double z = split.lastZ();
+ double y = sqr(split.lastPt() / split.scale()) / (z*(1.-z));
+
+ ret *= 3.*(1./(1.-z*(1.-y))+1./(1.-(1.-z)*(1.-y))-2.+z*(1.-z));
+
+ return ret;
+
+}
+
+// If needed, insert default implementations of function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void FFgx2ggxDipoleKernel::persistentOutput(PersistentOStream & ) const {
+}
+
+void FFgx2ggxDipoleKernel::persistentInput(PersistentIStream & , int) {
+}
+
+ClassDescription<FFgx2ggxDipoleKernel> FFgx2ggxDipoleKernel::initFFgx2ggxDipoleKernel;
+// Definition of the static class description member.
+
+void FFgx2ggxDipoleKernel::Init() {
+
+ static ClassDocumentation<FFgx2ggxDipoleKernel> documentation
+ ("FFgx2ggxDipoleKernel");
+
+}
+
diff --git a/DipoleShower/Kernels/FFgx2ggxDipoleKernel.h b/DipoleShower/Kernels/FFgx2ggxDipoleKernel.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/FFgx2ggxDipoleKernel.h
@@ -0,0 +1,181 @@
+// -*- C++ -*-
+#ifndef HERWIG_FFgx2ggxDipoleKernel_H
+#define HERWIG_FFgx2ggxDipoleKernel_H
+//
+// This is the declaration of the FFgx2ggxDipoleKernel class.
+//
+
+#include "DipoleSplittingKernel.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief FFgx2ggxDipoleKernel implements the g -> gg
+ * splitting off a final-final dipole
+ *
+ */
+class FFgx2ggxDipoleKernel: public DipoleSplittingKernel {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ FFgx2ggxDipoleKernel();
+
+ /**
+ * The destructor.
+ */
+ virtual ~FFgx2ggxDipoleKernel();
+ //@}
+
+public:
+
+ /**
+ * Return true, if this splitting kernel
+ * applies to the given dipole index.
+ */
+ virtual bool canHandle(const DipoleIndex&) const;
+
+ /**
+ * Return true, if this splitting kernel is
+ * the same for the given index a, as the given
+ * splitting kernel for index b.
+ */
+ virtual bool canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const;
+
+ /**
+ * Return the emitter data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emitter(const DipoleIndex&) const;
+
+ /**
+ * Return the emission data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emission(const DipoleIndex&) const;
+
+ /**
+ * Return the spectator data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr spectator(const DipoleIndex&) const;
+
+ /**
+ * Evaluate this splitting kernel for the given
+ * dipole splitting.
+ */
+ virtual double evaluate(const DipoleSplittingInfo&) const;
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<FFgx2ggxDipoleKernel> initFFgx2ggxDipoleKernel;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ FFgx2ggxDipoleKernel & operator=(const FFgx2ggxDipoleKernel &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of FFgx2ggxDipoleKernel. */
+template <>
+struct BaseClassTrait<Herwig::FFgx2ggxDipoleKernel,1> {
+ /** Typedef of the first base class of FFgx2ggxDipoleKernel. */
+ typedef Herwig::DipoleSplittingKernel NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the FFgx2ggxDipoleKernel class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::FFgx2ggxDipoleKernel>
+ : public ClassTraitsBase<Herwig::FFgx2ggxDipoleKernel> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::FFgx2ggxDipoleKernel"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * FFgx2ggxDipoleKernel is implemented. It may also include several, space-separated,
+ * libraries if the class FFgx2ggxDipoleKernel depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_FFgx2ggxDipoleKernel_H */
diff --git a/DipoleShower/Kernels/FFgx2qqxDipoleKernel.cc b/DipoleShower/Kernels/FFgx2qqxDipoleKernel.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/FFgx2qqxDipoleKernel.cc
@@ -0,0 +1,100 @@
+// -*- C++ -*-
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the FFgx2qqxDipoleKernel class.
+//
+
+#include "FFgx2qqxDipoleKernel.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+FFgx2qqxDipoleKernel::FFgx2qqxDipoleKernel()
+ : DipoleSplittingKernel() {}
+
+FFgx2qqxDipoleKernel::~FFgx2qqxDipoleKernel() {}
+
+IBPtr FFgx2qqxDipoleKernel::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr FFgx2qqxDipoleKernel::fullclone() const {
+ return new_ptr(*this);
+}
+
+bool FFgx2qqxDipoleKernel::canHandle(const DipoleIndex& ind) const {
+ return
+ ind.emitterData()->id() == ParticleID::g &&
+ ind.spectatorData()->mass() == ZERO &&
+ !ind.initialStateEmitter() && !ind.initialStateSpectator();
+}
+
+bool FFgx2qqxDipoleKernel::canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const {
+
+ assert(canHandle(a));
+
+ if ( !canHandle(b) )
+ return false;
+
+ return
+ sk.emitter(b)->id() + sk.emission(b)->id() == 0 &&
+ abs(sk.emitter(b)->id()) < 6 &&
+ sk.emitter(b)->mass() == ZERO;
+
+}
+
+
+tcPDPtr FFgx2qqxDipoleKernel::emitter(const DipoleIndex&) const {
+ assert(flavour());
+ assert(abs(flavour()->id()) < 6 && flavour()->mass() == ZERO);
+ return flavour();
+}
+
+tcPDPtr FFgx2qqxDipoleKernel::emission(const DipoleIndex&) const {
+ assert(flavour());
+ assert(abs(flavour()->id()) < 6 && flavour()->mass() == ZERO);
+ return flavour()->CC();
+}
+
+tcPDPtr FFgx2qqxDipoleKernel::spectator(const DipoleIndex& ind) const {
+ return ind.spectatorData();
+}
+
+double FFgx2qqxDipoleKernel::evaluate(const DipoleSplittingInfo& split) const {
+
+ double ret = alphaPDF(split);
+
+ double z = split.lastZ();
+
+ ret *= .5 * ( 1. - 2.*z*(1.-z) );
+
+ return ret;
+
+}
+
+// If needed, insert default implementations of function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void FFgx2qqxDipoleKernel::persistentOutput(PersistentOStream & ) const {
+}
+
+void FFgx2qqxDipoleKernel::persistentInput(PersistentIStream & , int) {
+}
+
+ClassDescription<FFgx2qqxDipoleKernel> FFgx2qqxDipoleKernel::initFFgx2qqxDipoleKernel;
+// Definition of the static class description member.
+
+void FFgx2qqxDipoleKernel::Init() {
+
+ static ClassDocumentation<FFgx2qqxDipoleKernel> documentation
+ ("FFgx2qqxDipoleKernel");
+
+}
+
diff --git a/DipoleShower/Kernels/FFgx2qqxDipoleKernel.h b/DipoleShower/Kernels/FFgx2qqxDipoleKernel.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/FFgx2qqxDipoleKernel.h
@@ -0,0 +1,181 @@
+// -*- C++ -*-
+#ifndef HERWIG_FFgx2qqxDipoleKernel_H
+#define HERWIG_FFgx2qqxDipoleKernel_H
+//
+// This is the declaration of the FFgx2qqxDipoleKernel class.
+//
+
+#include "DipoleSplittingKernel.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief FFgx2qqxDipoleKernel implements the g -> qqbar
+ * splitting off a final-final dipole
+ *
+ */
+class FFgx2qqxDipoleKernel: public DipoleSplittingKernel {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ FFgx2qqxDipoleKernel();
+
+ /**
+ * The destructor.
+ */
+ virtual ~FFgx2qqxDipoleKernel();
+ //@}
+
+public:
+
+ /**
+ * Return true, if this splitting kernel
+ * applies to the given dipole index.
+ */
+ virtual bool canHandle(const DipoleIndex&) const;
+
+ /**
+ * Return true, if this splitting kernel is
+ * the same for the given index a, as the given
+ * splitting kernel for index b.
+ */
+ virtual bool canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const;
+
+ /**
+ * Return the emitter data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emitter(const DipoleIndex&) const;
+
+ /**
+ * Return the emission data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emission(const DipoleIndex&) const;
+
+ /**
+ * Return the spectator data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr spectator(const DipoleIndex&) const;
+
+ /**
+ * Evaluate this splitting kernel for the given
+ * dipole splitting.
+ */
+ virtual double evaluate(const DipoleSplittingInfo&) const;
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<FFgx2qqxDipoleKernel> initFFgx2qqxDipoleKernel;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ FFgx2qqxDipoleKernel & operator=(const FFgx2qqxDipoleKernel &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of FFgx2qqxDipoleKernel. */
+template <>
+struct BaseClassTrait<Herwig::FFgx2qqxDipoleKernel,1> {
+ /** Typedef of the first base class of FFgx2qqxDipoleKernel. */
+ typedef Herwig::DipoleSplittingKernel NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the FFgx2qqxDipoleKernel class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::FFgx2qqxDipoleKernel>
+ : public ClassTraitsBase<Herwig::FFgx2qqxDipoleKernel> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::FFgx2qqxDipoleKernel"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * FFgx2qqxDipoleKernel is implemented. It may also include several, space-separated,
+ * libraries if the class FFgx2qqxDipoleKernel depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_FFgx2qqxDipoleKernel_H */
diff --git a/DipoleShower/Kernels/FFqx2qgxDipoleKernel.cc b/DipoleShower/Kernels/FFqx2qgxDipoleKernel.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/FFqx2qgxDipoleKernel.cc
@@ -0,0 +1,98 @@
+// -*- C++ -*-
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the FFqx2qgxDipoleKernel class.
+//
+
+#include "FFqx2qgxDipoleKernel.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+FFqx2qgxDipoleKernel::FFqx2qgxDipoleKernel()
+ : DipoleSplittingKernel() {}
+
+FFqx2qgxDipoleKernel::~FFqx2qgxDipoleKernel() {}
+
+IBPtr FFqx2qgxDipoleKernel::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr FFqx2qgxDipoleKernel::fullclone() const {
+ return new_ptr(*this);
+}
+
+bool FFqx2qgxDipoleKernel::canHandle(const DipoleIndex& ind) const {
+ return
+ abs(ind.emitterData()->id()) < 6 &&
+ ind.emitterData()->mass() == ZERO &&
+ ind.spectatorData()->mass() == ZERO &&
+ !ind.initialStateEmitter() && !ind.initialStateSpectator();
+}
+
+bool FFqx2qgxDipoleKernel::canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const {
+
+ assert(canHandle(a));
+
+ if ( !canHandle(b) )
+ return false;
+
+ return
+ sk.emission(b)->id() == ParticleID::g &&
+ abs(sk.emitter(b)->id()) < 6 &&
+ sk.emitter(b)->mass() == ZERO;
+
+
+}
+
+tcPDPtr FFqx2qgxDipoleKernel::emitter(const DipoleIndex& ind) const {
+ return ind.emitterData();
+}
+
+tcPDPtr FFqx2qgxDipoleKernel::emission(const DipoleIndex&) const {
+ return getParticleData(ParticleID::g);
+}
+
+tcPDPtr FFqx2qgxDipoleKernel::spectator(const DipoleIndex& ind) const {
+ return ind.spectatorData();
+}
+
+double FFqx2qgxDipoleKernel::evaluate(const DipoleSplittingInfo& split) const {
+
+ double ret = alphaPDF(split);
+
+ double z = split.lastZ();
+ double y = sqr(split.lastPt() / split.scale()) / (z*(1.-z));
+
+ ret *= (!strictLargeN() ? 4./3. : 3./2.)*( 2./(1.-z*(1.-y)) - (1.+z) );
+
+ return ret;
+
+}
+
+// If needed, insert default implementations of function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void FFqx2qgxDipoleKernel::persistentOutput(PersistentOStream & ) const {
+}
+
+void FFqx2qgxDipoleKernel::persistentInput(PersistentIStream & , int) {
+}
+
+ClassDescription<FFqx2qgxDipoleKernel> FFqx2qgxDipoleKernel::initFFqx2qgxDipoleKernel;
+// Definition of the static class description member.
+
+void FFqx2qgxDipoleKernel::Init() {
+
+ static ClassDocumentation<FFqx2qgxDipoleKernel> documentation
+ ("FFqx2qgxDipoleKernel");
+
+}
+
diff --git a/DipoleShower/Kernels/FFqx2qgxDipoleKernel.h b/DipoleShower/Kernels/FFqx2qgxDipoleKernel.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/FFqx2qgxDipoleKernel.h
@@ -0,0 +1,181 @@
+// -*- C++ -*-
+#ifndef HERWIG_FFqx2qgxDipoleKernel_H
+#define HERWIG_FFqx2qgxDipoleKernel_H
+//
+// This is the declaration of the FFqx2qgxDipoleKernel class.
+//
+
+#include "DipoleSplittingKernel.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief FFqx2qgxDipoleKernel implements the q -> qg
+ * splitting off a final-final dipole
+ *
+ */
+class FFqx2qgxDipoleKernel: public DipoleSplittingKernel {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ FFqx2qgxDipoleKernel();
+
+ /**
+ * The destructor.
+ */
+ virtual ~FFqx2qgxDipoleKernel();
+ //@}
+
+public:
+
+ /**
+ * Return true, if this splitting kernel
+ * applies to the given dipole index.
+ */
+ virtual bool canHandle(const DipoleIndex&) const;
+
+ /**
+ * Return true, if this splitting kernel is
+ * the same for the given index a, as the given
+ * splitting kernel for index b.
+ */
+ virtual bool canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const;
+
+ /**
+ * Return the emitter data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emitter(const DipoleIndex&) const;
+
+ /**
+ * Return the emission data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emission(const DipoleIndex&) const;
+
+ /**
+ * Return the spectator data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr spectator(const DipoleIndex&) const;
+
+ /**
+ * Evaluate this splitting kernel for the given
+ * dipole splitting.
+ */
+ virtual double evaluate(const DipoleSplittingInfo&) const;
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<FFqx2qgxDipoleKernel> initFFqx2qgxDipoleKernel;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ FFqx2qgxDipoleKernel & operator=(const FFqx2qgxDipoleKernel &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of FFqx2qgxDipoleKernel. */
+template <>
+struct BaseClassTrait<Herwig::FFqx2qgxDipoleKernel,1> {
+ /** Typedef of the first base class of FFqx2qgxDipoleKernel. */
+ typedef Herwig::DipoleSplittingKernel NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the FFqx2qgxDipoleKernel class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::FFqx2qgxDipoleKernel>
+ : public ClassTraitsBase<Herwig::FFqx2qgxDipoleKernel> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::FFqx2qgxDipoleKernel"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * FFqx2qgxDipoleKernel is implemented. It may also include several, space-separated,
+ * libraries if the class FFqx2qgxDipoleKernel depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_FFqx2qgxDipoleKernel_H */
diff --git a/DipoleShower/Kernels/FIgx2ggxDipoleKernel.cc b/DipoleShower/Kernels/FIgx2ggxDipoleKernel.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/FIgx2ggxDipoleKernel.cc
@@ -0,0 +1,100 @@
+// -*- C++ -*-
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the FIgx2ggxDipoleKernel class.
+//
+
+#include "FIgx2ggxDipoleKernel.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+FIgx2ggxDipoleKernel::FIgx2ggxDipoleKernel()
+ : DipoleSplittingKernel() {}
+
+FIgx2ggxDipoleKernel::~FIgx2ggxDipoleKernel() {}
+
+IBPtr FIgx2ggxDipoleKernel::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr FIgx2ggxDipoleKernel::fullclone() const {
+ return new_ptr(*this);
+}
+
+bool FIgx2ggxDipoleKernel::canHandle(const DipoleIndex& ind) const {
+ return
+ ind.emitterData()->id() == ParticleID::g &&
+ ind.spectatorData()->mass() == ZERO &&
+ !ind.initialStateEmitter() && ind.initialStateSpectator();
+}
+
+bool FIgx2ggxDipoleKernel::canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const {
+
+ assert(canHandle(a));
+
+ if ( !canHandle(b) )
+ return false;
+
+ return
+ sk.emitter(b)->id() == ParticleID::g &&
+ sk.emission(b)->id() == ParticleID::g &&
+ a.spectatorPDF() == b.spectatorPDF();
+
+}
+
+tcPDPtr FIgx2ggxDipoleKernel::emitter(const DipoleIndex&) const {
+ return getParticleData(ParticleID::g);
+}
+
+tcPDPtr FIgx2ggxDipoleKernel::emission(const DipoleIndex&) const {
+ return getParticleData(ParticleID::g);
+}
+
+tcPDPtr FIgx2ggxDipoleKernel::spectator(const DipoleIndex& ind) const {
+ return ind.spectatorData();
+}
+
+double FIgx2ggxDipoleKernel::evaluate(const DipoleSplittingInfo& split) const {
+
+ double ret = alphaPDF(split);
+
+ double z = split.lastZ();
+ double x = 1. / ( 1. + sqr(split.lastPt()/split.scale()) / (z*(1.-z)) );
+
+ //double rhom = 2.*((2.+z-x)/z);
+ //double rhop = 2.*((2.+(1.-z)-x)/(1.-z));
+ //ret *= 3. * ( 1./(1.-z+(1.-x)) + 1./(z+(1.-x)) - 2.+z*(1.-z) +(1.-x)*(1./rhom + 1./rhop) );
+
+ ret *= 3. * ( 1./(1.-z+(1.-x)) + 1./(z+(1.-x)) - 2.+z*(1.-z) );
+
+ return ret;
+
+}
+
+// If needed, insert default implementations of function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void FIgx2ggxDipoleKernel::persistentOutput(PersistentOStream & ) const {
+}
+
+void FIgx2ggxDipoleKernel::persistentInput(PersistentIStream & , int) {
+}
+
+ClassDescription<FIgx2ggxDipoleKernel> FIgx2ggxDipoleKernel::initFIgx2ggxDipoleKernel;
+// Definition of the static class description member.
+
+void FIgx2ggxDipoleKernel::Init() {
+
+ static ClassDocumentation<FIgx2ggxDipoleKernel> documentation
+ ("FIgx2ggxDipoleKernel");
+
+}
+
diff --git a/DipoleShower/Kernels/FIgx2ggxDipoleKernel.h b/DipoleShower/Kernels/FIgx2ggxDipoleKernel.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/FIgx2ggxDipoleKernel.h
@@ -0,0 +1,181 @@
+// -*- C++ -*-
+#ifndef HERWIG_FIgx2ggxDipoleKernel_H
+#define HERWIG_FIgx2ggxDipoleKernel_H
+//
+// This is the declaration of the FIgx2ggxDipoleKernel class.
+//
+
+#include "DipoleSplittingKernel.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief FIgx2ggxDipoleKernel implements the g -> gg
+ * splitting off a final-initial dipole
+ *
+ */
+class FIgx2ggxDipoleKernel: public DipoleSplittingKernel {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ FIgx2ggxDipoleKernel();
+
+ /**
+ * The destructor.
+ */
+ virtual ~FIgx2ggxDipoleKernel();
+ //@}
+
+public:
+
+ /**
+ * Return true, if this splitting kernel
+ * applies to the given dipole index.
+ */
+ virtual bool canHandle(const DipoleIndex&) const;
+
+ /**
+ * Return true, if this splitting kernel is
+ * the same for the given index a, as the given
+ * splitting kernel for index b.
+ */
+ virtual bool canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const;
+
+ /**
+ * Return the emitter data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emitter(const DipoleIndex&) const;
+
+ /**
+ * Return the emission data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emission(const DipoleIndex&) const;
+
+ /**
+ * Return the spectator data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr spectator(const DipoleIndex&) const;
+
+ /**
+ * Evaluate this splitting kernel for the given
+ * dipole splitting.
+ */
+ virtual double evaluate(const DipoleSplittingInfo&) const;
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<FIgx2ggxDipoleKernel> initFIgx2ggxDipoleKernel;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ FIgx2ggxDipoleKernel & operator=(const FIgx2ggxDipoleKernel &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of FIgx2ggxDipoleKernel. */
+template <>
+struct BaseClassTrait<Herwig::FIgx2ggxDipoleKernel,1> {
+ /** Typedef of the first base class of FIgx2ggxDipoleKernel. */
+ typedef Herwig::DipoleSplittingKernel NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the FIgx2ggxDipoleKernel class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::FIgx2ggxDipoleKernel>
+ : public ClassTraitsBase<Herwig::FIgx2ggxDipoleKernel> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::FIgx2ggxDipoleKernel"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * FIgx2ggxDipoleKernel is implemented. It may also include several, space-separated,
+ * libraries if the class FIgx2ggxDipoleKernel depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_FIgx2ggxDipoleKernel_H */
diff --git a/DipoleShower/Kernels/FIgx2qqxDipoleKernel.cc b/DipoleShower/Kernels/FIgx2qqxDipoleKernel.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/FIgx2qqxDipoleKernel.cc
@@ -0,0 +1,101 @@
+// -*- C++ -*-
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the FIgx2qqxDipoleKernel class.
+//
+
+#include "FIgx2qqxDipoleKernel.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+FIgx2qqxDipoleKernel::FIgx2qqxDipoleKernel()
+ : DipoleSplittingKernel() {}
+
+FIgx2qqxDipoleKernel::~FIgx2qqxDipoleKernel() {}
+
+IBPtr FIgx2qqxDipoleKernel::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr FIgx2qqxDipoleKernel::fullclone() const {
+ return new_ptr(*this);
+}
+
+bool FIgx2qqxDipoleKernel::canHandle(const DipoleIndex& ind) const {
+ return
+ ind.emitterData()->id() == ParticleID::g &&
+ ind.spectatorData()->mass() == ZERO &&
+ !ind.initialStateEmitter() && ind.initialStateSpectator();
+}
+
+bool FIgx2qqxDipoleKernel::canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const {
+
+ assert(canHandle(a));
+
+ if ( !canHandle(b) )
+ return false;
+
+ return
+ sk.emitter(b)->id() + sk.emission(b)->id() == 0 &&
+ abs(sk.emitter(b)->id()) < 6 &&
+ sk.emitter(b)->mass() == ZERO &&
+ a.spectatorPDF() == b.spectatorPDF();
+
+}
+
+
+tcPDPtr FIgx2qqxDipoleKernel::emitter(const DipoleIndex&) const {
+ assert(flavour());
+ assert(abs(flavour()->id()) < 6 && flavour()->mass() == ZERO);
+ return flavour();
+}
+
+tcPDPtr FIgx2qqxDipoleKernel::emission(const DipoleIndex&) const {
+ assert(flavour());
+ assert(abs(flavour()->id()) < 6 && flavour()->mass() == ZERO);
+ return flavour()->CC();
+}
+
+tcPDPtr FIgx2qqxDipoleKernel::spectator(const DipoleIndex& ind) const {
+ return ind.spectatorData();
+}
+
+double FIgx2qqxDipoleKernel::evaluate(const DipoleSplittingInfo& split) const {
+
+ double ret = alphaPDF(split);
+
+ double z = split.lastZ();
+
+ ret *= .5 * (1.-z*(1.-z));
+
+ return ret;
+
+}
+
+// If needed, insert default implementations of function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void FIgx2qqxDipoleKernel::persistentOutput(PersistentOStream & ) const {
+}
+
+void FIgx2qqxDipoleKernel::persistentInput(PersistentIStream & , int) {
+}
+
+ClassDescription<FIgx2qqxDipoleKernel> FIgx2qqxDipoleKernel::initFIgx2qqxDipoleKernel;
+// Definition of the static class description member.
+
+void FIgx2qqxDipoleKernel::Init() {
+
+ static ClassDocumentation<FIgx2qqxDipoleKernel> documentation
+ ("FIgx2qqxDipoleKernel");
+
+}
+
diff --git a/DipoleShower/Kernels/FIgx2qqxDipoleKernel.h b/DipoleShower/Kernels/FIgx2qqxDipoleKernel.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/FIgx2qqxDipoleKernel.h
@@ -0,0 +1,181 @@
+// -*- C++ -*-
+#ifndef HERWIG_FIgx2qqxDipoleKernel_H
+#define HERWIG_FIgx2qqxDipoleKernel_H
+//
+// This is the declaration of the FIgx2qqxDipoleKernel class.
+//
+
+#include "DipoleSplittingKernel.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief FIgx2qqxDipoleKernel implements the g -> qqbar
+ * splitting off a final-initial dipole
+ *
+ */
+class FIgx2qqxDipoleKernel: public DipoleSplittingKernel {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ FIgx2qqxDipoleKernel();
+
+ /**
+ * The destructor.
+ */
+ virtual ~FIgx2qqxDipoleKernel();
+ //@}
+
+public:
+
+ /**
+ * Return true, if this splitting kernel
+ * applies to the given dipole index.
+ */
+ virtual bool canHandle(const DipoleIndex&) const;
+
+ /**
+ * Return true, if this splitting kernel is
+ * the same for the given index a, as the given
+ * splitting kernel for index b.
+ */
+ virtual bool canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const;
+
+ /**
+ * Return the emitter data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emitter(const DipoleIndex&) const;
+
+ /**
+ * Return the emission data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emission(const DipoleIndex&) const;
+
+ /**
+ * Return the spectator data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr spectator(const DipoleIndex&) const;
+
+ /**
+ * Evaluate this splitting kernel for the given
+ * dipole splitting.
+ */
+ virtual double evaluate(const DipoleSplittingInfo&) const;
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<FIgx2qqxDipoleKernel> initFIgx2qqxDipoleKernel;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ FIgx2qqxDipoleKernel & operator=(const FIgx2qqxDipoleKernel &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of FIgx2qqxDipoleKernel. */
+template <>
+struct BaseClassTrait<Herwig::FIgx2qqxDipoleKernel,1> {
+ /** Typedef of the first base class of FIgx2qqxDipoleKernel. */
+ typedef Herwig::DipoleSplittingKernel NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the FIgx2qqxDipoleKernel class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::FIgx2qqxDipoleKernel>
+ : public ClassTraitsBase<Herwig::FIgx2qqxDipoleKernel> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::FIgx2qqxDipoleKernel"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * FIgx2qqxDipoleKernel is implemented. It may also include several, space-separated,
+ * libraries if the class FIgx2qqxDipoleKernel depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_FIgx2qqxDipoleKernel_H */
diff --git a/DipoleShower/Kernels/FIqx2qgxDipoleKernel.cc b/DipoleShower/Kernels/FIqx2qgxDipoleKernel.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/FIqx2qgxDipoleKernel.cc
@@ -0,0 +1,100 @@
+// -*- C++ -*-
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the FIqx2qgxDipoleKernel class.
+//
+
+#include "FIqx2qgxDipoleKernel.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+FIqx2qgxDipoleKernel::FIqx2qgxDipoleKernel()
+ : DipoleSplittingKernel() {}
+
+FIqx2qgxDipoleKernel::~FIqx2qgxDipoleKernel() {}
+
+IBPtr FIqx2qgxDipoleKernel::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr FIqx2qgxDipoleKernel::fullclone() const {
+ return new_ptr(*this);
+}
+
+bool FIqx2qgxDipoleKernel::canHandle(const DipoleIndex& ind) const {
+ return
+ abs(ind.emitterData()->id()) < 6 &&
+ ind.emitterData()->mass() == ZERO &&
+ ind.spectatorData()->mass() == ZERO &&
+ !ind.initialStateEmitter() && ind.initialStateSpectator();
+}
+
+bool FIqx2qgxDipoleKernel::canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const {
+
+ assert(canHandle(a));
+
+ if ( !canHandle(b) )
+ return false;
+
+ return
+ sk.emission(b)->id() == ParticleID::g &&
+ abs(sk.emitter(b)->id()) < 6 &&
+ sk.emitter(b)->mass() == ZERO &&
+ a.spectatorPDF() == b.spectatorPDF();
+
+
+}
+
+
+tcPDPtr FIqx2qgxDipoleKernel::emitter(const DipoleIndex& ind) const {
+ return ind.emitterData();
+}
+
+tcPDPtr FIqx2qgxDipoleKernel::emission(const DipoleIndex&) const {
+ return getParticleData(ParticleID::g);
+}
+
+tcPDPtr FIqx2qgxDipoleKernel::spectator(const DipoleIndex& ind) const {
+ return ind.spectatorData();
+}
+
+double FIqx2qgxDipoleKernel::evaluate(const DipoleSplittingInfo& split) const {
+
+ double ret = alphaPDF(split);
+
+ double z = split.lastZ();
+ double x = 1. / ( 1. + sqr(split.lastPt()/split.scale()) / (z*(1.-z)) );
+
+ ret *= (!strictLargeN() ? 4./3. : 3./2.) * ( 2./(1.-z+(1.-x)) -(1.+z) + (1.-x)*(1.+3.*x*z) );
+
+ return ret;
+
+}
+
+// If needed, insert default implementations of function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void FIqx2qgxDipoleKernel::persistentOutput(PersistentOStream & ) const {
+}
+
+void FIqx2qgxDipoleKernel::persistentInput(PersistentIStream & , int) {
+}
+
+ClassDescription<FIqx2qgxDipoleKernel> FIqx2qgxDipoleKernel::initFIqx2qgxDipoleKernel;
+// Definition of the static class description member.
+
+void FIqx2qgxDipoleKernel::Init() {
+
+ static ClassDocumentation<FIqx2qgxDipoleKernel> documentation
+ ("FIqx2qgxDipoleKernel");
+
+}
+
diff --git a/DipoleShower/Kernels/FIqx2qgxDipoleKernel.h b/DipoleShower/Kernels/FIqx2qgxDipoleKernel.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/FIqx2qgxDipoleKernel.h
@@ -0,0 +1,181 @@
+// -*- C++ -*-
+#ifndef HERWIG_FIqx2qgxDipoleKernel_H
+#define HERWIG_FIqx2qgxDipoleKernel_H
+//
+// This is the declaration of the FIqx2qgxDipoleKernel class.
+//
+
+#include "DipoleSplittingKernel.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief FIqx2qgxDipoleKernel implements the q -> qg
+ * splitting off a final-initial dipole
+ *
+ */
+class FIqx2qgxDipoleKernel: public DipoleSplittingKernel {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ FIqx2qgxDipoleKernel();
+
+ /**
+ * The destructor.
+ */
+ virtual ~FIqx2qgxDipoleKernel();
+ //@}
+
+public:
+
+ /**
+ * Return true, if this splitting kernel
+ * applies to the given dipole index.
+ */
+ virtual bool canHandle(const DipoleIndex&) const;
+
+ /**
+ * Return true, if this splitting kernel is
+ * the same for the given index a, as the given
+ * splitting kernel for index b.
+ */
+ virtual bool canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const;
+
+ /**
+ * Return the emitter data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emitter(const DipoleIndex&) const;
+
+ /**
+ * Return the emission data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emission(const DipoleIndex&) const;
+
+ /**
+ * Return the spectator data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr spectator(const DipoleIndex&) const;
+
+ /**
+ * Evaluate this splitting kernel for the given
+ * dipole splitting.
+ */
+ virtual double evaluate(const DipoleSplittingInfo&) const;
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<FIqx2qgxDipoleKernel> initFIqx2qgxDipoleKernel;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ FIqx2qgxDipoleKernel & operator=(const FIqx2qgxDipoleKernel &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of FIqx2qgxDipoleKernel. */
+template <>
+struct BaseClassTrait<Herwig::FIqx2qgxDipoleKernel,1> {
+ /** Typedef of the first base class of FIqx2qgxDipoleKernel. */
+ typedef Herwig::DipoleSplittingKernel NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the FIqx2qgxDipoleKernel class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::FIqx2qgxDipoleKernel>
+ : public ClassTraitsBase<Herwig::FIqx2qgxDipoleKernel> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::FIqx2qgxDipoleKernel"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * FIqx2qgxDipoleKernel is implemented. It may also include several, space-separated,
+ * libraries if the class FIqx2qgxDipoleKernel depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_FIqx2qgxDipoleKernel_H */
diff --git a/DipoleShower/Kernels/IFgx2ggxDipoleKernel.cc b/DipoleShower/Kernels/IFgx2ggxDipoleKernel.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/IFgx2ggxDipoleKernel.cc
@@ -0,0 +1,101 @@
+// -*- C++ -*-
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the IFgx2ggxDipoleKernel class.
+//
+
+#include "IFgx2ggxDipoleKernel.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+IFgx2ggxDipoleKernel::IFgx2ggxDipoleKernel()
+ : DipoleSplittingKernel() {}
+
+IFgx2ggxDipoleKernel::~IFgx2ggxDipoleKernel() {}
+
+IBPtr IFgx2ggxDipoleKernel::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr IFgx2ggxDipoleKernel::fullclone() const {
+ return new_ptr(*this);
+}
+
+bool IFgx2ggxDipoleKernel::canHandle(const DipoleIndex& ind) const {
+ return
+ ind.emitterData()->id() == ParticleID::g &&
+ ind.spectatorData()->mass() == ZERO &&
+ ind.initialStateEmitter() && !ind.initialStateSpectator();
+}
+
+bool IFgx2ggxDipoleKernel::canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const {
+
+ assert(canHandle(a));
+
+ if ( !canHandle(b) )
+ return false;
+
+ return
+ sk.emitter(b)->id() == ParticleID::g &&
+ sk.emission(b)->id() == ParticleID::g &&
+ a.emitterPDF() == b.emitterPDF();
+
+}
+
+
+tcPDPtr IFgx2ggxDipoleKernel::emitter(const DipoleIndex&) const {
+ return getParticleData(ParticleID::g);
+}
+
+tcPDPtr IFgx2ggxDipoleKernel::emission(const DipoleIndex&) const {
+ return getParticleData(ParticleID::g);
+}
+
+tcPDPtr IFgx2ggxDipoleKernel::spectator(const DipoleIndex& ind) const {
+ return ind.spectatorData();
+}
+
+double IFgx2ggxDipoleKernel::evaluate(const DipoleSplittingInfo& split) const {
+
+ double ret = alphaPDF(split);
+
+ double z = split.lastZ();
+ double ratio = sqr(split.lastPt()/split.scale());
+ double x = ( z*(1.-z) - ratio ) / ( 1. - z - ratio );
+ double u = ratio / (1.-z);
+
+ //double rho = (1.+x+u)/x;
+ //ret *= 6. * ( 1./(1.-x+u) + (1.-x)/x - 1. + x*(1.-x) +u/rho );
+ ret *= 6. * ( 1./(1.-x+u) + (1.-x)/x - 1. + x*(1.-x) );
+
+ return ret;
+
+}
+
+// If needed, insert default implementations of function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void IFgx2ggxDipoleKernel::persistentOutput(PersistentOStream & ) const {
+}
+
+void IFgx2ggxDipoleKernel::persistentInput(PersistentIStream & , int) {
+}
+
+ClassDescription<IFgx2ggxDipoleKernel> IFgx2ggxDipoleKernel::initIFgx2ggxDipoleKernel;
+// Definition of the static class description member.
+
+void IFgx2ggxDipoleKernel::Init() {
+
+ static ClassDocumentation<IFgx2ggxDipoleKernel> documentation
+ ("IFgx2ggxDipoleKernel");
+
+}
+
diff --git a/DipoleShower/Kernels/IFgx2ggxDipoleKernel.h b/DipoleShower/Kernels/IFgx2ggxDipoleKernel.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/IFgx2ggxDipoleKernel.h
@@ -0,0 +1,181 @@
+// -*- C++ -*-
+#ifndef HERWIG_IFgx2ggxDipoleKernel_H
+#define HERWIG_IFgx2ggxDipoleKernel_H
+//
+// This is the declaration of the IFgx2ggxDipoleKernel class.
+//
+
+#include "DipoleSplittingKernel.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief IFgx2ggxDipoleKernel implements the g -> gg
+ * splitting off an initial-final dipole
+ *
+ */
+class IFgx2ggxDipoleKernel: public DipoleSplittingKernel {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ IFgx2ggxDipoleKernel();
+
+ /**
+ * The destructor.
+ */
+ virtual ~IFgx2ggxDipoleKernel();
+ //@}
+
+public:
+
+ /**
+ * Return true, if this splitting kernel
+ * applies to the given dipole index.
+ */
+ virtual bool canHandle(const DipoleIndex&) const;
+
+ /**
+ * Return true, if this splitting kernel is
+ * the same for the given index a, as the given
+ * splitting kernel for index b.
+ */
+ virtual bool canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const;
+
+ /**
+ * Return the emitter data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emitter(const DipoleIndex&) const;
+
+ /**
+ * Return the emission data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emission(const DipoleIndex&) const;
+
+ /**
+ * Return the spectator data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr spectator(const DipoleIndex&) const;
+
+ /**
+ * Evaluate this splitting kernel for the given
+ * dipole splitting.
+ */
+ virtual double evaluate(const DipoleSplittingInfo&) const;
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<IFgx2ggxDipoleKernel> initIFgx2ggxDipoleKernel;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ IFgx2ggxDipoleKernel & operator=(const IFgx2ggxDipoleKernel &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of IFgx2ggxDipoleKernel. */
+template <>
+struct BaseClassTrait<Herwig::IFgx2ggxDipoleKernel,1> {
+ /** Typedef of the first base class of IFgx2ggxDipoleKernel. */
+ typedef Herwig::DipoleSplittingKernel NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the IFgx2ggxDipoleKernel class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::IFgx2ggxDipoleKernel>
+ : public ClassTraitsBase<Herwig::IFgx2ggxDipoleKernel> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::IFgx2ggxDipoleKernel"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * IFgx2ggxDipoleKernel is implemented. It may also include several, space-separated,
+ * libraries if the class IFgx2ggxDipoleKernel depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_IFgx2ggxDipoleKernel_H */
diff --git a/DipoleShower/Kernels/IFgx2qqxDipoleKernel.cc b/DipoleShower/Kernels/IFgx2qqxDipoleKernel.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/IFgx2qqxDipoleKernel.cc
@@ -0,0 +1,103 @@
+// -*- C++ -*-
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the IFgx2qqxDipoleKernel class.
+//
+
+#include "IFgx2qqxDipoleKernel.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+IFgx2qqxDipoleKernel::IFgx2qqxDipoleKernel()
+ : DipoleSplittingKernel() {}
+
+IFgx2qqxDipoleKernel::~IFgx2qqxDipoleKernel() {}
+
+IBPtr IFgx2qqxDipoleKernel::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr IFgx2qqxDipoleKernel::fullclone() const {
+ return new_ptr(*this);
+}
+
+bool IFgx2qqxDipoleKernel::canHandle(const DipoleIndex& ind) const {
+ return
+ ind.emitterData()->id() == ParticleID::g &&
+ ind.spectatorData()->mass() == ZERO &&
+ ind.initialStateEmitter() && !ind.initialStateSpectator();
+}
+
+bool IFgx2qqxDipoleKernel::canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const {
+
+ assert(canHandle(a));
+
+ if ( !canHandle(b) )
+ return false;
+
+ return
+ flavour() == sk.flavour() &&
+ abs(flavour()->id()) < 6 &&
+ flavour()->mass() == ZERO &&
+ a.emitterPDF() == b.emitterPDF();
+
+}
+
+
+tcPDPtr IFgx2qqxDipoleKernel::emitter(const DipoleIndex&) const {
+ assert(flavour());
+ assert(abs(flavour()->id()) < 6 && flavour()->mass() == ZERO);
+ return flavour();
+}
+
+tcPDPtr IFgx2qqxDipoleKernel::emission(const DipoleIndex&) const {
+ assert(flavour());
+ assert(abs(flavour()->id()) < 6 && flavour()->mass() == ZERO);
+ return flavour();
+}
+
+tcPDPtr IFgx2qqxDipoleKernel::spectator(const DipoleIndex& ind) const {
+ return ind.spectatorData();
+}
+
+double IFgx2qqxDipoleKernel::evaluate(const DipoleSplittingInfo& split) const {
+
+ double ret = alphaPDF(split);
+
+ double z = split.lastZ();
+ double ratio = sqr(split.lastPt()/split.scale());
+ double x = ( z*(1.-z) - ratio ) / ( 1. - z - ratio );
+
+ ret *= (!strictLargeN() ? 4./3. : 3./2.) * ( x + 2.*(1.-x)/x );
+
+ return ret;
+
+}
+
+// If needed, insert default implementations of function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void IFgx2qqxDipoleKernel::persistentOutput(PersistentOStream & ) const {
+}
+
+void IFgx2qqxDipoleKernel::persistentInput(PersistentIStream & , int) {
+}
+
+ClassDescription<IFgx2qqxDipoleKernel> IFgx2qqxDipoleKernel::initIFgx2qqxDipoleKernel;
+// Definition of the static class description member.
+
+void IFgx2qqxDipoleKernel::Init() {
+
+ static ClassDocumentation<IFgx2qqxDipoleKernel> documentation
+ ("IFgx2qqxDipoleKernel");
+
+}
+
diff --git a/DipoleShower/Kernels/IFgx2qqxDipoleKernel.h b/DipoleShower/Kernels/IFgx2qqxDipoleKernel.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/IFgx2qqxDipoleKernel.h
@@ -0,0 +1,181 @@
+// -*- C++ -*-
+#ifndef HERWIG_IFgx2qqxDipoleKernel_H
+#define HERWIG_IFgx2qqxDipoleKernel_H
+//
+// This is the declaration of the IFgx2qqxDipoleKernel class.
+//
+
+#include "DipoleSplittingKernel.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief IFgx2qqxDipoleKernel implements the g -> qq
+ * splitting off an initial-final dipole
+ *
+ */
+class IFgx2qqxDipoleKernel: public DipoleSplittingKernel {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ IFgx2qqxDipoleKernel();
+
+ /**
+ * The destructor.
+ */
+ virtual ~IFgx2qqxDipoleKernel();
+ //@}
+
+public:
+
+ /**
+ * Return true, if this splitting kernel
+ * applies to the given dipole index.
+ */
+ virtual bool canHandle(const DipoleIndex&) const;
+
+ /**
+ * Return true, if this splitting kernel is
+ * the same for the given index a, as the given
+ * splitting kernel for index b.
+ */
+ virtual bool canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const;
+
+ /**
+ * Return the emitter data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emitter(const DipoleIndex&) const;
+
+ /**
+ * Return the emission data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emission(const DipoleIndex&) const;
+
+ /**
+ * Return the spectator data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr spectator(const DipoleIndex&) const;
+
+ /**
+ * Evaluate this splitting kernel for the given
+ * dipole splitting.
+ */
+ virtual double evaluate(const DipoleSplittingInfo&) const;
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<IFgx2qqxDipoleKernel> initIFgx2qqxDipoleKernel;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ IFgx2qqxDipoleKernel & operator=(const IFgx2qqxDipoleKernel &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of IFgx2qqxDipoleKernel. */
+template <>
+struct BaseClassTrait<Herwig::IFgx2qqxDipoleKernel,1> {
+ /** Typedef of the first base class of IFgx2qqxDipoleKernel. */
+ typedef Herwig::DipoleSplittingKernel NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the IFgx2qqxDipoleKernel class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::IFgx2qqxDipoleKernel>
+ : public ClassTraitsBase<Herwig::IFgx2qqxDipoleKernel> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::IFgx2qqxDipoleKernel"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * IFgx2qqxDipoleKernel is implemented. It may also include several, space-separated,
+ * libraries if the class IFgx2qqxDipoleKernel depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_IFgx2qqxDipoleKernel_H */
diff --git a/DipoleShower/Kernels/IFqx2gqxDipoleKernel.cc b/DipoleShower/Kernels/IFqx2gqxDipoleKernel.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/IFqx2gqxDipoleKernel.cc
@@ -0,0 +1,99 @@
+// -*- C++ -*-
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the IFqx2gqxDipoleKernel class.
+//
+
+#include "IFqx2gqxDipoleKernel.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+IFqx2gqxDipoleKernel::IFqx2gqxDipoleKernel()
+ : DipoleSplittingKernel() {}
+
+IFqx2gqxDipoleKernel::~IFqx2gqxDipoleKernel() {}
+
+IBPtr IFqx2gqxDipoleKernel::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr IFqx2gqxDipoleKernel::fullclone() const {
+ return new_ptr(*this);
+}
+
+bool IFqx2gqxDipoleKernel::canHandle(const DipoleIndex& ind) const {
+ return
+ abs(ind.emitterData()->id()) < 6 &&
+ ind.emitterData()->mass() == ZERO &&
+ ind.spectatorData()->mass() == ZERO &&
+ ind.initialStateEmitter() && !ind.initialStateSpectator();
+}
+
+bool IFqx2gqxDipoleKernel::canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const {
+
+ assert(canHandle(a));
+
+ if ( !canHandle(b) )
+ return false;
+
+ return
+ a.emitterData() == b.emitterData() &&
+ emitter(a) == sk.emitter(b) &&
+ a.emitterPDF() == b.emitterPDF();
+
+}
+
+
+tcPDPtr IFqx2gqxDipoleKernel::emitter(const DipoleIndex&) const {
+ return getParticleData(ParticleID::g);
+}
+
+tcPDPtr IFqx2gqxDipoleKernel::emission(const DipoleIndex& ind) const {
+ return ind.emitterData()->CC();
+}
+
+tcPDPtr IFqx2gqxDipoleKernel::spectator(const DipoleIndex& ind) const {
+ return ind.spectatorData();
+}
+
+double IFqx2gqxDipoleKernel::evaluate(const DipoleSplittingInfo& split) const {
+
+ double ret = alphaPDF(split);
+
+ double z = split.lastZ();
+ double ratio = sqr(split.lastPt()/split.scale());
+ double x = ( z*(1.-z) - ratio ) / ( 1. - z - ratio );
+
+ ret *= .5 * ( 1.-2.*x*(1.-x) );
+
+ return ret;
+
+}
+
+// If needed, insert default implementations of function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void IFqx2gqxDipoleKernel::persistentOutput(PersistentOStream & ) const {
+}
+
+void IFqx2gqxDipoleKernel::persistentInput(PersistentIStream & , int) {
+}
+
+ClassDescription<IFqx2gqxDipoleKernel> IFqx2gqxDipoleKernel::initIFqx2gqxDipoleKernel;
+// Definition of the static class description member.
+
+void IFqx2gqxDipoleKernel::Init() {
+
+ static ClassDocumentation<IFqx2gqxDipoleKernel> documentation
+ ("IFqx2gqxDipoleKernel");
+
+}
+
diff --git a/DipoleShower/Kernels/IFqx2gqxDipoleKernel.h b/DipoleShower/Kernels/IFqx2gqxDipoleKernel.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/IFqx2gqxDipoleKernel.h
@@ -0,0 +1,181 @@
+// -*- C++ -*-
+#ifndef HERWIG_IFqx2gqxDipoleKernel_H
+#define HERWIG_IFqx2gqxDipoleKernel_H
+//
+// This is the declaration of the IFqx2gqxDipoleKernel class.
+//
+
+#include "DipoleSplittingKernel.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief IFqx2gqxDipoleKernel implements the q -> gqbar
+ * splitting off an initial-final dipole
+ *
+ */
+class IFqx2gqxDipoleKernel: public DipoleSplittingKernel {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ IFqx2gqxDipoleKernel();
+
+ /**
+ * The destructor.
+ */
+ virtual ~IFqx2gqxDipoleKernel();
+ //@}
+
+public:
+
+ /**
+ * Return true, if this splitting kernel
+ * applies to the given dipole index.
+ */
+ virtual bool canHandle(const DipoleIndex&) const;
+
+ /**
+ * Return true, if this splitting kernel is
+ * the same for the given index a, as the given
+ * splitting kernel for index b.
+ */
+ virtual bool canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const;
+
+ /**
+ * Return the emitter data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emitter(const DipoleIndex&) const;
+
+ /**
+ * Return the emission data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emission(const DipoleIndex&) const;
+
+ /**
+ * Return the spectator data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr spectator(const DipoleIndex&) const;
+
+ /**
+ * Evaluate this splitting kernel for the given
+ * dipole splitting.
+ */
+ virtual double evaluate(const DipoleSplittingInfo&) const;
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<IFqx2gqxDipoleKernel> initIFqx2gqxDipoleKernel;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ IFqx2gqxDipoleKernel & operator=(const IFqx2gqxDipoleKernel &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of IFqx2gqxDipoleKernel. */
+template <>
+struct BaseClassTrait<Herwig::IFqx2gqxDipoleKernel,1> {
+ /** Typedef of the first base class of IFqx2gqxDipoleKernel. */
+ typedef Herwig::DipoleSplittingKernel NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the IFqx2gqxDipoleKernel class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::IFqx2gqxDipoleKernel>
+ : public ClassTraitsBase<Herwig::IFqx2gqxDipoleKernel> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::IFqx2gqxDipoleKernel"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * IFqx2gqxDipoleKernel is implemented. It may also include several, space-separated,
+ * libraries if the class IFqx2gqxDipoleKernel depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_IFqx2gqxDipoleKernel_H */
diff --git a/DipoleShower/Kernels/IFqx2qgxDipoleKernel.cc b/DipoleShower/Kernels/IFqx2qgxDipoleKernel.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/IFqx2qgxDipoleKernel.cc
@@ -0,0 +1,100 @@
+// -*- C++ -*-
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the IFqx2qgxDipoleKernel class.
+//
+
+#include "IFqx2qgxDipoleKernel.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+IFqx2qgxDipoleKernel::IFqx2qgxDipoleKernel()
+ : DipoleSplittingKernel() {}
+
+IFqx2qgxDipoleKernel::~IFqx2qgxDipoleKernel() {}
+
+IBPtr IFqx2qgxDipoleKernel::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr IFqx2qgxDipoleKernel::fullclone() const {
+ return new_ptr(*this);
+}
+
+bool IFqx2qgxDipoleKernel::canHandle(const DipoleIndex& ind) const {
+ return
+ abs(ind.emitterData()->id()) < 6 &&
+ ind.emitterData()->mass() == ZERO &&
+ ind.spectatorData()->mass() == ZERO &&
+ ind.initialStateEmitter() && !ind.initialStateSpectator();
+}
+
+bool IFqx2qgxDipoleKernel::canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const {
+
+ assert(canHandle(a));
+
+ if ( !canHandle(b) )
+ return false;
+
+ return
+ emitter(a) == sk.emitter(b) &&
+ emission(a) == sk.emission(b) &&
+ a.emitterPDF() == b.emitterPDF();
+
+}
+
+
+tcPDPtr IFqx2qgxDipoleKernel::emitter(const DipoleIndex& ind) const {
+ return ind.emitterData();
+}
+
+tcPDPtr IFqx2qgxDipoleKernel::emission(const DipoleIndex&) const {
+ return getParticleData(ParticleID::g);
+}
+
+tcPDPtr IFqx2qgxDipoleKernel::spectator(const DipoleIndex& ind) const {
+ return ind.spectatorData();
+}
+
+double IFqx2qgxDipoleKernel::evaluate(const DipoleSplittingInfo& split) const {
+
+ double ret = alphaPDF(split);
+
+ double z = split.lastZ();
+ double ratio = sqr(split.lastPt()/split.scale());
+ double x = ( z*(1.-z) - ratio ) / ( 1. - z - ratio );
+ double u = ratio / (1.-z);
+
+ ret *= (!strictLargeN() ? 4./3. : 3./2.) * ( 2./(1.-x+u) - (1.+x) + u*(1.+3.*x*(1.-u) ) );
+
+ return ret;
+
+}
+
+// If needed, insert default implementations of function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void IFqx2qgxDipoleKernel::persistentOutput(PersistentOStream & ) const {
+}
+
+void IFqx2qgxDipoleKernel::persistentInput(PersistentIStream & , int) {
+}
+
+ClassDescription<IFqx2qgxDipoleKernel> IFqx2qgxDipoleKernel::initIFqx2qgxDipoleKernel;
+// Definition of the static class description member.
+
+void IFqx2qgxDipoleKernel::Init() {
+
+ static ClassDocumentation<IFqx2qgxDipoleKernel> documentation
+ ("IFqx2qgxDipoleKernel");
+
+}
+
diff --git a/DipoleShower/Kernels/IFqx2qgxDipoleKernel.h b/DipoleShower/Kernels/IFqx2qgxDipoleKernel.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/IFqx2qgxDipoleKernel.h
@@ -0,0 +1,181 @@
+// -*- C++ -*-
+#ifndef HERWIG_IFqx2qgxDipoleKernel_H
+#define HERWIG_IFqx2qgxDipoleKernel_H
+//
+// This is the declaration of the IFqx2qgxDipoleKernel class.
+//
+
+#include "DipoleSplittingKernel.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief IFqx2qgxDipoleKernel implements the q -> qg
+ * splitting off an initial-final dipole
+ *
+ */
+class IFqx2qgxDipoleKernel: public DipoleSplittingKernel {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ IFqx2qgxDipoleKernel();
+
+ /**
+ * The destructor.
+ */
+ virtual ~IFqx2qgxDipoleKernel();
+ //@}
+
+public:
+
+ /**
+ * Return true, if this splitting kernel
+ * applies to the given dipole index.
+ */
+ virtual bool canHandle(const DipoleIndex&) const;
+
+ /**
+ * Return true, if this splitting kernel is
+ * the same for the given index a, as the given
+ * splitting kernel for index b.
+ */
+ virtual bool canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const;
+
+ /**
+ * Return the emitter data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emitter(const DipoleIndex&) const;
+
+ /**
+ * Return the emission data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emission(const DipoleIndex&) const;
+
+ /**
+ * Return the spectator data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr spectator(const DipoleIndex&) const;
+
+ /**
+ * Evaluate this splitting kernel for the given
+ * dipole splitting.
+ */
+ virtual double evaluate(const DipoleSplittingInfo&) const;
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<IFqx2qgxDipoleKernel> initIFqx2qgxDipoleKernel;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ IFqx2qgxDipoleKernel & operator=(const IFqx2qgxDipoleKernel &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of IFqx2qgxDipoleKernel. */
+template <>
+struct BaseClassTrait<Herwig::IFqx2qgxDipoleKernel,1> {
+ /** Typedef of the first base class of IFqx2qgxDipoleKernel. */
+ typedef Herwig::DipoleSplittingKernel NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the IFqx2qgxDipoleKernel class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::IFqx2qgxDipoleKernel>
+ : public ClassTraitsBase<Herwig::IFqx2qgxDipoleKernel> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::IFqx2qgxDipoleKernel"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * IFqx2qgxDipoleKernel is implemented. It may also include several, space-separated,
+ * libraries if the class IFqx2qgxDipoleKernel depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_IFqx2qgxDipoleKernel_H */
diff --git a/DipoleShower/Kernels/IIgx2ggxDipoleKernel.cc b/DipoleShower/Kernels/IIgx2ggxDipoleKernel.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/IIgx2ggxDipoleKernel.cc
@@ -0,0 +1,100 @@
+// -*- C++ -*-
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the IIgx2ggxDipoleKernel class.
+//
+
+#include "IIgx2ggxDipoleKernel.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+IIgx2ggxDipoleKernel::IIgx2ggxDipoleKernel()
+ : DipoleSplittingKernel() {}
+
+IIgx2ggxDipoleKernel::~IIgx2ggxDipoleKernel() {}
+
+IBPtr IIgx2ggxDipoleKernel::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr IIgx2ggxDipoleKernel::fullclone() const {
+ return new_ptr(*this);
+}
+
+bool IIgx2ggxDipoleKernel::canHandle(const DipoleIndex& ind) const {
+ return
+ ind.emitterData()->id() == ParticleID::g &&
+ ind.spectatorData()->mass() == ZERO &&
+ ind.initialStateEmitter() && ind.initialStateSpectator();
+}
+
+bool IIgx2ggxDipoleKernel::canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const {
+
+ assert(canHandle(a));
+
+ if ( !canHandle(b) )
+ return false;
+
+ return
+ sk.emitter(b)->id() == ParticleID::g &&
+ sk.emission(b)->id() == ParticleID::g &&
+ a.emitterPDF() == b.emitterPDF() &&
+ a.spectatorData() == b.spectatorData() &&
+ a.spectatorPDF() == b.spectatorPDF();
+
+}
+
+
+tcPDPtr IIgx2ggxDipoleKernel::emitter(const DipoleIndex&) const {
+ return getParticleData(ParticleID::g);
+}
+
+tcPDPtr IIgx2ggxDipoleKernel::emission(const DipoleIndex&) const {
+ return getParticleData(ParticleID::g);
+}
+
+tcPDPtr IIgx2ggxDipoleKernel::spectator(const DipoleIndex& ind) const {
+ return ind.spectatorData();
+}
+
+double IIgx2ggxDipoleKernel::evaluate(const DipoleSplittingInfo& split) const {
+
+ double ret = alphaPDF(split);
+
+ double z = split.lastZ();
+ double ratio = sqr(split.lastPt()/split.scale());
+ double x = ( z*(1.-z) - ratio ) / ( 1. - z );
+
+ ret *= 6. * ( x/(1.-x) + (1.-x)/x +x*(1.-x) );
+
+ return ret;
+
+}
+
+// If needed, insert default implementations of function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void IIgx2ggxDipoleKernel::persistentOutput(PersistentOStream & ) const {
+}
+
+void IIgx2ggxDipoleKernel::persistentInput(PersistentIStream & , int) {
+}
+
+ClassDescription<IIgx2ggxDipoleKernel> IIgx2ggxDipoleKernel::initIIgx2ggxDipoleKernel;
+// Definition of the static class description member.
+
+void IIgx2ggxDipoleKernel::Init() {
+
+ static ClassDocumentation<IIgx2ggxDipoleKernel> documentation
+ ("IIgx2ggxDipoleKernel");
+
+}
+
diff --git a/DipoleShower/Kernels/IIgx2ggxDipoleKernel.h b/DipoleShower/Kernels/IIgx2ggxDipoleKernel.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/IIgx2ggxDipoleKernel.h
@@ -0,0 +1,181 @@
+// -*- C++ -*-
+#ifndef HERWIG_IIgx2ggxDipoleKernel_H
+#define HERWIG_IIgx2ggxDipoleKernel_H
+//
+// This is the declaration of the IIgx2ggxDipoleKernel class.
+//
+
+#include "DipoleSplittingKernel.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief IIgx2ggxDipoleKernel implements the g -> gg
+ * splitting off an initial-initial dipole
+ *
+ */
+class IIgx2ggxDipoleKernel: public DipoleSplittingKernel {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ IIgx2ggxDipoleKernel();
+
+ /**
+ * The destructor.
+ */
+ virtual ~IIgx2ggxDipoleKernel();
+ //@}
+
+public:
+
+ /**
+ * Return true, if this splitting kernel
+ * applies to the given dipole index.
+ */
+ virtual bool canHandle(const DipoleIndex&) const;
+
+ /**
+ * Return true, if this splitting kernel is
+ * the same for the given index a, as the given
+ * splitting kernel for index b.
+ */
+ virtual bool canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const;
+
+ /**
+ * Return the emitter data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emitter(const DipoleIndex&) const;
+
+ /**
+ * Return the emission data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emission(const DipoleIndex&) const;
+
+ /**
+ * Return the spectator data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr spectator(const DipoleIndex&) const;
+
+ /**
+ * Evaluate this splitting kernel for the given
+ * dipole splitting.
+ */
+ virtual double evaluate(const DipoleSplittingInfo&) const;
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<IIgx2ggxDipoleKernel> initIIgx2ggxDipoleKernel;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ IIgx2ggxDipoleKernel & operator=(const IIgx2ggxDipoleKernel &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of IIgx2ggxDipoleKernel. */
+template <>
+struct BaseClassTrait<Herwig::IIgx2ggxDipoleKernel,1> {
+ /** Typedef of the first base class of IIgx2ggxDipoleKernel. */
+ typedef Herwig::DipoleSplittingKernel NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the IIgx2ggxDipoleKernel class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::IIgx2ggxDipoleKernel>
+ : public ClassTraitsBase<Herwig::IIgx2ggxDipoleKernel> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::IIgx2ggxDipoleKernel"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * IIgx2ggxDipoleKernel is implemented. It may also include several, space-separated,
+ * libraries if the class IIgx2ggxDipoleKernel depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_IIgx2ggxDipoleKernel_H */
diff --git a/DipoleShower/Kernels/IIgx2qqxDipoleKernel.cc b/DipoleShower/Kernels/IIgx2qqxDipoleKernel.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/IIgx2qqxDipoleKernel.cc
@@ -0,0 +1,105 @@
+// -*- C++ -*-
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the IIgx2qqxDipoleKernel class.
+//
+
+#include "IIgx2qqxDipoleKernel.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+IIgx2qqxDipoleKernel::IIgx2qqxDipoleKernel()
+ : DipoleSplittingKernel() {}
+
+IIgx2qqxDipoleKernel::~IIgx2qqxDipoleKernel() {}
+
+IBPtr IIgx2qqxDipoleKernel::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr IIgx2qqxDipoleKernel::fullclone() const {
+ return new_ptr(*this);
+}
+
+bool IIgx2qqxDipoleKernel::canHandle(const DipoleIndex& ind) const {
+ return
+ ind.emitterData()->id() == ParticleID::g &&
+ ind.spectatorData()->mass() == ZERO &&
+ ind.initialStateEmitter() && ind.initialStateSpectator();
+}
+
+bool IIgx2qqxDipoleKernel::canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const {
+
+ assert(canHandle(a));
+
+ if ( !canHandle(b) )
+ return false;
+
+ return
+ flavour() == sk.flavour() &&
+ abs(flavour()->id()) < 6 &&
+ flavour()->mass() == ZERO &&
+ a.emitterPDF() == b.emitterPDF() &&
+ a.spectatorData() == b.spectatorData() &&
+ a.spectatorPDF() == b.spectatorPDF();
+
+}
+
+
+tcPDPtr IIgx2qqxDipoleKernel::emitter(const DipoleIndex&) const {
+ assert(flavour());
+ assert(abs(flavour()->id()) < 6 && flavour()->mass() == ZERO);
+ return flavour();
+}
+
+tcPDPtr IIgx2qqxDipoleKernel::emission(const DipoleIndex&) const {
+ assert(flavour());
+ assert(abs(flavour()->id()) < 6 && flavour()->mass() == ZERO);
+ return flavour();
+}
+
+tcPDPtr IIgx2qqxDipoleKernel::spectator(const DipoleIndex& ind) const {
+ return ind.spectatorData();
+}
+
+double IIgx2qqxDipoleKernel::evaluate(const DipoleSplittingInfo& split) const {
+
+ double ret = alphaPDF(split);
+
+ double z = split.lastZ();
+ double ratio = sqr(split.lastPt()/split.scale());
+ double x = ( z*(1.-z) - ratio ) / ( 1. - z );
+
+ ret *= (!strictLargeN() ? 4./3. : 3./2.) * ( 1./x +sqr(1.-x)/x );
+
+ return ret;
+
+}
+
+// If needed, insert default implementations of function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void IIgx2qqxDipoleKernel::persistentOutput(PersistentOStream & ) const {
+}
+
+void IIgx2qqxDipoleKernel::persistentInput(PersistentIStream & , int) {
+}
+
+ClassDescription<IIgx2qqxDipoleKernel> IIgx2qqxDipoleKernel::initIIgx2qqxDipoleKernel;
+// Definition of the static class description member.
+
+void IIgx2qqxDipoleKernel::Init() {
+
+ static ClassDocumentation<IIgx2qqxDipoleKernel> documentation
+ ("IIgx2qqxDipoleKernel");
+
+}
+
diff --git a/DipoleShower/Kernels/IIgx2qqxDipoleKernel.h b/DipoleShower/Kernels/IIgx2qqxDipoleKernel.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/IIgx2qqxDipoleKernel.h
@@ -0,0 +1,181 @@
+// -*- C++ -*-
+#ifndef HERWIG_IIgx2qqxDipoleKernel_H
+#define HERWIG_IIgx2qqxDipoleKernel_H
+//
+// This is the declaration of the IIgx2qqxDipoleKernel class.
+//
+
+#include "DipoleSplittingKernel.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief IIgx2qqxDipoleKernel implements the g -> qq
+ * splitting off an initial-initial dipole
+ *
+ */
+class IIgx2qqxDipoleKernel: public DipoleSplittingKernel {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ IIgx2qqxDipoleKernel();
+
+ /**
+ * The destructor.
+ */
+ virtual ~IIgx2qqxDipoleKernel();
+ //@}
+
+public:
+
+ /**
+ * Return true, if this splitting kernel
+ * applies to the given dipole index.
+ */
+ virtual bool canHandle(const DipoleIndex&) const;
+
+ /**
+ * Return true, if this splitting kernel is
+ * the same for the given index a, as the given
+ * splitting kernel for index b.
+ */
+ virtual bool canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const;
+
+ /**
+ * Return the emitter data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emitter(const DipoleIndex&) const;
+
+ /**
+ * Return the emission data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emission(const DipoleIndex&) const;
+
+ /**
+ * Return the spectator data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr spectator(const DipoleIndex&) const;
+
+ /**
+ * Evaluate this splitting kernel for the given
+ * dipole splitting.
+ */
+ virtual double evaluate(const DipoleSplittingInfo&) const;
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<IIgx2qqxDipoleKernel> initIIgx2qqxDipoleKernel;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ IIgx2qqxDipoleKernel & operator=(const IIgx2qqxDipoleKernel &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of IIgx2qqxDipoleKernel. */
+template <>
+struct BaseClassTrait<Herwig::IIgx2qqxDipoleKernel,1> {
+ /** Typedef of the first base class of IIgx2qqxDipoleKernel. */
+ typedef Herwig::DipoleSplittingKernel NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the IIgx2qqxDipoleKernel class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::IIgx2qqxDipoleKernel>
+ : public ClassTraitsBase<Herwig::IIgx2qqxDipoleKernel> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::IIgx2qqxDipoleKernel"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * IIgx2qqxDipoleKernel is implemented. It may also include several, space-separated,
+ * libraries if the class IIgx2qqxDipoleKernel depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_IIgx2qqxDipoleKernel_H */
diff --git a/DipoleShower/Kernels/IIqx2gqxDipoleKernel.cc b/DipoleShower/Kernels/IIqx2gqxDipoleKernel.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/IIqx2gqxDipoleKernel.cc
@@ -0,0 +1,101 @@
+// -*- C++ -*-
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the IIqx2gqxDipoleKernel class.
+//
+
+#include "IIqx2gqxDipoleKernel.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+IIqx2gqxDipoleKernel::IIqx2gqxDipoleKernel()
+ : DipoleSplittingKernel() {}
+
+IIqx2gqxDipoleKernel::~IIqx2gqxDipoleKernel() {}
+
+IBPtr IIqx2gqxDipoleKernel::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr IIqx2gqxDipoleKernel::fullclone() const {
+ return new_ptr(*this);
+}
+
+bool IIqx2gqxDipoleKernel::canHandle(const DipoleIndex& ind) const {
+ return
+ abs(ind.emitterData()->id()) < 6 &&
+ ind.emitterData()->mass() == ZERO &&
+ ind.spectatorData()->mass() == ZERO &&
+ ind.initialStateEmitter() && ind.initialStateSpectator();
+}
+
+bool IIqx2gqxDipoleKernel::canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const {
+
+ assert(canHandle(a));
+
+ if ( !canHandle(b) )
+ return false;
+
+ return
+ a.emitterData() == b.emitterData() &&
+ emitter(a) == sk.emitter(b) &&
+ a.emitterPDF() == b.emitterPDF() &&
+ a.spectatorData() == b.spectatorData() &&
+ a.spectatorPDF() == b.spectatorPDF();
+
+}
+
+
+tcPDPtr IIqx2gqxDipoleKernel::emitter(const DipoleIndex&) const {
+ return getParticleData(ParticleID::g);
+}
+
+tcPDPtr IIqx2gqxDipoleKernel::emission(const DipoleIndex& ind) const {
+ return ind.emitterData()->CC();
+}
+
+tcPDPtr IIqx2gqxDipoleKernel::spectator(const DipoleIndex& ind) const {
+ return ind.spectatorData();
+}
+
+double IIqx2gqxDipoleKernel::evaluate(const DipoleSplittingInfo& split) const {
+
+ double ret = alphaPDF(split);
+
+ double z = split.lastZ();
+ double ratio = sqr(split.lastPt()/split.scale());
+ double x = ( z*(1.-z) - ratio ) / ( 1. - z );
+
+ ret *= .5 * ( 1.-2.*x*(1.-x) );
+
+ return ret;
+
+}
+
+// If needed, insert default implementations of function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void IIqx2gqxDipoleKernel::persistentOutput(PersistentOStream & ) const {
+}
+
+void IIqx2gqxDipoleKernel::persistentInput(PersistentIStream & , int) {
+}
+
+ClassDescription<IIqx2gqxDipoleKernel> IIqx2gqxDipoleKernel::initIIqx2gqxDipoleKernel;
+// Definition of the static class description member.
+
+void IIqx2gqxDipoleKernel::Init() {
+
+ static ClassDocumentation<IIqx2gqxDipoleKernel> documentation
+ ("IIqx2gqxDipoleKernel");
+
+}
+
diff --git a/DipoleShower/Kernels/IIqx2gqxDipoleKernel.h b/DipoleShower/Kernels/IIqx2gqxDipoleKernel.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/IIqx2gqxDipoleKernel.h
@@ -0,0 +1,181 @@
+// -*- C++ -*-
+#ifndef HERWIG_IIqx2gqxDipoleKernel_H
+#define HERWIG_IIqx2gqxDipoleKernel_H
+//
+// This is the declaration of the IIqx2gqxDipoleKernel class.
+//
+
+#include "DipoleSplittingKernel.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief IIqx2gqxDipoleKernel implements the q -> gqbar
+ * splitting off an initial-initial dipole
+ *
+ */
+class IIqx2gqxDipoleKernel: public DipoleSplittingKernel {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ IIqx2gqxDipoleKernel();
+
+ /**
+ * The destructor.
+ */
+ virtual ~IIqx2gqxDipoleKernel();
+ //@}
+
+public:
+
+ /**
+ * Return true, if this splitting kernel
+ * applies to the given dipole index.
+ */
+ virtual bool canHandle(const DipoleIndex&) const;
+
+ /**
+ * Return true, if this splitting kernel is
+ * the same for the given index a, as the given
+ * splitting kernel for index b.
+ */
+ virtual bool canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const;
+
+ /**
+ * Return the emitter data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emitter(const DipoleIndex&) const;
+
+ /**
+ * Return the emission data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emission(const DipoleIndex&) const;
+
+ /**
+ * Return the spectator data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr spectator(const DipoleIndex&) const;
+
+ /**
+ * Evaluate this splitting kernel for the given
+ * dipole splitting.
+ */
+ virtual double evaluate(const DipoleSplittingInfo&) const;
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<IIqx2gqxDipoleKernel> initIIqx2gqxDipoleKernel;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ IIqx2gqxDipoleKernel & operator=(const IIqx2gqxDipoleKernel &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of IIqx2gqxDipoleKernel. */
+template <>
+struct BaseClassTrait<Herwig::IIqx2gqxDipoleKernel,1> {
+ /** Typedef of the first base class of IIqx2gqxDipoleKernel. */
+ typedef Herwig::DipoleSplittingKernel NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the IIqx2gqxDipoleKernel class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::IIqx2gqxDipoleKernel>
+ : public ClassTraitsBase<Herwig::IIqx2gqxDipoleKernel> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::IIqx2gqxDipoleKernel"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * IIqx2gqxDipoleKernel is implemented. It may also include several, space-separated,
+ * libraries if the class IIqx2gqxDipoleKernel depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_IIqx2gqxDipoleKernel_H */
diff --git a/DipoleShower/Kernels/IIqx2qgxDipoleKernel.cc b/DipoleShower/Kernels/IIqx2qgxDipoleKernel.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/IIqx2qgxDipoleKernel.cc
@@ -0,0 +1,101 @@
+// -*- C++ -*-
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the IIqx2qgxDipoleKernel class.
+//
+
+#include "IIqx2qgxDipoleKernel.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+IIqx2qgxDipoleKernel::IIqx2qgxDipoleKernel()
+ : DipoleSplittingKernel() {}
+
+IIqx2qgxDipoleKernel::~IIqx2qgxDipoleKernel() {}
+
+IBPtr IIqx2qgxDipoleKernel::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr IIqx2qgxDipoleKernel::fullclone() const {
+ return new_ptr(*this);
+}
+
+bool IIqx2qgxDipoleKernel::canHandle(const DipoleIndex& ind) const {
+ return
+ abs(ind.emitterData()->id()) < 6 &&
+ ind.emitterData()->mass() == ZERO &&
+ ind.spectatorData()->mass() == ZERO &&
+ ind.initialStateEmitter() && ind.initialStateSpectator();
+}
+
+bool IIqx2qgxDipoleKernel::canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const {
+
+ assert(canHandle(a));
+
+ if ( !canHandle(b) )
+ return false;
+
+ return
+ emitter(a) == sk.emitter(b) &&
+ emission(a) == sk.emission(b) &&
+ a.emitterPDF() == b.emitterPDF() &&
+ a.spectatorData() == b.spectatorData() &&
+ a.spectatorPDF() == b.spectatorPDF();
+
+}
+
+
+tcPDPtr IIqx2qgxDipoleKernel::emitter(const DipoleIndex& ind) const {
+ return ind.emitterData();
+}
+
+tcPDPtr IIqx2qgxDipoleKernel::emission(const DipoleIndex&) const {
+ return getParticleData(ParticleID::g);
+}
+
+tcPDPtr IIqx2qgxDipoleKernel::spectator(const DipoleIndex& ind) const {
+ return ind.spectatorData();
+}
+
+double IIqx2qgxDipoleKernel::evaluate(const DipoleSplittingInfo& split) const {
+
+ double ret = alphaPDF(split);
+
+ double z = split.lastZ();
+ double ratio = sqr(split.lastPt()/split.scale());
+ double x = ( z*(1.-z) - ratio ) / ( 1. - z );
+
+ ret *= (!strictLargeN() ? 4./3. : 3./2.) * ( (1.+sqr(x))/(1.-x) );
+
+ return ret;
+
+}
+
+// If needed, insert default implementations of function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void IIqx2qgxDipoleKernel::persistentOutput(PersistentOStream & ) const {
+}
+
+void IIqx2qgxDipoleKernel::persistentInput(PersistentIStream & , int) {
+}
+
+ClassDescription<IIqx2qgxDipoleKernel> IIqx2qgxDipoleKernel::initIIqx2qgxDipoleKernel;
+// Definition of the static class description member.
+
+void IIqx2qgxDipoleKernel::Init() {
+
+ static ClassDocumentation<IIqx2qgxDipoleKernel> documentation
+ ("IIqx2qgxDipoleKernel");
+
+}
+
diff --git a/DipoleShower/Kernels/IIqx2qgxDipoleKernel.h b/DipoleShower/Kernels/IIqx2qgxDipoleKernel.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/IIqx2qgxDipoleKernel.h
@@ -0,0 +1,181 @@
+// -*- C++ -*-
+#ifndef HERWIG_IIqx2qgxDipoleKernel_H
+#define HERWIG_IIqx2qgxDipoleKernel_H
+//
+// This is the declaration of the IIqx2qgxDipoleKernel class.
+//
+
+#include "DipoleSplittingKernel.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief IIqx2qgxDipoleKernel implements the q -> qg
+ * splitting off an initial-initial dipole
+ *
+ */
+class IIqx2qgxDipoleKernel: public DipoleSplittingKernel {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ IIqx2qgxDipoleKernel();
+
+ /**
+ * The destructor.
+ */
+ virtual ~IIqx2qgxDipoleKernel();
+ //@}
+
+public:
+
+ /**
+ * Return true, if this splitting kernel
+ * applies to the given dipole index.
+ */
+ virtual bool canHandle(const DipoleIndex&) const;
+
+ /**
+ * Return true, if this splitting kernel is
+ * the same for the given index a, as the given
+ * splitting kernel for index b.
+ */
+ virtual bool canHandleEquivalent(const DipoleIndex& a,
+ const DipoleSplittingKernel& sk,
+ const DipoleIndex& b) const;
+
+ /**
+ * Return the emitter data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emitter(const DipoleIndex&) const;
+
+ /**
+ * Return the emission data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr emission(const DipoleIndex&) const;
+
+ /**
+ * Return the spectator data after splitting, given
+ * a dipole index.
+ */
+ virtual tcPDPtr spectator(const DipoleIndex&) const;
+
+ /**
+ * Evaluate this splitting kernel for the given
+ * dipole splitting.
+ */
+ virtual double evaluate(const DipoleSplittingInfo&) const;
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<IIqx2qgxDipoleKernel> initIIqx2qgxDipoleKernel;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ IIqx2qgxDipoleKernel & operator=(const IIqx2qgxDipoleKernel &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of IIqx2qgxDipoleKernel. */
+template <>
+struct BaseClassTrait<Herwig::IIqx2qgxDipoleKernel,1> {
+ /** Typedef of the first base class of IIqx2qgxDipoleKernel. */
+ typedef Herwig::DipoleSplittingKernel NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the IIqx2qgxDipoleKernel class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::IIqx2qgxDipoleKernel>
+ : public ClassTraitsBase<Herwig::IIqx2qgxDipoleKernel> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::IIqx2qgxDipoleKernel"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * IIqx2qgxDipoleKernel is implemented. It may also include several, space-separated,
+ * libraries if the class IIqx2qgxDipoleKernel depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_IIqx2qgxDipoleKernel_H */
diff --git a/DipoleShower/Kernels/Makefile.am b/DipoleShower/Kernels/Makefile.am
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kernels/Makefile.am
@@ -0,0 +1,21 @@
+noinst_LTLIBRARIES = libHwDipoleShowerKernels.la
+
+libHwDipoleShowerKernels_la_SOURCES = \
+ DipoleSplittingKernel.h DipoleSplittingKernel.cc \
+ FFMqx2qgxDipoleKernel.h FFMqx2qgxDipoleKernel.cc \
+ FFMgx2ggxDipoleKernel.h FFMgx2ggxDipoleKernel.cc \
+ FFMgx2qqxDipoleKernel.h FFMgx2qqxDipoleKernel.cc \
+ FFqx2qgxDipoleKernel.h FFqx2qgxDipoleKernel.cc \
+ FFgx2ggxDipoleKernel.h FFgx2ggxDipoleKernel.cc \
+ FFgx2qqxDipoleKernel.h FFgx2qqxDipoleKernel.cc \
+ FIqx2qgxDipoleKernel.h FIqx2qgxDipoleKernel.cc \
+ FIgx2ggxDipoleKernel.h FIgx2ggxDipoleKernel.cc \
+ FIgx2qqxDipoleKernel.h FIgx2qqxDipoleKernel.cc \
+ IFqx2qgxDipoleKernel.h IFqx2qgxDipoleKernel.cc \
+ IFqx2gqxDipoleKernel.h IFqx2gqxDipoleKernel.cc \
+ IFgx2ggxDipoleKernel.h IFgx2ggxDipoleKernel.cc \
+ IFgx2qqxDipoleKernel.h IFgx2qqxDipoleKernel.cc \
+ IIqx2qgxDipoleKernel.h IIqx2qgxDipoleKernel.cc \
+ IIqx2gqxDipoleKernel.h IIqx2gqxDipoleKernel.cc \
+ IIgx2ggxDipoleKernel.h IIgx2ggxDipoleKernel.cc \
+ IIgx2qqxDipoleKernel.h IIgx2qqxDipoleKernel.cc
diff --git a/DipoleShower/Kinematics/DipoleSplittingKinematics.cc b/DipoleShower/Kinematics/DipoleSplittingKinematics.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kinematics/DipoleSplittingKinematics.cc
@@ -0,0 +1,141 @@
+// -*- C++ -*-
+//
+// DipoleSplittingKinematics.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the DipoleSplittingKinematics class.
+//
+
+#include "DipoleSplittingKinematics.h"
+#include "Herwig++/DipoleShower/Base/DipoleSplittingInfo.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/Interface/Reference.h"
+#include "ThePEG/Interface/Parameter.h"
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+#include <limits>
+
+using namespace Herwig;
+
+DipoleSplittingKinematics::DipoleSplittingKinematics()
+ : HandlerBase(), theIRCutoff(1.0*GeV),
+ theXMin(1.e-5), theJacobian(0.0),
+ theLastPt(0.0*GeV), theLastZ(0.0), theLastPhi(0.0),
+ theLastEmitterZ(1.0), theLastSpectatorZ(1.0),
+ theLastSplittingParameters() {}
+
+DipoleSplittingKinematics::~DipoleSplittingKinematics() {}
+
+void DipoleSplittingKinematics::persistentOutput(PersistentOStream & os) const {
+ os << ounit(theIRCutoff,GeV) << theXMin << theMCCheck;
+}
+
+void DipoleSplittingKinematics::persistentInput(PersistentIStream & is, int) {
+ is >> iunit(theIRCutoff,GeV) >> theXMin >> theMCCheck;
+}
+
+void DipoleSplittingKinematics::prepareSplitting(DipoleSplittingInfo& dInfo) {
+
+ dInfo.splittingKinematics(this);
+
+ if ( lastPt() > IRCutoff() )
+ dInfo.lastPt(lastPt());
+ else {
+ dInfo.lastPt(0.0*GeV);
+ dInfo.didStopEvolving();
+ }
+
+ dInfo.lastZ(lastZ());
+ dInfo.lastPhi(lastPhi());
+ dInfo.lastEmitterZ(lastEmitterZ());
+ dInfo.lastSpectatorZ(lastSpectatorZ());
+ dInfo.splittingParameters().resize(lastSplittingParameters().size());
+ copy(lastSplittingParameters().begin(),lastSplittingParameters().end(),
+ dInfo.splittingParameters().begin());
+
+}
+
+Lorentz5Momentum DipoleSplittingKinematics::getKt (const Lorentz5Momentum& p1,
+ const Lorentz5Momentum& p2,
+ Energy pt,
+ double phi) const {
+
+ Boost beta = (p1+p2).findBoostToCM();
+
+ Lorentz5Momentum p1c = p1;
+
+ if (beta.mag2() > Constants::epsilon) {
+ p1c.boost(beta);
+ }
+
+ Lorentz5Momentum k (0.*GeV,0.*GeV,0.*GeV,0.*GeV);
+
+ double ct = p1c.vect().unit().z();
+ double st = sqrt(1.-ct*ct);
+
+ double cphi = cos(phi);
+ double sphi = sqrt(1.-cphi*cphi);
+ if (phi > Constants::pi) sphi = -sphi;
+
+ if (st > Constants::epsilon) {
+ double cchi = p1c.vect().unit().x()/st;
+ double schi = p1c.vect().unit().y()/st;
+ k.setX((cphi*cchi*ct-sphi*schi)*pt);
+ k.setY((cphi*schi*ct+sphi*cchi)*pt);
+ k.setZ(-cphi*st*pt);
+ } else {
+ k.setX(pt*cphi);
+ k.setY(pt*sphi);
+ k.setZ(0.*GeV);
+ }
+
+ if (beta.mag2() > Constants::epsilon)
+ k.boost(-beta);
+
+ return k;
+
+}
+
+// If needed, insert default implementations of virtual function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+AbstractClassDescription<DipoleSplittingKinematics> DipoleSplittingKinematics::initDipoleSplittingKinematics;
+// Definition of the static class description member.
+
+void DipoleSplittingKinematics::Init() {
+
+ static ClassDocumentation<DipoleSplittingKinematics> documentation
+ ("DipoleSplittingKinematics is the base class for dipole splittings "
+ "as performed in the dipole shower.");
+
+
+ static Parameter<DipoleSplittingKinematics,Energy> interfaceIRCutoff
+ ("IRCutoff",
+ "The IR cutoff to be used by this splitting kinematics.",
+ &DipoleSplittingKinematics::theIRCutoff, GeV, 1.0*GeV, 0.0*GeV, 0*GeV,
+ false, false, Interface::lowerlim);
+
+
+ static Parameter<DipoleSplittingKinematics,double> interfaceXMin
+ ("XMin",
+ "The minimum momentum fraction for incoming partons",
+ &DipoleSplittingKinematics::theXMin, 1.0e-5, 0.0, 1.0,
+ false, false, Interface::limited);
+
+
+ static Reference<DipoleSplittingKinematics,DipoleMCCheck> interfaceMCCheck
+ ("MCCheck",
+ "[debug option] MCCheck",
+ &DipoleSplittingKinematics::theMCCheck, false, false, true, true, false);
+
+ interfaceMCCheck.rank(-1);
+
+}
+
diff --git a/DipoleShower/Kinematics/DipoleSplittingKinematics.h b/DipoleShower/Kinematics/DipoleSplittingKinematics.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kinematics/DipoleSplittingKinematics.h
@@ -0,0 +1,475 @@
+// -*- C++ -*-
+//
+// DipoleSplittingKinematics.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_DipoleSplittingKinematics_H
+#define HERWIG_DipoleSplittingKinematics_H
+//
+// This is the declaration of the DipoleSplittingKinematics class.
+//
+
+#include "ThePEG/Handlers/HandlerBase.h"
+#include "ThePEG/Vectors/Lorentz5Vector.h"
+
+#include "Herwig++/DipoleShower/Utility/DipoleMCCheck.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+class DipoleIndex;
+class DipoleSplittingInfo;
+class DipoleSplittingKernel;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief DipoleSplittingKinematics is the base class for dipole splittings
+ * as performed in the dipole shower.
+ *
+ * @see \ref DipoleSplittingKinematicsInterfaces "The interfaces"
+ * defined for DipoleSplittingKinematics.
+ */
+class DipoleSplittingKinematics: public HandlerBase {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ DipoleSplittingKinematics();
+
+ /**
+ * The destructor.
+ */
+ virtual ~DipoleSplittingKinematics();
+ //@}
+
+public:
+
+ /**
+ * Return the boundaries in between the evolution
+ * variable random number is to be sampled; the lower
+ * cuoff is assumed to correspond to the infrared cutoff.
+ */
+ virtual pair<double,double> kappaSupport(const DipoleSplittingInfo& dIndex) const = 0;
+
+ /**
+ * Return the boundaries in between the momentum
+ * fraction random number is to be sampled.
+ */
+ virtual pair<double,double> xiSupport(const DipoleSplittingInfo& dIndex) const = 0;
+
+ /**
+ * Return the dipole scale associated to the
+ * given pair of emitter and spectator. This
+ * should be the invariant mass or absolute value
+ * final/final or initial/initial and the absolute
+ * value of the momentum transfer for intial/final or
+ * final/initial dipoles.
+ */
+ virtual Energy dipoleScale(const Lorentz5Momentum& pEmitter,
+ const Lorentz5Momentum& pSpectator) const = 0;
+
+ /**
+ * Return the maximum pt for the given dipole scale.
+ */
+ virtual Energy ptMax(Energy dScale,
+ double emX, double specX,
+ const DipoleIndex& dIndex,
+ const DipoleSplittingKernel& split) const = 0;
+
+ /**
+ * Return the maximum virtuality for the given dipole scale.
+ */
+ virtual Energy QMax(Energy dScale,
+ double emX, double specX,
+ const DipoleIndex& dIndex) const = 0;
+
+ /**
+ * Return the pt given a virtuality.
+ */
+ virtual Energy PtFromQ(Energy scale, const DipoleSplittingInfo&) const = 0;
+
+ /**
+ * Return the virtuality given a pt.
+ */
+ virtual Energy QFromPt(Energy scale, const DipoleSplittingInfo&) const = 0;
+
+ /**
+ * Return the infrared cutoff.
+ */
+ virtual Energy IRCutoff() const { return theIRCutoff; }
+
+ /**
+ * Return the minimum momentum fraction for
+ * incoming partons
+ */
+ double xMin() const { return theXMin; }
+
+ /**
+ * Return the random number associated to
+ * the given pt.
+ */
+ virtual double ptToRandom(Energy pt, Energy dScale,
+ const DipoleIndex& dIndex) const = 0;
+
+ /**
+ * Generate splitting variables given three random numbers
+ * and the momentum fractions of the emitter and spectator.
+ * Return true on success.
+ */
+ virtual bool generateSplitting(double kappa, double xi, double phi,
+ DipoleSplittingInfo& dIndex) = 0;
+
+ /**
+ * For the splitting products present in the given dipole splitting
+ * info object calculate the kinematics parameters and return the
+ * propagator factor.
+ */
+ virtual InvEnergy2 setKinematics(DipoleSplittingInfo&) const = 0;
+
+ /**
+ * For the splitting parameters given in the dipole splitting info
+ * object, calculate the phasespace Jacobian times the propagator
+ * factor.
+ */
+ virtual double jacobianTimesPropagator(const DipoleSplittingInfo&,
+ Energy) const = 0;
+
+ /**
+ * Get the splitting phasespace weight associated to
+ * the last call to generateSplitting. This is taken to
+ * be the single particle phasespace times 16 \pi^2 divided
+ * by the relevant propagator invariant.
+ */
+ double jacobian() const { return theJacobian; }
+
+ /**
+ * Return true, if this splitting kinematics
+ * class is capable of delivering an overestimate
+ * to the jacobian.
+ */
+ virtual bool haveOverestimate() const { return false; }
+
+ /**
+ * Return the overestimated jacobian for the
+ * last generated parameters.
+ */
+ virtual double jacobianOverestimate() const { return -1.; }
+
+ /**
+ * Return the last generated pt
+ */
+ Energy lastPt() const { return theLastPt; }
+
+ /**
+ * Return the last generated momentum fraction.
+ */
+ double lastZ() const { return theLastZ; }
+
+ /**
+ * Return the last generated azimuthal angle.
+ */
+ double lastPhi() const { return theLastPhi; }
+
+ /**
+ * Return the momentum fraction, by which the emitter's
+ * momentum fraction should be divided after the splitting.
+ */
+ double lastEmitterZ() const { return theLastEmitterZ; }
+
+ /**
+ * Return the momentum fraction, by which the spectator's
+ * momentum fraction should be divided after the splitting.
+ */
+ double lastSpectatorZ() const { return theLastSpectatorZ; }
+
+ /**
+ * Return any additional parameters needed to
+ * evaluate the splitting kernel or to generate the
+ * full splitting.
+ */
+ const vector<double>& lastSplittingParameters() const { return theLastSplittingParameters; }
+
+ /**
+ * Complete a DipoleSplittingInfo object with
+ * the parameters generated by the last call to
+ * generateSplitting()
+ */
+ void prepareSplitting(DipoleSplittingInfo& dInfo);
+
+public:
+
+ /**
+ * Generate the full kinematics given emitter and
+ * spectator momentum and a previously completeted
+ * DipoleSplittingInfo object.
+ */
+ virtual void generateKinematics(const Lorentz5Momentum& pEmitter,
+ const Lorentz5Momentum& pSpectator,
+ const DipoleSplittingInfo& dInfo) = 0;
+
+ /**
+ * Return the emitter's momentum after the splitting.
+ */
+ const Lorentz5Momentum& lastEmitterMomentum() const { return theEmitterMomentum; }
+
+ /**
+ * Return the spectator's momentum after the splitting.
+ */
+ const Lorentz5Momentum& lastSpectatorMomentum() const { return theSpectatorMomentum; }
+
+ /**
+ * Return the emission's momentum.
+ */
+ const Lorentz5Momentum& lastEmissionMomentum() const { return theEmissionMomentum; }
+
+ /*
+ * Return true, if there is a transformation which should
+ * be applied to all other final state particles except the ones
+ * involved in the splitting after having performed the splitting
+ */
+ virtual bool doesTransform () const { return false; }
+
+ /*
+ * perform the transformation, if existing
+ */
+ virtual Lorentz5Momentum transform (const Lorentz5Momentum& p) const { return p; }
+
+protected:
+
+ /**
+ * Calculate a transverse momentum for the given momenta,
+ * invariant pt and azimuth.
+ */
+ Lorentz5Momentum getKt (const Lorentz5Momentum& p1,
+ const Lorentz5Momentum& p2,
+ Energy pt,
+ double phi) const;
+
+ /**
+ * Set the splitting phasespace weight associated to
+ * the last call to generateSplitting. This is taken to
+ * be the single particle phasespace times 16 \pi^2 divided
+ * by the relevant propagator invariant.
+ */
+ void jacobian(double w) { theJacobian = w; }
+
+ /**
+ * Set the last generated pt
+ */
+ void lastPt(Energy p) { theLastPt = p; }
+
+ /**
+ * Set the last generated momentum fraction.
+ */
+ void lastZ(double z) { theLastZ = z; }
+
+ /**
+ * Set the last generated azimuthal angle.
+ */
+ void lastPhi(double p) { theLastPhi = p; }
+
+ /**
+ * Set the momentum fraction, by which the emitter's
+ * momentum fraction should be divided after the splitting.
+ */
+ void lastEmitterZ(double z) { theLastEmitterZ = z; }
+
+ /**
+ * Set the momentum fraction, by which the spectator's
+ * momentum fraction should be divided after the splitting.
+ */
+ void lastSpectatorZ(double z) { theLastSpectatorZ = z; }
+
+ /**
+ * Access any additional parameters needed to
+ * evaluate the splitting kernel or to generate the
+ * full splitting.
+ */
+ vector<double>& splittingParameters() { return theLastSplittingParameters; }
+
+ /**
+ * Set the emitter's momentum after the splitting.
+ */
+ void emitterMomentum(const Lorentz5Momentum& p) { theEmitterMomentum = p; }
+
+ /**
+ * Set the spectator's momentum after the splitting.
+ */
+ void spectatorMomentum(const Lorentz5Momentum& p) { theSpectatorMomentum = p; }
+
+ /**
+ * Set the emission's momentum.
+ */
+ void emissionMomentum(const Lorentz5Momentum& p) { theEmissionMomentum = p; }
+
+public:
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+private:
+
+ /**
+ * The infrared cutoff associated to this
+ * splitting kinematics.
+ */
+ Energy theIRCutoff;
+
+ /**
+ * The minimum momentum fraction for
+ * incoming partons
+ */
+ double theXMin;
+
+ /**
+ * The last calculated splitting phase space weight.
+ */
+ double theJacobian;
+
+ /**
+ * The last generated pt
+ */
+ Energy theLastPt;
+
+ /**
+ * The last generated momentum fraction.
+ */
+ double theLastZ;
+
+ /**
+ * The last generated azimuthal angle.
+ */
+ double theLastPhi;
+
+ /**
+ * The momentum fraction, by which the emitter's
+ * momentum fraction should be divided after the splitting.
+ */
+ double theLastEmitterZ;
+
+ /**
+ * The momentum fraction, by which the spectator's
+ * momentum fraction should be divided after the splitting.
+ */
+ double theLastSpectatorZ;
+
+ /**
+ * Any additional parameters needed to
+ * evaluate the splitting kernel or to generate the
+ * full splitting.
+ */
+ vector<double> theLastSplittingParameters;
+
+ /**
+ * The emitter's momentum after the splitting.
+ */
+ Lorentz5Momentum theEmitterMomentum;
+
+ /**
+ * The emission's momentum after the splitting.
+ */
+ Lorentz5Momentum theEmissionMomentum;
+
+ /**
+ * The spectator's momentum after the splitting.
+ */
+ Lorentz5Momentum theSpectatorMomentum;
+
+protected:
+
+ /**
+ * Pointer to a check histogram object
+ */
+ Ptr<DipoleMCCheck>::ptr theMCCheck;
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is an abstract class.
+ */
+ static AbstractClassDescription<DipoleSplittingKinematics> initDipoleSplittingKinematics;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ DipoleSplittingKinematics & operator=(const DipoleSplittingKinematics &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of DipoleSplittingKinematics. */
+template <>
+struct BaseClassTrait<Herwig::DipoleSplittingKinematics,1> {
+ /** Typedef of the first base class of DipoleSplittingKinematics. */
+ typedef HandlerBase NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the DipoleSplittingKinematics class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::DipoleSplittingKinematics>
+ : public ClassTraitsBase<Herwig::DipoleSplittingKinematics> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::DipoleSplittingKinematics"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * DipoleSplittingKinematics is implemented. It may also include several, space-separated,
+ * libraries if the class DipoleSplittingKinematics depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_DipoleSplittingKinematics_H */
diff --git a/DipoleShower/Kinematics/FFLightKinematics.cc b/DipoleShower/Kinematics/FFLightKinematics.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kinematics/FFLightKinematics.cc
@@ -0,0 +1,239 @@
+// -*- C++ -*-
+//
+// FFLightKinematics.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the FFLightKinematics class.
+//
+
+#include "FFLightKinematics.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+#include "ThePEG/Repository/UseRandom.h"
+#include "ThePEG/Repository/EventGenerator.h"
+#include "Herwig++/DipoleShower/Base/DipoleSplittingInfo.h"
+
+using namespace Herwig;
+
+FFLightKinematics::FFLightKinematics()
+ : DipoleSplittingKinematics() {}
+
+FFLightKinematics::~FFLightKinematics() {}
+
+IBPtr FFLightKinematics::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr FFLightKinematics::fullclone() const {
+ return new_ptr(*this);
+}
+
+pair<double,double> FFLightKinematics::kappaSupport(const DipoleSplittingInfo&) const {
+ return make_pair(0.0,1.0);
+}
+
+pair<double,double> FFLightKinematics::xiSupport(const DipoleSplittingInfo& split) const {
+ double c = sqrt(1.-4.*sqr(IRCutoff()/generator()->maximumCMEnergy()));
+ if ( split.index().emitterData()->id() == ParticleID::g ) {
+ if ( split.emissionData()->id() != ParticleID::g )
+ return make_pair(0.5*(1.-c),0.5*(1.+c));
+ double b = log((1.+c)/(1.-c));
+ return make_pair(-b,b);
+ }
+ return make_pair(-log(0.5*(1.+c)),-log(0.5*(1.-c)));
+}
+
+Energy FFLightKinematics::dipoleScale(const Lorentz5Momentum& pEmitter,
+ const Lorentz5Momentum& pSpectator) const {
+ return sqrt(2.*(pEmitter*pSpectator));
+}
+
+Energy FFLightKinematics::ptMax(Energy dScale,
+ double, double,
+ const DipoleIndex&,
+ const DipoleSplittingKernel&) const {
+ return dScale/2.;
+}
+
+Energy FFLightKinematics::QMax(Energy dScale,
+ double, double,
+ const DipoleIndex&) const {
+ return dScale;
+}
+
+Energy FFLightKinematics::PtFromQ(Energy scale, const DipoleSplittingInfo& split) const {
+ double z = split.lastZ();
+ return scale*sqrt(z*(1.-z));
+}
+
+Energy FFLightKinematics::QFromPt(Energy scale, const DipoleSplittingInfo& split) const {
+ double z = split.lastZ();
+ return scale/sqrt(z*(1.-z));
+}
+
+double FFLightKinematics::ptToRandom(Energy pt, Energy,
+ const DipoleIndex&) const {
+ return log(pt/IRCutoff()) / log(0.5 * generator()->maximumCMEnergy()/IRCutoff());
+}
+
+bool FFLightKinematics::generateSplitting(double kappa, double xi, double rphi,
+ DipoleSplittingInfo& info) {
+
+ Energy pt = IRCutoff() * pow(0.5 * generator()->maximumCMEnergy()/IRCutoff(),kappa);
+
+ if ( pt > info.hardPt() ) {
+ jacobian(0.0);
+ return false;
+ }
+
+ double z;
+ double mapZJacobian;
+
+ if ( info.index().emitterData()->id() == ParticleID::g ) {
+ if ( info.emissionData()->id() != ParticleID::g ) {
+ z = xi;
+ mapZJacobian = 1.;
+ } else {
+ z = exp(xi)/(1.+exp(xi));
+ mapZJacobian = z*(1.-z);
+ }
+ } else {
+ z = 1.-exp(-xi);
+ mapZJacobian = 1.-z;
+ }
+
+ double s = z*(1.-z);
+ double zp = 0.5*(1.+sqrt(1.-sqr(pt/info.hardPt())));
+ double zm = 0.5*(1.-sqrt(1.-sqr(pt/info.hardPt())));
+
+ if ( pt < IRCutoff() ||
+ pt > info.hardPt() ||
+ z > zp || z < zm ) {
+ jacobian(0.0);
+ return false;
+ }
+
+ double phi = 2.*Constants::pi*rphi;
+
+ jacobian( 2. * mapZJacobian * (1. - sqr(pt) / (s * sqr(info.scale())) ) *
+ log(0.5 * generator()->maximumCMEnergy()/IRCutoff()) );
+
+ lastPt(pt);
+ lastZ(z);
+ lastPhi(phi);
+
+ if ( theMCCheck )
+ theMCCheck->book(1.,1.,info.scale(),info.hardPt(),pt,z,jacobian());
+
+ return true;
+
+}
+
+InvEnergy2 FFLightKinematics::setKinematics(DipoleSplittingInfo& split) const {
+
+ Lorentz5Momentum emitter = split.splitEmitter()->momentum();
+ Lorentz5Momentum emission = split.emission()->momentum();
+ Lorentz5Momentum spectator = split.splitSpectator()->momentum();
+
+ split.splittingKinematics(const_cast<FFLightKinematics*>(this));
+
+ Energy2 scale = 2.*(emission*emitter + emission*spectator + emitter*spectator);
+ split.scale(sqrt(scale));
+
+ double y = 2.*emission*emitter / scale;
+ double z = emitter*spectator / (emitter*spectator + emission*spectator);
+
+ split.lastPt(split.scale() * sqrt(y*z*(1.-z)));
+ split.lastZ(z);
+
+ split.hardPt(split.lastPt());
+
+ if ( split.hardPt() > IRCutoff() ) {
+ split.continuesEvolving();
+ } else {
+ split.didStopEvolving();
+ }
+
+ return 1./(2.*(emitter*emission));
+
+}
+
+double FFLightKinematics::
+jacobianTimesPropagator(const DipoleSplittingInfo& split,
+ Energy scale) const {
+
+ Energy pt = split.lastPt();
+ double z = split.lastZ();
+ double s = z*(1.-z);
+ double zp = 0.5*(1.+sqrt(1.-sqr(pt/split.hardPt())));
+ double zm = 0.5*(1.-sqrt(1.-sqr(pt/split.hardPt())));
+
+ if ( pt < IRCutoff() ||
+ pt > split.hardPt() ||
+ z > zp || z < zm ) {
+ return 0.;
+ }
+
+ return (2.*scale/pt)*(1.-sqr(pt)/(s*sqr(scale)));
+
+}
+
+
+void FFLightKinematics::generateKinematics(const Lorentz5Momentum& pEmitter,
+ const Lorentz5Momentum& pSpectator,
+ const DipoleSplittingInfo& dInfo) {
+
+ double z = dInfo.lastZ();
+ Energy pt = dInfo.lastPt();
+ double y = sqr(pt / (pEmitter+pSpectator).m()) / (z*(1.-z));
+
+ Lorentz5Momentum kt =
+ getKt(pEmitter, pSpectator, pt, dInfo.lastPhi());
+
+ Lorentz5Momentum em = z*pEmitter + y*(1.-z)*pSpectator + kt;
+ em.setMass(0.*GeV);
+ em.rescaleEnergy();
+
+ Lorentz5Momentum emm = (1.-z)*pEmitter + z*y*pSpectator - kt;
+ emm.setMass(0.*GeV);
+ emm.rescaleEnergy();
+
+ Lorentz5Momentum spe = (1.-y)*pSpectator;
+ spe.setMass(0.*GeV);
+ spe.rescaleEnergy();
+
+ emitterMomentum(em);
+ emissionMomentum(emm);
+ spectatorMomentum(spe);
+
+}
+
+// If needed, insert default implementations of function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void FFLightKinematics::persistentOutput(PersistentOStream & ) const {
+}
+
+void FFLightKinematics::persistentInput(PersistentIStream & , int) {
+}
+
+ClassDescription<FFLightKinematics> FFLightKinematics::initFFLightKinematics;
+// Definition of the static class description member.
+
+void FFLightKinematics::Init() {
+
+ static ClassDocumentation<FFLightKinematics> documentation
+ ("FFLightKinematics implements massless splittings "
+ "off a final-final dipole.");
+
+}
+
diff --git a/DipoleShower/Kinematics/FFLightKinematics.h b/DipoleShower/Kinematics/FFLightKinematics.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kinematics/FFLightKinematics.h
@@ -0,0 +1,237 @@
+// -*- C++ -*-
+//
+// FFLightKinematics.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_FFLightKinematics_H
+#define HERWIG_FFLightKinematics_H
+//
+// This is the declaration of the FFLightKinematics class.
+//
+
+#include "DipoleSplittingKinematics.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief FFLightKinematics implements massless splittings
+ * off a final-final dipole.
+ *
+ */
+class FFLightKinematics: public DipoleSplittingKinematics {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ FFLightKinematics();
+
+ /**
+ * The destructor.
+ */
+ virtual ~FFLightKinematics();
+ //@}
+
+public:
+
+ /**
+ * Return the boundaries in between the evolution
+ * variable random number is to be sampled; the lower
+ * cuoff is assumed to correspond to the infrared cutoff.
+ */
+ virtual pair<double,double> kappaSupport(const DipoleSplittingInfo& dIndex) const;
+
+ /**
+ * Return the boundaries in between the momentum
+ * fraction random number is to be sampled.
+ */
+ virtual pair<double,double> xiSupport(const DipoleSplittingInfo& dIndex) const;
+
+ /**
+ * Return the dipole scale associated to the
+ * given pair of emitter and spectator. This
+ * should be the invariant mass or absolute value
+ * final/final or initial/initial and the absolute
+ * value of the momentum transfer for intial/final or
+ * final/initial dipoles.
+ */
+ virtual Energy dipoleScale(const Lorentz5Momentum& pEmitter,
+ const Lorentz5Momentum& pSpectator) const;
+
+ /**
+ * Return the maximum pt for the given dipole scale.
+ */
+ virtual Energy ptMax(Energy dScale,
+ double emX, double specX,
+ const DipoleIndex& dIndex,
+ const DipoleSplittingKernel&) const;
+
+ /**
+ * Return the maximum virtuality for the given dipole scale.
+ */
+ virtual Energy QMax(Energy dScale,
+ double emX, double specX,
+ const DipoleIndex& dIndex) const;
+
+ /**
+ * Return the pt given a virtuality.
+ */
+ virtual Energy PtFromQ(Energy scale, const DipoleSplittingInfo&) const;
+
+ /**
+ * Return the virtuality given a pt.
+ */
+ virtual Energy QFromPt(Energy scale, const DipoleSplittingInfo&) const;
+
+ /**
+ * Return the random number associated to
+ * the given pt.
+ */
+ virtual double ptToRandom(Energy pt, Energy dScale,
+ const DipoleIndex& dIndex) const;
+
+ /**
+ * Generate splitting variables given three random numbers
+ * and the momentum fractions of the emitter and spectator.
+ * Return true on success.
+ */
+ virtual bool generateSplitting(double kappa, double xi, double phi,
+ DipoleSplittingInfo& dIndex);
+
+ /**
+ * For the splitting products present in the given dipole splitting
+ * info object calculate the kinematics parameters and return the
+ * propagator factor.
+ */
+ virtual InvEnergy2 setKinematics(DipoleSplittingInfo&) const;
+
+ /**
+ * For the splitting parameters given in the dipole splitting info
+ * object, calculate the phasespace Jacobian times the propagator
+ * factor.
+ */
+ virtual double jacobianTimesPropagator(const DipoleSplittingInfo&,
+ Energy) const;
+
+ /**
+ * Generate the full kinematics given emitter and
+ * spectator momentum and a previously completeted
+ * DipoleSplittingInfo object.
+ */
+ virtual void generateKinematics(const Lorentz5Momentum& pEmitter,
+ const Lorentz5Momentum& pSpectator,
+ const DipoleSplittingInfo& dInfo);
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<FFLightKinematics> initFFLightKinematics;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ FFLightKinematics & operator=(const FFLightKinematics &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of FFLightKinematics. */
+template <>
+struct BaseClassTrait<Herwig::FFLightKinematics,1> {
+ /** Typedef of the first base class of FFLightKinematics. */
+ typedef Herwig::DipoleSplittingKinematics NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the FFLightKinematics class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::FFLightKinematics>
+ : public ClassTraitsBase<Herwig::FFLightKinematics> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::FFLightKinematics"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * FFLightKinematics is implemented. It may also include several, space-separated,
+ * libraries if the class FFLightKinematics depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_FFLightKinematics_H */
diff --git a/DipoleShower/Kinematics/FFMassiveKinematics.cc b/DipoleShower/Kinematics/FFMassiveKinematics.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kinematics/FFMassiveKinematics.cc
@@ -0,0 +1,322 @@
+// -*- C++ -*-
+//
+// FFMassiveKinematics.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the FFMassiveKinematics class.
+//
+
+#include "FFMassiveKinematics.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+#include "ThePEG/Repository/UseRandom.h"
+#include "ThePEG/Repository/EventGenerator.h"
+#include "Herwig++/DipoleShower/Base/DipoleSplittingInfo.h"
+#include "Herwig++/DipoleShower/Kernels/DipoleSplittingKernel.h"
+
+// TODO: remove after verification
+// only for checking for NaN or inf
+#include <gsl/gsl_math.h>
+
+using namespace Herwig;
+
+FFMassiveKinematics::FFMassiveKinematics()
+ : DipoleSplittingKinematics() {}
+
+FFMassiveKinematics::~FFMassiveKinematics() {}
+
+IBPtr FFMassiveKinematics::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr FFMassiveKinematics::fullclone() const {
+ return new_ptr(*this);
+}
+
+pair<double,double> FFMassiveKinematics::kappaSupport(const DipoleSplittingInfo&) const {
+ return make_pair(0.0,1.0);
+}
+
+pair<double,double> FFMassiveKinematics::xiSupport(const DipoleSplittingInfo& split) const {
+ double c = sqrt(1.-4.*sqr(IRCutoff()/generator()->maximumCMEnergy()));
+ if ( split.index().emitterData()->id() == ParticleID::g ) {
+ if ( split.emissionData()->id() != ParticleID::g )
+ return make_pair(0.5*(1.-c),0.5*(1.+c));
+ double b = log((1.+c)/(1.-c));
+ return make_pair(-b,b);
+ }
+ return make_pair(-log(0.5*(1.+c)),-log(0.5*(1.-c)));
+}
+
+Energy FFMassiveKinematics::dipoleScale(const Lorentz5Momentum& pEmitter,
+ const Lorentz5Momentum& pSpectator) const {
+ return (pEmitter+pSpectator).m();
+}
+
+Energy FFMassiveKinematics::ptMax(Energy dScale,
+ double, double,
+ const DipoleIndex& ind,
+ const DipoleSplittingKernel& split) const {
+ double mui2 = sqr( split.emitter(ind)->mass() / dScale );
+ double mu2 = sqr( split.emission(ind)->mass() / dScale );
+ double muj2 = sqr( split.spectator(ind)->mass() / dScale );
+
+ // stolen from generateSplitting
+ Energy ptmax = rootOfKallen( mui2, mu2, sqr(1.-sqrt(muj2)) ) /
+ ( 2.-2.*sqrt(muj2) ) * dScale;
+
+ return ptmax > 0.*GeV ? ptmax : 0.*GeV;
+}
+
+Energy FFMassiveKinematics::QMax(Energy dScale,
+ double, double,
+ const DipoleIndex& ind) const {
+ double Muj = ind.spectatorData()->mass() / dScale;
+ return dScale * ( 1.-2.*Muj+sqr(Muj) );
+}
+
+// relict
+Energy FFMassiveKinematics::PtFromQ(Energy, const DipoleSplittingInfo&) const {
+ assert(false && "implementation missing");
+ return 0.*GeV;
+}
+Energy FFMassiveKinematics::QFromPt(Energy, const DipoleSplittingInfo&) const {
+ assert(false && "implementation missing");
+ return 0.*GeV;
+}
+
+double FFMassiveKinematics::ptToRandom(Energy pt, Energy,
+ const DipoleIndex&) const {
+ return log(pt/IRCutoff()) / log(0.5 * generator()->maximumCMEnergy()/IRCutoff());
+}
+
+bool FFMassiveKinematics::generateSplitting(double kappa, double xi, double rphi,
+ DipoleSplittingInfo& info) {
+
+ Energy pt = IRCutoff() * pow(0.5 * generator()->maximumCMEnergy()/IRCutoff(),kappa);
+
+ if ( pt > info.hardPt() || pt < IRCutoff() ) {
+ jacobian(0.0);
+ return false;
+ }
+
+ double z;
+ double mapZJacobian;
+
+ if ( info.index().emitterData()->id() == ParticleID::g ) {
+ if ( info.emissionData()->id() != ParticleID::g ) {
+ z = xi;
+ mapZJacobian = 1.;
+ } else {
+ z = exp(xi)/(1.+exp(xi));
+ mapZJacobian = z*(1.-z);
+ }
+ } else {
+ z = 1.-exp(-xi);
+ mapZJacobian = 1.-z;
+ }
+
+ // masses
+ double mui2 = sqr( info.emitterData()->mass() / info.scale() );
+ double mu2 = sqr( info.emissionData()->mass() / info.scale() );
+ double muj2 = sqr( info.spectatorData()->mass() / info.scale() );
+ double Mui2 = 0.;
+ if ( info.emitterData()->id() + info.emissionData()->id() == 0 ) Mui2 = 0.; // gluon
+ else Mui2 = mui2; // (anti)quark
+ double Muj2 = muj2;
+
+ if( sqrt(mui2)+sqrt(mu2)+sqrt(muj2) > 1. ){
+ jacobian(0.0);
+ return false;
+ }
+
+ double bar = 1.-mui2-mu2-muj2;
+ double y = ( sqr( pt / info.scale() ) + sqr(1.-z)*mui2 + z*z*mu2 ) /
+ (z*(1.-z)*bar);
+
+ // phasespace constraint to incorporate ptMax
+ double zp1 = ( 1.+mui2-mu2+muj2-2.*sqrt(muj2) +
+ rootOfKallen(mui2,mu2,sqr(1-sqrt(muj2))) *
+ sqrt( 1.-sqr(pt/info.hardPt()) ) ) /
+ ( 2.*sqr(1.-sqrt(muj2)) );
+ double zm1 = ( 1.+mui2-mu2+muj2-2.*sqrt(muj2) -
+ rootOfKallen(mui2,mu2,sqr(1-sqrt(muj2))) *
+ sqrt( 1.-sqr(pt/info.hardPt()) ) ) /
+ ( 2.*sqr(1.-sqrt(muj2)) );
+ if ( z > zp1 || z < zm1 ) {
+ jacobian(0.0);
+ return false;
+ }
+
+ // kinematic phasespace boundaries for (y,z)
+ double ym = 2.*sqrt(mui2)*sqrt(mu2)/bar;
+ double yp = 1. - 2.*sqrt(muj2)*(1.-sqrt(muj2))/bar;
+ if ( y < ym || y > yp ) {
+ jacobian(0.0);
+ return false;
+ }
+
+ double zm = ( (2.*mui2+bar*y)*(1.-y) - sqrt(y*y-ym*ym)*sqrt(sqr(2.*muj2+bar-bar*y)-4.*muj2) ) /
+ ( 2.*(1.-y)*(mui2+mu2+bar*y) );
+ double zp = ( (2.*mui2+bar*y)*(1.-y) + sqrt(y*y-ym*ym)*sqrt(sqr(2.*muj2+bar-bar*y)-4.*muj2) ) /
+ ( 2.*(1.-y)*(mui2+mu2+bar*y) );
+
+ if ( z < zm || z > zp ) {
+ jacobian(0.0);
+ return false;
+ }
+
+ double phi = 2.*Constants::pi*rphi;
+
+ jacobian( 2. * mapZJacobian * (1.-y) *
+ log(0.5 * generator()->maximumCMEnergy()/IRCutoff()) *
+ bar / rootOfKallen(1.,Mui2,Muj2) );
+
+ lastPt(pt);
+ lastZ(z);
+ lastPhi(phi);
+
+ if ( theMCCheck )
+ theMCCheck->book(1.,1.,info.scale(),info.hardPt(),pt,z,jacobian());
+
+ return true;
+
+}
+
+InvEnergy2 FFMassiveKinematics::setKinematics(DipoleSplittingInfo& split) const {
+
+ // masses
+ double mui2 = sqr( split.emitterData()->mass() / split.scale() );
+ double mu2 = sqr( split.emissionData()->mass() / split.scale() );
+ double muj2 = sqr( split.spectatorData()->mass() / split.scale() );
+ double Mui2 = 0.;
+ if ( split.emitterData()->id() + split.emissionData()->id() == 0 ) Mui2 = 0.; // gluon
+ else Mui2 = mui2; // (anti)quark
+
+ split.splittingKinematics(const_cast<FFMassiveKinematics*>(this));
+
+ Lorentz5Momentum emitter = split.splitEmitter()->momentum();
+ Lorentz5Momentum emission = split.emission()->momentum();
+ Lorentz5Momentum spectator = split.splitSpectator()->momentum();
+
+ Energy2 scale = (emitter+emission+spectator).m2();
+ split.scale(sqrt(scale));
+
+ double y = 2.*emission*emitter / scale / (1.-mui2-mu2-muj2);
+ double z = emitter*spectator / (emitter*spectator + emission*spectator);
+
+ split.lastPt( split.scale() * sqrt( y * (1.-mui2-mu2-muj2) * z*(1.-z) - sqr(1.-z)*mui2 - sqr(z)*mu2 ) );
+ split.lastZ(z);
+
+ split.hardPt(split.lastPt());
+
+ if ( split.hardPt() > IRCutoff() ) {
+ split.continuesEvolving();
+ } else {
+ split.didStopEvolving();
+ }
+
+ return 1./((emitter+emission).m2()-Mui2*sqr(split.scale()));
+
+}
+
+double FFMassiveKinematics::
+jacobianTimesPropagator(const DipoleSplittingInfo&,
+ Energy) const {
+ assert(false && "implementation missing");
+ return 0.;
+}
+
+void FFMassiveKinematics::generateKinematics(const Lorentz5Momentum& pEmitter,
+ const Lorentz5Momentum& pSpectator,
+ const DipoleSplittingInfo& dInfo) {
+
+ double z = dInfo.lastZ();
+ Energy pt = dInfo.lastPt();
+
+ // masses
+ double mui2 = sqr( dInfo.emitterData()->mass() / dInfo.scale() );
+ double mu2 = sqr( dInfo.emissionData()->mass() / dInfo.scale() );
+ double muj2 = sqr( dInfo.spectatorData()->mass() / dInfo.scale() );
+
+ double y = ( sqr( pt / dInfo.scale() ) + sqr(1.-z)*mui2 + z*z*mu2 ) /
+ (z*(1.-z)*(1.-mui2-mu2-muj2));
+
+ Energy2 sbar = sqr(dInfo.scale()) *(1.-mui2-mu2-muj2);
+
+ // CMF: particle energies
+ Energy Ei = ( sbar*(1.-(1.-z)*(1.-y)) + 2.*sqr(dInfo.scale())*mui2 ) / (2.*dInfo.scale());
+ Energy E = ( sbar*(1.- z *(1.-y)) + 2.*sqr(dInfo.scale())*mu2 ) / (2.*dInfo.scale());
+ Energy Ej = ( sbar*(1.- y ) + 2.*sqr(dInfo.scale())*muj2 ) / (2.*dInfo.scale());
+ // CMF: momenta in z-direction (axis of pEmitter & pSpectator)
+ Energy qi3 = (2.*Ei*Ej-z*(1.-y)*sbar ) / 2./sqrt(Ej*Ej-sqr(dInfo.scale())*muj2);
+ Energy q3 = (2.*E *Ej-(1.-z)*(1.-y)*sbar) / 2./sqrt(Ej*Ej-sqr(dInfo.scale())*muj2);
+ Energy qj3 = sqrt( sqr(Ej) - sqr(dInfo.scale())*muj2 );
+
+ // get z axis in the dipole's CMF which is parallel to pSpectator
+ Boost toCMF = (pEmitter+pSpectator).findBoostToCM();
+ Lorentz5Momentum pjAux = pSpectator; pjAux.boost(toCMF);
+ ThreeVector<double> pjAxis = pjAux.vect().unit();
+
+ // set the momenta in this special reference frame
+ // note that pt might in some cases differ from the physical pt!
+ // phi is defined exactly as in getKt
+ Energy ptResc = sqrt( sqr(Ei)-sqr(dInfo.scale())*mui2-sqr(qi3) );
+ Lorentz5Momentum em ( ptResc*cos(dInfo.lastPhi()), -ptResc*sin(dInfo.lastPhi()), qi3, Ei );
+ Lorentz5Momentum emm ( -ptResc*cos(dInfo.lastPhi()), ptResc*sin(dInfo.lastPhi()), q3, E );
+ Lorentz5Momentum spe ( 0.*GeV, 0.*GeV, qj3, Ej );
+
+ // rotate back
+ em.rotateUz (pjAxis);
+ emm.rotateUz(pjAxis);
+ spe.rotateUz(pjAxis);
+
+ // boost back
+ em.boost (-toCMF);
+ emm.boost(-toCMF);
+ spe.boost(-toCMF);
+
+ // mass shells, rescale energy
+ em.setMass(dInfo.scale()*sqrt(mui2));
+ em.rescaleEnergy();
+ emm.setMass(dInfo.scale()*sqrt(mu2));
+ emm.rescaleEnergy();
+ spe.setMass(dInfo.scale()*sqrt(muj2));
+ spe.rescaleEnergy();
+
+ // book
+ emitterMomentum(em);
+ emissionMomentum(emm);
+ spectatorMomentum(spe);
+
+}
+
+// If needed, insert default implementations of function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void FFMassiveKinematics::persistentOutput(PersistentOStream & ) const {
+}
+
+void FFMassiveKinematics::persistentInput(PersistentIStream & , int) {
+}
+
+ClassDescription<FFMassiveKinematics> FFMassiveKinematics::initFFMassiveKinematics;
+// Definition of the static class description member.
+
+void FFMassiveKinematics::Init() {
+
+ static ClassDocumentation<FFMassiveKinematics> documentation
+ ("FFMassiveKinematics implements massive splittings "
+ "off a final-final dipole.");
+
+}
+
diff --git a/DipoleShower/Kinematics/FFMassiveKinematics.h b/DipoleShower/Kinematics/FFMassiveKinematics.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kinematics/FFMassiveKinematics.h
@@ -0,0 +1,246 @@
+// -*- C++ -*-
+//
+// FFMassiveKinematics.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_FFMassiveKinematics_H
+#define HERWIG_FFMassiveKinematics_H
+//
+// This is the declaration of the FFMassiveKinematics class.
+//
+
+#include "DipoleSplittingKinematics.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer and Martin Stoll
+ *
+ * \brief FFMassiveKinematics implements massive splittings
+ * off a final-final dipole.
+ *
+ */
+class FFMassiveKinematics: public DipoleSplittingKinematics {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ FFMassiveKinematics();
+
+ /**
+ * The destructor.
+ */
+ virtual ~FFMassiveKinematics();
+ //@}
+
+public:
+
+ /**
+ * Return the boundaries in between the evolution
+ * variable random number is to be sampled; the lower
+ * cuoff is assumed to correspond to the infrared cutoff.
+ */
+ virtual pair<double,double> kappaSupport(const DipoleSplittingInfo& dIndex) const;
+
+ /**
+ * Return the boundaries in between the momentum
+ * fraction random number is to be sampled.
+ */
+ virtual pair<double,double> xiSupport(const DipoleSplittingInfo& dIndex) const;
+
+ /**
+ * Return the dipole scale associated to the
+ * given pair of emitter and spectator. This
+ * should be the invariant mass or absolute value
+ * final/final or initial/initial and the absolute
+ * value of the momentum transfer for intial/final or
+ * final/initial dipoles.
+ */
+ virtual Energy dipoleScale(const Lorentz5Momentum& pEmitter,
+ const Lorentz5Momentum& pSpectator) const;
+
+ /**
+ * Return the maximum pt for the given dipole scale.
+ */
+ virtual Energy ptMax(Energy dScale,
+ double emX, double specX,
+ const DipoleIndex& ind,
+ const DipoleSplittingKernel& split) const;
+
+ /**
+ * Return the maximum virtuality for the given dipole scale.
+ */
+ virtual Energy QMax(Energy dScale,
+ double emX, double specX,
+ const DipoleIndex& dIndex) const;
+
+ /**
+ * Return the pt given a virtuality.
+ */
+ virtual Energy PtFromQ(Energy scale, const DipoleSplittingInfo&) const;
+
+ /**
+ * Return the virtuality given a pt.
+ */
+ virtual Energy QFromPt(Energy scale, const DipoleSplittingInfo&) const;
+
+ /**
+ * Return the random number associated to
+ * the given pt.
+ */
+ virtual double ptToRandom(Energy pt, Energy dScale,
+ const DipoleIndex& dIndex) const;
+
+ /**
+ * Generate splitting variables given three random numbers
+ * and the momentum fractions of the emitter and spectator.
+ * Return true on success.
+ */
+ virtual bool generateSplitting(double kappa, double xi, double phi,
+ DipoleSplittingInfo& dIndex);
+
+ /**
+ * For the splitting products present in the given dipole splitting
+ * info object calculate the kinematics parameters and return the
+ * propagator factor.
+ */
+ virtual InvEnergy2 setKinematics(DipoleSplittingInfo&) const;
+
+ /**
+ * For the splitting parameters given in the dipole splitting info
+ * object, calculate the phasespace Jacobian times the propagator
+ * factor.
+ */
+ virtual double jacobianTimesPropagator(const DipoleSplittingInfo&,
+ Energy) const;
+
+ /**
+ * Generate the full kinematics given emitter and
+ * spectator momentum and a previously completeted
+ * DipoleSplittingInfo object.
+ */
+ virtual void generateKinematics(const Lorentz5Momentum& pEmitter,
+ const Lorentz5Momentum& pSpectator,
+ const DipoleSplittingInfo& dInfo);
+
+public:
+
+ /**
+ * Triangular / Kallen function
+ */
+ template <class T>
+ inline double rootOfKallen (T a, T b, T c) const {
+ return sqrt( a*a + b*b + c*c - 2.*( a*b+a*c+b*c ) ); }
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<FFMassiveKinematics> initFFMassiveKinematics;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ FFMassiveKinematics & operator=(const FFMassiveKinematics &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of FFMassiveKinematics. */
+template <>
+struct BaseClassTrait<Herwig::FFMassiveKinematics,1> {
+ /** Typedef of the first base class of FFMassiveKinematics. */
+ typedef Herwig::DipoleSplittingKinematics NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the FFMassiveKinematics class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::FFMassiveKinematics>
+ : public ClassTraitsBase<Herwig::FFMassiveKinematics> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::FFMassiveKinematics"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * FFMassiveKinematics is implemented. It may also include several, space-separated,
+ * libraries if the class FFMassiveKinematics depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_FFMassiveKinematics_H */
diff --git a/DipoleShower/Kinematics/FILightKinematics.cc b/DipoleShower/Kinematics/FILightKinematics.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kinematics/FILightKinematics.cc
@@ -0,0 +1,242 @@
+// -*- C++ -*-
+//
+// FILightKinematics.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the FILightKinematics class.
+//
+
+#include "FILightKinematics.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+#include "ThePEG/Repository/UseRandom.h"
+#include "ThePEG/Repository/EventGenerator.h"
+#include "Herwig++/DipoleShower/Base/DipoleSplittingInfo.h"
+
+using namespace Herwig;
+
+FILightKinematics::FILightKinematics()
+ : DipoleSplittingKinematics() {}
+
+FILightKinematics::~FILightKinematics() {}
+
+IBPtr FILightKinematics::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr FILightKinematics::fullclone() const {
+ return new_ptr(*this);
+}
+
+pair<double,double> FILightKinematics::kappaSupport(const DipoleSplittingInfo&) const {
+ return make_pair(0.0,1.0);
+}
+
+pair<double,double> FILightKinematics::xiSupport(const DipoleSplittingInfo& split) const {
+ double c = sqrt(1.-4.*sqr(IRCutoff()/generator()->maximumCMEnergy()));
+ if ( split.index().emitterData()->id() == ParticleID::g ) {
+ if ( split.emissionData()->id() != ParticleID::g )
+ return make_pair(0.5*(1.-c),0.5*(1.+c));
+ double b = log((1.+c)/(1.-c));
+ return make_pair(-b,b);
+ }
+ return make_pair(-log(0.5*(1.+c)),-log(0.5*(1.-c)));
+}
+
+Energy FILightKinematics::dipoleScale(const Lorentz5Momentum& pEmitter,
+ const Lorentz5Momentum& pSpectator) const {
+ return sqrt(2.*(pEmitter*pSpectator));
+}
+
+Energy FILightKinematics::ptMax(Energy dScale,
+ double, double specX,
+ const DipoleIndex&,
+ const DipoleSplittingKernel&) const {
+ return dScale * sqrt((1.-specX)/specX) /2.;
+}
+
+Energy FILightKinematics::QMax(Energy dScale,
+ double, double specX,
+ const DipoleIndex&) const {
+ return dScale * sqrt((1.-specX)/specX);
+}
+
+Energy FILightKinematics::PtFromQ(Energy scale, const DipoleSplittingInfo& split) const {
+ double z = split.lastZ();
+ return scale*sqrt(z*(1.-z));
+}
+
+Energy FILightKinematics::QFromPt(Energy scale, const DipoleSplittingInfo& split) const {
+ double z = split.lastZ();
+ return scale/sqrt(z*(1.-z));
+}
+
+
+double FILightKinematics::ptToRandom(Energy pt, Energy,
+ const DipoleIndex&) const {
+ return log(pt/IRCutoff()) / log(0.5 * generator()->maximumCMEnergy()/IRCutoff());
+}
+
+bool FILightKinematics::generateSplitting(double kappa, double xi, double rphi,
+ DipoleSplittingInfo& info) {
+
+ if ( info.spectatorX() < xMin() ) {
+ jacobian(0.0);
+ return false;
+ }
+
+ Energy pt = IRCutoff() * pow(0.5 * generator()->maximumCMEnergy()/IRCutoff(),kappa);
+
+ if ( pt > info.hardPt() ) {
+ jacobian(0.0);
+ return false;
+ }
+
+ double z;
+ double mapZJacobian;
+
+ if ( info.index().emitterData()->id() == ParticleID::g ) {
+ if ( info.emissionData()->id() != ParticleID::g ) {
+ z = xi;
+ mapZJacobian = 1.;
+ } else {
+ z = exp(xi)/(1.+exp(xi));
+ mapZJacobian = z*(1.-z);
+ }
+ } else {
+ z = 1.-exp(-xi);
+ mapZJacobian = 1.-z;
+ }
+
+ double s = z*(1.-z);
+
+ double xs = info.spectatorX();
+
+ double x = 1. / ( 1. + sqr(pt/info.scale()) / s );
+
+ double zp = 0.5*(1.+sqrt(1.-sqr(pt/info.hardPt())));
+ double zm = 0.5*(1.-sqrt(1.-sqr(pt/info.hardPt())));
+
+ if ( pt < IRCutoff() ||
+ pt > info.hardPt() ||
+ z > zp || z < zm ||
+ x < xs ) {
+ jacobian(0.0);
+ return false;
+ }
+
+ double phi = 2.*Constants::pi*rphi;
+
+ jacobian( 2. * mapZJacobian * log(0.5 * generator()->maximumCMEnergy()/IRCutoff()));
+
+ lastPt(pt);
+ lastZ(z);
+ lastPhi(phi);
+ lastSpectatorZ(x);
+
+ if ( theMCCheck )
+ theMCCheck->book(1.,info.spectatorX(),info.scale(),info.hardPt(),pt,z,jacobian());
+
+ return true;
+
+}
+
+InvEnergy2 FILightKinematics::setKinematics(DipoleSplittingInfo& split) const {
+
+ Lorentz5Momentum emitter = split.splitEmitter()->momentum();
+ Lorentz5Momentum emission = split.emission()->momentum();
+ Lorentz5Momentum spectator = split.splitSpectator()->momentum();
+
+ split.splittingKinematics(const_cast<FILightKinematics*>(this));
+
+ Energy2 scale = 2.*(- emission*emitter + emission*spectator + emitter*spectator);
+ split.scale(sqrt(scale));
+
+ double x =
+ scale / (2.*(emitter*spectator + emission*spectator));
+ double z = emitter*spectator / (emitter*spectator + emission*spectator);
+
+ split.lastPt(split.scale() * sqrt(z*(1.-z)*(1.-x)/x));
+ split.lastZ(z);
+
+ split.hardPt(split.lastPt());
+
+ if ( split.hardPt() > IRCutoff() ) {
+ split.continuesEvolving();
+ } else {
+ split.didStopEvolving();
+ }
+
+ return 1./(2.*x*(emitter*emission));
+
+}
+
+double FILightKinematics::
+jacobianTimesPropagator(const DipoleSplittingInfo&,
+ Energy) const {
+ assert(false && "implementation missing");
+ return 0.;
+}
+
+
+void FILightKinematics::generateKinematics(const Lorentz5Momentum& pEmitter,
+ const Lorentz5Momentum& pSpectator,
+ const DipoleSplittingInfo& dInfo) {
+
+ Energy pt = dInfo.lastPt();
+ double z = dInfo.lastZ();
+
+ Lorentz5Momentum kt =
+ getKt (pEmitter, pSpectator, pt, dInfo.lastPhi());
+
+ double ratio = sqr(pt/(-(pEmitter-pSpectator).m()));
+ double xInv = (1.+ratio/(z*(1.-z)));
+
+ Lorentz5Momentum em = z*pEmitter + (ratio/z)*pSpectator + kt;
+ em.setMass(0.*GeV);
+ em.rescaleEnergy();
+
+ Lorentz5Momentum emm = (1.-z)*pEmitter + (ratio/(1.-z))*pSpectator - kt;
+ emm.setMass(0.*GeV);
+ emm.rescaleEnergy();
+
+ Lorentz5Momentum spe = xInv*pSpectator;
+ spe.setMass(0.*GeV);
+ spe.rescaleEnergy();
+
+ emitterMomentum(em);
+ emissionMomentum(emm);
+ spectatorMomentum(spe);
+
+}
+
+// If needed, insert default implementations of function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void FILightKinematics::persistentOutput(PersistentOStream & ) const {
+}
+
+void FILightKinematics::persistentInput(PersistentIStream & , int) {
+}
+
+ClassDescription<FILightKinematics> FILightKinematics::initFILightKinematics;
+// Definition of the static class description member.
+
+void FILightKinematics::Init() {
+
+ static ClassDocumentation<FILightKinematics> documentation
+ ("FILightKinematics implements massless splittings "
+ "off a final-initial dipole.");
+
+}
+
diff --git a/DipoleShower/Kinematics/FILightKinematics.h b/DipoleShower/Kinematics/FILightKinematics.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kinematics/FILightKinematics.h
@@ -0,0 +1,237 @@
+// -*- C++ -*-
+//
+// FILightKinematics.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_FILightKinematics_H
+#define HERWIG_FILightKinematics_H
+//
+// This is the declaration of the FILightKinematics class.
+//
+
+#include "DipoleSplittingKinematics.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief FILightKinematics implements massless splittings
+ * off a final-initial dipole.
+ *
+ */
+class FILightKinematics: public DipoleSplittingKinematics {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ FILightKinematics();
+
+ /**
+ * The destructor.
+ */
+ virtual ~FILightKinematics();
+ //@}
+
+public:
+
+ /**
+ * Return the boundaries in between the evolution
+ * variable random number is to be sampled; the lower
+ * cuoff is assumed to correspond to the infrared cutoff.
+ */
+ virtual pair<double,double> kappaSupport(const DipoleSplittingInfo& dIndex) const;
+
+ /**
+ * Return the boundaries in between the momentum
+ * fraction random number is to be sampled.
+ */
+ virtual pair<double,double> xiSupport(const DipoleSplittingInfo& dIndex) const;
+
+ /**
+ * Return the dipole scale associated to the
+ * given pair of emitter and spectator. This
+ * should be the invariant mass or absolute value
+ * final/final or initial/initial and the absolute
+ * value of the momentum transfer for intial/final or
+ * final/initial dipoles.
+ */
+ virtual Energy dipoleScale(const Lorentz5Momentum& pEmitter,
+ const Lorentz5Momentum& pSpectator) const;
+
+ /**
+ * Return the maximum pt for the given dipole scale.
+ */
+ virtual Energy ptMax(Energy dScale,
+ double emX, double specX,
+ const DipoleIndex& dIndex,
+ const DipoleSplittingKernel&) const;
+
+ /**
+ * Return the maximum virtuality for the given dipole scale.
+ */
+ virtual Energy QMax(Energy dScale,
+ double emX, double specX,
+ const DipoleIndex& dIndex) const;
+
+ /**
+ * Return the pt given a virtuality.
+ */
+ virtual Energy PtFromQ(Energy scale, const DipoleSplittingInfo&) const;
+
+ /**
+ * Return the virtuality given a pt.
+ */
+ virtual Energy QFromPt(Energy scale, const DipoleSplittingInfo&) const;
+
+ /**
+ * Return the random number associated to
+ * the given pt.
+ */
+ virtual double ptToRandom(Energy pt, Energy dScale,
+ const DipoleIndex& dIndex) const;
+
+ /**
+ * Generate splitting variables given three random numbers
+ * and the momentum fractions of the emitter and spectator.
+ * Return true on success.
+ */
+ virtual bool generateSplitting(double kappa, double xi, double phi,
+ DipoleSplittingInfo& dIndex);
+
+ /**
+ * For the splitting products present in the given dipole splitting
+ * info object calculate the kinematics parameters and return the
+ * propagator factor.
+ */
+ virtual InvEnergy2 setKinematics(DipoleSplittingInfo&) const;
+
+ /**
+ * For the splitting parameters given in the dipole splitting info
+ * object, calculate the phasespace Jacobian times the propagator
+ * factor.
+ */
+ virtual double jacobianTimesPropagator(const DipoleSplittingInfo&,
+ Energy) const;
+
+ /**
+ * Generate the full kinematics given emitter and
+ * spectator momentum and a previously completeted
+ * DipoleSplittingInfo object.
+ */
+ virtual void generateKinematics(const Lorentz5Momentum& pEmitter,
+ const Lorentz5Momentum& pSpectator,
+ const DipoleSplittingInfo& dInfo);
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<FILightKinematics> initFILightKinematics;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ FILightKinematics & operator=(const FILightKinematics &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of FILightKinematics. */
+template <>
+struct BaseClassTrait<Herwig::FILightKinematics,1> {
+ /** Typedef of the first base class of FILightKinematics. */
+ typedef Herwig::DipoleSplittingKinematics NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the FILightKinematics class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::FILightKinematics>
+ : public ClassTraitsBase<Herwig::FILightKinematics> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::FILightKinematics"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * FILightKinematics is implemented. It may also include several, space-separated,
+ * libraries if the class FILightKinematics depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_FILightKinematics_H */
diff --git a/DipoleShower/Kinematics/IFLightKinematics.cc b/DipoleShower/Kinematics/IFLightKinematics.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kinematics/IFLightKinematics.cc
@@ -0,0 +1,314 @@
+// -*- C++ -*-
+//
+// IFLightKinematics.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the IFLightKinematics class.
+//
+
+#include "IFLightKinematics.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/Interface/Switch.h"
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+#include "ThePEG/Repository/UseRandom.h"
+#include "ThePEG/Repository/EventGenerator.h"
+#include "Herwig++/DipoleShower/Base/DipoleSplittingInfo.h"
+
+using namespace Herwig;
+
+IFLightKinematics::IFLightKinematics()
+ : DipoleSplittingKinematics(), theCollinearScheme(false) {}
+
+IFLightKinematics::~IFLightKinematics() {}
+
+IBPtr IFLightKinematics::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr IFLightKinematics::fullclone() const {
+ return new_ptr(*this);
+}
+
+pair<double,double> IFLightKinematics::kappaSupport(const DipoleSplittingInfo&) const {
+ return make_pair(0.0,1.0);
+}
+
+pair<double,double> IFLightKinematics::xiSupport(const DipoleSplittingInfo& split) const {
+
+ double c = sqrt(1.-4.*sqr(IRCutoff()/generator()->maximumCMEnergy()));
+
+ if ( split.index().emitterData()->id() == ParticleID::g ) {
+ if ( split.emitterData()->id() == ParticleID::g ) {
+ double b = log((1.+c)/(1.-c));
+ return make_pair(-b,b);
+ } else {
+ return make_pair(log(0.5*(1.-c)),log(0.5*(1.+c)));
+ }
+ }
+
+ if ( split.index().emitterData()->id() != ParticleID::g &&
+ split.emitterData()->id() != ParticleID::g ) {
+ return make_pair(-log(0.5*(1.+c)),-log(0.5*(1.-c)));
+ }
+
+ return make_pair(0.5*(1.-c),0.5*(1.+c));
+
+}
+
+Energy IFLightKinematics::dipoleScale(const Lorentz5Momentum& pEmitter,
+ const Lorentz5Momentum& pSpectator) const {
+ return sqrt(2.*(pEmitter*pSpectator));
+}
+
+Energy IFLightKinematics::ptMax(Energy dScale,
+ double emX, double,
+ const DipoleIndex&,
+ const DipoleSplittingKernel&) const {
+ return dScale * sqrt(1.-emX) /2.;
+}
+
+Energy IFLightKinematics::QMax(Energy,
+ double, double,
+ const DipoleIndex&) const {
+ assert(false && "add this");
+ return 0.0*GeV;
+}
+
+Energy IFLightKinematics::PtFromQ(Energy, const DipoleSplittingInfo&) const {
+ assert(false && "add this");
+ return 0.0*GeV;
+}
+
+Energy IFLightKinematics::QFromPt(Energy, const DipoleSplittingInfo&) const {
+ assert(false && "add this");
+ return 0.0*GeV;
+}
+
+
+double IFLightKinematics::ptToRandom(Energy pt, Energy,
+ const DipoleIndex&) const {
+ return log(pt/IRCutoff()) / log(0.5 * generator()->maximumCMEnergy()/IRCutoff());
+}
+
+bool IFLightKinematics::generateSplitting(double kappa, double xi, double rphi,
+ DipoleSplittingInfo& info) {
+
+ if ( info.emitterX() < xMin() ) {
+ jacobian(0.0);
+ return false;
+ }
+
+ Energy pt = IRCutoff() * pow(0.5 * generator()->maximumCMEnergy()/IRCutoff(),kappa);
+
+ if ( pt > info.hardPt() ) {
+ jacobian(0.0);
+ return false;
+ }
+
+ double z = 0.;
+ double mapZJacobian = 0.;
+
+ if ( info.index().emitterData()->id() == ParticleID::g ) {
+ if ( info.emitterData()->id() == ParticleID::g ) {
+ z = exp(xi)/(1.+exp(xi));
+ mapZJacobian = z*(1.-z);
+ } else {
+ z = exp(xi);
+ mapZJacobian = z;
+ }
+ }
+
+ if ( info.index().emitterData()->id() != ParticleID::g ) {
+ if ( info.emitterData()->id() != ParticleID::g ) {
+ z = 1.-exp(-xi);
+ mapZJacobian = 1.-z;
+ } else {
+ z = xi;
+ mapZJacobian = 1.;
+ }
+ }
+
+ double ratio = sqr(pt/info.scale());
+
+ double x = ( z*(1.-z) - ratio ) / ( 1. - z - ratio );
+ double u = ratio/(1.-z);
+
+ if ( x < 0. || x > 1. || u > 1. ) {
+ jacobian(0.0);
+ return false;
+ }
+
+ double xe = info.emitterX();
+
+ double zp = 0.5*( 1.+ xe +
+ (1.-xe)*sqrt(1.-sqr(pt/info.hardPt()) ) );
+ double zm = 0.5*( 1.+ xe -
+ (1.-xe)*sqrt(1.-sqr(pt/info.hardPt()) ) );
+
+ if ( pt < IRCutoff() ||
+ pt > info.hardPt() ||
+ z > zp || z < zm ||
+ x < xe ) {
+ jacobian(0.0);
+ return false;
+ }
+
+ double phi = 2.*Constants::pi*rphi;
+
+ jacobian(2. * mapZJacobian * (1.-z)/(z*(1.-z)-ratio) * log(0.5 * generator()->maximumCMEnergy()/IRCutoff()));
+
+ lastPt(pt);
+ lastZ(z);
+ lastPhi(phi);
+ lastEmitterZ(x);
+
+ if ( theMCCheck )
+ theMCCheck->book(info.emitterX(),1.,info.scale(),info.hardPt(),pt,z,jacobian());
+
+ return true;
+
+}
+
+InvEnergy2 IFLightKinematics::setKinematics(DipoleSplittingInfo& split) const {
+
+ Lorentz5Momentum emitter = split.splitEmitter()->momentum();
+ Lorentz5Momentum emission = split.emission()->momentum();
+ Lorentz5Momentum spectator = split.splitSpectator()->momentum();
+
+ split.splittingKinematics(const_cast<IFLightKinematics*>(this));
+
+ Energy2 scale = 2.*(emission*emitter - emission*spectator + emitter*spectator);
+ split.scale(sqrt(scale));
+
+ double x =
+ scale / (2.*(emitter*emission + emitter*spectator));
+ double u = emitter*emission / (emitter*emission + emitter*spectator);
+
+ split.lastPt(split.scale() * sqrt(u*(1.-u)*(1.-x)));
+ split.lastZ(u+x*(1.-u));
+
+ split.hardPt(split.lastPt());
+
+ if ( split.hardPt() > IRCutoff() ) {
+ split.continuesEvolving();
+ } else {
+ split.didStopEvolving();
+ }
+
+ return 1./(2.*x*(emitter*emission));
+
+}
+
+double IFLightKinematics::
+jacobianTimesPropagator(const DipoleSplittingInfo&,
+ Energy) const {
+ assert(false && "implementation missing");
+ return 0.;
+}
+
+void IFLightKinematics::generateKinematics(const Lorentz5Momentum& pEmitter,
+ const Lorentz5Momentum& pSpectator,
+ const DipoleSplittingInfo& dInfo) {
+
+ Energy pt = dInfo.lastPt();
+ double ratio = sqr(pt/-(pEmitter-pSpectator).m());
+ double z = dInfo.lastZ();
+ double x = (z*(1.-z)-ratio)/(1.-z-ratio);
+ double u = ratio / (1.-z);
+
+ pt = -(pEmitter-pSpectator).m()*sqrt(u*(1.-u)*(1.-x)/x);
+
+ Lorentz5Momentum kt =
+ getKt (pEmitter, pSpectator, pt, dInfo.lastPhi());
+
+ Lorentz5Momentum em;
+ Lorentz5Momentum emm;
+ Lorentz5Momentum spe;
+
+ if ( !theCollinearScheme &&
+ x > u && (1.-x)/(x-u) < 1. ) {
+
+ em =
+ ((1.-u)/(x-u))*pEmitter + ((u/x)*(1.-x)/(x-u))*pSpectator - kt/(x-u);
+ em.setMass(0.*GeV);
+ em.rescaleEnergy();
+
+ emm =
+ ((1.-x)/(x-u))*pEmitter + ((u/x)*(1.-u)/(x-u))*pSpectator - kt/(x-u);
+ emm.setMass(0.*GeV);
+ emm.rescaleEnergy();
+
+ spe =
+ (1.-u/x)*pSpectator;
+ spe.setMass(0.*GeV);
+ spe.rescaleEnergy();
+
+ } else {
+
+ em = (1./x)*pEmitter;
+
+ emm = ((1.-x)*(1.-u)/x)*pEmitter + u*pSpectator + kt;
+ emm.setMass(0.*GeV);
+ emm.rescaleEnergy();
+
+ spe = ((1.-x)*u/x)*pEmitter + (1.-u)*pSpectator - kt;
+ spe.setMass(0.*GeV);
+ spe.rescaleEnergy();
+
+ }
+
+ emitterMomentum(em);
+ emissionMomentum(emm);
+ spectatorMomentum(spe);
+
+}
+
+// If needed, insert default implementations of function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void IFLightKinematics::persistentOutput(PersistentOStream & os) const {
+ os << theCollinearScheme;
+}
+
+void IFLightKinematics::persistentInput(PersistentIStream & is, int) {
+ is >> theCollinearScheme;
+}
+
+ClassDescription<IFLightKinematics> IFLightKinematics::initIFLightKinematics;
+// Definition of the static class description member.
+
+void IFLightKinematics::Init() {
+
+ static ClassDocumentation<IFLightKinematics> documentation
+ ("IFLightKinematics implements massless splittings "
+ "off a initial-final dipole.");
+
+
+ static Switch<IFLightKinematics,bool> interfaceCollinearScheme
+ ("CollinearScheme",
+ "[experimental] Switch on or off the collinear scheme",
+ &IFLightKinematics::theCollinearScheme, false, false, false);
+ static SwitchOption interfaceCollinearSchemeOn
+ (interfaceCollinearScheme,
+ "On",
+ "Switch on the collinear scheme.",
+ true);
+ static SwitchOption interfaceCollinearSchemeOff
+ (interfaceCollinearScheme,
+ "Off",
+ "Switch off the collinear scheme",
+ false);
+
+ interfaceCollinearScheme.rank(-1);
+
+}
+
diff --git a/DipoleShower/Kinematics/IFLightKinematics.h b/DipoleShower/Kinematics/IFLightKinematics.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kinematics/IFLightKinematics.h
@@ -0,0 +1,246 @@
+// -*- C++ -*-
+//
+// IFLightKinematics.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_IFLightKinematics_H
+#define HERWIG_IFLightKinematics_H
+//
+// This is the declaration of the IFLightKinematics class.
+//
+
+#include "DipoleSplittingKinematics.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief IFLightKinematics implements massless splittings
+ * off an initial-final dipole.
+ *
+ * @see \ref IFLightKinematicsInterfaces "The interfaces"
+ * defined for IFLightKinematics.
+ */
+class IFLightKinematics: public DipoleSplittingKinematics {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ IFLightKinematics();
+
+ /**
+ * The destructor.
+ */
+ virtual ~IFLightKinematics();
+ //@}
+
+public:
+
+ /**
+ * Return the boundaries in between the evolution
+ * variable random number is to be sampled; the lower
+ * cuoff is assumed to correspond to the infrared cutoff.
+ */
+ virtual pair<double,double> kappaSupport(const DipoleSplittingInfo& dIndex) const;
+
+ /**
+ * Return the boundaries in between the momentum
+ * fraction random number is to be sampled.
+ */
+ virtual pair<double,double> xiSupport(const DipoleSplittingInfo& dIndex) const;
+
+ /**
+ * Return the dipole scale associated to the
+ * given pair of emitter and spectator. This
+ * should be the invariant mass or absolute value
+ * final/final or initial/initial and the absolute
+ * value of the momentum transfer for intial/final or
+ * final/initial dipoles.
+ */
+ virtual Energy dipoleScale(const Lorentz5Momentum& pEmitter,
+ const Lorentz5Momentum& pSpectator) const;
+
+ /**
+ * Return the maximum pt for the given dipole scale.
+ */
+ virtual Energy ptMax(Energy dScale,
+ double emX, double specX,
+ const DipoleIndex&,
+ const DipoleSplittingKernel&) const;
+
+ /**
+ * Return the maximum virtuality for the given dipole scale.
+ */
+ virtual Energy QMax(Energy dScale,
+ double emX, double specX,
+ const DipoleIndex& dIndex) const;
+
+ /**
+ * Return the pt given a virtuality.
+ */
+ virtual Energy PtFromQ(Energy scale, const DipoleSplittingInfo&) const;
+
+ /**
+ * Return the virtuality given a pt.
+ */
+ virtual Energy QFromPt(Energy scale, const DipoleSplittingInfo&) const;
+
+ /**
+ * Return the random number associated to
+ * the given pt.
+ */
+ virtual double ptToRandom(Energy pt, Energy dScale,
+ const DipoleIndex& dIndex) const;
+
+ /**
+ * Generate splitting variables given three random numbers
+ * and the momentum fractions of the emitter and spectator.
+ * Return true on success.
+ */
+ virtual bool generateSplitting(double kappa, double xi, double phi,
+ DipoleSplittingInfo& dIndex);
+
+ /**
+ * For the splitting products present in the given dipole splitting
+ * info object calculate the kinematics parameters and return the
+ * propagator factor.
+ */
+ virtual InvEnergy2 setKinematics(DipoleSplittingInfo&) const;
+
+ /**
+ * For the splitting parameters given in the dipole splitting info
+ * object, calculate the phasespace Jacobian times the propagator
+ * factor.
+ */
+ virtual double jacobianTimesPropagator(const DipoleSplittingInfo&,
+ Energy) const;
+
+ /**
+ * Generate the full kinematics given emitter and
+ * spectator momentum and a previously completeted
+ * DipoleSplittingInfo object.
+ */
+ virtual void generateKinematics(const Lorentz5Momentum& pEmitter,
+ const Lorentz5Momentum& pSpectator,
+ const DipoleSplittingInfo& dInfo);
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<IFLightKinematics> initIFLightKinematics;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ IFLightKinematics & operator=(const IFLightKinematics &);
+
+private:
+
+ /**
+ * Wether or not to choose the `collinear' scheme
+ */
+ bool theCollinearScheme;
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of IFLightKinematics. */
+template <>
+struct BaseClassTrait<Herwig::IFLightKinematics,1> {
+ /** Typedef of the first base class of IFLightKinematics. */
+ typedef Herwig::DipoleSplittingKinematics NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the IFLightKinematics class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::IFLightKinematics>
+ : public ClassTraitsBase<Herwig::IFLightKinematics> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::IFLightKinematics"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * IFLightKinematics is implemented. It may also include several, space-separated,
+ * libraries if the class IFLightKinematics depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_IFLightKinematics_H */
diff --git a/DipoleShower/Kinematics/IILightKinematics.cc b/DipoleShower/Kinematics/IILightKinematics.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kinematics/IILightKinematics.cc
@@ -0,0 +1,353 @@
+// -*- C++ -*-
+//
+// IILightKinematics.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the IILightKinematics class.
+//
+
+#include "IILightKinematics.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/Interface/Switch.h"
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+#include "ThePEG/Repository/UseRandom.h"
+#include "ThePEG/Repository/EventGenerator.h"
+#include "Herwig++/DipoleShower/Base/DipoleSplittingInfo.h"
+
+using namespace Herwig;
+
+IILightKinematics::IILightKinematics()
+ : DipoleSplittingKinematics(), theCollinearScheme(false), didCollinear(false) {}
+
+IILightKinematics::~IILightKinematics() {}
+
+IBPtr IILightKinematics::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr IILightKinematics::fullclone() const {
+ return new_ptr(*this);
+}
+
+pair<double,double> IILightKinematics::kappaSupport(const DipoleSplittingInfo&) const {
+ return make_pair(0.0,1.0);
+}
+
+pair<double,double> IILightKinematics::xiSupport(const DipoleSplittingInfo& split) const {
+
+ double c = sqrt(1.-4.*sqr(IRCutoff()/generator()->maximumCMEnergy()));
+
+ if ( split.index().emitterData()->id() == ParticleID::g ) {
+ if ( split.emitterData()->id() == ParticleID::g ) {
+ double b = log((1.+c)/(1.-c));
+ return make_pair(-b,b);
+ } else {
+ return make_pair(log(0.5*(1.-c)),log(0.5*(1.+c)));
+ }
+ }
+
+ if ( split.index().emitterData()->id() != ParticleID::g &&
+ split.emitterData()->id() != ParticleID::g ) {
+ return make_pair(-log(0.5*(1.+c)),-log(0.5*(1.-c)));
+ }
+
+ return make_pair(0.5*(1.-c),0.5*(1.+c));
+
+}
+
+Energy IILightKinematics::dipoleScale(const Lorentz5Momentum& pEmitter,
+ const Lorentz5Momentum& pSpectator) const {
+ return sqrt(2.*(pEmitter*pSpectator));
+}
+
+Energy IILightKinematics::ptMax(Energy dScale,
+ double emX, double specX,
+ const DipoleIndex&,
+ const DipoleSplittingKernel&) const {
+ double tau = emX*specX;
+ return (1.-tau) * dScale / 2.;
+}
+
+Energy IILightKinematics::QMax(Energy,
+ double, double,
+ const DipoleIndex&) const {
+ assert(false && "add this");
+ return 0.0*GeV;
+}
+
+Energy IILightKinematics::PtFromQ(Energy, const DipoleSplittingInfo&) const {
+ assert(false && "add this");
+ return 0.0*GeV;
+}
+
+Energy IILightKinematics::QFromPt(Energy, const DipoleSplittingInfo&) const {
+ assert(false && "add this");
+ return 0.0*GeV;
+}
+
+
+double IILightKinematics::ptToRandom(Energy pt, Energy,
+ const DipoleIndex&) const {
+ return log(pt/IRCutoff()) / log(0.5 * generator()->maximumCMEnergy()/IRCutoff());
+}
+
+bool IILightKinematics::generateSplitting(double kappa, double xi, double rphi,
+ DipoleSplittingInfo& info) {
+
+ if ( info.emitterX() < xMin() ||
+ info.spectatorX() < xMin() ) {
+ jacobian(0.0);
+ return false;
+ }
+
+ Energy pt = IRCutoff() * pow(0.5 * generator()->maximumCMEnergy()/IRCutoff(),kappa);
+
+ if ( pt > info.hardPt() ) {
+ jacobian(0.0);
+ return false;
+ }
+
+ double z = 0.;
+ double mapZJacobian = 0.;
+
+ if ( info.index().emitterData()->id() == ParticleID::g ) {
+ if ( info.emitterData()->id() == ParticleID::g ) {
+ z = exp(xi)/(1.+exp(xi));
+ mapZJacobian = z*(1.-z);
+ } else {
+ z = exp(xi);
+ mapZJacobian = z;
+ }
+ }
+
+ if ( info.index().emitterData()->id() != ParticleID::g ) {
+ if ( info.emitterData()->id() != ParticleID::g ) {
+ z = 1.-exp(-xi);
+ mapZJacobian = (1.-z);
+ } else {
+ z = xi;
+ mapZJacobian = 1.;
+ }
+ }
+
+ double ratio = sqr(pt/info.scale());
+
+ double x = ( z*(1.-z) - ratio ) / ( 1. - z );
+ double v = ratio / (1.-z);
+
+ if ( x < 0. || x > 1. || v > 1. || v > 1.-x ) {
+ jacobian(0.0);
+ return false;
+ }
+
+ double tau = info.emitterX()*info.spectatorX();
+
+ double zp = 0.5*( 1.+ tau +
+ (1.-tau)*sqrt(1.-sqr(pt/info.hardPt()) ) );
+ double zm = 0.5*( 1.+ tau -
+ (1.-tau)*sqrt(1.-sqr(pt/info.hardPt()) ) );
+
+ if ( pt < IRCutoff() ||
+ pt > info.hardPt() ||
+ z > zp || z < zm ) {
+ jacobian(0.0);
+ return false;
+ }
+
+ if ( !theCollinearScheme &&
+ (1.-v-x)/(v+x) < 1. ) {
+ if ( (x+v) < info.emitterX() ||
+ x/(x+v) < info.spectatorX() ) {
+ jacobian(0.0);
+ return false;
+ }
+ } else {
+ if ( x < info.emitterX() ) {
+ jacobian(0.0);
+ return false;
+ }
+ }
+
+ double phi = 2.*Constants::pi*rphi;
+
+ jacobian(2. * mapZJacobian * (1.-z)/(z*(1.-z)-ratio) * log(0.5 * generator()->maximumCMEnergy()/IRCutoff()));
+
+ lastPt(pt);
+ lastZ(z);
+ lastPhi(phi);
+
+ if ( !theCollinearScheme &&
+ (1.-v-x)/(v+x) < 1. ) {
+ lastEmitterZ(x+v);
+ lastSpectatorZ(x/(x+v));
+ } else {
+ lastEmitterZ(x);
+ lastSpectatorZ(1.);
+ }
+
+ if ( theMCCheck )
+ theMCCheck->book(info.emitterX(),info.spectatorX(),info.scale(),info.hardPt(),pt,z,jacobian());
+
+ return true;
+
+}
+
+InvEnergy2 IILightKinematics::setKinematics(DipoleSplittingInfo& split) const {
+
+ Lorentz5Momentum emitter = split.splitEmitter()->momentum();
+ Lorentz5Momentum emission = split.emission()->momentum();
+ Lorentz5Momentum spectator = split.splitSpectator()->momentum();
+
+ split.splittingKinematics(const_cast<IILightKinematics*>(this));
+
+ Energy2 scale = 2.*(-emission*emitter - emission*spectator + emitter*spectator);
+ split.scale(sqrt(scale));
+
+ double x = scale/(2.*(emitter*spectator));
+ double v = (emitter*emission)/(emitter*spectator);
+
+ split.lastZ(v+x);
+ split.lastPt(split.scale() * sqrt(v*(1.-x-v)));
+
+ split.hardPt(split.lastPt());
+
+ if ( split.hardPt() > IRCutoff() ) {
+ split.continuesEvolving();
+ } else {
+ split.didStopEvolving();
+ }
+
+ return 1./(2.*x*(emitter*emission));
+
+}
+
+double IILightKinematics::
+jacobianTimesPropagator(const DipoleSplittingInfo&,
+ Energy) const {
+ assert(false && "implementation missing");
+ return 0.;
+}
+
+void IILightKinematics::generateKinematics(const Lorentz5Momentum& pEmitter,
+ const Lorentz5Momentum& pSpectator,
+ const DipoleSplittingInfo& dInfo) {
+
+ Energy pt = dInfo.lastPt();
+ double z = dInfo.lastZ();
+
+ double ratio = sqr(pt/(pEmitter+pSpectator).m());
+
+ double x = ( z*(1.-z) - ratio ) / ( 1. - z );
+ double v = ratio / (1.-z);
+
+ pt = sqrt(v*(1.-x-v)/x) * (pEmitter+pSpectator).m();
+
+ Lorentz5Momentum kt =
+ getKt (pEmitter, pSpectator, pt, dInfo.lastPhi());
+
+ if ( !theCollinearScheme &&
+ (1.-v-x)/(v+x) < 1. ) {
+
+ Lorentz5Momentum em =
+ (1./(v+x))*pEmitter+(v*(1.-v-x)/(x*(x+v)))*pSpectator+kt/(x+v);
+ em.setMass(0.*GeV);
+ em.rescaleEnergy();
+
+ Lorentz5Momentum emm =
+ ((1.-v-x)/(v+x))*pEmitter+(v/(x*(x+v)))*pSpectator+kt/(x+v);
+ emm.setMass(0.*GeV);
+ emm.rescaleEnergy();
+
+ Lorentz5Momentum spe =
+ (1.+v/x)*pSpectator;
+ spe.setMass(0.*GeV);
+ spe.rescaleEnergy();
+
+ emitterMomentum(em);
+ emissionMomentum(emm);
+ spectatorMomentum(spe);
+
+ didCollinear = false;
+
+ } else {
+
+ Lorentz5Momentum em =
+ (1./x)*pEmitter;
+ em.setMass(0.*GeV);
+ em.rescaleEnergy();
+
+ Lorentz5Momentum emm =
+ ((1.-x-v)/x)*pEmitter+v*pSpectator+kt;
+ emm.setMass(0.*GeV);
+ emm.rescaleEnergy();
+
+ Lorentz5Momentum spe =
+ pSpectator;
+
+ emitterMomentum(em);
+ emissionMomentum(emm);
+ spectatorMomentum(spe);
+
+ K = em + spe - emm;
+ K2 = K.m2();
+
+ Ktilde = pEmitter + pSpectator;
+ KplusKtilde = K + Ktilde;
+
+ KplusKtilde2 = KplusKtilde.m2();
+
+ didCollinear = true;
+
+ }
+
+}
+
+// If needed, insert default implementations of function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void IILightKinematics::persistentOutput(PersistentOStream & os) const {
+ os << theCollinearScheme;
+}
+
+void IILightKinematics::persistentInput(PersistentIStream & is, int) {
+ is >> theCollinearScheme;
+}
+
+ClassDescription<IILightKinematics> IILightKinematics::initIILightKinematics;
+// Definition of the static class description member.
+
+void IILightKinematics::Init() {
+
+ static ClassDocumentation<IILightKinematics> documentation
+ ("IILightKinematics implements massless splittings "
+ "off an initial-initial dipole.");
+
+
+ static Switch<IILightKinematics,bool> interfaceCollinearScheme
+ ("CollinearScheme",
+ "[experimental] Switch on or off the collinear scheme",
+ &IILightKinematics::theCollinearScheme, false, false, false);
+ static SwitchOption interfaceCollinearSchemeOn
+ (interfaceCollinearScheme,
+ "On",
+ "Switch on the collinear scheme.",
+ true);
+ static SwitchOption interfaceCollinearSchemeOff
+ (interfaceCollinearScheme,
+ "Off",
+ "Switch off the collinear scheme",
+ false);
+
+ interfaceCollinearScheme.rank(-1);
+
+}
+
diff --git a/DipoleShower/Kinematics/IILightKinematics.h b/DipoleShower/Kinematics/IILightKinematics.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kinematics/IILightKinematics.h
@@ -0,0 +1,269 @@
+// -*- C++ -*-
+//
+// IILightKinematics.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_IILightKinematics_H
+#define HERWIG_IILightKinematics_H
+//
+// This is the declaration of the IILightKinematics class.
+//
+
+#include "DipoleSplittingKinematics.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief IILightKinematics implements massless splittings
+ * off an initial-initial dipole.
+ *
+ * @see \ref IILightKinematicsInterfaces "The interfaces"
+ * defined for IILightKinematics.
+ */
+class IILightKinematics: public DipoleSplittingKinematics {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ IILightKinematics();
+
+ /**
+ * The destructor.
+ */
+ virtual ~IILightKinematics();
+ //@}
+
+public:
+
+ /**
+ * Return the boundaries in between the evolution
+ * variable random number is to be sampled; the lower
+ * cuoff is assumed to correspond to the infrared cutoff.
+ */
+ virtual pair<double,double> kappaSupport(const DipoleSplittingInfo& dIndex) const;
+
+ /**
+ * Return the boundaries in between the momentum
+ * fraction random number is to be sampled.
+ */
+ virtual pair<double,double> xiSupport(const DipoleSplittingInfo& dIndex) const;
+
+ /**
+ * Return the dipole scale associated to the
+ * given pair of emitter and spectator. This
+ * should be the invariant mass or absolute value
+ * final/final or initial/initial and the absolute
+ * value of the momentum transfer for intial/final or
+ * final/initial dipoles.
+ */
+ virtual Energy dipoleScale(const Lorentz5Momentum& pEmitter,
+ const Lorentz5Momentum& pSpectator) const;
+
+ /**
+ * Return the maximum pt for the given dipole scale.
+ */
+ virtual Energy ptMax(Energy dScale,
+ double emX, double specX,
+ const DipoleIndex&,
+ const DipoleSplittingKernel&) const;
+
+ /**
+ * Return the maximum virtuality for the given dipole scale.
+ */
+ virtual Energy QMax(Energy dScale,
+ double emX, double specX,
+ const DipoleIndex& dIndex) const;
+
+ /**
+ * Return the pt given a virtuality.
+ */
+ virtual Energy PtFromQ(Energy scale, const DipoleSplittingInfo&) const;
+
+ /**
+ * Return the virtuality given a pt.
+ */
+ virtual Energy QFromPt(Energy scale, const DipoleSplittingInfo&) const;
+
+ /**
+ * Return the random number associated to
+ * the given pt.
+ */
+ virtual double ptToRandom(Energy pt, Energy dScale,
+ const DipoleIndex& dIndex) const;
+
+ /**
+ * Generate splitting variables given three random numbers
+ * and the momentum fractions of the emitter and spectator.
+ * Return true on success.
+ */
+ virtual bool generateSplitting(double kappa, double xi, double phi,
+ DipoleSplittingInfo& dIndex);
+
+ /**
+ * For the splitting products present in the given dipole splitting
+ * info object calculate the kinematics parameters and return the
+ * propagator factor.
+ */
+ virtual InvEnergy2 setKinematics(DipoleSplittingInfo&) const;
+
+ /**
+ * For the splitting parameters given in the dipole splitting info
+ * object, calculate the phasespace Jacobian times the propagator
+ * factor.
+ */
+ virtual double jacobianTimesPropagator(const DipoleSplittingInfo&,
+ Energy) const;
+
+ /**
+ * Generate the full kinematics given emitter and
+ * spectator momentum and a previously completeted
+ * DipoleSplittingInfo object.
+ */
+ virtual void generateKinematics(const Lorentz5Momentum& pEmitter,
+ const Lorentz5Momentum& pSpectator,
+ const DipoleSplittingInfo& dInfo);
+
+ /*
+ * Return true, if there is a transformation which should
+ * be applied to all other final state particles except the ones
+ * involved in the splitting after having performed the splitting
+ */
+ virtual bool doesTransform () const { return theCollinearScheme || didCollinear; }
+
+ /*
+ * perform the transformation, if existing
+ */
+ virtual Lorentz5Momentum transform (const Lorentz5Momentum& p) const {
+ if ( !theCollinearScheme && !didCollinear ) return p;
+ return p-(2.*(KplusKtilde*p)/KplusKtilde2)*KplusKtilde+(2.*(Ktilde*p)/K2)*K;
+ }
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<IILightKinematics> initIILightKinematics;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ IILightKinematics & operator=(const IILightKinematics &);
+
+private:
+
+ /**
+ * Wether or not to choose the `collinear' scheme
+ */
+ bool theCollinearScheme;
+
+ bool didCollinear;
+
+ Lorentz5Momentum K;
+ Energy2 K2;
+ Lorentz5Momentum Ktilde;
+ Lorentz5Momentum KplusKtilde;
+ Energy2 KplusKtilde2;
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of IILightKinematics. */
+template <>
+struct BaseClassTrait<Herwig::IILightKinematics,1> {
+ /** Typedef of the first base class of IILightKinematics. */
+ typedef Herwig::DipoleSplittingKinematics NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the IILightKinematics class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::IILightKinematics>
+ : public ClassTraitsBase<Herwig::IILightKinematics> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::IILightKinematics"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * IILightKinematics is implemented. It may also include several, space-separated,
+ * libraries if the class IILightKinematics depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_IILightKinematics_H */
diff --git a/DipoleShower/Kinematics/Makefile.am b/DipoleShower/Kinematics/Makefile.am
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Kinematics/Makefile.am
@@ -0,0 +1,9 @@
+noinst_LTLIBRARIES = libHwDipoleShowerKinematics.la
+
+libHwDipoleShowerKinematics_la_SOURCES = \
+ DipoleSplittingKinematics.h DipoleSplittingKinematics.cc \
+ FFMassiveKinematics.h FFMassiveKinematics.cc \
+ FFLightKinematics.h FFLightKinematics.cc \
+ FILightKinematics.h FILightKinematics.cc \
+ IFLightKinematics.h IFLightKinematics.cc \
+ IILightKinematics.h IILightKinematics.cc
diff --git a/DipoleShower/Makefile.am b/DipoleShower/Makefile.am
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Makefile.am
@@ -0,0 +1,14 @@
+SUBDIRS = Base Kernels Kinematics Utility AlphaS
+
+pkglib_LTLIBRARIES = HwDipoleShower.la
+HwDipoleShower_la_LDFLAGS = -module -version-info 11:1:0
+
+HwDipoleShower_la_LIBADD = \
+ Base/libHwDipoleShowerBase.la \
+ Kernels/libHwDipoleShowerKernels.la \
+ Kinematics/libHwDipoleShowerKinematics.la \
+ Utility/libHwDipoleShowerUtility.la
+
+HwDipoleShower_la_SOURCES = \
+ DipoleShowerHandler.h DipoleShowerHandler.cc
+
diff --git a/DipoleShower/Utility/ConstituentReshuffler.cc b/DipoleShower/Utility/ConstituentReshuffler.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Utility/ConstituentReshuffler.cc
@@ -0,0 +1,249 @@
+// -*- C++ -*-
+//
+// ConstituentReshuffler.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the ConstituentReshuffler class.
+//
+
+#include "ConstituentReshuffler.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+#include <limits>
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+#include "DipolePartonSplitter.h"
+
+#include "Herwig++/Utilities/GSLBisection.h"
+
+#include "Herwig++/DipoleShower/DipoleShowerHandler.h"
+
+using namespace Herwig;
+
+ConstituentReshuffler::ConstituentReshuffler()
+ : HandlerBase() {}
+
+ConstituentReshuffler::~ConstituentReshuffler() {}
+
+IBPtr ConstituentReshuffler::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr ConstituentReshuffler::fullclone() const {
+ return new_ptr(*this);
+}
+
+double ConstituentReshuffler::ReshuffleEquation::aUnit() {
+ return 1.;
+}
+
+double ConstituentReshuffler::ReshuffleEquation::vUnit() {
+ return 1.;
+}
+
+double ConstituentReshuffler::ReshuffleEquation::operator() (double xi) const {
+
+ double r = - w/GeV;
+
+ for (PList::iterator p = p_begin; p != p_end; ++p) {
+ r += sqrt(sqr((**p).dataPtr()->constituentMass()) +
+ xi*xi*(sqr((**p).momentum().t())-sqr((**p).dataPtr()->mass()))) / GeV;
+ }
+
+ return r;
+
+}
+
+void ConstituentReshuffler::reshuffle(PList& out,
+ PPair& in,
+ PList& intermediates) {
+
+ if (out.size() == 0)
+ return;
+
+ if (out.size() == 1) {
+
+ PPtr recoiler;
+ PPtr parton = out.front();
+
+ if (DipolePartonSplitter::colourConnected(parton,in.first) &&
+ DipolePartonSplitter::colourConnected(parton,in.second)) {
+ if (UseRandom::rnd() < .5)
+ recoiler = in.first;
+ else
+ recoiler = in.second;
+ } else if (DipolePartonSplitter::colourConnected(parton,in.first)) {
+ recoiler = in.first;
+ } else if (DipolePartonSplitter::colourConnected(parton,in.second)) {
+ recoiler = in.second;
+ } else assert(false);
+
+ assert(abs(recoiler->momentum().vect().perp2()/GeV2) < 1e-6);
+
+ double sign = recoiler->momentum().z() < 0.*GeV ? -1. : 1.;
+
+ Energy2 qperp2 = parton->momentum().perp2();
+
+ if (qperp2/GeV2 < Constants::epsilon) {
+ // no emission off a 2 -> singlet process which
+ // needed a single forced splitting: should never happen (?)
+ assert(false);
+ throw Veto();
+ }
+
+ Energy2 m2 = sqr(parton->dataPtr()->constituentMass());
+
+ Energy abs_q = parton->momentum().vect().mag();
+ Energy qz = parton->momentum().z();
+ Energy abs_pz = recoiler->momentum().t();
+ assert(abs_pz > 0.*GeV);
+
+ Energy xi_pz = sign*(2.*qperp2*abs_pz + m2*(abs_q + sign*qz))/(2.*qperp2);
+ Energy x_qz = (2.*qperp2*qz + m2*(qz+sign*abs_q))/(2.*qperp2);
+
+ Lorentz5Momentum recoiler_momentum
+ (0.*GeV,0.*GeV,xi_pz,xi_pz < 0.*GeV ? - xi_pz : xi_pz);
+
+ recoiler_momentum.rescaleMass();
+
+ Lorentz5Momentum parton_momentum
+ (parton->momentum().x(),parton->momentum().y(),x_qz,sqrt(m2+qperp2+x_qz*x_qz));
+
+ parton_momentum.rescaleMass();
+
+ PPtr n_parton = new_ptr(Particle(parton->dataPtr()));
+ n_parton->set5Momentum(parton_momentum);
+
+ DipolePartonSplitter::change(parton,n_parton,false);
+
+ out.pop_front();
+ intermediates.push_back(parton);
+ out.push_back(n_parton);
+
+ PPtr n_recoiler = new_ptr(Particle(recoiler->dataPtr()));
+ n_recoiler->set5Momentum(recoiler_momentum);
+
+ DipolePartonSplitter::change(recoiler,n_recoiler,true);
+
+ intermediates.push_back(recoiler);
+
+ if (recoiler == in.first) {
+ in.first = n_recoiler;
+ }
+
+ if (recoiler == in.second) {
+ in.second = n_recoiler;
+ }
+
+ return;
+
+ }
+
+ Energy zero (0.*GeV);
+ Lorentz5Momentum Q (zero,zero,zero,zero);
+
+ for (PList::iterator p = out.begin();
+ p != out.end(); ++p) {
+ Q += (**p).momentum();
+ }
+
+ Boost beta = Q.findBoostToCM();
+
+ list<Lorentz5Momentum> mbackup;
+
+ bool need_boost = (beta.mag2() > Constants::epsilon);
+
+ if (need_boost) {
+
+ for (PList::iterator p = out.begin();
+ p != out.end(); ++p) {
+ Lorentz5Momentum mom = (**p).momentum();
+ mbackup.push_back(mom);
+ (**p).set5Momentum(mom.boost(beta));
+ }
+
+ }
+
+ double xi;
+
+ ReshuffleEquation solve (Q.m(),out.begin(),out.end());
+
+ GSLBisection solver(1e-10,1e-8,10000);
+
+ try {
+ xi = solver.value(solve,0.0,1.1);
+ } catch (GSLBisection::GSLerror) {
+ throw DipoleShowerHandler::RedoShower();
+ } catch (GSLBisection::IntervalError) {
+ throw DipoleShowerHandler::RedoShower();
+ }
+
+ PList reshuffled;
+
+ list<Lorentz5Momentum>::const_iterator backup_it;
+ if (need_boost)
+ backup_it = mbackup.begin();
+
+ for (PList::iterator p = out.begin();
+ p != out.end(); ++p) {
+
+ PPtr rp = new_ptr(Particle((**p).dataPtr()));
+
+ DipolePartonSplitter::change(*p,rp,false);
+
+ Lorentz5Momentum rm (xi*(**p).momentum().x(),
+ xi*(**p).momentum().y(),
+ xi*(**p).momentum().z(),
+ sqrt(sqr((**p).dataPtr()->constituentMass()) +
+ xi*xi*(sqr((**p).momentum().t())-sqr((**p).dataPtr()->mass()))));
+
+ rm.rescaleMass();
+
+ if (need_boost) {
+ (**p).set5Momentum(*backup_it);
+ ++backup_it;
+ rm.boost(-beta);
+ }
+
+ rp->set5Momentum(rm);
+
+ intermediates.push_back(*p);
+ reshuffled.push_back(rp);
+
+
+ }
+
+ out.clear();
+ out.splice(out.end(),reshuffled);
+
+}
+
+// If needed, insert default implementations of virtual function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void ConstituentReshuffler::persistentOutput(PersistentOStream &) const {
+}
+
+void ConstituentReshuffler::persistentInput(PersistentIStream &, int) {
+}
+
+ClassDescription<ConstituentReshuffler> ConstituentReshuffler::initConstituentReshuffler;
+// Definition of the static class description member.
+
+void ConstituentReshuffler::Init() {
+
+ static ClassDocumentation<ConstituentReshuffler> documentation
+ ("The ConstituentReshuffler class implements reshuffling "
+ "of partons on their nominal mass shell to their constituent "
+ "mass shells.");
+
+}
+
diff --git a/DipoleShower/Utility/ConstituentReshuffler.h b/DipoleShower/Utility/ConstituentReshuffler.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Utility/ConstituentReshuffler.h
@@ -0,0 +1,191 @@
+// -*- C++ -*-
+//
+// ConstituentReshuffler.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_ConstituentReshuffler_H
+#define HERWIG_ConstituentReshuffler_H
+//
+// This is the declaration of the ConstituentReshuffler class.
+//
+
+#include "ThePEG/Handlers/HandlerBase.h"
+#include "ThePEG/Utilities/Exception.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief The ConstituentReshuffler class implements reshuffling
+ * of partons on their nominal mass shell to their constituent
+ * mass shells.
+ *
+ */
+class ConstituentReshuffler: public HandlerBase {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ ConstituentReshuffler();
+
+ /**
+ * The destructor.
+ */
+ virtual ~ConstituentReshuffler();
+ //@}
+
+public:
+
+ /**
+ * Reshuffle the outgoing partons to constituent
+ * masses. Optionally, incoming partons are given
+ * to absorb recoils. Add the non-reshuffled partons
+ * to the intermediates list. Throw ConstituentReshufflerProblem
+ * if a numerical problem prevents the solution of
+ * the reshuffling equation.
+ */
+ void reshuffle(PList& out,
+ PPair& in,
+ PList& intermediates);
+
+protected:
+
+ /**
+ * The function object defining the equation
+ * to be solved.
+ */
+ struct ReshuffleEquation {
+
+ ReshuffleEquation (Energy q,
+ PList::iterator m_begin,
+ PList::iterator m_end)
+ : w(q), p_begin(m_begin), p_end(m_end) {}
+
+ typedef double ArgType;
+ typedef double ValType;
+
+ static double aUnit();
+ static double vUnit();
+
+ double operator() (double xi) const;
+
+ Energy w;
+
+ PList::iterator p_begin;
+ PList::iterator p_end;
+
+ };
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<ConstituentReshuffler> initConstituentReshuffler;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ ConstituentReshuffler & operator=(const ConstituentReshuffler &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of ConstituentReshuffler. */
+template <>
+struct BaseClassTrait<Herwig::ConstituentReshuffler,1> {
+ /** Typedef of the first base class of ConstituentReshuffler. */
+ typedef HandlerBase NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the ConstituentReshuffler class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::ConstituentReshuffler>
+ : public ClassTraitsBase<Herwig::ConstituentReshuffler> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::ConstituentReshuffler"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * ConstituentReshuffler is implemented. It may also include several, space-separated,
+ * libraries if the class ConstituentReshuffler depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_ConstituentReshuffler_H */
diff --git a/DipoleShower/Utility/DipoleMCCheck.cc b/DipoleShower/Utility/DipoleMCCheck.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Utility/DipoleMCCheck.cc
@@ -0,0 +1,283 @@
+// -*- C++ -*-
+//
+// DipoleMCCheck.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the DipoleMCCheck class.
+//
+
+#include "DipoleMCCheck.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/Interface/Parameter.h"
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+DipoleMCCheck::DipoleMCCheck()
+ : HandlerBase(),
+ theHardPtBins(10),
+ theEmitterXBins(5), theSpectatorXBins(5),
+ thePtBins(100), theZBins(100) {
+}
+
+DipoleMCCheck::~DipoleMCCheck() {}
+
+IBPtr DipoleMCCheck::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr DipoleMCCheck::fullclone() const {
+ return new_ptr(*this);
+}
+
+vector<double> DipoleMCCheck::makeLogBins(double xlow, double xup, unsigned int n) const {
+
+ vector<double> res;
+
+ double c = log10(xup/xlow) / (n-1.);
+
+ for ( unsigned int k = 0; k < n; ++k )
+ res.push_back(xlow*pow(10.0,k*c));
+
+ return res;
+
+}
+
+// If needed, insert default implementations of virtual function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+void DipoleMCCheck::doinitrun() {
+ HandlerBase::doinitrun();
+
+ vector<double> ptbins;
+ double w = 0.5/theHardPtBins;
+
+ for ( unsigned int k = 1; k <= theHardPtBins; ++k )
+ ptbins.push_back(k*w);
+
+ vector<double> xebins;
+ if ( theEmitterXBins > 1 )
+ xebins = makeLogBins(1e-7,1.0,theEmitterXBins);
+ else
+ xebins.push_back(1.0);
+
+ vector<double> xsbins;
+ if ( theSpectatorXBins > 1 )
+ xsbins = makeLogBins(1e-7,1.0,theSpectatorXBins);
+ else
+ xsbins.push_back(1.0);
+
+ for ( vector<double>::const_iterator xeit = xebins.begin();
+ xeit != xebins.end(); ++xeit ) {
+ map<double,
+ map<double,
+ pair<Ptr<Histogram>::ptr,Ptr<Histogram>::ptr>
+ >
+ > xebin;
+ for ( vector<double>::const_iterator xsit = xsbins.begin();
+ xsit != xsbins.end(); ++xsit ) {
+ map<double,
+ pair<Ptr<Histogram>::ptr,Ptr<Histogram>::ptr>
+ > xsbin;
+ for ( vector<double>::const_iterator ptit = ptbins.begin();
+ ptit != ptbins.end(); ++ptit ) {
+ pair<Ptr<Histogram>::ptr,Ptr<Histogram>::ptr> ptbin
+ (new_ptr(Histogram(0.0,0.5,thePtBins)),
+ new_ptr(Histogram(0.0,1.0,theZBins)));
+ xsbin[*ptit] = ptbin;
+ }
+ xebin[*xsit] = xsbin;
+ }
+ histoMap[*xeit] = xebin;
+ }
+
+}
+
+void DipoleMCCheck::dofinish() {
+ HandlerBase::dofinish();
+
+ map<double,
+ map<double,
+ map<double,
+ pair<Ptr<Histogram>::ptr,Ptr<Histogram>::ptr>
+ >
+ >
+ >::iterator xeit;
+
+ map<double,
+ map<double,
+ pair<Ptr<Histogram>::ptr,Ptr<Histogram>::ptr>
+ >
+ >::iterator xsit;
+
+ map<double,
+ pair<Ptr<Histogram>::ptr,Ptr<Histogram>::ptr>
+ >::iterator ptit;
+
+ double xelow = 0.0;
+ double xeup = 0.0;
+
+ for ( xeit = histoMap.begin(); xeit != histoMap.end(); ++xeit ) {
+
+ xeup = xelow + xeit->first;
+
+ double xslow = 0.0;
+ double xsup = 0.0;
+
+ for ( xsit = xeit->second.begin(); xsit != xeit->second.end(); ++xsit ) {
+
+ xsup = xslow + xsit->first;
+
+ // open files here
+
+ ostringstream ptFileName;
+ ptFileName << name() << "_pt_"
+ << xelow << "_" << xeup << "_"
+ << xslow << "_" << xsup << ".dat";
+
+ ofstream ptFile(ptFileName.str().c_str());
+
+ ostringstream zFileName;
+ zFileName << name() << "_z_"
+ << xelow << "_" << xeup << "_"
+ << xslow << "_" << xsup << ".dat";
+
+ ofstream zFile(zFileName.str().c_str());
+
+ double ptlow = 0.0;
+ double ptup = 0.0;
+
+ for ( ptit = xsit->second.begin(); ptit != xsit->second.end(); ++ptit ) {
+
+ ptup = ptlow + ptit->first;
+
+ // dump histos here
+
+ ptFile << "#\n# " << ptlow << " < \\kappa < " << ptup << "\n#\n";
+ zFile << "#\n# " << ptlow << " < \\kappa < " << ptup << "\n#\n";
+
+ ptit->second.first->simpleOutput(ptFile,false);
+ ptit->second.second->simpleOutput(zFile,false);
+
+ ptFile << "\n\n\n";
+ zFile << "\n\n\n";
+
+ ptlow = ptup;
+
+ }
+
+ xslow = xsup;
+
+ }
+
+ xelow = xeup;
+
+ }
+
+}
+
+void DipoleMCCheck::book(double xe,double xs,
+ Energy dScale,
+ Energy hardPt,
+ Energy pt, double z,
+ double weight) {
+
+ map<double,
+ map<double,
+ map<double,
+ pair<Ptr<Histogram>::ptr,Ptr<Histogram>::ptr>
+ >
+ >
+ >::iterator xeit;
+
+ map<double,
+ map<double,
+ pair<Ptr<Histogram>::ptr,Ptr<Histogram>::ptr>
+ >
+ >::iterator xsit;
+
+ map<double,
+ pair<Ptr<Histogram>::ptr,Ptr<Histogram>::ptr>
+ >::iterator ptit;
+
+ if ( theEmitterXBins == 1 || xe >= 1. )
+ xeit = --histoMap.end();
+ else
+ xeit = histoMap.upper_bound(xe);
+
+ if ( theSpectatorXBins == 1 || xs >= 1. )
+ xsit = --(xeit->second.end());
+ else
+ xsit = xeit->second.upper_bound(xs);
+
+ if ( theHardPtBins == 1 || hardPt/dScale >= 0.5 )
+ ptit = --(xsit->second.end());
+ else
+ ptit = xsit->second.upper_bound(hardPt/dScale);
+
+ ptit->second.first->addWeighted(pt/dScale,weight);
+ ptit->second.second->addWeighted(z,weight);
+
+}
+
+void DipoleMCCheck::persistentOutput(PersistentOStream & os) const {
+ os << theHardPtBins << theEmitterXBins
+ << theSpectatorXBins << thePtBins
+ << theZBins;
+}
+
+void DipoleMCCheck::persistentInput(PersistentIStream & is, int) {
+ is >> theHardPtBins >> theEmitterXBins
+ >> theSpectatorXBins >> thePtBins
+ >> theZBins;
+}
+
+ClassDescription<DipoleMCCheck> DipoleMCCheck::initDipoleMCCheck;
+// Definition of the static class description member.
+
+void DipoleMCCheck::Init() {
+
+ static ClassDocumentation<DipoleMCCheck> documentation
+ ("DipoleMCCheck is used to perform checks for "
+ "the dipole shower.");
+
+
+ static Parameter<DipoleMCCheck,unsigned int> interfaceHardPtBins
+ ("HardPtBins",
+ "HardPtBins",
+ &DipoleMCCheck::theHardPtBins, 10, 1, 0,
+ false, false, Interface::lowerlim);
+
+ static Parameter<DipoleMCCheck,unsigned int> interfaceEmitterXBins
+ ("EmitterXBins",
+ "EmitterXBins",
+ &DipoleMCCheck::theEmitterXBins, 5, 1, 0,
+ false, false, Interface::lowerlim);
+
+ static Parameter<DipoleMCCheck,unsigned int> interfaceSpectatorXBins
+ ("SpectatorXBins",
+ "SpectatorXBins",
+ &DipoleMCCheck::theSpectatorXBins, 5, 1, 0,
+ false, false, Interface::lowerlim);
+
+ static Parameter<DipoleMCCheck,unsigned int> interfacePtBins
+ ("PtBins",
+ "PtBins",
+ &DipoleMCCheck::thePtBins, 100, 1, 0,
+ false, false, Interface::lowerlim);
+
+ static Parameter<DipoleMCCheck,unsigned int> interfaceZBins
+ ("ZBins",
+ "ZBins",
+ &DipoleMCCheck::theZBins, 100, 1, 0,
+ false, false, Interface::lowerlim);
+
+}
+
diff --git a/DipoleShower/Utility/DipoleMCCheck.h b/DipoleShower/Utility/DipoleMCCheck.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Utility/DipoleMCCheck.h
@@ -0,0 +1,231 @@
+// -*- C++ -*-
+//
+// DipoleMCCheck.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_DipoleMCCheck_H
+#define HERWIG_DipoleMCCheck_H
+//
+// This is the declaration of the DipoleMCCheck class.
+//
+
+#include "ThePEG/Handlers/HandlerBase.h"
+
+#include "Herwig++/Utilities/Histogram.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief DipoleMCCheck is used to perform checks for
+ * the dipole shower.
+ *
+ * @see \ref DipoleMCCheckInterfaces "The interfaces"
+ * defined for DipoleMCCheck.
+ */
+class DipoleMCCheck: public HandlerBase {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ DipoleMCCheck();
+
+ /**
+ * The destructor.
+ */
+ virtual ~DipoleMCCheck();
+ //@}
+
+public:
+
+ /**
+ * Book a point.
+ */
+ void book(double xe,double xs,
+ Energy dScale,
+ Energy hardPt,
+ Energy pt, double z,
+ double weight);
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+
+protected:
+
+ /**
+ * Initialize this object. Called in the run phase just before
+ * a run begins.
+ */
+ virtual void doinitrun();
+
+ /**
+ * Finalize this object. Called in the run phase just after a
+ * run has ended. Used eg. to write out statistics.
+ */
+ virtual void dofinish();
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+private:
+
+ /**
+ * The number of bins in the starting scale
+ * divided by the dipole scale, the upper bound
+ * is 1/2.
+ */
+ unsigned int theHardPtBins;
+
+ /**
+ * The number of bins in the emitter fraction.
+ * The lenght of the zero bin is taken to be
+ * 10^(-7).
+ */
+ unsigned int theEmitterXBins;
+
+ /**
+ * The number of bins in the spectator fraction.
+ * The lenght of the zero bin is taken to be
+ * 10^(-7).
+ */
+ unsigned int theSpectatorXBins;
+
+ /**
+ * The number of bins in pt dicided by the
+ * dipole scale; the upper bound is 1/2
+ */
+ unsigned int thePtBins;
+
+ /**
+ * The number of bins in z
+ */
+ unsigned int theZBins;
+
+ /**
+ * The recursive map structure: xe, xs, hard pt / GeV
+ * to histograms for pt and z;
+ * output is done such that there's one file for each
+ * xe,xs bin, including all histograms for the
+ * hard pt bins.
+ */
+ map<double,
+ map<double,
+ map<double,
+ pair<Ptr<Histogram>::ptr,Ptr<Histogram>::ptr>
+ >
+ >
+ > histoMap;
+
+ /**
+ * Helper to make logarithmic bins.
+ */
+ vector<double> makeLogBins(double xlow, double xup, unsigned int n) const;
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<DipoleMCCheck> initDipoleMCCheck;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ DipoleMCCheck & operator=(const DipoleMCCheck &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of DipoleMCCheck. */
+template <>
+struct BaseClassTrait<Herwig::DipoleMCCheck,1> {
+ /** Typedef of the first base class of DipoleMCCheck. */
+ typedef HandlerBase NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the DipoleMCCheck class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::DipoleMCCheck>
+ : public ClassTraitsBase<Herwig::DipoleMCCheck> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::DipoleMCCheck"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * DipoleMCCheck is implemented. It may also include several, space-separated,
+ * libraries if the class DipoleMCCheck depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_DipoleMCCheck_H */
diff --git a/DipoleShower/Utility/DipolePartonSplitter.cc b/DipoleShower/Utility/DipolePartonSplitter.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Utility/DipolePartonSplitter.cc
@@ -0,0 +1,352 @@
+// -*- C++ -*-
+//
+// DipolePartonSplitter.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the DipolePartonSplitter class.
+//
+
+#include "DipolePartonSplitter.h"
+
+#include "ThePEG/EventRecord/Particle.h"
+#include "ThePEG/EventRecord/ColourLine.h"
+
+using namespace Herwig;
+
+void DipolePartonSplitter::split(tPPtr parent, tPPtr firstChild, tPPtr secondChild,
+ bool initialState) {
+
+ firstChild->colourInfo(new_ptr(ColourBase()));
+ secondChild->colourInfo(new_ptr(ColourBase()));
+
+ if (!initialState) {
+ parent->addChild(firstChild);
+ parent->addChild(secondChild);
+ } else {
+
+ tPVector parents = parent->parents();
+
+ for (tPVector::const_iterator q = parents.begin();
+ q != parents.end(); ++q) {
+
+ (**q).addChild(firstChild);
+ (**q).abandonChild(parent);
+
+ }
+
+ firstChild->addChild(parent);
+ firstChild->addChild(secondChild);
+
+ }
+
+}
+
+void DipolePartonSplitter::split(tPPtr parent, tPPtr firstChild, tPPtr secondChild,
+ tPPtr ref, bool initialState) {
+
+ split(parent,firstChild,secondChild,initialState);
+
+ // final state splittings
+
+ if (!initialState) {
+
+ // triplet radiating octet
+ if (parent->hasColour() &&
+ !parent->hasAntiColour()) {
+
+ assert(secondChild->hasColour() &&
+ secondChild->hasAntiColour() &&
+ firstChild->hasColour() &&
+ !firstChild->hasAntiColour());
+
+ secondChild->incomingColour(parent);
+ firstChild->antiColourNeighbour(secondChild);
+
+ return;
+
+ }
+
+ // anti-triplet radiating octet
+ if (!parent->hasColour() &&
+ parent->hasAntiColour()) {
+
+ assert(secondChild->hasColour() &&
+ secondChild->hasAntiColour() &&
+ !firstChild->hasColour() &&
+ firstChild->hasAntiColour());
+
+ secondChild->incomingAntiColour(parent);
+ firstChild->colourNeighbour(secondChild);
+
+ return;
+
+ }
+
+ // octet radiating octet
+ if (parent->hasColour() &&
+ parent->hasAntiColour() &&
+ secondChild->hasColour() &&
+ secondChild->hasAntiColour()) {
+
+ assert(firstChild->hasColour() &&
+ firstChild->hasAntiColour());
+
+ // check wether we radiated from the colour or anticolour line
+
+ if (parent->colourLine() == ref->antiColourLine()) {
+ firstChild->incomingAntiColour(parent);
+ secondChild->incomingColour(parent);
+ firstChild->antiColourNeighbour(secondChild);
+ } else {
+ firstChild->incomingColour(parent);
+ secondChild->incomingAntiColour(parent);
+ firstChild->colourNeighbour(secondChild);
+ }
+
+ return;
+
+ }
+
+ // octet splitting into triplet x anti-triplet
+ if (parent->hasColour() &&
+ parent->hasAntiColour() &&
+ ( (secondChild->hasAntiColour() &&
+ !secondChild->hasColour()) ||
+ (!secondChild->hasAntiColour() &&
+ secondChild->hasColour()) )) {
+
+ if (firstChild->hasColour()) {
+ assert(!firstChild->hasAntiColour() &&
+ secondChild->hasAntiColour() &&
+ !secondChild->hasColour());
+
+ firstChild->incomingColour(parent);
+ secondChild->incomingAntiColour(parent);
+
+ return;
+
+ }
+
+ if (firstChild->hasAntiColour()) {
+ assert(!firstChild->hasColour() &&
+ secondChild->hasColour() &&
+ !secondChild->hasAntiColour());
+
+ firstChild->incomingAntiColour(parent);
+ secondChild->incomingColour(parent);
+
+ return;
+
+ }
+
+ }
+
+ }
+
+ // initial state splittings
+
+ if (initialState) {
+
+ // triplet
+ if (parent->hasColour() &&
+ !parent->hasAntiColour()) {
+
+ if (secondChild->hasColour() &&
+ secondChild->hasAntiColour()) {
+
+ // radiating octet
+
+ assert(firstChild->hasColour() &&
+ !firstChild->hasAntiColour());
+
+ parent->antiColourNeighbour(secondChild);
+ firstChild->outgoingColour(secondChild);
+
+ } else {
+
+ // 'radiating' anti-triplet
+
+ assert(!secondChild->hasColour() &&
+ secondChild->hasAntiColour() &&
+ firstChild->hasColour() &&
+ firstChild->hasAntiColour());
+
+ secondChild->incomingAntiColour(firstChild);
+ parent->colourLine()->addColoured(firstChild);
+
+ }
+
+ return;
+
+ }
+
+ // anti-triplet
+ if (!parent->hasColour() &&
+ parent->hasAntiColour()) {
+
+ if (secondChild->hasColour() &&
+ secondChild->hasAntiColour()) {
+
+ // radiating octet
+
+ assert(!firstChild->hasColour() &&
+ firstChild->hasAntiColour());
+
+ parent->colourNeighbour(secondChild);
+ firstChild->outgoingAntiColour(secondChild);
+
+ } else {
+
+ // 'radiating' triplet
+
+ assert(secondChild->hasColour() &&
+ !secondChild->hasAntiColour() &&
+ firstChild->hasColour() &&
+ firstChild->hasAntiColour());
+
+ secondChild->incomingColour(firstChild);
+ parent->antiColourLine()->addAntiColoured(firstChild);
+
+ }
+
+ return;
+
+ }
+
+ // octet radiating octet
+
+ if (parent->hasColour() &&
+ parent->hasAntiColour() &&
+ secondChild->hasColour() &&
+ secondChild->hasAntiColour()) {
+
+ assert(firstChild->hasColour() &&
+ firstChild->hasAntiColour());
+
+ // check wether we radiated from the colour or anticolour line
+
+ if (parent->colourLine() == ref->colourLine()) {
+ parent->colourLine()->addAntiColoured(secondChild);
+ parent->antiColourLine()->addAntiColoured(firstChild);
+ secondChild->incomingColour(firstChild);
+ } else {
+ parent->antiColourLine()->addColoured(secondChild);
+ parent->colourLine()->addColoured(firstChild);
+ secondChild->incomingAntiColour(firstChild);
+ }
+
+ return;
+
+ }
+
+ // octet splitting into triplet x triplet
+ if (parent->hasColour() &&
+ parent->hasAntiColour() &&
+ ( (secondChild->hasAntiColour() &&
+ !secondChild->hasColour()) ||
+ (!secondChild->hasAntiColour() &&
+ secondChild->hasColour()) )) {
+
+ if (firstChild->hasColour()) {
+ assert(!firstChild->hasAntiColour() &&
+ secondChild->hasColour() &&
+ !secondChild->hasAntiColour());
+
+ parent->colourLine()->addColoured(firstChild);
+ parent->antiColourLine()->addColoured(secondChild);
+
+ return;
+
+ }
+
+ if (firstChild->hasAntiColour()) {
+ assert(!firstChild->hasColour() &&
+ secondChild->hasAntiColour() &&
+ !secondChild->hasColour());
+
+ parent->antiColourLine()->addAntiColoured(firstChild);
+ parent->colourLine()->addAntiColoured(secondChild);
+
+ return;
+
+ }
+
+ }
+
+
+ }
+
+ // should never happen
+ assert(false);
+
+}
+
+void DipolePartonSplitter::change(tPPtr parent, tPPtr child, bool initialState) {
+
+ child->colourInfo(new_ptr(ColourBase()));
+
+ if (parent->hasColour())
+ parent->colourLine()->addColoured(child);
+
+ if (parent->hasAntiColour())
+ parent->antiColourLine()->addAntiColoured(child);
+
+ if (!initialState) {
+ parent->addChild(child);
+ } else {
+
+
+ tPVector parents = parent->parents();
+
+ for (tPVector::const_iterator q = parents.begin();
+ q != parents.end(); ++q) {
+
+ (**q).addChild(child);
+ (**q).abandonChild(parent);
+
+ }
+
+ child->addChild(parent);
+
+ }
+
+}
+
+bool DipolePartonSplitter::colourConnected(tcPPtr first, tcPPtr second) {
+
+ if (!first->coloured() || !second->coloured())
+ return false;
+
+ if (first->colourInfo()->colourLine()) {
+
+ if (second->colourInfo()->colourLine() &&
+ first->colourInfo()->colourLine() == second->colourInfo()->colourLine())
+ return true;
+
+ if (second->colourInfo()->antiColourLine() &&
+ first->colourInfo()->colourLine() == second->colourInfo()->antiColourLine())
+ return true;
+
+ }
+
+ if (first->colourInfo()->antiColourLine()) {
+
+ if (second->colourInfo()->colourLine() &&
+ first->colourInfo()->antiColourLine() == second->colourInfo()->colourLine())
+ return true;
+
+ if (second->colourInfo()->antiColourLine() &&
+ first->colourInfo()->antiColourLine() == second->colourInfo()->antiColourLine())
+ return true;
+
+ }
+
+ return false;
+
+}
+
diff --git a/DipoleShower/Utility/DipolePartonSplitter.h b/DipoleShower/Utility/DipolePartonSplitter.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Utility/DipolePartonSplitter.h
@@ -0,0 +1,71 @@
+// -*- C++ -*-
+//
+// DipolePartonSplitter.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_DipolePartonSplitter_H
+#define HERWIG_DipolePartonSplitter_H
+//
+// This is the declaration of the DipolePartonSplitter class.
+//
+
+#include "ThePEG/EventRecord/Particle.fh"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief The DipolePartonSplitter is a helper class to fix up
+ * colour and mother-child relations in typical shower
+ * splittings.
+ *
+ */
+struct DipolePartonSplitter {
+
+ /**
+ * Fix up mother child relations for splitting the first
+ * to the second and third parton; use conventions
+ * of a backward splitting, if initialState is true.
+ * In this case, the first child is assumed to be the
+ * new incoming parton.
+ */
+ static void split(tPPtr parent, tPPtr firstChild, tPPtr secondChild,
+ bool initialState);
+
+ /**
+ * Fix up relations for splitting the first
+ * to the second and third parton; use conventions
+ * of a backward splitting, if initialState is true.
+ * In this case, the first child is assumed to be the
+ * new incoming parton. A reference is given to
+ * determine which colour line did actually radiate
+ * in case of ambiguities, in the sense that the
+ * colour connected parent-ref pair raidated as a dipole.
+ */
+ static void split(tPPtr parent, tPPtr firstChild, tPPtr secondChild,
+ tPPtr ref, bool initialState);
+
+ /**
+ * Fix up relations for the case that
+ * the new parton instance exists only
+ * due to changes in e.g. kinematics.
+ */
+ static void change(tPPtr parent, tPPtr child, bool initialState);
+
+ /**
+ * Return true, if the given partons are colour connected.
+ */
+ static bool colourConnected(tcPPtr first, tcPPtr second);
+
+};
+
+}
+
+#endif /* HERWIG_DipolePartonSplitter_H */
diff --git a/DipoleShower/Utility/IntrinsicPtGenerator.cc b/DipoleShower/Utility/IntrinsicPtGenerator.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Utility/IntrinsicPtGenerator.cc
@@ -0,0 +1,198 @@
+// -*- C++ -*-
+//
+// IntrinsicPtGenerator.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the IntrinsicPtGenerator class.
+//
+
+#include "IntrinsicPtGenerator.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/Interface/Parameter.h"
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+#include "ThePEG/Config/Constants.h"
+
+#include "DipolePartonSplitter.h"
+
+#include "Herwig++/Shower/ShowerHandler.h"
+#include "Herwig++/PDF/HwRemDecayer.h"
+
+using namespace Herwig;
+
+IntrinsicPtGenerator::IntrinsicPtGenerator()
+ : HandlerBase(),
+ theValenceIntrinsicPtScale(1.0*GeV),
+ theSeaIntrinsicPtScale(1.0*GeV) {}
+
+IntrinsicPtGenerator::~IntrinsicPtGenerator() {}
+
+IBPtr IntrinsicPtGenerator::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr IntrinsicPtGenerator::fullclone() const {
+ return new_ptr(*this);
+}
+
+SpinOneLorentzRotation IntrinsicPtGenerator::kick(PPair& in,
+ PList& intermediates) {
+
+ if ( theValenceIntrinsicPtScale == 0.0*GeV &&
+ theSeaIntrinsicPtScale == 0.0*GeV )
+ return SpinOneLorentzRotation();
+
+ assert(ShowerHandler::currentHandler());
+
+ tHwRemDecPtr remDec = ShowerHandler::currentHandler()->remnantDecayer();
+
+ assert(remDec);
+
+ Lorentz5Momentum Q = in.first->momentum() + in.second->momentum();
+
+ // first parton
+
+ if (in.first->coloured()) {
+
+ Axis perp;
+ Energy pt = 0.*GeV;
+
+ double phi = 2.*Constants::pi*UseRandom::rnd();
+
+ Axis dir = in.first->momentum().vect().unit();
+ perp = dir.orthogonal();
+ perp.rotate(phi,dir);
+
+ double r = sqrt(-log(1.-UseRandom::rnd()));
+
+ if ( remDec->content().first.isValenceQuark(in.first) )
+ pt = sqrt(2.) * theValenceIntrinsicPtScale * r;
+ else {
+ assert(in.first->id() == ParticleID::g ||
+ remDec->content().first.isSeaQuark(in.first));
+ pt = sqrt(2.) * theSeaIntrinsicPtScale * r;
+ }
+
+ PPtr nin = new_ptr(Particle(in.first->dataPtr()));
+
+ DipolePartonSplitter::change(in.first,nin,true);
+
+ nin->set5Momentum(Lorentz5Momentum(0.*GeV,in.first->momentum().vect() +
+ pt * perp));
+
+ intermediates.push_back(in.first);
+ in.first = nin;
+
+ }
+
+ // second parton
+
+ if (in.second->coloured()) {
+
+ Axis perp;
+ Energy pt = 0.*GeV;
+
+ double phi = 2.*Constants::pi*UseRandom::rnd();
+
+ Axis dir = in.second->momentum().vect().unit();
+ perp = dir.orthogonal();
+ perp.rotate(phi,dir);
+
+ double r = sqrt(-log(1.-UseRandom::rnd()));
+
+ if ( remDec->content().second.isValenceQuark(in.second) )
+ pt = sqrt(2.) * theValenceIntrinsicPtScale * r;
+ else {
+ assert(in.second->id() == ParticleID::g ||
+ remDec->content().second.isSeaQuark(in.second));
+ pt = sqrt(2.) * theSeaIntrinsicPtScale * r;
+ }
+
+ PPtr nin = new_ptr(Particle(in.second->dataPtr()));
+ nin->colourInfo(new_ptr(ColourBase()));
+
+ DipolePartonSplitter::change(in.second,nin,true);
+
+ nin->set5Momentum(Lorentz5Momentum(0.*GeV,in.second->momentum().vect() +
+ pt * perp));
+
+ intermediates.push_back(in.second);
+ in.second = nin;
+
+ }
+
+ // restore mometum conservation
+
+ Lorentz5Momentum nQ = in.first->momentum() + in.second->momentum();
+
+ double x = Q.m()/nQ.m();
+
+ nQ *= x;
+
+ // work around for constructor problems
+ // in Lorentz5Vector constructor, mass is not guaranteed
+ // to be zero, event it was set as such before,
+ // since gets recalculated in the LorentzVector
+ Lorentz5Momentum scaled = x * in.first->momentum();
+ scaled.setMass(ZERO); scaled.rescaleEnergy();
+ in.first->set5Momentum(scaled);
+ scaled = x * in.second->momentum();
+ scaled.setMass(ZERO); scaled.rescaleEnergy();
+ in.second->set5Momentum(scaled);
+
+ // apparently, this is more stable than boosting directly with
+ // n_Q.boostVector()-Q.boostVector()
+
+ Boost beta1 = -Q.boostVector();
+ Boost beta2 = nQ.boostVector();
+
+ SpinOneLorentzRotation transform (beta1);
+ transform.boost(beta2);
+
+ return transform;
+
+}
+
+// If needed, insert default implementations of virtual function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void IntrinsicPtGenerator::persistentOutput(PersistentOStream & os) const {
+ os << ounit(theValenceIntrinsicPtScale,GeV) << ounit(theSeaIntrinsicPtScale,GeV);
+}
+
+void IntrinsicPtGenerator::persistentInput(PersistentIStream & is, int) {
+ is >> iunit(theValenceIntrinsicPtScale,GeV) >> iunit(theSeaIntrinsicPtScale,GeV);
+}
+
+ClassDescription<IntrinsicPtGenerator> IntrinsicPtGenerator::initIntrinsicPtGenerator;
+// Definition of the static class description member.
+
+void IntrinsicPtGenerator::Init() {
+
+ static ClassDocumentation<IntrinsicPtGenerator> documentation
+ ("IntrinsicPtGenerator generates intrinsic pt for massless "
+ "incoming partons in a shower independent way.");
+
+
+ static Parameter<IntrinsicPtGenerator,Energy> interfaceValenceIntrinsicPtScale
+ ("ValenceIntrinsicPtScale",
+ "The width of the intrinsic pt Gaussian distribution for valence partons.",
+ &IntrinsicPtGenerator::theValenceIntrinsicPtScale, GeV, 1.0*GeV, 0.0*GeV, 0*GeV,
+ false, false, Interface::lowerlim);
+
+ static Parameter<IntrinsicPtGenerator,Energy> interfaceSeaIntrinsicPtScale
+ ("SeaIntrinsicPtScale",
+ "The width of the intrinsic pt Gaussian distribution for sea partons.",
+ &IntrinsicPtGenerator::theSeaIntrinsicPtScale, GeV, 1.0*GeV, 0.0*GeV, 0*GeV,
+ false, false, Interface::lowerlim);
+
+}
+
diff --git a/DipoleShower/Utility/IntrinsicPtGenerator.h b/DipoleShower/Utility/IntrinsicPtGenerator.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Utility/IntrinsicPtGenerator.h
@@ -0,0 +1,174 @@
+// -*- C++ -*-
+//
+// IntrinsicPtGenerator.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_IntrinsicPtGenerator_H
+#define HERWIG_IntrinsicPtGenerator_H
+//
+// This is the declaration of the IntrinsicPtGenerator class.
+//
+
+#include "ThePEG/Handlers/HandlerBase.h"
+#include "ThePEG/Vectors/SpinOneLorentzRotation.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief IntrinsicPtGenerator generates intrinsic pt for massless
+ * incoming partons in a shower independent way.
+ *
+ * @see \ref IntrinsicPtGeneratorInterfaces "The interfaces"
+ * defined for IntrinsicPtGenerator.
+ */
+class IntrinsicPtGenerator: public HandlerBase {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ IntrinsicPtGenerator();
+
+ /**
+ * The destructor.
+ */
+ virtual ~IntrinsicPtGenerator();
+ //@}
+
+public:
+
+ /**
+ * Generate intrinsic pt for the given incoming
+ * partons and return the transformation to be
+ * applied on the final state particles. Add the
+ * old incoming partons to the given list.
+ */
+ SpinOneLorentzRotation kick(PPair& in,
+ PList& intermediates);
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+private:
+
+ /**
+ * The mean of the Gaussian distribution for
+ * the intrinsic pt of valence partons.
+ */
+ Energy theValenceIntrinsicPtScale;
+
+ /**
+ * The mean of the Gaussian distribution for
+ * the intrinsic pt of sea partons.
+ */
+ Energy theSeaIntrinsicPtScale;
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<IntrinsicPtGenerator> initIntrinsicPtGenerator;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ IntrinsicPtGenerator & operator=(const IntrinsicPtGenerator &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of IntrinsicPtGenerator. */
+template <>
+struct BaseClassTrait<Herwig::IntrinsicPtGenerator,1> {
+ /** Typedef of the first base class of IntrinsicPtGenerator. */
+ typedef HandlerBase NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the IntrinsicPtGenerator class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::IntrinsicPtGenerator>
+ : public ClassTraitsBase<Herwig::IntrinsicPtGenerator> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::IntrinsicPtGenerator"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * IntrinsicPtGenerator is implemented. It may also include several, space-separated,
+ * libraries if the class IntrinsicPtGenerator depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_IntrinsicPtGenerator_H */
diff --git a/DipoleShower/Utility/Makefile.am b/DipoleShower/Utility/Makefile.am
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Utility/Makefile.am
@@ -0,0 +1,8 @@
+noinst_LTLIBRARIES = libHwDipoleShowerUtility.la
+
+libHwDipoleShowerUtility_la_SOURCES = \
+ ConstituentReshuffler.h ConstituentReshuffler.cc \
+ IntrinsicPtGenerator.h IntrinsicPtGenerator.cc \
+ DipolePartonSplitter.h DipolePartonSplitter.cc \
+ PDFRatio.h PDFRatio.cc \
+ DipoleMCCheck.h DipoleMCCheck.cc
\ No newline at end of file
diff --git a/DipoleShower/Utility/PDFRatio.cc b/DipoleShower/Utility/PDFRatio.cc
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Utility/PDFRatio.cc
@@ -0,0 +1,142 @@
+// -*- C++ -*-
+//
+// PDFRatio.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the PDFRatio class.
+//
+
+#include "PDFRatio.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/Interface/Parameter.h"
+
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+#include "Herwig++/Shower/ShowerHandler.h"
+#include "Herwig++/PDF/HwRemDecayer.h"
+
+using namespace Herwig;
+
+PDFRatio::PDFRatio()
+ : HandlerBase(),
+ theValenceExtrapolation(0.7), theSeaExtrapolation(0.6),
+ theFreezingScale(1.0*GeV) {}
+
+PDFRatio::~PDFRatio() {}
+
+IBPtr PDFRatio::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr PDFRatio::fullclone() const {
+ return new_ptr(*this);
+}
+
+double PDFRatio::operator() (const PDF& pdf,
+ Energy2 scale,
+ tcPDPtr from, tcPDPtr to,
+ double x, double z) const {
+
+ if ( x/z > 1.0 )
+ return 0.0;
+
+ if ( scale < sqr(theFreezingScale) )
+ scale = sqr(theFreezingScale);
+
+ tcHwRemDecPtr remDec =
+ ShowerHandler::currentHandler()->remnantDecayer();
+
+ const HwRemDecayer::HadronContent* theContent = 0;
+
+ if ( remDec->content().first.hadron == pdf.particle() ) {
+ theContent = &(remDec->content().first);
+ }
+
+ if ( remDec->content().second.hadron == pdf.particle() ) {
+ theContent = &(remDec->content().second);
+ }
+
+ assert(theContent);
+
+ double exFrom =
+ theContent->isValenceQuarkData(from) ?
+ theValenceExtrapolation : theSeaExtrapolation;
+
+ double exTo =
+ theContent->isValenceQuarkData(to) ?
+ theValenceExtrapolation : theSeaExtrapolation;
+
+ double xTo = x/z;
+
+ double fromPDF =
+ x < exFrom ?
+ pdf.xfx(from,scale,x) :
+ ((1.-x)/(1.-exFrom)) * pdf.xfx(from,scale,exFrom);
+
+ if ( abs(fromPDF) < 1e-8 )
+ fromPDF = 0.0;
+
+ double toPDF =
+ xTo < exTo ?
+ pdf.xfx(to,scale,xTo) :
+ ((1.-xTo)/(1.-exTo)) * pdf.xfx(to,scale,exTo);
+
+ if ( abs(toPDF) < 1e-8 )
+ toPDF = 0.0;
+
+ if ( toPDF == 0.0 || fromPDF == 0.0 )
+ return 0.0;
+
+ return toPDF / fromPDF;
+
+}
+
+// If needed, insert default implementations of virtual function defined
+// in the InterfacedBase class here (using ThePEG-interfaced-impl in Emacs).
+
+
+void PDFRatio::persistentOutput(PersistentOStream & os) const {
+ os << theValenceExtrapolation << theSeaExtrapolation
+ << ounit(theFreezingScale,GeV);
+}
+
+void PDFRatio::persistentInput(PersistentIStream & is, int) {
+ is >> theValenceExtrapolation >> theSeaExtrapolation
+ >> iunit(theFreezingScale,GeV);
+}
+
+ClassDescription<PDFRatio> PDFRatio::initPDFRatio;
+// Definition of the static class description member.
+
+void PDFRatio::Init() {
+
+ static ClassDocumentation<PDFRatio> documentation
+ ("PDFRatio implements numerically stable pdf ratios.");
+
+
+ static Parameter<PDFRatio,double> interfaceValenceExtrapolation
+ ("ValenceExtrapolation",
+ "The x from which on extrapolation should be done for valence partons.",
+ &PDFRatio::theValenceExtrapolation, 0.7, 0.0, 1.0,
+ false, false, Interface::limited);
+
+ static Parameter<PDFRatio,double> interfaceSeaExtrapolation
+ ("SeaExtrapolation",
+ "The x from which on extrapolation should be done for valence partons.",
+ &PDFRatio::theSeaExtrapolation, 0.6, 0.0, 1.0,
+ false, false, Interface::limited);
+
+ static Parameter<PDFRatio,Energy> interfaceFreezingScale
+ ("FreezingScale",
+ "The scale below which the PDFs are frozen.",
+ &PDFRatio::theFreezingScale, GeV, 1.0*GeV, 0.0*GeV, 0*GeV,
+ false, false, Interface::lowerlim);
+
+}
+
diff --git a/DipoleShower/Utility/PDFRatio.h b/DipoleShower/Utility/PDFRatio.h
new file mode 100644
--- /dev/null
+++ b/DipoleShower/Utility/PDFRatio.h
@@ -0,0 +1,178 @@
+// -*- C++ -*-
+//
+// PDFRatio.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2007 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+#ifndef HERWIG_PDFRatio_H
+#define HERWIG_PDFRatio_H
+//
+// This is the declaration of the PDFRatio class.
+//
+
+#include "ThePEG/Handlers/HandlerBase.h"
+#include "ThePEG/PDF/PDF.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * \ingroup DipoleShower
+ * \author Simon Platzer
+ *
+ * \brief PDFRatio implements numerically stable PDF ratios.
+ *
+ * @see \ref PDFRatioInterfaces "The interfaces"
+ * defined for PDFRatio.
+ */
+class PDFRatio: public HandlerBase {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ PDFRatio();
+
+ /**
+ * The destructor.
+ */
+ virtual ~PDFRatio();
+ //@}
+
+public:
+
+ /**
+ * For the given PDF, scale and partons from and to and
+ * x,z values return the ratio xf_to(x/z) / xf_from(x)
+ */
+ double operator() (const PDF& pdf,
+ Energy2 scale,
+ tcPDPtr from, tcPDPtr to,
+ double x, double z) const;
+
+public:
+
+ /** @name Functions used by the persistent I/O system. */
+ //@{
+ /**
+ * Function used to write out object persistently.
+ * @param os the persistent output stream written to.
+ */
+ void persistentOutput(PersistentOStream & os) const;
+
+ /**
+ * Function used to read in object persistently.
+ * @param is the persistent input stream read from.
+ * @param version the version number of the object when written.
+ */
+ void persistentInput(PersistentIStream & is, int version);
+ //@}
+
+ /**
+ * The standard Init function used to initialize the interfaces.
+ * Called exactly once for each class by the class description system
+ * before the main function starts or
+ * when this class is dynamically loaded.
+ */
+ static void Init();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr clone() const;
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ virtual IBPtr fullclone() const;
+ //@}
+
+
+// If needed, insert declarations of virtual function defined in the
+// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
+
+private:
+
+ /**
+ * The x from which on extrapolation should
+ * be done for valence partons.
+ */
+ double theValenceExtrapolation;
+
+ /**
+ * The x from which on extrapolation should
+ * be done for sea partons.
+ */
+ double theSeaExtrapolation;
+
+ /**
+ * The scale below which the PDF will be frozen
+ */
+ Energy theFreezingScale;
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<PDFRatio> initPDFRatio;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ PDFRatio & operator=(const PDFRatio &);
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of PDFRatio. */
+template <>
+struct BaseClassTrait<Herwig::PDFRatio,1> {
+ /** Typedef of the first base class of PDFRatio. */
+ typedef HandlerBase NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the PDFRatio class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::PDFRatio>
+ : public ClassTraitsBase<Herwig::PDFRatio> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::PDFRatio"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * PDFRatio is implemented. It may also include several, space-separated,
+ * libraries if the class PDFRatio depends on other classes (base classes
+ * excepted). In this case the listed libraries will be dynamically
+ * linked in the order they are specified.
+ */
+ static string library() { return "HwDipoleShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_PDFRatio_H */

File Metadata

Mime Type
text/x-diff
Expires
Tue, Nov 19, 7:41 PM (1 d, 9 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3805886
Default Alt Text
(506 KB)

Event Timeline