LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
example_MyPythia.cxx File Reference
#include <iostream>
#include "HepMC/PythiaWrapper.h"
#include "HepMC/IO_HEPEVT.h"
#include "HepMC/IO_GenEvent.h"
#include "HepMC/GenEvent.h"

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

int main ( )

Definition at line 53 of file example_MyPythia.cxx.

53  {
54  //
55  //........................................HEPEVT
56  // Pythia 6.1 uses HEPEVT with 4000 entries and 8-byte floating point
57  // numbers. We need to explicitly pass this information to the
58  // HEPEVT_Wrapper.
59  //
60  HepMC::HEPEVT_Wrapper::set_max_number_entries(4000);
61  HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
62  //
63  //........................................PYTHIA INITIALIZATIONS
64  // (Some platforms may require the initialization of pythia PYDATA block
65  // data as external - if you get pythia initialization errors try
66  // commenting in/out the below call to initpydata() )
67  // initpydata();
68  //
69  // Select W+gamma process (process number 20)
70  // (here we have to be careful of C/F77 differences: arrays in C
71  // start at 0, F77 at 1, so we need to subtract 1 from the process #)
72  pysubs.msel=0;
73  pysubs.msub[20-1] = 1;
74  // set random number seed (mandatory!)
75  pydatr.mrpy[0]=55122 ;
76  // Tell Pythia not to write multiple copies of particles in event record.
77  pypars.mstp[128-1] = 2;
78  // Example of setting a Pythia parameter: set the top mass
79  pydat2.pmas[1-1][6-1]= 175;
80  //
81  // Call pythia initialization
82  call_pyinit( "CMS", "p", "p", 14000. );
83 
84  //........................................HepMC INITIALIZATIONS
85  //
86  // Instantiate an IO strategy for reading from HEPEVT.
87  HepMC::IO_HEPEVT hepevtio;
88  //
89  // Instantial an IO strategy to write the data to file - it uses the
90  // same ParticleDataTable
91  HepMC::IO_GenEvent ascii_io("example_MyPythia.dat",std::ios::out);
92  //
93  //........................................EVENT LOOP
94  for ( int i = 1; i <= 10; i++ ) {
95  if ( i%50==1 ) std::cout << "Processing Event Number "
96  << i << std::endl;
97  call_pyevnt(); // generate one event with Pythia
98  // pythia pyhepc routine converts common PYJETS in common HEPEVT
99  call_pyhepc( 1 );
100  HepMC::GenEvent* evt = hepevtio.read_next_event();
101  // add some information to the event
102  evt->set_event_number(i);
103  evt->set_signal_process_id(20);
104  // write the event out to the ascii file
105  ascii_io << evt;
106  // we also need to delete the created event from memory
107  delete evt;
108  }
109  //........................................TERMINATION
110  // write out some information from Pythia to the screen
111  call_pystat( 1 );
112 
113  return 0;
114 }