|
|
|||
File indexing completed on 2026-09-10 08:28:31
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 /// \file example_MyPythia.cxx 0027 /// \brief Main program of the HepMCEx01/data example 0028 0029 // Matt.Dobbs@Cern.CH, December 1999 0030 // November 2000, updated to use Pythia 6.1 0031 // example of generating events with Pythia 0032 // using HepMC/PythiaWrapper.h 0033 // Events are read into the HepMC event record from the FORTRAN HEPEVT 0034 // common block using the IO_HEPEVT strategy and then output to file in 0035 // ascii format using the IO_Ascii strategy. 0036 ////////////////////////////////////////////////////////////////////////// 0037 // To Compile: go to the HepMC directory and type: 0038 // gmake examples/example_MyPythia.exe 0039 // 0040 // In this example the precision and number of entries for the HEPEVT 0041 // fortran common block are explicitly defined to correspond to those 0042 // used in the Pythia version of the HEPEVT common block. 0043 // 0044 // If you get funny output from HEPEVT in your own code, probably you have 0045 // set these values incorrectly! 0046 // 0047 0048 #include <iostream> 0049 #include "HepMC/PythiaWrapper.h" 0050 #include "HepMC/IO_HEPEVT.h" 0051 #include "HepMC/IO_GenEvent.h" 0052 #include "HepMC/GenEvent.h" 0053 0054 int main() { 0055 // 0056 //........................................HEPEVT 0057 // Pythia 6.1 uses HEPEVT with 4000 entries and 8-byte floating point 0058 // numbers. We need to explicitly pass this information to the 0059 // HEPEVT_Wrapper. 0060 // 0061 HepMC::HEPEVT_Wrapper::set_max_number_entries(4000); 0062 HepMC::HEPEVT_Wrapper::set_sizeof_real(8); 0063 // 0064 //........................................PYTHIA INITIALIZATIONS 0065 // (Some platforms may require the initialization of pythia PYDATA block 0066 // data as external - if you get pythia initialization errors try 0067 // commenting in/out the below call to initpydata() ) 0068 // initpydata(); 0069 // 0070 // Select W+gamma process (process number 20) 0071 // (here we have to be careful of C/F77 differences: arrays in C 0072 // start at 0, F77 at 1, so we need to subtract 1 from the process #) 0073 pysubs.msel=0; 0074 pysubs.msub[20-1] = 1; 0075 // set random number seed (mandatory!) 0076 pydatr.mrpy[0]=55122 ; 0077 // Tell Pythia not to write multiple copies of particles in event record. 0078 pypars.mstp[128-1] = 2; 0079 // Example of setting a Pythia parameter: set the top mass 0080 pydat2.pmas[1-1][6-1]= 175; 0081 // 0082 // Call pythia initialization 0083 call_pyinit( "CMS", "p", "p", 14000. ); 0084 0085 //........................................HepMC INITIALIZATIONS 0086 // 0087 // Instantiate an IO strategy for reading from HEPEVT. 0088 HepMC::IO_HEPEVT hepevtio; 0089 // 0090 // Instantial an IO strategy to write the data to file - it uses the 0091 // same ParticleDataTable 0092 HepMC::IO_GenEvent ascii_io("example_MyPythia.dat",std::ios::out); 0093 // 0094 //........................................EVENT LOOP 0095 for ( int i = 1; i <= 10; i++ ) { 0096 if ( i%50==1 ) std::cout << "Processing Event Number " 0097 << i << std::endl; 0098 call_pyevnt(); // generate one event with Pythia 0099 // pythia pyhepc routine converts common PYJETS in common HEPEVT 0100 call_pyhepc( 1 ); 0101 HepMC::GenEvent* evt = hepevtio.read_next_event(); 0102 // add some information to the event 0103 evt->set_event_number(i); 0104 evt->set_signal_process_id(20); 0105 // write the event out to the ascii file 0106 ascii_io << evt; 0107 // we also need to delete the created event from memory 0108 delete evt; 0109 } 0110 //........................................TERMINATION 0111 // write out some information from Pythia to the screen 0112 call_pystat( 1 ); 0113 0114 return 0; 0115 }
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|