PYTHIA  8.313
HepMC2.h
1 // HepMC2.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2025 Torbjorn Sjostrand.
3 // PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details.
4 // Please respect the MCnet Guidelines, see GUIDELINES for details.
5 
6 // Author: Mikhail Kirsanov, Mikhail.Kirsanov@cern.ch
7 // Exception classes provided by James Monk, with minor changes.
8 // Header file and function definitions for the Pythia8ToHepMC class,
9 // which converts a PYTHIA event record to the standard HepMC format.
10 //
11 // Common wrapper for HepMC2/3 added by Leif Lönnblad.
12 
13 #ifndef Pythia8_HepMC2_H
14 #define Pythia8_HepMC2_H
15 
16 #ifdef Pythia8_HepMC3_H
17 #error Cannot include HepMC2.h if HepMC3.h has already been included.
18 #endif
19 
20 #include <exception>
21 #include <sstream>
22 #include <vector>
23 #include "HepMC/IO_BaseClass.h"
24 #include "HepMC/IO_GenEvent.h"
25 #include "HepMC/GenEvent.h"
26 #include "HepMC/Units.h"
27 #include "Pythia8/Pythia.h"
28 #include "Pythia8/HIInfo.h"
29 
30 namespace HepMC {
31 
32 //==========================================================================
33 
34 // Base exception for all exceptions that Pythia8ToHepMC might throw.
35 
36 class Pythia8ToHepMCException : public std::exception {
37 
38 public:
39  virtual const char* what() const throw() { return "Pythia8ToHepMCException";}
40 
41 };
42 
43 //--------------------------------------------------------------------------
44 
45 // Exception thrown when an undecayed parton is written into the record.
46 
48 
49 public:
50 
51  // Constructor and destructor.
53  iSave = i;
54  idSave = pdg_idIn;
55  std::stringstream ss;
56  ss << "Bad end vertex at " << i << " for flavour " << pdg_idIn;
57  msg = ss.str();
58  }
59  virtual ~PartonEndVertexException() throw() {}
60 
61  // Throw exception.
62  virtual const char* what() const throw() {return msg.c_str();}
63 
64  // Return info on location and flavour of bad parton.
65  int index() const {return iSave;}
66  int pdg_id() const {return idSave;}
67 
68 protected:
69 
70  std::string msg;
71  int iSave, idSave;
72 };
73 
74 //==========================================================================
75 
76 // The Pythia8ToHepMC class.
77 
78 class Pythia8ToHepMC : public IO_BaseClass {
79 
80 public:
81 
82  // Constructor and destructor.
83  Pythia8ToHepMC() : m_internal_event_number(0), m_print_inconsistency(true),
84  m_free_parton_exception(true), m_convert_gluon_to_0(false),
85  m_store_pdf(true), m_store_proc(true), m_store_xsec(true),
86  m_store_weights(true) {;}
87  virtual ~Pythia8ToHepMC() {;}
88 
89  // The recommended method to convert Pythia events into HepMC ones.
90  bool fill_next_event( Pythia8::Pythia& pythia, GenEvent& evt,
91  int ievnum = -1, bool append = false, GenParticle* rootParticle = 0,
92  int iBarcode = -1 ) {return fill_next_event( pythia.event, &evt, ievnum,
93  &pythia.info, &pythia.settings, append, rootParticle, iBarcode);}
94  bool fill_next_event( Pythia8::Pythia& pythia, GenEvent* evt,
95  int ievnum = -1, bool append = false, GenParticle* rootParticle = 0,
96  int iBarcode = -1 ) {return fill_next_event( pythia.event, evt, ievnum,
97  &pythia.info, &pythia.settings, append, rootParticle, iBarcode);}
98 
99  // Alternative method to convert Pythia events into HepMC ones.
100  bool fill_next_event( Pythia8::Event& pyev, GenEvent& evt,
101  int ievnum = -1, const Pythia8::Info* pyinfo = 0,
102  Pythia8::Settings* pyset = 0, bool append = false,
103  GenParticle* rootParticle = 0, int iBarcode = -1) {
104  return fill_next_event(pyev, &evt, ievnum, pyinfo, pyset,
105  append, rootParticle, iBarcode); }
106 
107  bool fill_next_event( Pythia8::Event& pyev, GenEvent* evt,
108  int ievnum = -1, const Pythia8::Info* pyinfo = 0,
109  Pythia8::Settings* pyset = 0, bool append = false,
110  GenParticle* rootParticle = 0, int iBarcode = -1);
111 
112  // Read out values for some switches.
113  bool print_inconsistency() const {return m_print_inconsistency;}
114  bool free_parton_exception() const {return m_free_parton_exception;}
115  bool free_parton_warnings() const {return m_free_parton_exception;}
116  bool convert_gluon_to_0() const {return m_convert_gluon_to_0;}
117  bool store_pdf() const {return m_store_pdf;}
118  bool store_proc() const {return m_store_proc;}
119  bool store_xsec() const {return m_store_xsec;}
120  bool store_weights() const {return m_store_weights;}
121 
122  // Set values for some switches.
123  void set_print_inconsistency(bool b = true) {m_print_inconsistency = b;}
124  void set_free_parton_exception(bool b = true) {m_free_parton_exception = b;}
125  void set_free_parton_warnings(bool b = true) {m_free_parton_exception = b;}
126  void set_convert_gluon_to_0(bool b = false) {m_convert_gluon_to_0 = b;}
127  void set_store_pdf(bool b = true) {m_store_pdf = b;}
128  void set_store_proc(bool b = true) {m_store_proc = b;}
129  void set_store_xsec(bool b = true) {m_store_xsec = b;}
130  void set_store_weights(bool b = true) {m_store_weights = b;}
131 
132 private:
133 
134  // Try to send warning message to the logger if present, otherwise
135  // send it to cout if print_inconsistency().
136  bool warning(const Pythia8::Info* pyinfo, std::string loc,
137  std::string message, std::string extraInfo = "") {
138  if (pyinfo != nullptr)
139  pyinfo->loggerPtr->warningMsg(loc, message, extraInfo);
140  else if ( print_inconsistency() )
141  std::cout << "Warning in " << loc << ": " << message << extraInfo
142  << std::endl;
143  return false;
144  }
145 
146  // Following methods are not implemented for this class.
147  virtual bool fill_next_event( GenEvent* ) { return 0; }
148  virtual void write_event( const GenEvent* ) {;}
149 
150  // Use of copy constructor is not allowed.
151  Pythia8ToHepMC( const Pythia8ToHepMC& ) : IO_BaseClass() {;}
152 
153  // Data members.
154  int m_internal_event_number;
155  bool m_print_inconsistency, m_free_parton_exception, m_convert_gluon_to_0,
156  m_store_pdf, m_store_proc, m_store_xsec, m_store_weights;
157 
158 };
159 
160 //==========================================================================
161 
162 // Main method for conversion from PYTHIA event to HepMC event.
163 // Read one event from Pythia8 and fill a new GenEvent, alternatively
164 // append to an existing GenEvent, and return T/F = success/failure.
165 
167  GenEvent* evt, int ievnum, const Pythia8::Info* pyinfo,
168  Pythia8::Settings* pyset, bool append, GenParticle* rootParticle,
169  int iBarcode) {
170 
171  // 1. Error if no event passed.
172  if (evt == nullptr) return warning(pyinfo,
173  "Pythia8ToHepMC::fill_next_event", "passed null event");
174 
175  // Update event number counter.
176  if (!append) {
177  if (ievnum >= 0) {
178  evt->set_event_number(ievnum);
179  m_internal_event_number = ievnum;
180  } else {
181  evt->set_event_number(m_internal_event_number);
182  ++m_internal_event_number;
183  }
184  }
185 
186  // Conversion factors from Pythia units GeV and mm to HepMC ones.
187  double momFac = HepMC::Units::conversion_factor(HepMC::Units::GEV,
188  evt->momentum_unit());
189  double lenFac = HepMC::Units::conversion_factor(HepMC::Units::MM,
190  evt->length_unit());
191 
192  // Set up for alternative to append to an existing event.
193  int iStart = 1;
194  int newBarcode = 0;
195  if (append) {
196  if (rootParticle == nullptr) return warning(pyinfo,
197  "Pythia8ToHepMC::fill_next_event",
198  "passed null root particle in append mode");
199  iStart = 2;
200  newBarcode = (iBarcode > -1) ? iBarcode : evt->particles_size();
201  // New vertex associated with appended particles.
202  GenVertex* prod_vtx0 = new GenVertex();
203  prod_vtx0->add_particle_in( rootParticle );
204  evt->add_vertex( prod_vtx0 );
205  }
206 
207  // 1a. If there is a HIInfo object fill info from that.
208  if ( pyinfo && pyinfo->hiInfo ) {
209  HepMC::HeavyIon ion;
210  ion.set_Ncoll_hard(pyinfo->hiInfo->nCollND());
211  ion.set_Ncoll(pyinfo->hiInfo->nCollTot());
212  ion.set_Npart_proj(pyinfo->hiInfo->nAbsProj() +
213  pyinfo->hiInfo->nDiffProj());
214  ion.set_Npart_targ(pyinfo->hiInfo->nAbsTarg() +
215  pyinfo->hiInfo->nDiffTarg());
216  ion.set_impact_parameter(pyinfo->hiInfo->b());
217  evt->set_heavy_ion(ion);
218  }
219 
220  // 2. Create a particle instance for each entry and fill a map, and
221  // a vector which maps from the particle index to the GenParticle address.
222  std::vector<GenParticle*> hepevt_particles( pyev.size() );
223  for (int i = iStart; i < pyev.size(); ++i) {
224 
225  // Fill the particle.
226  hepevt_particles[i] = new GenParticle(
227  FourVector( momFac * pyev[i].px(), momFac * pyev[i].py(),
228  momFac * pyev[i].pz(), momFac * pyev[i].e() ),
229  pyev[i].id(), pyev[i].statusHepMC() );
230  if (iBarcode != 0) ++newBarcode;
231  hepevt_particles[i]->suggest_barcode( (append) ? newBarcode : i );
232  hepevt_particles[i]->set_generated_mass( momFac * pyev[i].m() );
233 
234  // Colour flow uses index 1 and 2.
235  int colType = pyev[i].colType();
236  if (colType == 1 || colType == 2)
237  hepevt_particles[i]->set_flow(1, pyev[i].col());
238  if (colType == -1 || colType == 2)
239  hepevt_particles[i]->set_flow(2, pyev[i].acol());
240  }
241 
242  // Here we assume that the first two particles in the list
243  // are the incoming beam particles.
244  if (!append)
245  evt->set_beam_particles( hepevt_particles[1], hepevt_particles[2] );
246 
247  // 3. Loop over particles AGAIN, this time creating vertices.
248  // We build the production vertex for each entry in hepevt.
249  // The HEPEVT pointers are bi-directional, so gives decay vertices as well.
250  for (int i = iStart; i < pyev.size(); ++i) {
251  GenParticle* p = hepevt_particles[i];
252 
253  // 3a. Search to see if a production vertex already exists.
254  std::vector<int> mothers = pyev[i].motherList();
255  unsigned int imother = 0;
256  int mother = -1; // note that in Pythia8 there is a particle number 0!
257  if ( !mothers.empty() ) mother = mothers[imother];
258  GenVertex* prod_vtx = p->production_vertex();
259  while ( !prod_vtx && mother > 0 ) {
260  prod_vtx = (append && mother == 1) ? rootParticle->end_vertex()
261  : hepevt_particles[mother]->end_vertex();
262  if (prod_vtx) prod_vtx->add_particle_out( p );
263  mother = ( ++imother < mothers.size() ) ? mothers[imother] : -1;
264  }
265 
266  // 3b. If no suitable production vertex exists - and the particle has
267  // at least one mother or position information to store - make one.
268  FourVector prod_pos( lenFac * pyev[i].xProd(), lenFac * pyev[i].yProd(),
269  lenFac * pyev[i].zProd(), lenFac * pyev[i].tProd() );
270  if ( !prod_vtx && ( mothers.size() > 0 || prod_pos != FourVector() ) ) {
271  prod_vtx = new GenVertex();
272  prod_vtx->add_particle_out( p );
273  evt->add_vertex( prod_vtx );
274  }
275 
276  // 3c. If prod_vtx doesn't already have position specified, fill it.
277  if ( prod_vtx && prod_vtx->position() == FourVector() )
278  prod_vtx->set_position( prod_pos );
279 
280  // 3d. loop over mothers to make sure their end_vertices are consistent.
281  imother = 0;
282  mother = -1;
283  if ( !mothers.empty() ) mother = mothers[imother];
284  while ( prod_vtx && mother > 0 ) {
285 
286  // If end vertex of the mother isn't specified, do it now.
287  GenParticle* ppp = (append && mother == 1) ? rootParticle
288  : hepevt_particles[mother];
289  if ( !ppp->end_vertex() ) {
290  prod_vtx->add_particle_in( ppp );
291  } else if (ppp->end_vertex() != prod_vtx ) {
292  // Problem scenario: the mother already has a decay vertex which
293  // differs from the daughter's production vertex.
294  // Can happen with Vincia showers since antenna emissions have two
295  // parents. In that case, let vertex structure be defined by first
296  // parent, ignoring second parent.
297  if ( (pyev[i].statusAbs() == 43 || pyev[i].statusAbs() == 51
298  || pyev[i].statusAbs() == 53) && mother >= 1) break;
299  // Otherwise this means there is internal inconsistency in the
300  // HEPEVT event record. Print an error.
301  // Note: we could provide a fix by joining the two vertices with a
302  // dummy particle if the problem arises often.
303  warning(pyinfo, "Pythia8ToHepMC::fill_next_event",
304  "inconsistent mother/daugher information in Pythia8 event",
305  "i = " + Pythia8::toString(i) + " mother = " +
306  Pythia8::toString(mother));
307  }
308 
309  // End of vertex-setting loops.
310  mother = ( ++imother < mothers.size() ) ? mothers[imother] : -1;
311  }
312  }
313 
314  // If hadronization switched on then no final coloured particles.
315  bool doHadr = (pyset == 0) ? m_free_parton_exception
316  : pyset->flag("HadronLevel:all") && pyset->flag("HadronLevel:Hadronize");
317 
318  // 4. Check for particles which come from nowhere, i.e. are without
319  // mothers or daughters. These need to be attached to a vertex, or else
320  // they will never become part of the event.
321  for (int i = iStart; i < pyev.size(); ++i) {
322  if ( hepevt_particles[i]->end_vertex() == nullptr &&
323  hepevt_particles[i]->production_vertex() == nullptr ) {
324  warning(pyinfo, "Pythia8ToHepMC::fill_next_event"
325  "found orphan particle", "i = " + Pythia8::toString(i));
326  GenVertex* prod_vtx = new GenVertex();
327  prod_vtx->add_particle_out( hepevt_particles[i] );
328  evt->add_vertex( prod_vtx );
329  }
330 
331  // Also check for free partons (= gluons and quarks; not diquarks?).
332  if ( doHadr && m_free_parton_exception ) {
333  int pdg_tmp = hepevt_particles[i]->pdg_id();
334  if ( (abs(pdg_tmp) <= 6 || pdg_tmp == 21)
335  && !hepevt_particles[i]->end_vertex() )
336  throw PartonEndVertexException(i, pdg_tmp);
337  }
338  }
339 
340  // Done if only appending to already existing event.
341  if (append) return true;
342 
343  // 5. Store PDF, weight, cross section and other event information.
344  // Flavours of incoming partons.
345  if (m_store_pdf && pyinfo != 0) {
346  int id1pdf = pyinfo->id1pdf();
347  int id2pdf = pyinfo->id2pdf();
348  if ( m_convert_gluon_to_0 ) {
349  if (id1pdf == 21) id1pdf = 0;
350  if (id2pdf == 21) id2pdf = 0;
351  }
352 
353  // Store PDF information.
354  evt->set_pdf_info( PdfInfo( id1pdf, id2pdf, pyinfo->x1pdf(),
355  pyinfo->x2pdf(), pyinfo->QFac(), pyinfo->pdf1(), pyinfo->pdf2() ) );
356  }
357 
358  // Store process code, scale, alpha_em, alpha_s.
359  if (m_store_proc && pyinfo != 0) {
360  evt->set_signal_process_id( pyinfo->code() );
361  evt->set_mpi( pyinfo->nMPI() );
362  evt->set_event_scale( pyinfo->QRen() );
363  if (evt->alphaQED() <= 0) evt->set_alphaQED( pyinfo->alphaEM() );
364  if (evt->alphaQCD() <= 0) evt->set_alphaQCD( pyinfo->alphaS() );
365  }
366 
367  // Store cross-section information in pb and event weight. The latter is
368  // usually dimensionless, but in units of pb for Les Houches strategies +-4.
369  if (m_store_xsec && pyinfo != 0) {
370  HepMC::GenCrossSection xsec;
371  xsec.set_cross_section( pyinfo->sigmaGen() * 1e9,
372  pyinfo->sigmaErr() * 1e9);
373  evt->set_cross_section(xsec);
374  // If multiweights with possibly different xsec, overwrite central value
375  std::vector<double> xsecVec = pyinfo->weightContainerPtr->getTotalXsec();
376  if (xsecVec.size() > 0) {
377  xsec.set_cross_section(xsecVec[0]*1e9);
378  evt->set_cross_section(xsec);
379  }
380  }
381 
382  if (m_store_weights && pyinfo != 0) {
383  for (int iweight = 0; iweight < pyinfo->numberOfWeights();
384  ++iweight) {
385  std::string name = pyinfo->weightNameByIndex(iweight);
386  double value = pyinfo->weightValueByIndex(iweight);
387  evt->weights()[name] = value;
388  }
389  }
390 
391  // Done for new event.
392  return true;
393 
394 }
395 
396 //==========================================================================
397 
398 } // end namespace HepMC
399 
400 namespace Pythia8 {
401 
402 //==========================================================================
403 // This a wrapper around HepMC::Pythia8ToHepMC in the Pythia8
404 // namespace that simplify the most common use cases. It stores the
405 // current GenEvent and output stream internally to avoid cluttering
406 // of user code. This class is also defined in HepMC3.h with the same
407 // signatures, and the user can therefore switch between HepMC version
408 // 2 and 3, by simply changing the include file.
410 
411 public:
412 
413  // We can either have standard ascii output or none at all.
414  enum OutputType { none, ascii2 };
415 
416  // Typedef for the version 2 specific classes used.
417  typedef HepMC::GenEvent GenEvent;
418  typedef shared_ptr<GenEvent> EventPtr;
419  typedef HepMC::IO_GenEvent Writer;
420  typedef shared_ptr<Writer> WriterPtr;
421 
422  // The empty constructor does not creat an aoutput stream.
424 
425  // Construct an object with an internal output stream.
426  Pythia8ToHepMC(string filename, OutputType ft = ascii2) {
427  setNewFile(filename, ft);
428  }
429 
430  // Open a new external output stream.
431  bool setNewFile(string filename, OutputType ft = ascii2) {
432  switch ( ft ) {
433  case ascii2:
434  writerPtr = make_shared<HepMC::IO_GenEvent>(filename);
435  break;
436  case none:
437  writerPtr = nullptr;
438  break;
439  }
440  return writerPtr != nullptr;
441  }
442 
443  // Create a new GenEvent object and fill it with information from
444  // the given Pythia object.
445  bool fillNextEvent(Pythia & pythia) {
446  geneve = make_shared<GenEvent>();
447  return fill_next_event(pythia, *geneve);
448  }
449 
450  // Write out the current GenEvent to the internal stream.
451  void writeEvent() {
452  writerPtr->write_event(&*geneve);
453  }
454 
455  // Create a new GenEvent object and fill it with information from
456  // the given Pythia object and write it out directly to the
457  // internal stream.
458  bool writeNextEvent(Pythia & pythia) {
459  if ( !fillNextEvent(pythia) ) return false;
460  writeEvent();
461  return true;
462  }
463 
464  // Get a reference to the current GenEvent.
465  GenEvent & event() {
466  return *geneve;
467  }
468 
469  // Get a pointer to the current GenEvent.
470  EventPtr getEventPtr() {
471  return geneve;
472  }
473 
474  // Get a reference to the internal stream.
475  Writer & output() {
476  return *writerPtr;
477  }
478 
479  // Get a pointer to the internal stream.
480  WriterPtr outputPtr() {
481  return writerPtr;
482  }
483 
484  // Set cross section information in the current GenEvent.
485  void setXSec(double xsec, double xsecerr) {
486  HepMC::GenCrossSection xs;
487  xs.set_cross_section(xsec, xsecerr);
488  geneve->set_cross_section(xs);
489  }
490 
491  // Update all weights in the current GenEvent.
492  void setWeights(const vector<double> & wv) {
493  if ( wv.size() != weightNames.size() )
494  geneve->weights() = wv;
495  else
496  for ( int i= 0, N = wv.size(); i < N; ++i )
497  geneve->weights()[weightNames[i]] = wv[i];
498  }
499 
500  // Set all weight names in the current run.
501  void setWeightNames(const vector<string> &wnv) {
502  weightNames = wnv;
503  }
504 
505  // Update the PDF information in the current GenEvent
506  void setPdfInfo(int id1, int id2, double x1, double x2,
507  double scale, double xf1, double xf2,
508  int pdf1 = 0, int pdf2 = 0) {
509  HepMC::PdfInfo pdf(id1, id2, x1, x2, scale, xf1, xf2, pdf1, pdf2);
510  geneve->set_pdf_info(pdf);
511  }
512 
513 private:
514 
515  // The current GenEvent.
516  EventPtr geneve = nullptr;
517 
518  // The output stream.
519  WriterPtr writerPtr = nullptr;
520 
521  // The weight names in the current run.
522  vector<string> weightNames;
523 
524 };
525 
526 }
527 
528 #endif // end Pythia8_HepMC2_H
Pythia8ToHepMC()
Constructor and destructor.
Definition: HepMC2.h:83
void setWeightNames(const vector< string > &wnv)
Set all weight names in the current run.
Definition: HepMC2.h:501
bool flag(string keyIn)
Give back current value, with check that key exists.
Definition: Settings.cc:1599
GenEvent & event()
Get a reference to the current GenEvent.
Definition: HepMC2.h:465
int nCollND() const
The number of non-diffractive sub-collisions in the event.
Definition: HIInfo.h:60
Definition: Info.h:45
The Event class holds all info on the generated event.
Definition: Event.h:408
Exception thrown when an undecayed parton is written into the record.
Definition: HepMC2.h:47
void setPdfInfo(int id1, int id2, double x1, double x2, double scale, double xf1, double xf2, int pdf1=0, int pdf2=0)
Update the PDF information in the current GenEvent.
Definition: HepMC2.h:506
Logger * loggerPtr
Pointer to the logger.
Definition: Info.h:86
Pythia8ToHepMC(string filename, OutputType ft=ascii2)
Construct an object with an internal output stream.
Definition: HepMC2.h:426
vector< double > getTotalXsec()
Return cross section estimate for total run.
Definition: Weights.cc:1137
int nMPI() const
Number of multiparton interactions, with code and pT for them.
Definition: Info.h:270
Settings settings
Settings: databases of flags/modes/parms/words to control run.
Definition: Pythia.h:374
double b() const
The impact-parameter distance in the current event.
Definition: HIInfo.h:38
bool writeNextEvent(Pythia &pythia)
Definition: HepMC2.h:458
The Pythia8ToHepMC class.
Definition: HepMC2.h:78
double sigmaErr(int i=0) const
The uncertainty on the estimated cross-section in units of mb.
Definition: Info.h:320
Event event
The event record for the complete event history.
Definition: Pythia.h:365
Base exception for all exceptions that Pythia8ToHepMC might throw.
Definition: HepMC2.h:36
PartonEndVertexException(int i, int pdg_idIn)
Constructor and destructor.
Definition: HepMC2.h:52
int id1pdf(int i=0) const
Hard process flavours, x values, parton densities, couplings, Q2 scales.
Definition: Info.h:169
void setXSec(double xsec, double xsecerr)
Set cross section information in the current GenEvent.
Definition: HepMC2.h:485
void warningMsg(string loc, string message, string extraInfo="", bool showAlways=false)
Warnings indicate that there might be an issue, but the run will continue.
Definition: Logger.cc:32
void writeEvent()
Write out the current GenEvent to the internal stream.
Definition: HepMC2.h:451
virtual const char * what() const
Throw exception.
Definition: HepMC2.h:62
EventPtr getEventPtr()
Get a pointer to the current GenEvent.
Definition: HepMC2.h:470
Pythia8ToHepMC()
The empty constructor does not creat an aoutput stream.
Definition: HepMC2.h:423
HIInfo * hiInfo
Definition: Info.h:113
Definition: HepMC2.h:409
string toString(bool val)
Convert a boolean to a string.
Definition: PythiaStdlib.h:217
bool fill_next_event(Pythia8::Event &pyev, GenEvent &evt, int ievnum=-1, const Pythia8::Info *pyinfo=0, Pythia8::Settings *pyset=0, bool append=false, GenParticle *rootParticle=0, int iBarcode=-1)
Alternative method to convert Pythia events into HepMC ones.
Definition: HepMC2.h:100
double sigmaGen(int i=0) const
The estimated cross-section in units of mb.
Definition: Info.h:312
bool setNewFile(string filename, OutputType ft=ascii2)
Open a new external output stream.
Definition: HepMC2.h:431
int size() const
Event record size.
Definition: Event.h:459
int nAbsTarg() const
The number of absorptively wounded target nucleons in the event.
Definition: HIInfo.h:95
WriterPtr outputPtr()
Get a pointer to the internal stream.
Definition: HepMC2.h:480
bool print_inconsistency() const
Read out values for some switches.
Definition: HepMC2.h:113
int nAbsProj() const
The number of absorptively wounded projectile nucleons in the event.
Definition: HIInfo.h:83
void setWeights(const vector< double > &wv)
Update all weights in the current GenEvent.
Definition: HepMC2.h:492
HepMC::GenEvent GenEvent
Typedef for the version 2 specific classes used.
Definition: HepMC2.h:417
void set_print_inconsistency(bool b=true)
Set values for some switches.
Definition: HepMC2.h:123
OutputType
We can either have standard ascii output or none at all.
Definition: HepMC2.h:414
Header for classes to set beam momentum and interaction vertex spread.
Definition: Analysis.h:20
The Pythia class contains the top-level routines to generate an event.
Definition: Pythia.h:71
bool fillNextEvent(Pythia &pythia)
Definition: HepMC2.h:445
const Info & info
Public information and statistic on the generation.
Definition: Pythia.h:368
Writer & output()
Get a reference to the internal stream.
Definition: HepMC2.h:475
int nDiffTarg() const
The number of diffractively wounded target nucleons in the event.
Definition: HIInfo.h:98
Definition: HepMC2.h:30
int index() const
Return info on location and flavour of bad parton.
Definition: HepMC2.h:65
int nDiffProj() const
The number of diffractively wounded projectile nucleons in the event.
Definition: HIInfo.h:86
bool fill_next_event(Pythia8::Pythia &pythia, GenEvent &evt, int ievnum=-1, bool append=false, GenParticle *rootParticle=0, int iBarcode=-1)
The recommended method to convert Pythia events into HepMC ones.
Definition: HepMC2.h:90
Definition: Settings.h:196
int nCollTot() const
The total number of sub-collisions in the event.
Definition: HIInfo.h:57