Skip to content
Snippets Groups Projects

Pythia DIS

Merged Whitney Armstrong requested to merge dis_pythia into master
8 files
+ 6692
40
Compare changes
  • Side-by-side
  • Inline
Files
8
+ 150
0
<<<<<<< HEAD
// main45.cc is a part of the PYTHIA event generator.
// Copyright (C) 2020 Torbjorn Sjostrand.
// PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details.
@@ -37,6 +38,122 @@ int main( int argc, char* argv[] ){
double eElectron = 10.0;
double Q2min = 5.;
int nEvent = 10000;
=======
#include "Pythia8/Pythia.h"
#include "Pythia8Plugins/HepMC3.h"
#include <unistd.h>
#include <cassert>
using namespace Pythia8;
#include "clipp.h"
using namespace clipp;
using std::string;
//______________________________________________________________________________
enum class mode { none, help, list, part };
struct settings {
double E_electron = 10.0; // GeV
double E_ion = 275.0; // GeV
std::string outfile = "dis.hepmc";
int ion_PID = 2212;
int electron_PID = 11;
bool help = false;
bool success = false;
double Q2_min = 4.0;
int N_events = 1000;
mode selected = mode::none;
};
template <typename T>
void print_usage(T cli, const char* argv0)
{
// used default formatting
std::cout << "Usage:\n" << usage_lines(cli, argv0) << "\nOptions:\n" << documentation(cli) << '\n';
}
//______________________________________________________________________________
template <typename T>
void print_man_page(T cli, const char* argv0)
{
// all formatting options (with their default values)
auto fmt = clipp::doc_formatting{}
.start_column(8) // column where usage lines and documentation starts
.doc_column(20) // parameter docstring start col
.indent_size(4) // indent of documentation lines for children of a
// documented group
.line_spacing(0) // number of empty lines after single documentation lines
.paragraph_spacing(1) // number of empty lines before and after paragraphs
.flag_separator(", ") // between flags of the same parameter
.param_separator(" ") // between parameters
.group_separator(" ") // between groups (in usage)
.alternative_param_separator("|") // between alternative flags
.alternative_group_separator(" | ") // between alternative groups
.surround_group("(", ")") // surround groups with these
.surround_alternatives("(", ")") // surround group of alternatives with these
.surround_alternative_flags("", "") // surround alternative flags with these
.surround_joinable("(", ")") // surround group of joinable flags with these
.surround_optional("[", "]") // surround optional parameters with these
.surround_repeat("", "..."); // surround repeatable parameters with these
auto mp = make_man_page(cli, argv0, fmt);
mp.prepend_section("DESCRIPTION", "Simple pythia dis generator.");
mp.append_section("EXAMPLES", " $ pythia_dis [output_file]");
std::cout << mp << "\n";
}
//______________________________________________________________________________
settings cmdline_settings(int argc, char* argv[]) {
settings s;
auto lastOpt =
" options:" % (option("-h", "--help").set(s.selected, mode::help) % "show help",
value("file", s.outfile).if_missing([] {
std::cout << "You need to provide an output filename argument!\n";
}) % "output file");
auto cli =
(command("help").set(s.selected, mode::help) | lastOpt);
assert(cli.flags_are_prefix_free());
auto res = parse(argc, argv, cli);
// if( res.any_error() ) {
// s.success = false;
// std::cout << make_man_page(cli, argv[0]).prepend_section("error: ",
// " The best
// thing since
// sliced bread.");
// return s;
//}
s.success = true;
if (s.selected == mode::help) {
print_man_page<decltype(cli)>(cli, argv[0]);
};
return s;
}
//______________________________________________________________________________
int main(int argc, char* argv[]) {
settings s = cmdline_settings(argc, argv);
if (!s.success) {
return 1;
}
if (s.selected == mode::help) {
return 0;
}
// Beam energies, minimal Q2, number of events to generate.
double eProton = s.E_ion;
double eElectron = s.E_electron;
double Q2min = s.Q2_min;
int nEvent = s.N_events;
>>>>>>> 5c96bf0c8bedda31e7d1c8a8f1d24ceb5722db3a
// Generator. Shorthand for event.
Pythia pythia;
@@ -45,7 +162,11 @@ int main( int argc, char* argv[] ){
// Set up incoming beams, for frame with unequal beam energies.
pythia.readString("Beams:frameType = 2");
// BeamA = proton.
<<<<<<< HEAD
pythia.readString("Beams:idA = 2212");
=======
pythia.readString("Beams:idA = " +std::to_string(s.ion_PID));
>>>>>>> 5c96bf0c8bedda31e7d1c8a8f1d24ceb5722db3a
pythia.settings.parm("Beams:eA", eProton);
// BeamB = electron.
pythia.readString("Beams:idB = 11");
@@ -55,7 +176,11 @@ int main( int argc, char* argv[] ){
// Neutral current (with gamma/Z interference).
pythia.readString("WeakBosonExchange:ff2ff(t:gmZ) = on");
// Uncomment to allow charged current.
<<<<<<< HEAD
//pythia.readString("WeakBosonExchange:ff2ff(t:W) = on");
=======
// pythia.readString("WeakBosonExchange:ff2ff(t:W) = on");
>>>>>>> 5c96bf0c8bedda31e7d1c8a8f1d24ceb5722db3a
// Phase-space cut: minimal Q2 of process.
pythia.settings.parm("PhaseSpace:Q2Min", Q2min);
@@ -80,6 +205,7 @@ int main( int argc, char* argv[] ){
cout << endl << endl << endl;
// Histograms.
<<<<<<< HEAD
double Wmax = sqrt(4.* eProton * eElectron);
Hist Qhist("Q [GeV]", 100, 0., 50.);
Hist Whist("W [GeV]", 100, 0., Wmax);
@@ -95,6 +221,23 @@ int main( int argc, char* argv[] ){
double xs = 0.;
for (int i=0; i < pythia.info.nProcessesLHEF(); ++i)
xs += pythia.info.sigmaLHEF(i);
=======
double Wmax = sqrt(4. * eProton * eElectron);
Hist Qhist("Q [GeV]", 100, 0., 50.);
Hist Whist("W [GeV]", 100, 0., Wmax);
Hist xhist("x", 100, 0., 1.);
Hist yhist("y", 100, 0., 1.);
Hist pTehist("pT of scattered electron [GeV]", 100, 0., 50.);
Hist pTrhist("pT of radiated parton [GeV]", 100, 0., 50.);
Hist pTdhist("ratio pT_parton/pT_electron", 100, 0., 5.);
double sigmaTotal(0.), errorTotal(0.);
bool wroteRunInfo = false;
// Get the inclusive x-section by summing over all process x-sections.
double xs = 0.;
for (int i = 0; i < pythia.info.nProcessesLHEF(); ++i)
xs += pythia.info.sigmaLHEF(i);
>>>>>>> 5c96bf0c8bedda31e7d1c8a8f1d24ceb5722db3a
// Begin event loop.
for (int iEvent = 0; iEvent < nEvent; ++iEvent) {
@@ -176,8 +319,11 @@ int main( int argc, char* argv[] ){
// Write the HepMC event to file. Done with it.
ascii_io.write_event(hepmcevt);
<<<<<<< HEAD
=======
>>>>>>> 5c96bf0c8bedda31e7d1c8a8f1d24ceb5722db3a
// End of event loop. Statistics and histograms.
}
pythia.stat();
@@ -185,5 +331,9 @@ int main( int argc, char* argv[] ){
return 0;
<<<<<<< HEAD
}
=======
}
>>>>>>> 5c96bf0c8bedda31e7d1c8a8f1d24ceb5722db3a
Loading