-
Notifications
You must be signed in to change notification settings - Fork 0
/
main95.cc
151 lines (109 loc) · 4.62 KB
/
main95.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// main11.cc is a part of the PYTHIA event generator.
// Copyright (C) 2012 Torbjorn Sjostrand.
// PYTHIA is licenced under the GNU GPL version 2, see COPYING for details.
// Please respect the MCnet Guidelines, see GUIDELINES for details.
// This is a simple test program.
// It illustrates how Les Houches Event File input can be used in Pythia8.
// It uses the ttsample.lhe input file, the latter only with 100 events.
#include <fstream>
// #include "Pythia8/Pythia.h"
// #include "Pythia8/Pythia8ToHepMC.h"
#include "Pythia.h"
#include "HepMCInterface.h"
#include "HepMC/GenEvent.h"
#include "HepMC/IO_GenEvent.h"
int main(int argc, char **argv) {
if (argc < 3) {
std::cerr << " Not enough input information!" << std::endl;
exit (0);
}
std::string namefile_in;
namefile_in = argv[1];
std::string namefile_out;
namefile_out = argv[2];
std::cout << " namefile_in = " << namefile_in << std::endl;
std::cout << " namefile_out = " << namefile_out << std::endl;
int energy = 13;
if (argc >= 4) energy = atoi(argv[3]);
int startEntry = 0;
if (argc >= 5) startEntry = atoi(argv[4]);
int endEntry = -1;
if (argc >= 6) endEntry = atoi(argv[5]);
std::cout << " energy = " << energy << std::endl;
std::cout << " startEntry = " << startEntry << std::endl;
std::cout << " endEntry = " << endEntry << std::endl;
// output file
// we want to store the list of all final state particles
std::ofstream out_pythia;
// Highest precision required for jet clustering
out_pythia.precision(15);
// Generator. We here stick with default values, but changes
// could be inserted with readString or readFile.
Pythia8::Pythia pythia;
// http://home.thep.lu.se/~torbjorn/pythia81html/BeamParameters.html
// pythia.readString("Beams:frameType = 1");
// if (energy == 8) pythia.readString("Beams:eCM = 8000"); // 8 TeV
// if (energy == 13) pythia.readString("Beams:eCM = 13000"); // 13 TeV
// if (energy == 14) pythia.readString("Beams:eCM = 14000"); // 14 TeV
// Initialize Les Houches Event File run. List initialization information.
// the analysis program
pythia.readString("Beams:frameType = 4");
std::string sfile = "Beams:LHEF ="+namefile_in;
pythia.readString(sfile.c_str());
// Interface for conversion from Pythia8::Event to HepMC event.
HepMC::I_Pythia8 ToHepMC;
// HepMC::Pythia8ToHepMC ToHepMC;
// Specify file where HepMC events will be stored.
HepMC::IO_GenEvent ascii_io(namefile_out.c_str(), std::ios::out);
// Allow for possibility of a few faulty events.
int nAbort = 10;
int iAbort = 0;
// pythia.settings.listAll();
// pythia.particleData.listAll();
// Settings
// pythia.readString("ProcessLevel:all = off"); // Off event generation -> need on for MPI
pythia.readString("HadronLevel:all = on"); // On hadronization
pythia.readString("24:onMode = off");
pythia.readString("-24:onMode = off");
pythia.readString("24:onIfMatch = 12 11"); // e ve
pythia.readString("24:onIfMatch = 14 13"); // mu numu
// pythia.readString("24:onIfMatch = 15 16"); // tau nutau
pythia.readString("-24:onIfMatch = 12 -11"); // e ve
pythia.readString("-24:onIfMatch = 14 -13"); // mu numu
// pythia.readString("-24:onIfMatch = 15 -16"); // tau nutau
// Initialization
pythia.init();
// Create an LHAup object that can access relevant information in pythia.
Pythia8::LHAupFromPYTHIA8 myLHA(&pythia.process, &pythia.info);
// Open a file on which LHEF events should be stored, and write header.
// Begin event loop; generate until none left in input file.
// for (int iEvent = 0; iEvent < 200; ++iEvent) {
for (int iEvent = 0; ; ++iEvent) {
if (!(iEvent%500)) std::cout<<" ievent = " << iEvent << std::endl;
// Generate events, and check whether generation failed.
if (!pythia.next()) {
// If failure because reached end of file then exit event loop.
if (pythia.info.atEndOfFile()) break;
// First few failures write off as "acceptable" errors, then quit.
if (++iAbort < nAbort) continue;
break;
}
//---- subrange of events ----
if (iEvent < startEntry) continue;
if (endEntry!=-1 && iEvent>=endEntry) break;
// Construct new empty HepMC event and fill it.
// Units will be as chosen for HepMC build; but can be changed
// by arguments, e.g. GenEvt( HepMC::Units::GEV, HepMC::Units::MM)
// HepMC::GenEvent* hepmcevt = new HepMC::GenEvent();
HepMC::GenEvent* hepmcevt = new HepMC::GenEvent(HepMC::Units::GEV, HepMC::Units::MM);
ToHepMC.fill_next_event( pythia, hepmcevt );
// Write the HepMC event to file. Done with it.
ascii_io << hepmcevt;
delete hepmcevt;
// End of event loop.
}
// Give statistics. Print histogram.
// pythia.stat();
//delete pythia;
return 0;
}