15 #include "ProMCHeader.pb.h"
17 #include "ProMCBook.h"
19 using namespace Pythia8;
23 string getEnvVar( std::string
const & key ) {
24 char * val = getenv( key.c_str() );
25 return (val == NULL) ? std::string(
"") : std::string(val);
30 void readPDG( ProMCHeader * header ) {
33 istringstream curstring;
34 string PdgTableFilename = getEnvVar(
"PROMC") +
"/data/particle.tbl";
35 if (PdgTableFilename.size() < 2) {
36 cout <<
"** ERROR: PROMC variable not set. Did you run source.sh"
41 ifstream file_to_read(PdgTableFilename.c_str());
42 if (!file_to_read.good()) {
43 cout <<
"** ERROR: PDG Table (" << PdgTableFilename
44 <<
") not found! exit. **" << endl;
50 getline(file_to_read,temp_string);
51 getline(file_to_read,temp_string);
52 getline(file_to_read,temp_string);
54 while (getline(file_to_read,temp_string)) {
57 curstring.str(temp_string);
58 long int ID; std::string name;
int charge;
float mass;
float width;
65 curstring >> ID >> name >> charge >> mass >> width >> lifetime;
66 ProMCHeader_ParticleData* pp= header->add_particledata();
71 pp->set_lifetime(lifetime);
72 cout << ID <<
" " << name <<
" " << mass << endl;
85 pythia.readString(
"WeakSingleBoson:ffbar2gmZ = on");
86 pythia.readString(
"PhaseSpace:mHatMin = 80.");
87 pythia.readString(
"PhaseSpace:mHatMax = 120.");
88 pythia.readString(
"Random:setSeed = on");
89 pythia.readString(
"Random:seed = 0");
90 pythia.init( 2212, 2212, 14000.);
93 ProMCBook* epbook =
new ProMCBook(
"Pythia8.promc",
"w");
94 epbook->setDescription(Ntot,
"PYTHIA8");
98 header.set_id1( pythia.info.idA() );
99 header.set_id2( pythia.info.idB() );
100 header.set_ecm( pythia.info.eCM() );
101 header.set_s( pythia.info.s() );
105 const double kEV = 1000*100;
107 const double kL = 100;
110 header.set_momentumunit( (
int)kEV );
111 header.set_lengthunit( (
int)kL );
115 epbook->setHeader(header);
118 for (
int n = 0; n < Ntot; n++) {
119 if (!pythia.next()) {
121 if (pythia.info.atEndOfFile()) {
122 cout <<
" Aborted since reached end of Les Houches Event File\n";
132 ProMCEvent_Event *eve = promc.mutable_event();
134 eve->set_process_id( pythia.info.code() );
135 eve->set_scale( pythia.info.pTHat( ));
136 eve->set_alpha_qed( pythia.info.alphaEM() );
137 eve->set_alpha_qcd( pythia.info.alphaS() );
138 eve->set_scale_pdf( pythia.info.QFac() );
139 eve->set_x1( pythia.info.x1pdf() );
140 eve->set_x2( pythia.info.x2pdf() );
141 eve->set_id1( pythia.info.id1pdf() );
142 eve->set_id2( pythia.info.id2pdf() );
143 eve->set_pdf1( pythia.info.pdf1() );
144 eve->set_pdf2( pythia.info.pdf2() );
145 eve->set_weight( pythia.info.weight() );
148 ProMCEvent_Particles *pa= promc.mutable_particles();
149 for (
int i = 0; i < pythia.event.size(); i++) {
153 pa->add_pdg_id( pythia.event[i].id() );
155 pa->add_status( pythia.event.statusHepMC(i) );
156 pa->add_mother1( pythia.event[i].mother1() );
157 pa->add_mother2( pythia.event[i].mother2() );
158 pa->add_daughter1( pythia.event[i].daughter1() );
159 pa->add_daughter2( pythia.event[i].daughter2() );
161 pa->add_px( (
int)(pythia.event[i].px()*kEV) );
162 pa->add_py( (
int)(pythia.event[i].py()*kEV) );
163 pa->add_pz( (
int)(pythia.event[i].pz()*kEV) );
164 pa->add_mass( (
int)(pythia.event[i].m()*kEV) );
166 pa->add_x(
int(pythia.event[i].xProd()*kL) );
167 pa->add_y(
int(pythia.event[i].yProd()*kL) );
168 pa->add_z(
int(pythia.event[i].zProd()*kL) );
169 pa->add_t(
int(pythia.event[i].tProd()*kL) );
172 epbook->write(promc);
178 double sigmapb = pythia.info.sigmaGen() * 1.0E9;
179 cout <<
"== Cross section for this run = " << sigmapb <<
" pb" << endl;
180 cout <<
"== Events for this run = " << Ntot << endl;
181 double lumi = (Ntot/sigmapb)/1000;
182 cout <<
"== Luminosity for this run = " << lumi <<
" fb-1" << endl;
187 stat.set_cross_section_accumulated( sigmapb );
188 stat.set_cross_section_error_accumulated( pythia.info.sigmaErr() * 1e9 );
189 stat.set_luminosity_accumulated( Ntot/sigmapb );
190 stat.set_ntried( pythia.info.nTried() );
191 stat.set_nselected( pythia.info.nSelected() );
192 stat.set_naccepted( pythia.info.nAccepted() );
193 epbook->setStatistics( stat );