Page MenuHomeHEPForge

No OneTemporary

This file is larger than 256 KB, so syntax highlighting was skipped.
diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -1,6 +1,7 @@
168ae2110e964d62fbc1331a1c2e095952a67748 release-2-5-2
3abb4fa42e20e332796c2572334c2d77204cd0e0 release-2-4-2
4796ca080aafd5daa3b7349b015cb1df944428a2 release-2-5-0
76da042f056eb153981b4d005d5474ffb90a5e88 release-2-4-1
+81a684a558413c69df314365eabf09893ffd43d8 release-2-6-0
bd75cd00d99f4bdbaed992daf98f0a73c0f91e9b release-2-4-0
ff6ecc8d49ce10299303b050394bd5cb5837f1c3 release-2-5-1
diff --git a/Contrib/MCPWNLO/DRELLYAN/DYAnalysis/Makefile b/Contrib/MCPWNLO/DRELLYAN/DYAnalysis/Makefile
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/DRELLYAN/DYAnalysis/Makefile
@@ -0,0 +1,38 @@
+# -*- Makefile -*- (for emacs)
+
+#
+# This Makefile is intended for compiling Herwig++ plugins
+# You can find plugins here: INSERT URL
+#
+# This Makefile received very little testing,
+# any bug reports are very welcome!
+#
+
+# location of include files
+HPPDIR = /usera/seyi/Herwig
+THEPEGDIR = /usera/seyi/Herwig
+
+#CLHEPINCLUDE =
+#ROOTINCLUDE = -I/usera/andreas/root/include
+#ROOTCFLAGS := $(shell /usera/andreas/root/bin/root-config --ldflags)
+#ROOTGLIBS := $(shell /usera/andreas/root/bin/root-config --glibs)
+#ROOT = $(ROOTCFLAGS) $(ROOTGLIBS)
+INCLUDE = -I$(THEPEGDIR)/include -I$(HPPDIR)/include
+#
+# C++ flags
+#
+CXX = g++
+CXXFLAGS = -O2
+
+ALLCCFILES=$(shell echo *.cc)
+all : $(ALLCCFILES:.cc=.so)
+
+%.so : %.cc %.h
+ $(CXX) -fPIC $(CPPFLAGS) $(INCLUDE) $(ROOT) $(CXXFLAGS) -shared $< -o $@
+
+install:
+
+ cp MySimpleAnalysis.so $(HPPDIR)/lib/Herwig++
+
+clean:
+ rm -f $(ALLCCFILES:.cc=.so)
diff --git a/Contrib/MCPWNLO/DRELLYAN/DYAnalysis/MySimpleAnalysis.cc b/Contrib/MCPWNLO/DRELLYAN/DYAnalysis/MySimpleAnalysis.cc
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/DRELLYAN/DYAnalysis/MySimpleAnalysis.cc
@@ -0,0 +1,353 @@
+// -*- C++ -*-
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the MySimpleAnalysis class.
+//
+
+#include "MySimpleAnalysis.h"
+#include "ThePEG/Repository/EventGenerator.h"
+#include "ThePEG/EventRecord/Particle.h"
+#include "ThePEG/EventRecord/Event.h"
+#include "ThePEG/PDT/EnumParticles.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+#ifdef ThePEG_TEMPLATES_IN_CC_FILE
+// #include "MySimpleAnalysis.tcc"
+#endif
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+MySimpleAnalysis::MySimpleAnalysis() :
+ _ptZ(4,Histogram(0.,250.,250)), _ptWp(4,Histogram(0.,250.,250)),_ptWm(4,Histogram(0.,250.,250)),
+ _mWp(-250.,250.,100),_mZ(-250.,250.,100),_mWm(-250.,250.,100),
+ _rapZ(-10.,10., 100), _rapWp(-10.,10., 100),_rapWm(-10.,10., 100),
+ _rapem(-10.,10., 100),_rapep(-10.,10., 100),_rapnu(-10.,10., 100),_rapanu(-10.,10., 100),
+
+ _ptW4(0.,20.,10),
+ _ptW5(20.,40.,4),
+ _ptW6(40.,80.,4),
+ _ptW7(80.,100.,1),
+ _ptW8(100.,120.,1),
+ _ptW9(120.,160.,1),
+ _ptW10(160.,200.,1),
+ _ptZ4(0.,12.,24),
+ _ptZ5(12.,20.,8),
+ _ptZ6(20.,30.,5),
+ _ptZ7(30.,50.,5),
+ _ptZ8(50.,100.,5),
+ _ptZ9(100.,150.,2),
+ _ptZ10(150.,200.,1)
+
+
+{}
+
+//MySimpleAnalysis::~MySimpleAnalysis() {}
+
+// namespace {
+// inline Lorentz5Momentum getMomentum(tcPPtr particle) {
+// return particle->momentum();
+// //Lorentz5Momentum tmp = particle->children()[0]->next()->momentum();
+// //tmp += particle->children()[1]->next()->momentum();
+// //tmp.rescaleMass();
+// //return tmp;
+
+// }
+// }
+
+void MySimpleAnalysis::analyze(tEventPtr event, long, int, int) {
+string infile = "DYPP.dat";
+
+ ifstream normin;
+ string stringin = "";
+ double normfac = 1;
+ double stringdoub = 0;
+ bool next = 0, filerror = 0;
+ normin.open(infile.c_str());
+ if(!normin) { cerr << "Error: Failed to open file " << infile << endl; filerror = 1; normfac = 1.; }
+ if(!filerror) {
+ while(normin) {
+
+ normin >> stringin;
+
+ if(next) { normin >> stringdoub; normfac = stringdoub; break; }
+ if(stringin == "NORMFACTOR") { next = 1; }
+
+ }
+
+ }
+
+ eventweight_=event->weight()*normfac;
+
+ // AnalysisHandler::analyze(event, ieve, loop, state);
+ // Rotate to CMS, extract final state particles and call analyze(particles).
+ // find the Z or W
+ Lorentz5Momentum pz;
+ StepVector::const_iterator sit =event->primaryCollision()->steps().begin();
+ StepVector::const_iterator send=event->primaryCollision()->steps().end();
+ for(;sit!=send;++sit)
+ {
+ ParticleSet part=(**sit).all();
+ ParticleSet::const_iterator iter=part.begin();
+ ParticleSet::const_iterator end =part.end();
+ for( ;iter!=end;++iter)
+ {
+ if(((**iter).id()==ParticleID::Z0||(**iter).id()==ParticleID::gamma)&&
+ (**iter).children().size()==2)
+ {
+ pz=(*iter)->momentum();
+ Energy pt = pz.perp()/GeV;
+ Energy mz = pz.mass()/GeV;
+ if(mz>20.&&mz<80.) _ptZ[1].addWeighted(pt,eventweight_);
+ else if (mz>80.&&mz<100.) _ptZ[2].addWeighted(pt,eventweight_);
+ else if (mz>100.) _ptZ[3].addWeighted(pt,eventweight_);
+ if(mz>66.&&mz<116.) {
+ _ptZ4.addWeighted(pt,eventweight_);
+ _ptZ5.addWeighted(pt,eventweight_);
+ _ptZ6.addWeighted(pt,eventweight_);
+ _ptZ7.addWeighted(pt,eventweight_);
+ _ptZ8.addWeighted(pt,eventweight_);
+ _ptZ9.addWeighted(pt,eventweight_);
+ _ptZ10.addWeighted(pt,eventweight_);}
+ _ptZ[0].addWeighted(pt,eventweight_);
+ _mZ.addWeighted(mz,eventweight_);
+ double rap = 0.5*log((pz.e()+pz.z())/(pz.e()-pz.z()));
+ _rapZ.addWeighted(rap,eventweight_);
+ _phiZ.addWeighted(pz.phi(),eventweight_);
+ } else if ((**iter).id()==ParticleID::Wplus) {
+ pz=(*iter)->momentum();
+ Energy pt = pz.perp()/GeV;
+ Energy mz = pz.mass()/GeV;
+ if(mz>20.&&mz<80.) _ptWp[1].addWeighted(pt,eventweight_);
+ else if (mz>80.&&mz<100.) _ptWp[2].addWeighted(pt,eventweight_);
+ else if (mz>100.) _ptWp[3].addWeighted(pt,eventweight_);
+ _ptWp[0].addWeighted(pt,eventweight_);
+ _mWp.addWeighted(mz,eventweight_);
+ double rap = 0.5*log((pz.e()+pz.z())/(pz.e()-pz.z()));
+ _rapWp.addWeighted(rap,eventweight_);
+ _phiWp.addWeighted(pz.phi(),eventweight_);
+ } else if ((**iter).id()==ParticleID::Wminus) {
+ pz=(*iter)->momentum();
+ Energy pt = pz.perp()/GeV;
+ Energy mz = pz.mass()/GeV;
+ if(mz>20.&&mz<80.) _ptWm[1].addWeighted(pt,eventweight_);
+ else if (mz>80.&&mz<100.) _ptWm[2].addWeighted(pt,eventweight_);
+ else if (mz>100.) _ptWm[3].addWeighted(pt,eventweight_);
+ _ptWm[0].addWeighted(pt,eventweight_);
+ _mWm.addWeighted(mz,eventweight_);
+ double rap = 0.5*log((pz.e()+pz.z())/(pz.e()-pz.z()));
+ _rapWm.addWeighted(rap,eventweight_);
+ _phiWm.addWeighted(pz.phi(),eventweight_);
+ }
+
+ if ((**iter).id()==ParticleID::Wplus || (**iter).id()==ParticleID::Wminus) {
+ pz=(*iter)->momentum();
+ Energy pt = pz.perp()/GeV;
+ Energy mz = pz.mass()/GeV;
+ if(mz>70.&&mz<100.){
+ _ptW4.addWeighted(pt,eventweight_);
+ _ptW5.addWeighted(pt,eventweight_);
+ _ptW6.addWeighted(pt,eventweight_);
+ _ptW7.addWeighted(pt,eventweight_);
+ _ptW8.addWeighted(pt,eventweight_);
+ _ptW9.addWeighted(pt,eventweight_);
+ _ptW10.addWeighted(pt,eventweight_);
+ }}
+ }
+ }
+
+
+ // Rotate to CMS, extract final state particles and call analyze(particles).
+ // find the leptons
+
+
+ ParticleVector lept;
+ lept.clear();
+
+
+ for(sit=send-1;sit!=send;++sit)
+ {
+ ParticleSet part=(**sit).all();
+ ParticleSet::const_iterator iter1=part.begin();
+ ParticleSet::const_iterator end1 =part.end();
+
+ for( ;iter1!=end1;++iter1) {
+ if ((fabs((**iter1).id())==11 || fabs((**iter1).id())==12) && (**iter1).children().size()==0) {
+
+ lept.push_back((*iter1));
+ } }
+
+
+
+ Lorentz5Momentum pzep(0.0,0.0,0.0,0.0,0.0);
+ Lorentz5Momentum pzem(0.0,0.0,0.0,0.0,0.0);
+ Lorentz5Momentum pznu(0.0,0.0,0.0,0.0,0.0);
+ Lorentz5Momentum pzanu(0.0,0.0,0.0,0.0,0.0);
+ Lorentz5Momentum fullmom(0.0,0.0,0.0,0.0,0.0);
+ ParticleVector::const_iterator iter2=lept.begin();
+ ParticleVector::const_iterator end2 =lept.end();
+ for( ;iter2!=end2;++iter2) {
+ if((**iter2).id()==-11) {
+ pzep=(*iter2)->momentum();}
+ else if ((**iter2).id()==11) {
+ pzem=(*iter2)->momentum();}
+ else if ((**iter2).id()==12) {
+ pznu=(*iter2)->momentum();}
+ else if ((**iter2).id()==-12) {
+ pzanu=(*iter2)->momentum();}
+
+ }
+
+ double rapem = 0.5*log((pzem.e()+pzem.z())/(pzem.e()-pzem.z()));
+ double rapep = 0.5*log((pzep.e()+pzep.z())/(pzep.e()-pzep.z()));
+ double rapnu = 0.5*log((pznu.e()+pznu.z())/(pznu.e()-pznu.z()));
+ double rapanu = 0.5*log((pzanu.e()+pzanu.z())/(pzanu.e()-pzanu.z()));
+
+
+ _rapem.addWeighted(rapem,eventweight_);
+ _rapep.addWeighted(rapep,eventweight_);
+ _rapnu.addWeighted(rapnu,eventweight_);
+ _rapanu.addWeighted(rapanu,eventweight_);
+
+
+
+ }
+}
+
+
+
+
+//LorentzRotation MySimpleAnalysis::transform(tEventPtr) const {
+// return LorentzRotation();
+ // Return the Rotation to the frame in which you want to perform the analysis.
+//}
+
+//void MySimpleAnalysis::analyze(const tPVector & particles) {
+// AnalysisHandler::analyze(particles);
+//}
+
+//void MySimpleAnalysis::analyze(tPPtr) {}
+
+//void MySimpleAnalysis::persistentOutput(PersistentOStream &) const {
+ // *** ATTENTION *** os << ; // Add all member variable which should be written persistently here.
+//}
+
+//void MySimpleAnalysis::persistentInput(PersistentIStream &, int) {
+ // *** ATTENTION *** is >> ; // Add all member variable which should be read persistently here.
+//}
+
+NoPIOClassDescription<MySimpleAnalysis> MySimpleAnalysis::initMySimpleAnalysis;
+// Definition of the static class description member.
+
+void MySimpleAnalysis::Init() {
+
+ static ClassDocumentation<MySimpleAnalysis> documentation
+ ("There is no documentation for the MySimpleAnalysis class");
+
+}
+
+void MySimpleAnalysis::dofinish() {
+ AnalysisHandler::dofinish();
+ string fname = generator()->filename() + string("-") + name() + string(".top");
+ ofstream outfile(fname.c_str());
+ string title;
+ using namespace HistogramOptions;
+ title="pT of Z boson (bin-sized for data comparison with CDF Run I at 1.8TeV)";
+ _ptZ4.topdrawOutput(outfile,Frame,"",title);
+ _ptZ5.topdrawOutput(outfile,None,"", title="");
+ _ptZ6.topdrawOutput(outfile,None,"",title="");
+ _ptZ7.topdrawOutput(outfile,None,"",title="");
+ _ptZ8.topdrawOutput(outfile,None,"",title="");
+ _ptZ9.topdrawOutput(outfile,None,"",title="");
+ _ptZ10.topdrawOutput(outfile,None,"BLACK",title="");
+ title="pT of W boson (bin-sized for data comparison with D0 Run I at 1.8TeV)";
+ _ptW4.topdrawOutput(outfile,Frame,"",title);
+ _ptW5.topdrawOutput(outfile,None,"", title="");
+ _ptW6.topdrawOutput(outfile,None,"",title="");
+ _ptW7.topdrawOutput(outfile,None,"",title="");
+ _ptW8.topdrawOutput(outfile,None,"",title="");
+ _ptW9.topdrawOutput(outfile,None,"",title="");
+ _ptW10.topdrawOutput(outfile,None,"BLACK",title="");
+
+ // _phianu.topdrawOutput(outfile,Frame,"BLACK","Azimuth of anitneutrino");
+ // _phinu.topdrawOutput(outfile,Frame,"BLACK","Azimuth of neutrino");
+ // _phiep.topdrawOutput(outfile,Frame,"BLACK","Azimuth of positron");
+ // _phiem.topdrawOutput(outfile,Frame,"BLACK","Azimuth of electron");
+
+ _rapanu.topdrawOutput(outfile,Frame,"BLACK","Rapidity of anitneutrino");
+ _rapnu.topdrawOutput(outfile,Frame,"BLACK","Rapidity of neutrino");
+ _rapep.topdrawOutput(outfile,Frame,"BLACK","Rapidity of positron");
+ _rapem.topdrawOutput(outfile,Frame,"BLACK","Rapidity of electron");
+ for(unsigned int ix=0;ix<1;++ix)
+ {
+ if(ix==0){title="pt of Z for all masses ";}
+ else if(ix==1){title="pt of Z for mass 40-80 GeV";}
+ else if(ix==2){title="pt of Z for mass 80-100 GeV";}
+ else if(ix==3){title="pt of Z for mass 100- GeV";}
+ // _ptZ[ix].topdrawOutput(outfile,Frame,"BLACK",title);
+ _ptZ[ix].topdrawOutput(outfile,Frame|Ylog,"BLACK",title);
+ if(ix==0){title="pt of Wp for all masses ";}
+ else if(ix==1){title="pt of Wp for mass 40-80 GeV";}
+ else if(ix==2){title="pt of Wp for mass 80-100 GeV";}
+ else if(ix==3){title="pt of Wp for mass 100- GeV";}
+ // _ptWp[ix].topdrawOutput(outfile,Frame,"BLACK",title);
+ _ptWp[ix].topdrawOutput(outfile,Frame|Ylog,"BLACK",title);
+ if(ix==0){title="pt of Wm for all masses ";}
+ else if(ix==1){title="pt of Wm for mass 40-80 GeV";}
+ else if(ix==2){title="pt of Wm for mass 80-100 GeV";}
+ else if(ix==3){title="pt of Wm for mass 100- GeV";}
+ // _ptWm[ix].topdrawOutput(outfile,Frame,"BLACK",title);
+ _ptWm[ix].topdrawOutput(outfile,Frame|Ylog,"BLACK",title);
+ }
+ _mWp.topdrawOutput(outfile,Frame,"BLACK","Mass of Wp");
+ _mZ.topdrawOutput(outfile,Frame,"BLACK","Mass of Z");
+ //_mZ.topdrawOutput(outfile,Frame|Ylog,"BLACK", "Mass of Z");
+
+ // _mWp.topdrawOutput(outfile,Frame|Ylog,"BLACK", "Mass of Wp");
+ _mWm.topdrawOutput(outfile,Frame,"BLACK","Mass of Wm");
+// _mWm.topdrawOutput(outfile,Frame|Ylog,"BLACK", "Mass of Wm");
+ _rapZ.topdrawOutput(outfile,Frame,"BLACK","Rapidity of Z");
+// _rapZ.topdrawOutput(outfile,Frame|Ylog,"BLACK","Rapidity of Z");
+ _rapWp.topdrawOutput(outfile,Frame,"BLACK","Rapidity of Wp");
+// _rapWp.topdrawOutput(outfile,Frame|Ylog,"BLACK","Rapidity of Wp");
+ _rapWm.topdrawOutput(outfile,Frame,"BLACK","Rapidity of Wm");
+// _rapWm.topdrawOutput(outfile,Frame|Ylog,"BLACK","Rapidity of Wm");
+
+// _phiZ.topdrawOutput(outfile,Frame,"BLACK","Azimuth of Z");
+// _phiWp.topdrawOutput(outfile,Frame,"BLACK","Azimuth of Wp");
+// _phiWm.topdrawOutput(outfile,Frame,"BLACK","Azimuth of Wm");
+}
+
+
+
+// LorentzRotation MySimpleAnalysis::transform(tEventPtr event) const {
+// return LorentzRotation();
+// // Return the Rotation to the frame in which you want to perform the analysis.
+// }
+
+// void MySimpleAnalysis::analyze(const tPVector & particles) {
+// AnalysisHandler::analyze(particles);
+// }
+
+// void MySimpleAnalysis::analyze(tPPtr) {}
+
+// void MySimpleAnalysis::persistentOutput(PersistentOStream & os) const {
+// // *** ATTENTION *** os << ; // Add all member variable which should be written persistently here.
+// }
+
+// void MySimpleAnalysis::persistentInput(PersistentIStream & is, int) {
+// // *** ATTENTION *** is >> ; // Add all member variable which should be read persistently here.
+// }
+
+// ClassDescription<MySimpleAnalysis> MySimpleAnalysis::initMySimpleAnalysis;
+// // Definition of the static class description member.
+
+// void MySimpleAnalysis::Init() {
+
+// static ClassDocumentation<MySimpleAnalysis> documentation
+// ("There is no documentation for the MySimpleAnalysis class");
+
+// }
+
diff --git a/Contrib/MCPWNLO/DRELLYAN/DYAnalysis/MySimpleAnalysis.h b/Contrib/MCPWNLO/DRELLYAN/DYAnalysis/MySimpleAnalysis.h
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/DRELLYAN/DYAnalysis/MySimpleAnalysis.h
@@ -0,0 +1,244 @@
+// -*- C++ -*-
+#ifndef HERWIG_MySimpleAnalysis_H
+#define HERWIG_MySimpleAnalysis_H
+//
+// This is the declaration of the MySimpleAnalysis class.
+//
+
+#include "ThePEG/Repository/CurrentGenerator.h"
+#include "ThePEG/Handlers/AnalysisHandler.h"
+#include "Herwig++/Utilities/Histogram.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * Here is the documentation of the MySimpleAnalysis class.
+ *
+ * @see \ref MySimpleAnalysisInterfaces "The interfaces"
+ * defined for MySimpleAnalysis.
+ */
+class MySimpleAnalysis: public AnalysisHandler {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ MySimpleAnalysis();
+
+ /**
+ * The destructor.
+ */
+ //virtual void analyze(tEventPtr event, long ieve, int loop, int state);
+ //virtual ~MySimpleAnalysis();
+ //@}
+
+ public:
+
+ /** @name Virtual functions required by the AnalysisHandler class. */
+ //@{
+ /**
+ * Analyze a given Event. Note that a fully generated event
+ * may be presented several times, if it has been manipulated in
+ * between. The default version of this function will call transform
+ * to make a lorentz transformation of the whole event, then extract
+ * all final state particles and call analyze(tPVector) of this
+ * analysis object and those of all associated analysis objects. The
+ * default version will not, however, do anything on events which
+ * have not been fully generated, or have been manipulated in any
+ * way.
+ * @param event pointer to the Event to be analyzed.
+ * @param ieve the event number.
+ * @param loop the number of times this event has been presented.
+ * If negative the event is now fully generated.
+ * @param state a number different from zero if the event has been
+ * manipulated in some way since it was last presented.
+ */
+ virtual void analyze(tEventPtr event, long ieve, int loop, int state);
+
+ /**
+ * Transform the event to the desired Lorentz frame and return the
+ * corresponding LorentzRotation.
+ * @param event a pointer to the Event to be transformed.
+ * @return the LorentzRotation used in the transformation.
+ */
+ // virtual LorentzRotation transform(tEventPtr event) const;
+
+ /**
+ * Analyze the given vector of particles. The default version calls
+ * analyze(tPPtr) for each of the particles.
+ * @param particles the vector of pointers to particles to be analyzed
+ */
+ //virtual void analyze(const tPVector & particles);
+
+ /**
+ * Analyze the given particle.
+ * @param particle pointer to the particle to be analyzed.
+ */
+ //virtual void analyze(tPPtr particle);
+ //@}
+
+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.
+ */
+ inline virtual IBPtr clone() const {return new_ptr(*this);}
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ inline virtual IBPtr fullclone() const {return new_ptr(*this);}
+ //@}
+
+protected:
+
+ /** @name Standard Interfaced functions. */
+ //@{
+ /**
+ * Finalize this object. Called in the run phase just after a
+ * run has ended. Used eg. to write out statistics.
+ */
+ inline virtual void dofinish();
+
+ private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static NoPIOClassDescription<MySimpleAnalysis> initMySimpleAnalysis;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ MySimpleAnalysis & operator=(const MySimpleAnalysis &);
+
+private:
+ /**
+ * \f$p_T\f$ of the Z boson
+ */
+ vector<Histogram> _ptZ;
+ vector<Histogram> _ptWp;
+ vector<Histogram> _ptWm;
+
+ /**
+ * \f$p_T\f$ of the W/Z boson for data comparism
+ */
+ Histogram _ptZ4,_ptZ5,_ptZ6,_ptZ7,_ptZ8,_ptZ9,_ptZ10;
+ Histogram _ptW4,_ptW5,_ptW6,_ptW7,_ptW8,_ptW9,_ptW10;
+
+ /**
+ * Mass of the Z boson
+ */
+ Histogram _mZ;
+ Histogram _mWp;
+ Histogram _mWm;
+ /**
+ * The weight for the event
+ */
+ double eventweight_;
+ /**
+ * Rapidity of Z
+ */
+ Histogram _rapZ;
+ Histogram _rapWp;
+ Histogram _rapWm;
+
+ /**
+ * Azimuth of Z
+ */
+ Histogram _phiZ;
+ Histogram _phiWp;
+ Histogram _phiWm;
+/**
+ * Rapidity of leptons
+ */
+ Histogram _rapem;
+ Histogram _rapep;
+ Histogram _rapnu;
+ Histogram _rapanu;
+ /**
+ * Azimuth of leptons
+ */
+ Histogram _phiem;
+ Histogram _phiep;
+ Histogram _phinu;
+ Histogram _phianu;
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of MySimpleAnalysis. */
+template <>
+struct BaseClassTrait<Herwig::MySimpleAnalysis,1> {
+ /** Typedef of the first base class of MySimpleAnalysis. */
+ typedef AnalysisHandler NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the MySimpleAnalysis class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::MySimpleAnalysis>
+ : public ClassTraitsBase<Herwig::MySimpleAnalysis> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::MySimpleAnalysis"; }
+ /** Return the name(s) of the shared library (or libraries) be loaded to get
+ * access to the MySimpleAnalysis class and any other class on which it depends
+ * (except the base class). */
+ static string library() { return "MySimpleAnalysis.so"; }
+};
+
+/** @endcond */
+
+}
+
+//#include "MySimpleAnalysis.icc"
+#ifndef ThePEG_TEMPLATES_IN_CC_FILE
+// #include "MySimpleAnalysis.tcc"
+#endif
+
+#endif /* HERWIG_MySimpleAnalysis_H */
diff --git a/Contrib/MCPWNLO/DRELLYAN/DYAnalysis/MySimpleAnalysis.icc b/Contrib/MCPWNLO/DRELLYAN/DYAnalysis/MySimpleAnalysis.icc
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/DRELLYAN/DYAnalysis/MySimpleAnalysis.icc
@@ -0,0 +1,116 @@
+// -*- C++ -*-
+//
+// This is the implementation of the inlined member functions of
+// the MySimpleAnalysis class.
+//
+
+namespace Herwig {
+
+inline MySimpleAnalysis::MySimpleAnalysis() :
+ _ptZ(4,Histogram(0.,250.,250)), _ptWp(4,Histogram(0.,250.,250)),_ptWm(4,Histogram(0.,250.,250)),
+ _mWp(-250.,250.,100),_mZ(-250.,250.,100),_mWm(-250.,250.,100),
+ _rapZ(-4.,4., 40), _rapWp(-4.,4., 40),_rapWm(-4.,4., 40),
+ _phiZ(0.,3.2, 32), _phiWp(0.,3.2, 32), _phiWm(0.,3.2, 32),
+ _rapem(-4.,4., 40),_rapep(-4.,4., 40),_rapnu(-4.,4., 40),_rapanu(-4.,4., 40),
+ _phiem(0.,3.2, 32),_phiep(0.,3.2, 32), _phinu(0.,3.2, 32),_phianu(0.,3.2, 32),
+
+ _ptW4(0.,20.,10),
+ _ptW5(20.,40.,4),
+ _ptW6(40.,80.,4),
+ _ptW7(80.,100.,1),
+ _ptW8(100.,120.,1),
+ _ptW9(120.,160.,1),
+ _ptW10(160.,200.,1),
+ _ptZ4(0.,12.,24),
+ _ptZ5(12.,20.,8),
+ _ptZ6(20.,30.,5),
+ _ptZ7(30.,50.,5),
+ _ptZ8(50.,100.,5),
+ _ptZ9(100.,150.,2),
+ _ptZ10(150.,200.,1)
+
+
+{}
+
+
+inline IBPtr MySimpleAnalysis::clone() const {
+ return new_ptr(*this);
+}
+
+inline IBPtr MySimpleAnalysis::fullclone() const {
+ return new_ptr(*this);
+}
+
+
+inline void MySimpleAnalysis::dofinish() {
+ AnalysisHandler::dofinish();
+ string fname = generator()->filename() + string("-") + name() + string(".top");
+ ofstream outfile(fname.c_str());
+ string title;
+ using namespace HistogramOptions;
+ title="pT of Z boson for data comparison with CDF Run I at 1.8TeV";
+ _ptZ4.topdrawOutput(outfile,Frame,"",title);
+ _ptZ5.topdrawOutput(outfile,None,"", title="");
+ _ptZ6.topdrawOutput(outfile,None,"",title="");
+ _ptZ7.topdrawOutput(outfile,None,"",title="");
+ _ptZ8.topdrawOutput(outfile,None,"",title="");
+ _ptZ9.topdrawOutput(outfile,None,"",title="");
+ _ptZ10.topdrawOutput(outfile,None,"BLACK",title="");
+ title="pT of W boson for data comparison with D0 Run I at 1.8TeV";
+ _ptW4.topdrawOutput(outfile,Frame,"",title);
+ _ptW5.topdrawOutput(outfile,None,"", title="");
+ _ptW6.topdrawOutput(outfile,None,"",title="");
+ _ptW7.topdrawOutput(outfile,None,"",title="");
+ _ptW8.topdrawOutput(outfile,None,"",title="");
+ _ptW9.topdrawOutput(outfile,None,"",title="");
+ _ptW10.topdrawOutput(outfile,None,"BLACK",title="");
+
+ _phianu.topdrawOutput(outfile,Frame,"BLACK","Azimuth of anitneutrino");
+ _phinu.topdrawOutput(outfile,Frame,"BLACK","Azimuth of neutrino");
+ _phiep.topdrawOutput(outfile,Frame,"BLACK","Azimuth of positron");
+ _phiem.topdrawOutput(outfile,Frame,"BLACK","Azimuth of electron");
+
+ _rapanu.topdrawOutput(outfile,Frame,"BLACK","Rapidity of anitneutrino");
+ _rapnu.topdrawOutput(outfile,Frame,"BLACK","Rapidity of neutrino");
+ _rapep.topdrawOutput(outfile,Frame,"BLACK","Rapidity of positron");
+ _rapem.topdrawOutput(outfile,Frame,"BLACK","Rapidity of electron");
+ for(unsigned int ix=0;ix<1;++ix)
+ {
+ if(ix==0){title="pt of Z for all masses ";}
+ else if(ix==1){title="pt of Z for mass 40-80 GeV";}
+ else if(ix==2){title="pt of Z for mass 80-100 GeV";}
+ else if(ix==3){title="pt of Z for mass 100- GeV";}
+ // _ptZ[ix].topdrawOutput(outfile,Frame,"BLACK",title);
+ _ptZ[ix].topdrawOutput(outfile,Frame|Ylog,"BLACK",title);
+ if(ix==0){title="pt of Wp for all masses ";}
+ else if(ix==1){title="pt of Wp for mass 40-80 GeV";}
+ else if(ix==2){title="pt of Wp for mass 80-100 GeV";}
+ else if(ix==3){title="pt of Wp for mass 100- GeV";}
+ // _ptWp[ix].topdrawOutput(outfile,Frame,"BLACK",title);
+ _ptWp[ix].topdrawOutput(outfile,Frame|Ylog,"BLACK",title);
+ if(ix==0){title="pt of Wm for all masses ";}
+ else if(ix==1){title="pt of Wm for mass 40-80 GeV";}
+ else if(ix==2){title="pt of Wm for mass 80-100 GeV";}
+ else if(ix==3){title="pt of Wm for mass 100- GeV";}
+ // _ptWm[ix].topdrawOutput(outfile,Frame,"BLACK",title);
+ _ptWm[ix].topdrawOutput(outfile,Frame|Ylog,"BLACK",title);
+ }
+ _mWp.topdrawOutput(outfile,Frame,"BLACK","Mass of Wp");
+ _mZ.topdrawOutput(outfile,Frame,"BLACK","Mass of Z");
+ //_mZ.topdrawOutput(outfile,Frame|Ylog,"BLACK", "Mass of Z");
+
+ // _mWp.topdrawOutput(outfile,Frame|Ylog,"BLACK", "Mass of Wp");
+ _mWm.topdrawOutput(outfile,Frame,"BLACK","Mass of Wm");
+// _mWm.topdrawOutput(outfile,Frame|Ylog,"BLACK", "Mass of Wm");
+ _rapZ.topdrawOutput(outfile,Frame,"BLACK","Rapidity of Z");
+// _rapZ.topdrawOutput(outfile,Frame|Ylog,"BLACK","Rapidity of Z");
+ _rapWp.topdrawOutput(outfile,Frame,"BLACK","Rapidity of Wp");
+// _rapWp.topdrawOutput(outfile,Frame|Ylog,"BLACK","Rapidity of Wp");
+ _rapWm.topdrawOutput(outfile,Frame,"BLACK","Rapidity of Wm");
+// _rapWm.topdrawOutput(outfile,Frame|Ylog,"BLACK","Rapidity of Wm");
+
+ _phiZ.topdrawOutput(outfile,Frame,"BLACK","Azimuth of Z");
+ _phiWp.topdrawOutput(outfile,Frame,"BLACK","Azimuth of Wp");
+ _phiWm.topdrawOutput(outfile,Frame,"BLACK","Azimuth of Wm");
+}
+}
diff --git a/Contrib/MCPWNLO/DRELLYAN/DYAnalysis/WpTRun1.top b/Contrib/MCPWNLO/DRELLYAN/DYAnalysis/WpTRun1.top
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/DRELLYAN/DYAnalysis/WpTRun1.top
@@ -0,0 +1,36 @@
+NEW FRAME
+SET FONT DUPLEX
+TITLE TOP "pt of W boson (D0 data from Run 1)"
+CASE ""
+TITLE LEFT "1/S dS/dp1T"
+CASE " G G Y"
+SET ORDER X Y DY
+SET SCALE Y LOG
+TITLE BOTTOM ""
+CASE ""
+SET LIMITS X 0 200
+SET LIMITS Y 0.5e-06 0.238206
+1.0 0.047346 0.004606
+3.0 0.089138 0.012831
+5.0 0.074147 0.006407
+7.0 0.057844 0.006259
+9.0 0.044719 0.004848
+11.0 0.033584 0.004597
+13.0 0.027558 0.003199
+15.0 0.020727 0.002944
+17.0 0.016329 0.002134
+19.0 0.013268 0.001649
+22.5 0.009533 0.001013
+27.5 0.006035 0.000827
+32.5 0.004099 0.000658
+37.5 0.002961 0.0004978
+45.0 0.001709 0.000290
+55.0 0.000784 0.0002035
+65.0 0.0004978 0.0001991
+75.0 0.0003247 0.0001688
+90.0 0.0001355 0.0000649
+110.0 0.0000363636 0.0000203
+140.0 0.0000190476 0.0000113
+180.0 0.0000033333 0.0000043
+PLOT SYMBOL 2o
+NEW FRAME
diff --git a/Contrib/MCPWNLO/DRELLYAN/DYAnalysis/ZpTRun1.top b/Contrib/MCPWNLO/DRELLYAN/DYAnalysis/ZpTRun1.top
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/DRELLYAN/DYAnalysis/ZpTRun1.top
@@ -0,0 +1,64 @@
+NEW FRAME
+SET FONT DUPLEX
+SET INTENSITY 4
+set window x 2 12 y 2.9 9
+TITLE TOP "p1T0 of the Z boson (CDF data from Run 1)"
+CASE " Y Y "
+TITLE LEFT "1/S dS/dp1T"
+CASE " G G Y"
+SET ORDER X Y DX DY
+SET SCALE Y LOG
+SET LIMITS X 0 200
+SET LIMITS Y 0.5e-06 0.238206
+ 0.25 0.0135081 0.25 0.00217742
+ 0.75 0.0407258 0.25 0.00403226
+ 1.25 0.0596774 0.25 0.00483871
+ 1.75 0.0782258 0.25 0.00564516
+ 2.25 0.0814516 0.25 0.00564516
+ 2.75 0.0951613 0.25 0.00604839
+ 3.25 0.0951613 0.25 0.00564516
+ 3.75 0.0927419 0.25 0.00564516
+ 4.25 0.0802419 0.25 0.00524194
+ 4.75 0.0778226 0.25 0.00483871
+ 5.25 0.0721774 0.25 0.00483871
+ 5.75 0.0725806 0.25 0.00483871
+ 6.25 0.058871 0.25 0.00403226
+ 6.75 0.0584677 0.25 0.00403226
+ 7.25 0.0544355 0.25 0.00403226
+ 7.75 0.0552419 0.25 0.00403226
+ 8.25 0.0479839 0.25 0.00362903
+ 8.75 0.0419355 0.25 0.00362903
+ 9.25 0.0447581 0.25 0.00362903
+ 9.75 0.0385484 0.25 0.00330645
+ 10.25 0.0336694 0.25 0.00306452
+ 10.75 0.0315323 0.25 0.00298387
+ 11.25 0.0329839 0.25 0.00306452
+ 11.75 0.0301613 0.25 0.00290323
+ 12.5 0.0290726 0.5 0.0021371
+ 13.5 0.0243952 0.5 0.00189516
+ 14.5 0.0190726 0.5 0.00165323
+ 15.5 0.0210081 0.5 0.00177419
+ 16.5 0.0179839 0.5 0.0016129
+ 17.5 0.0172581 0.5 0.00157258
+ 18.5 0.0141532 0.5 0.00141129
+ 19.5 0.0121371 0.5 0.00133065
+ 21 0.0106048 1 0.000887097
+ 23 0.00733871 1 0.000725806
+ 25 0.00745968 1 0.000725806
+ 27 0.00637097 1 0.000685484
+ 29 0.00568548 1 0.000645161
+ 32 0.0041129 2 0.000403226
+ 36 0.00273387 2 0.000318548
+ 40 0.00259677 2 0.000306452
+ 44 0.00175 2 0.00025
+ 48 0.00158871 2 0.000237903
+ 55 0.000846774 5 0.000108871
+ 65 0.000431452 5 7.66129e-05
+ 75 0.000366935 5 7.05645e-05
+ 85 0.000181452 5 4.91935e-05
+ 95 0.000141532 5 4.31452e-05
+112.5 7.29839e-05 12.5 1.93548e-05
+137.5 2.86694e-05 12.5 1.19758e-05
+175 3.92742e-06 25 3.04839e-06
+PLOT SYMBOL 2o
+NEW FRAME
diff --git a/Contrib/MCPWNLO/DRELLYAN/DYPP.cxx b/Contrib/MCPWNLO/DRELLYAN/DYPP.cxx
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/DRELLYAN/DYPP.cxx
@@ -0,0 +1,1865 @@
+/* This program calculates for Drell Yan lepton pair production the integrals
+defined in equations (7.3) and (7.4) on page 28 of arXiv:07084390v1 and
+Appendices F and G. It also calculates the maximum values of the integrand
+in different regions of phase space which will be used for event generation
+in a sister program regZZ.cxx. */
+
+#include <cstdlib>
+#include <ctime>
+#include <iostream>
+#include <string>
+#include "LHAPDF/LHAPDF.h"
+#include <fstream>
+#include "DYPP_INPUTS.h"
+#include <cmath>
+#include <iomanip>
+
+using namespace LHAPDF;
+using namespace std;
+
+//POWHEG functions
+double G(double &rp2, double &rNq, double &rbb, double &rqq, double &rpm, double &rll);
+double DG(double &rp2, double &rNq,double &rbb,double &rqq,double &rpm,double &rll);
+
+//MC@NLO functions
+double DYBC(double &rx,double &ry, double r3, double r4);
+double DYD(double &rx, double &ry, double r3, double r4);
+double DYGBC(double &rx, double &ry, double r3, double r4);
+double DYGD(double &rx, double &ry, double r3, double r4);
+
+//Random number generator
+double random (int &rseed);
+
+ /*********************************************************************/
+ /*********************************************************************/
+ /*********************************************************************/
+
+// Main program for cross-section calculation.
+
+ int main() {
+ Input user;
+ int seed = user.rseed(); /* initial seed for random number generator */
+ char* scheme = user.rscheme(); /* DIS scheme or MSbar scheme */
+ char* pdfset = user.PDFset(); /* PDF set */
+ int proc = user.VBID(); /*process ID: Z production Z/gamma, W */
+ bool pp = user.acc(); /* pp or ppbar */
+
+ /* Define constants: emcm=center of mass energy, CF and TF are
+ colour factors respectively for gluon and quark emission. */
+
+ double emcm = user.cme();
+ double S2 = emcm*emcm;
+ double CF = 4./3.;
+ double TF =0.5;
+ double pi = 3.14152654;
+
+ bool MCNLO = user.MCNLO();
+ bool truncsh = user.trunc() ; /* Implement truncated shower? */
+ int nev = user.nevint(); /*number of events integrated over */
+ int nevg = user.nevgen(); /*number of events to generate */
+ int ii=0; //event count
+
+ /*Define the coupling constants. */
+ double v[6],a[6],va[6],vq[6];
+ double sin2thw=0.2312;
+ v[1]=-0.5+(2./3.)*sin2thw;
+ v[2]=0.5-(4./3.)*sin2thw;
+ v[3]=v[1];v[4]=v[2];v[5]=v[1];a[1]=0.5;a[2]=-0.5;a[3]=a[1];a[4]=a[2];a[5]=a[1];
+ for (int ij=1; ij <6;ij++) {
+ va[ij]=(pow(v[ij],2)+pow(a[ij],2));}
+
+ vq[1]=0.952; vq[2]=0.049; vq[3]=0.952;
+ vq[4]=0.00168; vq[5]=0.049; vq[6]=0.00001063;
+ /*************************************************************************/
+
+ /* pdf routine. Calls external LHAPDF which calculates the
+ parton distribution functions*/
+ const int SUBSET = 0;
+ // const string NAME = "cteq4d.LHgrid";
+ setVerbosity(SILENT); // or LOWKEY
+
+ initPDFByName(pdfset, SUBSET);
+// int subset = 0;
+ // char name[160];
+ // string byname = user.PDFset();
+// // if (DIS) {
+// // byname = "/usera/seyi/lhapdf-5.3.0/PDFsets/cteq5d.LHgrid";} else
+// // {byname = "/usera/seyi/lhapdf-5.3.0/PDFsets/cteq5m.LHgrid";}
+// strcpy(name,byname.c_str());
+// LHAPDFWrap pdf = LHAPDFWrap();
+// pdf.initPDFSet(name);
+// pdf.initPDF(subset);
+
+ /*************************************************************************/
+
+
+ /*Define variables for boson */
+ double mp, Yzz;
+ if (proc==23) {
+ mp = user.Mz(); /* Z boson pole mass*/
+ Yzz = user.widthz(); /* Z boson width */ }
+ else if (proc==24) {
+ mp = user.Mw(); /* W boson pole mass*/
+ Yzz =user.widthw(); /* W boson width */ }
+ double Qmax=mp+user.halfwidth()*Yzz;
+ double Qmin=mp-user.halfwidth()*Yzz;
+ double rhomin=atan((pow(Qmin,2)-pow(mp,2))/(Yzz*mp));
+ double rhomax=atan((pow(Qmax,2)-pow(mp,2))/(Yzz*mp));
+ double xqc=sqrt(pow(Qmin,2)/S2);
+ double fvmax=0.;
+ int sgn=1;
+ if (pp) {sgn=-1;}
+ /* Calculate maximum value for the Born cross-section fvmax */
+ int id;
+ if (proc==23) {
+ for(id=1; id<6; id++) {
+ fvmax+=(xfx(xqc,Qmin,id)*xfx(xqc,Qmin,sgn*id)+xfx(xqc,Qmin,-id)*xfx(xqc,Qmin,-sgn*id))*(pow(v[id],2)+pow(a[id],2))/(xqc*xqc);}}
+ if (proc==24) {
+ for(id=1; id<5; id++) {
+ fvmax+=2.*(xfx(xqc,Qmin,id)*xfx(xqc,Qmin,sgn*(id+1))+xfx(xqc,Qmin,-id)*xfx(xqc,Qmin,-sgn*(id+1)))*vq[id]/(xqc*xqc);}
+ for(id=1; id<3; id++) {
+ fvmax+=2.*(xfx(xqc,Qmin,id)*xfx(xqc,Qmin,sgn*(id+3))+xfx(xqc,Qmin,-id)*xfx(xqc,Qmin,-sgn*(id+3)))*vq[id+4]/(xqc*xqc);}
+}
+
+/* Generate Born variables Q, yz and hence xq and xqb which are Born process mmt fractions. Q = generated boson mass, yz= boson rapidity generated for the Born process*/
+
+ double xq,xqb,x,y,Q,yz;
+
+ /*PDF terms. [fq1,fq2] and [fqb1,fqb2] are pdfs for quarks from hadrons [1,2]
+ and antiquarks from hadrons [1,2] resp. ffq1 and ffq2 are the
+ 2 combinations of the products of the Born process pdfs.*/
+
+ double ffq1[7],ffq2[7],fv, fv1,fv2,fq1[7],fq2[7],fqb1[7],fqb2[7];
+
+ /* w1 and w2 are the integrands. p1 and p2 are the corresponding integrals
+ calcaulated from sum1 and sum2 & sd1 and sd2 are the corresponding errors
+ calculated via ssq1 and ssq2. bigwt is the maximum value of w1 over
+ the phase space (will be used for event generation) */
+
+ double w1[4],w2[4],p1[4],p2[4],p3[4],sd1[4],sd2[4],sd3[4];
+ double bigwt[4],sum1[4],sum2[4],sum3[4],ssq1[4],ssq2[4],ssq3[4];
+ double sumwgt,jgmax;
+ sumwgt = 0.;
+ //POWHEG stuff
+ double rmwgt;
+ double bigrmwgt=0.;
+ /* initialize sums and variances */
+
+ sum1[0]=0.;sum1[1]=0.;sum1[2]=0.;sum1[3]=0.;
+ sum2[0]=0.;sum2[1]=0.;sum2[2]=0.;sum2[3]=0.;
+ sum3[0]=0.;sum3[1]=0.;sum3[2]=0.;sum3[3]=0.;
+ ssq1[0]=0.;ssq1[1]=0.;ssq1[2]=0.;ssq1[3]=0.;
+ ssq2[0]=0.;ssq2[1]=0.;ssq2[2]=0.;ssq2[3]=0.;
+ ssq3[0]=0.;ssq3[1]=0.;ssq3[2]=0.;ssq3[3]=0.;
+ bigwt[0]=0.;bigwt[1]=0.;bigwt[2]=0.;bigwt[3]=0.;jgmax=0.;
+ w1[0]=0.;w1[1]=0.;w1[2]=0.;w1[3]=0.;
+ w2[0]=0.;w2[1]=0.;w2[2]=0.;w2[3]=0.;
+ double Born = 0.;
+
+ cout << "Integrating..." << endl;
+
+ for (int d = 0; d < nev; d++) {
+ // cout << d << endl;
+ do {
+ fv = 0; /*initialize cross-section for Born process*/
+ fv1 = 0;
+ fv2 = 0;
+ if (!user.zerowidth()) {
+ Q=sqrt(mp*Yzz*tan(rhomin+random(seed)*(rhomax-rhomin))+pow(mp,2));} else
+ {Q=mp;}
+ yz=log(pow(Q,2)/S2)*random(seed)-0.5*log(pow(Q,2)/S2);
+ xq=sqrt(pow(Q,2)/S2)*exp(yz);
+ xqb=sqrt(pow(Q,2)/S2)*exp(-yz);
+ int e;
+ if (proc==23) {
+ for (e=1; e<6; e++) {
+ fq1[e] = xfx(xq,Q,e);
+ fqb2[e]= xfx(xqb,Q,sgn*e);
+ fqb1[e] =xfx(xq,Q,-e);
+ fq2[e] = xfx(xqb,Q,-sgn*e);
+ ffq1[e] = fq1[e]*fqb2[e];
+ ffq2[e] = fqb1[e]*fq2[e];
+
+ fv1 += va[e]*ffq1[e];
+ fv2 += va[e]*ffq2[e];
+ }} else if(proc==24) {
+ for(e=1; e<5; e++) {
+ fq1[e] = xfx(xq,Q,e)*xfx(xqb,Q,sgn*(e+1))+xfx(xq,Q,-e)*xfx(xqb,Q,-sgn*(e+1))+xfx(xqb,Q,sgn*e)*xfx(xq,Q,e+1)+xfx(xqb,Q,-sgn*e)*xfx(xq,Q,-(e+1));
+ }
+ int ee=1;
+ for(e=5; e<7; e++) {
+ fq1[e] = xfx(xq,Q,ee)*xfx(xqb,Q,sgn*(ee+3))+xfx(xq,Q,-ee)*xfx(xqb,Q,-sgn*(ee+3))+xfx(xqb,Q,sgn*ee)*xfx(xq,Q,ee+3)+xfx(xqb,Q,-sgn*ee)*xfx(xq,Q,-(ee+3));
+ ee+=1;}
+ for (e=1; e<7; e++) {
+ fv1 += vq[e]*fq1[e];
+ fv2 = 0;}
+ }
+ fv = (fv1 + fv2)/(xq*xqb);
+
+ } while (random(seed) > fv/fvmax);
+
+ /* random numbers for phase space integrations */
+
+ double r1=random(seed);
+ double r2=random(seed);
+ double r3=random(seed);
+ double r4=random(seed);
+ x = r1;
+ y = 2.*r2 - 1.;
+ w1[0] = DYBC(x,y,r3,r4);
+ w1[1] = DYD(x,y,r3,r4);
+ w1[2] = DYGBC(x,y,r3,r4);
+ w1[3] = DYGD(x,y,r3,r4);
+
+ /* Mandelstam variables s,t,u and scale for NLO emission*/
+
+ double s = pow(Q,2)/x;
+ double t = -s*(1.-x)*(1.-y)/2.;
+ double u = -s*(1.-x)*(1.+y)/2.;
+ double scale = sqrt(u*t/s+pow(Q,2));
+ if (scale < sqrt(getQ2min(0))) {scale = sqrt(getQ2min(0));}
+ /*NLO momentum fractions x1,x2 */
+ double x1 = xq*sqrt((2.-(1.-x)*(1.-y))/((2.-(1.-x)*(1.+y))*x));
+ double x2 = xqb*sqrt((2.-(1.-x)*(1.+y))/((2.-(1.-x)*(1.-y))*x));
+
+// Terms for calculating NLO pdf factors = combinations of sums of vv1..vv8.
+
+ double fg1,fg2,fn1[6],fnb1[6],fn2[6],fnb2[6],fs1[6],fsb1[6];
+ double fs2[6],fsb2[6],ffn1[6],ffn2[6],fgn1[6],fgn2[6],fgnb1[6],fgnb2[6];
+ double ffs1[6],ffs2[6],v1[6],v2[6],v3[6],v4[6],v5[6],v6[6],v7[6],v8[6];
+ double fqq[26],fq[26],fw[26];
+ /* Calculate pdf factors for NLO emission. jqq,jg, jq are
+ the ratios of the NLO pdf factors to the Born level pdf factors.
+ jqq=[q(x1,scale)*q(x2,scale)+x1<->x2]/[q(x1,Q)*q(x2,Q)].
+ jg=[g(x1,scale)*q(x2,scale)+x1<->x2]/[q(x1,Q)*q(x2,Q)].
+ jq=[q(x1,Q)*q(x2,Q)+x1<->x2]/[q(x1,Q)*q(x2,Q)]*/
+ // initialize sums
+
+ double vv1=0;double vv2=0;double vv3=0;double vv4=0;
+ double vv5=0;double vv6=0;double vv7=0;double vv8=0;
+ double jqq=0;double jq=0;double jg=0;
+
+
+ if(proc==23) {
+ for (int ix=1; ix<6; ix++) {
+ fg1 = xfx(x1,scale,0);
+ fg2 = xfx(x2,scale,0);
+
+ fq1[ix] = xfx(xq,Q,ix);
+ fqb2[ix] = xfx(xqb,Q,sgn*ix);
+
+ fs1[ix] = xfx(xq,scale,ix);
+ fsb2[ix] = xfx(xqb,scale,sgn*ix);
+ fn1[ix] = xfx(x1,scale,ix);
+ fnb2[ix] = xfx(x2,scale,sgn*ix);
+ fqb1[ix] = xfx(xq,Q,-ix);
+ fq2[ix] = xfx(xqb,Q,-sgn*ix);
+
+ fsb1[ix] = xfx(xq,scale,-ix);
+ fs2[ix] = xfx(xqb,scale,-sgn*ix);
+ fnb1[ix] = xfx(x1,scale,-ix);
+ fn2[ix] = xfx(x2,scale,-sgn*ix);
+
+ ffq1[ix] = fq1[ix]*fqb2[ix];
+ ffq2[ix] = fqb1[ix]*fq2[ix];
+ ffn1[ix] = fn1[ix]*fnb2[ix];
+ ffn2[ix] = fnb1[ix]*fn2[ix];
+ ffs1[ix] = fs1[ix]*fsb2[ix];
+ ffs2[ix] = fsb1[ix]*fs2[ix];
+ fgn1[ix] = fg2*fn1[ix];
+ fgn2[ix] = fg1*fn2[ix];
+ fgnb1[ix] = fg2*fnb1[ix];
+ fgnb2[ix] = fg1*fnb2[ix];
+ v1[ix] = ffn1[ix]/ffq1[ix];
+ v2[ix] = ffn2[ix]/ffq2[ix];
+ v3[ix] = fgn1[ix]/ffq1[ix];
+ v4[ix] = fgn2[ix]/ffq2[ix];
+ v5[ix] = fgnb1[ix]/ffq2[ix];
+ v6[ix] = fgnb2[ix]/ffq1[ix];
+ v7[ix] = ffs1[ix]/ffq1[ix];
+ v8[ix] = ffs2[ix]/ffq2[ix];
+ if (ffq1[ix] == 0) {
+ v1[ix] = 0;
+ v3[ix] = 0;
+ v6[ix] = 0;
+ v7[ix] = 0;}
+ if (ffq2[ix] == 0) {
+ v2[ix] = 0;
+ v4[ix] = 0;
+ v5[ix] = 0;
+ v8[ix] = 0;}
+ vv1 += v1[ix];
+ vv2 += v2[ix];
+ vv3 += v3[ix];
+ vv4 += v4[ix];
+ vv5 += v5[ix];
+ vv6 += v6[ix];
+ vv7 += v7[ix];
+ vv8 += v8[ix];
+
+ }
+
+ jqq = vv1+vv2;
+ jg = vv3+vv4+vv5+vv6;
+ jq = vv7+vv8;
+ }
+ else if (proc==24) {
+ int ix, iy;
+ for (ix=1; ix<5; ix++) {
+ fw[ix]=xfx(x1,scale,ix)*xfx(x2,scale,sgn*(ix+1));
+ fq[ix]=xfx(xq,Q,ix)*xfx(xqb,Q,sgn*(ix+1));
+ fqq[ix]=xfx(xq,scale,ix)*xfx(xqb,scale,sgn*(ix+1));
+ if(fq[ix]!=0) {
+ jqq+=fw[ix]/fq[ix];
+ jq+=fqq[ix]/fq[ix];}
+}
+ int f=1;
+ for (ix=5; ix<9; ix++) {
+ fw[ix]=xfx(x1,scale,-f)*xfx(x2,scale,-sgn*(f+1));
+ fq[ix]=xfx(xq,Q,-f)*xfx(xqb,Q,-sgn*(f+1));
+ fqq[ix]=xfx(xq,scale,-f)*xfx(xqb,scale,-sgn*(f+1));
+ if (fq[ix]!=0) {
+ jqq+=fw[ix]/fq[ix];
+ jq+=fqq[ix]/fq[ix];}
+ f+=1;}
+ f=1;
+ for (ix=9; ix<13; ix++) {
+ fw[ix]=xfx(x2,scale,sgn*f)*xfx(x1,scale,(f+1));
+ fq[ix]=xfx(xqb,Q,sgn*f)*xfx(xq,Q,(f+1));
+ fqq[ix]=xfx(xqb,scale,sgn*f)*xfx(xq,scale,(f+1));
+ if (fq[ix]!=0) {
+ jqq+=fw[ix]/fq[ix];
+ jq+=fqq[ix]/fq[ix];}
+ f+=1;}
+ f=1;
+ for (ix=13; ix<17; ix++) {
+ fw[ix]=xfx(x2,scale,-sgn*f)*xfx(x1,scale,-(f+1));
+ fq[ix]=xfx(xqb,Q,-sgn*f)*xfx(xq,Q,-(f+1));
+ fqq[ix]=xfx(xqb,scale,-sgn*f)*xfx(xq,scale,-(f+1));
+ if (fq[ix]!=0) {
+ jqq+=fw[ix]/fq[ix];
+ jq+=fqq[ix]/fq[ix];}
+ f+=1;}
+ f=1;
+ for(ix=17;ix<19;ix++) {
+ fw[ix]=xfx(x1,scale,f)*xfx(x2,scale,sgn*(f+3));
+ fq[ix]=xfx(xq,Q,f)*xfx(xqb,Q,sgn*(f+3));
+ fqq[ix]=xfx(xq,scale,f)*xfx(xqb,scale,sgn*(f+3));
+ if (fq[ix]!=0) {
+ jqq+=fw[ix]/fq[ix];
+ jq+=fqq[ix]/fq[ix];}
+ f+=1;}
+ f=1;
+ for(ix=19;ix<21;ix++) {
+ fw[ix]=xfx(x1,scale,-f)*xfx(x2,scale,-sgn*(f+3));
+ fq[ix]=xfx(xq,Q,-f)*xfx(xqb,Q,-sgn*(f+3));
+ fqq[ix]=xfx(xq,scale,-f)*xfx(xqb,scale,-sgn*(f+3));
+ if (fq[ix]!=0) {
+ jqq+=fw[ix]/fq[ix];
+ jq+=fqq[ix]/fq[ix];}
+ f+=1;}
+ f=1;
+ for(ix=21;ix<23;ix++) {
+ fw[ix]=xfx(x2,scale,sgn*f)*xfx(x1,scale,(f+3));
+ fq[ix]=xfx(xqb,Q,sgn*f)*xfx(xq,Q,(f+3));
+ fqq[ix]=xfx(xqb,scale,sgn*f)*xfx(xq,scale,(f+3));
+ if (fq[ix]!=0) {
+ jqq+=fw[ix]/fq[ix];
+ jq+=fqq[ix]/fq[ix];}
+ f+=1;}
+ f=1;
+ for(ix=23;ix<25;ix++) {
+ fw[ix]=xfx(x2,scale,-sgn*f)*xfx(x1,scale,-(f+3));
+ fq[ix]=xfx(xqb,Q,-sgn*f)*xfx(xq,Q,-(f+3));
+ fqq[ix]=xfx(xqb,scale,-sgn*f)*xfx(xq,scale,-(f+3));
+ if (fq[ix]!=0) {
+ jqq+=fw[ix]/fq[ix];
+ jq+=fqq[ix]/fq[ix];}
+ f+=1;}
+
+
+
+ double Vud=0.952;
+ double Vus=0.049;
+ double Vub=0.00001063;
+ double Vcd=0.049;
+ double Vcs=0.952;
+ double Vcb=0.00168;
+
+ jg = 0.; jq = 0.,jqq=0.;
+ double CKM[6],CKM2[25];
+ CKM[1]=Vud+Vcd;
+ CKM[2]=Vud+Vus+Vub;
+ CKM[3]=Vus+Vcs;
+ CKM[4]=Vcb+Vcs+Vcd;
+ CKM[5]=Vub+Vcb;
+ for (iy=1; iy< 6 ; iy++){
+ jg += CKM[iy]*(xfx(x2,scale,0)*xfx(x1,scale,iy)+xfx(x2,scale,0)*xfx(x1,scale,-iy)+xfx(x1,scale,0)*xfx(x2,scale,sgn*iy)+xfx(x1,scale,0)*xfx(x2,scale,-sgn*iy));
+ }
+ // if (jg > jgmax) {jgmax = jg; cout << jgmax << '\t' << scale << endl;}
+
+ CKM2[1]=Vud;CKM2[2]=Vus;CKM2[3]=Vcs;CKM2[4]=Vcb;CKM2[5]=Vud;CKM2[6]=Vus;CKM2[7]=Vcs;CKM2[8]=Vcb;CKM2[9]=Vud;CKM2[10]=Vus;CKM2[11]=Vcs;CKM2[12]=Vcb;CKM2[13]=Vud;CKM2[14]=Vus;CKM2[15]=Vcs;CKM2[16]=Vcb;
+ CKM2[17]=Vcd;CKM2[18]=Vub;CKM2[19]=Vcd;CKM2[20]=Vub;CKM2[21]=Vcd;CKM2[22]=Vub;CKM2[23]=Vcd;CKM2[24]=Vub;
+ for (iy=1;iy <25 ; iy++){
+ jq += CKM2[iy]*fqq[iy];
+ }
+ for (iy=1;iy <25 ; iy++){
+ jqq += CKM2[iy]*fw[iy];
+ }
+ double Bfq=0.;
+ for (int iyy=1; iyy < 25; iyy++) {
+ Bfq += CKM2[iyy]*fq[iyy];
+ }
+ jq = jq/Bfq; jqq=jqq/Bfq; jg = jg/Bfq;
+
+ }
+
+ double scale2 = sqrt(pow(Q,2)+u*t/s);
+ double as = alphasPDF(scale2);
+ double wgt1, wgt2, wgt3, wgt4, wgt5;
+ wgt3 = jq;
+ jqq = jqq*as*CF/(2.*pi);
+ jq = jq*as*CF/(2.*pi);
+ jg = jg*as*TF/(2.*pi);
+ if (scheme=="DIS") {
+ wgt1 = -6.-4.*x;
+ wgt2 = -5.*x+4.5*pow(x,2)+1.5+(pow(x,2)+pow((1.-x),2))*log((1.-x)*pow(Q/scale,2));
+ wgt4 = 1.+4.*pow(pi,2)/3.+3.*log(pow(Q/scale,2));
+ wgt5 = (3.+2.*(1.+pow(x,2))*log(pow(Q/scale,2)))*(x*jqq-jq)/(1.-x)+2.*(1.+pow(x,2))*log(1.-x)/(1.-x)*jqq*x-4.*log(1.-x)/(1.-x)*jq;
+} else if (scheme=="MSbar") {
+ wgt1 = -2.*(1.+pow(x,2))/(1.-x)*log(x);
+ wgt2 = 0.5+3.*x-3.5*pow(x,2)+(pow(x,2)+pow(1.-x,2))*log(pow(1.-x,2)/x*pow(Q/scale,2));
+ wgt4 = -8.+2.*pow(pi,2)/3.+3.*log(pow(Q/scale,2)) ;
+ wgt5 = (2.*(1.+pow(x,2))*log(pow(Q/scale,2)))*(x*jqq-jq)/(1.-x)+4.*(1+pow(x,2))*log(1.-x)/(1.-x)*jqq*x-8.*log(1.-x)/(1.-x)*jq;}
+ /* Calculate integrals p1,p2 and calculte maximum weights bigwt in
+ phase space regions */
+
+ for (int iz=0; iz<2; iz++) {
+ w1[iz] = w1[iz]*jqq;
+
+ if (w1[iz] != 0.) {
+ w2[iz] = wgt3-w1[iz]+(wgt1*jqq*x+wgt4*jq)
+ +wgt5;} else {
+ w2[iz] = 0.;}
+ if (abs(w1[iz]) > abs(bigwt[iz])) {bigwt[iz]=w1[iz];}}
+
+
+ for (int ia=2; ia<4; ia++) {
+ w1[ia] = w1[ia]*jg;
+ if (w1[ia] != 0.) {
+ w2[ia] = -w1[ia]+wgt2*jg*x;} else {
+ w2[ia] = 0.;}
+ if (fabs(w1[3]) > fabs(bigwt[3])) {bigwt[ia]=w1[ia];
+
+}}
+ for (int ib=0; ib<4; ib++) {
+ sum1[ib] += w1[ib];
+ if (w2[ib] > 0) {
+ sum2[ib] += w2[ib];
+ ssq1[ib] += pow(w1[ib],2);
+ ssq2[ib] += pow(w2[ib],2);
+ } else {sum3[ib]+=w2[ib];
+ ssq3[ib] += pow(w2[ib],2);} }
+ Born += wgt3;
+ cout << "Integrated event : " << "\t" << d+1 << "\t" << "of" << "\t" << nev << "\r" << flush;
+ }
+ cout << endl;
+ double xsec = 0.;
+ double xsecabs = 0.;
+ for (int ic=0; ic<4; ic++) {
+ p1[ic] = sum1[ic]/nev;
+ p2[ic] = sum2[ic]/nev;
+ p3[ic] = sum3[ic]/nev;
+ sd1[ic] = sqrt((ssq1[ic]/nev-pow(p1[ic],2))/nev);
+ sd2[ic] = sqrt((ssq2[ic]/nev-pow(p2[ic],2))/nev);
+ sd3[ic] = sqrt((ssq3[ic]/nev-pow(p3[ic],2))/nev);
+ xsec+=p1[ic]+p2[ic]+p3[ic];
+ xsecabs+=fabs(p1[ic])+fabs(p2[ic])+fabs(p3[ic]);
+ //Output to screen the integrals, errors and maximum weights
+ cout << p1[ic] << "/" << p2[ic] <<"/" << p3 [ic]<<"/" << bigwt[ic] << endl;
+ // cout << Born << endl;
+ }
+ cout << "k factor = " << xsec << endl;
+ cout << "norm factor = " << xsecabs/xsec << endl;
+
+
+ //*******************************************************************
+ ofstream outdata, outdata1;
+ if (MCNLO){
+ outdata.open("MCDYPP.dat", ios::trunc);//output for MC@NLO events
+ } else {outdata.open("PWDYPP.dat", ios::trunc);} //output for POWHEG events
+
+ int Jt,Jtt; /*phase space identifiers*/
+ Jtt = 0;
+ double cst[4];
+ double cstt=0.;double ratio=0.;
+ for(int ix=0; ix<4 ; ix++){
+ cst[ix]=fabs(p1[ix])+fabs(p2[ix])+fabs(p3[ix]);
+ cstt += cst[ix];
+ ratio += p1[ix]+p2[ix]+p3[ix];}
+
+
+
+ outdata << "<LesHouchesEvents version =\"1.0\">" << endl; outdata << "<!--" << endl;
+ if (MCNLO){outdata << "NORMFACTOR =" <<"\t"<< xsecabs/xsec << endl;}else {outdata << "NORMFACTOR =" <<"\t"<< 1.0 << endl;}
+ if (MCNLO) {outdata << "MC@NLO" << "\t" ;} else {outdata << "POWHEG" << "\t" ;}
+ if (proc==23) {outdata << "Z boson production from" << "\t" ;} else {outdata << "W boson production from" << "\t" ;}
+ if (pp && user.cme() == 14000.) {outdata << "proton-proton collisions at LHC";} else if (!pp && (user.cme() > 1700. ||user.cme() < 2000.)) {outdata << "proton-antiproton collisions at the Tevatron" << endl;}
+ outdata << "File generated with DYPP.cxx" << endl; outdata << "-->" << endl;
+ outdata << "<init>" << endl;
+ int WGTOPT = 3;
+ if (!MCNLO) {WGTOPT = 1;}
+ outdata << "\t2212\t" << "-2212\t" << user.cme()/2. << "\t" << user.cme()/2. << "\t" << "0 \t 0 \t 7\t 7 \t" << WGTOPT << "\t 1" << endl;
+ double csn;
+ if (user.cme()==1800.) {
+ if (proc==23) {csn=248.;} else if (proc==24) {csn=2500.;}}
+ if (user.cme()==1960.) {
+ if (proc==23) {csn=264.9;} else if (proc==24) {csn=2865.2;}}
+ if (user.cme()==14000.) {
+ if (proc==23) {csn=1860.;} else if (proc==24) {csn=20300.;}}
+
+ outdata << "\t" << csn << "\t" << 0.000000 << "\t1.00000 \t" << proc << endl; outdata << "</init>" << endl;
+
+/**********************************************************************************************/
+
+ cout << "Generating events..." << endl;
+
+ for (int d = 0; d < nevg; d++) {
+
+ fv = 0.; /*cross section for Born process*/
+ // POWHEG stuff
+ bool emit = false;
+ double wgt, bigwgt,kt;
+ double s = 0,t = 0, u = 0,x1 = 0,x2 = 0;/* Mandelstam variables s,t,u and NLO momentum fractions x1,x2*/
+ // Assign particle IDs to quarks according to Born pdf factors
+ int ID[2],ID1, ID2;//ID2;
+ /************************************************/
+ do {
+ rmwgt=0.;
+ do {
+ fv1 = 0;
+ fv2 = 0;
+ if (!user.zerowidth()) {
+ Q=sqrt(mp*Yzz*tan(rhomin+random(seed)*(rhomax-rhomin))+pow(mp,2));} else
+ {Q=mp;}
+ yz=log(pow(Q,2)/S2)*random(seed)-0.5*log(pow(Q,2)/S2);
+ xq=sqrt(pow(Q,2)/S2)*exp(yz);
+ xqb=sqrt(pow(Q,2)/S2)*exp(-yz);
+ int e;
+ if (proc==23) {
+ for (e=1; e<6; e++) {
+ fq1[e] = xfx(xq,Q,e);
+ fqb2[e]= xfx(xqb,Q,sgn*e);
+ fqb1[e] =xfx(xq,Q,-e);
+ fq2[e] = xfx(xqb,Q,-sgn*e);
+ ffq1[e] = fq1[e]*fqb2[e];
+ ffq2[e] = fqb1[e]*fq2[e];
+
+ fv1 += va[e]*ffq1[e];
+ fv2 += va[e]*ffq2[e];
+ }} else if(proc==24) {
+ for(e=1; e<5; e++) {
+ fq1[e] = xfx(xq,Q,e)*xfx(xqb,Q,sgn*(e+1))+xfx(xq,Q,-e)*xfx(xqb,Q,-sgn*(e+1))+xfx(xqb,Q,sgn*e)*xfx(xq,Q,e+1)+xfx(xqb,Q,-sgn*e)*xfx(xq,Q,-(e+1));
+ }
+ int ee=1;
+ for(e=5; e<7; e++) {
+ fq1[e] = xfx(xq,Q,ee)*xfx(xqb,Q,sgn*(ee+3))+xfx(xq,Q,-ee)*xfx(xqb,Q,-sgn*(ee+3))+xfx(xqb,Q,sgn*ee)*xfx(xq,Q,(ee+3))+xfx(xqb,Q,-sgn*ee)*xfx(xq,Q,-(ee+3));
+ ee+=1;}
+ for (e=1; e<7; e++) {
+ fv1 += vq[e]*fq1[e];
+ fv2 = 0;}
+ }
+ /*recall PDFs give xf(x,Q) so need to divide out xq*xqb in product */
+
+ fv = (fv1 + fv2)/(xq*xqb);;
+
+ } while (random(seed) > fv/fvmax);
+
+// Assign particle IDs to quarks according to Born pdf factors
+
+
+ double g1 = 0;
+ double g2 = 0;
+ double g = 0;
+ if (proc==23) {
+
+ if (fv1 !=0 ) {
+ if (random(seed)< va[1]*ffq1[1]/fv1) {g1 = va[1]*ffq1[1];
+ ID1 = 1;}
+ else if (random(seed) < va[2]*ffq1[2]/(fv1-va[1]*ffq1[1])) {g1 = va[2]*ffq1[2];
+ ID1 = 2;}
+ else if (random(seed) < va[3]*ffq1[3]/(fv1-va[1]*ffq1[1]-va[2]*ffq1[2])) {g1 = va[3]*ffq1[3];
+ ID1 = 3;}
+ else if (random(seed) < va[4]*ffq1[4]/(va[4]*ffq1[4]+va[5]*ffq1[5])) {g1 = va[4]*ffq1[4];
+ ID1 = 4;}
+ else {g1 = va[5]*ffq1[5];
+ ID1 = 5;}}
+ if (fv2 !=0 ) {
+ if (random(seed) < va[1]*ffq2[1]/fv2) {g2 = va[1]*ffq2[1];
+ ID2 = -1;}
+ else if (random(seed) < va[2]*ffq2[2]/(fv2-va[1]*ffq2[1])) {g2 = va[2]*ffq2[2];
+ ID2 = -2;}
+ else if (random(seed) < va[3]*ffq2[3]/(fv2-va[1]*ffq2[1]-va[2]*ffq2[2])) {g2 = va[3]*ffq2[3];
+ ID2 = -3;}
+ else if (random(seed) < va[4]*ffq2[4]/(va[4]*ffq2[4]+va[5]*ffq2[5])) {g2 = va[4]*ffq2[4];
+ ID2 = -4;}
+ else {g2 = va[5]*ffq2[5];
+ ID2 = -5;}}
+ if (random(seed)< g1/(g1+g2)) {g = g1;
+ ID[0] = ID1; ID[1] = -ID1;}
+ else {g = g2;
+ ID[0] = ID2; ID[1]= -ID2; }}
+
+ else if (proc==24) {
+ if (random(seed) < vq[1]*fq1[1]/fv1) {g1=vq[1]*fq1[1];
+ ID1=1;}
+ else if (random(seed) < vq[2]*fq1[2]/(fv1-vq[1]*fq1[1])) {g1 = vq[2]*fq1[2];
+ ID1 = 2;}
+ else if (random(seed) < vq[3]*fq1[3]/(fv1-vq[1]*fq1[1]-vq[2]*fq1[2])) {g1 = vq[3]*fq1[3];
+ ID1 = 3;}
+ else if (random(seed) < vq[4]*fq1[4]/(vq[4]*fq1[4]+vq[5]*fq1[5]+vq[6]+fq1[6])) {g1 = vq[4]*fq1[4];
+ ID1 = 4;}
+ else if (random(seed) < vq[5]*fq1[5]/(vq[5]*fq1[5]+vq[6]*fq1[6])) {g1 = vq[5]*fq1[5];
+ ID1 = 5;}
+ else {g1 = vq[6]*fq1[6];
+ ID1 = 6;}
+ if(ID1 < 5) {
+ if (random(seed) < xfx(xq,Q,ID1)*xfx(xqb,Q,sgn*(ID1+1))/fq1[ID1]) {
+ ID[0]=ID1;ID[1]=-(ID1+1);}
+
+ else if (random(seed) < xfx(xq,Q,-ID1)*xfx(xqb,Q,-sgn*(ID1+1))/(fq1[ID1]-xfx(xq,Q,ID1)*xfx(xqb,Q,sgn*(ID1+1)))) {ID[0]=-ID1;ID[1]=ID1+1;}
+
+ else if (random(seed) < xfx(xq,Q,ID1+1)*xfx(xqb,Q,sgn*ID1)/(xfx(xq,Q,ID1+1)*xfx(xqb,Q,sgn*ID1)+xfx(xq,Q,-(ID1+1))*xfx(xqb,Q,-sgn*ID1))) {ID[0]=ID1+1;ID[1]=-ID1;}
+
+ else {ID[0]=-(ID1+1);ID[1]=ID1;} }
+
+ if (ID1 > 4) {
+
+ if (random(seed) < xfx(xq,Q,ID1-1)*xfx(xqb,Q,sgn*(ID1-4))/fq1[ID1]) { ID[0]=ID1-1;ID[1]=-(ID1-4);}
+
+ else if (random(seed) < xfx(xq,Q,-(ID1-1))*xfx(xqb,Q,-sgn*(ID1-4))/(fq1[ID1]-xfx(xq,Q,ID1-1)*xfx(xqb,Q,sgn*(ID1-4)))) {ID[0]=-(ID1-1);ID[1]=ID1-4;}
+
+ else if (random(seed) < xfx(xq,Q,ID1-4)*xfx(xqb,Q,sgn*(ID1-1))/(xfx(xq,Q,ID1-4)*xfx(xqb,Q,sgn*(ID1-1))+xfx(xq,Q,-(ID1-4))*xfx(xqb,Q,-sgn*(ID1-1))))
+ {ID[0]=ID1-4;ID[1]=-(ID1-1);}
+
+ else {ID[0]=-(ID1-4);ID[1]=ID1-1;} }
+
+ }
+
+ /* Select phase space according to contribution to cross-section.
+ Jt=odd generates NLO events. Jt=even generates Born events.*/
+ bigwgt=0;
+ if (random(seed) < cst[0]/cstt) {
+ if (random(seed) < fabs(p1[0])/cst[0]) {
+ Jt = 1;
+ bigwgt=bigwt[0];}
+ else { Jt = 2;} }
+ else if (random(seed) < cst[1]/(cstt-cst[0])) {
+ if (random(seed) < fabs(p1[1])/cst[1]) {
+ Jt = 3;
+ bigwgt=bigwt[1];}
+ else {Jt = 4;} }
+ else if (random(seed) < cst[2]/(cst[3]+cst[2])) {
+ if (random(seed) < fabs(p1[2])/cst[2]) {
+ Jt = 5;
+ bigwgt=bigwt[2];}
+ else {Jt = 6;} }
+ else if (random(seed) < fabs(p1[3])/cst[3]) {
+ Jt = 7;
+ bigwgt=bigwt[3];}
+ else {Jt = 8;}
+
+ wgt=0.;
+
+
+ if (Jt==1||Jt==3||Jt==5||Jt==7) {
+
+ /* Hereafter wgt=integrand*/
+
+
+/* random numbers for event generation */
+
+ double r1=random(seed);
+ double r2=random(seed);
+ double r3=random(seed);
+ double r4=random(seed);
+ double r5=random(seed);
+ double r6=random(seed);
+ x = r1;
+ y = 2.*r2 - 1.;
+ if (Jt==1) {
+ wgt=DYBC(x,y,r3,r4);}
+ if (Jt==3) {
+ wgt=DYD(x,y,r3,r4);}
+ if (Jt==5) {
+ wgt=DYGBC(x,y,r3,r4);}
+ if (Jt==7) {
+ wgt=DYGD(x,y,r3,r4);}
+
+ /* Mandelstam variables s,t,u and scale for NLO emission*/
+ double as,scale;
+ s = pow(Q,2)/x;
+ t = -s*(1.-x)*(1.-y)/2.;
+ u = -s*(1.-x)*(1.+y)/2.;
+ scale = sqrt(u*t/s+pow(Q,2));
+ // if (scale < sqrt(pdf.getQ2min(0))) {scale = sqrt(pdf.getQ2min(0));} // pdfs undefined for scale < Q2min.
+ if (scale < sqrt(getQ2min(0))) {scale = sqrt(getQ2min(0));}
+ /*NLO momentum fractions x1,x2 */
+ x1 = xq*sqrt((2.-(1.-x)*(1.-y))/((2.-(1.-x)*(1.+y))*x));
+ x2 = xqb*sqrt((2.-(1.-x)*(1.+y))/((2.-(1.-x)*(1.-y))*x));
+ r1=random(seed);
+ r2=random(seed);
+ r3=random(seed);
+ r4=random(seed);
+ r5=random(seed);
+ r6=random(seed);
+
+// Terms for calculating NLO pdf factors = combinations of sums of vv1..vv8.
+
+ double fg1,fg2,fn1[6],fnb1[6],fn2[6],fnb2[6],fs1[6],fsb1[6];
+ double fs2[6],fsb2[6],ffn1[6],ffn2[6],fgn1[6],fgn2[6],fgnb1[6];
+ double fgnb2[6],ffs1[6],ffs2[6];
+ double v1[6],v2[6],v3[6],v4[6],v5[6],v6[6],v7[6],v8[6];
+ double fqq[26],fq[26],fw[26];
+
+ /* Calculate pdf factors for NLO emission.
+ jqq,jg, jq are the ratios of the NLO pdf factors
+ to the Born level pdf factors.
+ jqq=[q(x1,scale)*q(x2,scale)+x1<->x2]/[q(x1,Q)*q(x2,Q)].
+ jg=[g(x1,scale)*q(x2,scale)+x1<->x2]/[q(x1,Q)*q(x2,Q)].
+ jq=[q(x1,Q)*q(x2,Q)+x1<->x2]/[q(x1,Q)*q(x2,Q)] */
+ // initialize sums.
+
+ double vv1=0;double vv2=0;double vv3=0;double vv4=0;
+ double vv5=0;double vv6=0;double vv7=0;double vv8=0;
+ double jqq=0;double jq=0;double jg=0;
+ if(proc==23) {
+ for (int ix=1; ix<6; ix++) {
+ int f = ix ;
+ fg1 = xfx(x1,scale,0);
+ fg2 = xfx(x2,scale,0);
+
+ fq1[ix] = xfx(xq,Q,f);
+ fqb2[ix] = xfx(xqb,Q,sgn*f);
+
+ fs1[ix] = xfx(xq,scale,f);
+ fsb2[ix] = xfx(xqb,scale,sgn*f);
+ fn1[ix] = xfx(x1,scale,f);
+ fnb2[ix] = xfx(x2,scale,sgn*f);
+ f = -ix;
+
+ fqb1[ix] = xfx(xq,Q,f);
+ fq2[ix] = xfx(xqb,Q,sgn*f);
+
+ fsb1[ix] = xfx(xq,scale,f);
+ fs2[ix] = xfx(xqb,scale,sgn*f);
+ fnb1[ix] = xfx(x1,scale,f);
+ fn2[ix] = xfx(x2,scale,sgn*f);
+ ffq1[ix] = fq1[ix]*fqb2[ix];
+ ffq2[ix] = fqb1[ix]*fq2[ix];
+ ffn1[ix] = fn1[ix]*fnb2[ix];
+ ffn2[ix] = fnb1[ix]*fn2[ix];
+ ffs1[ix] = fs1[ix]*fsb2[ix];
+ ffs2[ix] = fsb1[ix]*fs2[ix];
+ fgn1[ix] = fg2*fn1[ix];
+ fgn2[ix] = fg1*fn2[ix];
+ fgnb1[ix] = fg2*fnb1[ix];
+ fgnb2[ix] = fg1*fnb2[ix];
+ v1[ix] = ffn1[ix]/ffq1[ix];
+ v2[ix] = ffn2[ix]/ffq2[ix];
+ v3[ix] = fgn1[ix]/ffq1[ix];
+ v4[ix] = fgn2[ix]/ffq2[ix];
+ v5[ix] = fgnb1[ix]/ffq2[ix];
+ v6[ix] = fgnb2[ix]/ffq1[ix];
+ v7[ix] = ffs1[ix]/ffq1[ix];
+ v8[ix] = ffs2[ix]/ffq2[ix];
+ if (ffq1[ix] == 0) {
+ v1[ix] = 0;
+ v3[ix] = 0;
+ v6[ix] = 0;
+ v7[ix] = 0;}
+ if (ffq2[ix] == 0) {
+ v2[ix] = 0;
+ v4[ix] = 0;
+ v5[ix] = 0;
+ v8[ix] = 0;}
+ vv1 += v1[ix];
+ vv2 += v2[ix];
+ vv3 += v3[ix];
+ vv4 += v4[ix];
+ vv5 += v5[ix];
+ vv6 += v6[ix];
+ vv7 += v7[ix];
+ vv8 += v8[ix];
+ }
+ double Bfq = 0.;
+ jqq=0.;jq=0.; jg=0.;
+ for (int ix=1 ; ix < 6 ; ix++) {
+ Bfq += ffq1[ix]+ffq2[ix];
+ jqq += ffn1[ix]+ffn2[ix];
+ jq += ffs1[ix]+ffs2[ix];
+ jg += fgn1[ix]+fgn2[ix]+fgnb1[ix]+fgnb2[ix];
+ }
+ jq = jq/Bfq;
+ jqq = jqq/Bfq;
+ jg = jg/Bfq;
+
+ }
+
+else if (proc==24) {
+ int ix, iy;
+
+ for (ix=1; ix<5; ix++) {
+ fw[ix]=xfx(x1,scale,ix)*xfx(x2,scale,sgn*(ix+1));
+ fq[ix]=xfx(xq,Q,ix)*xfx(xqb,Q,sgn*(ix+1));
+ fqq[ix]=xfx(xq,scale,ix)*xfx(xqb,scale,sgn*(ix+1));
+
+}
+ int f=1;
+ for (ix=5; ix<9; ix++) {
+ fw[ix]=xfx(x1,scale,-f)*xfx(x2,scale,-sgn*(f+1));
+ fq[ix]=xfx(xq,Q,-f)*xfx(xqb,Q,-sgn*(f+1));
+ fqq[ix]=xfx(xq,scale,-f)*xfx(xqb,scale,-sgn*(f+1));
+
+ f+=1;}
+ f=1;
+ for (ix=9; ix<13; ix++) {
+ fw[ix]=xfx(x2,scale,sgn*f)*xfx(x1,scale,(f+1));
+ fq[ix]=xfx(xqb,Q,sgn*f)*xfx(xq,Q,(f+1));
+ fqq[ix]=xfx(xqb,scale,sgn*f)*xfx(xq,scale,(f+1));
+
+ f+=1;}
+ f=1;
+ for (ix=13; ix<17; ix++) {
+ fw[ix]=xfx(x2,scale,-sgn*f)*xfx(x1,scale,-(f+1));
+ fq[ix]=xfx(xqb,Q,-sgn*f)*xfx(xq,Q,-(f+1));
+ fqq[ix]=xfx(xqb,scale,-sgn*f)*xfx(xq,scale,-(f+1));
+
+ f+=1;}
+
+ f=1;
+ for(ix=17;ix<19;ix++) {
+ fw[ix]=xfx(x1,scale,f)*xfx(x2,scale,sgn*(f+3));
+ fq[ix]=xfx(xq,Q,f)*xfx(xqb,Q,sgn*(f+3));
+ fqq[ix]=xfx(xq,scale,f)*xfx(xqb,scale,sgn*(f+3));
+
+ f+=1;}
+
+ f=1;
+ for(ix=19;ix<21;ix++) {
+ fw[ix]=xfx(x1,scale,-f)*xfx(x2,scale,-sgn*(f+3));
+ fq[ix]=xfx(xq,Q,-f)*xfx(xqb,Q,-sgn*(f+3));
+ fqq[ix]=xfx(xq,scale,-f)*xfx(xqb,scale,-sgn*(f+3));
+
+ f+=1;}
+
+ f=1;
+ for(ix=21;ix<23;ix++) {
+ fw[ix]=xfx(x2,scale,sgn*f)*xfx(x1,scale,(f+3));
+ fq[ix]=xfx(xqb,Q,sgn*f)*xfx(xq,Q,(f+3));
+ fqq[ix]=xfx(xqb,scale,sgn*f)*xfx(xq,scale,(f+3));
+
+ f+=1;}
+
+ f=1;
+ for(ix=23;ix<25;ix++) {
+ fw[ix]=xfx(x2,scale,-sgn*f)*xfx(x1,scale,-(f+3));
+ fq[ix]=xfx(xqb,Q,-sgn*f)*xfx(xq,Q,-(f+3));
+ fqq[ix]=xfx(xqb,scale,-sgn*f)*xfx(xq,scale,-(f+3));
+
+ f+=1;}
+
+ double Vud=0.952;
+ double Vus=0.049;
+ double Vub=0.00001063;
+ double Vcd=0.049;
+ double Vcs=0.952;
+ double Vcb=0.00168;
+ jg = 0.; jq = 0.,jqq=0.;
+ double CKM[6],CKM2[25];
+ CKM[1]=Vud+Vcd;
+ CKM[2]=Vud+Vus+Vub;
+ CKM[3]=Vus+Vcs;
+ CKM[4]=Vcb+Vcs+Vcd;
+ CKM[5]=Vub+Vcb;
+ for (iy=1; iy< 6 ; iy++){
+ jg += CKM[iy]*(xfx(x2,scale,0)*xfx(x1,scale,iy)+xfx(x2,scale,0)*xfx(x1,scale,-iy)+xfx(x1,scale,0)*xfx(x2,scale,sgn*iy)+xfx(x1,scale,0)*xfx(x2,scale,-sgn*iy));
+ }
+ // cout << "jg1" << jg << endl;
+ CKM2[1]=Vud;CKM2[2]=Vus;CKM2[3]=Vcs;CKM2[4]=Vcb;CKM2[5]=Vud;CKM2[6]=Vus;CKM2[7]=Vcs;CKM2[8]=Vcb;CKM2[9]=Vud;CKM2[10]=Vus;CKM2[11]=Vcs;CKM2[12]=Vcb;CKM2[13]=Vud;CKM2[14]=Vus;CKM2[15]=Vcs;CKM2[16]=Vcb;
+ CKM2[17]=Vcd;CKM2[18]=Vub;CKM2[19]=Vcd;CKM2[20]=Vub;CKM2[21]=Vcd;CKM2[22]=Vub;CKM2[23]=Vcd;CKM2[24]=Vub;
+ for (iy=1;iy <25 ; iy++){
+ jq += CKM2[iy]*fqq[iy];
+ }
+ for (iy=1;iy <25 ; iy++){
+ jqq += CKM2[iy]*fw[iy];
+ }
+ double Bfq=0.;
+ for (int iyy=1; iyy < 25; iyy++) {
+ Bfq += CKM2[iyy]*fq[iyy];
+ }
+ jq = jq/Bfq; jqq=jqq/Bfq;jg = jg/Bfq;
+
+
+
+}
+
+
+ /*Select whether quark-gluon (Jtt=1) or gluon-quark
+ (Jtt=2) according to pdf factor. */
+
+ if (Jt==5||Jt==7){
+
+ double qg1 = xfx(x1,scale,ID[0]);
+ double qg2 = xfx(x2,scale,0);
+ double gq1 = xfx(x2,scale,-sgn*ID[1]);
+ double gq2 = xfx(x1,scale,0);
+ double jqg,jqbg;
+
+ jqg=qg1*qg2;
+ jqbg=gq1*gq2;
+ Jtt=2;
+ if (random(seed) < jqg/(jqg+jqbg)) {Jtt = 1;}
+
+ }
+
+
+ // as = pdf.alphasPDF(scale); // NLO alphas evaluated at Q=scale
+ as = alphasPDF(scale);
+ // Multiply integrands by colour factors
+
+ jq = jq*as*CF/(2.*pi);
+ jg = jg*as*TF/(2.*pi);
+ if (Jt==1||Jt==3) {
+ wgt=wgt*jqq;}
+
+ if (Jt==5||Jt==7) {
+ wgt=wgt*jg;}
+ //POWHEG stuff
+ /***************************************************************/
+ double wgt1, wgt2, wgt3, wgt4, wgt5;
+ wgt3 = jq;
+ jqq = jqq*as*CF/(2.*pi);
+ jq = jq*as*CF/(2.*pi);
+ jg = jg*as*TF/(2.*pi);
+ if (scheme=="DIS") {
+ wgt1 = -6.-4.*x;
+ wgt2 = -5.*x+4.5*pow(x,2)+1.5+(pow(x,2)+pow((1.-x),2))*log((1.-x)*pow(Q/scale,2));
+ wgt4 = 1.+4.*pow(pi,2)/3.+3.*log(pow(Q/scale,2));
+ wgt5 = (3.+2.*(1.+pow(x,2))*log(pow(Q/scale,2)))*(x*jqq-jq)/(1.-x)+2.*(1.+pow(x,2))*log(1.-x)/(1.-x)*jqq*x-4.*log(1.-x)/(1.-x)*jq;
+} else if (scheme=="MSbar") {
+ wgt1 = -2.*(1.+pow(x,2))/(1.-x)*log(x);
+ wgt2 = 0.5+3.*x-3.5*pow(x,2)+(pow(x,2)+pow(1.-x,2))*log(pow(1.-x,2)/x*pow(Q/scale,2));
+ wgt4 = -8.+2.*pow(pi,2)/3.+3.*log(pow(Q/scale,2));
+ wgt5 = (2.*(1.+pow(x,2))*log(pow(Q/scale,2)))*(x*jqq-jq)/(1.-x)+4.*(1+pow(x,2))*log(1.-x)/(1.-x)*jqq*x-8.*log(1.-x)/(1.-x)*jq;}
+ /* Calculate integrals p1,p2 and calculte maximum weights bigwt in
+ phase space regions */
+
+ for (int iz=0; iz<2; iz++) {
+ w1[iz] = w1[iz]*jqq;
+
+ if (w1[iz] != 0.) {
+ w2[iz] = wgt3-w1[iz]+(wgt1*jqq*x+wgt4*jq)
+ +wgt5;} else {
+ w2[iz] = 0.;}
+ }
+
+ // if (jg > jgmax) {jgmax = jg; cout << jgmax << endl;}
+ for (int ia=2; ia<4; ia++) {
+ w1[ia] = w1[ia]*jg;
+ if (w1[ia] != 0.) {
+ w2[ia] = -w1[ia]+wgt2*jg*x;} else {
+ w2[ia] = 0.;}
+ }
+ for (int ibb=0; ibb < 4; ibb++) {
+ rmwgt += w1[ibb]+w2[ibb];
+
+ }
+ if (rmwgt < 0.) {rmwgt = 0.;}
+
+ if (!MCNLO) {wgt = rmwgt; bigwgt = bigrmwgt;}
+
+
+
+ /***************************************************************/
+
+ /* UNWEIGHTING. For Jt=1,3,5,7: generate event according to
+ integrand by comparing generated integrand to maximum value.
+ If it fails veto, go back and generate new event else proceed...*/
+
+ } else {wgt = 1.; bigwgt=1.;}} while (random(seed) > fabs(wgt)/fabs(bigwgt));
+ //POWHEG stuff
+ if (!MCNLO) {Jt = 3;}
+
+ // Assign weights for unweighted events
+
+ if (Jt==1||Jt==5) {wgt=-1.;}
+ if (Jt==3||Jt==7) {wgt=1.;}
+
+ if (Jt==2) {if (random(seed) < fabs(p2[0])/(cst[0]-fabs(p1[0]))) {wgt=1.;} else {wgt=-1.;}}
+ if (Jt==4) {if (random(seed) < fabs(p2[1])/(cst[1]-fabs(p1[1]))) {wgt=1.;} else {wgt=-1.;}}
+ if (Jt==6) {if (random(seed) < fabs(p2[2])/(cst[2]-fabs(p1[2]))) {wgt=1.;} else {wgt=-1.;}}
+ if (Jt==8) {if (random(seed) < fabs(p2[3])/(cst[3]-fabs(p1[3]))) {wgt=1.;} else {wgt=-1.;}}
+ double z0, z1, pt1, xp, yp, qs, xp1, xp2;
+ double xx, yy, ww, M, MT, V, Vp;
+ int pro;
+ pt1=0.; qs=0.; xp1=0.;xp2=0.;pro=0;
+ //POWHEG stuff
+ if (!MCNLO) {
+ double ll,csfac,bb,bp,Nq,eps,Q2,r,ptm,qq,p2m,n,pt2,pt;
+ int Its, MaxIts, converged,pro, veto;
+ ll=0.2; csfac=2.*1./(3.*pi);eps=1.0e-6;Nq=40./(2.*pi);bb=23./(12.*pi);bp=58./(46.*pi); Q2 = pow (Q,2);r =Q2/S2;
+ ptm = pow(1.-r, 2)*S2/4.;
+ qq = ptm+Q2;
+ pt2 = 0.;
+ do {
+ if (pt2 < pow(ll,2)+0.001) {p2m = ptm;} else {p2m = pt2;}
+ n = random(seed);
+ pt2 = pow(ll,2)+0.001;
+ converged = 0; Its=0; MaxIts=1000000;
+
+ do {
+ pt2 = pt2 - (G(pt2,Nq,bb,qq,ptm,ll) - G(p2m,Nq,bb,qq,ptm,ll)+log(n))/DG(pt2,Nq,bb,qq,ptm,ll);
+ Its=Its+1;
+ if (fabs(G(pt2,Nq,bb,qq,ptm,ll)-G(p2m,Nq,bb,qq,ptm,ll)+log(n)) < eps) {converged=1;}
+ } while (converged ==0 );
+
+ kt = sqrt(pt2);
+ double xp=pow((sqrt(1.+pt2/Q2)+kt/Q),2);
+ double xm=pow((sqrt(1.+pt2/Q2)-kt/Q),2);
+ double alphas=alphasPDF(kt) + pow(alphasPDF(kt),2)*(67./3.-pow(pi,2)-50./9.)/(4.*pi);
+ V=Nq*alphas*log((sqrt(xp-r)+sqrt(xm-r))/(sqrt(xp-r)-sqrt(xm-r)));
+ Vp = Nq/(2.*bb)*(log(qq/pt2))/log(pt2/pow(ll,2));
+ if (random(seed) < V/Vp && pt2 > pow(ll,2)+0.001) {
+ veto = 0;
+ double Mmax=0.;
+ for (int ix=0; ix < 1000 ; ix++) {
+ yy = 2.*random(seed)-1.;
+ xx = (-Q2-2.*pt2+pow(yy,2)*Q2+2.*sqrt(Q2*pt2+pow(pt2,2)-pt2*pow(yy,2)*Q2))/(Q2*(pow(yy,2)-1.));
+ ww = -pt2/xx-2.*pt2;
+ M = Nq*2.*pi/((1.-xx)*(1.-pow(yy,2))*ww);
+ if (fabs(M) > fabs(Mmax)) {Mmax=M;}
+ }
+ do {
+ yy = 2.*random(seed)-1.;
+ xx = (-Q2-2.*pt2+pow(yy,2)*Q2+2.*sqrt(Q2*pt2+pow(pt2,2)-pt2*pow(yy,2)*Q2))/(Q2*(pow(yy,2)-1.));
+ ww = -pt2/xx-2.*pt2;
+ M = Nq*2.*pi/((1.-xx)*(1.-pow(yy,2))*ww);} while (random(seed) > fabs(M/Mmax));
+
+ x1=xq*sqrt((2.-(1.-xx)*(1.-yy))/((2.-(1.-xx)*(1.+yy))*xx));
+ x2=xqb*sqrt((2.-(1.-xx)*(1.+yy))/((2.-(1.-xx)*(1.-yy))*xx));
+ if (x1 > 1.|| x2 > 1.) {yy=-yy;}
+ x1=xq*sqrt((2.-(1.-xx)*(1.-yy))/((2.-(1.-xx)*(1.+yy))*xx));
+ x2=xqb*sqrt((2.-(1.-xx)*(1.+yy))/((2.-(1.-xx)*(1.-yy))*xx));
+ if (x1 < 1. && x2 <1.){
+ pt = kt;
+ if (pt < sqrt(getQ2min(0))) {pt = sqrt(getQ2min(0));}
+ double rjqq = xfx(x1,pt,ID[0])*xfx(x2,pt,-sgn*ID[1])/(xfx(xq,Q,ID[0])*xfx(xqb,Q,-sgn*ID[1]));
+ double rjqg = xfx(x1,pt,ID[0])*xfx(x2,pt,0)/(xfx(xq,Q,ID[0])*xfx(xqb,Q,-sgn*ID[1]));
+ double rjqbg = xfx(x1,pt,0)*xfx(x2,pt,-sgn*ID[1])/(xfx(xq,Q,ID[0])*xfx(xqb,Q,-sgn*ID[1]));
+ double Mqq=(4./3.*(pow(yy*(1.-xx),2)+pow(1.+xx,2))/((1.-xx)*(1.-pow(yy,2))))*rjqq;
+ double Mqg=(((3.+pow(yy,2))*pow(1.-xx,2)-2.*yy*(1.-pow(xx,2))+2.*(1.+pow(xx,2)))/(8.*(1.-yy)))*rjqg;
+ double Mqbg=(((3.+pow(yy,2))*pow(1.-xx,2)+2.*yy*(1.-pow(xx,2))+2.*(1.+pow(xx,2)))/(8.*(1.+yy)))*rjqbg;
+ MT = fabs(Mqq)+fabs(Mqg)+fabs(Mqbg);
+ double MTT;
+ if (random(seed) < fabs(Mqq)/fabs(MT)) {pro=1; MTT = Mqq;}else
+ if (random(seed) < fabs(Mqg)/(fabs(Mqg)+fabs(Mqbg))) {pro=2; MTT = Mqg;} else {pro=3; MTT = Mqbg;};
+} else {MT =0.; ww = 1.;}
+
+} else {veto = 1;} }while (veto == 1 || x1 > 1. || x2 > 1. || random(seed) > fabs(MT/ww)/fabs(M));
+
+
+ bool vetoed = false;
+
+ if (truncsh) {
+ double mu = 0.;
+ double alpham = 1.;
+ double Qg = 0.75;
+ double qc = 0.631;
+ z0=1.-0.5*(1.-xx)*(1.+yy);
+ if (yy < 0.) {z0=1.-0.5*(1.-xx)*(1.-yy);}
+ int Jt = 1;
+ if (random(seed) < pow(xq,2)/(pow(xq,2)+pow(xqb,2))) {Jt = 2;}
+ kt = sqrt(pt2);
+ s = pow(Q,2)/xx;
+ t = -s*(1.-xx)*(1.-yy)/2.;
+ u = -s*(1.-xx)*(1.+yy)/2.;
+ double Pz, Pzm, P, g, pt12, pdfr, alphatr, qi;
+ P=0.;g=0.;pt12=0.;alphatr=0.;pdfr=0.;
+ do {
+ emit = false;
+ qi = Q;
+ if (vetoed == true) {qi = qs;}
+ do {
+ z1 = random(seed)*((2.*pow(qi,2)+pow(Qg,2)-Qg*sqrt(4.*pow(qi,2)+pow(Qg,2)))/(2.*pow(qi,2))-Qg/qi)+Qg/qi;
+ Pz = (1.+pow(z1,2))/(z1*(1.-z1));
+ Pzm = (1.+pow(((2.*pow(qi,2)+pow(Qg,2)-Qg*sqrt(4.*pow(qi,2)+pow(Qg,2)))/(2.*pow(qi,2))),2))/((2.*pow(qi,2)+pow(Qg,2)-Qg*sqrt(4.*pow(qi,2)+pow(Qg,2)))/(2.*pow(qi,2))*(1.-(2.*pow(qi,2)+pow(Qg,2)-Qg*sqrt(4.*pow(qi,2)+pow(Qg,2)))/(2.*pow(qi,2))));
+ } while (random(seed) > Pz/Pzm);
+ double qh = sqrt((pt2+z0*pow(Qg,2))/pow(1.-z0,2));
+ double C=CF*alpham*log(1.-(2.*pow(qi,2)+pow(Qg,2)-Qg*sqrt(4.*pow(qi,2)+pow(Qg,2)))/(2.*pow(qi,2)))/pi;
+ double D=exp(log(pow(qh/qc,2))*C);
+ double E=exp(log(pow(qi/qc,2))*C);
+ qs = 0.;
+ if (random(seed) < 1. -E/D) {
+ do {qs = sqrt(exp(log(E/random(seed))/C)*pow(qc,2));} while (qs < qh);
+ if(qs < qi) {
+ emit = true;}
+ }
+ if (emit) {
+ P=CF*((1.+pow(z1,2))/(1.-z1)-2.*pow(mu,2)/(z1*(1.-z1)*pow(qs,2)));
+ g=2.*CF/(1.-z1);
+ pt12=(pow((1.-z1)*qs,2)-z1*pow(Qg,2));
+
+ if (pt12 > 0.) {
+ pt1= sqrt(pt12);
+ double kap=pt12/pow(qi*(1.-z1),2);
+ xp=z1/(1.+(1.-z1)*kap);
+ yp=1.-2.*(1.-z1)/(1.-xp);
+ if (yy < 0.) {yp=-1.+2.*(1.-z1)/(1.-xp);}
+ xp1=xq*sqrt((2.-(1.-xp)*(1.-yp))/((2.-(1.-xp)*(1.+yp))*xp));
+ xp2=xqb*sqrt((2.-(1.-xp)*(1.+yp))/((2.-(1.-xp)*(1.-yp))*xp));
+ pdfr = xp1*xp2*xfx(xp1,qs,ID[0])*xfx(xp2,qs,ID[1])/(xq*xqb*xfx(xq,qi,ID[0])*xfx(xqb,qi,ID[1]));
+ alphatr = alphasPDF(z1*(1-z1)*qs) + pow(alphasPDF(z1*(1-z1)*qs),2)*(67./3.-pow(pi,2)-50./9.)/(4.*pi);
+ }
+ }
+ if (emit == true && (pt12 > pt2 || pt12 < 0 || random(seed) > pdfr || random(seed) > P/g || random(seed) > alphatr/alpham)){vetoed = true;} else {vetoed = false;}
+ } while (vetoed == true && qs < qi); }}
+
+ /**********************************************************************/
+
+
+ /*Les Houches Accord event parameters:: PUP are the momenta,
+ ICOLUP is the colour code, MOTHUP is the mother information, ISTUP is
+ the status code. ISPINUP signifies spins. IDUP is the particle ID.
+ NUP is the number of particles in the event. SCALUP is the scale of
+ the event.AQEDUP and AQCDUP are alphaem and alphas resp.XWGTUP is
+ the weight of the event=1 or -1 for unweighted events.*/
+
+ double PUP[5][9],AQEDUP,AQCDUP,XWGTUP,SCALUP,mass[8];
+ int ICOLUP[3][7],MOTHUP[3][7],ISTUP[7],ISPINUP[7],IDUP[7],NUP;
+
+ XWGTUP = wgt;
+ //Default parameters
+
+ PUP[1][1]=0.;PUP[2][1]=0.;PUP[1][2]=0.;PUP[2][2]=0.;
+ MOTHUP[1][1]=0;
+ MOTHUP[2][1]=0;
+ MOTHUP[1][2]=0;
+ MOTHUP[2][2]=0;
+ MOTHUP[1][3]=1;
+ MOTHUP[2][3]=2;
+ ICOLUP[1][3]=0;
+ ICOLUP[2][3]=0;
+ ISTUP[1]=-1;
+ ISTUP[2]=-1;
+ ISTUP[3]=2;
+ mass[1]=0.;mass[2]=0.;mass[4]=0.;mass[5]=0.,mass[6]=0.; mass[7]=0.;
+ AQEDUP=0.007297352;
+ AQCDUP=0.118;
+
+ if (Jt==1||Jt==3||Jt==5||Jt==7) {
+
+ //transverse mmt of emission
+ if (MCNLO) {
+ kt = sqrt(pow(Q,2)*(1.-pow(y,2))*pow((1.-x),2)/(4.*x));}
+ if (emit) {
+ x1=xp1*sqrt((2.-(1.-xx)*(1.-yy))/((2.-(1.-xx)*(1.+yy))*xx));
+ x2=xp2*sqrt((2.-(1.-xx)*(1.+yy))/((2.-(1.-xx)*(1.-yy))*xx));}
+ if (!MCNLO) {
+ s=x1*x2*S2;
+ t=-s/2.*(1.-xx)*(1.+yy);
+ u=-s/2.*(1.-xx)*(1.-yy);
+}
+
+
+ double xge = -(t/(x1*S2)+u/(x2*S2));
+ double xgz = t/(x1*S2)-u/(x2*S2);
+ double xze = x1+x2-xge;
+ double xzz = x1-x2-xgz;
+ if (emit) {kt = sqrt(pow(xge,2)-pow(xgz,2))*emcm/2.;}
+ SCALUP = kt;
+ //4-MOMENTA
+
+ PUP[3][1]=x1*emcm/2.;
+ PUP[4][1]=PUP[3][1];
+ PUP[3][2]=-x2*emcm/2.;
+ PUP[4][2]=-PUP[3][2];
+ double phi=2.*pi*random(seed); //uniform azimuth
+ PUP[1][3]=kt*cos(phi);
+ PUP[2][3]=kt*sin(phi);
+ PUP[4][3]=xze*emcm/2.;
+ PUP[3][3]=xzz*emcm/2.;
+ PUP[1][4]=-PUP[1][3];
+ PUP[2][4]=-PUP[2][3];
+ PUP[4][4]=xge*emcm/2.;
+ PUP[3][4]=xgz*emcm/2.;
+ if (emit) {
+ double ZZ=sqrt(pow(PUP[1][3],2)+pow(PUP[2][3],2)+pow(PUP[3][3],2));
+ double cost=PUP[3][3]/sqrt(pow(PUP[1][3],2)+pow(PUP[2][3],2)+pow(PUP[3][3],2));
+ double sint=kt/sqrt(pow(PUP[1][3],2)+pow(PUP[2][3],2)+pow(PUP[3][3],2));
+ PUP[1][3]=pt1*cos(phi);
+ PUP[2][3]=pt1*sin(phi);
+ PUP[1][7]=-pt1*cos(phi);
+ PUP[2][7]=-pt1*sin(phi);
+ PUP[3][3]=(pow(Q,2)*ZZ+ZZ*pow(PUP[4][3],2)-pow(ZZ,3)+sqrt(2.*pow(Q*ZZ*PUP[4][3],2)-2.*pow(ZZ,2)*pow(PUP[4][3],4)+pow(ZZ,4)*pow(PUP[4][3],2)-4.*pow(PUP[4][3],4)*pow(pt1,2)+pow(PUP[4][3],2)*pow(Q,4)-2.*pow(PUP[4][3],4)*pow(Q,2)+pow(PUP[4][3],6)+4.*pow(ZZ*pt1*PUP[4][3],2)))/(2.*(pow(PUP[4][3],2)-pow(ZZ,2)));
+ if ( random(seed) < 0.5){
+ PUP[3][3]=(pow(Q,2)*ZZ+ZZ*pow(PUP[4][3],2)-pow(ZZ,3)-sqrt(2.*pow(Q*ZZ*PUP[4][3],2)-2.*pow(ZZ,2)*pow(PUP[4][3],4)+pow(ZZ,4)*pow(PUP[4][3],2)-4.*pow(PUP[4][3],4)*pow(pt1,2)+pow(PUP[4][3],2)*pow(Q,4)-2.*pow(PUP[4][3],4)*pow(Q,2)+pow(PUP[4][3],6)+4.*pow(ZZ*pt1*PUP[4][3],2)))/(2.*(pow(PUP[4][3],2)-pow(ZZ,2)));}
+ PUP[3][7]=ZZ-PUP[3][3];
+ PUP[1][3]=(pt1*cost+PUP[3][3]*sint)*cos(phi);
+ PUP[2][3]=(pt1*cost+PUP[3][3]*sint)*sin(phi);
+ PUP[3][3]=-pt1*sint+PUP[3][3]*cost;
+ PUP[4][3]=sqrt(pow(PUP[1][3],2)+pow(PUP[2][3],2)+pow(PUP[3][3],2)+pow(Q,2));
+ PUP[1][7]=(-pt1*cost+PUP[3][7]*sint)*cos(phi);
+ PUP[2][7]=(-pt1*cost+PUP[3][7]*sint)*sin(phi);
+ PUP[3][7]=pt1*sint+PUP[3][7]*cost;
+ PUP[4][7]=sqrt(pow(PUP[1][7],2)+pow(PUP[2][7],2)+pow(PUP[3][7],2));}
+
+ double cth, cofac, maxcofac;
+ if (proc==23) {do
+ {cth=2.*random(seed)-1.;
+ double GF = 0.0000116639;
+ double alphaem = 0.007297352;
+ double e2 = 4.*pi*alphaem;
+ double k = sqrt(2.)*GF*pow(mp,2)/e2;
+ double sin2thw = 0.2312;
+ double chi1 = k*pow(Q,2)*(pow(Q,2)-pow(mp,2))/(pow((pow(emcm,2)-pow(mp,2)),2)+pow(Yzz*mp,2));
+ double chi2 = pow(k,2)*pow(Q,4)/(pow((pow(Q,2)-pow(mp,2)),2)+pow(Yzz*mp,2));
+ double Aq,Vq,Ae,Ve,Qq;
+ Ae = -0.5;
+ Ve = Ae+2.*sin2thw;
+ if (fabs(ID1)==1||fabs(ID1)==3||fabs(ID1)==5) {Qq=-1./3.; Aq=-0.5; Vq=Aq-(2.*Qq*sin2thw);}
+ if (fabs(ID1==2)||fabs(ID1)==4) {Qq=2./3.; Aq=0.5; Vq=Aq-(2.*Qq*sin2thw);}
+ cofac = (1.+pow(cth,2))*(1.+2.*Vq*Ve*chi1+(pow(Aq,2)+pow(Vq,2))*(pow(Ae,2)+pow(Ve,2))*chi2)+cth*(4.*Qq*Aq*Ae*chi1+8.*Aq*Vq*Ae*Ve*chi2);
+ maxcofac = 2.*(1.+2.*Vq*Ve*chi1+(pow(Aq,2)+pow(Vq,2))*(pow(Ae,2)+pow(Ve,2))*chi2)+(4.*Qq*Aq*Ae*chi1+8.*Aq*Vq*Ae*Ve*chi2);}while(random(seed) > cofac/maxcofac);}
+ if (proc==24) {do
+ {cth=2.*random(seed)-1.;
+ cofac=pow(1.+cth,2);
+ maxcofac=4.;} while(random(seed) > cofac/maxcofac);}
+ if (proc==24) {
+ if (ID[0]==-1||ID[0]==-3||ID[0]==-5 ||ID[0]==2||ID[0]==4){
+ cth=-cth;} }
+ // cout << "cth" << cth << endl;
+ double phi2=2.*pi*random(seed);
+ //Assign 4-momenta in boson rest frame
+ PUP[3][5]=Q*cth/2.;
+ PUP[1][5]=sqrt(pow(Q,2)/4.-pow(PUP[3][5],2))*cos(phi2);
+ PUP[2][5]=sqrt(pow(Q,2)/4.-pow(PUP[3][5],2))*sin(phi2);
+ PUP[4][5]=Q/2.;
+ PUP[1][6]=-sqrt(pow(Q,2)/4.-pow(PUP[3][5],2))*cos(phi2);
+ PUP[2][6]=-sqrt(pow(Q,2)/4.-pow(PUP[3][5],2))*sin(phi2);
+ PUP[3][6]=-PUP[3][5];
+ PUP[4][6]=Q/2.;
+
+ mass[3]=Q;
+ // Boost to Lab frame
+ double v=sqrt(pow(PUP[4][3],2)-pow(Q,2))/PUP[4][3];
+ PUP[4][5]=(Q/2.-v*PUP[3][5])/sqrt(1.-pow(v,2));
+ PUP[3][5]=(PUP[3][5]-Q*v/2.)/sqrt(1.-pow(v,2));
+ PUP[4][6]=(Q/2.-v*PUP[3][6])/sqrt(1.-pow(v,2));
+ PUP[3][6]=(PUP[3][6]-Q*v/2.)/sqrt(1.-pow(v,2));
+ double ktt1=-sqrt(pow(PUP[4][5],2)-pow(PUP[3][5],2));
+ double ktt2=sqrt(pow(PUP[4][6],2)-pow(PUP[3][6],2));
+ if (emit) {kt = sqrt(pow(PUP[1][3],2)+pow(PUP[2][3],2));}
+ double tht=atan2(kt,PUP[3][3]);
+ double pe1=PUP[4][5];
+ double pe2=PUP[4][6];
+ double pz1=PUP[3][5];
+ double pz2=PUP[3][6];
+ PUP[4][5]=pe2;
+ PUP[4][6]=pe1;
+ PUP[3][5]=-(pz2*cos(tht)+ktt2*sin(tht));
+ PUP[3][6]=-(pz1*cos(tht)+ktt1*sin(tht));
+ PUP[1][5]=-(pz2*sin(tht)-ktt2*cos(tht))*cos(phi);
+ PUP[2][5]=-(pz2*sin(tht)-ktt2*cos(tht))*sin(phi);
+ PUP[1][6]=-(pz1*sin(tht)-ktt1*cos(tht))*cos(phi);
+ PUP[2][6]=-(pz1*sin(tht)-ktt1*cos(tht))*sin(phi);
+
+ //selecting between 2 solutions
+ if (random(seed) < 0.5) {
+ PUP[4][5]=pe1;
+ PUP[4][6]=pe2;
+ PUP[3][5]=-(pz1*cos(tht)+ktt1*sin(tht));
+ PUP[3][6]=-(pz2*cos(tht)+ktt2*sin(tht));
+ PUP[1][5]=-(pz1*sin(tht)-ktt1*cos(tht))*cos(phi);
+ PUP[2][5]=-(pz1*sin(tht)-ktt1*cos(tht))*sin(phi);
+ PUP[1][6]=-(pz2*sin(tht)-ktt2*cos(tht))*cos(phi);
+ PUP[2][6]=-(pz2*sin(tht)-ktt2*cos(tht))*sin(phi);
+ }
+ if (!MCNLO){
+ if (pro == 2) {Jt = 5; Jtt = 1;}
+ if (pro == 3) {Jt = 5; Jtt = 2;}}
+ //Assign particle IDs
+ if (Jt==1||Jt==3) {
+ IDUP[1]=ID[0];
+ IDUP[2]=ID[1];
+ IDUP[4]=21;
+ if (emit) {IDUP[4] = 21; IDUP[7] = 21;}
+}
+ if (Jt==5||Jt==7) {
+ if (Jtt==1) {
+ IDUP[1]=ID[0];
+ IDUP[2]=21;
+ IDUP[4]=IDUP[1];
+ if (emit) {IDUP[4] = 21 ; IDUP[7] = IDUP[1];}
+}
+ else {
+ IDUP[1]=21;
+ IDUP[2]=ID[1];
+ IDUP[4]=IDUP[2];
+ if (emit) {IDUP[4] = 21 ; IDUP[7] = IDUP[2];}
+}}
+
+ if (proc==23) {
+ IDUP[3]=23;
+ IDUP[5]=11;
+ IDUP[6]=-11;
+ } else if (proc==24) {
+ if (ID[0]==1||ID[0]==3||ID[0]==5 ||ID[0]==-2||ID[0]==-4){
+ IDUP[3]=-24;
+ IDUP[5]=11;
+ IDUP[6]=-12;} else {
+ IDUP[3]=24;
+ IDUP[5]=-11;
+ IDUP[6]=12;}}
+
+ ISTUP[4]=1;
+ ISTUP[5]=1;
+ ISTUP[6]=1;
+ ICOLUP[1][5]=0;
+ ICOLUP[2][5]=0;
+ ICOLUP[1][6]=0;
+ ICOLUP[2][6]=0;
+ MOTHUP[1][5]=3;
+ MOTHUP[2][5]=3;
+ MOTHUP[1][6]=3;
+ MOTHUP[2][6]=3;
+ ISPINUP[1]=-1;
+ ISPINUP[2]=-1;
+ ISPINUP[4]=-1;
+ ISPINUP[3]=+1;
+ ISPINUP[5]=+1;
+ ISPINUP[6]=-1;
+ NUP=6;
+ if (emit) {NUP=7;
+ PUP[4][8] = PUP[4][4];
+ PUP[3][8] = PUP[3][4];
+ PUP[2][8] = PUP[2][4];
+ PUP[1][8] = PUP[1][4];
+ PUP[4][4] = PUP[4][7];
+ PUP[3][4] = PUP[3][7];
+ PUP[2][4] = PUP[2][7];
+ PUP[1][4] = PUP[1][7];
+ PUP[4][7] = PUP[4][8];
+ PUP[3][7] = PUP[3][8];
+ PUP[2][7] = PUP[2][8];
+ PUP[1][7] = PUP[1][8];
+ ISPINUP[7]=-1;
+ ISTUP[7]=1;}
+ // Assign mother information and colour using Kleiss trick.
+ if (Jt==5||Jt==7) {
+ if (IDUP[1]==21) {
+ MOTHUP[1][4]=1;
+ MOTHUP[2][4]=1;
+ if (emit) {
+ MOTHUP[1][7]=2;
+ MOTHUP[2][7]=2;
+ }
+ if (IDUP[2]> 0.) {
+ ICOLUP[1][2]=501;
+ ICOLUP[2][2]=0;
+ ICOLUP[1][1]=502;
+ ICOLUP[2][1]=501;
+ ICOLUP[1][4]=502;
+ ICOLUP[2][4]=0;
+ if (emit) {
+ ICOLUP[1][2]=503;
+ ICOLUP[2][2]=0;
+ ICOLUP[1][1]=502;
+ ICOLUP[2][1]=501;
+ ICOLUP[1][7]=502;
+ ICOLUP[2][7]=0;
+ ICOLUP[1][4]=503;
+ ICOLUP[2][4]=501;
+ }
+ } else {
+ ICOLUP[1][2]=0;
+ ICOLUP[2][2]=501;
+ ICOLUP[1][1]=501;
+ ICOLUP[2][1]=502;
+ ICOLUP[1][4]=0;
+ ICOLUP[2][4]=502;
+ if (emit) {
+ ICOLUP[1][2]=0;
+ ICOLUP[2][2]=503;
+ ICOLUP[1][1]=501;
+ ICOLUP[2][1]=502;
+ ICOLUP[1][7]=0;
+ ICOLUP[2][7]=502;
+ ICOLUP[1][4]=501;
+ ICOLUP[2][4]=503;
+ }
+ }
+ }
+ if (IDUP[2]==21) {
+ MOTHUP[1][4]=2;
+ MOTHUP[2][4]=2;
+ if (IDUP[1] > 0) {
+ ICOLUP[1][1]=501;
+ ICOLUP[2][1]=0;
+ ICOLUP[1][2]=502;
+ ICOLUP[2][2]=501;
+ ICOLUP[1][4]=502;
+ ICOLUP[2][4]=0;
+ if (emit) {
+ ICOLUP[1][1]=503;
+ ICOLUP[2][1]=0;
+ ICOLUP[1][2]=502;
+ ICOLUP[2][2]=501;
+ ICOLUP[1][7]=502;
+ ICOLUP[2][7]=0;
+ ICOLUP[1][4]=503;
+ ICOLUP[2][4]=501;
+ }
+}
+ else {
+ ICOLUP[1][1]=0;
+ ICOLUP[2][1]=501;
+ ICOLUP[1][2]=501;
+ ICOLUP[2][2]=502;
+ ICOLUP[1][4]=0;
+ ICOLUP[2][4]=502;
+ if (emit) {
+ ICOLUP[1][1]=0;
+ ICOLUP[2][1]=503;
+ ICOLUP[1][2]=501;
+ ICOLUP[2][2]=502;
+ ICOLUP[1][7]=0;
+ ICOLUP[2][7]=502;
+ ICOLUP[1][4]=501;
+ ICOLUP[2][4]=503;
+ }
+ }
+ } }
+
+ if (Jt==1||Jt==3) {
+ if (random(seed) < pow(PUP[4][1],2)/(pow(PUP[4][1],2)
+ +pow(PUP[4][2],2))){
+ MOTHUP[1][4]=2;
+ MOTHUP[2][4]=2;
+ if (emit){
+ MOTHUP[1][7]=2;
+ MOTHUP[2][7]=2;
+ }
+ if (IDUP[1] > 0.) {
+ ICOLUP[1][1]=501;
+ ICOLUP[2][1]=0;
+ ICOLUP[1][2]=0;
+ ICOLUP[2][2]=502;
+ ICOLUP[1][4]=501;
+ ICOLUP[2][4]=502;
+ if (emit) {
+ ICOLUP[1][1]=501;
+ ICOLUP[2][1]=0;
+ ICOLUP[1][2]=0;
+ ICOLUP[2][2]=502;
+ ICOLUP[1][7]=503;
+ ICOLUP[2][7]=502;
+ ICOLUP[1][4]=501;
+ ICOLUP[2][4]=503;
+ }
+}
+ else{
+ ICOLUP[1][1]=0;
+ ICOLUP[2][1]=501;
+ ICOLUP[1][2]=502;
+ ICOLUP[2][2]=0;
+ ICOLUP[1][4]=502;
+ ICOLUP[2][4]=501;
+ if (emit) {
+ ICOLUP[1][1]=0;
+ ICOLUP[2][1]=501;
+ ICOLUP[1][2]=502;
+ ICOLUP[2][2]=0;
+ ICOLUP[1][7]=502;
+ ICOLUP[2][7]=503;
+ ICOLUP[1][4]=503;
+ ICOLUP[2][4]=501;}
+}
+ }
+ else {
+ MOTHUP[1][4]=1;
+ MOTHUP[2][4]=1;
+ if (emit) {
+ MOTHUP[1][7]=1;
+ MOTHUP[2][7]=1;}
+ if (IDUP[1] > 0.) {
+ ICOLUP[1][1]=501;
+ ICOLUP[2][1]=0;
+ ICOLUP[1][2]=0;
+ ICOLUP[2][2]=502;
+ ICOLUP[1][4]=501;
+ ICOLUP[2][4]=502;
+ if (emit) {
+ ICOLUP[1][1]=503;
+ ICOLUP[2][1]=0;
+ ICOLUP[1][2]=0;
+ ICOLUP[2][2]=502;
+ ICOLUP[1][7]=503;
+ ICOLUP[2][7]=501;
+ ICOLUP[1][4]=501;
+ ICOLUP[2][4]=502;
+ }
+}
+ else{
+ ICOLUP[1][1]=0;
+ ICOLUP[2][1]=501;
+ ICOLUP[1][2]=502;
+ ICOLUP[2][2]=0;
+ ICOLUP[1][4]=502;
+ ICOLUP[2][4]=501;
+ if (emit) {
+ ICOLUP[1][1]=0;
+ ICOLUP[2][1]=503;
+ ICOLUP[1][2]=502;
+ ICOLUP[2][2]=0;
+ ICOLUP[1][7]=501;
+ ICOLUP[2][7]=503;
+ ICOLUP[1][4]=502;
+ ICOLUP[2][4]=501;}
+ }
+ }
+ }}else {
+
+ //Generate Born events
+
+ SCALUP=Q;
+ ISPINUP[1]=-1;
+ ISPINUP[2]=-1;
+ ISPINUP[4]=-1;
+ ISPINUP[3]=+1;
+ ISPINUP[5]=+1;
+ PUP[3][1]=xq*emcm/2.;
+ PUP[4][1]=xq*emcm/2.;
+ PUP[3][2]=-xqb*emcm/2.;
+ PUP[4][2]=xqb*emcm/2.;
+ PUP[1][3]=0.;
+ PUP[2][3]=0.;
+ PUP[3][3]=PUP[3][1]+PUP[3][2];
+ PUP[4][3]=PUP[4][1]+PUP[4][2];
+ double cth, cofac, maxcofac;
+ if (proc==23) {do
+ {cth=2.*random(seed)-1.;
+ double GF = 0.0000116639;
+ double alphaem = 0.007297352;
+ double e2 = 4.*pi*alphaem;
+ double k = sqrt(2.)*GF*pow(mp,2)/e2;
+ double sin2thw = 0.2312;
+ double chi1 = k*pow(Q,2)*(pow(Q,2)-pow(mp,2))/(pow((pow(emcm,2)-pow(mp,2)),2)+pow(Yzz*mp,2));
+ double chi2 = pow(k,2)*pow(Q,4)/(pow((pow(Q,2)-pow(mp,2)),2)+pow(Yzz*mp,2));
+ double Aq,Vq,Ae,Ve,Qq;
+ Ae = -0.5;
+ Ve = Ae+2.*sin2thw;
+ if (ID[0]==1||ID[0]==3||ID[0]==5) {Qq=-1./3.; Aq=-0.5; Vq=Aq-(2.*Qq*sin2thw);}
+ if (ID[0]==2||ID[0]==4) {Qq=2./3.; Aq=0.5; Vq=Aq-(2.*Qq*sin2thw);}
+ cofac = (1.+pow(cth,2))*(1.+2.*Vq*Ve*chi1+(pow(Aq,2)+pow(Vq,2))*(pow(Ae,2)+pow(Ve,2))*chi2)+cth*(4.*Qq*Aq*Ae*chi1+8.*Aq*Vq*Ae*Ve*chi2);
+ maxcofac = 2.*(1.+2.*Vq*Ve*chi1+(pow(Aq,2)+pow(Vq,2))*(pow(Ae,2)+pow(Ve,2))*chi2)+(4.*Qq*Aq*Ae*chi1+8.*Aq*Vq*Ae*Ve*chi2);}while(random(seed) > cofac/maxcofac);}
+ if (proc==24) {do
+ {cth=2.*random(seed)-1.;
+ cofac=pow(1.+cth,2);
+ maxcofac=4.;} while(random(seed) > cofac/maxcofac);}
+ if (proc==24) {
+ if (ID[0]==-1||ID[0]==-3||ID[0]==-5 ||ID[0]==2||ID[0]==4){
+ cth=-cth;} }
+ double phi=2.*pi*random(seed);
+ //Assign 4-momenta in boson rest frame
+ PUP[3][4]=Q*cth/2.;
+ PUP[1][4]=sqrt(pow(Q,2)/4.-pow(PUP[3][4],2))*cos(phi);
+ PUP[2][4]=sqrt(pow(Q,2)/4.-pow(PUP[3][4],2))*sin(phi);
+ PUP[4][4]=Q/2.;
+ PUP[1][5]=-sqrt(pow(Q,2)/4.-pow(PUP[3][4],2))*cos(phi);
+ PUP[2][5]=-sqrt(pow(Q,2)/4.-pow(PUP[3][4],2))*sin(phi);
+ PUP[3][5]=-PUP[3][4];
+ PUP[4][5]=Q/2.;
+ mass[3]=Q;
+ //Boost to lab frame
+
+ double v = (xq - xqb) / (xq +xqb);
+ PUP[3][4]=-(PUP[3][4]-PUP[4][4]*v)/sqrt(1.-pow(v,2));
+ PUP[4][4]=(PUP[4][4]-Q*cth*v/2.)/sqrt(1.-pow(v,2));
+ PUP[3][5]=-(PUP[3][5]-PUP[4][5]*v)/sqrt(1.-pow(v,2));
+ PUP[4][5]=(PUP[4][5]+Q*cth*v/2.)/sqrt(1.-pow(v,2));
+ if (fabs(PUP[3][1]+PUP[3][2]-PUP[3][4]-PUP[3][5]) > 0.001) {
+ PUP[3][4]=-PUP[3][4];
+ PUP[3][5]=-PUP[3][5];}
+ //Assign particle IDs
+ IDUP[1]=ID[0];
+ IDUP[2]=ID[1];
+ if (proc==23) {
+ IDUP[3]=23;
+ IDUP[4]=11;
+ IDUP[5]=-11;}
+ else if (proc==24) {
+ if (ID[0]==1||ID[0]==3||ID[0]==5 ||ID[0]==-2||ID[0]==-4){
+ IDUP[3]=-24;
+ IDUP[4]=11;
+ IDUP[5]=-12;} else {
+ IDUP[3]=24;
+ IDUP[4]=-11;
+ IDUP[5]=12;}}
+
+ ISTUP[4]=1;
+ ISTUP[5]=1;
+ NUP=5;
+ MOTHUP[1][4]=3;
+ MOTHUP[2][4]=3;
+ MOTHUP[1][5]=3;
+ MOTHUP[2][5]=3;
+ ICOLUP[1][4]=0;
+ ICOLUP[2][4]=0;
+ ICOLUP[1][5]=0;
+ ICOLUP[2][5]=0;
+ //Assing colours
+ if (IDUP[1]> 0.) {
+ ICOLUP[1][1]=501;
+ ICOLUP[2][1]=0;
+ ICOLUP[1][2]=0;
+ ICOLUP[2][2]=501;}
+ else {
+ ICOLUP[1][1]=0;
+ ICOLUP[2][1]=501;
+ ICOLUP[1][2]=501;
+ ICOLUP[2][2]=0;}
+ }
+ ii+=1;
+
+ double sum1, sum2, sum3, sum4;
+ sum1=0.;sum2=0.;sum3=0.;sum4=0.;
+
+
+ sumwgt += XWGTUP;
+ outdata << "<event>" << endl;
+ outdata << NUP <<"\t" << proc <<"\t"<<XWGTUP<<"\t" << SCALUP << "\t" << AQEDUP << "\t" << AQCDUP << endl;
+ for (int ja = 1; ja < NUP+1; ja++) {
+ outdata << IDUP[ja] << "\t" << ISTUP[ja] << "\t" << MOTHUP[1][ja] <<"\t" << MOTHUP[2][ja] << "\t" << ICOLUP[1][ja] << "\t" << ICOLUP[2][ja] <<"\t" <<setprecision (9)<< PUP[1][ja] << "\t" << PUP[2][ja]<<"\t"<<PUP[3][ja]<<"\t"<<PUP[4][ja]<<"\t" << mass[ja] <<"\t"<< "0" << "\t" <<"9" <<endl;
+ }
+ outdata << "</event>" << endl;
+ cout << "Generated event : " << "\t" << ii << "\t" << "of" << "\t" << nevg << "\r" << flush;
+}
+
+ outdata << "</LesHouchesEvents>" << endl;
+ cout << endl;
+ return 0;
+ }
+ /*********************************************************************/
+ double G(double &rp2, double &rNq, double &rbb, double &rqq, double &rpm, double &rll) {
+ double rG=rNq/(2.*rbb)*(log(rqq/pow(rll,2))*log(log(rpm/pow(rll,2))/log(rp2/pow(rll,2)))-log(rpm/rp2));
+ return rG;}
+ double DG(double &rp2, double &rNq,double &rbb,double &rqq,double &rpm,double &rll) {
+ double rDG=rNq/(2.*rbb)*(-log(rqq/pow(rll,2))*(1./(log(rp2/pow(rll,2))*rp2))+1./rp2);
+ return rDG;}
+ /*********************************************************************/
+/* rx and ry are the radiation variables. rx is given by Q^2/S where Q is the
+ boson mass and S is the centre of mass energy squared. ry is the cosine of
+ the angle of emission of the parton at NLO in the centre of mass frame.*/
+
+/**************************************************************************/
+
+/* Phase space region DYBC includes the soft and collinear regions for
+ gluon emission. Returns the integrand.*/
+
+ double DYBC(double &rx,double &ry, double r3, double r4) {
+ double wgt = 0;
+ bool soft = false;
+ double xr=rx;
+ double yr=ry;
+// Change of variables to regulate divergences for soft = true
+
+ if (xr < 0.125 && yr > 0.75) {
+ soft = true;
+ xr=0.125*r3;
+ yr=1.-2.*xr*r4;
+
+ } else {
+ if (xr < 0.125 && yr < -0.75) {
+ soft = true;
+ xr=0.125*r3;
+ yr=-(1.-2.*xr*r4);
+
+ }
+ }
+
+ /* Check if phase space point is within the region defined by k < 1 ,
+ calculate integrand (wgt) and multiply by Jacobian if soft = true*/
+
+ double k=(1.-yr)/(xr*(1.+yr));
+
+ if (k < 1.) {
+ wgt=-(pow(yr,2)-2.*xr*pow(yr,2)+pow(xr*yr,2)+2.*xr*yr-2.*yr+8.*xr
+ +3.*pow(xr,2)+5.)/(4.*xr*(1.+yr));
+ if (soft) {
+ wgt=wgt*16.*xr ;
+ }
+ rx=xr; ry=yr;} else {
+ k=(1.+yr)/(xr*(1.-yr));
+ if (k < 1.) {
+ wgt=-(pow(yr,2)-2.*xr*pow(yr,2)+pow(xr*yr,2)-2.*xr*yr+2.*yr+8.*xr
+ +3.*pow(xr,2)+5.)/(4.*xr*(1.-yr));
+ if (soft) {
+ wgt=wgt*16.*xr ;
+ }
+ rx=xr; ry=yr;}else{
+ wgt= 0.;
+ }
+ }
+
+ return wgt;
+ }
+
+ /**************************************************************************/
+
+/* Phase space region DYD includes the hard regions for gluon emission.
+ fac=Jacobian from change of variables. Returns the integrand */
+
+ double DYD(double &rx, double &ry, double r3, double r4) {
+ double xr=rx;
+ double yr=ry;
+ double wgt = 0;
+ bool soft=false;
+ double fac = 0;
+
+ // Change of variables to regulate divergences for soft = true
+
+ if (xr < 0.25 && yr > 0.6) {
+ soft = true;
+ yr=1.-0.4*r3;
+ xr=0.625*r4*(1.-yr);
+ fac=5.*(1.-yr);
+ }else{
+ if (xr > 0.6 && yr < 0.25 && yr > 0.) {
+ soft = true;
+ xr=(1.-0.4*r3);
+ yr=0.625*r4*(1.-xr);
+ fac=5.*(1.-xr);
+ }else{
+ if (xr < 0.25 && yr < -0.6) {
+ soft = true;
+ yr=-(1.-0.4*r3);
+ xr=0.625*r4*(1.+yr);
+ fac=5.*(1.+yr);
+ }else{
+ if (xr > 0.6 && yr > -0.25 && yr < 0.) {
+ soft = true;
+ xr=1.-0.4*r3;
+ yr=-0.625*r4*(1.-xr);
+ fac=5.*(1.-xr);
+ }
+ }
+ }
+ }
+
+ /* Check if phase space point is within the region defined by k > 1 ,
+ calculate integrand (wgt) and multiply by Jacobian if soft = true*/
+
+ double k=(1.-yr)/(xr*(1.+yr));
+ if (k > 1.) {
+ k=(1.+yr)/(xr*(1.-yr));
+ wgt=0.;
+ if (k > 1.) {
+ wgt=(pow(yr,2)*pow((1.-xr),2)+pow((1.+xr),2))
+ /((1.-xr)*(1.-pow(yr,2)));
+
+ if (soft) {
+ wgt=wgt*fac;
+ }
+ rx=xr; ry=yr;} else {
+ wgt=0.;
+
+ }
+ }
+ return wgt;
+ }
+
+ /**********************************************************************/
+
+/* Phase space region DYGBC includes the soft and collinear regions for
+ quark emission. Returns the integrand */
+
+ double DYGBC(double &rx, double &ry, double r3, double r4) {
+ double xr=rx;
+ double yr=ry;
+ double wgt = 0;
+ bool soft = false;
+
+ // Change of variables to regulate divergences for soft = true
+
+ if(xr < 0.125 && yr > 0.75) {
+ soft = true;
+ xr = 0.125*r3;
+ yr = 1.-2.*xr*r4;
+ }
+
+ /* Check if phase space point is within the region defined by k < 1 ,
+ calculate integrand (wgt) and multiply by Jacobian if soft = true */
+
+ double k=(1.-yr)/(xr*(1.+yr));
+ if (k < 1.) {
+ wgt=(-3.*pow(xr,2)*pow(yr,2)+3.*xr*pow(yr,2)-pow(yr,2)
+ +pow(xr,3)*pow(yr,2)+3.*pow(xr,3)*yr-6.*pow(xr,2)*yr
+ +3.*xr*yr-1.+4.*xr-7.*pow(xr,2)+4.*pow(xr,3))/(4.*xr);
+ if (soft){
+ wgt=wgt*16.*xr ;
+ }
+ rx=xr; ry=yr;}else{
+ wgt = 0.;
+ }
+ return wgt;
+ }
+
+ /*********************************************************************/
+
+/* Phase space region DYGD includes the hard region for quark emission.
+ fac=Jacobian from change of variables. Returns the integrand */
+
+ double DYGD(double &rx, double &ry, double r3, double r4) {
+ double xr=rx;
+ double yr=ry;
+ double fac = 0;
+ double wgt = 0;
+ bool soft = false;
+ if(xr < 0.25 && yr > 0.6) {
+ soft = true;
+ yr = 1.-0.4*r3;
+ xr = 0.625*r4*(1.-yr);
+ fac = 5.*(1.-yr);
+ }
+
+ /* Check if phase space point is within the region defined by k > 1 ,
+ calculate integrand (wgt) and multiply by Jacobian if soft = true */
+
+ double k=(1.-yr)/(xr*(1.+yr));
+ if (k > 1.) {
+ wgt=((3.+pow(yr,2))*(1.-xr)*(1.-xr)-2.*yr*(1.-pow(xr,2))
+ +2.*(1.+pow(xr,2)))/(4.*(1.-yr));
+ if (soft) {
+ wgt = fac*wgt;
+ }
+ rx=xr; ry=yr;}else { wgt=0.;}
+ return wgt;
+ }
+
+ /*********************************************************************/
+
+// Random number generator.
+
+ double random (int &rseed) {
+ int M = 2147483647;
+ int A = 16807;
+ int Q = 127773;
+ int R = 2836;
+ double MINV = 0.46566128752458e-09;
+ int HI = rseed/Q;
+ int LO = rseed % Q;
+ rseed = A*LO - R*HI;
+ if (rseed < 0) {rseed = rseed + M;}
+ return rseed*MINV;}
+ /*********************************************************************/
diff --git a/Contrib/MCPWNLO/DRELLYAN/DYPP_INPUTS.h b/Contrib/MCPWNLO/DRELLYAN/DYPP_INPUTS.h
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/DRELLYAN/DYPP_INPUTS.h
@@ -0,0 +1,88 @@
+/* MC@NLO input file*/
+#include<iostream>
+#include <string>
+
+class Input
+
+{
+ public:
+
+ // Input();
+ // ~Input();
+
+/* POWHEG or MCNLO ? True if MCNLO and false if POWHEG*/
+
+bool MCNLO() {return true;}
+
+
+ /* Implement truncated shower for POWHEG? */
+
+bool trunc() {return true;}
+
+/* Vector Boson ID
+ Options : 23 for Z boson
+ : 24 for W boson
+*/
+
+ int VBID() {return 24;}
+
+/* Center of mass energy/GeV */
+
+ double cme() {return 1800.;}
+
+/*pp accelerator? True if pp, False if ppbar */
+
+bool acc() {return false;}
+
+/* Pole mass of Z/GeV */
+
+ double Mz() {return 91.2;}
+
+/* Pole mass of W/GeV */
+
+ double Mw() {return 80.3;}
+
+/* Zero width or Breit-Wigner resonance */
+
+bool zerowidth() {return false;}
+
+/* Width of W/GeV */
+
+ double widthw() {return 2.032;}
+
+/* Width of Z/GeV */
+
+double widthz() {return 2.486;};
+
+/* Number of half-widths from resonance Z/W peak/GeV */
+
+double halfwidth() {return 20.;}
+
+/* Renormalization scheme
+ Options : "DIS"
+ : "MSbar"
+*/
+
+char* rscheme() {return "MSbar";}
+
+
+/* PDFset e.g cteq5m.LHgrid, MRST2004nlo.LHgrid etc Make sure the chosen set is compatible with rscheme defined above! */
+
+char* PDFset() { return "cteq5m.LHgrid"; }
+
+/* Number of events for integration */
+
+ int nevint() {return 10000;}
+
+/* Number of events to generate */
+
+ int nevgen() {return 1;}
+
+/* Random number seed */
+
+ int rseed() {return 5;}
+
+};
+
+
+
diff --git a/Contrib/MCPWNLO/DRELLYAN/DYmanual.tex b/Contrib/MCPWNLO/DRELLYAN/DYmanual.tex
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/DRELLYAN/DYmanual.tex
@@ -0,0 +1,178 @@
+\documentclass[12pt,a4paper,oneside]{article}
+%\documentclass{article}
+%\usepackage{afterpage}
+%\usepackage[hang,small,bf]{caption}
+%\usepackage{fancyhdr}
+%\usepackage[something]{optional}
+%\usepackage[todo, question, colour]{optional}
+%\usepackage{epsfig,axodraw}
+%\usepackage{array,cite,amsmath,amssymb}
+%\usepackage{cite}
+%\usepackage{makeidx}
+%\usepackage{doublespace} % This doesn't work with FeynArts diagrams
+%\usepackage{array}
+%\usepackage{multicol}
+%\usepackage{subfigure}
+%\usepackage{rotating}
+%\usepackage{amssymb}
+\usepackage{setspace}
+\usepackage{booktabs}
+%\input{psfig.tex}
+%\usepackage{psfig}
+\oddsidemargin=-0.05in
+\textwidth=6.9in
+\topmargin=-0.8in
+\textheight=9.55in
+%\reqno
+%\newcounter{table}
+\addtocounter{table}{0}
+\usepackage{hyperref}
+\usepackage{epsfig,bm,amsmath}
+\onehalfspacing
+% \makeatletter
+% \DeclareRobustCommand{\Cpp}
+% {\valign{\vfil\hbox{##}\vfil\cr
+% \textsf{C\kern-.1em}\cr
+% $\hbox{\fontsize{\sf@size}{0}\textbf{+\kern-0.05em+}}$\cr}%
+% }
+\begin{document}
+\begin{center}
+\Large \textbf {Drell-Yan Vector Boson Production with {\tt MCPWNLO}} \\
+\end{center}
+\section{Introduction}
+This manual describes how to use this program to generate Drell-Yan events at hadron colliders with NLO accuracy using the {\tt MC@NLO} \cite{Frixione:2002ik} and {\tt POWHEG} \cite{Nason:2004rx} methods. More details on the use and application of the program and its interface with {\tt Herwig++} \cite{Bahr:2008pv} can be found in \cite{LatundeDada:2007jg, seyi}.
+\section{Setting the parameters}
+Within the directory {\tt MCPWNLO/DRELLYAN}, the file {\tt DYPP\_INPUTS.h} includes all the available user parameters
+for the main program {\tt DYPP.cxx}. The parameters are:\\
+\\
+{\tt bool MCNLO}: Set to {\tt true} if the {\tt MC@NLO} method is to be used or {\tt
+ false} if the {\tt POWHEG} method is to be used. \\
+{\tt bool trunc}: Set to {\tt true} if truncated shower of at most one gluon is to be
+implemented for {\tt POWHEG} method. Note that to interface with an angular ordered
+shower, this should be set to {\tt true}. \\
+{\tt int VBID}: Particle ID for the vector boson required. Set to {\tt 23} for $Z$ boson
+production or {\tt 24} for $W$ boson production. \\
+{\tt double cme}: The hadron-hadron center of mass energy in GeV e.g. 1800/1960 for the
+Tevatron and 14000 for the LHC. \\
+{\tt bool acc}: Type of collider. Set to {\tt true} if $p-p$ or {\tt false} if
+{$p-\bar{p}$. \\
+{\tt double Mz}: Pole mass of the $Z$ boson in GeV.
+{\tt double Mw}: Pole mass of the $W$ boson in GeV.
+{\tt bool zerowidth }: Set to {\tt true} if zero width approximation is to be used or {\tt
+ false} if Breit-Wigner resonance is to be used for boson mass. \\
+{\tt double widthw}: Width of the $W$ boson in GeV.\\
+{\tt double widthz}: Width of the $Z$ boson in GeV.\\
+{\tt double halfwidth}: Number of halfwidths either side of the resonance peak. \\
+{\tt char* rscheme}: Factorization scheme. Options are ``{\tt MSbar}'' and ``{\tt DIS}''.\\
+{\tt char* PDFset}: The PDFset to be used e.g. ``{\tt cteq5m.LHgrid}''. Make sure this agrees with the factorization
+scheme set above. \\
+{\tt int nevint}: Number of events (typically $ \approx 10^5$) to integrate over for cross-section calculation and
+determination of maximum weights. \\
+{\tt int nevgen}: Number of events (typically $\approx 10^5$) to generate. \\
+{\tt int rseed}: Initial seed for the random number generator. \\
+
+\section{Generating partonic events}
+After setting the parameters, open the {\tt Makefile} and set {\tt LHAPDFDIR} to your
+{\tt LHAPDF} directory. Also set {\tt HERWIGDIR} to the address of the {\tt Herwig} folder
+in the directory {\tt MCPWNLO}.
+To run {\tt DYPP.cxx}, in the folder {\tt DRELLYAN}, type the following commands :\\
+\\
+{\tt make clean} \\
+{\tt make} \\
+\\
+This creates the executable {\tt DYPP} and {\tt run\_dypp} (which is moved to {\tt
+ HERWIGDIR}). Next, type:
+{\tt ./DYPP} \\
+This runs the main program and generates the Les Houches file for interface with \textsf{Herwig++}. This file will be called {\tt PWDYPP.dat} if running {\tt POWHEG} and {\tt
+ MCDYPP.dat} if running {\tt MC@NLO}. It contains unweighted events with absolute weights
+of $1$.
+\section{{\tt POWHEG} requirements}
+If running {\tt POWHEG}, go to the folder {\tt PWInstallFiles} in the main {\tt MCPWNLO}
+directory. There you will find the following files:\\
+{\tt PartnerFinder.cc} {\tt PartnerFinder.h} {\tt PartnerFinder.icc}
+Replace the files of the same names in {\tt /Shower/Base} folder of your \textsf{Herwig++}
+installation directory. Then go back to the {\tt Shower} folder not in {\tt Base}!) and type: \\
+\\
+{\tt make} \\
+{\tt make install} \\
+\\
+This allows us to set the colour partner of the hardest emission correctly for {\tt
+ POWHEG}.
+\section{Analysis}
+
+In the folder {\tt DYAnalysis} in the {\tt DRELLYAN} directory are some analysis files
+which analyze the events after interfacing the Les Houches file with
+\textsf{Herwig++}. \\
+{\tt MySimpleAnalysis.cc} contains the main program which provides
+histograms for the transverse momenta of the dilepton pair produced from the vector
+bosons, the rapidity and azimuthal distributions of the bosons, the masses of the bosons and the rapidity and
+azimuths of the leptons. Other histograms can be added by booking histograms in the {\tt
+ MySimpleAnalysis.icc} file and declaring them in the {\tt MySimpleAnalysis.h}.\\
+Open the {\tt Makefile} and set {\tt HPDIR} and
+{\tt THEPEGDIR} to the folder where you installed \textsf{Herwig++} and
+\textsf{ThePEG}. Compile the directory by typing the following commands. \\
+\\
+{\tt make} \\
+{\tt make install} \\
+\\
+in the {\tt DYAnalysis} directory. This recreates the library, {\tt MySimpleAnalysis.so}.
+
+\section{Interfacing with \textsf{Herwig++}}
+Having generated the Les Houches file and set up the analysis handler, the next step is to
+run \textsf{Herwig++}. It is assumed that both \textsf{Herwig++} and \textsf{ThePEG} have
+already been installed on your system.
+
+Now go to the directory {\tt MCPWNLO/Herwig} and open the initialization file {\tt
+ DYPP.in}. This contains \textsf{Herwig++} user parameters which can be set depending on
+which process and NLO method you are running. The default set-up is for {\tt MC@NLO} $W$
+boson production at the $1800$ GeV Tevatron. A selection of these are:\\
+\\
+{\tt set Reader2:FileName DYPP.dat}: This is the filename for the Les Houches file your
+generated file is converted into by the program {\tt DRELLYAN/run\_dypp.cxx}. Leave this
+as it is! \\
+{\tt set Reader2:EBeamA 900.0}: The beam energy in GeV of the hadron from the `left'. \\
+{\tt set Reader2:EBeamB 900.0}: The beam energy in GeV of the hadron from the `right'.\\
+{\tt set LesHouchesHandler:WeightOption NegUnitWeight}: The weight option for the
+events. This allows for negative weighted events. \\
+{\tt insert SimpleQCD:MatrixElements[0] MEqq2W2ff}: The hard process. Here it's set up for
+$W$ boson production.\\
+\\
+Next are commands which should be uncommented if running {\tt POWHEG}. If running {\\
+tt MC@NLO}, comment these out. \\
+\\
+{\tt set /Herwig/Shower/Evolver:HardVetoMode 0}: The veto mode to be applied. For {\tt
+ POWHEG}, this should be set to $1$.\\
+{\tt set /Herwig/Shower/PartnerFinder:PHPartnerFinder 0}: The partner finder option. This
+should be set to $1$ for {\tt POWHEG}.\\
+{\tt set /Herwig/Shower/Evolver:HardVetoScaleSource 0}: This reads the maximum $p_T$ for
+the veto from {\tt SCALUP} in the Les Houches file. Set this to $1$ for {\tt POWHEG}.\\
+\\
+Having set up the initialization file, run \textsf{Herwig++} by typing the following
+commands: \\
+\\
+{\tt ./run\_dypp [eventfile] [number of events]} \\
+\\
+An example of the run
+command is:\\
+\\
+{\tt ./run\_dypp /usera/seyi/MCPWNLO/DRELLYAN/MCDYPP.dat 10000}\\
+\\
+where you should replace the eventfile with the path to your Les Houches file.
+\\
+ At the end of the run, a topdraw file called {\tt MG-MySimpleAnalysis.top} will be
+ produced containing the histograms booked by the analysis handler. If you have topdraw
+ installed, you can convert this to a postscript file by typing the command:\\
+\\
+{\tt td -dPOSTSCRIPT MG-MySimpleAnalysis.top}\\
+\\
+In the Analysis folder, the files ZpTRun1.top and WpTRun1.top contain Tevatron Run 1 data
+which can be used for comparisons.
+\section{Further Information}
+For further information about {\tt MCPWNLO} contact: {\tt seyi@hep.phy.cam.ac.uk}.
+\bibliography{manual}
+\bibliographystyle{utphys}
+\end{document}
+%%% Local Variables:
+%%% mode: latex
+%%% TeX-master: t
+%%% End:
diff --git a/Contrib/MCPWNLO/DRELLYAN/Makefile b/Contrib/MCPWNLO/DRELLYAN/Makefile
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/DRELLYAN/Makefile
@@ -0,0 +1,83 @@
+###############################################################################
+# DIRECTORIES
+
+#Where LHAPDF is installed
+LHAPDFDIR = /usera/seyi/lhapdfnew
+#Where the /MCPWNLO/Herwig folder is
+HERWIGDIR = /usera/seyi/MCPWNLO/Herwig
+
+###############################################################################
+
+## ROOT DIRECTORIES
+
+#ROOTSYS = /usera/seyi/root
+
+#ROOTLIB = -L$(ROOTSYS)/lib $(shell $(ROOTSYS)/bin/root-config --libs)
+
+#ROOTINC = $(ROOTSYS)/include/
+
+###############################################################################
+# LIBRARIES
+
+#Now the libraries -L(directory) -lname NOT preceeded by lib!!!!
+#i.e if your lib is called libNAME you need -lNAME
+
+##Path to CLHEP library should be $(CLHEPDIR)/lib/ and check lib name
+#CLHEPLIB = -L$(HOME)/ktjet/lib/ -lKtEvent -L$(CLHEPDIR)/lib/ -lCLHEP
+#CLHEPLIBNEW = -L$(CLHEPDIRNEW)/lib/ -lCLHEP
+##Path to LHAPDF library should be the same as the LHAPDF directory
+LHAPDFLIB = -L$(LHAPDFDIR)/lib -lLHAPDF
+LHAPDFINC = $(LHAPDFDIR)/include
+
+#MAC OS users....
+#If you had to get an external version of libg2c - i.e it doesn't come with you compiler......We stress, you've probably already got this.
+LIBG2C = /usr/local/lib/
+# You would then have to add -L$(LIBG2C) just in front of -lg2c on line 58
+
+################################################################################
+#No need to edit anything below this line!
+
+OPT = -funroll-loops -O2 -Wall
+
+
+FSOURCES = $(shell ls ./src/*.f)
+CXXSOURCES = $(shell ls ./src/*.cxx)
+FOBJS = $(FSOURCES:.f=.o)
+CXXOBJS = $(CXXSOURCES:.cxx=.o)
+CC = gcc
+FF = g77
+
+all: DYPP run_dypp
+
+%.o: %.cxx
+ $(CC) -c $(OPT) \
+ -I$(LHAPDFINC)\
+ $^ -o $@
+
+%.o: %.f
+ $(FF) -c $(OPT) $^ -o $@
+
+
+DYPP: DYPP.o
+ g++ $(OPT) -I./src/ $^\
+ $(CLHEPLIB) \
+ $(LHAPDFLIB) \
+ -L$(LIBG2C) -lg2c -o $@
+
+run_dypp: run_dypp.o
+ g++ $(OPT) -I./src/ $^\
+ $(LHAPDFLIB) \
+ -L$(LIBG2C) -lg2c -o $@
+ mv run_dypp $(HERWIGDIR)
+
+
+
+
+clean:
+ rm *.o
+ rm DYPP
+
+
+
+
+
diff --git a/Contrib/MCPWNLO/DRELLYAN/manual.bib b/Contrib/MCPWNLO/DRELLYAN/manual.bib
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/DRELLYAN/manual.bib
@@ -0,0 +1,91 @@
+@Article{Frixione:2002ik,
+ author = "Frixione, Stefano and Webber, Bryan R.",
+ title = "Matching {NLO QCD} computations and parton shower
+ simulations",
+ journal = "JHEP",
+ volume = "06",
+ year = "2002",
+ pages = "029",
+ eprint = "hep-ph/0204244",
+ SLACcitation = "%%CITATION = HEP-PH 0204244;%%"
+}
+@Article{LatundeDada:2006gx,
+ author = "Latunde-Dada, Oluseyi and Gieseke, Stefan and Webber, Bryan
+ ",
+ title = "A positive-weight next-to-leading-order {M}onte {C}arlo for $e^+
+ e^-$ annihilation to hadrons",
+ journal = "JHEP",
+ volume = "02",
+ year = "2007",
+ pages = "051",
+ eprint = "hep-ph/0612281",
+ SLACcitation = "%%CITATION = HEP-PH/0612281;%%"
+}
+@Article{LatundeDada:2008bv,
+ author = "Latunde-Dada, Oluseyi",
+ title = "{Applying the POWHEG method to top pair production and
+ decays at the ILC}",
+ journal = "Eur. Phys. J.",
+ volume = "C58",
+ year = "2008",
+ pages = "543-554",
+ eprint = "0806.4560",
+ archivePrefix = "arXiv",
+ primaryClass = "hep-ph",
+ doi = "10.1140/epjc/s10052-008-0785-1",
+ SLACcitation = "%%CITATION = 0806.4560;%%"
+}
+@Article{Bahr:2008pv,
+ author = "Bahr, M. and others",
+ title = "{Herwig++ Physics and Manual}",
+ journal = "Eur. Phys. J.",
+ volume = "C58",
+ year = "2008",
+ pages = "639-707",
+ eprint = "0803.0883",
+ archivePrefix = "arXiv",
+ primaryClass = "hep-ph",
+ doi = "10.1140/epjc/s10052-008-0798-9",
+ SLACcitation = "%%CITATION = 0803.0883;%%"
+}
+@Article{LatundeDada:2007jg,
+ author = "Latunde-Dada, Oluseyi",
+ title = "{Herwig++ Monte Carlo At Next-To-Leading Order for e+e-
+ annihilation and lepton pair production}",
+ journal = "JHEP",
+ volume = "11",
+ year = "2007",
+ pages = "040",
+ eprint = "0708.4390",
+ archivePrefix = "arXiv",
+ primaryClass = "hep-ph",
+ doi = "10.1088/1126-6708/2007/11/040",
+ SLACcitation = "%%CITATION = 0708.4390;%%"
+}
+@Article{Nason:2004rx,
+ author = "Nason, Paolo",
+ title = "A new method for combining {NLO QCD} with shower {M}onte {C}arlo
+ algorithms",
+ journal = "JHEP",
+ volume = "11",
+ year = "2004",
+ pages = "040",
+ eprint = "hep-ph/0409146",
+ SLACcitation = "%%CITATION = HEP-PH/0409146;%%"
+}
+@PHDTHESIS{seyi,
+author = "Latunde-Dada, O.A.T",
+year = "2008",
+school = "University of Cambridge",
+title = "Simulations of QCD processes at High Energy Colliders {\bf [http://www.hep.phy.cam.ac.uk/theory/seyi/thesis/thesis.tar.gz]}"
+}
+@Article{LatundeDada:2009rr,
+ author = "Latunde-Dada, Oluseyi",
+ title = "{MC@NLO for the hadronic decay of Higgs bosons in
+ associated production with vector bosons}",
+ year = "2009",
+ eprint = "0903.4135",
+ archivePrefix = "arXiv",
+ primaryClass = "hep-ph",
+ SLACcitation = "%%CITATION = 0903.4135;%%"
+}
diff --git a/Contrib/MCPWNLO/DRELLYAN/run_dypp.cxx b/Contrib/MCPWNLO/DRELLYAN/run_dypp.cxx
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/DRELLYAN/run_dypp.cxx
@@ -0,0 +1,67 @@
+#include <cstdlib>
+#include <ctime>
+#include <iostream>
+#include <string>
+#include <fstream>
+#include <cmath>
+#include <iomanip>
+
+using namespace std;
+
+
+int main (int argc, char *argv[]) {
+ string eventfile = "";
+ string numevents = "1";
+ if(argv[1] && argv[2]) { eventfile = argv[1]; numevents = argv[2];} else { cout << "Use: run_hpp [eventfile] [numevents]" << endl; exit(1); }
+
+ cout << "Running Herwig++ with eventfile: " << eventfile << " and " << numevents << " events\n";
+ // ifstream stream;
+ //ofstream outstream;
+ //ofstream outorigin;
+ //string allfile = "";
+ // string addstr = "";
+
+ // stream.open("wpnlo.in");
+ // outstream.open("wpnlo.temp");
+ //outorigin.open("wpnlo.orig");
+ // if(!stream) { cerr << "Error: Failed to open file" << endl;}
+
+ // string search_string = "eventfile.dat";
+ //string replace_string = eventfile;
+ //string inbuf;
+
+ // while(!stream.eof())
+ //{
+ // getline(stream, inbuf);
+ // int spot = inbuf.find(search_string);
+ // outorigin << inbuf << endl;
+ // if(spot >= 0)
+ // {
+ // string tmpstring = inbuf.substr(0,spot);
+ // tmpstring += replace_string;
+ // tmpstring += inbuf.substr(spot+search_string.length(), inbuf.length());
+ // inbuf = tmpstring;
+ // }
+ // outstream << inbuf << endl;
+ //
+ // }
+ //outstream.close();
+ //stream.close();
+
+ string runcomm1 = "mv ";
+ runcomm1.append(eventfile);
+ runcomm1.append(" DYPP.dat");
+ system(runcomm1.c_str());
+ cout << "Reading DYPP.in..." << endl;
+ system("Herwig++ read DYPP.in");
+ cout << "Done..." << endl;
+ cout << "Running MG.run..." << endl;
+ string runcomm2 = "Herwig++ run MG.run -N";
+ cout << "Done!" << endl;
+ runcomm2.append(numevents);
+ system(runcomm2.c_str());
+ string runcomm3 = "mv DYPP.dat ";
+ runcomm3.append(eventfile);
+ system(runcomm3.c_str());
+ // system("mv wpnlo.orig wpnlo.in");
+}
diff --git a/Contrib/MCPWNLO/EPEM/EPEMmanual.tex b/Contrib/MCPWNLO/EPEM/EPEMmanual.tex
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/EPEMmanual.tex
@@ -0,0 +1,175 @@
+\documentclass[12pt,a4paper,oneside]{article}
+%\documentclass{article}
+%\usepackage{afterpage}
+%\usepackage[hang,small,bf]{caption}
+%\usepackage{fancyhdr}
+%\usepackage[something]{optional}
+%\usepackage[todo, question, colour]{optional}
+%\usepackage{epsfig,axodraw}
+%\usepackage{array,cite,amsmath,amssymb}
+%\usepackage{cite}
+%\usepackage{makeidx}
+%\usepackage{doublespace} % This doesn't work with FeynArts diagrams
+%\usepackage{array}
+%\usepackage{multicol}
+%\usepackage{subfigure}
+%\usepackage{rotating}
+%\usepackage{amssymb}
+\usepackage{setspace}
+\usepackage{booktabs}
+%\input{psfig.tex}
+%\usepackage{psfig}
+\oddsidemargin=-0.05in
+\textwidth=6.9in
+\topmargin=-0.8in
+\textheight=9.55in
+%\reqno
+%\newcounter{table}
+\addtocounter{table}{0}
+\usepackage{hyperref}
+\usepackage{epsfig,bm,amsmath}
+\onehalfspacing
+% \makeatletter
+% \DeclareRobustCommand{\Cpp}
+% {\valign{\vfil\hbox{##}\vfil\cr
+% \textsf{C\kern-.1em}\cr
+% $\hbox{\fontsize{\sf@size}{0}\textbf{+\kern-0.05em+}}$\cr}%
+% }
+\begin{document}
+\begin{center}
+\Large \textbf {LEP $e^+e^-$ annihilation with {\tt MCPWNLO}} \\
+\end{center}
+\section{Introduction}
+This manual describes how to generate $e^+e^-$ annihilation events at LEP with NLO accuracy using the {\tt MC@NLO} \cite{Frixione:2002ik} and {\tt POWHEG} \cite{Nason:2004rx} methods. More details on the use and application of the program and its interface with {\tt Herwig++} \cite{Bahr:2008pv} can be found in \cite{LatundeDada:2007jg,LatundeDada:2006gx}.
+\section{Setting the parameters}
+Within the directory {\tt MCPWNLO/EPEM}, the files {\tt MCEPEM\_INPUTS.h} and {\tt PWEPEM\_INPUTS.h} include all the available user parameters
+for the main programs {\tt MCEPEM.cxx} and {\tt PWEPEM.cxx} for {\tt MC@NLO} and {\tt
+ POWHEG} event generation respectively. The {\tt MCEPEM} parameters are:\\
+\\
+{\tt double cme}: The center of mass energy in GeV e.g. $91.2$ for LEP.\\
+{\tt double Mz}: Pole mass of the $Z$ boson in GeV.\\
+{\tt int nf}: Number of parton flavours ($1-5$).\\
+{\tt bool massiveME }: Set to {\tt true} if a non-zero parton mass is to be used in the matrix element or {\tt
+ false} if all partons are to be considered massless.\\
+{\tt double alphasmz} : The value of $\alpha_S$ at the renormalization scale e.g. Mz for
+LEP. \\
+{\tt bool boost}: Set to {\tt true} if masses should be boosted to true parton masses if
+{\tt massiveME} above is set to {\tt false}.\\
+{\tt int it}: Maximum number of iterations for the Newton-Raphson boost.\\
+{\tt bool resolve}: Set to {\tt true} if the resolution cut on very soft emissions is to be implemented if {\tt massive}
+is set to {\tt true}.
+{\tt int nevint}: Number of events (typically $\approx 10^5$) to integrate over for cross-section calculation and
+determination of maximum weights. Note that this is missing from {\tt PWEPEM\_INPUTS.h}. \\
+{\tt int nevgen}: Number of events to generate (typically $ \approx 10^5$). \\
+{\tt int rseed}: Initial seed for the random number generator. \\
+\\
+In {\tt PWEPEM\_INPUTS.h}, there are the following additional parameters:\\
+\\
+{\tt double Lambda} : The value of $\Lambda_{\rm QCD}$ for the running of $\alpha_S$. \\
+{\tt bool trunc}: Set to {\tt true} if the truncated shower is to be switched on.
+\section{Generating partonic events}
+After setting the parameters, open the {\tt Makefile} and set {\tt HERWIGDIR} to the address of the {\tt Herwig} folder
+in the directory {\tt MCPWNLO}.
+To run {\tt MCEPEM.cxx} or {\tt PWEPEM.cxx}, in the directory {\tt EPEM}, type the following commands :\\
+\\
+{\tt make clean} \\
+{\tt make} \\
+\\
+This creates the executables {\tt MCEPEM}, {\tt PWEPEM} and {\tt run\_epem} (which is moved to {\tt
+ HERWIGDIR}). Next, type: \\
+{\tt .$\backslash$MCEPEM} \\
+or\\
+{\tt .$\backslash$PWEPEM} \\
+depending on which NLO method is being applied.
+This runs the main program and generates the Les Houches file for interface with \textsf{Herwig++}. This file will be called {\tt PWEPEM.dat} if running {\tt POWHEG} and {\tt
+ MCEPEM.dat} if running {\tt MC@NLO} containing unweighted events with absolute weights
+of $1$.
+\section{{\tt POWHEG} requirements}
+If running {\tt POWHEG}, go to the folder {\tt PWInstallFiles} in the main {\tt MCPWNLO}
+directory. There you will find the following files:\\
+{\tt PartnerFinder.cc} {\tt PartnerFinder.h} {\tt PartnerFinder.icc}
+Replace the files of the same names in {\tt /Shower/Base} folder of your \textsf{Herwig++}
+installation directory. Then go back to the {\tt Shower} folder (not in {\tt Base}!) and type: \\
+\\
+{\tt make} \\
+{\tt make install} \\
+\\
+This allows us to set the colour partner of the hardest emission correctly for {\tt
+ POWHEG}.
+\section{Analysis}
+
+In the folder {\tt LEPAnalysis} in the {\tt EPEM} directory are some analysis files
+which analyze the events after interfacing the Les Houches file with
+\textsf{Herwig++}. \\ The
+{\tt .cc} files contain the main programs which provide
+histograms for various LEP event shapes. Open the {\tt Makefile} and set {\tt HPDIR} and
+{\tt THEPEGDIR} to the folder where you installed \textsf{Herwig++} and \textsf{ThePEG}. Compile the directory by typing the following commands\\
+\\
+{\tt make} \\
+{\tt make install} \\
+\\
+in the {\tt LEPAnalysis} directory. This recreates the {\tt .so} libraries. You will need
+to do this every time to make a change in the analysis files.
+
+\section{Interfacing with \textsf{Herwig++}}
+Having generated the Les Houches file and set up the analysis handlers, the next step is to
+run \textsf{Herwig++}. It is assumed that both \textsf{Herwig++} and \textsf{ThePEG} have
+already been installed on your system.
+
+Now go to the directory {\tt MCPWNLO/Herwig} and open the initialization file {\tt
+ EPEM.in}. This contains \textsf{Herwig++} user parameters which can be set depending on
+which NLO method you are running. The default set-up is for {\tt MC@NLO}. A selection of
+these are:\\
+\\
+{\tt set Reader2:FileName EPEM.dat}: This is the filename for the Les Houches file your
+generated file is converted into by the program {\tt EPEM/run\_epem.cxx}. Leave this
+as it is! \\
+{\tt set Reader2:EBeamA 45.6}: The beam energy in GeV of the electrons. \\
+{\tt set Reader2:EBeamB 45.6}: The beam energy in GeV of the positrons.\\
+{\tt set LesHouchesHandler:WeightOption NegUnitWeight}: The weight option for the
+events. This allows for negative weighted events. \\
+{\tt insert SimpleEE:MatrixElements 0 MEee2gZ2qq}: The hard process. Here it's set up for
+$Z$/gamma production and decay into $q \bar{q}$ pairs.\\
+\\
+Next are commands which should be uncommented if running {\tt POWHEG}. If running {\tt MC@NLO}, comment these out. \\
+\\
+{\tt set /Herwig/Shower/Evolver:HardVetoMode 0}: The veto mode to be applied. For {\tt
+ POWHEG}, this should be set to $1$.\\
+{\tt set /Herwig/Shower/PartnerFinder:PHPartnerFinder 0}: The partner finder option. This
+should be set to $1$ for {\tt POWHEG}.\\
+{\tt set /Herwig/Shower/Evolver:HardVetoScaleSource 0}: This reads the maximum $p_T$ for
+the veto from {\tt SCALUP} in the Les Houches file. Set this to 1 for {\tt POWHEG}. \\
+\\
+Next are some tuned parameters to reproduce LEP multiplicities and the best fit to LEP
+eventshapes for the {\tt POWHEG} and {\tt MC@NLO} methods.\\
+\\
+{\tt set /Herwig/Shower/AlphaQCD:AlphaMZ 0.118}: This sets the value of $\alpha_S$ at $M_Z$.\\
+{ \tt set /Herwig/Shower/SudakovCommon:cutoffKinScale 2.45*GeV}: This sets the shower
+cut-off scale.\\
+\\
+Having set up the initialization file, run \textsf{Herwig++} by typing the following
+commands: \\
+\\
+{\tt .$\backslash$run\_epem [eventfile] [number of events]} \\
+\\
+An example of the run
+command is:\\
+\\
+{\tt .$\backslash$run\_epem /usera/seyi/MCPWNLO/EPEM/MCEPEM.dat 10000}\\
+\\
+where you should replace the eventfile with the path to your Les Houches file.
+\\
+ At the end of the run, {\tt .top} files will be
+ produced containing the histograms booked by the analysis handler. If you have topdraw
+ installed, you can convert this to a postscript file by typing the command:\\
+\\
+{\tt td -dPOSTSCRIPT *.top}
+\section{Further Information}
+For further information about {\tt MCPWNLO} contact: {\tt seyi@hep.phy.cam.ac.uk}.
+\bibliography{manual}
+\bibliographystyle{utphys}
+\end{document}
+%%% Local Variables:
+%%% mode: latex
+%%% TeX-master: t
+%%% End:
diff --git a/Contrib/MCPWNLO/EPEM/LEPAnalysis/Makefile b/Contrib/MCPWNLO/EPEM/LEPAnalysis/Makefile
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/LEPAnalysis/Makefile
@@ -0,0 +1,44 @@
+# -*- Makefile -*- (for emacs)
+
+#
+# This Makefile is intended for compiling Herwig++ plugins
+# You can find plugins here: INSERT URL
+#
+# This Makefile received very little testing,
+# any bug reports are very welcome!
+#
+
+# location of include files
+HPPDIR = /usera/seyi/Herwig
+THEPEGDIR = /usera/seyi/Herwig
+
+#CLHEPINCLUDE =
+#ROOTINCLUDE = -I/usera/andreas/root/include
+#ROOTCFLAGS := $(shell /usera/andreas/root/bin/root-config --ldflags)
+#ROOTGLIBS := $(shell /usera/andreas/root/bin/root-config --glibs)
+#ROOT = $(ROOTCFLAGS) $(ROOTGLIBS)
+INCLUDE = -I$(THEPEGDIR)/include -I$(HPPDIR)/include
+#
+# C++ flags
+#
+CXX = g++
+CXXFLAGS = -O2
+
+ALLCCFILES=$(shell echo *.cc)
+all : $(ALLCCFILES:.cc=.so)
+
+%.so : %.cc %.h
+ $(CXX) -fPIC $(CPPFLAGS) $(INCLUDE) $(ROOT) $(CXXFLAGS) -shared $< -o $@
+
+install:
+
+ cp MyLEPEventShapes.so $(HPPDIR)/lib/Herwig++
+ cp MyEventShapesMasterAnalysis.so $(HPPDIR)/lib/Herwig++
+ cp MyEventShapes.so $(HPPDIR)/lib/Herwig++
+ cp MyIdentifiedParticleAnalysis.so $(HPPDIR)/lib/Herwig++
+ cp MySingleParticleAnalysis.so $(HPPDIR)/lib/Herwig++
+ cp MyMultiplicityCount.so $(HPPDIR)/lib/Herwig++
+ cp MyLEPBMultiplicity.so $(HPPDIR)/lib/Herwig++
+ cp MyBFragmentationAnalysisHandler.so $(HPPDIR)/lib/Herwig++
+clean:
+ rm -f $(ALLCCFILES:.cc=.so)
diff --git a/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyBFragmentationAnalysisHandler.cc b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyBFragmentationAnalysisHandler.cc
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyBFragmentationAnalysisHandler.cc
@@ -0,0 +1,263 @@
+// -*- C++ -*-
+//
+// BFragmentationAnalysisHandler.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 MyBFragmentationAnalysisHandler class.
+//
+
+#include "MyBFragmentationAnalysisHandler.h"
+#include "ThePEG/PDT/EnumParticles.h"
+#include "ThePEG/Repository/EventGenerator.h"
+#include "ThePEG/EventRecord/Event.h"
+#include "Herwig++/Utilities/StandardSelectors.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+void MyBFragmentationAnalysisHandler::analyze(tEventPtr event, long,
+ int loop, int state) {
+ if ( loop > 0 || state != 0 || !event ) return;
+
+ ///////////////////////////
+ // Hadron Level Analysis //
+ ///////////////////////////
+ // extract the weakly decaying B hadrons using set to avoid double counting
+ set<PPtr> allParticles;
+ event->select(inserter(allParticles),WeakBHadronSelector());
+ // convert to vector
+ tPVector particles(allParticles.begin(),allParticles.end());
+ // numerator
+ _emax = 0.5*generator()->maximumCMEnergy();
+ analyze(particles);
+
+ ////////////////////////////////////////
+ // Parton Level Analysis (e+e-->bbar) //
+ ////////////////////////////////////////
+ // Get all the particles from the perturbative bit of the events. Find the
+ // b and bbar coming straight out of the Z/photon (b_orig, bbar_orig and
+ // ZGamma respectively). Then go and find the b and bbar that have their
+ // maximal off-shellness i.e. just before the first gluon is emitted.
+ // Finally go off down the b quark lines to find the b's just before they
+ // hadronize (b_end and bbar_end respectively).
+ ParticleSet pert=event->primaryCollision()->step(1)->all();
+ analyze_bquarks(pert);
+}
+
+void MyBFragmentationAnalysisHandler::analyze(const tPVector & particles) {
+ AnalysisHandler::analyze(particles);
+ // Calls analyze() for each particle.
+}
+
+
+void MyBFragmentationAnalysisHandler::analyze(tPPtr part) {
+ string infile = "EPEM.dat";
+ ifstream normin;
+ string stringin = "";
+ double normfac = 1;
+ double stringdoub = 0;
+ bool next = 0, filerror = 0;
+ normin.open(infile.c_str());
+ if(!normin) { cerr << "Error: Failed to open file " << infile << endl; filerror = 1; normfac = 1.; }
+ if(!filerror) {
+ while(normin) {
+
+ normin >> stringin;
+
+ if(next) { normin >> stringdoub; normfac = stringdoub; break; }
+ if(stringin == "NORMFACTOR") { next = 1; }
+
+ }
+ }
+ double eventweight = generator()->currentEvent()->weight()*normfac;
+ _fragBxE ->addWeighted(part->momentum().e()/_emax, eventweight);
+ _fragBxEa ->addWeighted(part->momentum().e()/_emax, eventweight);
+}
+
+void MyBFragmentationAnalysisHandler::analyze_bquarks(ParticleSet pert) {
+ string infile = "EPEM.dat";
+ ifstream normin;
+ string stringin = "";
+ double normfac = 1;
+ double stringdoub = 0;
+ bool next = 0, filerror = 0;
+ normin.open(infile.c_str());
+ if(!normin) { cerr << "Error: Failed to open file " << infile << endl; filerror = 1; normfac = 1.; }
+ if(!filerror) {
+ while(normin) {
+
+ normin >> stringin;
+
+ if(next) { normin >> stringdoub; normfac = stringdoub; break; }
+ if(stringin == "NORMFACTOR") { next = 1; }
+
+ }
+ }
+ double eventweight = generator()->currentEvent()->weight()*normfac;
+ ParticleSet::const_iterator pit;
+ PPtr b_orig,bbar_orig,ZGamma,b_start,bbar_start,b_end,bbar_end;
+ // First go through all the particles looking for b's coming out of Z/gamma's:
+ for(pit=pert.begin();pit!=pert.end();++pit) {
+ PPtr bline = *pit;
+ if(abs((*pit)->id())==5) {
+ while(abs(bline->parents()[0]->id())==5) bline=bline->parents()[0];
+ }
+ if(bline->id()== 5&&(bline->parents()[0]->id()!=21)) b_orig = bline;
+ if(bline->id()==-5&&(bline->parents()[0]->id()!=21)) bbar_orig = bline;
+ }
+ if(!b_orig) return;
+ if(!bbar_orig) return;
+ // Note down the Z/Photon that decays to the b & bbar:
+ if(b_orig->parents()[0]==bbar_orig->parents()[0])
+ ZGamma = b_orig->parents()[0];
+ PPtr root_b[] = {b_orig,bbar_orig};
+ // Now go and look for the b & bbar just before the first gluon is emitted:
+ for(int ix=0;ix<=1;ix++) {
+ while(root_b[ix]->momentum().m()<=
+ getParticleData(ParticleID::b)->mass()+1.e-8*GeV) {
+ for(unsigned int jx=0;jx<root_b[ix]->children().size();jx++)
+ if(root_b[ix]->id()==root_b[ix]->children()[jx]->id())
+ root_b[ix]=root_b[ix]->children()[jx];
+ }
+ }
+ b_start = root_b[0];
+ bbar_start = root_b[1];
+ // Now go and find the b and bbar quarks at the end of the shower before
+ // they turn into hadrons.
+ for(unsigned int ix=0;ix<=1;ix++) {
+ while(root_b[ix]->momentum().m()>=
+ getParticleData(ParticleID::b)->constituentMass()+1.e-8*GeV) {
+ for(unsigned int jx=0;jx<root_b[ix]->children().size();jx++)
+ if(root_b[ix]->id()==root_b[ix]->children()[jx]->id())
+ root_b[ix]=root_b[ix]->children()[jx];
+ }
+ }
+ b_end = root_b[0];
+ bbar_end = root_b[1];
+ // Fill the energy fraction histograms with that of the b quarks.
+ _fragbquarkxE ->addWeighted( b_end->momentum().e()/_emax, eventweight);
+ _fragbquarkxE ->addWeighted( bbar_end->momentum().e()/_emax, eventweight);
+ _fragbquarkjetmass ->addWeighted( b_start->momentum().m()/GeV, eventweight);
+ _fragbquarkjetmass ->addWeighted(bbar_start->momentum().m()/GeV, eventweight);
+}
+
+NoPIOClassDescription<MyBFragmentationAnalysisHandler>
+MyBFragmentationAnalysisHandler::initMyBFragmentationAnalysisHandler;
+// Definition of the static class description member.
+
+void MyBFragmentationAnalysisHandler::Init() {
+
+ static ClassDocumentation<MyBFragmentationAnalysisHandler> documentation
+ ("The MyBFragmentationAnalysisHandler class performs analysis"
+ " of the B fragmentation function");
+
+}
+
+void MyBFragmentationAnalysisHandler::dofinish() {
+ AnalysisHandler::dofinish();
+ // output the histograms
+ string fname = generator()->filename() + string("-") + name() + string(".top");
+ ofstream output(fname.c_str());
+ using namespace HistogramOptions;
+ double chisq,minfrac=0.05;
+ unsigned int npoint;
+ _fragBxE->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for SLD b hadron fragmentation "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _fragBxE->topdrawOutput(output,Frame|Errorbars,
+ "RED",
+ "B Hadron fragmentation function compared to SLD data",
+ " ",
+ "1/SdS/dx0B1",
+ " G G X X",
+ "x0B1",
+ " X X");
+ _fragBxEa->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for ALEPH b hadron fragmentation "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _fragBxEa->topdrawOutput(output,Frame|Errorbars,
+ "RED",
+ "B Hadron framgentation function compared to ALEPH data",
+ " ",
+ "1/SdS/dx0B1",
+ " G G X X",
+ "x0B1",
+ " X X");
+ _fragbquarkxE->topdrawOutput(output,Frame|Smooth,
+ "RED",
+ "b quark fragmentation function",
+ " ",
+ "1/SdS/dx0B1",
+ " G G X X",
+ "x0B1",
+ " X X");
+ _fragbquarkjetmass->topdrawOutput(output,Frame|Smooth,
+ "RED",
+ "b quark jet mass",
+ " ",
+ "1/SdS/dm0J1223",
+ " G G X XX X",
+ "m0J1223",
+ " X XX X");
+ output.close();
+}
+
+void MyBFragmentationAnalysisHandler::doinitrun() {
+ AnalysisHandler::doinitrun();
+ // SLD binning
+ double BxEbins[] = {0.00, 0.04, 0.08, 0.12, 0.16,
+ 0.20, 0.24, 0.28, 0.32, 0.36,
+ 0.40, 0.44, 0.48, 0.52, 0.56,
+ 0.60, 0.64, 0.68, 0.72, 0.76,
+ 0.80, 0.84, 0.88, 0.92, 0.96,
+ 1.0};
+ double BxEdata[] = {0.000,0.000,0.000,0.116,0.198,
+ 0.247,0.264,0.308,0.370,0.426,
+ 0.501,0.577,0.685,0.833,1.055,
+ 1.311,1.667,2.080,2.566,2.934,
+ 3.104,2.856,1.954,0.841,0.108};
+ double BxEerror[]= {0.000,0.000,0.000,0.030,0.037,
+ 0.030,0.029,0.032,0.033,0.034,
+ 0.039,0.041,0.042,0.053,0.074,
+ 0.089,0.088,0.084,0.116,0.178,
+ 0.235,0.179,0.162,0.215,0.062};
+ vector<double> bins(BxEbins,BxEbins+26), data(BxEdata,BxEdata+25),
+ error(BxEerror,BxEerror+25);
+ _fragBxE = new_ptr(Histogram(bins,data,error));
+ // ALEPH binning
+ double BxEabins[] = {0.0 ,0.1 ,0.25 ,0.35 ,0.45 ,
+ 0.55 ,0.6 ,0.65 ,0.7 ,0.725 ,
+ 0.75 ,0.775 ,0.8 ,0.825 ,0.85 ,
+ 0.875 ,0.9 ,0.925 ,0.95 ,0.975 ,
+ 1.};
+ double BxEadata[] = {0.0000,0.1193,0.2810,0.4510,0.7410,
+ 1.0180,1.2760,1.7020,2.1080,2.3520,
+ 2.5360,2.7960,2.9840,3.1000,2.9080,
+ 2.6440,2.0880,1.3480,0.4840,0.0400};
+ double BxEaerrora[] = {0.0000,0.0487,0.0470,0.0390,0.0590,
+ 0.0660,0.0640,0.0660,0.0760,0.0840,
+ 0.0920,0.1040,0.1080,0.1000,0.0880,
+ 0.0880,0.1160,0.1240,0.0760,0.0120};
+ double BxEaerrorb[] = {0.0000,0.0573,0.0350,0.0430,0.0660,
+ 0.0680,0.0640,0.0740,0.0960,0.1120,
+ 0.1240,0.1360,0.1320,0.1240,0.1040,
+ 0.1360,0.1880,0.1880,0.1000,0.0200};
+ double BxEaerror[20];
+ for(unsigned int ix=0;ix<20;++ix){BxEaerror[ix]=sqrt(sqr(BxEaerrora[ix])+
+ sqr(BxEaerrorb[ix]));}
+ bins = vector<double>(BxEabins,BxEabins+21);
+ data = vector<double>(BxEadata,BxEadata+20);
+ error = vector<double>(BxEaerror,BxEaerror+20);
+ _fragBxEa = new_ptr(Histogram(bins,data,error));
+ _fragbquarkxE = new_ptr(Histogram(0.,1.0,100));
+ _fragbquarkjetmass = new_ptr(Histogram(0.,90.0,90));
+}
diff --git a/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyBFragmentationAnalysisHandler.h b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyBFragmentationAnalysisHandler.h
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyBFragmentationAnalysisHandler.h
@@ -0,0 +1,199 @@
+// -*- C++ -*-
+//
+// MyBFragmentationAnalysisHandler.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_MyBFragmentationAnalysisHandler_H
+#define HERWIG_MyBFragmentationAnalysisHandler_H
+//
+// This is the declaration of the MyBFragmentationAnalysisHandler class.
+//
+
+#include "ThePEG/Repository/CurrentGenerator.h"
+#include "ThePEG/Handlers/AnalysisHandler.h"
+#include "Herwig++/Utilities/Histogram.h"
+#include "ThePEG/EventRecord/Event.h"
+
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * Here is the documentation of the MyBFragmentationAnalysisHandler class.
+ *
+ * @see \ref MyBFragmentationAnalysisHandlerInterfaces "The interfaces"
+ * defined for MyBFragmentationAnalysisHandler.
+ */
+class MyBFragmentationAnalysisHandler: public AnalysisHandler {
+
+public:
+
+ /** @name Virtual functions required by the AnalysisHandler class. */
+ //@{
+ /**
+ * Analyze a given Event. Note that a fully generated event
+ * may be presented several times, if it has been manipulated in
+ * between. The default version of this function will call transform
+ * to make a lorentz transformation of the whole event, then extract
+ * all final state particles and call analyze(tPVector) of this
+ * analysis object and those of all associated analysis objects. The
+ * default version will not, however, do anything on events which
+ * have not been fully generated, or have been manipulated in any
+ * way.
+ * @param event pointer to the Event to be analyzed.
+ * @param ieve the event number.
+ * @param loop the number of times this event has been presented.
+ * If negative the event is now fully generated.
+ * @param state a number different from zero if the event has been
+ * manipulated in some way since it was last presented.
+ */
+ virtual void analyze(tEventPtr event, long ieve, int loop, int state);
+
+ /**
+ * Identifies which step(2) final state particles originate
+ * from the b/bbar...
+ */
+ void analyze_bquarks(ParticleSet);
+
+ /**
+ * Analyze the given vector of particles. The default version calls
+ * analyze(tPPtr) for each of the particles.
+ * @param particles the vector of pointers to particles to be analyzed
+ */
+ virtual void analyze(const tPVector & particles);
+
+ /**
+ * Analyze the given particle.
+ * @param particle pointer to the particle to be analyzed.
+ */
+ virtual void analyze(tPPtr particle);
+ //@}
+
+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();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ inline virtual IBPtr clone() const {return new_ptr(*this);}
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ inline virtual IBPtr fullclone() const {return new_ptr(*this);}
+ //@}
+
+protected:
+
+ /** @name Standard Interfaced functions. */
+ //@{
+ /**
+ * 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 static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static NoPIOClassDescription<MyBFragmentationAnalysisHandler> initMyBFragmentationAnalysisHandler;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ MyBFragmentationAnalysisHandler & operator=(const MyBFragmentationAnalysisHandler &);
+
+private:
+
+ /**
+ * Histogram for the SLD binning
+ */
+ HistogramPtr _fragBxE;
+
+ /**
+ * Histogram for the ALEPH binning
+ */
+ HistogramPtr _fragBxEa;
+
+ /**
+ * Histograms for quark energy fraction
+ */
+ HistogramPtr _fragbquarkxE;
+
+ /**
+ * Histograms for b jet mass
+ */
+ HistogramPtr _fragbquarkjetmass;
+
+ /**
+ * Centre-of-mass energy of the collision
+ */
+ Energy _emax;
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of MyBFragmentationAnalysisHandler. */
+template <>
+struct BaseClassTrait<Herwig::MyBFragmentationAnalysisHandler,1> {
+ /** Typedef of the first base class of MyBFragmentationAnalysisHandler. */
+ typedef AnalysisHandler NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the MyBFragmentationAnalysisHandler class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::MyBFragmentationAnalysisHandler>
+ : public ClassTraitsBase<Herwig::MyBFragmentationAnalysisHandler> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::MyBFragmentationAnalysisHandler"; }
+ /** Return the name(s) of the shared library (or libraries) be loaded to get
+ * access to the MyBFragmentationAnalysisHandler class and any other class on which it depends
+ * (except the base class). */
+ // static string library() { return "HwAnalysis.so HwLEPAnalysis.so"; }
+ static string library() { return "MyBFragmentationAnalysisHandler.so"; }
+};
+
+/** @endcond */
+
+}
+
+//#include "MyBFragmentationAnalysisHandler.icc"
+
+#endif /* HERWIG_MyBFragmentationAnalysisHandler_H */
diff --git a/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyBFragmentationAnalysisHandler.icc b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyBFragmentationAnalysisHandler.icc
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyBFragmentationAnalysisHandler.icc
@@ -0,0 +1,24 @@
+// -*- C++ -*-
+//
+// BFragmentationAnalysisHandler.icc 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 inlined member functions of
+// the BFragmentationAnalysisHandler class.
+//
+
+namespace Herwig {
+
+inline IBPtr MyBFragmentationAnalysisHandler::clone() const {
+ return new_ptr(*this);
+}
+
+inline IBPtr MyBFragmentationAnalysisHandler::fullclone() const {
+ return new_ptr(*this);
+}
+
+}
diff --git a/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyEventShapes.cc b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyEventShapes.cc
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyEventShapes.cc
@@ -0,0 +1,405 @@
+// -*- C++ -*-
+//
+// MyEventShapes.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 MyEventShapes class.
+//
+
+#include "MyEventShapes.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+#ifdef ThePEG_TEMPLATES_IN_CC_FILE
+// #include "MyEventShapes.tcc"
+#endif
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+//MyEventShapes::~MyEventShapes() {}
+
+//void MyEventShapes::persistentOutput(PersistentOStream &) const {
+ // *** ATTENTION *** os << ; // Add all member variable which should be written persistently here.
+//}
+
+//void MyEventShapes::persistentInput(PersistentIStream &, int) {
+ // *** ATTENTION *** is >> ; // Add all member variable which should be read persistently here.
+//}
+
+NoPIOClassDescription<MyEventShapes> MyEventShapes::initMyEventShapes;
+// Definition of the static class description member.
+
+void MyEventShapes::Init() {
+
+ static ClassDocumentation<MyEventShapes> documentation
+ ("There is no documentation for the MyEventShapes class");
+
+}
+// void MyEventShapes::calcHemisphereMasses() {
+// Lorentz5Momentum pos, neg;
+// Energy pden(ZERO),epos(ZERO),eneg(ZERO);
+// for(unsigned int ix=0;ix<_pv.size();++ix)
+// {
+// if(_pv[ix].vect() * thrustAxis() > ZERO)
+// {
+// pos += _pv[ix];
+// epos += _pv[ix].perp(thrustAxis());
+// }
+// else
+// {
+// neg += _pv[ix];
+// eneg += _pv[ix].perp(thrustAxis());
+// }
+// pden += _pv[ix].vect().mag();
+// }
+// // denominator and masses
+// Energy2 den(sqr(pos.e()+neg.e()));
+// _mPlus = pos.m2()/den;
+// _mMinus = neg.m2()/den;
+// if (_mPlus < _mMinus) swap(_mPlus, _mMinus);
+// // jet broadening
+// _bPlus = 0.5*epos/pden;
+// _bMinus = 0.5*eneg/pden;
+// if (_bPlus < _bMinus) swap(_bPlus, _bMinus);
+// }
+
+vector<double> MyEventShapes::eigenvalues(const double T[3][3]) {
+
+ // b, c, d are the coefficients of the characteristic polynomial,
+ // a lambda^3 + b lambda^2 + c lambda + d
+ // where a is chosen to be +1.
+ double t11, t12, t13, t22, t23, t33;
+ t11 = T[0][0]; t12 = T[0][1]; t13 = T[0][2];
+ t22 = T[1][1]; t23 = T[1][2]; t33 = T[2][2];
+ double b = -(t11 + t22 + t33);
+ double c = t11*t22 + t11*t33 + t22*t33 - sqr(t12) - sqr(t13) - sqr(t23);
+ double d = - t11*t22*t33 - 2.*t12*t23*t13
+ + t11*sqr(t23) + t22*sqr(t13) + t33*sqr(t12);
+
+ // use Cardano's formula to compute the zeros
+ double p = (3.*c - sqr(b))/3.;
+ double q = (2.*sqr(b)*b - 9.*b*c + 27.*d)/27.;
+ // check diskriminant
+ vector<double> lambda;
+ if (4.*p*sqr(p) + 27.*sqr(q) > 0) {
+ for (unsigned int i=0; i<3; i++) {
+ lambda.push_back(-1.);
+ }
+ cerr << "MyEventShapes::eigenvalues: found D > 0! \n"
+ << "Matrix doesn't have real Eigenvalues in this case\n";
+ } else {
+ // get solutions
+ double alpha = acos(-q/2.*sqrt(-27./(p*p*p)))/3.;
+ double w = sqrt(-4.*p/3.);
+ lambda.push_back(w*cos(alpha) - b/3.);
+ lambda.push_back(-w*cos(alpha+M_PI/3.) - b/3.);
+ lambda.push_back(-w*cos(alpha-M_PI/3.) - b/3.);
+ }
+
+ // sort according to size of eigenvalues
+ // such that lambda[0] > lambda[1] > lambda[2]
+ if (lambda[0] < lambda[1]) {
+ swap(lambda[0], lambda[1]);
+ }
+ if (lambda[0] < lambda[2]) {
+ swap(lambda[0], lambda[2]);
+ }
+ if (lambda[1] < lambda[2]) {
+ swap(lambda[1], lambda[2]);
+ }
+
+ return lambda;
+}
+
+
+Axis MyEventShapes::eigenvector(const double T[3][3], const double &lam) {
+ // set up matrix of system to be solved
+ double a11, a12, a13, a23, a33;
+ a11 = T[0][0] - lam;
+ a12 = T[0][1];
+ a13 = T[0][2];
+ a23 = T[1][2];
+ a33 = T[2][2] - lam;
+
+ // intermediate steps from gauss type algorithm
+ double b1, b2, b4;
+ b1 = a11*a33 - sqr(a13);
+ b2 = a12*a33 - a13*a23;
+ b4 = a11*a23 - a12*a13;
+
+ // eigenvector
+ Axis u(b2, -b1, b4);
+
+ return u.unit();
+}
+
+
+vector<Axis> MyEventShapes::
+eigenvectors(const double T[3][3], const vector<double> &lam) {
+ vector<Axis> n;
+ for (unsigned int i=0; i<3; i++) {
+ n.push_back(eigenvector(T, lam[i]));
+ }
+ return n;
+}
+
+void MyEventShapes::diagonalizeTensors(bool linear, bool cmboost) {
+ // initialize
+ double Theta[3][3];
+ for(int i=0; i<3; i++) {
+ for(int j=0; j<3; j++) {
+ Theta[i][j] = 0.0;
+ }
+ }
+ double sum = 0.;
+ Momentum3 sumvec;
+ vector<double> lam;
+ vector<Axis> n;
+ // get cm-frame
+ Lorentz5Momentum pcm = Lorentz5Momentum();
+ Boost beta;
+ if (cmboost) {
+ for(unsigned int ix=0;ix<_pv.size();++ix) {
+ pcm += _pv[ix];
+ }
+ beta = pcm.findBoostToCM();
+ }
+ // get Theta_ij
+ for(unsigned int ix=0;ix<_pv.size();++ix) {
+ Lorentz5Momentum dum(_pv[ix]);
+ if (cmboost) {
+ dum.boost( beta );
+ }
+ Momentum3 pvec = dum.vect();
+ double pvec_MeV[3] = {pvec.x()/MeV, pvec.y()/MeV, pvec.z()/MeV};
+ if (pvec.mag() > ZERO) {
+ sumvec += pvec;
+ if (linear) {
+ sum += pvec.mag()*UnitRemoval::InvE;
+ } else {
+ sum += pvec.mag2()*UnitRemoval::InvE2;
+ }
+ for(int i=0; i<3; i++) {
+ for(int j=i; j<3; j++) {
+ if (linear) {
+ Theta[i][j] += (pvec_MeV[i])*(pvec_MeV[j])*MeV/(pvec.mag());
+ } else {
+ Theta[i][j] += (pvec_MeV[i])*(pvec_MeV[j]);
+ }
+ }
+ }
+ }
+ }
+ for(int i=0; i<3; i++) {
+ for(int j=0; j<3; j++) {
+ Theta[i][j] /= sum;
+ }
+ }
+
+ // diagonalize it
+ lam = eigenvalues(Theta);
+ n = eigenvectors(Theta, lam);
+
+ if (linear) {
+ _linTen = lam;
+ _linTenAxis = n;
+ } else {
+ _spher = lam;
+ _spherAxis = n;
+ }
+}
+
+void MyEventShapes::calculateThrust() {
+ // explicitly calculate in units of MeV
+ // algorithm based on Brandt/Dahmen Z Phys C1 (1978)
+ // and 'tasso' code from HERWIG
+ // assumes all momenta in cm system, no explicit boost performed here!
+ // unlike for C and D
+
+ _thrust.clear();
+ _thrustAxis.clear();
+
+ if (_pv.size() < 2) {
+ for (int i=0; i<3; i++) {
+ _thrust.push_back(-1);
+ _thrustAxis.push_back(Axis());
+ }
+ return;
+ }
+
+ // thrust
+ vector<Momentum3> p;
+ Energy psum = ZERO;
+ for(unsigned int l=0; l<_pv.size(); l++)
+ {
+ p.push_back(_pv[l].vect());
+ psum += p.back().mag();
+ }
+
+ Axis axis;
+ if (p.size() == 2) {
+ _thrust.push_back(1.0);
+ _thrust.push_back(0.0);
+ _thrust.push_back(0.0);
+ axis = p[0].unit();
+ if (axis.z() < 0) axis = -axis;
+ _thrustAxis.push_back(axis);
+ _thrustAxis.push_back(axis.orthogonal());
+ axis = _thrustAxis[0].cross(_thrustAxis[1]);
+ return;
+ }
+
+ if (p.size() == 3) {
+ if (p[0].mag2() < p[1].mag2()) swap(p[0], p[1]);
+ if (p[0].mag2() < p[2].mag2()) swap(p[0], p[2]);
+ if (p[1].mag2() < p[2].mag2()) swap(p[1], p[2]);
+ // thrust
+ axis = p[0].unit();
+ if (axis.z() < 0) axis = -axis;
+ _thrust.push_back(2.*p[0].mag()/psum);
+ _thrustAxis.push_back(axis);
+ // major
+ axis = (p[1] - (axis*p[1])*axis).unit();
+ if (axis.x() < 0) axis = -axis;
+ _thrust.push_back((abs(p[1]*axis) + abs(p[2]*axis))/psum);
+ _thrustAxis.push_back(axis);
+ // minor
+ _thrust.push_back(0.0);
+ axis = _thrustAxis[0].cross(_thrustAxis[1]);
+ _thrustAxis.push_back(axis);
+ return;
+ }
+
+ // ACHTUNG special case with >= 4 coplanar particles will still fail.
+ // probably not too important...
+ Energy2 val;
+ calcT(p, val, axis);
+ _thrust.push_back(sqrt(val)/psum);
+ if (axis.z() < 0) axis = -axis;
+ _thrustAxis.push_back(axis.unit());
+
+ //major
+ Momentum3 par;
+ for (unsigned int l=0; l<_pv.size(); l++)
+ {
+ par = (p[l]*axis.unit())*axis.unit();
+ p[l] = p[l] - par;
+ }
+ calcM(p, val, axis);
+ _thrust.push_back(sqrt(val)/psum);
+ if (axis.x() < 0) axis = -axis;
+ _thrustAxis.push_back(axis.unit());
+
+ // minor
+ if (_thrustAxis[0]*_thrustAxis[1] < 1e-10)
+ {
+ Energy eval = ZERO;
+ axis = _thrustAxis[0].cross(_thrustAxis[1]);
+ _thrustAxis.push_back(axis);
+ for (unsigned int l=0; l<_pv.size(); l++)
+ eval += abs(axis*_pv[l].vect());
+ _thrust.push_back(eval/psum);
+ }
+ else
+ {
+ _thrust.push_back(-1.0);
+ _thrustAxis.push_back(Axis());
+ }
+}
+
+void MyEventShapes::calcT(const vector<Momentum3> &p, Energy2 &t, Axis &taxis) {
+ Energy2 tval;
+ t = ZERO;
+ ThreeVector<Energy2> tv;
+ Momentum3 ptot;
+ vector<Momentum3> cpm;
+ for (unsigned int k=1; k < p.size(); k++) {
+ for (unsigned int j=0; j<k; j++) {
+ tv = p[j].cross(p[k]);
+ ptot = Momentum3();
+ for (unsigned int l=0; l<p.size(); l++) {
+ if (l!=j && l!=k) {
+ if (p[l]*tv > ZERO) {
+ ptot += p[l];
+ } else {
+ ptot -= p[l];
+ }
+ }
+ }
+ cpm.clear();
+ cpm.push_back(ptot-p[j]-p[k]);
+ cpm.push_back(ptot-p[j]+p[k]);
+ cpm.push_back(ptot+p[j]-p[k]);
+ cpm.push_back(ptot+p[j]+p[k]);
+ for (vector<Momentum3>::iterator it = cpm.begin();
+ it != cpm.end(); it++) {
+ tval = it->mag2();
+ if (tval > t) {
+ t = tval;
+ taxis = it->unit();
+ }
+ }
+ }
+ }
+}
+
+void MyEventShapes::calcM(const vector<Momentum3> &p, Energy2 &m, Axis &maxis) {
+ Energy2 mval;
+ m = ZERO;
+ Momentum3 tv, ptot;
+ vector<Momentum3> cpm;
+ for (unsigned int j=0; j < p.size(); j++) {
+ tv = p[j];
+ ptot = Momentum3();
+ for (unsigned int l=0; l<p.size(); l++) {
+ if (l!=j) {
+ if (p[l]*tv > ZERO) {
+ ptot += p[l];
+ } else {
+ ptot -= p[l];
+ }
+ }
+ }
+ cpm.clear();
+ cpm.push_back(ptot-p[j]);
+ cpm.push_back(ptot+p[j]);
+ for (vector<Momentum3>::iterator it = cpm.begin();
+ it != cpm.end(); it++) {
+ mval = it->mag2();
+ if (mval > m) {
+ m = mval;
+ maxis = it->unit();
+ }
+ }
+ }
+}
+
+void MyEventShapes::bookEEC(vector<double> & hi) {
+ // hi is the histogram. It is understood that hi.front() contains
+ // the bin [-1 < cos(chi) < -1+delta] and hi.back() the bin [1-delta
+ // < cos(chi) < 1]. Here, delta = 2/hi.size().
+ Energy Evis(ZERO);
+ for (unsigned int bin = 0; bin < hi.size(); bin++) {
+ double delta = 2./hi.size();
+ double coschi = -1+bin*delta;
+ if (_pv.size() > 1) {
+ for (unsigned int i = 0; i < _pv.size()-1; i++) {
+ Evis += _pv[i].e();
+ for (unsigned int j = i+1; j < _pv.size(); j++) {
+ double diff = abs(coschi-cos( _pv[i].vect().angle(_pv[j].vect()) ));
+ if (delta > diff)
+ hi[bin] += _pv[i].e()*_pv[j].e() * UnitRemoval::InvE2;
+ }
+ }
+ }
+ hi[bin] /= (Evis*Evis) * UnitRemoval::InvE2;
+ }
+}
+
diff --git a/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyEventShapes.fh b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyEventShapes.fh
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyEventShapes.fh
@@ -0,0 +1,19 @@
+// -*- C++ -*-
+//
+// This is the forward declaration of the EventShapes class.
+//
+#ifndef HERWIG_MyEventShapes_FH
+#define HERWIG_MyEventShapes_FH
+
+#include "ThePEG/Config/Pointers.h"
+
+namespace Herwig {
+using namespace ThePEG;
+
+class MyEventShapes;
+
+ThePEG_DECLARE_POINTERS(MyEventShapes,MyEventShapesPtr);
+
+}
+
+#endif
diff --git a/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyEventShapes.h b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyEventShapes.h
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyEventShapes.h
@@ -0,0 +1,582 @@
+// -*- C++ -*-
+//
+// MyEventShapes.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_MyEventShapes_H
+#define HERWIG_MyEventShapes_H
+//
+// This is the declaration of the MyEventShapes class.
+//
+
+#include "ThePEG/Interface/Interfaced.h"
+#include "ThePEG/Handlers/AnalysisHandler.h"
+#include "ThePEG/Vectors/Lorentz5Vector.h"
+#include "ThePEG/Vectors/ThreeVector.h"
+#include "ThePEG/EventRecord/Particle.h"
+#include "MyEventShapes.fh"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/** \ingroup Analysis
+ *
+ * The MyEventShapes class is designed so that certain event shapes,
+ * such as the thrust are only calculated once per event given the
+ * speed of the calculation.
+ *
+ * @see \ref MyEventShapesInterfaces "The interfaces"
+ * defined for MyEventShapes.
+ */
+class MyEventShapes: public Interfaced {
+
+ //public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ // inline MyEventShapes();
+
+ /**
+ * The copy constructor.
+ */
+ // inline MyEventShapes(const MyEventShapes &);
+
+ /**
+ * The destructor.
+ */
+ // virtual ~MyEventShapes();
+ //@}
+
+public:
+
+ /**
+ * Member to reset the particles to be considered
+ */
+ inline void reset(const tPVector &part);
+
+public:
+
+ /**
+ * Member functions to return thrust related shapes
+ */
+ //@{
+ /**
+ * The thrust
+ */
+ inline double thrust();
+
+ /**
+ * The major
+ */
+ inline double thrustMajor();
+
+ /**
+ * The minor
+ */
+ inline double thrustMinor();
+
+ /**
+ * The oblateness
+ */
+ inline double oblateness();
+
+ /**
+ * The thrust axis
+ */
+ inline Axis thrustAxis();
+
+ /**
+ * The major axis
+ */
+ inline Axis majorAxis();
+
+ /**
+ * The minor axis
+ */
+ inline Axis minorAxis();
+ //@}
+
+ /**
+ * Linear momentum tensor related event shapes
+ */
+ //@{
+ /**
+ * The C parameter
+ */
+ inline double CParameter();
+
+ /**
+ * The D parameter
+ */
+ inline double DParameter();
+
+ /**
+ * The eigenvalues in descending order
+ */
+ inline vector<double> linTenEigenValues();
+
+ /**
+ * The eigenvectors in order of descending eigenvalue
+ */
+ inline vector<Axis> linTenEigenVectors();
+ //@}
+
+ /**
+ * Quadratic momentum tensor related variables
+ */
+ //@{
+ /**
+ * The sphericity
+ */
+ inline double sphericity();
+
+ /**
+ * The aplanarity
+ */
+ inline double aplanarity();
+
+ /**
+ * The planarity
+ */
+ inline double planarity();
+
+ /**
+ * The sphericity axis
+ */
+ inline Axis sphericityAxis();
+
+ /**
+ * The sphericity eigenvalues
+ */
+ inline vector<double> sphericityEigenValues();
+
+ /**
+ * The sphericity eigenvectors
+ */
+ inline vector<Axis> sphericityEigenVectors();
+ //@}
+
+ /**
+ * Jet mass related event shapes
+ */
+ //@{
+ /**
+ * The high hemishpere mass squared divided by the visible energy squared
+ */
+ inline double Mhigh2();
+
+ /**
+ * The low hemishpere mass squared divided by the visible energy squared
+ */
+ inline double Mlow2();
+
+ /**
+ * The difference between the
+ * hemishpere masses squared divided by the visible energy squared
+ */
+ inline double Mdiff2();
+ //@}
+
+ /**
+ * Jet broadening related event shapes
+ */
+ //@{
+ /**
+ * The wide jet broadening
+ */
+ inline double Bmax();
+
+ /**
+ * The narrow jet broadening
+ */
+ inline double Bmin();
+
+ /**
+ * The sum of the jet broadenings
+ */
+ inline double Bsum();
+
+ /**
+ * The difference of the jet broadenings
+ */
+ inline double Bdiff();
+ //@}
+
+
+ /**
+ * The scaled momentum \f$\xi=-\log\left( p/E_{\rm beam}\right)\f$.
+ */
+ inline double getXi(const Lorentz5Momentum & p, const Energy & Ebeam);
+
+ /**
+ * Transverse momentum with respect to the beam
+ */
+ inline Energy getPt(const Lorentz5Momentum & p);
+
+ /**
+ * Rapidity with respect to the beam direction
+ */
+ inline double getRapidity(const Lorentz5Momentum & p);
+ //@}
+
+ /**
+ * Single particle variables related to one of the shape axis.
+ */
+ //@{
+ /**
+ * Transverse momentum with respect to the thrust axis in the event plane
+ */
+ inline Energy ptInT(const Lorentz5Momentum & p);
+
+ /**
+ * Transverse momentum with respect to the thrust axis out of the event plane
+ */
+ inline Energy ptOutT(const Lorentz5Momentum & p);
+
+ /**
+ * Rapidity with respect to the thrust axis
+ */
+ inline double yT(const Lorentz5Momentum & p);
+
+ /**
+ * Transverse momentum with respect to the sphericity axis in the event plane
+ */
+ inline Energy ptInS(const Lorentz5Momentum & p);
+
+ /**
+ * Transverse momentum with respect to the sphericity axis out of the event plane
+ */
+ inline Energy ptOutS(const Lorentz5Momentum & p);
+
+ /**
+ * Rapidity with respect to the sphericity axis
+ */
+ inline double yS(const Lorentz5Momentum & p);
+ //@}
+
+
+ /**
+ * Energy-energy correlation (EEC)
+ * @param hi is the histogram and has to be provided externally
+ * It is understood that
+ * the range of the histogam is -1 < cos(chi) < 1.
+ * hi.front() contains the bin [-1 < cos(chi) < -1+delta] and
+ * hi.back() the bin [1-delta < cos(chi) < 1]. delta =
+ * 2/hi.size(). We use classical indices to access the vector.
+ */
+ void bookEEC(vector<double> & hi);
+
+ /**
+ * Before writing the histogram it has to be normalized according to the
+ * number of events.
+ */
+ inline void normalizeEEC(vector<double> & hi, long evts);
+
+ /**
+ * The asymmetry of EEC is calculated from a given \f$\cos\chi\f$ and EEC
+ * histogram, which is a vector<double> as described above.
+ */
+ inline double AEEC(vector<double> & hi, double& coschi);
+
+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.
+ */
+ inline virtual IBPtr clone() const {return new_ptr(*this);}
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ inline virtual IBPtr fullclone() const {return new_ptr(*this);}
+ //@}
+
+private:
+
+ /**
+ * Check whether the initialization of a certain class of event shapes
+ * has been calculated and if not do so
+ */
+ //@{
+ /**
+ * Check if thrust related variables have been calculated and if not do so
+ */
+ inline void checkThrust();
+
+ /**
+ * Check if the linear tensor related variables have been calculated and if not do so
+ */
+ inline void checkLinTen();
+
+ /**
+ * Check if the quadratic tensor related variables have been calculated and if not do so
+ */
+ inline void checkSphericity();
+
+ /**
+ * Check if the hemisphere mass variables and jet broadenings
+ * have been calculated and if not do so
+ */
+ inline void checkHemispheres();
+ //@}
+
+ /**
+ * Methods that actually calculate the event shapes
+ */
+ //@{
+ /**
+ * Calculate the hemisphere masses and jet broadenings
+ */
+ inline void calcHemisphereMasses();
+
+ /**
+ * Calculate the thrust and related axes
+ */
+ void calculateThrust();
+
+ /**
+ * Diagonalize the tensors
+ * @param linear switch between diagonalization of linear/quadratic tensor.
+ * @param cmboost tells whether to boost into cm frame of all
+ * momenta first, or not (default off, and no interface to this).
+ */
+ void diagonalizeTensors(bool linear, bool cmboost);
+
+ /**
+ * Quite general diagonalization of a symmetric Matrix T, given as
+ * an array of doubles. The symmetry is not checked explicitly as
+ * this is clear in the context. It uses an explicit generic
+ * solution of the eigenvalue problem and no numerical
+ * approximation, based on Cardano's formula.
+ * @param T Matrix to be diagonalised
+ */
+ vector<double> eigenvalues(const double T[3][3]);
+
+ /**
+ * The eigenvector of @param T to a given eigenvalue @param lam
+ */
+ Axis eigenvector(const double T[3][3], const double &lam);
+
+ /**
+ * The eigenvectors of @param T corresponding to the eigenvectors
+ * @param lam . The ordering of the vectors corresponds to the
+ * ordering of the eigenvalues.
+ */
+ vector<Axis> eigenvectors(const double T[3][3], const vector<double> &lam);
+
+ /**
+ * Member to calculate the thrust
+ * @param p The three vectors
+ * @param t The thrust-squared (up to an Energy scale factor)
+ * @param taxis The thrust axis
+ */
+ void calcT(const vector<Momentum3> &p, Energy2 &t, Axis &taxis);
+
+ /**
+ * Member to calculate the major
+ * @param p The three vectors
+ * @param m The major-squared (up to an Energy scale factor)
+ * @param maxis The major axis
+ */
+ void calcM(const vector<Momentum3> &p, Energy2 &m, Axis &maxis);
+ //@}
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static NoPIOClassDescription<MyEventShapes> initMyEventShapes;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ MyEventShapes & operator=(const MyEventShapes &);
+
+private:
+
+ /**
+ * Vector of particle momenta to be analysed
+ */
+ vector<Lorentz5Momentum> _pv;
+
+ /**
+ * Various event shape axes
+ */
+ //@{
+ /**
+ * The thrust related axes
+ */
+ vector<Axis> _thrustAxis;
+
+ /**
+ * The sphericity related axes
+ */
+ vector<Axis> _spherAxis;
+
+ /**
+ * The linearised tensor axes
+ */
+ vector<Axis> _linTenAxis;
+ //@}
+
+ /**
+ * Values of axis related event shapes
+ */
+ //@{
+ /**
+ * Values of thrust related variables
+ */
+ vector<double> _thrust;
+
+ /**
+ * Values of sphericity related variables
+ */
+ vector<double> _spher;
+
+ /**
+ * Values of linearized tensor related variables
+ */
+ vector<double> _linTen;
+ //@}
+
+ /**
+ * Whether or not certain event axes have been calculated
+ */
+ //@{
+ /**
+ * Whether or not the thrust is calculated
+ */
+ bool _thrustDone;
+
+ /**
+ * Whether or not the sphericity is calculated
+ */
+ bool _spherDone;
+
+ /**
+ * Whether or not the linearizes tensor is calculated
+ */
+ bool _linTenDone;
+
+ /**
+ * Whether or not the hemisphere masses have been calculated
+ */
+ bool _hemDone;
+ //@}
+
+ /**
+ * Whether ot not to boost to the CMS frame for the tensor diagonalizations
+ */
+ bool _useCmBoost;
+
+ /**
+ * Hemisphere masses
+ */
+ //@{
+ /**
+ * The high hemisphere mass
+ */
+ double _mPlus;
+
+ /**
+ * The low hemisphere mass
+ */
+ double _mMinus;
+ //@}
+
+ /**
+ * The jet broadenings
+ */
+ //@{
+ /**
+ * The wide jet broadening
+ */
+ double _bPlus;
+
+ /**
+ * The narrow jet broadening
+ */
+ double _bMinus;
+ //@}
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of MyEventShapes. */
+template <>
+struct BaseClassTrait<Herwig::MyEventShapes,1> {
+ /** Typedef of the first base class of MyEventShapes. */
+ typedef Interfaced NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the MyEventShapes class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::MyEventShapes>
+ : public ClassTraitsBase<Herwig::MyEventShapes> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::MyEventShapes"; }
+ /** Return the name(s) of the shared library (or libraries) be loaded to get
+ * access to the MyEventShapes class and any other class on which it depends
+ * (except the base class). */
+ static string library() { return "MyEventShapes.so"; }
+ // static string library() { return "HwAnalysis.so"; }
+};
+
+/** @endcond */
+
+}
+
+#include "MyEventShapes.icc"
+#ifndef ThePEG_TEMPLATES_IN_CC_FILE
+// #include "MyEventShapes.tcc"
+#endif
+
+#endif /* HERWIG_MyEventShapes_H */
diff --git a/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyEventShapes.icc b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyEventShapes.icc
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyEventShapes.icc
@@ -0,0 +1,264 @@
+// -*- C++ -*-
+//
+// MyEventShapes.icc 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 inlined member functions of
+// the MyEventShapes class.
+//
+
+namespace Herwig {
+
+
+inline double MyEventShapes::thrust() {
+ checkThrust();
+ return _thrust[0];
+}
+
+inline double MyEventShapes::thrustMajor() {
+ checkThrust();
+ return _thrust[1];
+}
+
+inline double MyEventShapes::thrustMinor() {
+ checkThrust();
+ return _thrust[2];
+}
+
+inline double MyEventShapes::oblateness() {
+ checkThrust();
+ return _thrust[1]-_thrust[2];
+}
+
+inline Axis MyEventShapes::thrustAxis() {
+ checkThrust();
+ return _thrustAxis[0];
+}
+
+inline Axis MyEventShapes::majorAxis() {
+ checkThrust();
+ return _thrustAxis[1];
+}
+
+inline Axis MyEventShapes::minorAxis() {
+ checkThrust();
+ return _thrustAxis[2];
+}
+
+inline void MyEventShapes::reset(const tPVector &part)
+{
+ _pv.resize(part.size());
+ for(unsigned int ix=0;ix<part.size();++ix) _pv[ix]=part[ix]->momentum();
+ _thrustDone = false;
+ _spherDone = false;
+ _linTenDone = false;
+ _hemDone = false;
+ _useCmBoost = false;
+}
+
+inline double MyEventShapes::sphericity() {
+ checkSphericity();
+ return 3./2.*(_spher[1]+_spher[2]);
+}
+
+inline double MyEventShapes::aplanarity() {
+ checkSphericity();
+ return 3./2.*_spher[2];
+}
+
+inline double MyEventShapes::planarity() {
+ checkSphericity();
+ return _spher[1]-_spher[2];
+}
+
+inline Axis MyEventShapes::sphericityAxis() {
+ checkSphericity();
+ return _spherAxis[0];
+}
+
+inline vector<double> MyEventShapes::sphericityEigenValues() {
+ checkSphericity();
+ return _spher;
+}
+
+inline vector<Axis> MyEventShapes::sphericityEigenVectors() {
+ checkSphericity();
+ return _spherAxis;
+}
+
+inline vector<double> MyEventShapes::linTenEigenValues() {
+ checkLinTen();
+ return _linTen;
+}
+
+inline vector<Axis> MyEventShapes::linTenEigenVectors() {
+ checkLinTen();
+ return _linTenAxis;
+}
+
+inline double MyEventShapes::CParameter() {
+ checkLinTen();
+ return 3.*(_linTen[0]*_linTen[1]+_linTen[1]*_linTen[2]
+ +_linTen[2]*_linTen[0]);
+}
+
+inline double MyEventShapes::DParameter() {
+ checkLinTen();
+ return 27.*(_linTen[0]*_linTen[1]*_linTen[2]);
+}
+
+inline double MyEventShapes::Mhigh2() {
+ checkHemispheres();
+ return _mPlus;
+}
+
+inline double MyEventShapes::Mlow2() {
+ checkHemispheres();
+ return _mMinus;
+}
+
+inline double MyEventShapes::Mdiff2() {
+ checkHemispheres();
+ return _mPlus-_mMinus;
+}
+
+inline double MyEventShapes::Bmax() {
+ checkHemispheres();
+ return _bPlus;
+}
+
+inline double MyEventShapes::Bmin() {
+ checkHemispheres();
+ return _bMinus;
+}
+
+inline double MyEventShapes::Bsum() {
+ checkHemispheres();
+ return _bPlus+_bMinus;
+}
+
+inline double MyEventShapes::Bdiff() {
+ checkHemispheres();
+ return _bPlus-_bMinus;
+}
+
+inline void MyEventShapes::checkLinTen() {
+ if (!_linTenDone) {
+ _linTenDone = true;
+ diagonalizeTensors(true, _useCmBoost);
+ }
+}
+
+inline void MyEventShapes::checkSphericity() {
+ if (!_spherDone) {
+ _spherDone = true;
+ diagonalizeTensors(false, _useCmBoost);
+ }
+}
+
+inline void MyEventShapes::checkThrust() {
+ if (!_thrustDone) {
+ _thrustDone = true;
+ calculateThrust();
+ }
+}
+
+inline void MyEventShapes::checkHemispheres() {
+ if (!_hemDone) {
+ _hemDone = true;
+ calcHemisphereMasses();
+ }
+}
+
+inline void MyEventShapes::calcHemisphereMasses() {
+ Lorentz5Momentum pos, neg;
+ Energy pden(ZERO),epos(ZERO),eneg(ZERO);
+ for(unsigned int ix=0;ix<_pv.size();++ix)
+ {
+ if(_pv[ix].vect() * thrustAxis() > ZERO)
+ {
+ pos += _pv[ix];
+ epos += _pv[ix].perp(thrustAxis());
+ }
+ else
+ {
+ neg += _pv[ix];
+ eneg += _pv[ix].perp(thrustAxis());
+ }
+ pden += _pv[ix].vect().mag();
+ }
+ // denominator and masses
+ Energy2 den(sqr(pos.e()+neg.e()));
+ _mPlus = pos.m2()/den;
+ _mMinus = neg.m2()/den;
+ if (_mPlus < _mMinus) swap(_mPlus, _mMinus);
+ // jet broadening
+ _bPlus = 0.5*epos/pden;
+ _bMinus = 0.5*eneg/pden;
+ if (_bPlus < _bMinus) swap(_bPlus, _bMinus);
+}
+
+inline double MyEventShapes::getXi(const Lorentz5Momentum & p,
+ const Energy & Ebeam) {
+ return((Ebeam > ZERO && p.vect().mag() > ZERO) ?
+ log(Ebeam/p.vect().mag()) : -1.);
+}
+
+inline Energy MyEventShapes::getPt(const Lorentz5Momentum & p) {
+ return p.perp();
+}
+
+inline double MyEventShapes::getRapidity(const Lorentz5Momentum & p) {
+ return (p.t() > p.z() ? p.rapidity() : 1e99);
+}
+
+inline Energy MyEventShapes::ptInT(const Lorentz5Momentum & p) {
+ checkThrust();
+ return p.vect()*_thrustAxis[1];
+}
+
+inline Energy MyEventShapes::ptOutT(const Lorentz5Momentum & p) {
+ checkThrust();
+ return p.vect()*_thrustAxis[2];
+}
+
+inline double MyEventShapes::yT(const Lorentz5Momentum & p) {
+ checkThrust();
+ return (p.t() > p.vect()*_thrustAxis[0] ?
+ p.rapidity(_thrustAxis[0]) : 1e99);
+}
+
+inline Energy MyEventShapes::ptInS(const Lorentz5Momentum & p) {
+ checkSphericity();
+ return p.vect()*_spherAxis[1];
+}
+
+inline Energy MyEventShapes::ptOutS(const Lorentz5Momentum & p) {
+ checkSphericity();
+ return p.vect()*_spherAxis[2];
+}
+
+inline double MyEventShapes::yS(const Lorentz5Momentum & p) {
+ checkSphericity();
+ return (p.t() > p.vect()*_spherAxis[0] ?
+ p.rapidity(_spherAxis[0]) : 1e99);
+}
+
+inline void MyEventShapes::normalizeEEC(vector<double> & hi, long evts) {
+ for (unsigned int bin = 0; bin < hi.size(); bin++) bin /= (hi.size()*evts);
+}
+
+inline double MyEventShapes::AEEC(vector<double> & hi, double& coschi) {
+ if (coschi > 0. && coschi <= 1.) {
+ int i = static_cast<int>( floor((-coschi+1.)/2.*hi.size()) );
+ int j = static_cast<int>( floor(( coschi+1.)/2.*hi.size()) );
+ return hi[i]-hi[j];
+ } else {
+ return 1e99;
+ }
+}
+}
diff --git a/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyEventShapesMasterAnalysis.cc b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyEventShapesMasterAnalysis.cc
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyEventShapesMasterAnalysis.cc
@@ -0,0 +1,60 @@
+// -*- C++ -*-
+//
+// MyEventShapesMasterAnalysis.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 MyEventShapesMasterAnalysis class.
+//
+
+#include "MyEventShapesMasterAnalysis.h"
+#include "ThePEG/Interface/Reference.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+void MyEventShapesMasterAnalysis::analyze(tEventPtr event, long ieve, int loop, int state) {
+ AnalysisHandler::analyze(event, ieve, loop, state);
+}
+
+LorentzRotation MyEventShapesMasterAnalysis::transform(tEventPtr) const {
+ return LorentzRotation();
+ // Return the Rotation to the frame in which you want to perform the analysis.
+}
+
+void MyEventShapesMasterAnalysis::analyze(const tPVector & particles) {
+ _shapes->reset(particles);
+}
+
+void MyEventShapesMasterAnalysis::analyze(tPPtr) {}
+
+void MyEventShapesMasterAnalysis::persistentOutput(PersistentOStream & os) const {
+ os << _shapes;
+}
+
+void MyEventShapesMasterAnalysis::persistentInput(PersistentIStream & is, int) {
+ is >> _shapes;
+}
+
+ClassDescription<MyEventShapesMasterAnalysis> MyEventShapesMasterAnalysis::initMyEventShapesMasterAnalysis;
+// Definition of the static class description member.
+
+void MyEventShapesMasterAnalysis::Init() {
+
+ static ClassDocumentation<MyEventShapesMasterAnalysis> documentation
+ ("The MyEventShapesMasterAnalysis class is the master class for event"
+ " shapes analyses");
+
+ static Reference<MyEventShapesMasterAnalysis,MyEventShapes> interfaceMyEventShapes
+ ("MyEventShapes",
+ "Pointer to the object which calculates the event shapes",
+ &MyEventShapesMasterAnalysis::_shapes, false, false, true, false, false);
+
+}
+
diff --git a/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyEventShapesMasterAnalysis.h b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyEventShapesMasterAnalysis.h
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyEventShapesMasterAnalysis.h
@@ -0,0 +1,184 @@
+// -*- C++ -*-
+//
+// MyEventShapesMasterAnalysis.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_MyEventShapesMasterAnalysis_H
+#define HERWIG_MyEventShapesMasterAnalysis_H
+//
+// This is the declaration of the MyEventShapesMasterAnalysis class.
+//
+
+#include "ThePEG/Handlers/AnalysisHandler.h"
+#include "MyEventShapes.h"
+
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/** \ingroup Analysis
+ * The MyEventShapesMasterAnalysis class is responsible for extracting the
+ * final state particles from the event record and setting up the object which
+ * calculates the event shapes. This is done so that the MyEventShapes class which
+ * contains a lot of slow code isn't rerun unnecessarily.
+ *
+ * @see \ref MyEventShapesMasterAnalysisInterfaces "The interfaces"
+ * defined for MyEventShapesMasterAnalysis.
+ */
+class MyEventShapesMasterAnalysis: public AnalysisHandler {
+
+public:
+
+ /** @name Virtual functions required by the AnalysisHandler class. */
+ //@{
+ /**
+ * Analyze a given Event. Note that a fully generated event
+ * may be presented several times, if it has been manipulated in
+ * between. The default version of this function will call transform
+ * to make a lorentz transformation of the whole event, then extract
+ * all final state particles and call analyze(tPVector) of this
+ * analysis object and those of all associated analysis objects. The
+ * default version will not, however, do anything on events which
+ * have not been fully generated, or have been manipulated in any
+ * way.
+ * @param event pointer to the Event to be analyzed.
+ * @param ieve the event number.
+ * @param loop the number of times this event has been presented.
+ * If negative the event is now fully generated.
+ * @param state a number different from zero if the event has been
+ * manipulated in some way since it was last presented.
+ */
+ virtual void analyze(tEventPtr event, long ieve, int loop, int state);
+
+ /**
+ * Transform the event to the desired Lorentz frame and return the
+ * corresponding LorentzRotation.
+ * @param event a pointer to the Event to be transformed.
+ * @return the LorentzRotation used in the transformation.
+ */
+ virtual LorentzRotation transform(tEventPtr event) const;
+
+ /**
+ * Analyze the given vector of particles. The default version calls
+ * analyze(tPPtr) for each of the particles.
+ * @param particles the vector of pointers to particles to be analyzed
+ */
+ virtual void analyze(const tPVector & particles);
+
+ /**
+ * Analyze the given particle.
+ * @param particle pointer to the particle to be analyzed.
+ */
+ virtual void analyze(tPPtr particle);
+ //@}
+
+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.
+ */
+ inline virtual IBPtr clone() const {return new_ptr(*this);}
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ inline virtual IBPtr fullclone() const {return new_ptr(*this);}
+ //@}
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<MyEventShapesMasterAnalysis> initMyEventShapesMasterAnalysis;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ MyEventShapesMasterAnalysis & operator=(const MyEventShapesMasterAnalysis &);
+
+private:
+
+ /**
+ * Pointer to the MyEventShapes object
+ */
+ MyEventShapesPtr _shapes;
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of MyEventShapesMasterAnalysis. */
+template <>
+struct BaseClassTrait<Herwig::MyEventShapesMasterAnalysis,1> {
+ /** Typedef of the first base class of MyEventShapesMasterAnalysis. */
+ typedef AnalysisHandler NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the MyEventShapesMasterAnalysis class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::MyEventShapesMasterAnalysis>
+ : public ClassTraitsBase<Herwig::MyEventShapesMasterAnalysis> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::MyEventShapesMasterAnalysis"; }
+ /** Return the name(s) of the shared library (or libraries) be loaded to get
+ * access to the MyEventShapesMasterAnalysis class and any other class on which it depends
+ * (except the base class). */
+ static string library() { return "MyEventShapes.so MyEventShapesMasterAnalysis.so"; }
+
+};
+
+/** @endcond */
+
+}
+
+//#include "MyEventShapesMasterAnalysis.icc"
+#ifndef ThePEG_TEMPLATES_IN_CC_FILE
+// #include "MyEventShapesMasterAnalysis.tcc"
+#endif
+
+#endif /* HERWIG_MyEventShapesMasterAnalysis_H */
diff --git a/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyIdentifiedParticleAnalysis.cc b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyIdentifiedParticleAnalysis.cc
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyIdentifiedParticleAnalysis.cc
@@ -0,0 +1,2031 @@
+// -*- C++ -*-
+//
+// MyIdentifiedParticleAnalysis.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 MyIdentifiedParticleAnalysis class.
+//
+
+#include "MyIdentifiedParticleAnalysis.h"
+#include "ThePEG/PDT/EnumParticles.h"
+#include "ThePEG/EventRecord/Event.h"
+#include "ThePEG/Repository/EventGenerator.h"
+#include "ThePEG/Interface/Reference.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+int MyIdentifiedParticleAnalysis::getFlavour(const tPVector &pv) {
+ tPVector::const_iterator it;
+ for(it = pv.begin(); it!=pv.end(); it++)
+ if (abs((*it)->id()) < 7) break;
+ return abs((*it)->id());
+}
+
+void MyIdentifiedParticleAnalysis:: analyze(tEventPtr event, long ieve, int loop, int state){
+ AnalysisHandler::analyze(event, ieve, loop, state);
+ if ( loop > 0 || state != 0 || !event ) return;
+ string infile = "EPEM.dat";
+ ifstream normin;
+ string stringin = "";
+ double normfac = 1;
+ double stringdoub = 0;
+ bool next = 0, filerror = 0;
+ normin.open(infile.c_str());
+ if(!normin) { cerr << "Error: Failed to open file " << infile << endl; filerror = 1; normfac = 1.; }
+ if(!filerror) {
+ while(normin) {
+
+ normin >> stringin;
+
+ if(next) { normin >> stringdoub; normfac = stringdoub; break; }
+ if(stringin == "NORMFACTOR") { next = 1; }
+
+ }
+ }
+ double eventweight = generator()->currentEvent()->weight()*normfac;
+ // get the final-state
+ // tcEventPtr event=generator()->currentEvent();
+ tPVector hadrons=event->getFinalState();
+ // get the partons
+ tPVector partons=event->primaryCollision()->steps()[0]->getFinalState();
+ int flav = getFlavour(partons);
+ Energy Emax = 0.5*generator()->maximumCMEnergy();
+ for (tPVector::iterator it = hadrons.begin(); it != hadrons.end(); ++it ) {
+ // only looking at charged particles
+ if(!(*it)->data().charged()) continue;
+ // all particles
+ double xp = getX((*it)->momentum(), Emax);
+ // *_xpa ->addWeighted( xp;
+ _xpa->addWeighted(xp, eventweight);
+
+ if(abs((*it)->id()) == ParticleID::piplus) {
+ _pipma ->addWeighted(xp, eventweight);
+ _pipm ->addWeighted( (*it)->momentum().vect().mag()/GeV, eventweight);
+ }
+ else if(abs((*it)->id()) == ParticleID::Kplus) {
+ _kpma ->addWeighted( xp, eventweight);
+ _kpm ->addWeighted( (*it)->momentum().vect().mag()/GeV, eventweight);
+ }
+ else if(abs((*it)->id()) == ParticleID::pplus) {
+ _ppma ->addWeighted( xp, eventweight);
+ _ppm ->addWeighted( (*it)->momentum().vect().mag()/GeV, eventweight);
+ }
+ switch(flav) {
+ case 1:
+ case 2:
+ case 3:
+ _xpl ->addWeighted( xp, eventweight);
+ if(abs((*it)->id()) == ParticleID::piplus) _pipml ->addWeighted( xp, eventweight);
+ else if(abs((*it)->id()) == ParticleID::Kplus) _kpml ->addWeighted( xp, eventweight);
+ else if(abs((*it)->id()) == ParticleID::pplus) _ppml ->addWeighted( xp, eventweight);
+ _udsxp ->addWeighted( xp, eventweight);
+ if (xp > 0) _udsxip ->addWeighted( -log(xp), eventweight);
+ break;
+ case 4:
+ _xpc ->addWeighted( xp, eventweight);
+ if(abs((*it)->id()) == ParticleID::piplus) _pipmc ->addWeighted( xp, eventweight);
+ else if(abs((*it)->id()) == ParticleID::Kplus) _kpmc ->addWeighted( xp, eventweight);
+ else if(abs((*it)->id()) == ParticleID::pplus) _ppmc ->addWeighted( xp, eventweight);
+ break;
+ case 5:
+ _xpb ->addWeighted( xp, eventweight);
+ if(abs((*it)->id()) == ParticleID::piplus) _pipmb ->addWeighted( xp, eventweight);
+ else if(abs((*it)->id()) == ParticleID::Kplus) _kpmb ->addWeighted( xp, eventweight);
+ else if(abs((*it)->id()) == ParticleID::pplus) _ppmb ->addWeighted( xp, eventweight);
+ break;
+ default:
+ break;
+ }
+ }
+ // finally decaying particles
+ set<tcPPtr> allparticles;
+ StepVector steps = event->primaryCollision()->steps();
+ for ( StepVector::const_iterator it = steps.begin()+2;
+ it != steps.end(); ++it ) {
+ (**it).select(inserter(allparticles), ThePEG::AllSelector());
+ }
+
+ for(set<tcPPtr>::const_iterator it = allparticles.begin();
+ it != allparticles.end(); ++it) {
+ // lambda's
+ long id = abs( (*it)->id());
+ double xp;
+ switch(id) {
+ case ParticleID::Lambda0:
+ _lpm ->addWeighted( (*it)->momentum().vect().mag()/Emax, eventweight);
+ break;
+ case ParticleID::Kstarplus:
+ _xpKstarplus ->addWeighted( (*it)->momentum().vect().mag()/Emax, eventweight);
+ break;
+ case ParticleID::Ximinus:
+ _xpXiminus ->addWeighted( (*it)->momentum().e()/Emax, eventweight);
+ xp = (*it)->momentum().vect().mag()/Emax;
+ _xiXiminus ->addWeighted( -log(xp), eventweight);
+ break;
+ case ParticleID::Sigmastarplus:
+ _xpSigmaplus ->addWeighted( (*it)->momentum().e()/Emax, eventweight);
+ xp = (*it)->momentum().vect().mag()/Emax;
+ _xiSigmaplus ->addWeighted( -log(xp), eventweight);
+ break;
+ case ParticleID::Sigmastarminus:
+ _xpSigmaminus ->addWeighted( (*it)->momentum().e()/Emax, eventweight);
+ xp = (*it)->momentum().vect().mag()/Emax;
+ _xiSigmaminus ->addWeighted( -log(xp), eventweight);
+ break;
+ case ParticleID::Xistar0:
+ _xpXi0 ->addWeighted( (*it)->momentum().e()/Emax, eventweight);
+ xp = (*it)->momentum().vect().mag()/Emax;
+ _xiXi0 ->addWeighted( -log(xp), eventweight);
+ break;
+ case 3124: // lambda(1520)
+ _xpLambda1520 ->addWeighted( (*it)->momentum().e()/Emax, eventweight);
+ xp = (*it)->momentum().vect().mag()/Emax;
+ _xiLambda1520 ->addWeighted(-log(xp), eventweight);
+ break;
+ case ParticleID::Deltaplus2:
+ _xeDelta ->addWeighted( (*it)->momentum().e()/Emax, eventweight);
+ break;
+ case ParticleID::f_0:
+ _xpf980 ->addWeighted((*it)->momentum().vect().mag()/Emax, eventweight);
+ break;
+ case ParticleID::f_2:
+ _xpf2 ->addWeighted((*it)->momentum().vect().mag()/Emax, eventweight);
+ break;
+ case ParticleID::phi:
+ _xpphi ->addWeighted((*it)->momentum().vect().mag()/Emax, eventweight);
+ break;
+ case ParticleID::Kstar0:
+ _xpKstar0 ->addWeighted((*it)->momentum().vect().mag()/Emax, eventweight);
+ break;
+ case ParticleID::D0:
+ _xeD0 ->addWeighted( (*it)->momentum().e()/Emax, eventweight);
+ break;
+ case ParticleID::Dstarplus:
+ _xeDstar ->addWeighted( (*it)->momentum().e()/Emax, eventweight);
+ break;
+ case ParticleID::rho0:
+ _xerho0 ->addWeighted( (*it)->momentum().e()/Emax, eventweight);
+ break;
+ case ParticleID::pi0:
+ _xepi0 ->addWeighted( (*it)->momentum().e()/Emax, eventweight);
+ xp = (*it)->momentum().vect().mag()/Emax;
+ _xipi0 ->addWeighted(-log(xp), eventweight);
+ case ParticleID::eta:
+ _xeeta ->addWeighted( (*it)->momentum().e()/Emax, eventweight);
+ xp = (*it)->momentum().vect().mag()/Emax;
+ _xieta ->addWeighted(-log(xp), eventweight);
+ case ParticleID::etaprime:
+ _xeetap ->addWeighted( (*it)->momentum().e()/Emax, eventweight);
+ xp = (*it)->momentum().vect().mag()/Emax;
+ _xietap ->addWeighted(-log(xp), eventweight);
+ case ParticleID::rhoplus:
+ _xerhop ->addWeighted( (*it)->momentum().e()/Emax, eventweight);
+ xp = (*it)->momentum().vect().mag()/Emax;
+ _xirhop ->addWeighted(-log(xp), eventweight);
+ case ParticleID::omega:
+ _xeomega ->addWeighted( (*it)->momentum().e()/Emax, eventweight);
+ xp = (*it)->momentum().vect().mag()/Emax;
+ _xiomega ->addWeighted(-log(xp), eventweight);
+ case ParticleID::a_0plus:
+ _xea_0p ->addWeighted( (*it)->momentum().e()/Emax, eventweight);
+ xp = (*it)->momentum().vect().mag()/Emax;
+ _xia_0p ->addWeighted(-log(xp), eventweight);
+ case ParticleID::K0:
+ case ParticleID::K_S0:
+ case ParticleID::K_L0:
+ _xpK0->addWeighted((*it)->momentum().vect().mag()/Emax, eventweight);
+ }
+ }
+}
+
+// void MyIdentifiedParticleAnalysis::persistentOutput(PersistentOStream & os) const {
+// os << _shapes;
+// }
+
+// void MyIdentifiedParticleAnalysis::persistentInput(PersistentIStream & is, int) {
+// is >> _shapes;
+// }
+
+NoPIOClassDescription<MyIdentifiedParticleAnalysis>
+MyIdentifiedParticleAnalysis::initMyIdentifiedParticleAnalysis;
+// Definition of the static class description member.
+
+void MyIdentifiedParticleAnalysis::Init() {
+
+ static ClassDocumentation<MyIdentifiedParticleAnalysis> documentation
+ ("The MyIdentifiedParticleAnalysis class compares identified particle spectra with Z"
+ " pole data");
+
+// static Reference<MyIdentifiedParticleAnalysis,MyEventShapes> interfaceMyEventShapes
+// ("MyEventShapes",
+// "Pointer to the object which calculates the event shapes",
+// &MyIdentifiedParticleAnalysis::_shapes, false, false, true, false, false);
+}
+
+
+void MyIdentifiedParticleAnalysis::dofinish() {
+ AnalysisHandler::dofinish();
+ string fname = generator()->filename()
+ + string("-") + name() + string(".top");
+ ofstream output(fname.c_str());
+ // chisq
+ double chisq,minfrac=0.05;
+ unsigned int npoint;
+ using namespace HistogramOptions;
+ // Histogram for the \f$\xi\f$ distribution for all particles from all quarks
+ _xpa->normaliseToData();
+ _xpa->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for SLD xp (charged, all quarks) "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xpa->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum of charged particles for all events(SLD)",
+ " ",
+ "1/NdN/dx0p1",
+ " X X",
+ "x0p1",
+ " X X");
+ // light quarks
+ _xpl->normaliseToData();
+ _xpl->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for SLD xp (charged, light quarks) "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xpl->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum of charged particles for all light quark events(SLD)",
+ " ",
+ "1/NdN/dx0p1",
+ " X X",
+ "x0p1",
+ " X X");
+ // OPAL
+ _udsxp->normaliseToData();
+ _udsxp->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL xp (charged, light quarks) "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _udsxp->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum of charged particles for all light quark events(OPAL)",
+ " ",
+ "1/NdN/dx0p1",
+ " X X",
+ "x0p1",
+ " X X");
+ _udsxip->normaliseToData();
+ _udsxip->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL xi (charged, light quarks) "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _udsxip->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum of charged particles for all light quark events(OPAL)",
+ " ",
+ "1/NdN/dX",
+ " G",
+ "X",
+ "G");
+ // charm
+ _xpc->normaliseToData();
+ _xpc->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for SLD xp (charged, charm quarks) "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xpc->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum of charged particles for all charm events(SLD)",
+ " ",
+ "1/NdN/dx0p1",
+ " X X",
+ "x0p1",
+ " X X");
+ // bottom
+ _xpb->normaliseToData();
+ _xpb->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for SLD xp (charged, bottom quarks) "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xpb->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum of charged particles for all bottom events(SLD)",
+ " ",
+ "1/NdN/dx0p1",
+ " X X",
+ "x0p1",
+ " X X");
+ // pions all quarks
+ _pipma->normaliseToData();
+ _pipma->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for SLD xp (pions, all quarks) "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _pipma->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum of pions for all events(SLD)",
+ " ",
+ "1/NdN/dx0p1",
+ " X X",
+ "x0p1",
+ " X X");
+ // OPAL pions
+ _pipm->normaliseToData();
+ _pipm->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL momentum (pions, all quarks) "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _pipm->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The momentum of pions for all events(OPAL)",
+ " ",
+ "1/NdN/dp/GeV2-13",
+ " X X",
+ "p/GeV",
+ " ");
+ // light
+ _pipml->normaliseToData();
+ _pipml->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for SLD xp (pions, light quarks) "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _pipml->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum of pions for light quark events(SLD)",
+ " ",
+ "1/NdN/dx0p1",
+ " X X",
+ "x0p1",
+ " X X");
+ // charm
+ _pipmc->normaliseToData();
+ _pipmc->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for SLD xp (pions, charm quarks) "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _pipmc->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum of pions for charm events(SLD)",
+ " ",
+ "1/NdN/dx0p1",
+ " X X",
+ "x0p1",
+ " X X");
+ // bottom
+ _pipmb->normaliseToData();
+ _pipmb->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for SLD xp (pions, bottom quarks) "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _pipmb->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum of pions for bottom quark events(SLD)",
+ " ",
+ "1/NdN/dx0p1",
+ " X X",
+ "x0p1",
+ " X X");
+ // kaons all quarks
+ _kpma->normaliseToData();
+ _kpma->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for SLD xp (kaons, all quakrks) "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _kpma->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum of kaons for all events(SLD)",
+ " ",
+ "1/NdN/dx0p1",
+ " X X",
+ "x0p1",
+ " X X");
+ // OPAL kaons
+ _kpm->normaliseToData();
+ _kpm->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL momentum (kaons, all quarks) "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _kpm->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The momentum of kaons for all events(OPAL)",
+ " ",
+ "1/NdN/dp/GeV2-13",
+ " X X",
+ "p/GeV",
+ " ");
+ // light
+ _kpml->normaliseToData();
+ _kpml->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for SLD xp (kaons, light quarks) "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _kpml->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum of kaons for light quark events(SLD)",
+ " ",
+ "1/NdN/dx0p1",
+ " X X",
+ "x0p1",
+ " X X");
+ // charm
+ _kpmc->normaliseToData();
+ _kpmc->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for SLD xp (kaons, charm quarks) "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _kpmc->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum of kaons for charm events(SLD)",
+ " ",
+ "1/NdN/dx0p1",
+ " X X",
+ "x0p1",
+ " X X");
+ // bottom
+ _kpmb->normaliseToData();
+ _kpmb->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for SLD xp (kaons, bottom quarks) "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _kpmb->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum of kaons for bottom quark events(SLD)",
+ " ",
+ "1/NdN/dx0p1",
+ " X X",
+ "x0p1",
+ " X X");
+ // protons all quarks
+ _ppma->normaliseToData();
+ _ppma->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for SLD xp (protons, all quarks) "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _ppma->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum of protons for all events(SLD)",
+ " ",
+ "1/NdN/dx0p1",
+ " X X",
+ "x0p1",
+ " X X");
+ // OPAL protons
+ _ppm->normaliseToData();
+ _ppm->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL momentum (protons, all quarks ) "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _ppm->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The momentum of protons for all events(OPAL)",
+ " ",
+ "1/NdN/dpGeV2-13",
+ " X X",
+ "p/GeV",
+ " ");
+ // light
+ _ppml->normaliseToData();
+ _ppml->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for SLD xp (protons, light quarks) "
+ << "distribution or " << chisq/npoint << "per degree of freedom\n";
+ _ppml->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum of protons for light quark events(SLD)",
+ " ",
+ "1/NdN/dx0p1",
+ " X X",
+ "x0p1",
+ " X X");
+ // charm
+ _ppmc->normaliseToData();
+ _ppmc->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for SLD xp (protons, charm quarks) "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _ppmc->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum of protons for charm events(SLD)",
+ " ",
+ "1/NdN/dx0p1",
+ " X X",
+ "x0p1",
+ " X X");
+ // bottom
+ _ppmb->normaliseToData();
+ _ppmb->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for SLD xp (protons, bottom quarks) "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _ppmb->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum of protons for bottom quark events(SLD)",
+ " ",
+ "1/NdN/dx0p1",
+ " X X",
+ "x0p1",
+ " X X");
+ // lambda
+ _lpm->normaliseToData();
+ _lpm->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for ALEPH momentum (lambda, all quarks) "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _lpm->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum of L for all events (ALEPH)",
+ " F ",
+ "1/NdN/dp/GeV2-13",
+ " X X",
+ "p/GeV",
+ " ");
+ // K*+
+ _xpKstarplus->normaliseToData();
+ _xpKstarplus->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for ALEPH momentum K*+ "
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xpKstarplus->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum of K2*+3 for all events (ALEPH)",
+ " X X ",
+ "1/NdN/dx0p1",
+ " X X",
+ "x0p1",
+ " X X");
+ // xi-
+ _xpXiminus->normaliseToData();
+ _xpXiminus->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL xi- x_E"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xpXiminus->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum x0E1 of X2-3 for all events (OPAL)",
+ " X X FX X ",
+ "1/NdN/dx0E1",
+ " X X",
+ "x0E1",
+ " X X");
+ _xiXiminus->normaliseToData();
+ _xiXiminus->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL xi- xi"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xiXiminus->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum X of X2-3 for all events (OPAL)",
+ " G FX X ",
+ "1/NdN/dX",
+ " G",
+ "X",
+ "G");
+ // Sigma*+
+ _xpSigmaplus->normaliseToData();
+ _xpSigmaplus->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL Sigma*+ x_E"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xpSigmaplus->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum x0E1 of S2*+3 for all events (OPAL)",
+ " X X FX X ",
+ "1/NdN/dx0E1",
+ " X X",
+ "x0E1",
+ " X X");
+ _xiSigmaplus->normaliseToData();
+ _xiSigmaplus->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL Sigma*+ xi"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xiSigmaplus->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum X of S2*+3 for all events (OPAL)",
+ " G FX X ",
+ "1/NdN/dX",
+ " G",
+ "X",
+ "G");
+ // Sigma*-
+ _xpSigmaminus->normaliseToData();
+ _xpSigmaminus->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL Sigma*- x_E"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xpSigmaminus->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum x0E1 of S2*-3 for all events (OPAL)",
+ " X X FX X ",
+ "1/NdN/dx0E1",
+ " X X",
+ "x0E1",
+ " X X");
+ _xiSigmaminus->normaliseToData();
+ _xiSigmaminus->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL Sigma*- xi"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xiSigmaminus->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum X of S2*-3 for all events (OPAL)",
+ " G FX X ",
+ "1/NdN/dX",
+ " G",
+ "X",
+ "G");
+ // Xi*0
+ _xpXi0->normaliseToData();
+ _xpXi0->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL Xi*0 x_E"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xpXi0->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum x0E1 of X2*03 for all events (OPAL)",
+ " X X FX X ",
+ "1/NdN/dx0E1",
+ " X X",
+ "x0E1",
+ " X X");
+ _xiXi0->normaliseToData();
+ _xiXi0->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL Xi*0 xi"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xiXi0->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum X of X2*03 for all events (OPAL)",
+ " G FX X ",
+ "1/NdN/dX",
+ " G",
+ "X",
+ "G");
+ // lambda(1520)
+ _xpLambda1520->normaliseToData();
+ _xpLambda1520->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL Lambda(1520) x_E"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xpLambda1520->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum x0E1 of L(1520) for all events (OPAL)",
+ " X X F ",
+ "1/NdN/dx0E1",
+ " X X",
+ "x0E1",
+ " X X");
+ _xiLambda1520->normaliseToData();
+ _xiLambda1520->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL Lambda(1520) xi"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xiLambda1520->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum X of L(1520) for all events (OPAL)",
+ " G F ",
+ "1/NdN/dX",
+ " G",
+ "X",
+ "G");
+ // Delta++
+ _xeDelta->normaliseToData();
+ _xeDelta->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL Delta++ x_E"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xeDelta->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum x0E1 of D2++3 for all events (OPAL)",
+ " X X FX X ",
+ "1/NdN/dx0E1",
+ " X X",
+ "x0E1",
+ " X X");
+ // f_0
+ _xpf980->normaliseToData();
+ _xpf980->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL f_0(980) x_p"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xpf980->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum x0p1 of f001(980) for all events (OPAL)",
+ " X X X X ",
+ "1/NdN/dx0p1",
+ " X X",
+ "x0p1",
+ " X X");
+ // f_2
+ _xpf2->normaliseToData();
+ _xpf2->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL f_2 x_p"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xpf2->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum x0p1 of f021 for all events (OPAL)",
+ " X X X X ",
+ "1/NdN/dx0p1",
+ " X X",
+ "x0p1",
+ " X X");
+ // phi
+ _xpphi->normaliseToData();
+ _xpphi->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL phi x_p"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xpphi->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum x0p1 of F for all events (OPAL)",
+ " X X G ",
+ "1/NdN/dx0p1",
+ " X X",
+ "x0p1",
+ " X X");
+ // K*0
+ _xpKstar0->normaliseToData();
+ _xpKstar0->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL K*0 x_p"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xpKstar0->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum x0p1 of K2*03 for all events (OPAL)",
+ " X X X X ",
+ "1/NdN/dx0p1",
+ " X X",
+ "x0p1",
+ " X X");
+ // K0
+ _xpK0->normaliseToData();
+ _xpK0->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL K0 x_p"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xpK0->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum x0p1 of K203 for all events (OPAL)",
+ " X X X X ",
+ "1/NdN/dx0p1",
+ " X X",
+ "x0p1",
+ " X X");
+ // rho0
+ _xerho0->normaliseToData();
+ _xerho0->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for DELPHI rho0 x_E"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xerho0->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum x0E1 of R203 for all events (DELPHI)",
+ " X X GX X ",
+ "1/NdN/dx0E1",
+ " X X",
+ "x0E1",
+ " X X");
+ // pi0
+ _xepi0->normaliseToData();
+ _xepi0->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL pi0 x_E"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xepi0->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum x0E1 of P203 for all events (OPAL)",
+ " X X GX X ",
+ "1/NdN/dx0E1",
+ " X X",
+ "x0E1",
+ " X X");
+ _xipi0->normaliseToData();
+ _xipi0->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL pi0 xi"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xipi0->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum X of P203 for all events (OPAL)",
+ " G GX X ",
+ "1/NdN/dX",
+ " G",
+ "X",
+ "G");
+ // eta
+ _xeeta->normaliseToData();
+ _xeeta->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL eta x_E"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xeeta->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum x0E1 of H for all events (OPAL)",
+ " X X G ",
+ "1/NdN/dx0E1",
+ " X X",
+ "x0E1",
+ " X X");
+ _xieta->normaliseToData();
+ _xieta->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL eta xi"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xieta->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum X of H for all events (OPAL)",
+ " G G ",
+ "1/NdN/dX",
+ " G",
+ "X",
+ "G");
+ // eta'
+ _xeetap->normaliseToData();
+ _xeetap->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL eta' x_E"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xeetap->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum x0E1 of H' for all events (OPAL)",
+ " X X G ",
+ "1/NdN/dx0E1",
+ " X X",
+ "x0E1",
+ " X X");
+ _xietap->normaliseToData();
+ _xietap->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL eta' xi"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xietap->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum X of H' for all events (OPAL)",
+ " G G ",
+ "1/NdN/dX",
+ " G",
+ "X",
+ "G");
+ // rho+
+ _xerhop->normaliseToData();
+ _xerhop->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL rho+ x_E"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xerhop->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum x0E1 of R2+3 for all events (OPAL)",
+ " X X GX X ",
+ "1/NdN/dx0E1",
+ " X X",
+ "x0E1",
+ " X X");
+ _xirhop->normaliseToData();
+ _xirhop->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL rho+ xi"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xirhop->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum X of R2+3 for all events (OPAL)",
+ " G GX X ",
+ "1/NdN/dX",
+ " G",
+ "X",
+ "G");
+ // omega
+ _xeomega->normaliseToData();
+ _xeomega->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL omega x_E"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xeomega->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum x0E1 of W for all events (OPAL)",
+ " X X G ",
+ "1/NdN/dx0E1",
+ " X X",
+ "x0E1",
+ " X X");
+ _xiomega->normaliseToData();
+ _xiomega->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL omega xi"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xiomega->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum X of W for all events (OPAL)",
+ " G G ",
+ "1/NdN/dX",
+ " G",
+ "X",
+ "G");
+ // a_0+
+ _xea_0p->normaliseToData();
+ _xea_0p->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL a_0+ x_E"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xea_0p->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum x0E1 of A0012+3 for all events (OPAL)",
+ " X X X XX X ",
+ "1/NdN/dx0E1",
+ " X X",
+ "x0E1",
+ " X X");
+ _xia_0p->normaliseToData();
+ _xia_0p->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL a_0+ xi"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xia_0p->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum X of A0012+3 for all events (OPAL)",
+ " G X XX X ",
+ "1/NdN/dX",
+ " G",
+ "X",
+ "G");
+ // D0
+ _xeD0->normaliseToData();
+ _xeD0->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for DELPHI D0 x_E"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xeD0->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum x0E1 of D203 for all events (DELPHI)",
+ " X X X X ",
+ "1/NdN/dx0E1",
+ " X X",
+ "x0E1",
+ " X X");
+ // D*+
+ _xeDstar->normaliseToData();
+ _xeDstar->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for ALEPH Dstar x_E"
+ << "distribution or " << chisq/npoint << " per degree of freedom\n";
+ _xeDstar->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "The scaled momentum x0E1 of D2*+3 for all events (ALEPH)",
+ " X X X X ",
+ "1/NdN/dx0E1",
+ " X X",
+ "x0E1",
+ " X X");
+}
+
+void MyIdentifiedParticleAnalysis::doinitrun() {
+ AnalysisHandler::doinitrun();
+ // SLD data (all charged)
+ double xpbins[] = {0.005, 0.008, 0.010, 0.012, 0.014,
+ 0.016, 0.022, 0.027, 0.033, 0.038,
+ 0.044, 0.049, 0.055, 0.060, 0.066,
+ 0.071, 0.077, 0.082, 0.088, 0.099,
+ 0.110, 0.121, 0.143, 0.164, 0.186,
+ 0.208, 0.230, 0.252, 0.274, 0.296,
+ 0.318, 0.351, 0.384, 0.417, 0.450,
+ 0.482, 0.526, 0.570, 0.658, 0.768,
+ 1.000};
+ double xpdataa[]={509.2 ,513.9 ,485.5 ,443.4 ,398.7 ,
+ 335.8 ,267.2 ,217.8 ,180.7 ,153.2 ,
+ 130.6 ,113.4 , 99.09 , 87.57 , 77.56 ,
+ 69.78 , 62.84 , 56.72 , 48.90 , 40.78 ,
+ 34.39 , 27.35 , 20.53 , 15.64 , 12.25 ,
+ 9.67 , 7.75 , 6.161 , 5.029 , 4.053 ,
+ 3.139 , 2.338 , 1.748 , 1.326 , 1.008 ,
+ 0.724 , 0.480 , 0.285 , 0.114 , 0.024 };
+ double xperrora[]={9.5 ,7.8 ,6.6 ,5.6 ,4.9 ,
+ 3.9 ,2.9 ,2.3 ,1.9 ,1.6 ,
+ 1.4 ,1.2 ,1.03 ,0.91 ,0.81 ,
+ 0.73 ,0.66 ,0.60 ,0.51 ,0.43 ,
+ 0.37 ,0.29 ,0.23 ,0.18 ,0.15 ,
+ 0.12 ,0.11 ,0.088,0.076,0.065,
+ 0.052,0.042,0.034,0.028,0.023,
+ 0.018,0.013,0.009,0.005,0.001};
+ double xpdatal[] ={507.8 ,505.2 ,465.3 ,421.9 ,371.7 ,
+ 315.5 ,250.5 ,200.3 ,167.3 ,140.4 ,
+ 121.2 ,105.5 , 91.2 ,81.29 ,72.69 ,
+ 65.92 ,58.06 ,53.26 ,45.37 ,38.55 ,
+ 32.84 ,26.05 ,19.79 ,15.75 ,12.16 ,
+ 10.27 , 8.14 , 6.62 ,5.565 ,4.428 ,
+ 3.588 ,2.706 ,2.062 ,1.631 ,1.193 ,
+ 0.912 ,0.632 ,0.398 ,0.172 ,0.027};
+ double xperrorl[]={ 11.9 , 9.2 , 7.5 , 6.3 , 5.8 ,
+ 4.2 , 3.2 , 2.3 , 2.0 , 1.6 ,
+ 1.3 , 1.1 , 1.0 , 0.89 , 0.81 ,
+ 0.76 , 0.70 , 0.66 , 0.48 , 0.43 ,
+ 0.41 , 0.28 , 0.29 , 0.35 , 0.17 ,
+ 0.14 , 0.11 , 0.10 ,0.087 ,0.076 ,
+ 0.057 ,0.049 ,0.042 ,0.037 ,0.034 ,
+ 0.026 ,0.023 ,0.015 ,0.011 ,0.005 };
+ double xpdatac[] ={468.7 ,485.4 ,507.2 ,464.0 ,422.9 ,
+ 349.1 ,274.1 ,231.5 ,187.5 ,162.3 ,
+ 136.6 ,117.3 , 99.1 ,89.21 ,78.25 ,
+ 69.26 ,62.25 ,55.28 ,49.14 ,40.11 ,
+ 35.64 ,28.94 ,21.99 ,16.51 ,12.69 ,
+ 10.41 , 7.86 , 6.37 ,5.060 ,4.080 ,
+ 3.123 ,2.141 ,1.472 ,0.952 ,0.935 ,
+ 0.485 ,0.372 ,0.140 ,0.027 ,0.011};
+ double xperrorc[]={25.3, 22.6, 20.2, 17.6, 16.9,
+ 12.7, 9.5, 7.3, 6.9, 5.2,
+ 4.2, 3.6, 3.0, 2.65, 2.42,
+ 2.23, 2.06, 1.93, 1.42, 1.29,
+ 1.22, 0.83, 0.86, 1.03, 0.50,
+ 0.40, 0.32, 0.28,0.241,0.210,
+ 0.156,0.126,0.106,0.090,0.085,
+ 0.061,0.055,0.031,0.016,0.010};
+ double xpdatab[] ={546.1 ,558.5 ,531.9 ,490.8 ,436.5 ,
+ 382.8 ,308.6 ,254.8 ,213.2 ,182.1 ,
+ 154.5 ,134.3 ,118.6 ,102.4 ,91.92 ,
+ 83.63 ,75.06 ,66.58 ,57.31 ,47.80 ,
+ 39.19 ,29.54 ,20.69 ,15.36 ,10.65 ,
+ 8.06 , 6.28 , 4.69 ,3.490 ,2.935 ,
+ 2.041 ,1.534 ,1.111 ,0.736 ,0.510 ,
+ 0.330 ,0.188 ,0.089 ,0.017 ,0.003};
+ double xperrorb[]={ 14.2, 10.3, 8.0, 6.3, 6.7,
+ 4.4, 3.4, 2.6, 2.1, 1.9,
+ 1.7, 1.6, 1.4, 1.3, 1.22,
+ 1.14, 1.10, 1.04, 0.74, 0.71,
+ 0.67, 0.48, 0.48, 0.55, 0.26,
+ 0.20, 0.16, 0.13,0.110,0.098,
+ 0.068,0.058,0.051,0.042,0.037,
+ 0.027,0.022,0.012,0.006,0.002};
+ vector<double> bins =vector<double>(xpbins,xpbins+41);
+ vector<double> data =vector<double>(xpdataa,xpdataa+40);
+ vector<double> error=vector<double>(xperrora,xperrora+40);
+ _xpa=new_ptr(Histogram(bins,data,error));
+ data =vector<double>(xpdatal,xpdatal+40);
+ error=vector<double>(xperrorl,xperrorl+40);
+ _xpl=new_ptr(Histogram(bins,data,error));
+ data =vector<double>(xpdatac,xpdatac+40);
+ error=vector<double>(xperrorc,xperrorc+40);
+ _xpc=new_ptr(Histogram(bins,data,error));
+ data =vector<double>(xpdatab,xpdatab+40);
+ error=vector<double>(xperrorb,xperrorb+40);
+ _xpb=new_ptr(Histogram(bins,data,error));
+ // SLD pions data
+ double pipmbins[] = {0.005, 0.008, 0.010, 0.012, 0.014,
+ 0.016, 0.022, 0.027, 0.033, 0.038,
+ 0.044, 0.049, 0.055, 0.060, 0.066,
+ 0.071, 0.077, 0.082, 0.088, 0.099,
+ 0.110, 0.121, 0.143, 0.164, 0.186,
+ 0.208, 0.230, 0.252, 0.274, 0.296,
+ 0.318, 0.351, 0.384, 0.417, 0.450,
+ 0.482, 0.526, 0.570, 0.658, 0.768,
+ 1.000};
+ double pipmdataa[]={ 471.8 , 470.4 , 434.6 , 388.8 , 352.7 ,
+ 294.8 , 229.6 , 185.0 , 150.6 , 125.6 ,
+ 106.5 , 90.40 , 77.38 , 67.39 , 59.40 ,
+ 52.57 , 46.76 , 41.70 , 35.26 , 28.89 ,
+ 23.88 , 18.69 , 13.85 , 10.16 , 7.812 ,
+ 6.076 , 4.674 , 3.632 , 2.886 , 2.292 ,
+ 1.749 , 1.275 , 0.921 , 0.680 , 0.499 ,
+ 0.338 , 0.226 , 0.130 ,0.0526 ,0.0113 };
+ double pipmerrorastat[]={1.3, 1.1, 1.1, 1.0, 0.9,
+ 0.5, 0.5, 0.4, 0.4, 0.4,
+ 0.4, 0.35, 0.31, 0.29, 0.27,
+ 0.25, 0.24, 0.23, 0.15, 0.13,
+ 0.12, 0.08, 0.07, 0.06, 0.050,
+ 0.044, 0.039, 0.035, 0.031, 0.028,
+ 0.021, 0.018, 0.016, 0.014, 0.013,
+ 0.010, 0.009, 0.005, 0.0037, 0.0018};
+ double pipmerrorasytm[]={9.2, 6.6, 5.0, 4.0, 3.3,
+ 2.2, 1.3, 0.9, 0.7, 0.9,
+ 1.1, 1.33, 0.91, 0.70, 0.75,
+ 0.60, 0.50, 0.43, 0.36, 0.29,
+ 0.25, 0.19, 0.14, 0.11, 0.069,
+ 0.061, 0.053, 0.044, 0.037, 0.031,
+ 0.034, 0.028, 0.022, 0.018, 0.014,
+ 0.010, 0.007, 0.005, 0.0029, 0.0013};
+ double pipmdatal[] ={474.0 , 467.3 , 418.2 , 375.5 , 327.7 ,
+ 275.8 , 216.0 , 171.2 , 140.4 , 116.4 ,
+ 99.9 , 85.4 , 72.85 , 64.51 , 56.82 ,
+ 50.84 , 45.34 , 40.71 , 34.60 , 28.99 ,
+ 24.19 , 18.97 , 14.52 , 11.06 , 8.67 ,
+ 6.79 , 5.341 , 4.214 , 3.452 , 2.727 ,
+ 2.138 , 1.652 , 1.164 , 0.874 , 0.622 ,
+ 0.441 , 0.300 , 0.178 , 0.081 , 0.016};
+ double pipmerrorlstat[]={13.9 , 10.5 , 8.4 , 6.9 , 5.7 ,
+ 4.2 , 3.0 , 2.2 , 1.9 , 1.5 ,
+ 1.2 , 1.0 , 0.89 , 0.79 , 0.72 ,
+ 0.66 , 0.61 , 0.56 , 0.40 , 0.35 ,
+ 0.31 , 0.22 , 0.17 , 0.14 , 0.12 ,
+ 0.10 ,0.085 ,0.073 ,0.064 ,0.056 ,
+ 0.042 ,0.036 ,0.031 ,0.027 ,0.024 ,
+ 0.019 ,0.017 ,0.010 ,0.007 ,0.003};
+ double pipmerrorlsytm[]={0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
+ 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
+ 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
+ 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
+ double pipmdatac[] ={425.5 , 440.5 , 453.8 , 409.2 , 372.8 ,
+ 306.4 , 234.6 , 197.4 , 155.8 , 132.5 ,
+ 109.3 , 92.9 , 77.56 , 68.23 , 60.06 ,
+ 51.76 , 45.28 , 40.04 , 33.50 , 27.45 ,
+ 22.92 , 18.73 , 13.72 , 10.18 , 7.53 ,
+ 5.76 , 4.381 , 3.358 , 2.487 , 1.947 ,
+ 1.436 , 0.817 , 0.614 , 0.386 , 0.429 ,
+ 0.206 , 0.142 , 0.066 , 0.003 , 0.003};
+ double pipmerrorcstat[]={26.6 , 23.2 , 20.0 , 17.2 , 14.6 ,
+ 10.9 , 8.0 , 6.2 , 6.0 , 4.3 ,
+ 3.5 , 2.9 , 2.48 , 2.17 , 1.97 ,
+ 1.81 , 1.67 , 1.55 , 1.12 , 0.99 ,
+ 0.87 , 0.63 , 0.50 , 0.41 , 0.34 ,
+ 0.29 ,0.235 ,0.202 ,0.171 ,0.148 ,
+ 0.108 ,0.087 ,0.074 ,0.063 ,0.061 ,
+ 0.043 ,0.037 ,0.021 ,0.010 ,0.006};
+ double pipmerrorcsytm[]={0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
+ 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
+ 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
+ 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
+ double pipmdatab[] ={478.1 ,488.4 ,463.7 ,432.2 ,382.4 ,
+ 333.3 ,261.7 ,214.2 ,175.2 ,145.4 ,
+ 121.4 ,103.3 ,89.24 ,75.47 ,65.97 ,
+ 59.39 ,52.11 ,45.86 ,38.29 ,30.57 ,
+ 24.34 ,18.21 ,12.27 , 8.25 , 5.83 ,
+ 4.14 ,2.984 ,2.303 ,1.642 ,1.365 ,
+ 0.886 ,0.631 ,0.490 ,0.276 ,0.187 ,
+ 0.111 ,0.045 ,0.039 ,0.011 ,0.003};
+ double pipmerrorbstat[]={15.8, 11.9, 9.5, 7.7, 6.5,
+ 4.6, 3.3, 2.7, 2.3, 1.9,
+ 1.7, 1.5, 1.36, 1.21, 1.12,
+ 1.04, 0.97, 0.90, 0.65, 0.58,
+ 0.51, 0.36, 0.28, 0.22, 0.18,
+ 0.15, 0.128, 0.110, 0.094, 0.085,
+ 0.063, 0.052, 0.047, 0.038, 0.033,
+ 0.025, 0.019, 0.010, 0.005, 0.002};
+ double pipmerrorbsytm[]={0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
+ double pipmerrora[40],pipmerrorl[40],pipmerrorc[40],pipmerrorb[40];
+ for(unsigned int ix=0;ix<40;++ix) {
+ pipmerrora[ix]=sqrt(sqr(pipmerrorastat[ix])+sqr(pipmerrorasytm[ix]));
+ pipmerrorl[ix]=sqrt(sqr(pipmerrorlstat[ix])+sqr(pipmerrorlsytm[ix]));
+ pipmerrorc[ix]=sqrt(sqr(pipmerrorcstat[ix])+sqr(pipmerrorcsytm[ix]));
+ pipmerrorb[ix]=sqrt(sqr(pipmerrorbstat[ix])+sqr(pipmerrorbsytm[ix]));
+ }
+ bins =vector<double>(pipmbins,pipmbins+41);
+ data =vector<double>(pipmdataa,pipmdataa+40);
+ error=vector<double>(pipmerrora,pipmerrora+40);
+ _pipma=new_ptr(Histogram(bins,data,error));
+ data =vector<double>(pipmdatal,pipmdatal+40);
+ error=vector<double>(pipmerrorl,pipmerrorl+40);
+ _pipml=new_ptr(Histogram(bins,data,error));
+ data =vector<double>(pipmdatac,pipmdatac+40);
+ error=vector<double>(pipmerrorc,pipmerrorc+40);
+ _pipmc=new_ptr(Histogram(bins,data,error));
+ data =vector<double>(pipmdatab,pipmdatab+40);
+ error=vector<double>(pipmerrorb,pipmerrorb+40);
+ _pipmb=new_ptr(Histogram(bins,data,error));
+ // opal pion data
+ double pibinso[] = {0.227, 0.239, 0.251, 0.263, 0.276,
+ 0.290, 0.305, 0.320, 0.336, 0.353,
+ 0.371, 0.390, 0.410, 0.431, 0.453,
+ 0.476, 0.500, 0.525, 0.552, 0.580,
+ 0.610, 0.641, 0.673, 0.708, 0.744,
+ 0.782, 0.822, 0.864, 2.02, 2.12,
+ 2.23,
+ 2.34, 2.59, 2.72, 2.86, 3.01,
+ 3.16, 3.32, 3.49, 3.67, 3.86,
+ 4.06, 4.95, 6.05, 7.39, 9.02,
+ 11.02, 13.46, 16.44, 20.08, 29.95,
+ 45.60};
+ double pidatao[]={ 9.89 , 9.98 , 10.37 , 10.38 , 10.42 ,
+ 10.40 , 10.53 , 10.66 , 10.53 , 10.56 ,
+ 10.46 , 10.23 , 10.29 , 10.02 , 9.83 ,
+ 9.62 , 9.46 , 9.23 , 9.05 , 8.71 ,
+ 8.40 , 8.12 , 7.87 , 7.50 , 7.26 ,
+ 6.95 , 6.56 , 0.0 , 2.374 , 2.264 ,
+ 2.103 , 1.944 , 1.672 , 1.550 , 1.420 ,
+ 1.328 , 1.221 , 1.115 , 1.035 , 0.955 ,
+ 0.879 , 0.705 , 0.478 , 0.319 , 0.2052 ,
+ 0.1246 , 0.0717 , 0.0386 , 0.0206 , 0.0058 ,
+ 0.0006 };
+ double pierrorostat[]={0.07 ,0.07 ,0.07 ,0.07 ,0.07 ,
+ 0.07 ,0.06 ,0.06 ,0.06 ,0.06 ,
+ 0.06 ,0.06 ,0.06 ,0.05 ,0.05 ,
+ 0.05 ,0.05 ,0.05 ,0.05 ,0.04 ,
+ 0.04 ,0.04 ,0.04 ,0.04 ,0.03 ,
+ 0.03 ,0.04 ,0.0 ,0.031 ,0.013 ,
+ 0.018 ,0.010 ,0.009 ,0.013 ,0.008 ,
+ 0.008 ,0.008 ,0.007 ,0.007 ,0.006 ,
+ 0.006 ,0.003 ,0.002 ,0.001 ,0.0012,
+ 0.0008,0.0006,0.0005,0.0004,0.0001,
+ 0.0001};
+ double pierrorosyst[]={0.29 ,0.29 ,0.31 ,0.31 ,0.31 ,
+ 0.31 ,0.31 ,0.31 ,0.31 ,0.31 ,
+ 0.31 ,0.30 ,0.30 ,0.29 ,0.29 ,
+ 0.28 ,0.28 ,0.27 ,0.26 ,0.25 ,
+ 0.25 ,0.24 ,0.23 ,0.22 ,0.21 ,
+ 0.20 ,0.20 ,0.0,0.209 ,0.079 ,
+ 0.036 ,0.027 ,0.024 ,0.024 ,0.022 ,
+ 0.019 ,0.017 ,0.015 ,0.015 ,0.014 ,
+ 0.012 ,0.009 ,0.007 ,0.005 ,0.0032 ,
+ 0.0024 ,0.0016 ,0.0012 ,0.0013 ,0.0004 ,
+ 0.0002 };
+ double pierroro[51];
+ for(unsigned int ix=0;ix<51;++ix)
+ {pierroro[ix]=sqrt(sqr(pierrorostat[ix])+sqr(pierrorosyst[ix]));}
+ bins =vector<double>(pibinso,pibinso+52);
+ data =vector<double>(pidatao,pidatao+51);
+ error=vector<double>(pierroro,pierroro+51);
+ _pipm=new_ptr(Histogram(bins,data,error));
+ // SLD kaons
+ double Kbins[] = {0.014, 0.016, 0.022, 0.027, 0.033,
+ 0.038, 0.044, 0.049, 0.055, 0.060,
+ 0.066, 0.071, 0.077, 0.082, 0.088,
+ 0.099, 0.110, 0.121, 0.143, 0.164,
+ 0.186, 0.208, 0.230, 0.252, 0.274,
+ 0.296, 0.318, 0.351, 0.384, 0.417,
+ 0.450, 0.482, 0.526, 0.570, 0.658,
+ 0.768, 1.000};
+ double Kdataa[]={28.59 , 21.57 , 21.62 , 19.65 , 18.02 ,
+ 17.27 , 15.78 , 14.664 , 13.535 , 12.599 ,
+ 12.036 , 11.349 , 10.207 , 9.571 , 8.671 ,
+ 7.784 , 7.237 , 5.746 , 3.959 , 3.473 ,
+ 2.739 , 2.452 , 1.903 , 1.574 , 1.360 ,
+ 1.118 , 0.890 , 0.683 , 0.567 , 0.433 ,
+ 0.351 , 0.264 , 0.188 , 0.122 , 0.0485 ,
+ 0.0078};
+ double Kerrorastat[]={0.64 , 0.20 , 0.19 , 0.18 , 0.16 ,
+ 0.17 , 0.17 , 0.194 , 0.189 , 0.176 ,
+ 0.165 , 0.162 , 0.164 , 0.160 , 0.113 ,
+ 0.114 , 0.120 , 0.089 , 0.102 , 0.134 ,
+ 0.047 , 0.037 , 0.030 , 0.027 , 0.024 ,
+ 0.022 , 0.016 , 0.014 , 0.013 , 0.012 ,
+ 0.011 , 0.008 , 0.008 , 0.005 , 0.0037 ,
+ 0.0022};
+ double Kerrorasytm[]={9.26, 1.57, 0.80, 0.53, 0.44,
+ 0.43, 0.47, 0.442, 0.503, 0.558,
+ 0.635, 0.622, 0.603, 0.566, 0.505,
+ 0.440, 0.395, 0.369, 0.381, 0.532,
+ 0.419, 0.163, 0.063, 0.036, 0.026,
+ 0.020, 0.017, 0.016, 0.015, 0.014,
+ 0.012, 0.010, 0.008, 0.006, 0.0027,
+ 0.0011};
+ double Kdatal[] ={27.05 , 20.00 , 19.74 , 17.52 , 16.08 ,
+ 15.04 , 13.54 , 11.87 , 11.44 , 10.64 ,
+ 10.24 , 9.67 , 8.13 , 7.98 , 7.00 ,
+ 6.36 , 5.85 , 4.89 , 3.41 , 2.84 ,
+ 2.564 , 2.401 , 1.973 , 1.643 , 1.481 ,
+ 1.211 , 1.001 , 0.746 , 0.666 , 0.559 ,
+ 0.426 , 0.363 , 0.261 , 0.183 , 0.079 ,
+ 0.008};
+ double Kerrorlstat[]={1.27 , 0.42 , 0.40 , 0.37 , 0.37 ,
+ 0.34 , 0.34 , 0.34 , 0.33 , 0.30 ,
+ 0.29 , 0.29 , 0.27 , 0.28 , 0.19 ,
+ 0.19 , 0.20 , 0.15 , 0.17 , 0.22 ,
+ 0.082 ,0.067 ,0.054 ,0.048 ,0.044 ,
+ 0.039 ,0.029 ,0.025 ,0.023 ,0.022 ,
+ 0.020 ,0.016 ,0.015 ,0.010 ,0.007 ,
+ 0.004};
+ double Kerrorlsytm[]={0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
+ 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
+ 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
+ 0.0,0.0,0.0,0.0,0.0,0.0};
+ double Kdatac[] ={30.92 , 22.43 , 22.04 , 20.82 , 16.79 ,
+ 16.68 , 16.46 , 15.81 , 12.62 , 12.24 ,
+ 11.42 , 10.95 , 10.88 , 9.62 , 9.84 ,
+ 8.08 , 8.98 , 6.59 , 5.50 , 5.12 ,
+ 3.850 , 3.087 , 2.074 , 1.960 , 1.681 ,
+ 1.368 , 1.043 , 0.874 , 0.600 , 0.408 ,
+ 0.408 , 0.243 , 0.173 , 0.064 , 0.009 ,
+ 0.008};
+ double Kerrorcstat[]={3.86 , 1.37 , 1.27 , 1.17 , 1.15 ,
+ 1.15 , 1.06 , 1.08 , 0.99 , 0.92 ,
+ 0.87 , 0.85 , 0.84 , 0.81 , 0.59 ,
+ 0.58 , 0.63 , 0.45 , 0.51 , 0.68 ,
+ 0.245 ,0.190 ,0.145 ,0.132 ,0.119 ,
+ 0.104 ,0.076 ,0.068 ,0.058 ,0.050 ,
+ 0.050 ,0.037 ,0.034 ,0.020 ,0.011 ,
+ 0.008};
+ double Kerrorcsytm[]={0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
+ 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
+ 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
+ 0.0,0.0,0.0,0.0,0.0,0.0};
+ double Kdatab[] ={30.21 , 23.06 , 22.89 , 21.64 , 21.36 ,
+ 21.36 , 19.90 , 18.91 , 18.46 , 17.43 ,
+ 16.92 , 15.62 , 15.11 , 13.18 , 12.43 ,
+ 11.56 , 9.96 , 7.17 , 4.58 , 4.20 ,
+ 2.541 , 2.009 , 1.627 , 1.116 , 0.830 ,
+ 0.640 , 0.452 , 0.337 , 0.245 , 0.149 ,
+ 0.108 , 0.057 , 0.061 , 0.012 , 0.002 ,
+ 0.001};
+ double Kerrorbstat[]={1.99 , 0.62 , 0.60 , 0.55 , 0.53 ,
+ 0.56 , 0.57 , 0.60 , 0.58 , 0.54 ,
+ 0.53 , 0.52 , 0.52 , 0.50 , 0.36 ,
+ 0.37 , 0.38 , 0.27 , 0.29 , 0.36 ,
+ 0.126 ,0.096 ,0.078 ,0.062 ,0.053 ,
+ 0.045 ,0.032 ,0.028 ,0.024 ,0.020 ,
+ 0.018 ,0.012 ,0.013 ,0.005 ,0.003 ,
+ 0.001};
+ double Kerrorbsytm[]={0.0 ,0.0 ,0.0 ,0.0 ,0.0 ,0.0 ,0.0 ,0.0 ,0.0 ,0.0 ,
+ 0.0 ,0.0 ,0.0 ,0.0 ,0.0 ,0.0 ,0.0 ,0.0 ,0.0 ,0.0 ,
+ 0.0 ,0.0 ,0.0 ,0.0 ,0.0 ,0.0 ,0.0 ,0.0 ,0.0 ,0.0 ,
+ 0.0 ,0.0 ,0.0 ,0.0 ,0.0 ,0.0};
+ double Kerrora[36],Kerrorl[36],Kerrorc[36],Kerrorb[36];
+ for(unsigned int ix=0;ix<36;++ix)
+ {
+ Kerrora[ix]=sqrt(sqr(Kerrorastat[ix])+sqr(Kerrorasytm[ix]));
+ Kerrorl[ix]=sqrt(sqr(Kerrorlstat[ix])+sqr(Kerrorlsytm[ix]));
+ Kerrorc[ix]=sqrt(sqr(Kerrorcstat[ix])+sqr(Kerrorcsytm[ix]));
+ Kerrorb[ix]=sqrt(sqr(Kerrorbstat[ix])+sqr(Kerrorbsytm[ix]));
+ }
+ bins =vector<double>(Kbins,Kbins+37);
+ data =vector<double>(Kdataa,Kdataa+36);
+ error=vector<double>(Kerrora,Kerrora+36);
+ _kpma=new_ptr(Histogram(bins,data,error));
+ data =vector<double>(Kdatal,Kdatal+36);
+ error=vector<double>(Kerrorl,Kerrorl+36);
+ _kpml=new_ptr(Histogram(bins,data,error));
+ data =vector<double>(Kdatac,Kdatac+36);
+ error=vector<double>(Kerrorc,Kerrorc+36);
+ _kpmc=new_ptr(Histogram(bins,data,error));
+ data =vector<double>(Kdatab,Kdatab+36);
+ error=vector<double>(Kerrorb,Kerrorb+36);
+ _kpmb=new_ptr(Histogram(bins,data,error));
+ // OPAL kaons
+ double Kbinso[] = {0.271, 0.281, 0.292, 0.304, 0.317,
+ 0.331, 0.346, 0.362, 0.379, 0.397,
+ 0.416, 0.436, 0.457, 0.480, 0.504,
+ 0.528, 0.555, 0.583, 0.612, 0.643,
+ 0.675, 0.709, 0.745, 0.783, 4.05,
+ 4.95,
+ 6.05, 7.38, 9.02, 11.01, 13.45,
+ 16.43, 20.06, 29.93, 45.60};
+ double Kdatao[]={0.363 ,0.373 ,0.367 ,0.374 ,0.375 ,
+ 0.410 ,0.431 ,0.418 ,0.456 ,0.499 ,
+ 0.514 ,0.486 ,0.522 ,0.541 ,0.539 ,
+ 0.557 ,0.587 ,0.590 ,0.586 ,0.591 ,
+ 0.614 ,0.597 ,0.613 ,0.0 ,0.181 ,
+ 0.138 ,0.103 ,0.0767,0.0536,0.0349,
+ 0.0220,0.0127,0.0042,0.0004};
+ double Kerrorostat[]={0.030 ,0.027 ,0.024 ,0.022 ,0.021 ,
+ 0.020 ,0.020 ,0.018 ,0.018 ,0.018 ,
+ 0.017 ,0.011 ,0.011 ,0.011 ,0.011 ,
+ 0.011 ,0.011 ,0.010 ,0.010 ,0.010 ,
+ 0.009 ,0.009 ,0.009 ,0.0 ,0.004 ,
+ 0.003 ,0.001 ,0.0010,0.0006,0.0005,
+ 0.0003,0.0003,0.0001,0.0001};
+ double Kerrorosyst[]={0.028 ,0.028 ,0.025 ,0.023 ,0.019 ,
+ 0.019 ,0.019 ,0.020 ,0.016 ,0.017 ,
+ 0.016 ,0.011 ,0.011 ,0.012 ,0.018 ,
+ 0.020 ,0.014 ,0.048 ,0.016 ,0.044 ,
+ 0.024 ,0.025 ,0.031 , 0.0 ,0.015 ,
+ 0.009 ,0.006 ,0.0042,0.0029,0.0018,
+ 0.0012,0.0007,0.0003,0.0001};
+ double Kerroro[34];
+ for(unsigned int ix=0;ix<34;++ix)
+ {Kerroro[ix]=sqrt(sqr(Kerrorostat[ix])+sqr(Kerrorosyst[ix]));}
+ bins =vector<double>(Kbinso,Kbinso+35);
+ data =vector<double>(Kdatao,Kdatao+34);
+ error=vector<double>(Kerroro,Kerroro+34);
+ _kpm=new_ptr(Histogram(bins,data,error));
+ // SLD proton data
+ double pbins[] = {0.014, 0.016, 0.022, 0.027, 0.033,
+ 0.038, 0.044, 0.049, 0.055, 0.060,
+ 0.066, 0.071, 0.077, 0.082, 0.088,
+ 0.099, 0.110, 0.121, 0.143, 0.164,
+ 0.186, 0.208, 0.230, 0.252, 0.274,
+ 0.296, 0.318, 0.351, 0.384, 0.417,
+ 0.450, 0.482, 0.526, 0.570, 0.658,
+ 0.768, 1.000};
+ double pdataa[]={14.51 , 17.32 , 13.75 , 11.12 , 10.75 , 9.048 , 7.669 , 7.410 , 6.587 , 5.788 , 5.344 , 4.987 , 4.278 , 4.117 , 3.633 , 3.036 , 2.568 , 2.165 , 1.931 , 1.603 , 0.871 , 0.912 , 0.775 , 0.639 , 0.511 , 0.419 , 0.358 , 0.254 , 0.173 , 0.141 , 0.0950 , 0.0688 , 0.0470 , 0.0241 , 0.0093 , 0.0015};
+ double perrorastat[]={ 0.52 , 0.27 , 0.29 , 0.17 , 0.14 , 0.123 , 0.117 , 0.113 , 0.109 , 0.105 , 0.100 , 0.104 , 0.100 , 0.101 , 0.072 , 0.076 , 0.081 , 0.069 , 0.096 , 0.133 , 0.045 , 0.030 , 0.025 , 0.022 , 0.019 , 0.016 , 0.011 , 0.009 , 0.008 , 0.007 , 0.0055 , 0.0039 , 0.0032 , 0.0017 , 0.0010 , 0.0003};
+ double perrorasytm[]={5.08, 2.58, 2.50, 1.24, 0.47, 0.350, 0.298, 0.294, 0.259, 0.238, 0.228, 0.229, 0.242, 0.253, 0.269, 0.300, 0.357, 0.398, 0.452, 0.594, 0.255, 0.179, 0.062, 0.044, 0.033, 0.024, 0.018, 0.012, 0.008, 0.005,0.0036,0.0027,0.0018,0.0012,0.0006,0.0001};
+ double pdatal[] ={13.98 , 17.63 , 13.42 , 10.57 , 9.98 , 8.37 , 7.33 , 7.79 , 6.62 , 5.88 , 5.39 , 5.22 , 4.42 , 4.44 , 3.65 , 3.11 , 2.73 , 2.15 , 1.83 , 1.84 , 0.905 , 1.065 , 0.822 , 0.762 , 0.628 , 0.486 , 0.446 , 0.306 , 0.230 , 0.197 , 0.145 , 0.108 , 0.070 , 0.036 , 0.013 , 0.003};
+ double perrorlstat[]={0.99 , 0.58 , 0.60 , 0.36 , 0.31 , 0.26 , 0.24 , 0.23 , 0.22 , 0.20 , 0.19 , 0.19 , 0.18 , 0.19 , 0.13 , 0.13 , 0.15 , 0.12 , 0.16 , 0.24 ,0.078 ,0.054 ,0.044 ,0.038 ,0.033 ,0.029 ,0.022 ,0.018 ,0.015 ,0.013 ,0.011 ,0.008 ,0.006 ,0.003 ,0.002 ,0.001};
+ double perrorlsytm[]={0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
+ double pdatac[] ={13.28, 15.22, 13.32, 9.60, 11.64, 10.07, 8.10, 6.09, 6.54, 6.36, 4.62, 4.43, 4.08, 3.67, 4.07, 2.98, 2.30, 2.39, 1.72, 0.31, 0.561, 0.978, 0.907, 0.652, 0.572, 0.494, 0.454, 0.314, 0.170, 0.103, 0.064, 0.015, 0.044, 0.007, 0.015, 0.001};
+ double perrorcstat[]={ 2.94 , 1.89 , 1.86 , 1.16 , 1.01 , 0.87 , 0.76 , 0.72 , 0.67 , 0.63 , 0.59 , 0.58 , 0.55 , 0.55 , 0.42 , 0.41 , 0.43 , 0.36 , 0.50 , 0.71 , 0.235 , 0.163 , 0.136 , 0.116 , 0.101 , 0.089 , 0.069 , 0.054 , 0.041 , 0.033 , 0.028 , 0.018 , 0.017 , 0.007 , 0.005 , 0.002};
+ double perrorcsytm[]={0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
+ double pdatab[] ={13.79 , 17.93 , 16.41 , 12.11 , 10.32 , 9.52 , 7.72 , 6.86 , 6.19 , 4.96 , 4.82 , 4.57 , 4.07 , 3.82 , 3.29 , 2.68 , 2.24 , 1.84 , 1.91 , 1.25 , 0.867 , 0.739 , 0.645 , 0.392 , 0.252 , 0.266 , 0.146 , 0.102 , 0.020 , 0.034 , 0.004 , 0.016 , 0.003 , 0.004 , 0.001 , 0.000};
+ double perrorbstat[]={1.49 , 0.78 , 0.93 , 0.52 , 0.42 ,
+ 0.40 , 0.36 , 0.32 , 0.32 , 0.29 ,
+ 0.29 , 0.29 , 0.29 , 0.29 , 0.21 ,
+ 0.22 , 0.23 , 0.19 , 0.27 , 0.36 ,
+ 0.121 ,0.072 ,0.060 ,0.047 ,0.038 ,
+ 0.035 ,0.022 ,0.018 ,0.012 ,0.011 ,
+ 0.007 ,0.006 ,0.003 ,0.002 ,0.001 ,
+ 0.000};
+ double perrorbsytm[]={0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
+ 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
+ 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
+ 0.0,0.0,0.0,0.0,0.0,0.0};
+ double perrora[36],perrorl[36],perrorc[36],perrorb[36];
+ for(unsigned int ix=0;ix<36;++ix)
+ {
+ perrora[ix]=sqrt(sqr(perrorastat[ix])+sqr(perrorasytm[ix]));
+ perrorl[ix]=sqrt(sqr(perrorlstat[ix])+sqr(perrorlsytm[ix]));
+ perrorc[ix]=sqrt(sqr(perrorcstat[ix])+sqr(perrorcsytm[ix]));
+ perrorb[ix]=sqrt(sqr(perrorbstat[ix])+sqr(perrorbsytm[ix]));
+ }
+ bins =vector<double>(pbins,pbins+37);
+ data =vector<double>(pdataa,pdataa+36);
+ error=vector<double>(perrora,perrora+36);
+ _ppma=new_ptr(Histogram(bins,data,error));
+ data =vector<double>(pdatal,pdatal+36);
+ error=vector<double>(perrorl,perrorl+36);
+ _ppml=new_ptr(Histogram(bins,data,error));
+ data =vector<double>(pdatac,pdatac+36);
+ error=vector<double>(perrorc,perrorc+36);
+ _ppmc=new_ptr(Histogram(bins,data,error));
+ data =vector<double>(pdatab,pdatab+36);
+ error=vector<double>(perrorb,perrorb+36);
+ _ppmb=new_ptr(Histogram(bins,data,error));
+ // OPAL protons
+ double pbinso[] = {0.406, 0.421, 0.438, 0.456, 0.475,
+ 0.495, 0.517, 0.541, 0.565, 0.592,
+ 0.620, 0.650, 0.681, 0.714, 0.750,
+ 0.787, 0.826, 0.867, 0.911, 0.957,
+ 1.005, 1.056, 1.109, 1.166, 1.225,
+ 1.287, 1.353, 1.422, 4.05, 4.95,
+ 6.04,
+ 7.38, 9.01, 11.01, 13.44, 16.42,
+ 20.05, 29.90, 45.60};
+ double pdatao[]={0.169 ,0.174 ,0.171 ,0.185 ,
+ 0.181 ,0.202 ,0.215 ,0.228 ,
+ 0.230 ,0.230 ,0.236 ,0.239 ,
+ 0.246 ,0.248 ,0.248 ,0.254 ,
+ 0.260 ,0.260 ,0.257 ,0.263 ,
+ 0.257 ,0.256 ,0.257 ,0.248 ,
+ 0.241 ,0.250 ,0.245 ,0.0 ,
+ 0.0606 ,0.0517 ,0.0352 ,0.0214 ,
+ 0.0152 ,0.0093 ,0.0045 ,0.0015 ,
+ 0.00056 ,0.000015};
+ double perrorostat[]={0.010 ,0.009 ,0.009 ,0.008 ,
+ 0.008 ,0.008 ,0.008 ,0.008 ,
+ 0.008 ,0.008 ,0.007 ,0.007 ,
+ 0.007 ,0.007 ,0.004 ,0.004 ,
+ 0.004 ,0.004 ,0.004 ,0.004 ,
+ 0.004 ,0.004 ,0.004 ,0.004 ,
+ 0.004 ,0.004 ,0.004 ,0.0 ,
+ 0.0036 ,0.0029 ,0.0011 ,0.0011 ,
+ 0.0006 ,0.0004 ,0.0003 ,0.0002 ,
+ 0.00005 ,0.000004};
+ double perrorosyst[]={0.013 ,0.015 ,0.012 ,0.015 ,0.006 ,
+ 0.010 ,0.012 ,0.014 ,0.010 ,0.007 ,
+ 0.012 ,0.008 ,0.006 ,0.009 ,0.009 ,
+ 0.008 ,0.007 ,0.007 ,0.006 ,0.007 ,
+ 0.021 ,0.027 ,0.029 ,0.027 ,0.017 ,
+ 0.016 ,0.021 , 0.0 ,0.0129 ,0.0062 ,
+ 0.0031 ,0.0023 ,0.0021 ,0.0013 ,0.0006 ,
+ 0.0005 ,0.00014 ,0.000026};
+ double perroro[38];
+ for(unsigned int ix=0;ix<38;++ix)
+ perroro[ix]=sqrt(sqr(perrorostat[ix])+sqr(perrorosyst[ix]));
+ bins =vector<double>(pbinso,pbinso+39);
+ data =vector<double>(pdatao,pdatao+38);
+ error=vector<double>(perroro,perroro+38);
+ _ppm=new_ptr(Histogram(bins,data,error));
+ // OPAL light quarks
+ double udsbinso[] = {0.00, 0.01, 0.02, 0.03, 0.04,
+ 0.05, 0.06, 0.07, 0.08, 0.09,
+ 0.10, 0.12, 0.14, 0.16, 0.18,
+ 0.20, 0.25, 0.30, 0.40, 0.50,
+ 0.60, 0.80, 1.00};
+ double udsdatao[]={388. ,390. ,241. ,176. ,122.6 ,
+ 95.7 ,79.3 ,65.0 ,53.3 ,43.3 ,
+ 35.1 ,27.7 ,21.2 ,17.1 ,13.3 ,
+ 9.86 ,6.30 ,3.42 ,1.50 ,0.668 ,
+ 0.241 , 0.031};
+ double udserrorostat[]={5. ,5. ,4. ,3.,2.7 ,2.2 ,
+ 1.9 ,1.6 ,1.6 ,1.5 ,0.9 ,0.7 ,
+ 0.7 ,0.6 ,0.6 ,0.26,0.19,0.09,
+ 0.05,0.033 ,0.008 ,0.007};
+ double udserrorosyst[]={9. ,10.,7. ,5. ,3.9,2.9,
+ 2.3,1.7,1.3,1.0,0.7,0.4,
+ 0.4,0.3,0.3,0.30 ,0.25 ,
+ 0.17 ,0.10 ,0.048 ,0.024 ,0.007};
+ double udserroro[22];
+ for(unsigned int ix=0;ix<22;++ix)
+ {udserroro[ix]=sqrt(sqr(udserrorostat[ix])+sqr(udserrorosyst[ix]));}
+ bins =vector<double>(udsbinso,udsbinso+23);
+ data =vector<double>(udsdatao,udsdatao+22);
+ error=vector<double>(udserroro,udserroro+22);
+ _udsxp=new_ptr(Histogram(bins,data,error));
+ double udsxibinso[] = {0.0, 0.2, 0.4, 0.6, 0.8,
+ 1.0, 1.2, 1.4, 1.6, 1.8,
+ 2.0, 2.2, 2.4, 2.6, 2.8,
+ 3.0, 3.2, 3.4, 3.6, 3.8,
+ 4.0, 4.2, 4.4, 4.6, 4.8,
+ 5.0, 5.2, 5.4, 5.6, 5.8};
+ double udsxidatao[]={0.024 , 0.114 , 0.277 , 0.529 , 0.86 ,
+ 1.31 , 1.76 , 2.22 , 2.70 , 3.06 ,
+ 3.76 , 4.03 , 4.48 , 5.12 , 5.22 ,
+ 5.26 , 6.24 , 6.02 , 5.89 , 6.04 ,
+ 5.85 , 5.58 , 5.15 , 4.21 , 3.99 ,
+ 2.94 , 2.14 , 1.93 , 1.43};
+ double udsxierrorostat[]={0.006 ,0.003 ,0.009 ,0.016 ,0.02 ,
+ 0.03 ,0.05 ,0.06 ,0.07 ,0.08 ,
+ 0.09 ,0.10 ,0.10 ,0.11 ,0.12 ,
+ 0.13 ,0.12 ,0.12 ,0.13 ,0.12 ,
+ 0.13 ,0.11 ,0.11 ,0.12 ,0.10 ,
+ 0.10 ,0.10 ,0.08 ,0.09};
+ double udsxierrorosyst[]={0.006,0.011,0.025,0.032,0.05 ,0.06 ,
+ 0.07 ,0.06 ,0.06 ,0.09 ,0.11 ,0.13 ,
+ 0.18 ,0.16 ,0.17 ,0.19 ,0.21 ,0.20 ,
+ 0.26 ,0.20 ,0.20 ,0.14 ,0.09 ,0.24 ,
+ 0.14 ,0.15 ,0.12 ,0.13 ,0.23 };
+ double udsxierroro[22];
+ for(unsigned int ix=0;ix<22;++ix)
+ {udsxierroro[ix]=sqrt(sqr(udsxierrorostat[ix])+sqr(udsxierrorosyst[ix]));}
+ bins =vector<double>(udsxibinso,udsxibinso+23);
+ data =vector<double>(udsxidatao,udsxidatao+22);
+ error=vector<double>(udsxierroro,udsxierroro+22);
+ _udsxip=new_ptr(Histogram(bins,data,error));
+ // lambdas
+ double Lbinso[] = {0.012, 0.014, 0.016, 0.018, 0.020,
+ 0.025, 0.030, 0.035, 0.040, 0.050,
+ 0.060, 0.080, 0.100, 0.120, 0.140,
+ 0.160, 0.180, 0.200, 0.250, 0.300,
+ 0.350, 0.400, 0.500, 0.600, 0.700,
+ 0.900};
+ double Ldatao[]={2.97 ,3.43 ,3.74 ,3.70 ,3.69 ,3.68 ,
+ 3.70 ,3.41 ,3.18 ,2.66 ,2.04 ,1.52 ,
+ 1.19 ,0.956 ,0.771 ,0.630 ,0.528 ,0.408 ,
+ 0.269 ,0.182 ,0.129 ,0.078 ,0.035 ,0.0118 ,0.0026};
+ double Lerrorostat[]={0.35 ,0.30 ,0.29 ,0.21 ,0.18 ,0.16 ,
+ 0.15 ,0.14 ,0.11 ,0.09 ,0.06 ,0.04 ,
+ 0.03 ,0.023 ,0.018 ,0.015 ,0.013 ,0.010 ,
+ 0.008 ,0.007 ,0.006 ,0.005 ,0.003 ,0.0019 ,0.0012};
+ double Lerrorosyst[]={0.0,0.0,0.0,0.0,0.0,0.0,
+ 0.0,0.0,0.0,0.0,0.0,0.0,
+ 0.0,0.0,0.0,0.0,0.0,0.0,
+ 0.0,0.0,0.0,0.0,0.0,0.0,0.0};
+ double Lerroro[25];
+ for(unsigned int ix=0;ix<25;++ix)
+ Lerroro[ix]=sqrt(sqr(Lerrorostat[ix])+sqr(Lerrorosyst[ix]));
+ bins =vector<double>(Lbinso,Lbinso+26);
+ data =vector<double>(Ldatao,Ldatao+25);
+ error=vector<double>(Lerroro,Lerroro+25);
+ _lpm=new_ptr(Histogram(bins,data,error));
+ // K*+/- CERN-PPE-96-186
+ double Kstarpmbin[]={0.03 ,0.06 ,0.09 ,0.12 ,0.15 ,
+ 0.18 ,0.22 ,0.26 ,0.32 ,0.44 ,1.00};
+ double Kstarpmdata[]={5.17 ,3.43 ,2.09 ,2.01 ,1.54 ,
+ 1.16 ,0.71 ,0.59 ,0.38 ,0.06};
+ double Kstarpmstat[]={0.53 ,0.29 ,0.20 ,0.16 ,0.15 ,
+ 0.12 ,0.09 ,0.06 ,0.04 ,0.01};
+ double Kstarpmsyst[]={0.54,0.58,0.22,0.23,0.19,0.22,0.07,0.07,0.03,0.01};
+ double Kstarpmerror[10];
+ for(unsigned int ix=0;ix<10;++ix)
+ Kstarpmerror[ix] = sqrt(sqr(Kstarpmstat[ix])+sqr(Kstarpmsyst[ix]));
+ bins =vector<double>(Kstarpmbin,Kstarpmbin+11);
+ data =vector<double>(Kstarpmdata,Kstarpmdata+10);
+ error=vector<double>(Kstarpmerror,Kstarpmerror+10);
+ _xpKstarplus = new_ptr(Histogram(bins,data,error));
+ // xi- ALEXANDER 96 ZP C73,569
+ double ximbinsA[]={0.035 ,0.050 ,0.060 ,0.080 ,0.100 ,
+ 0.150 ,0.200 ,0.300 ,0.400 ,0.500};
+ double ximdataA[]={0.341 ,0.254 ,0.180 ,0.114 ,0.0737 ,
+ 0.0438 ,0.0192 ,0.0120 ,0.0084};
+ double ximstatA[]={0.018 ,0.014 ,0.007 ,0.005 ,0.0024 ,
+ 0.0021 ,0.0015 ,0.0012 ,0.0014};
+ double ximsystA[]={0.032 ,0.021 ,0.012 ,0.008 ,0.0048 ,
+ 0.0031 ,0.0014 ,0.0012 ,0.0015};
+ double ximerrorA[9];
+ for(unsigned int ix=0;ix<9;++ix)
+ ximerrorA[ix] = sqrt(sqr(ximstatA[ix])+sqr(ximsystA[ix]));
+ bins =vector<double>(ximbinsA,ximbinsA+10);
+ data =vector<double>(ximdataA,ximdataA+9);
+ error=vector<double>(ximerrorA,ximerrorA+9);
+ _xpXiminus = new_ptr(Histogram(bins,data,error));
+ double ximbinsB[]={0.6 ,0.8 ,1.0 ,1.2 ,1.4 ,
+ 1.6 ,1.8 ,2.0 ,2.2 ,2.4 ,
+ 2.6 ,2.8 ,3.0 ,3.2 ,3.4 ,3.6};
+ double ximdataB[]={0.0026 ,0.0044 ,0.0044 ,0.0050 ,0.0071 ,
+ 0.0075 ,0.0088 ,0.0086 ,0.0094 ,0.0103 ,
+ 0.0121 ,0.0102 ,0.0100 ,0.0087 ,0.0088};
+ double ximstatB[]={0.0005 ,0.0004 ,0.0004 ,0.0005 ,0.0004 ,
+ 0.0004 ,0.0004 ,0.0004 ,0.0004 ,0.0005 ,
+ 0.0006 ,0.0006 ,0.0007 ,0.0009 ,0.0011};
+ double ximsystB[]={0.0017 ,0.0011 ,0.0005 ,0.0005 ,0.0006 ,
+ 0.0006 ,0.0007 ,0.0006 ,0.0007 ,0.0008 ,
+ 0.0009 ,0.0008 ,0.0009 ,0.0010 ,0.0013};
+ double ximerrorB[15];
+ for(unsigned int ix=0;ix<15;++ix)
+ ximerrorB[ix] = sqrt(sqr(ximstatB[ix])+sqr(ximsystB[ix]));
+ bins =vector<double>(ximbinsB,ximbinsB+16);
+ data =vector<double>(ximdataB,ximdataB+15);
+ error=vector<double>(ximerrorB,ximerrorB+15);
+ _xiXiminus = new_ptr(Histogram(bins,data,error));
+ // sigma*+ALEXANDER 96 ZP C73,569
+ double sigmapbinsA[]={0.04 ,0.07 ,0.10 ,0.15 ,0.20 ,0.30 ,0.50};
+ double sigmapdataA[]={0.280 ,0.118 ,0.0619 ,0.0403 ,0.0248 ,0.0076};
+ double sigmapstatA[]={0.020 ,0.012 ,0.0060 ,0.0048 ,0.0027 ,0.0013};
+ double sigmapsystA[]={0.021 ,0.009 ,0.0047 ,0.0031 ,0.0019 ,0.0006};
+ double sigmaperrorA[6];
+ for(unsigned int ix=0;ix<6;++ix)
+ sigmaperrorA[ix] = sqrt(sqr(sigmapstatA[ix])+sqr(sigmapsystA[ix]));
+ bins =vector<double>(sigmapbinsA,sigmapbinsA+7);
+ data =vector<double>(sigmapdataA,sigmapdataA+6);
+ error=vector<double>(sigmaperrorA,sigmaperrorA+6);
+ _xpSigmaplus = new_ptr(Histogram(bins,data,error));
+ double sigmapbinsB[]={0.70 ,1.21 ,1.62 ,1.92 ,2.35 ,2.76 ,3.65};
+ double sigmapdataB[]={0.0030 ,0.0060 ,0.0068 ,0.0072 ,0.0086 ,0.0095};
+ double sigmapstatB[]={0.0005 ,0.0007 ,0.0008 ,0.0007 ,0.0008 ,0.0007};
+ double sigmapsystB[]={0.0002 ,0.0005 ,0.0005 ,0.0005 ,0.0007 ,0.0007};
+ double sigmaperrorB[6];
+ for(unsigned int ix=0;ix<6;++ix)
+ sigmaperrorB[ix] = sqrt(sqr(sigmapstatB[ix])+sqr(sigmapsystB[ix]));
+ bins =vector<double>(sigmapbinsB,sigmapbinsB+7);
+ data =vector<double>(sigmapdataB,sigmapdataB+6);
+ error=vector<double>(sigmaperrorB,sigmaperrorB+6);
+ _xiSigmaplus = new_ptr(Histogram(bins,data,error));
+ // sigma*+ ALEXANDER 96 ZP C73,569
+ double sigmambinsA[]={0.04 ,0.07 ,0.10 ,0.15 ,0.20 ,0.30 ,0.50};
+ double sigmamdataA[]={0.291 ,0.116 ,0.0646 ,0.0414 ,0.0235 ,0.0062};
+ double sigmamstatA[]={0.021 ,0.013 ,0.0071 ,0.0061 ,0.0040 ,0.0020};
+ double sigmamsystA[]={0.022 ,0.009 ,0.000 ,0.0032,0.0018,0.0005};
+ double sigmamerrorA[6];
+ for(unsigned int ix=0;ix<6;++ix)
+ sigmamerrorA[ix] = sqrt(sqr(sigmamstatA[ix])+sqr(sigmamsystA[ix]));
+ bins =vector<double>(sigmambinsA,sigmambinsA+7);
+ data =vector<double>(sigmamdataA,sigmamdataA+6);
+ error=vector<double>(sigmamerrorA,sigmamerrorA+6);
+ _xpSigmaminus = new_ptr(Histogram(bins,data,error));
+ double sigmambinsB[]={0.70 ,1.21 ,1.62 ,1.92 ,2.35 ,2.76 ,3.65};
+ double sigmamdataB[]={0.0024 ,0.0057 ,0.0070 ,0.0075 ,0.0085 ,0.0098};
+ double sigmamstatB[]={0.0008 ,0.0010 ,0.0010 ,0.0008 ,0.0009 ,0.0007};
+ double sigmamsystB[]={0.0002,0.0004,0.0005,0.0006,0.0006,0.0007};
+ double sigmamerrorB[6];
+ for(unsigned int ix=0;ix<6;++ix)
+ sigmamerrorB[ix] = sqrt(sqr(sigmamstatB[ix])+sqr(sigmamsystB[ix]));
+ bins =vector<double>(sigmambinsB,sigmambinsB+7);
+ data =vector<double>(sigmamdataB,sigmamdataB+6);
+ error=vector<double>(sigmamerrorB,sigmamerrorB+6);
+ _xiSigmaminus = new_ptr(Histogram(bins,data,error));
+ // xi*0 ALEXANDER 96 ZP C73,569
+ double xi0binsA[]={0.04 ,0.07 ,0.10 ,0.15 ,0.20 ,0.30};
+ double xi0dataA[]={0.064 ,0.0387 ,0.0239 ,0.0144 ,0.0049};
+ double xi0statA[]={0.014 ,0.0054 ,0.0028 ,0.0025 ,0.0015};
+ double xi0systA[]={0.009 ,0.0042,0.0024,0.0017,0.0006};
+ double xi0errorA[5];
+ for(unsigned int ix=0;ix<5;++ix)
+ xi0errorA[ix] = sqrt(sqr(xi0statA[ix])+sqr(xi0systA[ix]));
+ bins =vector<double>(xi0binsA,xi0binsA+6);
+ data =vector<double>(xi0dataA,xi0dataA+5);
+ error=vector<double>(xi0errorA,xi0errorA+5);
+ _xpXi0 = new_ptr(Histogram(bins,data,error));
+ double xi0binsB[]={1.21 ,1.62 ,1.92 ,2.36 ,2.79 ,3.83};
+ double xi0dataB[]={0.0012 ,0.0024 ,0.0027 ,0.0027 ,0.0019};
+ double xi0statB[]={0.0004 ,0.0004 ,0.0003 ,0.0004 ,0.0004};
+ double xi0systB[]={0.0002,0.0003,0.0003,0.0003,0.0003};
+ double xi0errorB[5];
+ for(unsigned int ix=0;ix<5;++ix)
+ xi0errorB[ix] = sqrt(sqr(xi0statB[ix])+sqr(xi0systB[ix]));
+ bins =vector<double>(xi0binsB,xi0binsB+6);
+ data =vector<double>(xi0dataB,xi0dataB+5);
+ error=vector<double>(xi0errorB,xi0errorB+5);
+ _xiXi0 = new_ptr(Histogram(bins,data,error));
+ double lambda1520binsA[]={0.035 ,0.039 ,0.045 ,0.052 ,0.060 ,0.100 ,0.300 ,0.500};
+ double lambda1520dataA[]={0.447 ,0.139 ,0.150 ,0.163 ,0.000 ,0.033 ,0.008};
+ double lambda1520statA[]={0.070 ,0.036 ,0.032 ,0.052 ,0.000 ,0.007 ,0.003};
+ double lambda1520systA[]={0.076,0.018,0.018,0.022,0.000,0.006,0.002};
+ double lambda1520errorA[7];
+ for(unsigned int ix=0;ix<7;++ix)
+ lambda1520errorA[ix] = sqrt(sqr(lambda1520statA[ix])+sqr(lambda1520systA[ix]));
+ bins =vector<double>(lambda1520binsA,lambda1520binsA+8);
+ data =vector<double>(lambda1520dataA,lambda1520dataA+7);
+ error=vector<double>(lambda1520errorA,lambda1520errorA+7);
+ _xpLambda1520 = new_ptr(Histogram(bins,data,error));
+ double lambda1520binsB[]={0.70 ,1.21 ,2.36 ,3.00 ,3.22 ,3.50 ,3.90,4.54};
+ double lambda1520dataB[]={0.0032 ,0.0060 ,0.0000 ,0.0058 ,0.0037 ,0.0020 ,0.0026};
+ double lambda1520statB[]={0.0010 ,0.0012 ,0.0000 ,0.0018 ,0.0008 ,0.0005 ,0.0004};
+ double lambda1520systB[]={0.0007,0.0010,0.0000,0.0008,0.0005,0.0003,0.0004};
+ double lambda1520errorB[7];
+ for(unsigned int ix=0;ix<7;++ix)
+ lambda1520errorB[ix] = sqrt(sqr(lambda1520statB[ix])+sqr(lambda1520systB[ix]));
+ bins =vector<double>(lambda1520binsB,lambda1520binsB+8);
+ data =vector<double>(lambda1520dataB,lambda1520dataB+7);
+ error=vector<double>(lambda1520errorB,lambda1520errorB+7);
+ _xiLambda1520 = new_ptr(Histogram(bins,data,error));
+ // delta++
+ double deltabins []={0.05,0.075,0.1,0.15,0.2,0.3,1.0};
+ double deltadata []={1.9,2.8,0.38,0.18,0.073 ,0.006};
+ double deltaerror[]={0.7,0.8,0.09,0.10,0.043,0.0029};
+ bins =vector<double>(deltabins,deltabins+7);
+ data =vector<double>(deltadata,deltadata+6);
+ error=vector<double>(deltaerror,deltaerror+6);
+ _xeDelta = new_ptr(Histogram(bins,data,error));
+ // f_0(980)
+ double f980bins []={0.00 ,0.06 ,0.12 ,0.14 ,0.16 ,0.20 ,0.25 ,0.35 ,0.50 ,1.00};
+ double f980data []={1.04 ,0.57 ,0.30 ,0.20 ,0.21 ,0.13 ,0.085 ,0.046 ,0.0079};
+ double f980error[]={0.09 ,0.05 ,0.06 ,0.05 ,0.03 ,0.02 ,0.011 ,0.005 ,0.0009};
+ bins =vector<double>(f980bins ,f980bins +10);
+ data =vector<double>(f980data ,f980data + 9);
+ error=vector<double>(f980error,f980error+ 9);
+ _xpf980 = new_ptr(Histogram(bins,data,error));
+ // f_2
+ double f2bins []={0.00 ,0.06 ,0.12 ,0.14 ,0.16 ,0.20 ,0.25 ,0.35 ,0.50 ,1.00 };
+ double f2data []={1.00 ,0.69 ,0.41 ,0.25 ,0.27 ,0.22 ,0.091 ,0.035 ,0.008};
+ double f2error[]={0.14 ,0.08 ,0.09 ,0.08 ,0.04 ,0.03 ,0.016 ,0.008 ,0.001};
+ bins =vector<double>(f2bins ,f2bins +10);
+ data =vector<double>(f2data ,f2data + 9);
+ error=vector<double>(f2error,f2error+ 9);
+ _xpf2 = new_ptr(Histogram(bins,data,error));
+// phi
+ double phibins []={0.00 ,0.06 ,0.12 ,0.14 ,0.16 ,0.20 ,0.25 ,0.35 ,0.50 ,1.00};
+ double phidata []={0.464 ,0.316 ,0.285 ,0.197 ,0.167 ,0.133 ,0.096 ,0.045 ,0.010};
+ double phistat []={0.011 ,0.021 ,0.020 ,0.019 ,0.017 ,0.007 ,0.004 ,0.002 ,0.001};
+ double phisyst []={0.005,0.007,0.009,0.006,0.002,0.002,0.001,0.001,0.000};
+ double phierror[9];
+ for(unsigned int ix=0;ix<9;++ix)
+ phierror[ix] = sqrt(sqr(phistat[ix])+sqr(phisyst[ix]));
+ bins =vector<double>(phibins ,phibins +10);
+ data =vector<double>(phidata ,phidata + 9);
+ error=vector<double>(phierror,phierror+ 9);
+ _xpphi = new_ptr(Histogram(bins,data,error));
+ // K*0
+ double Kstar0bins []={0.0 ,0.01 ,0.03 ,0.1 ,0.125 ,
+ 0.14 ,0.16 ,0.2 ,0.3 ,0.4 ,0.5 ,0.7 ,1.0 };
+ double Kstar0data []={1.22 ,4.96 ,4.14 ,2.35 ,1.99 ,
+ 1.60 ,1.30 ,0.81 ,0.44 ,0.22 ,0.090 ,0.013 };
+ double Kstar0stat []={0.15 ,0.17 ,0.20 ,0.16 ,0.15 ,
+ 0.11 ,0.09 ,0.04 ,0.03 ,0.02 ,0.009 ,0.004 };
+ double Kstar0syst []={0.04 ,0.15 ,0.19 ,0.13 ,0.09 ,
+ 0.10 ,0.06 ,0.05 ,0.03 ,0.01 ,0.003,0.003};
+ double Kstar0error[12];
+ for(unsigned int ix=0;ix<12;++ix)
+ Kstar0error[ix] = sqrt(sqr(Kstar0stat[ix])+sqr(Kstar0syst[ix]));
+ bins =vector<double>(Kstar0bins ,Kstar0bins +13);
+ data =vector<double>(Kstar0data ,Kstar0data +12);
+ error=vector<double>(Kstar0error,Kstar0error+12);
+ _xpKstar0 = new_ptr(Histogram(bins,data,error));
+ // D0
+ double D0bins []={0.15 ,0.25 ,0.35 ,0.45 ,0.55 ,0.65 ,0.75 ,0.85 ,1.00};
+ double D0data []={41.1 ,101.4 , 58.4 , 52.9 , 53.2 , 36.0 , 13.5 , 2.0};
+ double D0error[]={11.3 ,13.8 ,10.5 , 8.1 , 8.4 , 8.0 , 3.7 , 2.0};
+ bins =vector<double>(D0bins ,D0bins + 9);
+ data =vector<double>(D0data ,D0data + 8);
+ error=vector<double>(D0error,D0error+ 8);
+ _xeD0 = new_ptr(Histogram(bins,data,error));
+ // Dstar
+ double Dstarbins []={0.10 ,0.15 ,0.20 ,0.25 ,0.30 ,
+ 0.35 ,0.40 ,0.45 ,0.50 ,0.55 ,
+ 0.60 ,0.65 ,0.70 ,0.75 ,0.80 ,
+ 0.85 ,0.90 ,0.95 ,1.00};
+ double Dstardata []={7.47 , 9.03 ,10.42 ,10.76 , 9.89 ,
+ 8.97 , 8.17 , 6.94 , 6.73 , 5.56 ,
+ 4.94 , 3.49 , 3.13 , 2.00 , 1.27 ,
+ 0.50 , 0.27 , 0.06};
+ double Dstarerror[]={0.63 ,0.49 ,0.44 ,0.43 ,0.38 ,
+ 0.35 ,0.32 ,0.28 ,0.27 ,0.24 ,
+ 0.22 ,0.18 ,0.17 ,0.14 ,0.11 ,
+ 0.07 ,0.05 ,0.03};
+ bins =vector<double>(Dstarbins ,Dstarbins +19);
+ data =vector<double>(Dstardata ,Dstardata +18);
+ error=vector<double>(Dstarerror,Dstarerror+18);
+ _xeDstar = new_ptr(Histogram(bins,data,error));
+ // rho0
+ double rho0bins []={0.05 ,0.1 ,0.2 ,0.3 ,0.4 ,0.6 ,0.8 ,1.0};
+ double rho0data []={6.15 ,2.16 ,0.92 ,0.45 ,0.13 ,0.027,0.003};
+ double rho0error[]={0.72 ,0.23 ,0.10 ,0.05 ,0.02 ,0.005,0.002};
+ bins =vector<double>(rho0bins ,rho0bins +8);
+ data =vector<double>(rho0data ,rho0data +7);
+ error=vector<double>(rho0error,rho0error+7);
+ _xerho0 = new_ptr(Histogram(bins,data,error));
+ // pi0
+ double pi0binsA[]={0.007 ,0.009 ,0.011 ,0.013 ,0.016 ,
+ 0.020 ,0.025 ,0.030 ,0.035 ,0.040 ,
+ 0.050 ,0.060 ,0.070 ,0.085 ,0.100 ,
+ 0.125 ,0.150 ,0.200 ,0.300 ,0.400 ,0.500};
+ double pi0dataA[]={254. ,266. ,248. ,211. ,178. ,
+ 139. ,113. , 94.1 , 77.7 , 62.5 ,
+ 45.7 , 34.7 , 26.2 , 19.4 , 13.2 ,
+ 9.05 , 5.36 , 2.26 , 0.764 , 0.455};
+ double pi0statA[]={18. ,12. , 6. , 3. , 2. ,
+ 2. , 1. , 0.9 , 0.8 , 0.4 ,
+ 0.4 , 0.3 , 0.2 , 0.2 , 0.1 ,
+ 0.13 , 0.10 , 0.13 , 0.085 , 0.095};
+ double pi0systA[]={48 ,38 ,28 ,18 ,14 ,
+ 6 ,5 ,4.0 ,4.3 ,3.9 ,
+ 3.0 ,3.0 ,1.8 ,1.4 ,2.9 ,
+ 0.76 ,0.69 ,0.38 ,0.309,0.244};
+ double pi0errorA[20];
+ for(unsigned int ix=0;ix<20;++ix)
+ pi0errorA[ix] = sqrt(sqr(pi0statA[ix])+sqr(pi0systA[ix]));
+ bins =vector<double>(pi0binsA,pi0binsA+21);
+ data =vector<double>(pi0dataA,pi0dataA+20);
+ error=vector<double>(pi0errorA,pi0errorA+20);
+ _xepi0 = new_ptr(Histogram(bins,data,error));
+ double pi0binsB[]={0.69 ,0.92 ,1.20 ,1.61 ,1.90 ,
+ 2.08 ,2.30 ,2.47 ,2.66 ,2.81 ,
+ 3.00 ,3.22 ,3.36 ,3.51 ,3.70 ,
+ 3.92 ,4.15 ,4.37 ,4.55 ,4.77 ,5.06};
+ double pi0dataB[]={0.204 ,0.266 ,0.558 ,0.931 ,1.240 ,
+ 1.48 ,1.79 ,2.02 ,2.25 ,2.50 ,
+ 2.79 ,2.89 ,3.03 ,3.06 ,3.05 ,
+ 3.11 ,2.92 ,2.78 ,2.42 ,1.74};
+ double pi0statB[]={0.043 ,0.030 ,0.031 ,0.017 ,0.017
+ ,0.02 ,0.02 ,0.02 ,0.02 ,0.02 ,
+ 0.02 ,0.03 ,0.03 ,0.03 ,0.03 ,
+ 0.03 ,0.05 ,0.06 ,0.11 ,0.12};
+ double pi0systB[]={0.110 ,0.107 ,0.094 ,0.120 ,0.105 ,
+ 0.32 ,0.13 ,0.14 ,0.20 ,0.16 ,
+ 0.17 ,0.16 ,0.13 ,0.13 ,0.13 ,
+ 0.25 ,0.25 ,0.31 ,0.34 ,0.33};
+ double pi0errorB[20];
+ for(unsigned int ix=0;ix<20;++ix)
+ pi0errorB[ix] = sqrt(sqr(pi0statB[ix])+sqr(pi0systB[ix]));
+ bins =vector<double>(pi0binsB,pi0binsB+21);
+ data =vector<double>(pi0dataB,pi0dataB+20);
+ error=vector<double>(pi0errorB,pi0errorB+20);
+ _xipi0 = new_ptr(Histogram(bins,data,error));
+ // eta
+ double etabinsA[]={0.025 ,0.035 ,0.050 ,0.075 ,0.100 ,
+ 0.125 ,0.150 ,0.200 ,0.300 ,0.400 ,0.500 ,0.600 ,0.800 ,1.000};
+ double etadataA[]={10.6 , 7.63 , 5.10 , 3.81 , 2.83 ,
+ 2.21 , 1.46 , 0.733 , 0.364 , 0.220 , 0.086 , 0.033 , 0.0013};
+ double etastatA[]={1.5 ,0.78 ,0.38 ,0.21 ,0.12 ,
+ 0.10 ,0.05 ,0.026 ,0.022 ,0.019 ,0.010 ,0.004 ,0.0004};
+ double etasystA[]={2.4 ,1.27 ,0.61 ,0.44 ,0.28 ,
+ 0.22 ,0.13 ,0.062 ,0.047 ,0.031 ,0.019 ,0.008 ,0.0011};
+ double etaerrorA[13];
+ for(unsigned int ix=0;ix<13;++ix)
+ etaerrorA[ix] = sqrt(sqr(etastatA[ix])+sqr(etasystA[ix]));
+ bins =vector<double>(etabinsA,etabinsA+14);
+ data =vector<double>(etadataA,etadataA+13);
+ error=vector<double>(etaerrorA,etaerrorA+13);
+ _xeeta = new_ptr(Histogram(bins,data,error));
+ double etabinsB[]={0.00 ,0.22 ,0.51 ,0.69 ,0.92 ,
+ 1.20 ,1.61 ,1.90 ,2.08 ,2.31 ,2.60 ,3.03 ,3.42 ,3.82};
+ double etadataB[]={0.0012 ,0.023 ,0.047 ,0.099 ,0.126 ,
+ 0.180 ,0.252 ,0.301 ,0.314 ,0.324 ,0.302 ,0.294 ,0.261};
+ double etastatB[]={0.0004 ,0.003 ,0.006 ,0.008 ,0.008 ,
+ 0.006 ,0.009 ,0.014 ,0.014 ,0.018 ,0.023 ,0.030 ,0.038};
+ double etasystB[]={0.0009 ,0.005 ,0.009 ,0.011 ,0.014 ,
+ 0.014 ,0.021 ,0.027 ,0.028 ,0.032 ,0.028 ,0.038 ,0.046};
+ double etaerrorB[13];
+ for(unsigned int ix=0;ix<13;++ix)
+ etaerrorB[ix] = sqrt(sqr(etastatB[ix])+sqr(etasystB[ix]));
+ bins =vector<double>(etabinsB,etabinsB+14);
+ data =vector<double>(etadataB,etadataB+13);
+ error=vector<double>(etaerrorB,etaerrorB+13);
+ _xieta = new_ptr(Histogram(bins,data,error));
+ // rho+
+ double rhopbinsA[]={0.016 ,0.025 ,0.035 ,0.050 ,0.075 ,
+ 0.100 ,0.125 ,0.150 ,0.200 ,0.300 ,0.400 ,0.600 ,0.800, 1.000};
+ double rhopdataA[]={17.3 ,32.3 ,21.3 ,16.7 , 9.89 ,
+ 7.11 , 5.90 , 3.60 , 2.02 , 1.03 , 0.430 , 0.075 , 0.013};
+ double rhopstatA[]={8.1 ,2.5 ,0.7 ,0.4 ,0.40 ,
+ 0.25 ,0.25 ,0.12 ,0.07 ,0.04 ,0.023 ,0.013 ,0.003};
+ double rhopsystA[]={12.2 ,9.7 ,4.5 ,1.8 ,1.46 ,1.04 ,0.78 ,0.48 ,0.21 ,0.27 ,0.081,0.032,0.009};
+ double rhoperrorA[13];
+ for(unsigned int ix=0;ix<13;++ix)
+ rhoperrorA[ix] = sqrt(sqr(rhopstatA[ix])+sqr(rhopsystA[ix]));
+ bins =vector<double>(rhopbinsA,rhopbinsA+14);
+ data =vector<double>(rhopdataA,rhopdataA+13);
+ error=vector<double>(rhoperrorA,rhoperrorA+13);
+ _xerhop = new_ptr(Histogram(bins,data,error));
+ double rhopbinsB[]={0.0 ,0.5 ,1.0 ,1.5 ,2.0 ,2.5 ,3.0 ,3.5 ,4.0 ,4.5 ,5.0};
+ double rhopdataB[]={0.034 ,0.217 ,0.419 ,0.603 ,0.805 ,0.868 ,0.692 ,0.500 ,0.419 ,0.171};
+ double rhopstatB[]={0.004 ,0.010 ,0.014 ,0.017 ,0.022 ,0.021 ,0.028 ,0.092 ,0.035 ,0.008};
+ double rhopsystB[]={0.019,0.055,0.073,0.078,0.104,0.126,0.165,0.138,0.111,0.081};
+ double rhoperrorB[10];
+ for(unsigned int ix=0;ix<10;++ix)
+ rhoperrorB[ix] = sqrt(sqr(rhopstatB[ix])+sqr(rhopsystB[ix]));
+ bins =vector<double>(rhopbinsB,rhopbinsB+11);
+ data =vector<double>(rhopdataB,rhopdataB+10);
+ error=vector<double>(rhoperrorB,rhoperrorB+10);
+ _xirhop = new_ptr(Histogram(bins,data,error));
+ // omega
+ double omegabinsA[]={0.025 ,0.035 ,0.050 ,0.075 ,0.100 ,0.125 ,0.150 ,0.200 ,0.300 ,0.400 ,0.600};
+ double omegadataA[]={15.2 , 9.88 , 5.82 , 4.12 , 2.74 , 2.23 , 1.45 , 0.789 , 0.335 , 0.130};
+ double omegastatA[]={2.4 ,0.84 ,0.35 ,0.25 ,0.16 ,0.14 ,0.09 ,0.049 ,0.037 ,0.027};
+ double omegasystA[]={2.1 ,1.48 ,0.75 ,0.54 ,0.32 ,0.24 ,0.17 ,0.099,0.042,0.028};
+ double omegaerrorA[10];
+ for(unsigned int ix=0;ix<10;++ix)
+ omegaerrorA[ix] = sqrt(sqr(omegastatA[ix])+sqr(omegasystA[ix]));
+ bins =vector<double>(omegabinsA,omegabinsA+11);
+ data =vector<double>(omegadataA,omegadataA+10);
+ error=vector<double>(omegaerrorA,omegaerrorA+10);
+ _xeomega = new_ptr(Histogram(bins,data,error));
+ double omegabinsB[]={0.51 ,0.92 ,1.21 ,1.61 ,1.90 ,2.09 ,2.32 ,2.62 ,3.06 ,3.49 ,4.01};
+ double omegadataB[]={0.064 ,0.116 ,0.193 ,0.250 ,0.301 ,0.299 ,0.344 ,0.330 ,0.344 ,0.293};
+ double omegastatB[]={0.013 ,0.013 ,0.012 ,0.016 ,0.018 ,0.018 ,0.021 ,0.020 ,0.029 ,0.046};
+ double omegasystB[]={0.014,0.014,0.024,0.029,0.032,0.035,0.045,0.043,0.051,0.040};
+ double omegaerrorB[10];
+ for(unsigned int ix=0;ix<10;++ix)
+ omegaerrorB[ix] = sqrt(sqr(omegastatB[ix])+sqr(omegasystB[ix]));
+ bins =vector<double>(omegabinsB,omegabinsB +11);
+ data =vector<double>(omegadataB,omegadataB +10);
+ error=vector<double>(omegaerrorB,omegaerrorB+10);
+ _xiomega = new_ptr(Histogram(bins,data,error));
+ // eta'
+ double etapbinsA[]={0.050 ,0.070 ,0.100 ,0.125 ,0.150 ,0.200 ,0.300 ,0.400 ,0.600 ,0.800};
+ double etapdataA[]={1.01 ,0.462 ,0.460 ,0.293 ,0.354 ,0.137 ,0.088 ,0.034 ,0.013};
+ double etapstatA[]={0.38 ,0.180 ,0.144 ,0.099 ,0.068 ,0.028 ,0.020 ,0.010 ,0.006};
+ double etapsystA[]={0.14 ,0.073,0.082,0.049,0.054,0.017,0.011,0.006,0.003};
+ double etaperrorA[9];
+ for(unsigned int ix=0;ix<9;++ix)
+ etaperrorA[ix] = sqrt(sqr(etapstatA[ix])+sqr(etapsystA[ix]));
+ bins =vector<double>(etapbinsA,etapbinsA+10);
+ data =vector<double>(etapdataA,etapdataA+9);
+ error=vector<double>(etaperrorA,etaperrorA+9);
+ _xeetap = new_ptr(Histogram(bins,data,error));
+ double etapbinsB[]={0.22 ,0.51 ,0.92 ,1.21 ,1.61 ,1.91 ,2.09 ,2.33 ,2.71 ,3.09};
+ double etapdataB[]={0.009 ,0.017 ,0.030 ,0.034 ,0.061 ,0.039 ,0.050 ,0.036 ,0.052};
+ double etapstatB[]={0.004 ,0.005 ,0.007 ,0.007 ,0.012 ,0.013 ,0.016 ,0.014 ,0.020};
+ double etapsystB[]={0.002,0.003,0.004,0.004,0.009,0.007,0.009,0.006,0.007};
+ double etaperrorB[9];
+ for(unsigned int ix=0;ix<9;++ix)
+ etaperrorB[ix] = sqrt(sqr(etapstatB[ix])+sqr(etapsystB[ix]));
+ bins =vector<double>(etapbinsB,etapbinsB+10);
+ data =vector<double>(etapdataB,etapdataB+9);
+ error=vector<double>(etaperrorB,etaperrorB+9);
+ _xietap = new_ptr(Histogram(bins,data,error));
+ // a_0+
+ double a0binsA[]={0.050 ,0.070 ,0.100 ,0.125 ,0.150 ,0.200 ,0.300 ,0.400 ,0.600 ,0.800 ,1.000};
+ double a0dataA[]={1.65 ,1.05 ,0.747 ,0.985 ,0.623 ,0.207 ,0.093 ,0.038 ,0.014 ,0.0040};
+ double a0statA[]={1.03 ,0.49 ,0.215 ,0.238 ,0.107 ,0.046 ,0.027 ,0.015 ,0.005 ,0.0018};
+ double a0systA[]={0.75 ,0.73 ,0.214 ,0.560 ,0.171 ,0.069 ,0.040 ,0.015 ,0.006 ,0.0024};
+ double a0errorA[10];
+ for(unsigned int ix=0;ix<10;++ix)
+ a0errorA[ix] = sqrt(sqr(a0statA[ix])+sqr(a0systA[ix]));
+ bins =vector<double>(a0binsA,a0binsA+11);
+ data =vector<double>(a0dataA,a0dataA+10);
+ error=vector<double>(a0errorA,a0errorA+10);
+ _xea_0p = new_ptr(Histogram(bins,data,error));
+ double a0binsB[]={0.00 ,0.50 ,1.00 ,1.50 ,2.00 ,2.50 ,3.00 ,3.50};
+ double a0dataB[]={0.0071 ,0.019 ,0.040 ,0.088 ,0.076 ,0.104 ,0.093};
+ double a0statB[]={0.0025 ,0.006 ,0.009 ,0.013 ,0.019 ,0.041 ,0.063};
+ double a0systB[]={0.0022,0.007 ,0.012 ,0.023 ,0.030 ,0.041 ,0.050};
+ double a0errorB[7];
+ for(unsigned int ix=0;ix<7;++ix)
+ a0errorB[ix] = sqrt(sqr(a0statB[ix])+sqr(a0systB[ix]));
+ bins =vector<double>(a0binsB,a0binsB+8);
+ data =vector<double>(a0dataB,a0dataB+7);
+ error=vector<double>(a0errorB,a0errorB+7);
+ _xia_0p = new_ptr(Histogram(bins,data,error));
+ // K_0
+ double K0bins []={0.0114 ,0.020 ,0.030 ,0.040 ,0.050 ,
+ 0.060 ,0.070 ,0.080 ,0.090 ,0.100 ,
+ 0.125 ,0.150 ,0.200 ,0.250 ,0.300 ,
+ 0.350 ,0.400 ,0.450 ,0.500 ,0.600 ,0.800};
+ double K0data []={25.731 ,24.617 ,19.349 ,15.500 ,13.170 ,
+ 11.144 , 9.360 , 8.470 , 7.010 , 5.734 ,
+ 4.488 , 3.100 , 1.945 , 1.266 , 0.860 ,
+ 0.579 , 0.394 , 0.253 , 0.163 , 0.051};
+ double K0stat []={0.232 ,0.120 ,0.116 ,0.061 ,0.072 ,
+ 0.073 ,0.066 ,0.061 ,0.059 ,0.029 ,
+ 0.028 ,0.019 ,0.015 ,0.010 ,0.010 ,
+ 0.009 ,0.008 ,0.005 ,0.003 ,0.001};
+ double K0syst []={1.430,1.300,1.040,0.767,0.690,
+ 0.600,0.500,0.468,0.401,0.312,
+ 0.247,0.169,0.104,0.071,0.050,
+ 0.035,0.026,0.018,0.018,0.010};
+ double K0error[20];
+ for(unsigned int ix=0;ix<20;++ix)
+ K0error[ix] = sqrt(sqr(K0stat[ix])+sqr(K0syst[ix]));
+ bins =vector<double>(K0bins ,K0bins +21);
+ data =vector<double>(K0data ,K0data +20);
+ error=vector<double>(K0error,K0error+20);
+ _xpK0 = new_ptr(Histogram(bins,data,error));
+}
+
+
+
+
+
+
+
+
+
+// // a_0+
+// double a0binsA[]={};
+// double a0dataA[]={};
+// double a0statA[]={};
+// double a0systA[]={};
+// double a0errorA[7];
+// for(unsigned int ix=0;ix<10;++ix)
+// a0errorA[ix] = sqrt(sqr(a0statA[ix])+sqr(a0systA[ix]));
+// bins =vector<double>(a0binsA,a0binsA+11);
+// data =vector<double>(a0dataA,a0dataA+10);
+// error=vector<double>(a0errorA,a0errorA+10);
+// _xea_0p = new_ptr(Histogram(bins,data,error));
+// double a0binsB[]={};
+// double a0dataB[]={};
+// double a0statB[]={};
+// double a0systB[]={};
+// double a0errorB[7];
+// for(unsigned int ix=0;ix<7;++ix)
+// a0errorB[ix] = sqrt(sqr(a0statB[ix])+sqr(a0systB[ix]));
+// bins =vector<double>(a0binsB,a0binsB+8);
+// data =vector<double>(a0dataB,a0dataB+7);
+// error=vector<double>(a0errorB,a0errorB+7);
+// _xia_0p = new_ptr(Histogram(bins,data,error));
+
diff --git a/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyIdentifiedParticleAnalysis.h b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyIdentifiedParticleAnalysis.h
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyIdentifiedParticleAnalysis.h
@@ -0,0 +1,445 @@
+// -*- C++ -*-
+//
+// IdentifiedParticleAnalysis.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_MyIdentifiedParticleAnalysis_H
+#define HERWIG_MyIdentifiedParticleAnalysis_H
+//
+// This is the declaration of the MyIdentifiedParticleAnalysis class.
+//
+
+#include "ThePEG/Repository/CurrentGenerator.h"
+#include "ThePEG/Handlers/AnalysisHandler.h"
+#include "ThePEG/Repository/EventGenerator.h"
+#include "Herwig++/Utilities/Histogram.h"
+#include "ThePEG/Vectors/Lorentz5Vector.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * Here is the documentation of the MyIdentifiedParticleAnalysis class.
+ *
+ * @see \ref MyIdentifiedParticleAnalysisInterfaces "The interfaces"
+ * defined for MyIdentifiedParticleAnalysis.
+ */
+class MyIdentifiedParticleAnalysis: public AnalysisHandler {
+
+ public:
+
+ /** @name Virtual functions required by the AnalysisHandler class. */
+ //@{
+ /**
+ * Analyze the given vector of particles. The default version calls
+ * analyze(tPPtr) for each of the particles.
+ * @param particles the vector of pointers to particles to be analyzed
+ */
+ virtual void analyze(tEventPtr event, long ieve, int loop, int state);
+ // virtual void analyze(const tPVector & particles);
+ //@}
+
+ //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:
+
+ /**
+ * Work out the flavour of the quarks produced
+ */
+ int getFlavour(const tPVector &);
+
+ inline double getX(const Lorentz5Momentum & p, const Energy & Ebeam)
+ {return(Ebeam > ZERO ? double(p.vect().mag()/Ebeam) : -1.);}
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ inline virtual IBPtr clone() const {return new_ptr(*this);}
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ inline virtual IBPtr fullclone() const {return new_ptr(*this);}
+ //@}
+
+protected:
+
+ /** @name Standard Interfaced functions. */
+ //@{
+ /**
+ * 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 static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static NoPIOClassDescription<MyIdentifiedParticleAnalysis> initMyIdentifiedParticleAnalysis;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ MyIdentifiedParticleAnalysis & operator=(const MyIdentifiedParticleAnalysis &);
+
+private:
+
+ /**
+ * Single particle spectra
+ */
+ //@{
+ /**
+ * Histogram for the \f$\xi\f$ distribution for all particles from all quarks
+ */
+ HistogramPtr _xpa;
+
+ /**
+ * Histogram for the \f$\xi\f$ distribution for all particles from light quarks
+ */
+ HistogramPtr _xpl;
+
+ /**
+ * Histogram for the \f$\xi\f$ distribution for all particles from charm quarks
+ */
+ HistogramPtr _xpc;
+
+ /**
+ * Histogram for the \f$\xi\f$ distribution for all particles from bottom quarks
+ */
+ HistogramPtr _xpb;
+
+ /**
+ * Histogram for the \f$\xi\f$ distribution for charged pions from all quarks
+ */
+ HistogramPtr _pipma;
+
+ /**
+ * Histogram for the \f$\xi\f$ distribution for charged pions from light quarks
+ */
+ HistogramPtr _pipml;
+
+ /**
+ * Histogram for the \f$\xi\f$ distribution for charged pions from charm quarks
+ */
+ HistogramPtr _pipmc;
+
+ /**
+ * Histogram for the \f$\xi\f$ distribution for charged pions from bottom quarks
+ */
+ HistogramPtr _pipmb;
+
+ /**
+ * Histogram for the \f$\xi\f$ distribution for charged pions from OPAL
+ */
+ HistogramPtr _pipm;
+
+ /**
+ * Histogram for the \f$\xi\f$ distribution for charged kaons from all quarks
+ */
+ HistogramPtr _kpma;
+
+ /**
+ * Histogram for the \f$\xi\f$ distribution for charged kaons from light quarks
+ */
+ HistogramPtr _kpml;
+
+ /**
+ * Histogram for the \f$\xi\f$ distribution for charged kaons from charm quarks
+ */
+ HistogramPtr _kpmc;
+
+ /**
+ * Histogram for the \f$\xi\f$ distribution for charged kaons from bottom quarks
+ */
+ HistogramPtr _kpmb;
+
+ /**
+ * Histogram for the \f$\xi\f$ distribution for charged kaons from OPAL
+ */
+ HistogramPtr _kpm;
+
+
+ /**
+ * Histogram for the \f$\xi\f$ distribution for protons from all quarks
+ */
+ HistogramPtr _ppma;
+
+ /**
+ * Histogram for the \f$\xi\f$ distribution for protons from light quarks
+ */
+ HistogramPtr _ppml;
+
+ /**
+ * Histogram for the \f$\xi\f$ distribution for protons from charm quarks
+ */
+ HistogramPtr _ppmc;
+
+ /**
+ * Histogram for the \f$\xi\f$ distribution for protons from bottom quarks
+ */
+ HistogramPtr _ppmb;
+
+ /**
+ * Histogram for the \f$\xi\f$ distribution for protons from OPAL
+ */
+ HistogramPtr _ppm;
+
+ /**
+ * Histogram for the \f$x\f$ distribution for light quark events (lin)
+ */
+ HistogramPtr _udsxp;
+
+ /**
+ * Histogram for the \f$\xi\f$ distribution for light quark events (lin)
+ */
+ HistogramPtr _udsxip;
+
+ /**
+ * Histogram for the \f$\xi\f$ distribution for \f$\Lambda\f$
+ */
+ HistogramPtr _lpm;
+
+ /**
+ * Histogram for the ALEPH \f$K^{*\pm}\f$ \f$x\f$distribution
+ */
+ HistogramPtr _xpKstarplus;
+
+ /**
+ * Histogram for the OPAL \f$\Xi^-\f$ \f$x\f$ distribution
+ */
+ HistogramPtr _xpXiminus;
+
+ /**
+ * Histogram for the OPAL \f$\Xi^-\f$ \f$\xi\f$ distribution
+ */
+ HistogramPtr _xiXiminus;
+
+ /**
+ * Histogram for the OPAL \f$\Sigma^{*+}\f$ \f$x\f$ distribution
+ */
+ HistogramPtr _xpSigmaplus;
+
+ /**
+ * Histogram for the OPAL \f$\Sigma^{*+}\f$ \f$\xi\f$ distribution
+ */
+ HistogramPtr _xiSigmaplus;
+
+ /**
+ * Histogram for the OPAL \f$\Sigma^{*-}\f$ \f$x\f$ distribution
+ */
+ HistogramPtr _xpSigmaminus;
+
+ /**
+ * Histogram for the OPAL \f$\Sigma^{*-}\f$ \f$\xi\f$ distribution
+ */
+ HistogramPtr _xiSigmaminus;
+
+ /**
+ * Histogram for the OPAL \f$\Xi^{*0}\f$ \f$x\f$ distribution
+ */
+ HistogramPtr _xpXi0;
+
+ /**
+ * Histogram for the OPAL \f$\Xi^{*0}\f$ \f$\xi\f$ distribution
+ */
+ HistogramPtr _xiXi0;
+
+ /**
+ * Histogram for \f$\Lambda(1520)\f$ \f$x\f$ distribution
+ */
+ HistogramPtr _xpLambda1520;
+
+ /**
+ * Histogram for \f$\Lambda(1520)\f$ \f$\xi\f$ distribution
+ */
+ HistogramPtr _xiLambda1520;
+
+ /**
+ * Histogram for \f$\Delta^{++}\f$ \f$x\f$ distribution
+ */
+ HistogramPtr _xeDelta;
+
+ /**
+ * Histogram for \f$f_0(980)\f$ \f$x\f$ distribution
+ */
+ HistogramPtr _xpf980;
+
+ /**
+ * Histogram for \f$\phi\f$ \f$x\f$ distribution
+ */
+ HistogramPtr _xpphi;
+
+ /**
+ * Histogram for \f$f_2\f$ \f$x\f$ distribution
+ */
+ HistogramPtr _xpf2;
+
+ /**
+ * Histogram for \f$K^{*0}\f$ \f$x\f$ distribution
+ */
+ HistogramPtr _xpKstar0;
+
+ /**
+ * Histogram for \f$K^0\f$ \f$x\f$ distribution
+ */
+ HistogramPtr _xpK0;
+
+ /**
+ * Histogram for \f$\rho^0\f$ \f$x\f$ distribution
+ */
+ HistogramPtr _xerho0;
+
+ /**
+ * Histogram for the OPAL \f$\pi^0\f$ \f$x\f$ distribution
+ */
+ HistogramPtr _xepi0;
+
+ /**
+ * Histogram for the OPAL \f$\pi^0\f$ \f$\xi\f$ distribution
+ */
+ HistogramPtr _xipi0;
+
+ /**
+ * Histogram for the OPAL \f$\eta\f$ \f$x\f$ distribution
+ */
+ HistogramPtr _xeeta;
+
+ /**
+ * Histogram for the OPAL \f$\eta'\f$ \f$\xi\f$ distribution
+ */
+ HistogramPtr _xieta;
+
+ /**
+ * Histogram for the OPAL \f$\eta\f$ \f$x\f$ distribution
+ */
+ HistogramPtr _xeetap;
+
+ /**
+ * Histogram for the OPAL \f$\eta'\f$ \f$\xi\f$ distribution
+ */
+ HistogramPtr _xietap;
+
+ /**
+ * Histogram for the OPAL \f$\omega\f$ \f$x\f$ distribution
+ */
+ HistogramPtr _xeomega;
+
+ /**
+ * Histogram for the OPAL \f$\omega'\f$ \f$\xi\f$ distribution
+ */
+ HistogramPtr _xiomega;
+
+ /**
+ * Histogram for the OPAL \f$\rho^+\f$ \f$x\f$ distribution
+ */
+ HistogramPtr _xerhop;
+
+ /**
+ * Histogram for the OPAL \f$\rho^+\f$ \f$\xi\f$ distribution
+ */
+ HistogramPtr _xirhop;
+
+ /**
+ * Histogram for the OPAL \f$a_0^+\f$ \f$x\f$ distribution
+ */
+ HistogramPtr _xea_0p;
+
+ /**
+ * Histogram for the OPAL \f$a_0^+\f$ \f$\xi\f$ distribution
+ */
+ HistogramPtr _xia_0p;
+
+ /**
+ * Histogram for \f$D^0\f$ \f$x\f$ distribution
+ */
+ HistogramPtr _xeD0;
+
+ /**
+ * Histogram for \f$D^{*+}\f$ \f$x\f$ distribution
+ */
+ HistogramPtr _xeDstar;
+
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of MyIdentifiedParticleAnalysis. */
+template <>
+struct BaseClassTrait<Herwig::MyIdentifiedParticleAnalysis,1> {
+ /** Typedef of the first base class of MyIdentifiedParticleAnalysis. */
+ typedef AnalysisHandler NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the MyIdentifiedParticleAnalysis class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::MyIdentifiedParticleAnalysis>
+ : public ClassTraitsBase<Herwig::MyIdentifiedParticleAnalysis> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::MyIdentifiedParticleAnalysis"; }
+ /** Return the name(s) of the shared library (or libraries) be loaded to get
+ * access to the MyIdentifiedParticleAnalysis class and any other class on which it depends
+ * (except the base class). */
+ static string library() { return "MyEventShapes.so MyIdentifiedParticleAnalysis.so"; }
+};
+
+/** @endcond */
+
+}
+
+//#include "MyIdentifiedParticleAnalysis.icc"
+
+#endif /* HERWIG_MyIdentifiedParticleAnalysis_H */
diff --git a/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyLEPBMultiplicity.cc b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyLEPBMultiplicity.cc
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyLEPBMultiplicity.cc
@@ -0,0 +1,150 @@
+// -*- C++ -*-
+//
+// MyLEPBMultiplicity.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 MyLEPBMultiplicity class.
+//
+
+#include "MyLEPBMultiplicity.h"
+#include "ThePEG/Repository/EventGenerator.h"
+#include "ThePEG/EventRecord/Event.h"
+#include "ThePEG/PDT/EnumParticles.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "Herwig++/Utilities/StandardSelectors.h"
+
+using namespace Herwig;
+using namespace ThePEG;
+
+string BranchingInfo::bargraph(long N, BranchingInfo den)
+{
+ if (obsBranching == 0.0) return " ? ";
+ else if (nSigma(N,den) >= 6.0) return "-----|---->";
+ else if (nSigma(N,den) >= 5.0) return "-----|----*";
+ else if (nSigma(N,den) >= 4.0) return "-----|---*-";
+ else if (nSigma(N,den) >= 3.0) return "-----|--*--";
+ else if (nSigma(N,den) >= 2.0) return "-----|-*---";
+ else if (nSigma(N,den) >= 1.0) return "-----|*----";
+ else if (nSigma(N,den) > -1.0) return "-----*-----";
+ else if (nSigma(N,den) > -2.0) return "----*|-----";
+ else if (nSigma(N,den) > -3.0) return "---*-|-----";
+ else if (nSigma(N,den) > -4.0) return "--*--|-----";
+ else if (nSigma(N,den) > -5.0) return "-*---|-----";
+ else if (nSigma(N,den) > -6.0) return "*----|-----";
+ else return "<----|-----";
+}
+
+inline MyLEPBMultiplicity::MyLEPBMultiplicity() {
+ // B+
+ _data[521 ] = BranchingInfo(0.403, 0.009);
+ // B_s
+ _data[531 ] = BranchingInfo(0.103, 0.009);
+ // baryons
+ _data[5122] = BranchingInfo(0.091, 0.015);
+ // b's
+ _data[5] = BranchingInfo(0. , 0. );
+}
+
+void MyLEPBMultiplicity::analyze(tEventPtr event, long , int , int ) {
+ // extract the weakly decaying B hadrons using set to avoid double counting
+
+ string infile = "EPEM.dat";
+ ifstream normin;
+ string stringin = "";
+ double normfac = 1;
+ double stringdoub = 0;
+ bool next = 0, filerror = 0;
+ normin.open(infile.c_str());
+ if(!normin) { cerr << "Error: Failed to open file " << infile << endl; filerror = 1; normfac = 1.; }
+ if(!filerror) {
+ while(normin) {
+
+ normin >> stringin;
+
+ if(next) { normin >> stringdoub; normfac = stringdoub; break; }
+ if(stringin == "NORMFACTOR") { next = 1; }
+
+ }
+ }
+ double eventweight = generator()->currentEvent()->weight()*normfac;
+ set<PPtr> particles;
+ map <long,long> eventcount;
+ StepVector steps = event->primaryCollision()->steps();
+ steps[0]->select(inserter(particles), ThePEG::AllSelector());
+ unsigned int nb=0;
+ for(set<PPtr>::const_iterator cit=particles.begin();cit!=particles.end();++cit) {
+ if(abs((*cit)->id())==ParticleID::b) ++nb;
+ }
+ if(nb!=0) eventcount.insert(make_pair(5,nb));
+
+
+ particles.clear();
+ event->select(inserter(particles),WeakBHadronSelector());
+ for(set<PPtr>::const_iterator it = particles.begin();
+ it != particles.end(); ++it) {
+ long ID = abs( (*it)->id() );
+ //special for b baryons
+ if(ID!=511&&ID!=521&&ID!=531) ID=5122;
+ if (_data.find(ID) != _data.end()) {
+ eventcount.insert(make_pair(ID,0));
+ ++eventcount[ID]*eventweight;
+ // ++eventcount[ID];
+ }
+ }
+ for(map<long,long>::const_iterator it = eventcount.begin();
+ it != eventcount.end(); ++it) {
+ _data[it->first].actualCount += it->second*eventweight;
+ // _data[it->first].actualCount += it->second;
+ _data[it->first].sumofsquares += sqr(double(it->second));
+ }
+}
+
+NoPIOClassDescription<MyLEPBMultiplicity> MyLEPBMultiplicity::initMyLEPBMultiplicity;
+// Definition of the static class description member.
+
+void MyLEPBMultiplicity::Init() {
+
+ static ClassDocumentation<MyLEPBMultiplicity> documentation
+ ("There is no documentation for the MyLEPBMultiplicity class");
+
+}
+
+void MyLEPBMultiplicity::dofinish() {
+ string filename = generator()->filename() + ".Bmult";
+ ofstream outfile(filename.c_str());
+ outfile <<
+ "\nB branching fraction (compared to LEP data):\n"
+ " ID Name simMult obsMult obsErr Sigma\n";
+ long N = generator()->currentEventNumber() - 1;
+ BranchingInfo den = _data[5];
+ for (map<long,BranchingInfo>::const_iterator it = _data.begin();
+ it != _data.end();
+ ++it) {
+ if(it->first==5) continue;
+ BranchingInfo multiplicity = it->second;
+ string name = (it->first==5122 ? "b baryons" :
+ generator()->getParticleData(it->first)->PDGName() ) +" ";
+ ios::fmtflags oldFlags = outfile.flags();
+ outfile << std::scientific << std::showpoint
+ << std::setprecision(3)
+ << setw(7) << it->first << ' '
+ << setw(9) << name << ' '
+ << setw(2)
+ << multiplicity.simBranching(N,den) << " | "
+ << setw(2)
+ << multiplicity.obsBranching
+ << " +/- "
+ << setw(2) << multiplicity.obsError << ' '
+ << std::showpos << std::setprecision(1)
+ << multiplicity.nSigma(N,den) << ' '
+ << multiplicity.bargraph(N,den)
+ << std::noshowpos;
+ outfile << '\n';
+ outfile.flags(oldFlags);
+ }
+}
diff --git a/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyLEPBMultiplicity.h b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyLEPBMultiplicity.h
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyLEPBMultiplicity.h
@@ -0,0 +1,220 @@
+// -*- C++ -*-
+//
+// MyLEPBMultiplicity.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_MyLEPBMultiplicity_H
+#define HERWIG_MyLEPBMultiplicity_H
+//
+// This is the declaration of the MyLEPBMultiplicity class.
+//
+
+#include "ThePEG/Handlers/AnalysisHandler.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+
+/**
+ * Struct for the multiplcity data
+ */
+struct BranchingInfo {
+ /**
+ * Default constructor
+ * @param mult The observed multiplcity.
+ * @param error The error on the observed multiplicity
+ */
+ inline BranchingInfo(double mult=0.,double error=0.);
+
+ /**
+ * The observed multiplicity
+ */
+ double obsBranching;
+
+ /**
+ * The error on the observed multiplicity
+ */
+ double obsError;
+
+ /**
+ * Number of particles of this type
+ */
+ double actualCount;
+
+ /**
+ * Sum of squares of number per event for error
+ */
+ double sumofsquares;
+
+ /**
+ * The average fraction per quark
+ * @param N The number of events
+ * @param den The denominator to give the fraction
+ */
+ double simBranching(long N,BranchingInfo den=BranchingInfo());
+
+ /**
+ * The error on the average number per event
+ * @param N The number of events
+ * @param den The denominator to give the fraction
+ */
+ double simError(long N,BranchingInfo den=BranchingInfo());
+
+ /**
+ * Is the result more than \f$3\sigma\f$ from the experimental result
+ * @param N The number of events
+ * @param den The denominator to give the fraction
+ */
+ double nSigma(long N,BranchingInfo den=BranchingInfo());
+
+ /**
+ * Plot standard error in a simple barchart
+ * @param N The number of events
+ * @param den The denominator to give the fraction
+ */
+ string bargraph(long N,BranchingInfo den=BranchingInfo());
+};
+
+/**
+ * Here is the documentation of the MyLEPBBranching class.
+ *
+ * @see \ref MyLEPBMultiplicityInterfaces "The interfaces"
+ * defined for MyLEPBMultiplicity.
+ */
+class MyLEPBMultiplicity: public AnalysisHandler {
+
+public:
+
+ /**
+ * The default constructor.
+ */
+ inline MyLEPBMultiplicity();
+
+public:
+
+ /** @name Virtual functions required by the AnalysisHandler class. */
+ //@{
+ /**
+ * Analyze a given Event. Note that a fully generated event
+ * may be presented several times, if it has been manipulated in
+ * between. The default version of this function will call transform
+ * to make a lorentz transformation of the whole event, then extract
+ * all final state particles and call analyze(tPVector) of this
+ * analysis object and those of all associated analysis objects. The
+ * default version will not, however, do anything on events which
+ * have not been fully generated, or have been manipulated in any
+ * way.
+ * @param event pointer to the Event to be analyzed.
+ * @param ieve the event number.
+ * @param loop the number of times this event has been presented.
+ * If negative the event is now fully generated.
+ * @param state a number different from zero if the event has been
+ * manipulated in some way since it was last presented.
+ */
+ virtual void analyze(tEventPtr event, long ieve, int loop, int state);
+ //@}
+
+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();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ inline virtual IBPtr clone() const {return new_ptr(*this);}
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ inline virtual IBPtr fullclone() const {return new_ptr(*this);}
+ //@}
+
+protected:
+
+ /** @name Standard Interfaced functions. */
+ //@{
+ /**
+ * 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 static object used to initialize the description of this class.
+ * Indicates that this is an concrete class without persistent data.
+ */
+ static NoPIOClassDescription<MyLEPBMultiplicity> initMyLEPBMultiplicity;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ MyLEPBMultiplicity & operator=(const MyLEPBMultiplicity &);
+
+private:
+
+ /**
+ * Map of PDG codes to multiplicity info
+ */
+ map<long,BranchingInfo> _data;
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of MyLEPBMultiplicity. */
+template <>
+struct BaseClassTrait<Herwig::MyLEPBMultiplicity,1> {
+ /** Typedef of the first base class of MyLEPBMultiplicity. */
+ typedef AnalysisHandler NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the MyLEPBMultiplicity class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::MyLEPBMultiplicity>
+ : public ClassTraitsBase<Herwig::MyLEPBMultiplicity> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::MyLEPBMultiplicity"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * MyLEPBMultiplicity is implemented. It may also include several, space-separated,
+ * libraries if the class MyLEPBMultiplicity 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 "MyLEPBMultiplicity.so"; }
+};
+
+/** @endcond */
+
+}
+
+#include "MyLEPBMultiplicity.icc"
+
+#endif /* HERWIG_MyLEPBMultiplicity_H */
diff --git a/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyLEPBMultiplicity.icc b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyLEPBMultiplicity.icc
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyLEPBMultiplicity.icc
@@ -0,0 +1,42 @@
+// -*- C++ -*-
+//
+// MyLEPBMultiplicity.icc 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 inlined member functions of
+// the MyLEPBMultiplicity class.
+//
+
+namespace Herwig {
+
+inline BranchingInfo::BranchingInfo(double inmult,double inerror)
+ : obsBranching(inmult), obsError(inerror), actualCount(0),
+ sumofsquares(0.0)
+{}
+
+inline double BranchingInfo::simBranching(long N, BranchingInfo den) {
+ return den.actualCount>0 ?
+ double(actualCount) / double(den.actualCount) :
+ double(actualCount) / double(N) ;
+}
+
+inline double BranchingInfo::simError(long N, BranchingInfo den) {
+ double rn = N*( sumofsquares/double(N) - sqr(simBranching(N))) /
+ sqr(double(actualCount));
+ double rd = den.actualCount>0 ?
+ N*( den.sumofsquares/double(N) - sqr(den.simBranching(N))) /
+ sqr(double(den.actualCount)) : 0.;
+ return simBranching(N,den)*sqrt(rn+rd);
+}
+
+inline double BranchingInfo::nSigma(long N,BranchingInfo den) {
+ return obsBranching == 0.0 ?
+ 0.0 :
+ (simBranching(N,den) - obsBranching)
+ / sqrt(sqr(simError(N,den)) + sqr(obsError));
+}
+}
diff --git a/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyLEPEventShapes.cc b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyLEPEventShapes.cc
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyLEPEventShapes.cc
@@ -0,0 +1,666 @@
+// -*- C++ -*-
+//
+// MyLEPEventShapes.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 MyLEPEventShapes class.
+//
+
+#include "MyLEPEventShapes.h"
+#include "MyEventShapes.h"
+#include "ThePEG/EventRecord/Event.h"
+#include "ThePEG/Interface/Reference.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+#include "ThePEG/Repository/CurrentGenerator.h"
+
+using namespace Herwig;
+
+void MyLEPEventShapes::analyze(tEventPtr event, long ieve, int loop, int state) {
+ AnalysisHandler::analyze(event, ieve, loop, state);
+ if ( loop > 0 || state != 0 || !event ) return;
+ // get the final-state particles
+ tPVector hadrons=event->getFinalState();
+ // event shapes
+}
+
+LorentzRotation MyLEPEventShapes::transform(tEventPtr) const {
+ return LorentzRotation();
+ // Return the Rotation to the frame in which you want to perform the analysis.
+}
+
+void MyLEPEventShapes::analyze(const tPVector & particles) {
+ string infile = "EPEM.dat";
+ ifstream normin;
+ string stringin = "";
+ double normfac = 1;
+ double stringdoub = 0;
+ bool next = 0, filerror = 0;
+ normin.open(infile.c_str());
+ if(!normin) { cerr << "Error: Failed to open file " << infile << endl; filerror = 1; normfac = 1.; }
+ if(!filerror) {
+ while(normin) {
+
+ normin >> stringin;
+
+ if(next) { normin >> stringdoub; normfac = stringdoub; break; }
+ if(stringin == "NORMFACTOR") { next = 1; }
+
+ }
+ }
+
+ double eventweight = generator()->currentEvent()->weight()*normfac;
+
+ _shapes->reset(particles);
+ _omthr ->addWeighted( 1.-_shapes->thrust() ,eventweight);
+ _maj ->addWeighted( _shapes->thrustMajor() ,eventweight);
+ _min ->addWeighted( _shapes->thrustMinor() ,eventweight);
+ _obl ->addWeighted( _shapes->oblateness() ,eventweight);
+ _c ->addWeighted( _shapes->CParameter() ,eventweight);
+ _d ->addWeighted( _shapes->DParameter() ,eventweight);
+ _sph ->addWeighted( _shapes->sphericity() ,eventweight);
+ _apl ->addWeighted( _shapes->aplanarity() ,eventweight);
+ _pla ->addWeighted( _shapes->planarity() ,eventweight);
+ _mhi ->addWeighted( _shapes->Mhigh2() ,eventweight);
+ _mlo ->addWeighted( _shapes->Mlow2() ,eventweight);
+ _mdiff ->addWeighted( _shapes->Mdiff2() ,eventweight);
+ _bmax ->addWeighted( _shapes->Bmax() ,eventweight);
+ _bmin ->addWeighted( _shapes->Bmin() ,eventweight);
+ _bsum ->addWeighted( _shapes->Bsum() ,eventweight);
+ _bdiff ->addWeighted( _shapes->Bdiff() ,eventweight);
+}
+
+void MyLEPEventShapes::persistentOutput(PersistentOStream & os) const {
+ os << _shapes;
+}
+
+void MyLEPEventShapes::persistentInput(PersistentIStream & is, int) {
+ is >> _shapes;
+}
+
+ClassDescription<MyLEPEventShapes> MyLEPEventShapes::initMyLEPEventShapes;
+// Definition of the static class description member.
+
+void MyLEPEventShapes::Init() {
+
+ static ClassDocumentation<MyLEPEventShapes> documentation
+ ("The MyLEPEventShapes class compares event shapes at the Z mass"
+ "with experimental results");
+
+ static Reference<MyLEPEventShapes,MyEventShapes> interfaceMyEventShapes
+ ("MyEventShapes",
+ "Pointer to the object which calculates the event shapes",
+ &MyLEPEventShapes::_shapes, false, false, true, false, false);
+
+}
+
+void MyLEPEventShapes::dofinish() {
+ AnalysisHandler::dofinish();
+ string fname = generator()->filename() +
+ string("-") + name() + string(".top");
+ ofstream output(fname.c_str());
+ using namespace HistogramOptions;
+ _omthr->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "1-T compared to DELPHI data",
+ " ",
+ "1/SdS/d(1-T)",
+ " G G ",
+ "1-T",
+ " ");
+ _maj->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "Thrust Major compared to DELPHI data",
+ " ",
+ "1/SdS/dMajor",
+ " G G ",
+ "Major",
+ " ");
+ _min->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "Thrust Minor compared to DELPHI data",
+ " ",
+ "1/SdS/dMinor",
+ " G G ",
+ "Minor",
+ " ");
+ _obl->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "Oblateness compared to DELPHI data",
+ " ",
+ "1/SdS/dO",
+ " G G ",
+ "O",
+ " ");
+ _sph->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "Sphericity compared to DELPHI data",
+ " ",
+ "1/SdS/dS",
+ " G G ",
+ "S",
+ " ");
+ _apl->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "Aplanarity compared to DELPHI data",
+ " ",
+ "1/SdS/dA",
+ " G G ",
+ "A",
+ " ");
+ _pla->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "Planarity compared to DELPHI data",
+ " ",
+ "1/SdS/dP",
+ " G G ",
+ "P",
+ " ");
+ _c->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "C parameter compared to DELPHI data",
+ " ",
+ "1/SdS/dC",
+ " G G ",
+ "C",
+ " ");
+ _d->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "D parameter compared to DELPHI data",
+ " ",
+ "1/SdS/dD",
+ " G G ",
+ "D",
+ " ");
+ _mhi->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "High hemisphere mass compared to DELPHI data",
+ " ",
+ "1/SdS/dM0high1",
+ " G G X X",
+ "M0high1",
+ " X X");
+ _mlo->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "Low hemisphere mass compared to DELPHI data",
+ " ",
+ "1/SdS/dM0low1",
+ " G G X X",
+ "M0low1",
+ " X X");
+ _mdiff->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "Difference in hemisphere masses compared to DELPHI data",
+ " ",
+ "1/SdS/dM0diff1",
+ " G G X X",
+ "M0diff1",
+ " X X");
+ _bmax->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "Wide jet broadening measure compared to DELPHI data",
+ " ",
+ "1/SdS/dB0max1",
+ " G G X X",
+ "B0max1",
+ " X X");
+ _bmin->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "Narrow jet broadening measure compared to DELPHI data",
+ " ",
+ "1/SdS/dB0min1",
+ " G G X X",
+ "B0min1",
+ " X X");
+ _bsum->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "Sum of jet broadening measures compared to DELPHI data",
+ " ",
+ "1/SdS/dB0sum1",
+ " G G X X",
+ "B0sum1",
+ " X X");
+ _bdiff->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "Difference of jet broadenings measure compared to DELPHI data",
+ " ",
+ "1/SdS/dB0diff1",
+ " G G X X",
+ "B0diff1",
+ " X X");
+ // chi squareds
+ double chisq=0.,minfrac=0.05;
+ unsigned int ndegrees;
+ _omthr->chiSquared(chisq,ndegrees,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << ndegrees
+ << " degrees of freedom for DELPHI thrust distribution\n";
+ _maj->chiSquared(chisq,ndegrees,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << ndegrees
+ << " degrees of freedom for DELPHI major distribution\n";
+ _min->chiSquared(chisq,ndegrees,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << ndegrees
+ << " degrees of freedom for DELPHI minor distribution\n";
+ _obl->chiSquared(chisq,ndegrees,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << ndegrees
+ << " degrees of freedom for DELPHI oblateness distribution\n";
+ _sph->chiSquared(chisq,ndegrees,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << ndegrees
+ << " degrees of freedom for DELPHI sphericity distribution\n";
+ _apl->chiSquared(chisq,ndegrees,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << ndegrees
+ << " degrees of freedom for DELPHI aplanarity distribution\n";
+ _pla->chiSquared(chisq,ndegrees,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << ndegrees
+ << " degrees of freedom for DELPHI planarity distribution\n";
+ _c->chiSquared(chisq,ndegrees,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << ndegrees
+ << " degrees of freedom for DELPHI C distribution\n";
+ _d->chiSquared(chisq,ndegrees,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << ndegrees
+ << " degrees of freedom for DELPHI D distribution\n";
+ _mhi->chiSquared(chisq,ndegrees,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << ndegrees
+ << " degrees of freedom for DELPHI m_high distribution\n";
+ _mlo->chiSquared(chisq,ndegrees,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << ndegrees
+ << " degrees of freedom for DELPHI m_low distribution\n";
+ _mdiff->chiSquared(chisq,ndegrees,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << ndegrees
+ << " degrees of freedom for DELPHI m_diff distribution\n";
+ _bmax->chiSquared(chisq,ndegrees,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << ndegrees
+ << " degrees of freedom for DELPHI B_max distribution\n";
+ _bmin->chiSquared(chisq,ndegrees,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << ndegrees
+ << " degrees of freedom for DELPHI B_min distribution\n";
+ _bsum->chiSquared(chisq,ndegrees,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << ndegrees
+ << " degrees of freedom for DELPHI B_sum distribution\n";
+ _bdiff->chiSquared(chisq,ndegrees,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << ndegrees
+ << " degrees of freedom for DELPHI B_diff distribution\n";
+}
+
+void MyLEPEventShapes::doinitrun() {
+ AnalysisHandler::doinitrun();
+ vector<double> bins,data,error;
+ // 1-T
+ double vals1[] = {0.000, 0.010, 0.020, 0.030, 0.040,
+ 0.050, 0.060, 0.070, 0.080, 0.090,
+ 0.100, 0.120, 0.140, 0.160, 0.180,
+ 0.200, 0.250, 0.300, 0.350, 0.400,
+ 0.500};
+ double data1[]= { 1.030,10.951,17.645,14.192,10.009,
+ 7.572, 5.760, 4.619, 3.792, 3.176,
+ 2.456, 1.825, 1.401, 1.074, 0.8262,
+ 0.5525,0.3030,0.1312,0.0238,0.0007};
+ double error1stat[]={0.019 ,0.051 ,0.066 ,0.061 ,0.050 ,
+ 0.044 ,0.038 ,0.034 ,0.031 ,0.028 ,
+ 0.018 ,0.015 ,0.013 ,0.011 ,0.0100 ,
+ 0.0051 ,0.0038 ,0.0025 ,0.0012 ,0.0002 };
+ double error1syst[]={0.076 , 0.527 , 0.547 , 0.292 , 0.152 ,
+ 0.101 , 0.076 , 0.062 , 0.051 , 0.042 ,
+ 0.032 , 0.022 , 0.016 , 0.011 , 0.0083,
+ 0.0065 , 0.0058, 0.0044, 0.0014, 0.0001};
+ double error1[20];
+ for(unsigned int ix=0;ix<20;++ix){error1[ix]=sqrt(sqr(error1stat[ix])+
+ sqr(error1syst[ix]));}
+ bins = vector<double>(vals1 ,vals1 +21);
+ data = vector<double>(data1 ,data1 +20);
+ error = vector<double>(error1,error1+20);
+ _omthr= new_ptr(Histogram(bins,data,error));
+ // major
+ double vals2[] = {0.000, 0.020, 0.040, 0.050, 0.060,
+ 0.070, 0.080, 0.100, 0.120, 0.140,
+ 0.160, 0.200, 0.240, 0.280, 0.320,
+ 0.360, 0.400, 0.440, 0.480, 0.520,
+ 0.560, 0.600, 0.640};
+ double data2[]={0.00040 ,0.0590 ,0.642 ,2.178 ,4.303 ,
+ 5.849 ,6.889 ,6.342 ,4.890 ,3.900 ,
+ 2.960 ,2.124 ,1.5562 ,1.1807 ,0.8693,
+ 0.6493 ,0.4820 ,0.3493 ,0.2497 ,0.1489,
+ 0.0714 ,0.0203};
+ double error2stat[]={0.00090 ,0.0030 ,0.013 ,0.024 ,0.034 ,
+ 0.039 ,0.030 ,0.028 ,0.024 ,0.021 ,
+ 0.013 ,0.011 ,0.0095 ,0.0083 ,0.0071 ,
+ 0.0061 ,0.0052 ,0.0044 ,0.0037 ,0.0028 ,
+ 0.0019 ,0.0010};
+ double error2syst[]={0.00005 ,0.0058 ,0.028 ,0.086 ,0.155 ,
+ 0.192 ,0.194 ,0.143 ,0.085 ,0.050 ,
+ 0.030 ,0.021 ,0.0156 ,0.0118 ,0.0087 ,
+ 0.0065 ,0.0048 ,0.0055 ,0.0065 ,0.0058 ,
+ 0.0038 ,0.0014};
+ double error2[22];
+ for(unsigned int ix=0;ix<22;++ix){error2[ix]=sqrt(sqr(error2stat[ix])+
+ sqr(error2syst[ix]));}
+ bins = vector<double>(vals2 ,vals2 +23);
+ data = vector<double>(data2 ,data2 +22);
+ error = vector<double>(error2,error2+22);
+ _maj= new_ptr(Histogram(bins,data,error));
+ // minor
+ double vals3[] = {0.000, 0.020, 0.040, 0.050, 0.060,
+ 0.070, 0.080, 0.100, 0.120, 0.140,
+ 0.160, 0.200, 0.240, 0.280, 0.320,
+ 0.400};
+ double data3[]={ 0.0156 , 1.236 , 5.706 , 9.714 ,12.015 ,
+ 12.437 ,10.404 , 6.918 , 4.250 , 2.517 ,
+ 1.2561 , 0.4895 , 0.2112 , 0.0879 , 0.0250 };
+ double error3stat[]={0.0017 ,0.013 ,0.037 ,0.048 ,0.054 ,
+ 0.055 ,0.036 ,0.029 ,0.023 ,0.017 ,
+ 0.0086 ,0.0054 ,0.0036 ,0.0023 ,0.0009};
+ double error3syst[]={0.0036,0.066 ,0.073 ,0.125 ,0.155 ,
+ 0.161 ,0.136 ,0.092 ,0.058 ,0.035 ,
+ 0.0187,0.0080,0.0039,0.0018,0.0006};
+ double error3[15];
+ for(unsigned int ix=0;ix<15;++ix){error3[ix]=sqrt(sqr(error3stat[ix])+
+ sqr(error3syst[ix]));}
+ bins = vector<double>(vals3 ,vals3 +16);
+ data = vector<double>(data3 ,data3 +15);
+ error = vector<double>(error3,error3+15);
+ _min= new_ptr(Histogram(bins,data,error));
+ // oblateness
+ double vals4[] = {0.000, 0.020, 0.040, 0.060, 0.080,
+ 0.100, 0.120, 0.140, 0.160, 0.200,
+ 0.240, 0.280, 0.320, 0.360, 0.400,
+ 0.440, 0.520};
+ double data4[]={ 9.357 ,11.508 , 7.215 , 4.736 , 3.477 ,
+ 2.696 , 2.106 , 1.690 , 1.2648 , 0.8403 ,
+ 0.5674 , 0.3842 , 0.2573 , 0.1594 , 0.0836 ,
+ 0.0221 };
+ double error4stat[]={0.036 ,0.038 ,0.029 ,0.023 ,0.020 ,
+ 0.018 ,0.016 ,0.014 ,0.0085 ,0.0069 ,
+ 0.0056 ,0.0046 ,0.0037 ,0.0029 ,0.0020 ,
+ 0.0007};
+ double error4syst[]={0.178 ,0.140 ,0.072 ,0.047 ,0.035 ,
+ 0.027 ,0.021 ,0.017 ,0.0126,0.0087,
+ 0.0065,0.0050,0.0043,0.0037,0.0030,
+ 0.0015};
+ double error4[16];
+ for(unsigned int ix=0;ix<16;++ix){error4[ix]=sqrt(sqr(error4stat[ix])+
+ sqr(error4syst[ix]));}
+ bins = vector<double>(vals4 ,vals4 +17);
+ data = vector<double>(data4 ,data4 +16);
+ error = vector<double>(error4,error4+16);
+ _obl= new_ptr(Histogram(bins,data,error));
+ // sphericity
+ double vals5[] = {0.000, 0.010, 0.020, 0.030, 0.040,
+ 0.050, 0.060, 0.080, 0.100, 0.120,
+ 0.160, 0.200, 0.250, 0.300, 0.350,
+ 0.400, 0.500, 0.600, 0.700, 0.850};
+ double data5[]={16.198 ,20.008 ,12.896 , 8.237 , 5.885 ,
+ 4.458 , 3.272 , 2.290 , 1.699 , 1.2018 ,
+ 0.7988 , 0.5610 , 0.3926 , 0.2810 , 0.2099 ,
+ 0.1441 , 0.0842 , 0.04160 , 0.00758 };
+ double error5stat[]={0.067 ,0.072 ,0.056 ,0.043 ,0.037 ,
+ 0.032 ,0.019 ,0.016 ,0.014 ,0.0082 ,
+ 0.0067 ,0.0050 ,0.0042 ,0.0035 ,0.0030 ,
+ 0.0018 ,0.0013 ,0.00092 ,0.00032};
+ double error5syst[]={0.208 ,0.246 ,0.153 ,0.094 ,0.065 ,
+ 0.048 ,0.034 ,0.023 ,0.017 ,0.0120 ,
+ 0.0080 ,0.0063 ,0.0051 ,0.0043 ,0.0037 ,
+ 0.0032 ,0.0023 ,0.00129,0.00024};
+ double error5[19];
+ for(unsigned int ix=0;ix<19;++ix){error5[ix]=sqrt(sqr(error5stat[ix])+
+ sqr(error5syst[ix]));}
+ bins = vector<double>(vals5 ,vals5 +20);
+ data = vector<double>(data5 ,data5 +19);
+ error = vector<double>(error5,error5+19);
+ _sph=new_ptr(Histogram(bins,data,error));
+ // aplanarity
+ double vals6[] = {0.000, 0.005, 0.010, 0.015, 0.020,
+ 0.030, 0.040, 0.060, 0.080, 0.100,
+ 0.120, 0.140, 0.160, 0.200, 0.250,
+ 0.300};
+ double data6[]={75.10 ,55.31 ,26.03 ,13.927 , 6.768 ,
+ 3.014 , 1.281 , 0.5181 , 0.2619 , 0.1461 ,
+ 0.0758 , 0.0467 , 0.0234 , 0.00884 , 0.00310 };
+ double error6stat[]={0.19 ,0.17 ,0.11 ,0.079 ,0.038 ,
+ 0.025 ,0.012 ,0.0075 ,0.0054 ,0.0041 ,
+ 0.0029 ,0.0023 ,0.0011 ,0.00061 ,0.00040 };
+ double error6syst[]={0.75 ,0.55 ,0.28 ,0.176 ,0.098 ,
+ 0.056 ,0.035 ,0.0188 ,0.0118 ,0.0079 ,
+ 0.0043 ,0.0027 ,0.0014 ,0.00052,0.00018};
+ double error6[19];
+ for(unsigned int ix=0;ix<19;++ix){error6[ix]=sqrt(sqr(error6stat[ix])+
+ sqr(error6syst[ix]));}
+ bins = vector<double>(vals6 ,vals6 +16);
+ data = vector<double>(data6 ,data6 +15);
+ error = vector<double>(error6,error6+15);
+ _apl= new_ptr(Histogram(bins,data,error));
+ // planarity
+ double vals7[] = {0.000, 0.005, 0.010, 0.015, 0.020,
+ 0.025, 0.030, 0.035, 0.040, 0.050,
+ 0.060, 0.080, 0.100, 0.120, 0.160,
+ 0.200, 0.250, 0.300, 0.350, 0.400,
+ 0.500};
+ double data7[]={68.69 ,31.66 ,17.091 ,11.370 , 8.417 ,
+ 6.578 , 5.479 , 4.493 , 3.610 , 2.749 ,
+ 1.987 , 1.362 , 1.008 , 0.6676 , 0.4248 ,
+ 0.2692 , 0.1742 , 0.1042 , 0.0566 , 0.0145 };
+ double error7stat[]={0.19 ,0.12 ,0.088 ,0.072 ,0.062 ,
+ 0.055 ,0.050 ,0.045 ,0.029 ,0.025 ,
+ 0.015 ,0.012 ,0.011 ,0.0061 ,0.0048 ,
+ 0.0034 ,0.0028 ,0.0021 ,0.0015 ,0.0006};
+ double error7syst[]={0.74 ,0.35 ,0.188 ,0.127 ,0.095 ,
+ 0.075 ,0.063 ,0.052 ,0.042 ,0.033 ,
+ 0.024 ,0.017 ,0.013 ,0.0093,0.0063,
+ 0.0042 ,0.0029,0.0019,0.0011,0.0003};
+ double error7[20];
+ for(unsigned int ix=0;ix<20;++ix){error7[ix]=sqrt(sqr(error7stat[ix])+
+ sqr(error7syst[ix]));}
+ bins = vector<double>(vals7 ,vals7 +21);
+ data = vector<double>(data7 ,data7 +20);
+ error = vector<double>(error7,error7+20);
+ _pla= new_ptr(Histogram(bins,data,error));
+ // C
+ double vals8[] = {0.000, 0.040, 0.080, 0.120, 0.160,
+ 0.200, 0.240, 0.280, 0.320, 0.360,
+ 0.400, 0.440, 0.480, 0.520, 0.560,
+ 0.600, 0.640, 0.680, 0.720, 0.760,
+ 0.800, 0.840, 0.880, 0.920};
+ double data8[]={0.0881 ,1.5383 ,3.909 ,3.833 ,2.835 ,
+ 2.164 ,1.716 ,1.3860 ,1.1623 ,0.9720 ,
+ 0.8349 ,0.7161 ,0.6205 ,0.5441 ,0.4844 ,
+ 0.4209 ,0.3699 ,0.3286 ,0.2813 ,0.2178 ,
+ 0.1287 ,0.0542 ,0.0212 };
+ double error8stat[]={0.0030 ,0.0100 ,0.016 ,0.016 ,0.013 ,
+ 0.012 ,0.010 ,0.0092 ,0.0084 ,0.0077 ,
+ 0.0072 ,0.0066 ,0.0061 ,0.0057 ,0.0054 ,
+ 0.0050 ,0.0046 ,0.0044 ,0.0040 ,0.0033 ,
+ 0.0026 ,0.0016 ,0.0009};
+ double error8syst[]={0.0067,0.0831,0.142 ,0.088 ,0.040 ,
+ 0.022 ,0.017 ,0.0139,0.0116,0.0097,
+ 0.0083,0.0072,0.0062,0.0054,0.0050,
+ 0.0063,0.0079,0.0099,0.0129,0.0151,
+ 0.0130,0.0076,0.0040};
+ double error8[23];
+ for(unsigned int ix=0;ix<23;++ix){error8[ix]=sqrt(sqr(error8stat[ix])+
+ sqr(error8syst[ix]));}
+ bins = vector<double>(vals8 ,vals8 +24);
+ data = vector<double>(data8 ,data8 +23);
+ error = vector<double>(error8,error8+23);
+ _c= new_ptr(Histogram(bins,data,error));
+ // D
+ double vals9[] = {0.000, 0.008, 0.016, 0.030, 0.044,
+ 0.066, 0.088, 0.112, 0.136, 0.162,
+ 0.188, 0.218, 0.248, 0.284, 0.320,
+ 0.360, 0.400, 0.450, 0.500, 0.560,
+ 0.620, 0.710, 0.800};
+ double data9[]={22.228 ,22.766 ,12.107 , 6.879 , 4.284 ,
+ 2.727 , 1.909 , 1.415 , 1.051 , 0.7977 ,
+ 0.6155 , 0.4566 , 0.3341 , 0.2452 , 0.1774 ,
+ 0.1234 , 0.0902 , 0.0603 , 0.0368 , 0.0222 ,
+ 0.0128 , 0.0052 };
+ double error9stat[]={0.082 ,0.085 ,0.047 ,0.035 ,0.022 ,
+ 0.018 ,0.014 ,0.012 ,0.010 ,0.0089 ,
+ 0.0073 ,0.0063 ,0.0049 ,0.0042 ,0.0033 ,
+ 0.0028 ,0.0021 ,0.0017 ,0.0012 ,0.0009 ,
+ 0.0006 ,0.0004};
+ double error9syst[]={0.868 ,0.440 ,0.150 ,0.079 ,0.053 ,
+ 0.036 ,0.028 ,0.022 ,0.018 ,0.0145,
+ 0.0117 ,0.0089,0.0065,0.0049,0.0037 ,
+ 0.0028,0.0023 ,0.0018,0.0013,0.0009,
+ 0.0006,0.0003};
+ double error9[22];
+ for(unsigned int ix=0;ix<22;++ix){error9[ix]=sqrt(sqr(error9stat[ix])+
+ sqr(error9syst[ix]));}
+ bins = vector<double>(vals9 ,vals9 +23);
+ data = vector<double>(data9 ,data9 +22);
+ error = vector<double>(error9,error9+22);
+ _d= new_ptr(Histogram(bins,data,error));
+ // M high
+ double vals10[] = {0.000, 0.010, 0.020, 0.030, 0.040,
+ 0.050, 0.060, 0.080, 0.100, 0.120,
+ 0.140, 0.160, 0.200, 0.250, 0.300,
+ 0.350, 0.400};
+ double data10[]={ 1.994 ,18.580 ,20.678 ,13.377 , 8.965 ,
+ 6.558 , 4.515 , 2.914 , 1.991 , 1.406 ,
+ 1.010 , 0.6319 , 0.3085 , 0.1115 , 0.0184 ,
+ 0.0008 };
+ double error10stat[]={0.027 ,0.065 ,0.076 ,0.060 ,0.049 ,
+ 0.041 ,0.024 ,0.019 ,0.016 ,0.013 ,
+ 0.011 ,0.0063 ,0.0039 ,0.0022 ,0.0008 ,
+ 0.0002 };
+ double error10syst[]={0.166 ,0.709 ,0.729 ,0.412 ,0.239 ,
+ 0.151 ,0.082 ,0.037 ,0.020 ,0.014 ,
+ 0.010 ,0.0063,0.0051,0.0039,0.0012,
+ 0.0001};
+ double error10[16];
+ for(unsigned int ix=0;ix<16;++ix){error10[ix]=sqrt(sqr(error10stat[ix])+
+ sqr(error10syst[ix]));}
+ bins = vector<double>(vals10 ,vals10 +17);
+ data = vector<double>(data10 ,data10 +16);
+ error = vector<double>(error10,error10+16);
+ _mhi= new_ptr(Histogram(bins,data,error));
+ // M low
+ double vals11[] = {0.000, 0.010, 0.020, 0.030, 0.040,
+ 0.050, 0.060, 0.080, 0.100, 0.120};
+ double data11[]={23.414 ,39.12 ,18.080 , 7.704 , 3.922 ,
+ 2.128 , 1.013 , 0.3748 , 0.1412 };
+ double error11stat[]={0.074 ,0.11 ,0.081 ,0.052 ,0.036 ,
+ 0.026 ,0.013 ,0.0079 ,0.0050};
+ double error11syst[]={1.595 ,2.65 ,1.215 ,0.514 ,0.260 ,
+ 0.140 ,0.066 ,0.0241,0.0089};
+ double error11[9];
+ for(unsigned int ix=0;ix<9;++ix){error11[ix]=sqrt(sqr(error11stat[ix])+
+ sqr(error11syst[ix]));}
+ bins = vector<double>(vals11 ,vals11 +10);
+ data = vector<double>(data11 ,data11 + 9);
+ error = vector<double>(error11,error11+ 9);
+ _mlo= new_ptr(Histogram(bins,data,error));
+ // M diff
+ double vals12[] = {0.000, 0.010, 0.020, 0.030, 0.040,
+ 0.060, 0.080, 0.120, 0.160, 0.200,
+ 0.250, 0.300, 0.350, 0.400};
+ double data12[]={35.393 ,20.745 ,11.426 , 7.170 , 4.344 ,
+ 2.605 , 1.4238 , 0.7061 , 0.3831 , 0.1836 ,
+ 0.0579 , 0.0075 , 0.0003};
+ double error12stat[]={0.092 ,0.071 ,0.052 ,0.041 ,0.023 ,
+ 0.017 ,0.0092 ,0.0064 ,0.0046 ,0.0028 ,
+ 0.0015 ,0.0006 ,0.0002};
+ double error12syst[]={0.354 ,0.207 ,0.114 ,0.072 ,0.043 ,
+ 0.026 ,0.0142,0.0071,0.0044,0.0032,
+ 0.0018,0.0006,0.0001};
+ double error12[13];
+ for(unsigned int ix=0;ix<13;++ix){error12[ix]=sqrt(sqr(error12stat[ix])+
+ sqr(error12syst[ix]));}
+ bins = vector<double>(vals12 ,vals12 +14);
+ data = vector<double>(data12 ,data12 +13);
+ error = vector<double>(error12,error12+13);
+ _mdiff= new_ptr(Histogram(bins,data,error));
+ // Bmax
+ double vals13[] = {0.010, 0.020, 0.030, 0.040, 0.050,
+ 0.060, 0.070, 0.080, 0.100, 0.120,
+ 0.140, 0.170, 0.200, 0.240, 0.280,
+ 0.320};
+ double data13[]={0.6707 , 7.538 ,14.690 ,13.942 ,11.298 ,
+ 9.065 , 7.387 , 5.445 , 3.796 , 2.670 ,
+ 1.756 , 1.0580 , 0.5288 , 0.1460 , 0.0029 };
+ double error13stat[]={0.0096 ,0.038 ,0.058 ,0.057 ,0.053 ,
+ 0.048 ,0.043 ,0.026 ,0.022 ,0.018 ,
+ 0.012 ,0.0092 ,0.0056 ,0.0028 ,0.0004};
+ double error13syst[]={0.1077,0.809 ,0.745 ,0.592 ,0.379 ,
+ 0.266 ,0.222 ,0.176 ,0.127 ,0.087 ,
+ 0.051 ,0.0218,0.0053,0.0071,0.0003};
+ double error13[15];
+ for(unsigned int ix=0;ix<15;++ix){error13[ix]=sqrt(sqr(error13stat[ix])+
+ sqr(error13syst[ix]));}
+ bins = vector<double>(vals13 ,vals13 +16);
+ data = vector<double>(data13 ,data13 +15);
+ error = vector<double>(error13,error13+15);
+ _bmax= new_ptr(Histogram(bins,data,error));
+ // Bmin
+ double vals14[] = {0.000, 0.010, 0.020, 0.030, 0.040,
+ 0.050, 0.060, 0.080, 0.100, 0.120,
+ 0.150, 0.180};
+ double data14[]={0.645 ,11.169 ,28.908 ,25.972 ,14.119 ,
+ 7.500 , 3.405 , 1.320 , 0.5448 , 0.1916 ,
+ 0.0366};
+ double error14stat[]={0.010 ,0.045 ,0.082 ,0.083 ,0.061 ,
+ 0.044 ,0.021 ,0.013 ,0.0082 ,0.0040 ,
+ 0.0017};
+ double error14syst[]={0.096 ,1.006 ,1.823 ,1.478 ,0.860 ,
+ 0.494 ,0.233 ,0.089 ,0.0328,0.0104,
+ 0.0034};
+ double error14[11];
+ for(unsigned int ix=0;ix<11;++ix){error14[ix]=sqrt(sqr(error14stat[ix])+
+ sqr(error14syst[ix]));}
+ bins = vector<double>(vals14 ,vals14 +12);
+ data = vector<double>(data14 ,data14 +11);
+ error = vector<double>(error14,error14+11);
+ _bmin= new_ptr(Histogram(bins,data,error));
+ // Bsum
+ double vals15[] = {0.020, 0.030, 0.040, 0.050, 0.060,
+ 0.070, 0.080, 0.090, 0.100, 0.110,
+ 0.130, 0.150, 0.170, 0.190, 0.210,
+ 0.240, 0.270, 0.300, 0.330, 0.360};
+ double data15[]={0.2030 ,1.628 ,4.999 ,8.190 ,9.887 ,
+ 9.883 ,9.007 ,7.746 ,6.714 ,5.393 ,
+ 3.998 ,2.980 ,2.294 ,1.747 ,1.242 ,
+ 0.8125 ,0.4974 ,0.2285 ,0.0732 };
+ double error15stat[]={0.0055 ,0.015 ,0.031 ,0.041 ,0.047 ,
+ 0.049 ,0.047 ,0.044 ,0.041 ,0.026 ,
+ 0.023 ,0.019 ,0.017 ,0.015 ,0.010 ,
+ 0.0080 ,0.0062 ,0.0041 ,0.0024};
+ double error15syst[]={0.0383,0.183 ,0.463 ,0.644 ,0.661 ,
+ 0.564 ,0.443 ,0.332 ,0.255 ,0.180 ,
+ 0.125 ,0.098 ,0.085 ,0.075 ,0.063 ,
+ 0.0469,0.0296,0.0119,0.0007};
+ double error15[19];
+ for(unsigned int ix=0;ix<19;++ix){error15[ix]=sqrt(sqr(error15stat[ix])+
+ sqr(error15syst[ix]));}
+ bins = vector<double>(vals15 ,vals15 +20);
+ data = vector<double>(data15 ,data15 +19);
+ error = vector<double>(error15,error15+19);
+ _bsum= new_ptr(Histogram(bins,data,error));
+ // Bdiff
+ double vals16[] = {0.000, 0.010, 0.020, 0.030, 0.040,
+ 0.050, 0.060, 0.070, 0.080, 0.090,
+ 0.100, 0.120, 0.140, 0.160, 0.180,
+ 0.200, 0.240, 0.280};
+ double data16[]={26.630 ,18.684 ,12.343 , 8.819 , 6.688 ,
+ 5.111 , 4.071 , 3.271 , 2.681 , 2.233 ,
+ 1.647 , 1.111 , 0.7618 , 0.5138 , 0.3167 ,
+ 0.1265 , 0.0117};
+ double error16stat[]={0.081 ,0.066 ,0.054 ,0.046 ,0.040 ,
+ 0.035 ,0.031 ,0.028 ,0.025 ,0.023 ,
+ 0.014 ,0.011 ,0.0095 ,0.0078 ,0.0062 ,
+ 0.0026 ,0.0008};
+ double error16syst[]={0.459 ,0.292 ,0.186 ,0.134 ,0.106 ,
+ 0.084 ,0.068 ,0.054 ,0.043 ,0.035 ,
+ 0.026 ,0.019 ,0.0144,0.0119,0.0098,
+ 0.0056,0.0008};
+ double error16[17];
+ for(unsigned int ix=0;ix<17;++ix){error16[ix]=sqrt(sqr(error16stat[ix])+
+ sqr(error16syst[ix]));}
+ bins = vector<double>(vals16 ,vals16 +18);
+ data = vector<double>(data16 ,data16 +17);
+ error = vector<double>(error16,error16+17);
+ _bdiff= new_ptr(Histogram(bins,data,error));
+}
diff --git a/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyLEPEventShapes.h b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyLEPEventShapes.h
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyLEPEventShapes.h
@@ -0,0 +1,273 @@
+// -*- C++ -*-
+//
+// MyLEPEventShapes.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_MyLEPEventShapes_H
+#define HERWIG_MyLEPEventShapes_H
+//
+// This is the declaration of the MyLEPEventShapes class.
+//
+
+#include "ThePEG/Handlers/AnalysisHandler.h"
+#include "ThePEG/Vectors/Lorentz5Vector.h"
+#include "MyEventShapes.h"
+#include "Herwig++/Utilities/Histogram.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * The MyLEPEventShapes class performs the analysis of global event shapes and
+ * compares with LEP data. This handler is solely intended as a slave
+ * handler for the MyEventShapesMasterAnalysis class.
+ *
+ * @see \ref MyLEPEventShapesInterfaces "The interfaces"
+ * defined for MyLEPEventShapes
+ */
+class MyLEPEventShapes: public AnalysisHandler {
+
+public:
+
+ /** @name Virtual functions required by the AnalysisHandler class. */
+ //@{
+ /**
+ * Analyze a given Event. Note that a fully generated event
+ * may be presented several times, if it has been manipulated in
+ * between. The default version of this function will call transform
+ * to make a lorentz transformation of the whole event, then extract
+ * all final state particles and call analyze(tPVector) of this
+ * analysis object and those of all associated analysis objects. The
+ * default version will not, however, do anything on events which
+ * have not been fully generated, or have been manipulated in any
+ * way.
+ * @param event pointer to the Event to be analyzed.
+ * @param ieve the event number.
+ * @param loop the number of times this event has been presented.
+ * If negative the event is now fully generated.
+ * @param state a number different from zero if the event has been
+ * manipulated in some way since it was last presented.
+ */
+ virtual void analyze(tEventPtr event, long ieve, int loop, int state);
+
+ /**
+ * Transform the event to the desired Lorentz frame and return the
+ * corresponding LorentzRotation.
+ * @param event a pointer to the Event to be transformed.
+ * @return the LorentzRotation used in the transformation.
+ */
+ virtual LorentzRotation transform(tEventPtr event) const;
+
+ /**
+ * Analyze the given vector of particles. The default version calls
+ * analyze(tPPtr) for each of the particles.
+ * @param particles the vector of pointers to particles to be analyzed
+ */
+ virtual void analyze(const tPVector & particles);
+
+ using AnalysisHandler::analyze;
+ //@}
+
+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.
+ */
+ inline virtual IBPtr clone() const {return new_ptr(*this);}
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ inline virtual IBPtr fullclone() const {return new_ptr(*this);}
+ //@}
+
+protected:
+
+ /** @name Standard Interfaced functions. */
+ //@{
+ /**
+ * 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 static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<MyLEPEventShapes> initMyLEPEventShapes;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ MyLEPEventShapes & operator=(const MyLEPEventShapes &);
+
+private:
+
+ /**
+ * Histogram for \f$1-T\f$ distribution.
+ */
+ HistogramPtr _omthr;
+
+ /**
+ * Histogram for the major distribution
+ */
+ HistogramPtr _maj;
+
+ /**
+ * Histogram for the minor distribution
+ */
+ HistogramPtr _min;
+
+ /**
+ * Histogram for the oblateness distribution
+ */
+ HistogramPtr _obl;
+
+ /**
+ * Histogram for the sphericity distribution
+ */
+ HistogramPtr _sph;
+
+ /**
+ * Histogram for the aplanarity distribution
+ */
+ HistogramPtr _apl;
+
+ /**
+ * Histogram for the planarity distribution
+ */
+ HistogramPtr _pla;
+
+ /**
+ * Histogram for the C distribution
+ */
+ HistogramPtr _c;
+
+ /**
+ * Histogram for the D distribution
+ */
+ HistogramPtr _d;
+
+ /**
+ * Histogram for the \f$M_{\rm high}\f$ distribution
+ */
+ HistogramPtr _mhi;
+
+ /**
+ * Histogram for the \f$M_{\rm low}\f$ distribution
+ */
+ HistogramPtr _mlo;
+
+ /**
+ * Histogram for the \f$M_{\rm high}-M_{\rm low}\f$ distribution
+ */
+ HistogramPtr _mdiff;
+
+ /**
+ * Histogram for the \f$B_{\rm max}\f$ distribution
+ */
+ HistogramPtr _bmax;
+
+ /**
+ * Histogram for the \f$B_{\rm min}\f$ distribution
+ */
+ HistogramPtr _bmin;
+
+ /**
+ * Histogram for the \f$B_{\rm max}+B_{\rm min}\f$ distribution
+ */
+ HistogramPtr _bsum;
+
+ /**
+ * Histogram for the \f$B_{\rm max}-B_{\rm min}\f$ distribution
+ */
+ HistogramPtr _bdiff;
+
+ /**
+ * Pointer to the object which calculates the event shapes
+ */
+ MyEventShapesPtr _shapes;
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of MyLEPEventShapes. */
+template <>
+struct BaseClassTrait<Herwig::MyLEPEventShapes,1> {
+ /** Typedef of the first base class of MyLEPEventShapes. */
+ typedef AnalysisHandler NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the MyLEPEventShapes class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::MyLEPEventShapes>
+ : public ClassTraitsBase<Herwig::MyLEPEventShapes> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::MyLEPEventShapes"; }
+ /** Return the name(s) of the shared library (or libraries) be loaded to get
+ * access to the MyLEPEventShapes class and any other class on which it depends
+ * (except the base class). */
+ //static string library() { return "HwAnalysis.so HwLEPAnalysis.so"; }
+ static string library() { return "MyEventShapes.so MyLEPEventShapes.so"; }
+};
+
+/** @endcond */
+
+}
+
+//#include "MyLEPEventShapes.icc"
+
+#endif /* HERWIG_MyLEPEventShapes_H */
diff --git a/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyMultiplicityCount.cc b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyMultiplicityCount.cc
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyMultiplicityCount.cc
@@ -0,0 +1,472 @@
+// -*- C++ -*-
+//
+// MyMultiplicityCount.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 MyMultiplicityCount class.
+//
+
+#include "MyMultiplicityCount.h"
+#include "ThePEG/Interface/ParVector.h"
+#include "ThePEG/Interface/Switch.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/EventRecord/StandardSelectors.h"
+#include "ThePEG/EventRecord/Event.h"
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+#include "Herwig++/Utilities/EnumParticles.h"
+#include "Herwig++/Hadronization/Cluster.h"
+#include <iostream>
+#include <sstream>
+#include <fstream>
+
+using namespace Herwig;
+using namespace ThePEG;
+
+// string MultiplicityInfo::bargraph()
+// {
+// if (obsMultiplicity == 0.0) return " ? ";
+// else if (nSigma() >= 6.0) return "-----|---->";
+// else if (nSigma() >= 5.0) return "-----|----*";
+// else if (nSigma() >= 4.0) return "-----|---*-";
+// else if (nSigma() >= 3.0) return "-----|--*--";
+// else if (nSigma() >= 2.0) return "-----|-*---";
+// else if (nSigma() >= 1.0) return "-----|*----";
+// else if (nSigma() > -1.0) return "-----*-----";
+// else if (nSigma() > -2.0) return "----*|-----";
+// else if (nSigma() > -3.0) return "---*-|-----";
+// else if (nSigma() > -4.0) return "--*--|-----";
+// else if (nSigma() > -5.0) return "-*---|-----";
+// else if (nSigma() > -6.0) return "*----|-----";
+// else return "<----|-----";
+// }
+
+IBPtr MyMultiplicityCount::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr MyMultiplicityCount::fullclone() const {
+ return new_ptr(*this);
+}
+
+MyMultiplicityCount::MyMultiplicityCount() : _makeHistograms(false)
+{
+ // Average particle multiplicities in hadronic Z decay
+ // PDG 2006 with 2007 partial update
+
+ // all charged
+ _data[0] = MyMultiplicityInfo(20.76, 0.16, lightMeson); // all charged
+ // gamma
+ _data[22] = MyMultiplicityInfo(20.97, 1.17, lightMeson);
+ // pi+, pi0, eta
+ _data[211] = MyMultiplicityInfo(17.03, 0.16, lightMeson);
+ _data[111] = MyMultiplicityInfo( 9.76, 0.26, lightMeson);
+ _data[221] = MyMultiplicityInfo( 1.01, 0.08, lightMeson);
+ // rho+, rho0, omega, eta'
+ _data[213] = MyMultiplicityInfo( 2.40, 0.49, lightMeson);
+ _data[113] = MyMultiplicityInfo( 1.24, 0.10, lightMeson);
+ _data[223] = MyMultiplicityInfo( 1.02, 0.06, lightMeson);
+ _data[331] = MyMultiplicityInfo( 0.17, 0.05, lightMeson);
+ // f_0(980), a_0(980), phi
+ _data[10221] = MyMultiplicityInfo(0.147, 0.011, other);
+ _data[9000211] = MyMultiplicityInfo(0.27, 0.14, other);
+ _data[333] = MyMultiplicityInfo(0.098, 0.006, strangeMeson);
+ // f_2(1270), f_1(1285), f_2'(1525), K+, K0
+ _data[225] = MyMultiplicityInfo(0.169, 0.025, other);
+ _data[20223] = MyMultiplicityInfo(0.165, 0.051, other);
+ _data[335] = MyMultiplicityInfo(0.012, 0.006, other);
+ _data[321] = MyMultiplicityInfo(2.24, 0.04, strangeMeson);
+ _data[311] = MyMultiplicityInfo(2.039, 0.025, lightMeson);
+ // K*+(892), K*0(892), K*_2(1430)
+ _data[323] = MyMultiplicityInfo(0.72, 0.05, strangeMeson);
+ _data[313] = MyMultiplicityInfo(0.739, 0.022, strangeMeson);
+ _data[315] = MyMultiplicityInfo(0.073, 0.023, strangeMeson);
+ // D+, D0, D_s+
+ _data[411] = MyMultiplicityInfo(0.187, 0.020, other);
+ _data[421] = MyMultiplicityInfo(0.462, 0.026, other);
+ _data[431] = MyMultiplicityInfo(0.131, 0.028, other);
+ // D*+(2010), J/Psi(1S), Psi(2S)
+ _data[413] = MyMultiplicityInfo(0.183, 0.008, other);
+ _data[443] = MyMultiplicityInfo(0.0056, 0.0007, other);
+ _data[100443] = MyMultiplicityInfo(0.0023, 0.0007, other);
+ // p, Delta++(1232), Lambda, Sigma+, Sigma-, Sigma0
+ _data[2212] = MyMultiplicityInfo(1.046, 0.026, lightBaryon);
+ _data[2224] = MyMultiplicityInfo(0.087, 0.033, lightBaryon);
+ _data[3122] = MyMultiplicityInfo(0.388, 0.009, lightBaryon);
+ _data[3222] = MyMultiplicityInfo(0.107, 0.010, lightBaryon);
+ _data[3112] = MyMultiplicityInfo(0.082, 0.007, lightBaryon);
+ _data[3212] = MyMultiplicityInfo(0.076, 0.010, lightBaryon);
+ // Sigma*+, Sigma*-, Xi-, Xi*0, Omega-
+ _data[3224] = MyMultiplicityInfo(0.0239, 0.0021, lightBaryon);
+ _data[3114] = MyMultiplicityInfo(0.0240, 0.0024, lightBaryon);
+ _data[3312] = MyMultiplicityInfo(0.0258, 0.0009, lightBaryon);
+ _data[3324] = MyMultiplicityInfo(0.0059, 0.0011, lightBaryon);
+ _data[3334] = MyMultiplicityInfo(0.00164, 0.00028, lightBaryon);
+ // Lambda_c+
+ _data[4122] = MyMultiplicityInfo(0.078, 0.024, other);
+
+ // old values from 1.0 paper
+// _data[433] = MyMultiplicityInfo(0.096, 0.046, other);
+ _data[2112] = MyMultiplicityInfo(0.991, 0.054, lightBaryon);
+// _data[2214] = MyMultiplicityInfo(0., 0., lightBaryon);
+// _data[2114] = MyMultiplicityInfo(0., 0., lightBaryon);
+
+// values unknown
+ // B mesons
+ // _data[513] = MyMultiplicityInfo(0.28, 0.04, other); // flavour averaged value!
+ _data[513] = MyMultiplicityInfo(0., 0., other);
+ _data[511] = MyMultiplicityInfo(0., 0., other); // B0
+ _data[521] = MyMultiplicityInfo(0., 0., other); // B+
+ _data[531] = MyMultiplicityInfo(0., 0., other); // B_s
+ _data[541] = MyMultiplicityInfo(0., 0., other); // B_c
+ // B baryons
+ _data[5122] = MyMultiplicityInfo(0., 0., other); // Lambda_b
+ _data[5112] = MyMultiplicityInfo(0., 0., other); // Sig_b-
+ _data[5212] = MyMultiplicityInfo(0., 0., other); // Sig_b0
+ _data[5222] = MyMultiplicityInfo(0., 0., other); // Sig_b+
+ _data[5132] = MyMultiplicityInfo(0., 0., other); // Xi_b-
+ _data[5232] = MyMultiplicityInfo(0., 0., other); // Xi_b0
+ _data[5312] = MyMultiplicityInfo(0., 0., other); // Xi'_b-
+ _data[5322] = MyMultiplicityInfo(0., 0., other); // Xi'_b0
+ _data[5332] = MyMultiplicityInfo(0., 0., other); // Omega_b-
+}
+
+namespace {
+ bool isLastCluster(tcPPtr p) {
+ if ( p->id() != ParticleID::Cluster )
+ return false;
+ for ( size_t i = 0, end = p->children().size();
+ i < end; ++i ) {
+ if ( p->children()[i]->id() == ParticleID::Cluster )
+ return false;
+ }
+ return true;
+ }
+
+ Energy parentClusterMass(tcPPtr p) {
+ if (p->parents().empty())
+ return -1.0*MeV;
+
+ tcPPtr parent = p->parents()[0];
+ if (parent->id() == ParticleID::Cluster) {
+ if ( isLastCluster(parent) )
+ return parent->mass();
+ else
+ return p->mass();
+ }
+ else
+ return parentClusterMass(parent);
+ }
+
+ bool isPrimaryCluster(tcPPtr p) {
+ if ( p->id() != ParticleID::Cluster )
+ return false;
+ if( p->parents().empty())
+ return false;
+ for ( size_t i = 0, end = p->parents().size();
+ i < end; ++i ) {
+ if ( !(p->parents()[i]->dataPtr()->coloured()) )
+ return false;
+ }
+ return true;
+ }
+}
+void MyMultiplicityCount::analyze(tEventPtr event, long, int, int) {
+ string infile = "EPEM.dat";
+ ifstream normin;
+ string stringin = "";
+ double normfac = 1;
+ double stringdoub = 0;
+ bool next = 0, filerror = 0;
+ normin.open(infile.c_str());
+ if(!normin) { cerr << "Error: Failed to open file " << infile << endl; filerror = 1; normfac = 1.; }
+ if(!filerror) {
+ while(normin) {
+
+ normin >> stringin;
+
+ if(next) { normin >> stringdoub; normfac = stringdoub; break; }
+ if(stringin == "NORMFACTOR") { next = 1; }
+
+ }
+ }
+ double eventweight = generator()->currentEvent()->weight();
+ set<tcPPtr> particles;
+ event->selectFinalState(inserter(particles));
+
+ map <long,long> eventcount;
+ eventcount.insert(make_pair(0,0));
+
+ for(set<tcPPtr>::const_iterator it = particles.begin();
+ it != particles.end(); ++it) {
+
+ if((*it)->dataPtr()->charged())
+ // ++eventcount[0];
+ eventcount[0] = eventcount[0] + eventweight;
+ long ID = abs( (*it)->id() );
+ _finalstatecount.insert(make_pair(ID,0));
+ // ++_finalstatecount[ID];
+ _finalstatecount[ID] = _finalstatecount[ID] + eventweight;
+ }
+
+
+ StepVector steps = event->primaryCollision()->steps();
+
+ particles.clear();
+ steps[0]->select(inserter(particles), ThePEG::AllSelector());
+
+ for(set<tcPPtr>::const_iterator it = particles.begin();
+ it != particles.end(); ++it) {
+ long ID = (*it)->id();
+ _collisioncount.insert(make_pair(ID,0));
+ // ++_collisioncount[ID];
+ _collisioncount[ID] = _collisioncount[ID] + eventweight;
+ }
+
+ // =======
+
+
+ particles.clear();
+
+ if (steps.size() > 2) {
+ for ( StepVector::const_iterator it = steps.begin()+2;
+ it != steps.end(); ++it ) {
+ (**it).select(inserter(particles), ThePEG::AllSelector());
+ }
+ }
+
+ if( _makeHistograms )
+ _histograms.insert(make_pair(ParticleID::Cluster,
+ Histogram(0.0,10.0,200)));
+
+ for(set<tcPPtr>::const_iterator it = particles.begin();
+ it != particles.end(); ++it) {
+ long ID = abs( (*it)->id() );
+ if(ID==ParticleID::K0) continue;
+ if(ID==ParticleID::K_L0||ID==ParticleID::K_S0) ID=ParticleID::K0;
+
+ if ( _makeHistograms && isLastCluster(*it) ) {
+ _histograms[ParticleID::Cluster] += (*it)->mass()/GeV;
+ tcClusterPtr clu = dynamic_ptr_cast<tcClusterPtr>(*it);
+ if (clu) {
+ _clusters.insert(make_pair(clu->clusterId(), Histogram(0.0,10.0,200)));
+ _clusters[clu->clusterId()] += (*it)->mass()/GeV;
+ }
+ }
+
+ if( _makeHistograms && isPrimaryCluster(*it) ) {
+ _primary.insert(make_pair(0, Histogram(0.0,20.0,400)));
+ _primary[0] += (*it)->mass()/GeV;
+ tcClusterPtr clu = dynamic_ptr_cast<tcClusterPtr>(*it);
+ if(clu) {
+ _primary.insert(make_pair(clu->clusterId(), Histogram(0.0,20.0,400)));
+ _primary[clu->clusterId()] += (*it)->mass()/GeV;
+ }
+ }
+
+ if (_data.find(ID) != _data.end()) {
+ eventcount.insert(make_pair(ID,0));
+ // ++eventcount[ID];
+ eventcount[ID] = eventcount[ID] +eventweight;
+ if (_makeHistograms
+ && ! (*it)->parents().empty()
+ && (*it)->parents()[0]->id() == ParticleID::Cluster) {
+ _histograms.insert(make_pair(ID,Histogram(0.0,10.0,200)));
+ _histograms[ID] += parentClusterMass(*it)/GeV;
+ }
+ }
+
+ }
+
+ for(map<long,MyMultiplicityInfo>::iterator it = _data.begin();
+ it != _data.end(); ++it) {
+ long currentcount
+ = eventcount.find(it->first) == eventcount.end() ? 0
+ : eventcount[it->first];
+ it->second.count += currentcount;
+ }
+}
+
+void MyMultiplicityCount::analyze(const tPVector & ) {}
+
+void MyMultiplicityCount::dofinish() {
+ string infile = "EPEM.dat";
+ ifstream normin;
+ string stringin = "";
+ double normfac = 1;
+ double stringdoub = 0;
+ bool next = 0, filerror = 0;
+ normin.open(infile.c_str());
+ if(!normin) { cerr << "Error: Failed to open file " << infile << endl; filerror = 1; normfac = 1.; }
+ if(!filerror) {
+ while(normin) {
+
+ normin >> stringin;
+
+ if(next) { normin >> stringdoub; normfac = stringdoub; break; }
+ if(stringin == "NORMFACTOR") { next = 1; }
+
+ }
+ }
+
+ string filename = generator()->filename() + ".mult";
+ ofstream outfile(filename.c_str());
+
+ outfile <<
+ "\nParticle multiplicities (compared to LEP data):\n"
+ " ID Name simMult obsMult obsErr Sigma\n";
+ for (map<long,MyMultiplicityInfo>::const_iterator it = _data.begin();
+ it != _data.end();
+ ++it)
+ {
+ MyMultiplicityInfo multiplicity = it->second;
+ double newmultiplicity = multiplicity.simMultiplicity()*normfac;
+ string name = (it->first==0 ? "All chgd" :
+ generator()->getParticleData(it->first)->PDGName() );
+
+ ios::fmtflags oldFlags = outfile.flags();
+ outfile << std::scientific << std::showpoint
+ << std::setprecision(3)
+ << setw(7) << it->first << ' '
+ << setw(9) << name << ' '
+ << setw(2) << newmultiplicity << " | "
+ << setw(2) << multiplicity.obsMultiplicity << " +/- "
+ << setw(2) << multiplicity.obsError << ' '
+ << std::showpos << std::setprecision(1)
+ << (newmultiplicity-multiplicity.obsMultiplicity)/multiplicity.obsError << ' '
+ << multiplicity.nSigma() << ' '
+ << multiplicity.bargraph()
+ << std::noshowpos;
+
+ outfile << '\n';
+ outfile.flags(oldFlags);
+ }
+
+
+
+ outfile << "\nCount of particles involved in hard process:\n";
+ for (map<long,long>::const_iterator it = _collisioncount.begin();
+ it != _collisioncount.end(); ++ it) {
+ string name = generator()->getParticleData(it->first)->PDGName();
+ outfile << name << '\t' << it->second << '\n';
+ }
+
+
+
+ outfile << "\nFinal state particle count:\n";
+ for (map<long,long>::const_iterator it = _finalstatecount.begin();
+ it != _finalstatecount.end(); ++ it) {
+ string name = generator()->getParticleData(it->first)->PDGName();
+ outfile << name << '\t' << it->second << '\n';
+ }
+ outfile.close();
+
+ if (_makeHistograms) {
+
+ Histogram piratio
+ = _histograms[ParticleID::piplus].ratioWith(_histograms[ParticleID::pi0]);
+ Histogram Kratio
+ = _histograms[ParticleID::Kplus].ratioWith(_histograms[ParticleID::K0]);
+
+ using namespace HistogramOptions;
+ string histofilename = filename + ".top";
+ ofstream outfile2(histofilename.c_str());
+
+ for (map<int,Histogram>::const_iterator it = _primary.begin();
+ it != _primary.end(); ++it) {
+ ostringstream title1;
+ title1 << "Primary Cluster " << it->first;
+ string title = title1.str();
+ it->second.topdrawOutput(outfile2,Frame|Ylog,"BLACK",title,"",
+ "N (200 bins)","","Cluster mass [GeV]");
+ }
+ map<long,Histogram>::const_iterator cit = _histograms.find(ParticleID::Cluster);
+ string title = generator()->getParticleData(cit->first)->PDGName();
+ cit->second.topdrawOutput(outfile2,Frame|Ylog,"BLACK",title,"",
+ "N (200 bins)","","Parent cluster mass [GeV]");
+
+ for (map<int,Histogram>::const_iterator it = _clusters.begin();
+ it != _clusters.end(); ++it) {
+ ostringstream title1;
+ title1 << "Final Cluster " << it->first;
+ string title = title1.str();
+ it->second.topdrawOutput(outfile2,Frame|Rawcount|Ylog,"BLACK",title,"",
+ "N (200 bins)","","Cluster mass [GeV]");
+ }
+ for (map<long,Histogram>::const_iterator it = _histograms.begin();
+ it != _histograms.end(); ++it) {
+ string title = generator()->getParticleData(it->first)->PDGName();
+ it->second.topdrawOutput(outfile2,Frame|Rawcount|Ylog,"BLACK",title,"",
+ "N (200 bins)","","Parent cluster mass [GeV]");
+ }
+ piratio.topdrawOutput(outfile2,Frame|Rawcount,"BLACK","pi+ / pi0","",
+ "","","Parent cluster mass [GeV]");
+ Kratio.topdrawOutput(outfile2,Frame|Rawcount,"BLACK","K+ / K0","",
+ "","","Parent cluster mass [GeV]");
+ outfile2.close();
+ }
+ AnalysisHandler::dofinish();
+}
+
+ClassDescription<MyMultiplicityCount> MyMultiplicityCount::initMyMultiplicityCount;
+// Definition of the static class description member.
+
+void MyMultiplicityCount::Init() {
+
+ static ParVector<MyMultiplicityCount,long> interfaceparticlecodes
+ ("ParticleCodes",
+ "The PDG code for the particles",
+ &MyMultiplicityCount::_particlecodes,
+ 0, 0, 0, -10000000, 10000000, false, false, true);
+
+ static ParVector<MyMultiplicityCount,double> interfaceMultiplicity
+ ("Multiplicity",
+ "The multiplicity for the particle",
+ &MyMultiplicityCount::_multiplicity,
+ 0, 0, 0, 0., 1000., false, false, true);
+
+ static ParVector<MyMultiplicityCount,double> interfaceError
+ ("Error",
+ "The error on the multiplicity for the particle",
+ &MyMultiplicityCount::_error,
+ 0, 0, 0, 0., 1000., false, false, true);
+
+ static ParVector<MyMultiplicityCount,unsigned int> interfaceSpecies
+ ("Species",
+ "The type of particle",
+ &MyMultiplicityCount::_species,
+ 0, 0, other, 0, other, false, false, true);
+
+
+ static Switch<MyMultiplicityCount,bool> interfaceHistograms
+ ("Histograms",
+ "Set to On if detailed histograms are required.",
+ &MyMultiplicityCount::_makeHistograms, false, true, false);
+ static SwitchOption interfaceHistogramsOn
+ (interfaceHistograms,
+ "Yes",
+ "Generate histograms of cluster mass dependence.",
+ true);
+ static SwitchOption interfaceHistogramsOff
+ (interfaceHistograms,
+ "No",
+ "Do not generate histograms.",
+ false);
+
+ static ClassDocumentation<MyMultiplicityCount> documentation
+ ("The MyMultiplicityCount class count the multiplcities of final-state particles"
+ " and compares them with LEP data.");
+}
+
+void MyMultiplicityCount::persistentOutput(PersistentOStream & os) const {
+ os << _particlecodes << _multiplicity << _error << _species << _makeHistograms;
+}
+
+void MyMultiplicityCount::persistentInput(PersistentIStream & is, int) {
+ is >> _particlecodes >> _multiplicity >> _error >> _species >> _makeHistograms;
+}
diff --git a/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyMultiplicityCount.h b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyMultiplicityCount.h
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyMultiplicityCount.h
@@ -0,0 +1,296 @@
+// -*- C++ -*-
+//
+// MyMultiplicityCount.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_MyMultiplicityCount_H
+#define HERWIG_MyMultiplicityCount_H
+//
+// This is the declaration of the MyMultiplicityCount class.
+//
+
+#include "ThePEG/Handlers/AnalysisHandler.h"
+#include "ThePEG/Repository/Repository.h"
+#include "ThePEG/PDT/ParticleData.h"
+#include "Herwig++/Utilities/Histogram.h"
+#include "MyMultiplicityInfo.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+// */
+
+// /**
+// * Enumeration for species of particle
+// */
+// enum ParticleSpecies
+// {
+// lightMeson=0,strangeMeson,lightBaryon,other
+// };
+
+// /**
+// * Struct for the multiplcity data
+// */
+// struct MultiplicityInfo
+// {
+// /**
+// * Default constructor
+// * @param mult The observed multiplcity.
+// * @param error The error on the observed multiplicity
+// * @param type The type of particle
+// */
+// inline MultiplicityInfo(double mult=0.,double error=0.,
+// ParticleSpecies type=other);
+
+// /**
+// * The observed multiplicity
+// */
+// double obsMultiplicity;
+
+// /**
+// * The error on the observed multiplicity
+// */
+// double obsError;
+
+// /**
+// * The type of particle
+// */
+// ParticleSpecies type;
+
+// /**
+// * Simulation statistics for particles of this type
+// */
+// Statistic count;
+
+// /**
+// * The average number per event
+// */
+// double simMultiplicity();
+
+// /**
+// * The error on the average number per event
+// */
+// double simError();
+
+// /**
+// * Is the result more than \f$3\sigma\f$ from the experimental result
+// */
+// double nSigma();
+
+// /**
+// * Plot standard error in a simple barchart
+// */
+// string bargraph();
+// };
+
+/**
+ * The MyMultiplicityCount class is designed to count particle multiplicities and
+ * compare them to LEP data.
+ *
+ * @see \ref MyMultiplicityCountInterfaces "The interfaces"
+ * defined for MyMultiplicityCount.
+ */
+class MyMultiplicityCount: public AnalysisHandler {
+
+public:
+
+ /**
+ * The default constructor.
+ */
+ MyMultiplicityCount();
+
+public:
+
+ /** @name Virtual functions required by the AnalysisHandler class. */
+ //@{
+ /**
+ * Analyze a given Event. Note that a fully generated event
+ * may be presented several times, if it has been manipulated in
+ * between. The default version of this function will call transform
+ * to make a lorentz transformation of the whole event, then extract
+ * all final state particles and call analyze(tPVector) of this
+ * analysis object and those of all associated analysis objects. The
+ * default version will not, however, do anything on events which
+ * have not been fully generated, or have been manipulated in any
+ * way.
+ * @param event pointer to the Event to be analyzed.
+ * @param ieve the event number.
+ * @param loop the number of times this event has been presented.
+ * If negative the event is now fully generated.
+ * @param state a number different from zero if the event has been
+ * manipulated in some way since it was last presented.
+ */
+ virtual void analyze(tEventPtr event, long ieve, int loop, int state);
+
+ /**
+ * Analyze the given vector of particles. The default version calls
+ * analyze(tPPtr) for each of the particles.
+ * @param particles the vector of pointers to particles to be analyzed
+ */
+ virtual void analyze(const tPVector & particles);
+
+ using AnalysisHandler::analyze;
+ //@}
+
+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.
+ */
+ inline 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.
+ */
+ inline virtual IBPtr fullclone() const;
+ //@}
+
+protected:
+
+ /** @name Standard Interfaced functions. */
+ //@{
+ /**
+ * 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 static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<MyMultiplicityCount> initMyMultiplicityCount;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ MyMultiplicityCount & operator=(const MyMultiplicityCount &);
+
+private:
+
+ /**
+ * The PDG codes of the particles
+ */
+ vector<long> _particlecodes;
+
+ /**
+ * The multiplcity
+ */
+ vector<double> _multiplicity;
+
+ /**
+ * The error
+ */
+ vector<double> _error;
+
+ /**
+ * Species of particle
+ */
+ vector<unsigned int> _species;
+
+ /**
+ * Map of PDG codes to multiplicity info
+ */
+ map<long,MyMultiplicityInfo> _data;
+
+ /// Histograms for cluster mass dependence
+ map<long,Histogram> _histograms;
+
+ /**
+ * Histograms of the clusters after cluster splitting
+ */
+ map<int,Histogram> _clusters;
+
+ /**
+ * Histograms of the primary clusters
+ */
+ map<int,Histogram> _primary;
+
+ /**
+ * Map of number of final-state particles to PDG code
+ */
+ map<long,long> _finalstatecount;
+
+ /**
+ * Particles in hard process
+ */
+ map<long,long> _collisioncount;
+
+ /// Make histograms of cluster mass dependence
+ bool _makeHistograms;
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of MyMultiplicityCount. */
+template <>
+struct BaseClassTrait<Herwig::MyMultiplicityCount,1> {
+ /** Typedef of the first base class of MyMultiplicityCount. */
+ typedef AnalysisHandler NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the MyMultiplicityCount class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::MyMultiplicityCount>
+ : public ClassTraitsBase<Herwig::MyMultiplicityCount> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::MyMultiplicityCount"; }
+ /** Return the name(s) of the shared library (or libraries) be loaded to get
+ * access to the MyMultiplicityCount class and any other class on which it depends
+ * (except the base class). */
+ static string library() { return "MyMultiplicityCount.so"; }
+};
+
+/** @endcond */
+
+}
+
+//#include "MyMultiplicityCount.icc"
+
+#endif /* HERWIG_MyMultiplicityCount_H */
diff --git a/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyMultiplicityInfo.h b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyMultiplicityInfo.h
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MyMultiplicityInfo.h
@@ -0,0 +1,94 @@
+// -*- C++ -*-
+//
+// MultiplicityInfo.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2008 The Herwig Collaboration
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respe
+#include "Herwig++/Utilities/Statistic.h"
+
+namespace Herwig {
+using namespace ThePEG;
+
+/**
+ * Enumeration for species of particle
+ */
+enum ParticleSpecies {
+ lightMeson=0,strangeMeson,lightBaryon,other
+};
+
+/**
+ * Struct for the multiplcity data
+ */
+struct MyMultiplicityInfo {
+
+ /**
+ * Default constructor
+ * @param mult The observed multiplcity.
+ * @param error The error on the observed multiplicity
+ * @param type The type of particle
+ */
+ inline MyMultiplicityInfo(double mult=0.,double error=0.,
+ ParticleSpecies type=other)
+ : obsMultiplicity(mult), obsError(error), type(type) {};
+
+ /**
+ * The observed multiplicity
+ */
+ double obsMultiplicity;
+
+ /**
+ * The error on the observed multiplicity
+ */
+ double obsError;
+
+ /**
+ * The type of particle
+ */
+ ParticleSpecies type;
+
+ /**
+ * Simulation statistics for particles of this type
+ */
+ Statistic count;
+
+ /**
+ * The average number per event
+ */
+ double simMultiplicity() { return count.mean();}
+
+ /**
+ * The error on the average number per event
+ */
+ double simError() { return count.mean_stdDev();}
+
+ /**
+ * Is the result more than \f$3\sigma\f$ from the experimental result
+ */
+ double nSigma() {
+ return obsMultiplicity == 0.0 ? 0.0 :
+ (simMultiplicity() - obsMultiplicity)
+ / sqrt(sqr(simError()) + sqr(obsError));
+ }
+
+ /**
+ * Plot standard error in a simple barchart
+ */
+ string bargraph() {
+ if (obsMultiplicity == 0.0) return " ? ";
+ else if (nSigma() >= 6.0) return "-----|---->";
+ else if (nSigma() >= 5.0) return "-----|----*";
+ else if (nSigma() >= 4.0) return "-----|---*-";
+ else if (nSigma() >= 3.0) return "-----|--*--";
+ else if (nSigma() >= 2.0) return "-----|-*---";
+ else if (nSigma() >= 1.0) return "-----|*----";
+ else if (nSigma() > -1.0) return "-----*-----";
+ else if (nSigma() > -2.0) return "----*|-----";
+ else if (nSigma() > -3.0) return "---*-|-----";
+ else if (nSigma() > -4.0) return "--*--|-----";
+ else if (nSigma() > -5.0) return "-*---|-----";
+ else if (nSigma() > -6.0) return "*----|-----";
+ else return "<----|-----";
+ }
+};
+}
diff --git a/Contrib/MCPWNLO/EPEM/LEPAnalysis/MySingleParticleAnalysis.cc b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MySingleParticleAnalysis.cc
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MySingleParticleAnalysis.cc
@@ -0,0 +1,404 @@
+// -*- C++ -*-
+//
+// MySingleParticleAnalysis.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 MySingleParticleAnalysis class.
+//
+
+#include "MySingleParticleAnalysis.h"
+#include "ThePEG/Interface/Reference.h"
+#include "ThePEG/EventRecord/Event.h"
+#include "ThePEG/Repository/EventGenerator.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+void MySingleParticleAnalysis::analyze(const tPVector & particles) {
+ string infile = "EPEM.dat";
+ ifstream normin;
+ string stringin = "";
+ double normfac = 1;
+ double stringdoub = 0;
+ bool next = 0, filerror = 0;
+ normin.open(infile.c_str());
+ if(!normin) { cerr << "Error: Failed to open file " << infile << endl; filerror = 1; normfac = 1.; }
+ if(!filerror) {
+ while(normin) {
+
+ normin >> stringin;
+
+ if(next) { normin >> stringdoub; normfac = stringdoub; break; }
+ if(stringin == "NORMFACTOR") { next = 1; }
+
+ }
+ }
+ double eventweight = generator()->currentEvent()->weight()*normfac;
+ int Ncharged = 0;
+ for(unsigned int ix=0;ix<particles.size();++ix) {
+ const Lorentz5Momentum p = particles[ix]->momentum();
+ if(!particles[ix]->data().charged()) continue;
+ Ncharged++;
+ _yT->addWeighted(abs(_shapes->yT(p)),eventweight);
+ _yS->addWeighted(abs(_shapes->yS(p)),eventweight);
+ _ptinT->addWeighted(_shapes->ptInT(p)/GeV,eventweight);
+ _ptoutT->addWeighted(_shapes->ptOutT(p)/GeV,eventweight);
+ _ptinS->addWeighted(_shapes->ptInS(p)/GeV,eventweight);
+ _ptoutS->addWeighted(_shapes->ptOutS(p)/GeV,eventweight);
+ }
+ // make sure the right bin is booked by subtracting a small amount.
+ _nch->addWeighted(Ncharged-0.00001,eventweight);
+}
+
+void MySingleParticleAnalysis::persistentOutput(PersistentOStream & os) const {
+ os << _shapes;
+}
+
+void MySingleParticleAnalysis::persistentInput(PersistentIStream & is, int) {
+ is >> _shapes;
+}
+
+ClassDescription<MySingleParticleAnalysis>
+MySingleParticleAnalysis::initMySingleParticleAnalysis;
+// Definition of the static class description member.
+
+void MySingleParticleAnalysis::Init() {
+
+ static ClassDocumentation<MySingleParticleAnalysis> documentation
+ ("There is no documentation for the MySingleParticleAnalysis class");
+
+ static Reference<MySingleParticleAnalysis,MyEventShapes> interfaceMyEventShapes
+ ("MyEventShapes",
+ "Pointer to the object which calculates the event shapes",
+ &MySingleParticleAnalysis::_shapes, false, false, true, false, false);
+}
+
+
+void MySingleParticleAnalysis::dofinish() {
+ AnalysisHandler::dofinish();
+ string fname = generator()->filename() + string("-") + name() + string(".top");
+ ofstream output(fname.c_str());
+ // normalize the data
+ _yT->normaliseToData();
+ _yS->normaliseToData();
+ _ptinT->normaliseToData();
+ _ptoutT->normaliseToData();
+ _ptinS->normaliseToData();
+ _ptoutS->normaliseToData();
+ _nch->prefactor(2.);
+ // chisq
+ double chisq,minfrac=0.05;
+ unsigned int npoint;
+ _yT->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for DELPHI rapidity wrt "
+ << "thrust axis distribution or "
+ << chisq/npoint << " per degree of freedom \n";
+ _yS->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for DELPHI rapidity wrt "
+ << "sphericity axis distribution or "
+ << chisq/npoint << " per degree of freedom \n";
+ _ptinT->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for DELPHI pT in the plane wrt "
+ << "thrust axis distribution "
+ << chisq/npoint << " per degree of freedom \n";
+ _ptoutT->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for DELPHI pT out of the plane wrt "
+ << "thrust axis distribution "
+ << chisq/npoint << " per degree of freedom \n";
+ _ptinS->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for DELPHI pT in the plane wrt "
+ << "sphericity axis distribution "
+ << chisq/npoint << " per degree of freedom \n";
+ _ptoutS->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for DELPHI pT out of the wrt "
+ << "sphericity axis plane distribution "
+ << chisq/npoint << " per degree of freedom \n";
+ _nch->chiSquared(chisq,npoint,minfrac);
+ generator()->log() << "Chi Square = " << chisq << " for " << npoint
+ << " degrees of freedom for OPAL number of charged "
+ << "particles distribution or "
+ << chisq/npoint << " per degree of freedom \n";
+ // output the plots
+ using namespace HistogramOptions;
+ _yT->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "Radidity with respect to the thrust axis compared to DELPHI data",
+ " ",
+ "1/NdN/dy0T1",
+ " X X",
+ "y0T1",
+ " X X");
+ _yS->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "Radidity with respect to the sphericity axis"
+ " compared to DELPHI data",
+ " "
+ " ",
+ "1/NdN/dy0S1",
+ " X X",
+ "y0S1",
+ " X X");
+ _ptinT->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "p0T1 in the plane with respect to the thrust axis"
+ " compared to DELPHI data",
+ " X X "
+ " ",
+ "1/NdN/dp0T,in1",
+ " X X",
+ "p0T,in1",
+ " X X");
+ _ptoutT->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "p0T1 out of the plane with respect to the thrust axis"
+ " compared to DELPHI data",
+ " X X "
+ " ",
+ "1/NdN/dp0T,out1",
+ " X X",
+ "p0T,out1",
+ " X X");
+ _ptinS->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "p0T1 in the plane with respect to the sphericity axis"
+ " compared to DELPHI data",
+ " X X "
+ " ",
+ "1/NdN/dp0T,in1",
+ " X X",
+ "p0T,in1",
+ " X X");
+ _ptoutS->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "p0T1 out of the plane with respect to the sphericity axis"
+ " compared to DELPHI data",
+ " X X ",
+ "1/NdN/dp0T,out1",
+ " X X",
+ "p0T,out1",
+ " X X");
+ _nch->topdrawOutput(output,Frame|Errorbars|Ylog,
+ "RED",
+ "Multiplcity of charged particles compared to OPAL data",
+ " ",
+ "1/SdS/dN0charged1",
+ " G G X X",
+ "N0charged1",
+ " X X");
+}
+
+void MySingleParticleAnalysis::doinitrun() {
+ AnalysisHandler::doinitrun();
+ vector<double> bins,data,error;
+ // rapidity with respect to thrust axis
+ double vals19[] = {0.000, 0.250, 0.500, 0.750, 1.000,
+ 1.250, 1.500, 1.750, 2.000, 2.250,
+ 2.500, 2.750, 3.000, 3.250, 3.500,
+ 3.750, 4.000, 4.250, 4.500, 5.000,
+ 5.500, 6.000};
+ double data19[]={5.9517,6.4291,6.6831,6.7763,6.7650,
+ 6.7230,6.6085,6.4346,6.1697,5.7692,
+ 5.1450,4.3511,3.4481,2.5852,1.7999,
+ 1.1669,0.7054,0.3997,0.15673,0.03374,
+ 0.00502};
+ double error19stat[]={0.0095,0.0095,0.0094,0.0089 ,0.0085,
+ 0.0083,0.0081,0.0080,0.0078 ,0.0076,
+ 0.0072,0.0066,0.0059,0.0051 ,0.0043,
+ 0.0035,0.0027,0.0020,0.00089,0.00041,
+ 0.00016};
+ double error19syst[]={0.5628 ,0.4417 ,0.3319 ,0.2429 ,0.1755 ,
+ 0.1277 ,0.0939 ,0.0710 ,0.0617 ,0.0577 ,
+ 0.0514 ,0.0435 ,0.0345 ,0.0259 ,0.0180 ,
+ 0.0117 ,0.0071 ,0.0041 ,0.00177,0.00043,
+ 0.00007};
+ double error19[21];
+ for(unsigned int ix=0;ix<21;++ix){error19[ix]=sqrt(sqr(error19stat[ix])+
+ sqr(error19syst[ix]));}
+ bins = vector<double>(vals19 ,vals19 +22);
+ data = vector<double>(data19 ,data19 +21);
+ error = vector<double>(error19,error19+21);
+ _yT= new_ptr(Histogram(bins,data,error));
+ // rapidity with respect to the sphericity axis
+ double vals20[] = {0.000, 0.250, 0.500, 0.750, 1.000,
+ 1.250, 1.500, 1.750, 2.000, 2.250,
+ 2.500, 2.750, 3.000, 3.250, 3.500,
+ 3.750, 4.000, 4.250, 4.500, 5.000,
+ 5.500, 6.000};
+ double data20[]={6.5680 ,6.5901 ,6.6094 ,6.6152 ,6.5917 ,
+ 6.5817 ,6.5221 ,6.4097 ,6.1741 ,5.7542 ,
+ 5.1066 ,4.2721 ,3.3718 ,2.5185 ,1.7588 ,
+ 1.1589 ,0.7327 ,0.4402 ,0.1952 ,0.05574,
+ 0.01306};
+ double error20stat[]={0.0097 , 0.0096 , 0.0093 , 0.0088 , 0.0084 ,
+ 0.0082 , 0.0081 , 0.0080 , 0.0079 , 0.0076 ,
+ 0.0072 , 0.0066 , 0.0059 , 0.0051 , 0.0042 ,
+ 0.0034 , 0.0027 , 0.0021 , 0.0010 , 0.00050 ,
+ 0.00024};
+ double error20syst[]={0.5323 ,0.4246 ,0.3329 ,0.2554 ,0.1908 ,
+ 0.1393 ,0.0983 ,0.0673 ,0.0617 ,0.0575 ,
+ 0.0511 ,0.0427 ,0.0337 ,0.0252 ,0.0176 ,
+ 0.0130 ,0.0105 ,0.0078 ,0.0046 ,0.00180,
+ 0.00055};
+ double error20[21];
+ for(unsigned int ix=0;ix<21;++ix){error20[ix]=sqrt(sqr(error20stat[ix])+
+ sqr(error20syst[ix]));}
+ bins = vector<double>(vals20 ,vals20 +22);
+ data = vector<double>(data20 ,data20 +21);
+ error = vector<double>(error20,error20+21);
+ _yS= new_ptr(Histogram(bins,data,error));
+ // pt_in with respect to thrust axis
+ double vals21[] = {0.000, 0.100, 0.200, 0.300, 0.400,
+ 0.500, 0.600, 0.700, 0.800, 1.000,
+ 1.200, 1.400, 1.600, 1.800, 2.000,
+ 2.500, 3.000, 3.500, 4.000, 5.000,
+ 6.000, 7.000, 8.000, 10.000, 12.000,
+ 14.000};
+ double data21[]={46.663 ,39.823 ,29.351 ,21.034 ,15.156 ,
+ 11.149 , 8.348 , 6.430 , 4.5131 , 2.9522 ,
+ 2.0401 , 1.4597 , 1.0796 , 0.8155 , 0.5326 ,
+ 0.2988 , 0.18067 , 0.11471 , 0.06305 , 0.03040 ,
+ 0.01501 , 0.00858 , 0.00376 , 0.00123 , 0.00044};
+ double error21stat[]={0.037 ,0.033 ,0.028 ,0.024 ,0.020 ,
+ 0.017 ,0.015 ,0.013 ,0.0076 ,0.0062 ,
+ 0.0052 ,0.0044 ,0.0038 ,0.0033 ,0.0017 ,
+ 0.0013 ,0.00099 ,0.00079 ,0.00042 ,0.00029 ,
+ 0.00021 ,0.00016 ,0.00008 ,0.00004 ,0.00003};
+ double error21syst[]={1.758 ,1.092 ,0.608 ,0.350 ,0.219 ,
+ 0.150 ,0.111 ,0.087 ,0.0624 ,0.0420 ,
+ 0.0299 ,0.0222 ,0.0171 ,0.0136 ,0.0095 ,
+ 0.0057 ,0.00383,0.00273,0.00171,0.00095,
+ 0.00054,0.00035,0.00017,0.00006,0.00002};
+ double error21[25];
+ for(unsigned int ix=0;ix<25;++ix){error21[ix]=sqrt(sqr(error21stat[ix])+
+ sqr(error21syst[ix]));}
+ bins = vector<double>(vals21 ,vals21 +26);
+ data = vector<double>(data21 ,data21 +25);
+ error = vector<double>(error21,error21+25);
+ _ptinT= new_ptr(Histogram(bins,data,error));
+ // pt_out with respect to thrust axis
+ double vals22[] = {0.000, 0.100, 0.200, 0.300, 0.400,
+ 0.500, 0.600, 0.700, 0.800, 1.000,
+ 1.200, 1.400, 1.600, 1.800, 2.000,
+ 2.500, 3.000, 3.500};
+ double data22[]={66.160 ,49.794 ,33.544 ,21.407 ,13.466 ,
+ 8.527 , 5.448 , 3.5845 , 2.0309 , 0.9959 ,
+ 0.5288 , 0.2987 , 0.1755 , 0.1086 , 0.05266 ,
+ 0.01885 , 0.00814};
+ double error22stat[]={0.043 ,0.037 ,0.030 ,0.024 ,0.019 ,
+ 0.015 ,0.012 ,0.0098 ,0.0052 ,0.0037 ,
+ 0.0028 ,0.0021 ,0.0016 ,0.0013 ,0.00058 ,
+ 0.00035 ,0.00023};
+ double error22syst[]={1.822 ,1.149 ,0.678 ,0.397 ,0.239 ,
+ 0.150 ,0.097 ,0.0658 ,0.0398 ,0.0216 ,
+ 0.0127 ,0.0079 ,0.0051 ,0.0034 ,0.00189,
+ 0.00080,0.00040};
+ double error22[17];
+ for(unsigned int ix=0;ix<17;++ix){error22[ix]=sqrt(sqr(error22stat[ix])+
+ sqr(error22syst[ix]));}
+ bins = vector<double>(vals22 ,vals22 +18);
+ data = vector<double>(data22 ,data22 +17);
+ error = vector<double>(error22,error22+17);
+ _ptoutT= new_ptr(Histogram(bins,data,error));
+ // pt_in with respect to sphericity axis
+ double vals23[] = {0.000, 0.100, 0.200, 0.300, 0.400,
+ 0.500, 0.600, 0.700, 0.800, 1.000,
+ 1.200, 1.400, 1.600, 1.800, 2.000,
+ 2.500, 3.000, 3.500, 4.000, 5.000,
+ 6.000, 7.000, 8.000, 10.000, 12.000,
+ 14.000};
+ double data23[]={49.206 ,38.461 ,28.203 ,20.391 ,14.926 ,
+ 11.133 , 8.458 , 6.548 , 4.6706 , 3.0684 ,
+ 2.1299 , 1.5201 , 1.1143 , 0.8398 , 0.5334 ,
+ 0.2968 , 0.17343 , 0.10741 , 0.05615 , 0.02473 ,
+ 0.01157 , 0.00561 , 0.00204 , 0.00049 , 0.00012 };
+ double error23stat[]={0.038 ,0.033 ,0.027 ,0.023 ,0.020 ,
+ 0.017 ,0.015 ,0.013 ,0.0078 ,0.0064 ,
+ 0.0053 ,0.0045 ,0.0039 ,0.0034 ,0.0017 ,
+ 0.0013 ,0.00098 ,0.00078 ,0.00040 ,0.00027 ,
+ 0.00019 ,0.00013 ,0.00006 ,0.00003 ,0.00001};
+ double error23syst[]={1.672 ,0.984 ,0.571 ,0.349 ,0.233 ,
+ 0.168 ,0.129 ,0.102 ,0.0747 ,0.0504 ,
+ 0.0359 ,0.0264 ,0.0201 ,0.0159 ,0.0107 ,
+ 0.0065 ,0.00418,0.00292,0.00176,0.00089,
+ 0.00048,0.00026,0.00010,0.00002,0.00001};
+ double error23[25];
+ for(unsigned int ix=0;ix<25;++ix){error23[ix]=sqrt(sqr(error23stat[ix])+
+ sqr(error23syst[ix]));}
+ bins = vector<double>(vals23 ,vals23 +26);
+ data = vector<double>(data23 ,data23 +25);
+ error = vector<double>(error23,error23+25);
+ _ptinS= new_ptr(Histogram(bins,data,error));
+ // pt_out with respect to sphericity axis
+ double vals24[] = {0.000, 0.100, 0.200, 0.300, 0.400,
+ 0.500, 0.600, 0.700, 0.800, 1.000,
+ 1.200, 1.400, 1.600, 1.800, 2.000,
+ 2.500, 3.000, 3.500};
+ double data24[]={66.825 ,50.556 ,34.241 ,21.708 ,13.481 ,
+ 8.314 , 5.180 , 3.2986 , 1.7559 , 0.8187 ,
+ 0.4064 , 0.2175 , 0.1232 , 0.0712 , 0.03217 ,
+ 0.01112 , 0.00387};
+ double error24stat[]={0.043 ,0.037 ,0.030 ,0.024 ,0.019 ,
+ 0.015 ,0.012 ,0.0094 ,0.0049 ,0.0034 ,
+ 0.0024 ,0.0018 ,0.0014 ,0.0011 ,0.00047 ,
+ 0.00029 ,0.00017};
+ double error24syst[]={1.506 ,1.102 ,0.726 ,0.451 ,0.277 ,
+ 0.170 ,0.106 ,0.0679 ,0.0370 ,0.0181 ,
+ 0.0096 ,0.0055 ,0.0034 ,0.0022 ,0.00115,
+ 0.00050,0.00021};
+ double error24[17];
+ for(unsigned int ix=0;ix<17;++ix){error24[ix]=sqrt(sqr(error24stat[ix])+
+ sqr(error24syst[ix]));}
+ bins = vector<double>(vals24 ,vals24 +18);
+ data = vector<double>(data24 ,data24 +17);
+ error = vector<double>(error24,error24+17);
+ _ptoutS= new_ptr(Histogram(bins,data,error));
+ // number of charged particles
+ double vals25[]={01., 3., 5., 7., 9.,
+ 11.,13.,15.,17.,19.,
+ 21.,23.,25.,27.,29.,
+ 31.,33.,35.,37.,39.,
+ 41.,43.,45.,47.,49.,
+ 51.,53.,55.};
+ double data25[]={0.0010 ,0.016 ,0.16 ,0.68 , 2.08 ,
+ 4.69 , 8.00 ,10.79 ,12.61 ,12.85 ,
+ 11.83 , 9.99 , 7.85 , 5.95, 4.35 ,
+ 2.97 , 2.02 , 1.29 , 0.81 , 0.47 ,
+ 0.26 , 0.17 , 0.089 , 0.042 , 0.025 ,
+ 0.011 , 0.004};
+ double error25stat[]={0.0010 ,0.020 ,0.03 ,0.05 , 0.08 ,
+ 0.12 , 0.16 , 0.18 , 0.19 , 0.20 ,
+ 0.19 , 0.17 , 0.15 , 0.13 , 0.11 ,
+ 0.09 , 0.08 , 0.06 , 0.05 , 0.04 ,
+ 0.03 , 0.02 , 0.016 , 0.011 , 0.009 ,
+ 0.007 , 0.004};
+ double error25syst[]={0.0,0.0,0.10, 0.18, 0.19,
+ 0.23, 0.19, 0.40, 0.24, 0.34,
+ 0.20, 0.35, 0.14, 0.17, 0.17,
+ 0.09, 0.09, 0.11, 0.06, 0.05,
+ 0.04, 0.05, 0.038, 0.020, 0.015,
+ 0.007, 0.004};
+ double error25[27];
+ for(unsigned int ix=0;ix<27;++ix)
+ {
+ error25[ix]=sqrt(sqr(error25stat[ix])+
+ sqr(error25syst[ix]))/100.;
+ data25[ix]/=100.;
+ }
+ bins = vector<double>(vals25 ,vals25 +28);
+ data = vector<double>(data25 ,data25 +27);
+ error = vector<double>(error25,error25+27);
+ _nch=new_ptr(Histogram(bins,data,error));
+}
diff --git a/Contrib/MCPWNLO/EPEM/LEPAnalysis/MySingleParticleAnalysis.h b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MySingleParticleAnalysis.h
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/LEPAnalysis/MySingleParticleAnalysis.h
@@ -0,0 +1,201 @@
+// -*- C++ -*-
+//
+// MySingleParticleAnalysis.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_MySingleParticleAnalysis_H
+#define HERWIG_MySingleParticleAnalysis_H
+//
+// This is the declaration of the MySingleParticleAnalysis class.
+//
+
+#include "ThePEG/Repository/CurrentGenerator.h"
+#include "ThePEG/Handlers/AnalysisHandler.h"
+#include "ThePEG/Repository/EventGenerator.h"
+#include "Herwig++/Utilities/Histogram.h"
+#include "MyEventShapes.h"
+
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * The MySingleParticleAnalysis class performs the analysis for
+ * single particle variables and is intended as a slave handler for the
+ * EventShapesMasterAnalysis class.
+ *
+ * @see \ref MySingleParticleAnalysisInterfaces "The interfaces"
+ * defined for MySingleParticleAnalysis.
+ */
+class MySingleParticleAnalysis: public AnalysisHandler {
+
+public:
+
+ /** @name Virtual functions required by the AnalysisHandler class. */
+ //@{
+
+ /**
+ * Analyze the given vector of particles. The default version calls
+ * analyze(tPPtr) for each of the particles.
+ * @param particles the vector of pointers to particles to be analyzed
+ */
+ virtual void analyze(const tPVector & particles);
+ //@}
+
+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.
+ */
+ inline virtual IBPtr clone() const {return new_ptr(*this);}
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ inline virtual IBPtr fullclone() const {return new_ptr(*this);}
+ //@}
+
+protected:
+
+ /** @name Standard Interfaced functions. */
+ //@{
+ /**
+ * 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 static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<MySingleParticleAnalysis> initMySingleParticleAnalysis;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ MySingleParticleAnalysis & operator=(const MySingleParticleAnalysis &);
+
+private:
+
+ /**
+ * Histogram for the rapidity distribution with respect to the thrust axis
+ */
+ HistogramPtr _yT;
+
+ /**
+ * Histogram for the rapidity distribution with respect to the sphericity axis
+ */
+ HistogramPtr _yS;
+
+ /**
+ * Histogram for the \f$p_{T,in}\f$ distribution with respect to the thrust axis
+ */
+ HistogramPtr _ptinT;
+
+ /**
+ * Histogram for the \f$p_{T,out}\f$ distribution with respect to the thrust axis
+ */
+ HistogramPtr _ptoutT;
+
+ /**
+ * Histogram for the \f$p_{S,in}\f$ distribution with respect to the sphericity axis
+ */
+ HistogramPtr _ptinS;
+
+ /**
+ * Histogram for the \f$p_{S,out}\f$ distribution with respect to the sphericity axis
+ */
+ HistogramPtr _ptoutS;
+
+ /**
+ * Histogram for the number of charged particles
+ */
+ HistogramPtr _nch;
+
+ /**
+ * Object which calculates the event shapes
+ */
+ MyEventShapesPtr _shapes;
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of MySingleParticleAnalysis. */
+template <>
+struct BaseClassTrait<Herwig::MySingleParticleAnalysis,1> {
+ /** Typedef of the first base class of MySingleParticleAnalysis. */
+ typedef AnalysisHandler NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the MySingleParticleAnalysis class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::MySingleParticleAnalysis>
+ : public ClassTraitsBase<Herwig::MySingleParticleAnalysis> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::MySingleParticleAnalysis"; }
+ /** Return the name(s) of the shared library (or libraries) be loaded to get
+ * access to the MySingleParticleAnalysis class and any other class on which it depends
+ * (except the base class). */
+ static string library() { return "MyEventShapes.so MySingleParticleAnalysis.so"; }
+};
+
+/** @endcond */
+
+}
+
+//#include "MySingleParticleAnalysis.icc"
+
+#endif /* HERWIG_MySingleParticleAnalysis_H */
diff --git a/Contrib/MCPWNLO/EPEM/MCEPEM.cxx b/Contrib/MCPWNLO/EPEM/MCEPEM.cxx
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/MCEPEM.cxx
@@ -0,0 +1,787 @@
+#include <cstdlib>
+#include <ctime>
+#include <iostream>
+#include <fstream>
+#include <string>
+//#include "LHAPDFWrap.h"
+#include <iostream>
+#include <fstream>
+#include <stdio.h>
+#include "MCEPEM_INPUTS.h"
+#include <cmath>
+#include <iomanip>
+using namespace std;
+// Checks if phase space point is in soft and collinear region?
+void QQgsc(double r3,double r4, double &rx, double &ry, double param[8], double &rwgt, double &rwgtax, double &rwgt1, double &rwgtax1, bool resolve);
+// Checks if phase space point is in hard region?
+void QQgh(double r3,double r4, double &rx, double &ry, double param[8], double &rwgt, double &rwgtax, double &rwgt1, double &rwgtax1, bool resolve);
+// Checks if phase space point is in gap between phase space for massive partons and full half-triangle?
+void QQgsp(double r3,double r4, double &rx, double &ry, double param[8], double &rwgt, double &rwgtax, double &rwgt1, double &rwgtax1, bool resolve);
+// Random number generator
+double random (int &rseed);
+
+// Main program
+
+int main() {
+ Input user;
+ int nev = user.nevint();
+ int nevg = user.nevgen();
+ int nit = user.it();
+ double emcm = user.cme();
+ int seed = user.rseed();
+ int nf = user.nf();
+ bool massiveME = user.massiveME();
+ bool resolve = user.resolve();
+ bool boost = user.bst();
+ if (massiveME) {boost=false;}
+ int ii=0; //event count
+ // Constants
+ double pi = 3.14152654;
+ double GF = 0.0000116639;
+ double Mz = user.Mz();
+ double Yz = 2.486;
+ double alphaem = 0.007297352;
+ double alphas = user.alphasmz();
+ //Lepton charge & coupling constants
+ double Che = -1;
+ double sin2thw = 0.2312;
+ double Ae = -0.5;
+ double Ve = Ae-2.*Che*sin2thw;
+ double AV2 = pow(Ae,2)+pow(Ve,2);
+ double CLe = (Ae+Ve)/2.;
+ double CRe = (Ve-Ae)/2.;
+ double gz2 = sqrt(32.)*GF*pow(Mz,2);
+ double e2 = 4.*pi*alphaem;
+ double k = sqrt(2.)*GF*pow(Mz,2)/e2;
+ double chi1 = k*pow(emcm,2)*(pow(emcm,2)-pow(Mz,2))/(pow((pow(emcm,2)-pow(Mz,2)),2)+pow(Yz*Mz,2));
+ double chi2 = pow(k,2)*pow(emcm,4)/(pow((pow(emcm,2)-pow(Mz,2)),2)+pow(Yz*Mz,2));
+ //quark masses ,velocities and couplings. NB:gluon mass[6] =0.75
+
+ double mq[7],beta[6],Ch[6],Aq[6],Vq[6],cs[6],sigV[6],sigA[6],sigVA[6],css;
+ mq[1] = 0.325; mq[2] = 0.325; mq[3] = 0.5; mq[4] = 1.6; mq[5] = 5.; mq[6] = 0.75;
+
+ Ch[1]=-1./3.; Ch[2]=2./3.; Ch[3]=Ch[1]; Ch[4]=Ch[2]; Ch[5]=Ch[1];
+ Aq[1]=-0.5; Aq[2]=0.5; Aq[3]=Aq[1]; Aq[4]=Aq[2]; Aq[5]=Aq[1];
+
+/* w, w1 are the integrands. p,p1 are the corresponding integrals calculated from sum,sum1 & sd, sd1 are the corresponding errors
+ calculated via ssq, ssq1. bigwt is the maximum value of the integrand over the phase space (will be used for event generation) */
+
+ double wgt, wgtax, wgt1,wgtax1;
+ double w[3],w1[3],bigwt[3],sum[3],sum1[3],ssq[3],ssq1[3],sd[3],sd1[3],p[3],p1[3];
+
+ sum1[0]=0.;sum1[1]=0.;sum[2]=0.;
+ sum1[0]=0.;sum1[1]=0.;sum1[2]=0.;
+ ssq[0]=0.;ssq[1]=0.;ssq[2]=0.;
+ ssq1[0]=0.;ssq1[1]=0.;ssq1[2]=0.;
+ bigwt[0]=0.;bigwt[1]=0.;bigwt[2]=0.;
+
+ cout << "Integrating..." << endl;
+
+ for (int d = 0; d < nev; d++) {
+ //Calculate Born cross-section
+
+ //initialize cross-sections...
+ cs[1]=0.; cs[2]=0.; cs[3]=0.; cs[4]=0.; cs[5]=0.; css=0.;
+ for (int ix=1; ix < nf+1 ; ix++) {
+ Vq[ix] = Aq[ix]-(2.*Ch[ix]*sin2thw);
+ beta[ix] = sqrt(1.-4.*pow(mq[ix]/emcm,2));
+ sigV[ix] = pow(Ch[ix],2)-2.*Ch[ix]*Ve*Vq[ix]*chi1+AV2*pow(Vq[ix],2)*chi2;
+ sigA[ix] = AV2*pow(Aq[ix],2)*chi2;
+ sigVA[ix]= -2.*Ch[ix]*Ae*Aq[ix]*chi1+4.*Ae*Ve*Aq[ix]*Vq[ix]*chi2;
+ cs[ix] = beta[ix]+0.5*pow(beta[ix],2)+0.5*(1.-pow(beta[ix],2))*beta[ix]*sigV[ix]+pow(beta[ix],3)*sigA[ix];
+ css+=cs[ix];
+}
+
+
+ //select flavour of process
+ double m;
+ int ID;
+ if (random(seed) < cs[1]/css) {ID = 1; } else {
+ if (random(seed) < cs[2]/(css-cs[1])) {ID = 2;} else {
+ if (random(seed) < cs[3]/(css-cs[1]-cs[2])) {ID = 3; } else {
+ if (random(seed) < cs[4]/(cs[4]+cs[5])) {ID = 4; } else {
+ ID = 5; m = mq[5];}}}}
+
+ m=mq[ID];
+ if (!massiveME) {m = 0.;}
+
+// Parameters for NLO cross-section calculation.
+ double param[8];
+ param[0] = pow(m,2)/pow(emcm,2);
+ param[1] = 1.+12.*param[0]; // R = 1+param[1]*alphas/pi for vector current
+ param[2] = 1.-22.*param[0]; // R = 1+param[2]*alphas/pi for axial vector current
+ param[3] = 2.*param[0];
+ param[4] = sqrt(1.-4.*param[0]); // beta
+ param[5] = 0.5*(1.+param[4]);
+ param[6] = (param[0]*param[5]+0.25*param[4]*pow(1+param[4],2))/(param[5]-param[0]);
+ param[7] = 2.*alphas/(3.*pi); // colour factor
+
+ // Random numbers and phase space points x and y.
+ double r1=random(seed);
+ double r2=random(seed);
+ double r3=random(seed);
+ double r4=random(seed);
+ double x,y;
+ x = r1;
+ y = r2;
+ QQgsc(r3, r4, x, y, param, wgt, wgtax, wgt1, wgtax1, resolve);
+ w[0] = (wgt*sigV[ID]+wgtax*sigA[ID])/2.; w1[0]=(wgt1*sigV[ID]+wgtax1*sigA[ID])/2.;
+ QQgh(r3, r4, x, y, param, wgt, wgtax, wgt1, wgtax1, resolve);
+ w[1] = (wgt*sigV[ID]+wgtax*sigA[ID])/2.; w1[1]=(wgt1*sigV[ID]+wgtax1*sigA[ID])/2.;
+ QQgsp(r3, r4, x, y, param, wgt, wgtax, wgt1, wgtax1, resolve);
+ w[2] = (wgt*sigV[ID]+wgtax*sigA[ID])/2.; w1[2]=(wgt1*sigV[ID]+wgtax1*sigA[ID])/2.;
+ if (!massiveME) {w[2]=0; w1[2]=0.;}
+
+ for (int iz = 0; iz < 3; iz++) {
+ if (abs(w[iz]) > abs(bigwt[iz])) {bigwt[iz] = w[iz];}
+ sum[iz]+=w[iz];
+ sum1[iz]+=w1[iz];
+ ssq[iz]+=pow(w[iz],2);
+ ssq1[iz]+=pow(w1[iz],2);
+
+}
+ cout << "Integrated event : " << "\t" << d+1 << "\t" << "of" << "\t" << nev << "\r" << flush;
+
+}
+ cout << endl;
+ double xsec=0;
+ double cstt=0;
+ double xsecabs = 0.;
+ for (int ic=0; ic<3; ic++) {
+ p[ic] = sum[ic]/nev;
+ p1[ic] = sum1[ic]/nev;
+ sd[ic] = sqrt((ssq[ic]/nev-pow(p[ic],2))/nev);
+ sd1[ic] = sqrt((ssq1[ic]/nev-pow(p1[ic],2))/nev);
+ xsec+=p[ic]+p1[ic];
+ xsecabs+=fabs(p[ic])+fabs(p1[ic]);
+ //Output to screen the integrals, errors and maximum weights
+// cout << "PHASE SPACE INTEGRALS:" << "\t" << p[ic] << "/" << p1[ic] <<"/" << sd[ic] <<"/" << sd1[ic]
+// <<"/" << bigwt[ic] << "\t" << xsec << endl;
+}
+
+
+ //*********************************************************************************
+ /*Les Houches Accord event parameters:: PUP are the momenta,
+ ICOLUP is the colour code, MOTHUP is the mother information, ISTUP is
+ the status code. ISPINUP signifies spins. IDUP is the particle ID.
+ NUP is the number of particles in the event. SCALUP is the scale of
+ the event.AQEDUP and AQCDUP are alphaem and alphas resp.XWGTUP is
+ the weight of the event=1 or -1 for unweighted events.*/
+
+ double PUP[6][7],AQEDUP,AQCDUP,XWGTUP,SCALUP;
+ int ICOLUP[3][7],MOTHUP[3][7],ISTUP[7],ISPINUP[7],IDUP[7],NUP;
+ NUP=0;
+ SCALUP = emcm;
+ AQEDUP=0.007297352;
+ AQCDUP=alphas;
+ IDUP[1]=11;
+ IDUP[2]=-11;
+ IDUP[3]=23;
+ IDUP[6]=21;
+ MOTHUP[1][1]=0;
+ MOTHUP[1][2]=0;
+ MOTHUP[2][1]=0;
+ MOTHUP[2][2]=0;
+ MOTHUP[1][3]=1;
+ MOTHUP[2][3]=2;
+ MOTHUP[1][4]=3;
+ MOTHUP[2][4]=3;
+ MOTHUP[1][5]=3;
+ MOTHUP[2][5]=3;
+ MOTHUP[1][6]=3;
+ MOTHUP[2][6]=3;
+ ICOLUP[1][1]=0;
+ ICOLUP[2][1]=0;
+ ICOLUP[1][2]=0;
+ ICOLUP[2][2]=0;
+ ICOLUP[1][3]=0;
+ ICOLUP[2][3]=0;
+ ISTUP[1]=-1;
+ ISTUP[2]=-1;
+ ISTUP[3]=2;
+ ISTUP[4]=1;
+ ISTUP[5]=1;
+ ISTUP[6]=1;
+ //Allocate phase space region
+ double cst[3],bigwgt;
+ bigwgt=0.;
+ cst[0]=fabs(p[0])+fabs(p1[0]);
+ cst[1]=fabs(p[1])+fabs(p1[1]);
+ cst[2]=fabs(p[2])+fabs(p1[2]);
+ cstt = cst[0]+cst[1]+cst[2];
+
+ ofstream outdata;
+ outdata.open("MCEPEM.dat", ios::trunc);//output for events
+
+
+ outdata << "<LesHouchesEvents version =\"1.0\">" << endl; outdata << "<!--" << endl;
+ outdata << "NORMFACTOR = " << "\t" << xsecabs/xsec << endl;
+ outdata << "MC@NLO Z/gamma boson production from e+e- annihilation at LEP" <<endl ;
+ outdata << "File generated with MCEPEM.cxx" << endl; outdata << "-->" << endl;
+ outdata << "<init>" << endl;
+ outdata << "\t11\t" << "-11\t" ;
+ outdata << user.cme()/2. << "\t" << user.cme()/2. << "\t" << "0 \t 0 \t 7\t 7 \t 3 \t 1" << endl;
+ outdata << "\t" << 30590. << "\t" << 0.000000 << "\t1.00000 \t11" << endl; outdata << "</init>" << endl;
+
+
+ cout << "Generating events..." << endl;
+
+
+ for (int d = 0; d < nevg; d++) {
+ int Jt; //phase space identifier
+ if (random(seed) < cst[0]/cstt) {
+ if (random(seed) < fabs(p[0])/cst[0]) {
+ Jt=1; bigwgt=bigwt[0];} else
+ {Jt=2;}} else
+ if (random(seed) < cst[1]/(cst[1]+cst[2])) {
+ if (random(seed) < fabs(p[1])/cst[1]) {
+ Jt=3; bigwgt=bigwt[1];} else
+ {Jt=4;}} else
+ {Jt=5;}
+
+ //select flavour of process
+ double m,mg,mass[8];
+ int ID;
+ if (random(seed) < cs[1]/css) {ID = 1; } else {
+ if (random(seed) < cs[2]/(css-cs[1])) {ID = 2;} else {
+ if (random(seed) < cs[3]/(css-cs[1]-cs[2])) {ID = 3;} else {
+ if (random(seed) < cs[4]/(cs[4]+cs[5])) {ID = 4;} else {
+ ID = 5;}}}}
+ if (massiveME) { m = mq[ID];} else { m = 0.;}
+ mass[1]=0.;
+ mass[2]=0.;
+ mass[3]=emcm;
+ //quark IDs
+ IDUP[4] = ID;
+ IDUP[5] = -ID;
+
+// Parameters for NLO cross-section calculation.
+ double param[8];
+ param[0] = pow(m,2)/pow(emcm,2);
+ param[1] = 1.+12.*param[0]; // R = 1+param[1]*alphas/pi for vector current
+ param[2] = 1.-22.*param[0]; // R = 1+param[2]*alphas/pi for axial vector current
+ param[3] = 2.*param[0];
+ param[4] = sqrt(1.-4.*param[0]); // beta
+ param[5] = 0.5*(1.+param[4]);
+ param[6] = (param[0]*param[5]+0.25*param[4]*pow(1+param[4],2))/(param[5]-param[0]);
+ param[7] = 2.*alphas/(3.*pi); // colour factor
+
+ // cross-section parameters
+ double sigU = param[4]*sigV[ID]+pow(param[4],3)*sigA[ID];
+ double sigL = 0.5*(1.-pow(param[4],2))*param[4]*sigV[ID];
+ double sigF = pow(param[4],2)*sigVA[ID];
+ double CLf = (Aq[ID]+Vq[ID])/2.;
+ double CRf = (Vq[ID]-Aq[ID])/2.;
+ // phase space point x1,x2
+ double x1,x2;
+ double wt; //event weight
+ wt = 0.;
+ bool qg = true;
+ double cth,pcm;
+ cth=0.;pcm=0.;
+ if (Jt==1||Jt==3) {
+ double c13, c23, x3;
+ do {
+ // Random numbers
+ double r1=random(seed);
+ double r2=random(seed);
+ double r3=random(seed);
+ double r4=random(seed);
+ x1 = r1;
+ x2 = r2;
+ if (Jt==1) {
+ QQgsc(r3, r4, x1, x2, param, wgt, wgtax, wgt1, wgtax1, resolve);
+ wt = (wgt*sigV[ID]+wgtax*sigA[ID])/2.;}
+ if (Jt==3) {
+ QQgh(r3, r4, x1, x2, param, wgt, wgtax, wgt1, wgtax1, resolve);
+ wt = (wgt*sigV[ID]+wgtax*sigA[ID])/2.;}
+ x3=2.-x1-x2;
+ c13=(x1*x3-2.*(1.-x2))/(sqrt(pow(x1,2)-4.*param[0])*x3);
+ c23=(x2*x3-2.*(1.-x1))/(sqrt(pow(x2,2)-4.*param[0])*x3);
+ } while (random(seed) > fabs(wt)/fabs(bigwgt) || isinf(c13) || isinf(c23));
+
+ if (Jt==1){wt=-1.;}
+ if (Jt==3){wt=1.;}
+ double cofac, maxcofac,cf,ct, ppt;
+ double px1 = sqrt(pow(0.5*emcm*x1,2)-pow(m,2));
+ double px2 = sqrt(pow(0.5*emcm*x2,2)-pow(m,2));
+ double px3 = sqrt(pow(0.5*emcm*x3,2));
+ do {cth = 2.*random(seed)-1.;
+ cofac = (1.+pow(cth,2))*sigU+2.*sigL*(1.-pow(cth,2))+2.*cth*sigF;
+ maxcofac = 2.*(sigU+sigF);
+ if (random(seed) < pow(x1,2)/(pow(x1,2)+pow(x2,2))) {
+ cf = (px2*c23+px3)/px1; ct = (px1-px3*cf)/px2; }else
+ {cf = (px1*c13+px3)/px2; ct = (px2-px3*cf)/px1; qg=false;}
+ if (ct > 1. || cf > 1.) {cofac = 0.;}
+ } while (random(seed) > cofac/maxcofac);
+ double phi = 2.*pi*random(seed);
+ double phi2 = 2.*pi*random(seed);
+ if (qg) {
+ pcm = px1;
+ PUP[3][4]=px1*cth;
+ double pt = sqrt(pow(px1,2)-pow(PUP[3][4],2));
+ PUP[1][4]=pt*cos(phi);
+ PUP[2][4]=pt*sin(phi);
+ MOTHUP[1][6] = 3;
+ MOTHUP[2][6] = 3;
+ double ppl = px2*ct;
+ if (random(seed) < 0.5) {
+ ppt = sqrt (pow(px2,2)-pow(ppl,2));}else {ppt = -sqrt (pow(px2,2)-pow(ppl,2));}
+ double ppt1 = ppt*cos(phi2);
+ double ppt2 = ppt*sin(phi2);
+ PUP[3][5]=-(ppl*cth-ppt1*sin(acos(cth)));
+ PUP[1][5]=-((ppl*sin(acos(cth))+ppt1*cth)*cos(phi)-ppt2*sin(phi));
+ PUP[2][5]=-((ppl*sin(acos(cth))+ppt1*cth)*sin(phi)+ppt2*cos(phi));}
+ else {
+ pcm = px2;
+ PUP[3][5]=px2*cth;
+ double pt = sqrt(pow(px2,2)-pow(PUP[3][5],2));
+ PUP[1][5]=pt*cos(phi);
+ PUP[2][5]=pt*sin(phi);
+ MOTHUP[1][6] = 3;
+ MOTHUP[2][6] = 3;
+ double ppl = px1*ct;
+ if (random(seed) < 0.5) {
+ ppt = sqrt (pow(px1,2)-pow(ppl,2));}else {ppt = -sqrt (pow(px1,2)-pow(ppl,2));}
+ double ppt1 = ppt*cos(phi2);
+ double ppt2 = ppt*sin(phi2);
+ PUP[3][4]=-(ppl*cth-ppt1*sin(acos(cth)));
+ PUP[1][4]=-((ppl*sin(acos(cth))+ppt1*cth)*cos(phi)-ppt2*sin(phi));
+ PUP[2][4]=-((ppl*sin(acos(cth))+ppt1*cth)*sin(phi)+ppt2*cos(phi));}
+
+ // double ppl2 = px3*cf;
+ // double ppt3 = -ppt/fabs(ppt)*sqrt(pow(px3,2)-pow(ppl2,2));
+ // double ppt4 = ppt3*cos(phi2);
+ //double ppt5 = ppt3*sin(phi2);
+ // PUP[3][6]=-(ppl2*cth-ppt4*sin(acos(cth)));
+ // PUP[1][6]=-((ppl2*sin(acos(cth))+ppt4*cth)*cos(phi)-ppt5*sin(phi));
+ // PUP[2][6]=-((ppl2*sin(acos(cth))+ppt4*cth)*sin(phi)+ppt5*cos(phi));
+ PUP[3][6]= -PUP[3][4] - PUP[3][5];
+ PUP[1][6]= -PUP[1][4] - PUP[1][5];
+ PUP[2][6]= -PUP[2][4] - PUP[2][5];
+ PUP[4][4] = x1*emcm/2.;
+ PUP[4][5] = x2*emcm/2.;
+ PUP[4][6] = x3*emcm/2.;
+ // cout << PUP[1][6] +PUP[1][4]+PUP[1][5] << "\t" << PUP[2][6] +PUP[2][4]+PUP[2][5] << "\t" << PUP[3][6] +PUP[3][4]+PUP[3][5] << endl;
+ //colour info
+ ICOLUP[1][4] = 501;
+ ICOLUP[2][4] = 0;
+ ICOLUP[1][5] = 0;
+ ICOLUP[2][5] = 502;
+ ICOLUP[1][6] = 502;
+ ICOLUP[2][6] = 501;
+ //Number of particles
+ NUP=6;
+
+ }
+
+
+ if (Jt==2||Jt==4||Jt==5) {
+ x1 = 1.;x2 = 1.; wt = 1.;
+ pcm = sqrt(pow(0.5*emcm,2)-pow(m,2));
+ double cofac, maxcofac;
+ do {cth = 2.*random(seed)-1.;
+ cofac = (1.+pow(cth,2))*sigU+2.*sigL*(1.-pow(cth,2))+2.*cth*sigF;
+ maxcofac = 2.*(sigU+sigF);
+ } while (random(seed) > cofac/maxcofac);
+ double phi = 2.*random(seed)*pi;
+ PUP[3][4] = pcm*cth;
+ PUP[1][4] = sqrt(pow(pcm,2)-pow(PUP[3][4],2))*cos(phi);
+ PUP[2][4] = sqrt(pow(pcm,2)-pow(PUP[3][4],2))*sin(phi);
+ PUP[1][5] = -PUP[1][4];
+ PUP[2][5] = -PUP[2][4];
+ PUP[3][5] = -PUP[3][4];
+ PUP[4][4] = emcm/2.;
+ PUP[4][5] = emcm/2.;
+ PUP[3][6]=0.;
+ PUP[1][6]=0.;
+ PUP[2][6]=0.;
+ //colour info
+ ICOLUP[1][4] = 501;
+ ICOLUP[2][4] = 0;
+ ICOLUP[1][5] = 0;
+ ICOLUP[2][5] = 501;
+ //Number of particles
+ NUP=5;
+ }
+ double alpha = 1.;
+
+ //boost masses if needed. Need to boost to nominal gluon mass always.
+ double mb;
+ if (massiveME || (!massiveME && boost)) {mb = mq[ID]; mg = mq[6]; }
+ if (!massiveME && !boost) {mb = 0.; mg = 0.;}
+ double Eq,Eqb,Eg;
+ double pq = sqrt(pow(PUP[1][4],2)+pow(PUP[2][4],2)+pow(PUP[3][4],2));
+ double pqb = sqrt(pow(PUP[1][5],2)+pow(PUP[2][5],2)+pow(PUP[3][5],2));
+ double pg = sqrt(pow(PUP[1][6],2)+pow(PUP[2][6],2)+pow(PUP[3][6],2));
+ for (int ix=1; ix < nit+1; ix++) {
+ Eq = sqrt(pow(mb,2)+alpha*pow(pq,2));
+ Eqb = sqrt(pow(mb,2)+alpha*pow(pqb,2));
+ Eg = sqrt(pow(mg,2)+alpha*pow(pg,2));
+ if (NUP==6) {
+ alpha = alpha+(2.*(emcm-Eq-Eqb-Eg))/(pow(pq,2)/Eq+pow(pqb,2)/Eqb+pow(pg,2)/Eg);}
+ else {alpha = alpha+(2.*(emcm-Eq-Eqb))/(pow(pq,2)/Eq+pow(pqb,2)/Eqb);}
+ }
+ PUP[1][4] =sqrt(alpha)*PUP[1][4];
+ PUP[2][4] =sqrt(alpha)*PUP[2][4];
+ PUP[3][4] =sqrt(alpha)*PUP[3][4];
+ PUP[4][4] =Eq;
+ PUP[1][5] =sqrt(alpha)*PUP[1][5];
+ PUP[2][5] =sqrt(alpha)*PUP[2][5];
+ PUP[3][5] =sqrt(alpha)*PUP[3][5];
+ PUP[4][5] =Eqb;
+ PUP[1][6] =sqrt(alpha)*PUP[1][6];
+ PUP[2][6] =sqrt(alpha)*PUP[2][6];
+ PUP[3][6] =sqrt(alpha)*PUP[3][6];
+ PUP[4][6] =Eg;
+ if (massiveME || (!massiveME && boost)) {
+ mass[4] = mq[ID];
+ mass[5] = mq[ID];
+ mass[6] = mq[6];}
+ if (!massiveME && !boost)
+ {mass[4] = 0.;
+ mass[5] = 0.;
+ mass[6] = 0.;}
+
+
+ //spin information (not needed yet!)
+ double C[9], M[9];
+ C[1] = pow(CRe,2)*(chi2/(pow((emcm*k),2)))*pow(gz2,2);
+ C[2] = pow(CLe,2)*(chi2/(pow((emcm*k),2)))*pow(gz2,2);
+ C[3] = CLf*(emcm/2.-pcm)+CRf*(emcm/2.+pcm);
+ C[4] = CLf*(emcm/2.+pcm)+CLf*(emcm/2.-pcm);
+ C[5] = (CLf+CRf)*m;
+ C[6] = 2*e2*Ch[ID]*CRe*chi1*gz2/(k*emcm);
+ C[7] = 2*e2*Ch[ID]*CLe*chi1*gz2/(k*emcm);
+ C[8] = e2*Ch[ID];
+ M[1] = (C[1]*pow(C[3],2)-C[6]*C[3]+pow(C[8],2))*pow(1+cth,2);
+ M[5] = (C[2]*pow(C[4],2)-C[7]*C[4]+pow(C[8],2))*pow(1+cth,2);
+ M[2] = (C[1]*pow(C[4],2)-C[6]*C[4]+pow(C[8],2))*pow(1+cth,2);
+ M[6] = (C[2]*pow(C[3],2)-C[7]*C[3]+pow(C[8],2))*pow(1+cth,2);
+ M[3] = (C[1]*pow(C[5],2)-2.*m/emcm*C[6]*C[5]+pow(C[8],2)*4.*param[0])*(1.-pow(cth,2));
+ M[7] = (C[2]*pow(C[5],2)-2.*m/emcm*C[7]*C[5]+pow(C[8],2)*4.*param[0])*(1.-pow(cth,2));
+ M[4] = M[3];
+ M[8] = M[7];
+ double Mud, Mdu;
+ Mud = 0.; Mdu =0.;
+ for (int ix=1; ix < 5; ix++) {Mud+=M[ix];}
+ for (int ix=5; ix < 9; ix++) {Mud+=M[ix];}
+ if (random(seed) < Mud/(Mud+Mdu)) {
+ ISPINUP[1]=+1;
+ ISPINUP[2]=-1;
+ ISPINUP[3]=+1;
+ if (random(seed) < (M[1]+M[3])/Mud) {
+ ISPINUP[4] = +1;
+ if (random(seed) < M[1]/(M[1]+M[3])) {
+ ISPINUP[5] = -1;}else {ISPINUP[5] = +1;}} else {
+ ISPINUP[4] = -1;
+ if (random(seed) < M[2]/(M[2]+M[4])) {
+ ISPINUP[5] = +1;} else {ISPINUP[5] = -1;} }} else {
+ ISPINUP[1]=-1;
+ ISPINUP[2]=+1;
+ ISPINUP[3]=-1;
+ if (random(seed) < (M[6]+M[7])/Mdu) {
+ ISPINUP[4] = +1;
+ if (random(seed) < M[6]/(M[6]+M[7])) {
+ ISPINUP[5] = -1;}else {ISPINUP[5] = +1;}} else {
+ ISPINUP[4] = -1;
+ if (random(seed) < M[5]/(M[5]+M[8])) {
+ ISPINUP[5] = +1;} else {ISPINUP[5] = -1;} }}
+ if (qg) {ISPINUP[6] = ISPINUP[4];} else {ISPINUP[6] = ISPINUP[5];}
+
+ //Momenta of incoming particles and Z boson
+
+ PUP[4][1]=emcm/2.;
+ PUP[1][1]=0.;
+ PUP[2][1]=0.;
+ PUP[3][1]=emcm/2;
+ PUP[4][2]=emcm/2;
+ PUP[1][2]=0.;
+ PUP[2][2]=0.;
+ PUP[3][2]=-emcm/2;
+ PUP[4][3]=emcm;
+ PUP[1][3]=0.;
+ PUP[2][3]=0.;
+ PUP[3][3]=0.;
+
+ //weight info
+ XWGTUP = wt;
+ ii+=1;
+ // cout << ii << endl;
+ double sum1, sum2, sum3, sum4;
+ sum1=0.;sum2=0.;sum3=0.;sum4=0.;
+ outdata << "<event>" << endl;
+ outdata << NUP <<"\t" << "11" <<"\t"<<XWGTUP<<"\t" << SCALUP << "\t" << AQEDUP << "\t" << AQCDUP << endl;
+ for (int ja = 1; ja < NUP+1; ja++) {
+ outdata << IDUP[ja] << "\t" << ISTUP[ja] << "\t" << MOTHUP[1][ja] <<"\t" << MOTHUP[2][ja] << "\t" << ICOLUP[1][ja] << "\t" << ICOLUP[2][ja] <<"\t" <<setprecision (9)<< PUP[1][ja] << "\t" << PUP[2][ja]<<"\t"<<PUP[3][ja]<<"\t"<<PUP[4][ja]<<"\t" << mass[ja] <<"\t"<< "0" << "\t" <<"9" <<endl;
+ sum1+=PUP[4][ja];sum2+=PUP[1][ja];sum3+=PUP[2][ja];sum4+=PUP[3][ja];
+ cout << "Generated event : " << "\t" << ii << "\t" << "of" << "\t" << nevg << "\r" << flush;
+}
+ outdata << "</event>" << endl;
+
+
+ // cout << sum1 << "\t" << sum2 << "\t" << sum3 << "\t" << sum4 << endl;
+ }
+
+ outdata << "</LesHouchesEvents>" << endl;
+ cout << endl;
+ return 0;
+}
+/********************************************************************************/
+// In soft and collinear phase space region ?
+
+void QQgsc(double r3,double r4, double &rx, double &ry, double param[8], double &rwgt, double &rwgtax, double &rwgt1, double &rwgtax1, bool resolve) {
+
+ //Initialize weights
+ rwgt = 0.;rwgtax = 0.;rwgt1 = 0.;rwgtax1 = 0.;
+
+ /*Remove 2-jet events */
+ double y1 = 1.-rx;
+ double y2 = 1.-ry;
+ if ((1.-y1)==1 && (1.-y2)==1.) {return;}
+ bool soft = false;
+ int region = 0; // 1 for jet region cont. x=1; 2 for jet region cont. y=1
+ double fac = 1.; // weight factor for soft regions
+
+ if (y1 < 0.25 && y2 <0.25) {
+ soft = true;
+ if (y2 < y1) {
+ y1 = 0.25*r3;
+ y2 = r4*y1;
+ fac = 2.*r3;
+} else {
+ y2 = 0.25*r4;
+ y1 = r3*y2;
+ fac = 2.*r4;
+}
+ }
+
+ /* Check if outside Dalitz boundary */
+
+ if (y1*y2*(1.-y1-y2) < param[0]*pow((y1+y2),2)) {return;}
+
+ /*Inside jet 1? */
+ double w1 = 1.-y1;
+ double w2 = 1.-y2;
+ double tk = param[5];
+ double d1 = 0.25-(1.-w2)/tk;
+ double z, d2 , xx1, xx2;
+ if (d1 > 0.) {
+ z = 0.5+sqrt(d1);
+ d2 = pow(w2,2)-4.*param[0];
+ if (d2 > 0.) {
+ d2 = sqrt(d2);
+ double rr = 1.+param[0]/(1.-w2+param[0]);
+ xx1 = (rr*(2.-w2)+(2.*z-rr)*d2)/2.;
+ xx2 = (rr*(2.-w2)+(2.*(1.-z)-rr)*d2)/2.;
+ if (xx2 < w1 && w1 < xx1) {
+ region = 1;}
+ }
+ }
+ if (region == 0) {
+ w1 = 1.-y2;
+ w2 = 1.-y1;
+ tk = param[6];
+ d1 = 0.25-(1.-w2)/tk;
+ if (d1 > 0.) {
+ z = 0.5+sqrt(d1);
+ d2 = pow(w2,2)-4.*param[0];
+ if (d2 > 0.) {
+ d2 = sqrt(d2);
+ double rr = 1.+param[0]/(1.-w2+param[0]);
+ xx1 = (rr*(2.-w2)+(2.*z-rr)*d2)/2.;
+ xx2 = (rr*(2.-w2)+(2.*(1.-z)-rr)*d2)/2.;
+ if (xx2 < w1 && w1 < xx1) {
+ region = 2;} else {return;}
+ } else {return;}
+ } else {return;} }
+
+ /* Calculate weights for jet regions */
+ double zeta = -8.*param[0]*(1.+param[3]);
+ double zetax = param[3]*(pow((3.+y1+y2),2)-19.+4.*param[0]);
+ double r, zz;
+ rx = 1.-y1;
+ ry = 1.-y2;
+
+ if (region == 1) {
+ r = 0.5*(1.+param[0]/(1.+param[0]-ry));
+ zz = r+(rx-(2.-ry)*r)/sqrt(pow(ry,2)-2.*param[3]);
+
+ rwgt = ((pow((rx+param[3]),2)+pow((ry+param[3]),2)+zeta)/((1.+param[3])*y1*y2)-param[3]*(1./pow(y1,2)+1./pow(y2,2)))/param[4];
+ rwgt = rwgt-(((1.+pow(zz,2))/(1.-zz))-param[3]/y2)/(y2*sqrt(pow(ry,2)-2.*param[3]));
+
+ rwgt = rwgt*param[7]*fac;
+
+ rwgtax = ((pow((rx+param[3]),2)+pow((ry+param[3]),2)+zetax)/(pow(param[4],2)*y1*y2)-param[3]*(1./pow(y1,2)+1./pow(y2,2)))/param[4];
+ rwgtax = rwgtax-(((1.+pow(zz,2))/(1.-zz))-param[3]/y2)/(y2*sqrt(pow(ry,2)-2.*param[3]));
+ rwgtax = rwgtax*param[7]*fac;
+
+ } else if (region == 2) {
+ r = 0.5*(1.+param[0]/(1.+param[0]-rx));
+ zz = r+(ry-(2.-rx)*r)/sqrt(pow(rx,2)-2.*param[3]);
+
+ rwgt = ((pow((rx+param[3]),2)+pow((ry+param[3]),2)+zeta)/((1.+param[3])*y1*y2)-param[3]*(1./pow(y1,2)+1./pow(y2,2)))/param[4];
+ rwgt = rwgt-(((1.+pow(zz,2))/(1.-zz))-param[3]/y1)/(y1*sqrt(pow(rx,2)-2.*param[3]));
+ rwgt = rwgt*param[7]*fac;
+
+ rwgtax = ((pow((rx+param[3]),2)+pow((ry+param[3]),2)+zetax)/(pow(param[4],2)*y1*y2)-param[3]*(1./pow(y1,2)+1./pow(y2,2)))/param[4];
+ rwgtax = rwgtax-(((1.+pow(zz,2))/(1.-zz))-param[3]/y1)/(y1*sqrt(pow(rx,2)-2.*param[3]));
+ rwgtax = rwgtax*param[7]*fac;
+
+ }
+ rwgt1 = (2.+3.*param[7]*param[1])*fac-rwgt;
+ rwgtax1 = (2.+3.*param[7]*param[2])*fac-rwgtax;
+ /* Implement soft resolution cut */
+ if (resolve) {
+ if (rx+ry > 1.9999) {return;}}
+}
+ /*********************************************************************/
+ // In hard region?
+
+void QQgh(double r3,double r4, double &rx, double &ry, double param[8], double &rwgt, double &rwgtax, double &rwgt1, double &rwgtax1, bool resolve) {
+
+ //Initialize weights and phase space points
+ rwgt = 0.;rwgtax = 0.;rwgt1 = 0.;rwgtax1 = 0.;
+
+ /*Remove 2-jet events */
+ double y1 = 1.-rx;
+ double y2 = 1.-ry;
+ if ((1.-y1)==1. && (1.-y2)==1.) {return;}
+ bool soft = false;
+ double fac = 1.; // weight factor for soft regions
+
+// Mappings for soft and collinear regions
+ if (y1 < 0.25){
+ if (y2 < 0.25) {
+ soft = true;
+ if (y1 < y2) {
+ y1 = 0.25-y1;
+ y2 = y1*(1.5-2.*y2);
+
+} else {
+ y2 = 0.25-y2;
+ y1 = y2*(1.5-2.*y1);
+}} else if (y2 < y1+2.*pow(y1,2)) {rx = 1.; ry = 1.; return;}
+ } else if (y2 < 0.25) { if (y1 < y2+2.*pow(y2,2)) {rx = 1.; ry = 1.; return;} }
+
+
+ if (soft) {if (y1 < y2) {fac = 2.*y1;} else {fac = 2.*y2;} }
+
+ if (!soft) {
+
+ if (y1 > 0.375 && y2 < 0.25) {
+ if (y1 > 1.-2.5*y2 && y1 < 1.-y2) {
+ y2 = r4*0.25;
+ y1 = 1.-(1.+1.5*r3)*y2;
+ fac = 2.*r4;
+ } else {rx = 1.; ry = 1.; return;} }
+
+ if (y2 > 0.375 && y1 < 0.25) {
+ if (y2 > 1.-2.5*y1 && y2 < 1.-y1) {
+ y1 = r3*0.25;
+ y2 = 1.-(1.+1.5*r4)*y1;
+ fac = 2.*r3;
+ } else {rx = 1.; ry = 1.; return;}}}
+
+// Check if outside half-box */
+ if (2.-y1-y2 < 1.) {return;}
+
+
+
+ /*Inside jet 1? */
+ double w1 = 1.-y1;
+ double w2 = 1.-y2;
+ double tk = param[5];
+ double d1 = 0.25-(1.-w2)/tk;
+ double z,d2,xx;
+
+
+ if (d1 > 0.) {
+ z = 0.5+sqrt(d1);
+ d2 = pow(w2,2)-4.*param[0];
+ if (d2 > 0.) {
+ d2 = sqrt(d2);
+ double rr = 1.+param[0]/(1.-w2+param[0]);
+ xx = (rr*(2.-w2)+(2.*z-rr)*d2)/2.;
+ if (w1 < xx) {
+ z = 1.-z;
+ xx = (rr*(2.-w2)+(2.*z-rr)*d2)/2.;
+ if (w1 > xx) {return;}}}}
+
+ /*Inside jet 2? */
+
+ w1 = 1.-y2;
+ w2 = 1.-y1;
+ tk = param[6];
+ d1 = 0.25-(1.-w2)/tk;
+ if (d1 > 0.) {
+ z = 0.5+sqrt(d1);
+ d2 = pow(w2,2)-4.*param[0];
+ if (d2 > 0.) {
+ d2 = sqrt(d2);
+ double rr = 1.+param[0]/(1.-w2+param[0]);
+ xx = (rr*(2.-w2)+(2.*z-rr)*d2)/2.;
+ if (w1 < xx) {
+ z = 1.-z;
+ xx = (rr*(2.-w2)+(2.*z-rr)*d2)/2.;
+ if (w1 > xx) {return;}}}}
+ /* Outside Dalitz plot? */
+ if (y1*y2*(1.-y1-y2) < param[0]*pow((y1+y2),2)) { return;}
+
+ /* Calculate weights for dead region */
+ double zeta = -8.*param[0]*(1.+param[3]);
+ double zetax = param[3]*(pow((3.+y1+y2),2)-19.+4.*param[0]);
+ rx = 1.-y1;
+ ry = 1.-y2;
+
+ rwgt = ((pow((rx+param[3]),2)+pow((ry+param[3]),2)+zeta)/((1.+param[3])*y1*y2)-param[3]*(1./pow(y1,2)+1./pow(y2,2)))/param[4];
+ rwgt = rwgt*param[7]*fac;
+
+ rwgtax = ((pow((rx+param[3]),2)+pow((ry+param[3]),2)+zetax)/(pow(param[4],2)*y1*y2)-param[3]*(1./pow(y1,2)+1./pow(y2,2)))/param[4];
+ rwgtax = rwgtax*param[7]*fac;
+
+ rwgt1 = (2.+3.*param[7]*param[1])*fac-rwgt;
+ rwgtax1 = (2.+3.*param[7]*param[2])*fac-rwgtax;
+
+ /* Implement soft resolution cut */
+ if (resolve) {
+ if (rx+ry > 1.9999) {return;}}
+}
+ /*********************************************************************/
+ // In gap between phase space for massive partons and full half-triangle?
+
+void QQgsp(double r3,double r4, double &rx, double &ry, double param[8], double &rwgt, double &rwgtax, double &rwgt1, double &rwgtax1, bool resolve) {
+
+ //Initialize weights and phase space points
+ rwgt = 0.;rwgtax = 0.;rwgt1 = 0.;rwgtax1 = 0.;
+
+ /*Remove 2-jet events */
+ double y1 = 1.-rx;
+ double y2 = 1.-ry;
+ if ((1.-y1)==1. && (1.-y2)==1.) {return;}
+ /* Check if outside half-box */
+ if (2.-y1-y2 <= 1.) {return;}
+
+/* Inside Dalitz plot? */
+ if (y1*y2*(1.-y1-y2) > param[0]*pow((y1+y2),2)) {return;}
+ /* Calculate weights */
+ rwgt1 = 2.+3.*param[7]*param[1];
+ rwgtax1 = 2.+3.*param[7]*param[2];}
+ /*********************************************************************/
+// Random number generator.
+
+ double random (int &rseed) {
+ int M = 2147483647;
+ int A = 16807;
+ int Q = 127773;
+ int R = 2836;
+ double MINV = 0.46566128752458e-09;
+ int HI = rseed/Q;
+ int LO = rseed % Q;
+ rseed = A*LO - R*HI;
+ if (rseed < 0) {rseed = rseed + M;}
+ return rseed*MINV;}
+
+ /*********************************************************************/
+ /*********************************************************************/
+ /*********************************************************************/
diff --git a/Contrib/MCPWNLO/EPEM/MCEPEM_INPUTS.h b/Contrib/MCPWNLO/EPEM/MCEPEM_INPUTS.h
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/MCEPEM_INPUTS.h
@@ -0,0 +1,62 @@
+/* MC@NLO input file*/
+#include<iostream>
+#include <string>
+
+class Input
+
+{
+ public:
+
+ // Input();
+ // ~Input();
+
+/* Center of mass energy/GeV */
+
+ double cme() {return 91.2;}
+
+/* Pole mass of Z/GeV */
+
+ double Mz() {return 91.2;}
+
+ /* AlphaS (MZ) */
+
+ double alphasmz() {return 0.118;}
+
+
+ /* Number of parton flavours */
+
+ int nf() {return 5;}
+
+ /* Use massless matrix element? Options: true or false */
+
+bool massiveME() {return true;}
+
+ /*Boost masses to true quark masses? (if using massless ME)Options: true or false */
+
+bool bst() {return true;}
+
+/* Maximum number of iterations for Newton-Raphson boost. 4 is recommended for sqrt(s)=91.2GeV */
+
+ int it() {return 4;}
+
+/* Implement resolution cut? */
+
+bool resolve() {return true;}
+
+/* Number of events for integration */
+
+ int nevint() {return 100000;}
+
+/* Number of events to generate */
+
+ int nevgen() {return 100000;}
+
+
+/* Random number seed */
+
+ int rseed() {return 1;}
+
+};
+
+
+
diff --git a/Contrib/MCPWNLO/EPEM/Makefile b/Contrib/MCPWNLO/EPEM/Makefile
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/Makefile
@@ -0,0 +1,73 @@
+###############################################################################
+# DIRECTORIES
+
+#Where the /MCPWNLO/Herwig folder is
+HERWIGDIR = /usera/seyi/MCPWNLO/Herwig
+
+##############################################################################
+###############################################################################
+# LIBRARIES
+
+#Now the libraries -L(directory) -lname NOT preceeded by lib!!!!
+#i.e if your lib is called libNAME you need -lNAME
+
+##Path to CLHEP library should be $(CLHEPDIR)/lib/ and check lib name
+#CLHEPLIB = -L$(HOME)/ktjet/lib/ -lKtEvent -L$(CLHEPDIR)/lib/ -lCLHEP
+#CLHEPLIBNEW = -L$(CLHEPDIRNEW)/lib/ -lCLHEP
+##Path to LHAPDF library should be the same as the LHAPDF directory
+LHAPDFLIB = -L$(LHAPDFDIR)/lib -lLHAPDF
+LHAPDFINC = $(LHAPDFDIR)/include
+
+#MAC OS users....
+#If you had to get an external version of libg2c - i.e it doesn't come with you compiler......We stress, you've probably already got this.
+LIBG2C = /usr/local/lib/
+# You would then have to add -L$(LIBG2C) just in front of -lg2c on line 58
+
+################################################################################
+#No need to edit anything below this line!
+
+OPT = -funroll-loops -O2 -Wall
+
+
+FSOURCES = $(shell ls ./src/*.f)
+CXXSOURCES = $(shell ls ./src/*.cxx)
+FOBJS = $(FSOURCES:.f=.o)
+CXXOBJS = $(CXXSOURCES:.cxx=.o)
+CC = gcc
+FF = g77
+
+all: MCEPEM PWEPEM run_epem
+
+%.o: %.cxx
+ $(CC) -c $(OPT) \
+ $^ -o $@
+
+%.o: %.f
+ $(FF) -c $(OPT) $^ -o $@
+
+
+
+
+MCEPEM: MCEPEM.o
+ g++ $(OPT) -I./src/ $^\
+ -L$(LIBG2C) -lg2c -o $@
+
+PWEPEM: PWEPEM.o
+ g++ $(OPT) -I./src/ $^\
+ -L$(LIBG2C) -lg2c -o $@
+
+
+run_epem: run_epem.o
+ g++ $(OPT) -I./src/ $^\
+ -L$(LIBG2C) -lg2c -o $@
+ mv run_epem $(HERWIGDIR)
+clean:
+ rm *.o
+ rm MCEPEM
+ rm PWEPEM
+
+
+
+
+
+
diff --git a/Contrib/MCPWNLO/EPEM/PWEPEM.cxx b/Contrib/MCPWNLO/EPEM/PWEPEM.cxx
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/PWEPEM.cxx
@@ -0,0 +1,902 @@
+#include <cstdlib>
+#include <ctime>
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <fstream>
+#include <stdio.h>
+#include <cmath>
+#include <iomanip>
+// Set this to path of input file
+
+#include "PWEPEM_INPUTS.h"
+
+
+using namespace std;
+
+/******************************************************************************/
+// filegen generates interpolation files for numerical integration. These are tables of pt squared vs integral
+ void filegen(double &rintgend1, double &rintgend2, double &rintgend3, double &rintgend4);
+// Function used in filegen. This is the integral over x.
+ double function(double pt2, double x);
+// interp reads files generated by filegen to find solutions to Sudakov form factor. Uses polynomial of order 3.
+double interp(int N,double XXX, double Xmax1, double Xmax2, double Xmax3, double Xmax4);
+// xmaxmin determines the maximum and minimum value of x for given values of pt2 depending on which y branch it lies.
+void xmaxmin (double pt2, double &rxmax, double &rxmin5,double &rxmin6 );
+// ME calculates the value of the approximation to the NLO matrix element for given y and x.
+double ME (double pt2,double &rx, double &ry1, double &ry2, double xmin5, double &rM1, double &rM2, double &rw);
+// Random number generator
+double random (int &rseed);
+/******************************************************************************/
+ Input user;
+ double pt2max = 0.0901699441;
+ double pt2min = 0.0000048;
+ double pi = 3.14152654;
+ double b = 23./(12.*pi);
+ double bp = 58./(46.*pi);
+ double emcm = user.cme();
+ double CF = 4./3.;
+ double Lambda = user.Lambda();
+
+int main() {
+ // Switches
+ int nevg = user.nevgen();
+ int nit = user.it();
+ // double emcm = user.cme();
+ int seed = user.rseed();
+ int nf = user.nf();
+ double Mz = user.Mz();
+ double alphasmz = user.alphasmz();
+ bool truncate = user.trunc();
+ bool massiveME = user.massiveME();
+ bool boost = user.bst();
+ if (massiveME) {boost=false;}
+ int ii=0; //event count
+
+
+ // Integrals at end of pt2-integral tables
+
+ double end1,end2,end3,end4;
+
+ // Generate integration files
+
+ filegen(end1,end2,end3,end4);
+
+
+ int mm=0;
+
+ // File for output
+
+ ofstream outdata5;
+ outdata5.open("PWEPEM.dat", ios::trunc);
+ outdata5 << "<LesHouchesEvents version =\"1.0\">" << endl; outdata5 << "<!--" << endl;
+ outdata5 << "NORMFACTOR = " << "\t" << 1.0 << endl;
+ outdata5 << "File generated with PWEPEM.cxx" << endl; outdata5 << "-->" << endl;
+ outdata5 << "<init>" << endl;
+ outdata5 << "\t11\t" << "-11\t";
+ outdata5 << user.cme()/2. << "\t" << user.cme()/2. << "\t" << "0 \t 0 \t 7\t 7 \t 1 \t 1" << endl;
+ outdata5 << "\t" << 30590. << "\t" << 0.000000 << "\t1.00000 \t11" << endl; outdata5 << "</init>" << endl;
+ for (int ixx=1; ixx < nevg+1; ixx++) {
+ double x1, x2;
+ x1 = 0.; x2 = 0.;
+ //iterate = true if solution found and hence hardest emission.
+
+ bool iterate =false;
+ double intg=0.;
+
+ for (int ia=0; iterate==false; ia++){
+
+ //find solution to log(Delta) = log(random number)
+
+ double logn=fabs(log(random(seed)));
+ intg+=logn;
+ double pt2=interp(1000,intg,end1,end2,end3,end4);
+
+ if (0.*intg !=0) {break;}
+ if (intg > end4) {break;}
+ if (pt2 < pt2min) {break;}
+ double xmax, xmin5, xmin6;
+ xmaxmin(pt2, xmax, xmin5, xmin6);
+ double x , y1, y2, M, M1, M2, w;
+ // find maximum value of ME
+ double Mmax=0.;
+ for (int ix=0; ix < 10000 ; ix++) {
+ x=(xmax-xmin6)*random(seed)+xmin6;
+ M = ME(pt2,x,y1,y2,xmin5,M1,M2,w);
+ if (fabs(M) > fabs(Mmax)) {Mmax=M;}
+ }
+
+ // distribute according to matrix element*delta function
+
+ do {
+ x=(xmax-xmin6)*random(seed)+xmin6;
+ M = ME(pt2,x,y1,y2,xmin5,M1,M2,w);} while (random(seed) > fabs(M/Mmax));
+
+ //parent parton identifier
+
+ int Jt;
+ Jt = 0;
+ // Select parent parton and matrix element upper bound veto
+
+ if (x > xmin5 && pt2 < 1./12.){
+ if (random(seed) < (fabs(M1)/fabs(M))) {
+ if (random(seed) < (pow(x,2)+pow(y1,2))/2.) {
+ //Kleiss trick
+ if (random(seed) < pow(x,2)/(pow(x,2)+pow(y1,2))) {
+ x1=x;
+ x2=y1;
+ Jt=1;}
+ else{
+ x2=x;
+ x1=y1;
+ Jt=2;}
+
+
+ mm=mm+1;
+
+ iterate=true;
+
+ }}
+ else{
+ if (random(seed) < (pow(x,2)+pow(y2,2))/2.) {
+ //Kleiss trick
+ if (random(seed) < pow(x,2)/(pow(x,2)+pow(y2,2))) {
+ x1=x;
+ x2=y2;
+ Jt=1;}
+ else{
+ x2=x;
+ x1=y2;
+ Jt=2;}
+
+ mm=mm+1;
+
+ iterate=true;}}}
+ else {
+ if (random(seed) < (pow(x,2)+pow(y2,2))/2.) {
+ //Kleiss trick
+ if (random(seed) < pow(x,2)/(pow(x,2)+pow(y2,2))) {
+ x1=x;
+ x2=y2;
+ Jt=1;}
+ else{
+ x2=x;
+ x1=y2;
+ Jt=2;}
+
+ mm=mm+1;
+
+ iterate=true; }}
+
+// Constants
+ double GF = 0.0000116639;
+ double Yz = 2.486;
+ double alphaem = 0.007297352;
+
+ //Lepton charge & coupling constants
+ double Che = -1;
+ double sin2thw = 0.2312;
+ double Ae = -0.5;
+ double Ve = Ae-2.*Che*sin2thw;
+ double AV2 = pow(Ae,2)+pow(Ve,2);
+ double CLe = (Ae+Ve)/2.;
+ double CRe = (Ve-Ae)/2.;
+ double gz2 = sqrt(32.)*GF*pow(Mz,2);
+ double e2 = 4.*pi*alphaem;
+ double k = sqrt(2.)*GF*pow(Mz,2)/e2;
+ double chi1 = k*pow(emcm,2)*(pow(emcm,2)-pow(Mz,2))/(pow((pow(emcm,2)-pow(Mz,2)),2)+pow(Yz*Mz,2));
+ double chi2 = pow(k,2)*pow(emcm,4)/(pow((pow(emcm,2)-pow(Mz,2)),2)+pow(Yz*Mz,2));
+
+ //quark masses ,velocities and couplings. NB:gluon mass[6] =0.75
+ double mq[7],beta[6],Ch[6],Aq[6],Vq[6],cs[6],sigV[6],sigA[6],sigVA[6],css;
+
+ mq[1] = 0.325; mq[2] = 0.325; mq[3] = 0.5; mq[4] = 1.6; mq[5] = 5.; mq[6] = 0.75;
+
+
+ Ch[1]=-1./3.; Ch[2]=2./3.; Ch[3]=Ch[1]; Ch[4]=Ch[2]; Ch[5]=Ch[1];
+ Aq[1]=-0.5; Aq[2]=0.5; Aq[3]=Aq[1]; Aq[4]=Aq[2]; Aq[5]=Aq[1];
+ //Calculate Born cross-section
+ //initialize cross-sections...
+ cs[1]=0.; cs[2]=0.; cs[3]=0.; cs[4]=0.; cs[5]=0.; css=0.;
+ for (int ix=0; ix < nf+1; ix++) {
+ Vq[ix] = Aq[ix]-(2.*Ch[ix]*sin2thw);
+ beta[ix] = sqrt(1.-4.*pow(mq[ix]/emcm,2));
+ sigV[ix] = pow(Ch[ix],2)-2.*Ch[ix]*Ve*Vq[ix]*chi1+AV2*pow(Vq[ix],2)*chi2;
+ sigA[ix] = AV2*pow(Aq[ix],2)*chi2;
+ sigVA[ix]= -2.*Ch[ix]*Ae*Aq[ix]*chi1+4.*Ae*Ve*Aq[ix]*Vq[ix]*chi2;
+ cs[ix] = beta[ix]+0.5*pow(beta[ix],2)+0.5*(1.-pow(beta[ix],2))*beta[ix]*sigV[ix]+pow(beta[ix],3)*sigA[ix];
+ css+=cs[ix];
+}
+ //select flavour of process
+ double m, mg, mass[8];
+ int ID;
+ if (random(seed) < cs[1]/css) {ID = 1; } else {
+ if (random(seed) < cs[2]/(css-cs[1])) {ID = 2;} else {
+ if (random(seed) < cs[3]/(css-cs[1]-cs[2])) {ID = 3; } else {
+ if (random(seed) < cs[4]/(cs[4]+cs[5])) {ID = 4; } else {
+ ID = 5; m = mq[5];}}}}
+ if (massiveME) {m = mq[ID];} else {m = 0.;}
+ mass[1]=0.;
+ mass[2]=0.;
+ mass[3]=emcm;
+ // Parameters for NLO cross-section calculation.
+ double param[8];
+ param[0] = pow(m,2)/pow(emcm,2);
+ param[1] = 1.+12.*param[0]; // R = 1+param[1]*alphasmz/pi for vector current
+ param[2] = 1.-22.*param[0]; // R = 1+param[2]*alphasmz/pi for axial vector current
+ param[3] = 2.*param[0];
+ param[4] = sqrt(1.-4.*param[0]); // beta
+ param[5] = 0.5*(1.+param[4]);
+ param[6] = (param[0]*param[5]+0.25*param[4]*pow(1+param[4],2))/(param[5]-param[0]);
+ param[7] = 2.*alphasmz/(3.*pi); // colour factor
+
+ // cross-section parameters
+ double sigU = param[4]*sigV[ID]+pow(param[4],3)*sigA[ID];
+ double sigL = 0.5*(1.-pow(param[4],2))*param[4]*sigV[ID];
+ double sigF = pow(param[4],2)*sigVA[ID];
+ double CLf = (Aq[ID]+Vq[ID])/2.;
+ double CRf = (Vq[ID]-Aq[ID])/2.;
+ //*********************************************************************************
+double x3 = 2.-x1-x2;
+ double c13=(x1*x3-2.*(1.-x2))/(sqrt(pow(x1,2)-4.*param[0])*x3);
+ double c23=(x2*x3-2.*(1.-x1))/(sqrt(pow(x2,2)-4.*param[0])*x3);
+ if (isinf(c13) || isinf(c23))
+ {x3 = x3 + 0.0000001;
+ x1 = x1 - 0.0000001/2.;
+ x2 = x2 - 0.0000001/2.;
+ c13=(x1*x3-2.*(1.-x2))/(sqrt(pow(x1,2)-4.*param[0])*x3);
+ c23=(x2*x3-2.*(1.-x1))/(sqrt(pow(x2,2)-4.*param[0])*x3);}
+ double cth,pcm;
+ double cofac, maxcofac,cf,ct, ppt;
+ double px1 = sqrt(pow(0.5*emcm*x1,2)-pow(m,2));
+ double px2 = sqrt(pow(0.5*emcm*x2,2)-pow(m,2));
+ double px3 = sqrt(pow(0.5*emcm*x3,2));
+ do {cth = 2.*random(seed)-1.;
+ cofac = (1.+pow(cth,2))*sigU+2.*sigL*(1.-pow(cth,2))+2.*cth*sigF;
+ maxcofac = 2.*(sigU+sigF);
+ if (Jt==1) {
+ cf = (px2*c23+px3)/px1; ct = (px1-px3*cf)/px2;}else
+ {cf = (px1*c13+px3)/px2; ct = (px2-px3*cf)/px1;}
+ if (ct > 1. || cf > 1. || isinf(cf) || isinf(ct) || 0.*cf !=0 || 0.*ct !=0) {iterate = false;}
+ } while (random(seed) > cofac/maxcofac);
+ /**************************************************************************/
+ if(iterate) {
+
+ double z1, ptr2, ptsq ,z, q;
+ ptr2 =0.;
+ bool emit = false;
+ ptsq=pow(emcm,2)*pt2;
+
+ // Truncated Shower
+
+ if (truncate) {
+ double Qg=0.75;
+ double u=0.75;
+ double qc=2.8;
+ double alpham=1.;
+ double x3=2.-x1-x2;
+ // ptsq=pow(emcm,2)*pt2;
+
+ if (Jt==1) {
+ z=0.5*(x2+sqrt(pow(x2,2)-4.*pt2));
+
+ }else {
+ z=0.5*(x1+sqrt(pow(x1,2)-4.*pt2));
+
+ }
+ double qi=emcm;
+
+ double Pzmax=(1.+pow((1.-Qg/emcm),2))/(Qg/emcm);
+ double Pz;
+ do{
+ z1=random(seed)*(1.-Qg/emcm-u/emcm)+u/emcm;
+ Pz=(1.+pow(z1,2))/(1.-z1);} while (random(seed) > Pz/Pzmax);
+ if (ptsq/pow(z*(1.-z),2)+pow(u/z,2)+pow(Qg/(1.-z),2)/z < 0.) {emit=false;}
+ double qh=sqrt(ptsq/pow(z*(1.-z),2)+pow(u/z,2)+pow(Qg/(1.-z),2)/z);
+ double C=CF*alpham*log(Qg/(qi-u))/pi;
+ double D=exp(2.*log(qh/qc)*C);
+ double E=exp(2.*log(qi/qc)*C);
+ if (random(seed) < 1.-E/D) {
+ do {
+ q=sqrt(exp(log(E/random(seed))/C)*pow(qc,2));} while (q < qh);
+ ptr2 = pow((1.-z1)*z1*q,2)-pow((1-z1)*u,2)-z1*pow(Qg,2);
+ emit = true;
+ //energy fractions
+ double ze=z+pt2/z;
+ double z1e=z1+ptr2/(pow(emcm,2)*z1);
+ // vetoes: pt, and alphas
+
+ if (Jt==1) {if ((1.-z1e)*(x2+x3)*emcm/2.< sqrt(ptr2)){emit=false;}
+ if (ze*z1e*(x2+x3)*emcm/2.< sqrt(ptsq)) {emit=false;}}
+
+ if (Jt==2) {if ((1.-z1e)*(x1+x3)*emcm/2.< sqrt(ptr2)){emit=false;}
+ if (ze*z1e*(x1+x3)*emcm/2.< sqrt(ptsq)) {emit=false;}}
+ double alphas=1./(b*log(ptr2/pow(Lambda,2)))*(1.-bp*log(log(ptr2/pow(Lambda,2)))/(b*log(ptr2/pow(Lambda,2))));
+ alphas=alphas+pow(alphas,2)*(67./3.-pow(pi,2)-50./9.)/(4.*pi);
+
+ if (ptr2 < 0 || q > qi || ptr2 > ptsq || random(seed) > alphas/alpham || random(seed) > Pz*(1.-z1)/2. || x3 > x1 || x3 > x2) {emit=false;}
+ //change to energy fraction z1e
+ z1=z1e;
+ }
+ }
+
+
+ // Assign event properties for LH reader
+
+ /***********************************************************************/
+ /*Les Houches Accord event parameters:: PUP are the momenta,
+ ICOLUP is the colour code, MOTHUP is the mother information, ISTUP is
+ the status code. ISPINUP signifies spins. IDUP is the particle ID.
+ NUP is the number of particles in the event. SCALUP is the scale of
+ the event.AQEDUP and AQCDUP are alphaem and alphasmz resp.XWGTUP is
+ the weight of the event=1 or -1 for unweighted events.*/
+
+ double PUP[6][9],AQEDUP,AQCDUP,XWGTUP,SCALUP;
+ int ICOLUP[3][8],MOTHUP[3][8],ISTUP[8],ISPINUP[8],IDUP[8],NUP;
+ SCALUP = sqrt(ptsq);
+ AQEDUP=0.007297352;
+ AQCDUP=alphasmz;
+ IDUP[1]=11;
+ IDUP[2]=-11;
+ IDUP[3]=23;
+ IDUP[4]=ID;
+ IDUP[5]=-ID;
+ IDUP[6]=21;
+ MOTHUP[1][1]=0;
+ MOTHUP[1][2]=0;
+ MOTHUP[2][1]=0;
+ MOTHUP[2][2]=0;
+ MOTHUP[1][3]=1;
+ MOTHUP[2][3]=2;
+ MOTHUP[1][4]=3;
+ MOTHUP[2][4]=3;
+ MOTHUP[1][5]=3;
+ MOTHUP[2][5]=3;
+ MOTHUP[1][6]=3;
+ MOTHUP[2][6]=3;
+ ICOLUP[1][1]=0;
+ ICOLUP[2][1]=0;
+ ICOLUP[1][2]=0;
+ ICOLUP[2][2]=0;
+ ICOLUP[1][3]=0;
+ ICOLUP[2][3]=0;
+ ISTUP[1]=-1;
+ ISTUP[2]=-1;
+ ISTUP[3]=2;
+ ISTUP[4]=1;
+ ISTUP[5]=1;
+ ISTUP[6]=1;
+
+ double phi = 2.*pi*random(seed);
+ double phi2 = 2.*pi*random(seed);
+
+ if (Jt==1) {
+ double x=x2+x3;
+ pcm = px1;
+ PUP[3][4]=px1*cth;
+ double pt = sqrt(pow(px1,2)-pow(PUP[3][4],2));
+ PUP[1][4]=pt*cos(phi);
+ PUP[2][4]=pt*sin(phi);
+ double ppl,ppl2,ppe1,ppe2;
+ ppl2 = 0.; ppe1 = 0.; ppe2 = 0.;
+ if (!emit){
+ ppl = px2*ct;
+ if (random(seed) < 0.5) {
+ ppt = sqrt (pow(px2,2)-pow(ppl,2));}else {ppt = -sqrt (pow(px2,2)-pow(ppl,2));}
+} else {
+ ppe1=z1*x*emcm/2.;
+ ppe2=(1.-z1)*x*emcm/2.;
+ ppl2=sqrt(pow(ppe2,2)-ptr2);
+ ppl=sqrt(pow(ppe1,2)-ptr2);
+ if (ppe1 < sqrt(ptr2)) {
+ ppl=0.; ppe1=sqrt(ptr2); ppe2=x*emcm/2.-ppe1; ppl2=sqrt(pow(ppe2,2)-ptr2);}
+ if (ppe2 < sqrt(ptr2)) {
+ ppl2=0.; ppe2=sqrt(ptr2); ppe1=x*emcm/2.-ppe2; ppl=sqrt(pow(ppe1,2)-ptr2);}
+ if (random(seed) < 0.5) {
+ ppt = sqrt(ptr2);}else {ppt = -sqrt(ptr2) ;}
+}
+
+ double ppt1 = ppt*cos(phi2);
+ double ppt2 = ppt*sin(phi2);
+ PUP[3][5]=-(ppl*cth-ppt1*sin(acos(cth)));
+ PUP[1][5]=-((ppl*sin(acos(cth))+ppt1*cth)*cos(phi)-ppt2*sin(phi));
+ PUP[2][5]=-((ppl*sin(acos(cth))+ppt1*cth)*sin(phi)+ppt2*cos(phi));
+ if (emit){
+ PUP[4][4] = x1*emcm/2.;
+ PUP[4][5]=ppe1;
+ PUP[4][6]=ppe2;
+ PUP[3][6]=-(ppl2*cth+ppt1*sin(acos(cth)));
+ PUP[1][6]=-((ppl2*sin(acos(cth))-ppt1*cth)*cos(phi)+ppt2*sin(phi));
+ PUP[2][6]=-((ppl2*sin(acos(cth))-ppt1*cth)*sin(phi)-ppt2*cos(phi));
+ ICOLUP[1][4]=501;
+ ICOLUP[2][4]=0;
+ ICOLUP[1][5]=0;
+ ICOLUP[2][5]=503;
+ }
+ }
+
+ else {
+ double x=x1+x3;
+ pcm = px2;
+ PUP[3][5]=px2*cth;
+ double pt = sqrt(pow(px2,2)-pow(PUP[3][5],2));
+ PUP[1][5]=pt*cos(phi);
+ PUP[2][5]=pt*sin(phi);
+ double ppl, ppl2, ppe1,ppe2;
+ ppl2 = 0.; ppe1 = 0.; ppe2 = 0.;
+ if (!emit){
+ ppl = px1*ct;
+ if (random(seed) < 0.5) {
+ ppt = sqrt (pow(px1,2)-pow(ppl,2));}else {ppt = -sqrt (pow(px1,2)-pow(ppl,2));}} else {
+ ppe1=z1*x*emcm/2.;
+ ppe2=(1.-z1)*x*emcm/2.;
+ ppl2=sqrt(pow(ppe2,2)-ptr2);
+ ppl=sqrt(pow(ppe1,2)-ptr2);
+ if (ppe1 < sqrt(ptr2)) {
+ ppl=0.; ppe1=sqrt(ptr2); ppe2=x*emcm/2.-ppe1; ppl2=sqrt(pow(ppe2,2)-ptr2);}
+ if (ppe2 < sqrt(ptr2)) {
+ ppl2=0.; ppe2=sqrt(ptr2); ppe1=x*emcm/2.-ppe2; ppl=sqrt(pow(ppe1,2)-ptr2);}
+ if (random(seed) < 0.5) {
+ ppt = sqrt(ptr2);}else {ppt = -sqrt(ptr2) ;}
+ }
+ double ppt1 = ppt*cos(phi2);
+ double ppt2 = ppt*sin(phi2);
+ PUP[3][4]=-(ppl*cth-ppt1*sin(acos(cth)));
+ PUP[1][4]=-((ppl*sin(acos(cth))+ppt1*cth)*cos(phi)-ppt2*sin(phi));
+ PUP[2][4]=-((ppl*sin(acos(cth))+ppt1*cth)*sin(phi)+ppt2*cos(phi));
+ if (emit){
+ PUP[4][4]=ppe1;
+ PUP[4][5] = x2*emcm/2.;
+ PUP[4][6]=ppe2;
+ PUP[3][6]=-(ppl2*cth+ppt1*sin(acos(cth)));
+ PUP[1][6]=-((ppl2*sin(acos(cth))-ppt1*cth)*cos(phi)+ppt2*sin(phi));
+ PUP[2][6]=-((ppl2*sin(acos(cth))-ppt1*cth)*sin(phi)-ppt2*cos(phi));
+ ICOLUP[1][4]=501;
+ ICOLUP[2][4]=0;
+ ICOLUP[1][5]=0;
+ ICOLUP[2][5]=503;
+ }
+ }
+ if (!emit){
+ double ppl2 = px3*cf;
+ double ppt3 = -ppt/fabs(ppt)*sqrt(pow(px3,2)-pow(ppl2,2));
+ double ppt4 = ppt3*cos(phi2);
+ double ppt5 = ppt3*sin(phi2);
+ PUP[3][6]=-(ppl2*cth-ppt4*sin(acos(cth)));
+ PUP[1][6]=-((ppl2*sin(acos(cth))+ppt4*cth)*cos(phi)-ppt5*sin(phi));
+ PUP[2][6]=-((ppl2*sin(acos(cth))+ppt4*cth)*sin(phi)+ppt5*cos(phi));
+ PUP[4][4] = x1*emcm/2.;
+ PUP[4][5] = x2*emcm/2.;
+ PUP[4][6] = x3*emcm/2.;
+
+ //colour info
+ ICOLUP[1][4] = 501;
+ ICOLUP[2][4] = 0;
+ ICOLUP[1][5] = 0;
+ ICOLUP[2][5] = 502;
+ ICOLUP[1][6] = 502;
+ ICOLUP[2][6] = 501;
+ //Number of particles
+ NUP=6;
+ double alpha = 1.;
+ //boost masses if needed. Need to boost to nominal gluon mass always.
+ double mb;
+ if (massiveME || (!massiveME && boost)) {mb = mq[ID]; mg = mq[6]; }
+ if (!massiveME && !boost) {mb = 0.; mg = 0.;}
+ double Eq,Eqb,Eg;
+ double pq = sqrt(pow(PUP[1][4],2)+pow(PUP[2][4],2)+pow(PUP[3][4],2));
+ double pqb = sqrt(pow(PUP[1][5],2)+pow(PUP[2][5],2)+pow(PUP[3][5],2));
+ double pg = sqrt(pow(PUP[1][6],2)+pow(PUP[2][6],2)+pow(PUP[3][6],2));
+ for (int ix=1; ix < nit+1; ix++) {
+ Eq = sqrt(pow(mb,2)+alpha*pow(pq,2));
+ Eqb = sqrt(pow(mb,2)+alpha*pow(pqb,2));
+ Eg = sqrt(pow(mg,2)+alpha*pow(pg,2));
+ alpha = alpha+(2.*(emcm-Eq-Eqb-Eg))/(pow(pq,2)/Eq+pow(pqb,2)/Eqb+pow(pg,2)/Eg);
+ }
+ if (0.*Eq != 0) {cout << " " << cf << "\t" << ct << "\t" << pq << "\t" << pqb << "\t" << pg << "\t" <<alpha << endl;}
+ PUP[1][4] =sqrt(alpha)*PUP[1][4];
+ PUP[2][4] =sqrt(alpha)*PUP[2][4];
+ PUP[3][4] =sqrt(alpha)*PUP[3][4];
+ PUP[4][4] =Eq;
+ PUP[1][5] =sqrt(alpha)*PUP[1][5];
+ PUP[2][5] =sqrt(alpha)*PUP[2][5];
+ PUP[3][5] =sqrt(alpha)*PUP[3][5];
+ PUP[4][5] =Eqb;
+ PUP[1][6] =sqrt(alpha)*PUP[1][6];
+ PUP[2][6] =sqrt(alpha)*PUP[2][6];
+ PUP[3][6] =sqrt(alpha)*PUP[3][6];
+ PUP[4][6] =Eg;
+ if (massiveME || (!massiveME && boost)) {
+ mass[4] = mq[ID];
+ mass[5] = mq[ID];
+ mass[6] = mq[6];}
+ if (!massiveME && !boost)
+ {mass[4] = 0.;
+ mass[5] = 0.;
+ mass[6] = 0.;}
+ } else {
+
+ //truncated emission
+
+ double phi3=2.*pi*random(seed);
+ double phi4=2.*pi*random(seed);
+ double ph=2.*pi*random(seed);
+ double phh=2.*pi*random(seed);
+ if (Jt==2) {PUP[4][4]=PUP[4][5];}
+ double ptgg;
+ if (random(seed) < 0.5) {ptgg=sqrt(ptr2);}else{ptgg=-sqrt(ptr2);}
+ double btgg=ptr2/(4.*(1.-z1)*pow(emcm-PUP[4][4],2));
+ double pegg=(1.-z1)*(emcm-PUP[4][4])+btgg*(emcm-PUP[4][4]);
+ double pzgg=(1.-z1)*(emcm-PUP[4][4])-btgg*(emcm-PUP[4][4]);
+ double sth=sqrt(ptr2)/(z1*(emcm-PUP[4][4]));
+ double ptq, ptg;
+ if (random(seed) < 0.5) {
+ ptq=sqrt(ptsq)*cos(asin(sth))+z*z1*(emcm-PUP[4][4])*sth;
+ ptg=-sqrt(ptsq)*cos(asin(sth))+(1-z)*z1*(emcm-PUP[4][4])*sth;
+ } else {
+ ptq=-sqrt(ptsq)*cos(asin(sth))+z*z1*(emcm-PUP[4][4])*sth;
+ ptg=sqrt(ptsq)*cos(asin(sth))+(1.-z)*z1*(emcm-PUP[4][4])*sth;}
+
+ double btq=pow(ptq,2)/(4.*z1*z*pow(emcm-PUP[4][4],2));
+ double btg=pow(ptg,2)/(4.*(1.-z)*z1*pow(emcm-PUP[4][4],2));
+ double pe=z*z1*(emcm-PUP[4][4])+btq*(emcm-PUP[4][4]);
+ double pzq=z*z1*(emcm-PUP[4][4])-btq*(emcm-PUP[4][4]);
+ double peg=z1*(1.-z)*(emcm-PUP[4][4])+btg*(emcm-PUP[4][4]);
+ double pzg=z1*(1.-z)*(emcm-PUP[4][4])-btg*(emcm-PUP[4][4]);
+ PUP[4][6]=pegg;
+ double p6t1=ptgg*cos(ph);
+ double p6t2=ptgg*sin(ph);
+ PUP[1][6]=-((pzgg*sin(acos(cth))+p6t1*cth)*cos(phh)-p6t2*sin(phh));
+ PUP[2][6]=-((pzgg*sin(acos(cth))+p6t1*cth)*sin(phh)+p6t2*cos(phh));
+ PUP[3][6]=-(pzgg*cth-p6t1*sin(acos(cth)));
+ PUP[4][5]=pe;
+ double p5t1=ptq*cos(phi4);
+ double p5t2=ptq*sin(phi4);
+ PUP[1][5]=-((pzq*sin(acos(cth))+p5t1*cth)*cos(phi3)-p5t2*sin(phi3));
+ PUP[2][5]=-((pzq*sin(acos(cth))+p5t1*cth)*sin(phi3)+p5t2*cos(phi3));
+ PUP[3][5]=-(pzq*cth-p5t1*sin(acos(cth)));
+ PUP[4][7]=peg;
+ double p7t1=ptg*cos(phi4);
+ double p7t2=ptg*sin(phi4);
+ PUP[1][7]=-((pzg*sin(acos(cth))+p7t1*cth)*cos(phi3)-p7t2*sin(phi3));
+ PUP[2][7]=-((pzg*sin(acos(cth))+p7t1*cth)*sin(phi3)+p7t2*cos(phi3));
+ PUP[3][7]=-(pzg*cth-p7t1*sin(acos(cth)));
+ PUP[1][4]=-PUP[1][7]-PUP[1][6]-PUP[1][5];
+ PUP[2][4]=-PUP[2][7]-PUP[2][6]-PUP[2][5];
+ PUP[3][4]=-PUP[3][7]-PUP[3][6]-PUP[3][5];
+ if (Jt==2) {
+ PUP[1][8]= PUP[1][4]; PUP[2][8]= PUP[2][4]; PUP[3][8]= PUP[3][4];
+ PUP[1][4]= PUP[1][5]; PUP[2][4]= PUP[2][5]; PUP[3][4]= PUP[3][5];
+ PUP[1][5]= PUP[1][8]; PUP[2][5]= PUP[2][8]; PUP[3][5]= PUP[3][8];}
+ double pq = sqrt(pow(PUP[1][4],2)+pow(PUP[2][4],2)+pow(PUP[3][4],2));
+ double pqb = sqrt(pow(PUP[1][5],2)+pow(PUP[2][5],2)+pow(PUP[3][5],2));
+ double pg = sqrt(pow(PUP[1][6],2)+pow(PUP[2][6],2)+pow(PUP[3][6],2));
+ double pgg = sqrt(pow(PUP[1][7],2)+pow(PUP[2][7],2)+pow(PUP[3][7],2));
+ double mb;
+ if (massiveME || (!massiveME && boost)) {mb = mq[ID]; mg = mq[6]; }
+ if (!massiveME && !boost) {mb = 0.; mg = 0.;}
+ double Eq,Eqb,Eg,Egg;
+ double alpha=1;
+ double nit=5;
+ for (int ixx=1; ixx < nit+1; ixx++) {
+ Eq = sqrt(pow(mb,2)+alpha*pow(pq,2));
+ Eqb = sqrt(pow(mb,2)+alpha*pow(pqb,2));
+ Eg = sqrt(pow(mg,2)+alpha*pow(pg,2));
+ Egg= sqrt(pow(mg,2)+alpha*pow(pgg,2));
+ alpha = alpha+(2.*(emcm-Eq-Eqb-Eg-Egg))/(pow(pq,2)/Eq+pow(pqb,2)/Eqb+pow(pg,2)/Eg+pow(pgg,2)/Egg);
+ }
+ PUP[1][4] =sqrt(alpha)*PUP[1][4];
+ PUP[2][4] =sqrt(alpha)*PUP[2][4];
+ PUP[3][4] =sqrt(alpha)*PUP[3][4];
+ PUP[4][4] =Eq;
+ PUP[1][5] =sqrt(alpha)*PUP[1][5];
+ PUP[2][5] =sqrt(alpha)*PUP[2][5];
+ PUP[3][5] =sqrt(alpha)*PUP[3][5];
+ PUP[4][5] =Eqb;
+ PUP[1][6] =sqrt(alpha)*PUP[1][6];
+ PUP[2][6] =sqrt(alpha)*PUP[2][6];
+ PUP[3][6] =sqrt(alpha)*PUP[3][6];
+ PUP[4][6] =Eg;
+ PUP[1][7] =sqrt(alpha)*PUP[1][7];
+ PUP[2][7] =sqrt(alpha)*PUP[2][7];
+ PUP[3][7] =sqrt(alpha)*PUP[3][7];
+ PUP[4][7] =Egg;
+
+ if (massiveME || (!massiveME && boost)) {
+ mass[4] = mq[ID];
+ mass[5] = mq[ID];
+ mass[6] = mq[6];
+ mass[7] = mq[6]; }
+ if (!massiveME && !boost)
+ {mass[4] = 0.;
+ mass[5] = 0.;
+ mass[6] = 0.;
+ mass[7] = 0.; }
+ IDUP[7]=21;
+ ISTUP[7]=1;
+ MOTHUP[1][7]=3;
+ MOTHUP[2][7]=3;
+ if (x1 > x2 && acos((PUP[3][6]*PUP[3][4]+PUP[2][6]*PUP[2][4]+PUP[1][6]*PUP[1][4])/(PUP[4][6]*PUP[4][4])) > 1.57 || x2 > x1 && acos((PUP[3][6]*PUP[3][5]+PUP[2][6]*PUP[2][5]+PUP[1][6]*PUP[1][5])/(PUP[4][6]*PUP[4][5])) < 1.57) {
+ ICOLUP[1][6]=502;
+ ICOLUP[2][6]=501;
+ ICOLUP[1][7]=503;
+ ICOLUP[2][7]=502;
+ }else{
+ ICOLUP[1][7]=502;
+ ICOLUP[2][7]=501;
+ ICOLUP[1][6]=503;
+ ICOLUP[2][6]=502;
+ }
+ NUP=7;
+ }
+ // spin info-redundant
+
+ double C[9], M[9];
+ C[1] = pow(CRe,2)*(chi2/(pow((emcm*k),2)))*pow(gz2,2);
+ C[2] = pow(CLe,2)*(chi2/(pow((emcm*k),2)))*pow(gz2,2);
+ C[3] = CLf*(emcm/2.-pcm)+CRf*(emcm/2.+pcm);
+ C[4] = CLf*(emcm/2.+pcm)+CLf*(emcm/2.-pcm);
+ C[5] = (CLf+CRf)*m;
+ C[6] = 2*e2*Ch[ID]*CRe*chi1*gz2/(k*emcm);
+ C[7] = 2*e2*Ch[ID]*CLe*chi1*gz2/(k*emcm);
+ C[8] = e2*Ch[ID];
+ M[1] = (C[1]*pow(C[3],2)-C[6]*C[3]+pow(C[8],2))*pow(1+cth,2);
+ M[5] = (C[2]*pow(C[4],2)-C[7]*C[4]+pow(C[8],2))*pow(1+cth,2);
+ M[2] = (C[1]*pow(C[4],2)-C[6]*C[4]+pow(C[8],2))*pow(1+cth,2);
+ M[6] = (C[2]*pow(C[3],2)-C[7]*C[3]+pow(C[8],2))*pow(1+cth,2);
+ M[3] = (C[1]*pow(C[5],2)-2.*m/emcm*C[6]*C[5]+pow(C[8],2)*4.*param[0])*(1.-pow(cth,2));
+ M[7] = (C[2]*pow(C[5],2)-2.*m/emcm*C[7]*C[5]+pow(C[8],2)*4.*param[0])*(1.-pow(cth,2));
+ M[4] = M[3];
+ M[8] = M[7];
+ double Mud, Mdu;
+ Mud = 0.; Mdu =0.;
+ for (int ix=1; ix < 5; ix++) {Mud+=M[ix];}
+ for (int ix=5; ix < 9; ix++) {Mud+=M[ix];}
+ if (random(seed) < Mud/(Mud+Mdu)) {
+ ISPINUP[1]=+1;
+ ISPINUP[2]=-1;
+ ISPINUP[3]=+1;
+ if (random(seed) < (M[1]+M[3])/Mud) {
+ ISPINUP[4] = +1;
+ if (random(seed) < M[1]/(M[1]+M[3])) {
+ ISPINUP[5] = -1;}else {ISPINUP[5] = +1;}} else {
+ ISPINUP[4] = -1;
+ if (random(seed) < M[2]/(M[2]+M[4])) {
+ ISPINUP[5] = +1;} else {ISPINUP[5] = -1;} }} else {
+ ISPINUP[1]=-1;
+ ISPINUP[2]=+1;
+ ISPINUP[3]=-1;
+ if (random(seed) < (M[6]+M[7])/Mdu) {
+ ISPINUP[4] = +1;
+ if (random(seed) < M[6]/(M[6]+M[7])) {
+ ISPINUP[5] = -1;}else {ISPINUP[5] = +1;}} else {
+ ISPINUP[4] = -1;
+ if (random(seed) < M[5]/(M[5]+M[8])) {
+ ISPINUP[5] = +1;} else {ISPINUP[5] = -1;} }}
+ if (Jt==1) {ISPINUP[6] = ISPINUP[4];} else {ISPINUP[6] = ISPINUP[5];}
+ ISPINUP[7]=ISPINUP[6];
+ //Momenta of incoming particles and Z boson
+
+ PUP[4][1]=emcm/2.;
+ PUP[1][1]=0.;
+ PUP[2][1]=0.;
+ PUP[3][1]=emcm/2;
+ PUP[4][2]=emcm/2;
+ PUP[1][2]=0.;
+ PUP[2][2]=0.;
+ PUP[3][2]=-emcm/2;
+ PUP[4][3]=emcm;
+ PUP[1][3]=0.;
+ PUP[2][3]=0.;
+ PUP[3][3]=0.;
+
+ //weight info
+ XWGTUP = 1;
+ double sum1, sum2, sum3, sum4;
+ sum1=0.;sum2=0.;sum3=0.;sum4=0.;
+ ii+=1;
+ outdata5 << "<event>" << endl;
+ outdata5 << NUP <<"\t" << "11" <<"\t"<<XWGTUP<<"\t" << SCALUP << "\t" << AQEDUP << "\t" << AQCDUP << endl;
+ for (int ja = 1; ja < NUP+1; ja++) {
+ outdata5 << IDUP[ja] << "\t" << ISTUP[ja] << "\t" << MOTHUP[1][ja] <<"\t" << MOTHUP[2][ja] << "\t" << ICOLUP[1][ja] << "\t" << ICOLUP[2][ja] <<"\t" <<setprecision (9)<< PUP[1][ja] << "\t" << PUP[2][ja]<<"\t"<<PUP[3][ja]<<"\t"<<PUP[4][ja]<<"\t" << mass[ja] <<"\t"<< "0" << "\t" <<"9" <<endl;
+ sum1+=PUP[4][ja];sum2+=PUP[1][ja];sum3+=PUP[2][ja];sum4+=PUP[3][ja];
+}
+ cout << "Generated event : " << "\t" << ixx << "\t" << "of" << "\t" << nevg << "\r" << flush;
+ outdata5 << "</event>" << endl;
+
+ // cout << sum1 << "\t" << sum2 << "\t" << sum3 << "\t" << sum4 << endl;
+
+ }
+ }
+
+ }
+ outdata5 << "</LesHouchesEvents>" << endl;
+ cout << endl;
+ return 0; }
+
+
+/********************************************************************************/
+/********************************************************************************/
+// filegen generates interpolation files for numerical integration. These are tables of pt squared vs integral
+
+void filegen (double &rintgend1, double &rintgend2, double &rintgend3, double &rintgend4){
+ cout << "Generating interpolation files..." << endl;
+ ofstream outdata,outdata1,outdata2,outdata3,outdata4;
+ outdata1.open("pwepem1.dat", ios::trunc);
+ outdata2.open("pwepem2.dat", ios::trunc);
+ outdata3.open("pwepem3.dat", ios::trunc);
+ outdata4.open("pwepem4.dat", ios::trunc);
+ double pt2t,pt2b,nit,intg, pt2;
+ pt2t = 0.; pt2b =0.;
+ intg = 0.;
+ nit = 1000;
+
+ for (int iy=1; iy < 5; iy++) {
+
+ if (iy==1) {pt2t = pt2max; pt2b=0.001;}
+ if (iy==2) {pt2t = 0.001; pt2b=0.0001;}
+ if (iy==3) {pt2t = 0.0001; pt2b=0.00001;}
+ if (iy==4) {pt2t = 0.00001; pt2b=pt2min;}
+ double div = (pt2t-pt2b)/nit;
+ pt2 = pt2t+div;
+ for (int ix=0; ix<nit; ix++) {
+
+ pt2=pt2-div;
+ if (pt2 < pt2b) {break;}
+ double lsqfrac = pow(Lambda/emcm,2);
+ double alphas=1./(b*log(pt2/lsqfrac))*(1.-bp*log(log(pt2/lsqfrac))/(b*log(pt2/lsqfrac)));
+ alphas=alphas + pow(alphas,2)*(67./3.-pow(pi,2)-50./9.)/(4.*pi);
+ double xminr=(39.*pt2-1.+pow(pt2,3)+15.*pow(pt2,2));
+ double xmini=(6.*sqrt(-33.*pow(pt2,2)+3.*pt2-3.*pow(pt2,3)));
+ if (pt2 > 0.0901698) {xmini = 0.;}
+ double xminm=sqrt(pow(xminr,2)+pow(xmini,2));
+ double xmint=atan2(xmini,xminr);
+ double xmin1=-1./12.*pow(xminm,(1./3.))*cos(xmint/3.);
+ double xmin2=(-1./12.-pow(pt2,2)/12.-5.*pt2/6.)*cos(xmint/3.)/(pow(xminm,(1./3.)));
+ double xmin3=pt2/6.+5./6.;
+ double xmin4=sqrt(3.)/12.*pow(xminm,(1./3.))*sin(xmint/3.)
+ -3.*sqrt(3.)*(-1./36.-pow(pt2,2)/36.-5.*pt2/18.)
+ /pow(xminm,(1./3.))*sin(xmint/3.);
+ double xmin5=xmin1+xmin2+xmin3+xmin4;
+ double xmin6=xmin1+xmin2+xmin3-xmin4;
+
+ if (pt2 < 1./12.) {
+ intg+= 2.*alphas/(3.*pi)*((log(16.*pow(pt2,2))/pt2
+ -function(pt2,xmin6))+(log(16.*pow(pt2,2))/pt2-function(pt2,xmin5)))*div;
+
+ } else {
+ intg+= 2.*alphas/(3.*pi)*(function(pt2,xmin5)-function(pt2,xmin6))*div;
+
+ }
+
+ if (iy==1) {outdata1 << pt2 << "\t" << abs(intg) << endl;}
+ if (iy==2) {outdata2 << pt2 << "\t" << abs(intg) << endl;}
+ if (iy==3) {outdata3 << pt2 << "\t" << abs(intg) << endl;}
+ if (iy==4) {outdata4 << pt2 << "\t" << abs(intg) << endl;}
+ }
+ //cout << fabs(intg) << endl;
+ if (iy==1) {rintgend1=abs(intg);}
+ if (iy==2) {rintgend2=abs(intg);}
+ if (iy==3) {rintgend3=abs(intg);}
+ if (iy==4) {rintgend4=abs(intg);}
+ }
+ cout << "...Done" << endl;
+}
+
+// Function used in filegen. This is the integral over x.
+
+double function (double pt2, double x) {
+ double G=log(1.-x)/pt2+2.*log(sqrt(1.-x)+sqrt(1.-4.*pt2-x))/pt2;
+ return G;}
+
+// interp reads files generated by filegen to find solutions to Sudakov form factor. Uses polynomial of order 3.
+
+double interp(int N,double XXX, double Xmax1, double Xmax2, double Xmax3, double Xmax4) {
+ double FF;
+ double AA;
+ int IX=0;
+ int IY=N+1;
+ int MID;
+ double aa,bb,cc,dd,ee,ii,gg,hh;
+ ifstream indata;
+
+ for (int iy=0;(IY-IX) > 1;iy++) {
+ if (XXX < Xmax1 ) {
+ indata.open("pwepem1.dat", ios::in);
+ }else if (XXX > Xmax1 && XXX < Xmax2 ) {
+ indata.open("pwepem2.dat", ios::in);
+ }else if (XXX > Xmax2 && XXX < Xmax3 ) {
+ indata.open("pwepem3.dat", ios::in);
+ }else if (XXX > Xmax3) {
+ indata.open("pwepem4.dat", ios::in);
+ }
+ MID=(IX+IY)/2;
+ for(int ix=0;ix < MID ;ix++) {
+ indata >> FF >> AA;}
+
+ indata.close();
+
+ if (XXX >= AA) {
+ IX=MID;} else {IY=MID;}
+ if ((IY-IX) < 1) break;}
+ if (IX < 5) {IX=5;}
+ if (XXX < Xmax1 ) {
+ indata.open("pwepem1.dat", ios::in);
+ }else if (XXX > Xmax1 && XXX < Xmax2 ) {
+ indata.open("pwepem2.dat", ios::in);
+ }else if (XXX > Xmax2 && XXX < Xmax3 ) {
+ indata.open("pwepem3.dat", ios::in);
+ }else if (XXX > Xmax3) {
+ indata.open("pwepem4.dat", ios::in);
+ }
+ for (int ix=0;ix<IX-3;ix++) {
+ indata >> FF >> AA;}
+ indata >> aa >> bb ;
+ indata >> cc >> dd ;
+ indata >> ee >> ii ;
+ indata >> gg >> hh ;
+ indata.close();
+ double d1=(cc-aa)/(dd-bb);
+ double d2=(ee-cc)/(ii-dd);
+ double d3=(gg-ee)/(hh-ii) ;
+ double dydx=(gg-aa)/(hh-bb);
+ double dydx1=(ee-aa)/(ii-bb);
+ double dydx2=(gg-cc)/(hh-dd);
+ double d2ydx2=(dydx2-dydx1)/((hh+dd-ii-bb)/2.);
+ double d2ydx21=2.*(d2-d1)/(ii-bb);
+ double d2ydx22=2.*(d3-d2)/(hh-dd);
+ double d3ydx3=2*(d2ydx22-d2ydx21)/(hh+dd-ii-bb);
+ double ddd=d3ydx3/6.;
+ double ccc=(d2ydx2-6.*ddd*(XXX-bb))/2.;
+ double bbb=(dydx-2.*ccc*(XXX-bb)-3.*ddd*pow((XXX-bb),2));
+ return bbb*(XXX-bb)+ccc*pow((XXX-bb),2)+ddd*pow((XXX-bb),3)+aa;}
+
+// xmaxmin determines the maximum and minimum value of x for given values of pt2 depending on which y branch it lies.
+
+ void xmaxmin (double pt2, double &rxmax, double &rxmin5,double &rxmin6 ) {
+ double xminr=(39.*pt2-1.+pow(pt2,3)+15.*pow(pt2,2));
+ double xmini=(6.*sqrt(-33.*pow(pt2,2)+3.*pt2-3.*pow(pt2,3)));
+ if (pt2 == 0.0901698) {xmini = 0.;}
+ double xminm=sqrt(pow(xminr,2)+pow(xmini,2));
+ double xmint=atan2(xmini,xminr);
+ double xmin1=-1./12.*pow(xminm,(1./3.))*cos(xmint/3.);
+ double xmin2=(-1./12.-pow(pt2,2)/12.-5.*pt2/6.)*cos(xmint/3.)/(pow(xminm,(1./3.)));
+ double xmin3=pt2/6.+5./6.;
+ double xmin4=sqrt(3.)/12.*pow(xminm,(1./3.))*sin(xmint/3.)
+ -3.*sqrt(3.)*(-1./36.-pow(pt2,2)/36.-5.*pt2/18.)
+ /pow(xminm,(1./3.))*sin(xmint/3.);
+ rxmin5=xmin1+xmin2+xmin3+xmin4;
+ rxmin6=xmin1+xmin2+xmin3-xmin4;
+ if (pt2 < 1./12.) {
+ rxmax=1.-4.*pt2;} else {
+ rxmax=rxmin5;
+ }
+ }
+
+// ME calculates the value of the approximation to the NLO matrix element for given y and x.
+
+ double ME (double pt2,double &rx, double &ry1, double &ry2, double xmin5, double &rM1, double &rM2, double &rw) {
+ ry1=(-2.+3.*rx-pow(rx,2)-sqrt(pow(rx,2)-2.*pow(rx,3)+pow(rx,4)-4.*pt2*pow(rx,2)+4.*pt2*pow(rx,3)))/(2.*(rx-1.));
+ ry2=(-2.+3.*rx-pow(rx,2)+sqrt(pow(rx,2)-2.*pow(rx,3)+pow(rx,4)-4.*pt2*pow(rx,2)+4.*pt2*pow(rx,3)))/(2.*(rx-1.));
+
+// Using the pt^2 delta function to eliminate x. w1,w2=d(pt)/dy
+ rw=(1.-rx)*(ry1-ry2)/(2.*sqrt(pt2)*pow(rx,2));
+ rM1=2./((1.-rx)*(1.-ry1)*rw);
+ rM2=2./((1.-rx)*(1.-ry2)*rw);
+ if (rx < xmin5 || pt2 > 1./12.){rM1=0;}
+ double M=fabs(rM1)+fabs(rM2);
+ return M;}
+
+// Random number generator
+
+ double random (int &rseed) {
+ int M = 2147483647;
+ int A = 16807;
+ int Q = 127773;
+ int R = 2836;
+ double MINV = 0.46566128752458e-09;
+ int HI = rseed/Q;
+ int LO = rseed % Q;
+ rseed = A*LO - R*HI;
+ if (rseed <= 0) {rseed = rseed + M;}
+ return rseed*MINV;}
diff --git a/Contrib/MCPWNLO/EPEM/PWEPEM_INPUTS.h b/Contrib/MCPWNLO/EPEM/PWEPEM_INPUTS.h
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/PWEPEM_INPUTS.h
@@ -0,0 +1,60 @@
+/* POWHEG input file*/
+#include<iostream>
+#include <string>
+
+class Input
+
+{
+ public:
+
+
+/* Center of mass energy/GeV */
+
+ double cme() {return 91.2;}
+
+/* Pole mass of Z/GeV */
+
+ double Mz() {return 91.2;}
+
+ /* AlphaS (MZ) */
+
+ double alphasmz() {return 0.118;}
+
+ /* LambdaQCD/GeV */
+
+ double Lambda() { return 0.2;}
+
+ /* Number of parton flavours */
+
+ int nf() {return 5;}
+
+ /* Use massless matrix element? Options: true or false */
+
+bool massiveME() {return true;}
+
+ /*Boost masses to true quark masses? (if using massless ME)Options: true or false */
+
+bool bst() {return false;}
+
+/* Maximum number of iterations for Newton-Raphson boost. 4 is recommended for sqrt(s)=91.2GeV */
+
+ int it() {return 4;}
+
+
+/* Number of events to generate */
+
+ int nevgen() {return 100000;}
+
+
+/* Random number seed */
+
+ int rseed() {return 3;}
+
+ /* Implement truncated shower? */
+
+bool trunc() {return true;}
+
+};
+
+
+
diff --git a/Contrib/MCPWNLO/EPEM/manual.bib b/Contrib/MCPWNLO/EPEM/manual.bib
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/manual.bib
@@ -0,0 +1,91 @@
+@Article{Frixione:2002ik,
+ author = "Frixione, Stefano and Webber, Bryan R.",
+ title = "Matching {NLO QCD} computations and parton shower
+ simulations",
+ journal = "JHEP",
+ volume = "06",
+ year = "2002",
+ pages = "029",
+ eprint = "hep-ph/0204244",
+ SLACcitation = "%%CITATION = HEP-PH 0204244;%%"
+}
+@Article{LatundeDada:2006gx,
+ author = "Latunde-Dada, Oluseyi and Gieseke, Stefan and Webber, Bryan
+ ",
+ title = "A positive-weight next-to-leading-order {M}onte {C}arlo for $e^+
+ e^-$ annihilation to hadrons",
+ journal = "JHEP",
+ volume = "02",
+ year = "2007",
+ pages = "051",
+ eprint = "hep-ph/0612281",
+ SLACcitation = "%%CITATION = HEP-PH/0612281;%%"
+}
+@Article{LatundeDada:2008bv,
+ author = "Latunde-Dada, Oluseyi",
+ title = "{Applying the POWHEG method to top pair production and
+ decays at the ILC}",
+ journal = "Eur. Phys. J.",
+ volume = "C58",
+ year = "2008",
+ pages = "543-554",
+ eprint = "0806.4560",
+ archivePrefix = "arXiv",
+ primaryClass = "hep-ph",
+ doi = "10.1140/epjc/s10052-008-0785-1",
+ SLACcitation = "%%CITATION = 0806.4560;%%"
+}
+@Article{Bahr:2008pv,
+ author = "Bahr, M. and others",
+ title = "{Herwig++ Physics and Manual}",
+ journal = "Eur. Phys. J.",
+ volume = "C58",
+ year = "2008",
+ pages = "639-707",
+ eprint = "0803.0883",
+ archivePrefix = "arXiv",
+ primaryClass = "hep-ph",
+ doi = "10.1140/epjc/s10052-008-0798-9",
+ SLACcitation = "%%CITATION = 0803.0883;%%"
+}
+@Article{LatundeDada:2007jg,
+ author = "Latunde-Dada, Oluseyi",
+ title = "{Herwig++ Monte Carlo At Next-To-Leading Order for e+e-
+ annihilation and lepton pair production}",
+ journal = "JHEP",
+ volume = "11",
+ year = "2007",
+ pages = "040",
+ eprint = "0708.4390",
+ archivePrefix = "arXiv",
+ primaryClass = "hep-ph",
+ doi = "10.1088/1126-6708/2007/11/040",
+ SLACcitation = "%%CITATION = 0708.4390;%%"
+}
+@Article{Nason:2004rx,
+ author = "Nason, Paolo",
+ title = "A new method for combining {NLO QCD} with shower {M}onte {C}arlo
+ algorithms",
+ journal = "JHEP",
+ volume = "11",
+ year = "2004",
+ pages = "040",
+ eprint = "hep-ph/0409146",
+ SLACcitation = "%%CITATION = HEP-PH/0409146;%%"
+}
+@PHDTHESIS{seyi,
+author = "Latunde-Dada, O.A.T",
+year = "2008",
+school = "University of Cambridge",
+title = "Simulations of QCD processes at High Energy Colliders {\bf [http://www.hep.phy.cam.ac.uk/theory/seyi/thesis/thesis.tar.gz]}"
+}
+@Article{LatundeDada:2009rr,
+ author = "Latunde-Dada, Oluseyi",
+ title = "{MC@NLO for the hadronic decay of Higgs bosons in
+ associated production with vector bosons}",
+ year = "2009",
+ eprint = "0903.4135",
+ archivePrefix = "arXiv",
+ primaryClass = "hep-ph",
+ SLACcitation = "%%CITATION = 0903.4135;%%"
+}
diff --git a/Contrib/MCPWNLO/EPEM/run_epem.cxx b/Contrib/MCPWNLO/EPEM/run_epem.cxx
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/EPEM/run_epem.cxx
@@ -0,0 +1,67 @@
+#include <cstdlib>
+#include <ctime>
+#include <iostream>
+#include <string>
+#include <fstream>
+#include <cmath>
+#include <iomanip>
+
+using namespace std;
+
+
+int main (int argc, char *argv[]) {
+ string eventfile = "";
+ string numevents = "1";
+ if(argv[1] && argv[2]) { eventfile = argv[1]; numevents = argv[2];} else { cout << "Use: run_hpp [eventfile] [numevents]" << endl; exit(1); }
+
+ cout << "Running Herwig++ with eventfile: " << eventfile << " and " << numevents << " events\n";
+ // ifstream stream;
+ //ofstream outstream;
+ //ofstream outorigin;
+ //string allfile = "";
+ // string addstr = "";
+
+ // stream.open("wpnlo.in");
+ // outstream.open("wpnlo.temp");
+ //outorigin.open("wpnlo.orig");
+ // if(!stream) { cerr << "Error: Failed to open file" << endl;}
+
+ // string search_string = "eventfile.dat";
+ //string replace_string = eventfile;
+ //string inbuf;
+
+ // while(!stream.eof())
+ //{
+ // getline(stream, inbuf);
+ // int spot = inbuf.find(search_string);
+ // outorigin << inbuf << endl;
+ // if(spot >= 0)
+ // {
+ // string tmpstring = inbuf.substr(0,spot);
+ // tmpstring += replace_string;
+ // tmpstring += inbuf.substr(spot+search_string.length(), inbuf.length());
+ // inbuf = tmpstring;
+ // }
+ // outstream << inbuf << endl;
+ //
+ // }
+ //outstream.close();
+ //stream.close();
+
+ string runcomm1 = "mv ";
+ runcomm1.append(eventfile);
+ runcomm1.append(" EPEM.dat");
+ system(runcomm1.c_str());
+ cout << "Reading EPEM.in..." << endl;
+ system("Herwig++ read EPEM.in");
+ cout << "Done..." << endl;
+ cout << "Running MG.run..." << endl;
+ string runcomm2 = "Herwig++ run MG.run -N";
+ cout << "Done!" << endl;
+ runcomm2.append(numevents);
+ system(runcomm2.c_str());
+ string runcomm3 = "mv EPEM.dat ";
+ runcomm3.append(eventfile);
+ system(runcomm3.c_str());
+ // system("mv wpnlo.orig wpnlo.in");
+}
diff --git a/Contrib/MCPWNLO/HIGGSDEC/MCHG.cxx b/Contrib/MCPWNLO/HIGGSDEC/MCHG.cxx
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/HIGGSDEC/MCHG.cxx
@@ -0,0 +1,1003 @@
+#include <cstdlib>
+#include <ctime>
+#include <iostream>
+#include <fstream>
+#include <string>
+//#include "LHAPDFWrap.h"
+#include <stdio.h>
+#include "MCHG_INPUTS.h"
+#include <cmath>
+#include <iomanip>
+using namespace std;
+// Checks if phase space point is in soft and collinear region?
+void QQgsc(double r1,double r2,double r3,double r4, double &rx, double &ry, double param[9], double &rwgt, double &rwgt1, bool resolve);
+// Checks if phase space point is in hard region?
+void QQgh(double r1,double r2,double r3,double r4, double &rx, double &ry, double param[9], double &rwgt, double &rwgt1, bool resolve);
+// Checks if phase space point is in gap between phase space for massive partons and full half-triangle?
+void QQgsp(double r1,double r2,double r3,double r4, double &rx, double &ry, double param[9], double &rwgt, double &rwgt1, bool resolve);
+// Dilogarithm Function
+double ddilog(double x);
+// Random number generator
+double random (int &rseed);
+
+// Main program
+
+int main() {
+ Input user;
+ int nev = user.nevint();
+ int nevg = user.nevgen();
+ int nit = user.it();
+ bool iface = user.iface();
+ bool rest = user.rest();
+ bool ifile = user.ifile();
+ char* filename;
+ if (iface && ifile) {
+ filename = user.filename();
+ rest = false;
+ nevg = user.nfile();
+ }
+ if (iface && !ifile && !rest)
+ {cout << "Need interface file!" << endl;
+ return 0;}
+ double emcm = user.cme();
+ double mH = user.mH();
+ int seed = user.rseed();
+ bool resolve = user.resolve();
+ int ii=0; //event count
+ // Constants
+ double pi = 3.14152654;
+ double GF = 0.0000116639;
+ double m = user.mb();
+ double Mz = user.Mz();
+ double Mw = user.Mw();
+ double Yz = 2.486;
+ double alphaem = 0.007297352;
+ double alphas = user.alphasmH();
+ //Lepton charge & coupling constants
+ double Che = -1;
+ double sin2thw = 0.2312;
+ double cos2thw = 1-sin2thw;
+ double Ae = -0.5;
+ double Ve = Ae-2.*Che*sin2thw;
+ double CLe = (Ae+Ve)/2.;
+ double CRe = (Ve-Ae)/2.;
+ double gz2 = sqrt(32.)*GF*pow(Mz,2);
+ double e2 = 4.*pi*alphaem;
+ double k = sqrt(2.)*GF*pow(Mz,2)/e2;
+ double chi1 =0.;
+ double chi2 = pow(k,2)*pow(Mz,4)/(pow(Yz*Mz,2));
+ //quark masses ,velocities and couplings. NB:gluon mass[10] =0.75
+
+ double Ch[6];
+ double mg = 0.75;
+ Ch[1]=-1./3.; Ch[2]=2./3.; Ch[3]=Ch[1]; Ch[4]=Ch[2]; Ch[5]=Ch[1];
+ /* w, w1 are the integrands. p,p1 are the corresponding integrals calculated from sum,sum1 & sd, sd1 are the corresponding errors
+ calculated via ssq, ssq1. bigwt is the maximum value of the integrand over the phase space (will be used for event generation) */
+
+ double wgt, wgt1;
+ double w[3],w1[3],bigwt[3],sum[3],sum1[3],ssq[3],ssq1[3],sd[3],sd1[3],p[3],p1[3];
+
+ sum1[0]=0.;sum1[1]=0.;sum[2]=0.;
+ sum1[0]=0.;sum1[1]=0.;sum1[2]=0.;
+ ssq[0]=0.;ssq[1]=0.;ssq[2]=0.;
+ ssq1[0]=0.;ssq1[1]=0.;ssq1[2]=0.;
+ bigwt[0]=0.;bigwt[1]=0.;bigwt[2]=0.;
+
+ cout << "Integrating..." << endl;
+
+ for (int d = 0; d < nev; d++) {
+ //Calculate Born cross-section
+
+ // Parameters for NLO cross-section calculation.
+ double param[9];
+ param[0] = pow(m,2)/pow(mH,2);
+ param[1] = 2.*param[0];
+ param[2] = sqrt(1.-4.*param[0]); // beta
+ param[3] = (1.-pow(param[2],2))/param[2]*log((1.+param[2])/(1.-param[2]))+ (1.+pow(param[2],2))/param[2]*(4.*ddilog((1.-param[2])/(1.+param[2]))+2.*log((1.+param[2])/(2.*param[2]))*log((1.+param[2])/(1.-param[2]))+2.*ddilog((param[2]-1.)/(1.+param[2]))-log(2./(1.+param[2]))*log((1.+param[2])/(1.-param[2])))-3.*log(4./(1.-pow(param[2],2)))-4.*log(param[2])+1./(16.*pow(param[2],3))*(3.+18.*pow(param[2],2)+3.*pow(param[2],4))*log((1.+param[2])/(1.-param[2]))-3./8.*pow(param[2],2)+21./8.;
+ param[4] = 0.5*(1.+param[2]);
+ param[5] = (param[0]*param[4]+0.25*param[2]*pow(1+param[2],2))/(param[4]-param[0]);
+ param[6] = 4.*alphas/(3.*pi); // colour factor
+ param[7] = 3.*GF*pow(m,2)/(4.*sqrt(2)*pi)*mH*pow(param[2],3);
+ param[8] = 1./(2.*pow(param[2],3));
+
+ // Random numbers and phase space points x and y.
+ double r1=random(seed);
+ double r2=random(seed);
+ double r3=random(seed);
+ double r4=random(seed);
+ double x,y;
+ x = r1;
+ y = r2;
+ QQgsc(r1, r2, r3, r4, x, y, param, wgt, wgt1, resolve);
+ w[0] = wgt; w1[0]=wgt1;
+ QQgh(r1, r2, r3, r4, x, y, param, wgt, wgt1, resolve);
+ w[1] = wgt; w1[1]=wgt1;
+ QQgsp(r1, r2, r3, r4, x, y, param, wgt, wgt1, resolve);
+ w[2] = wgt; w1[2]=wgt1;
+
+ for (int iz = 0; iz < 3; iz++) {
+ if (abs(w[iz]) > abs(bigwt[iz])) {bigwt[iz] = w[iz];}
+ sum[iz]+=w[iz];
+ sum1[iz]+=w1[iz];
+ ssq[iz]+=pow(w[iz],2);
+ ssq1[iz]+=pow(w1[iz],2);
+
+}
+ cout << "Integrated event : " << "\t" << d+1 << "\t" << "of" << "\t" << nev << "\r" << flush;
+
+}
+ cout << endl;
+ double xsec=0;
+ double cstt=0;
+ double xsecabs = 0.;
+ for (int ic=0; ic<3; ic++) {
+ p[ic] = sum[ic]/nev;
+ p1[ic] = sum1[ic]/nev;
+ sd[ic] = sqrt((ssq[ic]/nev-pow(p[ic],2))/nev);
+ sd1[ic] = sqrt((ssq1[ic]/nev-pow(p1[ic],2))/nev);
+ xsec+=p[ic]+p1[ic];
+ xsecabs+=fabs(p[ic])+fabs(p1[ic]);
+ //Output to screen the integrals, errors and maximum weights
+ // cout << "PHASE SPACE INTEGRALS:" << "\t" << p[ic] << "/" << p1[ic] <<"/" << sd[ic] <<"/" << sd1[ic]
+ // <<"/" << bigwt[ic] << "\t" << xsec << endl;
+}
+
+
+ //*********************************************************************************
+ /*Les Houches Accord event parameters:: PUP are the momenta,
+ ICOLUP is the colour code, MOTHUP is the mother information, ISTUP is
+ the status code. ISPINUP signifies spins. IDUP is the particle ID.
+ NUP is the number of particles in the event. SCALUP is the scale of
+ the event.AQEDUP and AQCDUP are alphaem and alphas resp.XWGTUP is
+ the weight of the event=1 or -1 for unweighted events.*/
+
+ double PUP[6][11],AQEDUP,AQCDUP,XWGTUP,SCALUP;
+ int ICOLUP[3][11],MOTHUP[3][11],ISTUP[11],ISPINUP[11],IDUP[11],NUP, NUPP;
+ NUP=0;
+ NUPP=0;
+ SCALUP = mH;
+ AQEDUP=0.007297352;
+ AQCDUP=alphas;
+ IDUP[1]=11;
+ IDUP[2]=-11;
+ IDUP[3]=23;
+ IDUP[4]=25;
+ IDUP[5]=23;
+ IDUP[6]=5;
+ IDUP[7]=-5;
+ IDUP[8]=11;
+ IDUP[9]=-11;
+ IDUP[10]=21;
+ MOTHUP[1][1]=0;
+ MOTHUP[1][2]=0;
+ MOTHUP[2][1]=0;
+ MOTHUP[2][2]=0;
+ MOTHUP[1][3]=1;
+ MOTHUP[2][3]=2;
+ MOTHUP[1][4]=3;
+ MOTHUP[2][4]=3;
+ MOTHUP[1][5]=3;
+ MOTHUP[2][5]=3;
+ MOTHUP[1][6]=4;
+ MOTHUP[2][6]=4;
+ MOTHUP[1][7]=4;
+ MOTHUP[2][7]=4;
+ MOTHUP[1][8]=5;
+ MOTHUP[2][8]=5;
+ MOTHUP[1][9]=5;
+ MOTHUP[2][9]=5;
+ MOTHUP[1][10]=4;
+ MOTHUP[2][10]=4;
+ ICOLUP[1][1]=0;
+ ICOLUP[2][1]=0;
+ ICOLUP[1][2]=0;
+ ICOLUP[2][2]=0;
+ ICOLUP[1][3]=0;
+ ICOLUP[2][3]=0;
+ ICOLUP[1][4]=0;
+ ICOLUP[2][4]=0;
+ ICOLUP[1][5]=0;
+ ICOLUP[2][5]=0;
+ ICOLUP[1][8]=0;
+ ICOLUP[2][8]=0;
+ ICOLUP[1][9]=0;
+ ICOLUP[2][9]=0;
+ ISTUP[1]=-1;
+ ISTUP[2]=-1;
+ ISTUP[3]=2;
+ ISTUP[4]=2;
+ ISTUP[5]=2;
+ ISTUP[6]=1;
+ ISTUP[7]=1;
+ ISTUP[8]=1;
+ ISTUP[9]=1;
+ ISTUP[10]=1;
+ //Momenta of incoming particles and Z boson
+ PUP[4][1]=emcm/2.;
+ PUP[1][1]=0.;
+ PUP[2][1]=0.;
+ PUP[3][1]=emcm/2;
+ PUP[4][2]=emcm/2;
+ PUP[1][2]=0.;
+ PUP[2][2]=0.;
+ PUP[3][2]=-emcm/2;
+ PUP[4][3]=emcm;
+ PUP[1][3]=0.;
+ PUP[2][3]=0.;
+ PUP[3][3]=0.;
+
+ //Allocate phase space region
+ double cst[3],bigwgt;
+ bigwgt=0.;
+ cst[0]=fabs(p[0])+fabs(p1[0]);
+ cst[1]=fabs(p[1])+fabs(p1[1]);
+ cst[2]=fabs(p[2])+fabs(p1[2]);
+ cstt = cst[0]+cst[1]+cst[2];
+
+ // Calculating the associated cross-section in picobarns...
+ double Betaz, tcst;
+ if (!iface){
+ Betaz = sqrt((pow(emcm,2)-pow(Mz+mH,2))*(pow(emcm,2)-pow(Mz-mH,2)))/(pow(emcm,2)-pow(mH,2)+pow(Mz,2));
+ double gammaz = 1./sqrt(1.-pow(Betaz,2));
+ tcst = 389400000.*pow(GF*Mw,2)*Betaz*gammaz*pow(Mz,3)/(cos2thw*32.*pi*pow(emcm, 3))*pow((pow(emcm,2)+pow(Mz,2)-pow(mH,2))/(pow(emcm,2)-pow(Mz,2)),2)*(1.-4.*sin2thw+8.*pow(sin2thw,2))*(4.*(1.-2./3.*pow(Betaz,2))) ;
+ }
+ //=====================================================================================================================================
+ ifstream indata;
+ ofstream outdata, outdata2, outdata3;
+ if (iface && rest) {
+ outdata2.open ("MCHGiface.dat", ios::trunc); // output for b, \bar{b} and g momenta in Higgs rest frame
+ outdata2 << "MC@NLO Higgs boson decay in rest frame" <<endl ;}
+
+ if (iface && ifile) {
+ indata.open (filename); // input file containing Higgs 5-momenta
+ outdata2.open ("MCHGiface.dat", ios::trunc); // output for b, \bar{b} and g momenta boosted to the lab frame
+ outdata2 << "MC@NLO Higgs boson decay in lab frame" <<endl ;}
+
+ if (!iface) {
+ outdata.open("eeZH.dat", ios::trunc);//output for associated production events
+ outdata << "<LesHouchesEvents version =\"1.0\">" << endl; outdata << "<!--" << endl;
+ outdata << "IPROC = " << "\t" << 23 << endl;
+ outdata << "NORMFACTOR = " << "\t" << xsecabs/xsec << endl;
+ outdata << "MC@NLO Higgs boson decay" <<endl ;
+ outdata << "File generated with MCHG.cxx" << endl; outdata << "-->" << endl;
+ outdata << "<init>" << endl;
+ outdata << "\t11\t" << "-11\t" ;
+ outdata << emcm/2. << "\t" << emcm/2. << "\t" << "0 \t 0 \t 7\t 7 \t 3 \t 1" << endl;
+ outdata << "\t" << tcst << "\t" << 0.000000 << "\t1.00000 \t11" << endl; outdata << "</init>" << endl;
+ }
+
+ cout << "Generating events..." << endl;
+
+
+ for (int d = 0; d < nevg; d++) {
+ int Jt, Jtt; //phase space identifiers
+ Jtt = 0;
+ if (random(seed) < cst[0]/cstt) {
+ if (random(seed) < fabs(p[0])/cst[0]) {
+ Jt=1; bigwgt=bigwt[0];} else
+ {Jt=2;}} else
+ if (random(seed) < cst[1]/(cst[1]+cst[2])) {
+ if (random(seed) < fabs(p[1])/cst[1]) {
+ Jt=3; bigwgt=bigwt[1];} else
+ {Jt=4;}} else
+ {Jt=5;}
+ bool labrest = false;
+ if (iface && ifile && !rest) {
+ indata >> PUP[1][4] >> PUP[2][4] >> PUP[3][4] >> PUP[4][4] >> mH ;
+ if (PUP[4][4] == mH) {labrest=true;} }
+
+ double phi6;
+ if (!iface) {
+ // Distributing the Z and H momenta
+
+ double cth3, Mtht;
+ do {
+ cth3= 2.*random(seed)-1.;
+ Mtht = 2.*(1.-pow(Betaz,2))+pow(Betaz,2)*(1.-pow(cth3,2));
+ } while (random(seed) > Mtht/(2.*(1.-pow(Betaz,2))+pow(Betaz,2)));
+ phi6 = 2.*random(seed)*pi;
+ double pZ;
+
+ if (Betaz == 0.) {pZ = 0.;} else {pZ = sqrt(pow(0.5*(emcm+(pow(mH,2)-pow(Mz,2))/emcm),2)-pow(mH,2));}
+ PUP[4][4]=0.5*(emcm+(pow(mH,2)-pow(Mz,2))/emcm);
+ PUP[1][4]=-pZ*sin(acos(cth3))*cos(phi6);
+ PUP[2][4]=-pZ*sin(acos(cth3))*sin(phi6);
+ PUP[3][4]=-pZ*cth3;
+ PUP[4][5]=emcm-PUP[4][4];
+ PUP[1][5]=pZ*sin(acos(cth3))*cos(phi6);
+ PUP[2][5]=pZ*sin(acos(cth3))*sin(phi6);
+ PUP[3][5]=pZ*cth3;
+ }
+ if (iface && !rest) {phi6 = pi + acos(PUP[1][4]/sqrt(pow(PUP[1][4],2) +pow(PUP[2][4],2)));}
+ //=================================================================================================================================
+ //select flavour of process
+ double mass[10];
+ int ID = 5;
+ mass[1]=0.;
+ mass[2]=0.;
+ mass[3]=emcm;
+ mass[4]=mH;
+ mass[5]=Mz;
+ mass[8]=0.;
+ mass[9]=0.;
+ //quark IDs
+ IDUP[6] = ID;
+ IDUP[7] = -ID;
+
+// Parameters for NLO cross-section calculation.
+ double param[9];
+ param[0] = pow(m,2)/pow(mH,2);
+ param[1] = 2.*param[0];
+ param[2] = sqrt(1.-4.*param[0]); // beta
+ param[3] = (1.-pow(param[2],2))/param[2]*log((1.+param[2])/(1.-param[2]))+ (1.+pow(param[2],2))/param[2]*(4.*ddilog((1.-param[2])/(1.+param[2]))+2.*log((1.+param[2])/(2.*param[2]))*log((1.+param[2])/(1.-param[2]))+2.*ddilog((param[2]-1.)/(1.+param[2]))-log(2./(1.+param[2]))*log((1.+param[2])/(1.-param[2])))-3.*log(4./(1.-pow(param[2],2)))-4.*log(param[2])+1./(16.*pow(param[2],3))*(3.+18.*pow(param[2],2)+3.*pow(param[2],4))*log((1.+param[2])/(1.-param[2]))-3./8.*pow(param[2],2)+21./8.;
+ param[4] = 0.5*(1.+param[2]);
+ param[5] = (param[0]*param[4]+0.25*param[2]*pow(1+param[2],2))/(param[4]-param[0]);
+ param[6] = 4.*alphas/(3.*pi); // colour factor
+ param[7] = 3.*GF*pow(m,2)/(4.*sqrt(2)*pi)*mH*pow(param[2],3);
+ param[8] = 1./(2.*pow(param[2],3));
+
+ // phase space point x1,x2
+ double x1,x2;
+ double wt; //event weight
+ wt = 0.;
+ bool qg = true;
+ double cth,pcm;
+ cth=0.;pcm=0.;
+
+ if (Jt==1||Jt==3) {
+ double c13, c23, x3;
+ do {
+ // Random numbers
+ double r1=random(seed);
+ double r3=random(seed);
+ double r4=random(seed);
+ double r2 =random(seed);
+ x1 = r1;
+ x2 = r2;
+ if (Jt==1) {
+ QQgsc(r1, r2, r3, r4, x1, x2, param, wgt, wgt1, resolve);
+ wt = wgt;}
+ if (Jt==3) {
+ QQgh(r1, r2, r3, r4, x1, x2, param, wgt, wgt1, resolve);
+ wt = wgt;}
+ x3=2.-x1-x2;
+ c13=(x1*x3-2.*(1.-x2))/(sqrt(pow(x1,2)-4.*param[0])*x3);
+ c23=(x2*x3-2.*(1.-x1))/(sqrt(pow(x2,2)-4.*param[0])*x3);
+ } while (random(seed) > fabs(wt)/fabs(bigwgt) || isinf(c13) || isinf(c23));
+
+ if (Jt==1){wt=-1.;}
+ if (Jt==3){wt=1.;}
+ double cf,ct, ppt;
+ double px1 = sqrt(pow(0.5*mH*x1,2)-pow(m,2));
+ double px2 = sqrt(pow(0.5*mH*x2,2)-pow(m,2));
+ double px3 = sqrt(pow(0.5*mH*x3,2));
+ do {cth = 2.*random(seed)-1.;
+ if (random(seed) < pow(x1,2)/(pow(x1,2)+pow(x2,2))) {
+ cf = (px2*c23+px3)/px1; ct = (px1-px3*cf)/px2;}else
+ {cf = (px1*c13+px3)/px2; ct = (px2-px3*cf)/px1; qg=false;}
+ } while (ct > 1. || cf > 1.);
+ double phi = 2.*pi*random(seed);
+ double phi2 = 2.*pi*random(seed);
+ if (qg) {
+ pcm = px1;
+ PUP[3][6]=px1*cth;
+ double pt = sqrt(pow(px1,2)-pow(PUP[3][6],2));
+ PUP[1][6]=pt*cos(phi);
+ PUP[2][6]=pt*sin(phi);
+ MOTHUP[1][10] = 4;
+ MOTHUP[2][10] = 4;
+ double ppl = px2*ct;
+ if (random(seed) < 0.5) {
+ ppt = sqrt (pow(px2,2)-pow(ppl,2));}else {ppt = -sqrt (pow(px2,2)-pow(ppl,2));}
+ double ppt1 = ppt*cos(phi2);
+ double ppt2 = ppt*sin(phi2);
+ PUP[3][7]=-(ppl*cth-ppt1*sin(acos(cth)));
+ PUP[1][7]=-((ppl*sin(acos(cth))+ppt1*cth)*cos(phi)-ppt2*sin(phi));
+ PUP[2][7]=-((ppl*sin(acos(cth))+ppt1*cth)*sin(phi)+ppt2*cos(phi));}
+ else {
+ pcm = px2;
+ PUP[3][7]=px2*cth;
+ double pt = sqrt(pow(px2,2)-pow(PUP[3][7],2));
+ PUP[1][7]=pt*cos(phi);
+ PUP[2][7]=pt*sin(phi);
+ MOTHUP[1][10] = 4;
+ MOTHUP[2][10] = 4;
+ double ppl = px1*ct;
+ if (random(seed) < 0.5) {
+ ppt = sqrt (pow(px1,2)-pow(ppl,2));}else {ppt = -sqrt (pow(px1,2)-pow(ppl,2));}
+ double ppt1 = ppt*cos(phi2);
+ double ppt2 = ppt*sin(phi2);
+ PUP[3][6]=-(ppl*cth-ppt1*sin(acos(cth)));
+ PUP[1][6]=-((ppl*sin(acos(cth))+ppt1*cth)*cos(phi)-ppt2*sin(phi));
+ PUP[2][6]=-((ppl*sin(acos(cth))+ppt1*cth)*sin(phi)+ppt2*cos(phi));}
+
+ PUP[3][10]= -PUP[3][6] - PUP[3][7];
+ PUP[1][10]= -PUP[1][6] - PUP[1][7];
+ PUP[2][10]= -PUP[2][6] - PUP[2][7];
+ PUP[4][6] = x1*mH/2.;
+ PUP[4][7] = x2*mH/2.;
+ PUP[4][10] = x3*mH/2.;
+ //colour info
+ ICOLUP[1][6] = 501;
+ ICOLUP[2][6] = 0;
+ ICOLUP[1][7] = 0;
+ ICOLUP[2][7] = 502;
+ ICOLUP[1][10] = 502;
+ ICOLUP[2][10] = 501;
+ //Number of particles
+ NUP=10;
+ NUPP = 4; // number in Higgs rest frame
+ if (Jt == 1) { Jtt = 1;} // from soft collinear region
+ if (Jt == 3) { Jtt = 2;} // from hard non-collinear region
+}
+
+
+ if (Jt==2||Jt==4||Jt==5) {
+ Jtt = 1;
+ x1 = 1.;x2 = 1.; wt = 1.;
+ pcm = sqrt(pow(0.5*mH,2)-pow(m,2));
+ cth = 2.*random(seed)-1.;
+ double phi = 2.*random(seed)*pi;
+ PUP[3][6] = pcm*cth;
+ PUP[1][6] = sqrt(pow(pcm,2)-pow(PUP[3][6],2))*cos(phi);
+ PUP[2][6] = sqrt(pow(pcm,2)-pow(PUP[3][6],2))*sin(phi);
+ PUP[1][7] = -PUP[1][6];
+ PUP[2][7] = -PUP[2][6];
+ PUP[3][7] = -PUP[3][6];
+ PUP[4][6] = mH/2.;
+ PUP[4][7] = mH/2.;
+ PUP[3][10]=0.;
+ PUP[1][10]=0.;
+ PUP[2][10]=0.;
+ //colour info
+ ICOLUP[1][6] = 501;
+ ICOLUP[2][6] = 0;
+ ICOLUP[1][7] = 0;
+ ICOLUP[2][7] = 501;
+ //Number of particles
+ NUP=9;
+ NUPP = 3; // number in Higgs rest frame
+ Jtt = 3; // Born event
+ }
+ double alpha = 1.;
+
+ //boost masses if needed. Need to boost to nominal gluon mass always.
+ double mb = m;
+ double Eq,Eqb,Eg;
+ double pq = sqrt(pow(PUP[1][6],2)+pow(PUP[2][6],2)+pow(PUP[3][6],2));
+ double pqb = sqrt(pow(PUP[1][7],2)+pow(PUP[2][7],2)+pow(PUP[3][7],2));
+ double pg = sqrt(pow(PUP[1][10],2)+pow(PUP[2][10],2)+pow(PUP[3][10],2));
+ for (int ix=1; ix < nit+1; ix++) {
+ Eq = sqrt(pow(mb,2)+alpha*pow(pq,2));
+ Eqb = sqrt(pow(mb,2)+alpha*pow(pqb,2));
+ if (NUP == 9) {mg =0.;} else {mg =0.75;}
+ Eg = sqrt(pow(mg,2)+alpha*pow(pg,2));
+ if (NUP==10) {
+ alpha = alpha+(2.*(mH-Eq-Eqb-Eg))/(pow(pq,2)/Eq+pow(pqb,2)/Eqb+pow(pg,2)/Eg);}
+ else {alpha = alpha+(2.*(mH-Eq-Eqb))/(pow(pq,2)/Eq+pow(pqb,2)/Eqb);}
+ }
+ PUP[1][6] =sqrt(alpha)*PUP[1][6];
+ PUP[2][6] =sqrt(alpha)*PUP[2][6];
+ PUP[3][6] =sqrt(alpha)*PUP[3][6];
+ PUP[4][6] =Eq;
+ PUP[1][7] =sqrt(alpha)*PUP[1][7];
+ PUP[2][7] =sqrt(alpha)*PUP[2][7];
+ PUP[3][7] =sqrt(alpha)*PUP[3][7];
+ PUP[4][7] =Eqb;
+ PUP[1][10] =sqrt(alpha)*PUP[1][10];
+ PUP[2][10] =sqrt(alpha)*PUP[2][10];
+ PUP[3][10] =sqrt(alpha)*PUP[3][10];
+ PUP[4][10] =Eg;
+ mass[6] = m;
+ mass[7] = m;
+ mass[10] = mg;
+ if (iface && rest) {
+ ii += 1;
+ outdata2 << "<event>" << endl;
+ outdata2 << NUPP << "\t" << Jtt << "\t" << wt << endl;
+ outdata2 << IDUP[4] << "\t" << 0. << "\t" << 0. << "\t" << 0. << "\t" << mass[4] << "\t" << mass[4] << endl;
+ outdata2 << IDUP[6] << "\t" << PUP[1][6] << "\t" << PUP[2][6] << "\t" << PUP[3][6] << "\t" << PUP[4][6] << "\t" << mass[6] << endl;
+ outdata2 << IDUP[7] << "\t" << PUP[1][7] << "\t" << PUP[2][7] << "\t" << PUP[3][7] << "\t" << PUP[4][7] << "\t" << mass[7] << endl;
+ if (Jt == 1 || Jt == 3) {
+ outdata2 << IDUP[10] << "\t" << PUP[1][10] << "\t" << PUP[2][10] << "\t" << PUP[3][10] << "\t" << PUP[4][10] << "\t" << mass[10] << endl;}
+ outdata2 << "</event>" << endl;
+ cout << "Generated event : " << "\t" << ii << "\t" << "of" << "\t" << nevg << "\r" << flush;
+}
+ if (labrest) {
+ ii+=1;
+ outdata2 << "<event>" << endl;
+ outdata2 << NUPP << "\t" << Jtt << "\t" << wt << endl;
+ outdata2 << IDUP[4] << "\t" << 0. << "\t" << 0. << "\t" << 0. << "\t" << mass[4] << "\t" << mass[4] << endl;
+ outdata2 << IDUP[6] << "\t" << PUP[1][6] << "\t" << PUP[2][6] << "\t" << PUP[3][6] << "\t" << PUP[4][6] << "\t" << mass[6] << endl;
+ outdata2 << IDUP[7] << "\t" << PUP[1][7] << "\t" << PUP[2][7] << "\t" << PUP[3][7] << "\t" << PUP[4][7] << "\t" << mass[7] << endl;
+ if (Jt == 1 || Jt == 3) {
+ outdata2 << IDUP[10] << "\t" << PUP[1][10] << "\t" << PUP[2][10] << "\t" << PUP[3][10] << "\t" << PUP[4][10] << "\t" << mass[10] << endl;}
+ outdata2 << "</event>" << endl;
+ cout << "Generated event : " << "\t" << ii << "\t" << "of" << "\t" << nevg << "\r" << flush;
+ }
+
+ if (!labrest && ((!iface && Betaz != 0.) || (iface && !rest))) {
+ // boost to lab frame
+ double Eqq = PUP[4][6] ; double Eqqb = PUP[4][7] ; double Eggg= PUP[4][10];
+ double vv2 = sqrt(pow(PUP[4][4],2)-pow(mH,2))/PUP[4][4];
+ PUP[4][6]=(Eqq - vv2*PUP[3][6])/sqrt(1.-pow(vv2,2));
+ PUP[3][6]=(PUP[3][6]-Eqq*vv2)/sqrt(1.-pow(vv2,2));
+ PUP[4][7]=(Eqqb-vv2*PUP[3][7])/sqrt(1.-pow(vv2,2));
+ PUP[3][7]=(PUP[3][7]-Eqqb*vv2)/sqrt(1.-pow(vv2,2));
+ PUP[4][10]=(Eggg-vv2*PUP[3][10])/sqrt(1.-pow(vv2,2));
+ PUP[3][10]=(PUP[3][10]-Eggg*vv2)/sqrt(1.-pow(vv2,2));
+ // Rotate to beam axis.
+ double costz = PUP[3][4]/(sqrt(pow(PUP[4][4],2)-pow(mH,2)));
+ double sintz = sin(acos(costz));
+ double costx = PUP[1][4]/(sqrt(pow(PUP[1][4],2)+pow(PUP[2][4],2)));
+ double sintx = sin(acos(costx));
+ costx = -cos(phi6);
+ sintx = -sin(phi6);
+ double qx = PUP[1][6];
+ PUP[1][6] = -qx*costz+PUP[3][6]*sintz;
+ PUP[3][6] = qx*sintz + PUP[3][6]*costz;
+ qx = PUP[1][6];
+ PUP[1][6]=qx*costx-PUP[2][6]*sintx;
+ PUP[2][6]=qx*sintx+PUP[2][6]*costx;
+ double qbx = PUP[1][7];
+ PUP[1][7] = -qbx*costz+PUP[3][7]*sintz;
+ PUP[3][7] = qbx*sintz + PUP[3][7]*costz;
+ qbx = PUP[1][7];
+ PUP[1][7]=qbx*costx-PUP[2][7]*sintx;
+ PUP[2][7]=qbx*sintx+PUP[2][7]*costx;
+ double gx = PUP[1][10];
+ PUP[1][10] = -gx*costz+PUP[3][10]*sintz;
+ PUP[3][10] = gx*sintz + PUP[3][10]*costz;
+ gx = PUP[1][10];
+ PUP[1][10]=gx*costx-PUP[2][10]*sintx;
+ PUP[2][10]=gx*sintx+PUP[2][10]*costx;
+ PUP[1][6] = -PUP[1][6];
+ PUP[2][6] = -PUP[2][6];
+ PUP[3][6] = -PUP[3][6];
+ PUP[1][7] = -PUP[1][7];
+ PUP[2][7] = -PUP[2][7];
+ PUP[3][7] = -PUP[3][7];
+ PUP[1][10] = -PUP[1][10];
+ PUP[2][10] = -PUP[2][10];
+ PUP[3][10] = -PUP[3][10];
+ if (iface && !rest) {
+ ii+=1;
+ outdata2 << "<event>" << endl;
+ outdata2 << NUPP << "\t" << Jtt << "\t" << wt << endl;
+ outdata2 << IDUP[4] << "\t" << PUP[1][4] << "\t" << PUP[2][4] << "\t" << PUP[3][4] << "\t" << PUP[4][4] << "\t" << mass[4] << endl;
+ outdata2 << IDUP[6] << "\t" << PUP[1][6] << "\t" << PUP[2][6] << "\t" << PUP[3][6] << "\t" << PUP[4][6] << "\t" << mass[6] << endl;
+ outdata2 << IDUP[7] << "\t" << PUP[1][7] << "\t" << PUP[2][7] << "\t" << PUP[3][7] << "\t" << PUP[4][7] << "\t" << mass[7] << endl;
+ if (Jt == 1 || Jt == 3) {
+ outdata2 << IDUP[10] << "\t" << PUP[1][10] << "\t" << PUP[2][10] << "\t" << PUP[3][10] << "\t" << PUP[4][10] << "\t" << mass[10] << endl;}
+ outdata2 << "</event>" << endl;
+ // cout << "here" << endl;
+ cout << "Generated event : " << "\t" << ii << "\t" << "of" << "\t" << nevg << "\r" << flush;
+ }
+ }
+
+ double CLf, CRf;
+ CLf = 0.; CRf = 0.;
+ //spin information (not needed yet!)
+ double C[9], M[9];
+ C[1] = pow(CRe,2)*(chi2/(pow((mH*k),2)))*pow(gz2,2);
+ C[2] = pow(CLe,2)*(chi2/(pow((mH*k),2)))*pow(gz2,2);
+ C[3] = CLf*(mH/2.-pcm)+CRf*(mH/2.+pcm);
+ C[4] = CLf*(mH/2.+pcm)+CLf*(mH/2.-pcm);
+ C[5] = (CLf+CRf)*m;
+ C[6] = 2*e2*Ch[ID]*CRe*chi1*gz2/(k*mH);
+ C[7] = 2*e2*Ch[ID]*CLe*chi1*gz2/(k*mH);
+ C[8] = e2*Ch[ID];
+ M[1] = (C[1]*pow(C[3],2)-C[6]*C[3]+pow(C[8],2))*pow(1+cth,2);
+ M[5] = (C[2]*pow(C[4],2)-C[7]*C[4]+pow(C[8],2))*pow(1+cth,2);
+ M[2] = (C[1]*pow(C[4],2)-C[6]*C[4]+pow(C[8],2))*pow(1+cth,2);
+ M[6] = (C[2]*pow(C[3],2)-C[7]*C[3]+pow(C[8],2))*pow(1+cth,2);
+ M[3] = (C[1]*pow(C[5],2)-2.*m/mH*C[6]*C[5]+pow(C[8],2)*4.*param[0])*(1.-pow(cth,2));
+ M[7] = (C[2]*pow(C[5],2)-2.*m/mH*C[7]*C[5]+pow(C[8],2)*4.*param[0])*(1.-pow(cth,2));
+ M[4] = M[3];
+ M[8] = M[7];
+ double Mud, Mdu;
+ Mud = 0.; Mdu =0.;
+ for (int ix=1; ix < 5; ix++) {Mud+=M[ix];}
+ for (int ix=5; ix < 9; ix++) {Mud+=M[ix];}
+ if (random(seed) < Mud/(Mud+Mdu)) {
+ ISPINUP[1]=+1;
+ ISPINUP[2]=-1;
+ ISPINUP[3]=+1;
+ if (random(seed) < (M[1]+M[3])/Mud) {
+ ISPINUP[4] = +1;
+ if (random(seed) < M[1]/(M[1]+M[3])) {
+ ISPINUP[5] = -1;}else {ISPINUP[5] = +1;}} else {
+ ISPINUP[4] = -1;
+ if (random(seed) < M[2]/(M[2]+M[4])) {
+ ISPINUP[5] = +1;} else {ISPINUP[5] = -1;} }} else {
+ ISPINUP[1]=-1;
+ ISPINUP[2]=+1;
+ ISPINUP[3]=-1;
+ if (random(seed) < (M[6]+M[7])/Mdu) {
+ ISPINUP[4] = +1;
+ if (random(seed) < M[6]/(M[6]+M[7])) {
+ ISPINUP[5] = -1;}else {ISPINUP[5] = +1;}} else {
+ ISPINUP[4] = -1;
+ if (random(seed) < M[5]/(M[5]+M[8])) {
+ ISPINUP[5] = +1;} else {ISPINUP[5] = -1;} }}
+ if (qg) {ISPINUP[6] = ISPINUP[4];} else {ISPINUP[6] = ISPINUP[5];}
+
+ if (!iface) {
+ // Z boson rest frame
+
+ double cth2,cofact, maxcofact;
+ IDUP[3]=23;
+ IDUP[5]=23;
+ IDUP[8]=11;
+ IDUP[9]=-11;
+ do {cth2=2.*random(seed)-1.;
+ cofact = 1.+pow(cth2,2);
+ maxcofact = 2.;} while(random(seed) > cofact/maxcofact);
+ double phi5 = 2.*random(seed)*pi;
+ PUP[3][9] = Mz*cth2/2.;
+ PUP[1][9] = sqrt(pow(Mz/2.,2)-pow(PUP[3][4],2))*cos(phi5);
+ PUP[2][9] = sqrt(pow(Mz/2.,2)-pow(PUP[3][4],2))*sin(phi5);
+ PUP[1][8] = -PUP[1][9];
+ PUP[2][8] = -PUP[2][9];
+ PUP[3][8] = -PUP[3][9];
+ PUP[4][8] = Mz/2.;
+ PUP[4][9] = Mz/2.;
+ if (Betaz != 0.) {
+ // boost to lab
+ double vv2 = sqrt(pow(PUP[4][5],2)-pow(Mz,2))/PUP[4][5];
+ PUP[4][9]=(Mz/2.-vv2*PUP[3][9])/sqrt(1.-pow(vv2,2));
+ PUP[3][9]=(PUP[3][9]-Mz*vv2/2.)/sqrt(1.-pow(vv2,2));
+ PUP[4][8]=(Mz/2.-vv2*PUP[3][8])/sqrt(1.-pow(vv2,2));
+ PUP[3][8]=(PUP[3][8]-Mz*vv2/2.)/sqrt(1.-pow(vv2,2));
+ double ktt1=-sqrt(pow(PUP[4][9],2)-pow(PUP[3][9],2));
+ double ktt2=sqrt(pow(PUP[4][8],2)-pow(PUP[3][8],2));
+ double kt = sqrt(pow(PUP[1][5],2)+pow(PUP[2][5],2));
+ double tht=atan2(kt,PUP[3][5]);
+ double pe1=PUP[4][9];
+ double pe2=PUP[4][8];
+ double pz1=PUP[3][9];
+ double pz2=PUP[3][8];
+ PUP[4][9]=pe2;
+ PUP[4][8]=pe1;
+ PUP[3][9]=-(pz2*cos(tht)+ktt2*sin(tht));
+ PUP[3][8]=-(pz1*cos(tht)+ktt1*sin(tht));
+ PUP[1][9]=-(pz2*sin(tht)-ktt2*cos(tht))*cos(phi6);
+ PUP[2][9]=-(pz2*sin(tht)-ktt2*cos(tht))*sin(phi6);
+ PUP[1][8]=-(pz1*sin(tht)-ktt1*cos(tht))*cos(phi6);
+ PUP[2][8]=-(pz1*sin(tht)-ktt1*cos(tht))*sin(phi6);
+ if (random(seed) < 0.5) {
+ PUP[4][9]=pe1;
+ PUP[4][8]=pe2;
+ PUP[3][9]=-(pz1*cos(tht)+ktt1*sin(tht));
+ PUP[3][8]=-(pz2*cos(tht)+ktt2*sin(tht));
+ PUP[1][9]=-(pz1*sin(tht)-ktt1*cos(tht))*cos(phi6);
+ PUP[2][9]=-(pz1*sin(tht)-ktt1*cos(tht))*sin(phi6);
+ PUP[1][8]=-(pz2*sin(tht)-ktt2*cos(tht))*cos(phi6);
+ PUP[2][8]=-(pz2*sin(tht)-ktt2*cos(tht))*sin(phi6);
+ } }
+ //weight info
+ XWGTUP = wt;
+ ii+=1;
+ double sum1, sum2, sum3, sum4;
+ sum1=0.;sum2=0.;sum3=0.;sum4=0.;
+
+ outdata << "<event>" << endl;
+ outdata << NUP <<"\t" << "11" <<"\t"<<XWGTUP<<"\t" << SCALUP << "\t" << AQEDUP << "\t" << AQCDUP << endl;
+ for (int ja = 1; ja < NUP+1; ja++) {
+ outdata << IDUP[ja] << "\t" << ISTUP[ja] << "\t" << MOTHUP[1][ja] <<"\t" << MOTHUP[2][ja] << "\t" << ICOLUP[1][ja] << "\t" << ICOLUP[2][ja] <<"\t" <<setprecision (9)<< PUP[1][ja] << "\t" << PUP[2][ja]<<"\t"<<PUP[3][ja]<<"\t"<<PUP[4][ja]<<"\t" << mass[ja] <<"\t"<< "0" << "\t" <<"9" <<endl;
+ sum1+=PUP[4][ja];sum2+=PUP[1][ja];sum3+=PUP[2][ja];sum4+=PUP[3][ja];
+ cout << "Generated event : " << "\t" << ii << "\t" << "of" << "\t" << nevg << "\r" << flush;
+}
+ outdata << "</event>" << endl;}}
+ if (!iface) {
+ outdata << "</LesHouchesEvents>" << endl;
+ cout << endl;}
+ return 0;
+}
+/********************************************************************************/
+// In soft and collinear phase space region ?
+
+void QQgsc(double r1, double r2, double r3,double r4, double &rx, double &ry, double param[9], double &rwgt, double &rwgt1, bool resolve) {
+
+ //Initialize weights
+ rwgt = 0.; rwgt1 = 0.;
+
+ /*Remove 2-jet events */
+ double y1 = 1.-r1;
+ double y2 = 1.-r2;
+ if ((1.-y1)==1 && (1.-y2)==1.) {return;}
+ bool soft = false;
+ int region = 0; // 1 for jet region cont. x=1; 2 for jet region cont. y=1
+ double fac = 1.; // weight factor for soft regions
+
+ if (y1 < 0.25 && y2 <0.25) {
+ soft = true;
+ if (y2 < y1) {
+ y1 = 0.25*r3;
+ y2 = r4*y1;
+ fac = 2.*r3;
+ } else {
+ y2 = 0.25*r4;
+ y1 = r3*y2;
+ fac = 2.*r4;
+ }
+ }
+
+ /* Check if outside Dalitz boundary */
+
+ if (y1*y2*(1.-y1-y2) < param[0]*pow((y1+y2),2)) {return;}
+
+ /*Inside jet 1? */
+ double w1 = 1.-y1;
+ double w2 = 1.-y2;
+ double tk = param[4];
+ double d1 = 0.25-(1.-w2)/tk;
+ double z, d2 , xx1, xx2;
+ if (d1 > 0.) {
+ z = 0.5+sqrt(d1);
+ d2 = pow(w2,2)-4.*param[0];
+ if (d2 > 0.) {
+ d2 = sqrt(d2);
+ double rr = 1.+param[0]/(1.-w2+param[0]);
+ xx1 = (rr*(2.-w2)+(2.*z-rr)*d2)/2.;
+ xx2 = (rr*(2.-w2)+(2.*(1.-z)-rr)*d2)/2.;
+ if (xx2 < w1 && w1 < xx1) {
+ region = 1;}
+ }
+ }
+ if (region == 0) {
+ w1 = 1.-y2;
+ w2 = 1.-y1;
+ tk = param[5];
+ d1 = 0.25-(1.-w2)/tk;
+ if (d1 > 0.) {
+ z = 0.5+sqrt(d1);
+ d2 = pow(w2,2)-4.*param[0];
+ if (d2 > 0.) {
+ d2 = sqrt(d2);
+ double rr = 1.+param[0]/(1.-w2+param[0]);
+ xx1 = (rr*(2.-w2)+(2.*z-rr)*d2)/2.;
+ xx2 = (rr*(2.-w2)+(2.*(1.-z)-rr)*d2)/2.;
+ if (xx2 < w1 && w1 < xx1) {
+ region = 2;} else {return;}
+ } else {return;}
+ } else {return;} }
+ // fac = 1.;
+ /* Calculate weights for jet regions */
+ double r, zz;
+ rx = 1.-y1;
+ ry = 1.-y2;
+
+ if (region == 1) {
+ r = 0.5*(1.+param[0]/(1.+param[0]-ry));
+ zz = r+(rx-(2.-ry)*r)/sqrt(pow(ry,2)-2.*param[1]);
+ rwgt = ((pow(1-rx,2) + pow(1-ry,2))/((1-rx)*(1-ry))+2.*(1.-param[1])*(rx+ry-1.-2.*param[1])/((1.-rx)*(1.-ry))+2.*param[1]*(1./(1.-rx)+1./(1.-ry))-param[1]*(1.-2.*param[1])*(1./pow(1-rx,2)+1./pow(1.-ry,2))+2.)*param[8];
+ rwgt = rwgt-((((1.+pow(zz,2))/(1.-zz))-param[1]/y2)/(y2*sqrt(pow(ry,2)-2.*param[1])))/2.;
+ rwgt = rwgt*param[6]*fac;
+ } else if (region == 2) {
+ r = 0.5*(1.+param[0]/(1.+param[0]-rx));
+ zz = r+(ry-(2.-rx)*r)/sqrt(pow(rx,2)-2.*param[1]);
+ rwgt = ((pow(1-rx,2) + pow(1-ry,2))/((1-rx)*(1-ry))+2.*(1.-param[1])*(rx+ry-1.-2.*param[1])/((1.-rx)*(1.-ry))+2.*param[1]*(1./(1.-rx)+1./(1.-ry))-param[1]*(1.-2.*param[1])*(1./pow(1-rx,2)+1./pow(1.-ry,2))+2.)*param[8];
+ rwgt = rwgt-((((1.+pow(zz,2))/(1.-zz))-param[1]/y1)/(y1*sqrt(pow(rx,2)-2.*param[1])))/2.;
+ rwgt = rwgt*param[6]*fac;
+ }
+ rwgt1 = (2.+2.*param[3]*param[6])*fac-rwgt;
+ /* Implement soft resolution cut */
+ if (resolve) {
+ if (rx+ry > 1.9999) {return;}}
+}
+ /*********************************************************************/
+ // In hard region?
+
+void QQgh(double r1, double r2, double r3,double r4, double &rx, double &ry, double param[9], double &rwgt,double &rwgt1, bool resolve) {
+
+ //Initialize weights and phase space points
+ rwgt = 0.;rwgt1 = 0.;
+
+ /*Remove 2-jet events */
+ double y1 = 1.-r1;
+ double y2 = 1.-r2;
+ if ((1.-y1)==1. && (1.-y2)==1.) {return;}
+ bool soft = false;
+ double fac = 1.; // weight factor for soft regions
+
+// Mappings for soft and collinear regions
+ if (y1 < 0.25){
+ if (y2 < 0.25) {
+ soft = true;
+ if (y1 < y2) {
+ y1 = 0.25-y1;
+ y2 = y1*(1.5-2.*y2);
+
+ } else {
+ y2 = 0.25-y2;
+ y1 = y2*(1.5-2.*y1);
+ }} else if (y2 < y1+2.*pow(y1,2)) {return;}
+ } else if (y2 < 0.25) { if (y1 < y2+2.*pow(y2,2)) {return;} }
+
+
+ if (soft) {if (y1 < y2) {fac = 2.*y1;} else {fac = 2.*y2;} }
+ if (!soft) {
+
+ if (y1 > 0.375 && y2 < 0.25) {
+ if (y1 > 1.-2.5*y2 && y1 < 1.-y2) {
+ y2 = r4*0.25;
+ y1 = 1.-(1.+1.5*r3)*y2;
+ fac = 2.*r4;
+ } else {return;} }
+
+ if (y2 > 0.375 && y1 < 0.25) {
+ if (y2 > 1.-2.5*y1 && y2 < 1.-y1) {
+ y1 = r3*0.25;
+ y2 = 1.-(1.+1.5*r4)*y1;
+ fac = 2.*r3;
+ } else {return;}}}
+
+// Check if outside half-box */
+ if (2.-y1-y2 < 1.) {return;}
+
+
+
+ /*Inside jet 1? */
+ double w1 = 1.-y1;
+ double w2 = 1.-y2;
+ double tk = param[4];
+ double d1 = 0.25-(1.-w2)/tk;
+ double z,d2,xx;
+
+
+ if (d1 > 0.) {
+ z = 0.5+sqrt(d1);
+ d2 = pow(w2,2)-4.*param[0];
+ if (d2 > 0.) {
+ d2 = sqrt(d2);
+ double rr = 1.+param[0]/(1.-w2+param[0]);
+ xx = (rr*(2.-w2)+(2.*z-rr)*d2)/2.;
+ if (w1 < xx) {
+ z = 1.-z;
+ xx = (rr*(2.-w2)+(2.*z-rr)*d2)/2.;
+ if (w1 > xx) {return;}}}}
+
+ /*Inside jet 2? */
+
+ w1 = 1.-y2;
+ w2 = 1.-y1;
+ tk = param[5];
+ d1 = 0.25-(1.-w2)/tk;
+ if (d1 > 0.) {
+ z = 0.5+sqrt(d1);
+ d2 = pow(w2,2)-4.*param[0];
+ if (d2 > 0.) {
+ d2 = sqrt(d2);
+ double rr = 1.+param[0]/(1.-w2+param[0]);
+ xx = (rr*(2.-w2)+(2.*z-rr)*d2)/2.;
+ if (w1 < xx) {
+ z = 1.-z;
+ xx = (rr*(2.-w2)+(2.*z-rr)*d2)/2.;
+ if (w1 > xx) {return;}}}}
+ /* Outside Dalitz plot? */
+ if (y1*y2*(1.-y1-y2) < param[0]*pow((y1+y2),2)) { return;}
+
+ /* Calculate weights for dead region */
+ rx = 1.-y1;
+ ry = 1.-y2;
+ rwgt = (pow(1-rx,2) + pow(1-ry,2))/((1-rx)*(1-ry))+2.*(1.-param[1])*(rx+ry-1.-2.*param[1])/((1.-rx)*(1.-ry))+2.*param[1]*(1./(1.-rx)+1./(1.-ry))-param[1]*(1.-2.*param[1])*(1./pow(1-rx,2)+1./pow(1.-ry,2))+2.;
+ rwgt = rwgt*param[6]*param[8]*fac;
+ rwgt1 = (2.+2.*param[3]*param[6])*fac-rwgt;
+ /* Implement soft resolution cut */
+ if (resolve) {
+ if (rx+ry > 1.9999) {return;}}
+}
+ /*********************************************************************/
+ // In gap between phase space for massive partons and full half-triangle?
+
+void QQgsp(double r1, double r2, double r3,double r4, double &rx, double &ry, double param[8], double &rwgt,double &rwgt1, bool resolve) {
+
+ //Initialize weights and phase space points
+ rwgt = 0.;rwgt1 = 0.;
+
+ /*Remove 2-jet events */
+ double y1 = 1.-r1;
+ double y2 = 1.-r2;
+ if ((1.-y1)==1. && (1.-y2)==1.) {return;}
+ /* Check if outside half-box */
+ if (2.-y1-y2 <= 1.) {return;}
+
+/* Inside Dalitz plot? */
+ if (y1*y2*(1.-y1-y2) > param[0]*pow((y1+y2),2)) {return;}
+ /* Calculate weights */
+ rwgt1 = 2.+2.*param[3]*param[6];}
+
+ /*********************************************************************/
+// Random number generator.
+
+ double random (int &rseed) {
+ int M = 2147483647;
+ int A = 16807;
+ int Q = 127773;
+ int R = 2836;
+ double MINV = 0.46566128752458e-09;
+ int HI = rseed/Q;
+ int LO = rseed % Q;
+ rseed = A*LO - R*HI;
+ if (rseed < 0) {rseed = rseed + M;}
+ return rseed*MINV;}
+/*********************************************************************/
+double ddilog(double x)
+{
+ // The DiLogarithm function
+ // Code translated by R.Brun from CERNLIB DILOG function C332
+
+ const double hf = 0.5;
+ const double pi = 3.14152654;
+ const double pi2 = pi*pi;
+ const double pi3 = pi2/3;
+ const double pi6 = pi2/6;
+ const double pi12 = pi2/12;
+ const double c[20] = {0.42996693560813697, 0.40975987533077105,
+ -0.01858843665014592, 0.00145751084062268,-0.00014304184442340,
+ 0.00001588415541880,-0.00000190784959387, 0.00000024195180854,
+ -0.00000003193341274, 0.00000000434545063,-0.00000000060578480,
+ 0.00000000008612098,-0.00000000001244332, 0.00000000000182256,
+ -0.00000000000027007, 0.00000000000004042,-0.00000000000000610,
+ 0.00000000000000093,-0.00000000000000014, 0.00000000000000002};
+
+ double t,h,y,s,a,alfa,b1,b2,b0;
+
+ if (x == 1) {
+ h = pi6;
+ } else if (x == -1) {
+ h = -pi12;
+ } else {
+ t = -x;
+ if (t <= -2) {
+ y = -1/(1+t);
+ s = 1;
+ b1= log(-t);
+ b2= log(1+1/t);
+ a = -pi3+hf*(b1*b1-b2*b2);
+ } else if (t < -1) {
+ y = -1-t;
+ s = -1;
+ a = log(-t);
+ a = -pi6+a*(a+log(1+1/t));
+ } else if (t <= -0.5) {
+ y = -(1+t)/t;
+ s = 1;
+ a = log(-t);
+ a = -pi6+a*(-hf*a+log(1+t));
+ } else if (t < 0) {
+ y = -t/(1+t);
+ s = -1;
+ b1= log(1+t);
+ a = hf*b1*b1;
+ } else if (t <= 1) {
+ y = t;
+ s = 1;
+ a = 0;
+ } else {
+ y = 1/t;
+ s = -1;
+ b1= log(t);
+ a = pi6+hf*b1*b1;
+ }
+ h = y+y-1;
+ alfa = h+h;
+ b1 = 0;
+ b2 = 0;
+ for (int i=19;i>=0;i--){
+ b0 = c[i] + alfa*b1-b2;
+ b2 = b1;
+ b1 = b0;
+ }
+ h = -(s*(b0-h*b2)+a);
+ }
+ return h;
+}
+
+
+
+
+ /*********************************************************************/
+ /*********************************************************************/
+ /*********************************************************************/
diff --git a/Contrib/MCPWNLO/HIGGSDEC/MCHGPP.cxx b/Contrib/MCPWNLO/HIGGSDEC/MCHGPP.cxx
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/HIGGSDEC/MCHGPP.cxx
@@ -0,0 +1,1190 @@
+#include <cstdlib>
+#include <ctime>
+#include <iostream>
+#include <fstream>
+#include <string>
+//#include "LHAPDFWrap.h"
+//#include "/usera/seyi/lhapdf/include/LHAPDF/LHAPDF.h"
+#include "LHAPDF/LHAPDF.h"
+#include <iostream>
+#include <fstream>
+#include <stdio.h>
+#include "MCHGPP_INPUTS.h"
+#include <cmath>
+#include <iomanip>
+
+using namespace LHAPDF;
+using namespace std;
+
+// Checks if phase space point is in soft and collinear region?
+void QQgsc(double r1,double r2,double r3,double r4, double &rx, double &ry, double param[9], double &rwgt, double &rwgt1, bool resolve);
+// Checks if phase space point is in hard region?
+void QQgh(double r1,double r2,double r3,double r4, double &rx, double &ry, double param[9], double &rwgt, double &rwgt1, bool resolve);
+// Checks if phase space point is in gap between phase space for massive partons and full half-triangle?
+void QQgsp(double r1,double r2,double r3,double r4, double &rx, double &ry, double param[9], double &rwgt, double &rwgt1, bool resolve);
+// Dilogarithm Function
+double ddilog(double x);
+// Random number generator
+double random (int &rseed);
+
+// Main program
+
+int main() {
+ Input user;
+ int nev = user.nevint();
+ int nevg = user.nevgen();
+ int nit = user.it();
+ double emcm = user.cme();
+ double mH = user.mH();
+ int seed = user.rseed();
+ int proc = user.VBID(); /*process ID: Z production Z/gamma, W */
+ bool pp = user.pp(); /*type of accelerator */
+ bool resolve = user.resolve();
+ char* pdfset = user.PDFset(); /* PDF set */
+ int ii=0; //event count
+ // Constants
+ double pi = 3.14152654;
+ double GF = 0.0000116639;
+ double m = user.mb();
+ double Mw = user.Mw();
+ double Mz = user.Mz();
+ double Yz = 2.486;
+ double alphaem = 0.007297352;
+ double alphas = user.alphasmH();
+ //Lepton charge & coupling constants
+ double Che = -1;
+ double sin2thw = 0.2312;
+ double cos2thw = 1.-0.2312;
+ double Ae = -0.5;
+ double Ve = Ae-2.*Che*sin2thw;
+ double CLe = (Ae+Ve)/2.;
+ double CRe = (Ve-Ae)/2.;
+ double Mv = Mw;
+ if (proc == 23) {Mv = Mz;}
+ double gz2 = sqrt(32.)*GF*pow(Mv,2);
+ double e2 = 4.*pi*alphaem;
+ double k = sqrt(2.)*GF*pow(Mv,2)/e2;
+ double chi1 = k*pow(mH,2)*(pow(mH,2)-pow(Mv,2))/(pow((pow(mH,2)-pow(Mv,2)),2)+pow(Yz*Mv,2));
+ double chi2 = pow(k,2)*pow(Mv,4)/(pow((pow(Mv,2)-pow(Mv,2)),2)+pow(Yz*Mv,2));
+ //quark masses ,velocities and couplings. NB:gluon mass[10] =0.75
+ double mg, Ch[6];
+ mg = 0.75; // nominal gluon mass
+ Ch[1]=-1./3.; Ch[2]=2./3.; Ch[3]=Ch[1]; Ch[4]=Ch[2]; Ch[5]=Ch[1];
+
+/* w, w1 are the integrands. p,p1 are the corresponding integrals calculated from sum,sum1 & sd, sd1 are the corresponding errors
+ calculated via ssq, ssq1. bigwt is the maximum value of the integrand over the phase space (will be used for event generation) */
+
+ double wgt, wgt1;
+ double w[3],w1[3],bigwt[3],sum[3],sum1[3],ssq[3],ssq1[3],sd[3],sd1[3],p[3],p1[3];
+
+ sum1[0]=0.;sum1[1]=0.;sum[2]=0.;
+ sum1[0]=0.;sum1[1]=0.;sum1[2]=0.;
+ ssq[0]=0.;ssq[1]=0.;ssq[2]=0.;
+ ssq1[0]=0.;ssq1[1]=0.;ssq1[2]=0.;
+ bigwt[0]=0.;bigwt[1]=0.;bigwt[2]=0.;
+
+ cout << "Integrating..." << endl;
+
+ for (int d = 0; d < nev; d++) {
+ //Calculate Born cross-section
+
+// Parameters for NLO cross-section calculation.
+ double param[9];
+ param[0] = pow(m,2)/pow(mH,2);
+ param[1] = 2.*param[0];
+ param[2] = sqrt(1.-4.*param[0]); // beta
+ param[3] = (1.-pow(param[2],2))/param[2]*log((1.+param[2])/(1.-param[2]))+ (1.+pow(param[2],2))/param[2]*(4.*ddilog((1.-param[2])/(1.+param[2]))+2.*log((1.+param[2])/(2.*param[2]))*log((1.+param[2])/(1.-param[2]))+2.*ddilog((param[2]-1.)/(1.+param[2]))-log(2./(1.+param[2]))*log((1.+param[2])/(1.-param[2])))-3.*log(4./(1.-pow(param[2],2)))-4.*log(param[2])+1./(16.*pow(param[2],3))*(3.+18.*pow(param[2],2)+3.*pow(param[2],4))*log((1.+param[2])/(1.-param[2]))-3./8.*pow(param[2],2)+21./8.;
+ param[4] = 0.5*(1.+param[2]);
+ param[5] = (param[0]*param[4]+0.25*param[2]*pow(1+param[2],2))/(param[4]-param[0]);
+ param[6] = 4.*alphas/(3.*pi); // colour factor
+ param[7] = 3.*GF*pow(m,2)/(4.*sqrt(2)*pi)*mH*pow(param[2],3);
+ param[8] = 1./(2.*pow(param[2],3));
+
+ // Random numbers and phase space points x and y.
+ double r1=random(seed);
+ double r2=random(seed);
+ double r3=random(seed);
+ double r4=random(seed);
+ double x,y;
+ x = r1;
+ y = r2;
+ QQgsc(r1, r2, r3, r4, x, y, param, wgt, wgt1, resolve);
+ w[0] = wgt; w1[0]=wgt1;
+ QQgh(r1, r2, r3, r4, x, y, param, wgt, wgt1, resolve);
+ w[1] = wgt; w1[1]=wgt1;
+ QQgsp(r1, r2, r3, r4, x, y, param, wgt, wgt1, resolve);
+ w[2] = wgt; w1[2]=wgt1;
+
+ for (int iz = 0; iz < 3; iz++) {
+ if (abs(w[iz]) > abs(bigwt[iz])) {bigwt[iz] = w[iz];}
+ sum[iz]+=w[iz];
+ sum1[iz]+=w1[iz];
+ ssq[iz]+=pow(w[iz],2);
+ ssq1[iz]+=pow(w1[iz],2);
+
+}
+ cout << "Integrated event : " << "\t" << d+1 << "\t" << "of" << "\t" << nev << "\r" << flush;
+
+}
+ cout << endl;
+ double xsec=0;
+ double cstt=0;
+ double xsecabs = 0.;
+ for (int ic=0; ic<3; ic++) {
+ p[ic] = sum[ic]/nev;
+ p1[ic] = sum1[ic]/nev;
+ sd[ic] = sqrt((ssq[ic]/nev-pow(p[ic],2))/nev);
+ sd1[ic] = sqrt((ssq1[ic]/nev-pow(p1[ic],2))/nev);
+ xsec+=p[ic]+p1[ic];
+ xsecabs+=fabs(p[ic])+fabs(p1[ic]);
+ //Output to screen the integrals, errors and maximum weights
+ cout << "PHASE SPACE INTEGRALS:" << "\t" << p[ic] << "/" << p1[ic] <<"/" << sd[ic] <<"/" << sd1[ic]
+ <<"/" << bigwt[ic] << "\t" << xsec << endl;
+}
+
+
+ //*********************************************************************************
+ /*Les Houches Accord event parameters:: PUP are the momenta,
+ ICOLUP is the colour code, MOTHUP is the mother information, ISTUP is
+ the status code. ISPINUP signifies spins. IDUP is the particle ID.
+ NUP is the number of particles in the event. SCALUP is the scale of
+ the event.AQEDUP and AQCDUP are alphaem and alphas resp.XWGTUP is
+ the weight of the event=1 or -1 for unweighted events.*/
+
+ double PUP[6][11],AQEDUP,AQCDUP,XWGTUP,SCALUP;
+ int ICOLUP[3][11],MOTHUP[3][11],ISTUP[11],ISPINUP[11],IDUP[11],NUP;
+ NUP=0;
+ SCALUP = mH;
+ AQEDUP=0.007297352;
+ AQCDUP=alphas;
+ IDUP[4]=25;
+ IDUP[6]=5;
+ IDUP[7]=-5;
+ IDUP[10]=21;
+ MOTHUP[1][1]=0;
+ MOTHUP[1][2]=0;
+ MOTHUP[2][1]=0;
+ MOTHUP[2][2]=0;
+ MOTHUP[1][3]=1;
+ MOTHUP[2][3]=2;
+ MOTHUP[1][4]=3;
+ MOTHUP[2][4]=3;
+ MOTHUP[1][5]=3;
+ MOTHUP[2][5]=3;
+ MOTHUP[1][6]=4;
+ MOTHUP[2][6]=4;
+ MOTHUP[1][7]=4;
+ MOTHUP[2][7]=4;
+ MOTHUP[1][8]=5;
+ MOTHUP[2][8]=5;
+ MOTHUP[1][9]=5;
+ MOTHUP[2][9]=5;
+ MOTHUP[1][10]=4;
+ MOTHUP[2][10]=4;
+ ICOLUP[1][3]=0;
+ ICOLUP[2][3]=0;
+ ICOLUP[1][4]=0;
+ ICOLUP[2][4]=0;
+ ICOLUP[1][5]=0;
+ ICOLUP[2][5]=0;
+ ICOLUP[1][8]=0;
+ ICOLUP[2][8]=0;
+ ICOLUP[1][9]=0;
+ ICOLUP[2][9]=0;
+ ISTUP[1]=-1;
+ ISTUP[2]=-1;
+ ISTUP[3]=2;
+ ISTUP[4]=2;
+ ISTUP[5]=2;
+ ISTUP[6]=1;
+ ISTUP[7]=1;
+ ISTUP[8]=1;
+ ISTUP[9]=1;
+ ISTUP[10]=1;
+ //Allocate phase space region
+ double cst[3],bigwgt;
+ bigwgt=0.;
+ cst[0]=fabs(p[0])+fabs(p1[0]);
+ cst[1]=fabs(p[1])+fabs(p1[1]);
+ cst[2]=fabs(p[2])+fabs(p1[2]);
+ cstt = cst[0]+cst[1]+cst[2];
+
+ /*************************************************************************/
+
+ /* pdf routine. Calls external LHAPDF which calculates the
+ parton distribution functions*/
+ const int SUBSET = 0;
+ // const string NAME = "cteq4d.LHgrid";
+ setVerbosity(SILENT); // or LOWKEY
+
+ initPDFByName(pdfset, SUBSET);
+ // int subset = 0;
+ // char name[160];
+ // string byname = user.PDFset();
+ // // if (DIS) {
+ // // byname = "/usera/seyi/lhapdf-5.3.0/PDFsets/cteq5d.LHgrid";} else
+ // // {byname = "/usera/seyi/lhapdf-5.3.0/PDFsets/cteq5m.LHgrid";}
+ // strcpy(name,byname.c_str());
+ // LHAPDFWrap pdf = LHAPDFWrap();
+ // pdf.initPDFSet(name);
+ // pdf.initPDF(subset);
+
+ /*************************************************************************/
+ //cross-section estimator
+ /* Type of accelerator */
+ int sgn=1;
+ if (pp) {sgn=-1;}
+ double t0 = pow(Mv + mH,2)/pow(emcm,2);
+ double tcst = 0.;
+ double fwmax = 0.;
+ for (int ix =0; ix < 10000 ; ix++) {
+ t0 = pow((Mv+mH)/emcm,2);
+ double xq1 = random(seed)*(1.-t0)+t0;
+ double xq2 = random(seed)*(1.-t0/xq1) + t0/xq1;
+ double FW = 1./3.*(xfx(xq1,Mv+mH,2)*xfx(xq2,Mv+mH,sgn*1)+xfx(xq2,Mv+mH,-sgn*2)*xfx(xq1,Mv+mH,-1)+xfx(xq1,Mv+mH,-2)*xfx(xq2,Mv+mH,-sgn*1)+xfx(xq2,Mv+mH,sgn*2)*xfx(xq1,Mv+mH,1));
+ if (proc ==23){2./3.*((xfx(xq1,Mv+mH,1)*xfx(xq2,Mv+mH,sgn*1)+xfx(xq2,Mv+mH,-sgn*1)*xfx(xq1,Mv+mH,-1))*(1./4.-2./3.*sin2thw+8./9.*pow(sin2thw,2))+(xfx(xq1,Mv+mH,2)*xfx(xq2,Mv+mH,sgn*2)+xfx(xq2,Mv+mH,-sgn*2)*xfx(xq1,Mv+mH,-2))*(1./4.-1./3.*sin2thw+4./9.*pow(sin2thw,2)));}
+ double s2s = xq1*xq2*pow(emcm,2);
+ double betav = sqrt((s2s-pow(Mv+mH,2))*(s2s-pow(Mv-mH,2)))/(s2s-pow(mH,2)+pow(Mv,2));
+ double gammav = 1./sqrt(1.-pow(betav,2));
+ // double fw = 1./s2s*sqrt(1.-pow(Mv+mH,2)/s2s)*sqrt(1.-pow(Mv-mH,2)/s2s)*((1.-(Mv+mH,2)/s2s)*(1.-(Mv-mH,2)/s2s)+12.*pow(Mv,2)/s2s)*(1./pow(1.-Mv/s2s,2));
+ double fw = 1./sqrt(pow(s2s,3))*betav*gammav*pow((s2s+pow(Mv,2) - pow(mH,2))/(s2s-pow(Mv,2)),2)*(1.-2.*pow(betav,2)/3.);
+ double fww =1./sqrt(pow(s2s,3))*betav*gammav*pow((s2s+pow(Mv,2) - pow(mH,2))/(s2s-pow(Mv,2)),2)*(2.*(1-pow(betav,2))+pow(betav,2));
+ tcst += pow(GF*Mw,2)*pow(Mv,3)/(4.*pi*cos2thw)*FW*fw;
+ if (fww > fwmax) {fwmax = fww;}
+ }
+ tcst = tcst/10000.*fabs(1.-1./t0)*389400000.;
+
+ /*************************************************************************/
+ ofstream outdata;
+ outdata.open("PPVH.dat", ios::trunc);//output for events
+ outdata << "<LesHouchesEvents version =\"1.0\">" << endl; outdata << "<!--" << endl;
+ outdata << "IPROC = " <<"\t" << proc << endl;
+ outdata << "NORMFACTOR = " << "\t" << xsecabs/xsec << endl;
+ outdata << "MC@NLO W+Higgs boson production" <<endl ;
+ outdata << "File generated with MCHGPP.cxx" << endl; outdata << "-->" << endl;
+ outdata << "<init>" << endl;
+ outdata << "\t2212\t" << "-2212\t" ;
+ outdata << emcm/2. << "\t" << emcm/2. << "\t" << "0 \t 0 \t 7\t 7 \t 3 \t 1" << endl;
+ outdata << "\t" << tcst << "\t" << 0.000000 << "\t1.00000 \t11" << endl; outdata << "</init>" << endl;
+
+
+ cout << "Generating events..." << endl;
+
+
+ for (int d = 0; d < nevg; d++) {
+ int Jt; //phase space identifier
+ if (random(seed) < cst[0]/cstt) {
+ if (random(seed) < fabs(p[0])/cst[0]) {
+ Jt=1; bigwgt=bigwt[0];} else
+ {Jt=2;}} else
+ if (random(seed) < cst[1]/(cst[1]+cst[2])) {
+ if (random(seed) < fabs(p[1])/cst[1]) {
+ Jt=3; bigwgt=bigwt[1];} else
+ {Jt=4;}} else
+ {Jt=5;}
+
+ /*************************************************************************/
+ int ID = 5;
+ // Parameters for NLO cross-section calculation.
+ double param[9];
+ param[0] = pow(m,2)/pow(mH,2);
+ param[1] = 2.*param[0];
+ param[2] = sqrt(1.-4.*param[0]); // beta
+ param[3] = (1.-pow(param[2],2))/param[2]*log((1.+param[2])/(1.-param[2]))+ (1.+pow(param[2],2))/param[2]*(4.*ddilog((1.-param[2])/(1.+param[2]))+2.*log((1.+param[2])/(2.*param[2]))*log((1.+param[2])/(1.-param[2]))+2.*ddilog((param[2]-1.)/(1.+param[2]))-log(2./(1.+param[2]))*log((1.+param[2])/(1.-param[2])))-3.*log(4./(1.-pow(param[2],2)))-4.*log(param[2])+1./(16.*pow(param[2],3))*(3.+18.*pow(param[2],2)+3.*pow(param[2],4))*log((1.+param[2])/(1.-param[2]))-3./8.*pow(param[2],2)+21./8.;
+ param[4] = 0.5*(1.+param[2]);
+ param[5] = (param[0]*param[4]+0.25*param[2]*pow(1+param[2],2))/(param[4]-param[0]);
+ param[6] = 4.*alphas/(3.*pi); // colour factor
+ param[7] = 3.*GF*pow(m,2)/(4.*sqrt(2)*pi)*mH*pow(param[2],3);
+ param[8] = 1./(2.*pow(param[2],3));
+
+
+
+
+ //Momenta of incoming particles and W, W* boson
+ double ctheta, yy, Mb, xq, xqb, MVH, Ev, Eh, pv, S, S2;
+ S = emcm;
+ S2 = pow(S,2);
+ double Qmin = Mv + mH;
+ double xqc=sqrt(pow(Qmin,2)/S2);
+ double fvmax=0.;
+
+ /*Define the coupling constants. */
+ /*Define the coupling constants. */
+ double v[6],a[6],va[6];
+ double sin2thw=0.2312;
+ v[1]=-0.5+(2./3.)*sin2thw;
+ v[2]=0.5-(4./3.)*sin2thw;
+ v[3]=v[1];v[4]=v[2];v[5]=v[1];a[1]=0.5;a[2]=-0.5;a[3]=a[1];a[4]=a[2];a[5]=a[1];
+ for (int ij=1; ij <6;ij++) {
+ va[ij]=(pow(v[ij],2)+pow(a[ij],2));}
+ double vq[7] ;
+ vq[1]=0.952; vq[2]=0.049; vq[3]=0.952;
+ vq[4]=0.00168; vq[5]=0.049; vq[6]=0.00001063;
+
+ /*************************************************************************/
+
+
+ /*PDF terms. [fq1,fq2] and [fqb1,fqb2] are pdfs for quarks from hadrons [1,2]
+ and antiquarks from hadrons [1,2] resp. ffq1 and ffq2 are the
+ 2 combinations of the products of the Born process pdfs.*/
+
+ double fv, fv1,fv2,fq1[7],fq2[7],fqb1[7],fqb2[7], Q;
+ fv1 =0.; fv2 =0.;
+ if (proc == 24) {
+ for(int id=1; id<5; id++) {
+ fvmax+=2.*(xfx(xqc,Qmin,id)*xfx(xqc,Qmin,sgn*(id+1))+xfx(xqc,Qmin,-id)*xfx(xqc,Qmin,-sgn*(id+1)))*vq[id]/(xqc*xqc);}
+ for(int id=1; id<3; id++) {
+ fvmax+=2.*(xfx(xqc,Qmin,id)*xfx(xqc,Qmin,sgn*(id+3))+xfx(xqc,Qmin,-id)*xfx(xqc,Qmin,-sgn*(id+3)))*vq[id+4]/(xqc*xqc);}}
+ if (proc==23) {
+ for(int id=1; id<6; id++) {
+ fvmax+=(xfx(xqc,Qmin,id)*xfx(xqc,Qmin,sgn*id)+xfx(xqc,Qmin,-id)*xfx(xqc,Qmin,-sgn*id))*(pow(v[id],2)+pow(a[id],2))/(xqc*xqc);}}
+ // Mbmax = (pow(-pow(mH,2)-2.*pow(Mv,2),2)+pow(Mv,2)*(pow(mH,2)+pow(Mv,2)))*sqrt(pow(pow(mH,2)+pow(Mv,2),2) + pow(mH,4)+pow(Mv,4))/(pow(mH,4)*pow(Mv,2)*pow(pow(mH,2)+pow(Mv,2),2));
+ do {
+
+ // xx = random(seed);
+ // yy = 2.*random(seed)-1.;
+ // ss = (pow(mH,2)+pow(Mv,2))/xx;
+ // ll = ss*(ss+pow(Mv,4)/ss+pow(mH,4)/ss-(2.*pow(Mv,2)*pow(mH,2)/ss+2.*pow(mH,2)+2.*pow(Mv,2)));
+ // tt = -ss/2.*(1.-xx - sqrt(ll)*yy/ss);
+ // uu = -ss/2.*(1.-xx + sqrt(ll)*yy/ss);
+ // Mb = (sqrt(ll)*(tt-pow(Mv,2))*(uu-pow(Mv,2))+pow(Mv,2)*ss)/(pow(ss-pow(Mv,2),2)*pow(Mv,2)*pow(ss,2));
+ // Ew = (ss+pow(Mv,2)-pow(mH,2))/(2.*sqrt(ss));
+ // pw = sqrt(ll)/(2.*sqrt(ss));
+ // Eh = sqrt(pow(pw,2)+pow(mH,2));
+ // MWH = Ew+Eh;
+ // Q = MWH;
+ // if (ll > 0. && MWH < S) {
+ // do {
+ // yz = 6.*random(seed) - 3.0 ; //rapidity range -3:3
+
+ //xq=sqrt(pow(MWH,2)/S2)*exp(yz);
+ // xqb=sqrt(pow(MWH,2)/S2)*exp(-yz);
+ // } while (xq > 1. || xqb > 1.);}
+ double tau = pow((Mv+mH)/emcm, 2);
+ ctheta = 2.*random(seed)-1.;
+ do {
+ xq = random(seed)*(1.-tau) + tau;
+ xqb = random(seed)*(1.-tau/xq) +tau/xq;
+ } while(fabs(0.5*log(xq/xqb)) > 3.);
+ yy = xq*xqb*pow(emcm,2);
+ double betav = sqrt((yy-pow(Mv+mH,2))*(yy-pow(Mv-mH,2)))/(yy-pow(mH,2)+pow(Mv,2)) ;
+ double gammav = 1./sqrt(1.-pow(betav,2));
+ Mb = (betav*gammav)/sqrt(pow(yy,3))*pow((yy+pow(Mv,2)-pow(mH,2))/(yy-pow(Mv,2)),2)*(2.*(1.-pow(betav,2))+pow(betav,2)*(1.-pow(ctheta,2)));
+ Ev = (yy+pow(Mv,2)-pow(mH,2))/(2.*sqrt(yy));
+ pv = sqrt(pow(Ev,2) - pow(Mv,2));
+ Eh = sqrt(pow(pv,2)+pow(mH,2));
+ MVH = Ev+Eh;
+ Q = MVH;
+ if (proc==23) {
+ for (int e=1; e<6; e++) {
+ fq1[e] = xfx(xq,Q,e);
+ fqb2[e]= xfx(xqb,Q,sgn*e);
+ fqb1[e] =xfx(xq,Q,-e);
+ fq2[e] = xfx(xqb,Q,-sgn*e);
+ fv1 += va[e]*fq1[e]*fqb2[e];
+ fv2 += va[e]*fqb1[e]*fq2[e];
+ }} else if(proc==24){
+ for(int e=1; e<5; e++) {
+ fq1[e] = xfx(xq,Q,e)*xfx(xqb,Q,sgn*(e+1))+xfx(xq,Q,-e)*xfx(xqb,Q,-sgn*(e+1))+xfx(xqb,Q,sgn*e)*xfx(xq,Q,e+1)+xfx(xqb,Q,-sgn*e)*xfx(xq,Q,-(e+1));}
+ int ee=1;
+ for(int e=5; e<7; e++) {fq1[e] = xfx(xq,Q,ee)*xfx(xqb,Q,sgn*(ee+3))+xfx(xq,Q,-ee)*xfx(xqb,Q,-sgn*(ee+3))+xfx(xqb,Q,sgn*ee)*xfx(xq,Q,ee+3)+xfx(xqb,Q,-sgn*ee)*xfx(xq,Q,-(ee+3));
+ ee+=1;}
+ for (int e=1; e<7; e++) {
+ fv1 += vq[e]*fq1[e];
+ fv2 = 0;}}
+ fv = (fv1 + fv2)/(xq*xqb);
+ } while (random(seed) > fv*Mb/(fvmax*fwmax));
+
+ // Distributing the Vector boson and H momenta
+
+ PUP[4][1]=xq*S/2.;
+ PUP[1][1]=0.;
+ PUP[2][1]=0.;
+ PUP[3][1]=xq*S/2.;
+ PUP[4][2]=xqb*S/2.;
+ PUP[1][2]=0.;
+ PUP[2][2]=0.;
+ PUP[3][2]=-xqb*S/2.;
+ PUP[4][3]=PUP[4][1]+PUP[4][2];
+ PUP[1][3]=0.;
+ PUP[2][3]=0.;
+ PUP[3][3]=PUP[3][1]+PUP[3][2];
+ // Still in parton C.O.M
+ double phi3 = 2.*random(seed)*pi;
+ PUP[4][5]=Ev;
+ PUP[1][5]=pv*sin(acos(ctheta))*cos(phi3);
+ PUP[2][5]=pv*sin(acos(ctheta))*sin(phi3);
+ PUP[3][5]=pv*ctheta;
+ PUP[4][4]=Eh;
+ PUP[1][4]=-PUP[1][5];
+ PUP[2][4]=-PUP[2][5];
+ PUP[3][4]=-PUP[3][5];
+ // Boost to lab frame
+ double vv = PUP[3][3]/PUP[4][3];
+ PUP[4][5] = (Ev + vv*PUP[3][5])/sqrt(1.-pow(vv,2));
+ PUP[3][5] = (PUP[3][5] + vv*Ev)/sqrt(1.-pow(vv,2));
+ PUP[4][4] = (Eh + vv*PUP[3][4])/sqrt(1.-pow(vv,2));
+ PUP[3][4] = (PUP[3][4] + vv*Eh)/sqrt(1.-pow(vv,2));
+
+
+ /*************************************************************************/
+
+
+ /*PDF terms. [fq1,fq2] and [fqb1,fqb2] are pdfs for quarks from hadrons [1,2]
+ and antiquarks from hadrons [1,2] resp. ffq1 and ffq2 are the
+ 2 combinations of the products of the Born process pdfs.*/
+
+ fv1 = 0;
+ double ffq1[7], ffq2[7];
+ if (proc==23) {
+ for (int e=1; e<6; e++) {
+ fq1[e] = xfx(xq,Q,e);
+ fqb2[e]= xfx(xqb,Q,sgn*e);
+ fqb1[e] =xfx(xq,Q,-e);
+ fq2[e] = xfx(xqb,Q,-sgn*e);
+ ffq1[e] = fq1[e]*fqb2[e];
+ ffq2[e] = fqb1[e]*fq2[e];
+
+ fv1 += va[e]*ffq1[e];
+ fv2 += va[e]*ffq2[e];
+ }} else if (proc==24) {
+ for(int e=1; e<5; e++) {
+ fq1[e] = xfx(xq,Q,e)*xfx(xqb,Q,sgn*(e+1))+xfx(xq,Q,-e)*xfx(xqb,Q,-sgn*(e+1))+xfx(xqb,Q,sgn*e)*xfx(xq,Q,e+1)+xfx(xqb,Q,-sgn*e)*xfx(xq,Q,-(e+1));
+ }
+ int ee=1;
+ for(int e=5; e<7; e++) {
+ fq1[e] = xfx(xq,Q,ee)*xfx(xqb,Q,sgn*(ee+3))+xfx(xq,Q,-ee)*xfx(xqb,Q,-sgn*(ee+3))+xfx(xqb,Q,sgn*ee)*xfx(xq,Q,(ee+3))+xfx(xqb,Q,-sgn*ee)*xfx(xq,Q,-(ee+3));
+ ee+=1;}
+ for (int e=1; e<7; e++) {
+ fv1 += vq[e]*fq1[e];
+ fv2 = 0;}}
+
+ /* Select incoming parton IDs */
+ int ID1, ID2, IDD[3];
+ ID1 = 0; ID2 =0;
+ double g1= 0 ;
+ double g2 = 0;
+ double g = 0;
+ if (proc==23) {
+
+ if (fv1 !=0 ) {
+ if (random(seed)< va[1]*ffq1[1]/fv1) {g1 = va[1]*ffq1[1];
+ ID1 = 1;}
+ else if (random(seed) < va[2]*ffq1[2]/(fv1-va[1]*ffq1[1])) {g1 = va[2]*ffq1[2];
+ ID1 = 2;}
+ else if (random(seed) < va[3]*ffq1[3]/(fv1-va[1]*ffq1[1]-va[2]*ffq1[2])) {g1 = va[3]*ffq1[3];
+ ID1 = 3;}
+ else if (random(seed) < va[4]*ffq1[4]/(va[4]*ffq1[4]+va[5]*ffq1[5])) {g1 = va[4]*ffq1[4];
+ ID1 = 4;}
+ else {g1 = va[5]*ffq1[5];
+ ID1 = 5;}}
+ if (fv2 !=0 ) {
+ if (random(seed) < va[1]*ffq2[1]/fv2) {g2 = va[1]*ffq2[1];
+ ID2 = -1;}
+ else if (random(seed) < va[2]*ffq2[2]/(fv2-va[1]*ffq2[1])) {g2 = va[2]*ffq2[2];
+ ID2 = -2;}
+ else if (random(seed) < va[3]*ffq2[3]/(fv2-va[1]*ffq2[1]-va[2]*ffq2[2])) {g2 = va[3]*ffq2[3];
+ ID2 = -3;}
+ else if (random(seed) < va[4]*ffq2[4]/(va[4]*ffq2[4]+va[5]*ffq2[5])) {g2 = va[4]*ffq2[4];
+ ID2 = -4;}
+ else {g2 = va[5]*ffq2[5];
+ ID2 = -5;}}
+ if (random(seed)< g1/(g1+g2)) {g = g1;
+ IDD[0] = ID1; IDD[1] = -ID1;}
+ else {g = g2;
+ IDD[0] = ID2; IDD[1]= -ID2; }} else if(proc == 24) {
+
+ if (random(seed) < vq[1]*fq1[1]/fv1) {g1=vq[1]*fq1[1];
+ ID1=1;}
+ else if (random(seed) < vq[2]*fq1[2]/(fv1-vq[1]*fq1[1])) {g1 = vq[2]*fq1[2];
+ ID1 = 2;}
+ else if (random(seed) < vq[3]*fq1[3]/(fv1-vq[1]*fq1[1]-vq[2]*fq1[2])) {g1 = vq[3]*fq1[3];
+ ID1 = 3;}
+ else if (random(seed) < vq[4]*fq1[4]/(vq[4]*fq1[4]+vq[5]*fq1[5]+vq[6]+fq1[6])) {g1 = vq[4]*fq1[4];
+ ID1 = 4;}
+ else if (random(seed) < vq[5]*fq1[5]/(vq[5]*fq1[5]+vq[6]*fq1[6])) {g1 = vq[5]*fq1[5];
+ ID1 = 5;}
+ else {g1 = vq[6]*fq1[6];
+ ID1 = 6;}
+ if(ID1 < 5) {
+ if (random(seed) < xfx(xq,Q,ID1)*xfx(xqb,Q,sgn*(ID1+1))/fq1[ID1]) {
+ IDD[0]=ID1;IDD[1]=-(ID1+1);}
+ else if (random(seed) < xfx(xq,Q,-ID1)*xfx(xqb,Q,-sgn*(ID1+1))/(fq1[ID1]-xfx(xq,Q,ID1)*xfx(xqb,Q,sgn*(ID1+1)))) {IDD[0]=-ID1;IDD[1]=ID1+1;}
+ else if (random(seed) < xfx(xq,Q,ID1+1)*xfx(xqb,Q,sgn*ID1)/(xfx(xq,Q,ID1+1)*xfx(xqb,Q,sgn*ID1)+xfx(xq,Q,-(ID1+1))*xfx(xqb,Q,-sgn*ID1))) {IDD[0]=ID1+1;IDD[1]=-ID1;}
+ else {IDD[0]=-(ID1+1);IDD[1]=ID1;} }
+
+ if (ID1 > 4) {
+ if (random(seed) < xfx(xq,Q,ID1-1)*xfx(xqb,Q,sgn*(ID1-4))/fq1[ID1]) {IDD[0]=ID1-1;IDD[1]=-(ID1-4);}
+ else if (random(seed) < xfx(xq,Q,-(ID1-1))*xfx(xqb,Q,-sgn*(ID1-4))/(fq1[ID1]-xfx(xq,Q,ID1-1)*xfx(xqb,Q,sgn*(ID1-4)))) {IDD[0]=-(ID1-1);IDD[1]=ID1-4;}
+ else if (random(seed) < xfx(xq,Q,ID1-4)*xfx(xqb,Q,sgn*(ID1-1))/(xfx(xq,Q,ID1-4)*xfx(xqb,Q,sgn*(ID1-1))+xfx(xq,Q,-(ID1-4))*xfx(xqb,Q,-sgn*(ID1-1))))
+ {IDD[0]=ID1-4;IDD[1]=-(ID1-1);}
+ else {IDD[0]=-(ID1-4);IDD[1]=ID1-1;} }}
+
+ //set flavour and masses of process
+ double mass[10];
+ mass[1]=0.;
+ mass[2]=0.;
+ mass[3]=MVH;
+ mass[4]=mH;
+ mass[5]=Mv;
+ mass[8]=0.;
+ mass[9]=0.;
+ //quark IDs
+ IDUP[6] = ID;
+ IDUP[7] = -ID;
+ IDUP[1] = IDD[0];
+ IDUP[2] = IDD[1];
+ ICOLUP[1][2] =503;
+ ICOLUP[2][2] =0;
+ ICOLUP[1][1] =0;
+ ICOLUP[2][1] =503;
+ if (IDUP[1] > 0) {
+ ICOLUP[1][1] =503;
+ ICOLUP[2][1] =0;
+ ICOLUP[1][2] =0;
+ ICOLUP[2][2] =503;
+}
+
+ double cth2, cofac, maxcofac;
+ if (proc == 24) {
+ do {cth2=2.*random(seed)-1.;
+ cofac=pow(1.+cth2,2);
+ maxcofac=4.;} while(random(seed) > cofac/maxcofac);
+
+ IDUP[3] = -24;
+ IDUP[5] = -24;
+ IDUP[8] = 11;
+ IDUP[9] = -12;
+ if (IDD[0]==-1||IDD[0]==-3||IDD[0]==-5 ||IDD[0]==2||IDD[0]==4){
+ IDUP[3]=24;
+ IDUP[5] =24;
+ IDUP[8] = -11;
+ IDUP[9] = 12;
+
+ cth2=-cth2;
+}} else if (proc==23) {
+ IDUP[3]=23;
+ IDUP[5]=23;
+ IDUP[8]=11;
+ IDUP[9]=-11;
+ do
+ {cth2=2.*random(seed)-1.;
+ cofac = 1.+pow(cth2,2);
+ maxcofac = 2.;}while(random(seed) > cofac/maxcofac);
+ }
+
+ double phi2=2.*pi*random(seed);
+ //Assign 4-momenta in boson rest frame
+ PUP[3][9] = Mv*cth2/2.;
+ PUP[1][9] = sqrt(pow(Mv/2.,2)-pow(PUP[3][9],2))*cos(phi2);
+ PUP[2][9] = sqrt(pow(Mv/2.,2)-pow(PUP[3][9],2))*sin(phi2);
+ PUP[1][8] = -PUP[1][9];
+ PUP[2][8] = -PUP[2][9];
+ PUP[3][8] = -PUP[3][9];
+ PUP[4][8] = Mv/2.;
+ PUP[4][9] = Mv/2.;
+
+ double vv2 = sqrt(pow(PUP[4][5],2)-pow(Mv,2))/PUP[4][5];
+ PUP[4][9]=(Mv/2.-vv2*PUP[3][9])/sqrt(1.-pow(vv2,2));
+ PUP[3][9]=(PUP[3][9]-Mv*vv2/2.)/sqrt(1.-pow(vv2,2));
+ PUP[4][8]=(Mv/2.-vv2*PUP[3][8])/sqrt(1.-pow(vv2,2));
+ PUP[3][8]=(PUP[3][8]-Mv*vv2/2.)/sqrt(1.-pow(vv2,2));
+ double ktt1=-sqrt(pow(PUP[4][9],2)-pow(PUP[3][9],2));
+ double ktt2=sqrt(pow(PUP[4][8],2)-pow(PUP[3][8],2));
+ double kt = sqrt(pow(PUP[1][5],2)+pow(PUP[2][5],2));
+ double tht=atan2(kt,PUP[3][5]);
+ double pe1=PUP[4][9];
+ double pe2=PUP[4][8];
+ double pz1=PUP[3][9];
+ double pz2=PUP[3][8];
+ PUP[4][9]=pe2;
+ PUP[4][8]=pe1;
+ PUP[3][9]=-(pz2*cos(tht)+ktt2*sin(tht));
+ PUP[3][8]=-(pz1*cos(tht)+ktt1*sin(tht));
+ PUP[1][9]=-(pz2*sin(tht)-ktt2*cos(tht))*cos(phi3);
+ PUP[2][9]=-(pz2*sin(tht)-ktt2*cos(tht))*sin(phi3);
+ PUP[1][8]=-(pz1*sin(tht)-ktt1*cos(tht))*cos(phi3);
+ PUP[2][8]=-(pz1*sin(tht)-ktt1*cos(tht))*sin(phi3);
+ if (random(seed) < 0.5) {
+ PUP[4][9]=pe1;
+ PUP[4][8]=pe2;
+ PUP[3][9]=-(pz1*cos(tht)+ktt1*sin(tht));
+ PUP[3][8]=-(pz2*cos(tht)+ktt2*sin(tht));
+ PUP[1][9]=-(pz1*sin(tht)-ktt1*cos(tht))*cos(phi3);
+ PUP[2][9]=-(pz1*sin(tht)-ktt1*cos(tht))*sin(phi3);
+ PUP[1][8]=-(pz2*sin(tht)-ktt2*cos(tht))*cos(phi3);
+ PUP[2][8]=-(pz2*sin(tht)-ktt2*cos(tht))*sin(phi3);
+ }
+
+
+// phase space point x1,x2
+ double x1,x2;
+ double wt; //event weight
+ wt = 0.;
+ bool qg = true;
+ double cth,pcm;
+ cth=0.;pcm=0.;
+ if (Jt==1||Jt==3) {
+ double c13, c23, x3;
+ do {
+ // Random numbers
+ double r1=random(seed);
+ double r3=random(seed);
+ double r4=random(seed);
+ double r2=random(seed);
+ x1 = r1;
+ x2 = r2;
+ if (Jt==1) {
+ QQgsc(r1, r2, r3, r4, x1, x2, param, wgt, wgt1, resolve);
+ wt = wgt;}
+ if (Jt==3) {
+ QQgh(r1, r2, r3, r4, x1, x2, param, wgt, wgt1, resolve);
+ wt = wgt;}
+ x3=2.-x1-x2;
+ c13=(x1*x3-2.*(1.-x2))/(sqrt(pow(x1,2)-4.*param[0])*x3);
+ c23=(x2*x3-2.*(1.-x1))/(sqrt(pow(x2,2)-4.*param[0])*x3);
+ } while (random(seed) > fabs(wt)/fabs(bigwgt) || isinf(c13) || isinf(c23));
+
+ if (Jt==1){wt=-1.;}
+ if (Jt==3){wt=1.;}
+ double cf,ct, ppt;
+ double px1 = sqrt(pow(0.5*mH*x1,2)-pow(m,2));
+ double px2 = sqrt(pow(0.5*mH*x2,2)-pow(m,2));
+ double px3 = sqrt(pow(0.5*mH*x3,2));
+
+
+ do {cth = 2.*random(seed)-1.;
+ if (random(seed) < pow(x1,2)/(pow(x1,2)+pow(x2,2))) {
+ cf = (px2*c23+px3)/px1; ct = (px1-px3*cf)/px2; }else
+ {cf = (px1*c13+px3)/px2; ct = (px2-px3*cf)/px1; qg=false;}
+ } while (ct > 1. || cf > 1.);
+ double phi = 2.*pi*random(seed);
+ double phi2 = 2.*pi*random(seed);
+ if (qg) {
+ pcm = px1;
+ PUP[3][6]=px1*cth;
+ double pt = sqrt(pow(px1,2)-pow(PUP[3][6],2));
+ PUP[1][6]=pt*cos(phi);
+ PUP[2][6]=pt*sin(phi);
+ MOTHUP[1][10] = 4;
+ MOTHUP[2][10] = 4;
+ double ppl = px2*ct;
+ if (random(seed) < 0.5) {
+ ppt = sqrt (pow(px2,2)-pow(ppl,2));}else {ppt = -sqrt (pow(px2,2)-pow(ppl,2));}
+ double ppt1 = ppt*cos(phi2);
+ double ppt2 = ppt*sin(phi2);
+ PUP[3][7]=-(ppl*cth-ppt1*sin(acos(cth)));
+ PUP[1][7]=-((ppl*sin(acos(cth))+ppt1*cth)*cos(phi)-ppt2*sin(phi));
+ PUP[2][7]=-((ppl*sin(acos(cth))+ppt1*cth)*sin(phi)+ppt2*cos(phi));}
+ else {
+ pcm = px2;
+ PUP[3][7]=px2*cth;
+ double pt = sqrt(pow(px2,2)-pow(PUP[3][7],2));
+ PUP[1][7]=pt*cos(phi);
+ PUP[2][7]=pt*sin(phi);
+ MOTHUP[1][10] = 4;
+ MOTHUP[2][10] = 4;
+ double ppl = px1*ct;
+ if (random(seed) < 0.5) {
+ ppt = sqrt (pow(px1,2)-pow(ppl,2));}else {ppt = -sqrt (pow(px1,2)-pow(ppl,2));}
+ double ppt1 = ppt*cos(phi2);
+ double ppt2 = ppt*sin(phi2);
+ PUP[3][6]=-(ppl*cth-ppt1*sin(acos(cth)));
+ PUP[1][6]=-((ppl*sin(acos(cth))+ppt1*cth)*cos(phi)-ppt2*sin(phi));
+ PUP[2][6]=-((ppl*sin(acos(cth))+ppt1*cth)*sin(phi)+ppt2*cos(phi));}
+
+ PUP[3][10]= -PUP[3][6] - PUP[3][7];
+ PUP[1][10]= -PUP[1][6] - PUP[1][7];
+ PUP[2][10]= -PUP[2][6] - PUP[2][7];
+ PUP[4][6] = x1*mH/2.;
+ PUP[4][7] = x2*mH/2.;
+ PUP[4][10] = x3*mH/2.;
+
+ //colour info
+ ICOLUP[1][6] = 501;
+ ICOLUP[2][6] = 0;
+ ICOLUP[1][7] = 0;
+ ICOLUP[2][7] = 502;
+ ICOLUP[1][10] = 502;
+ ICOLUP[2][10] = 501;
+ //Number of particles
+ NUP=10;
+
+ }
+
+ if (Jt==2||Jt==4||Jt==5) {
+ x1 = 1.;x2 = 1.; wt = 1.;
+ pcm = sqrt(pow(0.5*mH,2)-pow(m,2));
+ cth = 2.*random(seed)-1.;
+ double phi = 2.*random(seed)*pi;
+ PUP[3][6] = pcm*cth;
+ PUP[1][6] = sqrt(pow(pcm,2)-pow(PUP[3][6],2))*cos(phi);
+ PUP[2][6] = sqrt(pow(pcm,2)-pow(PUP[3][6],2))*sin(phi);
+ PUP[1][7] = -PUP[1][6];
+ PUP[2][7] = -PUP[2][6];
+ PUP[3][7] = -PUP[3][6];
+ PUP[4][6] = mH/2.;
+ PUP[4][7] = mH/2.;
+ PUP[4][10]=0.;
+ PUP[3][10]=0.;
+ PUP[1][10]=0.;
+ PUP[2][10]=0.;
+ //colour info
+ ICOLUP[1][6] = 501;
+ ICOLUP[2][6] = 0;
+ ICOLUP[1][7] = 0;
+ ICOLUP[2][7] = 501;
+ //Number of particles
+ NUP=9;
+ }
+ double alpha = 1.;
+
+ //boost masses if needed. Need to boost to nominal gluon mass always.
+ double mb = m;
+ double Eq,Eqb,Eg;
+ double pq = sqrt(pow(PUP[1][6],2)+pow(PUP[2][6],2)+pow(PUP[3][6],2));
+ double pqb = sqrt(pow(PUP[1][7],2)+pow(PUP[2][7],2)+pow(PUP[3][7],2));
+ double pg = sqrt(pow(PUP[1][10],2)+pow(PUP[2][10],2)+pow(PUP[3][10],2));
+ for (int ix=1; ix < nit+1; ix++) {
+ Eq = sqrt(pow(mb,2)+alpha*pow(pq,2));
+ Eqb = sqrt(pow(mb,2)+alpha*pow(pqb,2));
+ if (NUP == 9) {mg = 0.;} else {mg =0.75;}
+ Eg = sqrt(pow(mg,2)+alpha*pow(pg,2));
+ if (NUP==10) {
+ alpha = alpha+(2.*(mH-Eq-Eqb-Eg))/(pow(pq,2)/Eq+pow(pqb,2)/Eqb+pow(pg,2)/Eg);}
+ else {alpha = alpha+(2.*(mH-Eq-Eqb))/(pow(pq,2)/Eq+pow(pqb,2)/Eqb);}
+ }
+
+ PUP[1][6] =sqrt(alpha)*PUP[1][6];
+ PUP[2][6] =sqrt(alpha)*PUP[2][6];
+ PUP[3][6] =sqrt(alpha)*PUP[3][6];
+ PUP[4][6] =Eq;
+ PUP[1][7] =sqrt(alpha)*PUP[1][7];
+ PUP[2][7] =sqrt(alpha)*PUP[2][7];
+ PUP[3][7] =sqrt(alpha)*PUP[3][7];
+ PUP[4][7] =Eqb;
+ PUP[1][10] =sqrt(alpha)*PUP[1][10];
+ PUP[2][10] =sqrt(alpha)*PUP[2][10];
+ PUP[3][10] =sqrt(alpha)*PUP[3][10];
+ PUP[4][10] =Eg;
+ // boost to lab frame
+ double Eqq = PUP[4][6] ; double Eqqb = PUP[4][7] ; double Eggg= PUP[4][10];
+ vv2 = sqrt(pow(PUP[4][4],2)-pow(mH,2))/PUP[4][4];
+ PUP[4][6]=(Eqq - vv2*PUP[3][6])/sqrt(1.-pow(vv2,2));
+ PUP[3][6]=(PUP[3][6]-Eqq*vv2)/sqrt(1.-pow(vv2,2));
+ PUP[4][7]=(Eqqb-vv2*PUP[3][7])/sqrt(1.-pow(vv2,2));
+ PUP[3][7]=(PUP[3][7]-Eqqb*vv2)/sqrt(1.-pow(vv2,2));
+ PUP[4][10]=(Eggg-vv2*PUP[3][10])/sqrt(1.-pow(vv2,2));
+ PUP[3][10]=(PUP[3][10]-Eggg*vv2)/sqrt(1.-pow(vv2,2));
+ // Rotate to beam axis.
+ double costz = PUP[3][4]/(sqrt(pow(PUP[4][4],2)-pow(mH,2)));
+ double sintz = sin(acos(costz));
+ double costx = PUP[1][4]/(sqrt(pow(PUP[1][4],2)+pow(PUP[2][4],2)));
+ double sintx = sin(acos(costx));
+ costx = -cos(phi3);
+ sintx = -sin(phi3);
+ double qx = PUP[1][6];
+ PUP[1][6] = -qx*costz+PUP[3][6]*sintz;
+ PUP[3][6] = qx*sintz + PUP[3][6]*costz;
+ qx = PUP[1][6];
+ PUP[1][6]=qx*costx-PUP[2][6]*sintx;
+ PUP[2][6]=qx*sintx+PUP[2][6]*costx;
+ double qbx = PUP[1][7];
+ PUP[1][7] = -qbx*costz+PUP[3][7]*sintz;
+ PUP[3][7] = qbx*sintz + PUP[3][7]*costz;
+ qbx = PUP[1][7];
+ PUP[1][7]=qbx*costx-PUP[2][7]*sintx;
+ PUP[2][7]=qbx*sintx+PUP[2][7]*costx;
+ double gx = PUP[1][10];
+ PUP[1][10] = -gx*costz+PUP[3][10]*sintz;
+ PUP[3][10] = gx*sintz + PUP[3][10]*costz;
+ gx = PUP[1][10];
+ PUP[1][10]=gx*costx-PUP[2][10]*sintx;
+ PUP[2][10]=gx*sintx+PUP[2][10]*costx;
+ PUP[1][6] = -PUP[1][6];
+ PUP[2][6] = -PUP[2][6];
+ PUP[3][6] = -PUP[3][6];
+ PUP[1][7] = -PUP[1][7];
+ PUP[2][7] = -PUP[2][7];
+ PUP[3][7] = -PUP[3][7];
+ PUP[1][10] = -PUP[1][10];
+ PUP[2][10] = -PUP[2][10];
+ PUP[3][10] = -PUP[3][10];
+ mass[6] = m;
+ mass[7] = m;
+ mass[10] = mg;
+ double CLf, CRf;
+ CLf =0.; CRf = 0.;
+ //spin information (not needed yet!)
+ double C[9], M[9];
+ C[1] = pow(CRe,2)*(chi2/(pow((mH*k),2)))*pow(gz2,2);
+ C[2] = pow(CLe,2)*(chi2/(pow((mH*k),2)))*pow(gz2,2);
+ C[3] = CLf*(mH/2.-pcm)+CRf*(mH/2.+pcm);
+ C[4] = CLf*(mH/2.+pcm)+CLf*(mH/2.-pcm);
+ C[5] = (CLf+CRf)*m;
+ C[6] = 2*e2*Ch[ID]*CRe*chi1*gz2/(k*mH);
+ C[7] = 2*e2*Ch[ID]*CLe*chi1*gz2/(k*mH);
+ C[8] = e2*Ch[ID];
+ M[1] = (C[1]*pow(C[3],2)-C[6]*C[3]+pow(C[8],2))*pow(1+cth,2);
+ M[5] = (C[2]*pow(C[4],2)-C[7]*C[4]+pow(C[8],2))*pow(1+cth,2);
+ M[2] = (C[1]*pow(C[4],2)-C[6]*C[4]+pow(C[8],2))*pow(1+cth,2);
+ M[6] = (C[2]*pow(C[3],2)-C[7]*C[3]+pow(C[8],2))*pow(1+cth,2);
+ M[3] = (C[1]*pow(C[5],2)-2.*m/mH*C[6]*C[5]+pow(C[8],2)*4.*param[0])*(1.-pow(cth,2));
+ M[7] = (C[2]*pow(C[5],2)-2.*m/mH*C[7]*C[5]+pow(C[8],2)*4.*param[0])*(1.-pow(cth,2));
+ M[4] = M[3];
+ M[8] = M[7];
+ double Mud, Mdu;
+ Mud = 0.; Mdu =0.;
+ for (int ix=1; ix < 5; ix++) {Mud+=M[ix];}
+ for (int ix=5; ix < 9; ix++) {Mud+=M[ix];}
+ if (random(seed) < Mud/(Mud+Mdu)) {
+ ISPINUP[1]=+1;
+ ISPINUP[2]=-1;
+ ISPINUP[3]=+1;
+ if (random(seed) < (M[1]+M[3])/Mud) {
+ ISPINUP[4] = +1;
+ if (random(seed) < M[1]/(M[1]+M[3])) {
+ ISPINUP[5] = -1;}else {ISPINUP[5] = +1;}} else {
+ ISPINUP[4] = -1;
+ if (random(seed) < M[2]/(M[2]+M[4])) {
+ ISPINUP[5] = +1;} else {ISPINUP[5] = -1;} }} else {
+ ISPINUP[1]=-1;
+ ISPINUP[2]=+1;
+ ISPINUP[3]=-1;
+ if (random(seed) < (M[6]+M[7])/Mdu) {
+ ISPINUP[4] = +1;
+ if (random(seed) < M[6]/(M[6]+M[7])) {
+ ISPINUP[5] = -1;}else {ISPINUP[5] = +1;}} else {
+ ISPINUP[4] = -1;
+ if (random(seed) < M[5]/(M[5]+M[8])) {
+ ISPINUP[5] = +1;} else {ISPINUP[5] = -1;} }}
+ if (qg) {ISPINUP[6] = ISPINUP[4];} else {ISPINUP[6] = ISPINUP[5];}
+ //weight info
+ XWGTUP = wt;
+
+ ii+=1;
+ double sum1, sum2, sum3, sum4;
+ sum1=0.;sum2=0.;sum3=0.;sum4=0.;
+ outdata << "<event>" << endl;
+ outdata << NUP <<"\t" << "11" <<"\t"<<XWGTUP<<"\t" << SCALUP << "\t" << AQEDUP << "\t" << AQCDUP << endl;
+ for (int ja = 1; ja < NUP+1; ja++) {
+ outdata << IDUP[ja] << "\t" << ISTUP[ja] << "\t" << MOTHUP[1][ja] <<"\t" << MOTHUP[2][ja] << "\t" << ICOLUP[1][ja] << "\t" << ICOLUP[2][ja] <<"\t" <<setprecision (9)<< PUP[1][ja] << "\t" << PUP[2][ja]<<"\t"<<PUP[3][ja]<<"\t"<<PUP[4][ja]<<"\t" << mass[ja] <<"\t"<< "0" << "\t" <<"9" <<endl;
+ sum1+=PUP[4][ja];sum2+=PUP[1][ja];sum3+=PUP[2][ja];sum4+=PUP[3][ja];
+ cout << "Generated event : " << "\t" << ii << "\t" << "of" << "\t" << nevg << "\r" << flush;
+}
+ outdata << "</event>" << endl;
+ // cout << sum1 << "\t" << sum2 << "\t" << sum3 << "\t" << sum4 << endl;
+ }
+
+ outdata << "</LesHouchesEvents>" << endl;
+ cout << endl;
+ return 0;
+}
+/********************************************************************************/
+// In soft and collinear phase space region ?
+
+void QQgsc(double r1, double r2, double r3,double r4, double &rx, double &ry, double param[9], double &rwgt, double &rwgt1, bool resolve) {
+
+ //Initialize weights
+ rwgt = 0.; rwgt1 = 0.;
+
+ /*Remove 2-jet events */
+ double y1 = 1.-r1;
+ double y2 = 1.-r2;
+ if ((1.-y1)==1 && (1.-y2)==1.) {return;}
+ bool soft = false;
+ int region = 0; // 1 for jet region cont. x=1; 2 for jet region cont. y=1
+ double fac = 1.; // weight factor for soft regions
+
+ if (y1 < 0.25 && y2 <0.25) {
+ soft = true;
+ if (y2 < y1) {
+ y1 = 0.25*r3;
+ y2 = r4*y1;
+ fac = 2.*r3;
+ } else {
+ y2 = 0.25*r4;
+ y1 = r3*y2;
+ fac = 2.*r4;
+ }
+ }
+
+ /* Check if outside Dalitz boundary */
+
+ if (y1*y2*(1.-y1-y2) < param[0]*pow((y1+y2),2)) {return;}
+
+ /*Inside jet 1? */
+ double w1 = 1.-y1;
+ double w2 = 1.-y2;
+ double tk = param[4];
+ double d1 = 0.25-(1.-w2)/tk;
+ double z, d2 , xx1, xx2;
+ if (d1 > 0.) {
+ z = 0.5+sqrt(d1);
+ d2 = pow(w2,2)-4.*param[0];
+ if (d2 > 0.) {
+ d2 = sqrt(d2);
+ double rr = 1.+param[0]/(1.-w2+param[0]);
+ xx1 = (rr*(2.-w2)+(2.*z-rr)*d2)/2.;
+ xx2 = (rr*(2.-w2)+(2.*(1.-z)-rr)*d2)/2.;
+ if (xx2 < w1 && w1 < xx1) {
+ region = 1;}
+ }
+ }
+ if (region == 0) {
+ w1 = 1.-y2;
+ w2 = 1.-y1;
+ tk = param[5];
+ d1 = 0.25-(1.-w2)/tk;
+ if (d1 > 0.) {
+ z = 0.5+sqrt(d1);
+ d2 = pow(w2,2)-4.*param[0];
+ if (d2 > 0.) {
+ d2 = sqrt(d2);
+ double rr = 1.+param[0]/(1.-w2+param[0]);
+ xx1 = (rr*(2.-w2)+(2.*z-rr)*d2)/2.;
+ xx2 = (rr*(2.-w2)+(2.*(1.-z)-rr)*d2)/2.;
+ if (xx2 < w1 && w1 < xx1) {
+ region = 2;} else {return;}
+ } else {return;}
+ } else {return;} }
+ // fac = 1.;
+ /* Calculate weights for jet regions */
+ double r, zz;
+ rx = 1.-y1;
+ ry = 1.-y2;
+
+ if (region == 1) {
+ r = 0.5*(1.+param[0]/(1.+param[0]-ry));
+ zz = r+(rx-(2.-ry)*r)/sqrt(pow(ry,2)-2.*param[1]);
+
+ rwgt = ((pow(1-rx,2) + pow(1-ry,2))/((1-rx)*(1-ry))+2.*(1.-param[1])*(rx+ry-1.-2.*param[1])/((1.-rx)*(1.-ry))+2.*param[1]*(1./(1.-rx)+1./(1.-ry))-param[1]*(1.-2.*param[1])*(1./pow(1-rx,2)+1./pow(1.-ry,2))+2.)*param[8];
+ rwgt = rwgt-((((1.+pow(zz,2))/(1.-zz))-param[1]/y2)/(y2*sqrt(pow(ry,2)-2.*param[1])))/2.;
+
+ rwgt = rwgt*param[6]*fac;
+ } else if (region == 2) {
+ r = 0.5*(1.+param[0]/(1.+param[0]-rx));
+ zz = r+(ry-(2.-rx)*r)/sqrt(pow(rx,2)-2.*param[1]);
+ rwgt = ((pow(1-rx,2) + pow(1-ry,2))/((1-rx)*(1-ry))+2.*(1.-param[1])*(rx+ry-1.-2.*param[1])/((1.-rx)*(1.-ry))+2.*param[1]*(1./(1.-rx)+1./(1.-ry))-param[1]*(1.-2.*param[1])*(1./pow(1-rx,2)+1./pow(1.-ry,2))+2.)*param[8];
+ rwgt = rwgt-((((1.+pow(zz,2))/(1.-zz))-param[1]/y1)/(y1*sqrt(pow(rx,2)-2.*param[1])))/2.;
+ rwgt = rwgt*param[6]*fac;
+ }
+ rwgt1 = (2.+2.*param[3]*param[6])*fac-rwgt;
+ /* Implement soft resolution cut */
+ if (resolve) {
+ if (rx+ry > 1.9999) {return;}}
+}
+ /*********************************************************************/
+ // In hard region?
+
+void QQgh(double r1, double r2, double r3,double r4, double &rx, double &ry, double param[9], double &rwgt,double &rwgt1, bool resolve) {
+
+ //Initialize weights and phase space points
+ rwgt = 0.;rwgt1 = 0.;
+
+ /*Remove 2-jet events */
+ double y1 = 1.-r1;
+ double y2 = 1.-r2;
+ if ((1.-y1)==1. && (1.-y2)==1.) {return;}
+ bool soft = false;
+ double fac = 1.; // weight factor for soft regions
+
+// Mappings for soft and collinear regions
+ if (y1 < 0.25){
+ if (y2 < 0.25) {
+ soft = true;
+ if (y1 < y2) {
+ y1 = 0.25-y1;
+ y2 = y1*(1.5-2.*y2);
+
+ } else {
+ y2 = 0.25-y2;
+ y1 = y2*(1.5-2.*y1);
+ }} else if (y2 < y1+2.*pow(y1,2)) {return;}
+ } else if (y2 < 0.25) { if (y1 < y2+2.*pow(y2,2)) {return;} }
+
+
+ if (soft) {if (y1 < y2) {fac = 2.*y1;} else {fac = 2.*y2;} }
+ if (!soft) {
+
+ if (y1 > 0.375 && y2 < 0.25) {
+ if (y1 > 1.-2.5*y2 && y1 < 1.-y2) {
+ y2 = r4*0.25;
+ y1 = 1.-(1.+1.5*r3)*y2;
+ fac = 2.*r4;
+ } else {return;} }
+
+ if (y2 > 0.375 && y1 < 0.25) {
+ if (y2 > 1.-2.5*y1 && y2 < 1.-y1) {
+ y1 = r3*0.25;
+ y2 = 1.-(1.+1.5*r4)*y1;
+ fac = 2.*r3;
+ } else {return;}}}
+
+// Check if outside half-box */
+ if (2.-y1-y2 < 1.) {return;}
+
+
+
+ /*Inside jet 1? */
+ double w1 = 1.-y1;
+ double w2 = 1.-y2;
+ double tk = param[4];
+ double d1 = 0.25-(1.-w2)/tk;
+ double z,d2,xx;
+
+
+ if (d1 > 0.) {
+ z = 0.5+sqrt(d1);
+ d2 = pow(w2,2)-4.*param[0];
+ if (d2 > 0.) {
+ d2 = sqrt(d2);
+ double rr = 1.+param[0]/(1.-w2+param[0]);
+ xx = (rr*(2.-w2)+(2.*z-rr)*d2)/2.;
+ if (w1 < xx) {
+ z = 1.-z;
+ xx = (rr*(2.-w2)+(2.*z-rr)*d2)/2.;
+ if (w1 > xx) {return;}}}}
+
+ /*Inside jet 2? */
+
+ w1 = 1.-y2;
+ w2 = 1.-y1;
+ tk = param[5];
+ d1 = 0.25-(1.-w2)/tk;
+ if (d1 > 0.) {
+ z = 0.5+sqrt(d1);
+ d2 = pow(w2,2)-4.*param[0];
+ if (d2 > 0.) {
+ d2 = sqrt(d2);
+ double rr = 1.+param[0]/(1.-w2+param[0]);
+ xx = (rr*(2.-w2)+(2.*z-rr)*d2)/2.;
+ if (w1 < xx) {
+ z = 1.-z;
+ xx = (rr*(2.-w2)+(2.*z-rr)*d2)/2.;
+ if (w1 > xx) {return;}}}}
+ /* Outside Dalitz plot? */
+ if (y1*y2*(1.-y1-y2) < param[0]*pow((y1+y2),2)) { return;}
+ /* Calculate weights for dead region */
+ rx = 1.-y1;
+ ry = 1.-y2;
+ rwgt = (pow(1-rx,2) + pow(1-ry,2))/((1-rx)*(1-ry))+2.*(1.-param[1])*(rx+ry-1.-2.*param[1])/((1.-rx)*(1.-ry))+2.*param[1]*(1./(1.-rx)+1./(1.-ry))-param[1]*(1.-2.*param[1])*(1./pow(1-rx,2)+1./pow(1.-ry,2))+2.;
+ rwgt = rwgt*param[6]*param[8]*fac;
+ rwgt1 = (2.+2.*param[3]*param[6])*fac-rwgt;
+ /* Implement soft resolution cut */
+ if (resolve) {
+ if (rx+ry > 1.9999) {return;}}
+}
+ /*********************************************************************/
+ // In gap between phase space for massive partons and full half-triangle?
+
+void QQgsp(double r1, double r2, double r3,double r4, double &rx, double &ry, double param[8], double &rwgt,double &rwgt1, bool resolve) {
+
+ //Initialize weights and phase space points
+ rwgt = 0.;rwgt1 = 0.;
+
+ /*Remove 2-jet events */
+ double y1 = 1.-r1;
+ double y2 = 1.-r2;
+ if ((1.-y1)==1. && (1.-y2)==1.) {return;}
+ /* Check if outside half-box */
+ if (2.-y1-y2 <= 1.) {return;}
+
+/* Inside Dalitz plot? */
+ if (y1*y2*(1.-y1-y2) > param[0]*pow((y1+y2),2)) {return;}
+ /* Calculate weights */
+ rwgt1 = 2.+2.*param[3]*param[6];}
+
+ /*********************************************************************/
+// Random number generator.
+
+ double random (int &rseed) {
+ int M = 2147483647;
+ int A = 16807;
+ int Q = 127773;
+ int R = 2836;
+ double MINV = 0.46566128752458e-09;
+ int HI = rseed/Q;
+ int LO = rseed % Q;
+ rseed = A*LO - R*HI;
+ if (rseed < 0) {rseed = rseed + M;}
+ return rseed*MINV;}
+/*********************************************************************/
+double ddilog(double x)
+{
+ // The DiLogarithm function
+ // Code translated by R.Brun from CERNLIB DILOG function C332
+
+ const double hf = 0.5;
+ const double pi = 3.14152654;
+ const double pi2 = pi*pi;
+ const double pi3 = pi2/3;
+ const double pi6 = pi2/6;
+ const double pi12 = pi2/12;
+ const double c[20] = {0.42996693560813697, 0.40975987533077105,
+ -0.01858843665014592, 0.00145751084062268,-0.00014304184442340,
+ 0.00001588415541880,-0.00000190784959387, 0.00000024195180854,
+ -0.00000003193341274, 0.00000000434545063,-0.00000000060578480,
+ 0.00000000008612098,-0.00000000001244332, 0.00000000000182256,
+ -0.00000000000027007, 0.00000000000004042,-0.00000000000000610,
+ 0.00000000000000093,-0.00000000000000014, 0.00000000000000002};
+
+ double t,h,y,s,a,alfa,b1,b2,b0;
+
+ if (x == 1) {
+ h = pi6;
+ } else if (x == -1) {
+ h = -pi12;
+ } else {
+ t = -x;
+ if (t <= -2) {
+ y = -1/(1+t);
+ s = 1;
+ b1= log(-t);
+ b2= log(1+1/t);
+ a = -pi3+hf*(b1*b1-b2*b2);
+ } else if (t < -1) {
+ y = -1-t;
+ s = -1;
+ a = log(-t);
+ a = -pi6+a*(a+log(1+1/t));
+ } else if (t <= -0.5) {
+ y = -(1+t)/t;
+ s = 1;
+ a = log(-t);
+ a = -pi6+a*(-hf*a+log(1+t));
+ } else if (t < 0) {
+ y = -t/(1+t);
+ s = -1;
+ b1= log(1+t);
+ a = hf*b1*b1;
+ } else if (t <= 1) {
+ y = t;
+ s = 1;
+ a = 0;
+ } else {
+ y = 1/t;
+ s = -1;
+ b1= log(t);
+ a = pi6+hf*b1*b1;
+ }
+ h = y+y-1;
+ alfa = h+h;
+ b1 = 0;
+ b2 = 0;
+ for (int i=19;i>=0;i--){
+ b0 = c[i] + alfa*b1-b2;
+ b2 = b1;
+ b1 = b0;
+ }
+ h = -(s*(b0-h*b2)+a);
+ }
+ return h;
+}
+
+
+
+
+ /*********************************************************************/
+ /*********************************************************************/
+ /*********************************************************************/
diff --git a/Contrib/MCPWNLO/HIGGSDEC/MCHGPP_INPUTS.h b/Contrib/MCPWNLO/HIGGSDEC/MCHGPP_INPUTS.h
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/HIGGSDEC/MCHGPP_INPUTS.h
@@ -0,0 +1,81 @@
+/* MC@NLO input file*/
+#include<iostream>
+#include <string>
+
+class Input
+
+{
+ public:
+
+ // Input();
+ // ~Input();
+
+/* Center of mass energy/GeV */
+
+ double cme() {return 1800.;}
+
+ /* Vector Boson ID
+ Options : 23 for Z boson
+ : 24 for W boson
+ */
+
+ int VBID() {return 24;}
+
+ /* Type of collider. Set to true if proton-proton or false if ppbar */
+
+ bool pp() {return false;}
+
+ /* Mass of Higgs/GeV */
+
+ double mH() {return 114.;}
+
+ /* Pole mass of Z/GeV */
+
+ double Mz() {return 91.2;}
+
+/* Pole mass of W/GeV */
+
+ double Mw() {return 80.3;}
+
+ /* Mass of b quark/GeV */
+
+ double mb() {return 5.0;}
+
+ /* AlphaS (MH) */
+
+ double alphasmH() {return 0.114138;}
+
+
+ /* Number of parton flavours */
+
+ int nf() {return 1;}
+
+/* Maximum number of iterations for Newton-Raphson boost. About 4 is recommended */
+
+ int it() {return 4;}
+
+/* Implement resolution cut for xb xbbar phase space? */
+
+bool resolve() {return true;}
+
+/* PDFset e.g cteq5m.LHgrid, MRST2004nlo.LHgrid etc Make sure the chosen set is compatible with rscheme defined above! */
+
+ char* PDFset() { return "cteq5m.LHgrid"; }
+
+/* Number of events for integration */
+
+ int nevint() {return 10000;}
+
+/* Number of events to generate */
+
+ int nevgen() {return 10000;}
+
+
+/* Random number seed */
+
+ int rseed() {return 1;}
+
+};
+
+
+
diff --git a/Contrib/MCPWNLO/HIGGSDEC/MCHG_INPUTS.h b/Contrib/MCPWNLO/HIGGSDEC/MCHG_INPUTS.h
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/HIGGSDEC/MCHG_INPUTS.h
@@ -0,0 +1,92 @@
+/* MC@NLO input file*/
+#include<iostream>
+#include <string>
+
+class Input
+
+{
+ public:
+
+ // Input();
+ // ~Input();
+
+ /* Do you want to interface this program to another which generates Higgs bosons independently?
+ If YES and you want to generate associated ZH events with this code, choose true.
+ If NO and want to use the internal associated Higgs production code, choose false. */
+
+ bool iface() {return true;}
+
+
+ /*********************************************************************************************************/
+ /* INFORMATION REQUIRED FOR INTERFACING ANOTHER PROCESS TO NLO HIGGS DECAY */
+ /* */
+ /*********************************************************************************************************/
+ /*If interfacing, do you require the b, \bar{b} and g momenta in the Higgs rest frame or the lab frame?
+ If rest frame, set to true. If lab frame, set to false. Please provide fileof lab frame Higgs' 5-momenta*/
+
+ bool rest() {return false;}
+
+ /* Have you got a properly formatted file containing Higgs 5-momenta (px, py, pz, E, mass) to interface? You
+ must do if rest() == false! */
+
+ bool ifile() {return true;}
+
+ /* Address of the file */
+
+ char* filename() { return "/usera/seyi/MCPWNLO/HIGGSDEC/Higgs.dat"; }
+
+ /* Number of events in ifile */
+
+ int nfile() {return 1; }
+
+ /*********************************************************************************************************/
+
+/* Center of mass energy/GeV */
+
+ double cme() {return 500.0;}
+
+ /* Mass of Higgs/GeV */
+
+ double mH() {return 114.;}
+
+/* Pole mass of Z/GeV */
+
+ double Mz() {return 91.2;}
+
+ /* Pole mass of W/GeV */
+
+ double Mw() {return 80.3;}
+
+ /* Mass of b quark/GeV */
+
+ double mb() {return 5.0;}
+
+ /* AlphaS (MH) */
+
+ double alphasmH() {return 0.114138;}
+
+/* Maximum number of iterations for Newton-Raphson boost. About 4 is recommended */
+
+ int it() {return 4;}
+
+/* Implement resolution cut for xb,xbbar phase space? */
+
+bool resolve() {return true;}
+
+/* Number of events for integration */
+
+ int nevint() {return 10000;}
+
+/* Number of events to generate */
+
+ int nevgen() {return 100;}
+
+
+/* Random number seed */
+
+ int rseed() {return 1;}
+
+};
+
+
+
diff --git a/Contrib/MCPWNLO/HIGGSDEC/Makefile b/Contrib/MCPWNLO/HIGGSDEC/Makefile
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/HIGGSDEC/Makefile
@@ -0,0 +1,94 @@
+###############################################################################
+# DIRECTORIES
+
+#Where LHAPDF is installed
+LHAPDFDIR = /usera/seyi/lhapdfnew
+#Where the /MCPWNLO/Herwig folder is
+HERWIGDIR = /usera/seyi/MCPWNLO/Herwig
+
+###############################################################################
+
+## ROOT DIRECTORIES
+
+#ROOTSYS = /usera/seyi/root
+
+#ROOTLIB = -L$(ROOTSYS)/lib $(shell $(ROOTSYS)/bin/root-config --libs)
+
+#ROOTINC = $(ROOTSYS)/include/
+
+###############################################################################
+# LIBRARIES
+
+#Now the libraries -L(directory) -lname NOT preceeded by lib!!!!
+#i.e if your lib is called libNAME you need -lNAME
+
+##Path to CLHEP library should be $(CLHEPDIR)/lib/ and check lib name
+#CLHEPLIB = -L$(HOME)/ktjet/lib/ -lKtEvent -L$(CLHEPDIR)/lib/ -lCLHEP
+#CLHEPLIBNEW = -L$(CLHEPDIRNEW)/lib/ -lCLHEP
+##Path to LHAPDF library should be the same as the LHAPDF directory
+LHAPDFLIB = -L$(LHAPDFDIR)/lib -lLHAPDF
+LHAPDFINC = $(LHAPDFDIR)/include
+
+#MAC OS users....
+#If you had to get an external version of libg2c - i.e it doesn't come with you compiler......We stress, you've probably already got this.
+LIBG2C = /usr/local/lib/
+# You would then have to add -L$(LIBG2C) just in front of -lg2c on line 58
+
+################################################################################
+#No need to edit anything below this line!
+
+OPT = -funroll-loops -O2 -Wall
+
+
+FSOURCES = $(shell ls ./src/*.f)
+CXXSOURCES = $(shell ls ./src/*.cxx)
+FOBJS = $(FSOURCES:.f=.o)
+CXXOBJS = $(CXXSOURCES:.cxx=.o)
+CC = gcc
+FF = g77
+
+all: MCHG MCHGPP run_eeZH run_PPVH
+
+%.o: %.cxx
+ $(CC) -c $(OPT) \
+ -I$(LHAPDFINC)\
+ $^ -o $@
+
+%.o: %.f
+ $(FF) -c $(OPT) $^ -o $@
+
+
+MCHG: MCHG.o
+ g++ $(OPT) -I./src/ $^\
+ $(CLHEPLIB) \
+ $(LHAPDFLIB) \
+ -L$(LIBG2C) -lg2c -o $@
+
+MCHGPP: MCHGPP.o
+ g++ $(OPT) -I./src/ $^\
+ $(CLHEPLIB) \
+ $(LHAPDFLIB) \
+ -L$(LIBG2C) -lg2c -o $@
+
+run_eeZH: run_eeZH.o
+ g++ $(OPT) -I./src/ $^\
+ $(LHAPDFLIB) \
+ -L$(LIBG2C) -lg2c -o $@
+ mv run_eeZH $(HERWIGDIR)
+
+run_PPVH: run_PPVH.o
+ g++ $(OPT) -I./src/ $^\
+ $(LHAPDFLIB) \
+ -L$(LIBG2C) -lg2c -o $@
+ mv run_PPVH $(HERWIGDIR)
+
+
+
+clean:
+ rm *.o
+ rm MCHG
+ rm MCHGPP
+
+
+
+
diff --git a/Contrib/MCPWNLO/HIGGSDEC/VHAnalysis/Makefile b/Contrib/MCPWNLO/HIGGSDEC/VHAnalysis/Makefile
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/HIGGSDEC/VHAnalysis/Makefile
@@ -0,0 +1,38 @@
+# -*- Makefile -*- (for emacs)
+
+#
+# This Makefile is intended for compiling Herwig++ plugins
+# You can find plugins here: INSERT URL
+#
+# This Makefile received very little testing,
+# any bug reports are very welcome!
+#
+
+# location of include files
+HPPDIR = /usera/seyi/Herwig
+THEPEGDIR = /usera/seyi/Herwig
+
+#CLHEPINCLUDE =
+#ROOTINCLUDE = -I/usera/andreas/root/include
+#ROOTCFLAGS := $(shell /usera/andreas/root/bin/root-config --ldflags)
+#ROOTGLIBS := $(shell /usera/andreas/root/bin/root-config --glibs)
+#ROOT = $(ROOTCFLAGS) $(ROOTGLIBS)
+INCLUDE = -I$(THEPEGDIR)/include -I$(HPPDIR)/include
+#
+# C++ flags
+#
+CXX = g++
+CXXFLAGS = -O2
+
+ALLCCFILES=$(shell echo *.cc)
+all : $(ALLCCFILES:.cc=.so)
+
+%.so : %.cc %.h
+ $(CXX) -fPIC $(CPPFLAGS) $(INCLUDE) $(ROOT) $(CXXFLAGS) -shared $< -o $@
+
+install:
+
+ cp MyVHAnalysis.so $(HPPDIR)/lib/Herwig++
+
+clean:
+ rm -f $(ALLCCFILES:.cc=.so)
diff --git a/Contrib/MCPWNLO/HIGGSDEC/VHAnalysis/MyVHAnalysis.cc b/Contrib/MCPWNLO/HIGGSDEC/VHAnalysis/MyVHAnalysis.cc
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/HIGGSDEC/VHAnalysis/MyVHAnalysis.cc
@@ -0,0 +1,201 @@
+// -*- C++ -*-
+//
+// MyVHAnalysis.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 MyVHAnalysis class.
+//
+
+#include "MyVHAnalysis.h"
+#include "ThePEG/Repository/EventGenerator.h"
+#include "ThePEG/EventRecord/Particle.h"
+#include "ThePEG/EventRecord/Event.h"
+#include "ThePEG/PDT/EnumParticles.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+MyVHAnalysis::MyVHAnalysis() :
+ _Mbb(0.,150.,150),
+ _Lbb(-350.,350.,175), _rapbb(-5.,5.,100),
+ _PTbmH(0.,300.,125),
+ _PTVH(0.,600.,150), _Ebb(0.,800., 200) {}
+
+ void MyVHAnalysis::analyze(tEventPtr event, long, int, int) {
+
+ // AnalysisHandler::analyze(event, ieve, loop, state);
+ // Rotate to CMS, extract final state particles and call analyze(particles).
+ // find the Z
+ string infile = "PPVH.dat";
+ ifstream normin;
+ string stringin = "";
+ int IPROC = 24;
+ int stringdoub = 0;
+ bool next = 0, filerror = 0;
+ normin.open(infile.c_str());
+ if(!normin) { cerr << "Error: Failed to open file " << infile << endl; filerror = 1; IPROC = 24; }
+ if(!filerror) {
+ while(normin) {
+
+ normin >> stringin;
+
+ if(next) { normin >> stringdoub; IPROC = stringdoub; break; }
+ if(stringin == "IPROC") { next = 1; }
+
+ }
+ }
+
+ Lorentz5Momentum pz, pVd;
+ StepVector::const_iterator sit =event->primaryCollision()->steps().begin();
+ StepVector::const_iterator stest =event->primaryCollision()->steps().end();
+ StepVector::const_iterator send=sit;
+ ++send;
+ if(send==stest) --send;
+ ++send;
+ if(send==stest) --send;
+ ++send;
+ double ptbb, mzbb, pzz, rapbb, ptbb2, pggg, pzemax, pzemax2, ptbb3;
+ pzemax = 0.; pzemax2 = 0.;
+ Lorentz5Momentum pzbb, pzV, pg, pgg, pzb, pzb2;
+ for(sit=send-1;sit!=send;++sit) {
+ ParticleSet part=(**sit).all();
+ ParticleSet::const_iterator iter = part.begin(), end = part.end();
+ for( ;iter!=end;++iter) {
+ // if((**iter).children().size()==2) continue;
+ // if(abs((**iter).id())!= 5 || abs((**iter).id())!=11 || abs((**iter).id())!=12) continue;
+ if((**iter).id() == 5) {
+ pz =(*iter)->momentum();
+ if (pz.e() > pzemax) {pzb = pz;}}
+ if((**iter).id() == -5) {
+ pz =(*iter)->momentum();
+ if (pz.e() > pzemax2) {pzb2 = pz;}}
+ if (IPROC == 24) {
+ if (abs((**iter).id())== 11 || abs((**iter).id()) == 12) {
+ pVd = (*iter)->momentum();
+ pzV += pVd;
+ }} else if (IPROC == 23) {
+ if (abs((**iter).id())== 11) {
+ pVd = (*iter)->momentum();
+ pzV += pVd;
+ }}
+
+
+ }
+ pzbb = pzb + pzb2 ;
+ ptbb = sqrt(pow(pzbb.x(),2)+pow(pzbb.y(),2)+pow(pzbb.z(),2))*sin(acos((pzV.x()*pzbb.x()+pzV.y()*pzbb.y()+pzV.z()*pzbb.z())/(sqrt(pow(pzV.x(),2)+pow(pzV.y(),2)+pow(pzV.z(),2))*sqrt(pow(pzbb.x(),2)+pow(pzbb.y(),2)+pow(pzbb.z(),2)))));
+ mzbb = sqrt(pow(pzbb.e(),2)- pow(pzbb.x(),2)-pow(pzbb.y(),2)-pow(pzbb.z(),2));
+ ptbb = abs(ptbb)/GeV;
+ ptbb2 = pzbb.perp()/GeV;
+ mzbb = mzbb/GeV;
+ pzz = pzbb.z()/GeV;
+ rapbb = pzbb.rapidity();
+ if (mzbb < 10.0/GeV) continue;
+ _PTVH.addWeighted(ptbb ,event->weight());
+ _Mbb .addWeighted(mzbb ,event->weight());
+ _Lbb .addWeighted(pzz ,event->weight());
+ _rapbb .addWeighted(rapbb ,event->weight());
+ _PTbmH .addWeighted(ptbb2 ,event->weight());
+ _Ebb.addWeighted(pzbb.e()/GeV ,event->weight());
+
+ //cout << ptbb << "\t" << mzbb << "\t" << ptbb2 << endl;
+ //if(mz>20.&&mz<80.) _ptZ[1].addWeighted(pt,event->weight());
+ // else if (mz>80.&&mz<100.) _ptZ[2].addWeighted(pt,event->weight());
+ //else if (mz>100.) _ptZ[3].addWeighted(pt,event->weight());
+ //_ptZ[0].addWeighted(pt ,event->weight());
+ //_mZ .addWeighted(mz ,event->weight());
+ // _rapZ .addWeighted(pz.rapidity(),event->weight());
+ //_phiZ .addWeighted(pz.phi() ,event->weight());
+ // }
+ //else if ((**iter).id()==ParticleID::Wplus) {
+ // pz=(*iter)->momentum();
+ // double pt = pz.perp()/GeV;
+ // double mz = pz.mass()/GeV;
+ // if(mz>20.&&mz<80.) _ptWp[1].addWeighted(pt,event->weight());
+ // else if (mz>80.&&mz<100.) _ptWp[2].addWeighted(pt,event->weight());
+ // else if (mz>100.) _ptWp[3].addWeighted(pt,event->weight());
+ // _ptWp[0].addWeighted(pt ,event->weight());
+ // _mWp .addWeighted(mz ,event->weight());
+ // _rapWp .addWeighted(pz.rapidity(),event->weight());
+ // _phiWp .addWeighted(pz.phi() ,event->weight());
+ // }
+ // else if ((**iter).id()==ParticleID::Wminus) {
+ // pz=(*iter)->momentum();
+ //double pt = pz.perp()/GeV;
+ // double mz = pz.mass()/GeV;
+ // if(mz>20.&&mz<80.) (_ptWm[1]).addWeighted(pt,event->weight());
+ // else if (mz>80.&&mz<100.) (_ptWm[2]).addWeighted(pt,event->weight());
+ // else if (mz>100.) (_ptWm[3]).addWeighted(pt,event->weight());
+ // _ptWm[0].addWeighted(pt ,event->weight());
+ // _mWm .addWeighted(mz ,event->weight());
+ // _rapWm .addWeighted(pz.rapidity(),event->weight());
+ // _phiWm .addWeighted(pz.phi() ,event->weight());
+ // }
+ // }
+
+ }
+
+}
+// Lorentz5Momentum ps;
+// double pss;
+// for (sit = send; sit != send+1; sit++) {
+// ParticleSet part2(**sit).all();
+// ParticleSet::const_iterator iter2= part2.begin(), end2 = part2.end();
+// for( ;iter2!=end2;++iter2) {
+// ps = (*iter2)->momentum();
+// pss += abs(ps.perp()/GeV);
+// }
+// _rapWm.addWeighted(pss,event->weight());
+// }
+
+NoPIOClassDescription<MyVHAnalysis> MyVHAnalysis::initMyVHAnalysis;
+// Definition of the static class description member.
+
+void MyVHAnalysis::Init() {
+
+ static ClassDocumentation<MyVHAnalysis> documentation
+ ("The MyVHAnalysis class performs a simple analysis of W and"
+ " Z production in hadron-hadron collisions");
+
+}
+
+void MyVHAnalysis::dofinish() {
+ AnalysisHandler::dofinish();
+ string fname = generator()->filename() + string("-") + name() + string(".top");
+ ofstream outfile(fname.c_str());
+ string title;
+ using namespace HistogramOptions;
+ // for(unsigned int ix=0;ix<4;++ix) {
+ // if(ix==0){title="pt of Z for all masses ";}
+ // else if(ix==1){title="pt of Z for mass 40-80 GeV";}
+ // else if(ix==2){title="pt of Z for mass 80-100 GeV";}
+ // else if(ix==3){title="pt of Z for mass 100- GeV";}
+ // _ptZ[ix].topdrawOutput(outfile,Frame,"BLACK",title);
+ // _ptZ[ix].topdrawOutput(outfile,Frame|Ylog,"BLACK",title);
+ // if(ix==0){title="pt of Wp for all masses ";}
+ // else if(ix==1){title="pt of Wp for mass 40-80 GeV";}
+ // else if(ix==2){title="pt of Wp for mass 80-100 GeV";}
+ // else if(ix==3){title="pt of Wp for mass 100- GeV";}
+ // _ptWp[ix].topdrawOutput(outfile,Frame,"BLACK",title);
+ // _ptWp[ix].topdrawOutput(outfile,Frame|Ylog,"BLACK",title);
+ // if(ix==0){title="pt of Wm for all masses ";}
+ // else if(ix==1){title="pt of Wm for mass 40-80 GeV";}
+ // else if(ix==2){title="pt of Wm for mass 80-100 GeV";}
+ // else if(ix==3){title="pt of Wm for mass 100- GeV";}
+ // _ptWm[ix].topdrawOutput(outfile,Frame,"BLACK",title);
+ // _ptWm[ix].topdrawOutput(outfile,Frame|Ylog,"BLACK",title);
+ // }
+ _Mbb.topdrawOutput(outfile,Frame,"BLACK","Mass of b anti-b pair");
+ _Ebb.topdrawOutput(outfile,Frame|Ylog,"BLACK","Energy of b anti-b pair");
+ _PTbmH.topdrawOutput(outfile,Frame|Ylog,"BLACK","pT of b anti-b pair wrt to beam axis");
+ _PTVH.topdrawOutput(outfile,Frame|Ylog,"BLACK","pT of b anti-b pair wrt to the vector boson");
+ _Lbb.topdrawOutput(outfile,Frame,"BLACK", "Longtitudinal mmt of b anti-b pair");
+ _rapbb.topdrawOutput(outfile,Frame|Ylog,"BLACK", "Rapidity of b anti-b pair");
+}
+
diff --git a/Contrib/MCPWNLO/HIGGSDEC/VHAnalysis/MyVHAnalysis.h b/Contrib/MCPWNLO/HIGGSDEC/VHAnalysis/MyVHAnalysis.h
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/HIGGSDEC/VHAnalysis/MyVHAnalysis.h
@@ -0,0 +1,184 @@
+// -*- C++ -*-
+//
+// MyVHAnalysis.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_MyVHAnalysis_H
+#define HERWIG_MyVHAnalysis_H
+//
+// This is the declaration of the MyVHAnalysis class.
+//
+
+#include "ThePEG/Repository/CurrentGenerator.h"
+#include "ThePEG/Handlers/AnalysisHandler.h"
+#include "Herwig++/Utilities/Histogram.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * The MyVHAnalysis class is designed to perform some simple analysis of
+ * gauge boson, W and Z, distributions in hadron-hadron collisions. The main
+ * distriubtions are the transverse momentum and rapidities of the gauge bosons
+ * which are of physical interest, and the azimuthal angle distribution for
+ * testing purposes.
+ *
+ * @see \ref MyVHAnalysisInterfaces "The interfaces"
+ * defined for MyVHAnalysis.
+ */
+class MyVHAnalysis: public AnalysisHandler {
+
+public:
+
+ /**
+ * The default constructor.
+ */
+ MyVHAnalysis();
+
+ /** @name Virtual Functions required by the AnalysisHandler class. */
+ //@{
+ /**
+ * Analyze a given Event. Note that a fully generated event
+ * may be presented several times, if it has been manipulated in
+ * between. The default version of this function will call transform
+ * to make a lorentz transformation of the whole event, then extract
+ * all final state particles and call analyze(tPVector) of this
+ * analysis object and those of all associated analysis objects. The
+ * default version will not, however, do anything on events which
+ * have not been fully generated, or have been manipulated in any
+ * way.
+ * @param event pointer to the Event to be analyzed.
+ * @param ieve the event number.
+ * @param loop the number of times this event has been presented.
+ * If negative the event is now fully generated.
+ * @param state a number different from zero if the event has been
+ * manipulated in some way since it was last presented.
+ */
+ virtual void analyze(tEventPtr event, long ieve, int loop, int state);
+ //@}
+
+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();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ inline virtual IBPtr clone() const {return new_ptr(*this);}
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ inline virtual IBPtr fullclone() const {return new_ptr(*this);}
+ //@}
+
+protected:
+
+ /** @name Standard Interfaced functions. */
+ //@{
+ /**
+ * 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 static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static NoPIOClassDescription<MyVHAnalysis> initMyVHAnalysis;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ MyVHAnalysis & operator=(const MyVHAnalysis &);
+
+private:
+
+ /**
+ * Mass of the b bbar pair
+ */
+ Histogram _Mbb;
+
+ /**
+ * Energy of the b bbar pair
+ */
+ Histogram _Ebb;
+
+ /**
+ * pT of the b bbar pair wrt the beam axis
+ */
+ Histogram _PTbmH;
+
+ /**
+ * pT of the b bbar pair wrt the vector boson
+ */
+ Histogram _PTVH;
+
+ /**
+ * Longitudinal momentum of the b bbar pair
+ */
+ Histogram _Lbb;
+
+ /**
+ * Rapidity of the b bbar pair
+ */
+ Histogram _rapbb;
+
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of MyVHAnalysis. */
+template <>
+struct BaseClassTrait<Herwig::MyVHAnalysis,1> {
+ /** Typedef of the first base class of MyVHAnalysis. */
+ typedef AnalysisHandler NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the MyVHAnalysis class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::MyVHAnalysis>
+ : public ClassTraitsBase<Herwig::MyVHAnalysis> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::MyVHAnalysis"; }
+ /** Return the name(s) of the shared library (or libraries) be loaded to get
+ * access to the MyVHAnalysis class and any other class on which it depends
+ * (except the base class). */
+ static string library() { return "MyVHAnalysis.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_MyVHAnalysis_H */
diff --git a/Contrib/MCPWNLO/HIGGSDEC/VHmanual.tex b/Contrib/MCPWNLO/HIGGSDEC/VHmanual.tex
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/HIGGSDEC/VHmanual.tex
@@ -0,0 +1,175 @@
+\documentclass[12pt,a4paper,oneside]{article}
+%\documentclass{article}
+%\usepackage{afterpage}
+%\usepackage[hang,small,bf]{caption}
+%\usepackage{fancyhdr}
+%\usepackage[something]{optional}
+%\usepackage[todo, question, colour]{optional}
+%\usepackage{epsfig,axodraw}
+%\usepackage{array,cite,amsmath,amssymb}
+%\usepackage{cite}
+%\usepackage{makeidx}
+%\usepackage{doublespace} % This doesn't work with FeynArts diagrams
+%\usepackage{array}
+%\usepackage{multicol}
+%\usepackage{subfigure}
+%\usepackage{rotating}
+%\usepackage{amssymb}
+\usepackage{setspace}
+\usepackage{booktabs}
+%\input{psfig.tex}
+%\usepackage{psfig}
+\oddsidemargin=-0.05in
+\textwidth=6.9in
+\topmargin=-0.8in
+\textheight=9.55in
+%\reqno
+%\newcounter{table}
+\addtocounter{table}{0}
+\usepackage{hyperref}
+\usepackage{epsfig,bm,amsmath}
+\onehalfspacing
+% \makeatletter
+% \DeclareRobustCommand{\Cpp}
+% {\valign{\vfil\hbox{##}\vfil\cr
+% \textsf{C\kern-.1em}\cr
+% $\hbox{\fontsize{\sf@size}{0}\textbf{+\kern-0.05em+}}$\cr}%
+% }
+\begin{document}
+\begin{center}
+\Large \textbf {Drell-Yan Vector Boson Production with {\tt MCPWNLO}} \\
+\end{center}
+\section{Introduction}
+This manual describes how to use this program to generate Drell-Yan events at hadron colliders with NLO accuracy using the {\tt MC@NLO} \cite{Frixione:2002ik} and {\tt POWHEG} \cite{Nason:2004rx} methods. More details on the use and application of the program and its interface with {\tt Herwig++} \cite{Bahr:2008pv} can be found in \cite{LatundeDada:2007jg, seyi}.
+\section{Setting the parameters}
+Within the directory {\tt MCPWNLO/DRELLYAN}, the file {\tt DYPP\_INPUTS.h} includes all the available user parameters
+for the main program {\tt DYPP.cxx}. The parameters are:\\
+\\
+{\tt bool MCNLO}: Set to {\tt true} if the {\tt MC@NLO} method is to be used or {\tt
+ false} if the {\tt POWHEG} method is to be used. \\
+{\tt bool trunc}: Set to {\tt true} if truncated shower of at most one gluon is to be
+implemented for {\tt POWHEG} method. Note that to interface with an angular ordered
+shower, this should be set to {\tt true}. \\
+{\tt int VBID}: Particle ID for the vector boson required. Set to {\tt 23} for $Z$ boson
+production or {\tt 24} for $W$ boson production. \\
+{\tt double cme}: The hadron-hadron center of mass energy in GeV e.g. 1800/1960 for the
+Tevatron and 14000 for the LHC. \\
+{\tt bool acc}: Type of collider. Set to {\tt true} if $p-p$ or {\tt false} if
+{$p-\bar{p}$. \\
+{\tt double Mz}: Pole mass of the $Z$ boson in GeV.
+{\tt double Mw}: Pole mass of the $W$ boson in GeV.
+{\tt bool zerowidth }: Set to {\tt true} if zero width approximation is to be used or {\tt
+ false} if Breit-Wigner resonance is to be used for boson mass. \\
+{\tt double widthw}: Width of the $W$ boson in GeV.\\
+{\tt double widthz}: Width of the $Z$ boson in GeV.\\
+{\tt double halfwidth}: Number of halfwidths either side of the resonance peak. \\
+{\tt char* rscheme}: Factorization scheme. Options are ``{\tt MSbar}'' and ``{\tt DIS}''.\\
+{\tt char* PDFset}: The PDFset to be used e.g. ``{\tt cteq5m.LHgrid}''. Make sure this agrees with the factorization
+scheme set above. \\
+{\tt int nevint}: Number of events (typically $ \approx 10^5$) to integrate over for cross-section calculation and
+determination of maximum weights. \\
+{\tt int nevgen}: Number of events (typically $\approx 10^5$) to generate. \\
+{\tt int rseed}: Initial seed for the random number generator. \\
+
+\section{Generating partonic events}
+After setting the parameters, open the {\tt Makefile} and set {\tt LHAPDFDIR} to your
+{\tt LHAPDF} directory. Also set {\tt HERWIGDIR} to the address of the {\tt Herwig} folder
+in the directory {\tt MCPWNLO}.
+To run {\tt DYPP.cxx}, in the folder {\tt DRELLYAN}, type the following commands :\\
+\\
+{\tt make clean} \\
+{\tt make} \\
+\\
+This creates the executable {\tt DYPP} and {\tt run\_dypp} (which is moved to {\tt
+ HERWIGDIR}). Next, type:
+{\tt ./DYPP} \\
+This runs the main program and generates the Les Houches file for interface with \textsf{Herwig++}. This file will be called {\tt PWDYPP.dat} if running {\tt POWHEG} and {\tt
+ MCDYPP.dat} if running {\tt MC@NLO}. It contains unweighted events with absolute weights
+of $1$.
+\section{{\tt POWHEG} requirements}
+If running {\tt POWHEG}, go to the folder {\tt PWInstallFiles} in the main {\tt MCPWNLO}
+directory. There you will find the following files:\\
+{\tt PartnerFinder.cc} {\tt PartnerFinder.h} {\tt PartnerFinder.icc}
+Replace the files of the same names in {\tt /Shower/Base} folder of your \textsf{Herwig++}
+installation directory. Then go back to the {\tt Shower} folder not in {\tt Base}!) and type: \\
+\\
+{\tt make} \\
+{\tt make install} \\
+\\
+This allows us to set the colour partner of the hardest emission correctly for {\tt
+ POWHEG}.
+\section{Analysis}
+
+In the folder {\tt DYAnalysis} in the {\tt DRELLYAN} directory are some analysis files
+which analyze the events after interfacing the Les Houches file with
+\textsf{Herwig++}. \\
+{\tt MySimpleAnalysis.cc} contains the main program which provides
+histograms for the transverse momenta of the dilepton pair produced from the vector
+bosons, the rapidity and azimuthal distributions of the bosons, the masses of the bosons and the rapidity and
+azimuths of the leptons. Other histograms can be added by booking histograms in the {\tt
+ MySimpleAnalysis.icc} file and declaring them in the {\tt MySimpleAnalysis.h}.\\
+Open the {\tt Makefile} and set {\tt HPDIR} and
+{\tt THEPEGDIR} to the folder where you installed \textsf{Herwig++} and
+\textsf{ThePEG}. Compile the directory by typing the following commands. \\
+\\
+{\tt make} \\
+{\tt make install} \\
+\\
+in the {\tt DYAnalysis} directory. This recreates the library, {\tt MySimpleAnalysis.so}.
+
+\section{Interfacing with \textsf{Herwig++}}
+Having generated the Les Houches file and set up the analysis handler, the next step is to
+run \textsf{Herwig++}. It is assumed that both \textsf{Herwig++} and \textsf{ThePEG} have
+already been installed on your system.
+
+Now go to the directory {\tt MCPWNLO/Herwig} and open the initialization file {\tt
+ DYPP.in}. This contains \textsf{Herwig++} user parameters which can be set depending on
+which process and NLO method you are running. The default set-up is for {\tt MC@NLO} $W$
+boson production at the $1800$ GeV Tevatron. A selection of these are:\\
+\\
+{\tt set Reader2:FileName DYPP.dat}: This is the filename for the Les Houches file your
+generated file is converted into by the program {\tt DRELLYAN/run\_dypp.cxx}. Leave this
+as it is! \\
+{\tt set Reader2:EBeamA 900.0}: The beam energy in GeV of the hadron from the `left'. \\
+{\tt set Reader2:EBeamB 900.0}: The beam energy in GeV of the hadron from the `right'.\\
+{\tt set LesHouchesHandler:WeightOption NegUnitWeight}: The weight option for the
+events. This allows for negative weighted events. \\
+{\tt insert SimpleQCD:MatrixElements[0] MEqq2W2ff}: The hard process. Here it's set up for
+$W$ boson production.\\
+\\
+Next are commands which should be uncommented if running {\tt POWHEG}. If running {\\
+tt MC@NLO}, comment these out. \\
+\\
+{\tt set /Herwig/Shower/Evolver:HardVetoMode 0}: The veto mode to be applied. For {\tt
+ POWHEG}, this should be set to $1$.\\
+{\tt set /Herwig/Shower/PartnerFinder:PHPartnerFinder 0}: The partner finder option. This
+should be set to $1$ for {\tt POWHEG}.\\
+{\tt set /Herwig/Shower/Evolverr:HardVetoScaleSource 0}: This reads the maximum $p_T$ for
+the veto from {\tt SCALUP} in the LEs Houches file. Set this to $1$ for {\tt POWHEG}.\\
+\\
+Having set up the initialization file, run \textsf{Herwig++} by typing the following
+commands: \\
+\\
+{\tt ./run\_dypp [eventfile] [number of events]} \\
+\\
+An example of the run
+command is:\\
+\\
+{\tt ./run\_dypp /usera/seyi/MCPWNLO/DRELLYAN/MCDYPP.dat 10000}\\
+\\
+where you should replace the eventfile with the path to your Les Houches file.
+\\
+ At the end of the run, a topdraw file called {\tt MG-MySimpleAnalysis.top} will be
+ produced containing the histograms booked by the analysis handler. If you have topdraw
+ installed, you can convert this to a postscript file by typing the command:\\
+\\
+{\tt td -dPOSTSCRIPT MG-MySimpleAnalysis.top}
+\section{Further Information}
+For further information about {\tt MCPWNLO} contact: {\tt seyi@hep.phy.cam.ac.uk}.
+\bibliography{manual}
+\bibliographystyle{utphys}
+\end{document}
+%%% Local Variables:
+%%% mode: latex
+%%% TeX-master: t
+%%% End:
diff --git a/Contrib/MCPWNLO/HIGGSDEC/manual.bib b/Contrib/MCPWNLO/HIGGSDEC/manual.bib
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/HIGGSDEC/manual.bib
@@ -0,0 +1,91 @@
+@Article{Frixione:2002ik,
+ author = "Frixione, Stefano and Webber, Bryan R.",
+ title = "Matching {NLO QCD} computations and parton shower
+ simulations",
+ journal = "JHEP",
+ volume = "06",
+ year = "2002",
+ pages = "029",
+ eprint = "hep-ph/0204244",
+ SLACcitation = "%%CITATION = HEP-PH 0204244;%%"
+}
+@Article{LatundeDada:2006gx,
+ author = "Latunde-Dada, Oluseyi and Gieseke, Stefan and Webber, Bryan
+ ",
+ title = "A positive-weight next-to-leading-order {M}onte {C}arlo for $e^+
+ e^-$ annihilation to hadrons",
+ journal = "JHEP",
+ volume = "02",
+ year = "2007",
+ pages = "051",
+ eprint = "hep-ph/0612281",
+ SLACcitation = "%%CITATION = HEP-PH/0612281;%%"
+}
+@Article{LatundeDada:2008bv,
+ author = "Latunde-Dada, Oluseyi",
+ title = "{Applying the POWHEG method to top pair production and
+ decays at the ILC}",
+ journal = "Eur. Phys. J.",
+ volume = "C58",
+ year = "2008",
+ pages = "543-554",
+ eprint = "0806.4560",
+ archivePrefix = "arXiv",
+ primaryClass = "hep-ph",
+ doi = "10.1140/epjc/s10052-008-0785-1",
+ SLACcitation = "%%CITATION = 0806.4560;%%"
+}
+@Article{Bahr:2008pv,
+ author = "Bahr, M. and others",
+ title = "{Herwig++ Physics and Manual}",
+ journal = "Eur. Phys. J.",
+ volume = "C58",
+ year = "2008",
+ pages = "639-707",
+ eprint = "0803.0883",
+ archivePrefix = "arXiv",
+ primaryClass = "hep-ph",
+ doi = "10.1140/epjc/s10052-008-0798-9",
+ SLACcitation = "%%CITATION = 0803.0883;%%"
+}
+@Article{LatundeDada:2007jg,
+ author = "Latunde-Dada, Oluseyi",
+ title = "{Herwig++ Monte Carlo At Next-To-Leading Order for e+e-
+ annihilation and lepton pair production}",
+ journal = "JHEP",
+ volume = "11",
+ year = "2007",
+ pages = "040",
+ eprint = "0708.4390",
+ archivePrefix = "arXiv",
+ primaryClass = "hep-ph",
+ doi = "10.1088/1126-6708/2007/11/040",
+ SLACcitation = "%%CITATION = 0708.4390;%%"
+}
+@Article{Nason:2004rx,
+ author = "Nason, Paolo",
+ title = "A new method for combining {NLO QCD} with shower {M}onte {C}arlo
+ algorithms",
+ journal = "JHEP",
+ volume = "11",
+ year = "2004",
+ pages = "040",
+ eprint = "hep-ph/0409146",
+ SLACcitation = "%%CITATION = HEP-PH/0409146;%%"
+}
+@PHDTHESIS{seyi,
+author = "Latunde-Dada, O.A.T",
+year = "2008",
+school = "University of Cambridge",
+title = "Simulations of QCD processes at High Energy Colliders {\bf [http://www.hep.phy.cam.ac.uk/theory/seyi/thesis/thesis.tar.gz]}"
+}
+@Article{LatundeDada:2009rr,
+ author = "Latunde-Dada, Oluseyi",
+ title = "{MC@NLO for the hadronic decay of Higgs bosons in
+ associated production with vector bosons}",
+ year = "2009",
+ eprint = "0903.4135",
+ archivePrefix = "arXiv",
+ primaryClass = "hep-ph",
+ SLACcitation = "%%CITATION = 0903.4135;%%"
+}
diff --git a/Contrib/MCPWNLO/HIGGSDEC/run_PPVH.cxx b/Contrib/MCPWNLO/HIGGSDEC/run_PPVH.cxx
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/HIGGSDEC/run_PPVH.cxx
@@ -0,0 +1,67 @@
+#include <cstdlib>
+#include <ctime>
+#include <iostream>
+#include <string>
+#include <fstream>
+#include <cmath>
+#include <iomanip>
+
+using namespace std;
+
+
+int main (int argc, char *argv[]) {
+ string eventfile = "";
+ string numevents = "1";
+ if(argv[1] && argv[2]) { eventfile = argv[1]; numevents = argv[2];} else { cout << "Use: run_hpp [eventfile] [numevents]" << endl; exit(1); }
+
+ cout << "Running Herwig++ with eventfile: " << eventfile << " and " << numevents << " events\n";
+ // ifstream stream;
+ //ofstream outstream;
+ //ofstream outorigin;
+ //string allfile = "";
+ // string addstr = "";
+
+ // stream.open("wpnlo.in");
+ // outstream.open("wpnlo.temp");
+ //outorigin.open("wpnlo.orig");
+ // if(!stream) { cerr << "Error: Failed to open file" << endl;}
+
+ // string search_string = "eventfile.dat";
+ //string replace_string = eventfile;
+ //string inbuf;
+
+ // while(!stream.eof())
+ //{
+ // getline(stream, inbuf);
+ // int spot = inbuf.find(search_string);
+ // outorigin << inbuf << endl;
+ // if(spot >= 0)
+ // {
+ // string tmpstring = inbuf.substr(0,spot);
+ // tmpstring += replace_string;
+ // tmpstring += inbuf.substr(spot+search_string.length(), inbuf.length());
+ // inbuf = tmpstring;
+ // }
+ // outstream << inbuf << endl;
+ //
+ // }
+ //outstream.close();
+ //stream.close();
+
+ string runcomm1 = "mv ";
+ runcomm1.append(eventfile);
+ runcomm1.append(" PPVH.dat");
+ system(runcomm1.c_str());
+ cout << "Reading PPVH.in..." << endl;
+ system("Herwig++ read PPVH.in");
+ cout << "Done..." << endl;
+ cout << "Running MG.run..." << endl;
+ string runcomm2 = "Herwig++ run MG.run -N";
+ cout << "Done!" << endl;
+ runcomm2.append(numevents);
+ system(runcomm2.c_str());
+ string runcomm3 = "mv PPVH.dat ";
+ runcomm3.append(eventfile);
+ system(runcomm3.c_str());
+ // system("mv wpnlo.orig wpnlo.in");
+}
diff --git a/Contrib/MCPWNLO/HIGGSDEC/run_eeZH.cxx b/Contrib/MCPWNLO/HIGGSDEC/run_eeZH.cxx
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/HIGGSDEC/run_eeZH.cxx
@@ -0,0 +1,67 @@
+#include <cstdlib>
+#include <ctime>
+#include <iostream>
+#include <string>
+#include <fstream>
+#include <cmath>
+#include <iomanip>
+
+using namespace std;
+
+
+int main (int argc, char *argv[]) {
+ string eventfile = "";
+ string numevents = "1";
+ if(argv[1] && argv[2]) { eventfile = argv[1]; numevents = argv[2];} else { cout << "Use: run_hpp [eventfile] [numevents]" << endl; exit(1); }
+
+ cout << "Running Herwig++ with eventfile: " << eventfile << " and " << numevents << " events\n";
+ // ifstream stream;
+ //ofstream outstream;
+ //ofstream outorigin;
+ //string allfile = "";
+ // string addstr = "";
+
+ // stream.open("wpnlo.in");
+ // outstream.open("wpnlo.temp");
+ //outorigin.open("wpnlo.orig");
+ // if(!stream) { cerr << "Error: Failed to open file" << endl;}
+
+ // string search_string = "eventfile.dat";
+ //string replace_string = eventfile;
+ //string inbuf;
+
+ // while(!stream.eof())
+ //{
+ // getline(stream, inbuf);
+ // int spot = inbuf.find(search_string);
+ // outorigin << inbuf << endl;
+ // if(spot >= 0)
+ // {
+ // string tmpstring = inbuf.substr(0,spot);
+ // tmpstring += replace_string;
+ // tmpstring += inbuf.substr(spot+search_string.length(), inbuf.length());
+ // inbuf = tmpstring;
+ // }
+ // outstream << inbuf << endl;
+ //
+ // }
+ //outstream.close();
+ //stream.close();
+
+ string runcomm1 = "mv ";
+ runcomm1.append(eventfile);
+ runcomm1.append(" eeZH.dat");
+ system(runcomm1.c_str());
+ cout << "Reading eeZH.in..." << endl;
+ system("Herwig++ read eeZH.in");
+ cout << "Done..." << endl;
+ cout << "Running MG.run..." << endl;
+ string runcomm2 = "Herwig++ run MG.run -N";
+ cout << "Done!" << endl;
+ runcomm2.append(numevents);
+ system(runcomm2.c_str());
+ string runcomm3 = "mv eeZH.dat ";
+ runcomm3.append(eventfile);
+ system(runcomm3.c_str());
+ // system("mv wpnlo.orig wpnlo.in");
+}
diff --git a/Contrib/MCPWNLO/Herwig/DYPP.in b/Contrib/MCPWNLO/Herwig/DYPP.in
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/Herwig/DYPP.in
@@ -0,0 +1,115 @@
+# This will read in all the standard hadron decay modes and add
+# the new particles that are used in HERWIG 6.4, but not in ThePEG
+#read Decays.in
+#
+#cd /Herwig/
+#set theGlobalParameters:EffectiveGluonMass 0.750*GeV
+#set theGlobalParameters:HadronizationScale 0.5*GeV
+#set theGlobalParameters:OnOffThePEGStringFragmentationMode 0
+#set theGlobalParameters:OnOffSoftUnderlyingEventMode 0
+#set theGlobalParameters:MinVirtuality2 0.1*GeV2
+#set theGlobalParameters:MaxDisplacement 1.0e-10*millimeter
+#
+set /Herwig/Particles/B0:Stable 0
+set /Herwig/Particles/B+:Stable 0
+set /Herwig/Particles/B_s0:Stable 0
+set /Herwig/Particles/Lambda_b0:Stable 0
+set /Herwig/Particles/Xi_b0:Stable 0
+set /Herwig/Particles/Xi_b-:Stable 0
+set /Herwig/Particles/Omega_b-:Stable 0
+
+#
+mkdir LesHouches
+cd LesHouches
+library LesHouches.so
+cd /Herwig/EventHandlers
+create ThePEG::LesHouchesFileReader Reader2 LesHouches.so
+set Reader2:FileName DYPP.dat
+set Reader2:BeamA 2212
+# Beam B = 2212 for proton-proton e.g. LHC collisions
+set Reader2:BeamB -2212
+set Reader2:EBeamA 900.0
+set Reader2:EBeamB 900.0
+set Reader2:PDFA /Herwig/Partons/MRST
+set Reader2:PDFB /Herwig/Partons/MRST
+create ThePEG::Cuts QCDCuts
+set QCDCuts:ScaleMin 1.0*GeV
+set QCDCuts:X1Min 0.00001
+set QCDCuts:X2Min 0.00001
+set QCDCuts:MHatMin 20.*GeV
+set QCDCuts:X1Max 0.9
+set QCDCuts:X2Max 0.9
+create ThePEG::LesHouchesEventHandler LesHouchesHandler
+insert LesHouchesHandler:LesHouchesReaders[0] Reader2
+set LesHouchesHandler:PartonExtractor /Herwig/Partons/QCDExtractor
+set LesHouchesHandler:StatLevel 2
+set LesHouchesHandler:CascadeHandler /Herwig/Shower/ShowerHandler
+set LesHouchesHandler:HadronizationHandler /Herwig/Hadronization/ClusterHadHandler
+set LesHouchesHandler:DecayHandler /Herwig/Decays/DecayHandler
+# MCatNLO option
+set LesHouchesHandler:WeightOption NegUnitWeight
+# POWHEG option
+#set LesHouchesHandler:WeightOption UnitWeight
+# insert LesHouchesHandler:PostSubProcessHandlers [0] /Herwig/QEDRadiation/QEDRadHandler
+
+cd /Herwig/Generators
+create ThePEG::EventGenerator MGGenerator
+set MGGenerator:RandomNumberGenerator /Herwig/Random
+set MGGenerator:StandardModelParameters /Herwig/Model
+set MGGenerator:EventHandler /Herwig/EventHandlers/LesHouchesHandler
+
+cd /Herwig/Generators
+set MGGenerator:EventHandler:Cuts /Herwig/Cuts/QCDCuts
+
+cd /Herwig/Cuts
+set JetKtCut:MinKT 0.0*GeV
+
+cd /Herwig/MatrixElements/
+
+# Drell-Yan Z/gamma
+insert SimpleQCD:MatrixElements[0] MEqq2W2ff
+# Z boson production option
+#MEqq2gZ2ff
+
+#set MEee2gZ2qq:MinimumFlavour 1
+#set MEee2gZ2qq:MaximumFlavour 5
+
+
+cd /Herwig/Analysis
+create Herwig::MySimpleAnalysis MySimpleAnalysis MySimpleAnalysis.so
+insert /Herwig/Generators/MGGenerator:AnalysisHandlers 0 MySimpleAnalysis
+
+#cd /Herwig/Shower
+# HardVetoMode : 0 (All off), 1 (All on), 2 (only IS emissions vetoed)
+#, 3 (only FS emissions vetoed).
+# For MC@NLO set HardVetoMode = 0. For POWHEG set HardVetoMode = 1 or 2
+##################################################################
+#set /Herwig/Shower/Evolver:HardVetoMode 0
+##################################################################
+##################################################################
+# PHPartnerFinder = 1 for POWHEG
+##################################################################
+#set /Herwig/Shower/PartnerFinder:PHPartnerFinder 0
+##################################################################
+# HardVetoRead. Set to 1 for POWHEG.
+##################################################################
+#set /Herwig/Shower/Evolver:HardVetoScaleSource 1
+##################################################################
+# 1.9 GeV for Tevatron W/Z production.
+# 2.2 GeV for LHC W/Z production
+##################################################################
+set /Herwig/Shower/Evolver:IntrinsicPtGaussian 1.9*GeV
+##################################################################
+set /Herwig/Shower/Evolver:MECorrMode 0
+##################################################################
+cd /Herwig/Generators/
+set MGGenerator:NumberOfEvents 1000000
+set MGGenerator:RandomNumberGenerator:Seed 31122001
+set MGGenerator:PrintEvent 10
+set MGGenerator:MaxErrors 100000000
+#set MGGenerator:EventHandler:LuminosityFunction:Energy 14000.0
+#set MGGenerator:Strategy /Herwig/ThePEGStrategy
+#set MGGenerator:EventHandler:LuminosityFunction:Energy 500
+#
+saverun MG MGGenerator
+
diff --git a/Contrib/MCPWNLO/Herwig/EPEM.in b/Contrib/MCPWNLO/Herwig/EPEM.in
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/Herwig/EPEM.in
@@ -0,0 +1,138 @@
+# This will read in all the standard hadron decay modes and add
+# the new particles that are used in HERWIG 6.4, but not in ThePEG
+#read Decays.in
+#
+#cd /Herwig/
+#set theGlobalParameters:EffectiveGluonMass 0.750*GeV
+#set theGlobalParameters:HadronizationScale 0.5*GeV
+#set theGlobalParameters:OnOffThePEGStringFragmentationMode 0
+#set theGlobalParameters:OnOffSoftUnderlyingEventMode 0
+#set theGlobalParameters:MinVirtuality2 0.1*GeV2
+#set theGlobalParameters:MaxDisplacement 1.0e-10*millimeter
+#
+set /Herwig/Particles/B0:Stable 0
+set /Herwig/Particles/B+:Stable 0
+set /Herwig/Particles/B_s0:Stable 0
+set /Herwig/Particles/Lambda_b0:Stable 0
+set /Herwig/Particles/Xi_b0:Stable 0
+set /Herwig/Particles/Xi_b-:Stable 0
+set /Herwig/Particles/Omega_b-:Stable 0
+
+#
+mkdir LesHouches
+cd LesHouches
+library LesHouches.so
+cd /Herwig/EventHandlers
+create ThePEG::LesHouchesFileReader Reader2 LesHouches.so
+set Reader2:FileName EPEM.dat
+set Reader2:BeamA 11
+set Reader2:BeamB -11
+set Reader2:EBeamA 45.6
+set Reader2:EBeamB 45.6
+set Reader2:PDFA /Herwig/Partons/LeptonPDF
+set Reader2:PDFB /Herwig/Partons/LeptonPDF
+create ThePEG::Cuts QCDCuts
+set QCDCuts:ScaleMin 1.0*GeV
+set QCDCuts:X1Min 0.00001
+set QCDCuts:X2Min 0.00001
+set QCDCuts:MHatMin 20.*GeV
+set QCDCuts:X1Max 0.9
+set QCDCuts:X2Max 0.9
+create ThePEG::LesHouchesEventHandler LesHouchesHandler
+insert LesHouchesHandler:LesHouchesReaders[0] Reader2
+set LesHouchesHandler:PartonExtractor /Herwig/Partons/EEExtractor
+set LesHouchesHandler:StatLevel 2
+set LesHouchesHandler:CascadeHandler /Herwig/Shower/ShowerHandler
+set LesHouchesHandler:HadronizationHandler /Herwig/Hadronization/ClusterHadHandler
+set LesHouchesHandler:DecayHandler /Herwig/Decays/DecayHandler
+#set LesHouchesHandler:WeightOption VarNegWeight
+# MCatNLO option
+set LesHouchesHandler:WeightOption NegUnitWeight
+# POWHEG option
+#set LesHouchesHandler:WeightOption UnitWeight
+# insert LesHouchesHandler:PostSubProcessHandlers [0] /Herwig/QEDRadiation/QEDRadHandler
+
+cd /Herwig/Generators
+create ThePEG::EventGenerator MGGenerator
+set MGGenerator:RandomNumberGenerator /Herwig/Random
+set MGGenerator:StandardModelParameters /Herwig/Model
+set MGGenerator:EventHandler /Herwig/EventHandlers/LesHouchesHandler
+
+cd /Herwig/Generators
+set MGGenerator:EventHandler:Cuts /Herwig/Cuts/EECuts
+
+cd /Herwig/MatrixElements/
+
+#e+e-
+insert SimpleEE:MatrixElements 0 /Herwig/MatrixElements/MEee2gZ2qq
+
+
+set MEee2gZ2qq:MinimumFlavour 1
+set MEee2gZ2qq:MaximumFlavour 5
+
+cd /Herwig/Generators
+
+cd /Herwig/Analysis
+create Herwig::MyMultiplicityCount MyMultiplicity MyMultiplicityCount.so
+create Herwig::MyLEPBMultiplicity MyBMultiplicity MyLEPBMultiplicity.so
+create Herwig::MyBFragmentationAnalysisHandler MyBFrag MyBFragmentationAnalysisHandler.so
+create Herwig::MyEventShapes MyLEPShapes MyEventShapes.so
+create Herwig::MyEventShapesMasterAnalysis MyShapes MyEventShapesMasterAnalysis.so
+create Herwig::MyLEPEventShapes MyLEPEvent MyLEPEventShapes.so
+create Herwig::MyIdentifiedParticleAnalysis MyLEPIdent MyIdentifiedParticleAnalysis.so
+create Herwig::MySingleParticleAnalysis MyLEPSingle MySingleParticleAnalysis.so
+
+set MyShapes:MyEventShapes MyLEPShapes MyEventShapes.so
+set MyLEPEvent:MyEventShapes MyLEPShapes MyEventShapes.so
+set MyLEPSingle:MyEventShapes MyLEPShapes MyEventShapes.so
+insert MyShapes:Slaves 0 MyLEPEvent
+insert MyShapes:Slaves 0 MyLEPSingle
+insert /Herwig/Generators/MGGenerator:AnalysisHandlers 0 MyMultiplicity
+insert /Herwig/Generators/MGGenerator:AnalysisHandlers 0 MyBMultiplicity
+insert /Herwig/Generators/MGGenerator:AnalysisHandlers 0 MyBFrag
+insert /Herwig/Generators/MGGenerator:AnalysisHandlers 0 MyShapes
+insert /Herwig/Generators/MGGenerator:AnalysisHandlers 0 MyLEPIdent
+insert /Herwig/Generators/MGGenerator:AnalysisHandlers 0 MyLEPEvent
+
+#cd /Herwig/Shower
+# HardVetoMode : 0 (All off), 1 (All on), 2 (only IS emissions vetoed),
+#3 (only FS emissions vetoed).
+# HardVetoMode = 1 for POWHEG
+##################################################################
+set /Herwig/Shower/Evolver:HardVetoMode 1
+##################################################################
+# PHPartnerFinder = 1 for POWHEG
+##################################################################
+set /Herwig/Shower/PartnerFinder:PHPartnerFinder 1
+##################################################################
+# HardVetoRead. Set to 1 for POWHEG.
+##################################################################
+set /Herwig/Shower/Evolver:HardVetoScaleSource 1
+##################################################################
+
+set /Herwig/Shower/Evolver:MECorrMode 0
+
+##################################################################
+#For MC@NLO, use these settings...
+##################################################################
+set /Herwig/Shower/AlphaQCD:AlphaMZ 0.118
+set /Herwig/Shower/SudakovCommon:cutoffKinScale 2.45*GeV
+##################################################################
+#For POWHEG use these settings...
+##################################################################
+#set /Herwig/Shower/AlphaQCD:AlphaMZ 0.127
+#set /Herwig/Shower/SudakovCommon:cutoffKinScale 2.60*GeV
+##################################################################
+
+cd /Herwig/Generators/
+set MGGenerator:NumberOfEvents 1000000
+set MGGenerator:RandomNumberGenerator:Seed 31122001
+set MGGenerator:PrintEvent 10
+set MGGenerator:MaxErrors 100000000
+set MGGenerator:EventHandler:CascadeHandler:MPIHandler NULL
+#set MGGenerator:EventHandler:LuminosityFunction:Energy 14000.0
+#set MGGenerator:Strategy /Herwig/ThePEGStrategy
+#set MGGenerator:EventHandler:LuminosityFunction:Energy 500
+#
+saverun MG MGGenerator
+
diff --git a/Contrib/MCPWNLO/Herwig/ILCTTB.in b/Contrib/MCPWNLO/Herwig/ILCTTB.in
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/Herwig/ILCTTB.in
@@ -0,0 +1,104 @@
+# This will read in all the standard hadron decay modes and add
+# the new particles that are used in HERWIG 6.4, but not in ThePEG
+#read Decays.in
+#
+#cd /Herwig/
+#set theGlobalParameters:EffectiveGluonMass 0.750*GeV
+#set theGlobalParameters:HadronizationScale 0.5*GeV
+#set theGlobalParameters:OnOffThePEGStringFragmentationMode 0
+#set theGlobalParameters:OnOffSoftUnderlyingEventMode 0
+#set theGlobalParameters:MinVirtuality2 0.1*GeV2
+#set theGlobalParameters:MaxDisplacement 1.0e-10*millimeter
+#
+set /Herwig/Particles/B0:Stable 0
+set /Herwig/Particles/B+:Stable 0
+set /Herwig/Particles/B_s0:Stable 0
+set /Herwig/Particles/Lambda_b0:Stable 0
+set /Herwig/Particles/Xi_b0:Stable 0
+set /Herwig/Particles/Xi_b-:Stable 0
+set /Herwig/Particles/Omega_b-:Stable 0
+
+#
+mkdir LesHouches
+cd LesHouches
+library LesHouches.so
+cd /Herwig/EventHandlers
+#create ThePEG::LesHouchesFileReader Reader2 MadGraphReader.so
+create ThePEG::LesHouchesFileReader Reader2 LesHouches.so
+set Reader2:FileName TTB.dat
+set Reader2:BeamA 11
+set Reader2:BeamB -11
+set Reader2:EBeamA 250.0
+set Reader2:EBeamB 250.0
+set Reader2:PDFA /Herwig/Partons/LeptonPDF
+set Reader2:PDFB /Herwig/Partons/LeptonPDF
+create ThePEG::Cuts QCDCuts
+set QCDCuts:ScaleMin 1.0*GeV
+set QCDCuts:X1Min 0.00001
+set QCDCuts:X2Min 0.00001
+set QCDCuts:MHatMin 20.*GeV
+set QCDCuts:X1Max 0.9
+set QCDCuts:X2Max 0.9
+create ThePEG::LesHouchesEventHandler LesHouchesHandler
+insert LesHouchesHandler:LesHouchesReaders[0] Reader2
+set LesHouchesHandler:PartonExtractor /Herwig/Partons/QCDExtractor
+#set LesHouchesHandler:PartonExtractor /Herwig/Partons/EEExtractor
+set LesHouchesHandler:StatLevel 2
+set LesHouchesHandler:CascadeHandler /Herwig/Shower/ShowerHandler
+set LesHouchesHandler:HadronizationHandler /Herwig/Hadronization/ClusterHadHandler
+set LesHouchesHandler:DecayHandler /Herwig/Decays/DecayHandler
+set LesHouchesHandler:WeightOption UnitWeight
+# insert LesHouchesHandler:PostSubProcessHandlers [0] /Herwig/QEDRadiation/QEDRadHandler
+
+cd /Herwig/Generators
+create ThePEG::EventGenerator MGGenerator
+set MGGenerator:RandomNumberGenerator /Herwig/Random
+set MGGenerator:StandardModelParameters /Herwig/Model
+set MGGenerator:EventHandler /Herwig/EventHandlers/LesHouchesHandler
+
+cd /Herwig/Generators
+set MGGenerator:EventHandler:Cuts /Herwig/Cuts/EECuts
+
+cd /Herwig/MatrixElements/
+
+#e+e-
+insert SimpleEE:MatrixElements 0 /Herwig/MatrixElements/MEee2gZ2qq
+#MEqq2W2ff MEqq2gZ2ff MEee2gZ2qq
+
+set MEee2gZ2qq:MinimumFlavour 6
+set MEee2gZ2qq:MaximumFlavour 6
+
+cd /Herwig/Analysis
+create Herwig::SimpleILCAnalysis SimpleILC SimpleILCAnalysis.so
+insert /Herwig/Generators/MGGenerator:AnalysisHandlers 0 SimpleILC
+
+#cd /Herwig/Shower
+# HardVetoMode : 0 (All off), 1 (All on), 2 (only IS emissions vetoed)
+#, 3 (only FS emissions vetoed).
+##################################################################
+set /Herwig/Shower/Evolver:HardVetoMode 1
+##################################################################
+# POWHEGTOPVeto: 0 (off), 1 (All on), 2 (Only top production veto on),
+# 3 (only top decay veto on).
+# NB: You need to set HardVetoMode = 1 or 3 for POWHEGTOPVeto to work.
+#############################################################
+set /Herwig/Shower/Evolver:POWHEGTOPVeto 1
+#############################################################
+set /Herwig/Shower/Evolver:MECorrMode 0
+##################################################################
+# PHPartnerFinder = 0 deault and 1 for POWHEG
+##################################################################
+set /Herwig/Shower/PartnerFinder:PHPartnerFinder 1
+##################################################################
+cd /Herwig/Generators/
+set MGGenerator:NumberOfEvents 1000000
+set MGGenerator:RandomNumberGenerator:Seed 31122001
+set MGGenerator:PrintEvent 10
+set MGGenerator:MaxErrors 100000000
+set MGGenerator:EventHandler:CascadeHandler:MPIHandler NULL
+#set MGGenerator:EventHandler:LuminosityFunction:Energy 14000.0
+#set MGGenerator:Strategy /Herwig/ThePEGStrategy
+#set MGGenerator:EventHandler:LuminosityFunction:Energy 500
+#
+saverun MG MGGenerator
+
diff --git a/Contrib/MCPWNLO/Herwig/PPVH.in b/Contrib/MCPWNLO/Herwig/PPVH.in
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/Herwig/PPVH.in
@@ -0,0 +1,90 @@
+# This will read in all the standard hadron decay modes and add
+# the new particles that are used in HERWIG 6.4, but not in ThePEG
+#read Decays.in
+#
+#cd /Herwig/
+#set theGlobalParameters:EffectiveGluonMass 0.750*GeV
+#set theGlobalParameters:HadronizationScale 0.5*GeV
+#set theGlobalParameters:OnOffThePEGStringFragmentationMode 0
+#set theGlobalParameters:OnOffSoftUnderlyingEventMode 0
+#set theGlobalParameters:MinVirtuality2 0.1*GeV2
+#set theGlobalParameters:MaxDisplacement 1.0e-10*millimeter
+#
+set /Herwig/Particles/B0:Stable 0
+set /Herwig/Particles/B+:Stable 0
+set /Herwig/Particles/B_s0:Stable 0
+set /Herwig/Particles/Lambda_b0:Stable 0
+set /Herwig/Particles/Xi_b0:Stable 0
+set /Herwig/Particles/Xi_b-:Stable 0
+set /Herwig/Particles/Omega_b-:Stable 0
+
+#
+mkdir LesHouches
+cd LesHouches
+library LesHouches.so
+cd /Herwig/EventHandlers
+#create ThePEG::LesHouchesFileReader Reader2 MadGraphReader.so
+create ThePEG::LesHouchesFileReader Reader2 LesHouches.so
+set Reader2:FileName PPVH.dat
+set Reader2:BeamA 2212
+set Reader2:BeamB -2212
+set Reader2:EBeamA 980.0
+set Reader2:EBeamB 980.0
+set Reader2:PDFA /Herwig/Partons/MRST
+set Reader2:PDFB /Herwig/Partons/MRST
+create ThePEG::Cuts QCDCuts
+set QCDCuts:ScaleMin 1.0*GeV
+set QCDCuts:X1Min 0.00001
+set QCDCuts:X2Min 0.00001
+set QCDCuts:MHatMin 20.*GeV
+set QCDCuts:X1Max 0.9
+set QCDCuts:X2Max 0.9
+create ThePEG::LesHouchesEventHandler LesHouchesHandler
+insert LesHouchesHandler:LesHouchesReaders[0] Reader2
+set LesHouchesHandler:PartonExtractor /Herwig/Partons/QCDExtractor
+set LesHouchesHandler:StatLevel 2
+set LesHouchesHandler:CascadeHandler /Herwig/Shower/ShowerHandler
+set LesHouchesHandler:HadronizationHandler /Herwig/Hadronization/ClusterHadHandler
+set LesHouchesHandler:DecayHandler /Herwig/Decays/DecayHandler
+set LesHouchesHandler:WeightOption NegUnitWeight
+# insert LesHouchesHandler:PostSubProcessHandlers [0] /Herwig/QEDRadiation/QEDRadHandler
+
+cd /Herwig/Cuts
+set JetKtCut:MinKT 0.0*GeV
+
+cd /Herwig/Generators
+create ThePEG::EventGenerator MGGenerator
+set MGGenerator:RandomNumberGenerator /Herwig/Random
+set MGGenerator:StandardModelParameters /Herwig/Model
+set MGGenerator:EventHandler /Herwig/EventHandlers/LesHouchesHandler
+
+cd /Herwig/Generators
+set MGGenerator:EventHandler:Cuts /Herwig/Cuts/QCDCuts
+
+cd /Herwig/MatrixElements/
+
+#e+e-
+insert SimpleQCD:MatrixElements[0] /Herwig/MatrixElements/MEPP2WH
+#MEqq2W2ff MEqq2gZ2ff MEee2gZ2qq
+
+set /Herwig/Shower/Evolver:IntrinsicPtGaussian 1.9*GeV
+
+set /Herwig/Shower/Evolver:MECorrMode 0
+
+cd /Herwig/Analysis
+cd /Herwig/Analysis
+create Herwig::MyVHAnalysis MyVHAnalysis MyVHAnalysis.so
+insert /Herwig/Generators/MGGenerator:AnalysisHandlers 0 MyVHAnalysis
+
+cd /Herwig/Generators/
+set MGGenerator:NumberOfEvents 1000000
+set MGGenerator:RandomNumberGenerator:Seed 31122001
+set MGGenerator:PrintEvent 10
+set MGGenerator:MaxErrors 100000000
+set MGGenerator:EventHandler:CascadeHandler:MPIHandler NULL
+#set MGGenerator:EventHandler:LuminosityFunction:Energy 14000.0
+#set MGGenerator:Strategy /Herwig/ThePEGStrategy
+#set MGGenerator:EventHandler:LuminosityFunction:Energy 500
+#
+saverun MG MGGenerator
+
diff --git a/Contrib/MCPWNLO/Herwig/eeZH.in b/Contrib/MCPWNLO/Herwig/eeZH.in
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/Herwig/eeZH.in
@@ -0,0 +1,90 @@
+# This will read in all the standard hadron decay modes and add
+# the new particles that are used in HERWIG 6.4, but not in ThePEG
+#read Decays.in
+#
+#cd /Herwig/
+#set theGlobalParameters:EffectiveGluonMass 0.750*GeV
+#set theGlobalParameters:HadronizationScale 0.5*GeV
+#set theGlobalParameters:OnOffThePEGStringFragmentationMode 0
+#set theGlobalParameters:OnOffSoftUnderlyingEventMode 0
+#set theGlobalParameters:MinVirtuality2 0.1*GeV2
+#set theGlobalParameters:MaxDisplacement 1.0e-10*millimeter
+#
+set /Herwig/Particles/B0:Stable 0
+set /Herwig/Particles/B+:Stable 0
+set /Herwig/Particles/B_s0:Stable 0
+set /Herwig/Particles/Lambda_b0:Stable 0
+set /Herwig/Particles/Xi_b0:Stable 0
+set /Herwig/Particles/Xi_b-:Stable 0
+set /Herwig/Particles/Omega_b-:Stable 0
+
+#
+mkdir LesHouches
+cd LesHouches
+library LesHouches.so
+cd /Herwig/EventHandlers
+#create ThePEG::LesHouchesFileReader Reader2 MadGraphReader.so
+create ThePEG::LesHouchesFileReader Reader2 LesHouches.so
+set Reader2:FileName eeZH.dat
+set Reader2:BeamA 11
+set Reader2:BeamB -11
+set Reader2:EBeamA 250.0
+set Reader2:EBeamB 250.0
+set Reader2:PDFA /Herwig/Partons/LeptonPDF
+set Reader2:PDFB /Herwig/Partons/LeptonPDF
+create ThePEG::Cuts QCDCuts
+set QCDCuts:ScaleMin 1.0*GeV
+set QCDCuts:X1Min 0.00001
+set QCDCuts:X2Min 0.00001
+set QCDCuts:MHatMin 20.*GeV
+set QCDCuts:X1Max 0.9
+set QCDCuts:X2Max 0.9
+create ThePEG::LesHouchesEventHandler LesHouchesHandler
+insert LesHouchesHandler:LesHouchesReaders[0] Reader2
+#set LesHouchesHandler:PartonExtractor /Herwig/Partons/QCDExtractor
+set LesHouchesHandler:PartonExtractor /Herwig/Partons/EEExtractor
+set LesHouchesHandler:StatLevel 2
+set LesHouchesHandler:CascadeHandler /Herwig/Shower/ShowerHandler
+set LesHouchesHandler:HadronizationHandler /Herwig/Hadronization/ClusterHadHandler
+set LesHouchesHandler:DecayHandler /Herwig/Decays/DecayHandler
+set LesHouchesHandler:WeightOption NegUnitWeight
+# insert LesHouchesHandler:PostSubProcessHandlers [0] /Herwig/QEDRadiation/QEDRadHandler
+
+cd /Herwig/Generators
+create ThePEG::EventGenerator MGGenerator
+set MGGenerator:RandomNumberGenerator /Herwig/Random
+set MGGenerator:StandardModelParameters /Herwig/Model
+set MGGenerator:EventHandler /Herwig/EventHandlers/LesHouchesHandler
+
+cd /Herwig/Generators
+set MGGenerator:EventHandler:Cuts /Herwig/Cuts/EECuts
+
+cd /Herwig/MatrixElements/
+
+#e+e-
+insert SimpleEE:MatrixElements 0 /Herwig/MatrixElements/MEee2ZH
+#MEqq2W2ff MEqq2gZ2ff MEee2gZ2qq
+
+#set MEee2gZ2qq:MinimumFlavour 6
+#set MEee2gZ2qq:MaximumFlavour 6
+
+cd /Herwig/Analysis
+create Herwig::MyVHAnalysis MyVHAnalysis MyVHAnalysis.so
+insert /Herwig/Generators/MGGenerator:AnalysisHandlers 0 MyVHAnalysis
+
+##################################################################
+set /Herwig/Shower/Evolver:MECorrMode 0
+##################################################################
+
+cd /Herwig/Generators/
+set MGGenerator:NumberOfEvents 1000000
+set MGGenerator:RandomNumberGenerator:Seed 31122001
+set MGGenerator:PrintEvent 100
+set MGGenerator:MaxErrors 100000000
+set MGGenerator:EventHandler:CascadeHandler:MPIHandler NULL
+#set MGGenerator:EventHandler:LuminosityFunction:Energy 14000.0
+#set MGGenerator:Strategy /Herwig/ThePEGStrategy
+#set MGGenerator:EventHandler:LuminosityFunction:Energy 500
+#
+saverun MG MGGenerator
+
diff --git a/Contrib/MCPWNLO/ILCTTBAR/ILCAnalysis/Makefile b/Contrib/MCPWNLO/ILCTTBAR/ILCAnalysis/Makefile
new file mode 100755
--- /dev/null
+++ b/Contrib/MCPWNLO/ILCTTBAR/ILCAnalysis/Makefile
@@ -0,0 +1,37 @@
+# -*- Makefile -*- (for emacs)
+
+#
+# This Makefile is intended for compiling Herwig++ plugins
+# You can find plugins here: INSERT URL
+#
+# This Makefile received very little testing,
+# any bug reports are very welcome!
+#
+
+# location of include files
+HPPDIR = /usera/seyi/Herwig
+THEPEGDIR = /usera/seyi/Herwig
+
+#CLHEPINCLUDE =
+#ROOTINCLUDE = -I/usera/andreas/root/include
+#ROOTCFLAGS := $(shell /usera/andreas/root/bin/root-config --ldflags)
+#ROOTGLIBS := $(shell /usera/andreas/root/bin/root-config --glibs)
+#ROOT = $(ROOTCFLAGS) $(ROOTGLIBS)
+INCLUDE = -I$(THEPEGDIR)/include -I$(HPPDIR)/include
+#
+# C++ flags
+#
+CXX = g++
+CXXFLAGS = -O2
+
+ALLCCFILES=$(shell echo *.cc)
+all : $(ALLCCFILES:.cc=.so)
+
+%.so : %.cc %.h
+ $(CXX) -fPIC $(CPPFLAGS) $(INCLUDE) $(ROOT) $(CXXFLAGS) -shared $< -o $@
+
+install:
+# cp LEPEventShapes.so $(HPPDIR)/lib/Herwig++
+ cp SimpleILCAnalysis.so $(HPPDIR)/lib/Herwig++
+clean:
+ rm -f $(ALLCCFILES:.cc=.so)
diff --git a/Contrib/MCPWNLO/ILCTTBAR/ILCAnalysis/SimpleILCAnalysis.cc b/Contrib/MCPWNLO/ILCTTBAR/ILCAnalysis/SimpleILCAnalysis.cc
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/ILCTTBAR/ILCAnalysis/SimpleILCAnalysis.cc
@@ -0,0 +1,315 @@
+// -*- C++ -*-
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the SimpleLHCAnalysis class.
+//
+
+#include "SimpleILCAnalysis.h"
+#include "ThePEG/Repository/EventGenerator.h"
+#include "ThePEG/EventRecord/Particle.h"
+#include "ThePEG/EventRecord/Event.h"
+#include "ThePEG/PDT/EnumParticles.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+
+#ifdef ThePEG_TEMPLATES_IN_CC_FILE
+// #include "SimpleILCAnalysis.tcc"
+#endif
+
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+
+using namespace Herwig;
+
+SimpleILCAnalysis::SimpleILCAnalysis() :
+ _acostem(0.,3.2,32),
+ _acostee(0.,3.2,32),
+ _acostebe(0.,3.2,32),
+ _Mt(120.,200.,100),
+ _Mtb(120.,200.,100),
+ _rapb(-5.,5.,50),
+ _rapbb(-5.,5.,50),
+ _pzb(-200.,200.,80),
+ _pzbb(-200.,200.,80),
+ _ptb(0.,200.,40),
+ _ptbb(0.,200.,40),
+ _pbe(0.,200.,40),
+ _pbbe(0.,200.,40),
+ _pzbr(0.,1.,50),
+ _pzbbr(0.,1.,50),
+ _ptbr(0.,1.,50),
+ _ptbbr(0.,1.,50)
+
+{}
+
+
+void SimpleILCAnalysis::analyze(tEventPtr event, long, int, int) {
+ eventweight_=event->weight();
+ cout << "eventweight" << " " << eventweight_ << endl;
+ // Rotate to CMS, extract final state particles and call analyze(particles).
+
+ Lorentz5Momentum pz;
+ StepVector::const_iterator sit =event->primaryCollision()->steps().begin();
+ StepVector::const_iterator send=event->primaryCollision()->steps().end();
+
+ ParticleVector b;
+ b.clear();
+ ParticleVector lept;
+ lept.clear();
+
+ Lorentz5Momentum pb(0.0,0.0,0.0,0.0,0.0);
+ Lorentz5Momentum pbb(0.0,0.0,0.0,0.0,0.0);
+
+ for( ;sit!=send;sit=send)
+
+ for(sit=send-2;sit!=send-1;++sit) {
+ ParticleSet partt=(**sit).all();
+ ParticleSet::const_iterator iterr=partt.begin();
+ ParticleSet::const_iterator endd =partt.end();
+ for( ;iterr!=endd;++iterr) {
+ if (fabs((**iterr).id())==5) {
+
+ b.push_back((*iterr));
+ }
+ }
+ ParticleVector::const_iterator iters=b.begin();
+ ParticleVector::const_iterator ends =b.end();
+ for( ;iters!=ends;++iters) {
+ if ((**iters).id()==5) {
+ pb=(*iters)->momentum();
+ } else
+ if ((**iters).id()==-5) {
+ pbb=(*iters)->momentum();
+
+ }
+ }
+ }
+
+ for(sit=send-2;sit!=send-1;++sit)
+ {
+ ParticleSet part=(**sit).all();
+ ParticleSet::const_iterator iter=part.begin();
+ ParticleSet::const_iterator end =part.end();
+
+ for( ;iter!=end;++iter) {
+ if (((fabs((**iter).id())==11) || (fabs((**iter).id())==12) )&& (**iter).children().size()==0) {
+ lept.push_back((*iter));
+ }
+ }
+
+
+ Lorentz5Momentum pep(0.0,0.0,0.0,0.0,0.0);
+ Lorentz5Momentum pem(0.0,0.0,0.0,0.0,0.0);
+ Lorentz5Momentum pnup(0.0,0.0,0.0,0.0,0.0);
+ Lorentz5Momentum pnum(0.0,0.0,0.0,0.0,0.0);
+ ParticleVector::const_iterator iter1=lept.begin();
+ ParticleVector::const_iterator end1 =lept.end();
+
+ for( ;iter1!=end1;++iter1) {
+ if((**iter1).id()==-11) {
+ pep=(*iter1)->momentum();}
+ else if ((**iter1).id()==11) {
+ pem=(*iter1)->momentum();}
+ else if ((**iter1).id()==-12) {
+ pnup=(*iter1)->momentum();}
+ else if ((**iter1).id()==12) {
+ pnum=(*iter1)->momentum();}
+
+ }
+
+ Energy pbe=pb.e()/GeV;
+ Energy pbbe=pbb.e()/GeV;
+ Energy ptb=pb.perp()/GeV;
+ Energy ptbb=pbb.perp()/GeV;
+ double ptbr=ptb/pbe;
+ double ptbbr=ptbb/pbbe;
+
+ Energy pzb=pb.z()/GeV;
+ Energy pzbb=pbb.z()/GeV;
+ double pzbr=pzb/pbe;
+ double pzbbr=pzbb/pbbe;
+ double rapb=0.5*log((pbe+pzb)/(pbe-pzb));
+ double rapbb=0.5*log((pbbe+pzbb)/(pbbe-pzbb));
+ Lorentz5Momentum pt=pb+pep+pnum;
+ Lorentz5Momentum ptbar=pbb+pem+pnup;
+ Energy Mt=pt.mass()/GeV;
+ Energy Mtb=ptbar.mass()/GeV;
+
+
+ double costem = (pem.x()*pt.x()+pem.y()*pt.y()+pem.z()*pt.z())/(sqrt(pem.perp()*pem.perp()+pem.z()*pem.z())*sqrt(pt.perp()*pt.perp()+pt.z()*pt.z()));
+ double acostem = acos(costem);
+
+ double costee = (pem.x()*pep.x()+pem.y()*pep.y()+pem.z()*pep.z())/(sqrt(pem.x()*pem.x()+pem.y()*pem.y()+pem.z()*pem.z())*sqrt(pep.perp()*pep.perp()+pep.z()*pep.z()));
+ double acostee = acos(costee);
+
+ double costebe= pem.z()/sqrt(pem.perp()*pem.perp()+pem.z()*pem.z());
+ double acostebe = acos(costebe);
+
+ _acostem.addWeighted(acostem,eventweight_);
+ _acostee.addWeighted(acostee,eventweight_);
+ _acostebe.addWeighted(acostebe,eventweight_);
+ _Mt.addWeighted(Mt,eventweight_);
+ _Mtb.addWeighted(Mtb,eventweight_);
+ _pbe.addWeighted(pbe,eventweight_);
+ _pbbe.addWeighted(pbbe,eventweight_);
+ _ptb.addWeighted(ptb,eventweight_);
+ _ptbb.addWeighted(ptbb,eventweight_);
+ _ptbr.addWeighted(ptbr,eventweight_);
+ _ptbbr.addWeighted(ptbbr,eventweight_);
+ _pzbr.addWeighted(pzbr,eventweight_);
+ _pzbbr.addWeighted(pzbbr,eventweight_);
+ _rapb.addWeighted(rapb,eventweight_);
+ _rapbb.addWeighted(rapbb,eventweight_);
+ _pzb.addWeighted(pzb,eventweight_);
+ _pzbb.addWeighted(pzbb,eventweight_);
+
+ }
+
+}
+
+//LorentzRotation SimpleILCAnalysis::transform(tEventPtr) const {
+// return LorentzRotation();
+ // Return the Rotation to the frame in which you want to perform the analysis.
+//}
+
+//void SimpleILCAnalysis::analyze(const tPVector & particles) {
+// AnalysisHandler::analyze(particles);
+//}
+
+//void SimpleILCAnalysis::analyze(tPPtr) {}
+
+//void SimpleILCAnalysis::persistentOutput(PersistentOStream &) const {
+ // *** ATTENTION *** os << ; // Add all member variable which should be written persistently here.
+//}
+
+//void SimpleILCAnalysis::persistentInput(PersistentIStream &, int) {
+ // *** ATTENTION *** is >> ; // Add all member variable which should be read persistently here.
+//}
+
+NoPIOClassDescription<SimpleILCAnalysis> SimpleILCAnalysis::initSimpleILCAnalysis;
+// Definition of the static class description member.
+
+void SimpleILCAnalysis::Init() {
+
+ static ClassDocumentation<SimpleILCAnalysis> documentation
+ ("There is no documentation for the SimpleILCAnalysis class");
+
+}
+
+ void SimpleILCAnalysis::dofinish() {
+ AnalysisHandler::dofinish();
+ string fname = generator()->filename() + string("-") + name() + string(".top");
+ ofstream outfile(fname.c_str());
+ string title;
+ using namespace HistogramOptions;
+
+ _Mt.topdrawOutput(outfile,Frame,"BLACK","Mass of top (e+,nu,b)/GeV");
+
+ _Mtb.topdrawOutput(outfile,Frame,"BLACK","Mass of anti-top (e-,nubar,bbar)/GeV");
+
+ _acostem.topdrawOutput(outfile,Frame,"BLACK","Angle between top and decay e-");
+ _acostee.topdrawOutput(outfile,Frame,"BLACK","Angle between decay e+ and e-");
+ _acostebe.topdrawOutput(outfile,Frame,"BLACK","Angle between decay e- and beam e-");
+
+ _rapb.topdrawOutput(outfile,Frame|Ylog,"BLACK","Rapidity of b quark");
+ _rapbb.topdrawOutput(outfile,Frame|Ylog,"BLACK","Rapidity of anti-b quark");
+
+ _pbe.topdrawOutput(outfile,Frame,"BLACK","Energy of b quark");
+ _pbbe.topdrawOutput(outfile,Frame,"BLACK","Energy of anti-b quark");
+ _ptb.topdrawOutput(outfile,Frame,"BLACK","Transverse mmt of b quark");
+ _ptbb.topdrawOutput(outfile,Frame,"BLACK","Transverse mmt of anti-b quar");
+ _ptbr.topdrawOutput(outfile,Frame,"BLACK","Transverse mmt/Energy ratio of b quark");
+ _ptbbr.topdrawOutput(outfile,Frame,"BLACK","Transverse mmt/Energy ratio of anti-b quark");
+ _pzb.topdrawOutput(outfile,Frame,"BLACK","Longitudinal mmt of b quark");
+ _pzbb.topdrawOutput(outfile,Frame,"BLACK","Longitudinal mmt of anti-b quark");
+ _pzbr.topdrawOutput(outfile,Frame,"BLACK","Longitudinal mmt/Energy ratio of b quark");
+ _pzbbr.topdrawOutput(outfile,Frame,"BLACK","Longitudinal mmt/Energy ratio of anti-b quark");
+
+}
+
+
+// void SimpleILCAnalysis::analyze(tEventPtr event, long ieve, int loop, int state) {
+// // AnalysisHandler::analyze(event, ieve, loop, state);
+// // Rotate to CMS, extract final state particles and call analyze(particles).
+// // find the Z
+// Lorentz5Momentum pz;
+// StepVector::const_iterator sit =event->primaryCollision()->steps().begin();
+// StepVector::const_iterator send=event->primaryCollision()->steps().end();
+// for(;sit!=send;++sit)
+// {
+// ParticleSet part=(**sit).all();
+// ParticleSet::const_iterator iter=part.begin();
+// ParticleSet::const_iterator end =part.end();
+// for( ;iter!=end;++iter)
+// {
+// if(((**iter).id()==ParticleID::Z0||(**iter).id()==ParticleID::gamma)&&
+// (**iter).children().size()==2)
+// {
+// pz=getMomentum(*iter);
+// Energy pt = pz.perp()/GeV;
+// Energy mz = pz.mass()/GeV;
+// if(mz>20.&&mz<80.) (_ptZ[1])+=(pt);
+// else if (mz>80.&&mz<100.) (_ptZ[2])+=(pt);
+// else if (mz>100.) (_ptZ[3])+=(pt);
+// (_ptZ[0])+=(pt);
+// (_mZ)+=(mz);
+// double rap = 0.5*log((pz.e()+pz.z())/(pz.e()-pz.z()));
+// (_rapZ)+=(rap);
+// (_phiZ)+=pz.phi();
+// } else if ((**iter).id()==ParticleID::Wplus) {
+// pz=getMomentum(*iter);
+// Energy pt = pz.perp()/GeV;
+// Energy mz = pz.mass()/GeV;
+// if(mz>20.&&mz<80.) (_ptWp[1])+=(pt);
+// else if (mz>80.&&mz<100.) (_ptWp[2])+=(pt);
+// else if (mz>100.) (_ptWp[3])+=(pt);
+// (_ptWp[0])+=(pt);
+// (_mWp)+=(mz);
+// double rap = 0.5*log((pz.e()+pz.z())/(pz.e()-pz.z()));
+// (_rapWp)+=(rap);
+// (_phiWp)+=pz.phi();
+// } else if ((**iter).id()==ParticleID::Wminus) {
+// pz=getMomentum(*iter);
+// Energy pt = pz.perp()/GeV;
+// Energy mz = pz.mass()/GeV;
+// if(mz>20.&&mz<80.) (_ptWm[1])+=(pt);
+// else if (mz>80.&&mz<100.) (_ptWm[2])+=(pt);
+// else if (mz>100.) (_ptWm[3])+=(pt);
+// (_ptWm[0])+=(pt);
+// (_mWm)+=(mz);
+// double rap = 0.5*log((pz.e()+pz.z())/(pz.e()-pz.z()));
+// (_rapWm)+=(rap);
+// (_phiWm)+=pz.phi();
+// }
+// }
+// }
+// }
+
+// LorentzRotation SimpleILCAnalysis::transform(tEventPtr event) const {
+// return LorentzRotation();
+// // Return the Rotation to the frame in which you want to perform the analysis.
+// }
+
+// void SimpleILCAnalysis::analyze(const tPVector & particles) {
+// AnalysisHandler::analyze(particles);
+// }
+
+// void SimpleILCAnalysis::analyze(tPPtr) {}
+
+// void SimpleILCAnalysis::persistentOutput(PersistentOStream & os) const {
+// // *** ATTENTION *** os << ; // Add all member variable which should be written persistently here.
+// }
+
+// void SimpleILCAnalysis::persistentInput(PersistentIStream & is, int) {
+// // *** ATTENTION *** is >> ; // Add all member variable which should be read persistently here.
+// }
+
+// ClassDescription<SimpleILCAnalysis> SimpleILCAnalysis::initSimpleILCAnalysis;
+// // Definition of the static class description member.
+
+// void SimpleILCAnalysis::Init() {
+
+// static ClassDocumentation<SimpleILCAnalysis> documentation
+// ("There is no documentation for the SimpleILCAnalysis class");
+
+// }
+
diff --git a/Contrib/MCPWNLO/ILCTTBAR/ILCAnalysis/SimpleILCAnalysis.h b/Contrib/MCPWNLO/ILCTTBAR/ILCAnalysis/SimpleILCAnalysis.h
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/ILCTTBAR/ILCAnalysis/SimpleILCAnalysis.h
@@ -0,0 +1,232 @@
+// -*- C++ -*-
+#ifndef HERWIG_SimpleILCAnalysis_H
+#define HERWIG_SimpleILCAnalysis_H
+//
+// This is the declaration of the SimpleILCAnalysis class.
+//
+
+#include "ThePEG/Repository/CurrentGenerator.h"
+#include "ThePEG/Handlers/AnalysisHandler.h"
+#include "Herwig++/Utilities/Histogram.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * Here is the documentation of the SimpleILCAnalysis class.
+ *
+ * @see \ref SimpleILCAnalysisInterfaces "The interfaces"
+ * defined for SimpleILCAnalysis.
+ */
+class SimpleILCAnalysis: public AnalysisHandler {
+
+public:
+
+ /** @name Standard constructors and destructors. */
+ //@{
+ /**
+ * The default constructor.
+ */
+ SimpleILCAnalysis();
+
+ 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();
+
+ /** @name Virtual functions required by the AnalysisHandler class. */
+ //@{
+ /**
+ * Analyze a given Event. Note that a fully generated event
+ * may be presented several times, if it has been manipulated in
+ * between. The default version of this function will call transform
+ * to make a lorentz transformation of the whole event, then extract
+ * all final state particles and call analyze(tPVector) of this
+ * analysis object and those of all associated analysis objects. The
+ * default version will not, however, do anything on events which
+ * have not been fully generated, or have been manipulated in any
+ * way.
+ * @param event pointer to the Event to be analyzed.
+ * @param ieve the event number.
+ * @param loop the number of times this event has been presented.
+ * If negative the event is now fully generated.
+ * @param state a number different from zero if the event has been
+ * manipulated in some way since it was last presented.
+ */
+ virtual void analyze(tEventPtr event, long ieve, int loop, int state);
+
+ /**
+ * Transform the event to the desired Lorentz frame and return the
+ * corresponding LorentzRotation.
+ * @param event a pointer to the Event to be transformed.
+ * @return the LorentzRotation used in the transformation.
+ */
+ // virtual LorentzRotation transform(tEventPtr event) const;
+
+ /**
+ * Analyze the given vector of particles. The default version calls
+ * analyze(tPPtr) for each of the particles.
+ * @param particles the vector of pointers to particles to be analyzed
+ */
+ // virtual void analyze(const tPVector & particles);
+
+ /**
+ * Analyze the given particle.
+ * @param particle pointer to the particle to be analyzed.
+ */
+ // virtual void analyze(tPPtr particle);
+ //@}
+
+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.
+ */
+ inline virtual IBPtr clone() const {return new_ptr(*this);}
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ inline virtual IBPtr fullclone() const {return new_ptr(*this);}
+ //@}
+
+protected:
+
+ /** @name Standard Interfaced functions. */
+ //@{
+ /**
+ * Finalize this object. Called in the run phase just after a
+ * run has ended. Used eg. to write out statistics.
+ */
+ inline virtual void dofinish();
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static NoPIOClassDescription<SimpleILCAnalysis> initSimpleILCAnalysis;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ SimpleILCAnalysis & operator=(const SimpleILCAnalysis &);
+
+private:
+
+ /**
+ * The weight for the event
+ */
+ double eventweight_;
+ /**
+ * Mass of the top pair
+ */
+ Histogram _Mt;
+ Histogram _Mtb;
+
+ /**
+ * Momenta of the b, bbar (energy pbe,pbbe, transverse mmt
+ *ptb ptbb, long. mmt pzb, pzbb and ratios to the energies
+ * ending in *r
+ */
+ Histogram _pbe;
+ Histogram _pbbe;
+ Histogram _ptb;
+ Histogram _ptbb;
+ Histogram _ptbr;
+ Histogram _ptbbr;
+ Histogram _pzb;
+ Histogram _pzbb;
+ Histogram _pzbr;
+ Histogram _pzbbr;
+ /**
+ * Rapidity of b, bbar
+ */
+ Histogram _rapb;
+ Histogram _rapbb;
+ /**
+ * Correlation angles
+ */
+ Histogram _acostem; // btw Decay electron and top
+ Histogram _acostee; // btw Decay charged leptons
+ Histogram _acostebe; // btw Decay electron and incoming e-
+
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of SimpleILCAnalysis. */
+template <>
+struct BaseClassTrait<Herwig::SimpleILCAnalysis,1> {
+ /** Typedef of the first base class of SimpleILCAnalysis. */
+ typedef AnalysisHandler NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the SimpleILCAnalysis class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::SimpleILCAnalysis>
+ : public ClassTraitsBase<Herwig::SimpleILCAnalysis> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::SimpleILCAnalysis"; }
+ /** Return the name(s) of the shared library (or libraries) be loaded to get
+ * access to the SimpleILCAnalysis class and any other class on which it depends
+ * (except the base class). */
+ static string library() { return "SimpleILCAnalysis.so"; }
+};
+
+/** @endcond */
+
+}
+
+//#include "SimpleILCAnalysis.icc"
+#ifndef ThePEG_TEMPLATES_IN_CC_FILE
+// #include "SimpleILCAnalysis.tcc"
+#endif
+
+#endif /* HERWIG_SimpleILCAnalysis_H */
diff --git a/Contrib/MCPWNLO/ILCTTBAR/ILCTTBAR.cxx b/Contrib/MCPWNLO/ILCTTBAR/ILCTTBAR.cxx
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/ILCTTBAR/ILCTTBAR.cxx
@@ -0,0 +1,3194 @@
+/* This program generates top pairs at NLO accuracy from polarized e+e- annihilation
+at the ILC.
+ The events are produced in the LH xml format */
+#include <cstdlib>
+#include <ctime>
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <fstream>
+#include <stdio.h>
+#include <cmath>
+#include <iomanip>
+#include "ILCTTBAR_INPUTS.h"
+using namespace std;
+
+void filegen(double &rintgend1a, double &rintgend2a,double &rintgend3a, double &rintgend4a,double &rintgend1v, double &rintgend2v,double &rintgend3v, double &rintgend4v); // generates production interpolation files
+
+ void filegendec (double &rintgend1, double &rintgend2, double &rintgend3, double &rintgend4);// generates decay interpolation files
+
+double coeff(int N, double XXX, bool axi); //interpolates for vector/axial coefficeints
+
+double interp(int N,double XXX, double Xmax1, double Xmax2, double Xmax3, double Xmax4, bool axi); // interpolates for production process
+
+ double interpd(int N,double XXX, double Xmax1, double Xmax2, double Xmax3, double Xmax4);// interpolates for decay process
+
+void xmaxmin (double pt2, double d2, double &rxmax, double &rxmin5,double &rxmin6); // finds maximum and minimum values for variable x in production process
+
+double ME (double d2, double pt2,double &rx, double &ry1, double &ry2,double xmin5, double &rM1, double &rM2, double &rw, bool axi); //calculates matrix element for production process
+
+ double MEd (double pt2,double &rx3, double &rx11, double &rx12, double &rMd1, double &rMd2);//calculates matrix element for decay process
+
+ void PolarizedME (double xt, double xtb, double xg, double &rct, double &rst, double &rsphi, double &rcphi,double &rLLL,double &rLRR,double &rLRL,double &rLLR,double &rRLL,double &rRRR, double &rRRL,double &rRLR,double areafac);//calculates polarized matrix element for production process
+
+ double PolMEdec(double xw1, double xb1, double xg1,double &rctw, double &rctl,double &rbphi, double &rbgphi,int tm, double xd0, double zd0, double fac);//calculates polarized matrix element for decay process
+
+double random (int &rseed); // random number generator
+
+double ddilog(double x); //Dilogarithm function
+
+bool ax(int rseed1); // axial-vector or vector?
+
+/***************************************************************************************************/
+// PARAMETERS
+ Input user;
+ double pi = 3.14152654;
+ double b = 23./(12.*pi);
+ double bp = 58./(46.*pi);
+ double mt =175.;
+ double emcm = user.cme();
+ double ms = 2.*mt/emcm;
+ double rho = pow(mt/emcm,2);
+ double d2 = pow(ms,2);
+ double beta=sqrt(1.-d2);
+ double CF=4./3.;
+// Max and min kt^2 for production. Note this is kappa.
+ double real = -1440.*rho-44.-1728.*pow(rho,2);
+ double im = 12.*sqrt(fabs(-14592.*pow(rho,3)+3168.*pow(rho,2)-144.*rho-15.+20736.*pow(rho,4)));
+ double magn = sqrt(pow(real,2)+pow(im,2));
+ double theta = atan2(im, real);
+ double xymax = 1./6.*pow(magn,1./3.)*cos(theta/3.)-(-32.*rho-8./3.)/pow(magn,1./3.)*cos(theta/3.)-1./3.;
+ double pt2max = (pow(1.-xymax,2)*(2.*xymax-1.)-rho*pow(2.-2.*xymax,2))/(pow(xymax,2)-4.*rho);
+ double pt2min=pow(0.2/emcm,2);
+ double xmeet = 2./3. + 4./3.*rho;
+ double pt2meet = (pow(1.-xmeet,2)*(2.*xmeet-1.)-rho*pow(2.-2.*xmeet,2))/(pow(xmeet,2)-4.*rho);
+ double mw=80.;
+ double a =pow(mw/mt,2);
+// Max and min kt^2 for decays. Note this is kappa*mt^2
+ double pt2maxd = pow((1.-sqrt(a))/2.,2)*pow(mt,2);
+ double pt2mind = 0.04;
+ double alphaem=0.007297352;
+ double e2 = 4.*pi*alphaem;
+ double s=pow(emcm,2);
+ double Mz=91.2;
+ double Yz=2.486;
+ double GF=0.0000116639;
+ double sinsq2thw=0.2024;
+ double sinsqthw=0.2312;
+ double costhw=0.8768;
+ double k = sqrt(2.)*GF*pow(Mz,2)/e2;
+ double At=0.5;
+ double Qt = 2./3.;
+ double Vt=0.5-2.*Qt*sinsqthw;
+ double Ae=-0.5;
+ double Ve=-0.5+2.*sinsqthw;
+ double Ref=s*(s-pow(Mz,2))/(16.*sinsqthw*(pow((s-pow(Mz,2)),2)+pow(Mz*Yz,2)));
+ double Imf=-Mz*Yz*s/(16.*sinsqthw*(pow((s-pow(Mz,2)),2)+pow(Mz*Yz,2)));
+ double ve = 2.*Ve;
+ double ae = 2.*Ae;
+ double vt = 2.*Vt;
+ double at = 2.*At;
+ int Pm = user.Pem();
+ int Pp = user.Pep();
+ double qel=(2.*sinsqthw-1.)/(2.*costhw);
+ double qer=sinsqthw/costhw;
+ double qtl=(3.-4.*sinsqthw)/(6.*costhw);
+ double qtr= -2.*sinsqthw/(3.*costhw);
+ double c1= coeff(18,ms,false);
+ double d1= coeff (24,ms,true);
+ double chi1 = k*s*(s-pow(Mz,2))/(pow((s-pow(Mz,2)),2)+pow(Yz*Mz,2));
+ double chi2 = pow(k,2)*pow(s,2)/(pow((s-pow(Mz,2)),2)+pow(Yz*Mz,2));
+ double alphaprod =1./(b*log(1./pt2min))*(1.-bp*log(log(1./pt2min))/(b*log(1./pt2min)));
+ double sV=pow(Qt,2)-2.*Qt*Ve*Vt*chi1+(pow(Ae,2)+pow(Ve,2))*pow(Vt,2)*chi2;
+ double sA=(pow(Ae,2)+pow(Ve,2))*pow(At,2)*chi2;
+ double A=(pow(beta,3)+d1*alphaprod/pi)*sA*4.*pi*pow(alphaem,2)/s;
+ double V=(beta*(1.+2.*pow(mt,2)/s)+c1*alphaprod/pi)*sV*4.*pi*pow(alphaem,2)/s;
+
+
+//cross-section in picobarns
+ double AV=(A+V)*389400000.;
+
+// Parameters and integrals for Bbar production and decay born variables
+ double asmt = 0.107; // alphas at top mass
+ double xg0=0.2*2./(pow(beta,2)*emcm);
+ double F1Vg=2./3.;
+ double F1Vz=(0.25-2.*sinsqthw/3.)/(sqrt(sinsqthw)*costhw);
+ double F1Az=(-0.25)/(sqrt(sinsqthw)*costhw);
+ double I1virt=-2.+(1.+pow(beta,2))/(2.*beta)*(-1.5+log(4.*pow(beta,2)/(1.-pow(beta,2)))*log((1.-beta)/(1.+beta))+2.*pow(pi,2)/3.+2*ddilog((1.-beta)/(1.+beta))+0.5*pow((log((1.-beta)/(1.+beta))),2));
+ double I2=(1.-pow(beta,2))/(4.*beta)*(log((1.-beta)/(1.+beta)));
+ double I1soft=-2.*log(xg0)*(1.+(1.+pow(beta,2))/(2.*beta)*log((1.-beta)/(1.+beta)))+log((1.-pow(beta,2))/(4.*pow(beta,2)))-1./beta*log((1.-beta)/(1.+beta))+(1.+pow(beta,2))/(2.*beta)*(-log(pow(beta,2))*log((1.-beta)/(1.+beta))-pow(pi,2)/3+2.*ddilog((1.-beta)/(1.+beta))+0.5*pow((log((1.-beta)/(1.+beta))),2));
+ double I11=I1virt+I1soft;
+ double dF1Vg=asmt*4./(3.*2.*pi)*F1Vg*(I11+I2);
+ double dF1Vz=asmt*4./(3.*2.*pi)*F1Vz*(I11+I2);
+ double dF1Az=asmt*4./(3.*2.*pi)*F1Az*(I11-I2);
+ double sum =0.;
+/***************************************************************************************************/
+
+int main() {
+ // Switches
+ int nevg = user.nevgen();
+ double emcm = user.cme();
+ int seed = user.rseed();
+ bool ptruncate = user.truncpro();
+ bool dtruncate = user.truncdec();
+ bool POWprod = user.POWHEGprod();
+ bool POWdecay = user.POWHEGdecay();
+ //=========================================================//
+ //Parameters for production and decay Bbar born variables
+ bool findmaxprod=false;
+ bool findmaxdec=false;
+ double int1=0.,int2=0.,int3=0.,int4=0.;
+ double max1=0.,max2=0.,max3=0.,max4=0.;
+ double maxd1=0.,maxd2=0.,maxd3=0.,maxd4=0.;
+ //=========================================================//
+ for (int ix = 1; ix < 100000 ; ix++) {
+ double xt=random(seed);
+ double xtb=random(seed);
+ double xgg=2.-xt-xtb;
+ if (xgg < xg0 || (1.-xt)*(1.-xtb)*(xt+xtb-1.) < pow(mt/emcm,2)*pow(2.-xt-xtb,2)) {
+ sum=sum+1.;}
+ }
+ double areafac = 1./(1.-sum/100000.);
+ //=========================================================//
+ double sum = 0.;
+ for (int ix=0; ix <100000; ix++) {
+ double x0=0.2/(mt/2.*(1.-a));
+ double z0=0.0028;
+ double cbgst1, cbgst2;
+ double xg1=random(seed)*(1.-a);
+ double xw1=a+random(seed);
+ double xb1=2.-xw1-xg1;
+ double bw11=sqrt(1.-4.*a/pow(xw1,2));
+ double wb=acos(1./(xw1*bw11*xb1)*(xg1-xw1-xb1+xw1*xb1+2.*a));
+ double wg=acos(1./(xw1*bw11*xg1)*(xb1-xw1-xg1+xw1*xg1+2.*a));
+ double cbg=cos(2.*pi*-wb-wg);
+ double sbg=sin(2.*pi*-wb-wg);
+ double xtp=sqrt(pow((2.-xg1)/2.*mt,2)-pow(xg1*0.5*mt,2));
+ double xte=(2.-xg1)/2.*mt;
+ double vtep=xtp/xte;
+ double gamt=sqrt(1./(1.-pow(vtep,2)));
+ double pb =gamt*(xb1*mt*0.5*cbg-vtep*xte);
+ double pt = xb1*mt*0.5*sbg;
+ cbgst1=cos(atan2(pt,pb));
+ double xg2=random(seed)*(1.-a);
+ double xw2=a+random(seed);
+ double xb2=2.-xw2-xg2;
+ double bw22=sqrt(1.-4.*a/pow(xw2,2));
+ wb=acos(1./(xw2*bw22*xb2)*(xg2-xw2-xb2+xw2*xb2+2.*a));
+ wg=acos(1./(xw2*bw22*xg2)*(xg2-xw2-xg2+xw2*xg2+2.*a));
+ cbg=cos(2.*pi*-wb-wg);
+ sbg=sin(2.*pi*-wb-wg);
+ xtp=sqrt(pow((2.-xg2)/2.*mt,2)-pow(xg2*0.5*mt,2));
+ xte=(2.-xg2)/2.*mt;
+ vtep=xtp/xte;
+ gamt=sqrt(1./(1.-pow(vtep,2)));
+ pb =gamt*(xb2*mt*0.5*cbg-vtep*xte);
+ pt = xb2*mt*0.5*sbg;
+ cbgst2=cos(atan2(pt,pb));
+ if (xg2 < x0 || xg1 < x0 || (1.-cbgst1)/2. < z0|| (1.-cbgst2)/2. < z0|| xw1-a < a*xg1/(1.-xg1)+1.-\
+ xg1 || xw1-a > 1. || xw2-a < a*xg2/(1.-xg2)+1.-xg2 || xw2-a > 1.) {
+ sum++;
+ }
+ }
+ double fac = 1./(1.-sum/100000.);
+ //=========================================================//
+ bool axi = ax(seed);
+ bool emit; // true if truncated emission in production
+ bool demitt, demittb; // true if truncated emission in t and tbar decay respectively
+ double qhp = emcm; //Scale of hardest production emission for use in decay truncated shower
+ int EVT = 0; //Final state polarization identifier
+
+ double T1[6],T2[6],PUP[5][18],AQEDUP,AQCDUP,XWGTUP,SCALUP,mass[18];
+ int ICOLUP[3][18],MOTHUP[3][18],ISTUP[18],ISPINUP[18],IDUP[18],NUP;
+
+ int ii=0; //event count
+
+ //Orientation sines and cosines for top pairs in production and decays
+
+ double cost, sint, costz,costx,costbz,costbx,sintx,sintbx,sintbz,sintz;
+ costz = 0.;costbz = 0.; costx = 0.;costbx = 0.;
+ sintz = 0.;sintbz = 0.; sintx = 0.;sintbx = 0.;
+ double xg1,xg2,xw11,xw12,pt2r1,pt2r2;
+ xg1 = 0.; xg2 = 0.;xw11 = 0.; xw12 = 0.;pt2r1=0.; pt2r2 = 0.;
+ double xgrt, xgrtb, xwrt, xwrtb,ptr2,ptr2b;
+ xgrt = 0.; xgrtb = 0.;ptr2=0.; ptr2b = 0. ;
+ // Integrals at end of pt2-integral tables:production
+ double end1a,end2a,end3a,end4a,end1v,end2v,end3v,end4v ;
+
+ /*********************************START PRODUCTION PROCESS*************************************/
+ if (POWprod) {
+
+ filegen(end1a,end2a, end3a, end4a,end1v,end2v,end3v,end4v);}
+
+// Integrals at end of pt2-integral tables:decay
+ double dend1,dend2,dend3,dend4;
+ if (POWdecay) {
+
+ filegendec (dend1, dend2, dend3, dend4);}
+
+
+ int mm=0;
+ ofstream outdata;
+ bool xml = true ;
+ /**********************************************************************************************/
+ outdata.open("ILCTTBAR.dat", ios::trunc);
+ outdata << "<LesHouchesEvents version =\"1.0\">" << endl; outdata << "<!--" << endl;
+ if (Pm == 1) {outdata << "RH e-" << "\t" ; } else {outdata << "LH e-" << "\t" ; }
+ if (Pp == 1) {outdata << "RH e+" << endl; } else {outdata << "LH e+" ; }
+ outdata << "annihilation at the ILC" << endl;
+ outdata << "File generated with ILCTTBAR.cxx" << endl; outdata << "-->" << endl;
+ outdata << "<init>" << endl;
+ outdata << "\t11\t" << "-11\t" <<"\t" << user.cme()/2. << "\t" << user.cme()/2. << "\t" << "0 \t 0 \t 7\t 7 \t 1 \t 1" << endl;
+ outdata << "\t" << AV << "\t" << 0.000000 << "\t1.00000 \t11" << endl;
+ outdata << "</init>" << endl;
+ /**********************************************************************************************/
+
+ for (int ixx=1; ixx < nevg+1; ixx++) {
+ double x1, x2;
+ if (POWprod) {
+ bool iterate =false;
+ emit = false;
+ double intg=0.;
+
+
+ for (int ia=0; iterate==false; ia++){
+ double logn=fabs(log(random(seed)));
+ intg+=logn;
+ double end1=end1v, end2=end2v, end3=end3v, end4=end4v;
+ if(axi) {end1=end1a, end2=end2a, end3=end3a, end4=end4a;}
+ double pt2=interp(1000,intg,end1,end2,end3,end4,axi);
+
+ if (0.*intg !=0) {break;}
+ if (intg > end4) {break;}
+ if (pt2 < pt2min) {break;}
+ double xmax, xmin5, xmin6;
+
+ xmaxmin(pt2,d2,xmax, xmin5, xmin6);
+ double x, y1, y2, M, M1, M2, w;
+ double Mmax=0.;
+ for (int ix=0; ix < 1000 ; ix++) {
+ x=(xmax-xmin6)*random(seed)+xmin6;
+ M= ME(d2,pt2,x,y1,y2,xmin5,M1,M2,w,axi);
+
+ if (fabs(M) > fabs(Mmax)) {Mmax=M;}
+ }
+ do {
+ x=(xmax-xmin6)*random(seed)+xmin6;
+ M = ME(d2,pt2,x,y1,y2,xmin5,M1,M2,w,axi);} while (random(seed) > fabs(M/Mmax));
+
+ int Jt; // Identifier for solution
+ if (x > xmin5 && pt2 < pt2meet){
+ if (random(seed) < (fabs(M1)/fabs(M))) {
+ //Kleiss trick
+ if (random(seed) < pow(x,2)/(pow(x,2)+pow(y1,2))) {
+ x1=x;
+ x2=y1;
+ Jt=1;}
+ else{
+ x2=x;
+ x1=y1;
+ Jt=2;}
+ mm=mm+1;
+
+ iterate=true;
+
+ }
+ else{
+ //Kleiss trick
+ if (random(seed) < pow(x,2)/(pow(x,2)+pow(y2,2))) {
+ x1=x;
+ x2=y2;
+ Jt=1;}
+ else{
+ x2=x;
+ x1=y2;
+ Jt=2;}
+ mm=mm+1;
+ iterate=true;}}
+ else {
+ //Kleiss trick
+ if (random(seed) < pow(x,2)/(pow(x,2)+pow(y2,2))) {
+ x1=x;
+ x2=y2;
+ Jt=1;}
+ else{
+ x2=x;
+ x1=y2;
+ Jt=2;}
+ mm=mm+1;
+ iterate=true; }
+ if (iterate) {
+
+ double z1, ptr2, ptsq ,z, q;
+ z1 =0.; ptr2 =0.;
+ double x3=2.-x1-x2;
+ double Qg=0.75;
+ double u=mt;
+ double qc=2.8;
+ double CF =4./3.;
+ double alpham=1.;
+ ptsq=pow(emcm,2)*pt2;
+ double l=sqrt(1.-d2);
+ double ac, ab, ag;
+ if (Jt==2) {
+ ac=(x2*(1.+l)-sqrt(pow(x2*(1.+l),2)-2.*d2*(1.+l-d2/2.)))/(2.*(1.+l-d2/2.));
+ ab=0.5*(x1*(1.+l)+sqrt(pow((1.+l)*x1,2)-8.*(d2/4.+pt2)*(1.+l-d2/2.)))/((1.+l-d2/2.));
+ ag=2./(1.+l)-ab-ac;
+ z=ab/(ab+ag);
+ }else {
+ ac=(x1*(1.+l)-sqrt(pow(x1*(1.+l),2)-2.*d2*(1.+l-d2/2.)))/(2.*(1.+l-d2/2.));
+ ab=0.5*(x2*(1.+l)+sqrt(pow((1.+l)*x2,2)-8.*(d2/4.+pt2)*(1.+l-d2/2.)))/((1.+l-d2/2.));
+ ag=2./(1.+l)-ab-ac;
+ z=ab/(ab+ag);
+ }
+
+ /**********************START PRODUCTION TRUNCATED SHOWER****************************/
+ // Scale of hardest emission.
+ qhp=sqrt(ptsq/pow(z*(1.-z),2)+pow(u/z,2)+pow(Qg/(1.-z),2)/z);
+ // Truncated Shower for production
+ if (ptruncate) {
+ double qi=emcm;
+
+
+ if (ptsq/pow(z*(1.-z),2)+pow(u/z,2)+pow(Qg/(1.-z),2)/z < 0.) {emit=false;}
+ double qh=sqrt(ptsq/pow(z*(1.-z),2)+pow(u/z,2)+pow(Qg/(1.-z),2)/z);
+ double C=CF*alpham*log(Qg/(qi-u))/pi;
+ double D=exp(2.*log(qh/qc)*C);
+ double E=exp(2.*log(qi/qc)*C);
+ if (random(seed) < 1.-E/D) {
+ do {
+ q=sqrt(exp(log(E/random(seed))/C)*pow(qc,2));} while (q < qh);
+ double Pzmax=(1.+pow((1.-Qg/emcm),2))/(Qg/emcm)-2.*pow(u,2)/(Qg/emcm*(1.-Qg/emcm)*pow(q,2));
+ double Pz;
+ do{
+ z1=random(seed)*(1.-Qg/emcm-u/emcm)+u/emcm;
+ Pz=(1.+pow(z1,2))/(1.-z1)-2.*pow(u,2)/(z1*(1.-z1)*pow(q,2));} while (random(seed) > Pz/Pzmax);
+
+ ptr2 = pow((1.-z1)*z1*q,2)-pow((1-z1)*u,2)-z1*pow(Qg,2);
+ emit = true;
+ double kapp=pow(sqrt(ptr2)/emcm,2);
+ //energy fractions
+ double ze=ab+2.*((d2/4.+kapp)/ab-d2/4.*ab)/(1.+l);
+ double ab1=z1*(ab+ag);
+ double z1e=ab1+2.*((d2/4.+kapp)/ab1-d2/4.*ab1)/(1.+l);
+ if (Jt==1) {if ((1.-z1e)*(x2+x3)*emcm/2.< sqrt(ptr2)){emit=false;}
+ if (ze*z1e*(x2+x3)*emcm/2.< sqrt(ptsq)) {emit=false;}}
+ if (Jt==2) {if ((1.-z1e)*(x1+x3)*emcm/2.< sqrt(ptr2)){emit=false;}
+ if (ze*z1e*(x1+x3)*emcm/2.< sqrt(ptsq)) {emit=false;}}
+ double alphas = 1./(b*log(ptr2/(pt2min*pow(emcm,2))))*(1.-bp*log(log(ptr2/(pt2min*pow(emcm,2))))/(b*log(ptr2/(pt2min*pow(emcm,2)))));
+ alphas=alphas+pow(alphas,2)*(67./3.-pow(pi,2)-50./9.)/(4.*pi);
+ if (ptr2 < 0 || q > qi || ptr2 > ptsq || random(seed) > alphas/alpham || random(seed) > Pz*(1.-z1)/2.) {emit=false;}
+
+
+ z1=z1e;
+ }
+
+ }
+ /**********************END PRODUCTION TRUNCATED SHOWER****************************/
+ // Polarizer
+
+ double LLL,LRR,LRL,LLR,RLL,RRR,RRL,RLR,ME;
+ ME =0.;
+ double xt, xtb, xg, ct,st,sphi,cphi,phig,maxprod;
+ if (!findmaxprod) {
+ for (int im=0; im < 10000 ; im++) {
+ do {
+ xt=random(seed);
+ xtb=random(seed);
+ xg=2.-xt-xtb;} while (xg < xg0 || (1.-xt)*(1.-xtb)*(xt+xtb-1.) < pow(mt/emcm*xg,2));
+ phig=2.*random(seed)*pi;
+ cphi=cos(phig);
+ sphi=sin(phig);
+ ct=1.-2.*random(seed);
+ st=sin(acos(ct));
+ PolarizedME (xt,xtb,xg,ct,st,sphi,cphi,LLL,LRR,LRL,LLR,RLL,RRR,RRL,RLR,areafac);
+ if (Pm==-1) {if(fabs(LRR) > fabs(max1)) {max1=LRR;}
+ if(fabs(LLR) > fabs(max2)) {max2=LLR;}
+ if(fabs(LRL) > fabs(max3)) {max3=LRL;}
+ if(fabs(LLL) > fabs(max4)) {max4=LLL;}
+ int1+=LRR;
+ int2+=LLR;
+ int3+=LRL;
+ int4+=LLL;
+ } else if (Pm==1) {if(fabs(RRR) > fabs(max1)) {max1=RRR;}
+ if(fabs(RLR) > fabs(max2)) {max2=RLR;}
+ if(fabs(RRL) > fabs(max3)) {max3=RRL;}
+ if(fabs(RLL) > fabs(max4)) {max4=RLL;}
+ int1+=RRR;
+ int2+=RLR;
+ int3+=RRL;
+ int4+=RLL;
+ }
+ }
+
+ }
+ findmaxprod=true;
+
+ double intt=int1+int2+int3+int4;
+ if(random(seed)< (int1+int2)/intt) {
+ if(random(seed) < int1/(int1+int2)) {
+ EVT=1;
+ maxprod=max1;
+} else {
+ EVT=2;
+ maxprod=max2;} }
+ else {if(random(seed) < int3/(int3+int4)) {
+ EVT=3;
+ maxprod=max3;} else {
+ EVT=4;
+ maxprod=max4; }}
+
+ do{
+ do {
+ xt=random(seed);
+ xtb=random(seed);
+ xg=2.-xt-xtb;} while(xg < xg0 || (1.-xt)*(1.-xtb)*(xt+xtb-1.) < pow(mt/emcm*xg,2));
+ phig=2.*random(seed)*pi;
+ cphi=cos(phig);
+ sphi=sin(phig);
+ ct=1.-2.*random(seed);
+ st=sin(acos(ct));
+ PolarizedME (xt,xtb,xg,ct,st,sphi,cphi,LLL,LRR,LRL,LLR,RLL,RRR,RRL,RLR,areafac);
+ if (Pm==-1) {if(EVT==1) {ME=LRR;}
+ if(EVT==2) {ME=LLR;}
+ if(EVT==3) {ME=LRL;}
+ if(EVT==4) {ME=LLL;}
+ } else if (Pm==1) {if(EVT==1) {ME=RRR;}
+ if(EVT==2) {ME=RLR;}
+ if(EVT==3) {ME=RRL;}
+ if(EVT==4) {ME=RLL;}
+ }
+
+ }while (random(seed)> fabs(ME/maxprod));
+
+ double maxphi=0.;
+ double mg=0.75;
+ xg=2.-x1-x2;
+ cphi=1.;
+ sphi=1.;
+ PolarizedME (x1,x2,xg,ct,st,cphi,sphi,LLL,LRR,LRL,LLR,RLL,RRR,RRL,RLR,areafac);
+ if (Pm==-1) {if(EVT==1) {maxphi=LRR;}
+ if(EVT==2) {maxphi=LLR;}
+ if(EVT==3) {maxphi=LRL;}
+ if(EVT==4) {maxphi=LLL;}
+ } else if (Pm==1) {if(EVT==1) {maxphi=RRR;}
+ if(EVT==2) {maxphi=RLR;}
+ if(EVT==3) {maxphi=RRL;}
+ if(EVT==4) {maxphi=RLL;}
+ }
+ cphi=-1.;
+ PolarizedME (x1,x2,xg,ct,st,cphi,sphi,LLL,LRR,LRL,LLR,RLL,RRR,RRL,RLR,areafac);
+ if (Pm==-1) {if(EVT==1) {if(LRR > maxphi){maxphi=LRR;}}
+ if(EVT==2) {if(LLR > maxphi){maxphi=LLR;}}
+ if(EVT==3) {if(LRL > maxphi){maxphi=LRL;}}
+ if(EVT==4) {if(LLL > maxphi){maxphi=LLL;}}
+ } else if (Pm==1) {if(EVT==1) {if(RRR > maxphi){maxphi=RRR;}}
+ if(EVT==2) {if(RLR > maxphi){maxphi=RLR;}}
+ if(EVT==3) {if(RRL > maxphi){maxphi=RRL;}}
+ if(EVT==4) {if(RLL > maxphi){maxphi=RLL;}}
+
+ }
+ do {
+ phig=2.*random(seed)*pi;
+ cphi=cos(phig);
+ sphi=sin(phig);
+ PolarizedME (x1,x2,xg,ct,st,cphi,sphi,LLL,LRR,LRL,LLR,RLL,RRR,RRL,RLR,areafac);
+ if (Pm==-1) {if(EVT==1) {ME=LRR;}
+ if(EVT==2) {ME=LLR;}
+ if(EVT==3) {ME=LRL;}
+ if(EVT==4) {ME=LLL;}
+ } else if (Pm==1) {if(EVT==1) {ME=RRR;}
+ if(EVT==2) {ME=RLR;}
+ if(EVT==3) {ME=RRL;}
+ if(EVT==4) {ME=RLL;}
+ }}while(random(seed)> fabs(ME/maxphi));
+
+ // Assign momenta to production process
+
+ double ppt,ctt,cf;
+ double x=x2+x3;
+ //energy fraction z
+ z=x2/x;
+ if(Jt==2) {x=x1+x3; z=x1/x;}
+ double px1 = sqrt(pow(0.5*emcm*x1,2)-pow(mt,2));
+ double px2 = sqrt(pow(0.5*emcm*x2,2)-pow(mt,2));
+ double c12=(x1*x2-2.*(1.-x3)+d2)/sqrt((pow(x1,2)-d2)*(pow(x2,2)-d2));
+ double c13=(x1*x3-2.*(1.-x2))/(sqrt(pow(x1,2)-d2)*x3);
+ double c23=(x2*x3-2.*(1.-x1))/(sqrt(pow(x2,2)-d2)*x3);
+
+ if (Jt==1) {
+ cf = -c13; ctt = -c12;
+ }else
+ {cf =-c23; ctt =-c12;}
+
+ double phi=2.*pi*random(seed);
+ if (Jt==1) {
+ double x=x2+x3;
+ PUP[3][4]=px1*ct;
+ double pt = sqrt(pow(px1,2)-pow(PUP[3][4],2));
+ PUP[1][4]=pt*cos(phi);
+ PUP[2][4]=pt*sin(phi);
+ double ppl,ppl2,ppe1,ppe2;
+ ppl2 =0.; ppe1 =0.;ppe2 = 0.;
+ if (!emit){
+ ppl = px2*ctt;
+ if (random(seed) < 0.5) {
+ ppt = sqrt (pow(px2,2)-pow(ppl,2));}else {ppt = -sqrt (pow(px2,2)-pow(ppl,2));}
+} else {
+ ppe1=z1*x*emcm/2.;
+ ppe2=(1.-z1)*x*emcm/2.;
+ ppl2=sqrt(pow(ppe2,2)-ptr2);
+ ppl=sqrt(pow(ppe1,2)-ptr2);
+ if (ppe1 < sqrt(ptr2)) {
+ ppl=0.; ppe1=sqrt(ptr2); ppe2=x*emcm/2.-ppe1; ppl2=sqrt(pow(ppe2,2)-ptr2);}
+ if (ppe2 < sqrt(ptr2)) {
+ ppl2=0.; ppe2=sqrt(ptr2); ppe1=x*emcm/2.-ppe2; ppl=sqrt(pow(ppe1,2)-ptr2);}
+ if (random(seed) < 0.5) {
+ ppt = sqrt(ptr2);}else {ppt = -sqrt(ptr2) ;}
+}
+ double ppt1 = ppt*cos(phig);
+ double ppt2 = ppt*sin(phig);
+ PUP[3][5]=-(ppl*ct-ppt1*sin(acos(ct)));
+ PUP[1][5]=-((ppl*sin(acos(ct))+ppt1*ct)*cos(phi)-ppt2*sin(phi));
+ PUP[2][5]=-((ppl*sin(acos(ct))+ppt1*ct)*sin(phi)+ppt2*cos(phi));
+ if (emit){
+ PUP[4][4] = x1*emcm/2.;
+ PUP[4][5]=ppe1;
+ PUP[4][6]=ppe2;
+ PUP[3][6]=-(ppl2*ct+ppt1*sin(acos(ct)));
+ PUP[1][6]=-((ppl2*sin(acos(ct))-ppt1*ct)*cos(phi)+ppt2*sin(phi));
+ PUP[2][6]=-((ppl2*sin(acos(ct))-ppt1*ct)*sin(phi)-ppt2*cos(phi));
+ }
+ }
+ else {
+ ct = -ct;
+ double x=x1+x3;
+ PUP[3][5]=px2*ct;
+ double pt = sqrt(pow(px2,2)-pow(PUP[3][5],2));
+ PUP[1][5]=pt*cos(phi);
+ PUP[2][5]=pt*sin(phi);
+ double ppl, ppl2, ppe1,ppe2;
+ ppl2 =0.; ppe1 =0.;ppe2 = 0.;
+ if (!emit){
+ ppl = px1*ctt;
+ if (random(seed) < 0.5) {
+ ppt = sqrt (pow(px1,2)-pow(ppl,2));
+ }else {ppt = -sqrt (pow(px1,2)-pow(ppl,2));}} else {
+ ppe1=z1*x*emcm/2.;
+ ppe2=(1.-z1)*x*emcm/2.;
+ ppl2=sqrt(pow(ppe2,2)-ptr2);
+ ppl=sqrt(pow(ppe1,2)-ptr2);
+ if (ppe1 < sqrt(ptr2)) {
+ ppl=0.; ppe1=sqrt(ptr2); ppe2=x*emcm/2.-ppe1; ppl2=sqrt(pow(ppe2,2)-ptr2);}
+ if (ppe2 < sqrt(ptr2)) {
+ ppl2=0.; ppe2=sqrt(ptr2); ppe1=x*emcm/2.-ppe2; ppl=sqrt(pow(ppe1,2)-ptr2);}
+ if (random(seed) < 0.5) {
+ ppt = sqrt(ptr2);}else {ppt = -sqrt(ptr2) ;}
+ }
+
+ double ppt1 = ppt*cos(phig);
+ double ppt2 = ppt*sin(phig);
+ PUP[3][4]=-(ppl*ct-ppt1*sin(acos(ct)));
+ PUP[1][4]=-((ppl*sin(acos(ct))+ppt1*ct)*cos(phi)-ppt2*sin(phi));
+ PUP[2][4]=-((ppl*sin(acos(ct))+ppt1*ct)*sin(phi)+ppt2*cos(phi));
+
+ if (emit){
+ PUP[4][4]=ppe1;
+ PUP[4][5] = x2*emcm/2.;
+ PUP[4][6]=ppe2;
+ PUP[3][6]=-(ppl2*ct+ppt1*sin(acos(ct)));
+ PUP[1][6]=-((ppl2*sin(acos(ct))-ppt1*ct)*cos(phi)+ppt2*sin(phi));
+ PUP[2][6]=-((ppl2*sin(acos(ct))-ppt1*ct)*sin(phi)-ppt2*cos(phi));
+ }}
+ if (!emit){
+ PUP[3][6]=-PUP[3][4]-PUP[3][5];
+ PUP[1][6]=-PUP[1][4]-PUP[1][5];
+ PUP[2][6]=-PUP[2][4]-PUP[2][5];
+ PUP[4][4] = x1*emcm/2.;
+ PUP[4][5] = x2*emcm/2.;
+ PUP[4][6] = x3*emcm/2.;
+
+ double alpha = 1.;
+ int nit = 5;
+ //boost masses if needed. Need to boost to nominal gluon mass always.
+ double Eq,Eqb,Eg;
+ double pq = sqrt(pow(PUP[1][4],2)+pow(PUP[2][4],2)+pow(PUP[3][4],2));
+ double pqb = sqrt(pow(PUP[1][5],2)+pow(PUP[2][5],2)+pow(PUP[3][5],2));
+ double pg = sqrt(pow(PUP[1][6],2)+pow(PUP[2][6],2)+pow(PUP[3][6],2));
+
+ for (int ix=1; ix < nit+1; ix++) {
+ Eq = sqrt(pow(mt,2)+alpha*pow(pq,2));
+ Eqb = sqrt(pow(mt,2)+alpha*pow(pqb,2));
+ Eg = sqrt(pow(mg,2)+alpha*pow(pg,2));
+ alpha = alpha+(2.*(emcm-Eq-Eqb-Eg))/(pow(pq,2)/Eq+pow(pqb,2)/Eqb+pow(pg,2)/Eg);
+ }
+ PUP[1][4] =sqrt(alpha)*PUP[1][4];
+ PUP[2][4] =sqrt(alpha)*PUP[2][4];
+ PUP[3][4] =sqrt(alpha)*PUP[3][4];
+ PUP[4][4] =Eq;
+ PUP[1][5] =sqrt(alpha)*PUP[1][5];
+ PUP[2][5] =sqrt(alpha)*PUP[2][5];
+ PUP[3][5] =sqrt(alpha)*PUP[3][5];
+ PUP[4][5] =Eqb;
+ PUP[1][6] =sqrt(alpha)*PUP[1][6];
+ PUP[2][6] =sqrt(alpha)*PUP[2][6];
+ PUP[3][6] =sqrt(alpha)*PUP[3][6];
+ PUP[4][6] =Eg;
+
+ } else {double phi3=2.*pi*random(seed);
+ double ph=2.*pi*random(seed);
+ double phh=2.*pi*random(seed);
+ if (Jt==2) {PUP[4][4]=PUP[4][5];}
+ double ptgg;
+ if (random(seed) < 0.5) {ptgg=sqrt(ptr2);}else{ptgg=-sqrt(ptr2);}
+ double btgg=ptr2/(4.*(1.-z1)*pow(emcm-PUP[4][4],2));
+ double pegg=(1.-z1)*(emcm-PUP[4][4])+btgg*(emcm-PUP[4][4]);
+ double pzgg=(1.-z1)*(emcm-PUP[4][4])-btgg*(emcm-PUP[4][4]);
+ double sth=sqrt(ptr2)/(z1*(emcm-PUP[4][4]));
+ double ptq, ptg;
+ if (random(seed) < 0.5) {
+ ptq=sqrt(ptsq)*cos(asin(sth))+z*z1*(emcm-PUP[4][4])*sth;
+ ptg=-sqrt(ptsq)*cos(asin(sth))+(1-z)*z1*(emcm-PUP[4][4])*sth;
+ } else {
+ ptq=-sqrt(ptsq)*cos(asin(sth))+z*z1*(emcm-PUP[4][4])*sth;
+ ptg=sqrt(ptsq)*cos(asin(sth))+(1.-z)*z1*(emcm-PUP[4][4])*sth;}
+
+ double btq=pow(ptq,2)/(4.*z1*z*pow(emcm-PUP[4][4],2));
+ double btg=pow(ptg,2)/(4.*(1.-z)*z1*pow(emcm-PUP[4][4],2));
+ double pe=z*z1*(emcm-PUP[4][4])+btq*(emcm-PUP[4][4]);
+ double pzq=z*z1*(emcm-PUP[4][4])-btq*(emcm-PUP[4][4]);
+ double peg=z1*(1.-z)*(emcm-PUP[4][4])+btg*(emcm-PUP[4][4]);
+ double pzg=z1*(1.-z)*(emcm-PUP[4][4])-btg*(emcm-PUP[4][4]);
+ PUP[4][6]=pegg;
+ double p6t1=ptgg*cos(ph);
+ double p6t2=ptgg*sin(ph);
+ PUP[1][6]=-((pzgg*sin(acos(ct))+p6t1*ct)*cos(phh)-p6t2*sin(phh));
+ PUP[2][6]=-((pzgg*sin(acos(ct))+p6t1*ct)*sin(phh)+p6t2*cos(phh));
+ PUP[3][6]=-(pzgg*ct-p6t1*sin(acos(ct)));
+ PUP[4][5]=pe;
+ double p5t1=ptq*cos(phig);
+ double p5t2=ptq*sin(phig);
+ PUP[1][5]=-((pzq*sin(acos(ct))+p5t1*ct)*cos(phi3)-p5t2*sin(phi3));
+ PUP[2][5]=-((pzq*sin(acos(ct))+p5t1*ct)*sin(phi3)+p5t2*cos(phi3));
+ PUP[3][5]=-(pzq*ct-p5t1*sin(acos(ct)));
+ PUP[4][7]=peg;
+ double p7t1=ptg*cos(phig);
+ double p7t2=ptg*sin(phig);
+ PUP[1][7]=-((pzg*sin(acos(ct))+p7t1*ct)*cos(phi3)-p7t2*sin(phi3));
+ PUP[2][7]=-((pzg*sin(acos(ct))+p7t1*ct)*sin(phi3)+p7t2*cos(phi3));
+ PUP[3][7]=-(pzg*ct-p7t1*sin(acos(ct)));
+ PUP[1][4]=-PUP[1][7]-PUP[1][6]-PUP[1][5];
+ PUP[2][4]=-PUP[2][7]-PUP[2][6]-PUP[2][5];
+ PUP[3][4]=-PUP[3][7]-PUP[3][6]-PUP[3][5];
+ if (Jt==2) {
+ PUP[1][8]= PUP[1][4]; PUP[2][8]= PUP[2][4]; PUP[3][8]= PUP[3][4];
+ PUP[1][4]= PUP[1][5]; PUP[2][4]= PUP[2][5]; PUP[3][4]= PUP[3][5];
+ PUP[1][5]= PUP[1][8]; PUP[2][5]= PUP[2][8]; PUP[3][5]= PUP[3][8];}
+ double pq = sqrt(pow(PUP[1][4],2)+pow(PUP[2][4],2)+pow(PUP[3][4],2));
+ double pqb = sqrt(pow(PUP[1][5],2)+pow(PUP[2][5],2)+pow(PUP[3][5],2));
+ double pg = sqrt(pow(PUP[1][6],2)+pow(PUP[2][6],2)+pow(PUP[3][6],2));
+ double pgg = sqrt(pow(PUP[1][7],2)+pow(PUP[2][7],2)+pow(PUP[3][7],2));
+ double Eq,Eqb,Eg,Egg;
+ double alpha=1;
+ double nit=5;
+ for (int ixx=1; ixx < nit+1; ixx++) {
+ Eq = sqrt(pow(mt,2)+alpha*pow(pq,2));
+ Eqb = sqrt(pow(mt,2)+alpha*pow(pqb,2));
+ Eg = sqrt(pow(mg,2)+alpha*pow(pg,2));
+ Egg= sqrt(pow(mg,2)+alpha*pow(pgg,2));
+ alpha = alpha+(2.*(emcm-Eq-Eqb-Eg-Egg))/(pow(pq,2)/Eq+pow(pqb,2)/Eqb+pow(pg,2)/Eg+pow(pgg,2)/Egg);
+ }
+ PUP[1][4] =sqrt(alpha)*PUP[1][4];
+ PUP[2][4] =sqrt(alpha)*PUP[2][4];
+ PUP[3][4] =sqrt(alpha)*PUP[3][4];
+ PUP[4][4] =Eq;
+ PUP[1][5] =sqrt(alpha)*PUP[1][5];
+ PUP[2][5] =sqrt(alpha)*PUP[2][5];
+ PUP[3][5] =sqrt(alpha)*PUP[3][5];
+ PUP[4][5] =Eqb;
+ PUP[1][6] =sqrt(alpha)*PUP[1][6];
+ PUP[2][6] =sqrt(alpha)*PUP[2][6];
+ PUP[3][6] =sqrt(alpha)*PUP[3][6];
+ PUP[4][6] =Eg;
+ PUP[1][7] =sqrt(alpha)*PUP[1][7];
+ PUP[2][7] =sqrt(alpha)*PUP[2][7];
+ PUP[3][7] =sqrt(alpha)*PUP[3][7];
+ PUP[4][7] =Egg;
+ }
+ //Momenta of incoming particles and Z boson
+
+ PUP[4][1]=emcm/2.;
+ PUP[1][1]=0.;
+ PUP[2][1]=0.;
+ PUP[3][1]=emcm/2;
+ PUP[4][2]=emcm/2;
+ PUP[1][2]=0.;
+ PUP[2][2]=0.;
+ PUP[3][2]=-emcm/2;
+ PUP[4][3]=emcm;
+ PUP[1][3]=0.;
+ PUP[2][3]=0.;
+ PUP[3][3]=0.;
+
+ double sum1, sum2, sum3, sum4;
+ sum1=0.;sum2=0.;sum3=0.;sum4=0.;
+ ii+=1;
+ // get cosines and sines for production process
+ T1[1]=0.;
+ T1[2]=0.;
+ T1[3]=sqrt(pow(PUP[1][4],2)+pow(PUP[2][4],2)+pow(PUP[3][4],2));
+ T2[1]=0.;
+ T2[2]=0.;
+ T2[3]=sqrt(pow(PUP[1][5],2)+pow(PUP[2][5],2)+pow(PUP[3][5],2));
+ costz=PUP[3][4]/T1[3];
+ costx=PUP[1][4]/sqrt(pow(PUP[1][4],2)+pow(PUP[2][4],2));
+ sintz=sin(acos(costz));
+ sintx=sin(acos(costx));
+ costbz=PUP[3][5]/T2[3];
+ costbx=PUP[1][5]/sqrt(pow(PUP[1][5],2)+pow(PUP[2][5],2));
+ sintbz=sin(acos(costbz));
+ sintbx=sin(acos(costbx));
+ }
+
+
+ }}
+
+ /*************************************END OF PRODUCTION*************************************/
+
+ /*********************************START DECAY PROCESS*************************************/
+
+ if (POWdecay) {
+
+ int Jtd, Jtbd; // Identifier for solutions
+ Jtd =0; Jtbd =0;
+ bool diterate =false;
+ double intg=0.;
+ int ev = 0; // ev =1, 2 for top and tbar decay respectively
+ for (int ia=0; diterate==false || ev != 2; ia++){
+ double logn=fabs(log(random(seed)));
+ intg+=logn;
+ double pt2=interpd(1000,intg,dend1,dend2,dend3,dend4)*pow(mt,2);
+ if (0.*intg !=0) {break;}
+ if (intg > dend4) {break;}
+ if (pt2 < pt2mind) {break;}
+ double xdmax=(mt-a*mt-2.*sqrt(a*pt2))/mt; // maximum value of x
+ double xdmin=2.*sqrt(pt2)/mt; // minimum value of x
+ double Mdmax=0.;
+ double x3, x11, x12, Md, Md1, Md2;
+ for (int ix=0; ix < 1000 ; ix++) {
+ x3=(xdmax-xdmin)*random(seed)+xdmin;
+ Md= MEd (pt2, x3, x11, x12, Md1, Md2);
+ if (fabs(Md) > fabs(Mdmax)) {Mdmax=Md;}
+ }
+ do {
+ x3=(xdmax-xdmin)*random(seed)+xdmin;
+ Md= MEd (pt2, x3, x11, x12, Md1, Md2);}while (random(seed) > fabs(Md/Mdmax));
+
+
+ if (random(seed) < fabs(Md1/Md)) {
+ x1=x11;
+ if (ev==0){ xg1 = x3; xw11=x1; pt2r1=pt2/pow(mt,2); Jtd = 1;}
+ if (ev==1){ xg2 = x3; xw12=x1; pt2r2=pt2/pow(mt,2); Jtbd =1;}
+ ev++;
+ diterate =true;
+ } else {
+ x1=x12;
+ if (ev==0){xg1 = x3; xw11=x1; pt2r1=pt2/pow(mt,2); Jtd = 2;}
+ if (ev==1){ xg2 = x3; xw12=x1; pt2r2=pt2/pow(mt,2); Jtbd = 2;}
+ ev++;
+ diterate =true;
+ }
+ }
+
+ /******************************START DECAY TRUNCATED SHOWER*****************************************/
+ double z1, zt1, ztb1, zt2, ztb2, q;
+ zt1 =0.; ztb1 =0.;zt2 =0.; ztb2 =0.;
+ double qht2,qhtb2,qi, kapp;
+ qht2 =0.; qhtb2 =0.;
+ // emitt =false;
+ demitt=false;
+ demittb=false;
+
+ //Decay truncated shower
+ if (dtruncate) {
+ double Qg=0.75;
+ double u=mt;
+ double ub=0.75;
+ double qc=sqrt(1.53*pow(mt,2));
+ double qcc=2.8;
+ double CF =4./3.;
+ double alpham=1.;
+ double mb = 0.;
+ double c = pow(mb/mt,2);
+
+
+ if (Jtd ==1 ) {
+ zt1= -0.5*(2.*xg1-2.+xw11+a-sqrt(pow(xw11+a,2)-4.*a))/sqrt(pow(xw11+a,2)-4.*a);
+ zt2=-0.5*(2.*pow((xw11+a),2)+4*a*xg1-8*a-pow((xw11+a),2)*xg1-sqrt(-48.*(xw11+a)*a*xg1-16.*a-32.*a*c*xg1+8.*pow((xw11+a),2)*c*xg1+16.*(xw11+a)*a*c*xg1+32.*pow(a,2)*c-16.*a*pow(c,2)-8.*pow((xw11+a),2)*a-8.*pow((xw11+a),2)*c+32.*(xw11+a)*pow(a,2)-4.*a*pow(xg1,2)*pow((xw11+a),2)-32.*(xw11+a)*a*c-8.*pow((xw11+a),2)*a*c+16.*(xw11+a)*pow(xg1,2)*a+4.*pow((xw11+a),3)*a*xg1-4.*pow((xw11+a),3)*c*xg1+8.*pow((xw11+a),2)*a*xg1-16.*(xw11+a)*pow(a,2)*xg1-32.*pow(a,2)+4.*pow((xw11+a),2)+4.*pow((xw11+a),4)-16.*pow(a,3)-8.*pow((xw11+a),3)-8.*pow((xw11+a),2)*xg1+pow((xw11+a),4)*pow(xg1,2)+32.*a*xg1+32.*a*c+32.*(xw11+a)*a+32.*pow(a,2)*xg1-16.*a*pow(xg1,2)-8.*pow((xw11+a),3)*a+8.*pow((xw11+a),3)*c-4.*pow((xw11+a),4)*xg1-4.*pow((xw11+a),3)*pow(xg1,2)+12.*pow((xw11+a),3)*xg1+4.*pow((xw11+a),2)*pow(a,2)+4.*pow((xw11+a),2)*pow(c,2)+4.*pow((xw11+a),2)*pow(xg1,2)))/(4.*a-pow((xw11+a),2));}
+ if (Jtd ==2){zt2=-0.5*(2.*pow((xw11+a),2)+4*a*xg1-8*a-pow((xw11+a),2)*xg1-sqrt(-48.*(xw11+a)*a*xg1-16.*a-32.*a*c*xg1+8.*pow((xw11+a),2)*c*xg1+16.*(xw11+a)*a*c*xg1+32.*pow(a,2)*c-16.*a*pow(c,2)-8.*pow((xw11+a),2)*a-8.*pow((xw11+a),2)*c+32.*(xw11+a)*pow(a,2)-4.*a*pow(xg1,2)*pow((xw11+a),2)-32.*(xw11+a)*a*c-8.*pow((xw11+a),2)*a*c+16.*(xw11+a)*pow(xg1,2)*a+4.*pow((xw11+a),3)*a*xg1-4.*pow((xw11+a),3)*c*xg1+8.*pow((xw11+a),2)*a*xg1-16.*(xw11+a)*pow(a,2)*xg1-32.*pow(a,2)+4.*pow((xw11+a),2)+4.*pow((xw11+a),4)-16.*pow(a,3)-8.*pow((xw11+a),3)-8.*pow((xw11+a),2)*xg1+pow((xw11+a),4)*pow(xg1,2)+32.*a*xg1+32.*a*c+32.*(xw11+a)*a+32.*pow(a,2)*xg1-16.*a*pow(xg1,2)-8.*pow((xw11+a),3)*a+8.*pow((xw11+a),3)*c-4.*pow((xw11+a),4)*xg1-4.*pow((xw11+a),3)*pow(xg1,2)+12.*pow((xw11+a),3)*xg1+4.*pow((xw11+a),2)*pow(a,2)+4.*pow((xw11+a),2)*pow(c,2)+4.*pow((xw11+a),2)*pow(xg1,2)))/(4.*a-pow((xw11+a),2));
+}
+ if (Jtbd==1){
+ ztb1= -0.5*(2.*xg2-2.+xw12+a-sqrt(pow(xw12+a,2)-4.*a))/sqrt(pow(xw12+a,2)-4.*a);
+ ztb2=-0.5*(2.*pow((xw12+a),2)+4*a*xg2-8*a-pow((xw12+a),2)*xg2-sqrt(-48.*(xw12+a)*a*xg2-16.*a-32.*a*c*xg2+8.*pow((xw12+a),2)*c*xg2+16.*(xw12+a)*a*c*xg2+32.*pow(a,2)*c-16.*a*pow(c,2)-8.*pow((xw12+a),2)*a-8.*pow((xw12+a),2)*c+32.*(xw12+a)*pow(a,2)-4.*a*pow(xg2,2)*pow((xw12+a),2)-32.*(xw12+a)*a*c-8.*pow((xw12+a),2)*a*c+16.*(xw12+a)*pow(xg2,2)*a+4.*pow((xw12+a),3)*a*xg2-4.*pow((xw12+a),3)*c*xg2+8.*pow((xw12+a),2)*a*xg2-16.*(xw12+a)*pow(a,2)*xg2-32.*pow(a,2)+4.*pow((xw12+a),2)+4.*pow((xw12+a),4)-16.*pow(a,3)-8.*pow((xw12+a),3)-8.*pow((xw12+a),2)*xg2+pow((xw12+a),4)*pow(xg2,2)+32.*a*xg2+32.*a*c+32.*(xw12+a)*a+32.*pow(a,2)*xg2-16.*a*pow(xg2,2)-8.*pow((xw12+a),3)*a+8.*pow((xw12+a),3)*c-4.*pow((xw12+a),4)*xg2-4.*pow((xw12+a),3)*pow(xg2,2)+12.*pow((xw12+a),3)*xg2+4.*pow((xw12+a),2)*pow(a,2)+4.*pow((xw12+a),2)*pow(c,2)+4.*pow((xw12+a),2)*pow(xg2,2)))/(4.*a-pow((xw12+a),2));}
+ if (Jtbd == 2){
+ ztb2=-0.5*(2.*pow((xw12+a),2)+4*a*xg2-8*a-pow((xw12+a),2)*xg2-sqrt(-48.*(xw12+a)*a*xg2-16.*a-32.*a*c*xg2+8.*pow((xw12+a),2)*c*xg2+16.*(xw12+a)*a*c*xg2+32.*pow(a,2)*c-16.*a*pow(c,2)-8.*pow((xw12+a),2)*a-8.*pow((xw12+a),2)*c+32.*(xw12+a)*pow(a,2)-4.*a*pow(xg2,2)*pow((xw12+a),2)-32.*(xw12+a)*a*c-8.*pow((xw12+a),2)*a*c+16.*(xw12+a)*pow(xg2,2)*a+4.*pow((xw12+a),3)*a*xg2-4.*pow((xw12+a),3)*c*xg2+8.*pow((xw12+a),2)*a*xg2-16.*(xw12+a)*pow(a,2)*xg2-32.*pow(a,2)+4.*pow((xw12+a),2)+4.*pow((xw12+a),4)-16.*pow(a,3)-8.*pow((xw12+a),3)-8.*pow((xw12+a),2)*xg2+pow((xw12+a),4)*pow(xg2,2)+32.*a*xg2+32.*a*c+32.*(xw12+a)*a+32.*pow(a,2)*xg2-16.*a*pow(xg2,2)-8.*pow((xw12+a),3)*a+8.*pow((xw12+a),3)*c-4.*pow((xw12+a),4)*xg2-4.*pow((xw12+a),3)*pow(xg2,2)+12.*pow((xw12+a),3)*xg2+4.*pow((xw12+a),2)*pow(a,2)+4.*pow((xw12+a),2)*pow(c,2)+4.*pow((xw12+a),2)*pow(xg2,2)))/(4.*a-pow((xw12+a),2));
+ }
+
+ qi=mt;
+ double ptsqt,ptsqtb;
+ ptsqt = 0.; ptsqtb =0.;
+ if (Jtd == 2) {
+ ptsqt = pow(mt,2)*pt2r1;
+ qht2= sqrt(xg1/(1.-zt2)*pow(mt,2));}
+ if (Jtbd == 2) {
+ ptsqtb = pow(mt,2)*pt2r2;
+ qhtb2=sqrt(xg2/(1.-ztb2)*pow(mt,2));}
+ if (Jtd == 1) {
+ qht2= sqrt(1.53*pow(mt,2));
+ ptsqt =sqrt(1.53*pow(mt,2));}
+ if(Jtbd == 1) {
+ qhtb2= sqrt(1.53*pow(mt,2));
+ ptsqtb =sqrt(1.53*pow(mt,2));}
+ double zmin=1.-(1.-a)/(qi/mt+2.*sqrt(a*(qi/mt-1)));
+ double zmax = 1.-Qg/qi;
+ double C=CF*alpham*log((1-zmax)/(1.-zmin))/pi;
+ double D=exp(-2.*log(qht2/qc)*C);
+ double E=exp(-2.*log(qi/qc)*C);
+ if (random(seed) < 1.-E/D) {
+ double Pz, Pzmax;
+ do {
+
+ q=sqrt(exp(log(E/random(seed))/C)*pow(qc,2));
+ Pzmax=(1.+pow((1.-Qg/mt),2))/(Qg/mt)+2.*pow(u,2)/(Qg/mt*(1.-Qg/mt)*pow(q,2));
+ z1=random(seed)*(+Qg/q-(1.-a)/(pow(q/mt,2)+2.*sqrt(a*(pow(q/mt,2)-1))))+1.-Qg/q;
+ kapp=pow(q/mt,2);
+ ptr2 = pow(mt,2)*(kapp-1.)*pow(1.-z1,2);
+ Pz=(1.+pow(z1,2))/(1.-z1)+2.*pow(u,2)/(z1*(1.-z1)*pow(q,2));} while (random(seed) > Pz/Pzmax || (kapp > 1.+a*pow(1.-sqrt(z1*(1.-a)/(a*(1.-z1))),2)) || kapp < 1 || q > qht2 || q < qi) ;
+ demitt = true;
+
+ //energy fractions
+ xgrt=(1.-z1)*kapp;
+ double uu=1.+a-c-xgrt;
+ double wr=1.-(1.-z1)*(kapp-1.);
+ double vv=sqrt(pow(uu,2)-4.*a*wr*z1);
+ xwrt=(uu+vv)/(2.*wr)+(uu-vv)/(2.*z1)-a;
+ double alphas = 1./(b*log(ptr2/(pt2min*pow(mt,2))))*(1.-bp*log(log(ptr2/(pt2min*pow(mt,2))))/(b*log(ptr2/(pt2min*pow(mt,2)))));
+ alphas=alphas+pow(alphas,2)*(67./3.-pow(pi,2)-50./9.)/(4.*pi);
+ if (ptr2 < 0 || q < qi || ptr2 > ptsqt || random(seed) > alphas/alpham || random(seed) > Pz*(1.-z1)/2.|| xgrt*mt/2. < sqrt(ptr2)) {demitt=false;}
+ }
+
+ C=CF*alpham*log((1-zmax)/(1.-zmin))/pi;
+ D=exp(-2.*log(qhtb2/qc)*C);
+ E=exp(-2.*log(qi/qc)*C);
+ if (random(seed) < 1.-E/D) {
+ double Pz, Pzmax;
+ do {
+ q=sqrt(exp(log(E/random(seed))/C)*pow(qc,2));
+ Pzmax=(1.+pow((1.-Qg/mt),2))/(Qg/mt)+2.*pow(u,2)/(Qg/mt*(1.-Qg/mt)*pow(q,2));
+ z1=random(seed)*(+Qg/q-(1.-a)/(pow(q/mt,2)+2.*sqrt(a*(pow(q/mt,2)-1))))+1.-Qg/q;
+ kapp=pow(q/mt,2);
+ ptr2b = pow(mt,2)*(kapp-1.)*pow(1.-z1,2);
+ Pz=(1.+pow(z1,2))/(1.-z1)+2.*pow(u,2)/(z1*(1.-z1)*pow(q,2));} while (random(seed) > Pz/Pzmax || (kapp > 1.+a*pow(1.-sqrt(z1*(1.-a)/(a*(1.-z1))),2)) || kapp < 1 || q > qhtb2 || q < qi);
+ demittb = true;
+
+ //energy fractions
+ xgrtb=(1.-z1)*kapp;
+ double uu=1.+a-c-xgrtb;
+ double wr=1.-(1.-z1)*(kapp-1.);
+ double vv=sqrt(pow(uu,2)-4.*a*wr*z1);
+
+ xwrtb=(uu+vv)/(2.*wr)+(uu-vv)/(2.*z1)-a;
+
+ double alphas = 1./(b*log(ptr2b/(pt2min*pow(mt,2))))*(1.-bp*log(log(ptr2b/(pt2min*pow(mt,2))))/(b*log(ptr2b/(pt2min*pow(mt,2)))));
+ alphas=alphas+pow(alphas,2)*(67./3.-pow(pi,2)-50./9.)/(4.*pi);
+
+ if (ptr2b < 0 || q < qi || ptr2b > ptsqtb || random(seed) > alphas/alpham || random(seed) > Pz*(1.-z1)/2.|| xgrtb*mt/2. < sqrt(ptr2b)) {demittb=false;}
+
+ }
+
+ if (!demitt && Jtd == 1) {
+ qi=sqrt(1.16*pow(mt,2));
+ ptsqt = pow(mt,2)*pt2r1;
+ qht2=sqrt(pow(mt,2)*(xw11-1.)/(-zt1*(1.-zt1)));
+ C=CF*alpham*log(Qg/(qi-ub))/pi;
+ D=exp(2.*log(qht2/qcc)*C);
+ E=exp(2.*log(qi/qcc)*C);
+
+ if (random(seed) < 1.-E/D) {
+ double Pz, Pzmax;
+
+ do {
+
+ q=sqrt(exp(log(E/random(seed))/C)*pow(qcc,2));
+ Pzmax=(1.+pow((1.-Qg/qi),2))/(Qg/qi);
+
+
+ z1=random(seed)*(1.-Qg/qi-ub/qi)+ub/qi;
+ Pz=(1.+pow(z1,2))/(1.-z1);} while (random(seed) > Pz/Pzmax || q < qht2 || q >qi);
+
+
+ demitt = true;
+ kapp=pow(q/mt,2);
+ ptr2 = pow(mt,2)*kapp*pow(z1*(1.-z1),2);
+ //energy fractions
+ xwrt=1.-c-z1*(1.-z1)*kapp;
+
+ xgrt=0.5*(2.-xwrt-a)-(z1-0.5)*sqrt(pow(xwrt+a,2)-4.*a);
+
+ double alphas = 1./(b*log(ptr2/(pt2min*pow(mt,2))))*(1.-bp*log(log(ptr2/(pt2min*pow(mt,2))))/(b*log(ptr2/(pt2min*pow(mt,2)))));
+ alphas=alphas+pow(alphas,2)*(67./3.-pow(pi,2)-50./9.)/(4.*pi);
+ if (ptr2 < 0 || q > qi || ptr2 > ptsqt || random(seed) > alphas/alpham || random(seed) > Pz*(1.-z1)/2.|| xgrt*mt/2. < sqrt(ptr2)) {demitt=false;}
+
+ }
+ }
+ if (!demittb && Jtbd == 1) {
+ qi=sqrt(1.16*pow(mt,2));
+ ptsqtb = pow(mt,2)*pt2r2;
+ qhtb2=sqrt(pow(mt,2)*(xw12-1.)/(-ztb1*(1.-ztb1)));
+ C=CF*alpham*log(Qg/(qi-ub))/pi;
+ D=exp(2.*log(qhtb2/qcc)*C);
+ E=exp(2.*log(qi/qcc)*C);
+ if (random(seed) < 1.-E/D) {
+ double Pz, Pzmax;
+ do {
+ q=sqrt(exp(log(E/random(seed))/C)*pow(qcc,2));
+ Pzmax=(1.+pow((1.-Qg/qi),2))/(Qg/qi);
+
+ z1=random(seed)*(1.-Qg/qi-ub/qi)+ub/qi;
+ Pz=(1.+pow(z1,2))/(1.-z1);} while (random(seed) > Pz/Pzmax|| q < qhtb2 || q >qi);
+
+ demittb = true;
+ kapp=pow(q/mt,2);
+ ptr2b = pow(mt,2)*kapp*pow(z1*(1.-z1),2);
+ //energy fractions
+ xwrtb=1-c-z1*(1.-z1)*kapp;
+ xgrtb=0.5*(2.-xwrtb-a)-(z1-0.5)*sqrt(pow(xwrtb+a,2)-4.*a);
+double alphas = 1./(b*log(ptr2b/(pt2min*pow(mt,2))))*(1.-bp*log(log(ptr2b/(pt2min*pow(mt,2))))/(b*log(ptr2b/(pt2min*pow(mt,2)))));
+ alphas=alphas+pow(alphas,2)*(67./3.-pow(pi,2)-50./9.)/(4.*pi);
+ if (ptr2b < 0 || q > qi || ptr2b > ptsqtb || random(seed) > alphas/alpham || random(seed) > Pz*(1.-z1)/2. || xgrtb*mt/2. < sqrt(ptr2b)) {demittb=false;}
+
+ }
+ }
+
+
+ }
+ /**********************END DECAY TRUNCATED SHOWER****************************/
+ }
+ // Polarizer
+ if (!POWprod) {
+ double qelr=qel;
+ double qtlr1=qtl;
+ double qtlr2=qtr;
+ double RA=-Qt+qelr*qtlr1*Ref*16.;
+ double RB=qelr*qtlr1*Imf*16.;
+ double LA=-Qt+qelr*qtlr2*Ref*16.;
+ double LB=qelr*qtlr2*Imf*16.;
+ double MM11=beta*(pow(RA+LA,2)+pow(RB+LB,2))*(1.-pow(beta,2))*4./3.;
+ double MM22=beta*(pow(RA+LA,2)+pow(RB+LB,2))*(1.-pow(beta,2))*4./3.;
+ double MM12=beta*(pow((RA*(1.-beta)+LA*(1.+beta)),2)+pow((RB*(1.-beta)+LB*(1.+beta)),2))*8./3.;
+ double MM21=beta*(pow((RA*(1.+beta)+LA*(1.-beta)),2)+pow((RB*(1.+beta)+LB*(1.-beta)),2))*8./3.;
+ if (Pm==1 && Pp==-1)
+ {qelr=qer;
+ qtlr1=qtr;
+ qtlr2=qtl;
+ MM11=beta*(pow(RA+LA,2)+pow(RB+LB,2))*(1.-pow(beta,2))*4./3.;
+ MM22=beta*(pow(RA+LA,2)+pow(RB+LB,2))*(1.-pow(beta,2))*4./3.;
+ MM12=beta*(pow((RA*(1.+beta)+LA*(1.-beta)),2)+pow((RB*(1.+beta)+LB*(1.-beta)),2))*8./3.;
+ MM21=beta*(pow((RA*(1.-beta)+LA*(1.+beta)),2)+pow((RB*(1.-beta)+LB*(1.+beta)),2))*8./3.;
+ }
+ double M11max = beta*(pow(RA+LA,2)+pow(RB+LB,2))*(1.-pow(beta,2));
+ double M22max=beta*(pow(RA+LA,2)+pow(RB+LB,2))*(1.-pow(beta,2));
+ double M21max = beta*(pow((RA*(1.+beta)+LA*(1.-beta)),2)+pow((RB*(1.+beta)+LB*(1.-beta)),2))*4.;
+ double M12max = beta*(pow((RA*(1.-beta)+LA*(1.+beta)),2)+pow((RB*(1.-beta)+LB*(1.+beta)),2))*4.;
+ if (Pm==1 && Pp==-1) {double Mdum=M21max; M21max=M12max; M12max=Mdum;}
+ double MM, MMmax;
+ double MMM=fabs(MM11)+fabs(MM12)+fabs(MM21)+fabs(MM22);
+ if (random(seed) < (fabs(MM11)+fabs(MM12))/MMM){
+ if(random(seed) < fabs(MM11)/(fabs(MM11)+fabs(MM12))){
+ EVT=1; MM=MM11; MMmax=M11max; }else {
+ EVT=3; MM=MM12; MMmax=M12max; }}else{
+ if(random(seed) < fabs(MM21)/(fabs(MM21)+fabs(MM22))){
+ EVT =2;MM=MM21; MMmax=M21max;}else {
+ EVT=4; MM=MM22; MMmax=M22max; }}
+
+ double Mm = 0.;
+ do {
+ cost = 1.-2.*random(seed);
+ if (EVT==1) {
+ Mm = beta*(pow(RA+LA,2)+pow(RB+LB,2))*(1.-pow(beta,2))*(1.-pow(cost,2));}
+ if (EVT==3) {
+ Mm = beta*(pow((RA*(1.+beta)+LA*(1.-beta)),2)+pow((RB*(1.+beta)+LB*(1.-beta)),2))*pow(1.+cost,2);}
+ if(EVT==2) {
+ Mm = beta*(pow((RA*(1.-beta)+LA*(1.+beta)),2)+pow((RB*(1.-beta)+LB*(1.+beta)),2))*pow(1.-cost,2);}
+ if(EVT==4) {
+ Mm = beta*(pow(RA+LA,2)+pow(RB+LB,2))*(1.-pow(beta,2))*(1.-pow(cost,2));}
+ if (Pm==-1 && Pp==1) {
+ if(EVT==2) {
+ Mm = beta*(pow((RA*(1.+beta)+LA*(1.-beta)),2)+pow((RB*(1.+beta)+LB*(1.-beta)),2))*pow(1.+cost,2);}
+ if (EVT==3) {
+ Mm = beta*(pow((RA*(1.-beta)+LA*(1.+beta)),2)+pow((RB*(1.-beta)+LB*(1.+beta)),2))*pow(1.-cost,2);}
+ }} while (random(seed) > Mm/MMmax);
+ T1[1]=0.5*emcm*beta*sin(acos(cost));
+ T1[2]=0.;
+ T1[3]=0.5*emcm*beta*cost;
+ T2[1]=-0.5*emcm*beta*sin(acos(cost));
+ T2[2]=0.;
+ T2[3]=-0.5*emcm*beta*cost;
+ sint=sin(acos(cost));
+ }
+
+ /**********************END DECAY PROCESS ****************************/
+
+ /***********************START DISTRIBUTING BORN EVENTS ACCORDING TO BBAR FUNCTION AND ASSIGNING MMT TO DECAY PRODUCTS********************/
+
+ double vt=sqrt(pow(T1[3],2)+pow(T1[1],2)+pow(T1[2],2))/sqrt(pow(T1[3],2)+pow(T1[1],2)+pow(T1[2],2)+pow(mt,2));
+ double gammat=1./sqrt(1.-vt*vt);
+ double vtb=sqrt(pow(T2[3],2)+pow(T2[1],2)+pow(T2[2],2))/sqrt(pow(T2[3],2)+pow(T2[1],2)+pow(T2[2],2)+pow(mt,2));
+ double gammatb=1./sqrt(1.-vtb*vtb);
+ double Ew,Eg,Eb,El,Ew2,Eg2,Eb2,xw2,xw1,xb1,xb2,bgphi,pw;
+ int tm, tbm, st,stb;
+ tm = 0; tbm = 0;
+ if (EVT==1) {tm=1; tbm=-1; st=1;stb=-1;}
+ if (EVT==2) {tm=-1;tbm=-1; st=-1;stb=-1;}
+ if (EVT==3) {tm=1;tbm=1; st=1; stb=1;}
+ if (EVT==4){tm=-1;tbm=1; st=-1; stb=1;}
+ if (POWdecay) {
+ xw1=xw11+a;
+ xw2=xw12+a;
+ xb2=2.-xw2-xg2;
+ xb1= 2.-xw1-xg1;
+ Ew=xw1*mt/2.;
+ Eg=xg1*mt/2.;
+ Eb=xb1*mt/2.;
+ if (POWdecay && demitt) {
+ Ew = (2.-xb1-xg1-xgrt)*mt/2.;
+ if (Ew < mw) {demitt = false; Ew=xw1*mt/2.;}
+}
+
+ Ew2=xw2*mt/2.;
+ Eg2=xg2*mt/2.;
+ Eb2=xb2*mt/2.;
+ if (POWdecay && demittb) {
+ Ew2 = (2.-xb2-xg2-xgrtb)*mt/2.;
+ if (Ew2 < mw) {demittb = false; Ew2=xw2*mt/2.;}
+}
+
+ El=0.5*mw;
+
+
+} else {Ew = 0.5*(mt+mw*mw/mt);Eb=0.5*(mt-mw*mw/mt); Eg=0; El=0.5*mw;Ew2=Ew; Eb2=Eb; Eg2=Eg;}
+ double xww1, xww2;
+ xww1 = xw1 ;
+ xww2 = xw2 ;
+ pw=sqrt(pow(Ew,2)-pow(mw,2));
+
+ double ctw,ctl,max,bphi,TL,TO,TI,ctw2,ctl2,bphi2,TL2,TO2,TI2,bgphi2;
+ // Production process only with LO decays
+ if (!POWdecay) {
+ for(int ix=0;;ix++) {
+ ctw=1.-2.*random(seed);
+ ctl=1.-2.*random(seed);
+ bphi=2*pi*random(seed);
+ ctw2=1.-2.*random(seed);
+ ctl2=1.-2.*random(seed);
+ bphi2=2*pi*random(seed);
+ TL=pow(mt,2)*(1.+tm*ctw)*(1.-pow(ctl,2));
+ TO=pow(mw,2)*(1.-tm*ctw)*pow((1.-ctl),2);
+ TI=tm*2.*mt*mw*(1.-ctl)*sqrt(1.-pow(ctw,2))*sqrt(1.-pow(ctl,2))*cos(bphi);
+ TL2=pow(mt,2)*(1.+tbm*ctw2)*(1.-pow(ctl2,2));
+ TO2=pow(mw,2)*(1.-tbm*ctw2)*pow((1.-ctl2),2);
+ TI2=tbm*2.*mt*mw*(1.-ctl2)*sqrt(1.-pow(ctw2,2))*sqrt(1.-pow(ctl2,2))*cos(bphi2);
+ max=pow(pow(mt,2)*2.+pow(mw,2)*8.+2.*mt*mw*2.,2);
+ if (random(seed)< (TL+TO+TI)*(TL2+TO2+TI2)/(max)) {break;}}} else
+ // NLO decay process hence Bbar function
+ if (POWdecay)
+
+ {double xd0=0.2/(mt/2.*(1.-a));
+ double zd0=0.0028;
+ double cbgst1, cbgst2;
+ if (!findmaxdec) {
+ for (int idec=1;idec <1000; idec++) {
+ do {
+ xg1=random(seed)*(1.-a);
+ xw1=a+random(seed)*(1.-(a*xg1/(1-xg1)+(1.-xg1)))+a*xg1/(1-xg1)+(1.-xg1);
+ xb1=2.-xw1-xg1;
+ double bw11=sqrt(1.-4.*a/pow(xw1,2));
+ double wb=acos(1./(xw1*bw11*xb1)*(xg1-xw1-xb1+xw1*xb1+2.*a));
+ double wg=acos(1./(xw1*bw11*xg1)*(xb1-xw1-xg1+xw1*xg1+2.*a));
+ double cbg=cos(2.*pi*-wb-wg);
+ double sbg=sin(2.*pi*-wb-wg);
+ double xtp=sqrt(pow((2.-xg1)/2.*mt,2)-pow(xg1*0.5*mt,2));
+ double xte=(2.-xg1)/2.*mt;
+ double vtep=xtp/xte;
+ double gamt=sqrt(1./(1.-pow(vtep,2)));
+ double pb =gamt*(xb1*mt*0.5*cbg-vtep*xb1*mt*0.5*cbg);
+ double pt = xb1*mt*0.5*sbg;
+ cbgst1=cos(atan2(pt,pb));
+ xg2=random(seed)*(1.-a);
+ xw2=a+random(seed)*(1.-(a*xg2/(1-xg2)+(1.-xg2)))+a*xg2/(1-xg2)+(1.-xg2);
+ xb2=2.-xw2-xg2;
+ double bw22=sqrt(1.-4.*a/pow(xw2,2));
+ wb=acos(1./(xw2*bw22*xb2)*(xg2-xw2-xb2+xw2*xb2+2.*a));
+ wg=acos(1./(xw2*bw22*xg2)*(xg2-xw2-xg2+xw2*xg2+2.*a));
+ cbg=cos(2.*pi*-wb-wg);
+ sbg=sin(2.*pi*-wb-wg);
+ xtp=sqrt(pow((2.-xg2)/2.*mt,2)-pow(xg2*0.5*mt,2));
+ xte=(2.-xg2)/2.*mt;
+ vtep=xtp/xte;
+ gamt=sqrt(1./(1.-pow(vtep,2)));
+ pb =gamt*(xb2*mt*0.5*cbg-vtep*xb2*mt*0.5*cbg);
+ pt = xb2*mt*0.5*sbg;
+ cbgst2=cos(atan2(pt,pb));
+}
+ while (xg2 < xd0 || xg1 < xd0 || (1.-cbgst1)/2. < zd0|| (1.-cbgst2)/2. < zd0);
+ ctw=1.-2.*random(seed);
+ ctl=1.-2.*random(seed);
+ bphi=2*pi*random(seed);
+ ctw2=1.-2.*random(seed);
+ ctl2=1.-2.*random(seed);
+ bphi2=2*pi*random(seed);
+ bgphi=2*pi*random(seed);
+ bgphi2=2*pi*random(seed);
+ double T1=PolMEdec(xw1,xb1,xg1,ctw,ctl,bphi,bgphi,1,xd0,zd0,fac);
+ double T2=PolMEdec(xw1,xb1,xg1,ctw,ctl,bphi,bgphi,-1,xd0,zd0,fac);
+ double T3=PolMEdec(xw2,xb2,xg2,ctw2,ctl2,bphi2,bgphi2,1,xd0,zd0,fac);
+ double T4=PolMEdec(xw2,xb2,xg2,ctw2,ctl2,bphi2,bgphi2,-1,xd0,zd0,fac);
+ if (fabs(T1*T4) > maxd1) {maxd1=T1*T4;}
+ if (fabs(T2*T4) > maxd2) {maxd2=T2*T4;}
+ if (fabs(T1*T3) > maxd3) {maxd3=T1*T3;}
+ if (fabs(T2*T3) > maxd4) {maxd4=T2*T3;}
+ }
+ }
+ findmaxdec=true;
+ double maxd,TTB;
+ maxd =0.;
+ if (EVT==1) {maxd=maxd1;}
+ if (EVT==2) {maxd=maxd2;}
+ if (EVT==3) {maxd=maxd3;}
+ if (EVT==4) {maxd=maxd4;}
+ do{
+ do {
+ xg1=random(seed)*(1.-a);
+ xw1=a+random(seed)*(1.-(a*xg1/(1-xg1)+(1.-xg1)))+a*xg1/(1-xg1)+(1.-xg1);
+ xb1=2.-xw1-xg1;
+ double bw11=sqrt(1.-4.*a/pow(xw1,2));
+ double wb=acos(1./(xw1*bw11*xb1)*(xg1-xw1-xb1+xw1*xb1+2.*a));
+ double wg=acos(1./(xw1*bw11*xg1)*(xb1-xw1-xg1+xw1*xg1+2.*a));
+ double cbg=cos(2.*pi*-wb-wg);
+ double sbg=sin(2.*pi*-wb-wg);
+ double xtp=sqrt(pow((2.-xg1)/2.*mt,2)-pow(xg1*0.5*mt,2));
+ double xte=(2.-xg1)/2.*mt;
+ double vtep=xtp/xte;
+ double gamt=sqrt(1./(1.-pow(vtep,2)));
+ double pb =gamt*(xb1*mt*0.5*cbg-vtep*xb1*mt*0.5*cbg);
+ double pt = xb1*mt*0.5*sbg;
+ cbgst1=cos(atan2(pt,pb));
+ xg2=random(seed)*(1.-a);
+ xw2=a+random(seed)*(1.-(a*xg2/(1-xg2)+(1.-xg2)))+a*xg2/(1-xg2)+(1.-xg2);
+ xb2=2.-xw2-xg2;
+ double bw22=sqrt(1.-4.*a/pow(xw2,2));
+ wb=acos(1./(xw2*bw22*xb2)*(xg2-xw2-xb2+xw2*xb2+2.*a));
+ wg=acos(1./(xw2*bw22*xg2)*(xg2-xw2-xg2+xw2*xg2+2.*a));
+ cbg=cos(2.*pi*-wb-wg);
+ sbg=sin(2.*pi*-wb-wg);
+ xtp=sqrt(pow((2.-xg2)/2.*mt,2)-pow(xg2*0.5*mt,2));
+ xte=(2.-xg2)/2.*mt;
+ vtep=xtp/xte;
+ gamt=sqrt(1./(1.-pow(vtep,2)));
+ pb =gamt*(xb2*mt*0.5*cbg-vtep*xb2*mt*0.5*cbg);
+ pt = xb2*mt*0.5*sbg;
+ cbgst2=cos(atan2(pt,pb));
+}while (xg2 < xd0 || xg1 < xd0 || (1.-cbgst1)/2. < zd0|| (1.-cbgst2)/2. < zd0);
+ ctw=1.-2.*random(seed);
+ ctl=1.-2.*random(seed);
+ bphi=2*pi*random(seed);
+ ctw2=1.-2.*random(seed);
+ ctl2=1.-2.*random(seed);
+ bphi2=2.*pi*random(seed);
+ bgphi=2.*pi*random(seed);
+ bgphi2=2.*pi*random(seed);
+ TTB=PolMEdec(xw1,xb1,xg1,ctw,ctl,bphi,bgphi,tm,xd0,zd0,fac)*PolMEdec(xw2,xb2,xg2,ctw2,ctl2,bphi2,bgphi2,tbm,xd0,zd0,fac);}
+ while (random(seed) > fabs(TTB/maxd));
+ }
+ // Assign momenta
+ double W1[4],E[4],EE1[4],NN1[4],BB1[4],G1[4],B1[4];
+ double W2[4],EE2[4],NN2[4],BB2[4],G2[4],B2[4];
+ double phi=2.*pi*random(seed);
+ // top rest frame
+ W1[1]=pw*sin(acos(ctw))*cos(phi);
+ W1[2]=pw*sin(acos(ctw))*sin(phi);
+ W1[3]=pw*(ctw);
+ //W rest frame
+ E[1]=El*sin(acos(ctl))*cos(bphi);
+ E[2]=El*sin(acos(ctl))*sin(bphi);
+ E[3]=El*ctl;
+ double vv=pw/Ew;
+ double gammaw=1./sqrt(1.-pow(vv,2));
+ //top rest frame
+ E[3]=gammaw*(E[3]+vv*El);
+
+ EE1[3]=E[3]*ctw+E[1]*sin(acos(ctw));
+ EE1[1]=E[3]*sin(acos(ctw))-E[1]*ctw;
+ EE1[0]=EE1[1];
+ EE1[1]=EE1[0]*cos(phi)-E[2]*sin(phi);
+ EE1[2]=E[2]*cos(phi)+EE1[0]*sin(phi);
+ NN1[1]=W1[1]-EE1[1];
+ NN1[2]=W1[2]-EE1[2];
+ NN1[3]=W1[3]-EE1[3];
+ BB1[1]=-W1[1];
+ BB1[2]=-W1[2];
+ BB1[3]=-W1[3];
+
+ double KT,phb,GG1[5],G[4],KT1,phb2, GT[4],thetr,BT[4], GGT[4],TG1[4];
+ KT1 =0.; phb2 =0.;
+ if (POWdecay) {
+ GT[1]=0.;
+ GT[2]=0.;
+ GT[3]=0.;
+ TG1[1]=0.;
+ TG1[2]=0.;
+ TG1[3]=0.;
+ KT=sqrt(pt2r1*pow(mt,2));// transverse momenta for decay gluon
+ phb=2.*pi*random(seed);
+ B1[1]=-KT*cos(phb);
+ B1[2]=-KT*sin(phb);
+ B1[3]=-sqrt(pow(Eb,2)-pow(B1[1],2)-pow(B1[2],2));
+ G[1]=KT*cos(phb);
+ G[2]=KT*sin(phb);
+ G[3]=-sqrt(pow(Eg,2)-pow(G[1],2)-pow(G[2],2));
+ // If truncated emission
+ if (!demitt) {
+ if (fabs(pw-sqrt(pow(B1[1]+G[1],2)+pow(B1[2]+G[2],2)+pow(B1[3]+G[3],2))) > 0.1) {G[3]=sqrt(pow(Eg,2)-pow(G[1],2)-pow(G[2],2));} }
+ if (demitt) {
+ if (fabs(sqrt(pow(xww1*mt/2.,2)-pow(mw,2))-sqrt(pow(B1[1]+G[1],2)+pow(B1[2]+G[2],2)+pow(B1[3]+G[3],2))) > 0.1) {G[3]=sqrt(pow(Eg,2)-pow(G[1],2)-pow(G[2],2));}}
+ if (demitt) {
+ if (pow(B1[3]+G[3],2) < ptr2) {demitt = false; pw = sqrt (pow(xww1*mt/2.,2)-pow(mw,2));
+
+
+ // top rest frame
+ W1[1]=pw*sin(acos(ctw))*cos(phi);
+ W1[2]=pw*sin(acos(ctw))*sin(phi);
+ W1[3]=pw*(ctw);
+ //W rest frame
+ E[1]=El*sin(acos(ctl))*cos(bphi);
+ E[2]=El*sin(acos(ctl))*sin(bphi);
+ E[3]=El*ctl;
+ vv=pw/(xww1*mt/2.);
+ gammaw=1./sqrt(1.-pow(vv,2));
+ //top rest frame
+ E[3]=gammaw*(E[3]+vv*El);
+
+ EE1[3]=E[3]*ctw+E[1]*sin(acos(ctw));
+ EE1[1]=E[3]*sin(acos(ctw))-E[1]*ctw;
+
+
+ EE1[0]=EE1[1];
+
+ EE1[1]=EE1[0]*cos(phi)-E[2]*sin(phi);
+ EE1[2]=E[2]*cos(phi)+EE1[0]*sin(phi);
+ NN1[1]=W1[1]-EE1[1];
+ NN1[2]=W1[2]-EE1[2];
+ NN1[3]=W1[3]-EE1[3];
+
+ B1[1]=-KT*cos(phb);
+ B1[2]=-KT*sin(phb);
+ B1[3]=-sqrt(pow(Eb,2)-pow(B1[1],2)-pow(B1[2],2));
+ G[1]=KT*cos(phb);
+ G[2]=KT*sin(phb);
+ G[3]=-sqrt(pow(Eg,2)-pow(G[1],2)-pow(G[2],2));
+
+ if (fabs(pw-sqrt(pow(B1[1]+G[1],2)+pow(B1[2]+G[2],2)+pow(B1[3]+G[3],2))) > 0.1) {G[3]=sqrt(pow(Eg,2)-pow(G[1],2)-pow(G[2],2));}
+ }
+ }
+
+ if(demitt) {
+ KT1 = sqrt(ptr2);// transverse momenta for decay truncated gluon
+ phb2 = 2.*pi*random(seed);
+ BT[1]=KT1*cos(phb2);
+ BT[2]=KT1*sin(phb2);
+ BT[3]= -sqrt(pow(B1[3]+G[3],2)-pow(KT1,2));
+ GT[1]=-KT1*cos(phb2);
+ GT[2]=-KT1*sin(phb2);
+ GT[3]= -pw - BT[3];
+}
+ thetr = asin(KT1/(B1[3]+G[3])); // angle of truncated emission
+ double ctwr = cos(thetr);
+ if (demitt) {
+ BT[3]=B1[3]*ctwr+B1[1]*sin(acos(ctwr));
+ BT[1]=-B1[3]*sin(acos(ctwr))+B1[1]*ctwr;
+ GGT[3]=G[3]*ctwr+G[1]*sin(acos(ctwr));
+ GGT[1]=-G[3]*sin(acos(ctwr))+G[1]*ctwr;
+ BT[0]=BT[1];
+ BT[1]=BT[0]*cos(phb2)-B1[2]*sin(phb2);
+ BT[2]=B1[2]*cos(phb2)+BT[0]*sin(phb2);
+ GGT[0]=GGT[1];
+ GGT[1]=GGT[0]*cos(phb2)-G[2]*sin(phb2);
+ GGT[2]=G[2]*cos(phb2)+GGT[0]*sin(phb2);
+ B1[3] = BT[3];
+ B1[1] = BT[1];
+ B1[2] = BT[2];
+ G[3] = GGT[3];
+ G[2] = GGT[2];
+ G[1] = GGT[1];
+}
+ // Rotate through W angle in top rest frame
+ BB1[3]=B1[3]*ctw+B1[1]*sin(acos(ctw));
+ BB1[1]=B1[3]*sin(acos(ctw))-B1[1]*ctw;
+ GG1[3]=G[3]*ctw+G[1]*sin(acos(ctw));
+ GG1[1]=G[3]*sin(acos(ctw))-G[1]*ctw;
+ TG1[3]=GT[3]*ctw+GT[1]*sin(acos(ctw));
+ TG1[1]=GT[3]*sin(acos(ctw))-GT[1]*ctw;
+ BB1[0]=BB1[1];
+ BB1[1]=BB1[0]*cos(phi)-B1[2]*sin(phi);
+ BB1[2]=B1[2]*cos(phi)+BB1[0]*sin(phi);
+ GG1[0]=GG1[1];
+ GG1[1]=GG1[0]*cos(phi)-G[2]*sin(phi);
+ GG1[2]=G[2]*cos(phi)+GG1[0]*sin(phi);
+ TG1[0]=TG1[1];
+ TG1[1]=TG1[0]*cos(phi)-GT[2]*sin(phi);
+ TG1[2]=GT[2]*cos(phi)+TG1[0]*sin(phi);
+ if (fabs(W1[1]+GG1[1]+BB1[1]+TG1[1]) > 0.1 || fabs(W1[2]+GG1[2]+BB1[2]+TG1[2]) >0.1) {B1[3]=sqrt(pow(Eb,2)-pow(KT,2));
+ G[3]=-sqrt(pow(Eg,2)-pow(KT,2)); B1[1]=-KT*cos(phb) ; B1[2] = -KT*sin(phb); G[1]=KT*cos(phb); G[2] = KT*sin(phb); thetr = asin(KT1/(sqrt(pow(B1[1]+G[1],2)+pow(B1[2]+G[2],2)+pow(B1[3]+G[3],2))));
+ ctwr = cos(thetr);
+
+ if (demitt) {
+ // rotate through truncated emission angle
+ BT[3]=B1[3]*ctwr+B1[1]*sin(acos(ctwr));
+ BT[1]=-B1[3]*sin(acos(ctwr))+B1[1]*ctwr;
+ GGT[3]=G[3]*ctwr+G[1]*sin(acos(ctwr));
+ GGT[1]=-G[3]*sin(acos(ctwr))+G[1]*ctwr;
+ BT[0]=BT[1];
+ BT[1]=BT[0]*cos(phb2)-B1[2]*sin(phb2);
+ BT[2]=B1[2]*cos(phb2)+BT[0]*sin(phb2);
+ GGT[0]=GGT[1];
+ GGT[1]=GGT[0]*cos(phb2)-G[2]*sin(phb2);
+ GGT[2]=G[2]*cos(phb2)+GGT[0]*sin(phb2);
+ B1[3] = BT[3];
+ B1[1] = BT[1];
+ B1[2] = BT[2];
+ G[3] = GGT[3];
+ G[2] = GGT[2];
+ G[1] = GGT[1];}
+
+ BB1[3]=B1[3]*ctw+B1[1]*sin(acos(ctw));
+ BB1[1]=B1[3]*sin(acos(ctw))-B1[1]*ctw;
+ GG1[3]=G[3]*ctw+G[1]*sin(acos(ctw));
+ GG1[1]=G[3]*sin(acos(ctw))-G[1]*ctw;
+ TG1[3]=GT[3]*ctw+GT[1]*sin(acos(ctw));
+ TG1[1]=GT[3]*sin(acos(ctw))-GT[1]*ctw;
+ BB1[0]=BB1[1];
+ BB1[1]=BB1[0]*cos(phi)-B1[2]*sin(phi);
+ BB1[2]=B1[2]*cos(phi)+BB1[0]*sin(phi);
+ GG1[0]=GG1[1];
+ GG1[1]=GG1[0]*cos(phi)-G[2]*sin(phi);
+ GG1[2]=G[2]*cos(phi)+GG1[0]*sin(phi);
+ TG1[0]=TG1[1];
+ TG1[1]=TG1[0]*cos(phi)-GT[2]*sin(phi);
+ TG1[2]=GT[2]*cos(phi)+TG1[0]*sin(phi);
+ }
+ }
+ if (POWdecay && demitt){
+ // Boost momenta to preserve top mass.
+ double bp = sqrt(pow(BB1[3],2)+pow(BB1[2],2)+pow(BB1[1],2));
+ double gp = sqrt(pow(GG1[3],2)+pow(GG1[2],2)+pow(GG1[1],2));
+ double gtrp = sqrt(pow(TG1[3],2)+pow(TG1[2],2)+pow(TG1[1],2));
+ double wp = sqrt(pow(W1[3],2)+pow(W1[2],2)+pow(W1[1],2));
+ double mfac = (mt*gp + mt*bp+mt*gtrp-sqrt(-pow(wp*mw,2)+pow(mt,2)*pow(wp,2)+pow(bp*mw,2)+2.*bp*gp*pow(mw,2)+2.*bp*gtrp*pow(mw,2)+pow(gp*mw,2)+2.*gp*gtrp*pow(mw,2)+pow(gtrp*mw,2)))/(-pow(wp,2)+pow(bp,2)+2.*bp*gp+2.*bp*gtrp+pow(gp,2)+2.*gp*gtrp+pow(gtrp,2)); BB1[3]=mfac*BB1[3]; BB1[2]=mfac*BB1[2]; BB1[1]=mfac*BB1[1];GG1[3]=mfac*GG1[3]; GG1[2]=mfac*GG1[2]; GG1[1]=mfac*GG1[1];
+ TG1[3]=mfac*TG1[3]; TG1[2]=mfac*TG1[2]; TG1[1]=mfac*TG1[1];W1[3]=mfac*W1[3]; W1[2]=mfac*W1[2]; W1[1]=mfac*W1[1];
+ E[1]=El*sin(acos(ctl))*cos(bphi);
+ E[2]=El*sin(acos(ctl))*sin(bphi);
+ E[3]=El*ctl;
+ double vv=sqrt((pow(W1[1],2)+pow(W1[2],2)+pow(W1[3],2))/(pow(W1[1],2)+pow(W1[2],2)+pow(W1[3],2)+pow(mw,2)));
+ double gammaw=1./sqrt(1.-pow(vv,2));
+ //top rest frame
+ E[3]=gammaw*(E[3]+vv*El);
+
+ EE1[3]=E[3]*ctw+E[1]*sin(acos(ctw));
+ EE1[1]=E[3]*sin(acos(ctw))-E[1]*ctw;
+ EE1[0]=EE1[1];
+ EE1[1]=EE1[0]*cos(phi)-E[2]*sin(phi);
+ EE1[2]=E[2]*cos(phi)+EE1[0]*sin(phi);
+ NN1[1]=W1[1]-EE1[1];
+ NN1[2]=W1[2]-EE1[2];
+ NN1[3]=W1[3]-EE1[3];
+}
+ // Boost to labframe
+ W1[3]=gammat*(W1[3]+vt*sqrt(pow(W1[3],2)+pow(W1[1],2)+pow(W1[2],2)+pow(mw,2)));
+ EE1[3]=gammat*(EE1[3]+vt*sqrt(pow(EE1[3],2)+pow(EE1[1],2)+pow(EE1[2],2)));
+ BB1[3]=gammat*(BB1[3]+vt*sqrt(pow(BB1[3],2)+pow(BB1[1],2)+pow(BB1[2],2)));
+
+ if(POWdecay && demitt) {TG1[3]=gammat*(TG1[3]+vt*sqrt(pow(TG1[3],2)+pow(TG1[1],2)+pow(TG1[2],2)));}
+ double WNE,WNNE,EEE,BBB,EEEE,BBBB,GGG,GGGG;
+ double phcm = 2.*pi*random(seed);
+ double cphcm = cos(phcm);
+ double sphcm = sin(phcm);
+ if(!POWprod){
+ T1[1]=250.*beta*sint*cphcm;
+ T1[2]=250.*beta*sint*sphcm;
+ T1[3]=250.*beta*cost;
+ PUP[1][3]=T1[1];
+ PUP[2][3]=T1[2];
+ PUP[3][3]=T1[3];
+ costx=T1[1]/sqrt(pow(T1[1],2)+pow(T1[2],2));
+ sintx=sin(acos(costx));
+ costz=T1[3]/sqrt(pow(T1[1],2)+pow(T1[2],2)+pow(T1[3],2));
+ sintz=sin(acos(costz));
+ WNE=W1[1];
+ W1[1]=-WNE*costz+W1[3]*sintz;
+ W1[3]=WNE*sintz+W1[3]*costz;
+ WNNE=W1[1];
+ W1[1]=WNNE*cos(phcm)-W1[2]*sin(phcm);
+ W1[2]=WNNE*sin(phcm)+W1[2]*cos(phcm);
+ EEE=EE1[1];
+ EE1[1]=-EEE*costz+EE1[3]*sintz;
+ EE1[3]=EEE*sintz+EE1[3]*costz;
+ EEEE=EE1[1];
+ EE1[1]=EEEE*cos(phcm)-EE1[2]*sin(phcm);
+ EE1[2]=EEEE*sin(phcm)+EE1[2]*cos(phcm);
+ BBB=BB1[1];
+ BB1[1]=-BBB*costz+BB1[3]*sintz;
+ BB1[3]=BBB*sintz+BB1[3]*costz;
+ BBBB=BB1[1];
+ BB1[1]=BBBB*cos(phcm)-BB1[2]*sin(phcm);
+ BB1[2]=BBBB*sin(phcm)+BB1[2]*cos(phcm);
+ G1[1]=T1[1]-W1[1]-BB1[1];
+ G1[2]=T1[2]-W1[2]-BB1[2];
+ G1[3]=T1[3]-W1[3]-BB1[3];
+ if (POWdecay && demitt) {
+ double GGG;
+ GGG=TG1[1];
+ TG1[1] = -GGG*costz+TG1[3]*sintz;
+ TG1[3] = GGG*sintz+TG1[3]*costz;
+ GGGG=TG1[1];
+ TG1[1]=GGGG*cos(phcm)-TG1[2]*sin(phcm);
+ TG1[2]=GGGG*sin(phcm)+TG1[2]*cos(phcm);
+ G1[1]=T1[1]-W1[1]-BB1[1]-TG1[1];
+ G1[2]=T1[2]-W1[2]-BB1[2]-TG1[2];
+ G1[3]=T1[3]-W1[3]-BB1[3]-TG1[3];
+}
+}else {
+ T1[4]=T1[3];
+ T1[5]=T1[3]*sintz;
+ T1[3]=T1[3]*costz;
+ T1[1]=T1[5]*costx;
+ if(fabs(T1[1]-PUP[1][4]) > 0.001) {T1[1]=-T1[1];sintz=-sintz;}
+ T1[5]=T1[4]*sintz;
+ T1[2]=-T1[5]*sintx;
+ if(fabs(T1[2]-PUP[2][4]) > 0.001) {T1[2]=-T1[2];sintx=-sintx;}
+ WNE=W1[1];
+ W1[1]=WNE*costz+W1[3]*sintz;
+ W1[3]=-WNE*sintz+W1[3]*costz;
+ WNNE=W1[1];
+ W1[1]=WNNE*costx+W1[2]*sintx;
+ W1[2]=-WNNE*sintx+W1[2]*costx;
+ EEE=EE1[1];
+ EE1[1]=EEE*costz+EE1[3]*sintz;
+ EE1[3]=-EEE*sintz+EE1[3]*costz;
+ EEEE=EE1[1];
+ EE1[1]=EEEE*costx+EE1[2]*sintx;
+ EE1[2]=-EEEE*sintx+EE1[2]*costx;
+ BBB=BB1[1];
+ BB1[1]=BBB*costz+BB1[3]*sintz;
+ BB1[3]=-BBB*sintz+BB1[3]*costz;
+ BBBB=BB1[1];
+ BB1[1]=BBBB*costx+BB1[2]*sintx;
+ BB1[2]=-BBBB*sintx+BB1[2]*costx;
+ G1[1]=T1[1]-W1[1]-BB1[1];
+ G1[2]=T1[2]-W1[2]-BB1[2];
+ G1[3]=T1[3]-W1[3]-BB1[3];
+ if (POWdecay && demitt){
+ GGG=TG1[1];
+ TG1[1]=GGG*costz+TG1[3]*sintz;
+ TG1[3]=-GGG*sintz+TG1[3]*costz;
+ GGGG=TG1[1];
+ TG1[1]=GGGG*costx+TG1[2]*sintx;
+ TG1[2]=-GGGG*sintx+TG1[2]*costx;
+ G1[1]=T1[1]-W1[1]-BB1[1]-TG1[1];
+ G1[2]=T1[2]-W1[2]-BB1[2]-TG1[2];
+ G1[3]=T1[3]-W1[3]-BB1[3]-TG1[3];
+ }
+ }
+ NN1[1]=W1[1]-EE1[1];
+ NN1[2]=W1[2]-EE1[2];
+ NN1[3]=W1[3]-EE1[3];
+ if(!POWdecay) {
+ BB1[1]=T1[1]-W1[1];
+ BB1[2]=T1[2]-W1[2];
+ BB1[3]=T1[3]-W1[3];}
+ pw=sqrt(pow(Ew2,2)-pow(mw,2));
+ phi=2.*pi*random(seed);
+
+ // Do the same as above for tbar
+
+ // tbar rest frame
+
+ W2[1]=pw*sin(acos(ctw2))*cos(phi);
+ W2[2]=pw*sin(acos(ctw2))*sin(phi);
+ W2[3]=pw*(ctw2);
+
+ //W rest frame
+
+ E[1]=El*sin(acos(ctl2))*cos(bphi2);
+ E[2]=El*sin(acos(ctl2))*sin(bphi2);
+ E[3]=El*ctl2;
+ vv=pw/Ew2;
+ gammaw=1./sqrt(1.-pow(vv,2));
+ //tbar rest frame
+ E[3]=gammaw*(E[3]+vv*El);
+
+ EE2[3]=E[3]*ctw2+E[1]*sin(acos(ctw2));
+ EE2[1]=E[3]*sin(acos(ctw2))-E[1]*ctw2;
+
+
+ EE2[0]=EE2[1];
+
+ EE2[1]=EE2[0]*cos(phi)-E[2]*sin(phi);
+ EE2[2]=E[2]*cos(phi)+EE2[0]*sin(phi);
+ NN2[1]=W2[1]-EE2[1];
+ NN2[2]=W2[2]-EE2[2];
+ NN2[3]=W2[3]-EE2[3];
+
+ double GG2[5],TG2[4];;
+ if (POWdecay) {
+ GT[1]=0.;
+ GT[2]=0.;
+ GT[3]=0.;
+ KT=sqrt(pt2r2*pow(mt,2)); // transverse momenta for decay gluon
+ phb=2.*pi*random(seed);
+ B2[1]=-KT*cos(phb);
+ B2[2]=-KT*sin(phb);
+ B2[3]=-sqrt(pow(Eb2,2)-pow(B2[1],2)-pow(B2[2],2));
+ G[1]=KT*cos(phb);
+ G[2]=KT*sin(phb);
+ G[3]=-sqrt(pow(Eg2,2)-pow(G[1],2)-pow(G[2],2));
+
+ if (!demittb) {
+ if (fabs(pw-sqrt(pow(B2[1]+G[1],2)+pow(B2[2]+G[2],2)+pow(B2[3]+G[3],2))) > 0.1) {G[3]=sqrt(pow(Eg2,2)-pow(G[1],2)-pow(G[2],2));} }
+ if (demittb) {
+ if (fabs(sqrt(pow(xww2*mt/2.,2)-pow(mw,2))-sqrt(pow(B2[1]+G[1],2)+pow(B2[2]+G[2],2)+pow(B2[3]+G[3],2))) > 0.1) {G[3]=sqrt(pow(Eg2,2)-pow(G[1],2)-pow(G[2],2));}}
+
+ if (demittb) {
+ if (pow(B2[3]+G[3],2) < ptr2b) {demittb = false; pw = sqrt (pow(xww2*mt/2.,2)-pow(mw,2));
+
+
+ // tbar rest frame
+ W2[1]=pw*sin(acos(ctw2))*cos(phi);
+ W2[2]=pw*sin(acos(ctw2))*sin(phi);
+ W2[3]=pw*(ctw2);
+ //W rest frame
+ E[1]=El*sin(acos(ctl2))*cos(bphi2);
+ E[2]=El*sin(acos(ctl2))*sin(bphi2);
+ E[3]=El*ctl2;
+ vv=pw/(xww2*mt/2.);
+ gammaw=1./sqrt(1.-pow(vv,2));
+ //tbar rest frame
+ E[3]=gammaw*(E[3]+vv*El);
+
+ EE2[3]=E[3]*ctw2+E[1]*sin(acos(ctw2));
+ EE2[1]=E[3]*sin(acos(ctw2))-E[1]*ctw2;
+
+
+ EE2[0]=EE2[1];
+
+ EE2[1]=EE2[0]*cos(phi)-E[2]*sin(phi);
+ EE2[2]=E[2]*cos(phi)+EE2[0]*sin(phi);
+ NN2[1]=W2[1]-EE2[1];
+ NN2[2]=W2[2]-EE2[2];
+ NN2[3]=W2[3]-EE2[3];
+
+ B2[1]=-KT*cos(phb);
+ B2[2]=-KT*sin(phb);
+ B2[3]=-sqrt(pow(Eb2,2)-pow(B2[1],2)-pow(B2[2],2));
+ G[1]=KT*cos(phb);
+ G[2]=KT*sin(phb);
+ G[3]=-sqrt(pow(Eg2,2)-pow(G[1],2)-pow(G[2],2));
+
+ if (fabs(pw-sqrt(pow(B2[1]+G[1],2)+pow(B2[2]+G[2],2)+pow(B2[3]+G[3],2))) > 0.1) {G[3]=sqrt(pow(Eg2,2)-pow(G[1],2)-pow(G[2],2));}
+ }
+ }
+ if(demittb) {
+ KT1 = sqrt(ptr2b);// transverse momenta for decay truncated gluon
+
+ phb2 = 2.*pi*random(seed);
+ BT[1]=KT1*cos(phb2);
+ BT[2]=KT1*sin(phb2);
+ BT[3]= -sqrt(pow(B2[3]+G[3],2)-pow(KT1,2));
+ GT[1]=-KT1*cos(phb2);
+ GT[2]=-KT1*sin(phb2);
+ GT[3]= -pw - BT[3];
+}
+ thetr = asin(KT1/(B2[3]+G[3]));
+ double ctwr = cos(thetr);
+ if (POWdecay &&demittb) {
+ BT[3]=B2[3]*ctwr+B2[1]*sin(acos(ctwr));
+ BT[1]=-B2[3]*sin(acos(ctwr))+B2[1]*ctwr;
+ GGT[3]=G[3]*ctwr+G[1]*sin(acos(ctwr));
+ GGT[1]=-G[3]*sin(acos(ctwr))+G[1]*ctwr;
+ BT[0]=BT[1];
+ BT[1]=BT[0]*cos(phb2)-B2[2]*sin(phb2);
+ BT[2]=B2[2]*cos(phb2)+BT[0]*sin(phb2);
+ GGT[0]=GGT[1];
+ GGT[1]=GGT[0]*cos(phb2)-G[2]*sin(phb2);
+ GGT[2]=G[2]*cos(phb2)+GGT[0]*sin(phb2);
+ B2[3] = BT[3];
+ B2[1] = BT[1];
+ B2[2] = BT[2];
+ G[3] = GGT[3];
+ G[2] = GGT[2];
+ G[1] = GGT[1];
+
+}
+ //detour to W rest frame
+ B2[0]=gammaw*(B2[3]-vv*Eb2);
+
+ BB2[3]=B2[3]*ctw2+B2[1]*sin(acos(ctw2));
+ BB2[1]=B2[3]*sin(acos(ctw2))-B2[1]*ctw2;
+ GG2[3]=G[3]*ctw2+G[1]*sin(acos(ctw2));
+ GG2[1]=G[3]*sin(acos(ctw2))-G[1]*ctw2;
+ TG2[3]=GT[3]*ctw2+GT[1]*sin(acos(ctw2));
+ TG2[1]=GT[3]*sin(acos(ctw2))-GT[1]*ctw2;
+ GG2[0]=GG2[1];
+ GG2[1]=GG2[0]*cos(phi)-G[2]*sin(phi);
+ GG2[2]=G[2]*cos(phi)+GG2[0]*sin(phi);
+ BB2[0]=BB2[1];
+ BB2[1]=BB2[0]*cos(phi)-B2[2]*sin(phi);
+ BB2[2]=B2[2]*cos(phi)+BB2[0]*sin(phi);
+ TG2[0]=TG2[1];
+ TG2[1]=TG2[0]*cos(phi)-GT[2]*sin(phi);
+ TG2[2]=GT[2]*cos(phi)+TG2[0]*sin(phi);
+
+ if (fabs(W2[1]+GG2[1]+BB2[1]+TG2[1]) > 0.1 || fabs(W2[2]+GG2[2]+BB2[2]+TG2[2]) >0.1) {B2[3]=sqrt(pow(Eb2,2)-pow(KT,2));
+ G[3]=-sqrt(pow(Eg2,2)-pow(KT,2)); B2[1]=-KT*cos(phb) ; B2[2] = -KT*sin(phb); G[1]=KT*cos(phb); G[2] = KT*sin(phb); thetr = asin(KT1/(sqrt(pow(B2[1]+G[1],2)+pow(B2[2]+G[2],2)+pow(B2[3]+G[3],2))));
+
+ ctwr = cos(thetr);
+ if (POWdecay &&demittb) {
+ BT[3]=B2[3]*ctwr+B2[1]*sin(acos(ctwr));
+ BT[1]=-B2[3]*sin(acos(ctwr))+B2[1]*ctwr;
+ GGT[3]=G[3]*ctwr+G[1]*sin(acos(ctwr));
+ GGT[1]=-G[3]*sin(acos(ctwr))+G[1]*ctwr;
+ BT[0]=BT[1];
+ BT[1]=BT[0]*cos(phb2)-B2[2]*sin(phb2);
+ BT[2]=B2[2]*cos(phb2)+BT[0]*sin(phb2);
+ GGT[0]=GGT[1];
+ GGT[1]=GGT[0]*cos(phb2)-G[2]*sin(phb2);
+ GGT[2]=G[2]*cos(phb2)+GGT[0]*sin(phb2);
+ B2[3] = BT[3];
+ B2[1] = BT[1];
+ B2[2] = BT[2];
+ G[3] = GGT[3];
+ G[2] = GGT[2];
+ G[1] = GGT[1];}
+
+ BB2[3]=B2[3]*ctw2+B2[1]*sin(acos(ctw2));
+ BB2[1]=B2[3]*sin(acos(ctw2))-B2[1]*ctw2;
+ GG2[3]=G[3]*ctw2+G[1]*sin(acos(ctw2));
+ GG2[1]=G[3]*sin(acos(ctw2))-G[1]*ctw2;
+ TG2[3]=GT[3]*ctw2+GT[1]*sin(acos(ctw2));
+ TG2[1]=GT[3]*sin(acos(ctw2))-GT[1]*ctw2;
+ GG2[0]=GG2[1];
+ GG2[1]=GG2[0]*cos(phi)-G[2]*sin(phi);
+ GG2[2]=G[2]*cos(phi)+GG2[0]*sin(phi);
+ BB2[0]=BB2[1];
+ BB2[1]=BB2[0]*cos(phi)-B2[2]*sin(phi);
+ BB2[2]=B2[2]*cos(phi)+BB2[0]*sin(phi);
+ TG2[0]=TG2[1];
+ TG2[1]=TG2[0]*cos(phi)-GT[2]*sin(phi);
+ TG2[2]=GT[2]*cos(phi)+TG2[0]*sin(phi);
+ }
+ }
+ if (POWdecay && demittb){
+ double bp = sqrt(pow(BB2[3],2)+pow(BB2[2],2)+pow(BB2[1],2));
+ double gp = sqrt(pow(GG2[3],2)+pow(GG2[2],2)+pow(GG2[1],2));
+ double gtrp = sqrt(pow(TG2[3],2)+pow(TG2[2],2)+pow(TG2[1],2));
+ double wp = sqrt(pow(W2[3],2)+pow(W2[2],2)+pow(W2[1],2));
+ double mfac = (mt*gp + mt*bp+mt*gtrp-sqrt(-pow(wp*mw,2)+pow(mt,2)*pow(wp,2)+pow(bp*mw,2)+2.*bp*gp*pow(mw,2)+2.*bp*gtrp*pow(mw,2)+pow(gp*mw,2)+2.*gp*gtrp*pow(mw,2)+pow(gtrp*mw,2)))/(-pow(wp,2)+pow(bp,2)+2.*bp*gp+2.*bp*gtrp+pow(gp,2)+2.*gp*gtrp+pow(gtrp,2));
+ BB2[3]=mfac*BB2[3]; BB2[2]=mfac*BB2[2]; BB2[1]=mfac*BB2[1];GG2[3]=mfac*GG2[3]; GG2[2]=mfac*GG2[2]; GG2[1]=mfac*GG2[1];
+ TG2[3]=mfac*TG2[3]; TG2[2]=mfac*TG2[2]; TG2[1]=mfac*TG2[1];W2[3]=mfac*W2[3]; W2[2]=mfac*W2[2]; W2[1]=mfac*W2[1];
+ E[1]=El*sin(acos(ctl2))*cos(bphi2);
+ E[2]=El*sin(acos(ctl2))*sin(bphi2);
+ E[3]=El*ctl2;
+ double vv=sqrt((pow(W2[1],2)+pow(W2[2],2)+pow(W2[3],2))/(pow(W2[1],2)+pow(W2[2],2)+pow(W2[3],2)+pow(mw,2)));
+ double gammaw=1./sqrt(1.-pow(vv,2));
+ //t bar rest frame
+ E[3]=gammaw*(E[3]+vv*El);
+
+ EE2[3]=E[3]*ctw2+E[1]*sin(acos(ctw2));
+ EE2[1]=E[3]*sin(acos(ctw2))-E[1]*ctw2;
+ EE2[0]=EE2[1];
+ EE2[1]=EE2[0]*cos(phi)-E[2]*sin(phi);
+ EE2[2]=E[2]*cos(phi)+EE2[0]*sin(phi);
+ NN2[1]=W2[1]-EE2[1];
+ NN2[2]=W2[2]-EE2[2];
+ NN2[3]=W2[3]-EE2[3];
+
+ }
+
+ // lab frame
+ W2[3]=gammatb*(W2[3]+vtb*sqrt(pow(W2[3],2)+pow(W2[1],2)+pow(W2[2],2)+pow(mw,2)));
+ EE2[3]=gammatb*(EE2[3]+vtb*sqrt(pow(EE2[3],2)+pow(EE2[1],2)+pow(EE2[2],2)));
+ BB2[3]=gammatb*(BB2[3]+vtb*sqrt(pow(BB2[3],2)+pow(BB2[1],2)+pow(BB2[2],2)));
+ if(POWdecay && demittb) {TG2[3]=gammatb*(TG2[3]+vtb*sqrt(pow(TG2[3],2)+pow(TG2[1],2)+pow(TG2[2],2)));}
+
+ if(!POWprod){
+
+ T2[1]=-250.*beta*sint*cphcm;
+ T2[2]=-250.*beta*sint*sphcm;
+ T2[3]=-250.*beta*cost;
+ PUP[1][4]=T2[1];
+ PUP[2][4]=T2[2];
+ PUP[3][4]=T2[3];
+ costbx=T2[1]/sqrt(pow(T2[1],2)+pow(T2[2],2));
+ sintbx = sin(acos(costbx));
+ costbz=-T2[3]/sqrt(pow(T2[1],2)+pow(T2[2],2)+pow(T2[3],2));
+ sintbz = sin(acos(costbz));
+
+ WNE=W2[1];
+ W2[1]=(-WNE*costbz+W2[3]*sintbz);
+ W2[3]=(WNE*sintbz+W2[3]*costbz);
+ WNNE=W2[1];
+ W2[1]=(WNNE*cos(phcm)-W2[2]*sin(phcm));
+ W2[2]=(WNNE*sin(phcm)+W2[2]*cos(phcm));
+ EEE=EE2[1];
+ EE2[1]=(-EEE*costbz+EE2[3]*sintbz);
+ EE2[3]=(EEE*sintbz+EE2[3]*costbz);
+ EEEE=EE2[1];
+ EE2[1]=(EEEE*cos(phcm)-EE2[2]*sin(phcm));
+ EE2[2]=(EEEE*sin(phcm)+EE2[2]*cos(phcm));
+ BBB=BB2[1];
+ BB2[1]=(-BBB*costbz+BB2[3]*sintbz);
+ BB2[3]=(BBB*sintbz+BB2[3]*costbz);
+ BBBB=BB2[1];
+ BB2[1]=(BBBB*cos(phcm)-BB2[2]*sin(phcm));
+ BB2[2]=(BBBB*sin(phcm)+BB2[2]*cos(phcm));
+ W2[1]= -W2[1];
+ W2[2]= -W2[2];
+ W2[3]= -W2[3];
+ EE2[1]= -EE2[1];
+ EE2[2]= -EE2[2];
+ EE2[3]= -EE2[3];
+ BB2[1]= -BB2[1];
+ BB2[2]= -BB2[2];
+ BB2[3]= -BB2[3],
+ G2[1]=T2[1]-W2[1]-BB2[1];
+ G2[2]=T2[2]-W2[2]-BB2[2];
+ G2[3]=T2[3]-W2[3]-BB2[3];
+ if (POWdecay && demittb) {
+ GGG=TG2[1];
+ TG2[1] = -GGG*costbz+TG2[3]*sintbz;
+ TG2[3] = GGG*sintbz+TG2[3]*costbz;
+ GGGG=TG2[1];
+ TG2[1]=(GGGG*cos(phcm)-TG2[2]*sin(phcm));
+ TG2[2]=(GGGG*sin(phcm)+TG2[2]*cos(phcm));
+ TG2[1]= -TG2[1];
+ TG2[2]= -TG2[2];
+ TG2[3]= -TG2[3],
+ G2[1]=T2[1]-W2[1]-BB2[1]-TG2[1];
+ G2[2]=T2[2]-W2[2]-BB2[2]-TG2[2];
+ G2[3]=T2[3]-W2[3]-BB2[3]-TG2[3];
+}
+ }else
+ {
+ T2[4]=T2[3];
+ T2[5]=T2[3]*sintbz;
+ T2[3]=T2[3]*costbz;
+ T2[1]=T2[5]*costbx;
+ if(fabs(T2[1]-PUP[1][5]) > 0.001) {T2[1]=-T2[1];sintbz=-sintbz;}
+ T2[5]=T2[4]*sintbz;
+ T2[2]=-T2[5]*sintbx;
+ if(fabs(T2[2]-PUP[2][5]) > 0.001) {T2[2]=-T2[2];sintbx=-sintbx;}
+ WNE=W2[1];
+ W2[1]=WNE*costbz+W2[3]*sintbz;
+ W2[3]=-WNE*sintbz+W2[3]*costbz;
+ WNNE=W2[1];
+ W2[1]=WNNE*costbx+W2[2]*sintbx;
+ W2[2]=-WNNE*sintbx+W2[2]*costbx;
+ EEE=EE2[1];
+ EE2[1]=EEE*costbz+EE2[3]*sintbz;
+ EE2[3]=-EEE*sintbz+EE2[3]*costbz;
+ EEEE=EE2[1];
+ EE2[1]=EEEE*costbx+EE2[2]*sintbx;
+ EE2[2]=-EEEE*sintbx+EE2[2]*costbx;
+ BBB=BB2[1];
+ BB2[1]=BBB*costbz+BB2[3]*sintbz;
+ BB2[3]=-BBB*sintbz+BB2[3]*costbz;
+ BBBB=BB2[1];
+ BB2[1]=BBBB*costbx+BB2[2]*sintbx;
+ BB2[2]=-BBBB*sintbx+BB2[2]*costbx;
+ G2[1]=T2[1]-W2[1]-BB2[1];
+ G2[2]=T2[2]-W2[2]-BB2[2];
+ G2[3]=T2[3]-W2[3]-BB2[3];
+ if (POWdecay && demittb){
+ GGG=TG2[1];
+ TG2[1]=GGG*costbz+TG2[3]*sintbz;
+ TG2[3]=-GGG*sintbz+TG2[3]*costbz;
+ GGGG=TG2[1];
+ TG2[1]=GGGG*costbx+TG2[2]*sintbx;
+ TG2[2]=-GGGG*sintbx+TG2[2]*costbx;
+ G2[1]=T2[1]-W2[1]-BB2[1]-TG2[1];
+ G2[2]=T2[2]-W2[2]-BB2[2]-TG2[2];
+ G2[3]=T2[3]-W2[3]-BB2[3]-TG2[3];
+ }
+
+ }
+
+ NN2[1]=W2[1]-EE2[1];
+ NN2[2]=W2[2]-EE2[2];
+ NN2[3]=W2[3]-EE2[3];
+ if(!POWdecay) {
+ BB2[1]=T2[1]-W2[1];
+ BB2[2]=T2[2]-W2[2];
+ BB2[3]=T2[3]-W2[3];}
+
+
+ double TE1=sqrt(pow(T1[1],2)+pow(T1[2],2)+pow(T1[3],2)+pow(mt,2));
+ double TE2=sqrt(pow(T2[1],2)+pow(T2[2],2)+pow(T2[3],2)+pow(mt,2));
+ double NE1=sqrt(pow(NN1[1],2)+pow(NN1[2],2)+pow(NN1[3],2));
+ double NE2=sqrt(pow(NN2[1],2)+pow(NN2[2],2)+pow(NN2[3],2));
+ double GE1=sqrt(pow(G1[1],2)+pow(G1[2],2)+pow(G1[3],2));
+ double GE2=sqrt(pow(G2[1],2)+pow(G2[2],2)+pow(G2[3],2));
+ double BE1=sqrt(pow(BB1[1],2)+pow(BB1[2],2)+pow(BB1[3],2));
+ double BE2=sqrt(pow(BB2[1],2)+pow(BB2[2],2)+pow(BB2[3],2));
+ double LE1=sqrt(pow(EE1[1],2)+pow(EE1[2],2)+pow(EE1[3],2));
+ double LE2=sqrt(pow(EE2[1],2)+pow(EE2[2],2)+pow(EE2[3],2));
+
+ if (POWdecay &&demitt) {PUP[4][15]=sqrt(pow(TG1[1],2)+pow(TG1[2],2)+pow(TG1[3],2));PUP[1][15]=TG1[1]; PUP[2][15]=TG1[2]; PUP[3][15]=TG1[3];
+}
+ if (POWdecay &&demittb){PUP[4][16]=sqrt(pow(TG2[1],2)+pow(TG2[2],2)+pow(TG2[3],2));PUP[1][16]=TG2[1]; PUP[2][16]=TG2[2]; PUP[3][16]=TG2[3];
+ }
+
+
+ // Fill in Les Houches common block
+ mass[1]=0.;
+ mass[2]=0.;
+ mass[3]=mt;
+ mass[4]=mt;
+ mass[5]=0.;
+ mass[6]=0.;
+ mass[7]=0.;
+ mass[8]=0.;
+ mass[9]=0.;
+ mass[10]=0.;
+ mass[11]=0.;
+ mass[12]=0.;
+ mass[13]=0.;
+ mass[14]=0.;
+ mass[17]=emcm;
+ mass[15]=0.;
+ mass[16]=0.;
+ if (POWprod) {
+ if (emit) {
+ PUP[4][13]=PUP[4][6];
+ PUP[3][13]=PUP[3][6];
+ PUP[2][13]=PUP[2][6];
+ PUP[1][13]=PUP[1][6];
+ PUP[4][14]=PUP[4][7];
+ PUP[3][14]=PUP[3][7];
+ PUP[2][14]=PUP[2][7];
+ PUP[1][14]=PUP[1][7];} else {
+ PUP[4][13]=PUP[4][6];
+ PUP[3][13]=PUP[3][6];
+ PUP[2][13]=PUP[2][6];
+ PUP[1][13]=PUP[1][6];
+ }}
+ PUP[4][1]=emcm/2.;
+ PUP[3][1]=emcm/2.;
+ PUP[2][1]=0.;
+ PUP[1][1]=0.;
+ PUP[4][2]=emcm/2.;
+ PUP[3][2]=-emcm/2.;
+ PUP[2][2]=0.;
+ PUP[1][2]=0.;
+ PUP[4][3]=TE1;
+ PUP[3][3]=T1[3];
+ PUP[2][3]=T1[2];
+ PUP[1][3]=T1[1];
+ PUP[4][4]=TE2;
+ PUP[3][4]=T2[3];
+ PUP[2][4]=T2[2];
+ PUP[1][4]=T2[1];
+ PUP[4][17]=emcm;
+ PUP[3][17]=0.;
+ PUP[2][17]=0.;
+ PUP[1][17]=0.;
+ PUP[4][11]=GE1;
+ PUP[3][11]=G1[3];
+ PUP[2][11]=G1[2];
+ PUP[1][11]=G1[1];
+ PUP[4][12]=GE2;
+ PUP[3][12]=G2[3];
+ PUP[2][12]=G2[2];
+ PUP[1][12]=G2[1];
+ PUP[4][6]=BE1;
+ PUP[3][6]=BB1[3];
+ PUP[2][6]=BB1[2];
+ PUP[1][6]=BB1[1];
+ PUP[4][7]=BE2;
+ PUP[3][7]=BB2[3];
+ PUP[2][7]=BB2[2];
+ PUP[1][7]=BB2[1];
+ PUP[4][9]=LE1;
+ PUP[3][9]=EE1[3];
+ PUP[2][9]=EE1[2];
+ PUP[1][9]=EE1[1];
+ PUP[4][8]=LE2;
+ PUP[3][8]=EE2[3];
+ PUP[2][8]=EE2[2];
+ PUP[1][8]=EE2[1];
+ PUP[4][10]=NE1;
+ PUP[3][10]=NN1[3];
+ PUP[2][10]=NN1[2];
+ PUP[1][10]=NN1[1];
+ PUP[4][5]=NE2;
+ PUP[3][5]=NN2[3];
+ PUP[2][5]=NN2[2];
+ PUP[1][5]=NN2[1];
+ IDUP[1]=11;
+ IDUP[2]=-11;
+ IDUP[3]=6;
+ IDUP[4]=-6;
+ IDUP[11]=21;
+ IDUP[6]=5;
+ IDUP[7]=-5;
+ IDUP[8]=11;
+ IDUP[9]=-11;
+ IDUP[10]=12;
+ IDUP[5]=-12;
+ IDUP[12]=21;
+ IDUP[13]=21;
+ IDUP[14]=21;
+ IDUP[17]=22;
+ IDUP[15]=21;
+ IDUP[16]=21;
+ MOTHUP[1][1]=0;
+ MOTHUP[2][1]=0;
+ MOTHUP[1][2]=0;
+ MOTHUP[2][2]=0;
+ MOTHUP[1][3]=3;
+ MOTHUP[2][3]=3;
+ MOTHUP[1][4]=3;
+ MOTHUP[2][4]=3;
+ MOTHUP[1][17]=1;
+ MOTHUP[2][17]=2;
+ MOTHUP[1][11]=4;
+ MOTHUP[2][11]=4;
+ MOTHUP[1][6]=4;
+ MOTHUP[2][6]=4;
+ MOTHUP[1][7]=5;
+ MOTHUP[2][7]=5;
+ MOTHUP[1][8]=5;
+ MOTHUP[2][8]=5;
+ MOTHUP[1][9]=4;
+ MOTHUP[2][9]=4;
+ MOTHUP[1][10]=4;
+ MOTHUP[2][10]=4;
+ MOTHUP[1][5]=5;
+ MOTHUP[2][5]=5;
+ MOTHUP[1][12]=5;
+ MOTHUP[2][12]=5;
+ MOTHUP[1][13]=3;
+ MOTHUP[2][13]=3;
+ MOTHUP[1][14]=3;
+ MOTHUP[2][14]=3;
+ MOTHUP[1][15]=4;
+ MOTHUP[2][15]=4;
+ MOTHUP[1][16]=5;
+ MOTHUP[2][16]=5;
+ ISTUP[1]=-1;
+ ISTUP[2]=-1;
+ ISTUP[3]=2;
+ ISTUP[4]=2;
+ ISTUP[17]=2;
+ ISTUP[5]=1;
+ ISTUP[6]=1;
+ ISTUP[7]=1;
+ ISTUP[8]=1;
+ ISTUP[9]=1;
+ ISTUP[10]=1;
+ ISTUP[11]=1;
+ ISTUP[12]=1;
+ ISTUP[13]=1;
+ ISTUP[14]=1;
+ ISTUP[15]=1;
+ ISTUP[16]=1;
+ ISPINUP[1]=1;
+ ISPINUP[2]=-1;
+ ISPINUP[3]=1;
+ ISPINUP[4]=-1;
+ ISPINUP[5]=1;
+ ISPINUP[6]=1;
+ ISPINUP[7]=-1;
+ ISPINUP[8]=1;
+ ISPINUP[9]=-1;
+ ISPINUP[10]=1;
+ ISPINUP[11]=-1;
+ ISPINUP[12]=-1;
+ ISPINUP[13]=-1;
+ ISPINUP[14]=1;
+ ISPINUP[17]=1;
+ ISPINUP[15]=1;
+ ISPINUP[16]=1;
+ ICOLUP[1][1]=0;
+ ICOLUP[2][1]=0;
+ ICOLUP[1][2]=0;
+ ICOLUP[2][2]=0;
+ ICOLUP[1][17]=0;
+ ICOLUP[2][17]=0;
+ if (!POWprod && !POWdecay) {
+ ICOLUP[1][3]=501;
+ ICOLUP[2][3]=0;
+ ICOLUP[1][4]=0;
+ ICOLUP[2][4]=501;
+ ICOLUP[1][6]=501;
+ ICOLUP[2][6]=0;
+ ICOLUP[1][7]=0;
+ ICOLUP[2][7]=501;
+ }
+ if (!POWprod && POWdecay){
+ ICOLUP[1][3]=501;
+ ICOLUP[2][3]=0;
+ ICOLUP[1][4]=0;
+ ICOLUP[2][4]=501;
+ ICOLUP[1][11]=501;
+ ICOLUP[2][11]=503;
+ ICOLUP[1][6]=503;
+ ICOLUP[2][6]=0;
+ ICOLUP[1][7]=0;
+ ICOLUP[2][7]=504;
+ ICOLUP[1][12]=504;
+ ICOLUP[2][12]=501;
+ if (demitt) {
+ ICOLUP[1][11]=501;
+ ICOLUP[2][11]=505;
+ ICOLUP[1][15]=505;
+ ICOLUP[2][15]=503;}
+ if (demittb) {
+ ICOLUP[1][12]=506;
+ ICOLUP[2][12]=501;
+ ICOLUP[1][16]=504;
+ ICOLUP[2][16]=506;
+ }
+ }
+ if (POWprod && POWdecay) {
+ ICOLUP[1][3]=501;
+ ICOLUP[2][3]=0;
+ ICOLUP[1][4]=0;
+ ICOLUP[2][4]=502;
+ if (!emit){
+ ICOLUP[1][13]=502;
+ ICOLUP[2][13]=501;
+ ICOLUP[1][11]=501;
+ ICOLUP[2][11]=503;
+ ICOLUP[1][6]=503;
+ ICOLUP[2][6]=0;
+ ICOLUP[1][7]=0;
+ ICOLUP[2][7]=504;
+ ICOLUP[1][12]=504;
+ ICOLUP[2][12]=502;
+ if (demitt) {
+ ICOLUP[1][11]=505;
+ ICOLUP[2][11]=503;
+ ICOLUP[1][15]=501;
+ ICOLUP[2][15]=505;}
+ if (demittb) {
+ ICOLUP[1][12]=504;
+ ICOLUP[2][12]=506;
+ ICOLUP[1][16]=506;
+ ICOLUP[2][16]=502;
+ }
+ }else {
+ if((PUP[4][3] > PUP[4][4] && acos((PUP[3][13]*PUP[3][3]+PUP[2][13]*PUP[2][3]+PUP[1][13]*PUP[1][3])/(PUP[4][13]*PUP[4][3])) > 1.57) || PUP[4][4] > PUP[4][3] && acos((PUP[3][13]*PUP[3][4]+PUP[2][13]*PUP[2][4]+PUP[1][13]*PUP[1][4])/(PUP[4][13]*PUP[4][4])) < 1.57) {
+ ICOLUP[1][13]=505;
+ ICOLUP[2][13]=501;
+ ICOLUP[1][14]=502;
+ ICOLUP[2][14]=505;} else {
+ ICOLUP[1][14]=505;
+ ICOLUP[2][14]=501;
+ ICOLUP[1][13]=502;
+ ICOLUP[2][13]=505;
+ }
+ ICOLUP[1][11]=501;
+ ICOLUP[2][11]=503;
+ ICOLUP[1][6]=503;
+ ICOLUP[2][6]=0;
+ ICOLUP[1][7]=0;
+ ICOLUP[2][7]=504;
+ ICOLUP[1][12]=504;
+ ICOLUP[2][12]=502;
+ if (demitt) {
+ ICOLUP[1][11]=507;
+ ICOLUP[2][11]=503;
+ ICOLUP[1][15]=501;
+ ICOLUP[2][15]=507;}
+ if (demittb) {
+ ICOLUP[1][12]=504;
+ ICOLUP[2][12]=508;
+ ICOLUP[1][16]=508;
+ ICOLUP[2][16]=502;
+ }
+ }}
+ if (POWprod & !POWdecay) {
+ if (!emit){
+ ICOLUP[1][3]=501;
+ ICOLUP[2][3]=0;
+ ICOLUP[1][4]=0;
+ ICOLUP[2][4]=502;
+ ICOLUP[1][13]=502;
+ ICOLUP[2][13]=501;
+ ICOLUP[1][6]=501;
+ ICOLUP[2][6]=0;
+ ICOLUP[1][7]=0;
+ ICOLUP[2][7]=502;
+ } else {
+ ICOLUP[1][3]=501;
+ ICOLUP[2][3]=0;
+ ICOLUP[1][4]=0;
+ ICOLUP[2][4]=502;
+ if((PUP[4][3] > PUP[4][4] && acos((PUP[3][13]*PUP[3][3]+PUP[2][13]*PUP[2][3]+PUP[1][13]*PUP[1][3])/(PUP[4][13]*PUP[4][3])) > 1.57) || PUP[4][4] > PUP[4][3] && acos((PUP[3][13]*PUP[3][4]+PUP[2][13]*PUP[2][4]+PUP[1][13]*PUP[1][4])/(PUP[4][13]*PUP[4][4])) < 1.57) {
+ ICOLUP[1][13]=505;
+ ICOLUP[2][13]=501;
+ ICOLUP[1][14]=502;
+ ICOLUP[2][14]=505;} else {
+ ICOLUP[1][13]=502;
+ ICOLUP[2][13]=505;
+ ICOLUP[1][14]=505;
+ ICOLUP[2][14]=501;
+ }
+ ICOLUP[1][6]=501;
+ ICOLUP[2][6]=0;
+ ICOLUP[1][7]=0;
+ ICOLUP[2][7]=502;
+ }
+ }
+ ICOLUP[1][8]=0;
+ ICOLUP[2][8]=0;
+ ICOLUP[1][9]=0;
+ ICOLUP[2][9]=0;
+ ICOLUP[1][10]=0;
+ ICOLUP[2][10]=0;
+ ICOLUP[1][5]=0;
+ ICOLUP[2][5]=0;
+
+
+
+ //*********************************************************************/
+ //MADGRAPH FORMAT
+ //********************************************************************/
+
+// if (EVT==1) {count1++;}
+// if (EVT==2) {count2++;}
+// if (EVT==3) {count3++;}
+// if (EVT==4) {count4++;}
+// NUP=11;
+// if (POWprod) {NUP++;
+// if (emit) {NUP++;}}
+// if (POWdecay) {NUP++; NUP++;
+// if (demitt) {NUP++;}
+// if (demittb) {NUP++;}}
+// // cout << "NUP" << NUP << endl;
+
+// // if (POWprod && POWdecay) {
+// // if (!emit) {NUP=13;} else {NUP=14;}}
+// // if (!POWprod && POWdecay) {NUP =12;}
+// // if (POWprod && !POWdecay) {if (!emit){NUP=11;}else{NUP=12;}}
+// XWGTUP=1;
+// SCALUP=500.;
+// AQEDUP=0.0073;
+// AQCDUP=0.118;
+// double sum1,sum2,sum3,sum4;
+// int NUPP=15;
+// if (!emit){NUPP=14;}
+// sum1=0.;sum2=0.;sum3=0.;sum4=0.;
+// outdata << NUP <<"\t"<<ixx<<"\t"<<XWGTUP<<"\t"<<SCALUP<<"\t"<<AQEDUP<<"\t"<<AQCDUP <<endl;
+// for (int ja = 1; ja < 11; ja++) {
+// outdata << IDUP[ja] << "\t" ;
+// if (ja==2) {outdata << IDUP[17] << "\t" ;}}
+// if (POWdecay && POWprod) {{for (int ja=11; ja < 14; ja++)
+// {outdata << IDUP[ja] << "\t" ;}}
+
+// if (emit) {outdata << IDUP[14] << "\t" ;}
+// if (demitt) {outdata << IDUP[15] << "\t" ;}
+// if (demittb) {outdata << IDUP[16] << "\t" ;}}
+
+// //}
+// if (POWdecay && !POWprod) {{for (int ja=11; ja < 13; ja++)
+// {outdata << IDUP[ja] << "\t" ;}}
+// if (demitt) {
+// for (int ja=15; ja < NUP+2; ja++)
+// {outdata << IDUP[ja] << "\t" ;}}
+// if (!demitt && demittb)
+// {outdata << IDUP[16] << "\t" ;}
+// }
+// if (POWprod && !POWdecay) {for (int ja=13; ja<NUPP;ja++)
+// {outdata << IDUP[ja] << "\t" ;}}
+// outdata << endl;
+
+// for (int jb = 1; jb < 3; jb++) {
+// for (int jc = 1; jc < 11; jc++) {
+// outdata << MOTHUP[jb][jc]<<"\t" ;
+// if (jc==2) {outdata << MOTHUP[jb][17] << "\t" ;}}
+// if (POWdecay && POWprod) {{for (int jc=11; jc < 14; jc++)
+// {outdata << MOTHUP[jb][jc] << "\t" ;} }
+
+// if (emit) {outdata << MOTHUP[jb][14] << "\t" ;}
+// if (demitt) {outdata << MOTHUP[jb][15] << "\t" ;}
+// if (demittb) {outdata << MOTHUP[jb][16] << "\t" ;}}
+
+
+
+// if (POWdecay && !POWprod) {for (int jc=11; jc < 13; jc++)
+// {outdata << MOTHUP[jb][jc] << "\t" ;}
+// if (demitt) {
+// for (int jc=15; jc < NUP+2; jc++)
+// {outdata << MOTHUP[jb][jc] << "\t" ;} }
+// if (!demitt && demittb)
+// {outdata << MOTHUP[jb][16] << "\t" ;}
+// }
+// if (POWprod && !POWdecay) {for (int jc=13; jc<NUPP;jc++)
+// {outdata << MOTHUP[jb][jc] << "\t" ;}}
+// outdata << endl;}
+// for (int jd = 1; jd < 3; jd++) {
+// for (int je = 1; je < 11; je++) {
+// outdata << ICOLUP[jd][je]<<"\t" ;
+// if (je==2) {outdata << ICOLUP[jd][17] << "\t" ;}}
+// if (POWdecay && POWprod) {{for (int je=11; je < 14; je++)
+// {outdata << ICOLUP[jd][je] << "\t" ;}}
+// if (emit) {outdata << ICOLUP[jd][14] << "\t" ;}
+// if (demitt) {outdata << ICOLUP[jd][15] << "\t" ;}
+// if (demittb) {outdata << ICOLUP[jd][16] << "\t" ;}
+// }
+// if (POWdecay && !POWprod) {for (int je=11; je < 13; je++)
+// {outdata << ICOLUP[jd][je] << "\t" ;}
+// if (demitt) {
+// for (int je=15; je < NUP+2; je++)
+// {outdata << ICOLUP[jd][je] << "\t" ;} }
+// if (!demitt && demittb)
+// {outdata << ICOLUP[jd][16] << "\t" ;}
+// }
+// if (POWprod && !POWdecay) {for (int je=13; je<NUPP;je++)
+// {outdata << ICOLUP[jd][je] << "\t" ;}}
+// outdata << endl;}
+// for (int jf = 1; jf < 11; jf++) {
+// outdata << ISTUP[jf] << "\t" ;
+// if (jf==2) { outdata << ISTUP[17] << "\t" ;}}
+// if (POWdecay && POWprod) {{for (int jf=11; jf< 14; jf++)
+// {outdata << ISTUP[jf] << "\t" ;}}
+// if (emit) {outdata << ISTUP[14] << "\t" ;}
+// if (demitt) {outdata << ISTUP[15] << "\t" ;}
+// if (demittb) {outdata << ISTUP[16] << "\t" ;}
+// }
+// if (POWdecay && !POWprod) {{for (int jf=11; jf < 13; jf++)
+// {outdata << ISTUP[jf] << "\t" ;}}
+// if (demitt) {
+// for (int jf=15; jf < NUP+2; jf++)
+// {outdata << ISTUP[jf] << "\t" ;} }
+// if (!demitt && demittb)
+// {outdata << ISTUP[16] << "\t" ;}
+// }
+// if (POWprod && !POWdecay) {for (int jf=13; jf<NUPP;jf++)
+// {outdata << ISTUP[jf] << "\t" ;}}
+// outdata << endl;
+// for (int jg = 1; jg < 11; jg++) {
+// outdata << ISPINUP[jg] << "\t" ;
+// if (jg==2) { outdata << ISPINUP[17] << "\t" ;}}
+// if (POWdecay && POWprod) {{for (int jg=11; jg< 14; jg++)
+// {outdata << ISPINUP[jg] << "\t" ;}}
+// if (emit) {outdata << ISPINUP[14] << "\t" ;}
+// if (demitt) {outdata << ISPINUP[15] << "\t" ;}
+// if (demittb) {outdata << ISPINUP[16] << "\t" ;}
+// }
+// if (POWdecay && !POWprod) {for (int jg=11; jg < 13; jg++)
+// {outdata << ISPINUP[jg] << "\t" ;}
+// if (demitt) {
+// for (int jg=15; jg < NUP+2; jg++)
+// {outdata << ISPINUP[jg] << "\t" ;} }
+// if (!demitt && demittb)
+// {outdata << ISPINUP[16] << "\t" ;}
+// }
+// if (POWprod && !POWdecay) {for (int jg=13; jg<NUPP;jg++)
+// {outdata << ISPINUP[jg] << "\t" ;}}
+
+// outdata << endl;
+// int jhh=0;
+// for (int jh = 1; jh < 11; jh++) {
+// jhh=jhh+1;
+// outdata << jhh <<"\t" << PUP[4][jh] << "\t" << PUP[1][jh]<<"\t"<<PUP[2][jh]<<"\t"<<PUP[3][jh]<<endl;
+// if(jh==2){outdata << 3 <<"\t" << PUP[4][17] << "\t" << PUP[1][17]<<"\t"<<PUP[2][17]<<"\t"<<PUP[3][17]<<endl;jhh=jhh+1;}
+// if (jh != 3 && jh != 4){
+// sum1+=PUP[4][jh];sum2+=PUP[1][jh];sum3+=PUP[2][jh];sum3+=PUP[3][jh];}}
+// if (POWdecay && POWprod) {{for (int jh=11; jh< 14; jh++)
+
+// {jhh=jh+1;outdata << jhh <<"\t" << PUP[4][jh] << "\t" << PUP[1][jh]<<"\t"<<PUP[2][jh]<<"\t"<<PUP[3][jh]<<endl;
+
+// sum1+=PUP[4][jh];sum2+=PUP[1][jh];sum3+=PUP[2][jh];sum3+=PUP[3][jh];}}
+// if (emit) {
+// outdata << jhh+1 <<"\t" << PUP[4][14] << "\t" << PUP[1][14]<<"\t"<<PUP[2][14]<<"\t"<<PUP[3][14]<<endl;
+// sum1+=PUP[4][14];sum2+=PUP[1][14];sum3+=PUP[2][14];sum3+=PUP[3][14];
+// }
+// if (demitt) {
+// outdata << jhh+1 <<"\t" << PUP[4][15] << "\t" << PUP[1][15]<<"\t"<<PUP[2][15]<<"\t"<<PUP[3][15]<<endl;
+// sum1+=PUP[4][15];sum2+=PUP[1][15];sum3+=PUP[2][15];sum3+=PUP[3][15];
+// }
+// if (demittb) {
+// outdata << jhh+1 <<"\t" << PUP[4][16] << "\t" << PUP[1][16]<<"\t"<<PUP[2][16]<<"\t"<<PUP[3][16]<<endl;
+// sum1+=PUP[4][16];sum2+=PUP[1][16];sum3+=PUP[2][16];sum3+=PUP[3][16];
+// }
+// }
+// if (POWdecay && !POWprod) {for (int jh=11; jh< 13; jh++)
+
+// {jhh=jh+1;outdata << jhh <<"\t" << PUP[4][jh] << "\t" << PUP[1][jh]<<"\t"<<PUP[2][jh]<<"\t"<<PUP[3][jh]<<endl;
+// sum1+=PUP[4][jh];sum2+=PUP[1][jh];sum3+=PUP[2][jh];sum3+=PUP[3][jh];}
+// if (demitt) {
+// for (int jh=15; jh< NUP+2; jh++)
+
+// {jhh=jh+2;outdata << jhh-3 <<"\t" << PUP[4][jh] << "\t" << PUP[1][jh]<<"\t"<<PUP[2][jh]<<"\t"<<PUP[3][jh]<<endl;
+// sum1+=PUP[4][jh];sum2+=PUP[1][jh];sum3+=PUP[2][jh];sum3+=PUP[3][jh];} }
+// if (!demitt && demittb) {
+// outdata << 14 <<"\t" << PUP[4][16] << "\t" << PUP[1][16]<<"\t"<<PUP[2][16]<<"\t"<<PUP[3][16]<<endl;
+// sum1+=PUP[4][16];sum2+=PUP[1][16];sum3+=PUP[2][16];sum3+=PUP[3][16];}
+// }
+
+
+
+// if (POWprod && !POWdecay) {for (int jh=13; jh<NUPP;jh++)
+// {jhh=jh+1;outdata << jhh-2 <<"\t" << PUP[4][jh] << "\t" << PUP[1][jh]<<"\t"<<PUP[2][jh]<<"\t"<<PUP[3][jh]<<endl;
+
+// sum1+=PUP[4][jh];sum2+=PUP[1][jh];sum3+=PUP[2][jh];sum3+=PUP[3][jh];}}
+// // cout << count1 << "\t" << count2 << "\t" << count3 << "\t" << count4 << endl;
+// cout <<ixx << "\t" << sum1 << "\t" <<sum2 <<"\t" <<sum3 <<"\t" << sum4 << endl;
+// }
+
+
+
+ //*********************************************************************/
+ //XML FORMAT
+ //********************************************************************/
+
+ NUP=11;
+ if (POWprod) {NUP++;
+ if (emit) {NUP++;}}
+ if (POWdecay) {NUP++; NUP++;
+ if (demitt) {NUP++;}
+ if (demittb) {NUP++;}}
+// NUP=11;
+// if (POWprod && POWdecay) {
+// if (!emit) {NUP=14;} else {NUP=15;}}
+// if (!POWprod && POWdecay) {NUP =13;}
+// if (POWprod && !POWdecay) {if (!emit){NUP=12;}else{NUP=13;}}
+ XWGTUP=1;
+ SCALUP=emcm;
+ AQEDUP=0.0073;
+ AQCDUP=0.118;
+ double sum1,sum2,sum3,sum4;
+ int NUPP=15;
+ if (!emit){NUPP=14;}
+ sum1=0.;sum2=0.;sum3=0.;sum4=0.;
+ /************************************************************************************************/
+ if (xml) {
+ outdata << "<event>" << endl;
+ outdata << NUP <<"\t" << "11" <<"\t"<<XWGTUP<<"\t" << SCALUP << "\t" << AQEDUP << "\t" << AQCDUP << endl;
+
+ for (int ja = 1; ja < 11; ja++) {
+ if (ja == 3) {
+ outdata << IDUP[17] << "\t" << ISTUP[17] << "\t" << MOTHUP[1][17] <<"\t" << MOTHUP[2][17] << "\t" << ICOLUP[1][17] << "\t" << ICOLUP[2][17] <<"\t" <<setprecision (9)<< PUP[1][17] << "\t" << PUP[2][17]<<"\t"<<PUP[3][17]<<"\t"<<PUP[4][17]<<"\t" << mass[17] <<"\t"<< "0" << "\t" <<"9" <<endl;
+ }
+ outdata << IDUP[ja] << "\t" << ISTUP[ja] << "\t" << MOTHUP[1][ja] <<"\t" << MOTHUP[2][ja] << "\t" << ICOLUP[1][ja] << "\t" << ICOLUP[2][ja] <<"\t" <<setprecision (9)<< PUP[1][ja] << "\t" << PUP[2][ja]<<"\t"<<PUP[3][ja]<<"\t"<<PUP[4][ja]<<"\t" << mass[ja] <<"\t"<< "0" << "\t" <<"9" <<endl;
+ if (ja !=3 && ja != 4){
+ sum1+=PUP[4][ja];sum2+=PUP[1][ja];sum3+=PUP[2][ja];sum3+=PUP[3][ja];}
+ }
+ if (POWdecay && POWprod) {
+ if (emit) {
+ outdata << IDUP[13] << "\t" << ISTUP[13] << "\t" << MOTHUP[1][13] <<"\t" << MOTHUP[2][13] << "\t" <<ICOLUP[1][13] << "\t" << ICOLUP[2][13] <<"\t" <<setprecision (9)<< PUP[1][13] << "\t" << PUP[2][13]<<"\t"<<PUP[3][13]<<"\t"<<PUP[4][13]<<"\t" << mass[13] <<"\t"<< "0" << "\t" <<"9" <<endl;
+ sum1+=PUP[4][13];sum2+=PUP[1][13];sum3+=PUP[2][13];sum3+=PUP[3][13];
+outdata << IDUP[14] << "\t" << ISTUP[14] << "\t" << MOTHUP[1][14] <<"\t" << MOTHUP[2][14] << "\t" << ICOLUP[1][14] << "\t" << ICOLUP[2][14] <<"\t" <<setprecision (9)<< PUP[1][14] << "\t" << PUP[2][14]<<"\t"<<PUP[3][14]<<"\t"<<PUP[4][14]<<"\t" << mass[14] <<"\t"<< "0" << "\t" <<"9" <<endl;
+ sum1+=PUP[4][14];sum2+=PUP[1][14];sum3+=PUP[2][14];sum3+=PUP[3][14];
+ }
+ if (demitt) {outdata << IDUP[15] << "\t" << ISTUP[15] << "\t" << MOTHUP[1][15] <<"\t" << MOTHUP[2][15] << "\t" << ICOLUP[1][15] << "\t" << ICOLUP[2][15] <<"\t" <<setprecision (9)<< PUP[1][15] << "\t" << PUP[2][15]<<"\t"<<PUP[3][15]<<"\t"<<PUP[4][15]<<"\t" << mass[15] <<"\t"<< "0" << "\t" <<"9" <<endl;
+ sum1+=PUP[4][15];sum2+=PUP[1][15];sum3+=PUP[2][15];sum3+=PUP[3][15];
+ }
+ if (demittb) {outdata << IDUP[16] << "\t" << ISTUP[16] << "\t" << MOTHUP[1][16] <<"\t" << MOTHUP[2][16] << "\t"<< ICOLUP[1][16] << "\t" << ICOLUP[2][16] <<"\t" <<setprecision (9)<< PUP[1][16] << "\t" << PUP[2][16]<<"\t"<<PUP[3][16]<<"\t"<<PUP[4][16]<<"\t" << mass[16] <<"\t"<< "0" << "\t" <<"9" <<endl;
+ sum1+=PUP[4][16];sum2+=PUP[1][16];sum3+=PUP[2][16];sum3+=PUP[3][16];
+ }
+ {for (int ja=11; ja < 13; ja++)
+ {outdata << IDUP[ja] << "\t" << ISTUP[ja] << "\t" << MOTHUP[1][ja] <<"\t" << MOTHUP[2][ja] << "\t" << ICOLUP[1][ja] << "\t" << ICOLUP[2][ja] <<"\t" <<setprecision (9)<< PUP[1][ja] << "\t" << PUP[2][ja]<<"\t"<<PUP[3][ja]<<"\t"<<PUP[4][ja]<<"\t" << mass[ja] <<"\t"<< "0" << "\t" <<"9" <<endl;
+ sum1+=PUP[4][ja];sum2+=PUP[1][ja];sum3+=PUP[2][ja];sum3+=PUP[3][ja];
+ } }
+ if(!emit) {outdata << IDUP[13] << "\t" << ISTUP[13] << "\t" << MOTHUP[1][13] <<"\t" << MOTHUP[2][13] << "\t" << ICOLUP[1][13] << "\t" << ICOLUP[2][13] <<"\t" <<setprecision (9)<< PUP[1][13] << "\t" << PUP[2][13]<<"\t"<<PUP[3][13]<<"\t"<<PUP[4][13]<<"\t" << mass[13] <<"\t"<< "0" << "\t" <<"9" <<endl;
+ sum1+=PUP[4][13];sum2+=PUP[1][13];sum3+=PUP[2][13];sum3+=PUP[3][13];
+
+ }
+ }
+
+ if (POWdecay && !POWprod) {
+ if (demitt) {
+ for (int ja=15; ja < NUP+2; ja++)
+ {outdata << IDUP[ja] << "\t" << ISTUP[ja] << "\t" << MOTHUP[1][ja] <<"\t" << MOTHUP[2][ja] << "\t" << ICOLUP[1][ja] << "\t" << ICOLUP[2][ja] <<"\t" <<setprecision (9)<< PUP[1][ja] << "\t" << PUP[2][ja]<<"\t"<<PUP[3][ja]<<"\t"<<PUP[4][ja]<<"\t" << mass[ja] <<"\t"<< "0" << "\t" <<"9" <<endl;
+ sum1+=PUP[4][ja];sum2+=PUP[1][ja];sum3+=PUP[2][ja];sum3+=PUP[3][ja];
+ }}
+ if (!demitt && demittb)
+ {outdata << IDUP[16] << "\t" << ISTUP[16] << "\t" << MOTHUP[1][16] <<"\t" << MOTHUP[2][16] << "\t" << ICOLUP[1][16] << "\t" << ICOLUP[2][16] <<"\t" <<setprecision (9)<< PUP[1][16] << "\t" << PUP[2][16]<<"\t"<<PUP[3][16]<<"\t"<<PUP[4][16]<<"\t" << mass[16] <<"\t"<< "0" << "\t" <<"9" <<endl;
+ sum1+=PUP[4][16];sum2+=PUP[1][16];sum3+=PUP[2][16];sum3+=PUP[3][16];
+ }
+ {for (int ja=11; ja < 13; ja++)
+ {outdata << IDUP[ja] << "\t" << ISTUP[ja] << "\t" << MOTHUP[1][ja] <<"\t" << MOTHUP[2][ja] << "\t" << ICOLUP[1][ja] << "\t" << ICOLUP[2][ja] <<"\t" <<setprecision (9)<< PUP[1][ja] << "\t" << PUP[2][ja]<<"\t"<<PUP[3][ja]<<"\t"<<PUP[4][ja]<<"\t" << mass[ja] <<"\t"<< "0" << "\t" <<"9" <<endl;
+ sum1+=PUP[4][ja];sum2+=PUP[1][ja];sum3+=PUP[2][ja];sum3+=PUP[3][ja];
+}
+}
+
+ }
+ if (POWprod && !POWdecay) {for (int ja=13; ja<NUPP;ja++)
+ {outdata << IDUP[ja] << "\t" << ISTUP[ja] << "\t" << MOTHUP[1][ja] <<"\t" << MOTHUP[2][ja] << "\t" << ICOLUP[1][ja] << "\t" << ICOLUP[2][ja] <<"\t" <<setprecision (9)<< PUP[1][ja] << "\t" << PUP[2][ja]<<"\t"<<PUP[3][ja]<<"\t"<<PUP[4][ja]<<"\t" << mass[ja] <<"\t"<< "0" << "\t" <<"9" <<endl;
+ sum1+=PUP[4][ja];sum2+=PUP[1][ja];sum3+=PUP[2][ja];sum3+=PUP[3][ja];
+}}
+ // cout <<ixx << "\t" << sum1 << "\t" <<sum2 <<"\t" <<sum3 <<"\t" << sum4 << endl;
+ cout << "Generated event : " << "\t" << ixx << "\t" << "of" << "\t" << nevg << "\r" << flush;
+ outdata << "</event>" << endl;}
+ }
+ outdata << "</LesHouchesEvents>" << endl;
+ cout << endl;
+ return 0;
+ }
+/***************************************************************************************************/
+/* Axial or Vector axial current ? */
+ bool ax(int seed1) {
+ bool axial=false;
+ if (random(seed1) < A/(A+V)){axial = true;}
+ return axial;
+}
+/***************************************************************************************************/
+// Interpolation for vector and axial coefficients.
+
+double coeff(int N, double XXX, bool axi) {
+ double FF;
+ double AA;
+ int IX=0;
+ int IY=N+1;
+ int MID;
+ double aa,bb,cc,dd;
+ ifstream indata;
+
+ for (int iy=0;(IY-IX) > 1;iy++) {
+ if (axi) {
+ indata.open("axialcoeff.dat", ios::in);} else {
+ indata.open("vectorcoeff.dat", ios::in);
+ }
+
+ MID=(IX+IY)/2;
+ for(int ix=0;ix < MID ;ix++) {
+ indata >> AA >> FF;}
+
+ indata.close();
+ if (XXX == AA) {return FF; break;}
+ if (XXX >= AA) {
+ IX=MID;} else {IY=MID;}
+ if ((IY-IX) < 1) break;}
+ if (axi) {
+ indata.open("axialcoeff.dat", ios::in);} else {
+ indata.open("vectorcoeff.dat", ios::in);
+ }
+ for (int ix =1; ix < IY; ix++) {
+ if (ix == IY-1) {
+ indata >> bb >> aa ;}
+ indata >> dd >> cc ;}
+ indata.close();
+ // cout << bb <<"\t" << aa << endl;
+ // cout << dd <<"\t" << cc << endl;
+ double bbb = aa + (aa - cc)/(bb - dd)*(XXX - bb);
+ ;
+ indata.close();
+ return bbb;}
+/***************************************************************************************************/
+/* Generates interpolation files for production */
+
+ void filegen (double &rintgend1a, double &rintgend2a,double &rintgend3a, double &rintgend4a,double &rintgend1v, double &rintgend2v,double &rintgend3v, double &rintgend4v){
+ cout << "Generating production interpolation files..." << endl;
+ ofstream outdata,outdata1a,outdata2a,outdata3a,outdata4a,outdata1v,outdata2v,outdata3v,outdata4v;
+ outdata1a.open("ttbaraxpro1.dat", ios::trunc);
+ outdata2a.open("ttbaraxpro2.dat", ios::trunc);
+ outdata3a.open("ttbaraxpro3.dat", ios::trunc);
+ outdata4a.open("ttbaraxpro4.dat", ios::trunc);
+ outdata1v.open("ttbarvecpro1.dat", ios::trunc);
+ outdata2v.open("ttbarvecpro2.dat", ios::trunc);
+ outdata3v.open("ttbarvecpro3.dat", ios::trunc);
+ outdata4v.open("ttbarvecpro4.dat", ios::trunc);
+ double pt2t = 0.; double pt2b = 0.;
+ double intga,intgv, pt2;
+ int ngen;
+ intga = 0.;
+ intgv = 0.;
+ ngen = 1000;
+ for (int iy=1; iy < 5; iy++) {
+
+ if (iy==1) {pt2t = pt2max; pt2b=0.001;}
+ if (iy==2) {pt2t = 0.001; pt2b=0.0001;}
+ if (iy==3) {pt2t = 0.0001; pt2b=0.00001;}
+ if (iy==4) {pt2t = 0.00001; pt2b=pt2min;}
+ double div = (pt2t-pt2b)/ngen;
+ pt2 = pt2t+div;
+ for (int ix=0; ix<ngen; ix++) {
+ pt2=pt2-div;
+ if (pt2 < pt2b) {break;}
+ double xmax=1.-2.*pt2-2.*sqrt(pow(pt2,2)+rho*pt2);
+ double alphas=1./(b*log(pt2/pt2min))*(1.-bp*log(log(pt2/pt2min))/(b*log(pt2/pt2min)));
+ alphas+=pow(alphas,2)*(67./3.-pow(pi,2)-50./9.)/(4.*pi);
+ double xminr=39.*pt2-1.+3.*d2-42.*pt2*d2-3.*pow(d2,2)+pow(pt2,3)+15.*pow(pt2,2)+3.*pow(pt2,2)*d2+3.*pt2*pow(d2,2)+pow(d2,3);
+ double xmini=6.*sqrt (abs(-3.*pt2+33.*pow(pt2,2)+3.*pow(pt2,3)-18.*pt2*pow(d2,2)+12.*pt2*pow(d2,3)+12.*pt2*d2-42.*pow(pt2,3)*d2+51.*pow(pt2,2)*pow(d2,2)-75.*pow(pt2,2)*d2-3.*d2*pow(pt2,4)-3.*pt2*pow(d2,4)-9.*pow(pt2,3)*pow(d2,2)-9.*pow(pt2,2)*pow(d2,3)));
+ double xminm=sqrt(pow(xminr,2)+pow(xmini,2));
+ double xmint=atan2(xmini,xminr);
+ double xmin1=-1./12.*pow(xminm,(1./3.))*cos(xmint/3.);
+ double xmin2=(-1./12.+d2/6.-pow(pt2,2)/12.-5.*pt2/6.-pt2*d2/6.-pow(d2,2)/12.)*cos(xmint/3.)/(pow(xminm,(1./3.)));
+ double xmin3=pt2/6.+5./6.+d2/6.;
+ double xmin4=sqrt(3.)/12.*pow(xminm,(1./3.))*sin(xmint/3.)
+ -3.*sqrt(3.)*(-1./36.+d2/18.-pow(pt2,2)/36.-5.*pt2/18.-pt2/18.*d2-pow(d2,2)/36.)
+ /pow(xminm,(1./3.))*sin(xmint/3.);
+ double xmin5=xmin1+xmin2+xmin3+xmin4;
+ double xmin6=xmin1+xmin2+xmin3-xmin4;
+ if (pt2 > pt2meet) {xmax=xmin5;}
+ double div1 = (xmax - xmin6)/ngen;
+ double div2 = (xmax - xmin5)/ngen;
+ double xx ;
+ xx=xmax +div1/2.;
+ for (int ix =0; ix < ngen; ix++) {
+ xx=xx-div1;
+ if (xx < xmin6) {break;}
+ double yy = 1./(2.*(1.+rho-xx))*(pow(xx,2)-3.*xx-2.*rho*xx+2.+4.*rho-sqrt((pow(xx,2)-4.*rho)*(4.*pt2*(xx-1.-rho)+pow((xx-1.),2))));
+ double dydkap = sqrt(pow(xx,2)-4.*rho)/sqrt(4.*pt2*(xx-1.-rho)+pow(xx-1.,2));
+
+
+ double Waa = ((pow((xx+0.5*d2),2)+pow((yy+0.5*d2),2)+0.5*d2*(pow((5.-xx-yy),2)-19.+d2))/((1.-d2)*(1.-xx)*(1.-yy))-d2/
+ (2.*pow((1.-xx),2))-d2/(2.*pow((1.-yy),2)));
+ double Wvv = ((pow((xx+0.5*d2),2)+pow((yy+0.5*d2),2)-2.*d2*(1.+d2/2.))/((1.+d2/2.)*(1.-xx)*(1.-yy))-d2/(2.*pow((1.-
+ xx),2))-d2/(2.*pow((1.-yy),2)));
+ if (yy*0. != 0.) {dydkap=0.; Waa=0.; Wvv=0.;}
+ intga += dydkap*Waa*2.*alphas*div1/(3.*pi*sqrt(1.-d2))*div;
+ intgv += dydkap*Wvv*2.*alphas*div1/(3.*pi*sqrt(1.-d2))*div;
+
+
+
+}
+ xx =xmax + div2/2.;
+ if (pt2 < pt2meet) {
+ for (int iz =0; iz < ngen; iz++) {
+ xx=xx-div2;
+double yy = 1./(2.*(1.+rho-xx))*(pow(xx,2)-3.*xx-2.*rho*xx+2.+4.*rho+sqrt((pow(xx,2)-4.*rho)*(4.*pt2*(xx-1.-rho)+pow((xx-1.),2))));
+
+
+ if (yy*0. != 0.) {continue;}
+ if (xx < xmin5) {break;}
+ double dydkap = sqrt(pow(xx,2)-4.*rho)/sqrt(4.*pt2*(xx-1.-rho)+pow(xx-1.,2));
+ double Waa = ((pow((xx+0.5*d2),2)+pow((yy+0.5*d2),2)+0.5*d2*(pow((5.-xx-yy),2)-19.+d2))/((1.-d2)*(1.-xx)*(1.-yy))-d2/(2.*pow((1.-xx),2))-d2/(2.*pow((1.-yy),2)));
+ double Wvv = ((pow((xx+0.5*d2),2)+pow((yy+0.5*d2),2)-2.*d2*(1.+d2/2.))/((1.+d2/2.)*(1.-xx)*(1.-yy))-d2/(2.*pow((1.-xx),2))-d2/(2.*pow((1.-yy),2)));
+ if (yy*0. != 0.) {dydkap=0.;Waa=0.; Wvv=0.;}
+ intga += dydkap*Waa*2.*alphas*div2/(3.*pi*sqrt(1.-d2))*div;
+ intgv += dydkap*Wvv*2.*alphas*div2/(3.*pi*sqrt(1.-d2))*div;
+
+ }}
+
+
+ if (iy==1) {outdata1a << pt2 << "\t" << abs(intga) <<endl;
+ outdata1v << pt2 << "\t" << abs(intgv) <<endl;
+}
+ if (iy==2) {outdata2a << pt2 << "\t" << abs(intga) <<endl;
+ outdata2v << pt2 << "\t" << abs(intgv) <<endl;
+}
+ if (iy==3) {outdata3a << pt2 << "\t" << abs(intga) <<endl;
+ outdata3v << pt2 << "\t" << abs(intgv) <<endl;
+}
+ if (iy==4) {outdata4a << pt2 << "\t" << abs(intga) <<endl;
+ outdata4v << pt2 << "\t" << abs(intgv) <<endl;
+}
+ }
+
+ if (iy==1) {rintgend1a=abs(intga);rintgend1v=abs(intgv);}
+ if (iy==2) {rintgend2a=abs(intga);rintgend2v=abs(intgv);}
+ if (iy==3) {rintgend3a=abs(intga);rintgend3v=abs(intgv);}
+ if (iy==4) {rintgend4a=abs(intga);rintgend4v=abs(intgv);}
+}
+ cout << "...Done" << endl;
+}
+/***************************************************************************************************/
+/* Generates interpolation files for decays */
+
+void filegendec (double &rintgend1, double &rintgend2, double &rintgend3, double &rintgend4){
+ cout << "Generating decay interpolation files..." << endl;
+ ofstream outdata1d,outdata2d,outdata3d,outdata4d;
+ outdata1d.open("ttbardecay1.dat", ios::trunc);
+ outdata2d.open("ttbardecay2.dat", ios::trunc);
+ outdata3d.open("ttbardecay3.dat", ios::trunc);
+ outdata4d.open("ttbardecay4.dat", ios::trunc);
+ double pt2t= 0.; double pt2b= 0.;
+ double intg, pt2;
+ int ngen;
+ intg = 0.;
+ ngen = 1000;
+ for (int iy=1; iy < 5; iy++) {
+ if (iy==1) {pt2t = pt2maxd; pt2b=0.001*pow(mt,2);}
+ if (iy==2) {pt2t = 0.001*pow(mt,2); pt2b=0.0001*pow(mt,2);}
+ if (iy==3) {pt2t = 0.0001*pow(mt,2); pt2b=0.00001*pow(mt,2);}
+ if (iy==4) {pt2t = 0.00001*pow(mt,2); pt2b=pt2mind;}
+ double div = (pt2t-pt2b)/ngen;
+ pt2 = pt2t+div/2.;
+ for (int ix=0;ix<ngen;ix++) {
+ pt2=pt2-div;
+ if (pt2 < pt2b) {break;}
+ double alphas=1./(b*log(pt2/0.04))*(1.-bp*log(log(pt2/0.04))/(b*log(pt2/0.04)));
+ alphas+=pow(alphas,2)*(67./3.-pow(pi,2)-50./9.)/(4.*pi);
+ double xmax=(mt-a*mt-2.*sqrt(a*pt2))/mt;
+ double xmin=2.*sqrt(pt2)/mt;
+
+ double xx ;
+ double div1 = (xmax - xmin)/ngen;
+ xx=xmax +div1/2.;
+ for (int ix =0; ix < ngen; ix++) {
+ xx=xx-div1;
+ if (xx < xmin) {break;}
+ double kapp=pt2/pow(mt,2);
+ double yy1 = (pow(xx,2)+a*xx+2.-3.*xx-2.*a*kapp+sqrt((pow(xx,2)-4.*kapp*(1.-a))*pow(xx-1.,2)+4.*a*kapp*(4.*kapp+1.-a)+pow(xx,2)*(a+2.*xx-2.-8.*kapp)*a))/(2.*(kapp+1.-xx));
+ double yy2 = (pow(xx,2)+a*xx+2.-3.*xx-2.*a*kapp-sqrt((pow(xx,2)-4.*kapp*(1.-a))*pow(xx-1.,2)+4.*a*kapp*(4.*kapp+1.-a)+pow(xx,2)*(a+2.*xx-2.-8.*kapp)*a))/(2.*(kapp+1.-xx));
+ double gamm1 = alphas*4./(pi*3.*(1.-yy1)*pow(xx,2))*(xx-((1.-yy1)*(1.-xx)+pow(xx,2))/(1.-a)+xx*pow(yy1+xx-1.,2)/(2.*pow(1.-a,2))+2.*a*(1.-yy1)*pow(xx,2)/(pow(1.-a,2)*(1.+2.*a)));
+ double gamm2 = alphas*4./(pi*3.*(1.-yy2)*pow(xx,2))*(xx-((1.-yy2)*(1.-xx)+pow(xx,2))/(1.-a)+xx*pow(yy2+xx-1.,2)/(2.*pow(1.-a,2))+2.*a*(1.-yy2)*pow(xx,2)/(pow(1.-a,2)*(1.+2.*a)));
+ double dydkapp1=(-2.*a+(0.5*(-4.*pow(xx,2)+8.*xx-4.-4.*pow(xx,2)*a-8.*a*xx+32.*a*kapp+8.*a-4.*pow(a,2)))/sqrt((pow(xx,2)-4.*kapp*(1.-a))*pow(xx-1.,2)+4.*a*kapp*(4.*kapp+1.-a)+pow(xx,2)*(a+2.*xx-2.-8.*kapp)*a)-2.*yy1)/(2.*kapp+2.-2.*xx);
+ double dydkapp2=(-2.*a-(0.5*(-4.*pow(xx,2)+8.*xx-4.-4.*pow(xx,2)*a-8.*a*xx+32.*a*kapp+8.*a-4.*pow(a,2)))/sqrt((pow(xx,2)-4.*kapp*(1.-a))*pow(xx-1.,2)+4.*a*kapp*(4.*kapp+1.-a)+pow(xx,2)*(a+2.*xx-2.-8.*kapp)*a)-2.*yy2)/(2.*kapp+2.-2.*xx);
+ intg+=(gamm1*fabs(dydkapp1)+gamm2*fabs(dydkapp2))*div1*div/pow(mt,2);}
+
+ if (iy==1) {outdata1d << pt2/pow(mt,2) << "\t" << abs(intg) << endl;}
+ if (iy==2) {outdata2d << pt2/pow(mt,2) << "\t" << abs(intg) << endl;}
+ if (iy==3) {outdata3d << pt2/pow(mt,2) << "\t" << abs(intg) << endl;}
+ if (iy==4) {outdata4d << pt2/pow(mt,2) << "\t" << abs(intg) << endl;}
+ }
+ if (iy==1) {rintgend1=abs(intg);}
+ if (iy==2) {rintgend2=abs(intg);}
+ if (iy==3) {rintgend3=abs(intg);}
+ if (iy==4) {rintgend4=abs(intg);}
+ }
+ cout << "...Done" << endl;
+}
+/***************************************************************************************************/
+// Interpolation for production process.
+
+double interp(int N,double XXX, double Xmax1, double Xmax2, double Xmax3, double Xmax4, bool axi) {
+ double FF;
+ double AA;
+ int IX=0;
+ int IY=N+1;
+ int MID;
+ double aa,bb,cc,dd,ee,ii,gg,hh;
+ ifstream indata;
+
+ for (int iy=0;(IY-IX) > 1;iy++) {
+ if (axi) {
+ if (XXX < Xmax1 ) {
+ indata.open("ttbaraxpro1.dat", ios::in);
+ }else if (XXX > Xmax1 && XXX < Xmax2 ) {
+ indata.open("ttbaraxpro2.dat", ios::in);
+ }else if (XXX > Xmax2 && XXX < Xmax3 ) {
+ indata.open("ttbaraxpro3.dat", ios::in);
+ }else if (XXX > Xmax3) {
+ indata.open("ttbaraxpro4.dat", ios::in);
+ }} else {
+ if (XXX < Xmax1 ) {
+ indata.open("ttbarvecpro1.dat", ios::in);
+ }else if (XXX > Xmax1 && XXX < Xmax2 ) {
+ indata.open("ttbarvecpro2.dat", ios::in);
+ }else if (XXX > Xmax2 && XXX < Xmax3 ) {
+ indata.open("ttbarvecpro3.dat", ios::in);
+ }else if (XXX > Xmax3) {
+ indata.open("ttbarvecpro4.dat", ios::in);
+ }}
+
+ MID=(IX+IY)/2;
+ for(int ix=0;ix < MID ;ix++) {
+ indata >> FF >> AA;}
+
+ indata.close();
+ if (XXX == AA) {return FF; break;}
+ if (XXX >= AA) {
+ IX=MID;} else {IY=MID;}
+ if ((IY-IX) < 1) break;}
+ if (IX < 5) {IX=5;}
+ if (axi) {
+ if (XXX < Xmax1 ) {
+ indata.open("ttbaraxpro1.dat", ios::in);
+ }else if (XXX > Xmax1 && XXX < Xmax2 ) {
+ indata.open("ttbaraxpro2.dat", ios::in);
+ }else if (XXX > Xmax2 && XXX < Xmax3 ) {
+ indata.open("ttbaraxpro3.dat", ios::in);
+ }else if (XXX > Xmax3) {
+ indata.open("ttbaraxpro4.dat", ios::in);
+ } } else {
+ if (XXX < Xmax1 ) {
+ indata.open("ttbarvecpro1.dat", ios::in);
+ }else if (XXX > Xmax1 && XXX < Xmax2 ) {
+ indata.open("ttbarvecpro2.dat", ios::in);
+ }else if (XXX > Xmax2 && XXX < Xmax3 ) {
+ indata.open("ttbarvecpro3.dat", ios::in);
+ }else if (XXX > Xmax3) {
+ indata.open("ttbarvecpro4.dat", ios::in);
+ }
+ }
+ for (int ix=0;ix<IX-3;ix++) {
+ indata >> FF >> AA;}
+ indata >> aa >> bb ;
+ indata >> cc >> dd ;
+ indata >> ee >> ii ;
+ indata >> gg >> hh ;
+
+ indata.close();
+ double d1=(cc-aa)/(dd-bb);
+ double d2=(ee-cc)/(ii-dd);
+ double d3=(gg-ee)/(hh-ii) ;
+ double dydx=(gg-aa)/(hh-bb);
+ double dydx1=(ee-aa)/(ii-bb);
+ double dydx2=(gg-cc)/(hh-dd);
+ double d2ydx2=(dydx2-dydx1)/((hh+dd-ii-bb)/2.);
+ double d2ydx21=2.*(d2-d1)/(ii-bb);
+ double d2ydx22=2.*(d3-d2)/(hh-dd);
+ double d3ydx3=2*(d2ydx22-d2ydx21)/(hh+dd-ii-bb);
+ double ddd=d3ydx3/6.;
+ double ccc=(d2ydx2-6.*ddd*(XXX-bb))/2.;
+ double bbb=(dydx-2.*ccc*(XXX-bb)-3.*ddd*pow((XXX-bb),2));
+ return bbb*(XXX-bb)+ccc*pow((XXX-bb),2)+ddd*pow((XXX-bb),3)+aa;}
+/***************************************************************************************************/
+// Interpolation for decay process.
+
+double interpd(int N,double XXX, double Xmax1, double Xmax2, double Xmax3, double Xmax4) {
+ double FF;
+ double AA;
+ int IX=0;
+ int IY=N+1;
+ int MID;
+ double aa,bb,cc,dd,ee,ii,gg,hh;
+ ifstream indata;
+
+ for (int iy=0;(IY-IX) > 1;iy++) {
+ if (XXX < Xmax1 ) {
+ indata.open("ttbardecay1.dat", ios::in);
+ }else if (XXX > Xmax1 && XXX < Xmax2 ) {
+ indata.open("ttbardecay2.dat", ios::in);
+ }else if (XXX > Xmax2 && XXX < Xmax3 ) {
+ indata.open("ttbardecay3.dat", ios::in);
+ }else if (XXX > Xmax3) {
+ indata.open("ttbardecay4.dat", ios::in);
+ }
+ MID=(IX+IY)/2;
+ for(int ix=0;ix < MID ;ix++) {
+ indata >> FF >> AA;}
+
+ indata.close();
+ if (XXX == AA) {return FF; break;}
+ if (XXX >= AA) {
+ IX=MID;} else {IY=MID;}
+ if ((IY-IX) < 1) break;}
+ if (IX < 5) {IX=5;}
+ if (XXX < Xmax1 ) {
+ indata.open("ttbardecay1.dat", ios::in);
+ }else if (XXX > Xmax1 && XXX < Xmax2 ) {
+ indata.open("ttbardecay2.dat", ios::in);
+ }else if (XXX > Xmax2 && XXX < Xmax3 ) {
+ indata.open("ttbardecay3.dat", ios::in);
+ }else if (XXX > Xmax3) {
+ indata.open("ttbardecay4.dat", ios::in);
+ }
+ for (int ix=0;ix<IX-3;ix++) {
+ indata >> FF >> AA;}
+ indata >> aa >> bb ;
+ indata >> cc >> dd ;
+ indata >> ee >> ii ;
+ indata >> gg >> hh ;
+
+ indata.close();
+ double d1=(cc-aa)/(dd-bb);
+ double d2=(ee-cc)/(ii-dd);
+ double d3=(gg-ee)/(hh-ii) ;
+ double dydx=(gg-aa)/(hh-bb);
+ double dydx1=(ee-aa)/(ii-bb);
+ double dydx2=(gg-cc)/(hh-dd);
+ double d2ydx2=(dydx2-dydx1)/((hh+dd-ii-bb)/2.);
+ double d2ydx21=2.*(d2-d1)/(ii-bb);
+ double d2ydx22=2.*(d3-d2)/(hh-dd);
+ double d3ydx3=2*(d2ydx22-d2ydx21)/(hh+dd-ii-bb);
+ double ddd=d3ydx3/6.;
+ double ccc=(d2ydx2-6.*ddd*(XXX-bb))/2.;
+ double bbb=(dydx-2.*ccc*(XXX-bb)-3.*ddd*pow((XXX-bb),2));
+ return bbb*(XXX-bb)+ccc*pow((XXX-bb),2)+ddd*pow((XXX-bb),3)+aa;}
+/***************************************************************************************************/
+// Find maximum and minimum values of variable x for production process
+
+ void xmaxmin (double pt2, double d2, double &rxmax, double &rxmin5,double &rxmin6) {
+ double xminr=39.*pt2-1.+3.*d2-42.*pt2*d2-3.*pow(d2,2)+pow(pt2,3)+15.*pow(pt2,2)+3.*pow(pt2,2)*d2+3.*pt2*pow(d2,2)+pow(d2,3);
+ double xmini=6.*sqrt (abs(-3.*pt2+33.*pow(pt2,2)+3.*pow(pt2,3)-18.*pt2*pow(d2,2)+12.*pt2*pow(d2,3)+12.*pt2*d2-42.*pow(pt2,3)*d2+51.*pow(pt2,2)*pow(d2,2)-75.*pow(pt2,2)*d2-3.*d2*pow(pt2,4)-3.*pt2*pow(d2,4)-9.*pow(pt2,3)*pow(d2,2)-9.*pow(pt2,2)*pow(d2,3)));
+ double xminm=sqrt(pow(xminr,2)+pow(xmini,2));
+ double xmint=atan2(xmini,xminr);
+ double xmin1=-1./12.*pow(xminm,(1./3.))*cos(xmint/3.);
+ double xmin2=(-1./12.+d2/6.-pow(pt2,2)/12.-5.*pt2/6.-pt2*d2/6.-pow(d2,2)/12.)*cos(xmint/3.)/(pow(xminm,(1./3.)));
+ double xmin3=pt2/6.+5./6.+d2/6.;
+ double xmin4=sqrt(3.)/12.*pow(xminm,(1./3.))*sin(xmint/3.)
+ -3.*sqrt(3.)*(-1./36.+d2/18.-pow(pt2,2)/36.-5.*pt2/18.-pt2/18.*d2-pow(d2,2)/36.)
+ /pow(xminm,(1./3.))*sin(xmint/3.);
+ rxmin5=xmin1+xmin2+xmin3+xmin4;
+ rxmin6=xmin1+xmin2+xmin3-xmin4;
+ if (pt2 < pt2meet) {
+ rxmax=1.-2.*pt2-sqrt(pt2)*sqrt(d2+4.*pt2);} else {
+ rxmax=rxmin5;
+ }
+ }
+/***************************************************************************************************/
+// Calculate Matrix Element for production process
+
+ double ME (double d2, double pt2,double &rx, double &ry1, double &ry2,double xmin5, double &rM1, double &rM2, double &rw, bool axi) {
+ ry1=-(2.*pow(rx,2)-6.*rx-d2*rx+2.*d2+4.+2.*sqrt(-d2+pow(rx,2)+2.*rx*d2-d2*pow(rx,2)+4.*pt2*d2-4.*rx*pt2*d2-2.*pow(rx,3)+pow(rx,4)-d2*pow(rx,2)*pt2+4.*pt2*pow(rx,3)+pt2*pow(d2,2)-4*pt2*pow(rx,2)))/(4.*rx-4.-d2);
+ ry2=-(2.*pow(rx,2)-6.*rx-d2*rx+2.*d2+4.-2.*sqrt(-d2+pow(rx,2)+2.*rx*d2-d2*pow(rx,2)+4.*pt2*d2-4.*rx*pt2*d2-2.*pow(rx,3)+pow(rx,4)-d2*pow(rx,2)*pt2+4.*pt2*pow(rx,3)+pt2*pow(d2,2)-4*pt2*pow(rx,2)))/(4.*rx-4.-d2);
+// Using the pt^2 delta function to eliminate x. w1,w2=d(pt)/dy
+ rw=(4.*rx-4.-d2)/4.*(ry1-ry2)/(2.*sqrt(pt2)*(pow(rx,2)-d2));
+ if (axi) {
+ rM1=((pow((rx+0.5*d2),2)+pow((ry1+0.5*d2),2)+0.5*d2*(pow((5.-rx-ry1),2)-19.+d2))/((1.-d2)*(1.-rx)*(1.-ry1))-d2/(2.*pow((1.-rx),2))-d2/(2.*pow((1.-ry1),2)))/(rw*sqrt(1.-d2));
+ rM2=((pow((rx+0.5*d2),2)+pow((ry2+0.5*d2),2)+0.5*d2*(pow((5.-rx-ry2),2)-19.+d2))/((1.-d2)*(1.-rx)*(1.-ry2))-d2/(2.*pow((1.-rx),2))-d2/(2.*pow((1.-ry2),2)))/(rw*sqrt(1.-d2)); } else {
+ rM1=((pow((rx+0.5*d2),2)+pow((ry1+0.5*d2),2)-2.*d2*(1.+d2/2.))/((1.+d2/2.)*(1.-rx)*(1.-ry1))-d2/(2.*pow((1.-rx),2))-d2/(2.*pow((1.-ry1),2)))/(rw*sqrt(1.-d2));
+ rM2=((pow((rx+0.5*d2),2)+pow((ry2+0.5*d2),2)-2.*d2*(1.+d2/2.))/((1.+d2/2.)*(1.-rx)*(1.-ry2))-d2/(2.*pow((1.-rx),2))-d2/(2.*pow((1.-ry2),2)))/(rw*sqrt(1.-d2)); }
+
+ if (rx < xmin5 || pt2 > pt2meet){rM1=0;}
+ double M=fabs(rM1)+fabs(rM2);
+ return M;}
+/***************************************************************************************************/
+// Calculate Matrix Element for decay process
+
+double MEd (double pt2,double &rx3, double &rx11, double &rx12, double &rMd1, double &rMd2) {
+ rx11=-0.5*(2*pow(mt,2)-3*pow(mt,2)*rx3+pow(mt,2)*pow(rx3,2)+pow(mt,2)*rx3*a-2*pt2*a+sqrt(-4*pt2*pow(mt,2)*pow(rx3,2)-4*pow(mt,2)*pt2*pow(a,2)-8*pow(mt,2)*rx3*pt2*a-4*pow(mt,2)*pow(rx3,2)*pt2*a+pow(mt,4)*pow(rx3,2)-2*pow(mt,4)*pow(rx3,3)+pow(mt,4)*pow(rx3,4)-4*pt2*pow(mt,2)+16*pow(pt2,2)*a+8*pow(mt,2)*pt2*a-2*pow(mt,4)*pow(rx3,2)*a+2*pow(mt,4)*pow(rx3,3)*a+pow(mt,4)*pow(rx3,2)*pow(a,2)+8*pt2*pow(mt,2)*rx3))/(-pt2-pow(mt,2)+pow(mt,2)*rx3);
+ rx12=-0.5*(2*pow(mt,2)-3*pow(mt,2)*rx3+pow(mt,2)*pow(rx3,2)+pow(mt,2)*rx3*a-2*pt2*a-sqrt(-4*pt2*pow(mt,2)*pow(rx3,2)-4*pow(mt,2)*pt2*pow(a,2)-8*pow(mt,2)*rx3*pt2*a-4*pow(mt,2)*pow(rx3,2)*pt2*a+pow(mt,4)*pow(rx3,2)-2*pow(mt,4)*pow(rx3,3)+pow(mt,4)*pow(rx3,4)-4*pt2*pow(mt,2)+16*pow(pt2,2)*a+8*pow(mt,2)*pt2*a-2*pow(mt,4)*pow(rx3,2)*a+2*pow(mt,4)*pow(rx3,3)*a+pow(mt,4)*pow(rx3,2)*pow(a,2)+8*pt2*pow(mt,2)*rx3))/(-pt2-pow(mt,2)+pow(mt,2)*rx3);
+ double diff1=0.5*(-pow(mt,2)*(rx11+rx3*(2.-rx11-a)-pow(rx3,2)-1.)/(pow(rx11+a,2)-4*a)+pow(mt,2)*(1.-rx11)*(1.-rx3)/(pow(rx11+a,2)-4.*a)-pow(mt,2)*(1.-rx11)*(rx11+rx3*(2.-rx11-a)-pow(rx3,2)-1.)*(2.*rx11+2.*a)/(pow((pow(rx11+a,2)-4.*a),2)))/sqrt(pow(mt,2)*(1.-rx11)*(rx11+rx3*(2.-rx11-a)-pow(rx3,2)-1.)/(pow(rx11+a,2)-4.*a));
+ double diff2=0.5*(-pow(mt,2)*(rx12+rx3*(2.-rx12-a)-pow(rx3,2)-1.)/(pow(rx12+a,2)-4.*a)+pow(mt,2)*(1.-rx12)*(1.-rx3)/(pow(rx12+a,2)-4.*a)-pow(mt,2)*(1.-rx12)*(rx12+rx3*(2.-rx12-a)-pow(rx3,2)-1.)*(2.*rx12+2.*a)/(pow((pow(rx12+a,2)-4.*a),2)))/sqrt(pow(mt,2)*(1.-rx12)*(rx12+rx3*(2.-rx12-a)-pow(rx3,2)-1.)/(pow(rx12+a,2)-4.*a));
+ rMd1=4./(pi*3.*(1.-rx11)*pow(rx3,2))*(rx3-((1.-rx11)*(1.-rx3)+pow(rx3,2))/(1.-a)+rx3*pow(rx11+rx3-1.,2)/(2.*pow(1.-a,2))+2.*a*(1.-rx11)*pow(rx3,2)/(pow(1.-a,2)*(1.+2.*a)))/diff1;
+ rMd2=4./(pi*3.*(1.-rx12)*pow(rx3,2))*(rx3-((1.-rx12)*(1.-rx3)+pow(rx3,2))/(1.-a)+rx3*pow(rx12+rx3-1.,2)/(2.*pow(1.-a,2))+2.*a*(1.-rx12)*pow(rx3,2)/(pow(1.-a,2)*(1.+2.*a)))/diff2;
+ double M=fabs(rMd1)+fabs(rMd2);
+ return M;
+}
+/***************************************************************************************************/
+// Calculate Polarized Matrix Element for production process
+
+ void PolarizedME (double xt, double xtb, double xg, double &rct, double &rst, double &rsphi, double &rcphi,double &rLLL,double &rLRR,double &rLRL,double &rLLR,double &rRLL,double &rRRR, double &rRRL,double &rRLR, double areafac) {
+ double F1VL=-F1Vg+(-0.5+sinsqthw)/(sqrt(sinsqthw)*costhw)*pow(emcm,2)/(pow(emcm,2)-pow(Mz,2))*F1Vz;
+ double F1VR=-F1Vg+sinsqthw/(sqrt(sinsqthw)*costhw)*pow(emcm,2)/(pow(emcm,2)-pow(Mz,2))*F1Vz;
+ double F1AL=(-0.5+sinsqthw)/(sqrt(sinsqthw)*costhw)*pow(emcm,2)/(pow(emcm,2)-pow(Mz,2))*F1Az;
+ double F1AR=sinsqthw/(sqrt(sinsqthw)*costhw)*pow(emcm,2)/(pow(emcm,2)-pow(Mz,2))*F1Az;
+ double F1RL=F1VL+F1AL;
+ double F1RR=F1VR+F1AR;
+ double F1LL=F1VL-F1AL;
+ double F1LR=F1VR-F1AR;
+ //redfine vertex factor to include soft and virtual contributions
+ double vF1VL=-(F1Vg+dF1Vg)+(-0.5+sinsqthw)/(sqrt(sinsqthw)*costhw)*pow(emcm,2)/(pow(emcm,2)-pow(Mz,2))*(F1Vz+dF1Vz);
+ double vF1VR=-(F1Vg+dF1Vg)+sinsqthw/(sqrt(sinsqthw)*costhw)*pow(emcm,2)/(pow(emcm,2)-pow(Mz,2))*(F1Vz+dF1Vz);
+ double vF1AL=(-0.5+sinsqthw)/(sqrt(sinsqthw)*costhw)*pow(emcm,2)/(pow(emcm,2)-pow(Mz,2))*(F1Az+dF1Az);
+ double vF1AR=sinsqthw/(sqrt(sinsqthw)*costhw)*pow(emcm,2)/(pow(emcm,2)-pow(Mz,2))*(F1Az+dF1Az);
+ double bt=sqrt(1.-4.*pow(mt,2)/(pow(xt*emcm,2)));
+ double btb=sqrt(1.-4.*pow(mt,2)/(pow(xtb*emcm,2)));
+ double tt=acos((xg-xt-xtb+xt*xtb+4.*pow(mt/emcm,2))/(xt*bt*xtb*btb));
+ double tg=acos((xtb-xt-xg+xt*xg)/(xt*bt*xg));
+ double gam=emcm/(2.*mt);
+ double GLLR=pow(((vF1VL-beta*vF1AL)*(1.+rct)),2);
+ double GLRL=pow(((vF1VL+beta*vF1AL)*(1.-rct)),2);
+ double GLLL=pow(((vF1VL)*rst/gam),2);
+ double GLRR=pow(((vF1VL)*rst/gam),2);
+ double GRLR=pow((-(vF1VR-beta*vF1AR)*(1.-rct)),2);
+ double GRRL=pow((-(vF1VR+beta*vF1AR)*(1.+rct)),2);
+ double GRLL=pow(((vF1VR)*rst/gam),2);
+ double GRRR=pow(((vF1VR)*rst/gam),2);
+ double Apm=xg*sqrt(xt*xtb*(1.+bt)*(1.-btb))/(emcm*(1.-xt)*(1.-xtb));
+ double App=xg*sqrt(xt*xtb*(1.+bt)*(1.+btb))/(emcm*(1.-xt)*(1.-xtb));
+ double Amm=xg*sqrt(xt*xtb*(1.-bt)*(1.-btb))/(emcm*(1.-xt)*(1.-xtb));
+ double Amp=xg*sqrt(xt*xtb*(1.-bt)*(1.+btb))/(emcm*(1.-xt)*(1.-xtb));
+ double LLLLL=-Apm*sin(tg/2.)*cos(tg/2.)*cos(tt/2.)*(xt*bt+(1.-xt));
+ double LRLLL=Apm*pow((sin(tg/2.)),2)*sin(tt/2.)*(1.-xt);
+ double LZLLL=-Apm/sqrt(2.)*sin(tg/2.)*(xt*bt*cos(tg/2.)*sin(tt/2.)+(1.-xt)*sin((tt-tg)/2.));
+ double LLLLR=Apm*sin(tg/2.)*(xt*bt*cos(tg/2.)*cos(tt/2.)+(1.-xtb)*cos((tt+tg)/2.));
+ double LZLLR=Apm/sqrt(2.)*cos(tg/2.)*(xt*bt*sin(tg/2.)*sin(tt/2.)+(1.-xtb)*cos((tt+tg)/2.));
+ double LLRLL=-Amm*pow((cos(tg/2.)),2)*cos(tt/2.)*(1.-xt);
+ double LRRLL=-Amm*sin(tg/2.)*cos(tg/2.)*sin(tt/2.)*(xt*bt-(1.-xt));
+ double LZRLL=-Amm/sqrt(2.)*cos(tg/2.)*(xt*bt*sin(tg/2.)*cos(tt/2.)+(1.-xt)*sin((tt-tg)/2.));
+ double LRRLR=Amm*cos(tg/2.)*(xt*bt*sin(tg/2.)*sin(tt/2.)+(1.-xtb)*cos((tt+tg)/2.));
+ double LZRLR=Amm/sqrt(2.)*sin(tg/2.)*(xt*bt*cos(tg/2.)*cos(tt/2.)+(1.-xtb)*cos((tt+tg)/2.));
+ double LLLRL=-App*sin(tg/2.)*cos(tg/2.)*sin(tt/2.)*(xt*bt+(1.-xt));
+ double LRLRL=-App*pow((sin(tg/2.)),2)*cos(tt/2.)*(1.-xt);
+ double LZLRL=App/sqrt(2.)*sin(tg/2.)*(xt*bt*cos(tg/2.)*cos(tt/2.)+(1.-xt)*cos((tt-tg)/2.));
+ double LLLRR=App*sin(tg/2.)*(xt*bt*cos(tg/2.)*sin(tt/2.)+(1.-xtb)*sin((tt+tg)/2.));
+ double LZLRR=-App/sqrt(2.)*cos(tg/2.)*(xt*bt*sin(tg/2.)*cos(tt/2.)-(1.-xtb)*sin((tt+tg)/2.));
+ double LLRRL=-Amp*pow((cos(tg/2.)),2)*sin(tt/2.)*(1.-xt);
+ double LRRRL=Amp*sin(tg/2.)*cos(tg/2.)*cos(tt/2.)*(xt*bt-(1.-xt));
+ double LZRRL=-Amp/sqrt(2.)*cos(tg/2.)*(xt*bt*sin(tg/2.)*sin(tt/2.)-(1.-xt)*cos((tt-tg)/2.));
+ double LRRRR=-Amp*cos(tg/2.)*(xt*bt*sin(tg/2.)*cos(tt/2.)-(1.-xtb)*sin((tt+tg)/2.));
+ double LZRRR=Amp/sqrt(2.)*sin(tg/2.)*(xt*bt*cos(tg/2.)*sin(tt/2.)+(1.-xtb)*sin((tt+tg)/2.));
+ double LLLl=LLLLL+LLLLR;
+ double LLLr=LRLLL;
+ double LLLz=LZLLL+LZLLR;
+ double LRRl=LLRRL;
+ double LRRr=LRRRL+LRRRR;
+ double LRRz=LZRRL+LZRRR;
+ double LRLl=LLRLL;
+ double LRLr=LRRLL+LRRLR;
+ double LRLz=LZRLL+LZRLR;
+ double LLRl=LLLRR+LLLRL;
+ double LLRr=LRLRL;
+ double LLRz=LZLRR+LZLRL;
+ double RRRr=LLLl;
+ double RRRl=LLLr;
+ double RRRz=-LLLz;
+ double RLLr=LRRl;
+ double RLLl=LRRr;
+ double RLLz=-LRRz;
+ double RLRr=-LRLl;
+ double RLRl=-LRLr;
+ double RLRz=LRLz;
+ double RRLr=-LLRl;
+ double RRLl=-LLRr;
+ double RRLz=LLRz;
+ double MLLL[4],MLRR[4],MLRL[4],MLLR[4],MRLL[4],MRRR[4],MRRL[4],MRLR[4];
+ MLLL[1]=(F1LL*LLLl+F1RL*RLLl)*(1.+rct)/sqrt(2.);
+ MLLL[2]=(F1LL*LLLr+F1RL*RLLr)*(1.-rct)/sqrt(2.);
+ MLLL[3]=+(F1LL*LLLz+F1RL*RLLz)*rst;
+ MLRR[1]=(F1LL*LRRl+F1RL*RRRl)*(1.+rct)/sqrt(2.);
+ MLRR[2]=+(F1LL*LRRr+F1RL*RRRr)*(1.-rct)/sqrt(2.);
+ MLRR[3]=+(F1LL*LRRz+F1RL*RRRz)*rst;
+ MLRL[1]=(F1LL*LRLl+F1RL*RRLl)*(1.+rct)/sqrt(2.);
+ MLRL[2]=+(F1LL*LRLr+F1RL*RRLr)*(1.-rct)/sqrt(2.);
+ MLRL[3]=+(F1LL*LRLz+F1RL*RRLz)*rst;
+ MLLR[1]=(F1LL*LLRl+F1RL*RLRl)*(1.+rct)/sqrt(2.);
+ MLLR[2]=+(F1LL*LLRr+F1RL*RLRr)*(1.-rct)/sqrt(2.);
+ MLLR[3]=+(F1LL*LLRz+F1RL*RLRz)*rst;
+ MRLL[1]=-(F1LR*LLLl+F1RR*RLLl)*(1.-rct)/sqrt(2.);
+ MRLL[2]=-(F1LR*LLLr+F1RR*RLLr)*(1.+rct)/sqrt(2.);
+ MRLL[3]=+(F1LR*LLLz+F1RR*RLLz)*rst;
+ MRRR[1]=-(F1LR*LRRl+F1RR*RRRl)*(1.-rct)/sqrt(2.);
+ MRRR[2]=-(F1LR*LRRr+F1RR*RRRr)*(1.+rct)/sqrt(2.);
+ MRRR[3]=+(F1LR*LRRz+F1RR*RRRz)*rst;
+ MRRL[1]=-(F1LR*LRLl+F1RR*RRLl)*(1.-rct)/sqrt(2.);
+ MRRL[2]=-(F1LR*LRLr+F1RL*RRRr)*(1.+rct)/sqrt(2.);
+ MRRL[3]=+(F1LR*LRLz+F1RR*RRLz)*rst;
+ MRLR[1]=-(F1LR*LLRl+F1RR*RLRl)*(1.-rct)/sqrt(2.);
+ MRLR[2]=-(F1LR*LLRr+F1RR*RLRr)*(1.+rct)/sqrt(2.);
+ MRLR[3]=+(F1LR*LLRz+F1RR*RLRz)*rst;
+ rLLL=(pow(((MLLL[1]+MLLL[2])*rcphi+MLLL[3]),2)+pow(((MLLL[1]+MLLL[2])*rsphi),2))*16.*pi*asmt*pow(emcm,2)/(16.*pow(pi,2))+GLLL*areafac;
+ rLRR=(pow(((MLRR[1]+MLRR[2])*rcphi+MLRR[3]),2)+pow(((MLRR[1]+MLRR[2])*rsphi),2))*16.*pi*asmt*pow(emcm,2)/(16.*pow(pi,2))+GLRR*areafac;
+ rLRL=(pow(((MLRL[1]+MLRL[2])*rcphi+MLRL[3]),2)+pow(((MLRL[1]+MLRL[2])*rsphi),2))*16.*pi*asmt*pow(emcm,2)/(16.*pow(pi,2))+GLRL*areafac;
+ rLLR=(pow(((MLLR[1]+MLLR[2])*rcphi+MLLR[3]),2)+pow(((MLLR[1]+MLLR[2])*rsphi),2))*16.*pi*asmt*pow(emcm,2)/(16.*pow(pi,2))+GLLR*areafac;
+ rRLL=(pow(((MRLL[1]+MRLL[2])*rcphi+MRLL[3]),2)+pow(((MRLL[1]+MRLL[2])*rsphi),2))*16.*pi*asmt*pow(emcm,2)/(16.*pow(pi,2))+GRLL*areafac;
+ rRRR=(pow(((MRRR[1]+MRRR[2])*rcphi+MRRR[3]),2)+pow(((MRRR[1]+MRRR[2])*rsphi),2))*16.*pi*asmt*pow(emcm,2)/(16.*pow(pi,2))+GRRR*areafac;
+ rRRL=(pow(((MRRL[1]+MRRL[2])*rcphi+MRRL[3]),2)+pow(((MRRL[1]+MRRL[2])*rsphi),2))*16.*pi*asmt*pow(emcm,2)/(16.*pow(pi,2))+GRRL*areafac;
+ rRLR=(pow(((MRLR[1]+MRLR[2])*rcphi+MRLR[3]),2)+pow(((MRLR[1]+MRLR[2])*rsphi),2))*16.*pi*asmt*pow(emcm,2)/(16.*pow(pi,2))+GRLR*areafac;
+ }
+/***************************************************************************************************/
+// Calculate Polarized Matrix Element for decay process
+
+double PolMEdec(double xw1, double xb1, double xg1,double &rctw, double &rctl,double &rbphi, double &rbgphi,int tm, double xd0, double zd0, double fac){
+ double F1WL=1.;
+ double dF1WL=asmt*2./(3.*pi)*(-3.-pow(log(1.-a),2)+1.5*log(1-a)+4.+(5.-3.*a)/(8.*(1.-a))+pow(log(1.-a),2)-2.5*log(1.-a)-a*(2.-3.*a)/(4.*pow((1.-a),2))*log(a)-pow(pi,2)/2.-(1.+log(xd0))*(1.+log(zd0))+0.25*log(zd0)+ddilog(1.-a)-ddilog(a));
+ double dF2WL=asmt*2./(3.*pi)*1./a*log(1.-a);
+ double TL=1./a*(1.+tm*rctw)*(1.-pow(rctl,2))*fac*pow((F1WL+dF1WL-0.5*a*dF2WL),2);
+ double TO=(1.-tm*rctw)*pow((1.-rctl),2)*fac*pow((F1WL+dF1WL-0.5*dF2WL),2);
+ double TI=tm*2./sqrt(a)*(1.-rctl)*sqrt(1.-pow(rctw,2))*sqrt(1.-pow(rctl,2))*cos(rbphi)*fac*(F1WL+dF1WL-0.5*a*dF2WL)*(F1WL+dF1WL-0.5*dF2WL);
+ double T1sum=TL+TO+TI;
+ double bw1=sqrt(1.-4.*a/pow(xw1,2));
+ double cwb=1./(xw1*bw1*xb1)*(xg1-xw1-xb1+xw1*xb1+2.*a);
+ double cwg=1./(xw1*bw1*xg1)*(xb1-xw1-xg1+xw1*xg1+2.*a);
+ double twb=acos(cwb);
+ double twg=acos(cwg);
+ double swg=sin(twg);
+ double cwg2=cos(twg/2.);
+ double cwb2=cos(twb/2.);
+ double cbg2=cos((twb+twg)/2.);
+ double swg2=sin(twg/2.);
+ double swb2=sin(twb/2.);
+ double zet1=1.+a-xw1;
+ double MR1=-2./sqrt(zet1*xg1)*(xg1*cwg2+xb1*cwb2*cbg2);
+ double ML1=2./sqrt(zet1*xg1)*(-xg1*swg2+xb1*swb2*cbg2);
+ double MR2=xw1*(1.+bw1)/sqrt(a*2.*zet1*xg1)*(-xg1*swg2+xb1*swb2*cbg2);
+ double ML2=-xw1*(1.-bw1)/sqrt(a*2.*zet1*xg1)*(xg1*cwg2+xb1*cwb2*cbg2);
+ double MR3=sqrt(xb1)*cwb2*(2.*sqrt(xb1/(zet1*xg1))*cbg2-swg);
+ double ML3=-sqrt(xb1)*cwb2*(1.-cwg);
+ double MR4=-sqrt(xb1)*swb2*(1.+cwg);
+ double ML4=-sqrt(xb1)*swb2*(2.*sqrt(xb1/(zet1*xg1))*cbg2+swg);
+ double MR5=xw1*sqrt(xb1)/(2.*sqrt(2.*a))*((1.+bw1)*swb2*(-2.*sqrt(xb1/(zet1*xg1))*cbg2+swg)+(1.-bw1)*cwb2*(1.+cwg));
+ double ML5=xw1*sqrt(xb1)/(2.*sqrt(2.*a))*((1.-bw1)*cwb2*(2.*sqrt(xb1/(zet1*xg1))*cbg2+swg)+(1.+bw1)*swb2*(1.-cwg));
+ double A=(MR2+MR5)*sqrt(1.-pow(rctl,2)); double B=(MR1+MR3)*1./sqrt(2.)*(1.+rctl); double C=MR4*1./sqrt(2.)*(1.-rctl);
+ double D=(ML2+ML5)*sqrt(1.-pow(rctl,2)); double E=ML3*1./sqrt(2.)*(1.+rctl); double F=(ML1+ML4)*1./sqrt(2.)*(1.-rctl);
+ double MMT=((pow(A,2)+pow(B,2)+pow(C,2)+2.*A*B*cos(rbphi)+2.*B*C*cos(2.*rbphi)+2.*A*C*cos(rbphi))*0.5*(1.+tm*rctw)+(pow(D,2)+pow(E,2)+pow(F,2)+2.*D*E*cos(rbphi)+2.*E*F*cos(2.*rbphi)+2.*D*F*cos(rbphi))*0.5*(1.-tm*rctw)+tm*((A*D+B*E+C*F)*cos(rbgphi)+(A*E+C*D)*cos(rbphi+rbgphi)+(B*D+A*F)*cos(rbphi-rbgphi)+B*F*cos(2.*rbphi-rbgphi)+C*E*cos(2.*rbphi+rbgphi))*sqrt(1-pow(rctw,2)))*pow(mt,2)*pi*asmt*8./(pow(pi,2)*16.)+T1sum;
+ return MMT;
+}
+
+/***************************************************************************************************/
+// Random number generator
+
+ double random (int &rseed) {
+ int M = 2147483647;
+ int A = 16807;
+ int Q = 127773;
+ int R = 2836;
+ double MINV = 0.46566128752458e-09;
+ int HI = rseed/Q;
+ int LO = rseed % Q;
+ rseed = A*LO - R*HI;
+ if (rseed <= 0) {rseed = rseed + M;}
+ return rseed*MINV;}
+/***************************************************************************************************/
+double ddilog(double x)
+{
+ // The DiLogarithm function
+ // Code translated by R.Brun from CERNLIB DILOG function C332
+
+ const double hf = 0.5;
+ const double pi = 3.14152654;
+ const double pi2 = pi*pi;
+ const double pi3 = pi2/3;
+ const double pi6 = pi2/6;
+ const double pi12 = pi2/12;
+ const double c[20] = {0.42996693560813697, 0.40975987533077105,
+ -0.01858843665014592, 0.00145751084062268,-0.00014304184442340,
+ 0.00001588415541880,-0.00000190784959387, 0.00000024195180854,
+ -0.00000003193341274, 0.00000000434545063,-0.00000000060578480,
+ 0.00000000008612098,-0.00000000001244332, 0.00000000000182256,
+ -0.00000000000027007, 0.00000000000004042,-0.00000000000000610,
+ 0.00000000000000093,-0.00000000000000014, 0.00000000000000002};
+
+ double t,h,y,s,a,alfa,b1,b2,b0;
+
+ if (x == 1) {
+ h = pi6;
+ } else if (x == -1) {
+ h = -pi12;
+ } else {
+ t = -x;
+ if (t <= -2) {
+ y = -1/(1+t);
+ s = 1;
+ b1= log(-t);
+ b2= log(1+1/t);
+ a = -pi3+hf*(b1*b1-b2*b2);
+ } else if (t < -1) {
+ y = -1-t;
+ s = -1;
+ a = log(-t);
+ a = -pi6+a*(a+log(1+1/t));
+ } else if (t <= -0.5) {
+ y = -(1+t)/t;
+ s = 1;
+ a = log(-t);
+ a = -pi6+a*(-hf*a+log(1+t));
+ } else if (t < 0) {
+ y = -t/(1+t);
+ s = -1;
+ b1= log(1+t);
+ a = hf*b1*b1;
+ } else if (t <= 1) {
+ y = t;
+ s = 1;
+ a = 0;
+ } else {
+ y = 1/t;
+ s = -1;
+ b1= log(t);
+ a = pi6+hf*b1*b1;
+ }
+ h = y+y-1;
+ alfa = h+h;
+ b1 = 0;
+ b2 = 0;
+ for (int i=19;i>=0;i--){
+ b0 = c[i] + alfa*b1-b2;
+ b2 = b1;
+ b1 = b0;
+ }
+ h = -(s*(b0-h*b2)+a);
+ }
+ return h;
+}
+/*********************************************************************/
+
+
+// if(POWprod && !POWdecay) {
+// for (int ja = 1; ja < 12; ja++) {
+// outdata << IDUP[ja] << "\t" << ISTUP[ja] << "\t" << MOTHUP[1][ja] <<"\t" << MOTHUP[2][ja] << "\t" << ICOLUP[1][ja] << "\t" << ICOLUP[2][ja] <<"\t" <<setprecision (9)<< PUP[1][ja] << "\t" << PUP[2][ja]<<"\t"<<PUP[3][ja]<<"\t"<<PUP[4][ja]<<"\t" << mass[ja] <<"\t"<< "0" << "\t" <<"9" <<endl;
+// sum1+=PUP[4][ja];sum2+=PUP[1][ja];sum3+=PUP[2][ja];sum3+=PUP[3][ja];
+// }
+// if (emit) {
+// for (int ja=14; ja < 16; ja++) {
+// outdata << IDUP[ja] << "\t" << ISTUP[ja] << "\t" << MOTHUP[1][ja] <<"\t" << MOTHUP[2][ja] << "\t" << ICOLUP[1][ja] << "\t" << ICOLUP[2][ja] <<"\t" <<setprecision (9)<< PUP[1][ja] << "\t" << PUP[2][ja]<<"\t"<<PUP[3][ja]<<"\t"<<PUP[4][ja]<<"\t" << mass[ja] <<"\t"<< "0" << "\t" <<"9" <<endl;
+// sum1+=PUP[4][ja];sum2+=PUP[1][ja];sum3+=PUP[2][ja];sum3+=PUP[3][ja];}}else {
+// for (int ja=14; ja < 15; ja++) {
+// outdata << IDUP[ja] << "\t" << ISTUP[ja] << "\t" << MOTHUP[1][ja] <<"\t" << MOTHUP[2][ja] << "\t" << ICOLUP[1][ja] << "\t" << ICOLUP[2][ja] <<"\t" <<setprecision (9)<< PUP[1][ja] << "\t" << PUP[2][ja]<<"\t"<<PUP[3][ja]<<"\t"<<PUP[4][ja]<<"\t" << mass[ja] <<"\t"<< "0" << "\t" <<"9" <<endl;
+// sum1+=PUP[4][ja];sum2+=PUP[1][ja];sum3+=PUP[2][ja];sum3+=PUP[3][ja];
+// }
+
+// }}
+
+// // if (decay) {for (int jh=11; jh< NUP+1; jh++)
+
+// // {jhh=jh+1;outdata << jhh <<"\t" << PUP[4][jh] << "\t" << PUP[1][jh]<<"\t"<<PUP[2][jh]<<"\t"<<PUP[3][jh]<<endl;
+// // sum1+=PUP[4][jh];sum2+=PUP[1][jh];sum3+=PUP[2][jh];sum3+=PUP[3][jh];}}
+// // if (POWprod && !decay) {for (int jh=13; jh<NUPP;jh++)
+// // {jhh=jh+1;outdata << jhh-2 <<"\t" << PUP[4][jh] << "\t" << PUP[1][jh]<<"\t"<<PUP[2][jh]<<"\t"<<PUP[3][jh]<<endl;
+// // sum1+=2.*PUP[4][jh];sum2+=2.*PUP[1][jh];sum3+=2.*PUP[2][jh];sum3+=2.*PUP[3][jh];}}
+
+// cout <<ixx << "\t" << sum1 << "\t" <<sum2 <<"\t" <<sum3 <<"\t" << sum4 << "\t" << EVT << endl;
+// outdata << "</event>" << endl;
+// }
+ // outdata << "</LesHouchesEvents>" << endl;
+// return 0;
+// }
+
+ // outdata << NUP+1 <<"\t"<<ixx+1<<"\t"<<XWGTUP<<"\t"<<SCALUP<<"\t"<<AQEDUP<<"\t"<<AQCDUP <<endl;
+ // for (int ja = 1; ja < 11; ja++) {
+// outdata << IDUP[ja] << "\t" ;
+// if (ja==2) {outdata << IDUP[15] << "\t" ;}}
+// if (decay) {for (int ja=11; ja < NUP+1; ja++)
+// {outdata << IDUP[ja] << "\t" ;}}
+// if (POWprod && !decay) {for (int ja=13; ja<NUPP;ja++)
+// {outdata << IDUP[ja] << "\t" ;}}
+// outdata << endl;
+// for (int jb = 1; jb < 3; jb++) {
+// for (int jc = 1; jc < 11; jc++) {
+// outdata << MOTHUP[jb][jc]<<"\t" ;
+// if (jc==2) {outdata << MOTHUP[jb][15] << "\t" ;}}
+// if (decay) {for (int jc=11; jc < NUP+1; jc++)
+// {outdata << MOTHUP[jb][jc] << "\t" ;}}
+// if (POWprod && !decay) {for (int jc=13; jc<NUPP;jc++)
+// {outdata << MOTHUP[jb][jc] << "\t" ;}}
+// outdata << endl;}
+// for (int jd = 1; jd < 3; jd++) {
+// for (int je = 1; je < 11; je++) {
+// outdata << ICOLUP[jd][je]<<"\t" ;
+// if (je==2) {outdata << ICOLUP[jd][15] << "\t" ;}}
+// if (decay) {for (int je=11; je < NUP+1; je++)
+// {outdata << ICOLUP[jd][je] << "\t" ;}}
+// if (POWprod && !decay) {for (int je=13; je<NUPP;je++)
+// {outdata << ICOLUP[jd][je] << "\t" ;}}
+// outdata << endl;}
+// for (int jf = 1; jf < 11; jf++) {
+// outdata << ISTUP[jf] << "\t" ;
+// if (jf==2) { outdata << ISTUP[15] << "\t" ;}}
+// if (decay) {for (int jf=11; jf< NUP+1; jf++)
+// {outdata << ISTUP[jf] << "\t" ;}}
+// if (POWprod && !decay) {for (int jf=13; jf<NUPP;jf++)
+// {outdata << ISTUP[jf] << "\t" ;}}
+// outdata << endl;
+// for (int jg = 1; jg < 11; jg++) {
+// outdata << ISPINUP[jg] << "\t" ;
+// if (jg==2) { outdata << ISPINUP[15] << "\t" ;}}
+// if (decay) {for (int jg=11; jg< NUP+1; jg++)
+// {outdata << ISPINUP[jg] << "\t" ;}}
+// if (POWprod && !decay) {for (int jg=13; jg<NUPP;jg++)
+// {outdata << ISPINUP[jg] << "\t" ;}}
+// outdata << endl;
+// int jhh=0;
+// for (int jh = 1; jh < 11; jh++) {
+// jhh=jhh+1;
+// outdata << jhh <<"\t" << PUP[4][jh] << "\t" << PUP[1][jh]<<"\t"<<PUP[2][jh]<<"\t"<<PUP[3][jh]<<endl;
+// if(jh==2){outdata << 3 <<"\t" << PUP[4][15] << "\t" << PUP[1][15]<<"\t"<<PUP[2][15]<<"\t"<<PUP[3][15]<<endl;jhh=jhh+1;}
+// sum1+=PUP[4][jh];sum2+=PUP[1][jh];sum3+=PUP[2][jh];sum3+=PUP[3][jh];}
+// if (decay) {for (int jh=11; jh< NUP+1; jh++)
+
+// {jhh=jh+1;outdata << jhh <<"\t" << PUP[4][jh] << "\t" << PUP[1][jh]<<"\t"<<PUP[2][jh]<<"\t"<<PUP[3][jh]<<endl;
+// sum1+=PUP[4][jh];sum2+=PUP[1][jh];sum3+=PUP[2][jh];sum3+=PUP[3][jh];}}
+// if (POWprod && !decay) {for (int jh=13; jh<NUPP;jh++)
+// {jhh=jh+1;outdata << jhh-2 <<"\t" << PUP[4][jh] << "\t" << PUP[1][jh]<<"\t"<<PUP[2][jh]<<"\t"<<PUP[3][jh]<<endl;
+// sum1+=2.*PUP[4][jh];sum2+=2.*PUP[1][jh];sum3+=2.*PUP[2][jh];sum3+=2.*PUP[3][jh];}}
+
+// cout <<ixx << "\t" << sum1 << "\t" <<sum2 <<"\t" <<sum3 <<"\t" << sum4 << "\t" << EVT << endl;}
+
+// return 0; }
diff --git a/Contrib/MCPWNLO/ILCTTBAR/ILCTTBAR_INPUTS.h b/Contrib/MCPWNLO/ILCTTBAR/ILCTTBAR_INPUTS.h
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/ILCTTBAR/ILCTTBAR_INPUTS.h
@@ -0,0 +1,55 @@
+/* MC@NLO input file*/
+#include<iostream>
+#include <string>
+
+class Input
+
+{
+ public:
+
+ // Input();
+ // ~Input();
+
+/* Center of mass energy/GeV */
+
+ double cme() {return 1000.;}
+
+/* Polarization of e- (Pem) and e+ (Pep). +1 for RH and -1 for LH */
+
+ int Pem() {return 1;}
+
+ int Pep() {return -1;}
+
+/* Pole mass of Z/GeV */
+
+ double Mz() {return 91.2;}
+
+/* Number of events to generate */
+
+ int nevgen() {return 10;};
+
+
+/* Random number seed */
+
+ int rseed() {return 3;}
+
+/* Implement POWHEG for ttbar production? i.e want NLO production?*/
+
+bool POWHEGprod() {return true;}
+
+/*Implement POWHEG for ttbar decays? i.e want NLO decays?*/
+
+bool POWHEGdecay() {return true;}
+
+ /* Implement truncated shower for production? */
+
+bool truncpro() {return true;}
+
+ /* Implement truncated shower for decays? */
+
+bool truncdec() {return true;}
+
+};
+
+
+
diff --git a/Contrib/MCPWNLO/ILCTTBAR/ILCTTBARmanual.tex b/Contrib/MCPWNLO/ILCTTBAR/ILCTTBARmanual.tex
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/ILCTTBAR/ILCTTBARmanual.tex
@@ -0,0 +1,154 @@
+\documentclass[12pt,a4paper,oneside]{article}
+%\documentclass{article}
+%\usepackage{afterpage}
+%\usepackage[hang,small,bf]{caption}
+%\usepackage{fancyhdr}
+%\usepackage[something]{optional}
+%\usepackage[todo, question, colour]{optional}
+%\usepackage{epsfig,axodraw}
+%\usepackage{array,cite,amsmath,amssymb}
+%\usepackage{cite}
+%\usepackage{makeidx}
+%\usepackage{doublespace} % This doesn't work with FeynArts diagrams
+%\usepackage{array}
+%\usepackage{multicol}
+%\usepackage{subfigure}
+%\usepackage{rotating}
+%\usepackage{amssymb}
+\usepackage{setspace}
+\usepackage{booktabs}
+%\input{psfig.tex}
+%\usepackage{psfig}
+\oddsidemargin=-0.05in
+\textwidth=6.9in
+\topmargin=-0.8in
+\textheight=9.55in
+%\reqno
+%\newcounter{table}
+\addtocounter{table}{0}
+\usepackage{hyperref}
+\usepackage{epsfig,bm,amsmath}
+\onehalfspacing
+% \makeatletter
+% \DeclareRobustCommand{\Cpp}
+% {\valign{\vfil\hbox{##}\vfil\cr
+% \textsf{C\kern-.1em}\cr
+% $\hbox{\fontsize{\sf@size}{0}\textbf{+\kern-0.05em+}}$\cr}%
+% }
+\begin{document}
+\begin{center}
+\Large \textbf {ILC top pair production and decay with {\tt MCPWNLO}} \\
+\end{center}
+\section{Introduction}
+This manual describes how to generate $e^+e^-$ annihilation events at the ILC with NLO accuracy using the {\tt POWHEG} \cite{Nason:2004rx} method. More details on the use and application of the program and its interface with {\tt Herwig++} \cite{Bahr:2008pv} can be found in \cite{LatundeDada:2008bv}.
+\section{Setting the parameters}
+Within the directory {\tt MCPWNLO/ILCTTBAR}, the file {\tt ILCTTBAR\_INPUTS.h} includes all the available user parameters
+for the main program {\tt ILCTTBAR.cxx} for {\tt
+ POWHEG} event generation. The parameters are:\\
+\\
+{\tt double cme}: The center of mass energy in GeV e.g. $500$ for ILC. \\
+{\tt int Pem}: Polarization of the beam electrons (1 for right-handed helicity or -1 for left-handed helicity).\\
+{\tt int Pep}: Polarization of the beam positrons (1 or -1).\\
+{\tt double Mz}: Pole mass of the $Z$ boson in GeV.\\
+{\tt int nevgen}: Number of events to generate (typically $\approx 10^5$). \\
+{\tt int rseed}: Initial seed for the random number generator. \\
+{\tt bool POWHEGprod}: Set to {\tt true} if the {\tt POWHEG} method is to be used for production. \\
+{\tt bool POWHEGdecay}: Set to {\tt true} if the {\tt POWHEG} method is to be used for the decays. \\
+{\tt bool truncpro}: Set to {\tt true} if the truncated shower is to be switched on in the
+production process. \\
+{\tt bool truncdec}: Set to {\tt true} if the truncated shower is to be switched on in the
+decay process.\\
+\section{Generating partonic events}
+After setting the parameters, open the {\tt Makefile} and set {\tt HERWIGDIR} to the address of the {\tt Herwig} folder
+in the directory {\tt MCPWNLO}.
+To run {\tt ILCTTBAR.cxx}, in the directory {\tt ILCTTBAR}, type the following commands :\\
+\\
+{\tt make clean} \\
+{\tt make} \\
+\\
+This creates the executable {\tt ILCTTBAR} and {\tt run\_ilc} (which is moved to {\tt
+ HERWIGDIR}). Next, type: \\
+\\
+{\tt ./ILCTTBAR} \\
+\\
+This runs the main program and generates the Les Houches file for interface with \textsf{Herwig++}. This file will be called {\tt ILCTTBAR.dat} and contains unweighted events with absolute weights
+of $1$.
+\section{{\tt POWHEG} requirements}
+If running {\tt POWHEG}, go to the folder {\tt PWInstallFiles} in the main {\tt MCPWNLO}
+directory. There you will find the following files:\\
+{\tt Evolver.cc} {\tt Evolver.h} {\tt Evolver.icc} {\tt PartnerFinder.cc} {\tt PartnerFinder.h} {\tt PartnerFinder.icc}
+Replace the files of the same names in {\tt /Shower/Base} folder of your \textsf{Herwig++}
+installation directory. Then go back to the {\tt Shower} folder (not in {\tt Base}!) and type: \\
+\\
+{\tt make} \\
+{\tt make install} \\
+\\
+This allows us to veto the shower and set the colour partner of the hardest emission correctly for {\tt
+ POWHEG}.
+\section{Analysis}
+
+In the folder {\tt ILCAnalysis} in the {\tt ILCTTBAR} directory are some analysis files
+which analyze the events after interfacing the Les Houches file with
+\textsf{Herwig++}. \\ The
+{\tt SimpleILCAnalysis.cc} file contains the main program which provides
+histograms for various distributions. Open the {\tt Makefile} and set {\tt HPDIR} and
+{\tt THEPEGDIR} to the folder where you installed \textsf{Herwig++} and \textsf{ThePEG}. Compile the directory by typing the following commands\\
+\\
+{\tt make} \\
+{\tt make install} \\
+\\
+in the {\tt ILCAnalysis} directory. This recreates the {\tt SimpleILCAnalysis.so} library.
+
+\section{Interfacing with \textsf{Herwig++}}
+Having generated the Les Houches file and set up the analysis handlers, the next step is to
+run \textsf{Herwig++}. It is assumed that both \textsf{Herwig++} and \textsf{ThePEG} have
+already been installed on your system.
+
+Now go to the directory {\tt MCPWNLO/Herwig} and open the initialization file {\tt
+ ILCTTB.in}. This contains \textsf{Herwig++} user parameters which can be set. A selection of
+these are:\\
+\\
+{\tt set Reader2:FileName TTB.dat}: This is the filename for the Les Houches file your
+generated file is converted into by the program {\tt ILCTTBAR/run\_ilc.cxx}. Leave this
+as it is! \\
+{\tt set Reader2:EBeamA 250.0}: The beam energy in GeV of the electrons. \\
+{\tt set Reader2:EBeamB 250.0}: The beam energy in GeV of the positrons.\\
+{\tt set LesHouchesHandler:WeightOption UnitWeight}: The weight option for the
+events. \\
+{\tt insert SimpleEE:MatrixElements 0 MEee2gZ2qq}: The hard process. Here it's set up for
+$Z$/gamma production and decay into $q \bar{q}$ pairs.\\
+{\tt set MEee2gZ2qq:MinimumFlavour 6}: These sets the decays exclusively into top pairs. \\
+{\tt set MEee2gZ2qq:MaximumFlavour 6}: These sets the decays exclusively into top pairs. \\
+{\tt set /Herwig/Shower/Evolver:HardVetoMode 1}: The veto mode to be applied. For {\tt
+ POWHEG}, this should be set to $1$.\\
+{\tt set /Herwig/Shower/Evolver:POWHEGTOPVeto 1}: The {\tt POWHEG} top veto mode to be
+applied.\\
+{\tt set /Herwig/Shower/PartnerFinder:PHPartnerFinder 1}: The partner finder option. This
+should be set to $1$ for {\tt POWHEG}.\\
+\\
+Having set up the initialization file, run \textsf{Herwig++} by typing the following
+commands: \\
+\\
+{\tt ./run\_ilc [eventfile] [number of events]} \\
+\\
+An example of the run
+command is:\\
+\\
+{\tt ./run\_ilc /usera/seyi/MCPWNLO/ILCTTBAR/ILCTTBAR.dat 10000}\\
+\\
+where you should replace the eventfile with the path to your Les Houches file.
+\\
+ At the end of the run, a topdrawer file {\tt MG\_SimpleILC.top} will be
+ produced containing the histograms booked by the analysis handler. If you have topdraw
+ installed, you can convert this to a postscript file by typing the command:\\
+\\
+{\tt td -dPOSTSCRIPT *.top}
+\section{Further Information}
+For further information about {\tt MCPWNLO} contact: {\tt seyi@hep.phy.cam.ac.uk}.
+\bibliography{manual}
+\bibliographystyle{utphys}
+\end{document}
+%%% Local Variables:
+%%% mode: latex
+%%% TeX-master: t
+%%% End:
diff --git a/Contrib/MCPWNLO/ILCTTBAR/Makefile b/Contrib/MCPWNLO/ILCTTBAR/Makefile
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/ILCTTBAR/Makefile
@@ -0,0 +1,66 @@
+###############################################################################
+# DIRECTORIES
+
+#Where the /MCPWNLO/Herwig folder is
+HERWIGDIR = /usera/seyi/MCPWNLO/Herwig
+
+###############################################################################
+###############################################################################
+# LIBRARIES
+
+#Now the libraries -L(directory) -lname NOT preceeded by lib!!!!
+#i.e if your lib is called libNAME you need -lNAME
+
+##Path to CLHEP library should be $(CLHEPDIR)/lib/ and check lib name
+#CLHEPLIB = -L$(HOME)/ktjet/lib/ -lKtEvent -L$(CLHEPDIR)/lib/ -lCLHEP
+#CLHEPLIBNEW = -L$(CLHEPDIRNEW)/lib/ -lCLHEP
+##Path to LHAPDF library should be the same as the LHAPDF directory
+LHAPDFLIB = -L$(LHAPDFDIR)/lib -lLHAPDF
+LHAPDFINC = $(LHAPDFDIR)/include
+
+#MAC OS users....
+#If you had to get an external version of libg2c - i.e it doesn't come with you compiler......We stress, you've probably already got this.
+LIBG2C = /usr/local/lib/
+# You would then have to add -L$(LIBG2C) just in front of -lg2c on line 58
+
+################################################################################
+#No need to edit anything below this line!
+
+OPT = -funroll-loops -O2 -Wall
+
+
+FSOURCES = $(shell ls ./src/*.f)
+CXXSOURCES = $(shell ls ./src/*.cxx)
+FOBJS = $(FSOURCES:.f=.o)
+CXXOBJS = $(CXXSOURCES:.cxx=.o)
+CC = gcc
+FF = g77
+
+all: ILCTTBAR run_ilc
+
+%.o: %.cxx
+ $(CC) -c $(OPT) \
+ $^ -o $@
+
+%.o: %.f
+ $(FF) -c $(OPT) $^ -o $@
+
+ILCTTBAR: ILCTTBAR.o
+ g++ $(OPT) -I./src/ $^\
+ -L$(LIBG2C) -lg2c -o $@
+
+run_ilc: run_ilc.o
+ g++ $(OPT) -I./src/ $^\
+ -L$(LIBG2C) -lg2c -o $@
+ mv run_ilc $(HERWIGDIR)
+
+
+
+
+
+clean:
+ rm *.o
+ rm ILCTTBAR
+
+
+
diff --git a/Contrib/MCPWNLO/ILCTTBAR/axialcoeff.dat b/Contrib/MCPWNLO/ILCTTBAR/axialcoeff.dat
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/ILCTTBAR/axialcoeff.dat
@@ -0,0 +1,24 @@
+0.0 1.0
+0.1 1.156
+0.1461 1.25
+0.2 1.4375
+0.2154 1.5
+0.2808 1.75
+0.3 1.8125
+0.3615 2.0
+0.4 2.125
+0.4538 2.25
+0.5 2.28125
+0.5769 2.625
+0.6 2.625
+0.7 2.25
+0.7538 2.0
+0.8 1.75
+0.84615 1.5
+0.8769 1.25
+0.9 1.125
+0.9077 1.0
+0.9307 0.75
+0.9538 0.5
+0.9846 0.25
+1.0 0.0
diff --git a/Contrib/MCPWNLO/ILCTTBAR/manual.bib b/Contrib/MCPWNLO/ILCTTBAR/manual.bib
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/ILCTTBAR/manual.bib
@@ -0,0 +1,91 @@
+@Article{Frixione:2002ik,
+ author = "Frixione, Stefano and Webber, Bryan R.",
+ title = "Matching {NLO QCD} computations and parton shower
+ simulations",
+ journal = "JHEP",
+ volume = "06",
+ year = "2002",
+ pages = "029",
+ eprint = "hep-ph/0204244",
+ SLACcitation = "%%CITATION = HEP-PH 0204244;%%"
+}
+@Article{LatundeDada:2006gx,
+ author = "Latunde-Dada, Oluseyi and Gieseke, Stefan and Webber, Bryan
+ ",
+ title = "A positive-weight next-to-leading-order {M}onte {C}arlo for $e^+
+ e^-$ annihilation to hadrons",
+ journal = "JHEP",
+ volume = "02",
+ year = "2007",
+ pages = "051",
+ eprint = "hep-ph/0612281",
+ SLACcitation = "%%CITATION = HEP-PH/0612281;%%"
+}
+@Article{LatundeDada:2008bv,
+ author = "Latunde-Dada, Oluseyi",
+ title = "{Applying the POWHEG method to top pair production and
+ decays at the ILC}",
+ journal = "Eur. Phys. J.",
+ volume = "C58",
+ year = "2008",
+ pages = "543-554",
+ eprint = "0806.4560",
+ archivePrefix = "arXiv",
+ primaryClass = "hep-ph",
+ doi = "10.1140/epjc/s10052-008-0785-1",
+ SLACcitation = "%%CITATION = 0806.4560;%%"
+}
+@Article{Bahr:2008pv,
+ author = "Bahr, M. and others",
+ title = "{Herwig++ Physics and Manual}",
+ journal = "Eur. Phys. J.",
+ volume = "C58",
+ year = "2008",
+ pages = "639-707",
+ eprint = "0803.0883",
+ archivePrefix = "arXiv",
+ primaryClass = "hep-ph",
+ doi = "10.1140/epjc/s10052-008-0798-9",
+ SLACcitation = "%%CITATION = 0803.0883;%%"
+}
+@Article{LatundeDada:2007jg,
+ author = "Latunde-Dada, Oluseyi",
+ title = "{Herwig++ Monte Carlo At Next-To-Leading Order for e+e-
+ annihilation and lepton pair production}",
+ journal = "JHEP",
+ volume = "11",
+ year = "2007",
+ pages = "040",
+ eprint = "0708.4390",
+ archivePrefix = "arXiv",
+ primaryClass = "hep-ph",
+ doi = "10.1088/1126-6708/2007/11/040",
+ SLACcitation = "%%CITATION = 0708.4390;%%"
+}
+@Article{Nason:2004rx,
+ author = "Nason, Paolo",
+ title = "A new method for combining {NLO QCD} with shower {M}onte {C}arlo
+ algorithms",
+ journal = "JHEP",
+ volume = "11",
+ year = "2004",
+ pages = "040",
+ eprint = "hep-ph/0409146",
+ SLACcitation = "%%CITATION = HEP-PH/0409146;%%"
+}
+@PHDTHESIS{seyi,
+author = "Latunde-Dada, O.A.T",
+year = "2008",
+school = "University of Cambridge",
+title = "Simulations of QCD processes at High Energy Colliders {\bf [http://www.hep.phy.cam.ac.uk/theory/seyi/thesis/thesis.tar.gz]}"
+}
+@Article{LatundeDada:2009rr,
+ author = "Latunde-Dada, Oluseyi",
+ title = "{MC@NLO for the hadronic decay of Higgs bosons in
+ associated production with vector bosons}",
+ year = "2009",
+ eprint = "0903.4135",
+ archivePrefix = "arXiv",
+ primaryClass = "hep-ph",
+ SLACcitation = "%%CITATION = 0903.4135;%%"
+}
diff --git a/Contrib/MCPWNLO/ILCTTBAR/run_ilc.cxx b/Contrib/MCPWNLO/ILCTTBAR/run_ilc.cxx
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/ILCTTBAR/run_ilc.cxx
@@ -0,0 +1,67 @@
+#include <cstdlib>
+#include <ctime>
+#include <iostream>
+#include <string>
+#include <fstream>
+#include <cmath>
+#include <iomanip>
+
+using namespace std;
+
+
+int main (int argc, char *argv[]) {
+ string eventfile = "";
+ string numevents = "1";
+ if(argv[1] && argv[2]) { eventfile = argv[1]; numevents = argv[2];} else { cout << "Use: run_hpp [eventfile] [numevents]" << endl; exit(1); }
+
+ cout << "Running Herwig++ with eventfile: " << eventfile << " and " << numevents << " events\n";
+ // ifstream stream;
+ //ofstream outstream;
+ //ofstream outorigin;
+ //string allfile = "";
+ // string addstr = "";
+
+ // stream.open("wpnlo.in");
+ // outstream.open("wpnlo.temp");
+ //outorigin.open("wpnlo.orig");
+ // if(!stream) { cerr << "Error: Failed to open file" << endl;}
+
+ // string search_string = "eventfile.dat";
+ //string replace_string = eventfile;
+ //string inbuf;
+
+ // while(!stream.eof())
+ //{
+ // getline(stream, inbuf);
+ // int spot = inbuf.find(search_string);
+ // outorigin << inbuf << endl;
+ // if(spot >= 0)
+ // {
+ // string tmpstring = inbuf.substr(0,spot);
+ // tmpstring += replace_string;
+ // tmpstring += inbuf.substr(spot+search_string.length(), inbuf.length());
+ // inbuf = tmpstring;
+ // }
+ // outstream << inbuf << endl;
+ //
+ // }
+ //outstream.close();
+ //stream.close();
+
+ string runcomm1 = "mv ";
+ runcomm1.append(eventfile);
+ runcomm1.append(" TTB.dat");
+ system(runcomm1.c_str());
+ cout << "Reading ILCTTB.in..." << endl;
+ system("Herwig++ read ILCTTB.in");
+ cout << "Done..." << endl;
+ cout << "Running MG.run..." << endl;
+ string runcomm2 = "Herwig++ run MG.run -N";
+ cout << "Done!" << endl;
+ runcomm2.append(numevents);
+ system(runcomm2.c_str());
+ string runcomm3 = "mv TTB.dat ";
+ runcomm3.append(eventfile);
+ system(runcomm3.c_str());
+ // system("mv wpnlo.orig wpnlo.in");
+}
diff --git a/Contrib/MCPWNLO/ILCTTBAR/vectorcoeff.dat b/Contrib/MCPWNLO/ILCTTBAR/vectorcoeff.dat
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/ILCTTBAR/vectorcoeff.dat
@@ -0,0 +1,18 @@
+0.0 1.0
+0.1 1.05
+0.2 1.16875
+0.3 1.3125
+0.4 1.625
+0.474 2.0
+0.5 2.125
+0.6 2.725
+0.643 3.0
+0.70 3.5
+0.75 4.0
+0.80 4.65
+0.831 5.0
+0.8846 6.0
+0.90 6.25
+0.931 7.0
+0.9692 8.0
+1.0 9.8696
diff --git a/Contrib/MCPWNLO/PWInstallFiles/Evolver.cc b/Contrib/MCPWNLO/PWInstallFiles/Evolver.cc
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/PWInstallFiles/Evolver.cc
@@ -0,0 +1,845 @@
+// -*- C++ -*-
+//
+// Evolver.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 Evolver class.
+//
+#include "Evolver.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/Interface/Reference.h"
+#include "ThePEG/Interface/RefVector.h"
+#include "ThePEG/Interface/Switch.h"
+#include "ThePEG/Interface/Parameter.h"
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+#include "Herwig++/Shower/Base/ShowerParticle.h"
+#include "ShowerKinematics.h"
+#include "ThePEG/PDT/EnumParticles.h"
+#include "ThePEG/Repository/EventGenerator.h"
+#include "ThePEG/Handlers/EventHandler.h"
+#include "ThePEG/Utilities/Throw.h"
+#include "ShowerTree.h"
+#include "ShowerProgenitor.h"
+#include "KinematicsReconstructor.h"
+#include "PartnerFinder.h"
+#include "MECorrectionBase.h"
+#include "ThePEG/Handlers/XComb.h"
+
+using namespace Herwig;
+
+IBPtr Evolver::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr Evolver::fullclone() const {
+ return new_ptr(*this);
+}
+
+void Evolver::persistentOutput(PersistentOStream & os) const {
+ os << _model << _splittingGenerator << _maxtry
+ << _meCorrMode << _hardVetoMode << _hardVetoRead << _PHtopveto << _limitEmissions
+ << ounit(_iptrms,GeV) << _beta << ounit(_gamma,GeV) << ounit(_iptmax,GeV) << _vetoes ;
+
+
+}
+
+void Evolver::persistentInput(PersistentIStream & is, int) {
+ is >> _model >> _splittingGenerator >> _maxtry
+ >> _meCorrMode >> _hardVetoMode >> _hardVetoRead >> _PHtopveto >> _limitEmissions
+ >> iunit(_iptrms,GeV) >> _beta >> iunit(_gamma,GeV) >> iunit(_iptmax,GeV) >> _vetoes ;
+
+
+}
+
+void Evolver::doinitrun() {
+ Interfaced::doinitrun();
+ for(unsigned int ix=0;ix<showerModel()->meCorrections().size();++ix) {
+ showerModel()->meCorrections()[ix]->evolver(this);
+ }
+}
+
+ClassDescription<Evolver> Evolver::initEvolver;
+// Definition of the static class description member.
+
+void Evolver::Init() {
+
+ static ClassDocumentation<Evolver> documentation
+ ("This class is responsible for carrying out the showering,",
+ "including the kinematics reconstruction, in a given scale range.");
+
+ static Reference<Evolver,SplittingGenerator>
+ interfaceSplitGen("SplittingGenerator",
+ "A reference to the SplittingGenerator object",
+ &Herwig::Evolver::_splittingGenerator,
+ false, false, true, false);
+
+ static Reference<Evolver,ShowerModel> interfaceShowerModel
+ ("ShowerModel",
+ "The pointer to the object which defines the shower evolution model.",
+ &Evolver::_model, false, false, true, false, false);
+
+ static Parameter<Evolver,unsigned int> interfaceMaxTry
+ ("MaxTry",
+ "The maximum number of attempts to generate the shower from a"
+ " particular ShowerTree",
+ &Evolver::_maxtry, 100, 1, 1000,
+ false, false, Interface::limited);
+
+ static Switch<Evolver, unsigned int> ifaceMECorrMode
+ ("MECorrMode",
+ "Choice of the ME Correction Mode",
+ &Evolver::_meCorrMode, 1, false, false);
+ static SwitchOption off
+ (ifaceMECorrMode,"No","MECorrections off", 0);
+ static SwitchOption on
+ (ifaceMECorrMode,"Yes","hard+soft on", 1);
+ static SwitchOption hard
+ (ifaceMECorrMode,"Hard","only hard on", 2);
+ static SwitchOption soft
+ (ifaceMECorrMode,"Soft","only soft on", 3);
+
+ static Switch<Evolver, unsigned int> ifaceHardVetoMode
+ ("HardVetoMode",
+ "Choice of the Hard Veto Mode",
+ &Evolver::_hardVetoMode, 0, false, false);
+ static SwitchOption HVoff
+ (ifaceHardVetoMode,"No","hard vetos off", 0);
+ static SwitchOption HVon
+ (ifaceHardVetoMode,"Yes","hard vetos on", 1);
+ static SwitchOption HVIS
+ (ifaceHardVetoMode,"Initial", "only IS emissions vetoed", 2);
+ static SwitchOption HVFS
+ (ifaceHardVetoMode,"Final","only FS emissions vetoed", 3);
+
+ static Switch<Evolver, unsigned int> ifacePHtopveto
+ ("POWHEGTOPVeto",
+ "Choice of the PHtopVeto",
+ &Evolver::_PHtopveto, 0, false, false);
+ static SwitchOption PHtopvetoOff
+ (ifacePHtopveto,"No","TopVeto off", 0);
+ static SwitchOption PHtopvetoOn
+ (ifacePHtopveto,"Yes","Both top prod+ decay vetoes on", 1);
+ static SwitchOption prodveto
+ (ifacePHtopveto,"Prod","Only top production veto on", 2);
+ static SwitchOption decayveto
+ (ifacePHtopveto,"Decay","Only top decay veto on", 3);
+
+ static Switch<Evolver, unsigned int> ifaceHardVetoRead
+ ("HardVetoScaleSource",
+ "If hard veto scale is to be read",
+ &Evolver::_hardVetoRead, 0, false, false);
+ static SwitchOption HVRcalc
+ (ifaceHardVetoRead,"Calculate","Calculate from hard process", 0);
+ static SwitchOption HVRread
+ (ifaceHardVetoRead,"Read","Read from XComb->lastScale", 1);
+
+ static Parameter<Evolver, Energy> ifaceiptrms
+ ("IntrinsicPtGaussian",
+ "RMS of intrinsic pT of Gaussian distribution:\n"
+ "2*(1-Beta)*exp(-sqr(intrinsicpT/RMS))/sqr(RMS)",
+ &Evolver::_iptrms, GeV, ZERO, ZERO, 1000000.0*GeV,
+ false, false, Interface::limited);
+
+ static Parameter<Evolver, double> ifacebeta
+ ("IntrinsicPtBeta",
+ "Proportion of inverse quadratic distribution in generating intrinsic pT.\n"
+ "(1-Beta) is the proportion of Gaussian distribution",
+ &Evolver::_beta, 0, 0, 1,
+ false, false, Interface::limited);
+
+ static Parameter<Evolver, Energy> ifacegamma
+ ("IntrinsicPtGamma",
+ "Parameter for inverse quadratic:\n"
+ "2*Beta*Gamma/(sqr(Gamma)+sqr(intrinsicpT))",
+ &Evolver::_gamma,GeV, ZERO, ZERO, 100000.0*GeV,
+ false, false, Interface::limited);
+
+ static Parameter<Evolver, Energy> ifaceiptmax
+ ("IntrinsicPtIptmax",
+ "Upper bound on intrinsic pT for inverse quadratic",
+ &Evolver::_iptmax,GeV, ZERO, ZERO, 100000.0*GeV,
+ false, false, Interface::limited);
+
+ static RefVector<Evolver,ShowerVeto> ifaceVetoes
+ ("Vetoes",
+ "The vetoes to be checked during showering",
+ &Evolver::_vetoes, -1,
+ false,false,true,true,false);
+
+ static Switch<Evolver,unsigned int> interfaceLimitEmissions
+ ("LimitEmissions",
+ "Limit the number and type of emissions for testing",
+ &Evolver::_limitEmissions, 0, false, false);
+ static SwitchOption interfaceLimitEmissionsNoLimit
+ (interfaceLimitEmissions,
+ "NoLimit",
+ "Allow an arbitrary number of emissions",
+ 0);
+ static SwitchOption interfaceLimitEmissionsOneInitialStateEmission
+ (interfaceLimitEmissions,
+ "OneInitialStateEmission",
+ "Allow one emission in the initial state and none in the final state",
+ 1);
+ static SwitchOption interfaceLimitEmissionsOneFinalStateEmission
+ (interfaceLimitEmissions,
+ "OneFinalStateEmission",
+ "Allow one emission in the final state and none in the initial state",
+ 2);
+}
+
+void Evolver::generateIntrinsicpT(vector<ShowerProgenitorPtr> particlesToShower) {
+ _intrinsic.clear();
+ if ( !ipTon() || !isISRadiationON() ) return;
+ // don't do anything for the moment for secondary scatters
+ if( !ShowerHandler::currentHandler()->firstInteraction() ) return;
+ // generate intrinsic pT
+ for(unsigned int ix=0;ix<particlesToShower.size();++ix) {
+ // only consider initial-state particles
+ if(particlesToShower[ix]->progenitor()->isFinalState()) continue;
+ if(!particlesToShower[ix]->progenitor()->dataPtr()->coloured()) continue;
+ Energy ipt;
+ if(UseRandom::rnd() > _beta) {
+ ipt=_iptrms*sqrt(-log(UseRandom::rnd()));
+ }
+ else {
+ ipt=_gamma*sqrt(pow(1.+sqr(_iptmax/_gamma), UseRandom::rnd())-1.);
+ }
+ pair<Energy,double> pt = make_pair(ipt,UseRandom::rnd(Constants::twopi));
+ _intrinsic[particlesToShower[ix]] = pt;
+ }
+}
+
+void Evolver::setupMaximumScales(ShowerTreePtr hard,
+ vector<ShowerProgenitorPtr> p) {
+ // find out if hard partonic subprocess.
+ bool isPartonic(false);
+ map<ShowerProgenitorPtr,ShowerParticlePtr>::const_iterator
+ cit = _currenttree->incomingLines().begin();
+ Lorentz5Momentum pcm;
+ for(; cit!=hard->incomingLines().end(); ++cit) {
+ pcm += cit->first->progenitor()->momentum();
+ isPartonic |= cit->first->progenitor()->coloured();
+ }
+ // find maximum pt from hard process, the maximum pt from all outgoing
+ // coloured lines (this is simpler and more general than
+ // 2stu/(s^2+t^2+u^2)). Maximum scale for scattering processes will
+ // be transverse mass.
+ Energy ptmax = -1.0*GeV, pt = ZERO, mass = ZERO, ptest = ZERO;
+ if (!PHtopveto()) {
+ // general case calculate the scale
+ if (!hardVetoXComb()) {
+ // scattering process
+ if(hard->isHard()) {
+ // coloured incoming particles
+ if (isPartonic) {
+ map<ShowerProgenitorPtr,tShowerParticlePtr>::const_iterator
+ cjt = hard->outgoingLines().begin();
+ for(; cjt!=hard->outgoingLines().end(); ++cjt) {
+ if (cjt->first->progenitor()->coloured())
+ ptmax = max(ptmax,cjt->first->progenitor()->momentum().mt());
+ }
+ }
+ if (ptmax < ZERO) ptmax = pcm.m();
+ }
+ // decay, incoming() is the decaying particle.
+ else {
+ ptmax = hard->incomingLines().begin()->first
+ ->progenitor()->momentum().mass();
+ }
+ }
+ // hepeup.SCALUP is written into the lastXComb by the
+ // LesHouchesReader itself - use this by user's choice.
+ // Can be more general than this.
+ else {
+ ptmax = sqrt( ShowerHandler::currentHandler()
+ ->lastXCombPtr()->lastScale() );
+ }
+ }
+// *********************************************************************************
+
+ if (PHtopveto()) {
+
+ map<ShowerProgenitorPtr,tShowerParticlePtr>::const_iterator cjt, ctt, cbt, cet;
+
+ ctt = hard->outgoingLines().begin();
+ //store t and tbar mmt
+ double tmmt[5],pp;
+
+ for(; ctt!=hard->outgoingLines().end(); ++ctt) {
+ tmmt[3]+=ctt->first->progenitor()->momentum().z();
+ tmmt[2]+=ctt->first->progenitor()->momentum().y();
+ tmmt[1]+=ctt->first->progenitor()->momentum().x();
+ tmmt[4]+=ctt->first->progenitor()->momentum().e();
+ }
+
+
+ cet = hard->outgoingLines().begin();
+
+ double Wmmt[5]; // W boson momenta
+
+ for(; cet!=hard->outgoingLines().end(); ++cet) {
+
+ if(fabs(cet->first->progenitor()->id())==11 ||fabs(cet->first->progenitor()->id())==12 ){
+ Wmmt[3]+=cet->first->progenitor()->momentum().z();
+ Wmmt[2]+=cet->first->progenitor()->momentum().y();
+ Wmmt[1]+=cet->first->progenitor()->momentum().x();
+ Wmmt[4]+=cet->first->progenitor()->momentum().e();
+ }}
+ Wmmt[0]=sqrt(pow(Wmmt[4],2)-(pow(Wmmt[3],2)+pow(Wmmt[2],2)+pow(Wmmt[1],2)));
+
+ cjt = hard->outgoingLines().begin();
+ for(; cjt!=hard->outgoingLines().end(); ++cjt) {
+ if (cjt->first->progenitor()->coloured()) {
+ if (cjt->first->progenitor()->id()==21){
+
+ pt = cjt->first->progenitor()->momentum().perp();
+ mass = cjt->first->progenitor()->momentum().m();
+
+ ptest = sqrt(pt*pt);
+
+ if (prodveto()){
+ if (ptest > ptmax) {
+ ptmax = ptest;
+
+ }
+ }
+
+}}
+
+ }
+
+ cbt = hard->outgoingLines().begin();
+ for(; cbt!=hard->outgoingLines().end(); ++cbt) {
+ if (cbt->first->progenitor()->coloured()) {
+
+ if (fabs(cbt->first->progenitor()->id())==5){
+ //if decay there must be a b quark: use that instead
+
+ pp= sqrt(pow(tmmt[3],2)+pow(tmmt[2],2)+pow(tmmt[1],2));
+ tmmt[0] = sqrt(pow(tmmt[4],2)-pow(pp,2));
+ double v = pp/tmmt[4];
+
+ double bmmt[5]; // bottom momenta
+ bmmt[3]=cbt->first->progenitor()->momentum().z();
+ bmmt[2]=cbt->first->progenitor()->momentum().y();
+ bmmt[1]=cbt->first->progenitor()->momentum().x();
+ bmmt[4]=sqrt(pow(bmmt[3],2)+pow(bmmt[2],2)+pow(bmmt[1],2));
+ //Transform to top rest frame
+ bmmt[3] = (bmmt[3]*tmmt[3]+bmmt[2]*tmmt[2]+bmmt[1]*tmmt[1])/pp;
+ bmmt[4]=1./sqrt(1.-pow(v,2))*(bmmt[4]-v*bmmt[3]);
+ Wmmt[3]=(Wmmt[3]*tmmt[3]+Wmmt[1]*tmmt[1]+Wmmt[2]*tmmt[2])/pp;
+ Wmmt[4]=1./sqrt(1.-pow(v,2))*(Wmmt[4]-v*Wmmt[3]);
+
+ double x1 = 2.*Wmmt[4]/tmmt[0];
+ double a =pow(Wmmt[0]/tmmt[0],2);
+ if (x1-a > 1.) {x1=1.+a-0.00001;}
+ double x3 = 2.-x1-2.*bmmt[4]/tmmt[0];
+
+ pt =sqrt(pow(tmmt[0],2)*(1.-x1+a)*(x1-a+x3*(2.-x1)-pow(x3,2)-1.)/(pow(x1,2)-4.*a));
+ if (decayveto()) {
+ ptmax = pt;}
+
+ }}
+
+ }
+
+ }
+ // *********************************************************************************
+
+ // set maxHardPt for all progenitors. For partonic processes this
+ // is now the max pt in the FS, for non-partonic processes or
+ // processes with no coloured FS the invariant mass of the IS
+ vector<ShowerProgenitorPtr>::const_iterator ckt = p.begin();
+ for (; ckt != p.end(); ckt++) (*ckt)->maxHardPt(ptmax);
+}
+
+void Evolver::showerHardProcess(ShowerTreePtr hard) {
+ // set the current tree
+ currentTree(hard);
+ // zero number of emissions
+ _nis = _nfs = 0;
+ // extract particles to shower
+ vector<ShowerProgenitorPtr> particlesToShower=setupShower(true);
+ // setup the maximum scales for the shower, given by the hard process
+ if (hardVetoOn())
+ setupMaximumScales(_currenttree, particlesToShower);
+ // generate the intrinsic p_T once and for all
+ generateIntrinsicpT(particlesToShower);
+ unsigned int ntry(0);
+ do {
+ // clear results of last attempt
+ if(ntry!=0) {
+ currentTree()->clear();
+ setColourPartners(true);
+ _nis = 0;
+ _nfs = 0;
+ }
+ // generate the shower
+ // pick random starting point
+ unsigned int istart=UseRandom::irnd(particlesToShower.size());
+ unsigned int istop = particlesToShower.size();
+ // loop over particles with random starting point
+ for(unsigned int ix=istart;ix<=istop;++ix) {
+ if(ix==particlesToShower.size()) {
+ if(istart!=0) {
+ istop = istart-1;
+ ix=0;
+ }
+ else break;
+ }
+ // set the progenitor
+ _progenitor=particlesToShower[ix];
+ // initial-state
+ if(!_progenitor->progenitor()->isFinalState()) {
+ if(!isISRadiationON()) continue;
+ // get the PDF
+ setBeamParticle(_progenitor->beam());
+ assert(beamParticle());
+ // perform the shower
+ // set the beam particle
+ tPPtr beamparticle=_progenitor->original();
+ if(!beamparticle->parents().empty())
+ beamparticle=beamparticle->parents()[0];
+ // generate the shower
+ _progenitor->hasEmitted(startSpaceLikeShower(beamparticle));
+ }
+ // final-state
+ else {
+ if(!isFSRadiationON()) continue;
+ // perform shower
+ _progenitor->hasEmitted(startTimeLikeShower());
+ }
+ }
+ }
+ while(!_model->kinematicsReconstructor()->reconstructHardJets(hard,_intrinsic)&&
+ _maxtry>++ntry);
+ if(_maxtry==ntry) throw ShowerHandler::ShowerTriesVeto(ntry);
+ // the tree has now showered
+ _currenttree->hasShowered(true);
+}
+
+void Evolver::hardMatrixElementCorrection() {
+ // set me correction to null pointer
+ _currentme=MECorrectionPtr();
+ // set the initial enhancement factors for the soft correction
+ _initialenhance=1.;
+ _finalenhance =1.;
+ // if hard matrix element switched off return
+ if(!MECOn()) return;
+ // see if there is an appropriate matrix element correction
+ for(unsigned int ix=0;ix<showerModel()->meCorrections().size();++ix) {
+ double initial,final;
+ if(!showerModel()->meCorrections()[ix]->canHandle(_currenttree,
+ initial,final,this)) continue;
+ if(_currentme) {
+ ostringstream output;
+ output << "There is more than one possible matrix"
+ << "element which could be applied for ";
+ map<ShowerProgenitorPtr,ShowerParticlePtr>::const_iterator cit;
+ for(cit=_currenttree->incomingLines().begin();
+ cit!=_currenttree->incomingLines().end();++cit)
+ {output << cit->first->progenitor()->PDGName() << " ";}
+ output << " -> ";
+ map<ShowerProgenitorPtr,tShowerParticlePtr>::const_iterator cjt;
+ for(cjt=_currenttree->outgoingLines().begin();
+ cjt!=_currenttree->outgoingLines().end();++cjt)
+ {output << cjt->first->progenitor()->PDGName() << " ";}
+ output << "in Evolver::hardMatrixElementCorrection()\n";
+ throw Exception() << output << Exception::runerror;
+ }
+ else {
+ _currentme=showerModel()->meCorrections()[ix];
+ _initialenhance = initial;
+ _finalenhance = final;
+ }
+ }
+ // now apply the hard correction
+ if(_currentme && hardMEC())
+ _currentme->applyHardMatrixElementCorrection(_currenttree);
+}
+
+bool Evolver::timeLikeShower(tShowerParticlePtr particle) {
+ // don't do anything if not needed
+ if(_limitEmissions == 1 || ( _limitEmissions == 2 && _nfs != 0) ) return false;
+ // generate the emission
+ Branching fb;
+ while (true) {
+ fb=_splittingGenerator->chooseForwardBranching(*particle,_finalenhance);
+
+ // no emission return
+ if(!fb.kinematics) return false;
+ // if emission OK break
+ if(!timeLikeVetoed(fb,particle)) break;
+ // otherwise reset scale and continue
+ particle->setEvolutionScale(fb.kinematics->scale());
+ }
+ // has emitted
+ // Assign the shower kinematics to the emitting particle.
+ particle->setShowerKinematics(fb.kinematics);
+ // Assign the splitting function to the emitting particle.
+ // For the time being we are considering only 1->2 branching
+ // Create the ShowerParticle objects for the two children of
+ // the emitting particle; set the parent/child relationship
+ // if same as definition create particles, otherwise create cc
+ tcPDPtr pdata[2];
+ for(unsigned int ix=0;ix<2;++ix) pdata[ix]=getParticleData(fb.ids[ix+1]);
+ if(particle->id()!=fb.ids[0]) {
+ for(unsigned int ix=0;ix<2;++ix) {
+ tPDPtr cc(pdata[ix]->CC());
+ if(cc) pdata[ix]=cc;
+ }
+ }
+ ShowerParticleVector theChildren;
+ theChildren.push_back(new_ptr(ShowerParticle(pdata[0],true)));
+ theChildren.push_back(new_ptr(ShowerParticle(pdata[1],true)));
+ // update the children
+ particle->showerKinematics()->updateChildren(particle, theChildren);
+ // update the history if needed
+ if(particle==_currenttree->getFinalStateShowerProduct(_progenitor))
+ _currenttree->updateFinalStateShowerProduct(_progenitor,
+ particle,theChildren);
+ _currenttree->addFinalStateBranching(particle,theChildren);
+ // update number of emissions
+ ++_nfs;
+ if(_limitEmissions!=0) return true;
+ // shower the first particle
+ timeLikeShower(theChildren[0]);
+ // shower the second particle
+ timeLikeShower(theChildren[1]);
+ // branching has happened
+ return true;
+}
+
+bool
+Evolver::spaceLikeShower(tShowerParticlePtr particle, PPtr beam) {
+ // don't do anything if not needed
+ if(_limitEmissions == 2 ||
+ ( _limitEmissions == 1 && _nis != 0 ) ) return false;
+ Branching bb;
+ // generate branching
+ while (true) {
+ bb=_splittingGenerator->chooseBackwardBranching(*particle,beam,
+ _initialenhance,_beam);
+ // return if no emission
+ if(!bb.kinematics) return false;
+ // if not vetoed break
+ if(!spaceLikeVetoed(bb,particle)) break;
+ // otherwise reset scale and continue
+ particle->setEvolutionScale(bb.kinematics->scale());
+ }
+ // assign the splitting function and shower kinematics
+ particle->setShowerKinematics(bb.kinematics);
+ // For the time being we are considering only 1->2 branching
+ // particles as in Sudakov form factor
+ tcPDPtr part[2]={getParticleData(bb.ids[0]),
+ getParticleData(bb.ids[2])};
+ if(particle->id()!=bb.ids[1]) {
+ if(part[0]->CC()) part[0]=part[0]->CC();
+ if(part[1]->CC()) part[1]=part[1]->CC();
+ }
+ // Now create the actual particles, make the otherChild a final state
+ // particle, while the newParent is not
+ ShowerParticlePtr newParent=new_ptr(ShowerParticle(part[0],false));
+ ShowerParticlePtr otherChild = new_ptr(ShowerParticle(part[1],true,true));
+ ShowerParticleVector theChildren;
+ theChildren.push_back(particle);
+ theChildren.push_back(otherChild);
+ particle->showerKinematics()->updateParent(newParent, theChildren);
+ // update the history if needed
+ _currenttree->updateInitialStateShowerProduct(_progenitor,newParent);
+ _currenttree->addInitialStateBranching(particle,newParent,otherChild);
+ // for the reconstruction of kinematics, parent/child
+ // relationships are according to the branching process:
+ // now continue the shower
+ ++_nis;
+ bool emitted = _limitEmissions==0 ? spaceLikeShower(newParent,beam) : false;
+ // now reconstruct the momentum
+ if(!emitted) {
+ if(_intrinsic.find(_progenitor)==_intrinsic.end()) {
+ bb.kinematics->updateLast(newParent,ZERO,ZERO);
+ }
+ else {
+ pair<Energy,double> kt=_intrinsic[_progenitor];
+ bb.kinematics->updateLast(newParent,
+ kt.first*cos(kt.second),
+ kt.first*sin(kt.second));
+ }
+ }
+ particle->showerKinematics()->updateChildren(newParent, theChildren);
+ if(_limitEmissions!=0) return true;
+ // perform the shower of the final-state particle
+ timeLikeShower(otherChild);
+ // return the emitted
+ return true;
+}
+
+void Evolver::showerDecay(ShowerTreePtr decay) {
+ // set the ShowerTree to be showered
+ currentTree(decay);
+ // extract particles to be shower, set scales and perform hard matrix element
+ // correction
+ vector<ShowerProgenitorPtr> particlesToShower=setupShower(false);
+ setupMaximumScales(_currenttree, particlesToShower);
+ // compute the minimum mass of the final-state
+ Energy minmass(ZERO);
+ for(unsigned int ix=0;ix<particlesToShower.size();++ix) {
+ if(particlesToShower[ix]->progenitor()->isFinalState())
+ minmass+=particlesToShower[ix]->progenitor()->mass();
+ }
+ // main showering loop
+ unsigned int ntry(0);
+ do {
+ // clear results of last attempt
+ if(ntry!=0) {
+ _currenttree->clear();
+ setColourPartners(false);
+ }
+ unsigned int istart=UseRandom::irnd(particlesToShower.size());
+ unsigned int istop = particlesToShower.size();
+ // loop over particles with random starting point
+ for(unsigned int ix=istart;ix<=istop;++ix) {
+ if(ix==particlesToShower.size()) {
+ if(istart!=0) {
+ istop = istart-1;
+ ix=0;
+ }
+ else break;
+ }
+ // extract the progenitor
+ _progenitor=particlesToShower[ix];
+ // final-state radiation
+ if(_progenitor->progenitor()->isFinalState()) {
+ if(!isFSRadiationON()) continue;
+ // perform shower
+ _progenitor->hasEmitted(startTimeLikeShower());
+ }
+ // initial-state radiation
+ else {
+ if(!isISRadiationON()) continue;
+ // perform shower
+ // set the scales correctly. The current scale is the maximum scale for
+ // emission not the starting scale
+ Energy maxscale=_progenitor->progenitor()->evolutionScale();
+ Energy startScale=_progenitor->progenitor()->mass();
+ _progenitor->progenitor()->setEvolutionScale(startScale);
+ // perform the shower
+ _progenitor->hasEmitted(spaceLikeDecayShower(_progenitor->progenitor(),
+ maxscale,minmass));
+ }
+ }
+ }
+ while(!showerModel()->kinematicsReconstructor()->reconstructDecayJets(decay)&&
+ maximumTries()>++ntry);
+ if(maximumTries()==ntry) throw Exception() << "Failed to generate the shower after "
+ << ntry << " attempts in Evolver::showerDecay()"
+ << Exception::eventerror;
+ // tree has now showered
+ _currenttree->hasShowered(true);
+}
+
+bool Evolver::spaceLikeDecayShower(tShowerParticlePtr particle,
+ Energy maxscale,
+ Energy minmass) {
+ Branching fb;
+ while (true) {
+ fb=_splittingGenerator->chooseDecayBranching(*particle,maxscale,minmass,
+ _initialenhance);
+ // return if no radiation
+ if(!fb.kinematics) return false;
+ // if not vetoed break
+ if(!spaceLikeDecayVetoed(fb,particle)) break;
+ // otherwise reset scale and continue
+ particle->setEvolutionScale(fb.kinematics->scale());
+ }
+ // has emitted
+ // Assign the shower kinematics to the emitting particle.
+ particle->setShowerKinematics(fb.kinematics);
+ // For the time being we are considering only 1->2 branching
+ // Create the ShowerParticle objects for the two children of
+ // the emitting particle; set the parent/child relationship
+ // if same as definition create particles, otherwise create cc
+ tcPDPtr pdata[2];
+ for(unsigned int ix=0;ix<2;++ix) pdata[ix]=getParticleData(fb.ids[ix+1]);
+ if(particle->id()!=fb.ids[0]) {
+ for(unsigned int ix=0;ix<2;++ix) {
+ tPDPtr cc(pdata[ix]->CC());
+ if(cc) pdata[ix]=cc;
+ }
+ }
+ ShowerParticleVector theChildren;
+ theChildren.push_back(new_ptr(ShowerParticle(pdata[0],true)));
+ theChildren.push_back(new_ptr(ShowerParticle(pdata[1],true)));
+ // some code moved to updateChildren
+ particle->showerKinematics()->updateChildren(particle, theChildren);
+ // In the case of splittings which involves coloured particles,
+ // set properly the colour flow of the branching.
+ // update the history if needed
+ _currenttree->updateInitialStateShowerProduct(_progenitor,theChildren[0]);
+ _currenttree->addInitialStateBranching(particle,theChildren[0],theChildren[1]);
+ // shower the first particle
+ spaceLikeDecayShower(theChildren[0],maxscale,minmass);
+ // shower the second particle
+ timeLikeShower(theChildren[1]);
+ // branching has happened
+ return true;
+}
+
+vector<ShowerProgenitorPtr> Evolver::setupShower(bool hard) {
+ // put all the particles into a data structure which has the particles
+ // and the maximum pt for emission from the particle
+ // set the initial colour partners
+ setColourPartners(hard);
+ map<ShowerProgenitorPtr, ShowerParticlePtr>::const_iterator cit;
+ map<ShowerProgenitorPtr,tShowerParticlePtr>::const_iterator cjt;
+ // generate the hard matrix element correction if needed
+ hardMatrixElementCorrection();
+ // get the particles to be showered
+ vector<ShowerProgenitorPtr> particlesToShower;
+ // incoming particles
+ for(cit=_currenttree->incomingLines().begin();
+ cit!=_currenttree->incomingLines().end();++cit)
+ particlesToShower.push_back((*cit).first);
+ // outgoing particles
+ for(cjt=_currenttree->outgoingLines().begin();
+ cjt!=_currenttree->outgoingLines().end();++cjt)
+ particlesToShower.push_back(((*cjt).first));
+ // remake the colour partners if needed
+ if(_currenttree->hardMatrixElementCorrection()) {
+ setColourPartners(hard);
+ _currenttree->resetShowerProducts();
+ }
+ return particlesToShower;
+}
+
+void Evolver::setColourPartners(bool hard) {
+ vector<ShowerParticlePtr> particles;
+ map<ShowerProgenitorPtr, ShowerParticlePtr>::const_iterator cit;
+ map<ShowerProgenitorPtr,tShowerParticlePtr>::const_iterator cjt;
+ for(cit=_currenttree->incomingLines().begin();
+ cit!=_currenttree->incomingLines().end();++cit)
+ particles.push_back(cit->first->progenitor());
+ assert((particles.size()==1&&!hard)||(particles.size()==2&&hard));
+ // outgoing particles
+ for(cjt=_currenttree->outgoingLines().begin();
+ cjt!=_currenttree->outgoingLines().end();++cjt)
+ particles.push_back(cjt->first->progenitor());
+ // Set the initial evolution scales
+ showerModel()->partnerFinder()->setInitialEvolutionScales(particles,!hard);
+}
+
+bool Evolver::startTimeLikeShower() {
+ return timeLikeShower(_progenitor->progenitor());
+}
+
+bool Evolver::startSpaceLikeShower(PPtr parent) {
+ return spaceLikeShower(_progenitor->progenitor(),parent);
+}
+
+bool Evolver::timeLikeVetoed(const Branching & fb,
+ ShowerParticlePtr particle) {
+
+ // check whether emission was harder than largest pt of hard subprocess
+ if (hardVetoFS() && fb.kinematics->pT() > _progenitor->maxHardPt())
+ return true;
+ // soft matrix elementr correction veto
+ if(_currentme && softMEC() &&
+ _currentme->softMatrixElementVeto(_progenitor,particle,fb))
+ return true;
+ // veto on maximum pt
+ if(fb.kinematics->pT()>_progenitor->maximumpT())
+ return true;
+ // general vetos
+ if (fb.kinematics && !_vetoes.empty()) {
+
+ bool vetoed=false;
+ for (vector<ShowerVetoPtr>::iterator v = _vetoes.begin();
+ v != _vetoes.end(); ++v) {
+ bool test = (**v).vetoTimeLike(_progenitor,particle,fb);
+ switch((**v).vetoType()) {
+ case ShowerVeto::Emission:
+ vetoed |= test;
+ break;
+ case ShowerVeto::Shower:
+ if(test) throw VetoShower();
+ break;
+ case ShowerVeto::Event:
+ if(test) throw Veto();
+ break;
+ }
+ }
+ if(vetoed) return true;
+ }
+ return false;
+}
+
+bool Evolver::spaceLikeVetoed(const Branching & bb,ShowerParticlePtr particle) {
+ // check whether emission was harder than largest pt of hard subprocess
+ if (hardVetoIS() && bb.kinematics->pT() > _progenitor->maxHardPt())
+ return true;
+ // apply the soft correction
+ if(_currentme && softMEC() &&
+ _currentme->softMatrixElementVeto(_progenitor,particle,bb))
+ return true;
+ // check vs max pt for the shower
+ if(bb.kinematics->pT()>_progenitor->maximumpT())
+ return true;
+ // the more general vetos
+ if (!_vetoes.empty()) {
+ bool vetoed=false;
+ for (vector<ShowerVetoPtr>::iterator v = _vetoes.begin();
+ v != _vetoes.end(); ++v) {
+ bool test = (**v).vetoSpaceLike(_progenitor,particle,bb);
+ switch ((**v).vetoType()) {
+ case ShowerVeto::Emission:
+ vetoed |= test;
+ break;
+ case ShowerVeto::Shower:
+ if(test) throw VetoShower();
+ break;
+ case ShowerVeto::Event:
+ if(test) throw Veto();
+ break;
+ }
+ }
+ if (vetoed) return true;
+ }
+ return false;
+}
+
+bool Evolver::spaceLikeDecayVetoed(const Branching & fb,
+ ShowerParticlePtr particle) {
+ // apply the soft correction
+ if(_currentme && softMEC() &&
+ _currentme->softMatrixElementVeto(_progenitor,particle,fb))
+ return true;
+ // veto on hardest pt in the shower
+ if(fb.kinematics->pT()>_progenitor->maximumpT())
+ return true;
+ // general vetos
+ if (!_vetoes.empty()) {
+ bool vetoed=false;
+ for (vector<ShowerVetoPtr>::iterator v = _vetoes.begin();
+ v != _vetoes.end(); ++v) {
+ bool test = (**v).vetoSpaceLike(_progenitor,particle,fb);
+ switch((**v).vetoType()) {
+ case ShowerVeto::Emission:
+ vetoed |= test;
+ break;
+ case ShowerVeto::Shower:
+ if(test) throw VetoShower();
+ break;
+ case ShowerVeto::Event:
+ if(test) throw Veto();
+ break;
+ }
+ if (vetoed) return true;
+ }
+ }
+ return false;
+}
diff --git a/Contrib/MCPWNLO/PWInstallFiles/Evolver.fh b/Contrib/MCPWNLO/PWInstallFiles/Evolver.fh
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/PWInstallFiles/Evolver.fh
@@ -0,0 +1,22 @@
+// -*- C++ -*-
+//
+// This is the forward declaration of the Evolver class.
+//
+#ifndef HERWIG_Evolver_FH
+#define HERWIG_Evolver_FH
+
+#include "ThePEG/Config/Pointers.h"
+
+namespace Herwig {
+
+class Evolver;
+
+}
+
+namespace ThePEG {
+
+ThePEG_DECLARE_POINTERS(Herwig::Evolver,EvolverPtr);
+
+}
+
+#endif
diff --git a/Contrib/MCPWNLO/PWInstallFiles/Evolver.h b/Contrib/MCPWNLO/PWInstallFiles/Evolver.h
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/PWInstallFiles/Evolver.h
@@ -0,0 +1,595 @@
+// -*- C++ -*-
+//
+// Evolver.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_Evolver_H
+#define HERWIG_Evolver_H
+//
+// This is the declaration of the Evolver class.
+//
+
+#include "ThePEG/Interface/Interfaced.h"
+#include "Herwig++/Shower/SplittingFunctions/SplittingGenerator.h"
+#include "ShowerModel.h"
+#include "ThePEG/PDF/BeamParticleData.h"
+#include "ShowerTree.h"
+#include "MECorrectionBase.fh"
+#include "ShowerProgenitor.fh"
+#include "Herwig++/Shower/ShowerHandler.fh"
+#include "ShowerVeto.h"
+#include "Evolver.fh"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/** \ingroup Shower
+ * Here is the documentation of the Evolver class.
+ *
+ * @see \ref EvolverInterfaces "The interfaces"
+ * defined for Evolver.
+ */
+class Evolver: public Interfaced {
+
+/**
+ * The ShowerHandler is a friend to set some parameters at initialisation
+ */
+friend class ShowerHandler;
+
+/**
+ * The MECorrectionBase class is a friend to access some protected
+ * member functions to set the radiation enhancement factors
+ */
+friend class MECorrectionBase;
+
+public:
+
+ /**
+ * Default Constructor
+ */
+ Evolver() : _maxtry(100), _meCorrMode(1), _hardVetoMode(1),
+ _hardVetoRead(0),_PHtopveto(0),
+ _iptrms(ZERO), _beta(0.), _gamma(ZERO), _iptmax(),
+ _limitEmissions(0), _initialenhance(1.), _finalenhance(1.) {}
+
+ /**
+ * Member to perform the shower
+ */
+ //@{
+ /**
+ * Perform the shower of the hard process
+ */
+ virtual void showerHardProcess(ShowerTreePtr);
+
+ /**
+ * Perform the shower of a decay
+ */
+ virtual void showerDecay(ShowerTreePtr);
+ //@}
+
+ /**
+ * Access to the flags and shower variables
+ */
+ //@{
+ /**
+ * Is there any showering switched on
+ */
+ bool showeringON() const { return isISRadiationON() || isFSRadiationON(); }
+
+ /**
+ * It returns true/false if the initial-state radiation is on/off.
+ */
+ bool isISRadiationON() const { return _splittingGenerator->isISRadiationON(); }
+
+ /**
+ * It returns true/false if the final-state radiation is on/off.
+ */
+ bool isFSRadiationON() const { return _splittingGenerator->isFSRadiationON(); }
+
+ /**
+ * Get the ShowerModel
+ */
+ ShowerModelPtr showerModel() const {return _model;}
+
+ /**
+ * Get the SplittingGenerator
+ */
+ tSplittingGeneratorPtr splittingGenerator() const { return _splittingGenerator; }
+ //@}
+
+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:
+
+ /**
+ * Generate the hard matrix element correction
+ */
+ virtual void hardMatrixElementCorrection();
+
+ /**
+ * Extract the particles to be showered, set the evolution scales
+ * and apply the hard matrix element correction
+ * @param hard Whether this is a hard process or decay
+ * @return The particles to be showered
+ */
+ virtual vector<ShowerProgenitorPtr> setupShower(bool hard);
+
+ /**
+ * set the colour partners
+ */
+ virtual void setColourPartners(bool hard);
+
+ /**
+ * Methods to perform the evolution of an individual particle, including
+ * recursive calling on the products
+ */
+ //@{
+ /**
+ * It does the forward evolution of the time-like input particle
+ * (and recursively for all its radiation products).
+ * accepting only emissions which conforms to the showerVariables
+ * and soft matrix element correction pointed by meCorrectionPtr.
+ * If at least one emission has occurred then the method returns true.
+ * @param particle The particle to be showered
+ */
+ virtual bool timeLikeShower(tShowerParticlePtr particle);
+
+ /**
+ * It does the backward evolution of the space-like input particle
+ * (and recursively for all its time-like radiation products).
+ * accepting only emissions which conforms to the showerVariables.
+ * If at least one emission has occurred then the method returns true
+ * @param particle The particle to be showered
+ * @param beam The beam particle
+ */
+ virtual bool spaceLikeShower(tShowerParticlePtr particle,PPtr beam);
+
+ /**
+ * If does the forward evolution of the input on-shell particle
+ * involved in a decay
+ * (and recursively for all its time-like radiation products).
+ * accepting only emissions which conforms to the showerVariables.
+ * @param particle The particle to be showered
+ * @param maxscale The maximum scale for the shower.
+ * @param minimumMass The minimum mass of the final-state system
+ */
+ virtual bool spaceLikeDecayShower(tShowerParticlePtr particle,
+ Energy maxscale,
+ Energy minimumMass);
+ //@}
+
+ /**
+ * Switches for matrix element corrections
+ */
+ //@{
+ /**
+ * Any ME correction?
+ */
+ bool MECOn() const { return _meCorrMode > 0; }
+
+ /**
+ * Any hard ME correction?
+ */
+ bool hardMEC() const { return _meCorrMode == 1 || _meCorrMode == 2; }
+
+ /**
+ * Any soft ME correction?
+ */
+ bool softMEC() const { return _meCorrMode == 1 || _meCorrMode > 2; }
+
+ /* Switch for top veto
+ *
+ * Any POWHEGtopvetoes?
+ */
+
+ bool PHtopveto() const { return _PHtopveto > 0;}
+
+ bool prodveto() const {return _PHtopveto == 1 || _PHtopveto == 2;}
+
+ bool decayveto() const {return _PHtopveto == 1 || _PHtopveto > 2;}
+
+ //@}
+
+ /**
+ * Switch for intrinsic pT
+ */
+ //@{
+ /**
+ * Any intrinsic pT?
+ */
+ bool ipTon() const {
+ return _iptrms != ZERO || ( _beta == 1.0 && _gamma != ZERO && _iptmax !=ZERO );
+ }
+ //@}
+
+ /**@name Additional shower vetoes */
+ //@{
+ /**
+ * Insert a veto.
+ */
+ void addVeto (ShowerVetoPtr v) { _vetoes.push_back(v); }
+
+ /**
+ * Remove a veto.
+ */
+ void removeVeto (ShowerVetoPtr v) {
+ vector<ShowerVetoPtr>::iterator vit = find(_vetoes.begin(),_vetoes.end(),v);
+ if (vit != _vetoes.end())
+ _vetoes.erase(vit);
+ }
+
+ //@}
+
+ /**
+ * Switches for vetoing hard emissions
+ */
+ //@{
+ /**
+ * Vetos on?
+ */
+ bool hardVetoOn() const { return _hardVetoMode > 0; }
+
+ /**
+ * veto hard emissions in IS shower?
+ */
+ bool hardVetoIS() const { return _hardVetoMode == 1 || _hardVetoMode == 2; }
+
+ /**
+ * veto hard emissions in FS shower?
+ */
+ bool hardVetoFS() const { return _hardVetoMode == 1 || _hardVetoMode > 2; }
+
+ /**
+ * veto hard emissions according to lastScale from XComb?
+ */
+ bool hardVetoXComb() const {return (_hardVetoRead == 1);}
+ //@}
+
+ /**
+ * Enhancement factors for radiation needed to generate the soft matrix
+ * element correction.
+ */
+ //@{
+ /**
+ * Access the enhancement factor for initial-state radiation
+ */
+ double initialStateRadiationEnhancementFactor() const { return _initialenhance; }
+
+ /**
+ * Access the enhancement factor for final-state radiation
+ */
+ double finalStateRadiationEnhancementFactor() const { return _finalenhance; }
+
+ /**
+ * Set the enhancement factor for initial-state radiation
+ */
+ void initialStateRadiationEnhancementFactor(double in) { _initialenhance=in; }
+
+ /**
+ * Set the enhancement factor for final-state radiation
+ */
+ void finalStateRadiationEnhancementFactor(double in) { _finalenhance=in; }
+
+ //@}
+
+ /**
+ * Access/set the beam particle for the current initial-state shower
+ */
+ //@{
+ /**
+ * Get the beam particle data
+ */
+ Ptr<BeamParticleData>::const_pointer beamParticle() const { return _beam; }
+
+ /**
+ * Set the beam particle data
+ */
+ void setBeamParticle(Ptr<BeamParticleData>::const_pointer in) { _beam=in; }
+ //@}
+
+ /**
+ * Set/Get the current tree being evolverd for inheriting classes
+ */
+ //@{
+ /**
+ * Get the tree
+ */
+ tShowerTreePtr currentTree() { return _currenttree; }
+
+ /**
+ * Set the tree
+ */
+ void currentTree(tShowerTreePtr tree) { _currenttree=tree; }
+
+ //@}
+
+ /**
+ * Access the maximum number of attempts to generate the shower
+ */
+ unsigned int maximumTries() const { return _maxtry; }
+
+ /**
+ * Set/Get the ShowerProgenitor for the current shower
+ */
+ //@{
+ /**
+ * Access the progenitor
+ */
+ ShowerProgenitorPtr progenitor() { return _progenitor; }
+
+ /**
+ * Set the progenitor
+ */
+ void progenitor(ShowerProgenitorPtr in) { _progenitor=in; }
+ //@}
+
+ /**
+ * Calculate the intrinsic \f$p_T\f$.
+ */
+ virtual void generateIntrinsicpT(vector<ShowerProgenitorPtr>);
+
+ /**
+ * Access to the intrinsic \f$p_T\f$ for inheriting classes
+ */
+ map<tShowerProgenitorPtr,pair<Energy,double> > & intrinsicpT() { return _intrinsic; }
+
+ /**
+ * find the maximally allowed pt acc to the hard process.
+ */
+ void setupMaximumScales(ShowerTreePtr, vector<ShowerProgenitorPtr>);
+
+protected:
+
+ /**
+ * Start the shower of a timelike particle
+ */
+ virtual bool startTimeLikeShower();
+
+ /**
+ * Start the shower of a spacelike particle
+ */
+ virtual bool startSpaceLikeShower(PPtr);
+
+ /**
+ * Vetos for the timelike shower
+ */
+ virtual bool timeLikeVetoed(const Branching &,ShowerParticlePtr);
+
+ /**
+ * Vetos for the spacelike shower
+ */
+ virtual bool spaceLikeVetoed(const Branching &,ShowerParticlePtr);
+
+ /**
+ * Vetos for the spacelike shower
+ */
+ virtual bool spaceLikeDecayVetoed(const Branching &,ShowerParticlePtr);
+
+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:
+
+ /** @name Standard Interfaced functions. */
+ //@{
+ /**
+ * Initialize this object. Called in the run phase just before
+ * a run begins.
+ */
+ virtual void doinitrun();
+ //@}
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static ClassDescription<Evolver> initEvolver;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ Evolver & operator=(const Evolver &);
+
+private:
+
+ /**
+ * Pointer to the model for the shower evolution model
+ */
+ ShowerModelPtr _model;
+
+ /**
+ * Pointer to the splitting generator
+ */
+ SplittingGeneratorPtr _splittingGenerator;
+
+ /**
+ * Maximum number of tries to generate the shower of a particular tree
+ */
+ unsigned int _maxtry;
+
+ /**
+ * Matrix element correction switch
+ */
+ unsigned int _meCorrMode;
+
+ /**
+ * Hard emission veto switch
+ */
+ unsigned int _hardVetoMode;
+
+ /**
+ * Hard veto to be read switch
+ */
+ unsigned int _hardVetoRead;
+
+ /**
+ * POWHEGveto switch
+ */
+ unsigned int _PHtopveto;
+
+ /**
+ * rms intrinsic pT of Gaussian distribution
+ */
+ Energy _iptrms;
+
+ /**
+ * Proportion of inverse quadratic intrinsic pT distribution
+ */
+ double _beta;
+
+ /**
+ * Parameter for inverse quadratic: 2*Beta*Gamma/(sqr(Gamma)+sqr(intrinsicpT))
+ */
+ Energy _gamma;
+
+ /**
+ * Upper bound on intrinsic pT for inverse quadratic
+ */
+ Energy _iptmax;
+
+ /**
+ * Limit the number of emissions for testing
+ */
+ unsigned int _limitEmissions;
+
+ /**
+ * The progenitor of the current shower
+ */
+ ShowerProgenitorPtr _progenitor;
+
+ /**
+ * Matrix element correction used for the current shower
+ */
+ MECorrectionPtr _currentme;
+
+ /**
+ * The ShowerTree currently being showered
+ */
+ ShowerTreePtr _currenttree;
+
+ /**
+ * Radiation enhancement factors for use with the veto algorithm
+ * if needed by the soft matrix element correction
+ */
+ //@{
+ /**
+ * Enhancement factor for initial-state radiation
+ */
+ double _initialenhance;
+
+ /**
+ * Enhancement factor for final-state radiation
+ */
+ double _finalenhance;
+ //@}
+
+ /**
+ * The beam particle data for the current initial-state shower
+ */
+ Ptr<BeamParticleData>::const_pointer _beam;
+
+ /**
+ * Storage of the intrinsic \f$p_t\f$ of the particles
+ */
+ map<tShowerProgenitorPtr,pair<Energy,double> > _intrinsic;
+
+ /**
+ * Vetoes
+ */
+ vector<ShowerVetoPtr> _vetoes;
+
+ /**
+ * number of IS emissions
+ */
+ unsigned int _nis;
+
+ /**
+ * Number of FS emissions
+ */
+ unsigned int _nfs;
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of Evolver. */
+template <>
+struct BaseClassTrait<Herwig::Evolver,1> {
+ /** Typedef of the first base class of Evolver. */
+ typedef Interfaced NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the Evolver class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::Evolver>
+ : public ClassTraitsBase<Herwig::Evolver> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::Evolver"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * Evolver is implemented. It may also include several, space-separated,
+ * libraries if the class Evolver 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 "HwShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_Evolver_H */
diff --git a/Contrib/MCPWNLO/PWInstallFiles/PartnerFinder.cc b/Contrib/MCPWNLO/PWInstallFiles/PartnerFinder.cc
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/PWInstallFiles/PartnerFinder.cc
@@ -0,0 +1,298 @@
+// -*- C++ -*-
+//
+// PartnerFinder.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 PartnerFinder class.
+//
+
+#include "PartnerFinder.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/Interface/Parameter.h"
+#include "ThePEG/Interface/Switch.h"
+#include "ThePEG/Repository/EventGenerator.h"
+#include "ThePEG/Persistency/PersistentOStream.h"
+#include "ThePEG/Persistency/PersistentIStream.h"
+#include "ShowerParticle.h"
+#include "ThePEG/Repository/UseRandom.h"
+
+using namespace Herwig;
+
+// some useful functions to avoid using #define
+namespace {
+
+// return bool if final-state particle
+inline bool FS(const tShowerParticlePtr a) {
+ return a->isFinalState();
+}
+
+// return colour line pointer
+inline Ptr<ThePEG::ColourLine>::transient_pointer
+CL(const ShowerParticleVector::const_iterator & a) {
+ return (*a)->colourLine();
+}
+
+inline Ptr<ThePEG::ColourLine>::transient_pointer
+ACL(const ShowerParticleVector::const_iterator & a) {
+ return (*a)->antiColourLine();
+}
+
+}
+
+void PartnerFinder::persistentOutput(PersistentOStream & os) const {
+ os << _approach << _PHpfinder;
+}
+
+void PartnerFinder::persistentInput(PersistentIStream & is, int) {
+ is >> _approach >> _PHpfinder;
+}
+
+AbstractClassDescription<PartnerFinder> PartnerFinder::initPartnerFinder;
+// Definition of the static class description member.
+
+void PartnerFinder::Init() {
+
+ static ClassDocumentation<PartnerFinder> documentation
+ ("This class is responsible for finding the partners for each interaction types ",
+ "and within the evolution scale range specified by the ShowerVariables ",
+ "then to determine the initial evolution scales for each pair of partners.");
+
+ static Parameter<PartnerFinder,int> approach
+ ("Approximation",
+ "This is a test variable to consider the different approaches of "
+ "which colour dipoles of a hard process will shower.",
+ &PartnerFinder::_approach, 0, 1, 0,false,false,false);
+
+ static Switch<PartnerFinder, unsigned int> ifacePHpfinder
+ ("PHPartnerFinder",
+ "Choice of the Partner Finder",
+ &PartnerFinder::_PHpfinder, 0, false, false);
+ static SwitchOption PHpfinderoff
+ (ifacePHpfinder,"No","PHpfinder off", 0);
+ static SwitchOption PHpfinderon
+ (ifacePHpfinder,"Yes","PHpfinder on", 1);
+
+
+}
+
+bool PartnerFinder::setInitialEvolutionScales(const ShowerParticleVector &particles,
+ const bool isDecayCase,
+ const bool setPartners) {
+ int particlenumber = 0;
+
+ // set the partners and the scales
+ if(setPartners) {
+ // Loop over particles and consider only coloured particles which don't
+ // have already their colour partner fixed and that don't have children
+ // (the latter requirement is relaxed in the case isDecayCase is true).
+ // Build a map which has as key one of these particles (i.e. a pointer
+ // to a ShowerParticle object) and as a corresponding value the vector
+ // of all its possible *normal* candidate colour partners, defined as follows:
+ // --- have colour, and no children (this is not required in the case
+ // isDecayCase is true);
+ // --- if both are initial (incoming) state particles, or if both are
+ // final (outgoing) state particles, then both must have the
+ // same (non-null) colourLine() or the same (non-null) antiColourLine();
+ // --- if one is an initial (incoming) state particle and the other is
+ // a final (outgoing) state particle, then the (non-null) colourLine()
+ // of one of them must match the (non-null) antiColourLine() of the other.
+ // Notice that this definition exclude the special case of baryon-violating
+ // processes (as in R-parity Susy), which will show up as particles
+ // without candidate colour partners, and that we will be treated a part later
+ // (this means that no modifications of the following loop is needed!)
+ ShowerParticleVector::const_iterator cit, cjt;
+ for(cit = particles.begin(); cit != particles.end(); ++cit) {
+ if(!(*cit)->data().coloured()) continue;
+ // We now have a coloured particle
+ tShowerParticleVector partners;
+ for(cjt = particles.begin(); cjt != particles.end(); ++cjt) {
+ if(!(*cjt)->data().coloured()||cit==cjt) continue;
+ bool isPartner = false;
+ if(FS(*cit) != FS(*cjt) &&
+ ((CL(cit) && CL(cit)==CL(cjt)) || (ACL(cit) && ACL(cit)==ACL(cjt))))
+ isPartner = true;
+ else if((CL(cit) && CL(cit)==ACL(cjt)) || (ACL(cit) && ACL(cit)==CL(cjt)))
+ isPartner = true;
+ if(isPartner) partners.push_back(*cjt);
+ }
+ if (partners.empty()) {
+ // special for RPV
+ tColinePtr col = CL(cit);
+ if(FS(*cit)&&col&&col->sourceNeighbours().first) {
+ tColinePair cpair = col->sourceNeighbours();
+ for(cjt=particles.begin();cjt!=particles.end();++cjt) {
+ if(( FS(*cjt) && ( CL(cjt) == cpair.first || CL(cjt) == cpair.second))||
+ (!FS(*cjt) && (ACL(cjt) == cpair.first || ACL(cjt) == cpair.second ))) {
+ partners.push_back(*cjt);
+ }
+ }
+ }
+ else if(col&&col->sinkNeighbours().first) {
+ tColinePair cpair = col->sinkNeighbours();
+ for(cjt=particles.begin();cjt!=particles.end();++cjt) {
+ if(( FS(*cjt) && (ACL(cjt) == cpair.first || ACL(cjt) == cpair.second))||
+ (!FS(*cjt) && ( CL(cjt) == cpair.first || CL(cjt) == cpair.second))) {
+ partners.push_back(*cjt);
+ }
+ }
+ }
+ col = ACL(cit);
+ if(FS(*cit)&&col&&col->sinkNeighbours().first) {
+ tColinePair cpair = col->sinkNeighbours();
+ for(cjt=particles.begin();cjt!=particles.end();++cjt) {
+ if(( FS(*cjt) && (ACL(cjt) == cpair.first || ACL(cjt) == cpair.second))||
+ (!FS(*cjt) && ( CL(cjt) == cpair.first || CL(cjt) == cpair.second ))) {
+ partners.push_back(*cjt);
+ }
+ }
+ }
+ else if(col&&col->sourceNeighbours().first) {
+ tColinePair cpair = col->sourceNeighbours();
+ for(cjt=particles.begin();cjt!=particles.end();++cjt) {
+ if(( FS(*cjt) && ( CL(cjt) == cpair.first || CL(cjt) == cpair.second))||
+ (!FS(*cjt) && (ACL(cjt) == cpair.first ||ACL(cjt) == cpair.second))) {
+ partners.push_back(*cjt);
+ }
+ }
+ }
+ if(partners.empty()) {
+ throw Exception() << "`Failed to make colour connections in "
+ << "PartnerFinder::setQCDInitialEvolutionScales"
+ << (**cit)
+ << Exception::eventerror;
+ }
+ }
+ // In the case of more than one candidate colour partners,
+ // our treatment is based on two assumptions:
+ // 1) the choice of which is the colour partner is done
+ // *randomly* between the available candidates.
+ // 2) the choice of which is the colour partner is done
+ // *independently* from each particle: in other words,
+ // if for a particle "i" its selected colour partner is
+ // the particle "j", then the colour partner of "j"
+ // does not have to be necessarily "i".
+
+
+ /**************************************************************************/
+ // int position = UseRandom::irnd(partners.size());
+// pair<Energy,Energy> pairScales =
+// calculateInitialEvolutionScales(ShowerPPair(*cit,partners[position]),
+// isDecayCase);
+ // pair<Energy,Energy> pairScales;
+
+ pair<Energy,Energy> testscale,pairScales(make_pair(1e10*GeV,1e10*GeV));
+ int position(0);
+ int gluoncount = 0;
+ int particlecount = 0;
+ // count the number of gluons in shower tree.
+ bool hardprocess = false;
+ ShowerParticleVector::const_iterator ckt;
+ for(ckt=particles.begin();ckt!=particles.end();++ckt) {
+ if (fabs((**ckt).id()) > 5 && (**ckt).id() != 21) {hardprocess = true;} // dealing with hard process for W, Z or top pair production
+ if ((**ckt).id() == 21){
+ ++gluoncount;
+ }
+ if(fabs((**ckt).id()) < 7 || (**ckt).id() == 21){
+ ++particlecount;}
+}
+ ++particlenumber; //update particle number for showered particles
+
+ cout << "particleinfo" << particlenumber << "\t" << particlecount << endl;
+
+ if (PHpfinder() && hardprocess) {
+
+ for(unsigned int ix=0;ix<partners.size();++ix) {
+ testscale =
+ calculateInitialEvolutionScales(ShowerPPair(*cit,partners[ix]),
+ isDecayCase);
+ if(testscale.first<pairScales.first) {
+ pairScales=testscale;
+ position=ix;
+
+ }
+ }
+ pair<Energy,Energy> testscale2(make_pair(0*GeV,0*GeV));
+
+ //set scale for truncated gluon to larger of the 2 scales.
+
+ if (gluoncount > 1 && partners.size() == 2) {
+ if(particlenumber == particlecount - 1) {
+ for(unsigned int ix=0;ix<partners.size();++ix) {
+ testscale2 =
+ calculateInitialEvolutionScales(ShowerPPair(*cit,partners[ix]),
+ isDecayCase);
+ if(testscale2.first > pairScales.first) {
+ pairScales=testscale2;
+ position=ix;
+ }
+ }}
+ }}
+
+ else {
+
+ position = UseRandom::irnd(partners.size());
+ pairScales =
+ calculateInitialEvolutionScales(ShowerPPair(*cit,partners[position]),
+ isDecayCase);
+ }
+ /**************************************************************************/
+ switch(_approach) {
+ case 0: // Totally random
+ (*cit)->setEvolutionScale(pairScales.first);
+ (*cit)->setPartner(partners[position]);
+ break;
+ case 1: // Partner is also set, if it has already been set, pick 50/50
+ if(!(*cit)->partner() || UseRandom::rndbool()) {
+ (*cit)->setEvolutionScale(pairScales.first);
+ (*cit)->setPartner(partners[position]);
+ }
+ if(!partners[position]->partner() || UseRandom::rndbool()) {
+ partners[position]->setEvolutionScale(pairScales.second);
+ partners[position]->setPartner(*cit);
+ }
+ break;
+ default:
+ exit(2);
+ throw Exception() << "Invalid approach for setting colour partner in"
+ << " PartnerFinder::setQCDInitialEvolutionScale()"
+ << Exception::abortnow;
+ }
+ }
+ }
+ // partners all ready set only do the scales
+ else {
+ for(ShowerParticleVector::const_iterator cit = particles.begin();
+ cit != particles.end(); ++cit) {
+ if(!(**cit).dataPtr()->coloured()) continue;
+ tShowerParticlePtr partner = (**cit).partner();
+ pair<Energy,Energy> pairScales =
+ calculateInitialEvolutionScales(ShowerPPair(*cit,partner),
+ isDecayCase);
+ (*cit)->setEvolutionScale(pairScales.first);
+ }
+ }
+ return true;
+}
+
+pair<Energy,Energy> PartnerFinder::
+calculateInitialEvolutionScales(const ShowerPPair &particlePair,
+ const bool isDecayCase) {
+ bool FS1=FS(particlePair.first),FS2= FS(particlePair.second);
+
+ if(FS1 && FS2)
+ return calculateFinalFinalScales(particlePair);
+ else if(FS1 && !FS2) {
+ ShowerPPair a(particlePair.second, particlePair.first);
+ pair<Energy,Energy> rval = calculateInitialFinalScales(a,isDecayCase);
+ return pair<Energy,Energy>(rval.second,rval.first);
+ }
+ else if(!FS1 &&FS2)
+ return calculateInitialFinalScales(particlePair,isDecayCase);
+ else
+ return calculateInitialInitialScales(particlePair);
+}
diff --git a/Contrib/MCPWNLO/PWInstallFiles/PartnerFinder.fh b/Contrib/MCPWNLO/PWInstallFiles/PartnerFinder.fh
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/PWInstallFiles/PartnerFinder.fh
@@ -0,0 +1,22 @@
+// -*- C++ -*-
+//
+// This is the forward declaration of the PartnerFinder class.
+//
+#ifndef HERWIG_PartnerFinder_FH
+#define HERWIG_PartnerFinder_FH
+
+#include "ThePEG/Config/Pointers.h"
+
+namespace Herwig {
+
+class PartnerFinder;
+
+}
+
+namespace ThePEG {
+
+ThePEG_DECLARE_POINTERS(Herwig::PartnerFinder,PartnerFinderPtr);
+
+}
+
+#endif
diff --git a/Contrib/MCPWNLO/PWInstallFiles/PartnerFinder.h b/Contrib/MCPWNLO/PWInstallFiles/PartnerFinder.h
new file mode 100644
--- /dev/null
+++ b/Contrib/MCPWNLO/PWInstallFiles/PartnerFinder.h
@@ -0,0 +1,219 @@
+// -*- C++ -*-
+//
+// PartnerFinder.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_PartnerFinder_H
+#define HERWIG_PartnerFinder_H
+//
+// This is the declaration of the PartnerFinder class.
+//
+#include "Herwig++/Shower/ShowerConfig.h"
+#include "ThePEG/Interface/Interfaced.h"
+#include "Evolver.fh"
+#include "PartnerFinder.fh"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * typedef of a pair of particle for calculating the evolution scales
+ */
+typedef pair<tShowerParticlePtr,tShowerParticlePtr> ShowerPPair;
+
+/** \ingroup Shower
+ *
+ * This class is responsible of two related tasks:
+ * - it finds the partners
+ * - for each pair of partners (and interaction therefore)
+ * it sets the initial evolution scales of both of them.
+ *
+ * In general the finding of the partners is performed by this class but
+ * the calculation of the initial evolution scales should be implemented
+ * for different shower evolution models in classes inheriting from this one.
+ * Notice that a given particle has, in general, a different partner
+ * for each different interaction; however, given a partner, its
+ * initial evolution scale, Q, is purely a kinematical relationship
+ * between the pair, without dependence on the dynamics (i.e. type of interaction).
+ *
+ * @see \ref PartnerFinderInterfaces "The interfaces"
+ * defined for PartnerFinder.
+ */
+class PartnerFinder: public Interfaced {
+
+public:
+
+ /**
+ * The default constructor.
+ */
+ PartnerFinder() : _approach(0), _PHpfinder(0) {}
+
+ /**
+ * Given in input a collection of particles (ShowerParticle objects),
+ * each of these methods set the initial evolution scales of those particles,
+ * between the ones given in input, that do not have yet their
+ * evolution scale set.
+ * The input collection of particles can be either the full collection of
+ * showering particles (kept in the main class ShowerHandler,
+ * in the case isDecayCase is false, or simply, in the case isDecayCase
+ * is true, the decaying particle and its decay products.
+ * The methods returns true, unless something wrong (inconsistencies,
+ * or undefined values) happens.
+ *
+ * These methods are virtual but in most cases inheriting classes should not
+ * need to overide them as they simply find the relevant partner and call
+ * one of the calculateScale members to calculate the scale.
+ */
+ //@{
+ /**
+ * Set the initial scales
+ * @param particles The particles to be considered
+ * @param isDecayCase Whether or not this is a decay
+ * @param setPartners Whether to set the colour partners or just the scales
+ */
+ virtual bool setInitialEvolutionScales(const ShowerParticleVector &particles,
+ const bool isDecayCase,
+ const bool setPartners=true);
+ //@}
+
+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:
+
+ /**
+ * Given a pair of particles, supposedly partners w.r.t. an interaction,
+ * this method returns their initial evolution scales as a pair.
+ * If something wrong happens, it returns the null (ZERO,ZERO) pair.
+ * This method is used by the above setXXXInitialEvolutionScales
+ * methods.
+ * These methods must be overiden in inheriting classes
+ */
+ //@{
+ /**
+ * General method to calculate the initial evolution scales
+ */
+ virtual pair<Energy,Energy> calculateInitialEvolutionScales(const ShowerPPair &,
+ const bool isDecayCase);
+
+ /**
+ * Calculate the initial evolution scales for two final-state particles
+ */
+ virtual pair<Energy,Energy> calculateFinalFinalScales(const ShowerPPair &)=0;
+
+ /**
+ * Calculate the initial evolution scales for two initial-state particles
+ */
+ virtual pair<Energy,Energy> calculateInitialInitialScales(const ShowerPPair &)=0;
+
+ /**
+ * Calculate the initial evolution scales for one initial
+ * and one final-state particles
+ */
+ virtual pair<Energy,Energy> calculateInitialFinalScales(const ShowerPPair &,
+ const bool isDecayCase)=0;
+ //@}
+/** Switch Partner Finder to POWHEG? **/
+
+ bool PHpfinder() const {return _PHpfinder > 0;}
+
+ /* On? */
+
+ bool PHpfinderon() const {return (_PHpfinder > 0);}
+
+ /* Off */
+
+ bool PHpfinderoff() const {return (_PHpfinder == 0);}
+
+private:
+
+ /**
+ * The static object used to initialize the description of this class.
+ * Indicates that this is a concrete class with persistent data.
+ */
+ static AbstractClassDescription<PartnerFinder> initPartnerFinder;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ PartnerFinder & operator=(const PartnerFinder &);
+
+private:
+
+ /**
+ * Approach to use for setting the colour partners
+ */
+ int _approach;
+/**
+ * POWHEG Partner Finder switch
+ */
+ unsigned int _PHpfinder;
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of PartnerFinder. */
+template <>
+struct BaseClassTrait<Herwig::PartnerFinder,1> {
+ /** Typedef of the first base class of PartnerFinder. */
+ typedef Interfaced NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the PartnerFinder class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::PartnerFinder>
+ : public ClassTraitsBase<Herwig::PartnerFinder> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::PartnerFinder"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * PartnerFinder is implemented. It may also include several, space-separated,
+ * libraries if the class PartnerFinder 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 "HwShower.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_PartnerFinder_H */
diff --git a/Contrib/Makefile.am b/Contrib/Makefile.am
--- a/Contrib/Makefile.am
+++ b/Contrib/Makefile.am
@@ -1,17 +1,18 @@
EXTRA_DIST = \
AcerDetInterface \
Analysis2 \
AnomalousHVV \
DecayAnalysis \
LeptonME \
+MCPWNLO \
PGSInterface \
RadiativeZPrime \
TauAnalysis \
AlpGen
dist-hook:
rm -rf `find $(distdir) -name '.svn' -or -name 'Makefile'`
all:
bash make_makefiles.sh
diff --git a/Contrib/VBFTest/ILC.in b/Contrib/VBFTest/ILC.in
new file mode 100644
--- /dev/null
+++ b/Contrib/VBFTest/ILC.in
@@ -0,0 +1,110 @@
+##################################################
+# Example generator based on ILC parameters
+# usage: Herwig++ read ILC.in
+#
+# Since most parameters are identical to LEP,
+# we use the default LEPGenerator and adapt only
+# for the differences
+##################################################
+
+###################################################
+# Change settings for the ee->Z->qq matrix element
+# to produce only top quarks
+#
+# 'set' lines like this can be omitted if the
+# default value is already okay.
+#
+# Any repository setting can be modified here
+###################################################
+cd /Herwig
+create Herwig::O2AlphaS AlphaS2
+set Model:QCD/RunningAlphaS AlphaS2
+set Model:EW/CKM:theta_12 0.22274457
+set Model:EW/CKM:theta_13 0.
+set Model:EW/CKM:theta_23 0.
+set Model:EW/CKM:delta 0.
+set Model:EW/Sin2ThetaW .2319
+create Herwig::AlphaEM AlphaEM2
+set Model:EW/RunningAlphaEM AlphaEM2
+cd /Herwig/MatrixElements
+create Herwig::MEee2HiggsVBF MEee2HiggsVBF
+insert SimpleEE:MatrixElements[0] MEee2HiggsVBF
+
+set MEee2HiggsVBF:Process ZZ
+set MEee2HiggsVBF:ShapeScheme OnShell
+
+set /Herwig/Particles/e+:PDF /Herwig/Partons/NoPDF
+set /Herwig/Particles/e-:PDF /Herwig/Partons/NoPDF
+set /Herwig/Particles/h0:NominalMass 115
+set /Herwig/Particles/Z0:NominalMass 91.188
+set /Herwig/Particles/W+:NominalMass 80.42
+set /Herwig/Particles/W-:NominalMass 80.42
+set /Herwig/Masses/HiggsMass:HiggsShape 0
+#set /Herwig/Generators/LEPGenerator:EventHandler:BeamB /Herwig/Particles/e-
+
+
+
+##################################################
+# Technical parameters for this run
+##################################################
+cd /Herwig/Generators
+set LEPGenerator:NumberOfEvents 100000000
+set LEPGenerator:RandomNumberGenerator:Seed 31122001
+set LEPGenerator:DebugLevel 1
+set LEPGenerator:PrintEvent 100
+set LEPGenerator:MaxErrors 10000
+set LEPGenerator:EventHandler:HadronizationHandler NULL
+set LEPGenerator:EventHandler:CascadeHandler NULL
+set LEPGenerator:EventHandler:DecayHandler NULL
+set /Herwig/Analysis/Basics:CheckQuark 0
+##################################################
+# ILC physics parameters (override defaults)
+##################################################
+set LEPGenerator:EventHandler:LuminosityFunction:Energy 500.0
+
+##################################################
+# Useful analysis handlers for HepMC related output
+##################################################
+# Schematic overview of an event (requires --with-hepmc to be set at configure time
+# and the graphviz program 'dot' to produce a plot)
+# insert LEPGenerator:AnalysisHandlers 0 /Herwig/Analysis/Plot
+# A HepMC dump file (requires --with-hepmc to be set at configure time)
+# insert LEPGenerator:AnalysisHandlers 0 /Herwig/Analysis/HepMCFile
+# set /Herwig/Analysis/HepMCFile:PrintEvent 100
+# set /Herwig/Analysis/HepMCFile:Format GenEvent
+# set /Herwig/Analysis/HepMCFile:Units GeV_mm
+
+create Herwig::QuickVBF /Herwig/Analysis/QuickVBF QuickVBF.so
+insert LEPGenerator:AnalysisHandlers 0 /Herwig/Analysis/QuickVBF
+
+##################################################
+# Save run for later usage with 'Herwig++ run'
+##################################################
+#saverun ILC LEPGenerator
+
+##################################################
+# uncomment this section for an example batch run
+# of two repeats with different parameters
+#
+# Note that a separate call of 'Herwig run'
+# is not required
+##################################################
+saverun ILC1 LEPGenerator
+set /Herwig/Particles/h0:NominalMass 300
+saverun ILC2 LEPGenerator
+set /Herwig/Particles/h0:NominalMass 115
+set /Herwig/Generators/LEPGenerator:EventHandler:LuminosityFunction:Energy 1000
+saverun ILC3 LEPGenerator
+set /Herwig/Particles/h0:NominalMass 300
+saverun ILC4 LEPGenerator
+set /Herwig/Particles/h0:NominalMass 115
+set /Herwig/Generators/LEPGenerator:EventHandler:LuminosityFunction:Energy 500
+set /Herwig/MatrixElements/MEee2HiggsVBF:Process WW
+saverun ILC5 LEPGenerator
+set /Herwig/Particles/h0:NominalMass 300
+saverun ILC6 LEPGenerator
+set /Herwig/Particles/h0:NominalMass 115
+set /Herwig/Generators/LEPGenerator:EventHandler:LuminosityFunction:Energy 1000
+saverun ILC7 LEPGenerator
+set /Herwig/Particles/h0:NominalMass 300
+saverun ILC8 LEPGenerator
diff --git a/Contrib/VBFTest/LHC.in b/Contrib/VBFTest/LHC.in
new file mode 100644
--- /dev/null
+++ b/Contrib/VBFTest/LHC.in
@@ -0,0 +1,130 @@
+##################################################
+# Example generator based on LHC parameters
+# usage: Herwig++ read LHC.in
+##################################################
+
+cd /Herwig
+create Herwig::O2AlphaS AlphaS2
+set Model:QCD/RunningAlphaS AlphaS2
+set Model:EW/CKM:theta_12 0.000001
+set Model:EW/CKM:theta_13 0.
+set Model:EW/CKM:theta_23 0.
+set Model:EW/CKM:delta 0.
+set Model:EW/Sin2ThetaW .2319
+create Herwig::AlphaEM AlphaEM2
+set Model:EW/RunningAlphaEM AlphaEM2
+
+set /Herwig/Particles/h0:NominalMass 115
+set /Herwig/Particles/Z0:NominalMass 91.188
+set /Herwig/Particles/W+:NominalMass 80.42
+set /Herwig/Particles/W-:NominalMass 80.42
+set /Herwig/Masses/HiggsMass:HiggsShape 0
+
+cd /Herwig/Partons
+setup MRST /usr/local/share/Herwig++/PDF/mrst/1998/lo05a.dat
+set MRST:Interpolation Linear
+
+##################################################
+# Technical parameters for this run
+##################################################
+cd /Herwig/Generators
+set LHCGenerator:NumberOfEvents 10000000
+set LHCGenerator:RandomNumberGenerator:Seed 31122001
+set LHCGenerator:DebugLevel 1
+set LHCGenerator:PrintEvent 10
+set LHCGenerator:MaxErrors 10000
+set LHCGenerator:EventHandler:CascadeHandler NULL
+set LHCGenerator:EventHandler:DecayHandler NULL
+set LHCGenerator:EventHandler:HadronizationHandler NULL
+set LHCGenerator:EventHandler:StatLevel Full
+
+##################################################
+# LHC physics parameters (override defaults here)
+##################################################
+set LHCGenerator:EventHandler:LuminosityFunction:Energy 2000.0
+set LHCGenerator:EventHandler:BeamB /Herwig/Particles/pbar-
+
+# Intrinsic pT tune extrapolated to LHC energy
+set /Herwig/Shower/Evolver:IntrinsicPtGaussian 5.7*GeV
+
+##################################################
+# Matrix Elements for hadron-hadron collisions
+# (by default only gamma/Z switched on)
+##################################################
+cd /Herwig/MatrixElements/
+create Herwig::MEPP2HiggsVBF MEPP2HiggsVBF
+set MEPP2HiggsVBF:MaxFlavour 5
+set MEPP2HiggsVBF:ShapeScheme OnShell
+set MEPP2HiggsVBF:Process ZZ
+
+insert SimpleQCD:MatrixElements[0] MEPP2HiggsVBF
+set /Herwig/Cuts/JetKtCut:MinKT 0.*GeV
+
+set /Herwig/ACDCSampler:Ntry 100000
+
+cd /Herwig/Generators
+
+##################################################
+# Useful analysis handlers for hadron-hadron physics
+##################################################
+# analysis of W/Z events
+# insert LHCGenerator:AnalysisHandlers 0 /Herwig/Analysis/DrellYan
+# analysis of top-antitop events
+# insert LHCGenerator:AnalysisHandlers 0 /Herwig/Analysis/TTbar
+# analysis of gamma+jet events
+# insert LHCGenerator:AnalysisHandlers 0 /Herwig/Analysis/GammaJet
+# analysis of gamma-gamma events
+# insert LHCGenerator:AnalysisHandlers 0 /Herwig/Analysis/GammaGamma
+# analysis of higgs-jet events
+# insert LHCGenerator:AnalysisHandlers 0 /Herwig/Analysis/HiggsJet
+
+##################################################
+# Useful analysis handlers for HepMC related output
+##################################################
+# Schematic overview of an event (requires --with-hepmc to be set at configure time
+# and the graphviz program 'dot' to produce a plot)
+# insert LHCGenerator:AnalysisHandlers 0 /Herwig/Analysis/Plot
+# A HepMC dump file (requires --with-hepmc to be set at configure time)
+# insert LHCGenerator:AnalysisHandlers 0 /Herwig/Analysis/HepMCFile
+# set /Herwig/Analysis/HepMCFile:PrintEvent 100
+# set /Herwig/Analysis/HepMCFile:Format GenEvent
+# set /Herwig/Analysis/HepMCFile:Units GeV_mm
+set /Herwig/Analysis/Basics:CheckQuark 0
+
+create Herwig::QuickVBFHadron /Herwig/Analysis/QuickVBFHadron QuickVBFHadron.so
+insert LHCGenerator:AnalysisHandlers 0 /Herwig/Analysis/QuickVBFHadron
+
+##################################################
+# Save run for later usage with 'Herwig++ run'
+##################################################
+#saverun LHC LHCGenerator
+
+##################################################
+# uncomment this section for an example batch run
+# of two repeats with different parameters
+#
+# Note that a separate call of 'Herwig run'
+# is not required in this case
+##################################################
+saverun LHC1 LHCGenerator
+set /Herwig/Particles/h0:NominalMass 300
+saverun LHC2 LHCGenerator
+set /Herwig/Particles/h0:NominalMass 115
+set /Herwig/Generators/LHCGenerator:EventHandler:LuminosityFunction:Energy 14000
+set /Herwig/Generators/LHCGenerator:EventHandler:BeamB /Herwig/Particles/p+
+saverun LHC3 LHCGenerator
+set /Herwig/Particles/h0:NominalMass 300
+saverun LHC4 LHCGenerator
+set /Herwig/Particles/h0:NominalMass 115
+set /Herwig/Generators/LHCGenerator:EventHandler:LuminosityFunction:Energy 2000
+set /Herwig/Generators/LHCGenerator:EventHandler:BeamB /Herwig/Particles/pbar-
+set /Herwig/MatrixElements/MEPP2HiggsVBF:Process WW
+saverun LHC5 LHCGenerator
+set /Herwig/Particles/h0:NominalMass 300
+saverun LHC6 LHCGenerator
+set /Herwig/Particles/h0:NominalMass 115
+set /Herwig/Generators/LHCGenerator:EventHandler:LuminosityFunction:Energy 14000
+set /Herwig/Generators/LHCGenerator:EventHandler:BeamB /Herwig/Particles/p+
+saverun LHC7 LHCGenerator
+set /Herwig/Particles/h0:NominalMass 300
+saverun LHC8 LHCGenerator
diff --git a/Contrib/VBFTest/QuickVBF.cc b/Contrib/VBFTest/QuickVBF.cc
new file mode 100644
--- /dev/null
+++ b/Contrib/VBFTest/QuickVBF.cc
@@ -0,0 +1,134 @@
+// -*- C++ -*-
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the QuickVBF class.
+//
+
+#include "QuickVBF.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/PDT/EnumParticles.h"
+#include "ThePEG/Repository/EventGenerator.h"
+#include "ThePEG/EventRecord/Particle.h"
+#include "ThePEG/EventRecord/Event.h"
+
+using namespace Herwig;
+
+void QuickVBF::analyze(tEventPtr event, long ieve, int loop, int state) {
+ AnalysisHandler::analyze(event, ieve, loop, state);
+ // Rotate to CMS, extract final state particles and call analyze(particles).
+ StepVector::const_iterator sit =event->primaryCollision()->steps().begin();
+ StepVector::const_iterator stest =event->primaryCollision()->steps().end();
+ StepVector::const_iterator send=sit;
+ ++send;
+ if(send==stest) --send;
+ ++send;
+ if(send==stest) --send;
+ ++send;
+ Lorentz5Momentum pz;
+ for(;sit!=send;++sit) {
+ ParticleSet part;
+ (**sit).selectFinalState(inserter(part));
+ ParticleSet::const_iterator iter = part.begin(), end = part.end();
+ for( ;iter!=end;++iter) {
+ if((**iter).id()==ParticleID::h0) {
+ *_mH += (**iter).momentum().m()/GeV;
+ *_cosH += (**iter).momentum().cosTheta();
+ *_phiH += (**iter).momentum().phi()+Constants::pi;
+ *_eH += (**iter).momentum().t()/GeV;
+ }
+ else if((**iter).id()==ParticleID::nu_e) {
+ *_cosnu += (**iter).momentum().cosTheta();
+ *_phinu += (**iter).momentum().phi()+Constants::pi;
+ *_enu += (**iter).momentum().t()/GeV;
+ }
+ else if((**iter).id()==ParticleID::nu_ebar) {
+ *_cosnub += (**iter).momentum().cosTheta();
+ *_phinub += (**iter).momentum().phi()+Constants::pi;
+ *_enub += (**iter).momentum().t()/GeV;
+ }
+ else if((**iter).id()==ParticleID::eminus) {
+ *_cosem += (**iter).momentum().cosTheta();
+ *_phiem += (**iter).momentum().phi()+Constants::pi;
+ *_eem += (**iter).momentum().t()/GeV;
+ }
+ else if((**iter).id()==ParticleID::eplus) {
+ *_cosep += (**iter).momentum().cosTheta();
+ *_phiep += (**iter).momentum().phi()+Constants::pi;
+ *_eep += (**iter).momentum().t()/GeV;
+ }
+ }
+ }
+}
+
+NoPIOClassDescription<QuickVBF> QuickVBF::initQuickVBF;
+// Definition of the static class description member.
+
+void QuickVBF::Init() {
+
+ static ClassDocumentation<QuickVBF> documentation
+ ("There is no documentation for the QuickVBF class");
+
+}
+
+void QuickVBF::doinitrun() {
+ AnalysisHandler::doinitrun();
+ if(getParticleData(ParticleID::h0)->mass()>200.*GeV)
+ _mH = new_ptr(Histogram(200., 400.,200));
+ else
+ _mH = new_ptr(Histogram(114., 116.0,200));
+ _cosH = new_ptr(Histogram( -1.0, 1.0,200));
+ _phiH = new_ptr(Histogram( 0.0,2.0*Constants::pi,200));
+ _eH = new_ptr(Histogram( 0.0,1000.,1000));
+ _cosnu = new_ptr(Histogram( -1.0, 1.0,200));
+ _phinu = new_ptr(Histogram( 0.0,2.0*Constants::pi,200));
+ _enu = new_ptr(Histogram( 0.0,1000.,1000));
+ _cosnub = new_ptr(Histogram( -1.0, 1.0,200));
+ _phinub = new_ptr(Histogram( 0.0,2.0*Constants::pi,200));
+ _enub = new_ptr(Histogram( 0.0,1000.,1000));
+ _cosem = new_ptr(Histogram( -1.0, 1.0,200));
+ _phiem = new_ptr(Histogram( 0.0,2.0*Constants::pi,200));
+ _eem = new_ptr(Histogram( 0.0,1000.,1000));
+ _cosep = new_ptr(Histogram( -1.0, 1.0,200));
+ _phiep = new_ptr(Histogram( 0.0,2.0*Constants::pi,200));
+ _eep = new_ptr(Histogram( 0.0,1000.,1000));
+}
+
+void QuickVBF::dofinish() {
+ AnalysisHandler::dofinish();
+ string fname = generator()->filename() + string("-") + name() + string(".top");
+ ofstream outfile(fname.c_str());
+ using namespace HistogramOptions;
+ string title,species;
+ title = "mass of H";
+ _mH->topdrawOutput(outfile,Frame,"BLACK",title);
+ title = "theta of H";
+ _cosH->topdrawOutput(outfile,Frame,"BLACK",title);
+ title = "Energy of H";
+ _eH->topdrawOutput(outfile,Frame,"BLACK",title);
+ title = "azimuth of H";
+ _phiH->topdrawOutput(outfile,Frame,"BLACK",title);
+ title = "theta of nu";
+ _cosnu->topdrawOutput(outfile,Frame,"BLACK",title);
+ title = "Energy of nu";
+ _enu->topdrawOutput(outfile,Frame,"BLACK",title);
+ title = "azimuth of nu";
+ _phinu->topdrawOutput(outfile,Frame,"BLACK",title);
+ title = "theta of nub";
+ _cosnub->topdrawOutput(outfile,Frame,"BLACK",title);
+ title = "Energy of nub";
+ _enub->topdrawOutput(outfile,Frame,"BLACK",title);
+ title = "azimuth of nub";
+ _phinub->topdrawOutput(outfile,Frame,"BLACK",title);
+ title = "theta of em";
+ _cosem->topdrawOutput(outfile,Frame,"BLACK",title);
+ title = "Energy of em";
+ _eem->topdrawOutput(outfile,Frame,"BLACK",title);
+ title = "azimuth of em";
+ _phiem->topdrawOutput(outfile,Frame,"BLACK",title);
+ title = "theta of ep ";
+ _cosep ->topdrawOutput(outfile,Frame,"BLACK",title);
+ title = "Energy of ep ";
+ _eep ->topdrawOutput(outfile,Frame,"BLACK",title);
+ title = "azimuth of ep ";
+ _phiep ->topdrawOutput(outfile,Frame,"BLACK",title);
+}
diff --git a/Contrib/VBFTest/QuickVBF.h b/Contrib/VBFTest/QuickVBF.h
new file mode 100644
--- /dev/null
+++ b/Contrib/VBFTest/QuickVBF.h
@@ -0,0 +1,152 @@
+// -*- C++ -*-
+#ifndef HERWIG_QuickVBF_H
+#define HERWIG_QuickVBF_H
+//
+// This is the declaration of the QuickVBF class.
+//
+
+#include "ThePEG/Handlers/AnalysisHandler.h"
+#include "Herwig++/Utilities/Histogram.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * Here is the documentation of the QuickVBF class.
+ *
+ * @see \ref QuickVBFInterfaces "The interfaces"
+ * defined for QuickVBF.
+ */
+class QuickVBF: public AnalysisHandler {
+
+public:
+
+ /** @name Virtual functions required by the AnalysisHandler class. */
+ //@{
+ /**
+ * Analyze a given Event. Note that a fully generated event
+ * may be presented several times, if it has been manipulated in
+ * between. The default version of this function will call transform
+ * to make a lorentz transformation of the whole event, then extract
+ * all final state particles and call analyze(tPVector) of this
+ * analysis object and those of all associated analysis objects. The
+ * default version will not, however, do anything on events which
+ * have not been fully generated, or have been manipulated in any
+ * way.
+ * @param event pointer to the Event to be analyzed.
+ * @param ieve the event number.
+ * @param loop the number of times this event has been presented.
+ * If negative the event is now fully generated.
+ * @param state a number different from zero if the event has been
+ * manipulated in some way since it was last presented.
+ */
+ virtual void analyze(tEventPtr event, long ieve, int loop, int state);
+
+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();
+
+protected:
+
+ /** @name Clone Methods. */
+ //@{
+ /**
+ * Make a simple clone of this object.
+ * @return a pointer to the new object.
+ */
+ inline virtual IBPtr clone() const {return new_ptr(*this);}
+
+ /** Make a clone of this object, possibly modifying the cloned object
+ * to make it sane.
+ * @return a pointer to the new object.
+ */
+ inline virtual IBPtr fullclone() const {return new_ptr(*this);}
+ //@}
+
+
+protected:
+
+ /** @name Standard Interfaced functions. */
+ //@{
+ /**
+ * 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 static object used to initialize the description of this class.
+ * Indicates that this is an concrete class without persistent data.
+ */
+ static NoPIOClassDescription<QuickVBF> initQuickVBF;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ QuickVBF & operator=(const QuickVBF &);
+
+private:
+
+ HistogramPtr _mH ,_cosH ,_eH ,_phiH ;
+ HistogramPtr _cosnu ,_enu ,_phinu ;
+ HistogramPtr _cosnub,_enub,_phinub;
+ HistogramPtr _cosem ,_eem ,_phiem ;
+ HistogramPtr _cosep ,_eep ,_phiep ;
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of QuickVBF. */
+template <>
+struct BaseClassTrait<Herwig::QuickVBF,1> {
+ /** Typedef of the first base class of QuickVBF. */
+ typedef AnalysisHandler NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the QuickVBF class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::QuickVBF>
+ : public ClassTraitsBase<Herwig::QuickVBF> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::QuickVBF"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * QuickVBF is implemented. It may also include several, space-separated,
+ * libraries if the class QuickVBF 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 "QuickVBF.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_QuickVBF_H */
diff --git a/Contrib/VBFTest/QuickVBFHadron.cc b/Contrib/VBFTest/QuickVBFHadron.cc
new file mode 100644
--- /dev/null
+++ b/Contrib/VBFTest/QuickVBFHadron.cc
@@ -0,0 +1,241 @@
+// -*- C++ -*-
+//
+// This is the implementation of the non-inlined, non-templated member
+// functions of the QuickVBFHadron class.
+//
+
+#include "QuickVBFHadron.h"
+#include "ThePEG/Interface/ClassDocumentation.h"
+#include "ThePEG/PDT/EnumParticles.h"
+#include "ThePEG/Repository/EventGenerator.h"
+#include "ThePEG/EventRecord/Particle.h"
+#include "ThePEG/EventRecord/Event.h"
+
+#include "ThePEG/EventRecord/Collision.h"
+#include "ThePEG/EventRecord/Step.h"
+#include "ThePEG/EventRecord/SubProcess.h"
+#include "ThePEG/Handlers/XComb.h"
+#include "ThePEG/Handlers/EventHandler.h"
+#include "ThePEG/PDF/PartonExtractor.h"
+#include "ThePEG/PDF/PDF.h"
+
+using namespace Herwig;
+
+void QuickVBFHadron::analyze(tEventPtr event, long ieve, int loop, int state) {
+ AnalysisHandler::analyze(event, ieve, loop, state);
+ // Rotate to CMS, extract final state particles and call analyze(particles).
+ tPVector part = event->getFinalState();
+ Lorentz5Momentum pjj;
+ Energy2 mHsq(ZERO);
+ for(tPVector::const_iterator iter = part.begin(), end = part.end();
+ iter!=end;++iter) {
+ if((**iter).id()==ParticleID::h0) {
+ *_mH += (**iter).momentum().m()/GeV;
+ mHsq=(**iter).momentum().m2();
+ *_yH += (**iter).momentum().rapidity();
+ *_phiH += (**iter).momentum().phi()+Constants::pi;
+ *_pTH[0] += (**iter).momentum().perp()/GeV;
+ *_pTH[1] += (**iter).momentum().perp()/GeV;
+ }
+ else if((**iter).id()!=82) {
+ *_yjet += (**iter).momentum().rapidity();
+ *_phijet += (**iter).momentum().phi()+Constants::pi;
+ *_pTjet[0] += (**iter).momentum().perp()/GeV;
+ *_pTjet[1] += (**iter).momentum().perp()/GeV;
+ pjj+=(**iter).momentum();
+ }
+ }
+ *_mjj += pjj.m()/GeV;
+
+ if (!_doOnce) {
+ // Find the pdf information
+ tSubProPtr sub = event->primarySubProcess();
+ // get the event handler
+ tcEHPtr eh = dynamic_ptr_cast<tcEHPtr>(event->handler());
+ // get the pdfs
+ pair<PDF,PDF> pdfs;
+ pdfs.first = eh->pdf<PDF>(sub->incoming().first );
+ pdfs.second = eh->pdf<PDF>(sub->incoming().second);
+ // Make a semi-analytical prediction of the convolution over pdfs
+ const double num=1e7;
+ double allsum[14][14];
+ double allsqr[14][14];
+ for (int j=0; j<=13 ; ++j) {
+ for (int k=0; k<=13 ; ++k) {
+ allsum[j][k]=0;
+ allsqr[j][k]=0;
+ }
+ }
+ double zzsum=0;
+ double zzsqr=0;
+ double wwsum=0;
+ double wwsqr=0;
+ Energy2 scale=mHsq;
+ Energy2 s=event->primaryCollision()->m2();
+ cerr << "Starting semi-analytical calculation. Higgs mass/GeV=" <<
+ sqrt(mHsq)/GeV << ", sqrt(s)/GeV=" << sqrt(s)/GeV << "\n";
+ double tmin=mHsq/s;
+ double tlmin=log(tmin);
+ for (int i=0 ; i<int(num+0.5) ; ++i) {
+ double xxmin=exp(tlmin*UseRandom::rnd());
+ double xlmin=log(xxmin);
+ double x1=exp(xlmin*UseRandom::rnd());
+ double x2=xxmin/x1;
+ // out of laziness, just don't use the 0'th elements, to be like fortran
+ double disf[14][3];
+ for (int j=1 ; j<=13; ++j) {
+ for (int k=1 ; k<=2 ; ++k) {
+ disf[j][k]=0;
+ }
+ }
+ for (int j=1 ; j<=6 ; ++j) {
+ disf[j][1]=pdfs.first .xfx((tcPDPtr)getParticleData(j),scale,x1);
+ disf[j+6][1]=pdfs.first .xfx((tcPDPtr)getParticleData(-j),scale,x1);
+ }
+ disf[13][1]=pdfs.first .xfx((tcPDPtr)getParticleData(21),scale,x1);
+ for (int j=1 ; j<=6 ; ++j) {
+ disf[j][2]=pdfs.second.xfx((tcPDPtr)getParticleData(j),scale,x2);
+ disf[j+6][2]=pdfs.second.xfx((tcPDPtr)getParticleData(-j),scale,x2);
+ }
+ disf[13][2]=pdfs.second.xfx((tcPDPtr)getParticleData(21),scale,x2);
+ double w=tlmin*xlmin*
+ (disf[1][1]+disf[2][1]+disf[3][1]+disf[4][1]+
+ disf[7][1]+disf[8][1]+disf[9][1]+disf[10][1])*
+ (disf[1][2]+disf[2][2]+disf[3][2]+disf[4][2]+
+ disf[7][2]+disf[8][2]+disf[9][2]+disf[10][2]);
+ zzsum+=w;
+ zzsqr+=sqr(w);
+ w=tlmin*xlmin*
+ ((disf[1][1]+disf[3][1]+disf[8][1]+disf[10][1])*
+ (disf[2][2]+disf[4][2]+disf[7][2]+disf[9][2])+
+ (disf[2][1]+disf[4][1]+disf[7][1]+disf[9][1])*
+ (disf[1][2]+disf[3][2]+disf[8][2]+disf[10][2]));
+ // Extra factor because Hw++ test program sums over 4 Cabibbo possibilities
+ w*=4;
+ wwsum+=w;
+ wwsqr+=sqr(w);
+ for (int j=1; j<=13; ++j) {
+ for (int k=1; k<=13; ++k) {
+ w=tlmin*xlmin*disf[j][1]*disf[k][2];
+ allsum[j][k]+=w;
+ allsqr[j][k]+=sqr(w);
+ }
+ }
+ }
+ cerr << "Analytical result for ZZ=" << zzsum/num << "+-" << sqrt(zzsqr-sqr(zzsum)/num)/num << "\n";
+ cerr << "Analytical result for WW=" << wwsum/num << "+-" << sqrt(wwsqr-sqr(wwsum)/num)/num << "\n";
+ for (int j=1; j<=13; ++j) {
+ int idj=0;
+ if (j>=1&&j<=5) idj=j;
+ if (j>=7&&j<=11)idj=6-j;
+ if (idj!=0) {
+ for (int k=1; k<=13; ++k) {
+ int idk=0;
+ if (k>=1&&k<=5) idk=k;
+ if (k>=7&&k<=11)idk=6-k;
+ if (idk!=0 && allsum[j][k]>0) {
+ cerr << getParticleData(idj)->PDGName() << " " <<
+ getParticleData(idk)->PDGName() << "\t" <<
+ allsum[j][k]/num << "+-" << sqrt(allsqr[j][k]-sqr(allsum[j][k])/num)/num << "\n";
+ }
+ }
+ }
+ }
+ _doOnce=true;
+ }
+ /*
+ // ids of the partons going into the primary sub process
+ tSubProPtr sub = event->primarySubProcess();
+ int id1 = sub->incoming().first ->id();
+ int id2 = sub->incoming().second->id();
+ // get the event handler
+ tcEHPtr eh = dynamic_ptr_cast<tcEHPtr>(event->handler());
+ // get the values of x
+ double x1 = eh->lastX1();
+ double x2 = eh->lastX2();
+ // get the pdfs
+ pair<PDF,PDF> pdfs;
+ pdfs.first = eh->pdf<PDF>(sub->incoming().first );
+ pdfs.second = eh->pdf<PDF>(sub->incoming().second);
+ // get the scale
+ Energy2 scale = eh->lastScale();
+ // get the values of the pdfs
+ double pdf1 = pdfs.first .xfx(sub->incoming().first ->dataPtr(),scale,x1);
+ double pdf2 = pdfs.second.xfx(sub->incoming().second->dataPtr(),scale,x2);
+ // print them to cerr
+ if (x1<3e-4 || x2<3e-4) {
+ cerr << "The x values are:" << x1 << " " << x2 << "\n";
+ cerr << "The scale is:" << sqrt(scale)/GeV << " GeV \n";
+ cerr << "The parton ids are:" << id1 << " " << id2 << "\n";
+ cerr << "The pdfs are:" << pdf1 << " " << pdf2 << "\n\n";
+ }
+ for (int i=0;i<=100;++i) {
+ x1 = pow(10.0,4*(double(i)/100-1));
+ pdf1 = pdfs.first .xfx(sub->incoming().first ->dataPtr(),scale,x1);
+ cerr << x1 << " " << pdf1 << "\n";
+ }
+ */
+}
+
+bool QuickVBFHadron::_doOnce = false;
+
+IBPtr QuickVBFHadron::clone() const {
+ return new_ptr(*this);
+}
+
+IBPtr QuickVBFHadron::fullclone() const {
+ return new_ptr(*this);
+}
+
+NoPIOClassDescription<QuickVBFHadron> QuickVBFHadron::initQuickVBFHadron;
+// Definition of the static class description member.
+
+void QuickVBFHadron::Init() {
+
+ static ClassDocumentation<QuickVBFHadron> documentation
+ ("There is no documentation for the QuickVBFHadron class");
+
+}
+
+void QuickVBFHadron::dofinish() {
+ AnalysisHandler::dofinish();
+ string fname = generator()->filename() + string("-") + name() + string(".top");
+ ofstream outfile(fname.c_str());
+ using namespace HistogramOptions;
+ string title,species;
+ title = "mass of H";
+ _mH->topdrawOutput(outfile,Frame,"BLACK",title);
+ title = "rapidity of H";
+ _yH->topdrawOutput(outfile,Frame,"BLACK",title);
+ title = "pT of H";
+ _pTH[0]->topdrawOutput(outfile,Frame|Ylog,"BLACK",title);
+ _pTH[1]->topdrawOutput(outfile,Frame|Ylog,"BLACK",title);
+ title = "azimuth of H";
+ _phiH->topdrawOutput(outfile,Frame,"BLACK",title);
+ title = "rapidity of jet";
+ _yjet->topdrawOutput(outfile,Frame,"BLACK",title);
+ title = "pT of jet";
+ _pTjet[0]->topdrawOutput(outfile,Frame|Ylog,"BLACK",title);
+ _pTjet[1]->topdrawOutput(outfile,Frame|Ylog,"BLACK",title);
+ title = "azimuth of jet";
+ _phijet->topdrawOutput(outfile,Frame,"BLACK",title);
+ title = "mjj";
+ _mjj->topdrawOutput(outfile,Frame,"BLACK",title);
+}
+
+void QuickVBFHadron::doinitrun() {
+ AnalysisHandler::doinitrun();
+ if(getParticleData(ParticleID::h0)->mass()>200.*GeV)
+ _mH = new_ptr(Histogram(200., 400.,200));
+ else
+ _mH = new_ptr(Histogram(114., 116.0,200));
+ _yH = new_ptr(Histogram( -10.0, 10.0,200));
+ _phiH = new_ptr(Histogram( 0.0,2.0*Constants::pi,200));
+ _pTH[0] = new_ptr(Histogram( 0.0,1000.,1000));
+ _pTH[1] = new_ptr(Histogram( 0.0,1000.,100));
+ _yjet = new_ptr(Histogram( -10.0, 10.0,200));
+ _phijet = new_ptr(Histogram( 0.0,2.0*Constants::pi,200));
+ _pTjet[0] = new_ptr(Histogram( 0.0,1000.,1000));
+ _pTjet[1] = new_ptr(Histogram( 0.0,1000.,100));
+ _mjj = new_ptr(Histogram(0.0,200.,100));
+}
diff --git a/Contrib/VBFTest/QuickVBFHadron.h b/Contrib/VBFTest/QuickVBFHadron.h
new file mode 100644
--- /dev/null
+++ b/Contrib/VBFTest/QuickVBFHadron.h
@@ -0,0 +1,152 @@
+// -*- C++ -*-
+#ifndef HERWIG_QuickVBFHadron_H
+#define HERWIG_QuickVBFHadron_H
+//
+// This is the declaration of the QuickVBFHadron class.
+//
+
+#include "ThePEG/Handlers/AnalysisHandler.h"
+#include "Herwig++/Utilities/Histogram.h"
+
+namespace Herwig {
+
+using namespace ThePEG;
+
+/**
+ * Here is the documentation of the QuickVBFHadron class.
+ *
+ * @see \ref QuickVBFHadronInterfaces "The interfaces"
+ * defined for QuickVBFHadron.
+ */
+class QuickVBFHadron: public AnalysisHandler {
+
+public:
+
+ /** @name Virtual functions required by the AnalysisHandler class. */
+ //@{
+ /**
+ * Analyze a given Event. Note that a fully generated event
+ * may be presented several times, if it has been manipulated in
+ * between. The default version of this function will call transform
+ * to make a lorentz transformation of the whole event, then extract
+ * all final state particles and call analyze(tPVector) of this
+ * analysis object and those of all associated analysis objects. The
+ * default version will not, however, do anything on events which
+ * have not been fully generated, or have been manipulated in any
+ * way.
+ * @param event pointer to the Event to be analyzed.
+ * @param ieve the event number.
+ * @param loop the number of times this event has been presented.
+ * If negative the event is now fully generated.
+ * @param state a number different from zero if the event has been
+ * manipulated in some way since it was last presented.
+ */
+ virtual void analyze(tEventPtr event, long ieve, int loop, int state);
+ //@}
+
+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();
+
+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:
+
+ /** @name Standard Interfaced functions. */
+ //@{
+ /**
+ * 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 static object used to initialize the description of this class.
+ * Indicates that this is an concrete class without persistent data.
+ */
+ static NoPIOClassDescription<QuickVBFHadron> initQuickVBFHadron;
+
+ /**
+ * The assignment operator is private and must never be called.
+ * In fact, it should not even be implemented.
+ */
+ QuickVBFHadron & operator=(const QuickVBFHadron &);
+
+private:
+
+ HistogramPtr _mH ,_yH ,_pTH[2] ,_phiH ;
+ HistogramPtr _yjet,_pTjet[2],_phijet;
+ HistogramPtr _mjj;
+
+ static bool _doOnce;
+
+};
+
+}
+
+#include "ThePEG/Utilities/ClassTraits.h"
+
+namespace ThePEG {
+
+/** @cond TRAITSPECIALIZATIONS */
+
+/** This template specialization informs ThePEG about the
+ * base classes of QuickVBFHadron. */
+template <>
+struct BaseClassTrait<Herwig::QuickVBFHadron,1> {
+ /** Typedef of the first base class of QuickVBFHadron. */
+ typedef AnalysisHandler NthBase;
+};
+
+/** This template specialization informs ThePEG about the name of
+ * the QuickVBFHadron class and the shared object where it is defined. */
+template <>
+struct ClassTraits<Herwig::QuickVBFHadron>
+ : public ClassTraitsBase<Herwig::QuickVBFHadron> {
+ /** Return a platform-independent class name */
+ static string className() { return "Herwig::QuickVBFHadron"; }
+ /**
+ * The name of a file containing the dynamic library where the class
+ * QuickVBFHadron is implemented. It may also include several, space-separated,
+ * libraries if the class QuickVBFHadron 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 "QuickVBFHadron.so"; }
+};
+
+/** @endcond */
+
+}
+
+#endif /* HERWIG_QuickVBFHadron_H */
diff --git a/MatrixElement/Hadron/MEPP2GammaJet.cc b/MatrixElement/Hadron/MEPP2GammaJet.cc
--- a/MatrixElement/Hadron/MEPP2GammaJet.cc
+++ b/MatrixElement/Hadron/MEPP2GammaJet.cc
@@ -1,526 +1,526 @@
// -*- C++ -*-
//
// MEPP2GammaJet.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
// Copyright (C) 2002-2011 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 MEPP2GammaJet class.
//
#include "MEPP2GammaJet.h"
#include "ThePEG/Interface/Parameter.h"
#include "ThePEG/Interface/Switch.h"
#include "ThePEG/Interface/ClassDocumentation.h"
#include "ThePEG/Repository/EventGenerator.h"
#include "Herwig++/Models/StandardModel/StandardModel.h"
#include "ThePEG/Utilities/SimplePhaseSpace.h"
#include "ThePEG/Handlers/StandardXComb.h"
#include "Herwig++/MatrixElement/HardVertex.h"
#include "ThePEG/Cuts/Cuts.h"
#include "ThePEG/Persistency/PersistentOStream.h"
#include "ThePEG/Persistency/PersistentIStream.h"
#include "ThePEG/PDT/EnumParticles.h"
#include "ThePEG/MatrixElement/Tree2toNDiagram.h"
using namespace Herwig;
MEPP2GammaJet::MEPP2GammaJet() : _maxflavour(5), _processopt(0) {
massOption(vector<unsigned int>(2,0));
}
void MEPP2GammaJet::rebind(const TranslationMap & trans)
{
// dummy = trans.translate(dummy);
HwMEBase::rebind(trans);
_gluonvertex =trans.translate(_gluonvertex );
_photonvertex=trans.translate(_photonvertex);
}
IVector MEPP2GammaJet::getReferences() {
IVector ret = HwMEBase::getReferences();
ret.push_back(_gluonvertex);
ret.push_back(_photonvertex);
return ret;
}
void MEPP2GammaJet::doinit() {
// get the vedrtex pointers from the SM object
tcHwSMPtr hwsm= dynamic_ptr_cast<tcHwSMPtr>(standardModel());
// do the initialisation
if(hwsm) {
_gluonvertex = hwsm->vertexFFG();
_photonvertex = hwsm->vertexFFP();
}
else throw InitException() << "Wrong type of StandardModel object in "
<< "MEPP2GammaJet::doinit() the Herwig++"
<< " version must be used"
<< Exception::runerror;
// call the base class
HwMEBase::doinit();
}
void MEPP2GammaJet::getDiagrams() const {
// need the gluon and the photon in all processes
tcPDPtr g = getParticleData(ParticleID::g);
tcPDPtr p = getParticleData(ParticleID::gamma);
// for each quark species there are three subprocesses
for ( int iq=1; iq<=_maxflavour; ++iq ) {
tcPDPtr q = getParticleData(iq);
tcPDPtr qb = q->CC();
// q qbar to gamma gluon (two diagrams)
if(_processopt==0||_processopt==1) {
add(new_ptr((Tree2toNDiagram(3), q, qb, qb, 1, p, 2, g, -1)));
add(new_ptr((Tree2toNDiagram(3), q, q, qb, 2, p, 1, g, -2)));
}
// q gluon to gamma q (two diagrams)
if(_processopt==0||_processopt==2) {
add(new_ptr((Tree2toNDiagram(3), q, q, g, 1, p, 2, q, -3)));
add(new_ptr((Tree2toNDiagram(2), q, g, 1, q , 3, p, 3, q, -4)));
}
// qbar gluon to gamma qbar (two diagrams)
if(_processopt==0||_processopt==3) {
add(new_ptr((Tree2toNDiagram(3), qb, qb, g, 1, p, 2, qb, -5)));
add(new_ptr((Tree2toNDiagram(2), qb, g, 1, qb , 3, p, 3, qb, -6)));
}
}
}
unsigned int MEPP2GammaJet::orderInAlphaS() const {
return 1;
}
unsigned int MEPP2GammaJet::orderInAlphaEW() const {
return 1;
}
Energy2 MEPP2GammaJet::scale() const {
Energy2 s(sHat()),u(uHat()),t(tHat());
return 2.*s*t*u/(s*s+t*t+u*u);
}
Selector<MEBase::DiagramIndex>
MEPP2GammaJet::diagrams(const DiagramVector & diags) const {
// This example corresponds to the diagrams specified in the example
// in the getDiagrams() function.
double diag1(0.5),diag2(0.5);
diag1 = meInfo()[0];
diag2 = meInfo()[1];
Selector<DiagramIndex> sel;
for ( DiagramIndex i = 0; i < diags.size(); ++i ) {
if ( abs(diags[i]->id())%2 == 1 ) sel.insert(diag1, i);
else sel.insert(diag2, i);
}
return sel;
}
void MEPP2GammaJet::persistentOutput(PersistentOStream & os) const {
os << _gluonvertex << _photonvertex << _maxflavour << _processopt;
}
void MEPP2GammaJet::persistentInput(PersistentIStream & is, int) {
is >> _gluonvertex >> _photonvertex >> _maxflavour >> _processopt;
}
ClassDescription<MEPP2GammaJet> MEPP2GammaJet::initMEPP2GammaJet;
// Definition of the static class description member.
void MEPP2GammaJet::Init() {
static ClassDocumentation<MEPP2GammaJet> documentation
("The MEPP2GammaJet class implements the matrix element for"
" hadron-hadron to photon+jet");
static Parameter<MEPP2GammaJet,int> interfaceMaximumFlavour
("MaximumFlavour",
"The maximum flavour of the quarks in the process",
&MEPP2GammaJet::_maxflavour, 5, 1, 5,
false, false, Interface::limited);
static Switch<MEPP2GammaJet,unsigned int> interfaceProcesses
("Process",
"Subprocesses to include",
&MEPP2GammaJet::_processopt, 0, false, false);
static SwitchOption interfaceProcessesAll
(interfaceProcesses,
"All",
"Include all the subprocesses",
0);
static SwitchOption interfaceProcessesqqbar
(interfaceProcesses,
"qqbar",
"Only include the incoming q qbar subprocess",
1);
static SwitchOption interfaceProcessesqg
(interfaceProcesses,
"qg",
"Only include the incoming q g subprocess",
2);
static SwitchOption interfaceProcessesqbarg
(interfaceProcesses,
"qbarg",
"Only include the incoming qbar g subprocess",
3);
}
Selector<const ColourLines *>
MEPP2GammaJet::colourGeometries(tcDiagPtr diag) const {
// q qbar to gamma gluon colour lines
static const ColourLines qqbar1("1 5, -5 -2 -3");
static const ColourLines qqbar2("1 2 5, -5 -3");
// q gluon to gamma q colour lines
static const ColourLines qg1("1 2 -3, 3 5");
static const ColourLines qg2("1 -2, 2 3 5");
// qbar gluon to gamma qbar lines
static const ColourLines qbarg1("-1 -2 3, -3 -5");
static const ColourLines qbarg2("-1 2, -2 -3 -5");
// only one flow per diagram so insert the right one
Selector<const ColourLines *> sel;
switch (diag->id()) {
case -1 :
sel.insert(1.0, &qqbar1);
break;
case -2 :
sel.insert(1.0, &qqbar2);
break;
case -3 :
sel.insert(1.0, &qg1);
break;
case -4 :
sel.insert(1.0, &qg2);
break;
case -5 :
sel.insert(1.0, &qbarg1);
break;
case -6 :
sel.insert(1.0, &qbarg2);
break;
}
return sel;
}
double MEPP2GammaJet::me2() const {
// total matrix element and the various components
double me(0.);
// first case, q qbar to gluon photon
if(mePartonData()[0]->id()==-mePartonData()[1]->id()) {
// order of the particles
unsigned int iq(1),iqb(0),ip(3),ig(2);
if(mePartonData()[0]->id()>0) swap(iq,iqb);
if(mePartonData()[3]->id()==ParticleID::g) swap(ig, ip);
// calculate the spinors and polarization vectors
vector<SpinorWaveFunction> fin;
vector<SpinorBarWaveFunction> ain;
vector<VectorWaveFunction> pout,gout;
SpinorWaveFunction qin (meMomenta()[iq ],mePartonData()[iq ],incoming);
SpinorBarWaveFunction qbin(meMomenta()[iqb],mePartonData()[iqb],incoming);
VectorWaveFunction glout(meMomenta()[ig ],mePartonData()[ig ],outgoing);
VectorWaveFunction phout(meMomenta()[ip ],mePartonData()[ip ],outgoing);
for(unsigned int ix=0;ix<2;++ix) {
qin.reset(ix) ; fin.push_back( qin );
qbin.reset(ix) ; ain.push_back( qbin);
glout.reset(2*ix);gout.push_back(glout);
phout.reset(2*ix);pout.push_back(phout);
}
// calculate the matrix element
me = qqbarME(fin,ain,gout,pout,false)/9.;
-// Energy2 mt(scale());
-// double coupling=sqr(4.*pi)*SM().alphaEM(0.)*SM().alphaS(mt)*
-// sqr(mePartonData()[0]->charge());
-// Energy2 t(tHat()),u(uHat());
-// double me2=8./9./u/t*(t*t+u*u)*coupling;
-// cerr << "testing matrix element A"
-// << me << " "
-// << me2 << " " << me/me2
-// << endl;
+// Energy2 mt(scale());
+// double coupling=sqr(4.*Constants::pi)*SM().alphaEM(ZERO)*SM().alphaS(mt)*
+// sqr(mePartonData()[0]->iCharge()/3.);
+// Energy2 t(tHat()),u(uHat());
+// double me2=8./9./u/t*(t*t+u*u)*coupling;
+// cerr << "testing matrix element A"
+// << me << " "
+// << me2 << " " << me/me2
+// << endl;
}
else if(mePartonData()[0]->id()>0&&mePartonData()[1]->id()) {
// order of the particles
unsigned int iqin(0),iqout(2),ip(3),ig(1);
if(mePartonData()[0]->id()==ParticleID::g ) swap(iqin,ig);
if(mePartonData()[2]->id()==ParticleID::gamma) swap(ip,iqout);
// calculate the spinors and polarization vectors
vector<SpinorWaveFunction> fin;
vector<SpinorBarWaveFunction> fout;
vector<VectorWaveFunction> pout,gin;
SpinorWaveFunction qin (meMomenta()[iqin ],mePartonData()[iqin ],incoming);
SpinorBarWaveFunction qout(meMomenta()[iqout],mePartonData()[iqout],outgoing);
VectorWaveFunction glin(meMomenta()[ig ],mePartonData()[ig ],incoming);
VectorWaveFunction phout(meMomenta()[ip ],mePartonData()[ip ],outgoing);
for(unsigned int ix=0;ix<2;++ix) {
qin.reset(ix) ;fin.push_back( qin );
qout.reset(ix) ;fout.push_back( qout);
glin.reset(2*ix) ;gin.push_back( glin);
phout.reset(2*ix);pout.push_back(phout);
}
// calculate the matrix element
me = qgME(fin,gin,pout,fout,false)/24.;
-// Energy2 mt(scale());
-// double coupling=sqr(4.*pi)*SM().alphaEM(0.)*SM().alphaS(mt);
-// Energy2 s(sHat()),t(tHat()),u(uHat());
-// double me2=-1./3./s/t*(s*s+t*t+2.*u*(s+t+u))*coupling*
-// sqr(mePartonData()[0]->charge());
-// cerr << "testing matrix element B"
-// << me << " "
-// << me2 << " " << me/me2
-// << endl;
+// Energy2 mt(scale());
+// double coupling=sqr(4.*Constants::pi)*SM().alphaEM(ZERO)*SM().alphaS(mt);
+// Energy2 s(sHat()),t(tHat()),u(uHat());
+// double me2=-1./3./s/t*(s*s+t*t+2.*u*(s+t+u))*coupling*
+// sqr(mePartonData()[0]->iCharge()/3.);
+// cerr << "testing matrix element B"
+// << me << " "
+// << me2 << " " << me/me2
+// << endl;
}
else {
// order of the particles
unsigned int iqin(0),iqout(2),ip(3),ig(1);
if(mePartonData()[0]->id()==ParticleID::g ) swap(iqin,ig);
if(mePartonData()[2]->id()==ParticleID::gamma) swap(ip,iqout);
// calculate the spinors and polarization vectors
vector<SpinorBarWaveFunction> ain;
vector<SpinorWaveFunction> aout;
vector<VectorWaveFunction> pout,gin;
SpinorBarWaveFunction qin (meMomenta()[iqin ],mePartonData()[iqin ],incoming);
SpinorWaveFunction qout(meMomenta()[iqout],mePartonData()[iqout],outgoing);
VectorWaveFunction glin(meMomenta()[ig ],mePartonData()[ig ],incoming);
VectorWaveFunction phout(meMomenta()[ip ],mePartonData()[ip ],outgoing);
for(unsigned int ix=0;ix<2;++ix) {
qin.reset(ix) ;ain.push_back( qin );
qout.reset(ix) ;aout.push_back( qout);
glin.reset(2*ix) ;gin.push_back( glin);
phout.reset(2*ix);pout.push_back(phout);
}
// calculate the matrix element
me=qbargME(ain,gin,pout,aout,false)/24.;
-// Energy2 mt(scale());
-// double coupling=sqr(4.*pi)*SM().alphaEM(0.)*SM().alphaS(mt);
-// Energy2 s(sHat()),t(tHat()),u(uHat());
-// double me2=-1./3./s/t*(s*s+t*t+2.*u*(s+t+u))*coupling*
-// sqr(mePartonData()[0]->charge());
-// cerr << "testing matrix element C"
-// << me << " "
-// << me2 << " " << me/me2
-// << endl;
+// Energy2 mt(scale());
+// double coupling=sqr(4.*Constants::pi)*SM().alphaEM(ZERO)*SM().alphaS(mt);
+// Energy2 s(sHat()),t(tHat()),u(uHat());
+// double me2=-1./3./s/t*(s*s+t*t+2.*u*(s+t+u))*coupling*
+// sqr(mePartonData()[0]->iCharge()/3.);
+// cerr << "testing matrix element C"
+// << me << " "
+// << me2 << " " << me/me2
+// << endl;
}
return me;
}
double MEPP2GammaJet::qqbarME(vector<SpinorWaveFunction> & fin,
vector<SpinorBarWaveFunction> & ain,
vector<VectorWaveFunction> & gout,
vector<VectorWaveFunction> & pout,
bool calc) const {
// the particles should be in the order
// for the incoming
// 0 incoming fermion (u spinor)
// 1 incoming antifermion (vbar spinor)
// for the outgoing
// 0 outgoing gluon
// 1 outgoing photon
// me to be returned
ProductionMatrixElement newme(PDT::Spin1Half,PDT::Spin1Half,
PDT::Spin1,PDT::Spin1);
// wavefunction for the intermediate particles
SpinorWaveFunction inter;
unsigned int inhel1,inhel2,outhel1,outhel2;
Energy2 mt(scale());
Complex diag[3];
double me(0.),diag1(0.),diag2(0.);
for(inhel1=0;inhel1<2;++inhel1) {
for(inhel2=0;inhel2<2;++inhel2) {
for(outhel1=0;outhel1<2;++outhel1) {
for(outhel2=0;outhel2<2;++outhel2) {
// first diagram
inter = _gluonvertex->evaluate(mt,5,fin[inhel1].particle()->CC(),
fin[inhel1],gout[outhel1]);
diag[0] = _photonvertex->evaluate(ZERO,inter,ain[inhel2],pout[outhel2]);
// second diagram
inter = _photonvertex->evaluate(ZERO,5,fin[inhel1].particle()->CC(),
fin[inhel1],pout[outhel2]);
diag[1] = _gluonvertex->evaluate(mt,inter,ain[inhel2],gout[outhel1]);
// compute the running totals
diag[2]=diag[0]+diag[1];
diag1 +=norm(diag[0]);
diag2 +=norm(diag[1]);
me +=norm(diag[2]);
// matrix element
if(calc) newme(inhel1,inhel2,2*outhel1,2*outhel2)=diag[2];
}
}
}
}
// save the info on the diagrams
if(!calc) {
DVector save;
save.push_back(diag1);
save.push_back(diag2);
meInfo(save);
}
// return the answer
if(calc) _me.reset(newme);
return me;
}
double MEPP2GammaJet::qgME(vector<SpinorWaveFunction> & fin,
vector<VectorWaveFunction> & gin,
vector<VectorWaveFunction> & pout,
vector<SpinorBarWaveFunction> & fout,
bool calc) const {
// the particles should be in the order
// for the incoming
// 0 incoming fermion (u spinor)
// 1 incoming gluon
// for the outgoing
// 0 outgoing photon
// 1 outgoing fermion (ubar spinor)
// me to be returned
ProductionMatrixElement newme(PDT::Spin1Half,PDT::Spin1,
PDT::Spin1,PDT::Spin1Half);
// wavefunction for the intermediate particles
SpinorWaveFunction inter;
unsigned int inhel1,inhel2,outhel1,outhel2;
Energy2 mt(scale());
Complex diag[3];
double me(0.),diag1(0.),diag2(0.);
for(inhel1=0;inhel1<2;++inhel1) {
for(inhel2=0;inhel2<2;++inhel2) {
for(outhel1=0;outhel1<2;++outhel1) {
for(outhel2=0;outhel2<2;++outhel2) {
// first diagram
inter = _photonvertex->evaluate(ZERO,5,fin[inhel1].particle()->CC(),
fin[inhel1],pout[outhel1]);
diag[0]=_gluonvertex->evaluate(mt,inter,fout[outhel2],gin[inhel2]);
// second diagram
inter = _gluonvertex->evaluate(mt,5,fin[inhel1].particle()->CC(),
fin[inhel1],gin[inhel2]);
diag[1]=_photonvertex->evaluate(ZERO,inter,fout[outhel2],pout[outhel1]);
// compute the running totals
diag[2]=diag[0]+diag[1];
diag1 +=norm(diag[0]);
diag2 +=norm(diag[1]);
me +=norm(diag[2]);
// matrix element
if(calc) newme(inhel1,2*inhel2,2*outhel1,outhel2)=diag[2];
}
}
}
}
// save the info on the diagrams
if(!calc) {
DVector save;
save.push_back(diag1);
save.push_back(diag2);
meInfo(save);
}
// return the answer
if(calc) _me.reset(newme);
return me;
}
double MEPP2GammaJet::qbargME(vector<SpinorBarWaveFunction> & ain,
vector<VectorWaveFunction> & gin,
vector<VectorWaveFunction> & pout,
vector<SpinorWaveFunction> & aout,
bool calc) const {
// the particles should be in the order
// for the incoming
// 0 incoming fermion (vbar spinor)
// 1 incoming gluon
// for the outgoing
// 0 outgoing photon
// 1 outgoing fermion (v spinor)
//me to be returned
ProductionMatrixElement newme(PDT::Spin1Half,PDT::Spin1,
PDT::Spin1,PDT::Spin1Half);
// wavefunction for the intermediate particles
SpinorBarWaveFunction inter;
SpinorWaveFunction interb;
unsigned int inhel1,inhel2,outhel1,outhel2;
Energy2 mt(scale());
Complex diag[3];
double me(0.),diag1(0.),diag2(0.);
for(inhel1=0;inhel1<2;++inhel1) {
for(inhel2=0;inhel2<2;++inhel2) {
for(outhel1=0;outhel1<2;++outhel1) {
for(outhel2=0;outhel2<2;++outhel2) {
// first diagram
inter = _photonvertex->evaluate(ZERO,5,ain[inhel1].particle()->CC(),
ain[inhel1],pout[outhel1]);
diag[0]=_gluonvertex->evaluate(mt,aout[outhel2],inter,gin[inhel2]);
// second diagram
inter = _gluonvertex->evaluate(mt,5,ain[inhel1].particle()->CC(),
ain[inhel1],gin[inhel2]);
diag[1]=_photonvertex->evaluate(ZERO,aout[outhel2],inter,pout[outhel1]);
// compute the running totals
diag[2]=diag[0]+diag[1];
diag1 +=norm(diag[0]);
diag2 +=norm(diag[1]);
me +=norm(diag[2]);
// matrix element
if(calc) newme(inhel1,2*inhel2,2*outhel1,outhel2)=diag[2];
}
}
}
}
// save the info on the diagrams
if(!calc) {
DVector save;
save.push_back(diag1);
save.push_back(diag2);
meInfo(save);
}
// return the answer
if(calc) _me.reset(newme);
return me;
}
void MEPP2GammaJet::constructVertex(tSubProPtr sub) {
// extract the particles in the hard process
ParticleVector hard;
hard.push_back(sub->incoming().first);hard.push_back(sub->incoming().second);
hard.push_back(sub->outgoing()[0]);hard.push_back(sub->outgoing()[1]);
// order of particles
unsigned int order[4]={0,1,2,3};
// identify the process and calculate matrix element
if(hard[0]->id()==ParticleID::g||hard[1]->id()==ParticleID::g) {
if(hard[0]->id()==ParticleID::g ) swap(order[0],order[1]);
if(hard[3]->id()==ParticleID::gamma) swap(order[2],order[3]);
if(hard[order[0]]->id()>0) {
vector<SpinorWaveFunction> q;
vector<SpinorBarWaveFunction> qb;
vector<VectorWaveFunction> p,g;
SpinorWaveFunction (q ,hard[order[0]],incoming,false,true);
VectorWaveFunction (g ,hard[order[1]],incoming,false,true,true);
VectorWaveFunction (p ,hard[order[2]],outgoing,true ,true,true);
SpinorBarWaveFunction(qb,hard[order[3]],outgoing,true,true);
qgME(q,g,p,qb,true);
}
else {
vector<SpinorWaveFunction> q;
vector<SpinorBarWaveFunction> qb;
vector<VectorWaveFunction> p,g;
SpinorBarWaveFunction(qb,hard[order[0]],incoming,false,true);
VectorWaveFunction (g ,hard[order[1]],incoming,false,true,true);
VectorWaveFunction (p ,hard[order[2]],outgoing,true ,true,true);
SpinorWaveFunction (q ,hard[order[3]],outgoing,true,true);
qbargME(qb,g,p,q,true);
}
}
else {
if(hard[0]->id()<0) swap(order[0],order[1]);
if(hard[2]->id()==ParticleID::gamma) swap(order[2],order[3]);
vector<SpinorWaveFunction> q;
vector<SpinorBarWaveFunction> qb;
vector<VectorWaveFunction> p,g;
SpinorWaveFunction (q ,hard[order[0]],incoming,false,true);
SpinorBarWaveFunction(qb,hard[order[1]],incoming,false,true);
VectorWaveFunction (g ,hard[order[2]],outgoing,true ,true,true);
VectorWaveFunction (p ,hard[order[3]],outgoing,true ,true,true);
p[1]=p[2];g[1]=g[2];
qqbarME(q,qb,g,p,true);
}
// construct the vertex
HardVertexPtr hardvertex=new_ptr(HardVertex());
// set the matrix element for the vertex
hardvertex->ME(_me);
// set the pointers and to and from the vertex
for(unsigned int ix=0;ix<4;++ix)
hard[order[ix]]->spinInfo()->productionVertex(hardvertex);
}
diff --git a/MatrixElement/Matchbox/MatchboxFactory.cc b/MatrixElement/Matchbox/MatchboxFactory.cc
--- a/MatrixElement/Matchbox/MatchboxFactory.cc
+++ b/MatrixElement/Matchbox/MatchboxFactory.cc
@@ -1,786 +1,788 @@
// -*- C++ -*-
//
// MatchboxFactory.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
// Copyright (C) 2002-2012 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 MatchboxFactory class.
//
#include "MatchboxFactory.h"
#include "ThePEG/Interface/ClassDocumentation.h"
#include "ThePEG/Utilities/DescribeClass.h"
#include "ThePEG/Interface/Reference.h"
#include "ThePEG/Interface/RefVector.h"
#include "ThePEG/Interface/Switch.h"
#include "ThePEG/Interface/Parameter.h"
#include "ThePEG/Interface/Command.h"
#include "ThePEG/Utilities/StringUtils.h"
#include "ThePEG/Repository/Repository.h"
#include "ThePEG/Repository/EventGenerator.h"
#include "ThePEG/Persistency/PersistentOStream.h"
#include "ThePEG/Persistency/PersistentIStream.h"
#include "Herwig++/MatrixElement/Matchbox/Base/DipoleRepository.h"
using namespace Herwig;
using std::ostream_iterator;
MatchboxFactory::MatchboxFactory()
: SubProcessHandler(), theNLight(0),
theOrderInAlphaS(0), theOrderInAlphaEW(0),
theBornContributions(true), theVirtualContributions(true),
theRealContributions(true), theSubProcessGroups(false),
theFactorizationScaleFactor(1.0), theRenormalizationScaleFactor(1.0),
theFixedCouplings(false), theVetoScales(false),
theVerbose(false), theSubtractionData("") {}
MatchboxFactory::~MatchboxFactory() {}
IBPtr MatchboxFactory::clone() const {
return new_ptr(*this);
}
IBPtr MatchboxFactory::fullclone() const {
return new_ptr(*this);
}
void MatchboxFactory::prepareME(Ptr<MatchboxMEBase>::ptr me) const {
Ptr<MatchboxAmplitude>::ptr amp =
dynamic_ptr_cast<Ptr<MatchboxAmplitude>::ptr>((*me).amplitude());
me->matchboxAmplitude(amp);
if ( diagramGenerator() && !me->diagramGenerator() )
me->diagramGenerator(diagramGenerator());
if ( me->nLight() == 0 )
me->nLight(nLight());
if ( phasespace() && !me->phasespace() )
me->phasespace(phasespace());
if ( scaleChoice() && !me->scaleChoice() )
me->scaleChoice(scaleChoice());
if ( me->factorizationScaleFactor() == 1.0 )
me->factorizationScaleFactor(factorizationScaleFactor());
if ( me->renormalizationScaleFactor() == 1.0 )
me->renormalizationScaleFactor(renormalizationScaleFactor());
if ( fixedCouplings() )
me->setFixedCouplings();
if ( cache() && !me->cache() )
me->cache(cache());
if ( verbose() )
me->setVerbose();
}
struct ProjectQN {
inline pair<int,pair<int,int> > operator()(PDPtr p) const {
return
pair<int,pair<int,int> >((*p).iSpin(),pair<int,int>((*p).iCharge(),(*p).iColour()));
}
};
string pid(const vector<pair<int,pair<int,int> > >& key) {
ostringstream res;
for ( vector<pair<int,pair<int,int> > >::const_iterator k =
key.begin(); k != key.end(); ++k )
res << k->first << k->second.first
<< k->second.second;
return res.str();
}
vector<Ptr<MatchboxMEBase>::ptr> MatchboxFactory::
makeMEs(const vector<string>& proc, unsigned int orderas) const {
typedef vector<pair<int,pair<int,int> > > QNKey;
map<Ptr<MatchboxAmplitude>::ptr,map<QNKey,vector<PDVector> > > ampProcs;
set<PDVector> processes = makeSubProcesses(proc);
for ( vector<Ptr<MatchboxAmplitude>::ptr>::const_iterator amp
= amplitudes().begin(); amp != amplitudes().end(); ++amp ) {
(**amp).orderInGs(orderas);
(**amp).orderInGem(orderInAlphaEW());
if ( (**amp).orderInGs() != orderas ||
(**amp).orderInGem() != orderInAlphaEW() )
continue;
for ( set<PDVector>::const_iterator p = processes.begin();
p != processes.end(); ++p ) {
if ( !(**amp).canHandle(*p) )
continue;
QNKey key;
transform(p->begin(),p->end(),back_inserter(key),ProjectQN());
ampProcs[*amp][key].push_back(*p);
}
}
vector<Ptr<MatchboxMEBase>::ptr> res;
for ( map<Ptr<MatchboxAmplitude>::ptr,map<QNKey,vector<PDVector> > >::const_iterator
ap = ampProcs.begin(); ap != ampProcs.end(); ++ap ) {
for ( map<QNKey,vector<PDVector> >::const_iterator m = ap->second.begin();
m != ap->second.end(); ++m ) {
Ptr<MatchboxMEBase>::ptr me = ap->first->makeME(m->second);
me->subProcesses() = m->second;
me->amplitude(ap->first);
string pname = "ME" + ap->first->name() + pid(m->first);
if ( ! (generator()->preinitRegister(me,pname) ) )
throw InitException() << "Matrix element " << pname << " already existing.";
res.push_back(me);
}
}
return res;
}
void MatchboxFactory::setup() {
if ( !amplitudes().empty() ) {
if ( particleGroups().find("j") == particleGroups().end() )
throw InitException() << "Could not find a jet particle group named 'j'";
// rebind the particle data objects
for ( map<string,PDVector>::iterator g = particleGroups().begin();
g != particleGroups().end(); ++g )
for ( PDVector::iterator p = g->second.begin();
p != g->second.end(); ++p ) {
+#ifndef NDEBUG
long checkid = (**p).id();
+#endif
*p = getParticleData((**p).id());
assert((**p).id() == checkid);
}
const PDVector& partons = particleGroups()["j"];
unsigned int nl = 0;
for ( PDVector::const_iterator p = partons.begin();
p != partons.end(); ++p )
if ( abs((**p).id()) < 6 )
++nl;
nLight(nl/2);
vector<Ptr<MatchboxMEBase>::ptr> ames = makeMEs(process,orderInAlphaS());
copy(ames.begin(),ames.end(),back_inserter(bornMEs()));
if ( realContributions() ) {
vector<string> rproc = process;
rproc.push_back("j");
ames = makeMEs(rproc,orderInAlphaS()+1);
copy(ames.begin(),ames.end(),back_inserter(realEmissionMEs()));
}
}
// check if we have virtual contributions
bool haveVirtuals = true;
// check DR conventions of virtual contributions
bool virtualsAreDR = false;
bool virtualsAreCDR = false;
// check finite term conventions of virtual contributions
bool virtualsAreCS = false;
bool virtualsAreStandard = false;
// check and prepare the Born and virtual matrix elements
for ( vector<Ptr<MatchboxMEBase>::ptr>::iterator born
= bornMEs().begin(); born != bornMEs().end(); ++born ) {
prepareME(*born);
haveVirtuals &= (**born).haveOneLoop();
if ( (**born).haveOneLoop() ) {
virtualsAreDR |= (**born).isDR();
virtualsAreCDR |= !(**born).isDR();
virtualsAreCS |= (**born).isCS();
virtualsAreStandard |= !(**born).isCS();
}
}
// check the additional insertion operators
if ( !virtuals().empty() )
haveVirtuals = true;
for ( vector<Ptr<MatchboxInsertionOperator>::ptr>::const_iterator virt
= virtuals().begin(); virt != virtuals().end(); ++virt ) {
virtualsAreDR |= (**virt).isDR();
virtualsAreCDR |= !(**virt).isDR();
virtualsAreCS |= (**virt).isCS();
virtualsAreStandard |= !(**virt).isCS();
}
// check for consistent conventions on virtuals, if we are to include them
if ( virtualContributions() ) {
if ( virtualsAreDR && virtualsAreCDR ) {
throw InitException() << "Virtual corrections use inconsistent regularization schemes.\n";
}
if ( virtualsAreCS && virtualsAreStandard ) {
throw InitException() << "Virtual corrections use inconsistent conventions on finite terms.\n";
}
if ( !haveVirtuals ) {
throw InitException() << "Could not find amplitudes for all virtual contributions needed.\n";
}
}
// prepare dipole insertion operators
if ( virtualContributions() ) {
for ( vector<Ptr<MatchboxInsertionOperator>::ptr>::const_iterator virt
= DipoleRepository::insertionOperators().begin();
virt != DipoleRepository::insertionOperators().end(); ++virt ) {
if ( virtualsAreDR )
(**virt).useDR();
else
(**virt).useCDR();
if ( virtualsAreCS )
(**virt).useCS();
else
(**virt).useNonCS();
}
}
// prepare the real emission matrix elements
if ( realContributions() ) {
for ( vector<Ptr<MatchboxMEBase>::ptr>::iterator real
= realEmissionMEs().begin(); real != realEmissionMEs().end(); ++real ) {
prepareME(*real);
}
}
// start creating matrix elements
MEs().clear();
// setup born and virtual contributions
if ( !bornContributions() && virtualContributions() ) {
throw InitException() << "Virtual corrections without Born contributions not yet supported.\n";
}
if ( bornContributions() && !virtualContributions() ) {
for ( vector<Ptr<MatchboxMEBase>::ptr>::iterator born
= bornMEs().begin(); born != bornMEs().end(); ++born ) {
if ( (**born).onlyOneLoop() )
continue;
Ptr<MatchboxMEBase>::ptr bornme = (**born).cloneMe();
string pname = fullName() + "/" + (**born).name();
if ( ! (generator()->preinitRegister(bornme,pname) ) )
throw InitException() << "Matrix element " << pname << " already existing.";
bornme->cloneDependencies();
MEs().push_back(bornme);
}
}
if ( bornContributions() && virtualContributions() ) {
bornVirtualMEs().clear();
for ( vector<Ptr<MatchboxMEBase>::ptr>::iterator born
= bornMEs().begin(); born != bornMEs().end(); ++born ) {
Ptr<MatchboxNLOME>::ptr nlo = new_ptr(MatchboxNLOME());
string pname = fullName() + "/" + (**born).name();
if ( ! (generator()->preinitRegister(nlo,pname) ) )
throw InitException() << "NLO ME " << pname << " already existing.";
nlo->matrixElement(*born);
nlo->virtuals().clear();
if ( !nlo->matrixElement()->onlyOneLoop() ) {
for ( vector<Ptr<MatchboxInsertionOperator>::ptr>::const_iterator virt
= virtuals().begin(); virt != virtuals().end(); ++virt ) {
if ( (**virt).apply((**born).diagrams().front()->partons()) )
nlo->virtuals().push_back(*virt);
}
for ( vector<Ptr<MatchboxInsertionOperator>::ptr>::const_iterator virt
= DipoleRepository::insertionOperators().begin();
virt != DipoleRepository::insertionOperators().end(); ++virt ) {
if ( (**virt).apply((**born).diagrams().front()->partons()) )
nlo->virtuals().push_back(*virt);
}
if ( nlo->virtuals().empty() )
throw InitException() << "No insertion operators have been found for "
<< (**born).name() << "\n";
}
nlo->cloneDependencies();
bornVirtualMEs().push_back(nlo);
MEs().push_back(nlo);
}
}
if ( realContributions() ) {
if ( theSubtractionData != "" )
if ( theSubtractionData[theSubtractionData.size()-1] != '/' )
theSubtractionData += "/";
subtractedMEs().clear();
for ( vector<Ptr<MatchboxMEBase>::ptr>::iterator real
= realEmissionMEs().begin(); real != realEmissionMEs().end(); ++real ) {
Ptr<SubtractedME>::ptr sub = new_ptr(SubtractedME());
string pname = fullName() + "/" + (**real).name();
if ( ! (generator()->preinitRegister(sub,pname) ) )
throw InitException() << "Subtracted ME " << pname << " already existing.";
sub->borns() = bornMEs();
sub->head(*real);
sub->allDipoles().clear();
sub->dependent().clear();
sub->getDipoles();
if ( verbose() )
sub->setVerbose();
if ( subProcessGroups() )
sub->setSubProcessGroups();
if ( vetoScales() )
sub->doVetoScales();
if ( subtractionData() != "" )
sub->subtractionData(subtractionData());
subtractedMEs().push_back(sub);
MEs().push_back(sub);
}
}
}
void MatchboxFactory::print(ostream& os) const {
os << "--- MatchboxFactory setup -----------------------------------------------------------\n";
if ( !amplitudes().empty() ) {
os << " generated Born matrix elements:\n";
for ( vector<Ptr<MatchboxMEBase>::ptr>::const_iterator m = bornMEs().begin();
m != bornMEs().end(); ++m ) {
os << " '" << (**m).name() << "' for subprocesses:\n";
for ( vector<PDVector>::const_iterator p = (**m).subProcesses().begin();
p != (**m).subProcesses().end(); ++p ) {
os << " ";
for ( PDVector::const_iterator pp = p->begin();
pp != p->end(); ++pp ) {
os << (**pp).PDGName() << " ";
if ( pp == p->begin() + 1 )
os << "-> ";
}
os << "\n";
}
}
os << flush;
os << " generated real emission matrix elements:\n";
for ( vector<Ptr<MatchboxMEBase>::ptr>::const_iterator m = realEmissionMEs().begin();
m != realEmissionMEs().end(); ++m ) {
os << " '" << (**m).name() << "' for subprocesses:\n";
for ( vector<PDVector>::const_iterator p = (**m).subProcesses().begin();
p != (**m).subProcesses().end(); ++p ) {
os << " ";
for ( PDVector::const_iterator pp = p->begin();
pp != p->end(); ++pp ) {
os << (**pp).PDGName() << " ";
if ( pp == p->begin() + 1 )
os << "-> ";
}
os << "\n";
}
}
os << flush;
}
os << " generated Born+virtual matrix elements:\n";
for ( vector<Ptr<MatchboxNLOME>::ptr>::const_iterator bv
= bornVirtualMEs().begin(); bv != bornVirtualMEs().end(); ++bv ) {
(**bv).print(os);
}
os << " generated subtracted matrix elements:\n";
for ( vector<Ptr<SubtractedME>::ptr>::const_iterator sub
= subtractedMEs().begin(); sub != subtractedMEs().end(); ++sub ) {
os << " '" << (**sub).name() << "'\n";
}
os << "--------------------------------------------------------------------------------\n";
os << flush;
}
void MatchboxFactory::doinit() {
setup();
if ( theVerbose )
print(Repository::clog());
SubProcessHandler::doinit();
}
void MatchboxFactory::persistentOutput(PersistentOStream & os) const {
os << theDiagramGenerator
<< theNLight << theOrderInAlphaS << theOrderInAlphaEW
<< theBornContributions << theVirtualContributions
<< theRealContributions << theSubProcessGroups
<< thePhasespace << theScaleChoice
<< theFactorizationScaleFactor << theRenormalizationScaleFactor
<< theFixedCouplings << theVetoScales
<< theAmplitudes << theCache
<< theBornMEs << theVirtuals << theRealEmissionMEs
<< theBornVirtualMEs << theSubtractedMEs
<< theVerbose << theSubtractionData
<< theParticleGroups << process;
}
void MatchboxFactory::persistentInput(PersistentIStream & is, int) {
is >> theDiagramGenerator
>> theNLight >> theOrderInAlphaS >> theOrderInAlphaEW
>> theBornContributions >> theVirtualContributions
>> theRealContributions >> theSubProcessGroups
>> thePhasespace >> theScaleChoice
>> theFactorizationScaleFactor >> theRenormalizationScaleFactor
>> theFixedCouplings >> theVetoScales
>> theAmplitudes >> theCache
>> theBornMEs >> theVirtuals >> theRealEmissionMEs
>> theBornVirtualMEs >> theSubtractedMEs
>> theVerbose >> theSubtractionData
>> theParticleGroups >> process;
}
string MatchboxFactory::startParticleGroup(string name) {
particleGroupName = StringUtils::stripws(name);
particleGroup.clear();
return "";
}
string MatchboxFactory::endParticleGroup(string) {
if ( particleGroup.empty() )
throw InitException() << "Empty particle group.";
particleGroups()[particleGroupName] = particleGroup;
particleGroup.clear();
return "";
}
string MatchboxFactory::doProcess(string in) {
process = StringUtils::split(in);
if ( process.size() < 3 )
throw InitException() << "Invalid process.";
for ( vector<string>::iterator p = process.begin();
p != process.end(); ++p ) {
*p = StringUtils::stripws(*p);
}
return "";
}
struct SortPID {
inline bool operator()(PDPtr a, PDPtr b) const {
return a->id() < b->id();
}
};
set<PDVector> MatchboxFactory::
makeSubProcesses(const vector<string>& proc) const {
if ( proc.empty() )
throw InitException() << "No process specified.";
vector<PDVector> allProcs(1);
size_t pos = 0;
typedef map<string,PDVector>::const_iterator GroupIterator;
while ( pos < proc.size() ) {
GroupIterator git =
particleGroups().find(proc[pos]);
if ( git == particleGroups().end() ) {
throw InitException() << "particle group '"
<< proc[pos] << "' not defined.";
}
vector<PDVector> mine;
for ( vector<PDVector>::const_iterator i = allProcs.begin();
i != allProcs.end(); ++i ) {
for ( PDVector::const_iterator p = git->second.begin();
p != git->second.end(); ++p ) {
PDVector v = *i;
v.push_back(*p);
mine.push_back(v);
}
}
allProcs = mine;
++pos;
}
set<PDVector> allCheckedProcs;
for ( vector<PDVector>::const_iterator p = allProcs.begin();
p != allProcs.end(); ++p ) {
int charge = -(*p)[0]->iCharge() -(*p)[1]->iCharge();
for ( size_t k = 2; k < (*p).size(); ++k )
charge += (*p)[k]->iCharge();
if ( charge != 0 )
continue;
PDVector pr = *p;
sort(pr.begin()+2,pr.end(),SortPID());
allCheckedProcs.insert(pr);
}
return allCheckedProcs;
}
void MatchboxFactory::Init() {
static ClassDocumentation<MatchboxFactory> documentation
("MatchboxFactory",
"NLO QCD corrections have been calculated "
"using Matchbox \\cite{Platzer:2011bc}",
"%\\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 Reference<MatchboxFactory,Tree2toNGenerator> interfaceDiagramGenerator
("DiagramGenerator",
"Set the diagram generator.",
&MatchboxFactory::theDiagramGenerator, false, false, true, true, false);
static Parameter<MatchboxFactory,unsigned int> interfaceOrderInAlphaS
("OrderInAlphaS",
"The order in alpha_s to consider.",
&MatchboxFactory::theOrderInAlphaS, 0, 0, 0,
false, false, Interface::lowerlim);
static Parameter<MatchboxFactory,unsigned int> interfaceOrderInAlphaEW
("OrderInAlphaEW",
"The order in alpha_EW",
&MatchboxFactory::theOrderInAlphaEW, 2, 0, 0,
false, false, Interface::lowerlim);
static Switch<MatchboxFactory,bool> interfaceBornContributions
("BornContributions",
"Switch on or off the Born contributions.",
&MatchboxFactory::theBornContributions, true, false, false);
static SwitchOption interfaceBornContributionsOn
(interfaceBornContributions,
"On",
"Switch on Born contributions.",
true);
static SwitchOption interfaceBornContributionsOff
(interfaceBornContributions,
"Off",
"Switch off Born contributions.",
false);
static Switch<MatchboxFactory,bool> interfaceVirtualContributions
("VirtualContributions",
"Switch on or off the virtual contributions.",
&MatchboxFactory::theVirtualContributions, true, false, false);
static SwitchOption interfaceVirtualContributionsOn
(interfaceVirtualContributions,
"On",
"Switch on virtual contributions.",
true);
static SwitchOption interfaceVirtualContributionsOff
(interfaceVirtualContributions,
"Off",
"Switch off virtual contributions.",
false);
static Switch<MatchboxFactory,bool> interfaceRealContributions
("RealContributions",
"Switch on or off the real contributions.",
&MatchboxFactory::theRealContributions, true, false, false);
static SwitchOption interfaceRealContributionsOn
(interfaceRealContributions,
"On",
"Switch on real contributions.",
true);
static SwitchOption interfaceRealContributionsOff
(interfaceRealContributions,
"Off",
"Switch off real contributions.",
false);
static Switch<MatchboxFactory,bool> interfaceSubProcessGroups
("SubProcessGroups",
"Switch on or off production of sub-process groups.",
&MatchboxFactory::theSubProcessGroups, false, false, false);
static SwitchOption interfaceSubProcessGroupsOn
(interfaceSubProcessGroups,
"On",
"On",
true);
static SwitchOption interfaceSubProcessGroupsOff
(interfaceSubProcessGroups,
"Off",
"Off",
false);
static Reference<MatchboxFactory,MatchboxPhasespace> interfacePhasespace
("Phasespace",
"Set the phasespace generator.",
&MatchboxFactory::thePhasespace, false, false, true, true, false);
static Reference<MatchboxFactory,MatchboxScaleChoice> interfaceScaleChoice
("ScaleChoice",
"Set the scale choice object.",
&MatchboxFactory::theScaleChoice, false, false, true, true, false);
static Parameter<MatchboxFactory,double> interfaceFactorizationScaleFactor
("FactorizationScaleFactor",
"The factorization scale factor.",
&MatchboxFactory::theFactorizationScaleFactor, 1.0, 0.0, 0,
false, false, Interface::lowerlim);
static Parameter<MatchboxFactory,double> interfaceRenormalizationScaleFactor
("RenormalizationScaleFactor",
"The renormalization scale factor.",
&MatchboxFactory::theRenormalizationScaleFactor, 1.0, 0.0, 0,
false, false, Interface::lowerlim);
static Switch<MatchboxFactory,bool> interfaceFixedCouplings
("FixedCouplings",
"Switch on or off fixed couplings.",
&MatchboxFactory::theFixedCouplings, true, false, false);
static SwitchOption interfaceFixedCouplingsOn
(interfaceFixedCouplings,
"On",
"On",
true);
static SwitchOption interfaceFixedCouplingsOff
(interfaceFixedCouplings,
"Off",
"Off",
false);
static Switch<MatchboxFactory,bool> interfaceVetoScales
("VetoScales",
"Switch on or setting veto scales.",
&MatchboxFactory::theVetoScales, true, false, false);
static SwitchOption interfaceVetoScalesOn
(interfaceVetoScales,
"On",
"On",
true);
static SwitchOption interfaceVetoScalesOff
(interfaceVetoScales,
"Off",
"Off",
false);
static RefVector<MatchboxFactory,MatchboxAmplitude> interfaceAmplitudes
("Amplitudes",
"The amplitude objects.",
&MatchboxFactory::theAmplitudes, -1, false, false, true, true, false);
static Reference<MatchboxFactory,MatchboxMECache> interfaceCache
("Cache",
"Set the matrix element cache object.",
&MatchboxFactory::theCache, false, false, true, true, false);
static RefVector<MatchboxFactory,MatchboxMEBase> interfaceBornMEs
("BornMEs",
"The Born matrix elements to be used",
&MatchboxFactory::theBornMEs, -1, false, false, true, true, false);
static RefVector<MatchboxFactory,MatchboxInsertionOperator> interfaceVirtuals
("Virtuals",
"The virtual corrections to include",
&MatchboxFactory::theVirtuals, -1, false, false, true, true, false);
static RefVector<MatchboxFactory,MatchboxMEBase> interfaceRealEmissionMEs
("RealEmissionMEs",
"The RealEmission matrix elements to be used",
&MatchboxFactory::theRealEmissionMEs, -1, false, false, true, true, false);
static RefVector<MatchboxFactory,MatchboxNLOME> interfaceBornVirtuals
("BornVirtualMEs",
"The generated Born/virtual contributions",
&MatchboxFactory::theBornVirtualMEs, -1, false, true, true, true, false);
static RefVector<MatchboxFactory,SubtractedME> interfaceSubtractedMEs
("SubtractedMEs",
"The generated Born/virtual contributions",
&MatchboxFactory::theSubtractedMEs, -1, false, true, true, true, false);
static Switch<MatchboxFactory,bool> interfaceVerbose
("Verbose",
"Print full infomation on each evaluated phase space point.",
&MatchboxFactory::theVerbose, false, false, false);
static SwitchOption interfaceVerboseOn
(interfaceVerbose,
"On",
"On",
true);
static SwitchOption interfaceVerboseOff
(interfaceVerbose,
"Off",
"Off",
false);
static Parameter<MatchboxFactory,string> interfaceSubtractionData
("SubtractionData",
"Prefix for subtraction check data.",
&MatchboxFactory::theSubtractionData, "",
false, false);
static RefVector<MatchboxFactory,ParticleData> interfaceParticleGroup
("ParticleGroup",
"The particle group just started.",
&MatchboxFactory::particleGroup, -1, false, false, true, false, false);
static Command<MatchboxFactory> interfaceStartParticleGroup
("StartParticleGroup",
"Start a particle group.",
&MatchboxFactory::startParticleGroup, false);
static Command<MatchboxFactory> interfaceEndParticleGroup
("EndParticleGroup",
"End a particle group.",
&MatchboxFactory::endParticleGroup, false);
static Command<MatchboxFactory> interfaceProcess
("Process",
"Set the process to consider.",
&MatchboxFactory::doProcess, false);
}
// *** Attention *** The following static variable is needed for the type
// description system in ThePEG. Please check that the template arguments
// are correct (the class and its base class), and that the constructor
// arguments are correct (the class name and the name of the dynamically
// loadable library where the class implementation can be found).
DescribeClass<MatchboxFactory,SubProcessHandler>
describeHerwigMatchboxFactory("Herwig::MatchboxFactory", "HwMatchbox.so");
diff --git a/Tests/Rivet/LEP-Powheg-130.in b/Tests/Rivet/LEP-Powheg-130.in
--- a/Tests/Rivet/LEP-Powheg-130.in
+++ b/Tests/Rivet/LEP-Powheg-130.in
@@ -1,29 +1,23 @@
##################################################
# Rivet analyses at the Z pole
##################################################
read LEPBase-Powheg.in
##################################################
# LEP physics parameters (override defaults)
##################################################
cd /Herwig/Generators
set LEPGenerator:EventHandler:LuminosityFunction:Energy 130.
##################################################
# select the analyses
##################################################
-# OPAL event shapes and multiplicities at different energies
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 OPAL_2004_S6132243
-# ALEPH jet and event shapes at many energies
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 ALEPH_2004_S5765862
-# OPAL/JADE jet rates at many energies
-insert /Herwig/Analysis/RivetAnalysis:Analyses 0 JADE_OPAL_2000_S4300807
# OPAL b/c/light multiplicity
insert /Herwig/Analysis/RivetAnalysis:Analyses 0 OPAL_2002_S5361494
##################################################
# Save run for later usage with 'Herwig++ run'
##################################################
cd /Herwig/Generators
saverun LEP-Powheg-130 LEPGenerator
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -1,184 +1,184 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ([2.59])
-AC_INIT([Herwig++],[2.6.0],[herwig@projects.hepforge.org],[Herwig++])
+AC_INIT([Herwig++],[SVN],[herwig@projects.hepforge.org],[Herwig++])
AC_CONFIG_SRCDIR([Utilities/HerwigStrategy.cc])
AC_CONFIG_AUX_DIR([Config])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([Config/config.h])
dnl AC_PRESERVE_HELP_ORDER
AC_CANONICAL_HOST
case "${host}" in
*-darwin[[0156]].*)
AC_MSG_ERROR([Herwig++ requires OS X 10.3 or later])
;;
*-darwin7.*)
if test "x$MACOSX_DEPLOYMENT_TARGET" != "x10.3"; then
AC_MSG_ERROR(
[Please add 'MACOSX_DEPLOYMENT_TARGET=10.3' to the configure line.])
fi
;;
esac
dnl === disable debug symbols by default =====
if test "x$CXXFLAGS" = "x"; then
CXXFLAGS=-O3
fi
if test "x$CFLAGS" = "x"; then
CFLAGS=-O3
fi
dnl Looptools manual requires optimization off
if test "x$FCFLAGS" = "x"; then
FCFLAGS=-O0
fi
dnl ==========================================
AC_LANG([C++])
AM_INIT_AUTOMAKE([1.9 gnu dist-bzip2 -Wall])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
dnl Checks for programs.
AC_PROG_CXX([g++])
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_LN_S
dnl modified search order
AC_PROG_FC([gfortran g95 g77])
dnl xlf95 f95 fort ifort ifc efc pgf95 lf95 ftn xlf90 f90 pgf90 pghpf epcf90 xlf f77 frt pgf77 cf77 fort77 fl32 af77])
AC_LANG_PUSH([Fortran])
AC_MSG_CHECKING([if the Fortran compiler ($FC) works])
AC_COMPILE_IFELSE(
AC_LANG_PROGRAM([],[ print *[,]"Hello"]),
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([A Fortran compiler is required to build Herwig++.])
]
)
AC_LANG_POP([Fortran])
LT_PREREQ([2.2])
LT_INIT([disable-static dlopen pic-only])
dnl ####################################
dnl ####################################
dnl for Doc/fixinterfaces.pl
AC_PATH_PROG(PERL, perl)
HERWIG_CHECK_GSL
HERWIG_CHECK_THEPEG
HERWIG_CHECK_BOOST
HERWIG_COMPILERFLAGS
HERWIG_LOOPTOOLS
HERWIG_PDF_PATH
FASTJET_CHECK_FASTJET
HERWIG_VERSIONSTRING
HERWIG_CHECK_ABS_BUG
HERWIG_ENABLE_MODELS
SHARED_FLAG=-shared
AM_CONDITIONAL(NEED_APPLE_FIXES,
[test "xx${host/darwin/foundit}xx" != "xx${host}xx"])
if test "xx${host/darwin/foundit}xx" != "xx${host}xx"; then
APPLE_DSO_FLAGS=-Wl,-undefined,dynamic_lookup
SHARED_FLAG=-bundle
fi
AC_SUBST([APPLE_DSO_FLAGS])
AC_SUBST([SHARED_FLAG])
AC_CONFIG_FILES([UnderlyingEvent/Makefile
Models/Makefile
Models/StandardModel/Makefile
Models/RSModel/Makefile
Models/General/Makefile
Models/Susy/Makefile
Models/Susy/NMSSM/Makefile
Models/UED/Makefile
Models/Transplanckian/Makefile
Models/Leptoquarks/Makefile
Models/Zprime/Makefile
Models/TTbAsymm/Makefile
Models/ADD/Makefile
Models/Sextet/Makefile
Decay/Makefile
Decay/FormFactors/Makefile
Decay/Tau/Makefile
Decay/Baryon/Makefile
Decay/VectorMeson/Makefile
Decay/Perturbative/Makefile
Decay/ScalarMeson/Makefile
Decay/TensorMeson/Makefile
Decay/WeakCurrents/Makefile
Decay/Partonic/Makefile
Decay/General/Makefile
Decay/Radiation/Makefile
Doc/refman.conf
Doc/refman.h
PDT/Makefile
PDF/Makefile
MatrixElement/Makefile
MatrixElement/General/Makefile
MatrixElement/Lepton/Makefile
MatrixElement/Hadron/Makefile
MatrixElement/DIS/Makefile
MatrixElement/Powheg/Makefile
MatrixElement/Gamma/Makefile
MatrixElement/Matchbox/Makefile
MatrixElement/Matchbox/Base/Makefile
MatrixElement/Matchbox/Utility/Makefile
MatrixElement/Matchbox/Phasespace/Makefile
MatrixElement/Matchbox/Dipoles/Makefile
MatrixElement/Matchbox/InsertionOperators/Makefile
MatrixElement/Matchbox/Powheg/Makefile
MatrixElement/Matchbox/Builtin/Makefile
MatrixElement/Matchbox/Builtin/Processes/Makefile
Exsample2/Makefile
Shower/SplittingFunctions/Makefile
Shower/Default/Makefile
Shower/Base/Makefile
Shower/Makefile
DipoleShower/Makefile
DipoleShower/Base/Makefile
DipoleShower/Kernels/Makefile
DipoleShower/Kinematics/Makefile
DipoleShower/Utility/Makefile
DipoleShower/AlphaS/Makefile
Utilities/Makefile
Hadronization/Makefile
lib/Makefile
include/Makefile
src/Makefile
src/defaults/Makefile
src/herwig-config
Doc/Makefile
Doc/HerwigDefaults.in
Looptools/Makefile
Analysis/Makefile
src/Makefile-UserModules
src/defaults/Analysis.in
Contrib/Makefile
Contrib/make_makefiles.sh
Tests/Makefile
Makefile])
AC_CONFIG_FILES([Doc/fixinterfaces.pl],[chmod +x Doc/fixinterfaces.pl])
HERWIG_OVERVIEW
AC_CONFIG_COMMANDS([summary],[cat config.herwig])
AC_OUTPUT

File Metadata

Mime Type
text/x-diff
Expires
Mon, Jan 20, 8:52 PM (22 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4242342
Default Alt Text
(901 KB)

Event Timeline