![]() |
|
|||
File indexing completed on 2025-02-23 09:21:07
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 // 0027 ////////////////////////////////////////////////////////////////////////// 0028 // Matt.Dobbs@Cern.CH, December 1999 0029 // November 2000, updated to use Pythia 6.1 0030 // example of generating events with Pythia 0031 // using HepMC/PythiaWrapper.h 0032 // Events are read into the HepMC event record from the FORTRAN HEPEVT 0033 // common block using the IO_HEPEVT strategy and then output to file in 0034 // ascii format using the IO_Ascii strategy. 0035 ////////////////////////////////////////////////////////////////////////// 0036 // To Compile: go to the HepMC directory and type: 0037 // gmake examples/example_MyPythia.exe 0038 // 0039 // In this example the precision and number of entries for the HEPEVT 0040 // fortran common block are explicitly defined to correspond to those 0041 // used in the Pythia version of the HEPEVT common block. 0042 // 0043 // If you get funny output from HEPEVT in your own code, probably you have 0044 // set these values incorrectly! 0045 // 0046 0047 #include <iostream> 0048 #include "HepMC/PythiaWrapper.h" 0049 #include "HepMC/IO_HEPEVT.h" 0050 #include "HepMC/IO_GenEvent.h" 0051 #include "HepMC/GenEvent.h" 0052 0053 int main() { 0054 // 0055 //........................................HEPEVT 0056 // Pythia 6.1 uses HEPEVT with 4000 entries and 8-byte floating point 0057 // numbers. We need to explicitly pass this information to the 0058 // HEPEVT_Wrapper. 0059 // 0060 HepMC::HEPEVT_Wrapper::set_max_number_entries(4000); 0061 HepMC::HEPEVT_Wrapper::set_sizeof_real(8); 0062 // 0063 //........................................PYTHIA INITIALIZATIONS 0064 // (Some platforms may require the initialization of pythia PYDATA block 0065 // data as external - if you get pythia initialization errors try 0066 // commenting in/out the below call to initpydata() ) 0067 // initpydata(); 0068 // 0069 // Select W+gamma process (process number 20) 0070 // (here we have to be careful of C/F77 differences: arrays in C 0071 // start at 0, F77 at 1, so we need to subtract 1 from the process #) 0072 pysubs.msel=0; 0073 pysubs.msub[20-1] = 1; 0074 // set random number seed (mandatory!) 0075 pydatr.mrpy[0]=55122 ; 0076 // Tell Pythia not to write multiple copies of particles in event record. 0077 pypars.mstp[128-1] = 2; 0078 // Example of setting a Pythia parameter: set the top mass 0079 pydat2.pmas[1-1][6-1]= 175; 0080 // 0081 // Call pythia initialization 0082 call_pyinit( "CMS", "p", "p", 14000. ); 0083 0084 //........................................HepMC INITIALIZATIONS 0085 // 0086 // Instantiate an IO strategy for reading from HEPEVT. 0087 HepMC::IO_HEPEVT hepevtio; 0088 // 0089 // Instantial an IO strategy to write the data to file - it uses the 0090 // same ParticleDataTable 0091 HepMC::IO_GenEvent ascii_io("example_MyPythia.dat",std::ios::out); 0092 // 0093 //........................................EVENT LOOP 0094 for ( int i = 1; i <= 10; i++ ) { 0095 if ( i%50==1 ) std::cout << "Processing Event Number " 0096 << i << std::endl; 0097 call_pyevnt(); // generate one event with Pythia 0098 // pythia pyhepc routine converts common PYJETS in common HEPEVT 0099 call_pyhepc( 1 ); 0100 HepMC::GenEvent* evt = hepevtio.read_next_event(); 0101 // add some information to the event 0102 evt->set_event_number(i); 0103 evt->set_signal_process_id(20); 0104 // write the event out to the ascii file 0105 ascii_io << evt; 0106 // we also need to delete the created event from memory 0107 delete evt; 0108 } 0109 //........................................TERMINATION 0110 // write out some information from Pythia to the screen 0111 call_pystat( 1 ); 0112 0113 return 0; 0114 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |