| /trunk/ChangeLog |
|---|
| 1,4 → 1,8 |
| 2011-11-01 Lynn Garren |
| * examples: move Pythia and Herwig examples to examples/fio |
| 2011-10-31 Lynn Garren |
| * remove fio/PythiaWrapper.cc |
| /trunk/configure.ac |
|---|
| 148,6 → 148,8 |
| doc/VCMakefile |
| examples/Makefile |
| examples/VCMakefile |
| examples/fio/Makefile |
| examples/fio/VCMakefile |
| fio/Makefile |
| fio/VCMakefile |
| src/Makefile |
| 160,7 → 162,8 |
| test/testHepMCIteration.cc |
| test/testMultipleCopies.cc |
| test/testStreamIO.cc |
| examples/GNUmakefile.example]) |
| examples/GNUmakefile.example |
| examples/fio/GNUmakefile.example]) |
| AC_CONFIG_FILES([test/testHepMC.sh], [chmod +x test/testHepMC.sh]) |
| AC_CONFIG_FILES([test/testFlow.sh], [chmod +x test/testFlow.sh]) |
| /trunk/Makefile.am |
|---|
| 2,6 → 2,6 |
| includedir = $(prefix)/include |
| SUBDIRS = HepMC src fio test examples doc |
| SUBDIRS = HepMC src fio test examples examples/fio doc |
| # list all subdirectories - for distribution and cleaning |
| DIST_SUBDIRS = HepMC src fio test examples doc |
| DIST_SUBDIRS = HepMC src fio test examples examples/fio doc |
| /trunk/examples/PythiaHelper.h |
|---|
| File deleted |
| /trunk/examples/testPythiaCopies.cc |
|---|
| File deleted |
| /trunk/examples/example_MyPythiaOnlyToHepMC.cc |
|---|
| File deleted |
| /trunk/examples/example_MyHerwig.cc |
|---|
| File deleted |
| /trunk/examples/initpydata.f |
|---|
| File deleted |
| /trunk/examples/example_PythiaStreamIO.cc |
|---|
| File deleted |
| /trunk/examples/example_MyPythia.cc |
|---|
| File deleted |
| /trunk/examples/initPythia.cc |
|---|
| File deleted |
| /trunk/examples/testHerwigCopies.cc |
|---|
| File deleted |
| /trunk/examples/list_of_examples.cc |
|---|
| 2,7 → 2,7 |
| /// example to generate events and perform simple event selection |
| /// example to read the file written by pythia_out |
| /// example to generate events, write them, and read them back |
| /// \example example_MyPythia.cc |
| /// \example fio/example_MyPythia.cc |
| /// Example of generating events with Pythia using HepMC/PythiaWrapper.h |
| /// Events are read into the HepMC event record from the FORTRAN HEPEVT |
| 11,7 → 11,7 |
| /// from HEPEVT into the HepMC event record. |
| /// \example example_MyPythiaOnlyToHepMC.cc |
| /// \example example_MyHerwig.cc |
| /// \example fio/example_MyHerwig.cc |
| /// Example of applying an event selection to the events written to file |
| /// using example_MyPythia.cxx |
| 23,6 → 23,10 |
| /// This is meant to be of use for persons implementing HepMC inside a MC |
| /// event generator |
| /// \example example_BuildEventFromScratch.cc |
| /// Example of how to convert from another vector class to a SimpleVector. |
| /// This example uses CLHEP::HepLorentzVector |
| /// \example example_VectorConversion.cc |
| /// This example shows low to use the particle and vertex iterators |
| /// \example example_UsingIterators.cc |
| 30,13 → 34,13 |
| /// This example generates Pythia events and fills |
| /// cross section information from pyint5. |
| /// The example uses streaming I/O to write a file and then read it. |
| /// \example example_PythiaStreamIO.cc |
| /// \example fio/example_PythiaStreamIO.cc |
| /// Multiple events in memory at the same time |
| /// \example testHerwigCopies.cc |
| /// \example fio/testHerwigCopies.cc |
| /// Multiple events in memory at the same time |
| /// \example testPythiaCopies.cc |
| /// \example fio/testPythiaCopies.cc |
| /// This example converts from ThreeVector and FourVector to |
| /// CLHEP::Hep3Vector and CLHEP::HepLorentzVector |
| /trunk/examples/GNUmakefile.example.in |
|---|
| 16,57 → 16,39 |
| HepMCfiolib = -L$(HepMCdir)/lib -lHepMCfio |
| GENSERdir = @GENSERdir@ |
| CLHEPdir = @CLHEPdir@ |
| Pythia_LIB = -L$(GENSERdir)/lib -Wl,-rpath -Wl,$(GENSERdir)/lib \ |
| -lpythia6_403 -lpythia6_403_dumm -lpythia6_403_pdfdumm |
| Herwig_LIB = -L$(GENSERdir)/lib -Wl,-rpath -Wl,$(GENSERdir)/lib \ |
| -lherwig6_510 -lherwig6_510_dumm -lherwig6_510_pdfdumm |
| ################################################################################ Compiler options |
| # |
| CXX = @CXX@ |
| F77 = @F77@ |
| INCLUDES = -I$(HepMCdir)/include -I$(CLHEPdir)/include |
| CXXFLAGS = @AM_CXXFLAGS@ @CXXFLAGS@ $(INCLUDES) |
| ifeq "$(CXX)" "g++" |
| F77 = g77 |
| FLAGS = $(DFLG) -fno-second-underscore $(INCDIR) |
| else |
| F77 = f77 |
| FLAGS = $(DFLG) $(INCDIR) |
| ifeq "$(CXX)" "g++" |
| FLAGS += -fno-second-underscore |
| endif |
| EXAMPLES = example_BuildEventFromScratch.exe \ |
| example_EventSelection.exe \ |
| example_UsingIterators.exe |
| LINK_LIBS = @LDFLAGS@ |
| UNAME = $(shell uname) |
| UNAME = $(shell uname) |
| ifneq (,$(strip $(CLHEPdir))) |
| EXAMPLES += example_VectorConversion.exe |
| ifeq "$(UNAME)" "Darwin" |
| CLHEP_LIB = -L$(CLHEPdir)/lib -lCLHEP |
| else |
| CLHEP_LIB = -L$(CLHEPdir)/lib -lCLHEP -Wl,-r -Wl,$(CLHEPdir)/lib |
| CLHEP_LIB = -L$(CLHEPdir)/lib -lCLHEP -Wl,-rpath -Wl,$(CLHEPdir)/lib |
| endif |
| endif |
| ifeq "$(UNAME)" "Darwin" |
| else |
| LINK_LIBS += -Wl,-rpath -Wl,$(HepMCdir)/lib |
| endif |
| CLHEP_LIB = -L$(CLHEPdir)/lib -lCLHEP -Wl,-rpath -Wl,$(CLHEPdir)/lib |
| initpydata_OBJ= initpydata.o |
| pythia_OBJ = initPythia.o initpydata.o |
| SRCS = example_BuildEventFromScratch.cc \ |
| example_EventSelection.cc \ |
| example_MyHerwig.cc \ |
| example_MyPythia.cc \ |
| example_MyPythiaOnlyToHepMC.cc \ |
| example_UsingIterators.cc \ |
| example_PythiaStreamIO.cc \ |
| testPythiaCopies.cc \ |
| testHerwigCopies.cc \ |
| initPythia.cc \ |
| initpydata.f |
| HDRS = $(HepMCdir)/include/HepMC/*.h *.h |
| EXAMPLES = example_BuildEventFromScratch.exe \ |
| example_EventSelection.exe \ |
| example_MyHerwig.exe \ |
| example_MyPythia.exe \ |
| example_MyPythiaOnlyToHepMC.exe \ |
| example_UsingIterators.exe \ |
| example_PythiaStreamIO.exe \ |
| testPythiaCopies.exe \ |
| testHerwigCopies.exe |
| ################################################################################ |
| 108,13 → 90,19 |
| ############################################################################### |
| # |
| .SUFFIXES: .o .cxx .f .exe |
| .SUFFIXES: .o .cc .exe |
| all: $(EXAMPLES) |
| example_BuildEventFromScratch.exe: example_BuildEventFromScratch.o |
| @echo "Building $@ ..." |
| $(CXX) $(FLAGS) example_BuildEventFromScratch.o \ |
| $(HepMClib) \ |
| $(LINK_LIBS) -o $@ |
| example_VectorConversion.exe: example_VectorConversion.o |
| @echo "Building $@ ..." |
| $(CXX) $(FLAGS) example_VectorConversion.o \ |
| $(HepMClib) \ |
| $(CLHEP_LIB) \ |
| $(LINK_LIBS) -o $@ |
| 124,63 → 112,20 |
| $(HepMClib) \ |
| $(LINK_LIBS) -o $@ |
| example_MyHerwig.exe: example_MyHerwig.o |
| @echo "Building $@ ..." |
| $(CXX) $(FLAGS) example_MyHerwig.o \ |
| $(HepMClib) $(HepMCfiolib) \ |
| $(Herwig_LIB) $(LINK_LIBS) -o $@ |
| example_MyPythia.exe: $(initpydata_OBJ) $(pythia_OBJ) example_MyPythia.o |
| @echo "Building $@ ..." |
| $(CXX) $(FLAGS) $(pythia_OBJ) example_MyPythia.o \ |
| $(HepMClib) $(HepMCfiolib) \ |
| $(Pythia_LIB) $(LINK_LIBS) -o $@ |
| example_MyPythiaOnlyToHepMC.exe: $(initpydata_OBJ) $(pythia_OBJ) example_MyPythiaOnlyToHepMC.o |
| @echo "Building $@ ..." |
| $(CXX) $(FLAGS) $(pythia_OBJ) example_MyPythiaOnlyToHepMC.o \ |
| $(HepMClib) $(HepMCfiolib) \ |
| $(Pythia_LIB) $(LINK_LIBS) -o $@ |
| example_PythiaStreamIO.exe: $(initpydata_OBJ) $(pythia_OBJ) example_PythiaStreamIO.o |
| @echo "Building $@ ..." |
| $(CXX) $(FLAGS) $(pythia_OBJ) example_PythiaStreamIO.o \ |
| $(HepMClib) $(HepMCfiolib) \ |
| $(Pythia_LIB) $(LINK_LIBS) -o $@ |
| example_UsingIterators.exe: example_UsingIterators.o |
| @echo "Building $@ ..." |
| $(CXX) $(FLAGS) example_UsingIterators.o \ |
| $(HepMClib) \ |
| $(LINK_LIBS) -o $@ |
| testPythiaCopies.exe: $(initpydata_OBJ) $(pythia_OBJ) testPythiaCopies.o |
| @echo "Building $@ ..." |
| $(CXX) $(FLAGS) $(pythia_OBJ) testPythiaCopies.o \ |
| $(HepMClib) $(HepMCfiolib) \ |
| $(Pythia_LIB) $(LINK_LIBS) -o $@ |
| testHerwigCopies.exe: testHerwigCopies.o |
| @echo "Building $@ ..." |
| $(CXX) $(FLAGS) testHerwigCopies.o \ |
| $(HepMClib) $(HepMCfiolib) \ |
| $(Herwig_LIB) $(LINK_LIBS) -o $@ |
| ############################################################################### |
| # instructions for building a .o file from a .cxx file |
| # instructions for building a .o file from a .cc file |
| # |
| .cc.o: $(HDRS) $< |
| @echo "Compiling $< with $(CXX) ..." |
| @$(CXX) $(CXXFLAGS) -c $< -o $@ |
| ############################################################################### |
| # instructions for building a .o file from a .f file |
| # |
| .f.o: $< |
| @echo "Compiling $< with $(F77) ..." |
| @$(F77) $(FLAGS) -c $< -o $@ |
| ############################################################################### |
| # gmake clean removes all garbage from HepMC directories. |
| # |
| clean: |
| /trunk/examples/example_VectorConversion.cc |
|---|
| New file |
| 0,0 → 1,126 |
| ////////////////////////////////////////////////////////////////////////// |
| // Matt.Dobbs@Cern.CH, Feb 2000 |
| // Example of building an event and a particle data table from scratch |
| // This is meant to be of use for persons implementing HepMC inside a MC |
| // event generator |
| ////////////////////////////////////////////////////////////////////////// |
| // To Compile: go to the HepMC directory and type: |
| // gmake examples/example_BuildEventFromScratch.exe |
| // |
| #include <iostream> |
| #include "VectorConversion.h" |
| #include "HepMC/GenEvent.h" |
| #include "CLHEP/Vector/LorentzVector.h" |
| // in this example we use the HepMC namespace, so that we do not have to |
| // precede all HepMC classes with HepMC:: |
| // This example also shows how to use the CLHEP Lorentz vector with HepMC2 |
| using namespace HepMC; |
| using namespace CLHEP; |
| int main() { |
| // |
| // In this example we will place the following event into HepMC "by hand" |
| // |
| // name status pdg_id parent Px Py Pz Energy Mass |
| // 1 !p+! 3 2212 0,0 0.000 0.000 7000.000 7000.000 0.938 |
| // 2 !p+! 3 2212 0,0 0.000 0.000-7000.000 7000.000 0.938 |
| //========================================================================= |
| // 3 !d! 3 1 1,1 0.750 -1.569 32.191 32.238 0.000 |
| // 4 !u~! 3 -2 2,2 -3.047 -19.000 -54.629 57.920 0.000 |
| // 5 !W-! 3 -24 1,2 1.517 -20.68 -20.605 85.925 80.799 |
| // 6 !gamma! 1 22 1,2 -3.813 0.113 -1.833 4.233 0.000 |
| // 7 !d! 1 1 5,5 -2.445 28.816 6.082 29.552 0.010 |
| // 8 !u~! 1 -2 5,5 3.962 -49.498 -26.687 56.373 0.006 |
| // now we build the graph, which will look like |
| // p7 # |
| // p1 / # |
| // \v1__p3 p5---v4 # |
| // \_v3_/ \ # |
| // / \ p8 # |
| // v2__p4 \ # |
| // / p6 # |
| // p2 # |
| // # |
| // First create the event container, with Signal Process 20, event number 1 |
| // |
| // Note that the HepLorentzVectors will be automatically converted to |
| // HepMC::FourVector within GenParticle and GenVertex |
| GenEvent* evt = new GenEvent( 20, 1 ); |
| // define the units |
| evt->use_units(HepMC::Units::GEV, HepMC::Units::MM); |
| // |
| // create vertex 1 and vertex 2, together with their inparticles |
| GenVertex* v1 = new GenVertex(); |
| evt->add_vertex( v1 ); |
| v1->add_particle_in( new GenParticle( HepLorentzVector(0,0,7000,7000), |
| 2212, 3 ) ); |
| GenVertex* v2 = new GenVertex(); |
| evt->add_vertex( v2 ); |
| v2->add_particle_in( new GenParticle( HepLorentzVector(0,0,-7000,7000), |
| 2212, 3 ) ); |
| // |
| // create the outgoing particles of v1 and v2 |
| GenParticle* p3 = |
| new GenParticle( HepLorentzVector(.750,-1.569,32.191,32.238), 1, 3 ); |
| v1->add_particle_out( p3 ); |
| GenParticle* p4 = |
| new GenParticle( HepLorentzVector(-3.047,-19.,-54.629,57.920), -2, 3 ); |
| v2->add_particle_out( p4 ); |
| // |
| // create v3 |
| GenVertex* v3 = new GenVertex(); |
| evt->add_vertex( v3 ); |
| v3->add_particle_in( p3 ); |
| v3->add_particle_in( p4 ); |
| v3->add_particle_out( |
| new GenParticle( HepLorentzVector(-3.813,0.113,-1.833,4.233 ), 22, 1 ) |
| ); |
| GenParticle* p5 = |
| new GenParticle( HepLorentzVector(1.517,-20.68,-20.605,85.925), -24,3); |
| v3->add_particle_out( p5 ); |
| // |
| // create v4 |
| GenVertex* v4 = new GenVertex(HepLorentzVector(0.12,-0.3,0.05,0.004)); |
| evt->add_vertex( v4 ); |
| v4->add_particle_in( p5 ); |
| v4->add_particle_out( |
| new GenParticle( HepLorentzVector(-2.445,28.816,6.082,29.552), 1,1 ) |
| ); |
| v4->add_particle_out( |
| new GenParticle( HepLorentzVector(3.962,-49.498,-26.687,56.373), -2,1 ) |
| ); |
| // |
| // tell the event which vertex is the signal process vertex |
| evt->set_signal_process_vertex( v3 ); |
| // the event is complete, we now print it out to the screen |
| evt->print(); |
| // example conversion back to Lorentz vector |
| // add all outgoing momenta |
| std::cout << std::endl; |
| std::cout << " Add output momenta " << std::endl; |
| HepLorentzVector sum; |
| for ( GenEvent::particle_const_iterator p = evt->particles_begin(); |
| p != evt->particles_end(); ++p ){ |
| if( (*p)->status() == 1 ) { |
| sum += convertTo( (*p)->momentum() ); |
| (*p)->print(); |
| } |
| } |
| std::cout << "Vector Sum: " << sum << std::endl; |
| // now clean-up by deleteing all objects from memory |
| // |
| // deleting the event deletes all contained vertices, and all particles |
| // contained in those vertices |
| delete evt; |
| return 0; |
| } |
| /trunk/examples/Makefile.am |
|---|
| 6,16 → 6,8 |
| EXTRA_DIST = \ |
| example_BuildEventFromScratch.cc \ |
| example_EventSelection.cc \ |
| example_MyHerwig.cc \ |
| example_MyPythia.cc \ |
| example_MyPythiaOnlyToHepMC.cc \ |
| example_UsingIterators.cc \ |
| example_PythiaStreamIO.cc \ |
| testHerwigCopies.cc \ |
| testPythiaCopies.cc \ |
| initPythia.cc \ |
| initpydata.f \ |
| PythiaHelper.h \ |
| example_VectorConversion.cc \ |
| VectorConversion.h \ |
| example_UsingIterators.txt |
| /trunk/examples/VCMakefile.in |
|---|
| 28,16 → 28,8 |
| EXTRA_DIST = \ |
| example_BuildEventFromScratch.cc \ |
| example_EventSelection.cc \ |
| example_MyHerwig.cc \ |
| example_MyPythia.cc \ |
| example_MyPythiaOnlyToHepMC.cc \ |
| example_UsingIterators.cc \ |
| example_PythiaStreamIO.cc \ |
| testHerwigCopies.cc \ |
| testPythiaCopies.cc \ |
| initPythia.cc \ |
| initpydata.f \ |
| PythiaHelper.h \ |
| example_VectorConversion.cc \ |
| VectorConversion.h \ |
| example_UsingIterators.txt |
| /trunk/examples/example_BuildEventFromScratch.cc |
|---|
| 10,9 → 10,7 |
| #include <iostream> |
| #include "VectorConversion.h" |
| #include "HepMC/GenEvent.h" |
| #include "CLHEP/Vector/LorentzVector.h" |
| // in this example we use the HepMC namespace, so that we do not have to |
| // precede all HepMC classes with HepMC:: |
| 20,7 → 18,6 |
| // This example also shows how to use the CLHEP Lorentz vector with HepMC2 |
| using namespace HepMC; |
| using namespace CLHEP; |
| int main() { |
| // |
| 50,8 → 47,6 |
| // First create the event container, with Signal Process 20, event number 1 |
| // |
| // Note that the HepLorentzVectors will be automatically converted to |
| // HepMC::FourVector within GenParticle and GenVertex |
| GenEvent* evt = new GenEvent( 20, 1 ); |
| // define the units |
| evt->use_units(HepMC::Units::GEV, HepMC::Units::MM); |
| 59,19 → 54,19 |
| // create vertex 1 and vertex 2, together with their inparticles |
| GenVertex* v1 = new GenVertex(); |
| evt->add_vertex( v1 ); |
| v1->add_particle_in( new GenParticle( HepLorentzVector(0,0,7000,7000), |
| v1->add_particle_in( new GenParticle( FourVector(0,0,7000,7000), |
| 2212, 3 ) ); |
| GenVertex* v2 = new GenVertex(); |
| evt->add_vertex( v2 ); |
| v2->add_particle_in( new GenParticle( HepLorentzVector(0,0,-7000,7000), |
| v2->add_particle_in( new GenParticle( FourVector(0,0,-7000,7000), |
| 2212, 3 ) ); |
| // |
| // create the outgoing particles of v1 and v2 |
| GenParticle* p3 = |
| new GenParticle( HepLorentzVector(.750,-1.569,32.191,32.238), 1, 3 ); |
| new GenParticle( FourVector(.750,-1.569,32.191,32.238), 1, 3 ); |
| v1->add_particle_out( p3 ); |
| GenParticle* p4 = |
| new GenParticle( HepLorentzVector(-3.047,-19.,-54.629,57.920), -2, 3 ); |
| new GenParticle( FourVector(-3.047,-19.,-54.629,57.920), -2, 3 ); |
| v2->add_particle_out( p4 ); |
| // |
| // create v3 |
| 80,41 → 75,27 |
| v3->add_particle_in( p3 ); |
| v3->add_particle_in( p4 ); |
| v3->add_particle_out( |
| new GenParticle( HepLorentzVector(-3.813,0.113,-1.833,4.233 ), 22, 1 ) |
| new GenParticle( FourVector(-3.813,0.113,-1.833,4.233 ), 22, 1 ) |
| ); |
| GenParticle* p5 = |
| new GenParticle( HepLorentzVector(1.517,-20.68,-20.605,85.925), -24,3); |
| new GenParticle( FourVector(1.517,-20.68,-20.605,85.925), -24,3); |
| v3->add_particle_out( p5 ); |
| // |
| // create v4 |
| GenVertex* v4 = new GenVertex(HepLorentzVector(0.12,-0.3,0.05,0.004)); |
| GenVertex* v4 = new GenVertex(FourVector(0.12,-0.3,0.05,0.004)); |
| evt->add_vertex( v4 ); |
| v4->add_particle_in( p5 ); |
| v4->add_particle_out( |
| new GenParticle( HepLorentzVector(-2.445,28.816,6.082,29.552), 1,1 ) |
| new GenParticle( FourVector(-2.445,28.816,6.082,29.552), 1,1 ) |
| ); |
| v4->add_particle_out( |
| new GenParticle( HepLorentzVector(3.962,-49.498,-26.687,56.373), -2,1 ) |
| new GenParticle( FourVector(3.962,-49.498,-26.687,56.373), -2,1 ) |
| ); |
| // |
| // tell the event which vertex is the signal process vertex |
| evt->set_signal_process_vertex( v3 ); |
| // the event is complete, we now print it out to the screen |
| evt->print(); |
| // example conversion back to Lorentz vector |
| // add all outgoing momenta |
| std::cout << std::endl; |
| std::cout << " Add output momenta " << std::endl; |
| HepLorentzVector sum; |
| for ( GenEvent::particle_const_iterator p = evt->particles_begin(); |
| p != evt->particles_end(); ++p ){ |
| if( (*p)->status() == 1 ) { |
| sum += convertTo( (*p)->momentum() ); |
| (*p)->print(); |
| } |
| } |
| std::cout << "Vector Sum: " << sum << std::endl; |
| // now clean-up by deleteing all objects from memory |
| // |
| /trunk/examples/fio/example_PythiaStreamIO.cc |
|---|
| New file |
| 0,0 → 1,151 |
| ////////////////////////////////////////////////////////////////////////// |
| // example_PythiaStreamIO.cc |
| // |
| // garren@fnal.gov, May 2009 |
| // |
| ////////////////////////////////////////////////////////////////////////// |
| /// example of generating events with Pythia using HepMC/PythiaWrapper.h |
| /// Events are read into the HepMC event record from the FORTRAN HEPEVT |
| /// common block using the IO_HEPEVT strategy |
| /// |
| /// To Compile: go to the HepMC example directory and type: |
| /// make example_PythiaStreamIO.exe |
| /// |
| /// This example uses streaming I/O |
| /// writePythiaStreamIO() sets the cross section in GenRun |
| /// readPythiaStreamIO() reads the file written by writePythiaStreamIO() |
| /// |
| ////////////////////////////////////////////////////////////////////////// |
| #include <fstream> |
| #include <iostream> |
| #include "HepMC/PythiaWrapper.h" |
| #include "HepMC/IO_HEPEVT.h" |
| #include "HepMC/GenEvent.h" |
| #include "PythiaHelper.h" |
| void writePythiaStreamIO(); |
| void readPythiaStreamIO(); |
| int main() { |
| writePythiaStreamIO(); |
| readPythiaStreamIO(); |
| return 0; |
| } |
| void writePythiaStreamIO() { |
| // example to generate events and write output |
| std::cout << std::endl; |
| std::cout << "Begin pythia_out()" << std::endl; |
| //........................................HEPEVT |
| // Pythia 6.1 uses HEPEVT with 4000 entries and 8-byte floating point |
| // numbers. We need to explicitly pass this information to the |
| // HEPEVT_Wrapper. |
| // |
| HepMC::HEPEVT_Wrapper::set_max_number_entries(4000); |
| HepMC::HEPEVT_Wrapper::set_sizeof_real(8); |
| // |
| //........................................PYTHIA INITIALIZATIONS |
| initPythia(); |
| //........................................HepMC INITIALIZATIONS |
| // |
| // Instantiate an IO strategy for reading from HEPEVT. |
| HepMC::IO_HEPEVT hepevtio; |
| // |
| { // begin scope of ascii_io |
| // declare an output stream |
| const char outfile[] = "example_PythiaStreamIO_write.dat"; |
| std::ofstream ascii_io( outfile ); |
| if( !ascii_io ) { |
| std::cerr << "cannot open " << outfile << std::endl; |
| exit(-1); |
| } |
| // use the default IO_GenEvent precision |
| ascii_io.precision(16); |
| // write the line that defines the beginning of a GenEvent block |
| HepMC::write_HepMC_IO_block_begin( ascii_io ); |
| // |
| //........................................EVENT LOOP |
| for ( int i = 1; i <= 100; i++ ) { |
| if ( i%50==1 ) std::cout << "Processing Event Number " |
| << i << std::endl; |
| call_pyevnt(); // generate one event with Pythia |
| // pythia pyhepc routine converts common PYJETS in common HEPEVT |
| call_pyhepc( 1 ); |
| HepMC::GenEvent* evt = hepevtio.read_next_event(); |
| // define the units (Pythia uses GeV and mm) |
| evt->use_units(HepMC::Units::GEV, HepMC::Units::MM); |
| // add some information to the event |
| evt->set_event_number(i); |
| evt->set_signal_process_id(20); |
| // set number of multi parton interactions |
| evt->set_mpi( pypars.msti[31-1] ); |
| // set cross section information |
| evt->set_cross_section( HepMC::getPythiaCrossSection() ); |
| // write the event out to the ascii files |
| ascii_io << (*evt);; |
| // we also need to delete the created event from memory |
| delete evt; |
| } |
| // write the line that defines the end of a GenEvent block |
| HepMC::write_HepMC_IO_block_end( ascii_io ); |
| //........................................TERMINATION |
| // write out some information from Pythia to the screen |
| call_pystat( 1 ); |
| } // end scope of ascii_io |
| } |
| void readPythiaStreamIO() { |
| // example to read events written by writePythiaStreamIO |
| // and write them back out |
| std::cout << std::endl; |
| // input units are GeV and mm |
| const char infile[] = "example_PythiaStreamIO_write.dat"; |
| std::ifstream is( infile ); |
| if( !is ) { |
| std::cerr << "cannot open " << infile << std::endl; |
| exit(-1); |
| } |
| // |
| { // begin scope of ascii_io |
| // declare an output stream |
| const char outfile[] = "example_PythiaStreamIO_read.dat"; |
| std::ofstream ascii_io( outfile ); |
| if( !ascii_io ) { |
| std::cerr << "cannot open " << outfile << std::endl; |
| exit(-1); |
| } |
| ascii_io.precision(16); |
| HepMC::write_HepMC_IO_block_begin( ascii_io ); |
| // |
| //........................................EVENT LOOP |
| HepMC::GenEvent evt; |
| int i = 0; |
| while ( is ) { |
| evt.read( is ); |
| // make sure we have a valid event |
| if( evt.is_valid() ) { |
| ++i; |
| if ( i%50==1 ) std::cout << "Processing Event Number " |
| << i << std::endl; |
| if ( i%25==2 ) { |
| // write the cross section if it exists |
| if( evt.cross_section() ) { |
| std::cout << "cross section at event " << i << " is " |
| << evt.cross_section()->cross_section() |
| << std::endl; |
| } |
| } |
| // write the event out to the ascii files |
| evt.write( ascii_io ); |
| } |
| } |
| //........................................TERMINATION |
| HepMC::write_HepMC_IO_block_end( ascii_io ); |
| } // end scope of ascii_io |
| } |
| /trunk/examples/fio/example_MyPythia.cc |
|---|
| New file |
| 0,0 → 1,360 |
| ////////////////////////////////////////////////////////////////////////// |
| // Matt.Dobbs@Cern.CH, December 1999 |
| // November 2000, updated to use Pythia 6.1 |
| // |
| ////////////////////////////////////////////////////////////////////////// |
| /// example of generating events with Pythia using HepMC/PythiaWrapper.h |
| /// Events are read into the HepMC event record from the FORTRAN HEPEVT |
| /// common block using the IO_HEPEVT strategy |
| /// |
| /// To Compile: go to the HepMC directory and type: |
| /// gmake examples/example_MyPythia.exe |
| /// |
| /// In this example the precision and number of entries for the HEPEVT |
| /// fortran common block are explicitly defined to correspond to those |
| /// used in the Pythia version of the HEPEVT common block. |
| /// |
| /// If you get funny output from HEPEVT in your own code, probably you have |
| /// set these values incorrectly! |
| /// |
| ////////////////////////////////////////////////////////////////////////// |
| /// |
| /// pythia_out(): |
| /// Events are read into the HepMC event record from the FORTRAN HEPEVT |
| /// common block using the IO_HEPEVT strategy and then output to file in |
| /// ascii format using the IO_GenEvent strategy. |
| /// |
| /// pythia_particle_out(): |
| /// Events are read into the HepMC event record from the FORTRAN HEPEVT |
| /// common block using the IO_HEPEVT strategy and then output to file in |
| /// ascii format using the IO_AsciiParticles strategy. |
| /// This is identical to pythia_out() except for the choice of output format. |
| /// |
| /// event_selection(): |
| /// Events are read into the HepMC event record from the FORTRAN HEPEVT |
| /// common block using the IO_HEPEVT strategy and then a very simple event |
| /// selection is performed. |
| /// |
| /// pythia_in(): |
| /// Read the file created by pythia_out(). |
| /// |
| /// pythia_in_out(): |
| /// generate events with Pythia, write a file, and read the resulting output |
| /// Notice that we use scope to explicitly close the ouput files. |
| /// The two output files should be identical. |
| /// |
| #include <iostream> |
| #include "HepMC/PythiaWrapper.h" |
| #include "HepMC/IO_HEPEVT.h" |
| #include "HepMC/IO_GenEvent.h" |
| #include "HepMC/IO_AsciiParticles.h" |
| #include "HepMC/GenEvent.h" |
| #include "PythiaHelper.h" |
| //! example class |
| /// \class IsGoodEventMyPythia |
| /// event selection predicate. returns true if the event contains |
| /// a photon with pT > 25 GeV |
| class IsGoodEventMyPythia { |
| public: |
| /// returns true if event is "good" |
| bool operator()( const HepMC::GenEvent* evt ) { |
| for ( HepMC::GenEvent::particle_const_iterator p |
| = evt->particles_begin(); p != evt->particles_end(); ++p ){ |
| if ( (*p)->pdg_id() == 22 && (*p)->momentum().perp() > 25. ) { |
| //std::cout << "Event " << evt->event_number() |
| // << " is a good event." << std::endl; |
| //(*p)->print(); |
| return 1; |
| } |
| } |
| return 0; |
| } |
| }; |
| void pythia_out(); |
| void pythia_in(); |
| void pythia_in_out(); |
| void event_selection(); |
| void pythia_particle_out(); |
| int main() { |
| // example to generate events and write output |
| pythia_out(); |
| // example to generate events and perform simple event selection |
| event_selection(); |
| // example to read the file written by pythia_out |
| pythia_in(); |
| // example to generate events, write them, and read them back |
| pythia_in_out(); |
| return 0; |
| } |
| void pythia_out() |
| { |
| std::cout << std::endl; |
| std::cout << "Begin pythia_out()" << std::endl; |
| //........................................HEPEVT |
| // Pythia 6.1 uses HEPEVT with 4000 entries and 8-byte floating point |
| // numbers. We need to explicitly pass this information to the |
| // HEPEVT_Wrapper. |
| // |
| HepMC::HEPEVT_Wrapper::set_max_number_entries(4000); |
| HepMC::HEPEVT_Wrapper::set_sizeof_real(8); |
| // |
| //........................................PYTHIA INITIALIZATIONS |
| initPythia(); |
| //........................................HepMC INITIALIZATIONS |
| // |
| // Instantiate an IO strategy for reading from HEPEVT. |
| HepMC::IO_HEPEVT hepevtio; |
| // |
| { // begin scope of ascii_io |
| // Instantiate an IO strategy to write the data to file |
| HepMC::IO_GenEvent ascii_io("example_MyPythia.dat",std::ios::out); |
| // |
| //........................................EVENT LOOP |
| for ( int i = 1; i <= 100; i++ ) { |
| if ( i%50==1 ) std::cout << "Processing Event Number " |
| << i << std::endl; |
| call_pyevnt(); // generate one event with Pythia |
| // pythia pyhepc routine converts common PYJETS in common HEPEVT |
| call_pyhepc( 1 ); |
| HepMC::GenEvent* evt = hepevtio.read_next_event(); |
| // define the units (Pythia uses GeV and mm) |
| evt->use_units(HepMC::Units::GEV, HepMC::Units::MM); |
| // add some information to the event |
| evt->set_event_number(i); |
| evt->set_signal_process_id(20); |
| // set number of multi parton interactions |
| evt->set_mpi( pypars.msti[31-1] ); |
| // set cross section information |
| evt->set_cross_section( HepMC::getPythiaCrossSection() ); |
| // write the event out to the ascii files |
| ascii_io << evt; |
| // we also need to delete the created event from memory |
| delete evt; |
| } |
| //........................................TERMINATION |
| // write out some information from Pythia to the screen |
| call_pystat( 1 ); |
| } // end scope of ascii_io |
| } |
| void event_selection() |
| { |
| std::cout << std::endl; |
| std::cout << "Begin event_selection()" << std::endl; |
| //........................................HEPEVT |
| // Pythia 6.1 uses HEPEVT with 4000 entries and 8-byte floating point |
| // numbers. We need to explicitly pass this information to the |
| // HEPEVT_Wrapper. |
| // |
| HepMC::HEPEVT_Wrapper::set_max_number_entries(4000); |
| HepMC::HEPEVT_Wrapper::set_sizeof_real(8); |
| // |
| //........................................PYTHIA INITIALIZATIONS |
| initPythia(); |
| // |
| //........................................HepMC INITIALIZATIONS |
| // Instantiate an IO strategy for reading from HEPEVT. |
| HepMC::IO_HEPEVT hepevtio; |
| // declare an instance of the event selection predicate |
| IsGoodEventMyPythia is_good_event; |
| //........................................EVENT LOOP |
| int icount=0; |
| int num_good_events=0; |
| for ( int i = 1; i <= 100; i++ ) { |
| icount++; |
| if ( i%50==1 ) std::cout << "Processing Event Number " |
| << i << std::endl; |
| call_pyevnt(); // generate one event with Pythia |
| // pythia pyhepc routine convert common PYJETS in common HEPEVT |
| call_pyhepc( 1 ); |
| HepMC::GenEvent* evt = hepevtio.read_next_event(); |
| // define the units (Pythia uses GeV and mm) |
| evt->use_units(HepMC::Units::GEV, HepMC::Units::MM); |
| // set number of multi parton interactions |
| evt->set_mpi( pypars.msti[31-1] ); |
| // set cross section information |
| evt->set_cross_section( HepMC::getPythiaCrossSection() ); |
| // do event selection |
| if ( is_good_event(evt) ) { |
| std::cout << "Good Event Number " << i << std::endl; |
| ++num_good_events; |
| } |
| // we also need to delete the created event from memory |
| delete evt; |
| } |
| //........................................TERMINATION |
| // write out some information from Pythia to the screen |
| call_pystat( 1 ); |
| //........................................PRINT RESULTS |
| std::cout << num_good_events << " out of " << icount |
| << " processed events passed the cuts. Finished." << std::endl; |
| } |
| void pythia_in() |
| { |
| std::cout << std::endl; |
| std::cout << "Begin pythia_in()" << std::endl; |
| std::cout << "reading example_MyPythia.dat" << std::endl; |
| //........................................define an input scope |
| { |
| // open input stream |
| std::ifstream istr( "example_MyPythia.dat" ); |
| if( !istr ) { |
| std::cerr << "example_ReadMyPythia: cannot open example_MyPythia.dat" << std::endl; |
| exit(-1); |
| } |
| HepMC::IO_GenEvent ascii_in(istr); |
| // open output stream (alternate method) |
| HepMC::IO_GenEvent ascii_out("example_MyPythia2.dat",std::ios::out); |
| // now read the file |
| int icount=0; |
| HepMC::GenEvent* evt = ascii_in.read_next_event(); |
| while ( evt ) { |
| icount++; |
| if ( icount%50==1 ) std::cout << "Processing Event Number " << icount |
| << " its # " << evt->event_number() |
| << std::endl; |
| // write the event out to the ascii file |
| ascii_out << evt; |
| delete evt; |
| ascii_in >> evt; |
| } |
| //........................................PRINT RESULT |
| std::cout << icount << " events found. Finished." << std::endl; |
| } // ascii_out and istr destructors are called here |
| } |
| void pythia_in_out() |
| { |
| std::cout << std::endl; |
| std::cout << "Begin pythia_in_out()" << std::endl; |
| //........................................HEPEVT |
| // Pythia 6.3 uses HEPEVT with 4000 entries and 8-byte floating point |
| // numbers. We need to explicitly pass this information to the |
| // HEPEVT_Wrapper. |
| // |
| HepMC::HEPEVT_Wrapper::set_max_number_entries(4000); |
| HepMC::HEPEVT_Wrapper::set_sizeof_real(8); |
| // |
| //........................................PYTHIA INITIALIZATIONS |
| initPythia(); |
| //........................................HepMC INITIALIZATIONS |
| // |
| // Instantiate an IO strategy for reading from HEPEVT. |
| HepMC::IO_HEPEVT hepevtio; |
| // |
| //........................................define the output scope |
| { |
| // Instantial an IO strategy to write the data to file |
| HepMC::IO_GenEvent ascii_io("example_MyPythiaRead.dat",std::ios::out); |
| // |
| //........................................EVENT LOOP |
| for ( int i = 1; i <= 100; i++ ) { |
| if ( i%50==1 ) std::cout << "Processing Event Number " |
| << i << std::endl; |
| call_pyevnt(); // generate one event with Pythia |
| // pythia pyhepc routine converts common PYJETS in common HEPEVT |
| call_pyhepc( 1 ); |
| HepMC::GenEvent* evt = hepevtio.read_next_event(); |
| // define the units (Pythia uses GeV and mm) |
| evt->use_units(HepMC::Units::GEV, HepMC::Units::MM); |
| // set cross section information |
| evt->set_cross_section( HepMC::getPythiaCrossSection() ); |
| // add some information to the event |
| evt->set_event_number(i); |
| evt->set_signal_process_id(20); |
| // write the event out to the ascii file |
| ascii_io << evt; |
| // we also need to delete the created event from memory |
| delete evt; |
| } |
| //........................................TERMINATION |
| // write out some information from Pythia to the screen |
| call_pystat( 1 ); |
| } // ascii_io destructor is called here |
| // |
| //........................................define an input scope |
| { |
| // now read the file we wrote |
| HepMC::IO_GenEvent ascii_in("example_MyPythiaRead.dat",std::ios::in); |
| HepMC::IO_GenEvent ascii_io2("example_MyPythiaRead2.dat",std::ios::out); |
| int icount=0; |
| HepMC::GenEvent* evt = ascii_in.read_next_event(); |
| while ( evt ) { |
| icount++; |
| if ( icount%50==1 ) std::cout << "Processing Event Number " << icount |
| << " its # " << evt->event_number() |
| << std::endl; |
| // write the event out to the ascii file |
| ascii_io2 << evt; |
| delete evt; |
| ascii_in >> evt; |
| } |
| //........................................PRINT RESULT |
| std::cout << icount << " events found. Finished." << std::endl; |
| } // ascii_io2 and ascii_in destructors are called here |
| } |
| void pythia_particle_out() |
| { |
| std::cout << std::endl; |
| std::cout << "Begin pythia_particle_out()" << std::endl; |
| //........................................HEPEVT |
| // Pythia 6.1 uses HEPEVT with 4000 entries and 8-byte floating point |
| // numbers. We need to explicitly pass this information to the |
| // HEPEVT_Wrapper. |
| // |
| HepMC::HEPEVT_Wrapper::set_max_number_entries(4000); |
| HepMC::HEPEVT_Wrapper::set_sizeof_real(8); |
| // |
| //........................................PYTHIA INITIALIZATIONS |
| initPythia(); |
| //........................................HepMC INITIALIZATIONS |
| // |
| // Instantiate an IO strategy for reading from HEPEVT. |
| HepMC::IO_HEPEVT hepevtio; |
| // |
| { // begin scope of ascii_io |
| // Instantiate an IO strategy to write the data to file |
| HepMC::IO_AsciiParticles ascii_io("example_PythiaParticle.dat",std::ios::out); |
| // |
| //........................................EVENT LOOP |
| for ( int i = 1; i <= 100; i++ ) { |
| if ( i%50==1 ) std::cout << "Processing Event Number " |
| << i << std::endl; |
| call_pyevnt(); // generate one event with Pythia |
| // pythia pyhepc routine converts common PYJETS in common HEPEVT |
| call_pyhepc( 1 ); |
| HepMC::GenEvent* evt = hepevtio.read_next_event(); |
| // define the units (Pythia uses GeV and mm) |
| evt->use_units(HepMC::Units::GEV, HepMC::Units::MM); |
| // set cross section information |
| evt->set_cross_section( HepMC::getPythiaCrossSection() ); |
| // add some information to the event |
| evt->set_event_number(i); |
| evt->set_signal_process_id(20); |
| // write the event out to the ascii file |
| ascii_io << evt; |
| // we also need to delete the created event from memory |
| delete evt; |
| } |
| //........................................TERMINATION |
| // write out some information from Pythia to the screen |
| call_pystat( 1 ); |
| } // end scope of ascii_io |
| } |
| /trunk/examples/fio/PythiaHelper.h |
|---|
| New file |
| 0,0 → 1,13 |
| #ifndef PYTHIA_HELPER_H |
| #define PYTHIA_HELPER_H |
| ////////////////////////////////////////////////////////////////////////// |
| // garren@fnal.gov, April 2007 |
| // |
| // definitions needed by the pythia examples |
| // |
| ////////////////////////////////////////////////////////////////////////// |
| #include "HepMC/PythiaWrapper.h" |
| void initPythia(); |
| #endif // PYTHIA_HELPER_H |
| /trunk/examples/fio/example_MyPythiaOnlyToHepMC.cc |
|---|
| New file |
| 0,0 → 1,69 |
| ////////////////////////////////////////////////////////////////////////// |
| // Matt.Dobbs@Cern.CH, December 1999 |
| // November 2000, updated to use Pythia 6.1 |
| // example of generating events with Pythia |
| // using HepMC/PythiaWrapper.h |
| // Events are read into the HepMC event record from the FORTRAN HEPEVT |
| // common block using the IO_HEPEVT strategy -- nothing is done with them. |
| // This program is just used to find the total time required to transfer |
| // from HEPEVT into the HepMC event record. |
| ////////////////////////////////////////////////////////////////////////// |
| // To Compile: go to the HepMC directory and type: |
| // gmake examples/example_MyPythiaOnlyTo HepMC.exe |
| // |
| // See comments in examples/example_MyPythia.cxx regarding the HEPEVT wrapper. |
| // |
| #include <iostream> |
| #include "HepMC/PythiaWrapper.h" |
| #include "HepMC/IO_HEPEVT.h" |
| #include "HepMC/GenEvent.h" |
| #include "PythiaHelper.h" |
| int main() { |
| // |
| //........................................HEPEVT |
| // Pythia 6.1 uses HEPEVT with 4000 entries and 8-byte floating point |
| // numbers. We need to explicitly pass this information to the |
| // HEPEVT_Wrapper. |
| // |
| HepMC::HEPEVT_Wrapper::set_max_number_entries(4000); |
| HepMC::HEPEVT_Wrapper::set_sizeof_real(8); |
| // |
| //........................................PYTHIA INITIALIZATIONS |
| initPythia(); |
| // |
| //........................................HepMC INITIALIZATIONS |
| // |
| // Instantiate an IO strategy for reading from HEPEVT. |
| HepMC::IO_HEPEVT hepevtio; |
| // |
| //........................................EVENT LOOP |
| for ( int i = 1; i <= 100; i++ ) { |
| if ( i%50==1 ) std::cout << "Processing Event Number " |
| << i << std::endl; |
| call_pyevnt(); // generate one event with Pythia |
| // pythia pyhepc routine convert common PYJETS in common HEPEVT |
| call_pyhepc( 1 ); |
| HepMC::GenEvent* evt = hepevtio.read_next_event(); |
| // define the units (Pythia uses GeV and mm) |
| evt->use_units(HepMC::Units::GEV, HepMC::Units::MM); |
| // set number of multi parton interactions |
| evt->set_mpi( pypars.msti[31-1] ); |
| // set cross section information |
| evt->set_cross_section( HepMC::getPythiaCrossSection() ); |
| // |
| //.......................USER WOULD PROCESS EVENT HERE |
| // |
| // we also need to delete the created event from memory |
| delete evt; |
| } |
| //........................................TERMINATION |
| // write out some information from Pythia to the screen |
| call_pystat( 1 ); |
| return 0; |
| } |
| /trunk/examples/fio/testPythiaCopies.cc |
|---|
| New file |
| 0,0 → 1,82 |
| ////////////////////////////////////////////////////////////////////////// |
| // testPythiaCopies.cc |
| // |
| // garren@fnal.gov, January 2008 |
| // Multiple events in memory at the same time |
| ////////////////////////////////////////////////////////////////////////// |
| #include <fstream> |
| #include <iostream> |
| #include "HepMC/PythiaWrapper.h" |
| #include "HepMC/IO_HEPEVT.h" |
| #include "HepMC/GenEvent.h" |
| #include "HepMC/CompareGenEvent.h" |
| #include "PythiaHelper.h" |
| int main() { |
| // |
| //........................................HEPEVT |
| // Pythia 6.1 uses HEPEVT with 4000 entries and 8-byte floating point |
| // numbers. We need to explicitly pass this information to the |
| // HEPEVT_Wrapper. |
| // |
| HepMC::HEPEVT_Wrapper::set_max_number_entries(4000); |
| HepMC::HEPEVT_Wrapper::set_sizeof_real(8); |
| // |
| //........................................PYTHIA INITIALIZATIONS |
| initPythia(); |
| // |
| //........................................HepMC INITIALIZATIONS |
| // |
| // Instantiate an IO strategy for reading from HEPEVT. |
| HepMC::IO_HEPEVT hepevtio; |
| // |
| // open some output files |
| std::ofstream out1( "testPythiaOriginals.dat" ); |
| std::ofstream out2( "testPythiaCopies1.dat" ); |
| std::ofstream out3( "testPythiaCopies2.dat" ); |
| // |
| //........................................EVENT LOOP |
| for ( int i = 1; i <= 50; i++ ) { |
| if ( i%50==1 ) std::cout << "Processing Event Number " |
| << i << std::endl; |
| call_pyevnt(); // generate one event with Pythia |
| // pythia pyhepc routine convert common PYJETS in common HEPEVT |
| call_pyhepc( 1 ); |
| HepMC::GenEvent* evt = hepevtio.read_next_event(); |
| // pythia uses GeV and mm |
| evt->use_units( HepMC::Units::GEV, HepMC::Units::MM); |
| // set a couple of arbitrary weights |
| evt->weights().push_back(0.456); |
| evt->weights()["test2"] = 0.8956; |
| // set number of multi parton interactions |
| evt->set_mpi( pypars.msti[31-1] ); |
| // set cross section information |
| evt->set_cross_section( HepMC::getPythiaCrossSection() ); |
| // |
| //.......................make some copies |
| evt->print(out1); |
| HepMC::GenEvent ec = (*evt); |
| ec.print(out2); |
| HepMC::GenEvent* evt4 = new HepMC::GenEvent(*evt); |
| evt4->print(out3); |
| if( !compareGenEvent(evt,evt4) ) { |
| std::cerr << "testPythiaCopies: GenEvent comparison fails at event " |
| << evt->event_number() << std::endl; |
| return -1; |
| } |
| // |
| // now delete the created events from memory |
| delete evt; |
| delete evt4; |
| } |
| //........................................TERMINATION |
| // write out some information from Pythia to the screen |
| call_pystat( 1 ); |
| std::cout << "testPythiaCopies: event comparison is successful" << std::endl; |
| return 0; |
| } |
| /trunk/examples/fio/GNUmakefile.example.in |
|---|
| New file |
| 0,0 → 1,158 |
| ################################################################################ |
| # Makefile for building a HepMC executable with the gcc compiler |
| # |
| # Matt.Dobbs@CERN.CH 1.2000 |
| # |
| # This makefiles also works to compile the example programs. |
| # I.E.: syntax for compiling the example_MyPythia.cc example: |
| # gmake example_MyPythia.exe |
| # or simply gmake all to compile all examples. |
| # |
| ################################################################################ Define directory paths |
| # You may have to change GENSERdir and/or other variables |
| # |
| HepMCdir = @prefix@ |
| HepMClib = -L$(HepMCdir)/lib -lHepMC |
| HepMCfiolib = -L$(HepMCdir)/lib -lHepMCfio |
| GENSERdir = @GENSERdir@ |
| Pythia_LIB = -L$(GENSERdir)/lib -Wl,-rpath -Wl,$(GENSERdir)/lib \ |
| -lpythia6_403 -lpythia6_403_dumm -lpythia6_403_pdfdumm |
| Herwig_LIB = -L$(GENSERdir)/lib -Wl,-rpath -Wl,$(GENSERdir)/lib \ |
| -lherwig6_510 -lherwig6_510_dumm -lherwig6_510_pdfdumm |
| ################################################################################ Compiler options |
| # |
| CXX = @CXX@ |
| F77 = @F77@ |
| INCLUDES = -I$(HepMCdir)/include -I$(CLHEPdir)/include |
| CXXFLAGS = @AM_CXXFLAGS@ @CXXFLAGS@ $(INCLUDES) |
| ifeq "$(CXX)" "g++" |
| FLAGS = $(DFLG) -fno-second-underscore $(INCDIR) |
| else |
| FLAGS = $(DFLG) $(INCDIR) |
| endif |
| LINK_LIBS = @LDFLAGS@ |
| UNAME = $(shell uname) |
| ifneq "$(UNAME)" "Darwin" |
| LINK_LIBS += -Wl,-rpath -Wl,$(HepMCdir)/lib |
| endif |
| ifeq "$(UNAME)" "Linux" |
| ifeq "$(F77)" "gfortran" |
| LINK_LIBS += -lgfortran |
| else |
| LINK_LIBS += -lg2c |
| endif |
| endif |
| initpydata_OBJ= initpydata.o |
| pythia_OBJ = initPythia.o initpydata.o |
| HDRS = $(HepMCdir)/include/HepMC/*.h *.h |
| EXAMPLES = example_MyHerwig.exe \ |
| example_MyPythia.exe \ |
| example_MyPythiaOnlyToHepMC.exe \ |
| example_PythiaStreamIO.exe \ |
| testPythiaCopies.exe \ |
| testHerwigCopies.exe |
| ################################################################################ definition of the compiler options |
| # -I location of directory containing include files |
| # -L location of directory containing libraries |
| # -lname include the library from -L location called libname.a |
| # -lg2c is the library containing info on converting fortran to C |
| # -lf is the library containing the intrinsic for HPUX only. |
| # -shared make a shared library as output |
| # -fPIC produce position independent code |
| # necessary on some platforms (including HPUX) for -shared |
| # -fpic ^^ same(?) |
| # -O optimizes |
| # -g produces output for the debugger |
| # -pg produces output for gprof profiler |
| # note: if you want to see all warnings and ensure ansi standard |
| # compatibility, use: |
| # -pipe -ansi -pedantic -fnonnull-objects \ |
| # -W -Wall -Wwrite-strings -Wpointer-arith -Wnested-externs \ |
| # -Woverloaded-virtual -Wbad-function-cast -fnonnull-objects |
| # The proper order for cernlib libraries is: |
| # -lpawlib -lgraflib -lgrafX11 -lmathlib -lkernlib -lpacklib -ljetset74 |
| # |
| # makefile syntax: |
| # for target thedir/target.suf from source anotherdir/source.suf2 |
| # ${*D} = thedir |
| # ${*F} = target |
| # $* = thedir/target |
| # $@ = thedir/target.suf |
| # $< = anotherdir/source.suf2 |
| # |
| ############################################################################### |
| # |
| .SUFFIXES: .o .cxx .f .exe |
| all: $(EXAMPLES) |
| example_MyHerwig.exe: example_MyHerwig.o |
| @echo "Building $@ ..." |
| $(CXX) $(FLAGS) example_MyHerwig.o \ |
| $(HepMClib) $(HepMCfiolib) \ |
| $(Herwig_LIB) $(LINK_LIBS) -o $@ |
| example_MyPythia.exe: $(initpydata_OBJ) $(pythia_OBJ) example_MyPythia.o |
| @echo "Building $@ ..." |
| $(CXX) $(FLAGS) $(pythia_OBJ) example_MyPythia.o \ |
| $(HepMClib) $(HepMCfiolib) \ |
| $(Pythia_LIB) $(LINK_LIBS) -o $@ |
| example_MyPythiaOnlyToHepMC.exe: $(initpydata_OBJ) $(pythia_OBJ) example_MyPythiaOnlyToHepMC.o |
| @echo "Building $@ ..." |
| $(CXX) $(FLAGS) $(pythia_OBJ) example_MyPythiaOnlyToHepMC.o \ |
| $(HepMClib) $(HepMCfiolib) \ |
| $(Pythia_LIB) $(LINK_LIBS) -o $@ |
| example_PythiaStreamIO.exe: $(initpydata_OBJ) $(pythia_OBJ) example_PythiaStreamIO.o |
| @echo "Building $@ ..." |
| $(CXX) $(FLAGS) $(pythia_OBJ) example_PythiaStreamIO.o \ |
| $(HepMClib) $(HepMCfiolib) \ |
| $(Pythia_LIB) $(LINK_LIBS) -o $@ |
| testPythiaCopies.exe: $(initpydata_OBJ) $(pythia_OBJ) testPythiaCopies.o |
| @echo "Building $@ ..." |
| $(CXX) $(FLAGS) $(pythia_OBJ) testPythiaCopies.o \ |
| $(HepMClib) $(HepMCfiolib) \ |
| $(Pythia_LIB) $(LINK_LIBS) -o $@ |
| testHerwigCopies.exe: testHerwigCopies.o |
| @echo "Building $@ ..." |
| $(CXX) $(FLAGS) testHerwigCopies.o \ |
| $(HepMClib) $(HepMCfiolib) \ |
| $(Herwig_LIB) $(LINK_LIBS) -o $@ |
| ############################################################################### |
| # instructions for building a .o file from a .cxx file |
| # |
| .cc.o: $(HDRS) $< |
| @echo "Compiling $< with $(CXX) ..." |
| @$(CXX) $(CXXFLAGS) -c $< -o $@ |
| ############################################################################### |
| # instructions for building a .o file from a .f file |
| # |
| .f.o: $< |
| @echo "Compiling $< with $(F77) ..." |
| @$(F77) $(FLAGS) -c $< -o $@ |
| ############################################################################### |
| # gmake clean removes all garbage from HepMC directories. |
| # |
| clean: |
| rm -f *.o |
| ############################################################################### |
| # gmake distclean removes all compiled libraries, executables, +garbage |
| # to prepare the package for distribution |
| distclean: |
| $(MAKE) clean --no-print-directory |
| rm -f *.exe |
| rm -f *.dat |
| /trunk/examples/fio/initPythia.cc |
|---|
| New file |
| 0,0 → 1,33 |
| ////////////////////////////////////////////////////////////////////////// |
| // garren@fnal.gov, April 2007 |
| // |
| // Initialize pythia |
| // Using a separate cc file allows us to test issues with PythiaWrapper.h |
| // |
| ////////////////////////////////////////////////////////////////////////// |
| #include "HepMC/PythiaWrapper.h" |
| #include "PythiaHelper.h" |
| void initPythia() |
| { |
| // (Some platforms may require the initialization of pythia PYDATA block |
| // data as external - if you get pythia initialization errors try |
| // commenting in/out the below call to initpydata() ) |
| // initpydata(); |
| // |
| // Select W+gamma process (process number 20) |
| // (here we have to be careful of C/F77 differences: arrays in C |
| // start at 0, F77 at 1, so we need to subtract 1 from the process #) |
| pysubs.msel=0; |
| pysubs.msub[20-1] = 1; |
| // set random number seed (mandatory!) |
| pydatr.mrpy[0]=55122 ; |
| // Tell Pythia not to write multiple copies of particles in event record. |
| pypars.mstp[128-1] = 2; |
| // Example of setting a Pythia parameter: set the top mass |
| pydat2.pmas[1-1][6-1]= 175; |
| // |
| // Call pythia initialization |
| call_pyinit( "CMS", "p", "p", 14000. ); |
| } |
| /trunk/examples/fio/Makefile.am |
|---|
| New file |
| 0,0 → 1,21 |
| # This makefile is used to copy files during the "make install" step |
| INSTALLDIR = $(pkgdatadir)/examples/fio |
| # files to distribute |
| EXTRA_DIST = \ |
| example_MyHerwig.cc \ |
| example_MyPythia.cc \ |
| example_MyPythiaOnlyToHepMC.cc \ |
| example_PythiaStreamIO.cc \ |
| testHerwigCopies.cc \ |
| testPythiaCopies.cc \ |
| initPythia.cc \ |
| initpydata.f \ |
| PythiaHelper.h |
| install-data-local: |
| $(mkinstalldirs) $(DESTDIR)$(INSTALLDIR) |
| $(INSTALL_DATA) GNUmakefile.example $(DESTDIR)$(INSTALLDIR)/GNUmakefile |
| for file in $(EXTRA_DIST); do \ |
| $(INSTALL_DATA) $(srcdir)/$$file $(DESTDIR)$(INSTALLDIR)/$$file; done |
| /trunk/examples/fio/example_MyHerwig.cc |
|---|
| New file |
| 0,0 → 1,106 |
| ////////////////////////////////////////////////////////////////////////// |
| // Matt.Dobbs@Cern.CH, October 2002 |
| // example of generating events with Herwig using HepMC/HerwigWrapper.h |
| // Events are read into the HepMC event record from the FORTRAN HEPEVT |
| // common block using the IO_HERWIG strategy. |
| ////////////////////////////////////////////////////////////////////////// |
| /// To Compile: go to the HepMC directory and type: |
| /// gmake examples/example_MyHerwig.exe |
| /// |
| /// In this example the precision and number of entries for the HEPEVT |
| /// fortran common block are explicitly defined to correspond to those |
| /// used in the Herwig version of the HEPEVT common block. |
| /// If you get funny output from HEPEVT in your own code, probably you have |
| /// set these values incorrectly! |
| /// |
| #include <iostream> |
| #include "HepMC/HerwigWrapper.h" |
| #include "HepMC/IO_HERWIG.h" |
| #include "HepMC/IO_GenEvent.h" |
| #include "HepMC/GenEvent.h" |
| #include "HepMC/HEPEVT_Wrapper.h" |
| int main() { |
| // |
| //........................................HEPEVT |
| // Herwig 6.4 uses HEPEVT with 4000 entries and 8-byte floating point |
| // numbers. We need to explicitly pass this information to the |
| // HEPEVT_Wrapper. |
| // |
| HepMC::HEPEVT_Wrapper::set_max_number_entries(4000); |
| HepMC::HEPEVT_Wrapper::set_sizeof_real(8); |
| // |
| //.......................................INITIALIZATIONS |
| hwproc.PBEAM1 = 7000.; // energy of beam1 |
| hwproc.PBEAM2 = 7000.; // energy of beam2 |
| // 1610 = gg->H--> WW, 1706 = qq-->ttbar, 2510 = ttH -> ttWW |
| hwproc.IPROC = 1706; // qq -> ttbar production |
| hwproc.MAXEV = 100; // number of events |
| // tell it what the beam particles are: |
| for ( unsigned int i = 0; i < 8; ++i ) { |
| hwbmch.PART1[i] = (i < 1) ? 'P' : ' '; |
| hwbmch.PART2[i] = (i < 1) ? 'P' : ' '; |
| } |
| hwigin(); // INITIALISE OTHER COMMON BLOCKS |
| hwevnt.MAXPR = 1; // number of events to print |
| hwuinc(); // compute parameter-dependent constants |
| hweini(); // initialise elementary process |
| //........................................HepMC INITIALIZATIONS |
| // |
| // Instantiate an IO strategy for reading from HEPEVT. |
| HepMC::IO_HERWIG hepevtio; |
| // Instantiate an IO strategy to write the data to file |
| HepMC::IO_GenEvent ascii_io("example_MyHerwig.dat",std::ios::out); |
| // |
| //........................................EVENT LOOP |
| for ( int i = 1; i <= hwproc.MAXEV; i++ ) { |
| if ( i%50==1 ) std::cout << "Processing Event Number " |
| << i << std::endl; |
| // initialise event |
| hwuine(); |
| // generate hard subprocess |
| hwepro(); |
| // generate parton cascades |
| hwbgen(); |
| // do heavy object decays |
| hwdhob(); |
| // do cluster formation |
| hwcfor(); |
| // do cluster decays |
| hwcdec(); |
| // do unstable particle decays |
| hwdhad(); |
| // do heavy flavour hadron decays |
| hwdhvy(); |
| // add soft underlying event if needed |
| hwmevt(); |
| // finish event |
| hwufne(); |
| HepMC::GenEvent* evt = hepevtio.read_next_event(); |
| // define the units (Herwig uses GeV and mm) |
| evt->use_units(HepMC::Units::GEV, HepMC::Units::MM); |
| // set cross section information |
| evt->set_cross_section( HepMC::getHerwigCrossSection(i) ); |
| // add some information to the event |
| evt->set_event_number(i); |
| evt->set_signal_process_id(20); |
| if (i<=hwevnt.MAXPR) { |
| std::cout << "\n\n This is the FIXED version of HEPEVT as " |
| << "coded in IO_HERWIG " << std::endl; |
| HepMC::HEPEVT_Wrapper::print_hepevt(); |
| evt->print(); |
| } |
| // write the event to the ascii file |
| ascii_io << evt; |
| // we also need to delete the created event from memory |
| delete evt; |
| } |
| //........................................TERMINATION |
| hwefin(); |
| return 0; |
| } |
| /trunk/examples/fio/initpydata.f |
|---|
| New file |
| 0,0 → 1,11 |
| c |
| c Matt.Dobbs@Cern.CH, December 1999 |
| c EXTERNAL statement links PYDATA on most machines. |
| c (Often necessary for the initialization of Pythia) |
| c |
| subroutine initpydata |
| EXTERNAL PYDATA |
| return |
| end |
| /trunk/examples/fio/VCMakefile.in |
|---|
| New file |
| 0,0 → 1,85 |
| # custom makefile for Visual C++ |
| # This makefile is used to copy files during the "make install" step |
| @SET_MAKE@ |
| AM_MAKEFLAGS = @AM_MAKEFLAGS@ |
| srcdir = @srcdir@ |
| top_srcdir = @top_srcdir@ |
| pkgdatadir = $(datadir)/@PACKAGE@ |
| top_builddir = @top_builddir@ |
| prefix = @prefix@ |
| datadir = @datadir@ |
| datarootdir = @datarootdir@ |
| install_sh = @install_sh@ |
| VPATH = @srcdir@ |
| INSTALL = @INSTALL@ |
| INSTALL_DATA = @INSTALL_DATA@ |
| SET_MAKE = @SET_MAKE@ |
| mkinstalldirs = $(install_sh) -d |
| DIST_COMMON = $(srcdir)/GNUmakefile.example.in $(srcdir)/VCMakefile.in |
| DISTFILES = $(DIST_COMMON) $(EXTRA_DIST) |
| INSTALLDIR = $(pkgdatadir)/examples |
| # files to distribute |
| EXTRA_DIST = \ |
| example_MyHerwig.cc \ |
| example_MyPythia.cc \ |
| example_MyPythiaOnlyToHepMC.cc \ |
| example_PythiaStreamIO.cc \ |
| testHerwigCopies.cc \ |
| testPythiaCopies.cc \ |
| initPythia.cc \ |
| initpydata.f \ |
| PythiaHelper.h |
| all: all-am |
| all-am: VCMakefile GNUmakefile.example |
| clean: clean-am |
| clean-am: |
| check: check-am |
| check-am: all-am |
| install: install-am |
| install-exec: install-exec-am |
| install-data: install-data-local |
| uninstall: uninstall-am |
| install-exec-am: |
| install-am: |
| @$(MAKE) $(AM_MAKEFLAGS) install-data |
| install-data-local: |
| $(mkinstalldirs) $(DESTDIR)$(INSTALLDIR) |
| $(INSTALL_DATA) GNUmakefile.example $(DESTDIR)$(INSTALLDIR)/GNUmakefile |
| for file in $(EXTRA_DIST); do \ |
| $(INSTALL_DATA) $(srcdir)/$$file $(DESTDIR)$(INSTALLDIR)/$$file; done |
| .SUFFIXES: |
| .PRECIOUS: VCMakefile |
| VCMakefile: $(srcdir)/VCMakefile.in $(top_builddir)/config.status |
| @case '$?' in \ |
| *config.status*) \ |
| cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ |
| *) \ |
| echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ |
| cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ |
| esac; |
| GNUmakefile.example: $(top_builddir)/config.status $(srcdir)/GNUmakefile.example.in |
| cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ |
| .PHONY: all all-am install install-am install-data install-data-local \ |
| clean clean-am check check-am |
| # Tell versions [3.59,3.63) of GNU make to not export all variables. |
| # Otherwise a system limit (for SysV at least) may be exceeded. |
| .NOEXPORT: |
| /trunk/examples/fio/testHerwigCopies.cc |
|---|
| New file |
| 0,0 → 1,107 |
| ////////////////////////////////////////////////////////////////////////// |
| // testHerwigCopies.cc |
| // |
| // garren@fnal.gov, January 2008 |
| // Multiple events in memory at the same time |
| ////////////////////////////////////////////////////////////////////////// |
| #include <fstream> |
| #include <iostream> |
| #include "HepMC/HerwigWrapper.h" |
| #include "HepMC/IO_HERWIG.h" |
| #include "HepMC/GenEvent.h" |
| #include "HepMC/CompareGenEvent.h" |
| #include "HepMC/HEPEVT_Wrapper.h" |
| int main() { |
| // |
| //........................................HEPEVT |
| // Herwig 6.4 uses HEPEVT with 4000 entries and 8-byte floating point |
| // numbers. We need to explicitly pass this information to the |
| // HEPEVT_Wrapper. |
| // |
| HepMC::HEPEVT_Wrapper::set_max_number_entries(4000); |
| HepMC::HEPEVT_Wrapper::set_sizeof_real(8); |
| // |
| //.......................................INITIALIZATIONS |
| hwproc.PBEAM1 = 7000.; // energy of beam1 |
| hwproc.PBEAM2 = 7000.; // energy of beam2 |
| // 1610 = gg->H--> WW, 1706 = qq-->ttbar, 2510 = ttH -> ttWW |
| hwproc.IPROC = 1706; // qq -> ttbar production |
| hwproc.MAXEV = 50; // number of events |
| // tell it what the beam particles are: |
| for ( unsigned int i = 0; i < 8; ++i ) { |
| hwbmch.PART1[i] = (i < 1) ? 'P' : ' '; |
| hwbmch.PART2[i] = (i < 1) ? 'P' : ' '; |
| } |
| hwigin(); // INITIALISE OTHER COMMON BLOCKS |
| hwevnt.MAXPR = 0; // number of events to print |
| hwuinc(); // compute parameter-dependent constants |
| hweini(); // initialise elementary process |
| //........................................HepMC INITIALIZATIONS |
| // |
| // Instantiate an IO strategy for reading from HEPEVT. |
| HepMC::IO_HERWIG hepevtio; |
| // |
| // open some output files |
| std::ofstream out1( "testHerwigOriginals.dat" ); |
| std::ofstream out2( "testHerwigCopies1.dat" ); |
| std::ofstream out3( "testHerwigCopies2.dat" ); |
| // |
| //........................................EVENT LOOP |
| for ( int i = 1; i <= hwproc.MAXEV; i++ ) { |
| if ( i%50==1 ) std::cout << "Processing Event Number " |
| << i << std::endl; |
| // initialise event |
| hwuine(); |
| // generate hard subprocess |
| hwepro(); |
| // generate parton cascades |
| hwbgen(); |
| // do heavy object decays |
| hwdhob(); |
| // do cluster formation |
| hwcfor(); |
| // do cluster decays |
| hwcdec(); |
| // do unstable particle decays |
| hwdhad(); |
| // do heavy flavour hadron decays |
| hwdhvy(); |
| // add soft underlying event if needed |
| hwmevt(); |
| // finish event |
| hwufne(); |
| HepMC::GenEvent* evt = hepevtio.read_next_event(); |
| // herwig uses GeV and mm |
| evt->use_units( HepMC::Units::GEV, HepMC::Units::MM); |
| // set cross section information |
| evt->set_cross_section( HepMC::getHerwigCrossSection(i) ); |
| // add some information to the event |
| evt->set_event_number(i); |
| evt->set_signal_process_id(20); |
| // |
| //.......................make some copies |
| evt->print(out1); |
| HepMC::GenEvent ec = (*evt); |
| ec.print(out2); |
| HepMC::GenEvent* evt4 = new HepMC::GenEvent(*evt); |
| evt4->print(out3); |
| if( !compareGenEvent(evt,evt4) ) { |
| std::cerr << "testHerwigCopies: GenEvent comparison fails at event " |
| << evt->event_number() << std::endl; |
| return -1; |
| } |
| // we also need to delete the created event from memory |
| delete evt; |
| delete evt4; |
| } |
| //........................................TERMINATION |
| hwefin(); |
| std::cout << "testHerwigCopies: event comparison is successful" << std::endl; |
| return 0; |
| } |